r61288 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61287‎ | r61288 | r61289 >
Date:02:40, 20 January 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Make sure numbering in TOC classes is updated, fix freaky highlight but with template wrapper
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.templateEditor.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -158,7 +158,7 @@
159159 array(
160160 'src' => 'js/plugins/jquery.wikiEditor.highlight.js',
161161 'class' => 'j.wikiEditor.modules.highlight',
162 - 'version' => 15
 162+ 'version' => 16
163163 ),
164164 array(
165165 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js',
@@ -173,7 +173,7 @@
174174 array(
175175 'src' => 'js/plugins/jquery.wikiEditor.toc.js',
176176 'class' => 'j.wikiEditor.modules.toc',
177 - 'version' => 66
 177+ 'version' => 67
178178 ),
179179 array(
180180 'src' => 'js/plugins/jquery.wikiEditor.preview.js',
@@ -183,7 +183,7 @@
184184 array(
185185 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js',
186186 'class' => 'j.wikiEditor.modules.templateEditor',
187 - 'version' => 14
 187+ 'version' => 15
188188 ),
189189 array(
190190 'src' => 'js/plugins/jquery.wikiEditor.publish.js',
@@ -191,10 +191,10 @@
192192 'version' => 1 ),
193193 ),
194194 'combined' => array(
195 - array( 'src' => 'js/plugins.combined.js', 'version' => 161 ),
 195+ array( 'src' => 'js/plugins.combined.js', 'version' => 162 ),
196196 ),
197197 'minified' => array(
198 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 161 ),
 198+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 162 ),
199199 ),
200200 ),
201201 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -38,14 +38,18 @@
3939 markers.push( {
4040 start: tokenArray[beginIndex].offset,
4141 end: tokenArray[endIndex].offset,
 42+ anchor: 'wrap',
4243 afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize,
4344 beforeUnwrap: function( node ) {
4445 $( node ).data( 'display' ).remove();
4546 },
46 - getWrapper: function( ca1, ca2 ) {
47 - return $( ca1.parentNode ).is( 'div.wikiEditor-template' ) &&
48 - ca1.previousSibling == null &&
49 - ca1.nextSibling == null ?
 47+ onSkip: function() { },
 48+ getAnchor: function( ca1, ca2 ) {
 49+ // FIXME: Relies on the current <span> structure that is likely to die
 50+ return $( ca1.parentNode ).is( 'div.wikiEditor-template-text' ) &&
 51+ $( ca1.parentNode.previousSibling )
 52+ .is( 'ul.wikiEditor-template-modes' ) &&
 53+ ca1.parentNode.nextSibling == null ?
5054 ca1.parentNode : null;
5155 }
5256 } );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -83,16 +83,23 @@
8484 index: h,
8585 start: tokenArray[i].tokenStart,
8686 end: tokenArray[i].offset,
 87+ anchor: 'before',
8788 afterWrap: function( node ) {
8889 var marker = $( node ).data( 'marker' );
8990 $( node ).addClass( 'wikiEditor-toc-header' )
9091 .addClass( 'wikiEditor-toc-section-' + marker.index )
9192 .data( 'section', marker.index );
9293 },
93 - getWrapper: function( ca1, ca2 ) {
94 - return $( ca1.parentNode ).is( 'div.wikiEditor-toc-header' ) &&
95 - ca1.previousSibling == null && ca1.nextSibling == null ?
96 - ca1.parentNode : null;
 94+ onSkip: function( node ) {
 95+ var marker = $( node ).data( 'marker' );
 96+ $( node )
 97+ .removeClass( 'wikiEditor-toc-section-' + $( node ).data( 'section' ) )
 98+ .addClass( 'wikiEditor-toc-section-' + marker.index )
 99+ .data( 'section', marker.index );
 100+ },
 101+ getAnchor: function( ca1, ca2 ) {
 102+ return $( ca1.previousSibling ).is( 'div.wikiEditor-toc-header' ) ?
 103+ ca1.previousSibling : null;
97104 }
98105 } );
99106 outline.push ( {
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -178,13 +178,16 @@
179179 }
180180 // Filter nodes with the wikiEditor-noinclude class
181181 p = p ? p.nextSibling : null;
182 - while ( p && $( p ).hasClass( 'wikiEditor-noinclude' ) ) {
183 - p = p.nextSibling;
184 - }
185 - while ( p && p.firstChild ) {
186 - p = p.firstChild;
187 - nextDepth++;
188 - }
 182+ do {
 183+ while ( p && $( p ).hasClass( 'wikiEditor-noinclude' ) ) {
 184+ p = p.nextSibling;
 185+ }
 186+ if ( p && p.firstChild ) {
 187+ p = p.firstChild;
 188+ nextDepth++;
 189+ }
 190+ } while ( p && ( $( p ).hasClass( 'wikiEditor-noinclude' ) || p.firstChild ) );
 191+
189192 next = p;
190193 if ( node.nodeName != '#text' && node.nodeName != 'BR' ) {
191194 // Skip this node
@@ -264,28 +267,38 @@
265268 ca2 = ca2.parentNode.lastChild == ca2 ? ca2.parentNode : null;
266269 }
267270 if ( ca1 && ca2 ) {
268 - var wrapper = markers[i].getWrapper( ca1, ca2 );
269 - if ( !wrapper ) {
 271+ var anchor = markers[i].getAnchor( ca1, ca2 );
 272+ if ( !anchor ) {
270273 // We have to store things like .parentNode and .nextSibling because appendChild() changes these
271274 // properties
272275 var newNode = ca1.ownerDocument.createElement( 'div' );
273276 var commonAncestor = ca1.parentNode;
274277 var nextNode = ca2.nextSibling;
275 - // Append all nodes between ca1 and ca2 (inclusive) to newNode
276 - var n = ca1;
277 - while ( n != nextNode ) {
278 - var ns = n.nextSibling;
279 - newNode.appendChild( n );
280 - n = ns;
 278+ if ( markers[i].anchor == 'wrap' ) {
 279+ // Append all nodes between ca1 and ca2 (inclusive) to newNode
 280+ var n = ca1;
 281+ while ( n != nextNode ) {
 282+ var ns = n.nextSibling;
 283+ newNode.appendChild( n );
 284+ n = ns;
 285+ }
 286+
 287+ // Insert newNode in the right place
 288+ if ( nextNode ) {
 289+ commonAncestor.insertBefore( newNode, nextNode );
 290+ } else {
 291+ commonAncestor.appendChild( newNode );
 292+ }
 293+ } else if ( markers[i].anchor == 'before' ) {
 294+ commonAncestor.insertBefore( newNode, ca1 );
 295+ } else if ( markers[i].anchor == 'after' ) {
 296+ if ( nextNode ) {
 297+ commonAncestor.insertBefore( newNode, nextNode );
 298+ } else {
 299+ commonAncestor.appendChild( newNode );
 300+ }
281301 }
282302
283 - // Insert newNode in the right place
284 - if ( nextNode ) {
285 - commonAncestor.insertBefore( newNode, nextNode );
286 - } else {
287 - commonAncestor.appendChild( newNode );
288 - }
289 -
290303 $( newNode ).data( 'marker', markers[i] )
291304 .addClass( 'wikiEditor-highlight wikiEditor-highlight-tmp' );
292305
@@ -293,7 +306,10 @@
294307 markers[i].afterWrap( newNode, markers[i] );
295308 } else {
296309 // Temporarily add a class for bookkeeping purposes
297 - $( wrapper ).addClass( 'wikiEditor-highlight-tmp' );
 310+ $( anchor )
 311+ .addClass( 'wikiEditor-highlight-tmp' )
 312+ .data( 'marker', markers[i] );
 313+ markers[i].onSkip( anchor );
298314 }
299315 }
300316 // Clear for next iteration
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -7581,13 +7581,16 @@
75827582 }
75837583 // Filter nodes with the wikiEditor-noinclude class
75847584 p = p ? p.nextSibling : null;
7585 - while ( p && $( p ).hasClass( 'wikiEditor-noinclude' ) ) {
7586 - p = p.nextSibling;
7587 - }
7588 - while ( p && p.firstChild ) {
7589 - p = p.firstChild;
7590 - nextDepth++;
7591 - }
 7585+ do {
 7586+ while ( p && $( p ).hasClass( 'wikiEditor-noinclude' ) ) {
 7587+ p = p.nextSibling;
 7588+ }
 7589+ if ( p && p.firstChild ) {
 7590+ p = p.firstChild;
 7591+ nextDepth++;
 7592+ }
 7593+ } while ( p && ( $( p ).hasClass( 'wikiEditor-noinclude' ) || p.firstChild ) );
 7594+
75927595 next = p;
75937596 if ( node.nodeName != '#text' && node.nodeName != 'BR' ) {
75947597 // Skip this node
@@ -7667,28 +7670,38 @@
76687671 ca2 = ca2.parentNode.lastChild == ca2 ? ca2.parentNode : null;
76697672 }
76707673 if ( ca1 && ca2 ) {
7671 - var wrapper = markers[i].getWrapper( ca1, ca2 );
7672 - if ( !wrapper ) {
 7674+ var anchor = markers[i].getAnchor( ca1, ca2 );
 7675+ if ( !anchor ) {
76737676 // We have to store things like .parentNode and .nextSibling because appendChild() changes these
76747677 // properties
76757678 var newNode = ca1.ownerDocument.createElement( 'div' );
76767679 var commonAncestor = ca1.parentNode;
76777680 var nextNode = ca2.nextSibling;
7678 - // Append all nodes between ca1 and ca2 (inclusive) to newNode
7679 - var n = ca1;
7680 - while ( n != nextNode ) {
7681 - var ns = n.nextSibling;
7682 - newNode.appendChild( n );
7683 - n = ns;
 7681+ if ( markers[i].anchor == 'wrap' ) {
 7682+ // Append all nodes between ca1 and ca2 (inclusive) to newNode
 7683+ var n = ca1;
 7684+ while ( n != nextNode ) {
 7685+ var ns = n.nextSibling;
 7686+ newNode.appendChild( n );
 7687+ n = ns;
 7688+ }
 7689+
 7690+ // Insert newNode in the right place
 7691+ if ( nextNode ) {
 7692+ commonAncestor.insertBefore( newNode, nextNode );
 7693+ } else {
 7694+ commonAncestor.appendChild( newNode );
 7695+ }
 7696+ } else if ( markers[i].anchor == 'before' ) {
 7697+ commonAncestor.insertBefore( newNode, ca1 );
 7698+ } else if ( markers[i].anchor == 'after' ) {
 7699+ if ( nextNode ) {
 7700+ commonAncestor.insertBefore( newNode, nextNode );
 7701+ } else {
 7702+ commonAncestor.appendChild( newNode );
 7703+ }
76847704 }
76857705
7686 - // Insert newNode in the right place
7687 - if ( nextNode ) {
7688 - commonAncestor.insertBefore( newNode, nextNode );
7689 - } else {
7690 - commonAncestor.appendChild( newNode );
7691 - }
7692 -
76937706 $( newNode ).data( 'marker', markers[i] )
76947707 .addClass( 'wikiEditor-highlight wikiEditor-highlight-tmp' );
76957708
@@ -7696,7 +7709,10 @@
76977710 markers[i].afterWrap( newNode, markers[i] );
76987711 } else {
76997712 // Temporarily add a class for bookkeeping purposes
7700 - $( wrapper ).addClass( 'wikiEditor-highlight-tmp' );
 7713+ $( anchor )
 7714+ .addClass( 'wikiEditor-highlight-tmp' )
 7715+ .data( 'marker', markers[i] );
 7716+ markers[i].onSkip( anchor );
77017717 }
77027718 }
77037719 // Clear for next iteration
@@ -8023,14 +8039,18 @@
80248040 markers.push( {
80258041 start: tokenArray[beginIndex].offset,
80268042 end: tokenArray[endIndex].offset,
 8043+ anchor: 'wrap',
80278044 afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize,
80288045 beforeUnwrap: function( node ) {
80298046 $( node ).data( 'display' ).remove();
80308047 },
8031 - getWrapper: function( ca1, ca2 ) {
8032 - return $( ca1.parentNode ).is( 'div.wikiEditor-template' ) &&
8033 - ca1.previousSibling == null &&
8034 - ca1.nextSibling == null ?
 8048+ onSkip: function() { },
 8049+ getAnchor: function( ca1, ca2 ) {
 8050+ // FIXME: Relies on the current <span> structure that is likely to die
 8051+ return $( ca1.parentNode ).is( 'div.wikiEditor-template-text' ) &&
 8052+ $( ca1.parentNode.previousSibling )
 8053+ .is( 'ul.wikiEditor-template-modes' ) &&
 8054+ ca1.parentNode.nextSibling == null ?
80358055 ca1.parentNode : null;
80368056 }
80378057 } );
@@ -8662,16 +8682,23 @@
86638683 index: h,
86648684 start: tokenArray[i].tokenStart,
86658685 end: tokenArray[i].offset,
 8686+ anchor: 'before',
86668687 afterWrap: function( node ) {
86678688 var marker = $( node ).data( 'marker' );
86688689 $( node ).addClass( 'wikiEditor-toc-header' )
86698690 .addClass( 'wikiEditor-toc-section-' + marker.index )
86708691 .data( 'section', marker.index );
86718692 },
8672 - getWrapper: function( ca1, ca2 ) {
8673 - return $( ca1.parentNode ).is( 'div.wikiEditor-toc-header' ) &&
8674 - ca1.previousSibling == null && ca1.nextSibling == null ?
8675 - ca1.parentNode : null;
 8693+ onSkip: function( node ) {
 8694+ var marker = $( node ).data( 'marker' );
 8695+ $( node )
 8696+ .removeClass( 'wikiEditor-toc-section-' + $( node ).data( 'section' ) )
 8697+ .addClass( 'wikiEditor-toc-section-' + marker.index )
 8698+ .data( 'section', marker.index );
 8699+ },
 8700+ getAnchor: function( ca1, ca2 ) {
 8701+ return $( ca1.previousSibling ).is( 'div.wikiEditor-toc-header' ) ?
 8702+ ca1.previousSibling : null;
86768703 }
86778704 } );
86788705 outline.push ( {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -488,9 +488,8 @@
489489 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);}}}}
490490 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=context.modules.highlight.markers=[];context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var pos=0;var node=context.$content.get(0);var next=null;var i=0;var startNode=null;var depth=0,nextDepth=0,startDepth=null;var lastTextNode=null,lastTextNodeDepth=null;while(node.firstChild){node=node.firstChild;depth++;while(node&&$(node).hasClass('wikiEditor-noinclude')){node=node.nextSibling;}}
491491 while(i<markers.length&&node){var p=node;nextDepth=depth;while(p&&!p.nextSibling){p=p.parentNode;nextDepth--;}
492 -p=p?p.nextSibling:null;while(p&&$(p).hasClass('wikiEditor-noinclude')){p=p.nextSibling;}
493 -while(p&&p.firstChild){p=p.firstChild;nextDepth++;}
494 -next=p;if(node.nodeName!='#text'&&node.nodeName!='BR'){node=next;depth=nextDepth;continue;}
 492+p=p?p.nextSibling:null;do{while(p&&$(p).hasClass('wikiEditor-noinclude')){p=p.nextSibling;}
 493+if(p&&p.firstChild){p=p.firstChild;nextDepth++;}}while(p&&($(p).hasClass('wikiEditor-noinclude')||p.firstChild));next=p;if(node.nodeName!='#text'&&node.nodeName!='BR'){node=next;depth=nextDepth;continue;}
495494 var newPos=node.nodeName=='#text'?pos+node.nodeValue.length:pos+1;if(node.nodeName=='#text'){lastTextNode=node;lastTextNodeDepth=depth;}
496495 if(!startNode&&markers[i].start>=pos&&markers[i].start<newPos){if(markers[i].start>pos){node=node.splitText(markers[i].start-pos);pos=markers[i].start;}
497496 startNode=node;startDepth=depth;}
@@ -500,9 +499,9 @@
501500 var ca1=startNode,ca2=endNode;if(startDepth>endDepth){for(var j=0;j<startDepth-endDepth&&ca1;j++){ca1=ca1.parentNode.firstChild==ca1?ca1.parentNode:null;}}
502501 else if(startDepth<endDepth){for(var j=0;j<endDepth-startDepth&&ca2;j++){ca2=ca2.parentNode.lastChild==ca2?ca2.parentNode:null;}}
503502 while(ca1&&ca2&&ca1.parentNode!=ca2.parentNode){ca1=ca1.parentNode.firstChild==ca1?ca1.parentNode:null;ca2=ca2.parentNode.lastChild==ca2?ca2.parentNode:null;}
504 -if(ca1&&ca2){var wrapper=markers[i].getWrapper(ca1,ca2);if(!wrapper){var newNode=ca1.ownerDocument.createElement('div');var commonAncestor=ca1.parentNode;var nextNode=ca2.nextSibling;var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;}
505 -if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);}
506 -$(newNode).data('marker',markers[i]).addClass('wikiEditor-highlight wikiEditor-highlight-tmp');markers[i].afterWrap(newNode,markers[i]);}else{$(wrapper).addClass('wikiEditor-highlight-tmp');}}
 503+if(ca1&&ca2){var anchor=markers[i].getAnchor(ca1,ca2);if(!anchor){var newNode=ca1.ownerDocument.createElement('div');var commonAncestor=ca1.parentNode;var nextNode=ca2.nextSibling;if(markers[i].anchor=='wrap'){var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;}
 504+if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);}}else if(markers[i].anchor=='before'){commonAncestor.insertBefore(newNode,ca1);}else if(markers[i].anchor=='after'){if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);}}
 505+$(newNode).data('marker',markers[i]).addClass('wikiEditor-highlight wikiEditor-highlight-tmp');markers[i].afterWrap(newNode,markers[i]);}else{$(anchor).addClass('wikiEditor-highlight-tmp').data('marker',markers[i]);markers[i].onSkip(anchor);}}
507506 startNode=null;startDepth=null;i++;}
508507 pos=newPos;node=next;depth=nextDepth;}
509508 context.$content.find('div.wikiEditor-highlight:not(.wikiEditor-highlight-tmp)').each(function(){if(typeof $(this).data('marker').unwrap=='function')
@@ -538,7 +537,7 @@
539538 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
540539 $('#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={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++;}
541540 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;}}}
542 -if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){$(node).data('display').remove();},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-template')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});}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('model')!='undefined'){return;}
 541+if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,anchor:'wrap',afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){$(node).data('display').remove();},onSkip:function(){},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-template-text')&&$(ca1.parentNode.previousSibling).is('ul.wikiEditor-template-modes')&&ca1.parentNode.nextSibling==null?ca1.parentNode:null;}});}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('model')!='undefined'){return;}
543542 var model=new $.wikiEditor.modules.templateEditor.fn.model($(this).text());var $template=$(this).wrap('<div class="wikiEditor-template"></div>').addClass('wikiEditor-template-text wikiEditor-nodisplay').html($(this).html().replace(/\{\{/,'<span class="wikiEditor-template-start">{{</span><span class="wikiEditor-template-inner-text">').replace(/\}\}$/,'</span><span class="wikiEditor-template-end">}}</span>')).parent().addClass('wikiEditor-template-collapsed').data('model',model);$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(noEdit).prependTo($template);$template.find('.wikiEditor-template-end, .wikiEditor-template-start').mousedown(toggleWikiText);var $options=$('<ul />').addClass('wikiEditor-template-modes wikiEditor-noinclude').append($('<li />').addClass('wikiEditor-template-action-wikiText').append($('<img />').attr('src',$.wikiEditor.imgPath+'templateEditor/'+'wiki-text.png')).mousedown(toggleWikiText)).insertAfter($template.find('.wikiEditor-template-name'));$options.append($('<li />').addClass('wikiEditor-template-action-form').append($('<span>F</span>')).mousedown(function(){createDialog($template);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 templateModel=$templateDiv.data('model');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;}
544543 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);}
545544 $("<button></button>").click(function(){$('.wikiEditor-template-dialog-value input').each(function(){templateModel.setValue($(this).data('name'),$(this).val());});$dialog.dialog('close');}).text("OK").appendTo($dialog);$dialog.dialog();};function toggleWikiText(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-collapsed').toggleClass('wikiEditor-template-expanded').children('.wikiEditor-template-text, .wikiEditor-template-name, .wikiEditor-template-modes').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());}
@@ -577,7 +576,7 @@
578577 if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});}
579578 context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()-
580579 context.$ui.find('.tab-toc').outerHeight());context.modules.toc.$toc.data('previousWidth',context.$wikitext.width());},mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var outline=context.data.outline=[];var h=0;for(var i=0;i<tokenArray.length;i++){if(tokenArray[i].label!='TOC_HEADER'){continue;}
581 -h++;markers.push({index:h,start:tokenArray[i].tokenStart,end:tokenArray[i].offset,afterWrap:function(node){var marker=$(node).data('marker');$(node).addClass('wikiEditor-toc-header').addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);},getWrapper:function(ca1,ca2){return $(ca1.parentNode).is('div.wikiEditor-toc-header')&&ca1.previousSibling==null&&ca1.nextSibling==null?ca1.parentNode:null;}});outline.push({'text':tokenArray[i].match[2],'level':tokenArray[i].match[1].length,'index':h});}
 580+h++;markers.push({index:h,start:tokenArray[i].tokenStart,end:tokenArray[i].offset,anchor:'before',afterWrap:function(node){var marker=$(node).data('marker');$(node).addClass('wikiEditor-toc-header').addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);},onSkip:function(node){var marker=$(node).data('marker');$(node).removeClass('wikiEditor-toc-section-'+$(node).data('section')).addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);},getAnchor:function(ca1,ca2){return $(ca1.previousSibling).is('div.wikiEditor-toc-header')?ca1.previousSibling:null;}});outline.push({'text':tokenArray[i].match[2],'level':tokenArray[i].match[1].length,'index':h});}
582581 $.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}},exp:[{'regex':/^(={1,6})(.+?)\1\s*$/m,'label':'TOC_HEADER','markAfter':true}],fn:{create:function(context,config){if('$toc'in context.modules.toc){return;}
583582 $.wikiEditor.modules.toc.cfg.rtl=config.rtl;var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.toc.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context).data('positionMode','regular').data('collapsed',false);context.$ui.find('.wikiEditor-ui-right').append(context.modules.toc.$toc);context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());$.wikiEditor.modules.toc.fn.redraw(context,$.wikiEditor.modules.toc.cfg.defaultWidth);},redraw:function(context,fixedWidth){var fixedWidth=parseFloat(fixedWidth);if(context.modules.toc.$toc.data('positionMode')=='regular'){context.$ui.find('.wikiEditor-ui-right').css('width',fixedWidth+'px');context.$ui.find('.wikiEditor-ui-left').css('marginRight',(-1*fixedWidth)+'px').children().css('marginRight',fixedWidth+'px');}else if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.$ui.find('.wikiEditor-ui-left').css('width',fixedWidth);context.$ui.find('.wikiEditor-ui-right').css('left',fixedWidth);context.$wikitext.css('height',context.$ui.find('.wikiEditor-ui-right').height());}},switchLayout:function(context){var width,height=context.$ui.find('.wikiEditor-ui-right').height();if(context.modules.toc.$toc.data('positionMode')=='regular'&&!context.modules.toc.$toc.data('collapsed')){context.modules.toc.$toc.data('positionMode','goofy');context.modules.toc.$toc.data('positionModeChangeAt',context.$ui.find('.wikiEditor-ui-right').width());width=$.wikiEditor.modules.toc.cfg.textMinimumWidth;context.$ui.find('.wikiEditor-ui-left').css({'marginRight':'','position':'absolute','left':'0px','right':'auto','float':'none'}).children().css('marginRight','');context.$ui.find('.wikiEditor-ui-right').css({'width':'100%','position':'absolute','right':'0px','width':'auto','float':'none'});context.$wikitext.css('position','relative');}else if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.modules.toc.$toc.data('positionMode','regular');width=context.$wikitext.width()-context.$ui.find('.wikiEditor-ui-left').width();if(width>context.modules.toc.$toc.data('positionModeChangeAt')){width=context.modules.toc.$toc.data('positionModeChangeAt');}
584583 context.$wikitext.css({'position':'','height':''});context.$ui.find('.wikiEditor-ui-right').css({'marginRight':'','position':'','left':'','right':'','float':'','top':'','height':''});context.$ui.find('.wikiEditor-ui-left').css({'width':'','position':'','left':'','float':'','right':''});}

Status & tagging log