diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-02-28 08:36:29 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-02-28 08:36:29 +0100 |
commit | a4edbfa031eb4cd72678051f1510afde4f77951e (patch) | |
tree | 76cef11b1a13538c8982a7491dbbf7324d4a7b2a /extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js | |
parent | 1b65fa2a5f4c48b02ceda934e9c1aee2d03ce453 (diff) |
Update to MediaWiki 1.22.3
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js')
-rw-r--r-- | extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js index e1bc6f15..71592b53 100644 --- a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js +++ b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js @@ -1,6 +1,7 @@ /** * Toolbar module for wikiEditor */ +/*jshint onevar:false */ ( function ( mw, $ ) { $.wikiEditor.modules.toolbar = { /** @@ -17,7 +18,7 @@ api : { var $sections = context.modules.toolbar.$toolbar.find( 'div.sections' ), $tabs = context.modules.toolbar.$toolbar.find( 'div.tabs' ); for ( var section in data[type] ) { - if ( section == 'main' ) { + if ( section === 'main' ) { // Section context.modules.toolbar.$toolbar.prepend( $.wikiEditor.modules.toolbar.fn.buildSection( @@ -145,28 +146,28 @@ api : { } }, removeFromToolbar : function( context, data ) { - if ( typeof data.section == 'string' ) { + if ( typeof data.section === 'string' ) { // Section var tab = 'div.tabs span[rel="' + data.section + '"].tab'; var target = 'div[rel="' + data.section + '"].section'; var group = null; - if ( typeof data.group == 'string' ) { + if ( typeof data.group === 'string' ) { // Toolbar group target += ' div[rel="' + data.group + '"].group'; - if ( typeof data.tool == 'string' ) { + if ( typeof data.tool === 'string' ) { // Save for later checking if empty group = target; // Tool target += ' a[rel="' + data.tool + '"].tool'; } - } else if ( typeof data.page == 'string' ) { + } else if ( typeof data.page === 'string' ) { // Booklet page var index = target + ' div.index div[rel="' + data.page + '"]'; target += ' div.pages div[rel="' + data.page + '"].page'; - if ( typeof data.character == 'string' ) { + if ( typeof data.character === 'string' ) { // Character target += ' span[rel="' + data.character + '"]'; - } else if ( typeof data.row == 'number' ) { + } else if ( typeof data.row === 'number' ) { // Table row target += ' table tr:not(:has(th)):eq(' + data.row + ')'; } else { @@ -198,7 +199,11 @@ api : { * Event handlers */ evt: { - resize: function( context, event ) { + /** + * @param context + * @param event + */ + resize: function( context ) { context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section-visible' ).outerHeight() ); }, tocCollapse: function( context, event ) { @@ -235,7 +240,7 @@ fn: { * @param {Object} action * @param {Object} source */ - doAction : function( context, action, source ) { + doAction : function( context, action ) { switch ( action.type ) { case 'replace': case 'encapsulate': @@ -244,7 +249,7 @@ fn: { 'peri' : $.wikiEditor.autoMsg( action.options, 'peri' ), 'post' : $.wikiEditor.autoMsg( action.options, 'post' ) }; - var replace = action.type == 'replace'; + var replace = action.type === 'replace'; if ( 'regex' in action.options && 'regexReplace' in action.options ) { var selection = context.$textarea.textSelection( 'getSelection' ); if ( selection !== '' && selection.match( action.options.regex ) ) { @@ -263,7 +268,7 @@ fn: { } break; case 'callback': - if ( typeof action.execute == 'function' ) { + if ( typeof action.execute === 'function' ) { action.execute( context ); } break; @@ -287,7 +292,7 @@ fn: { if ( tool ) { // Consider a group with only hidden tools empty as well // .is( ':visible' ) always returns false because tool is not attached to the DOM yet - empty = empty && tool.css( 'display' ) == 'none'; + empty = empty && tool.css( 'display' ) === 'none'; $group.append( tool ); } } @@ -447,7 +452,7 @@ fn: { } ); }, buildPage : function( context, id, page ) { - var html; + var html, i; var $page = $( '<div/>' ).attr( { 'class' : 'page page-' + id, 'rel' : id @@ -461,7 +466,7 @@ fn: { html += $.wikiEditor.modules.toolbar.fn.buildHeading( context, page.headings ); } if ( 'rows' in page ) { - for ( var i = 0; i < page.rows.length; i++ ) { + for ( i = 0; i < page.rows.length; i++ ) { html += $.wikiEditor.modules.toolbar.fn.buildRow( context, page.rows[i] ); } } @@ -484,7 +489,7 @@ fn: { } if ( 'characters' in page ) { html = ''; - for ( var i = 0; i < page.characters.length; i++ ) { + for ( i = 0; i < page.characters.length; i++ ) { html += $.wikiEditor.modules.toolbar.fn.buildCharacter( page.characters[i], actions ); } $characters @@ -527,7 +532,7 @@ fn: { return html + '</tr>'; }, buildCharacter : function( character, actions ) { - if ( typeof character == 'string' ) { + if ( typeof character === 'string' ) { character = { 'label' : character, 'action' : { @@ -564,8 +569,9 @@ fn: { return mw.html.element( 'span', { 'rel': character.label }, character.label ); } } - mw.log( "A character for the toolbar was undefined. This is not supposed to happen. Double check the config." ); - return ""; // bug 31673; also an additional fix for bug 24208... + mw.log( 'A character for the toolbar was undefined. This is not supposed to happen. Double check the config.' ); + // bug 31673; also an additional fix for bug 24208... + return ''; }, buildTab : function( context, id, section ) { var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' ); @@ -575,7 +581,7 @@ fn: { } var $link = $( '<a/>' ) - .addClass( selected == id ? 'current' : null ) + .addClass( selected === id ? 'current' : null ) .attr( { href: '#', role: 'button', @@ -584,7 +590,7 @@ fn: { } ) .text( $.wikiEditor.autoMsg( section, 'label' ) ) .data( 'context', context ) - .mouseup( function( e ) { + .mouseup( function () { $(this).blur(); } ) .mousedown( function( e ) { @@ -604,7 +610,7 @@ fn: { var $sections = $(this).data( 'context' ).$ui.find( '.sections' ); var $section = $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) ); - var show = $section.css( 'display' ) == 'none'; + var show = $section.css( 'display' ) === 'none'; $section.parent().find( '.section-visible' ) .css( 'position', 'absolute' ) .attr( 'aria-expanded', 'false' ) @@ -668,7 +674,7 @@ fn: { id: 'wikiEditor-section-' + id } ); var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' ); - var show = selected == id; + var show = selected === id; if ( section.deferLoad !== undefined && section.deferLoad && id !== 'main' && !show ) { // This class shows the spinner and serves as a marker for the click handler in buildTab() @@ -724,6 +730,7 @@ fn: { } }, updateBookletSelection : function( context, id, $pages, $index ) { + /*jshint eqnull:true */ var cookie = 'wikiEditor-' + context.instance + '-booklet-' + id + '-page'; var selected = $.cookie( cookie ); // Re-save cookie @@ -747,7 +754,7 @@ fn: { context.modules.toolbar.$toolbar.append( $( '<div/>' ).css( 'clear', 'both' ) ); var sectionQueue = []; for ( var section in config ) { - if ( section == 'main' ) { + if ( section === 'main' ) { context.modules.toolbar.$toolbar.prepend( $.wikiEditor.modules.toolbar.fn.buildSection( context, section, config[section] ) ); |