r60127 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60126‎ | r60127 | r60128 >
Date:18:57, 16 December 2009
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Template folding works now, yay! Replace the wrapElement() function in the marker objects with needsWrap() and afterWrap(). Rewrite stylize() so it can be used as an afterWrap() callback. Minor fixes. Haven't tested this extensively yet, still has some known issues.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/wikiEditor.highlight.css (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)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,19 +72,19 @@
7373 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
7474 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 36 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 6 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 7 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 52 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 8 ),
81 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 8 ),
 81+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 9 ),
8282 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ),
8383 ),
8484 'combined' => array(
85 - array( 'src' => 'js/plugins.combined.js', 'version' => 118 ),
 85+ array( 'src' => 'js/plugins.combined.js', 'version' => 119 ),
8686 ),
8787 'minified' => array(
88 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 118 ),
 88+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 119 ),
8989 ),
9090 ),
9191 );
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.highlight.css
@@ -2,11 +2,27 @@
33 * not in the main document. For that reason, it's also not in the combined and
44 * minified files.
55 */
6 -.wikiEditor-highlight-template {
 6+
 7+/* Wikitext that's folded away and shouldn't be displayed */
 8+.wikiEditor-nodisplay {
 9+ display: none;
 10+}
 11+
 12+/* A collapsed template */
 13+.wikiEditor-template-collapsed {
714 display: inline;
 15+ cursor: pointer;
816 color: red;
 17+ text-decoration: underline;
918 }
1019
 20+/* An expanded template */
 21+.wikiEditor-template-expanded {
 22+ display: inline;
 23+ cursor: pointer;
 24+}
 25+
 26+/* == Header == */
1127 .wikiEditor-toc-header { /* TODO: move parsing to highlight module and rename this */
1228 display: inline;
1329 font-weight: bold;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -38,9 +38,11 @@
3939 markers.push( {
4040 start: tokenArray[beginIndex].offset,
4141 end: tokenArray[endIndex].offset,
42 - wrapElement: function() {
43 - return $( '<div />' ).addClass( 'wikiEditor-highlight-template' );
44 - }
 42+ needsWrap: function( ca1, ca2 ) {
 43+ return !$( ca1.parentNode ).is( 'div.wikiEditor-template' ) ||
 44+ ca1.previousSibling != null || ca1.nextSibling != null;
 45+ },
 46+ afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize
4547 } );
4648 } else { //else this was an unmatched opening
4749 tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN';
@@ -70,44 +72,41 @@
7173 // Initialize module within the context
7274 context.modules.templateEditor = {};
7375 },
74 - stylize: function( context ) {
75 - var $templates = context.$content.find( '.wiki-template' );
76 - $templates.each( function() {
 76+ stylize: function( wrappedTemplate ) {
 77+ $( wrappedTemplate ).each( function() {
7778 if ( typeof $(this).data( 'model' ) != 'undefined' ) {
7879 // We have a model, so all this init stuff has already happened
7980 return;
8081 }
8182 // Hide this
82 - $(this).addClass( 'wikieditor-nodisplay' );
 83+ $(this).addClass( 'wikiEditor-nodisplay wikiEditor-template' );
8384 // Build a model for this
84 - $(this).data( 'model' , new model( $( this ).text() ) );
 85+ $(this).data( 'model' , new $.wikiEditor.modules.templateEditor.fn.model( $(this).text() ) );
8586 var model = $(this).data( 'model' );
8687 // Expand
8788 function expandTemplate( $displayDiv ) {
8889 // Housekeeping
89 - $displayDiv.removeClass( 'wiki-collapsed-template' );
90 - $displayDiv.addClass( 'wiki-expanded-template' );
91 - $displayDiv.data( 'mode' ) = "expanded";
 90+ $displayDiv.removeClass( 'wikiEditor-template-collapsed' );
 91+ $displayDiv.addClass( 'wikiEditor-template-expanded' );
9292 $displayDiv.text( model.getText() );
9393 };
9494 // Collapse
9595 function collapseTemplate( $displayDiv ) {
9696 // Housekeeping
97 - $displayDiv.addClass( 'wiki-collapsed-template' );
98 - $displayDiv.removeClass( 'wiki-expanded-template' );
99 - $displayDiv.data( 'mode' ) = "collapsed";
 97+ $displayDiv.addClass( 'wikiEditor-template-collapsed' );
 98+ $displayDiv.removeClass( 'wikiEditor-template-expanded' );
10099 $displayDiv.text( model.getName() );
101100 };
102101 // Build the collapsed version of this template
103 - var $visibleDiv = $( "<div></div>" ).addClass( 'wikieditor-noinclude' );
104 - // Let these two know about eachother
105 - $(this).data( 'display' , $visibleDiv );
106 - $visibleDiv.data( 'wikitext-node', $(this) );
 102+ var $visibleDiv = $( "<div />" ).addClass( 'wikiEditor-noinclude' );
 103+ // Let these two know about each other
 104+ $(this).data( 'display', $visibleDiv );
 105+ $visibleDiv.data( 'wikitext', $(this) );
107106 $(this).after( $visibleDiv );
108107 // Add click handler
109 - $visibleDiv.click( function() {
 108+ $visibleDiv.mousedown( function() {
110109 // Is collapsed, switch to expand
111 - if ( $(this).data( 'mode' ) == 'collapsed' ) {
 110+ if ( $(this).hasClass( 'wikiEditor-template-collapsed' ) ) {
112111 expandTemplate( $(this) );
113112 } else {
114113 collapseTemplate( $(this) );
@@ -264,7 +263,7 @@
265264 newText = "";
266265 for ( i = 0 ; i < ranges.length; i++ ) {
267266 if( typeof ranges[i].newVal == 'undefined' ) {
268 - wikitext.substring( ranges[i].begin, ranges[i].end );
 267+ newText += wikitext.substring( ranges[i].begin, ranges[i].end );
269268 } else {
270269 newText += ranges[i].newVal;
271270 }
@@ -399,6 +398,13 @@
400399 }
401400 // The rest of the string
402401 ranges.push( new Range( valueEndIndex, wikitext.length ) );
 402+
 403+ // Save vars
 404+ this.ranges = ranges;
 405+ this.wikitext = wikitext;
 406+ this.params = params;
 407+ this.paramsByName = paramsByName;
 408+ this.templateNameIndex = templateNameIndex;
403409 } // model
404410 }
405411
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -40,7 +40,7 @@
4141 context.$content.parent().find( 'head' ).append( $j( '<link />' ).attr( {
4242 'rel': 'stylesheet',
4343 'type': 'text/css',
44 - 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?0',
 44+ 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?1',
4545 } ) );
4646 // Highlight stuff for the first time
4747 $.wikiEditor.modules.highlight.fn.scan( context, "" );
@@ -198,7 +198,7 @@
199199 startDepth = depth;
200200 }
201201 // TODO: What happens when wrapping a zero-length string?
202 - // TODO: Detect that something's already been wrapped and leave it alone
 202+ // TODO: Detect that something is wrapped but shouldn't be any more and unwrap it
203203 if ( startNode && markers[i].end > pos && markers[i].end <= newPos ) {
204204 // The marker ends somewhere in this textNode
205205 if ( markers[i].end < newPos ) {
@@ -234,16 +234,10 @@
235235 ca2 = ca2.parentNode;
236236 }
237237 }
238 - if ( ca1 && ca2 ) {
 238+ if ( ca1 && ca2 && markers[i].needsWrap( ca1, ca2 ) ) {
239239 // We have to store things like .parentNode and .nextSibling because appendChild() changes these
240240 // properties
241 - var newNode = markers[i].wrapElement;
242 - if ( typeof newNode == 'function' ) {
243 - newNode = newNode();
244 - }
245 - if ( newNode.jquery ) {
246 - newNode = newNode.get( 0 );
247 - }
 241+ var newNode = ca1.ownerDocument.createElement( 'div' );
248242 var commonAncestor = ca1.parentNode;
249243 var nextNode = ca2.nextSibling;
250244 // Append all nodes between ca1 and ca2 (inclusive) to newNode
@@ -253,12 +247,16 @@
254248 newNode.appendChild( n );
255249 n = ns;
256250 }
 251+
257252 // Insert newNode in the right place
258253 if ( nextNode ) {
259254 commonAncestor.insertBefore( newNode, nextNode );
260255 } else {
261256 commonAncestor.appendChild( newNode );
262257 }
 258+
 259+ // Allow the module adding this marker to manipulate it
 260+ markers[i].afterWrap( newNode );
263261 }
264262 // Clear for next iteration
265263 startNode = null;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -2168,7 +2168,7 @@
21692169 context.$content.parent().find( 'head' ).append( $j( '<link />' ).attr( {
21702170 'rel': 'stylesheet',
21712171 'type': 'text/css',
2172 - 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?0',
 2172+ 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?1',
21732173 } ) );
21742174 // Highlight stuff for the first time
21752175 $.wikiEditor.modules.highlight.fn.scan( context, "" );
@@ -2326,7 +2326,7 @@
23272327 startDepth = depth;
23282328 }
23292329 // TODO: What happens when wrapping a zero-length string?
2330 - // TODO: Detect that something's already been wrapped and leave it alone
 2330+ // TODO: Detect that something is wrapped but shouldn't be any more and unwrap it
23312331 if ( startNode && markers[i].end > pos && markers[i].end <= newPos ) {
23322332 // The marker ends somewhere in this textNode
23332333 if ( markers[i].end < newPos ) {
@@ -2362,16 +2362,10 @@
23632363 ca2 = ca2.parentNode;
23642364 }
23652365 }
2366 - if ( ca1 && ca2 ) {
 2366+ if ( ca1 && ca2 && markers[i].needsWrap( ca1, ca2 ) ) {
23672367 // We have to store things like .parentNode and .nextSibling because appendChild() changes these
23682368 // properties
2369 - var newNode = markers[i].wrapElement;
2370 - if ( typeof newNode == 'function' ) {
2371 - newNode = newNode();
2372 - }
2373 - if ( newNode.jquery ) {
2374 - newNode = newNode.get( 0 );
2375 - }
 2369+ var newNode = ca1.ownerDocument.createElement( 'div' );
23762370 var commonAncestor = ca1.parentNode;
23772371 var nextNode = ca2.nextSibling;
23782372 // Append all nodes between ca1 and ca2 (inclusive) to newNode
@@ -2381,12 +2375,16 @@
23822376 newNode.appendChild( n );
23832377 n = ns;
23842378 }
 2379+
23852380 // Insert newNode in the right place
23862381 if ( nextNode ) {
23872382 commonAncestor.insertBefore( newNode, nextNode );
23882383 } else {
23892384 commonAncestor.appendChild( newNode );
23902385 }
 2386+
 2387+ // Allow the module adding this marker to manipulate it
 2388+ markers[i].afterWrap( newNode );
23912389 }
23922390 // Clear for next iteration
23932391 startNode = null;
@@ -2687,9 +2685,11 @@
26882686 markers.push( {
26892687 start: tokenArray[beginIndex].offset,
26902688 end: tokenArray[endIndex].offset,
2691 - wrapElement: function() {
2692 - return $( '<div />' ).addClass( 'wikiEditor-highlight-template' );
2693 - }
 2689+ needsWrap: function( ca1, ca2 ) {
 2690+ return !$( ca1.parentNode ).is( 'div.wikiEditor-template' ) ||
 2691+ ca1.previousSibling != null || ca1.nextSibling != null;
 2692+ },
 2693+ afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize
26942694 } );
26952695 } else { //else this was an unmatched opening
26962696 tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN';
@@ -2719,44 +2719,41 @@
27202720 // Initialize module within the context
27212721 context.modules.templateEditor = {};
27222722 },
2723 - stylize: function( context ) {
2724 - var $templates = context.$content.find( '.wiki-template' );
2725 - $templates.each( function() {
 2723+ stylize: function( wrappedTemplate ) {
 2724+ $( wrappedTemplate ).each( function() {
27262725 if ( typeof $(this).data( 'model' ) != 'undefined' ) {
27272726 // We have a model, so all this init stuff has already happened
27282727 return;
27292728 }
27302729 // Hide this
2731 - $(this).addClass( 'wikieditor-nodisplay' );
 2730+ $(this).addClass( 'wikiEditor-nodisplay wikiEditor-template' );
27322731 // Build a model for this
2733 - $(this).data( 'model' , new model( $( this ).text() ) );
 2732+ $(this).data( 'model' , new $.wikiEditor.modules.templateEditor.fn.model( $(this).text() ) );
27342733 var model = $(this).data( 'model' );
27352734 // Expand
27362735 function expandTemplate( $displayDiv ) {
27372736 // Housekeeping
2738 - $displayDiv.removeClass( 'wiki-collapsed-template' );
2739 - $displayDiv.addClass( 'wiki-expanded-template' );
2740 - $displayDiv.data( 'mode' ) = "expanded";
 2737+ $displayDiv.removeClass( 'wikiEditor-template-collapsed' );
 2738+ $displayDiv.addClass( 'wikiEditor-template-expanded' );
27412739 $displayDiv.text( model.getText() );
27422740 };
27432741 // Collapse
27442742 function collapseTemplate( $displayDiv ) {
27452743 // Housekeeping
2746 - $displayDiv.addClass( 'wiki-collapsed-template' );
2747 - $displayDiv.removeClass( 'wiki-expanded-template' );
2748 - $displayDiv.data( 'mode' ) = "collapsed";
 2744+ $displayDiv.addClass( 'wikiEditor-template-collapsed' );
 2745+ $displayDiv.removeClass( 'wikiEditor-template-expanded' );
27492746 $displayDiv.text( model.getName() );
27502747 };
27512748 // Build the collapsed version of this template
2752 - var $visibleDiv = $( "<div></div>" ).addClass( 'wikieditor-noinclude' );
2753 - // Let these two know about eachother
2754 - $(this).data( 'display' , $visibleDiv );
2755 - $visibleDiv.data( 'wikitext-node', $(this) );
 2749+ var $visibleDiv = $( "<div />" ).addClass( 'wikiEditor-noinclude' );
 2750+ // Let these two know about each other
 2751+ $(this).data( 'display', $visibleDiv );
 2752+ $visibleDiv.data( 'wikitext', $(this) );
27562753 $(this).after( $visibleDiv );
27572754 // Add click handler
2758 - $visibleDiv.click( function() {
 2755+ $visibleDiv.mousedown( function() {
27592756 // Is collapsed, switch to expand
2760 - if ( $(this).data( 'mode' ) == 'collapsed' ) {
 2757+ if ( $(this).hasClass( 'wikiEditor-template-collapsed' ) ) {
27612758 expandTemplate( $(this) );
27622759 } else {
27632760 collapseTemplate( $(this) );
@@ -2913,7 +2910,7 @@
29142911 newText = "";
29152912 for ( i = 0 ; i < ranges.length; i++ ) {
29162913 if( typeof ranges[i].newVal == 'undefined' ) {
2917 - wikitext.substring( ranges[i].begin, ranges[i].end );
 2914+ newText += wikitext.substring( ranges[i].begin, ranges[i].end );
29182915 } else {
29192916 newText += ranges[i].newVal;
29202917 }
@@ -3048,6 +3045,13 @@
30493046 }
30503047 // The rest of the string
30513048 ranges.push( new Range( valueEndIndex, wikitext.length ) );
 3049+
 3050+ // Save vars
 3051+ this.ranges = ranges;
 3052+ this.wikitext = wikitext;
 3053+ this.params = params;
 3054+ this.paramsByName = paramsByName;
 3055+ this.templateNameIndex = templateNameIndex;
30523056 } // model
30533057 }
30543058
@@ -3468,9 +3472,8 @@
34693473 outline[h] = { 'text': match[2], 'wrapper': div, 'level': match[1].length, 'index': h + 1 };
34703474 h++;
34713475 }
3472 - context.$content.html( context.$content.html().replace( /\r?\n/g, "<br>" ) );
34733476 context.$content.each( traverseTextNodes );
3474 -
 3477+
34753478 // Normalize heading levels for list creation
34763479 // This is based on Linker::generateTOC(), so it should behave like the
34773480 // TOC on rendered articles does - which is considdered to be correct
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -119,7 +119,7 @@
120120 configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});}
121121 var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
122122 maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);}
123 -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={evt:{change:function(context,event){if(event.data.scope=='keydown'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){context.$content.parent().find('head').append($j('<link />').attr({'rel':'stylesheet','type':'text/css','href':wgScriptPath+'/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?0',}));$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label){this.offset=offset;this.label=label;}
 123+$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={evt:{change:function(context,event){if(event.data.scope=='keydown'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){context.$content.parent().find('head').append($j('<link />').attr({'rel':'stylesheet','type':'text/css','href':wgScriptPath+'/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?1',}));$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label){this.offset=offset;this.label=label;}
124124 var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('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;}
125125 match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;if(markAfter){markOffset+=match[0].length;}
126126 tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
@@ -134,10 +134,9 @@
135135 var ca1=startNode,ca2=node;if(startDepth>depth){for(var j=0;j<startDepth-depth&&ca1;j++){ca1=ca1.parentNode;}}
136136 else if(startDepth<depth){for(var j=0;j<depth-startDepth&&ca2;j++){ca2=ca2.parentNode;}}
137137 while(ca1&&ca2&&ca1.parentNode!=ca2.parentNode){if(ca1.parentNode.firstChild!=ca1||ca2.parentNode.lastChild!=ca2){ca1=ca2=null;}else{ca1=ca1.parentNode;ca2=ca2.parentNode;}}
138 -if(ca1&&ca2){var newNode=markers[i].wrapElement;if(typeof newNode=='function'){newNode=newNode();}
139 -if(newNode.jquery){newNode=newNode.get(0);}
140 -var commonAncestor=ca1.parentNode;var nextNode=ca2.nextSibling;var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;}
141 -if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);}}
 138+if(ca1&&ca2&&markers[i].needsWrap(ca1,ca2)){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;}
 139+if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);}
 140+markers[i].afterWrap(newNode);}
142141 startNode=null;startDepth=null;i++;}
143142 pos=newPos;node=next;depth=nextDepth;}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={fn:{create:function(context,config){if('initialized'in context.modules.preview){return;}
144143 context.modules.preview={'initialized':true,'previewText':null,'changesText':null};context.modules.preview.$preview=context.fn.addView({'name':'preview','titleMsg':'wikieditor-preview-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.previewText==wikitext){return;}
@@ -171,8 +170,8 @@
172171 $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked'))
173172 $('#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++;}
174173 if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}}
175 -if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,wrapElement:function(){return $('<div />').addClass('wikiEditor-highlight-template');}});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(context){var $templates=context.$content.find('.wiki-template');$templates.each(function(){if(typeof $(this).data('model')!='undefined'){return;}
176 -$(this).addClass('wikieditor-nodisplay');$(this).data('model',new model($(this).text()));var model=$(this).data('model');function expandTemplate($displayDiv){$displayDiv.removeClass('wiki-collapsed-template');$displayDiv.addClass('wiki-expanded-template');$displayDiv.data('mode')="expanded";$displayDiv.text(model.getText());};function collapseTemplate($displayDiv){$displayDiv.addClass('wiki-collapsed-template');$displayDiv.removeClass('wiki-expanded-template');$displayDiv.data('mode')="collapsed";$displayDiv.text(model.getName());};var $visibleDiv=$("<div></div>").addClass('wikieditor-noinclude');$(this).data('display',$visibleDiv);$visibleDiv.data('wikitext-node',$(this));$(this).after($visibleDiv);$visibleDiv.click(function(){if($(this).data('mode')=='collapsed'){expandTemplate($(this));}else{collapseTemplate($(this));}});collapseTemplate($visibleDiv);});},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;}
 174+if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,needsWrap:function(ca1,ca2){return!$(ca1.parentNode).is('div.wikiEditor-template')||ca1.previousSibling!=null||ca1.nextSibling!=null;},afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('model')!='undefined'){return;}
 175+$(this).addClass('wikiEditor-nodisplay wikiEditor-template');$(this).data('model',new $.wikiEditor.modules.templateEditor.fn.model($(this).text()));var model=$(this).data('model');function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$displayDiv.text(model.getText());};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};var $visibleDiv=$("<div />").addClass('wikiEditor-noinclude');$(this).data('display',$visibleDiv);$visibleDiv.data('wikitext',$(this));$(this).after($visibleDiv);$visibleDiv.mousedown(function(){if($(this).hasClass('wikiEditor-template-collapsed')){expandTemplate($(this));}else{collapseTemplate($(this));}});collapseTemplate($visibleDiv);});},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;}
177176 function Range(begin,end){this.begin=begin;this.end=end;}
178177 function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";}
179178 rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);}
@@ -180,7 +179,7 @@
181180 valueRange=ranges[params[rangeIndex].valueIndex];if(typeof valueRange.newVal=='undefined'||original){retVal=wikitext.substring(valueRange.begin,valueRange.end);}else{retVal=valueRange.newVal;}
182181 if(value!=null){ranges[params[rangeIndex].valueIndex].newVal=value;}
183182 return retVal;};this.getName=function(){if(typeof ranges[templateNameIndex].newVal=='undefined'){return wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);}else{return ranges[templateNameIndex].newVal;}};this.setName=function(name){ranges[templateNameIndex].newVal=name;};this.setValue=function(name,value){return getSetValue(name,value,false);};this.getValue=function(name){return getSetValue(name,null,false);};this.getOriginalValue=function(name){return getSetValue(name,null,true);};this.getAllParamNames=function(){return paramsByName;};this.getAllInitialParams=function(){return params;}
184 -this.getOriginalText=function(){return wikitext;};this.getText=function(){newText="";for(i=0;i<ranges.length;i++){if(typeof ranges[i].newVal=='undefined'){wikitext.substring(ranges[i].begin,ranges[i].end);}else{newText+=ranges[i].newVal;}}
 183+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;}}
185184 return newText;};if(wikitext.match(/\s*{{\s*\S*:/)){}
186185 var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+
187186 sanatizedStr.substring(endBraces.index+2);while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;}
@@ -190,7 +189,7 @@
191190 params.push(ranges[templateNameIndex].old);var currentParamNumber=0;var valueEndIndex;var paramsByName=[];while(!doneParsing){currentParamNumber++;oldDivider=divider;divider=sanatizedStr.indexOf('|',oldDivider+1);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;}
192191 currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){divider++;currentParamNumber--;continue;}
193192 nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}}
194 -ranges.push(new Range(valueEndIndex,wikitext.length));}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()-
 193+ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()-
195194 context.$ui.find('.tab-toc').outerHeight());}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;}
196195 var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.toc.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.cfg.defaultWidth).append(context.modules.toc.$toc);context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.cfg.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.cfg.defaultWidth);},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.textSelection('getCaretPosition');var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
197196 section=Math.max(0,section);}
@@ -223,7 +222,7 @@
224223 div=$(this).parent();else if($(this).parent().is('div'))
225224 div=$(this).parent().addClass('wikiEditor-toc-header');else{div=$('<div />').text(text).css('display','inline').addClass('wikiEditor-toc-header');$(this).replaceWith(div);}
226225 outline[h]={'text':match[2],'wrapper':div,'level':match[1].length,'index':h+1};h++;}
227 -context.$content.html(context.$content.html().replace(/\r?\n/g,"<br>"));context.$content.each(traverseTextNodes);var lastLevel=0;var nLevel=0;for(var i=0;i<outline.length;i++){if(outline[i].level>lastLevel){nLevel++;}
 226+context.$content.each(traverseTextNodes);var lastLevel=0;var nLevel=0;for(var i=0;i<outline.length;i++){if(outline[i].level>lastLevel){nLevel++;}
228227 else if(outline[i].level<lastLevel){nLevel-=Math.max(1,lastLevel-outline[i].level);}
229228 if(nLevel<=0){nLevel=1;}
230229 outline[i].nLevel=nLevel;lastLevel=outline[i].level;}

Status & tagging log