Matthias Mullie has uploaded a new change for review. https://gerrit.wikimedia.org/r/83035
Change subject: Slightly better abide to MW jshint & coding standards ...................................................................... Slightly better abide to MW jshint & coding standards Change-Id: I4df027cf04659a9add142236f35efe9e64a6212e --- M modules/base/ext.flow.base.js M modules/discussion/forms.js M modules/discussion/init.js M modules/discussion/paging.js M modules/discussion/ui-functions.js M modules/discussion/ui.js 6 files changed, 233 insertions(+), 224 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/35/83035/1 diff --git a/modules/base/ext.flow.base.js b/modules/base/ext.flow.base.js index b14542f..89d61b4 100644 --- a/modules/base/ext.flow.base.js +++ b/modules/base/ext.flow.base.js @@ -1,23 +1,24 @@ -( function($, mw) { +( function( $, mw ) { $( function() { mw.flow = { 'api' : { 'executeAction' : function( workflowParam, action, options, render ) { - var api = new mw.Api(); - var deferredObject = $.Deferred(); + var api = new mw.Api(), + deferredObject = $.Deferred(); - api.post( - $.extend( - { - 'action' : 'flow', - 'flowaction' : action, - 'gettoken' : 'gettoken' - }, - workflowParam + api + .post( + $.extend( + { + 'action' : 'flow', + 'flowaction' : action, + 'gettoken' : 'gettoken' + }, + workflowParam + ) ) - ) - .done( function(data) { - request = { + .done( function( data ) { + var request = { 'action' : 'flow', 'flowaction' : action, 'params' : $.toJSON( options ), @@ -31,15 +32,15 @@ } api.post( request ) - .done( function( ) { + .done( function() { deferredObject.resolve.apply( this, arguments ); } ) - .fail( function( ) { + .fail( function() { deferredObject.reject.apply( this, arguments ); } ); } ) - .fail(function( ) { - deferredObject.reject.apply( this, arguments); + .fail( function() { + deferredObject.reject.apply( this, arguments ); } ); return deferredObject.promise(); @@ -63,11 +64,11 @@ var deferredObject = $.Deferred(); mw.flow.api.read( pageName, topicId, options ) - .done( function(output) { + .done( function( output ) { // Immediate failure modes if ( - ! output.query || - ! output.query.flow || + !output.query || + !output.query.flow || output.query.flow._element !== 'block' ) { deferredObject.fail( 'invalid-result', 'Unable to understand the API result' ); @@ -102,11 +103,11 @@ 'generateTopicAction' : function( actionName, parameterList, promiseFilterCallback ) { return function( workflowId ) { - var deferredObject = $.Deferred(); - - var requestParams = {}; - var paramIndex = 1; - var requestArguments = arguments; + var deferredObject = $.Deferred(), + requestParams = {}, + paramIndex = 1, + requestArguments = arguments, + newDeferredObject; $.each( parameterList, function( key, value ) { requestParams[value] = requestArguments[paramIndex]; @@ -121,31 +122,33 @@ { 'topic' : requestParams }, true - ).done( function(data) { + ).done( function( data ) { + var output; + if ( data.flow[actionName].errors ) { - deferredObject.reject( 'block-errors', data.flow['reply'].errors ); + deferredObject.reject( 'block-errors', data.flow.reply.errors ); return; } if ( - ! data.flow || - ! data.flow[actionName] || - ! data.flow[actionName].result || - ! data.flow[actionName].result['topic'] + !data.flow || + !data.flow[actionName] || + !data.flow[actionName].result || + !data.flow[actionName].result.topic ) { deferredObject.reject( 'invalid-result', 'Unable to find appropriate section in result' ); return; } - var output = data.flow[actionName].result['topic']; + output = data.flow[actionName].result.topic; deferredObject.resolve( output, data ); } ) - .fail( function( ) { + .fail( function() { deferredObject.reject.apply( this, arguments ); } ); if ( promiseFilterCallback ) { - var newDeferredObject = promiseFilterCallback( deferredObject.promise() ); + newDeferredObject = promiseFilterCallback( deferredObject.promise() ); if ( newDeferredObject ) { deferredObject = newDeferredObject; } @@ -167,26 +170,28 @@ 'content' : content } }, true - ).done( function(data) { + ).done( function( data ) { + var output; + if ( data.flow['new-topic'].errors ) { deferredObject.reject( 'block-errors', data.flow['new-topic'].errors ); return; } if ( - ! data.flow || - ! data.flow['new-topic'] || - ! data.flow['new-topic'].result || - ! data.flow['new-topic'].result['topic_list'] + !data.flow || + !data.flow['new-topic'] || + !data.flow['new-topic'].result || + !data.flow['new-topic'].result.topic_list ) { deferredObject.reject( 'invalid-result', 'Unable to find appropriate section in result' ); return; } - var output = data.flow['new-topic'].result['topic_list']; + output = data.flow['new-topic'].result.topic_list; deferredObject.resolve( output, data ); } ) - .fail( function( ) { + .fail( function() { deferredObject.reject.apply( this, arguments ); } ); @@ -218,5 +223,5 @@ 'content' ] ); -}); -})( jQuery, mediaWiki ); \ No newline at end of file +} ); +} )( jQuery, mediaWiki ); diff --git a/modules/discussion/forms.js b/modules/discussion/forms.js index aabcd25..48f9648 100644 --- a/modules/discussion/forms.js +++ b/modules/discussion/forms.js @@ -1,12 +1,12 @@ ( function( $, mw ) { -$(document).on( 'flow_init', function( e ) { - $container = $( e.target ); - $container.find('form.flow-reply-form').flow( 'setupEmptyDisabler', +$( document ).on( 'flow_init', function( e ) { + var $container = $( e.target ); + $container.find( 'form.flow-reply-form' ).flow( 'setupEmptyDisabler', ['.flow-reply-content'], '.flow-reply-submit' ); - $('form.flow-newtopic-form').flow( 'setupEmptyDisabler', + $( 'form.flow-newtopic-form' ).flow( 'setupEmptyDisabler', [ '.flow-newtopic-title', '.flow-newtopic-content' @@ -33,11 +33,10 @@ function( promise ) { promise .done( function( output ) { - $form = $(this).closest( '.flow-newtopic-form' ); - - var $newRegion = $( output.rendered ) - .hide() - .insertAfter( $form ); + var $form = $( this ).closest( '.flow-newtopic-form' ), + $newRegion = $( output.rendered ) + .hide() + .insertAfter( $form ); $newRegion.trigger( 'flow_init' ); @@ -69,13 +68,12 @@ function( promise ) { promise .done( function( output ) { - var $replyContainer = $(this) - .closest( '.flow-post-container' ) - .children( '.flow-post-replies' ); - - var $newRegion = $( output.rendered ) - .hide() - .prependTo( $replyContainer ); + var $replyContainer = $( this ) + .closest( '.flow-post-container' ) + .children( '.flow-post-replies' ), + $newRegion = $( output.rendered ) + .hide() + .prependTo( $replyContainer ); $newRegion.trigger( 'flow_init' ); @@ -86,13 +84,13 @@ // Overload 'edit post' link. $container.find( '.flow-action-edit-post a' ) - .click( function(e) { + .click( function( e ) { e.preventDefault(); - var $postContainer = $(this).closest( '.flow-post' ); - var $contentContainer = $postContainer.find( '.flow-post-content' ); - var workflowId = $( this ).flow( 'getTopicWorkflowId' ); - var pageName = $(this).closest( '.flow-container' ).data( 'page-title' ); - var postId = $postContainer.data( 'post-id' ); + var $postContainer = $( this ).closest( '.flow-post' ), + $contentContainer = $postContainer.find( '.flow-post-content' ), + workflowId = $( this ).flow( 'getTopicWorkflowId' ), + pageName = $( this ).closest( '.flow-container' ).data( 'page-title' ), + postId = $postContainer.data( 'post-id' ); if ( $postContainer.find( '.flow-edit-post-form' ).length ) { return; @@ -109,11 +107,11 @@ } ) .done( function( data ) { - if ( ! data[0] || data[0]['post-id'] != postId ) { + if ( !data[0] || data[0]['post-id'] !== postId ) { console.dir( data ); - var $errorDiv = $( '<div/>' ) + $( '<div/>' ) .addClass( 'flow-error' ) - .text( mw.msg( 'flow-error-other') ) + .text( mw.msg( 'flow-error-other' ) ) .hide() .insertAfter( $contentContainer ) .slideDown(); @@ -140,7 +138,7 @@ .addClass( 'flow-cancel-link' ) .addClass( 'mw-ui-destructive' ) .attr( 'href', '#' ) - .click( function(e) { + .click( function( e ) { e.preventDefault(); $postForm.slideUp( 'fast', function() { @@ -175,19 +173,19 @@ return content; }, function( promise ) { - promise.done( function(output) { + promise.done( function( output ) { $contentContainer .empty() .append( - $(output.rendered) - .find('.flow-post-content') + $( output.rendered ) + .find( '.flow-post-content' ) .children() ); } ); } ); - $('form.flow-edit-post-form').flow( 'setupEmptyDisabler', + $( 'form.flow-edit-post-form' ).flow( 'setupEmptyDisabler', [ '.flow-edit-post-content' ], @@ -208,32 +206,32 @@ // Overload 'edit title' link. $container.find( '.flow-action-edit-title a' ) - .click( function(e) { + .click( function( e ) { e.preventDefault(); - var $topicContainer = $(this).closest( '.flow-topic-container' ); - var $titleBar = $topicContainer.find( '.flow-topic-title' ); - var oldTitle = $topicContainer.data( 'title' ); + var $topicContainer = $( this ).closest( '.flow-topic-container' ), + $titleBar = $topicContainer.find( '.flow-topic-title' ), + oldTitle = $topicContainer.data( 'title' ), + $titleEditForm = $( '<form />' ); $titleBar.find( '.flow-realtitle' ) .hide(); - var $titleEditForm = $( '<form />' ); $titleEditForm .addClass( 'flow-edit-title-form' ) .append( - $('<input />') + $( '<input />' ) .addClass( 'flow-edit-title-textbox' ) .attr( 'type', 'text' ) .val( oldTitle ) ) .append( - $('<a/>') + $( '<a/>' ) .addClass( 'flow-cancel-link' ) .addClass( 'mw-ui-destructive' ) .attr( 'href', '#' ) .text( mw.msg( 'flow-cancel' ) ) - .click( function(e) { + .click( function( e ) { e.preventDefault(); $titleBar.children( 'form' ) .remove(); @@ -248,7 +246,7 @@ .addClass( 'mw-ui-button' ) .addClass( 'mw-ui-primary' ) .attr( 'type', 'submit' ) - .val( mw.msg('flow-edit-title-submit' ) ) + .val( mw.msg( 'flow-edit-title-submit' ) ) ) .appendTo( $titleBar ) .find( '.flow-edit-title-textbox' ) @@ -259,8 +257,8 @@ '.flow-edit-title-submit', mw.flow.api.changeTitle, function() { - workflowId = $topicContainer.data( 'topic-id' ); - content = $titleEditForm.find( '.flow-edit-title-textbox' ).val(); + var workflowId = $topicContainer.data( 'topic-id' ), + content = $titleEditForm.find( '.flow-edit-title-textbox' ).val(); return [ workflowId, content ]; }, @@ -268,7 +266,7 @@ return content && true; }, function( promise ) { - promise.done(function( output ) { + promise.done( function( output ) { $titleBar.find( '.flow-realtitle' ) .empty() .text( output.rendered ) @@ -281,4 +279,4 @@ } ); } ); } ); -} )( jQuery, mediaWiki ); \ No newline at end of file +} )( jQuery, mediaWiki ); diff --git a/modules/discussion/init.js b/modules/discussion/init.js index 5d789b1..2d9c23e 100644 --- a/modules/discussion/init.js +++ b/modules/discussion/init.js @@ -1,5 +1,5 @@ -( function($, mw) { +( function( $, mw ) { $( function() { $( '.flow-container' ).trigger( 'flow_init' ); - }); + } ); } )( jQuery, mediaWiki ); diff --git a/modules/discussion/paging.js b/modules/discussion/paging.js index eba7bd4..41ab1c0 100644 --- a/modules/discussion/paging.js +++ b/modules/discussion/paging.js @@ -11,50 +11,50 @@ .data( 'offset', offset ) .data( 'limit', limit ) .append( - $('<a/>') + $( '<a/>' ) .attr( 'href', '#' ) - .text( mw.msg( 'flow-paging-'+direction ) ) + .text( mw.msg( 'flow-paging-' + direction ) ) ); }; - $( document ).on( 'flow_init', function( e ) { - $(this).find( '.flow-paging a' ).click( function(e) { + $( document ).on( 'flow_init', function() { + $( this ).find( '.flow-paging a' ).click( function( e ) { e.preventDefault(); - var $pagingLinkDiv = $(this).closest('.flow-paging') - .addClass( 'flow-paging-loading' ); + var $pagingLinkDiv = $( this ).closest( '.flow-paging' ) + .addClass( 'flow-paging-loading' ), - var offset = $pagingLinkDiv.data( 'offset' ); - var direction = $pagingLinkDiv.data( 'direction' ); - var limit = $pagingLinkDiv.data( 'limit' ); - var workflowId = $(this).flow( 'getTopicWorkflowId' ); - var pageName = $(this).closest( '.flow-container' ).data( 'page-title' ); - var requestLimit; + offset = $pagingLinkDiv.data( 'offset' ), + direction = $pagingLinkDiv.data( 'direction' ), + limit = $pagingLinkDiv.data( 'limit' ), + workflowId = $( this ).flow( 'getTopicWorkflowId' ), + pageName = $( this ).closest( '.flow-container' ).data( 'page-title' ), - // One more for paging forward. - requestLimit = limit + 1; + // One more for paging forward. + requestLimit = limit + 1, - var request = { - 'topic_list' : { - 'offset-dir' : direction, - 'offset-id' : offset, - 'limit' : requestLimit, - 'render' : true - } - }; + request = { + 'topic_list' : { + 'offset-dir' : direction, + 'offset-id' : offset, + 'limit' : requestLimit, + 'render' : true + } + }; mw.flow.api.readTopicList( pageName, workflowId, request ) .done( function( data ) { - var nextPage, prevPage; - var topics = []; + var topics = [], + $output = $( '<div/>' ), + $replaceContent; + $.each( data, function( k, v ) { - if ( k - 0 == k ) { + if ( k - 0 === k ) { topics.push( v ); } } ); - var $output = $('<div/>'); - if ( direction == 'rev' && data.paging.rev ) { + if ( direction === 'rev' && data.paging.rev ) { $output.append( getPagingLink( data.paging.rev @@ -64,7 +64,7 @@ $.each( topics, function( k, topic ) { $output.append( topic.rendered ); } ); - if ( direction == 'fwd' && data.paging.fwd ) { + if ( direction === 'fwd' && data.paging.fwd ) { $output.append( getPagingLink( data.paging.fwd @@ -72,7 +72,7 @@ ); } - var $replaceContent = $output.children(); + $replaceContent = $output.children(); $pagingLinkDiv.next( '.flow-error' ).remove(); $pagingLinkDiv.replaceWith( $replaceContent ); $replaceContent.trigger( 'flow_init' ); @@ -86,24 +86,25 @@ } ); $( function() { - var $window = $(window); + var $window = $( window ); $window - .scroll( function(e) { + .scroll( function() { $( '.flow-paging-fwd' ).each( function() { - var $pagingLinkDiv = $( this ); + var $pagingLinkDiv = $( this ), + + // Trigger infinite scroll when the user is half a screenlength + // away from the end. + windowEnd = $window.scrollTop() + ( 1.5 * $window.height() ); + if ( $pagingLinkDiv.hasClass( 'flow-paging-loading' ) ) { // Already loading return; } - // Trigger infinite scroll when the user is half a screenlength - // away from the end. - var windowEnd = $window.scrollTop() + (1.5 * $window.height() ); - if ( $pagingLinkDiv.position().top < windowEnd ) { - $pagingLinkDiv.find('a').click(); + $pagingLinkDiv.find( 'a' ).click(); } } ); } ); } ); -} )( jQuery, mediaWiki ); \ No newline at end of file +} )( jQuery, mediaWiki ); diff --git a/modules/discussion/ui-functions.js b/modules/discussion/ui-functions.js index 592a8ce..aaff763 100644 --- a/modules/discussion/ui-functions.js +++ b/modules/discussion/ui-functions.js @@ -1,45 +1,47 @@ -( function($, mw) { +( function( $, mw ) { $.fn.extend( true, { 'flow' : function() { - var args = Array.prototype.slice.call( arguments ); - var funcName = args.shift(); + var args = Array.prototype.slice.call( arguments ), + funcName = args.shift(); + return this._flow[funcName].apply( this, args ); }, '_flow' : { 'setupEmptyDisabler' : function( fieldSelectors, submitSelector ) { - var $form = this; - var validateFunction = function( $container ) { - var isOk = true; + var $form = this, + validateFunction = function( $container ) { + var isOk = true; - $.each( fieldSelectors, function() { - // I have no idea why "toString()" is necessary - if ( ! $container.find( this.toString() ).val() ) { - isOk = false; + $.each( fieldSelectors, function() { + // I have no idea why "toString()" is necessary + if ( !$container.find( this.toString() ).val() ) { + isOk = false; + return false; // break + } + } ); + + if ( isOk ) { + $container.find( submitSelector ) + .removeAttr( 'disabled' ); + } else { + $container.find( submitSelector ) + .attr( 'disabled', 'disabled' ); } - } ); - - if ( isOk ) { - $container.find( submitSelector ) - .removeAttr( 'disabled' ); - } else { - $container.find( submitSelector ) - .attr( 'disabled', 'disabled' ); - } - }; + }; $.each( fieldSelectors, function() { - $form.find(this.toString()) - .not('.flow-disabler') - .keyup( function(e) { - $container = $(e.target).closest( $form ); - validateFunction( $container ); - } ) - .addClass('flow-disabler'); - } ); + $form.find( this.toString() ) + .not( '.flow-disabler' ) + .keyup( function( e ) { + var $container = $( e.target ).closest( $form ); + validateFunction( $container ); + } ) + .addClass( 'flow-disabler' ); + } ); $form.each( function() { - validateFunction( $container ); + validateFunction( $( this ) ); } ); return $form; @@ -55,34 +57,35 @@ var $container = this; $container.find( submitSelector ) - .click( function(e) { + .click( function( e ) { e.preventDefault(); - var $button = $( this ); - var $form = $button.closest( 'form' ); + + var $button = $( this ), + $form = $button.closest( 'form' ), + params = loadParametersCallback.apply( this ), + $spinner = $( '<div/>' ), + deferredObject = $.Deferred(); $form.find( '.flow-error' ) .remove(); - var params = loadParametersCallback.apply( this ); - - if ( validateCallback && ! validateCallback.apply( this, params ) ) { + if ( validateCallback && !validateCallback.apply( this, params ) ) { $button.attr( 'disabled', 'disabled' ); - console.log( "Validate callback failed" ); + console.log( 'Validate callback failed' ); return; } $button.hide(); - var $spinner = $( '<div/>' ) + $spinner .addClass( 'flow-loading-indicator' ) .insertAfter( $button ); - var deferredObject = $.Deferred(); if ( promiseCallback ) { promiseCallback( deferredObject.promise() ); } submitFunction.apply( this, params ) - .done( function(output) { + .done( function( output ) { $spinner.remove(); $button.show(); $form.find( '.flow-cancel-link' ) @@ -90,12 +93,13 @@ deferredObject.resolve.apply( $button, arguments ); } ) - .fail( function( ) { + .fail( function() { + var $errorDiv = $( '<div/>' ).flow( 'showError', arguments ), + $disclaimer = $form.find( '.flow-disclaimer' ); + $spinner.remove(); $button.show(); - var $errorDiv = $('<div/>').flow( 'showError', arguments ); - var $disclaimer = $form.find( '.flow-disclaimer' ); if ( $disclaimer.length ) { $errorDiv.insertBefore( $disclaimer ); } else { @@ -109,10 +113,10 @@ return $container; }, - 'getTopicWorkflowId' : function( ) { - var $element = this; - var $topicContainer = $element.closest( '.flow-topic-container' ); - var $container = $element.closest( '.flow-container' ); + 'getTopicWorkflowId' : function() { + var $element = this, + $topicContainer = $element.closest( '.flow-topic-container' ), + $container = $element.closest( '.flow-container' ); if ( $topicContainer.length ) { return $topicContainer.data( 'topic-id' ); @@ -120,54 +124,54 @@ return $container.data( 'workflow-id' ); } else { console.dirxml( $element[0] ); - throw new Error( "Unable to get a workflow ID" ); + throw new Error( 'Unable to get a workflow ID' ); } }, - 'getWorkflowParameters' : function( ) { - var $container = this.closest( '.flow-container' ); - var workflowStatus = $container.data( 'workflow-existence' ); + 'getWorkflowParameters' : function() { + var $container = this.closest( '.flow-container' ), + workflowStatus = $container.data( 'workflow-existence' ); - if ( workflowStatus == 'new' ) { + if ( workflowStatus === 'new' ) { return { 'page' : $container.data( 'page-title' ) }; - } else if ( workflowStatus == 'existing' ) { + } else if ( workflowStatus === 'existing' ) { return { 'workflow' : $container.data( 'workflow-id' ) }; } else { - throw new Error( "Unknown workflow status " + workflowStatus ); + throw new Error( 'Unknown workflow status ' + workflowStatus ); } }, 'showError' : function( errorArgs ) { - var $errorDiv = this; + var $errorDiv = this, + apiExceptionPrefix = 'internal_api_error', + errors = [], + $errorList = $( '<ul/>' ); $errorDiv .addClass( 'flow-error' ) .hide() .slideDown( 'fast' ); - var apiExceptionPrefix = 'internal_api_error'; - if ( errorArgs[0] == 'http' ) { + if ( errorArgs[0] === 'http' ) { // HTTP error occurred $errorDiv.html( mw.message( 'flow-error-http' ).text() ); - } else if ( errorArgs[0].substr( 0, apiExceptionPrefix.length ) == apiExceptionPrefix ) { + } else if ( errorArgs[0].substr( 0, apiExceptionPrefix.length ) === apiExceptionPrefix ) { $errorDiv.html( mw.message( 'flow-error-external', errorArgs[1].error.info ).text() ); console.dir( errorArgs[1] ); - } else if ( errorArgs[0] == 'block-errors' ) { - var errors = []; + } else if ( errorArgs[0] === 'block-errors' ) { $.each( errorArgs[1], function( block, blockErrors ) { $.each( blockErrors, function( field, errorMsg ) { errors.push( errorMsg ); } ); } ); - if ( errors.length == 1 ) { + if ( errors.length === 1 ) { $errorDiv.html( mw.message( 'flow-error-external', errors.pop() ).text() ); } else if ( errors.length > 1 ) { - var $errorList = $( '<ul/>' ); $.each( errors, function( k, error ) { $( '<li />' ).text( error ) .appendTo( $errorList ); @@ -185,4 +189,4 @@ return $errorDiv; } } } ); -} )( jQuery, mediaWiki ); \ No newline at end of file +} )( jQuery, mediaWiki ); diff --git a/modules/discussion/ui.js b/modules/discussion/ui.js index ea2978a..d761ac8 100644 --- a/modules/discussion/ui.js +++ b/modules/discussion/ui.js @@ -1,32 +1,33 @@ ( function( $, mw ) { - $(document).on( 'flow_init', function( e ) { - $container = $( e.target ); + $( document ).on( 'flow_init', function( e ) { + var $container = $( e.target ); + // Set up menus $container.find( '.flow-post-actions, .flow-topic-actions' ) - .click( function(e) { - $(this).children( '.flow-post-actionbox, .flow-topic-actionbox, .flow-actionbox-pokey' ) + .click( function() { + $( this ).children( '.flow-post-actionbox, .flow-topic-actionbox, .flow-actionbox-pokey' ) .show(); } ) - .find('li') - .click( function(e) { - $(this).closest('.flow-topic-actions, .flow-post-actions') + .find( 'li' ) + .click( function() { + $( this ).closest( '.flow-topic-actions, .flow-post-actions' ) .children( '.flow-post-actionbox, .flow-topic-actionbox, .flow-actionbox-pokey' ) .fadeOut(); } ); // Set up timestamp on-hover $container.find( '.flow-topic-datestamp, .flow-datestamp' ) - .hover(function() { - $(this).children( '.flow-agotime' ).toggle() - $(this).children( '.flow-utctime' ).toggle() + .hover( function() { + $( this ).children( '.flow-agotime' ).toggle(); + $( this ).children( '.flow-utctime' ).toggle(); } ); // Set up reply form $container.find( '.flow-reply-form textarea' ) .addClass( 'flow-reply-box-closed' ) - .click( function(e) { - $(this).removeClass( 'flow-reply-box-closed' ); - $(this).closest( 'form' ) + .click( function() { + $( this ).removeClass( 'flow-reply-box-closed' ); + $( this ).closest( 'form' ) .children( '.flow-post-form-extras' ) .show(); } ); @@ -39,33 +40,33 @@ .addClass( 'flow-cancel-link' ) .addClass( 'mw-ui-destructive' ) .text( mw.msg( 'flow-cancel' ) ) - .click( function(e) { + .click( function( e ) { e.preventDefault(); - $(this).closest( '.flow-post-form-extras' ) + $( this ).closest( '.flow-post-form-extras' ) .slideUp( 'fast', function() { - $(this).closest( '.flow-reply-form' ) + $( this ).closest( '.flow-reply-form' ) .find( 'textarea' ) .addClass( 'flow-reply-box-closed' ) - .val('') + .val( '' ) .end() .find( '.flow-error' ) .remove(); - }); + } ); } ) - .insertBefore( $container.find('.flow-reply-form input[type=submit]') ); + .insertBefore( $container.find( '.flow-reply-form input[type=submit]' ) ); // Set up new topic form $container.find( '.flow-newtopic-step2' ).hide(); $container.find( '.flow-newtopic-title' ) .addClass( 'flow-newtopic-start' ) .attr( 'placeholder', mw.msg( 'flow-newtopic-start-placeholder' ) ) - .click( function(e) { - if ( ! $(this).hasClass('flow-newtopic-start' ) ) { + .click( function() { + if ( !$( this ).hasClass( 'flow-newtopic-start' ) ) { return; } $( '.flow-newtopic-step2' ) .show(); - $(this) + $( this ) .removeClass( 'flow-newtopic-start' ) .attr( 'placeholder', mw.msg( 'flow-newtopic-title-placeholder' ) ); $( '.flow-newtopic-submit' ) @@ -77,9 +78,10 @@ .addClass( 'flow-cancel-link' ) .addClass( 'mw-ui-destructive' ) .text( mw.msg( 'flow-cancel' ) ) - .click( function(e) { + .click( function( e ) { e.preventDefault(); - var $form = $(this).closest( 'form.flow-newtopic-form' ); + var $form = $( this ).closest( 'form.flow-newtopic-form' ); + $( '.flow-newtopic-step2' ) .slideUp( 'fast', function() { $form.find( '.flow-newtopic-title' ) @@ -92,16 +94,15 @@ .remove(); } ); } ) - .insertBefore( $container.find('.flow-newtopic-form input[type=submit]') ); + .insertBefore( $container.find( '.flow-newtopic-form input[type=submit]' ) ); // Set up folding $container.find( '.flow-topic-opener' ) - .click( function(e) { - var $topicContainer = $(this).closest('.flow-topic-container') - .toggleClass( 'flow-topic-closed' ); - - var $hideElement = $(this).closest('.flow-topic-container') - .children( '.flow-post-container' ); + .click( function() { + var $topicContainer = $( this ).closest( '.flow-topic-container' ) + .toggleClass( 'flow-topic-closed' ), + $hideElement = $( this ).closest( '.flow-topic-container' ) + .children( '.flow-post-container' ); if ( $topicContainer.hasClass( 'flow-topic-closed' ) ) { $hideElement.slideUp(); @@ -111,10 +112,10 @@ } ); } ); - $('body') - .click( function(e) { - if ( $(e.target) - .closest('.flow-post-actions, .flow-topic-actions' ) + $( 'body' ) + .click( function( e ) { + if ( $( e.target ) + .closest( '.flow-post-actions, .flow-topic-actions' ) .length === 0 ) { $( '.flow-post-actionbox, .flow-topic-actionbox, .flow-actionbox-pokey' ) -- To view, visit https://gerrit.wikimedia.org/r/83035 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4df027cf04659a9add142236f35efe9e64a6212e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits