r62180 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62179‎ | r62180 | r62181 >
Date:14:13, 9 February 2010
Author:catrope
Status:ok
Tags:
Comment:
UsabilityInitiative: Fix indentation, recombine, bump style versions for r62156. Also unintent a block of code elsewhere
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,7 +72,7 @@
7373 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ),
7575 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 112 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 113 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 47 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 12 ),
@@ -82,10 +82,10 @@
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 230 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 231 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 230 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 231 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -365,21 +365,23 @@
366366 context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' );
367367 setTimeout( function() {
368368 var $selection = context.$content.find( ':not(.wikiEditor)' );
369 - while ( $selection.length && $selection.length > 0){
 369+ while ( $selection.length && $selection.length > 0 ) {
370370 var $currentElement = $selection.eq( 0 );
371371 while ( !$currentElement.parent().is( 'body' ) && !$currentElement.parent().is( '.wikiEditor' ) ) {
372372 $currentElement = $currentElement.parent();
373373 }
374 - if($currentElement.is("br")){
375 - $currentElement.addClass('wikiEditor');
376 - }
377 - else{
378 - $("<p></p>").text( $currentElement.text() ).addClass( 'wikiEditor' ).insertAfter( $currentElement );
 374+ if ( $currentElement.is( 'br' ) ) {
 375+ $currentElement.addClass( 'wikiEditor' );
 376+ } else {
 377+ $( '<p></p>' )
 378+ .text( $currentElement.text() )
 379+ .addClass( 'wikiEditor' )
 380+ .insertAfter( $currentElement );
379381 $currentElement.remove();
380382 }
381383 $selection = context.$content.find( ':not(.wikiEditor)' );
382 - }
383 - }, 100 );
 384+ }
 385+ }, 100 );
384386 return true;
385387 }
386388 };
@@ -503,30 +505,30 @@
504506 // Converting <p>s is wrong if there's nothing before them, so check that.
505507 // .find( '* + p' ) isn't good enough because textnodes aren't considered
506508 $pre.find( 'p' ).each( function() {
507 - var text = $( this ).text();
508 - // If this <p> is preceded by some text, add a \n at the beginning, and if
509 - // it's followed by a textnode, add a \n at the end
510 - // We need the traverser because there can be other weird stuff in between
511 -
512 - // Check for preceding text
513 - var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev();
514 - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
515 - t = t.prev();
516 - }
517 - if ( t ) {
518 - text = "\n" + text;
519 - }
520 -
521 - // Check for following text
522 - t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next();
523 - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
524 - t = t.next();
525 - }
526 - if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n'
527 - && t.node.nodeValue.charAt( 0 ) != '\r' ) {
528 - text += "\n";
529 - }
530 - $( this ).text( text );
 509+ var text = $( this ).text();
 510+ // If this <p> is preceded by some text, add a \n at the beginning, and if
 511+ // it's followed by a textnode, add a \n at the end
 512+ // We need the traverser because there can be other weird stuff in between
 513+
 514+ // Check for preceding text
 515+ var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev();
 516+ while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
 517+ t = t.prev();
 518+ }
 519+ if ( t ) {
 520+ text = "\n" + text;
 521+ }
 522+
 523+ // Check for following text
 524+ t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next();
 525+ while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
 526+ t = t.next();
 527+ }
 528+ if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n'
 529+ && t.node.nodeValue.charAt( 0 ) != '\r' ) {
 530+ text += "\n";
 531+ }
 532+ $( this ).text( text );
531533 } );
532534 var retval;
533535 if ( $.browser.msie ) {
@@ -1285,7 +1287,7 @@
12861288 .bind( 'keydown', function( event ) {
12871289 return context.fn.trigger( 'keydown', event );
12881290 } )
1289 - .bind( 'paste', function( event ){
 1291+ .bind( 'paste', function( event ) {
12901292 return context.fn.trigger( 'paste', event );
12911293 } )
12921294 .bind( 'keyup mouseup paste cut encapsulateSelection', function( event ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6706,6 +6706,7 @@
67076707 * processing of events which did not actually change the content of the iframe.
67086708 */
67096709 'keydown': function( event ) {
 6710+
67106711 switch ( event.which ) {
67116712 case 90: // z
67126713 if ( ( event.ctrlKey || event.metaKey ) && context.history.length ) {
@@ -6792,6 +6793,29 @@
67936794 }
67946795 }
67956796 return true;
 6797+ },
 6798+ 'paste': function( event ) {
 6799+ context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' );
 6800+ setTimeout( function() {
 6801+ var $selection = context.$content.find( ':not(.wikiEditor)' );
 6802+ while ( $selection.length && $selection.length > 0 ) {
 6803+ var $currentElement = $selection.eq( 0 );
 6804+ while ( !$currentElement.parent().is( 'body' ) && !$currentElement.parent().is( '.wikiEditor' ) ) {
 6805+ $currentElement = $currentElement.parent();
 6806+ }
 6807+ if ( $currentElement.is( 'br' ) ) {
 6808+ $currentElement.addClass( 'wikiEditor' );
 6809+ } else {
 6810+ $( '<p></p>' )
 6811+ .text( $currentElement.text() )
 6812+ .addClass( 'wikiEditor' )
 6813+ .insertAfter( $currentElement );
 6814+ $currentElement.remove();
 6815+ }
 6816+ $selection = context.$content.find( ':not(.wikiEditor)' );
 6817+ }
 6818+ }, 100 );
 6819+ return true;
67966820 }
67976821 };
67986822
@@ -6914,30 +6938,30 @@
69156939 // Converting <p>s is wrong if there's nothing before them, so check that.
69166940 // .find( '* + p' ) isn't good enough because textnodes aren't considered
69176941 $pre.find( 'p' ).each( function() {
6918 - var text = $( this ).text();
6919 - // If this <p> is preceded by some text, add a \n at the beginning, and if
6920 - // it's followed by a textnode, add a \n at the end
6921 - // We need the traverser because there can be other weird stuff in between
6922 -
6923 - // Check for preceding text
6924 - var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev();
6925 - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
6926 - t = t.prev();
6927 - }
6928 - if ( t ) {
6929 - text = "\n" + text;
6930 - }
6931 -
6932 - // Check for following text
6933 - t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next();
6934 - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
6935 - t = t.next();
6936 - }
6937 - if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n'
6938 - && t.node.nodeValue.charAt( 0 ) != '\r' ) {
6939 - text += "\n";
6940 - }
6941 - $( this ).text( text );
 6942+ var text = $( this ).text();
 6943+ // If this <p> is preceded by some text, add a \n at the beginning, and if
 6944+ // it's followed by a textnode, add a \n at the end
 6945+ // We need the traverser because there can be other weird stuff in between
 6946+
 6947+ // Check for preceding text
 6948+ var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev();
 6949+ while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
 6950+ t = t.prev();
 6951+ }
 6952+ if ( t ) {
 6953+ text = "\n" + text;
 6954+ }
 6955+
 6956+ // Check for following text
 6957+ t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next();
 6958+ while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
 6959+ t = t.next();
 6960+ }
 6961+ if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n'
 6962+ && t.node.nodeValue.charAt( 0 ) != '\r' ) {
 6963+ text += "\n";
 6964+ }
 6965+ $( this ).text( text );
69426966 } );
69436967 var retval;
69446968 if ( $.browser.msie ) {
@@ -7696,6 +7720,9 @@
76977721 .bind( 'keydown', function( event ) {
76987722 return context.fn.trigger( 'keydown', event );
76997723 } )
 7724+ .bind( 'paste', function( event ) {
 7725+ return context.fn.trigger( 'paste', event );
 7726+ } )
77007727 .bind( 'keyup mouseup paste cut encapsulateSelection', function( event ) {
77017728 return context.fn.trigger( 'change', event );
77027729 } )
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -454,7 +454,9 @@
455455 switch(event.which){case 8:break;}
456456 return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.fn.purgeOffsets();context.oldDelayedHTML=newHTML;event.data.scope='realchange';if(newHTML!==context.history[context.history.length+context.historyPosition].html){context.historyPosition=-1;}
457457 context.history.push({'html':newHTML});while(context.history.length>10){context.history.shift();}}
458 -return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};}
 458+return true;},'paste':function(event){context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');setTimeout(function(){var $selection=context.$content.find(':not(.wikiEditor)');while($selection.length&&$selection.length>0){var $currentElement=$selection.eq(0);while(!$currentElement.parent().is('body')&&!$currentElement.parent().is('.wikiEditor')){$currentElement=$currentElement.parent();}
 459+if($currentElement.is('br')){$currentElement.addClass('wikiEditor');}else{$('<p></p>').text($currentElement.text()).addClass('wikiEditor').insertAfter($currentElement);$currentElement.remove();}
 460+$selection=context.$content.find(':not(.wikiEditor)');}},100);return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};}
459461 if(typeof event.data=='undefined'){event.data={};}
460462 if(name in context.evt){if(!context.evt[name](event)){return false;}}
461463 for(var module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt[name](context,event);}}
@@ -528,7 +530,7 @@
529531 context.$iframe[0].contentWindow.focus();context.savedSelection.select();context.savedSelection=null;}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event);});context.$iframe=$('<iframe></iframe>').attr({'frameBorder':0,'border':0,'tabindex':1,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!this.isSecondRun){context.$iframe[0].contentWindow.document.designMode='on';if($.browser.msie){this.isSecondRun=true;return;}}
530532 context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val().replace(/&esc;/g,'&esc;esc;').replace(/\<p\>/g,'&esc;&lt;p&gt;').replace(/\<\/p\>/g,'&esc;&lt;/p&gt;').replace(/\<span class="wikiEditor-tab"\>\<\/span\>/g,'&esc;&lt;span&nbsp;class=&quot;wikiEditor-tab&quot;&gt;&lt;/span&gt;').replace(/&nbsp;/g,'&esc;&amp;nbsp;');if($.browser.msie){html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');if($.browser.versionNumber<=7){html=html.replace(/ /g,"&nbsp;");}else{html=html.replace(/(^|\n) /g,"$1&nbsp;");}}
531533 html=$('<div />').text('<p>'+html.replace(/\r?\n/g,'</p><p>')+'</p>').html().replace(/&amp;nbsp;/g,'&nbsp;').replace(/&lt;p&gt;/g,'<p>').replace(/&lt;\/p&gt;/g,'</p>').replace(/<p><\/p>/g,'<br>').replace(/&amp;esc;&amp;amp;nbsp;/g,'&amp;nbsp;').replace(/&amp;esc;&amp;lt;p&amp;gt;/g,'&lt;p&gt;').replace(/&amp;esc;&amp;lt;\/p&amp;gt;/g,'&lt;/p&gt;').replace(/&amp;esc;&amp;lt;span&amp;nbsp;class=&amp;quot;wikiEditor-tab&amp;quot;&amp;gt;&amp;lt;\/span&amp;gt;/g,'&lt;span class="wikiEditor-tab"&gt;&lt;\/span&gt;').replace(/&amp;esc;esc;/g,'&amp;esc;');context.$content.html(html);context.oldHTML=html;context.history.push({'html':html});if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');}
532 -context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('keyup mouseup paste cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};}
 534+context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('paste',function(event){return context.fn.trigger('paste',event);}).bind('keyup mouseup paste cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};}
533535 var args=$.makeArray(arguments);if(args.length>0){var call=args.shift();if(call in context.api){context.api[call](context,typeof args[0]=='undefined'?{}:args[0]);}}
534536 return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
535537 mw.usability.load(['$j.ui','$j.ui.dialog','$j.ui.draggable','$j.ui.resizable'],function(){for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');configuration.newButtons={};for(msg in configuration.buttons)

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62156fixes bug 22428nimishg01:42, 9 February 2010

Status & tagging log