Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,19 +72,19 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ), |
75 | 75 | 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 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 52 ), |
80 | 80 | 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 ), |
82 | 82 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ), |
83 | 83 | ), |
84 | 84 | 'combined' => array( |
85 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 118 ), |
| 85 | + array( 'src' => 'js/plugins.combined.js', 'version' => 119 ), |
86 | 86 | ), |
87 | 87 | 'minified' => array( |
88 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 118 ), |
| 88 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 119 ), |
89 | 89 | ), |
90 | 90 | ), |
91 | 91 | ); |
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.highlight.css |
— | — | @@ -2,11 +2,27 @@ |
3 | 3 | * not in the main document. For that reason, it's also not in the combined and |
4 | 4 | * minified files. |
5 | 5 | */ |
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 { |
7 | 14 | display: inline; |
| 15 | + cursor: pointer; |
8 | 16 | color: red; |
| 17 | + text-decoration: underline; |
9 | 18 | } |
10 | 19 | |
| 20 | +/* An expanded template */ |
| 21 | +.wikiEditor-template-expanded { |
| 22 | + display: inline; |
| 23 | + cursor: pointer; |
| 24 | +} |
| 25 | + |
| 26 | +/* == Header == */ |
11 | 27 | .wikiEditor-toc-header { /* TODO: move parsing to highlight module and rename this */ |
12 | 28 | display: inline; |
13 | 29 | font-weight: bold; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -38,9 +38,11 @@ |
39 | 39 | markers.push( { |
40 | 40 | start: tokenArray[beginIndex].offset, |
41 | 41 | 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 |
45 | 47 | } ); |
46 | 48 | } else { //else this was an unmatched opening |
47 | 49 | tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN'; |
— | — | @@ -70,44 +72,41 @@ |
71 | 73 | // Initialize module within the context |
72 | 74 | context.modules.templateEditor = {}; |
73 | 75 | }, |
74 | | - stylize: function( context ) { |
75 | | - var $templates = context.$content.find( '.wiki-template' ); |
76 | | - $templates.each( function() { |
| 76 | + stylize: function( wrappedTemplate ) { |
| 77 | + $( wrappedTemplate ).each( function() { |
77 | 78 | if ( typeof $(this).data( 'model' ) != 'undefined' ) { |
78 | 79 | // We have a model, so all this init stuff has already happened |
79 | 80 | return; |
80 | 81 | } |
81 | 82 | // Hide this |
82 | | - $(this).addClass( 'wikieditor-nodisplay' ); |
| 83 | + $(this).addClass( 'wikiEditor-nodisplay wikiEditor-template' ); |
83 | 84 | // 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() ) ); |
85 | 86 | var model = $(this).data( 'model' ); |
86 | 87 | // Expand |
87 | 88 | function expandTemplate( $displayDiv ) { |
88 | 89 | // 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' ); |
92 | 92 | $displayDiv.text( model.getText() ); |
93 | 93 | }; |
94 | 94 | // Collapse |
95 | 95 | function collapseTemplate( $displayDiv ) { |
96 | 96 | // 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' ); |
100 | 99 | $displayDiv.text( model.getName() ); |
101 | 100 | }; |
102 | 101 | // 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) ); |
107 | 106 | $(this).after( $visibleDiv ); |
108 | 107 | // Add click handler |
109 | | - $visibleDiv.click( function() { |
| 108 | + $visibleDiv.mousedown( function() { |
110 | 109 | // Is collapsed, switch to expand |
111 | | - if ( $(this).data( 'mode' ) == 'collapsed' ) { |
| 110 | + if ( $(this).hasClass( 'wikiEditor-template-collapsed' ) ) { |
112 | 111 | expandTemplate( $(this) ); |
113 | 112 | } else { |
114 | 113 | collapseTemplate( $(this) ); |
— | — | @@ -264,7 +263,7 @@ |
265 | 264 | newText = ""; |
266 | 265 | for ( i = 0 ; i < ranges.length; i++ ) { |
267 | 266 | 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 ); |
269 | 268 | } else { |
270 | 269 | newText += ranges[i].newVal; |
271 | 270 | } |
— | — | @@ -399,6 +398,13 @@ |
400 | 399 | } |
401 | 400 | // The rest of the string |
402 | 401 | 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; |
403 | 409 | } // model |
404 | 410 | } |
405 | 411 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | context.$content.parent().find( 'head' ).append( $j( '<link />' ).attr( { |
42 | 42 | 'rel': 'stylesheet', |
43 | 43 | 'type': 'text/css', |
44 | | - 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?0', |
| 44 | + 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?1', |
45 | 45 | } ) ); |
46 | 46 | // Highlight stuff for the first time |
47 | 47 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
— | — | @@ -198,7 +198,7 @@ |
199 | 199 | startDepth = depth; |
200 | 200 | } |
201 | 201 | // 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 |
203 | 203 | if ( startNode && markers[i].end > pos && markers[i].end <= newPos ) { |
204 | 204 | // The marker ends somewhere in this textNode |
205 | 205 | if ( markers[i].end < newPos ) { |
— | — | @@ -234,16 +234,10 @@ |
235 | 235 | ca2 = ca2.parentNode; |
236 | 236 | } |
237 | 237 | } |
238 | | - if ( ca1 && ca2 ) { |
| 238 | + if ( ca1 && ca2 && markers[i].needsWrap( ca1, ca2 ) ) { |
239 | 239 | // We have to store things like .parentNode and .nextSibling because appendChild() changes these |
240 | 240 | // 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' ); |
248 | 242 | var commonAncestor = ca1.parentNode; |
249 | 243 | var nextNode = ca2.nextSibling; |
250 | 244 | // Append all nodes between ca1 and ca2 (inclusive) to newNode |
— | — | @@ -253,12 +247,16 @@ |
254 | 248 | newNode.appendChild( n ); |
255 | 249 | n = ns; |
256 | 250 | } |
| 251 | + |
257 | 252 | // Insert newNode in the right place |
258 | 253 | if ( nextNode ) { |
259 | 254 | commonAncestor.insertBefore( newNode, nextNode ); |
260 | 255 | } else { |
261 | 256 | commonAncestor.appendChild( newNode ); |
262 | 257 | } |
| 258 | + |
| 259 | + // Allow the module adding this marker to manipulate it |
| 260 | + markers[i].afterWrap( newNode ); |
263 | 261 | } |
264 | 262 | // Clear for next iteration |
265 | 263 | startNode = null; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -2168,7 +2168,7 @@ |
2169 | 2169 | context.$content.parent().find( 'head' ).append( $j( '<link />' ).attr( { |
2170 | 2170 | 'rel': 'stylesheet', |
2171 | 2171 | 'type': 'text/css', |
2172 | | - 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?0', |
| 2172 | + 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?1', |
2173 | 2173 | } ) ); |
2174 | 2174 | // Highlight stuff for the first time |
2175 | 2175 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
— | — | @@ -2326,7 +2326,7 @@ |
2327 | 2327 | startDepth = depth; |
2328 | 2328 | } |
2329 | 2329 | // 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 |
2331 | 2331 | if ( startNode && markers[i].end > pos && markers[i].end <= newPos ) { |
2332 | 2332 | // The marker ends somewhere in this textNode |
2333 | 2333 | if ( markers[i].end < newPos ) { |
— | — | @@ -2362,16 +2362,10 @@ |
2363 | 2363 | ca2 = ca2.parentNode; |
2364 | 2364 | } |
2365 | 2365 | } |
2366 | | - if ( ca1 && ca2 ) { |
| 2366 | + if ( ca1 && ca2 && markers[i].needsWrap( ca1, ca2 ) ) { |
2367 | 2367 | // We have to store things like .parentNode and .nextSibling because appendChild() changes these |
2368 | 2368 | // 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' ); |
2376 | 2370 | var commonAncestor = ca1.parentNode; |
2377 | 2371 | var nextNode = ca2.nextSibling; |
2378 | 2372 | // Append all nodes between ca1 and ca2 (inclusive) to newNode |
— | — | @@ -2381,12 +2375,16 @@ |
2382 | 2376 | newNode.appendChild( n ); |
2383 | 2377 | n = ns; |
2384 | 2378 | } |
| 2379 | + |
2385 | 2380 | // Insert newNode in the right place |
2386 | 2381 | if ( nextNode ) { |
2387 | 2382 | commonAncestor.insertBefore( newNode, nextNode ); |
2388 | 2383 | } else { |
2389 | 2384 | commonAncestor.appendChild( newNode ); |
2390 | 2385 | } |
| 2386 | + |
| 2387 | + // Allow the module adding this marker to manipulate it |
| 2388 | + markers[i].afterWrap( newNode ); |
2391 | 2389 | } |
2392 | 2390 | // Clear for next iteration |
2393 | 2391 | startNode = null; |
— | — | @@ -2687,9 +2685,11 @@ |
2688 | 2686 | markers.push( { |
2689 | 2687 | start: tokenArray[beginIndex].offset, |
2690 | 2688 | 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 |
2694 | 2694 | } ); |
2695 | 2695 | } else { //else this was an unmatched opening |
2696 | 2696 | tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN'; |
— | — | @@ -2719,44 +2719,41 @@ |
2720 | 2720 | // Initialize module within the context |
2721 | 2721 | context.modules.templateEditor = {}; |
2722 | 2722 | }, |
2723 | | - stylize: function( context ) { |
2724 | | - var $templates = context.$content.find( '.wiki-template' ); |
2725 | | - $templates.each( function() { |
| 2723 | + stylize: function( wrappedTemplate ) { |
| 2724 | + $( wrappedTemplate ).each( function() { |
2726 | 2725 | if ( typeof $(this).data( 'model' ) != 'undefined' ) { |
2727 | 2726 | // We have a model, so all this init stuff has already happened |
2728 | 2727 | return; |
2729 | 2728 | } |
2730 | 2729 | // Hide this |
2731 | | - $(this).addClass( 'wikieditor-nodisplay' ); |
| 2730 | + $(this).addClass( 'wikiEditor-nodisplay wikiEditor-template' ); |
2732 | 2731 | // 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() ) ); |
2734 | 2733 | var model = $(this).data( 'model' ); |
2735 | 2734 | // Expand |
2736 | 2735 | function expandTemplate( $displayDiv ) { |
2737 | 2736 | // 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' ); |
2741 | 2739 | $displayDiv.text( model.getText() ); |
2742 | 2740 | }; |
2743 | 2741 | // Collapse |
2744 | 2742 | function collapseTemplate( $displayDiv ) { |
2745 | 2743 | // 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' ); |
2749 | 2746 | $displayDiv.text( model.getName() ); |
2750 | 2747 | }; |
2751 | 2748 | // 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) ); |
2756 | 2753 | $(this).after( $visibleDiv ); |
2757 | 2754 | // Add click handler |
2758 | | - $visibleDiv.click( function() { |
| 2755 | + $visibleDiv.mousedown( function() { |
2759 | 2756 | // Is collapsed, switch to expand |
2760 | | - if ( $(this).data( 'mode' ) == 'collapsed' ) { |
| 2757 | + if ( $(this).hasClass( 'wikiEditor-template-collapsed' ) ) { |
2761 | 2758 | expandTemplate( $(this) ); |
2762 | 2759 | } else { |
2763 | 2760 | collapseTemplate( $(this) ); |
— | — | @@ -2913,7 +2910,7 @@ |
2914 | 2911 | newText = ""; |
2915 | 2912 | for ( i = 0 ; i < ranges.length; i++ ) { |
2916 | 2913 | 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 ); |
2918 | 2915 | } else { |
2919 | 2916 | newText += ranges[i].newVal; |
2920 | 2917 | } |
— | — | @@ -3048,6 +3045,13 @@ |
3049 | 3046 | } |
3050 | 3047 | // The rest of the string |
3051 | 3048 | 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; |
3052 | 3056 | } // model |
3053 | 3057 | } |
3054 | 3058 | |
— | — | @@ -3468,9 +3472,8 @@ |
3469 | 3473 | outline[h] = { 'text': match[2], 'wrapper': div, 'level': match[1].length, 'index': h + 1 }; |
3470 | 3474 | h++; |
3471 | 3475 | } |
3472 | | - context.$content.html( context.$content.html().replace( /\r?\n/g, "<br>" ) ); |
3473 | 3476 | context.$content.each( traverseTextNodes ); |
3474 | | - |
| 3477 | + |
3475 | 3478 | // Normalize heading levels for list creation |
3476 | 3479 | // This is based on Linker::generateTOC(), so it should behave like the |
3477 | 3480 | // TOC on rendered articles does - which is considdered to be correct |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | 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);});} |
121 | 121 | var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
122 | 122 | 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;} |
124 | 124 | 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;} |
125 | 125 | match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;if(markAfter){markOffset+=match[0].length;} |
126 | 126 | 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 @@ |
135 | 135 | var ca1=startNode,ca2=node;if(startDepth>depth){for(var j=0;j<startDepth-depth&&ca1;j++){ca1=ca1.parentNode;}} |
136 | 136 | else if(startDepth<depth){for(var j=0;j<depth-startDepth&&ca2;j++){ca2=ca2.parentNode;}} |
137 | 137 | 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);} |
142 | 141 | startNode=null;startDepth=null;i++;} |
143 | 142 | pos=newPos;node=next;depth=nextDepth;}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={fn:{create:function(context,config){if('initialized'in context.modules.preview){return;} |
144 | 143 | 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 @@ |
172 | 171 | $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked')) |
173 | 172 | $('#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++;} |
174 | 173 | 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;} |
177 | 176 | function Range(begin,end){this.begin=begin;this.end=end;} |
178 | 177 | function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";} |
179 | 178 | rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);} |
— | — | @@ -180,7 +179,7 @@ |
181 | 180 | valueRange=ranges[params[rangeIndex].valueIndex];if(typeof valueRange.newVal=='undefined'||original){retVal=wikitext.substring(valueRange.begin,valueRange.end);}else{retVal=valueRange.newVal;} |
182 | 181 | if(value!=null){ranges[params[rangeIndex].valueIndex].newVal=value;} |
183 | 182 | 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;}} |
185 | 184 | return newText;};if(wikitext.match(/\s*{{\s*\S*:/)){} |
186 | 185 | var sanatizedStr=wikitext.replace(/{{/," ");endBraces=sanatizedStr.match(/}}\s*$/);sanatizedStr=sanatizedStr.substring(0,endBraces.index)+" "+ |
187 | 186 | 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 @@ |
191 | 190 | 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;} |
192 | 191 | 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;} |
193 | 192 | 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()- |
195 | 194 | context.$ui.find('.tab-toc').outerHeight());}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} |
196 | 195 | 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++;} |
197 | 196 | section=Math.max(0,section);} |
— | — | @@ -223,7 +222,7 @@ |
224 | 223 | div=$(this).parent();else if($(this).parent().is('div')) |
225 | 224 | div=$(this).parent().addClass('wikiEditor-toc-header');else{div=$('<div />').text(text).css('display','inline').addClass('wikiEditor-toc-header');$(this).replaceWith(div);} |
226 | 225 | 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++;} |
228 | 227 | else if(outline[i].level<lastLevel){nLevel-=Math.max(1,lastLevel-outline[i].level);} |
229 | 228 | if(nLevel<=0){nLevel=1;} |
230 | 229 | outline[i].nLevel=nLevel;lastLevel=outline[i].level;} |