r89616 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89615‎ | r89616 | r89617 >
Date:23:18, 6 June 2011
Author:krinkle
Status:resolved
Tags:
Comment:
Extension:WikiEditor Code quality, JSHint validation and JSPERF
- Leaked globals
- Strict comparison to 0, false and ''
- Missing semicolon
- Variable name collision
- Minor improvements in caching (in a few places "var $that" cached $(this), but wasn't actually used)
- Replace calls to deprecated $j with $
- Checking undefined by strictly comparing references instead of a string comparison and typeof (speed)

(see bug 29106)
Modified paths:
  • /trunk/extensions/WikiEditor/modules/ext.wikiEditor.preview.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/ext.wikiEditor.publish.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.publish.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
@@ -153,7 +153,7 @@
154154 * Resize a dialog so its contents fit
155155 *
156156 * Usage: dialog.each( resize ); or dialog.bind( 'blah', resize );
157 - * NOTE: This function assumes $j.ui.dialog has already been loaded
 157+ * NOTE: This function assumes $.ui.dialog has already been loaded
158158 */
159159 resize: function() {
160160 var wrapper = $(this).closest( '.ui-dialog' );
@@ -195,7 +195,7 @@
196196 // Get the highest tab index
197197 var tabIndex = $( document ).lastTabIndex() + 1;
198198 $elements.each( function() {
199 - $j(this).attr( 'tabindex', tabIndex++ );
 199+ $(this).attr( 'tabindex', tabIndex++ );
200200 } );
201201 }
202202 },
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js
@@ -2,10 +2,10 @@
33 * This plugin provides a way to build a wiki-text editing user interface around a textarea.
44 *
55 * @example To intialize without any modules:
6 - * $j( 'div#edittoolbar' ).wikiEditor();
 6+ * $( 'div#edittoolbar' ).wikiEditor();
77 *
88 * @example To initialize with one or more modules, or to add modules after it's already been initialized:
9 - * $j( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'toolbar', { ... config ... } );
 9+ * $( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'toolbar', { ... config ... } );
1010 *
1111 */
1212 ( function( $ ) {
@@ -203,7 +203,7 @@
204204 $.fn.wikiEditor = function() {
205205
206206 // Skip any further work when running in browsers that are unsupported
207 -if ( !$j.wikiEditor.isSupported() ) {
 207+if ( !$.wikiEditor.isSupported() ) {
208208 return $(this);
209209 }
210210
@@ -252,7 +252,7 @@
253253 /*
254254 * Externally Accessible API
255255 *
256 - * These are available using calls to $j(selection).wikiEditor( call, data ) where selection is a jQuery selection
 256+ * These are available using calls to $(selection).wikiEditor( call, data ) where selection is a jQuery selection
257257 * of the textarea that the wikiEditor instance was built around.
258258 */
259259
@@ -357,7 +357,7 @@
358358 if ( event.ctrlKey || event.altKey || event.shiftKey ) {
359359 return true;
360360 } else {
361 - var $tabindexList = $j( '[tabindex]:visible' ).sort( function( a, b ) {
 361+ var $tabindexList = $( '[tabindex]:visible' ).sort( function( a, b ) {
362362 return a.tabIndex - b.tabIndex;
363363 } );
364364 for( var i=0; i < $tabindexList.length; i++ ) {
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js
@@ -9,14 +9,14 @@
1010 api : {
1111 addToToolbar : function( context, data ) {
1212
13 - var smooth = true;
 13+ var smooth = true, type;
1414
1515 for ( type in data ) {
1616 switch ( type ) {
1717 case 'sections':
18 - var $sections = context.modules.toolbar.$toolbar.find( 'div.sections' );
19 - var $tabs = context.modules.toolbar.$toolbar.find( 'div.tabs' );
20 - for ( section in data[type] ) {
 18+ var $sections = context.modules.toolbar.$toolbar.find( 'div.sections' ),
 19+ $tabs = context.modules.toolbar.$toolbar.find( 'div.tabs' );
 20+ for ( var section in data[type] ) {
2121 if ( section == 'main' ) {
2222 // Section
2323 context.modules.toolbar.$toolbar.prepend(
@@ -40,8 +40,8 @@
4141 if ( ! ( 'section' in data ) ) {
4242 continue;
4343 }
44 - var $section = context.modules.toolbar.$toolbar.find( 'div[rel=' + data.section + '].section' );
45 - for ( group in data[type] ) {
 44+ var $section = context.modules.toolbar.$toolbar.find( 'div[rel=' + data.section + '].section' );
 45+ for ( var group in data[type] ) {
4646 // Group
4747 $section.append(
4848 $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, data[type][group] )
@@ -56,7 +56,7 @@
5757 var $group = context.modules.toolbar.$toolbar.find(
5858 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.group + '].group'
5959 );
60 - for ( tool in data[type] ) {
 60+ for ( var tool in data[type] ) {
6161 // Tool
6262 $group.append( $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, data[type][tool] ) );
6363 }
@@ -75,7 +75,7 @@
7676 var $index = context.modules.toolbar.$toolbar.find(
7777 'div[rel=' + data.section + '].section .index'
7878 );
79 - for ( page in data[type] ) {
 79+ for ( var page in data[type] ) {
8080 // Page
8181 $pages.append( $.wikiEditor.modules.toolbar.fn.buildPage( context, page, data[type][page] ) );
8282 // Index
@@ -93,7 +93,7 @@
9494 var $table = context.modules.toolbar.$toolbar.find(
9595 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page table'
9696 );
97 - for ( row in data[type] ) {
 97+ for ( var row in data[type] ) {
9898 // Row
9999 $table.append( $.wikiEditor.modules.toolbar.fn.buildRow( context, data[type][row] ) );
100100 }
@@ -107,7 +107,7 @@
108108 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page div'
109109 );
110110 var actions = $characters.data( 'actions' );
111 - for ( character in data[type] ) {
 111+ for ( var character in data[type] ) {
112112 // Character
113113 $characters
114114 .append(
@@ -134,13 +134,13 @@
135135
136136 // Fix div.section size after adding things; if smooth is true uses a smooth
137137 // animation, otherwise just change height (breaking any ongoing animation)
138 - var $sections = context.modules.toolbar.$toolbar.find( 'div.sections' );
139 - $section = $sections.find( '.section:visible' );
140 - if ( $section.size() ) {
 138+ var $divSections = context.modules.toolbar.$toolbar.find( 'div.sections' );
 139+ $visibleSection = $divSections.find( '.section:visible' );
 140+ if ( $visibleSection.size() ) {
141141 if ( smooth ) {
142 - $sections.animate( { 'height': $section.outerHeight() }, 'fast' );
 142+ $divSections.animate( { 'height': $visibleSection.outerHeight() }, 'fast' );
143143 } else {
144 - $sections.height( $section.outerHeight() );
 144+ $divSections.height( $visibleSection.outerHeight() );
145145 }
146146 }
147147 },
@@ -186,8 +186,8 @@
187187 context.modules.toolbar.$toolbar.find( target ).remove();
188188 // Hide empty groups
189189 if ( group ) {
190 - $group = context.modules.toolbar.$toolbar.find( group );
191 - if ( $group.children().length == 0 ) {
 190+ var $group = context.modules.toolbar.$toolbar.find( group );
 191+ if ( $group.children().length === 0 ) {
192192 $group.hide();
193193 }
194194 }
@@ -222,7 +222,7 @@
223223 if ( '$toolbar' in context.modules.toolbar ) {
224224 return;
225225 }
226 - context.modules.toolbar.$toolbar = $( '<div />' )
 226+ context.modules.toolbar.$toolbar = $( '<div/>' )
227227 .addClass( 'wikiEditor-ui-toolbar' )
228228 .attr( 'id', 'wikiEditor-ui-toolbar' );
229229 $.wikiEditor.modules.toolbar.fn.build( context, config );
@@ -238,7 +238,7 @@
239239 doAction : function( context, action, source ) {
240240 // Verify that this has been called from a source that's within the toolbar
241241 // 'trackAction' defined in click tracking
242 - if ( $.trackAction != undefined && source.closest( '.wikiEditor-ui-toolbar' ).size() ) {
 242+ if ( $.trackAction !== undefined && source.closest( '.wikiEditor-ui-toolbar' ).size() ) {
243243 // Build a unique id for this action by tracking the parent rel attributes up to the toolbar level
244244 var rels = [];
245245 var step = source;
@@ -269,7 +269,7 @@
270270 var replace = action.type == 'replace';
271271 if ( 'regex' in action.options && 'regexReplace' in action.options ) {
272272 var selection = context.$textarea.textSelection( 'getSelection' );
273 - if ( selection != '' && selection.match( action.options.regex ) ) {
 273+ if ( selection !== '' && selection.match( action.options.regex ) ) {
274274 parts.peri = selection.replace( action.options.regex,
275275 action.options.regexReplace );
276276 parts.pre = parts.post = '';
@@ -280,7 +280,7 @@
281281 'encapsulateSelection',
282282 $.extend( {}, action.options, parts, { 'replace': replace } )
283283 );
284 - if ( typeof context.$iframe !== 'undefined' ) {
 284+ if ( context.$iframe !== undefined ) {
285285 context.$iframe[0].contentWindow.focus();
286286 }
287287 break;
@@ -297,15 +297,15 @@
298298 }
299299 },
300300 buildGroup : function( context, id, group ) {
301 - var $group = $( '<div />' ).attr( { 'class' : 'group group-' + id, 'rel' : id } );
 301+ var $group = $( '<div/>' ).attr( { 'class' : 'group group-' + id, 'rel' : id } );
302302 var label = $.wikiEditor.autoMsg( group, 'label' );
303303 if ( label ) {
304 - $group.append( '<div class="label">' + label + '</div>' )
 304+ $group.append( '<div class="label">' + label + '</div>' );
305305 }
306306 var empty = true;
307307 if ( 'tools' in group ) {
308 - for ( tool in group.tools ) {
309 - var tool = $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] );
 308+ for ( var tool in group.tools ) {
 309+ tool = $.wikiEditor.modules.toolbar.fn.buildTool( context, tool, group.tools[tool] );
310310 if ( tool ) {
311311 // Consider a group with only hidden tools empty as well
312312 // .is( ':visible' ) always returns false because tool is not attached to the DOM yet
@@ -321,8 +321,8 @@
322322 },
323323 buildTool : function( context, id, tool ) {
324324 if ( 'filters' in tool ) {
325 - for ( filter in tool.filters ) {
326 - if ( $( tool.filters[filter] ).size() == 0 ) {
 325+ for ( var filter in tool.filters ) {
 326+ if ( $( tool.filters[filter] ).size() === 0 ) {
327327 return null;
328328 }
329329 }
@@ -337,7 +337,7 @@
338338 $.wikiEditor.imgPath + 'toolbar/'
339339 );
340340 if ( typeof offsetOrIcon == 'object' ) {
341 - $button = $( '<span />' )
 341+ $button = $( '<span/>' )
342342 .attr( {
343343 'alt' : label,
344344 'title' : label,
@@ -349,7 +349,7 @@
350350 }
351351 }
352352 if ( !$button ) {
353 - $button = $( '<img />' )
 353+ $button = $( '<img/>' )
354354 .attr( {
355355 'src' : src,
356356 'width' : 22,
@@ -380,14 +380,14 @@
381381 }
382382 return $button;
383383 case 'select':
384 - var $select = $( '<div />' )
 384+ var $select = $( '<div/>' )
385385 .attr( { 'rel' : id, 'class' : 'tool tool-select' } );
386 - var $options = $( '<div />' ).addClass( 'options' );
 386+ var $options = $( '<div/>' ).addClass( 'options' );
387387 if ( 'list' in tool ) {
388 - for ( option in tool.list ) {
 388+ for ( var option in tool.list ) {
389389 var optionLabel = $.wikiEditor.autoMsg( tool.list[option], 'label' );
390390 $options.append(
391 - $( '<a />' )
 391+ $( '<a/>' )
392392 .data( 'action', tool.list[option].action )
393393 .data( 'context', context )
394394 .mousedown( function( e ) {
@@ -415,8 +415,8 @@
416416 );
417417 }
418418 }
419 - $select.append( $( '<div />' ).addClass( 'menu' ).append( $options ) );
420 - $select.append( $( '<a />' )
 419+ $select.append( $( '<div/>' ).addClass( 'menu' ).append( $options ) );
 420+ $select.append( $( '<a/>' )
421421 .addClass( 'label' )
422422 .text( label )
423423 .data( 'options', $options )
@@ -440,7 +440,7 @@
441441 buildBookmark : function( context, id, page ) {
442442 var label = $.wikiEditor.autoMsg( page,
443443 'label' );
444 - return $( '<div />' )
 444+ return $( '<div/>' )
445445 .text( label )
446446 .attr( 'rel', id )
447447 .data( 'context', context )
@@ -461,16 +461,16 @@
462462 { expires: 30, path: '/' }
463463 );
464464 // Click tracking
465 - if($.trackAction != undefined){
 465+ if ( $.trackAction !== undefined){
466466 $.trackAction(section + '.' + $(this).attr('rel'));
467467 }
468468 // No dragging!
469469 event.preventDefault();
470470 return false;
471 - } )
 471+ } );
472472 },
473473 buildPage : function( context, id, page ) {
474 - var $page = $( '<div />' ).attr( {
 474+ var $page = $( '<div/>' ).attr( {
475475 'class' : 'page page-' + id,
476476 'rel' : id
477477 } );
@@ -480,18 +480,18 @@
481481 var html =
482482 '<table cellpadding=0 cellspacing=0 ' + 'border=0 width="100%" class="table table-' + id + '">';
483483 if ( 'headings' in page ) {
484 - html += $.wikiEditor.modules.toolbar.fn.buildHeading( context, page.headings )
 484+ html += $.wikiEditor.modules.toolbar.fn.buildHeading( context, page.headings );
485485 }
486486 if ( 'rows' in page ) {
487 - for ( row in page.rows ) {
488 - html += $.wikiEditor.modules.toolbar.fn.buildRow( context, page.rows[row] )
 487+ for ( var row in page.rows ) {
 488+ html += $.wikiEditor.modules.toolbar.fn.buildRow( context, page.rows[row] );
489489 }
490490 }
491491 $page.html( html );
492492 break;
493493 case 'characters':
494494 $page.addClass( 'page-characters' );
495 - $characters = $( '<div />' ).data( 'context', context ).data( 'actions', {} );
 495+ $characters = $( '<div/>' ).data( 'context', context ).data( 'actions', {} );
496496 var actions = $characters.data( 'actions' );
497497 if ( 'language' in page ) {
498498 $characters.attr( 'lang', page.language );
@@ -530,14 +530,14 @@
531531 },
532532 buildHeading : function( context, headings ) {
533533 var html = '<tr>';
534 - for ( heading in headings ) {
 534+ for ( var heading in headings ) {
535535 html += '<th>' + $.wikiEditor.autoMsg( headings[heading], ['html', 'text'] ) + '</th>';
536536 }
537537 return html;
538538 },
539539 buildRow : function( context, row ) {
540540 var html = '<tr>';
541 - for ( cell in row ) {
 541+ for ( var cell in row ) {
542542 html += '<td class="cell cell-' + cell + '" valign="top"><span>' +
543543 $.wikiEditor.autoMsg( row[cell], ['html', 'text'] ) + '</span></td>';
544544 }
@@ -576,91 +576,94 @@
577577 buildTab : function( context, id, section ) {
578578 var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
579579 // Re-save cookie
580 - if ( selected != null ) {
 580+ if ( selected !== null ) {
581581 $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section', selected, { expires: 30, path: '/' } );
582582 }
583 - return $( '<span />' )
584 - .attr( { 'class' : 'tab tab-' + id, 'rel' : id } )
585 - .append(
586 - $( '<a />' )
587 - .addClass( selected == id ? 'current' : null )
588 - .attr( 'href', '#' )
589 - .text( $.wikiEditor.autoMsg( section, 'label' ) )
590 - .data( 'context', context )
591 - .mouseup( function( e ) {
592 - $(this).blur();
593 - } )
594 - .mousedown( function( e ) {
595 - // No dragging!
596 - e.preventDefault();
597 - return false;
598 - } )
599 - .click( function( e ) {
600 - var $sections = $(this).data( 'context' ).$ui.find( '.sections' );
601 - var $section =
602 - $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
603 - var show = $section.css( 'display' ) == 'none';
604 - $previousSections = $section.parent().find( '.section-visible' );
605 - $previousSections.css( 'position', 'absolute' );
606 - $previousSections.removeClass( 'section-visible' );
607 - $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'relative' ); } );
608 - $(this).parent().parent().find( 'a' ).removeClass( 'current' );
609 - $sections.css( 'overflow', 'hidden' );
610 - function animate( $this ) {
611 - $sections
612 - .css( 'display', 'block' )
613 - .animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
614 - $( this ).css( 'overflow', 'visible' ).css( 'height', 'auto' );
 583+ var $link =
 584+ $( '<a/>' )
 585+ .addClass( selected == id ? 'current' : null )
 586+ .attr( 'href', '#' )
 587+ .text( $.wikiEditor.autoMsg( section, 'label' ) )
 588+ .data( 'context', context )
 589+ .mouseup( function( e ) {
 590+ $(this).blur();
 591+ } )
 592+ .mousedown( function( e ) {
 593+ // No dragging!
 594+ e.preventDefault();
 595+ return false;
 596+ } )
 597+ .click( function( e ) {
 598+ var $sections = $(this).data( 'context' ).$ui.find( '.sections' );
 599+ var $section =
 600+ $(this).data( 'context' ).$ui.find( '.section-' + $(this).parent().attr( 'rel' ) );
 601+ var show = $section.css( 'display' ) == 'none';
 602+ $previousSections = $section.parent().find( '.section-visible' );
 603+ $previousSections.css( 'position', 'absolute' );
 604+ $previousSections.removeClass( 'section-visible' );
 605+ $previousSections.fadeOut( 'fast', function() { $(this).css( 'position', 'relative' ); } );
 606+ $(this).parent().parent().find( 'a' ).removeClass( 'current' );
 607+ $sections.css( 'overflow', 'hidden' );
 608+ var animate = function( $that ) {
 609+ $sections
 610+ .css( 'display', 'block' )
 611+ .animate( { 'height': $section.outerHeight() }, $section.outerHeight() * 2, function() {
 612+ $that.css( 'overflow', 'visible' ).css( 'height', 'auto' );
 613+ context.fn.trigger( 'resize' );
 614+ } );
 615+ };
 616+ if ( show ) {
 617+ $section.addClass( 'section-visible' );
 618+ $section.fadeIn( 'fast' );
 619+ if ( $section.hasClass( 'loading' ) ) {
 620+ // Loading of this section was deferred, load it now
 621+ var $that = $(this);
 622+ $that.addClass( 'current loading' );
 623+ setTimeout( function() {
 624+ $section.trigger( 'loadSection' );
 625+ animate( $that );
 626+ $that.removeClass( 'loading' );
 627+ }, 1000 );
 628+ } else {
 629+ animate( $(this) );
 630+ $(this).addClass( 'current' );
 631+ }
 632+ } else {
 633+ $sections
 634+ .css( 'height', $section.outerHeight() )
 635+ .animate( { 'height': 'hide' }, $section.outerHeight() * 2, function() {
 636+ $(this).css( { 'overflow': 'visible', 'height': 0 } );
615637 context.fn.trigger( 'resize' );
616638 } );
617 - }
618 - if ( show ) {
619 - $section.addClass( 'section-visible' );
620 - $section.fadeIn( 'fast' );
621 - if ( $section.hasClass( 'loading' ) ) {
622 - // Loading of this section was deferred, load it now
623 - var $this = $(this);
624 - $this.addClass( 'current loading' );
625 - setTimeout( function() {
626 - $section.trigger( 'loadSection' );
627 - animate( $(this) );
628 - $this.removeClass( 'loading' );
629 - }, 1000 );
630 - } else {
631 - animate( $(this) );
632 - $(this).addClass( 'current' );
633 - }
634 - } else {
635 - $sections
636 - .css( 'height', $section.outerHeight() )
637 - .animate( { 'height': 'hide' }, $section.outerHeight() * 2, function() {
638 - $(this).css( { 'overflow': 'visible', 'height': 0 } );
639 - context.fn.trigger( 'resize' );
640 - } );
641 - }
642 - // Click tracking
643 - if ( $.trackAction != undefined ) {
644 - $.trackAction( $section.attr('rel') + '.' + ( show ? 'show': 'hide' ) );
645 - }
646 - // Save the currently visible section
647 - $.cookie(
648 - 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section',
649 - show ? $section.attr( 'rel' ) : null,
650 - { expires: 30, path: '/' }
651 - );
652 - e.preventDefault();
653 - return false;
654 - } )
655 - );
 639+ }
 640+ // Click tracking
 641+ if ( $.trackAction !== undefined ) {
 642+ $.trackAction( $section.attr('rel') + '.' + ( show ? 'show': 'hide' ) );
 643+ }
 644+ // Save the currently visible section
 645+ $.cookie(
 646+ 'wikiEditor-' + $(this).data( 'context' ).instance + '-toolbar-section',
 647+ show ? $section.attr( 'rel' ) : null,
 648+ { expires: 30, path: '/' }
 649+ );
 650+ e.preventDefault();
 651+ return false;
 652+ });
 653+ return $( '<span/>' )
 654+ .attr({
 655+ 'class' : 'tab tab-' + id,
 656+ 'rel' : id
 657+ })
 658+ .append( $link );
656659 },
657660 buildSection: function( context, id, section ) {
658 - var $section = $( '<div />' ).attr( { 'class': section.type + ' section section-' + id, 'rel': id } );
 661+ var $section = $( '<div/>' ).attr( { 'class': section.type + ' section section-' + id, 'rel': id } );
659662 var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
660663 var show = selected == id;
661664
662 - if ( typeof section.deferLoad != 'undefined' && section.deferLoad && id !== 'main' && !show ) {
 665+ if ( section.deferLoad !== undefined && section.deferLoad && id !== 'main' && !show ) {
663666 // This class shows the spinner and serves as a marker for the click handler in buildTab()
664 - $section.addClass( 'loading' ).append( $( '<div />' ).addClass( 'spinner' ) );
 667+ $section.addClass( 'loading' ).append( $( '<div/>' ).addClass( 'spinner' ) );
665668 $section.bind( 'loadSection', function() {
666669 $.wikiEditor.modules.toolbar.fn.reallyBuildSection( context, id, section, $section );
667670 $section.removeClass( 'loading' );
@@ -672,8 +675,9 @@
673676 // Show or hide section
674677 if ( id !== 'main' ) {
675678 $section.css( 'display', show ? 'block' : 'none' );
676 - if ( show )
 679+ if ( show ) {
677680 $section.addClass( 'section-visible' );
 681+ }
678682 }
679683 return $section;
680684 },
@@ -682,7 +686,7 @@
683687 switch ( section.type ) {
684688 case 'toolbar':
685689 if ( 'groups' in section ) {
686 - for ( group in section.groups ) {
 690+ for ( var group in section.groups ) {
687691 $section.append(
688692 $.wikiEditor.modules.toolbar.fn.buildGroup( context, group, section.groups[group] )
689693 );
@@ -690,10 +694,10 @@
691695 }
692696 break;
693697 case 'booklet':
694 - var $pages = $( '<div />' ).addClass( 'pages' );
695 - var $index = $( '<div />' ).addClass( 'index' );
 698+ var $pages = $( '<div/>' ).addClass( 'pages' );
 699+ var $index = $( '<div/>' ).addClass( 'index' );
696700 if ( 'pages' in section ) {
697 - for ( page in section.pages ) {
 701+ for ( var page in section.pages ) {
698702 $pages.append(
699703 $.wikiEditor.modules.toolbar.fn.buildPage( context, page, section.pages[page] )
700704 );
@@ -715,7 +719,7 @@
716720 $.cookie( cookie, selected, { expires: 30, path: '/' } );
717721 }
718722 var $selectedIndex = $index.find( '*[rel=' + selected + ']' );
719 - if ( $selectedIndex.size() == 0 ) {
 723+ if ( $selectedIndex.size() === 0 ) {
720724 $selectedIndex = $index.children().eq( 0 );
721725 selected = $selectedIndex.attr( 'rel' );
722726 $.cookie( cookie, selected, { expires: 30, path: '/' } );
@@ -726,11 +730,11 @@
727731 $selectedIndex.addClass( 'current' );
728732 },
729733 build : function( context, config ) {
730 - var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.toolbar.$toolbar );
731 - var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.toolbar.$toolbar );
732 - context.modules.toolbar.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) );
 734+ var $tabs = $( '<div/>' ).addClass( 'tabs' ).appendTo( context.modules.toolbar.$toolbar );
 735+ var $sections = $( '<div/>' ).addClass( 'sections' ).appendTo( context.modules.toolbar.$toolbar );
 736+ context.modules.toolbar.$toolbar.append( $( '<div/>' ).css( 'clear', 'both' ) );
733737 var sectionQueue = [];
734 - for ( section in config ) {
 738+ for ( var section in config ) {
735739 if ( section == 'main' ) {
736740 context.modules.toolbar.$toolbar.prepend(
737741 $.wikiEditor.modules.toolbar.fn.buildSection( context, section, config[section] )
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.publish.js
@@ -74,7 +74,7 @@
7575 var newCopyWarnHTML = '<ul>';
7676 for ( var i = 0; i < copyWarnStatements.length; i++ ) {
7777 if ( copyWarnStatements[i] != '' ) {
78 - var copyWarnStatement = $j.trim( copyWarnStatements[i] ).replace( /\.*$/, '' );
 78+ var copyWarnStatement = $.trim( copyWarnStatements[i] ).replace( /\.*$/, '' );
7979 newCopyWarnHTML += '<li>' + copyWarnStatement + '.</li>';
8080 }
8181 }
@@ -112,7 +112,7 @@
113113 'checked' : '';
114114 $( '#wpMinoredit' ).attr( 'checked', minorChecked );
115115 $( '#wpWatchthis' ).attr( 'checked', watchChecked );
116 - $( '#wpSummary' ).val( $j( '#wikiEditor-' + context.instance +
 116+ $( '#wpSummary' ).val( $( '#wikiEditor-' + context.instance +
117117 '-dialog-summary' ).val() );
118118 $( '#editform' ).submit();
119119 },
Index: trunk/extensions/WikiEditor/modules/ext.wikiEditor.publish.js
@@ -4,5 +4,5 @@
55
66 $( document ).ready( function() {
77 // Add publish module
8 - $j( '#wpTextbox1' ).wikiEditor( 'addModule', 'publish' );
 8+ $( '#wpTextbox1' ).wikiEditor( 'addModule', 'publish' );
99 } );
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js
@@ -55,7 +55,7 @@
5656 'checked' : '';
5757 $( '#wpMinoredit' ).attr( 'checked', minorChecked );
5858 $( '#wpWatchthis' ).attr( 'checked', watchChecked );
59 - $( '#wpSummary' ).val( $j( '#wikiEditor-' + context.instance +
 59+ $( '#wpSummary' ).val( $( '#wikiEditor-' + context.instance +
6060 '-dialog-summary' ).val() );
6161 $( '#editform' ).submit();
6262 },
Index: trunk/extensions/WikiEditor/modules/ext.wikiEditor.preview.js
@@ -4,5 +4,5 @@
55
66 $( document ).ready( function() {
77 // Add preview module
8 - $j( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'preview' );
 8+ $( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'preview' );
99 } );

Follow-up revisions

RevisionCommit summaryAuthorDate
r90845Bug #29106: Patch from Michael M. to address JS legacy globals in wikiEditormah19:25, 26 June 2011
r91342* Fix broken post call to api in side-to-side diffs...hartman08:46, 2 July 2011
r91343Clean up some global var leaking in WikiEditor toolbar...hartman08:54, 2 July 2011
r91347Correct for in loops on arrays....hartman09:09, 2 July 2011
r91349Adding quotes for the [rel=] stuff, since this broke one test....hartman09:17, 2 July 2011

Status & tagging log