Index: trunk/extensions/WikiLove/WikiLove.php |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 | // add autoload classes |
58 | 58 | $wgAutoloadClasses['WikiLoveApi'] = $dir . 'WikiLove.api.php'; |
59 | 59 | $wgAutoloadClasses['WikiLoveHooks'] = $dir . 'WikiLove.hooks.php'; |
| 60 | +$wgAutoloadClasses['WikiLoveLocal'] = $dir . 'WikiLove.local.php'; |
60 | 61 | |
61 | 62 | // i18n messages |
62 | 63 | $wgExtensionMessagesFiles['WikiLove'] = $dir . 'WikiLove.i18n.php'; |
— | — | @@ -81,7 +82,7 @@ |
82 | 83 | 'styles' => 'ext.wikiLove.icon.css', |
83 | 84 | 'position' => 'top', |
84 | 85 | ), |
85 | | - 'ext.wikiLove' => $extWikiLoveTpl + array( |
| 86 | + 'ext.wikiLove.startup' => $extWikiLoveTpl + array( |
86 | 87 | 'scripts' => array( |
87 | 88 | 'ext.wikiLove.core.js', |
88 | 89 | 'ext.wikiLove.defaultOptions.js', |
— | — | @@ -119,6 +120,20 @@ |
120 | 121 | 'jquery.localize', |
121 | 122 | ), |
122 | 123 | ), |
| 124 | + 'ext.wikiLove.local' => array( |
| 125 | + 'class' => 'WikiLoveLocal', |
| 126 | + /* for information only, this is actually in the class! |
| 127 | + 'dependencies' => array( |
| 128 | + 'ext.wikiLove.startup', |
| 129 | + ), |
| 130 | + */ |
| 131 | + ), |
| 132 | + 'ext.wikiLove.init' => $extWikiLoveTpl + array( |
| 133 | + 'scripts' => 'ext.wikiLove.init.js', |
| 134 | + 'dependencies' => array( |
| 135 | + 'ext.wikiLove.local', |
| 136 | + ), |
| 137 | + ), |
123 | 138 | 'jquery.elastic' => array( |
124 | 139 | 'localBasePath' => dirname( __FILE__ ) . '/modules/jquery.elastic', |
125 | 140 | 'remoteExtPath' => 'WikiLove/modules/jquery.elastic', |
Index: trunk/extensions/WikiLove/WikiLove.hooks.php |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | $title = self::getUserTalkPage( $skin->getTitle() ); |
57 | 57 | if ( !is_null( $title ) ) { |
58 | 58 | $out->addModules( 'ext.wikiLove.icon' ); |
59 | | - $out->addModules( 'ext.wikiLove' ); |
| 59 | + $out->addModules( 'ext.wikiLove.init' ); |
60 | 60 | } |
61 | 61 | return true; |
62 | 62 | } |
Index: trunk/extensions/WikiLove/WikiLove.local.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<?php |
| 3 | +/* |
| 4 | + * Custom ResourceLoader module that loads a custom WikiLove.js per-wiki. |
| 5 | + */ |
| 6 | +class WikiLoveLocal extends ResourceLoaderWikiModule { |
| 7 | + protected function getPages( ResourceLoaderContext $context ) { |
| 8 | + return array( |
| 9 | + 'MediaWiki:WikiLove.js' => array( 'type' => 'script' ), |
| 10 | + ); |
| 11 | + } |
| 12 | + |
| 13 | + public function getDependencies() { |
| 14 | + return array( |
| 15 | + 'ext.wikiLove.startup', |
| 16 | + ); |
| 17 | + } |
| 18 | +} |
Property changes on: trunk/extensions/WikiLove/WikiLove.local.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 19 | + native |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js |
— | — | @@ -1,68 +1,80 @@ |
2 | | -$.wikiLove.types = { |
3 | | - // example type, could be removed later (also no i18n) |
4 | | - 'barnstar': { |
5 | | - name: 'Barnstar', // name of the type (appears in the types menu) |
6 | | - select: 'Select a barnstar:', // subtype select label |
7 | | - subtypes: { // some different subtypes |
8 | | - // note that when not using subtypes you should use these subtype options |
9 | | - // for the top-level type |
10 | | - 'original': { |
11 | | - fields: [ 'notify' ], // fields to ask for in form |
12 | | - option: 'Original barnstar', // option listed in the select list |
13 | | - descr: 'This barnstar is given to recognize particularly fine contributions to Wikipedia, to let people know that their hard work is seen and appreciated.', // description |
14 | | - header: 'A barnstar for you!', // header that appears at the top of the talk page post (optional) |
15 | | - title: 'The Original Barnstar', // title that appears inside the award box (optional) |
16 | | - image: 'Original Barnstar Hires.png', // image for the award |
17 | | - mail: 'Hello $7!\n\nI just awarded you a barnstar.' // message to use in email notification; $7 is replaced by the recipient's username |
| 2 | +$.wikiLove.optionsHook = function() { return { |
| 3 | + defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\ |
| 4 | +|rowspan="2" style="vertical-align: middle; padding: 5px;" | [[Image:$3|$4]]\n\ |
| 5 | +|style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\ |
| 6 | +|-\n\ |
| 7 | +|style="vertical-align: middle; padding: 3px;" | $1 ~~~~\n\ |
| 8 | +|}', |
| 9 | + defaultBackgroundColor: '#fdffe7', |
| 10 | + defaultBorderColor: '#fceb92', |
| 11 | + defaultImageSize: '100px', |
| 12 | + |
| 13 | + types: { |
| 14 | + // example type, could be removed later (also no i18n) |
| 15 | + 'barnstar': { |
| 16 | + name: 'Barnstar', // name of the type (appears in the types menu) |
| 17 | + select: 'Select a barnstar:', // subtype select label |
| 18 | + subtypes: { // some different subtypes |
| 19 | + // note that when not using subtypes you should use these subtype options |
| 20 | + // for the top-level type |
| 21 | + 'original': { |
| 22 | + fields: [ 'notify' ], // fields to ask for in form |
| 23 | + option: 'Original barnstar', // option listed in the select list |
| 24 | + descr: 'This barnstar is given to recognize particularly fine contributions to Wikipedia, to let people know that their hard work is seen and appreciated.', // description |
| 25 | + header: 'A barnstar for you!', // header that appears at the top of the talk page post (optional) |
| 26 | + title: 'The Original Barnstar', // title that appears inside the award box (optional) |
| 27 | + image: 'Original Barnstar Hires.png', // image for the award |
| 28 | + mail: 'Hello $7!\n\nI just awarded you a barnstar.' // message to use in email notification; $7 is replaced by the recipient's username |
| 29 | + }, |
| 30 | + 'editors': { |
| 31 | + fields: [ 'notify' ], |
| 32 | + option: 'Editor\'s barnstar', |
| 33 | + descr: 'The Editor\'s Barnstar is awarded to individuals who display particularly fine decisions in general editing.', |
| 34 | + header: 'A barnstar for you!', |
| 35 | + title: 'The Editor\'s Barnstar', |
| 36 | + image: 'Editors Barnstar Hires.png', |
| 37 | + mail: 'Hello $7!\n\nI just awarded you a barnstar.' |
| 38 | + }, |
| 39 | + 'tireless': { |
| 40 | + fields: [ 'title', 'notify' ], |
| 41 | + option: 'Tireless contributor barnstar', |
| 42 | + descr: 'The Tireless Contributor Barnstar is awarded to especially tireless Wikipedians who contribute an especially large body of work without sacrificing quality.', |
| 43 | + header: 'A barnstar for you!', |
| 44 | + title: 'Tireless contributor barnstar', |
| 45 | + image: 'Tireless Contributor Barnstar Hires.gif', |
| 46 | + mail: 'Hello $7!\n\nI just awarded you a barnstar.' |
| 47 | + } |
18 | 48 | }, |
19 | | - 'editors': { |
20 | | - fields: [ 'notify' ], |
21 | | - option: 'Editor\'s barnstar', |
22 | | - descr: 'The Editor\'s Barnstar is awarded to individuals who display particularly fine decisions in general editing.', |
23 | | - header: 'A barnstar for you!', |
24 | | - title: 'The Editor\'s Barnstar', |
25 | | - image: 'Editors Barnstar Hires.png', |
26 | | - mail: 'Hello $7!\n\nI just awarded you a barnstar.' |
27 | | - }, |
28 | | - 'tireless': { |
29 | | - fields: [ 'title', 'notify' ], |
30 | | - option: 'Tireless contributor barnstar', |
31 | | - descr: 'The Tireless Contributor Barnstar is awarded to especially tireless Wikipedians who contribute an especially large body of work without sacrificing quality.', |
32 | | - header: 'A barnstar for you!', |
33 | | - title: 'Tireless contributor barnstar', |
34 | | - image: 'Tireless Contributor Barnstar Hires.gif', |
35 | | - mail: 'Hello $7!\n\nI just awarded you a barnstar.' |
| 49 | + icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' // icon for left-side menu |
| 50 | + }, |
| 51 | + 'puppy': { |
| 52 | + name: 'Puppy', |
| 53 | + fields: [ 'header' ], |
| 54 | + header: 'A puppy for you!', |
| 55 | + text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // custom text |
| 56 | + gallery: { |
| 57 | + // right now we can only query the local wiki (not e.g. commons) |
| 58 | + category: 'Category:Puppies', |
| 59 | + total: 100, // total number of pictures to retrieve, and to randomise |
| 60 | + num: 3, // number of pictures to show from the randomised set |
| 61 | + width: 145 // width of each picture in pixels in the interface (not in the template) |
36 | 62 | } |
37 | 63 | }, |
38 | | - icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' // icon for left-side menu |
39 | | - }, |
40 | | - 'puppy': { |
41 | | - name: 'Puppy', |
42 | | - fields: [ 'header' ], |
43 | | - header: 'A puppy for you!', |
44 | | - text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // custom text |
45 | | - gallery: { |
46 | | - // right now we can only query the local wiki (not e.g. commons) |
47 | | - category: 'Category:Puppies', |
48 | | - total: 100, // total number of pictures to retrieve, and to randomise |
49 | | - num: 3, // number of pictures to show from the randomised set |
50 | | - width: 145 // width of each picture in pixels in the interface (not in the template) |
| 64 | + 'kitten': { |
| 65 | + name: 'Kitten', |
| 66 | + fields: [ 'header' ], |
| 67 | + header: 'A kitten for you!', |
| 68 | + text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename |
| 69 | + gallery: { |
| 70 | + imageList: ['File:Cucciolo gatto Bibo.jpg','File:Kitten (06) by Ron.jpg','File:Kitten-stare.jpg'], |
| 71 | + width: 145 |
| 72 | + } |
| 73 | + }, |
| 74 | + // default type, nice to leave this one in place when adding other types |
| 75 | + 'makeyourown': { |
| 76 | + name: mw.msg( 'wikilove-type-makeyourown' ), |
| 77 | + fields: [ 'header', 'title', 'image', 'notify' ], |
| 78 | + imageSize: '150px' |
51 | 79 | } |
52 | | - }, |
53 | | - 'kitten': { |
54 | | - name: 'Kitten', |
55 | | - fields: [ 'header' ], |
56 | | - header: 'A kitten for you!', |
57 | | - text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename |
58 | | - gallery: { |
59 | | - imageList: ['File:Cucciolo gatto Bibo.jpg','File:Kitten (06) by Ron.jpg','File:Kitten-stare.jpg'], |
60 | | - width: 145 |
61 | | - } |
62 | | - }, |
63 | | - // default type, nice to leave this one in place when adding other types |
64 | | - 'makeyourown': { |
65 | | - name: mw.msg( 'wikilove-type-makeyourown' ), |
66 | | - fields: [ 'header', 'title', 'image', 'notify' ], |
67 | | - imageSize: '150px' |
68 | 80 | } |
69 | | -} |
\ No newline at end of file |
| 81 | +}; }; |
\ No newline at end of file |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.init.js |
— | — | @@ -0,0 +1,13 @@ |
| 2 | +/* |
| 3 | + * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog. |
| 4 | + */ |
| 5 | + |
| 6 | +$.wikiLove.init = function() { |
| 7 | + $.wikiLove.options = $.wikiLove.optionsHook(); |
| 8 | + $( '#ca-wikilove a' ).click( function( e ) { |
| 9 | + $.wikiLove.openDialog(); |
| 10 | + e.preventDefault(); |
| 11 | + }); |
| 12 | +} |
| 13 | + |
| 14 | +$( document ).ready( $.wikiLove.init ); |
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.init.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 15 | + native |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -1,5 +1,7 @@ |
2 | 2 | ( function( $ ) { $.wikiLove = { |
3 | | - |
| 3 | + |
| 4 | + options: {}, // options modifiable by the user |
| 5 | + optionsHook: function() { return {}; }, // hook that can be overridden by the user to modify options |
4 | 6 | $dialog: null, // dialog jQuery object |
5 | 7 | currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown') |
6 | 8 | currentSubtypeId: null, // id of the currently selected subtype (e.g. 'original' or 'special') |
— | — | @@ -7,43 +9,30 @@ |
8 | 10 | previewData: null, // data of the currently previewed thing is set here |
9 | 11 | emailable: false, |
10 | 12 | gallery: {}, |
11 | | - defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\ |
12 | | -|rowspan="2" style="vertical-align: middle; padding: 5px;" | [[Image:$3|$4]]\n\ |
13 | | -|style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\ |
14 | | -|-\n\ |
15 | | -|style="vertical-align: middle; padding: 3px;" | $1 ~~~~\n\ |
16 | | -|}', |
17 | | - defaultBackgroundColor: '#fdffe7', |
18 | | - defaultBorderColor: '#fceb92', |
19 | | - defaultImageSize: '100px', |
20 | 13 | |
21 | 14 | /* |
22 | 15 | * Opens the dialog and builds it if necessary. |
23 | 16 | */ |
24 | 17 | openDialog: function() { |
25 | 18 | if ( $.wikiLove.$dialog === null ) { |
26 | | - // Load local configuration |
27 | | - var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } ); |
28 | | - mw.loader.load( wikiLoveConfigUrl ); |
29 | | - |
30 | 19 | // Test to see if the 'E-mail this user' link exists |
31 | 20 | $.wikiLove.emailable = $( '#t-emailuser' ).length ? true : false; |
32 | 21 | |
33 | 22 | // Build a type list like this: |
34 | 23 | var $typeList = $( '<ul id="mw-wikilove-types"></ul>' ); |
35 | | - for( var typeId in $.wikiLove.types ) { |
| 24 | + for( var typeId in $.wikiLove.options.types ) { |
36 | 25 | var $button = $( '<a href="#"></a>' ); |
37 | 26 | var $buttonInside = $( '<div class="mw-wikilove-inside"></div>' ); |
38 | 27 | |
39 | | - if( typeof $.wikiLove.types[typeId].icon == 'string' ) { |
| 28 | + if( typeof $.wikiLove.options.types[typeId].icon == 'string' ) { |
40 | 29 | $buttonInside.append( '<div class="mw-wikilove-icon-box"><img src="' |
41 | | - + mw.html.escape( $.wikiLove.types[typeId].icon ) + '"/></div>' ); |
| 30 | + + mw.html.escape( $.wikiLove.options.types[typeId].icon ) + '"/></div>' ); |
42 | 31 | } |
43 | 32 | else { |
44 | 33 | $buttonInside.addClass( 'mw-wikilove-no-icon' ); |
45 | 34 | } |
46 | 35 | |
47 | | - $buttonInside.append( '<div class="mw-wikilove-link-text">' + $.wikiLove.types[typeId].name + '</div>' ); |
| 36 | + $buttonInside.append( '<div class="mw-wikilove-link-text">' + $.wikiLove.options.types[typeId].name + '</div>' ); |
48 | 37 | |
49 | 38 | $button.append( '<div class="mw-wikilove-left-cap"></div>'); |
50 | 39 | $button.append( $buttonInside ); |
— | — | @@ -149,14 +138,14 @@ |
150 | 139 | $( '#mw-wikilove-types a' ).removeClass( 'selected' ); |
151 | 140 | $( this ).addClass( 'selected' ); // highlight the new type in the menu |
152 | 141 | |
153 | | - if( typeof $.wikiLove.types[$.wikiLove.currentTypeId].subtypes == 'object' ) { |
| 142 | + if( typeof $.wikiLove.options.types[$.wikiLove.currentTypeId].subtypes == 'object' ) { |
154 | 143 | // we're dealing with subtypes here |
155 | 144 | $.wikiLove.currentTypeOrSubtype = null; // reset the (sub)type object until a subtype is selected |
156 | 145 | $( '#mw-wikilove-subtype' ).html( '' ); // clear the subtype menu |
157 | 146 | |
158 | | - for( var subtypeId in $.wikiLove.types[$.wikiLove.currentTypeId].subtypes ) { |
| 147 | + for( var subtypeId in $.wikiLove.options.types[$.wikiLove.currentTypeId].subtypes ) { |
159 | 148 | // add all the subtypes to the menu while setting their subtype ids in jQuery data |
160 | | - var subtype = $.wikiLove.types[$.wikiLove.currentTypeId].subtypes[subtypeId]; |
| 149 | + var subtype = $.wikiLove.options.types[$.wikiLove.currentTypeId].subtypes[subtypeId]; |
161 | 150 | $( '#mw-wikilove-subtype' ).append( |
162 | 151 | $( '<option></option>' ).text( subtype.option ).data( 'subtypeId', subtypeId ) |
163 | 152 | ); |
— | — | @@ -164,13 +153,13 @@ |
165 | 154 | $( '#mw-wikilove-subtype' ).show(); |
166 | 155 | |
167 | 156 | // change and show the subtype label depending on the type |
168 | | - $( '#mw-wikilove-subtype-label' ).text( $.wikiLove.types[$.wikiLove.currentTypeId].select || mw.msg( 'wikilove-select-type' ) ); |
| 157 | + $( '#mw-wikilove-subtype-label' ).text( $.wikiLove.options.types[$.wikiLove.currentTypeId].select || mw.msg( 'wikilove-select-type' ) ); |
169 | 158 | $( '#mw-wikilove-subtype-label' ).show(); |
170 | 159 | $.wikiLove.changeSubtype(); // update controls depending on the currently selected (i.e. first) subtype |
171 | 160 | } |
172 | 161 | else { |
173 | 162 | // there are no subtypes, just use this type for the current (sub)type |
174 | | - $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId]; |
| 163 | + $.wikiLove.currentTypeOrSubtype = $.wikiLove.options.types[$.wikiLove.currentTypeId]; |
175 | 164 | $( '#mw-wikilove-subtype' ).hide(); |
176 | 165 | $( '#mw-wikilove-subtype-label' ).hide(); |
177 | 166 | $.wikiLove.updateAllDetails(); // update controls depending on this type |
— | — | @@ -190,7 +179,7 @@ |
191 | 180 | var newSubtypeId = $( '#mw-wikilove-subtype option:selected' ).first().data( 'subtypeId' ); |
192 | 181 | if( $.wikiLove.currentSubtypeId != newSubtypeId ) { // only change stuff when a different subtype is selected |
193 | 182 | $.wikiLove.currentSubtypeId = newSubtypeId; |
194 | | - $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId] |
| 183 | + $.wikiLove.currentTypeOrSubtype = $.wikiLove.options.types[$.wikiLove.currentTypeId] |
195 | 184 | .subtypes[$.wikiLove.currentSubtypeId]; |
196 | 185 | $( '#mw-wikilove-subtype-description' ).html( $.wikiLove.currentTypeOrSubtype.descr ); |
197 | 186 | $.wikiLove.updateAllDetails(); |
— | — | @@ -293,7 +282,7 @@ |
294 | 283 | } |
295 | 284 | |
296 | 285 | var msg = $.wikiLove.prepareMsg( |
297 | | - $.wikiLove.currentTypeOrSubtype.text || $.wikiLove.defaultText, |
| 286 | + $.wikiLove.currentTypeOrSubtype.text || $.wikiLove.options.defaultText, |
298 | 287 | $.wikiLove.currentTypeOrSubtype.imageSize, |
299 | 288 | $.wikiLove.currentTypeOrSubtype.backgroundColor, |
300 | 289 | $.wikiLove.currentTypeOrSubtype.borderColor |
— | — | @@ -332,9 +321,9 @@ |
333 | 322 | msg = msg.replace( '$2', $( '#mw-wikilove-title' ).val() ); // replace the title |
334 | 323 | msg = msg.replace( '$3', $( '#mw-wikilove-image' ).val() ); // replace the image |
335 | 324 | |
336 | | - var myImageSize = imageSize || $.wikiLove.defaultImageSize; |
337 | | - var myBackgroundColor = backgroundColor || $.wikiLove.defaultBackgroundColor; |
338 | | - var myBorderColor = borderColor || $.wikiLove.defaultBorderColor; |
| 325 | + var myImageSize = imageSize || $.wikiLove.options.defaultImageSize; |
| 326 | + var myBackgroundColor = backgroundColor || $.wikiLove.options.defaultBackgroundColor; |
| 327 | + var myBorderColor = borderColor || $.wikiLove.options.defaultBorderColor; |
339 | 328 | |
340 | 329 | msg = msg.replace( '$4', myImageSize ); // replace the image size |
341 | 330 | msg = msg.replace( '$5', myBackgroundColor ); // replace the background color |
— | — | @@ -580,17 +569,7 @@ |
581 | 570 | } |
582 | 571 | }); |
583 | 572 | }, |
584 | | - |
585 | | - /* |
586 | | - * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog. |
587 | | - */ |
588 | | - init: function() { |
589 | | - $( '#ca-wikilove a' ).click( function( e ) { |
590 | | - $.wikiLove.openDialog(); |
591 | | - e.preventDefault(); |
592 | | - }); |
593 | | - } |
594 | 573 | }; |
595 | | - |
596 | | -$( document ).ready( $.wikiLove.init ); |
597 | 574 | } ) ( jQuery ); |
| 575 | + |
| 576 | +mw.log( 'core loaded' ); |
\ No newline at end of file |