diff options
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js')
-rw-r--r-- | extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js index 71592b53..e1bc6f15 100644 --- a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js +++ b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js @@ -1,7 +1,6 @@ /** * Toolbar module for wikiEditor */ -/*jshint onevar:false */ ( function ( mw, $ ) { $.wikiEditor.modules.toolbar = { /** @@ -18,7 +17,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( @@ -146,28 +145,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 { @@ -199,11 +198,7 @@ api : { * Event handlers */ evt: { - /** - * @param context - * @param event - */ - resize: function( context ) { + resize: function( context, event ) { context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section-visible' ).outerHeight() ); }, tocCollapse: function( context, event ) { @@ -240,7 +235,7 @@ fn: { * @param {Object} action * @param {Object} source */ - doAction : function( context, action ) { + doAction : function( context, action, source ) { switch ( action.type ) { case 'replace': case 'encapsulate': @@ -249,7 +244,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 ) ) { @@ -268,7 +263,7 @@ fn: { } break; case 'callback': - if ( typeof action.execute === 'function' ) { + if ( typeof action.execute == 'function' ) { action.execute( context ); } break; @@ -292,7 +287,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 ); } } @@ -452,7 +447,7 @@ fn: { } ); }, buildPage : function( context, id, page ) { - var html, i; + var html; var $page = $( '<div/>' ).attr( { 'class' : 'page page-' + id, 'rel' : id @@ -466,7 +461,7 @@ fn: { html += $.wikiEditor.modules.toolbar.fn.buildHeading( context, page.headings ); } if ( 'rows' in page ) { - for ( i = 0; i < page.rows.length; i++ ) { + for ( var i = 0; i < page.rows.length; i++ ) { html += $.wikiEditor.modules.toolbar.fn.buildRow( context, page.rows[i] ); } } @@ -489,7 +484,7 @@ fn: { } if ( 'characters' in page ) { html = ''; - for ( i = 0; i < page.characters.length; i++ ) { + for ( var i = 0; i < page.characters.length; i++ ) { html += $.wikiEditor.modules.toolbar.fn.buildCharacter( page.characters[i], actions ); } $characters @@ -532,7 +527,7 @@ fn: { return html + '</tr>'; }, buildCharacter : function( character, actions ) { - if ( typeof character === 'string' ) { + if ( typeof character == 'string' ) { character = { 'label' : character, 'action' : { @@ -569,9 +564,8 @@ 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.' ); - // bug 31673; also an additional fix for bug 24208... - return ''; + 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... }, buildTab : function( context, id, section ) { var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' ); @@ -581,7 +575,7 @@ fn: { } var $link = $( '<a/>' ) - .addClass( selected === id ? 'current' : null ) + .addClass( selected == id ? 'current' : null ) .attr( { href: '#', role: 'button', @@ -590,7 +584,7 @@ fn: { } ) .text( $.wikiEditor.autoMsg( section, 'label' ) ) .data( 'context', context ) - .mouseup( function () { + .mouseup( function( e ) { $(this).blur(); } ) .mousedown( function( e ) { @@ -610,7 +604,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' ) @@ -674,7 +668,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() @@ -730,7 +724,6 @@ 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 @@ -754,7 +747,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] ) ); |