r62902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62901‎ | r62902 | r62903 >
Date:00:46, 24 February 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Restore cursor position after paste
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,20 +72,20 @@
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' => 151 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 152 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 34 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 50 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 18 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 93 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
82 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 24 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 25 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 283 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 284 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 283 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 284 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -401,6 +401,10 @@
402402 return true;
403403 },
404404 'paste': function( event ) {
 405+ // Save the cursor position to restore it after all this voodoo
 406+ var cursorPos = context.fn.getCaretPosition();
 407+ var oldLength = context.fn.getContents().length;
 408+
405409 context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' );
406410 if ( $.layout.name !== 'webkit' ) {
407411 context.$content.addClass( 'pasting' );
@@ -478,6 +482,11 @@
479483 if ( $.layout.name !== 'webkit' ) {
480484 context.$content.removeClass( 'pasting' );
481485 }
 486+
 487+ // Restore cursor position
 488+ context.fn.purgeOffsets();
 489+ var restoreTo = cursorPos[0] + context.fn.getContents().length - oldLength;
 490+ context.fn.setSelection( { start: restoreTo, end: restoreTo } );
482491 }, 0 );
483492 return true;
484493 },
@@ -1514,6 +1523,14 @@
15151524 ec = e ? e.node : null;
15161525 start = s ? s.offset : null;
15171526 end = e ? e.offset : null;
 1527+ // Don't try to set the selection past the end of a node, causes errors
 1528+ // Just put the selection at the end of the node in this case
 1529+ if ( sc.nodeName == '#text' && start >= sc.nodeValue.length ) {
 1530+ start = sc.nodeValue.length - 1;
 1531+ }
 1532+ if ( ec.nodeName == '#text' && end >= ec.nodeValue.length ) {
 1533+ end = ec.nodeValue.length - 1;
 1534+ }
15181535 }
15191536 if ( !sc || !ec ) {
15201537 // The requested offset isn't in the offsets array
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6834,6 +6834,10 @@
68356835 return true;
68366836 },
68376837 'paste': function( event ) {
 6838+ // Save the cursor position to restore it after all this voodoo
 6839+ var cursorPos = context.fn.getCaretPosition();
 6840+ var oldLength = context.fn.getContents().length;
 6841+
68386842 context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' );
68396843 if ( $.layout.name !== 'webkit' ) {
68406844 context.$content.addClass( 'pasting' );
@@ -6911,6 +6915,11 @@
69126916 if ( $.layout.name !== 'webkit' ) {
69136917 context.$content.removeClass( 'pasting' );
69146918 }
 6919+
 6920+ // Restore cursor position
 6921+ context.fn.purgeOffsets();
 6922+ var restoreTo = cursorPos[0] + context.fn.getContents().length - oldLength;
 6923+ context.fn.setSelection( { start: restoreTo, end: restoreTo } );
69156924 }, 0 );
69166925 return true;
69176926 },
@@ -7947,6 +7956,14 @@
79487957 ec = e ? e.node : null;
79497958 start = s ? s.offset : null;
79507959 end = e ? e.offset : null;
 7960+ // Don't try to set the selection past the end of a node, causes errors
 7961+ // Just put the selection at the end of the node in this case
 7962+ if ( sc.nodeName == '#text' && start >= sc.nodeValue.length ) {
 7963+ start = sc.nodeValue.length - 1;
 7964+ }
 7965+ if ( ec.nodeName == '#text' && end >= ec.nodeValue.length ) {
 7966+ end = ec.nodeValue.length - 1;
 7967+ }
79517968 }
79527969 if ( !sc || !ec ) {
79537970 // The requested offset isn't in the offsets array
@@ -9042,7 +9059,8 @@
90439060 return $( ca1.parentNode ).is( 'span.wikiEditor-template-text' ) ?
90449061 ca1.parentNode : null;
90459062 },
9046 - model: model
 9063+ model: model,
 9064+ context: context
90479065 } );
90489066 } else { //else this was an unmatched opening
90499067 tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN';
@@ -9084,10 +9102,11 @@
90859103 return;
90869104 }
90879105 var model = $(this).data( 'marker' ).model;
 9106+ var context = $(this).data( 'marker' ).context;
90889107
90899108 //check if model is collapsible
90909109 if ( !model.isCollapsible() ) {
9091 - $(this).addClass( 'wikiEditor-template-text' );
 9110+ //just treat it as normal text for now
90929111 return;
90939112 }
90949113
@@ -9117,19 +9136,11 @@
91189137 .append( '<img src="'+$.wikiEditor.imgPath+'/templateEditor/dialog-expanded.png" width="22" height="16" style="display:none;" />' )
91199138 .mousedown( function() { createDialog( $template ); return false; } )
91209139 .insertAfter( $templateName );
9121 - /*
9122 - var $options = $( '<ul />' )
9123 - .addClass( 'wikiEditor-template-modes wikiEditor-noinclude' )
9124 - .append( $( '<li />' )
9125 - .addClass( 'wikiEditor-template-action-wikiText' )
9126 - .append( $( '<img />' ).attr( 'src',
9127 - $.wikiEditor.imgPath + 'templateEditor/' + 'wiki-text.png' ) )
9128 - .mousedown( toggleWikiTextEditor ) )
9129 - .insertAfter( $template.find( '.wikiEditor-template-name' ) );
9130 - */
 9140+
91319141 $(this).data( 'setupDone', true );
91329142
91339143 function toggleWikiTextEditor(){
 9144+ context.fn.refreshOffsets();
91349145 var $template = $( this ).closest( '.wikiEditor-template' );
91359146 $template
91369147 .toggleClass( 'wikiEditor-template-expanded' )
@@ -9469,7 +9480,10 @@
94709481 }
94719482 };
94729483
9473 -
 9484+ //not collapsing "small" templates
 9485+ if( wikitext.length < 20 ){
 9486+ collapsible = false;
 9487+ }
94749488 // Whitespace* {{ whitespace* nonwhitespace:
94759489 if ( wikitext.match( /\s*{{\s*\S*:/ ) ) {
94769490 collapsible = false; // is a parser function
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -456,7 +456,7 @@
457457 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';}
458458 switch(event.which){case 8:break;}
459459 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';}
460 -context.fn.updateHistory(event.data.scope=='realchange');return true;},'paste':function(event){context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.addClass('pasting');}
 460+context.fn.updateHistory(event.data.scope=='realchange');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');}
461461 setTimeout(function(){context.$content.find('script,style,img,input,select,textarea,br,button').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;}
462462 else if((t.node.nodeValue.indexOf('\n')!=1||t.node.nodeValue.indexOf('\r')!=-1)){t.node.nodeValue=t.node.nodeValue.replace(/\r|\n/g,' ');}}
463463 t=t.next();}
@@ -464,7 +464,8 @@
465465 var html=$('<div></div>').text($currentElement.text().replace(/\r|\n/g,' ')).html();if($currentElement.is('br')){$currentElement.addClass('wikiEditor');}else if($currentElement.is('span')&&html.length==0){$currentElement.remove();}else if($currentElement.is('p')||$currentElement.is('div')){$newElement=$('<p></p>').addClass('wikiEditor').insertAfter($currentElement);if(html.length){$newElement.html(html);}else{$newElement.append($('<br>').addClass('wikiEditor'));}
466466 $currentElement.remove();}else{$newElement=$('<span></span>').html(html).insertAfter($currentElement);$newElement.replaceWith($newElement[0].childNodes);$currentElement.remove();}
467467 $selection=context.$content.find(':not(.wikiEditor)');}
468 -context.$content.find('.wikiEditor').removeClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.removeClass('pasting');}},0);return true;},'ready':function(event){context.history.push({'html':context.$content.html(),'sel':context.fn.getCaretPosition()});return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};}
 468+context.$content.find('.wikiEditor').removeClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.removeClass('pasting');}
 469+context.fn.purgeOffsets();var restoreTo=cursorPos[0]+context.fn.getContents().length-oldLength;context.fn.setSelection({start:restoreTo,end:restoreTo});},0);return true;},'ready':function(event){context.history.push({'html':context.$content.html(),'sel':context.fn.getCaretPosition()});return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};}
469470 if(typeof event.data=='undefined'){event.data={};}
470471 if(name in context.evt){if(!context.evt[name](event)){return false;}}
471472 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);}}
@@ -547,7 +548,8 @@
548549 if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}}
549550 if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1)
550551 if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));startPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=startPos+rawPeriText.replace(/\r\n/g,"\n").length;}catch(e){startPos=endPos=0;}}
551 -return[startPos,endPos];},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc&&sc.jquery?sc[0]:sc;ec=ec&&ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var start=options.start,end=options.end;if(!sc||!ec){var s=context.fn.getOffset(start);var e=context.fn.getOffset(end);sc=s?s.node:null;ec=e?e.node:null;start=s?s.offset:null;end=e?e.offset:null;}
 552+return[startPos,endPos];},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc&&sc.jquery?sc[0]:sc;ec=ec&&ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var start=options.start,end=options.end;if(!sc||!ec){var s=context.fn.getOffset(start);var e=context.fn.getOffset(end);sc=s?s.node:null;ec=e?e.node:null;start=s?s.offset:null;end=e?e.offset:null;if(sc.nodeName=='#text'&&start>=sc.nodeValue.length){start=sc.nodeValue.length-1;}
 553+if(ec.nodeName=='#text'&&end>=ec.nodeValue.length){end=ec.nodeValue.length-1;}}
552554 if(!sc||!ec){return context.$textarea;}
553555 var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;}
554556 while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;}
@@ -626,9 +628,9 @@
627629 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
628630 $('#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={'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){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++;}
629631 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;}}}
630 -if(endIndex!=-1){var model=new $.wikiEditor.modules.templateEditor.fn.model(context.fn.getContents().substring(tokenArray[beginIndex].offset,tokenArray[endIndex].offset));markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',splitPs:false,afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){},onSkip:function(){},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},model:model});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('setupDone')!='undefined'){return;}
631 -var model=$(this).data('marker').model;if(!model.isCollapsible()){$(this).addClass('wikiEditor-template-text');return;}
632 -var $template=$(this).wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(toggleWikiTextEditor).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/expand.png" width="12" height="16" />').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/collapse.png" width="12" height="16" style="display:none;" />').mousedown(toggleWikiTextEditor).prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/dialog-collapsed.png" width="22" height="16" />').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/dialog-expanded.png" width="22" height="16" style="display:none;" />').mousedown(function(){createDialog($template);return false;}).insertAfter($templateName);$(this).data('setupDone',true);function toggleWikiTextEditor(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('img').each(function(){$(this).toggle();});var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());}
 632+if(endIndex!=-1){var model=new $.wikiEditor.modules.templateEditor.fn.model(context.fn.getContents().substring(tokenArray[beginIndex].offset,tokenArray[endIndex].offset));markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',splitPs:false,afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){},onSkip:function(){},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},model:model,context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('setupDone')!='undefined'){return;}
 633+var model=$(this).data('marker').model;var context=$(this).data('marker').context;if(!model.isCollapsible()){return;}
 634+var $template=$(this).wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(toggleWikiTextEditor).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/expand.png" width="12" height="16" />').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/collapse.png" width="12" height="16" style="display:none;" />').mousedown(toggleWikiTextEditor).prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/dialog-collapsed.png" width="22" height="16" />').append('<img src="'+$.wikiEditor.imgPath+'/templateEditor/dialog-expanded.png" width="22" height="16" style="display:none;" />').mousedown(function(){createDialog($template);return false;}).insertAfter($templateName);$(this).data('setupDone',true);function toggleWikiTextEditor(){context.fn.refreshOffsets();var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('img').each(function(){$(this).toggle();});var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());}
633635 else{$wikitext.text($template.data('model').getText());}
634636 return false;};function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$displayDiv.unbind('mousedown');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};function createDialog($templateDiv){var $wikitext=$templateDiv.children('.wikiEditor-template-text');var templateModel=new $.wikiEditor.modules.templateEditor.fn.model($wikitext.text());$templateDiv.data('model',templateModel);var $dialog=$("<div></div>");var $title=$("<div>"+templateModel.getName()+"</div>").addClass('wikiEditor-template-dialog-title');var $table=$("<table></table>").addClass('wikiEditor-template-dialog-table').appendTo($dialog);var allInitialParams=templateModel.getAllInitialParams();for(var paramIndex in allInitialParams){var param=allInitialParams[paramIndex];if(typeof param.name=='undefined'){continue;}
635637 var $paramRow=$("<tr></tr>").addClass('wikiEditor-template-dialog-row');var $paramName=$("<td></td>").addClass('wikiEditor-template-dialog-name').text(param.name);var $paramVal=$("<td></td>").addClass('wikiEditor-template-dialog-value');var $paramInput=$("<input></input>").data('name',param.name).val(templateModel.getValue(param.name));$paramVal.append($paramInput);$paramRow.append($paramName).append($paramVal);$table.append($paramRow);}
@@ -646,7 +648,8 @@
647649 this.getOriginalText=function(){return wikitext;};this.getText=function(){newText="";for(i=0;i<ranges.length;i++){if(typeof ranges[i].newVal=='undefined'){newText+=wikitext.substring(ranges[i].begin,ranges[i].end);}else{newText+=ranges[i].newVal;}}
648650 return newText;};this.isCollapsible=function(){return collapsible;}
649651 this.updateRanges=function(){var adjustment=0;for(var i=0;i<ranges.length;i++){ranges[i].begin+=adjustment;if(typeof ranges[i].adjust!='undefined'){adjustment+=ranges[i].adjust();delete ranges[i].adjust;}
650 -ranges[i].end+=adjustment;}};if(wikitext.match(/\s*{{\s*\S*:/)){collapsible=false;}
 652+ranges[i].end+=adjustment;}};if(wikitext.length<20){collapsible=false;}
 653+if(wikitext.match(/\s*{{\s*\S*:/)){collapsible=false;}
651654 var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);if(endBraces){sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+
652655 sanatizedStr.substring(endBraces.index+2);}
653656 while(sanatizedStr.indexOf('<!')!=-1){startIndex=sanatizedStr.indexOf('<!');endIndex=sanatizedStr.indexOf('-->')+3;sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/\S/g,' ');sanatizedStr=sanatizedStr.substring(0,startIndex)+sanatizedSegment+sanatizedStr.substring(endIndex);}

Status & tagging log