Index: trunk/extensions/WikiLove/wikiLove.css |
— | — | @@ -231,6 +231,7 @@ |
232 | 232 | #wikiLoveDialog #wlAddDetails { |
233 | 233 | float: right; |
234 | 234 | width: 480px; |
| 235 | + margin-bottom: 5px; |
235 | 236 | } |
236 | 237 | |
237 | 238 | #wikiLoveDialog #wlAddDetails label { |
— | — | @@ -346,5 +347,13 @@ |
347 | 348 | } |
348 | 349 | |
349 | 350 | #wikiLoveDialog .wlError { |
| 351 | + /* @embed */ |
| 352 | + background-image: url(images/alert.png); |
| 353 | + background-position: center left; |
| 354 | + background-repeat: no-repeat; |
350 | 355 | color: red; |
| 356 | + font-weight: bold; |
| 357 | + line-height: 32px; |
| 358 | + padding-left: 34px; |
| 359 | + padding-bottom: 3px; |
351 | 360 | } |
Index: trunk/extensions/WikiLove/wikiLove.js |
— | — | @@ -29,11 +29,11 @@ |
30 | 30 | 'cat': { |
31 | 31 | descr: 'Cat', |
32 | 32 | title: null, |
33 | | - text: "[[$3|left|150px]]\n$1\n\n~~~~", // $3 is the image filename |
| 33 | + text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename |
34 | 34 | template: '', |
35 | 35 | gallery: { |
36 | 36 | // right now we can only query the local wiki (not e.g. commons) |
37 | | - category: 'Category:Tropical', |
| 37 | + category: 'Category:Cat', |
38 | 38 | total: 100, // total number of pictures to retrieve, and to randomise |
39 | 39 | num: 3, // number of pictures to show from the randomised set |
40 | 40 | width: 150 // width of each picture in pixels in the interface (not in the template) |
— | — | @@ -144,7 +144,7 @@ |
145 | 145 | .append( '<label for="wlMessage" id="wlMessageLabel">' + mw.msg( 'wikilove-enter-message' ) + '</label>' ) |
146 | 146 | .append( '<span class="wlOmitSig">' + mw.msg( 'wikilove-omit-sig' ) + '</span>' ) |
147 | 147 | .append( '<textarea id="wlMessage"></textarea>' ) |
148 | | - .append( $('<div id="wlNotify"></div>').html('<input type="checkbox" id="wlNotifyCheckbox" name="notify"/> Notify user by email') ) |
| 148 | + .append( $('<div id="wlNotify"></div>').html('<input type="checkbox" id="wlNotifyCheckbox" name="notify"/> <label for="wlNotifyCheckbox">Notify user by email</label>') ) |
149 | 149 | .append( '<input id="wlButtonPreview" class="submit" type="submit" value="' |
150 | 150 | + mw.msg( 'wikilove-button-preview' ) + '"/>' ) |
151 | 151 | .append( '<img class="wlSpinner" src="' + mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) |
— | — | @@ -292,6 +292,8 @@ |
293 | 293 | * Called when type or subtype changes, updates controls. Currently only updates title label and textbox. |
294 | 294 | */ |
295 | 295 | updateAllDetails: function() { |
| 296 | + $( '#wikiLoveDialog' ).find( '.wlError' ).remove(); |
| 297 | + |
296 | 298 | // show or hide title label and textbox depending on whether a predefined title exists |
297 | 299 | if( typeof $.wikiLove.currentTypeOrSubtype.title == 'string' ) { |
298 | 300 | $( '#wlTitleLabel').hide(); |
— | — | @@ -326,26 +328,27 @@ |
327 | 329 | */ |
328 | 330 | submitPreview: function( e ) { |
329 | 331 | e.preventDefault(); |
| 332 | + $( '#wlPreview' ).hide(); |
| 333 | + $( '#wikiLoveDialog' ).find( '.wlError' ).remove(); |
| 334 | + |
| 335 | + if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) { |
| 336 | + if ( !$.wikiLove.imageTitle ) { |
| 337 | + $.wikiLove.showError( 'wikilove-err-image' ); return false; |
| 338 | + } |
| 339 | + } |
330 | 340 | if( $( '#wlTitle' ).val().length <= 0 ) { |
331 | 341 | $.wikiLove.showError( 'wikilove-err-title' ); return false; |
332 | 342 | } |
333 | 343 | if( $( '#wlMessage' ).val().length <= 0 ) { |
334 | 344 | $.wikiLove.showError( 'wikilove-err-msg' ); return false; |
335 | 345 | } |
336 | | - if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) { |
337 | | - if ( !$.wikiLove.imageTitle ) { |
338 | | - $.wikiLove.showError( 'wikilove-err-img' ); return false; |
339 | | - } |
340 | | - } |
341 | 346 | |
342 | | - var rawMessage = $( '#wlMessage' ).val(); |
343 | | - |
344 | 347 | // If there isn't a signature already in the message, throw an error |
345 | | - if ( rawMessage.indexOf( '~~~' ) >= 0 ) { |
| 348 | + if ( $( '#wlMessage' ).val().indexOf( '~~~' ) >= 0 ) { |
346 | 349 | $.wikiLove.showError( 'wikilove-err-sig' ); return false; |
347 | 350 | } |
348 | 351 | |
349 | | - var msg = $.wikiLove.prepareMsg( rawMessage ); |
| 352 | + var msg = $.wikiLove.prepareMsg( $.wikiLove.currentTypeOrSubtype.text ); |
350 | 353 | |
351 | 354 | $.wikiLove.doPreview( '==' + $( '#wlTitle' ).val() + "==\n" + msg ); |
352 | 355 | $.wikiLove.previewData = { |
— | — | @@ -360,7 +363,7 @@ |
361 | 364 | }, |
362 | 365 | |
363 | 366 | showError: function( errmsg ) { |
364 | | - $.wikiLove.showPreview( mw.msg( errmsg ) ); |
| 367 | + $( '#wlAddDetails' ).append( $( '<div class="wlError"></div>' ).html( mw.msg( errmsg ) ) ); |
365 | 368 | }, |
366 | 369 | |
367 | 370 | /* |
— | — | @@ -447,9 +450,6 @@ |
448 | 451 | dataType: 'json', |
449 | 452 | type: 'POST', |
450 | 453 | success: function( data ) { |
451 | | - mw.log( data ); |
452 | | - mw.log( 'wgPageName: ' + mw.config.get( 'wgPageName' ) ); |
453 | | - |
454 | 454 | if ( notify && $.wikiLove.emailable ) { |
455 | 455 | $.wikiLove.sendEmail( |
456 | 456 | $.wikiLove.currentTypeOrSubtype.title, |
— | — | @@ -459,6 +459,11 @@ |
460 | 460 | |
461 | 461 | $( '#wlPreview .wlSpinner' ).fadeOut( 200 ); |
462 | 462 | |
| 463 | + if ( typeof data.error !== 'undefined' ) { |
| 464 | + $( '#wlPreview' ).append( '<div class="wlError">' + data.error.info + '<div>' ); |
| 465 | + return; |
| 466 | + } |
| 467 | + |
463 | 468 | if ( typeof data.redirect !== 'undefined' |
464 | 469 | && data.redirect.pageName == mw.config.get( 'wgPageName' ) ) { |
465 | 470 | // unfortunately, when on the talk page we cannot reload and then |
— | — | @@ -466,10 +471,6 @@ |
467 | 472 | // the page won't reload... |
468 | 473 | window.location.reload(); |
469 | 474 | } |
470 | | - else if ( typeof data.error !== 'undefined' ) { |
471 | | - $( '<div class="wlError">' + data.error.info + '<div>' ).insertBefore( '#wlSendForm' ); |
472 | | - window.location.reload(); |
473 | | - } |
474 | 475 | else { |
475 | 476 | window.location = mw.config.get( 'wgArticlePath' ).replace('$1', data.redirect.pageName) |
476 | 477 | + data.redirect.fragment; |