Index: trunk/extensions/WikiLove/WikiLove.php |
— | — | @@ -80,7 +80,10 @@ |
81 | 81 | |
82 | 82 | $wgResourceModules += array( |
83 | 83 | 'ext.wikiLove' => $wikiLoveTpl + array( |
84 | | - 'scripts' => 'wikiLove.js', |
| 84 | + 'scripts' => array( |
| 85 | + 'wikiLove.js', |
| 86 | + 'defaultTypes.js', |
| 87 | + ), |
85 | 88 | 'styles' => 'wikiLove.css', |
86 | 89 | 'messages' => array( |
87 | 90 | 'wikilove-dialog-title', |
— | — | @@ -90,7 +93,8 @@ |
91 | 94 | 'wikilove-get-started-list-2', |
92 | 95 | 'wikilove-get-started-list-3', |
93 | 96 | 'wikilove-add-details', |
94 | | - 'wikilove-gallery', |
| 97 | + 'wikilove-image', |
| 98 | + 'wikilove-header', |
95 | 99 | 'wikilove-title', |
96 | 100 | 'wikilove-enter-message', |
97 | 101 | 'wikilove-omit-sig', |
— | — | @@ -98,10 +102,12 @@ |
99 | 103 | 'wikilove-preview', |
100 | 104 | 'wikilove-button-send', |
101 | 105 | 'wikilove-type-makeyourown', |
| 106 | + 'wikilove-err-header', |
102 | 107 | 'wikilove-err-title', |
103 | 108 | 'wikilove-err-msg', |
104 | 109 | 'wikilove-err-image', |
105 | 110 | 'wikilove-err-sig', |
| 111 | + 'wikilove-barnstar-header', |
106 | 112 | ), |
107 | 113 | 'dependencies' => array( |
108 | 114 | 'jquery.ui.dialog', |
Index: trunk/extensions/WikiLove/wikiLove.css |
— | — | @@ -244,7 +244,7 @@ |
245 | 245 | width: 300px; |
246 | 246 | } |
247 | 247 | |
248 | | -#wikiLoveDialog #wlAddDetails .wlOmitSig { |
| 248 | +#wikiLoveDialog #wlAddDetails .wlNote { |
249 | 249 | font-weight: light; |
250 | 250 | font-size: 0.9em; |
251 | 251 | float: right; |
— | — | @@ -255,13 +255,9 @@ |
256 | 256 | resize: none; |
257 | 257 | } |
258 | 258 | |
259 | | -#wikiLoveDialog #wlAddDetails #wlNotify { |
260 | | - float: left; |
261 | | -} |
262 | | - |
263 | 259 | #wikiLoveDialog .wlSpinner { |
264 | 260 | float: right; |
265 | | - margin-top: 6px; |
| 261 | + margin-top: 0.9em; |
266 | 262 | display: none; |
267 | 263 | } |
268 | 264 | |
— | — | @@ -292,6 +288,9 @@ |
293 | 289 | #wikiLoveDialog #wlGallerySpinner .wlSpinner { |
294 | 290 | float: none; |
295 | 291 | position: absolute; |
| 292 | + top: 0; |
| 293 | + left: 50%; |
| 294 | + margin-left: -8px; |
296 | 295 | z-index: -1; |
297 | 296 | } |
298 | 297 | |
— | — | @@ -320,6 +319,12 @@ |
321 | 320 | display: block; |
322 | 321 | } |
323 | 322 | |
| 323 | +#wikiLoveDialog #wlSubtypeDescription { |
| 324 | + margin: 5px 0px 8px 15px; |
| 325 | + font-size: 1.0em; |
| 326 | + line-height: 1.2em; |
| 327 | +} |
| 328 | + |
324 | 329 | #wikiLoveDialog input[type=checkbox] { |
325 | 330 | display:inline-box; |
326 | 331 | margin: 5px 0px 5px 0px; |
Index: trunk/extensions/WikiLove/defaultTypes.js |
— | — | @@ -0,0 +1,57 @@ |
| 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 | + fields: [ 'header', 'title', 'image' ], // fields to ask for in form if not specified in config |
| 7 | + select: 'Select a barnstar:', // subtype select label |
| 8 | + subtypes: { // some different subtypes |
| 9 | + // note that when not using subtypes you should use these subtype options |
| 10 | + // for the top-level type |
| 11 | + 'original': { |
| 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: mw.msg( 'wikilove-barnstar-header' ), // 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 |
| 18 | + }, |
| 19 | + 'editors': { |
| 20 | + option: 'Editor\'s barnstar', |
| 21 | + descr: 'The Editor\'s Barnstar is awarded to individuals who display particularly fine decisions in general editing.', |
| 22 | + header: mw.msg( 'wikilove-barnstar-header' ), |
| 23 | + title: 'The Editor\'s Barnstar', |
| 24 | + image: 'Editors Barnstar Hires.png', |
| 25 | + mail: 'Hello $7!\n\nI just awarded you a barnstar.' |
| 26 | + }, |
| 27 | + 'tireless': { |
| 28 | + option: 'Tireless contributor barnstar', |
| 29 | + descr: 'The Tireless Contributor Barnstar is awarded to especially tireless Wikipedians who contribute an especially large body of work without sacrificing quality.', |
| 30 | + header: mw.msg( 'wikilove-barnstar-header' ), |
| 31 | + title: 'The Editor\'s Barnstar', |
| 32 | + image: 'Tireless Contributor Barnstar Hires.gif', |
| 33 | + mail: 'Hello $7!\n\nI just awarded you a barnstar.' |
| 34 | + } |
| 35 | + }, |
| 36 | + showNotify: true, // add email notices as an option for each award of this type |
| 37 | + icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' // icon for left-side menu |
| 38 | + }, |
| 39 | + 'cats': { |
| 40 | + name: 'Cat', |
| 41 | + fields: [ 'header' ], |
| 42 | + header: 'A kitten for you!', |
| 43 | + text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename |
| 44 | + gallery: { |
| 45 | + // right now we can only query the local wiki (not e.g. commons) |
| 46 | + category: 'Category:Cats', |
| 47 | + total: 100, // total number of pictures to retrieve, and to randomise |
| 48 | + num: 3, // number of pictures to show from the randomised set |
| 49 | + width: 145 // width of each picture in pixels in the interface (not in the template) |
| 50 | + } |
| 51 | + }, |
| 52 | + // default type, nice to leave this one in place when adding other types |
| 53 | + 'makeyourown': { |
| 54 | + name: mw.msg( 'wikilove-type-makeyourown' ), |
| 55 | + fields: [ 'header', 'title', 'image' ], |
| 56 | + imageSize: '150px' |
| 57 | + } |
| 58 | +} |
\ No newline at end of file |
Index: trunk/extensions/WikiLove/wikiLove.js |
— | — | @@ -1,51 +1,5 @@ |
2 | 2 | ( function( $ ) { $.wikiLove = { |
3 | | - types: { |
4 | | - // example type, could be removed later (also no i18n) |
5 | | - 'barnstar': { |
6 | | - descr: 'Barnstar', // description in the types menu |
7 | | - select: 'Select a barnstar:', // subtype select label |
8 | | - subtypes: { // some different subtypes |
9 | | - // note that when not using subtypes you should use these subtype options |
10 | | - // for the top-level type |
11 | | - 'original': { |
12 | | - title: 'An Original Barnstar for you!', // subject title for the message |
13 | | - descr: 'Original barnstar', // description in the menu |
14 | | - text: '{{subst:The Original Barnstar|$1 ~~~~}}', // message text, $1 is replaced by the user message |
15 | | - template: 'The Original Barnstar', // template that is used, for statistics |
16 | | - mail: 'Hello $2!\n\nI just awarded you a barnstar.' // message to use in email notification; $2 is replaced by the recipient's username |
17 | | - }, |
18 | | - 'special': { |
19 | | - title: null, // no predefined title, allows the user to enter a title |
20 | | - descr: 'Special barnstar', |
21 | | - text: '{{subst:The Special Barnstarl|$1 ~~~~}}', |
22 | | - template: 'The Special Barnstar', |
23 | | - mail: 'Hello $2!\n\nI just awarded you the special barnstar.' |
24 | | - } |
25 | | - }, |
26 | | - showNotify: true, // add email notices as an option for each award of this type |
27 | | - icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' |
28 | | - }, |
29 | | - 'cat': { |
30 | | - descr: 'Cat', |
31 | | - title: null, |
32 | | - text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename |
33 | | - template: '', |
34 | | - gallery: { |
35 | | - // right now we can only query the local wiki (not e.g. commons) |
36 | | - category: 'Category:Cats', |
37 | | - total: 100, // total number of pictures to retrieve, and to randomise |
38 | | - num: 3, // number of pictures to show from the randomised set |
39 | | - width: 145 // width of each picture in pixels in the interface (not in the template) |
40 | | - } |
41 | | - }, |
42 | | - // default type, nice to leave this one in place when adding other types |
43 | | - 'makeyourown': { |
44 | | - title: null, |
45 | | - descr: mw.msg( 'wikilove-type-makeyourown' ), |
46 | | - text: "$1", |
47 | | - template: '' |
48 | | - } |
49 | | - }, |
| 3 | + |
50 | 4 | $dialog: null, // dialog jQuery object |
51 | 5 | editToken: '', // edit token used for the final AJAX call |
52 | 6 | currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown') |
— | — | @@ -54,7 +8,15 @@ |
55 | 9 | previewData: null, // data of the currently previewed thing is set here |
56 | 10 | emailable: false, |
57 | 11 | gallery: {}, |
58 | | - imageTitle: '', |
| 12 | + defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\ |
| 13 | +|rowspan="2" style="vertical-align: middle; padding: 5px;" | [[Image:$3|$4]]\n\ |
| 14 | +|style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\ |
| 15 | +|-\n\ |
| 16 | +|style="vertical-align: middle; padding: 3px;" | $1 ~~~~\n\ |
| 17 | +|}', |
| 18 | + defaultBackgroundColor: '#fdffe7', |
| 19 | + defaultBorderColor: '#fceb92', |
| 20 | + defaultImageSize: '100px', |
59 | 21 | |
60 | 22 | /* |
61 | 23 | * Opens the dialog and builds it if necessary. |
— | — | @@ -62,8 +24,8 @@ |
63 | 25 | openDialog: function() { |
64 | 26 | if ( $.wikiLove.$dialog === null ) { |
65 | 27 | // Load local configuration |
66 | | - var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } ); |
67 | | - mw.loader.load( wikiLoveConfigUrl ); |
| 28 | + //var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } ); |
| 29 | + //mw.loader.load( wikiLoveConfigUrl ); |
68 | 30 | |
69 | 31 | // Find out if we can email the user |
70 | 32 | $.wikiLove.getEmailable(); |
— | — | @@ -86,7 +48,7 @@ |
87 | 49 | $buttonInside.addClass( 'wlNoIcon' ); |
88 | 50 | } |
89 | 51 | |
90 | | - $buttonInside.append( '<div class="wlLinkText">' + $.wikiLove.types[typeId].descr + '</div>' ); |
| 52 | + $buttonInside.append( '<div class="wlLinkText">' + $.wikiLove.types[typeId].name + '</div>' ); |
91 | 53 | |
92 | 54 | $button.append( '<div class="wlLeftCap"></div>'); |
93 | 55 | $button.append( $buttonInside ); |
— | — | @@ -113,16 +75,21 @@ |
114 | 76 | var $addDetails = $( '<div id="wlAddDetails"></div>' ) |
115 | 77 | .append( '<span class="wlNumber">2</span>' ) |
116 | 78 | .append( '<h3>' + mw.msg( 'wikilove-add-details' ) + '</h3>' ) |
117 | | - .append( '<label for="wlSubtype" id="wlSubtypeLabel"></label>' ) |
118 | 79 | .append( $( '<form id="wlPreviewForm"></form>' ) |
| 80 | + .append( '<label for="wlSubtype" id="wlSubtypeLabel"></label>' ) |
119 | 81 | .append( '<select id="wlSubtype"></select>' ) |
120 | | - .append( '<label id="wlGalleryLabel">' + mw.msg( 'wikilove-gallery' ) + '</label>' ) |
| 82 | + .append( '<div id="wlSubtypeDescription"/>' ) |
| 83 | + .append( '<label id="wlGalleryLabel">' + mw.msg( 'wikilove-image' ) + '</label>' ) |
121 | 84 | .append( '<div id="wlGallerySpinner">' + spinner + '</div>' ) |
122 | 85 | .append( '<div id="wlGallery"/>' ) |
123 | | - .append( '<label for="wlTitle" id="wlTitleLabel">' + mw.msg( 'wikilove-title' ) + '</label>' ) |
| 86 | + .append( '<label for="wlHeader" id="wlHeaderLabel">' + mw.msg( 'wikilove-header' ) + '</label>' ) |
| 87 | + .append( '<input type="text" class="text" id="wlHeader"/>' ) |
| 88 | + .append( '<label for="wlTitle" id="wlTitleLabel">' + mw.msg( 'wikilove-title' ) + '</label>' ) |
124 | 89 | .append( '<input type="text" class="text" id="wlTitle"/>' ) |
125 | | - .append( '<label for="wlMessage" id="wlMessageLabel">' + mw.msg( 'wikilove-enter-message' ) + '</label>' ) |
126 | | - .append( '<span class="wlOmitSig">' + mw.msg( 'wikilove-omit-sig' ) + '</span>' ) |
| 90 | + .append( '<label for="wlImage" id="wlImageLabel">' + mw.msg( 'wikilove-image' ) + '</label>' ) |
| 91 | + .append( '<input type="text" class="text" id="wlImage"/>' ) |
| 92 | + .append( '<label for="wlMessage" id="wlMessageLabel">' + mw.msg( 'wikilove-enter-message' ) + '</label>' ) |
| 93 | + .append( '<span class="wlNote">' + mw.msg( 'wikilove-omit-sig' ) + '</span>' ) |
127 | 94 | .append( '<textarea id="wlMessage"></textarea>' ) |
128 | 95 | .append( $('<div id="wlNotify"></div>').html('<input type="checkbox" id="wlNotifyCheckbox" name="notify"/> <label for="wlNotifyCheckbox">Notify user by email</label>') ) |
129 | 96 | .append( $('<button class="submit" id="wlButtonPreview" type="submit"></button>').button({ label: mw.msg( 'wikilove-button-preview' ), icons: { primary:'ui-icon-search' } }) ) |
— | — | @@ -149,6 +116,7 @@ |
150 | 117 | .append( $preview ) |
151 | 118 | .dialog({ |
152 | 119 | width: 800, |
| 120 | + position: ['center', 80], |
153 | 121 | autoOpen: false, |
154 | 122 | title: mw.msg( 'wikilove-dialog-title' ), |
155 | 123 | modal: true, |
— | — | @@ -190,7 +158,7 @@ |
191 | 159 | // add all the subtypes to the menu while setting their subtype ids in jQuery data |
192 | 160 | var subtype = $.wikiLove.types[$.wikiLove.currentTypeId].subtypes[subtypeId]; |
193 | 161 | $( '#wlSubtype' ).append( |
194 | | - $( '<option>' + subtype.descr + '</option>' ).data( 'subtypeId', subtypeId ) |
| 162 | + $( '<option>' + subtype.option + '</option>' ).data( 'subtypeId', subtypeId ) |
195 | 163 | ); |
196 | 164 | } |
197 | 165 | $( '#wlSubtype' ).show(); |
— | — | @@ -225,6 +193,7 @@ |
226 | 194 | $.wikiLove.currentSubtypeId = newSubtypeId; |
227 | 195 | $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId] |
228 | 196 | .subtypes[$.wikiLove.currentSubtypeId]; |
| 197 | + $( '#wlSubtypeDescription' ).html( $.wikiLove.currentTypeOrSubtype.descr ); |
229 | 198 | $.wikiLove.updateAllDetails(); |
230 | 199 | $( '#wlPreview' ).hide(); |
231 | 200 | $.wikiLove.previewData = null; |
— | — | @@ -259,30 +228,64 @@ |
260 | 229 | }, |
261 | 230 | |
262 | 231 | /* |
263 | | - * Called when type or subtype changes, updates controls. Currently only updates title label and textbox. |
| 232 | + * Called when type or subtype changes, updates controls. |
264 | 233 | */ |
265 | 234 | updateAllDetails: function() { |
266 | 235 | $( '#wikiLoveDialog' ).find( '.wlError' ).remove(); |
267 | 236 | |
| 237 | + // only show the description if it exists for this type or subtype |
| 238 | + if( typeof $.wikiLove.currentTypeOrSubtype.descr == 'string' ) { |
| 239 | + $( '#wlSubtypeDescription').show(); |
| 240 | + } else { |
| 241 | + $( '#wlSubtypeDescription').hide(); |
| 242 | + } |
| 243 | + |
| 244 | + // show or hide header label and textbox depending on whether a predefined header exists |
| 245 | + var needsHeader = $.inArray( 'header', $.wikiLove.types[$.wikiLove.currentTypeId].fields ); |
| 246 | + if( typeof $.wikiLove.currentTypeOrSubtype.header == 'string' || needsHeader == -1 ) { |
| 247 | + $( '#wlHeaderLabel').hide(); |
| 248 | + $( '#wlHeader' ).hide(); |
| 249 | + $( '#wlHeader' ).val( $.wikiLove.currentTypeOrSubtype.header ); |
| 250 | + } else if ( needsHeader != -1 ) { |
| 251 | + $( '#wlHeaderLabel').show(); |
| 252 | + $( '#wlHeader' ).show(); |
| 253 | + $( '#wlHeader' ).val( '' ); |
| 254 | + } |
| 255 | + |
268 | 256 | // show or hide title label and textbox depending on whether a predefined title exists |
269 | | - if( typeof $.wikiLove.currentTypeOrSubtype.title == 'string' ) { |
| 257 | + var needsTitle = $.inArray( 'title', $.wikiLove.types[$.wikiLove.currentTypeId].fields ); |
| 258 | + if( typeof $.wikiLove.currentTypeOrSubtype.title == 'string' || needsTitle == -1 ) { |
270 | 259 | $( '#wlTitleLabel').hide(); |
271 | 260 | $( '#wlTitle' ).hide(); |
272 | 261 | $( '#wlTitle' ).val( $.wikiLove.currentTypeOrSubtype.title ); |
273 | | - } else { |
| 262 | + } else if ( needsTitle != -1 ) { |
274 | 263 | $( '#wlTitleLabel').show(); |
275 | 264 | $( '#wlTitle' ).show(); |
276 | 265 | $( '#wlTitle' ).val( '' ); |
277 | 266 | } |
278 | 267 | |
| 268 | + // show or hide image label and textbox depending on whether a predefined image exists |
| 269 | + var needsTitle = $.inArray( 'image', $.wikiLove.types[$.wikiLove.currentTypeId].fields ); |
| 270 | + if( typeof $.wikiLove.currentTypeOrSubtype.image == 'string' || needsTitle == -1 ) { |
| 271 | + $( '#wlImageLabel').hide(); |
| 272 | + $( '#wlImage' ).hide(); |
| 273 | + $( '#wlImage' ).val( $.wikiLove.currentTypeOrSubtype.image ); |
| 274 | + } else if ( needsTitle != -1 ) { |
| 275 | + $( '#wlImageLabel').show(); |
| 276 | + $( '#wlImage' ).show(); |
| 277 | + $( '#wlImage' ).val( '' ); |
| 278 | + } |
| 279 | + |
279 | 280 | if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) { |
280 | 281 | $( '#wlGalleryLabel' ).show(); |
281 | 282 | $( '#wlGallery' ).show(); |
| 283 | + $( '#wlGallerySpinner' ).show(); |
282 | 284 | $.wikiLove.makeGallery(); |
283 | 285 | } |
284 | 286 | else { |
285 | 287 | $( '#wlGalleryLabel' ).hide(); |
286 | 288 | $( '#wlGallery' ).hide(); |
| 289 | + $( '#wlGallerySpinner' ).hide(); |
287 | 290 | } |
288 | 291 | |
289 | 292 | if( $.wikiLove.types[$.wikiLove.currentTypeId].showNotify ) { |
— | — | @@ -302,12 +305,12 @@ |
303 | 306 | $( '#wikiLoveDialog' ).find( '.wlError' ).remove(); |
304 | 307 | |
305 | 308 | if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) { |
306 | | - if ( !$.wikiLove.imageTitle ) { |
| 309 | + if ( $( '#wlImage' ).val().length <= 0 ) { |
307 | 310 | $.wikiLove.showError( 'wikilove-err-image' ); return false; |
308 | 311 | } |
309 | 312 | } |
310 | | - if( $( '#wlTitle' ).val().length <= 0 ) { |
311 | | - $.wikiLove.showError( 'wikilove-err-title' ); return false; |
| 313 | + if( $( '#wlHeader' ).val().length <= 0 ) { |
| 314 | + $.wikiLove.showError( 'wikilove-err-header' ); return false; |
312 | 315 | } |
313 | 316 | if( $( '#wlMessage' ).val().length <= 0 ) { |
314 | 317 | $.wikiLove.showError( 'wikilove-err-msg' ); return false; |
— | — | @@ -318,15 +321,24 @@ |
319 | 322 | $.wikiLove.showError( 'wikilove-err-sig' ); return false; |
320 | 323 | } |
321 | 324 | |
322 | | - var msg = $.wikiLove.prepareMsg( $.wikiLove.currentTypeOrSubtype.text ); |
| 325 | + if ( $.wikiLove.currentTypeOrSubtype.text ) { |
| 326 | + var text = $.wikiLove.currentTypeOrSubtype.text; |
| 327 | + } else { |
| 328 | + var text = $.wikiLove.defaultText; |
| 329 | + } |
| 330 | + var msg = $.wikiLove.prepareMsg( |
| 331 | + text, |
| 332 | + $.wikiLove.currentTypeOrSubtype.imageSize, |
| 333 | + $.wikiLove.currentTypeOrSubtype.backgroundColor, |
| 334 | + $.wikiLove.currentTypeOrSubtype.borderColor |
| 335 | + ); |
323 | 336 | |
324 | | - $.wikiLove.doPreview( '==' + $( '#wlTitle' ).val() + "==\n" + msg ); |
| 337 | + $.wikiLove.doPreview( '==' + $( '#wlHeader' ).val() + "==\n" + msg ); |
325 | 338 | $.wikiLove.previewData = { |
326 | | - 'title': $( '#wlTitle' ).val(), |
| 339 | + 'header': $( '#wlHeader' ).val(), |
327 | 340 | 'msg': msg, |
328 | 341 | 'type': $.wikiLove.currentTypeId |
329 | 342 | + ($.wikiLove.currentSubtypeId != null ? '-' + $.wikiLove.currentSubtypeId : ''), |
330 | | - 'template': $.wikiLove.currentTypeOrSubtype.template, |
331 | 343 | 'notify': $( '#wlNotifyCheckbox:checked' ).val() |
332 | 344 | }; |
333 | 345 | return false; |
— | — | @@ -339,21 +351,40 @@ |
340 | 352 | /* |
341 | 353 | * Prepares a message or e-mail body by replacing placeholders. |
342 | 354 | * $1: message entered by the user |
343 | | - * $2: username of the recipient |
344 | | - * $3: title of the chosen image |
| 355 | + * $2: title of the item |
| 356 | + * $3: title of the image |
| 357 | + * $4: image size |
| 358 | + * $5: background color |
| 359 | + * $6: border color |
| 360 | + * $7: username of the recipient |
345 | 361 | */ |
346 | | - prepareMsg: function( msg ) { |
347 | | - // replace the raw message |
348 | | - msg = msg.replace( '$1', $( '#wlMessage' ).val() ); |
| 362 | + prepareMsg: function( msg, imageSize, backgroundColor, borderColor ) { |
349 | 363 | |
350 | | - // replace the username we're sending to |
351 | | - msg = msg.replace( '$2', wgTitle ); |
| 364 | + msg = msg.replace( '$1', $( '#wlMessage' ).val() ); // replace the raw message |
| 365 | + msg = msg.replace( '$2', $( '#wlTitle' ).val() ); // replace the title |
| 366 | + msg = msg.replace( '$3', $( '#wlImage' ).val() ); // replace the image |
352 | 367 | |
353 | | - // replace the image filename |
354 | | - if ( $.wikiLove.imageTitle ) { |
355 | | - msg = msg.replace( '$3', $.wikiLove.imageTitle ); |
| 368 | + if ( imageSize ) { |
| 369 | + var myImageSize = imageSize; |
| 370 | + } else { |
| 371 | + var myImageSize = $.wikiLove.defaultImageSize; |
356 | 372 | } |
| 373 | + if ( backgroundColor ) { |
| 374 | + var myBackgroundColor = backgroundColor; |
| 375 | + } else { |
| 376 | + var myBackgroundColor = $.wikiLove.defaultBackgroundColor; |
| 377 | + } |
| 378 | + if ( borderColor ) { |
| 379 | + var myBorderColor = borderColor; |
| 380 | + } else { |
| 381 | + var myBorderColor = $.wikiLove.defaultBorderColor; |
| 382 | + } |
| 383 | + msg = msg.replace( '$4', myImageSize ); // replace the image size |
| 384 | + msg = msg.replace( '$5', myBackgroundColor ); // replace the background color |
| 385 | + msg = msg.replace( '$6', myBorderColor ); // replace the border color |
357 | 386 | |
| 387 | + msg = msg.replace( '$7', wgTitle ); // replace the username we're sending to |
| 388 | + |
358 | 389 | return msg; |
359 | 390 | }, |
360 | 391 | |
— | — | @@ -395,15 +426,15 @@ |
396 | 427 | */ |
397 | 428 | submitSend: function( e ) { |
398 | 429 | e.preventDefault(); |
399 | | - $.wikiLove.doSend( $.wikiLove.previewData.title, $.wikiLove.previewData.msg, |
400 | | - $.wikiLove.previewData.type, $.wikiLove.previewData.template, $.wikiLove.previewData.notify ); |
| 430 | + $.wikiLove.doSend( $.wikiLove.previewData.header, $.wikiLove.previewData.msg, |
| 431 | + $.wikiLove.previewData.type, $.wikiLove.previewData.notify ); |
401 | 432 | return false; |
402 | 433 | }, |
403 | 434 | |
404 | 435 | /* |
405 | 436 | * Fires the final AJAX request and then redirects to the talk page where the content is added. |
406 | 437 | */ |
407 | | - doSend: function( subject, wikitext, type, template, notify ) { |
| 438 | + doSend: function( subject, wikitext, type, notify ) { |
408 | 439 | $( '#wlPreview .wlSpinner' ).fadeIn( 200 ); |
409 | 440 | $.ajax({ |
410 | 441 | url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?', |
— | — | @@ -411,7 +442,6 @@ |
412 | 443 | 'action': 'wikiLove', |
413 | 444 | 'format': 'json', |
414 | 445 | 'title': mw.config.get( 'wgPageName' ), |
415 | | - 'template': template, |
416 | 446 | 'type': type, |
417 | 447 | 'text': wikitext, |
418 | 448 | 'subject': subject, |
— | — | @@ -505,9 +535,8 @@ |
506 | 536 | .attr( 'src', page.imageinfo[0].url ) |
507 | 537 | .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width ) |
508 | 538 | .hide() |
509 | | - .load( function() { $( this ).fadeIn( 400 ); } ); |
| 539 | + .load( function() { $( this ).css( 'display', 'inline-block' ); } ); |
510 | 540 | |
511 | | - |
512 | 541 | // append the image to the gallery and also make sure it's selectable |
513 | 542 | $( '#wlGallery' ).append( |
514 | 543 | $( '<a href="#"></a>' ) |
— | — | @@ -517,7 +546,7 @@ |
518 | 547 | e.preventDefault(); |
519 | 548 | $( '#wlGallery a' ).removeClass( 'selected' ); |
520 | 549 | $( this ).addClass( 'selected' ); |
521 | | - $.wikiLove.imageTitle = $.wikiLove.gallery[$( this ).attr( 'id' )]; |
| 550 | + $( '#wlImage' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] ); |
522 | 551 | return false; |
523 | 552 | }) |
524 | 553 | ); |
Index: trunk/extensions/WikiLove/WikiLove.api.php |
— | — | @@ -15,10 +15,6 @@ |
16 | 16 | $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); |
17 | 17 | } |
18 | 18 | |
19 | | - if ( strlen( $params['template'] ) > 0 && stripos( $params['text'], $params['template'] ) === false ) { |
20 | | - $this->dieUsage( 'Template could not be found in the message!', 'invalidtemplate' ); |
21 | | - } |
22 | | - |
23 | 19 | if ( $wgWikiLoveLogging ) { |
24 | 20 | $this->saveInDb( $talk, $params['subject'], $params['text'], $params['type'], $params['template'] ); |
25 | 21 | } |
— | — | @@ -48,7 +44,6 @@ |
49 | 45 | * @param $subject |
50 | 46 | * @param $text |
51 | 47 | * @param $type |
52 | | - * @param $template |
53 | 48 | * @return void |
54 | 49 | */ |
55 | 50 | private function saveInDb( $talk, $subject, $text, $type, $template ) { |
— | — | @@ -59,7 +54,6 @@ |
60 | 55 | 'wl_sender_id' => $wgUser->getId(), |
61 | 56 | 'wl_receiver_id' => User::newFromName( $talk->getSubjectPage()->getBaseText() )->getId(), |
62 | 57 | 'wl_type' => $type, |
63 | | - 'wl_template' => $template, |
64 | 58 | 'wl_subject' => $subject, |
65 | 59 | 'wl_message' => $text, |
66 | 60 | 'wl_email' => 0, |
— | — | @@ -90,9 +84,6 @@ |
91 | 85 | ApiBase::PARAM_TYPE => 'string', |
92 | 86 | ApiBase::PARAM_REQUIRED => true, |
93 | 87 | ), |
94 | | - 'template' => array( |
95 | | - ApiBase::PARAM_TYPE => 'string', |
96 | | - ), |
97 | 88 | 'type' => array( |
98 | 89 | ApiBase::PARAM_TYPE => 'string', |
99 | 90 | ), |
— | — | @@ -102,10 +93,9 @@ |
103 | 94 | public function getParamDescription() { |
104 | 95 | return array( |
105 | 96 | 'title' => 'Title of the user or user talk page to send WikiLove to', |
106 | | - 'text' => 'Raw ikitext to add in the new section', |
| 97 | + 'text' => 'Raw wikitext to add in the new section', |
107 | 98 | 'token' => 'Edit token. You can get one of these through prop=info', |
108 | 99 | 'subject' => 'Subject header of the new section', |
109 | | - 'template' => 'Template name used in the wikitext (for statistics)', |
110 | 100 | 'type' => array( 'Type of WikiLove (for statistics); this corresponds with a type', |
111 | 101 | 'selected in the left menu, and optionally a subtype after that', |
112 | 102 | '(e.g. "barnstar-normal" or "kitten")', |
— | — | @@ -117,9 +107,9 @@ |
118 | 108 | return array( |
119 | 109 | 'Give WikiLove to another user.', |
120 | 110 | "WikiLove is a positive message posted to a user's talk page through a", |
121 | | - 'convenient interface with preset images and templates. This action adds', |
122 | | - 'the specified wikitext to a certain talk page. For statistical purposes,', |
123 | | - 'the type and template (among the other data) are logged.', |
| 111 | + 'convenient interface with preset or locally defined templates. This action', |
| 112 | + 'adds the specified wikitext to a certain talk page. For statistical purposes,', |
| 113 | + 'the type and other data are logged.', |
124 | 114 | ); |
125 | 115 | } |
126 | 116 | |
— | — | @@ -130,10 +120,6 @@ |
131 | 121 | 'code' => 'nologging', |
132 | 122 | 'info' => 'Warning: action was not logged!' |
133 | 123 | ), |
134 | | - array( |
135 | | - 'code' => 'invalidtemplate', |
136 | | - 'info' => 'Template could not be found in the message!' |
137 | | - ), |
138 | 124 | ) ); |
139 | 125 | } |
140 | 126 | |
Index: trunk/extensions/WikiLove/patches/WikiLoveLog.sql |
— | — | @@ -9,7 +9,6 @@ |
10 | 10 | `wl_sender_id` int(11) NOT NULL, |
11 | 11 | `wl_receiver_id` int(11) NOT NULL, |
12 | 12 | `wl_type` varchar(64) NOT NULL, |
13 | | - `wl_template` varchar(64) NOT NULL, |
14 | 13 | `wl_subject` varchar(255) NOT NULL, |
15 | 14 | `wl_message` blob NOT NULL, |
16 | 15 | `wl_email` bool NOT NULL default '0' |