r63867 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63866‎ | r63867 | r63868 >
Date:18:00, 17 March 2010
Author:tparscal
Status:ok
Tags:
Comment:
Fixed some problems with deleting everything from the contents of the iframe and also some javascript errors in IE8. Also took IE completely out of compatability for templateEditor.
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.highlight.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,20 +72,20 @@
7373 array( 'src' => 'js/plugins/jquery.delayedBind.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' => 174 ),
77 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 50 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 175 ),
 77+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 51 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 21 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
82 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 66 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 67 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 4 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 351 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 352 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 351 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 352 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -15,14 +15,14 @@
1616 'browsers': {
1717 // Left-to-right languages
1818 'ltr': {
19 - 'msie': [['>=', 8]],
 19+ 'msie': false,
2020 'firefox': [['>=', 3]],
2121 'opera': [['>=', 10]],
2222 'safari': [['>=', 4]]
2323 },
2424 // Right-to-left languages
2525 'rtl': {
26 - 'msie': [['>=', 8]],
 26+ 'msie': false,
2727 'firefox': [['>=', 3]],
2828 'opera': [['>=', 10]],
2929 'safari': [['>=', 4]]
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -381,7 +381,10 @@
382382 context.oldHTML = newHTML;
383383 event.data.scope = 'realchange';
384384 }
385 -
 385+ // Never let the body be totally empty
 386+ if ( context.$content.children().length == 0 ) {
 387+ context.$content.append( '<p></p>' );
 388+ }
386389 return true;
387390 },
388391 'delayedChange': function( event ) {
@@ -390,17 +393,15 @@
391394 if ( context.oldDelayedHTML != newHTML ) {
392395 context.oldDelayedHTML = newHTML;
393396 event.data.scope = 'realchange';
394 -
395 - //surround by <p> if it does not already have it
 397+ // Surround by <p> if it does not already have it
396398 var cursorPos = context.fn.getCaretPosition();
397399 var t = context.fn.getOffset( cursorPos[0] );
398 - if ( t.node.nodeName == '#text' && t.node.parentNode.nodeName.toLowerCase() == 'body' ) {
 400+ if ( t && t.node.nodeName == '#text' && t.node.parentNode.nodeName.toLowerCase() == 'body' ) {
399401 $( t.node ).wrap( "<p></p>" );
400402 context.fn.purgeOffsets();
401403 context.fn.setSelection( { start: cursorPos[0], end: cursorPos[1] } );
402404 }
403 - }
404 -
 405+ }
405406 context.fn.updateHistory( event.data.scope == 'realchange' );
406407 return true;
407408 },
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -157,7 +157,7 @@
158158
159159 // Recycle markers that will be skipped in this run
160160 if ( context.modules.highlight.markers && division != '' ) {
161 - for ( var i = 0; i < context.modules.markers.length; i++ ) {
 161+ for ( var i = 0; i < context.modules.highlight.markers.length; i++ ) {
162162 if ( context.modules.highlight.markers[i].skipDivision == division ) {
163163 markers.push( context.modules.highlight.markers[i] );
164164 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6924,7 +6924,10 @@
69256925 context.oldHTML = newHTML;
69266926 event.data.scope = 'realchange';
69276927 }
6928 -
 6928+ // Never let the body be totally empty
 6929+ if ( context.$content.children().length == 0 ) {
 6930+ context.$content.append( '<p></p>' );
 6931+ }
69296932 return true;
69306933 },
69316934 'delayedChange': function( event ) {
@@ -6933,17 +6936,15 @@
69346937 if ( context.oldDelayedHTML != newHTML ) {
69356938 context.oldDelayedHTML = newHTML;
69366939 event.data.scope = 'realchange';
6937 -
6938 - //surround by <p> if it does not already have it
 6940+ // Surround by <p> if it does not already have it
69396941 var cursorPos = context.fn.getCaretPosition();
69406942 var t = context.fn.getOffset( cursorPos[0] );
6941 - if ( t.node.nodeName == '#text' && t.node.parentNode.nodeName.toLowerCase() == 'body' ) {
 6943+ if ( t && t.node.nodeName == '#text' && t.node.parentNode.nodeName.toLowerCase() == 'body' ) {
69426944 $( t.node ).wrap( "<p></p>" );
69436945 context.fn.purgeOffsets();
69446946 context.fn.setSelection( { start: cursorPos[0], end: cursorPos[1] } );
69456947 }
6946 - }
6947 -
 6948+ }
69486949 context.fn.updateHistory( event.data.scope == 'realchange' );
69496950 return true;
69506951 },
@@ -8693,7 +8694,7 @@
86948695
86958696 // Recycle markers that will be skipped in this run
86968697 if ( context.modules.highlight.markers && division != '' ) {
8697 - for ( var i = 0; i < context.modules.markers.length; i++ ) {
 8698+ for ( var i = 0; i < context.modules.highlight.markers.length; i++ ) {
86988699 if ( context.modules.highlight.markers[i].skipDivision == division ) {
86998700 markers.push( context.modules.highlight.markers[i] );
87008701 }
@@ -9300,14 +9301,14 @@
93019302 'browsers': {
93029303 // Left-to-right languages
93039304 'ltr': {
9304 - 'msie': [['>=', 8]],
 9305+ 'msie': false,
93059306 'firefox': [['>=', 3]],
93069307 'opera': [['>=', 10]],
93079308 'safari': [['>=', 4]]
93089309 },
93099310 // Right-to-left languages
93109311 'rtl': {
9311 - 'msie': [['>=', 8]],
 9312+ 'msie': false,
93129313 'firefox': [['>=', 3]],
93139314 'opera': [['>=', 10]],
93149315 'safari': [['>=', 4]]
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -461,7 +461,8 @@
462462 break;case 86:if(event.ctrlKey){context.evt.paste(event);}
463463 break;}
464464 return true;},'change':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldHTML!=newHTML){context.fn.purgeOffsets();context.oldHTML=newHTML;event.data.scope='realchange';}
465 -return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.oldDelayedHTML=newHTML;event.data.scope='realchange';var cursorPos=context.fn.getCaretPosition();var t=context.fn.getOffset(cursorPos[0]);if(t.node.nodeName=='#text'&&t.node.parentNode.nodeName.toLowerCase()=='body'){$(t.node).wrap("<p></p>");context.fn.purgeOffsets();context.fn.setSelection({start:cursorPos[0],end:cursorPos[1]});}}
 465+if(context.$content.children().length==0){context.$content.append('<p></p>');}
 466+return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.oldDelayedHTML=newHTML;event.data.scope='realchange';var cursorPos=context.fn.getCaretPosition();var t=context.fn.getOffset(cursorPos[0]);if(t&&t.node.nodeName=='#text'&&t.node.parentNode.nodeName.toLowerCase()=='body'){$(t.node).wrap("<p></p>");context.fn.purgeOffsets();context.fn.setSelection({start:cursorPos[0],end:cursorPos[1]});}}
466467 context.fn.updateHistory(event.data.scope=='realchange');return true;},'cut':function(event){setTimeout(function(){context.$content.find('br').each(function(){if($(this).parent().is('body')){$(this).wrap($('<p></p>'));}});},100);return true;},'paste':function(event){var cursorPos=context.fn.getCaretPosition();var oldLength=context.fn.getContents().length;context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.addClass('pasting');}
467468 setTimeout(function(){context.$content.find('script,style,img,input,select,textarea,hr,button,link,meta').remove();context.$content.find('*').each(function(){if($(this).children().length==0&&this.childNodes.length>0){$(this).text($(this).text());}});var t=context.fn.traverser(context.$content);while(t){if(t.node.nodeName=='#text'){if(t.node.nodeValue==='\n'){$('<p><br></p>').insertAfter($(t.node));var oldNode=t.node;t=t.next();$(oldNode).remove();continue;}
468469 else if((t.node.nodeValue.indexOf('\n')!=1||t.node.nodeValue.indexOf('\r')!=-1)){t.node.nodeValue=t.node.nodeValue.replace(/\r|\n/g,' ');}}
@@ -587,7 +588,7 @@
588589 var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in context.modules){if(module in $.wikiEditor.modules&&'exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;}
589590 match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;var tokenStart=match.index+oldOffset+markOffset;if(markAfter){markOffset+=match[0].length;}
590591 tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
591 -tokenArray.sort(function(a,b){return a.offset-b.offset||a.tokenStart-b.tokenStart;});context.fn.trigger('scan');},mark:function(context,division,tokens){var markers=[];if(context.modules.highlight.markers&&division!=''){for(var i=0;i<context.modules.markers.length;i++){if(context.modules.highlight.markers[i].skipDivision==division){markers.push(context.modules.highlight.markers[i]);}}}
 592+tokenArray.sort(function(a,b){return a.offset-b.offset||a.tokenStart-b.tokenStart;});context.fn.trigger('scan');},mark:function(context,division,tokens){var markers=[];if(context.modules.highlight.markers&&division!=''){for(var i=0;i<context.modules.highlight.markers.length;i++){if(context.modules.highlight.markers[i].skipDivision==division){markers.push(context.modules.highlight.markers[i]);}}}
592593 context.modules.highlight.markers=markers;context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var markersStr='';for(var i=0;i<markers.length;i++){markersStr+=markers[i].start+','+markers[i].end+','+markers[i].type+',';}
593594 if(context.modules.highlight.markersStr==markersStr){return;}
594595 context.modules.highlight.markersStr=markersStr;var visited=[],v=0;for(var i=0;i<markers.length;i++){if(typeof markers[i].skipDivision!=='undefined'&&(division==markers[i].skipDivision)){continue;}
@@ -644,7 +645,7 @@
645646 $('#wikiEditor-'+context.instance+'-dialog-minor').hide();else if($('#wpMinoredit').is(':checked'))
646647 $('#wikiEditor-'+context.instance+'-dialog-minor').attr('checked','checked');if($('#wpWatchthis').size()==0)
647648 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
648 -$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={'nameMappings':{"Infobox skyscraper":"building_name","Infobox settlement":"official_name"},'browsers':{'ltr':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},'req':['iframe'],evt:{mark:function(context,event){if(context.modules.highlight.currentScope=='realchange'){return;}
 649+$('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={'nameMappings':{"Infobox skyscraper":"building_name","Infobox settlement":"official_name"},'browsers':{'ltr':{'msie':false,'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':false,'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},'req':['iframe'],evt:{mark:function(context,event){if(context.modules.highlight.currentScope=='realchange'){return;}
649650 var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;}
650651 if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length-1&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}}
651652 if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',afterWrap:function(node){var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if(model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(node));}else{$(node).addClass('wikiEditor-template-text');}},beforeUnwrap:function(node){if($(node).parent().hasClass('wikiEditor-template')){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}},onSkip:function(node){if($(node).html()==$(node).data('oldHTML')){return;}

Status & tagging log