Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.init.js |
— | — | @@ -1,15 +1,3 @@ |
2 | | -/* |
3 | | - * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog. |
4 | | - */ |
5 | | - |
6 | 2 | ( function( $ ) { |
7 | | -$.wikiLove.init = function() { |
8 | | - $.wikiLove.options = $.wikiLove.optionsHook(); |
9 | | - $( '#ca-wikilove a' ).click( function( e ) { |
10 | | - $.wikiLove.openDialog(); |
11 | | - e.preventDefault(); |
12 | | - }); |
13 | | -} |
14 | | - |
15 | 3 | $( document ).ready( $.wikiLove.init ); |
16 | 4 | } )( jQuery ); |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -1,38 +1,41 @@ |
2 | | -( function( $ ) { $.wikiLove = { |
| 2 | +( function( $ ) { |
| 3 | +$.wikiLove = (function(){ |
| 4 | + |
| 5 | +var options = {}, // options modifiable by the user |
| 6 | + $dialog = null, // dialog jQuery object |
| 7 | + currentTypeId = null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown') |
| 8 | + currentSubtypeId = null, // id of the currently selected subtype (e.g. 'original' or 'special') |
| 9 | + currentTypeOrSubtype = null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.) |
| 10 | + previewData = null, // data of the currently previewed thing is set here |
| 11 | + emailable = false, |
| 12 | + gallery = {}; |
3 | 13 | |
4 | | - options: {}, // options modifiable by the user |
| 14 | +return { |
5 | 15 | optionsHook: function() { return {}; }, // hook that can be overridden by the user to modify options |
6 | | - $dialog: null, // dialog jQuery object |
7 | | - currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown') |
8 | | - currentSubtypeId: null, // id of the currently selected subtype (e.g. 'original' or 'special') |
9 | | - currentTypeOrSubtype: null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.) |
10 | | - previewData: null, // data of the currently previewed thing is set here |
11 | | - emailable: false, |
12 | | - gallery: {}, |
13 | 16 | |
14 | 17 | /* |
15 | 18 | * Opens the dialog and builds it if necessary. |
16 | 19 | */ |
17 | 20 | openDialog: function() { |
18 | | - if ( $.wikiLove.$dialog === null ) { |
| 21 | + if ( $dialog === null ) { |
19 | 22 | // Test to see if the 'E-mail this user' link exists |
20 | | - $.wikiLove.emailable = $( '#t-emailuser' ).length ? true : false; |
| 23 | + emailable = $( '#t-emailuser' ).length ? true : false; |
21 | 24 | |
22 | 25 | // Build a type list like this: |
23 | 26 | var $typeList = $( '<ul id="mw-wikilove-types"></ul>' ); |
24 | | - for( var typeId in $.wikiLove.options.types ) { |
| 27 | + for( var typeId in options.types ) { |
25 | 28 | var $button = $( '<a href="#"></a>' ); |
26 | 29 | var $buttonInside = $( '<div class="mw-wikilove-inside"></div>' ); |
27 | 30 | |
28 | | - if( typeof $.wikiLove.options.types[typeId].icon == 'string' ) { |
| 31 | + if( typeof options.types[typeId].icon == 'string' ) { |
29 | 32 | $buttonInside.append( '<div class="mw-wikilove-icon-box"><img src="' |
30 | | - + mw.html.escape( $.wikiLove.options.types[typeId].icon ) + '"/></div>' ); |
| 33 | + + mw.html.escape( options.types[typeId].icon ) + '"/></div>' ); |
31 | 34 | } |
32 | 35 | else { |
33 | 36 | $buttonInside.addClass( 'mw-wikilove-no-icon' ); |
34 | 37 | } |
35 | 38 | |
36 | | - $buttonInside.append( '<div class="mw-wikilove-link-text">' + $.wikiLove.options.types[typeId].name + '</div>' ); |
| 39 | + $buttonInside.append( '<div class="mw-wikilove-link-text">' + options.types[typeId].name + '</div>' ); |
37 | 40 | |
38 | 41 | $button.append( '<div class="mw-wikilove-left-cap"></div>'); |
39 | 42 | $button.append( $buttonInside ); |
— | — | @@ -41,7 +44,7 @@ |
42 | 45 | $typeList.append( $( '<li tabindex="0"></li>' ).append( $button ) ); |
43 | 46 | } |
44 | 47 | |
45 | | - $.wikiLove.$dialog = $( '\ |
| 48 | + $dialog = $( '\ |
46 | 49 | <div id="mw-wikilove-dialog">\ |
47 | 50 | <div id="mw-wikilove-select-type">\ |
48 | 51 | <span class="mw-wikilove-number">1</span>\ |
— | — | @@ -95,9 +98,9 @@ |
96 | 99 | </form>\ |
97 | 100 | </div>\ |
98 | 101 | </div>' ); |
99 | | - $.wikiLove.$dialog.localize(); |
| 102 | + $dialog.localize(); |
100 | 103 | |
101 | | - $.wikiLove.$dialog.dialog({ |
| 104 | + $dialog.dialog({ |
102 | 105 | width: 800, |
103 | 106 | position: ['center', 80], |
104 | 107 | autoOpen: false, |
— | — | @@ -119,7 +122,7 @@ |
120 | 123 | $( '#mw-wikilove-message' ).elastic(); // have the message textarea grow automatically |
121 | 124 | } |
122 | 125 | |
123 | | - $.wikiLove.$dialog.dialog( 'open' ); |
| 126 | + $dialog.dialog( 'open' ); |
124 | 127 | }, |
125 | 128 | |
126 | 129 | /* |
— | — | @@ -131,21 +134,21 @@ |
132 | 135 | $( '#mw-wikilove-get-started' ).hide(); // always hide the get started section |
133 | 136 | |
134 | 137 | var newTypeId = $( this ).data( 'typeId' ); |
135 | | - if( $.wikiLove.currentTypeId != newTypeId ) { // only do stuff when a different type is selected |
136 | | - $.wikiLove.currentTypeId = newTypeId; |
137 | | - $.wikiLove.currentSubtypeId = null; // reset the subtype id |
| 138 | + if( currentTypeId != newTypeId ) { // only do stuff when a different type is selected |
| 139 | + currentTypeId = newTypeId; |
| 140 | + currentSubtypeId = null; // reset the subtype id |
138 | 141 | |
139 | 142 | $( '#mw-wikilove-types a' ).removeClass( 'selected' ); |
140 | 143 | $( this ).addClass( 'selected' ); // highlight the new type in the menu |
141 | 144 | |
142 | | - if( typeof $.wikiLove.options.types[$.wikiLove.currentTypeId].subtypes == 'object' ) { |
| 145 | + if( typeof options.types[currentTypeId].subtypes == 'object' ) { |
143 | 146 | // we're dealing with subtypes here |
144 | | - $.wikiLove.currentTypeOrSubtype = null; // reset the (sub)type object until a subtype is selected |
| 147 | + currentTypeOrSubtype = null; // reset the (sub)type object until a subtype is selected |
145 | 148 | $( '#mw-wikilove-subtype' ).html( '' ); // clear the subtype menu |
146 | 149 | |
147 | | - for( var subtypeId in $.wikiLove.options.types[$.wikiLove.currentTypeId].subtypes ) { |
| 150 | + for( var subtypeId in options.types[currentTypeId].subtypes ) { |
148 | 151 | // add all the subtypes to the menu while setting their subtype ids in jQuery data |
149 | | - var subtype = $.wikiLove.options.types[$.wikiLove.currentTypeId].subtypes[subtypeId]; |
| 152 | + var subtype = options.types[currentTypeId].subtypes[subtypeId]; |
150 | 153 | if ( typeof subtype.option != 'undefined' ) { |
151 | 154 | $( '#mw-wikilove-subtype' ).append( |
152 | 155 | $( '<option></option>' ).text( subtype.option ).data( 'subtypeId', subtypeId ) |
— | — | @@ -155,13 +158,13 @@ |
156 | 159 | $( '#mw-wikilove-subtype' ).show(); |
157 | 160 | |
158 | 161 | // change and show the subtype label depending on the type |
159 | | - $( '#mw-wikilove-subtype-label' ).text( $.wikiLove.options.types[$.wikiLove.currentTypeId].select || mw.msg( 'wikilove-select-type' ) ); |
| 162 | + $( '#mw-wikilove-subtype-label' ).text( options.types[currentTypeId].select || mw.msg( 'wikilove-select-type' ) ); |
160 | 163 | $( '#mw-wikilove-subtype-label' ).show(); |
161 | 164 | $.wikiLove.changeSubtype(); // update controls depending on the currently selected (i.e. first) subtype |
162 | 165 | } |
163 | 166 | else { |
164 | 167 | // there are no subtypes, just use this type for the current (sub)type |
165 | | - $.wikiLove.currentTypeOrSubtype = $.wikiLove.options.types[$.wikiLove.currentTypeId]; |
| 168 | + currentTypeOrSubtype = options.types[currentTypeId]; |
166 | 169 | $( '#mw-wikilove-subtype' ).hide(); |
167 | 170 | $( '#mw-wikilove-subtype-label' ).hide(); |
168 | 171 | $.wikiLove.updateAllDetails(); // update controls depending on this type |
— | — | @@ -169,7 +172,7 @@ |
170 | 173 | |
171 | 174 | $( '#mw-wikilove-add-details' ).show(); |
172 | 175 | $( '#mw-wikilove-preview' ).hide(); |
173 | | - $.wikiLove.previewData = null; |
| 176 | + previewData = null; |
174 | 177 | } |
175 | 178 | }, |
176 | 179 | |
— | — | @@ -179,14 +182,14 @@ |
180 | 183 | changeSubtype: function() { |
181 | 184 | // find out which subtype is selected |
182 | 185 | var newSubtypeId = $( '#mw-wikilove-subtype option:selected' ).first().data( 'subtypeId' ); |
183 | | - if( $.wikiLove.currentSubtypeId != newSubtypeId ) { // only change stuff when a different subtype is selected |
184 | | - $.wikiLove.currentSubtypeId = newSubtypeId; |
185 | | - $.wikiLove.currentTypeOrSubtype = $.wikiLove.options.types[$.wikiLove.currentTypeId] |
186 | | - .subtypes[$.wikiLove.currentSubtypeId]; |
187 | | - $( '#mw-wikilove-subtype-description' ).html( $.wikiLove.currentTypeOrSubtype.descr ); |
| 186 | + if( currentSubtypeId != newSubtypeId ) { // only change stuff when a different subtype is selected |
| 187 | + currentSubtypeId = newSubtypeId; |
| 188 | + currentTypeOrSubtype = options.types[currentTypeId] |
| 189 | + .subtypes[currentSubtypeId]; |
| 190 | + $( '#mw-wikilove-subtype-description' ).html( currentTypeOrSubtype.descr ); |
188 | 191 | $.wikiLove.updateAllDetails(); |
189 | 192 | $( '#mw-wikilove-preview' ).hide(); |
190 | | - $.wikiLove.previewData = null; |
| 193 | + previewData = null; |
191 | 194 | } |
192 | 195 | }, |
193 | 196 | |
— | — | @@ -197,44 +200,44 @@ |
198 | 201 | $( '#mw-wikilove-dialog' ).find( '.mw-wikilove-error' ).remove(); |
199 | 202 | |
200 | 203 | // only show the description if it exists for this type or subtype |
201 | | - if( typeof $.wikiLove.currentTypeOrSubtype.descr == 'string' ) { |
| 204 | + if( typeof currentTypeOrSubtype.descr == 'string' ) { |
202 | 205 | $( '#mw-wikilove-subtype-description').show(); |
203 | 206 | } else { |
204 | 207 | $( '#mw-wikilove-subtype-description').hide(); |
205 | 208 | } |
206 | 209 | |
207 | 210 | // show or hide header label and textbox depending on whether a predefined header exists |
208 | | - if( $.inArray( 'header', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) { |
| 211 | + if( $.inArray( 'header', currentTypeOrSubtype.fields ) >= 0 ) { |
209 | 212 | $( '#mw-wikilove-header-label').show(); |
210 | 213 | $( '#mw-wikilove-header' ).show(); |
211 | 214 | } else { |
212 | 215 | $( '#mw-wikilove-header-label').hide(); |
213 | 216 | $( '#mw-wikilove-header' ).hide(); |
214 | 217 | } |
215 | | - $( '#mw-wikilove-header' ).val( $.wikiLove.currentTypeOrSubtype.header || '' ); |
| 218 | + $( '#mw-wikilove-header' ).val( currentTypeOrSubtype.header || '' ); |
216 | 219 | |
217 | 220 | // show or hide title label and textbox depending on whether a predefined title exists |
218 | | - if( $.inArray( 'title', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) { |
| 221 | + if( $.inArray( 'title', currentTypeOrSubtype.fields ) >= 0 ) { |
219 | 222 | $( '#mw-wikilove-title-label').show(); |
220 | 223 | $( '#mw-wikilove-title' ).show(); |
221 | 224 | } else { |
222 | 225 | $( '#mw-wikilove-title-label').hide(); |
223 | 226 | $( '#mw-wikilove-title' ).hide(); |
224 | 227 | } |
225 | | - $( '#mw-wikilove-title' ).val( $.wikiLove.currentTypeOrSubtype.title || '' ); |
| 228 | + $( '#mw-wikilove-title' ).val( currentTypeOrSubtype.title || '' ); |
226 | 229 | |
227 | 230 | // show or hide image label and textbox depending on whether a predefined image exists |
228 | | - if( $.inArray( 'image', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) { |
| 231 | + if( $.inArray( 'image', currentTypeOrSubtype.fields ) >= 0 ) { |
229 | 232 | $( '#mw-wikilove-image-label').show(); |
230 | 233 | $( '#mw-wikilove-image' ).show(); |
231 | 234 | } else { |
232 | 235 | $( '#mw-wikilove-image-label').hide(); |
233 | 236 | $( '#mw-wikilove-image' ).hide(); |
234 | 237 | } |
235 | | - $( '#mw-wikilove-image' ).val( $.wikiLove.currentTypeOrSubtype.image || '' ); |
| 238 | + $( '#mw-wikilove-image' ).val( currentTypeOrSubtype.image || '' ); |
236 | 239 | |
237 | | - if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) { |
238 | | - if( $.wikiLove.currentTypeOrSubtype.gallery.imageList instanceof Array) { |
| 240 | + if( typeof currentTypeOrSubtype.gallery == 'object' ) { |
| 241 | + if( currentTypeOrSubtype.gallery.imageList instanceof Array) { |
239 | 242 | $( '#mw-wikilove-gallery-label' ).show(); |
240 | 243 | $( '#mw-wikilove-gallery' ).show(); |
241 | 244 | $.wikiLove.showGallery(); // build gallery from array of images |
— | — | @@ -251,7 +254,7 @@ |
252 | 255 | $( '#mw-wikilove-gallery' ).hide(); |
253 | 256 | } |
254 | 257 | |
255 | | - if( $.inArray( 'notify', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 && $.wikiLove.emailable ) { |
| 258 | + if( $.inArray( 'notify', currentTypeOrSubtype.fields ) >= 0 && emailable ) { |
256 | 259 | $( '#mw-wikilove-notify' ).show(); |
257 | 260 | } else { |
258 | 261 | $( '#mw-wikilove-notify' ).hide(); |
— | — | @@ -269,11 +272,11 @@ |
270 | 273 | |
271 | 274 | |
272 | 275 | if ( $( '#mw-wikilove-image' ).val().length <= 0 ) { |
273 | | - if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) { |
| 276 | + if( typeof currentTypeOrSubtype.gallery == 'object' ) { |
274 | 277 | $.wikiLove.showError( 'wikilove-err-image' ); return false; |
275 | 278 | } |
276 | 279 | else { |
277 | | - $( '#mw-wikilove-image' ).val( $.wikiLove.options.defaultImage ); |
| 280 | + $( '#mw-wikilove-image' ).val( options.defaultImage ); |
278 | 281 | } |
279 | 282 | } |
280 | 283 | if( $( '#mw-wikilove-header' ).val().length <= 0 ) { |
— | — | @@ -295,24 +298,24 @@ |
296 | 299 | $.wikiLove.showError( 'wikilove-err-sig' ); return false; |
297 | 300 | } |
298 | 301 | |
299 | | - var text = $.wikiLove.prepareMsg( |
300 | | - $.wikiLove.currentTypeOrSubtype.text || $.wikiLove.options.defaultText, |
301 | | - $.wikiLove.currentTypeOrSubtype.imageSize, |
302 | | - $.wikiLove.currentTypeOrSubtype.backgroundColor, |
303 | | - $.wikiLove.currentTypeOrSubtype.borderColor |
| 302 | + var text = prepareMsg( |
| 303 | + currentTypeOrSubtype.text || options.defaultText, |
| 304 | + currentTypeOrSubtype.imageSize, |
| 305 | + currentTypeOrSubtype.backgroundColor, |
| 306 | + currentTypeOrSubtype.borderColor |
304 | 307 | ); |
305 | 308 | |
306 | | - $.wikiLove.doPreview( '==' + $( '#mw-wikilove-header' ).val() + "==\n" + text ); |
307 | | - $.wikiLove.previewData = { |
| 309 | + doPreview( '==' + $( '#mw-wikilove-header' ).val() + "==\n" + text ); |
| 310 | + previewData = { |
308 | 311 | 'header': $( '#mw-wikilove-header' ).val(), |
309 | 312 | 'text': text, |
310 | 313 | 'message': $( '#mw-wikilove-message' ).val(), |
311 | | - 'type': $.wikiLove.currentTypeId |
312 | | - + ($.wikiLove.currentSubtypeId !== null ? '-' + $.wikiLove.currentSubtypeId : '') |
| 314 | + 'type': currentTypeId |
| 315 | + + (currentSubtypeId !== null ? '-' + currentSubtypeId : '') |
313 | 316 | }; |
314 | 317 | |
315 | | - if ( $( '#mw-wikilove-notify-checkbox:checked' ).val() && $.wikiLove.emailable ) { |
316 | | - $.wikiLove.previewData.email = $.wikiLove.prepareMsg( $.wikiLove.currentTypeOrSubtype.email ); |
| 318 | + if ( $( '#mw-wikilove-notify-checkbox:checked' ).val() && emailable ) { |
| 319 | + previewData.email = prepareMsg( currentTypeOrSubtype.email ); |
317 | 320 | } |
318 | 321 | }, |
319 | 322 | |
— | — | @@ -336,9 +339,9 @@ |
337 | 340 | msg = msg.replace( '$2', $( '#mw-wikilove-title' ).val() ); // replace the title |
338 | 341 | msg = msg.replace( '$3', $( '#mw-wikilove-image' ).val() ); // replace the image |
339 | 342 | |
340 | | - var myImageSize = imageSize || $.wikiLove.options.defaultImageSize; |
341 | | - var myBackgroundColor = backgroundColor || $.wikiLove.options.defaultBackgroundColor; |
342 | | - var myBorderColor = borderColor || $.wikiLove.options.defaultBorderColor; |
| 343 | + var myImageSize = imageSize || options.defaultImageSize; |
| 344 | + var myBackgroundColor = backgroundColor || options.defaultBackgroundColor; |
| 345 | + var myBorderColor = borderColor || options.defaultBorderColor; |
343 | 346 | |
344 | 347 | msg = msg.replace( '$4', myImageSize ); // replace the image size |
345 | 348 | msg = msg.replace( '$5', myBackgroundColor ); // replace the background color |
— | — | @@ -387,8 +390,8 @@ |
388 | 391 | */ |
389 | 392 | submitSend: function( e ) { |
390 | 393 | e.preventDefault(); |
391 | | - $.wikiLove.doSend( $.wikiLove.previewData.header, $.wikiLove.previewData.text, |
392 | | - $.wikiLove.previewData.message, $.wikiLove.previewData.type, $.wikiLove.previewData.email ); |
| 394 | + $.wikiLove.doSend( previewData.header, previewData.text, |
| 395 | + previewData.message, previewData.type, previewData.email ); |
393 | 396 | }, |
394 | 397 | |
395 | 398 | /* |
— | — | @@ -447,18 +450,18 @@ |
448 | 451 | */ |
449 | 452 | showGallery: function() { |
450 | 453 | $( '#mw-wikilove-gallery-content' ).html( '' ); |
451 | | - $.wikiLove.gallery = {}; |
| 454 | + gallery = {}; |
452 | 455 | $( '#mw-wikilove-gallery-spinner' ).fadeIn( 200 ); |
453 | 456 | |
454 | | - if( typeof $.wikiLove.currentTypeOrSubtype.gallery.number == 'undefined' |
455 | | - || $.wikiLove.currentTypeOrSubtype.gallery.number <= 0 |
| 457 | + if( typeof currentTypeOrSubtype.gallery.number == 'undefined' |
| 458 | + || currentTypeOrSubtype.gallery.number <= 0 |
456 | 459 | ) { |
457 | | - $.wikiLove.currentTypeOrSubtype.gallery.number = $.wikiLove.currentTypeOrSubtype.gallery.imageList.length; |
| 460 | + currentTypeOrSubtype.gallery.number = currentTypeOrSubtype.gallery.imageList.length; |
458 | 461 | } |
459 | 462 | |
460 | 463 | var titles = ''; |
461 | | - var imageList = $.wikiLove.currentTypeOrSubtype.gallery.imageList; |
462 | | - for( var i=0; i<$.wikiLove.currentTypeOrSubtype.gallery.number; i++ ) { |
| 464 | + var imageList = currentTypeOrSubtype.gallery.imageList; |
| 465 | + for( var i=0; i<currentTypeOrSubtype.gallery.number; i++ ) { |
463 | 466 | // get a randomimage |
464 | 467 | var id = Math.floor( Math.random() * imageList.length ); |
465 | 468 | titles = titles + 'File:' + imageList[id] + '|'; |
— | — | @@ -476,7 +479,7 @@ |
477 | 480 | 'prop' : 'imageinfo', |
478 | 481 | 'iiprop' : 'mime|url', |
479 | 482 | 'titles' : titles, |
480 | | - 'iiurlwidth' : $.wikiLove.currentTypeOrSubtype.gallery.width |
| 483 | + 'iiurlwidth' : currentTypeOrSubtype.gallery.width |
481 | 484 | }, |
482 | 485 | dataType: 'json', |
483 | 486 | type: 'POST', |
— | — | @@ -491,7 +494,7 @@ |
492 | 495 | // build an image tag with the correct url and width |
493 | 496 | $img = $( '<img/>' ) |
494 | 497 | .attr( 'src', page.imageinfo[0].thumburl ) |
495 | | - .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width ) |
| 498 | + .attr( 'width', currentTypeOrSubtype.gallery.width ) |
496 | 499 | .hide() |
497 | 500 | .load( function() { $( this ).css( 'display', 'inline-block' ); } ); |
498 | 501 | $( '#mw-wikilove-gallery-content' ).append( |
— | — | @@ -502,15 +505,26 @@ |
503 | 506 | e.preventDefault(); |
504 | 507 | $( '#mw-wikilove-gallery a' ).removeClass( 'selected' ); |
505 | 508 | $( this ).addClass( 'selected' ); |
506 | | - $( '#mw-wikilove-image' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] ); |
| 509 | + $( '#mw-wikilove-image' ).val( gallery[$( this ).attr( 'id' )] ); |
507 | 510 | }) |
508 | 511 | ); |
509 | | - $.wikiLove.gallery['mw-wikilove-gallery-img-' + index] = page.title; |
| 512 | + gallery['mw-wikilove-gallery-img-' + index] = page.title; |
510 | 513 | index++; |
511 | 514 | } |
512 | 515 | } ); |
513 | 516 | } |
514 | 517 | }); |
| 518 | + }, |
| 519 | + |
| 520 | + /* |
| 521 | + * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog. |
| 522 | + */ |
| 523 | + init: function() { |
| 524 | + options = $.wikiLove.optionsHook(); |
| 525 | + $( '#ca-wikilove a' ).click( function( e ) { |
| 526 | + $.wikiLove.openDialog(); |
| 527 | + e.preventDefault(); |
| 528 | + }); |
515 | 529 | } |
516 | 530 | |
517 | 531 | /* |
— | — | @@ -526,7 +540,7 @@ |
527 | 541 | /* |
528 | 542 | makeGallery: function() { |
529 | 543 | $( '#mw-wikilove-gallery-content' ).html( '' ); |
530 | | - $.wikiLove.gallery = {}; |
| 544 | + gallery = {}; |
531 | 545 | $( '#mw-wikilove-gallery-spinner' ).fadeIn( 200 ); |
532 | 546 | |
533 | 547 | $.ajax({ |
— | — | @@ -536,19 +550,19 @@ |
537 | 551 | 'format' : 'json', |
538 | 552 | 'prop' : 'imageinfo', |
539 | 553 | 'iiprop' : 'mime|url', |
540 | | - 'iiurlwidth' : $.wikiLove.currentTypeOrSubtype.gallery.width, |
| 554 | + 'iiurlwidth' : currentTypeOrSubtype.gallery.width, |
541 | 555 | 'generator' : 'categorymembers', |
542 | | - 'gcmtitle' : $.wikiLove.currentTypeOrSubtype.gallery.category, |
| 556 | + 'gcmtitle' : currentTypeOrSubtype.gallery.category, |
543 | 557 | 'gcmnamespace': 6, |
544 | 558 | 'gcmsort' : 'timestamp', |
545 | | - 'gcmlimit' : $.wikiLove.currentTypeOrSubtype.gallery.total |
| 559 | + 'gcmlimit' : currentTypeOrSubtype.gallery.total |
546 | 560 | }, |
547 | 561 | dataType: 'json', |
548 | 562 | type: 'POST', |
549 | 563 | success: function( data ) { |
550 | 564 | // clear |
551 | 565 | $( '#mw-wikilove-gallery-content' ).html( '' ); |
552 | | - $.wikiLove.gallery = {}; |
| 566 | + gallery = {}; |
553 | 567 | |
554 | 568 | // if we have any images at all |
555 | 569 | if( data.query) { |
— | — | @@ -556,7 +570,7 @@ |
557 | 571 | var keys = Object.keys( data.query.pages ); |
558 | 572 | |
559 | 573 | // try to find "num" images to show |
560 | | - for( var i=0; i<$.wikiLove.currentTypeOrSubtype.gallery.num; i++ ) { |
| 574 | + for( var i=0; i<currentTypeOrSubtype.gallery.num; i++ ) { |
561 | 575 | // continue looking for a new image until we have found one thats valid |
562 | 576 | // or until we run out of images |
563 | 577 | while( keys.length > 0 ) { |
— | — | @@ -572,7 +586,7 @@ |
573 | 587 | // build an image tag with the correct url and width |
574 | 588 | var $img = $( '<img/>' ) |
575 | 589 | .attr( 'src', page.imageinfo[0].url ) |
576 | | - .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width ) |
| 590 | + .attr( 'width', currentTypeOrSubtype.gallery.width ) |
577 | 591 | .hide() |
578 | 592 | .load( function() { $( this ).css( 'display', 'inline-block' ); } ); |
579 | 593 | |
— | — | @@ -585,18 +599,18 @@ |
586 | 600 | e.preventDefault(); |
587 | 601 | $( '#mw-wikilove-gallery a' ).removeClass( 'selected' ); |
588 | 602 | $( this ).addClass( 'selected' ); |
589 | | - $( '#mw-wikilove-image' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] ); |
| 603 | + $( '#mw-wikilove-image' ).val( gallery[$( this ).attr( 'id' )] ); |
590 | 604 | }) |
591 | 605 | ); |
592 | 606 | |
593 | 607 | // save the page title into an array so we know which image id maps to which title |
594 | | - $.wikiLove.gallery['mw-wikilove-gallery-img-' + i] = page.title; |
| 608 | + gallery['mw-wikilove-gallery-img-' + i] = page.title; |
595 | 609 | break; |
596 | 610 | } |
597 | 611 | } |
598 | 612 | } |
599 | 613 | } |
600 | | - if( $.wikiLove.gallery.length <= 0 ) { |
| 614 | + if( gallery.length <= 0 ) { |
601 | 615 | $( '#mw-wikilove-gallery' ).hide(); |
602 | 616 | $( '#mw-wikilove-gallery-label' ).hide(); |
603 | 617 | } |
— | — | @@ -607,6 +621,6 @@ |
608 | 622 | }, |
609 | 623 | */ |
610 | 624 | }; |
| 625 | + |
| 626 | +}()); |
611 | 627 | } ) ( jQuery ); |
612 | | - |
613 | | -mw.log( 'core loaded' ); |
\ No newline at end of file |