Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | array( |
160 | 160 | 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', |
161 | 161 | 'class' => 'j.wikiEditor.modules.highlight', |
162 | | - 'version' => 15 |
| 162 | + 'version' => 16 |
163 | 163 | ), |
164 | 164 | array( |
165 | 165 | 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', |
— | — | @@ -173,7 +173,7 @@ |
174 | 174 | array( |
175 | 175 | 'src' => 'js/plugins/jquery.wikiEditor.toc.js', |
176 | 176 | 'class' => 'j.wikiEditor.modules.toc', |
177 | | - 'version' => 66 |
| 177 | + 'version' => 67 |
178 | 178 | ), |
179 | 179 | array( |
180 | 180 | 'src' => 'js/plugins/jquery.wikiEditor.preview.js', |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | array( |
185 | 185 | 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', |
186 | 186 | 'class' => 'j.wikiEditor.modules.templateEditor', |
187 | | - 'version' => 14 |
| 187 | + 'version' => 15 |
188 | 188 | ), |
189 | 189 | array( |
190 | 190 | 'src' => 'js/plugins/jquery.wikiEditor.publish.js', |
— | — | @@ -191,10 +191,10 @@ |
192 | 192 | 'version' => 1 ), |
193 | 193 | ), |
194 | 194 | 'combined' => array( |
195 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 161 ), |
| 195 | + array( 'src' => 'js/plugins.combined.js', 'version' => 162 ), |
196 | 196 | ), |
197 | 197 | 'minified' => array( |
198 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 161 ), |
| 198 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 162 ), |
199 | 199 | ), |
200 | 200 | ), |
201 | 201 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -38,14 +38,18 @@ |
39 | 39 | markers.push( { |
40 | 40 | start: tokenArray[beginIndex].offset, |
41 | 41 | end: tokenArray[endIndex].offset, |
| 42 | + anchor: 'wrap', |
42 | 43 | afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize, |
43 | 44 | beforeUnwrap: function( node ) { |
44 | 45 | $( node ).data( 'display' ).remove(); |
45 | 46 | }, |
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 ? |
50 | 54 | ca1.parentNode : null; |
51 | 55 | } |
52 | 56 | } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -83,16 +83,23 @@ |
84 | 84 | index: h, |
85 | 85 | start: tokenArray[i].tokenStart, |
86 | 86 | end: tokenArray[i].offset, |
| 87 | + anchor: 'before', |
87 | 88 | afterWrap: function( node ) { |
88 | 89 | var marker = $( node ).data( 'marker' ); |
89 | 90 | $( node ).addClass( 'wikiEditor-toc-header' ) |
90 | 91 | .addClass( 'wikiEditor-toc-section-' + marker.index ) |
91 | 92 | .data( 'section', marker.index ); |
92 | 93 | }, |
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; |
97 | 104 | } |
98 | 105 | } ); |
99 | 106 | outline.push ( { |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -178,13 +178,16 @@ |
179 | 179 | } |
180 | 180 | // Filter nodes with the wikiEditor-noinclude class |
181 | 181 | 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 | + |
189 | 192 | next = p; |
190 | 193 | if ( node.nodeName != '#text' && node.nodeName != 'BR' ) { |
191 | 194 | // Skip this node |
— | — | @@ -264,28 +267,38 @@ |
265 | 268 | ca2 = ca2.parentNode.lastChild == ca2 ? ca2.parentNode : null; |
266 | 269 | } |
267 | 270 | 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 ) { |
270 | 273 | // We have to store things like .parentNode and .nextSibling because appendChild() changes these |
271 | 274 | // properties |
272 | 275 | var newNode = ca1.ownerDocument.createElement( 'div' ); |
273 | 276 | var commonAncestor = ca1.parentNode; |
274 | 277 | 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 | + } |
281 | 301 | } |
282 | 302 | |
283 | | - // Insert newNode in the right place |
284 | | - if ( nextNode ) { |
285 | | - commonAncestor.insertBefore( newNode, nextNode ); |
286 | | - } else { |
287 | | - commonAncestor.appendChild( newNode ); |
288 | | - } |
289 | | - |
290 | 303 | $( newNode ).data( 'marker', markers[i] ) |
291 | 304 | .addClass( 'wikiEditor-highlight wikiEditor-highlight-tmp' ); |
292 | 305 | |
— | — | @@ -293,7 +306,10 @@ |
294 | 307 | markers[i].afterWrap( newNode, markers[i] ); |
295 | 308 | } else { |
296 | 309 | // 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 ); |
298 | 314 | } |
299 | 315 | } |
300 | 316 | // Clear for next iteration |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7581,13 +7581,16 @@ |
7582 | 7582 | } |
7583 | 7583 | // Filter nodes with the wikiEditor-noinclude class |
7584 | 7584 | 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 | + |
7592 | 7595 | next = p; |
7593 | 7596 | if ( node.nodeName != '#text' && node.nodeName != 'BR' ) { |
7594 | 7597 | // Skip this node |
— | — | @@ -7667,28 +7670,38 @@ |
7668 | 7671 | ca2 = ca2.parentNode.lastChild == ca2 ? ca2.parentNode : null; |
7669 | 7672 | } |
7670 | 7673 | 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 ) { |
7673 | 7676 | // We have to store things like .parentNode and .nextSibling because appendChild() changes these |
7674 | 7677 | // properties |
7675 | 7678 | var newNode = ca1.ownerDocument.createElement( 'div' ); |
7676 | 7679 | var commonAncestor = ca1.parentNode; |
7677 | 7680 | 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 | + } |
7684 | 7704 | } |
7685 | 7705 | |
7686 | | - // Insert newNode in the right place |
7687 | | - if ( nextNode ) { |
7688 | | - commonAncestor.insertBefore( newNode, nextNode ); |
7689 | | - } else { |
7690 | | - commonAncestor.appendChild( newNode ); |
7691 | | - } |
7692 | | - |
7693 | 7706 | $( newNode ).data( 'marker', markers[i] ) |
7694 | 7707 | .addClass( 'wikiEditor-highlight wikiEditor-highlight-tmp' ); |
7695 | 7708 | |
— | — | @@ -7696,7 +7709,10 @@ |
7697 | 7710 | markers[i].afterWrap( newNode, markers[i] ); |
7698 | 7711 | } else { |
7699 | 7712 | // 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 ); |
7701 | 7717 | } |
7702 | 7718 | } |
7703 | 7719 | // Clear for next iteration |
— | — | @@ -8023,14 +8039,18 @@ |
8024 | 8040 | markers.push( { |
8025 | 8041 | start: tokenArray[beginIndex].offset, |
8026 | 8042 | end: tokenArray[endIndex].offset, |
| 8043 | + anchor: 'wrap', |
8027 | 8044 | afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize, |
8028 | 8045 | beforeUnwrap: function( node ) { |
8029 | 8046 | $( node ).data( 'display' ).remove(); |
8030 | 8047 | }, |
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 ? |
8035 | 8055 | ca1.parentNode : null; |
8036 | 8056 | } |
8037 | 8057 | } ); |
— | — | @@ -8662,16 +8682,23 @@ |
8663 | 8683 | index: h, |
8664 | 8684 | start: tokenArray[i].tokenStart, |
8665 | 8685 | end: tokenArray[i].offset, |
| 8686 | + anchor: 'before', |
8666 | 8687 | afterWrap: function( node ) { |
8667 | 8688 | var marker = $( node ).data( 'marker' ); |
8668 | 8689 | $( node ).addClass( 'wikiEditor-toc-header' ) |
8669 | 8690 | .addClass( 'wikiEditor-toc-section-' + marker.index ) |
8670 | 8691 | .data( 'section', marker.index ); |
8671 | 8692 | }, |
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; |
8676 | 8703 | } |
8677 | 8704 | } ); |
8678 | 8705 | outline.push ( { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -488,9 +488,8 @@ |
489 | 489 | 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);}}}} |
490 | 490 | 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;}} |
491 | 491 | 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;} |
495 | 494 | var newPos=node.nodeName=='#text'?pos+node.nodeValue.length:pos+1;if(node.nodeName=='#text'){lastTextNode=node;lastTextNodeDepth=depth;} |
496 | 495 | 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;} |
497 | 496 | startNode=node;startDepth=depth;} |
— | — | @@ -500,9 +499,9 @@ |
501 | 500 | 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;}} |
502 | 501 | else if(startDepth<endDepth){for(var j=0;j<endDepth-startDepth&&ca2;j++){ca2=ca2.parentNode.lastChild==ca2?ca2.parentNode:null;}} |
503 | 502 | 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);}} |
507 | 506 | startNode=null;startDepth=null;i++;} |
508 | 507 | pos=newPos;node=next;depth=nextDepth;} |
509 | 508 | context.$content.find('div.wikiEditor-highlight:not(.wikiEditor-highlight-tmp)').each(function(){if(typeof $(this).data('marker').unwrap=='function') |
— | — | @@ -538,7 +537,7 @@ |
539 | 538 | $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked')) |
540 | 539 | $('#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++;} |
541 | 540 | 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;} |
543 | 542 | 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;} |
544 | 543 | 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);} |
545 | 544 | $("<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 @@ |
578 | 577 | if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});} |
579 | 578 | context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
580 | 579 | 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});} |
582 | 581 | $.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;} |
583 | 582 | $.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');} |
584 | 583 | 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':''});} |