Index: trunk/phase3/resources/jquery/jquery.colorUtil.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | // Check if we're already dealing with an array of colors |
21 | 21 | if ( color && color.constructor == Array && color.length == 3 ){ |
22 | 22 | return color; |
23 | | - } |
| 23 | + } |
24 | 24 | |
25 | 25 | // Look for rgb(num,num,num) |
26 | 26 | if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) { |
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.upload.js |
— | — | @@ -3,12 +3,12 @@ |
4 | 4 | * Note that additional code still lives in skins/common/upload.js |
5 | 5 | */ |
6 | 6 | |
7 | | -$(function() { |
| 7 | +$( function() { |
8 | 8 | /** |
9 | 9 | * Is the FileAPI available with sufficient functionality? |
10 | 10 | */ |
11 | | - function hasFileAPI() { |
12 | | - return (typeof window.FileReader != "undefined"); |
| 11 | + function hasFileAPI(){ |
| 12 | + return typeof window.FileReader !== 'undefined'; |
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
— | — | @@ -20,10 +20,10 @@ |
21 | 21 | * @param {File} file |
22 | 22 | * @return boolean |
23 | 23 | */ |
24 | | - function fileIsPreviewable(file) { |
| 24 | + function fileIsPreviewable( file ) { |
25 | 25 | var known = ['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml']; |
26 | 26 | var tooHuge = 10 * 1024 * 1024; |
27 | | - return ($.inArray(file.type, known) != -1) && (file.size > 0) && (file.size < tooHuge); |
| 27 | + return ($.inArray( file.type, known ) !== -1) && file.size > 0 && file.size < tooHuge; |
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
— | — | @@ -38,28 +38,28 @@ |
39 | 39 | * |
40 | 40 | * @param {File} file |
41 | 41 | */ |
42 | | - function showPreview(file) { |
| 42 | + function showPreview( file ) { |
43 | 43 | var previewSize = 180; |
44 | 44 | |
45 | | - var thumb = $("<div id='mw-upload-thumbnail' class='thumb tright'>" + |
46 | | - "<div class='thumbinner'>" + |
47 | | - "<canvas width=" + previewSize + " height=" + previewSize + " ></canvas>" + |
48 | | - "<div class='thumbcaption'><div class='filename'></div><div class='fileinfo'></div></div>" + |
49 | | - "</div>" + |
50 | | - "</div>"); |
51 | | - thumb.find('.filename').text(file.name).end() |
52 | | - .find('.fileinfo').text(prettySize(file.size)).end(); |
| 45 | + var thumb = $( '<div id="mw-upload-thumbnail" class="thumb tright">' + |
| 46 | + '<div class="thumbinner">' + |
| 47 | + '<canvas width="' + previewSize + '" height="' + previewSize + '" ></canvas>' + |
| 48 | + '<div class="thumbcaption"><div class="filename"></div><div class="fileinfo"></div></div>' + |
| 49 | + '</div>' + |
| 50 | + '</div>' ); |
| 51 | + thumb.find( '.filename' ).text( file.name ).end() |
| 52 | + .find( '.fileinfo' ).text( prettySize( file.size ) ).end(); |
53 | 53 | |
54 | | - var ctx = thumb.find('canvas')[0].getContext('2d'); |
| 54 | + var ctx = thumb.find( 'canvas' )[0].getContext( '2d' ); |
55 | 55 | var spinner = new Image(); |
56 | | - spinner.onload = function () { |
| 56 | + spinner.onload = function() { |
57 | 57 | ctx.drawImage( spinner, (previewSize - spinner.width) / 2, |
58 | 58 | (previewSize - spinner.height) / 2 ); |
59 | 59 | }; |
60 | 60 | spinner.src = wgScriptPath + '/skins/common/images/spinner.gif'; |
61 | | - $('#mw-htmlform-source').parent().prepend(thumb); |
| 61 | + $( '#mw-htmlform-source' ).parent().prepend( thumb ); |
62 | 62 | |
63 | | - fetchPreview(file, function(dataURL) { |
| 63 | + fetchPreview( file, function( dataURL ) { |
64 | 64 | var img = new Image(); |
65 | 65 | var rotation = 0; |
66 | 66 | img.onload = function() { |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | // Determine the offset required to center the image |
76 | 76 | dx = (180 - width) / 2; |
77 | 77 | dy = (180 - height) / 2; |
78 | | - switch (rotation) { |
| 78 | + switch ( rotation ) { |
79 | 79 | // If a rotation is applied, the direction of the axis |
80 | 80 | // changes as well. You can derive the values below by |
81 | 81 | // drawing on paper an axis system, rotate it and see |
— | — | @@ -102,10 +102,10 @@ |
103 | 103 | ctx.drawImage( img, x, y, width, height ); |
104 | 104 | |
105 | 105 | // Image size |
106 | | - var info = mediaWiki.msg('widthheight', img.width, img.height) + |
107 | | - ', ' + prettySize(file.size); |
108 | | - $('#mw-upload-thumbnail .fileinfo').text(info); |
109 | | - } |
| 106 | + var info = mw.msg( 'widthheight', img.width, img.height ) + |
| 107 | + ', ' + prettySize( file.size ); |
| 108 | + $( '#mw-upload-thumbnail .fileinfo' ).text( info ); |
| 109 | + }; |
110 | 110 | img.src = dataURL; |
111 | 111 | }); |
112 | 112 | } |
— | — | @@ -117,12 +117,12 @@ |
118 | 118 | * @param {File} file |
119 | 119 | * @param {function} callback |
120 | 120 | */ |
121 | | - function fetchPreview(file, callback) { |
| 121 | + function fetchPreview( file, callback ) { |
122 | 122 | var reader = new FileReader(); |
123 | 123 | reader.onload = function() { |
124 | | - callback(reader.result); |
| 124 | + callback( reader.result ); |
125 | 125 | }; |
126 | | - reader.readAsDataURL(file); |
| 126 | + reader.readAsDataURL( file ); |
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
— | — | @@ -132,32 +132,32 @@ |
133 | 133 | * @param {number} s |
134 | 134 | * @return string |
135 | 135 | */ |
136 | | - function prettySize(s) { |
| 136 | + function prettySize( s ) { |
137 | 137 | var sizes = ['size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes']; |
138 | | - while (s >= 1024 && sizes.length > 1) { |
| 138 | + while ( s >= 1024 && sizes.length > 1 ) { |
139 | 139 | s /= 1024; |
140 | | - sizes = sizes.slice(1); |
| 140 | + sizes = sizes.slice( 1 ); |
141 | 141 | } |
142 | | - return mediaWiki.msg(sizes[0], Math.round(s)) |
| 142 | + return mw.msg( sizes[0], Math.round( s ) ); |
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * Clear the file upload preview area. |
147 | 147 | */ |
148 | 148 | function clearPreview() { |
149 | | - $('#mw-upload-thumbnail').remove(); |
| 149 | + $( '#mw-upload-thumbnail' ).remove(); |
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | | - if (hasFileAPI()) { |
| 153 | + if ( hasFileAPI() ) { |
154 | 154 | // Update thumbnail when the file selection control is updated. |
155 | | - $('#wpUploadFile').change(function() { |
| 155 | + $( '#wpUploadFile' ).change( function() { |
156 | 156 | clearPreview(); |
157 | | - if (this.files && this.files.length) { |
| 157 | + if ( this.files && this.files.length ) { |
158 | 158 | // Note: would need to be updated to handle multiple files. |
159 | 159 | var file = this.files[0]; |
160 | | - if (fileIsPreviewable(file)) { |
161 | | - showPreview(file); |
| 160 | + if ( fileIsPreviewable( file ) ) { |
| 161 | + showPreview( file ); |
162 | 162 | } |
163 | 163 | } |
164 | 164 | }); |