r90955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90954‎ | r90955 | r90956 >
Date:13:28, 28 June 2011
Author:janpaul123
Status:resolved
Tags:
Comment:
Added functionality to disable the sending of WikiLove when the input has changed, per user test and comments.
Modified paths:
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
@@ -130,6 +130,16 @@
131131 $( '#mw-wikilove-preview-form' ).submit( $.wikiLove.validatePreviewForm );
132132 $( '#mw-wikilove-send-form' ).click( $.wikiLove.submitSend );
133133 $( '#mw-wikilove-message' ).elastic(); // have the message textarea grow automatically
 134+
 135+ // when the input changes, we want to disable the send button
 136+ $( '#mw-wikilove-header' ).change( $.wikiLove.changeInput );
 137+ $( '#mw-wikilove-header' ).keyup( $.wikiLove.changeInput );
 138+ $( '#mw-wikilove-title' ).change( $.wikiLove.changeInput );
 139+ $( '#mw-wikilove-title' ).keyup( $.wikiLove.changeInput );
 140+ $( '#mw-wikilove-image' ).change( $.wikiLove.changeInput );
 141+ $( '#mw-wikilove-image' ).keyup( $.wikiLove.changeInput );
 142+ $( '#mw-wikilove-message' ).change( $.wikiLove.changeInput );
 143+ $( '#mw-wikilove-message' ).keyup( $.wikiLove.changeInput );
134144 }
135145
136146 $dialog.dialog( 'open' );
@@ -350,6 +360,8 @@
351361 'header': $( '#mw-wikilove-header' ).val(),
352362 'text': text,
353363 'message': $( '#mw-wikilove-message' ).val(),
 364+ 'title': $( '#mw-wikilove-title' ).val(),
 365+ 'image': $( '#mw-wikilove-image' ).val(),
354366 'type': currentTypeId
355367 + (currentSubtypeId !== null ? '-' + currentSubtypeId : '')
356368 };
@@ -423,21 +435,41 @@
424436
425437 /*
426438 * Callback for the preview function. Sets the preview area with the HTML and fades it in.
 439+ * It also (re-)enables the send button.
427440 */
428441 showPreview: function( html ) {
429442 $( '#mw-wikilove-preview-area' ).html( html );
430443 $( '#mw-wikilove-preview' ).fadeIn( 200 );
 444+ $( '#mw-wikilove-button-send' ).button( 'enable' );
431445 },
432446
 447+ changeInput: function() {
 448+ if( previewData !== null &&
 449+ ( previewData.message != $( '#mw-wikilove-message' ).val()
 450+ || previewData.title != $( '#mw-wikilove-title' ).val()
 451+ || previewData.header != $( '#mw-wikilove-header' ).val()
 452+ || previewData.image != $( '#mw-wikilove-image' ).val()
 453+ )) {
 454+ $( '#mw-wikilove-button-send' ).button( 'disable' );
 455+ }
 456+ else {
 457+ $( '#mw-wikilove-button-send' ).button( 'enable' );
 458+ }
 459+ },
 460+
433461 /*
434462 * Handler for the send (final submit) button.
435463 * The type sent for statistics is 'typeId-subtypeId' when using subtypes,
436464 * or simply 'typeId' otherwise.
437465 */
438466 submitSend: function( e ) {
439 - e.preventDefault();
440 - $.wikiLove.doSend( previewData.header, previewData.text,
441 - previewData.message, previewData.type, previewData.email );
 467+ $( '#mw-wikilove-dialog' ).find( '.mw-wikilove-error' ).remove();
 468+
 469+ if( !$( '#mw-wikilove-button-send' ).button( 'option', 'disabled' ) ) {
 470+ e.preventDefault();
 471+ $.wikiLove.doSend( previewData.header, previewData.text,
 472+ previewData.message, previewData.type, previewData.email );
 473+ }
442474 },
443475
444476 /*
@@ -565,6 +597,7 @@
566598 $( '#mw-wikilove-gallery a' ).removeClass( 'selected' );
567599 $( this ).addClass( 'selected' );
568600 $( '#mw-wikilove-image' ).val( gallery[$( this ).attr( 'id' )] );
 601+ $.wikiLove.changeInput();
569602 })
570603 );
571604 gallery['mw-wikilove-gallery-img-' + index] = page.title;

Follow-up revisions

RevisionCommit summaryAuthorDate
r91041partial revert of r90955 - Erik wants us to do this differently - implementin...kaldari01:31, 29 June 2011

Status & tagging log