Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,20 +72,20 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 131 ), |
77 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 30 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 132 ), |
| 77 | + array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 31 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 49 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 15 ), |
80 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 86 ), |
| 80 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 87 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 10 ), |
82 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 17 ), |
| 82 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 18 ), |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 253 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 254 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 253 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 254 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -53,24 +53,29 @@ |
54 | 54 | } |
55 | 55 | }//while finding template ending |
56 | 56 | if ( endIndex != -1 ) { |
| 57 | + // Create a model for the template |
| 58 | + var model = new $.wikiEditor.modules.templateEditor.fn.model( |
| 59 | + context.fn.getContents().substring( tokenArray[beginIndex].offset, |
| 60 | + tokenArray[endIndex].offset |
| 61 | + ) |
| 62 | + ); |
57 | 63 | markers.push( { |
58 | 64 | start: tokenArray[beginIndex].offset, |
59 | 65 | end: tokenArray[endIndex].offset, |
60 | 66 | type: 'template', |
61 | 67 | anchor: 'wrap', |
| 68 | + splitPs: model.isCollapsible(), |
62 | 69 | afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize, |
63 | 70 | beforeUnwrap: function( node ) { |
64 | 71 | $( node ).data( 'display' ).remove(); |
65 | 72 | }, |
66 | | - onSkip: function() { }, |
67 | | - getAnchor: function( ca1, ca2 ) { |
| 73 | + onSkip: function() { }, // TODO update template info |
| 74 | + getAnchor: function( ca1, ca2 ) { |
68 | 75 | // FIXME: Relies on the current <span> structure that is likely to die |
69 | | - return $( ca1.parentNode ).is( 'div.wikiEditor-template-text' ) && |
70 | | - $( ca1.parentNode.previousSibling ) |
71 | | - .is( 'ul.wikiEditor-template-modes' ) && |
72 | | - ca1.parentNode.nextSibling == null ? |
| 76 | + return $( ca1.parentNode ).is( 'span.wikiEditor-template-text' ) ? |
73 | 77 | ca1.parentNode : null; |
74 | | - } |
| 78 | + }, |
| 79 | + model: model |
75 | 80 | } ); |
76 | 81 | } else { //else this was an unmatched opening |
77 | 82 | tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN'; |
— | — | @@ -107,15 +112,15 @@ |
108 | 113 | }, |
109 | 114 | stylize: function( wrappedTemplate ) { |
110 | 115 | $( wrappedTemplate ).each( function() { |
111 | | - if ( typeof $(this).data( 'model' ) != 'undefined' ) { |
| 116 | + if ( typeof $(this).data( 'setupDone' ) != 'undefined' ) { |
112 | 117 | // We have a model, so all this init stuff has already happened |
113 | 118 | return; |
114 | 119 | } |
115 | | - // Build a model for this |
116 | | - var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() ); |
| 120 | + var model = $(this).data( 'marker' ).model; |
117 | 121 | |
118 | 122 | //check if model is collapsible |
119 | 123 | if ( !model.isCollapsible() ) { |
| 124 | + $(this).addClass( 'wikiEditor-template-text' ); |
120 | 125 | return; |
121 | 126 | } |
122 | 127 | |
— | — | @@ -142,6 +147,8 @@ |
143 | 148 | .mousedown( toggleWikiTextEditor ) ) |
144 | 149 | .insertAfter( $template.find( '.wikiEditor-template-name' ) ); |
145 | 150 | |
| 151 | + $(this).data( 'setupDone', true ); |
| 152 | + |
146 | 153 | function toggleWikiTextEditor(){ |
147 | 154 | var $template = $( this ).closest( '.wikiEditor-template' ); |
148 | 155 | $template |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -112,6 +112,7 @@ |
113 | 113 | end: tokenArray[i].offset, |
114 | 114 | type: 'toc', |
115 | 115 | anchor: 'before', |
| 116 | + splitPs: false, |
116 | 117 | afterWrap: function( node ) { |
117 | 118 | var marker = $( node ).data( 'marker' ); |
118 | 119 | $( node ).addClass( 'wikiEditor-toc-header' ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -375,6 +375,11 @@ |
376 | 376 | }, |
377 | 377 | 'delayedChange': function( event ) { |
378 | 378 | event.data.scope = 'division'; |
| 379 | + var newHTML = context.$content.html(); |
| 380 | + if ( context.oldDelayedHTML != newHTML ) { |
| 381 | + context.oldDelayedHTML = newHTML; |
| 382 | + event.data.scope = 'realchange'; |
| 383 | + } |
379 | 384 | context.fn.updateHistory(); |
380 | 385 | return true; |
381 | 386 | }, |
— | — | @@ -1525,7 +1530,6 @@ |
1526 | 1531 | .replace( /&esc;&lt;span&nbsp;class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"><\/span>' ) |
1527 | 1532 | .replace( /&esc;esc;/g, '&esc;' ); |
1528 | 1533 | context.$content.html( html ); |
1529 | | - context.oldHTML = html; |
1530 | 1534 | |
1531 | 1535 | // Reflect direction of parent frame into child |
1532 | 1536 | if ( $( 'body' ).is( '.rtl' ) ) { |
— | — | @@ -1537,6 +1541,8 @@ |
1538 | 1542 | context.$iframe.show(); |
1539 | 1543 | // Let modules know we're ready to start working with the content |
1540 | 1544 | context.fn.trigger( 'ready' ); |
| 1545 | + // Only save HTML now: ready handlers may have modified it |
| 1546 | + context.oldHTML = context.oldDelayedHTML = context.$content.html(); |
1541 | 1547 | //remove our temporary loading |
1542 | 1548 | /* Disaling our loading div for now |
1543 | 1549 | $( '.wikiEditor-ui-loading' ).fadeOut( 'fast', function() { |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -194,11 +194,23 @@ |
195 | 195 | if ( s.offset > 0 && s.node.nodeName == '#text' ) { |
196 | 196 | // Split off the prefix |
197 | 197 | // This leaves the prefix in the current node and puts |
198 | | - // the rest in a new node which is our start node |
| 198 | + // the rest in a new node which is our start node |
199 | 199 | startNode = startNode.splitText( s.offset ); |
200 | 200 | // This also invalidates cached offset objects |
201 | 201 | context.fn.purgeOffsets(); // TODO: Optimize better, get end offset object earlier |
202 | 202 | } |
| 203 | + // Because we can't put block elements in <p>s, we'll have to split the <p> as well |
| 204 | + // if afterWrap() needs us to |
| 205 | + if ( markers[i].splitPs && startNode.parentNode.nodeName == 'P' ) { |
| 206 | + // Create a new <p> left of startNode, and append startNode's left siblings to it |
| 207 | + var startP = startNode.ownerDocument.createElement( 'p' ); |
| 208 | + while ( startNode.parentNode.firstChild != startNode ) { |
| 209 | + startP.appendChild( startNode.parentNode.firstChild ); |
| 210 | + } |
| 211 | + if ( startP.firstChild ) { |
| 212 | + startNode.parentNode.insertBefore( startP, startNode ); |
| 213 | + } |
| 214 | + } |
203 | 215 | |
204 | 216 | var end = markers[i].end; |
205 | 217 | var e = context.fn.getOffset( end ); |
— | — | @@ -209,13 +221,25 @@ |
210 | 222 | var endNode = e.node; |
211 | 223 | var endDepth = e.depth; |
212 | 224 | if ( e.offset < e.length - 1 && e.node.nodeName == '#text' ) { |
213 | | - // Split off the suffix - This puts the suffix in a new node and leaves the rest in the current |
214 | | - // node. |
215 | | - // endNode.nodeValue.length - ( newPos - markers[i].end ) |
216 | | - endNode.splitText( e.offset + 1 ); |
| 225 | + // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode |
| 226 | + endNode.splitText( e.offset ); |
217 | 227 | // This also invalidates cached offset objects |
218 | 228 | context.fn.purgeOffsets(); // TODO: Optimize better, get end offset object earlier |
219 | 229 | } |
| 230 | + // Split <p>s if needed, see above |
| 231 | + if ( markers[i].splitPs && endNode.parentNode.nodeName == 'P' && endNode.parentNode.parentNode ) { |
| 232 | + // Move textnodes preceding endNode out of the wrapping <p> |
| 233 | + var endP = endNode.parentNode; |
| 234 | + while ( endP.firstChild != endNode ) { |
| 235 | + endP.parentNode.insertBefore( endP.firstChild, endP ); |
| 236 | + } |
| 237 | + // Move endNode itself out as well |
| 238 | + endP.parentNode.insertBefore( endNode, endP ); |
| 239 | + if ( !endP.firstChild ) { |
| 240 | + // endP is empty, remove it |
| 241 | + endP.parentNode.removeChild( endP ); |
| 242 | + } |
| 243 | + } |
220 | 244 | |
221 | 245 | // Don't wrap trailing BRs, doing that causes weird issues |
222 | 246 | if ( endNode.nodeName == 'BR' ) { |
— | — | @@ -261,12 +285,7 @@ |
262 | 286 | // properties |
263 | 287 | var newNode = ca1.ownerDocument.createElement( 'span' ); |
264 | 288 | var commonAncestor = ca1.parentNode; |
265 | | - // Special case: can't put block elements in a <p> |
266 | | - if ( commonAncestor.nodeName == 'P' && commonAncestor.parentNode ) { |
267 | | - commonAncestor = commonAncestor.parentNode; |
268 | | - ca1 = ca1.parentNode; |
269 | | - ca2 = ca2.parentNode; |
270 | | - } |
| 289 | + |
271 | 290 | var nextNode = ca2.nextSibling; |
272 | 291 | if ( markers[i].anchor == 'wrap' ) { |
273 | 292 | // Append all nodes between ca1 and ca2 (inclusive) to newNode |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6808,6 +6808,11 @@ |
6809 | 6809 | }, |
6810 | 6810 | 'delayedChange': function( event ) { |
6811 | 6811 | event.data.scope = 'division'; |
| 6812 | + var newHTML = context.$content.html(); |
| 6813 | + if ( context.oldDelayedHTML != newHTML ) { |
| 6814 | + context.oldDelayedHTML = newHTML; |
| 6815 | + event.data.scope = 'realchange'; |
| 6816 | + } |
6812 | 6817 | context.fn.updateHistory(); |
6813 | 6818 | return true; |
6814 | 6819 | }, |
— | — | @@ -7958,7 +7963,6 @@ |
7959 | 7964 | .replace( /&esc;&lt;span&nbsp;class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g, '<span class="wikiEditor-tab"><\/span>' ) |
7960 | 7965 | .replace( /&esc;esc;/g, '&esc;' ); |
7961 | 7966 | context.$content.html( html ); |
7962 | | - context.oldHTML = html; |
7963 | 7967 | |
7964 | 7968 | // Reflect direction of parent frame into child |
7965 | 7969 | if ( $( 'body' ).is( '.rtl' ) ) { |
— | — | @@ -7970,6 +7974,8 @@ |
7971 | 7975 | context.$iframe.show(); |
7972 | 7976 | // Let modules know we're ready to start working with the content |
7973 | 7977 | context.fn.trigger( 'ready' ); |
| 7978 | + // Only save HTML now: ready handlers may have modified it |
| 7979 | + context.oldHTML = context.oldDelayedHTML = context.$content.html(); |
7974 | 7980 | //remove our temporary loading |
7975 | 7981 | /* Disaling our loading div for now |
7976 | 7982 | $( '.wikiEditor-ui-loading' ).fadeOut( 'fast', function() { |
— | — | @@ -8413,11 +8419,23 @@ |
8414 | 8420 | if ( s.offset > 0 && s.node.nodeName == '#text' ) { |
8415 | 8421 | // Split off the prefix |
8416 | 8422 | // This leaves the prefix in the current node and puts |
8417 | | - // the rest in a new node which is our start node |
| 8423 | + // the rest in a new node which is our start node |
8418 | 8424 | startNode = startNode.splitText( s.offset ); |
8419 | 8425 | // This also invalidates cached offset objects |
8420 | 8426 | context.fn.purgeOffsets(); // TODO: Optimize better, get end offset object earlier |
8421 | 8427 | } |
| 8428 | + // Because we can't put block elements in <p>s, we'll have to split the <p> as well |
| 8429 | + // if afterWrap() needs us to |
| 8430 | + if ( markers[i].splitPs && startNode.parentNode.nodeName == 'P' ) { |
| 8431 | + // Create a new <p> left of startNode, and append startNode's left siblings to it |
| 8432 | + var startP = startNode.ownerDocument.createElement( 'p' ); |
| 8433 | + while ( startNode.parentNode.firstChild != startNode ) { |
| 8434 | + startP.appendChild( startNode.parentNode.firstChild ); |
| 8435 | + } |
| 8436 | + if ( startP.firstChild ) { |
| 8437 | + startNode.parentNode.insertBefore( startP, startNode ); |
| 8438 | + } |
| 8439 | + } |
8422 | 8440 | |
8423 | 8441 | var end = markers[i].end; |
8424 | 8442 | var e = context.fn.getOffset( end ); |
— | — | @@ -8428,13 +8446,25 @@ |
8429 | 8447 | var endNode = e.node; |
8430 | 8448 | var endDepth = e.depth; |
8431 | 8449 | if ( e.offset < e.length - 1 && e.node.nodeName == '#text' ) { |
8432 | | - // Split off the suffix - This puts the suffix in a new node and leaves the rest in the current |
8433 | | - // node. |
8434 | | - // endNode.nodeValue.length - ( newPos - markers[i].end ) |
8435 | | - endNode.splitText( e.offset + 1 ); |
| 8450 | + // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode |
| 8451 | + endNode.splitText( e.offset ); |
8436 | 8452 | // This also invalidates cached offset objects |
8437 | 8453 | context.fn.purgeOffsets(); // TODO: Optimize better, get end offset object earlier |
8438 | 8454 | } |
| 8455 | + // Split <p>s if needed, see above |
| 8456 | + if ( markers[i].splitPs && endNode.parentNode.nodeName == 'P' && endNode.parentNode.parentNode ) { |
| 8457 | + // Move textnodes preceding endNode out of the wrapping <p> |
| 8458 | + var endP = endNode.parentNode; |
| 8459 | + while ( endP.firstChild != endNode ) { |
| 8460 | + endP.parentNode.insertBefore( endP.firstChild, endP ); |
| 8461 | + } |
| 8462 | + // Move endNode itself out as well |
| 8463 | + endP.parentNode.insertBefore( endNode, endP ); |
| 8464 | + if ( !endP.firstChild ) { |
| 8465 | + // endP is empty, remove it |
| 8466 | + endP.parentNode.removeChild( endP ); |
| 8467 | + } |
| 8468 | + } |
8439 | 8469 | |
8440 | 8470 | // Don't wrap trailing BRs, doing that causes weird issues |
8441 | 8471 | if ( endNode.nodeName == 'BR' ) { |
— | — | @@ -8480,12 +8510,7 @@ |
8481 | 8511 | // properties |
8482 | 8512 | var newNode = ca1.ownerDocument.createElement( 'span' ); |
8483 | 8513 | var commonAncestor = ca1.parentNode; |
8484 | | - // Special case: can't put block elements in a <p> |
8485 | | - if ( commonAncestor.nodeName == 'P' && commonAncestor.parentNode ) { |
8486 | | - commonAncestor = commonAncestor.parentNode; |
8487 | | - ca1 = ca1.parentNode; |
8488 | | - ca2 = ca2.parentNode; |
8489 | | - } |
| 8514 | + |
8490 | 8515 | var nextNode = ca2.nextSibling; |
8491 | 8516 | if ( markers[i].anchor == 'wrap' ) { |
8492 | 8517 | // Append all nodes between ca1 and ca2 (inclusive) to newNode |
— | — | @@ -8865,24 +8890,29 @@ |
8866 | 8891 | } |
8867 | 8892 | }//while finding template ending |
8868 | 8893 | if ( endIndex != -1 ) { |
| 8894 | + // Create a model for the template |
| 8895 | + var model = new $.wikiEditor.modules.templateEditor.fn.model( |
| 8896 | + context.fn.getContents().substring( tokenArray[beginIndex].offset, |
| 8897 | + tokenArray[endIndex].offset |
| 8898 | + ) |
| 8899 | + ); |
8869 | 8900 | markers.push( { |
8870 | 8901 | start: tokenArray[beginIndex].offset, |
8871 | 8902 | end: tokenArray[endIndex].offset, |
8872 | 8903 | type: 'template', |
8873 | 8904 | anchor: 'wrap', |
| 8905 | + splitPs: model.isCollapsible(), |
8874 | 8906 | afterWrap: $.wikiEditor.modules.templateEditor.fn.stylize, |
8875 | 8907 | beforeUnwrap: function( node ) { |
8876 | 8908 | $( node ).data( 'display' ).remove(); |
8877 | 8909 | }, |
8878 | | - onSkip: function() { }, |
8879 | | - getAnchor: function( ca1, ca2 ) { |
| 8910 | + onSkip: function() { }, // TODO update template info |
| 8911 | + getAnchor: function( ca1, ca2 ) { |
8880 | 8912 | // FIXME: Relies on the current <span> structure that is likely to die |
8881 | | - return $( ca1.parentNode ).is( 'div.wikiEditor-template-text' ) && |
8882 | | - $( ca1.parentNode.previousSibling ) |
8883 | | - .is( 'ul.wikiEditor-template-modes' ) && |
8884 | | - ca1.parentNode.nextSibling == null ? |
| 8913 | + return $( ca1.parentNode ).is( 'span.wikiEditor-template-text' ) ? |
8885 | 8914 | ca1.parentNode : null; |
8886 | | - } |
| 8915 | + }, |
| 8916 | + model: model |
8887 | 8917 | } ); |
8888 | 8918 | } else { //else this was an unmatched opening |
8889 | 8919 | tokenArray[beginIndex].label = 'TEMPLATE_FALSE_BEGIN'; |
— | — | @@ -8919,15 +8949,15 @@ |
8920 | 8950 | }, |
8921 | 8951 | stylize: function( wrappedTemplate ) { |
8922 | 8952 | $( wrappedTemplate ).each( function() { |
8923 | | - if ( typeof $(this).data( 'model' ) != 'undefined' ) { |
| 8953 | + if ( typeof $(this).data( 'setupDone' ) != 'undefined' ) { |
8924 | 8954 | // We have a model, so all this init stuff has already happened |
8925 | 8955 | return; |
8926 | 8956 | } |
8927 | | - // Build a model for this |
8928 | | - var model = new $.wikiEditor.modules.templateEditor.fn.model( $( this ).text() ); |
| 8957 | + var model = $(this).data( 'marker' ).model; |
8929 | 8958 | |
8930 | 8959 | //check if model is collapsible |
8931 | 8960 | if ( !model.isCollapsible() ) { |
| 8961 | + $(this).addClass( 'wikiEditor-template-text' ); |
8932 | 8962 | return; |
8933 | 8963 | } |
8934 | 8964 | |
— | — | @@ -8954,6 +8984,8 @@ |
8955 | 8985 | .mousedown( toggleWikiTextEditor ) ) |
8956 | 8986 | .insertAfter( $template.find( '.wikiEditor-template-name' ) ); |
8957 | 8987 | |
| 8988 | + $(this).data( 'setupDone', true ); |
| 8989 | + |
8958 | 8990 | function toggleWikiTextEditor(){ |
8959 | 8991 | var $template = $( this ).closest( '.wikiEditor-template' ); |
8960 | 8992 | $template |
— | — | @@ -9582,6 +9614,7 @@ |
9583 | 9615 | end: tokenArray[i].offset, |
9584 | 9616 | type: 'toc', |
9585 | 9617 | anchor: 'before', |
| 9618 | + splitPs: false, |
9586 | 9619 | afterWrap: function( node ) { |
9587 | 9620 | var marker = $( node ).data( 'marker' ); |
9588 | 9621 | $( node ).addClass( 'wikiEditor-toc-header' ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -454,7 +454,8 @@ |
455 | 455 | break;} |
456 | 456 | return true;},'change':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldHTML!=newHTML){context.fn.purgeOffsets();context.oldHTML=newHTML;event.data.scope='realchange';} |
457 | 457 | switch(event.which){case 8:break;} |
458 | | -return true;},'delayedChange':function(event){event.data.scope='division';context.fn.updateHistory();return true;},'paste':function(event){context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.addClass('pasting');} |
| 458 | +return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.oldDelayedHTML=newHTML;event.data.scope='realchange';} |
| 459 | +context.fn.updateHistory();return true;},'paste':function(event){context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.addClass('pasting');} |
459 | 460 | setTimeout(function(){var $selection=context.$content.find(':not(.wikiEditor)');while($selection.length&&$selection.length>0){var $currentElement=$selection.eq(0);while(!$currentElement.parent().is('body')&&!$currentElement.parent().is('.wikiEditor')){$currentElement=$currentElement.parent();} |
460 | 461 | var text=$currentElement.text();if($currentElement.is('br')){$currentElement.addClass('wikiEditor');}else if($currentElement.is('span')&&text.length==0){$currentElement.remove();}else{$newElement=$('<p></p>').addClass('wikiEditor').insertAfter($currentElement);if(text.length){$newElement.text(text);}else{$newElement.append($('<br>').addClass('wikiEditor'));} |
461 | 462 | $currentElement.remove();} |
— | — | @@ -555,8 +556,8 @@ |
556 | 557 | context.$iframe[0].contentWindow.focus();context.savedSelection.select();context.savedSelection=null;},'updateHistory':function(){var newHTML=context.$content.html();var newSel=context.fn.getCaretPosition();if(context.history.length==0||(context.oldDelayedHTML!=newHTML&&newHTML!=context.history[context.history.length+context.historyPosition].html)){context.fn.purgeOffsets();context.oldDelayedHTML=newHTML;context.oldDelayedSel=newSel;if(context.historyPosition<-1){context.history.splice(context.history.length+context.historyPosition);context.historyPosition=-1;} |
557 | 558 | context.history.push({'html':newHTML,'sel':newSel});while(context.history.length>10){context.history.shift();}}else if(context.oldDelayedSel!=newSel){context.oldDelayedSel=newSel;context.history[context.history.length+context.historyPosition].sel=newSel;}}};context.$textarea.wrapAll($('<div></div>').addClass('wikiEditor-ui')).wrapAll($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrapAll($('<div></div>').addClass('wikiEditor-ui-left')).wrapAll($('<div></div>').addClass('wikiEditor-ui-bottom')).wrapAll($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event);});context.fn.setupIframe=function(){context.$iframe=$('<iframe></iframe>').attr({'frameBorder':0,'border':0,'tabindex':1,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime()+'&is=content','id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!this.isSecondRun){context.$iframe[0].contentWindow.document.designMode='on';if($.browser.msie){this.isSecondRun=true;return;}} |
558 | 559 | context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val().replace(/&esc;/g,'&esc;esc;').replace(/\<p\>/g,'&esc;<p>').replace(/\<\/p\>/g,'&esc;</p>').replace(/\<span class="wikiEditor-tab"\>\<\/span\>/g,'&esc;<span class="wikiEditor-tab"></span>').replace(/ /g,'&esc;&nbsp;');if($.browser.msie){html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');if($.browser.versionNumber<=7){html=html.replace(/ /g," ");}else{html=html.replace(/(^|\n) /g,"$1 ");}} |
559 | | -html=$('<div />').text('<p>'+html.replace(/\r?\n/g,'</p><p>')+'</p>').html().replace(/&nbsp;/g,' ').replace(/<p>/g,'<p>').replace(/<\/p>/g,'</p>').replace(/<span( | )class=("|")wikiEditor-tab("|")><\/span>/g,'<span class="wikiEditor-tab"></span>').replace(/<p><\/p>/g,'<p><br></p>').replace(/&esc;&amp;nbsp;/g,'&nbsp;').replace(/&esc;&lt;p&gt;/g,'<p>').replace(/&esc;&lt;\/p&gt;/g,'</p>').replace(/&esc;&lt;span&nbsp;class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g,'<span class="wikiEditor-tab"><\/span>').replace(/&esc;esc;/g,'&esc;');context.$content.html(html);context.oldHTML=html;if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
560 | | -context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('paste',function(event){return context.fn.trigger('paste',event);}).bind('keyup paste mouseup cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup paste mouseup cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};};} |
| 560 | +html=$('<div />').text('<p>'+html.replace(/\r?\n/g,'</p><p>')+'</p>').html().replace(/&nbsp;/g,' ').replace(/<p>/g,'<p>').replace(/<\/p>/g,'</p>').replace(/<span( | )class=("|")wikiEditor-tab("|")><\/span>/g,'<span class="wikiEditor-tab"></span>').replace(/<p><\/p>/g,'<p><br></p>').replace(/&esc;&amp;nbsp;/g,'&nbsp;').replace(/&esc;&lt;p&gt;/g,'<p>').replace(/&esc;&lt;\/p&gt;/g,'</p>').replace(/&esc;&lt;span&nbsp;class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g,'<span class="wikiEditor-tab"><\/span>').replace(/&esc;esc;/g,'&esc;');context.$content.html(html);if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
| 561 | +context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');context.oldHTML=context.oldDelayedHTML=context.$content.html();$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('paste',function(event){return context.fn.trigger('paste',event);}).bind('keyup paste mouseup cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup paste mouseup cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};};} |
561 | 562 | var args=$.makeArray(arguments);if(typeof context.$iframe==='undefined'&&arguments[0]=='addModule'){var supported=false;for(module in arguments[1]){if($.wikiEditor.isSupported(module)&&module!=='toolbar'){supported=true;}} |
562 | 563 | if(supported){context.fn.setupIframe();}} |
563 | 564 | if(args.length>0){var call=args.shift();if(call in context.api){context.api[call](context,typeof args[0]=='undefined'?{}:args[0]);}} |
— | — | @@ -574,14 +575,17 @@ |
575 | 576 | context.modules.highlight.markersStr=markersStr;var visited=[];for(var i=0;i<markers.length;i++){var start=markers[i].start;var s=context.fn.getOffset(start);if(!s){continue;} |
576 | 577 | var startNode=s.node;var startDepth=s.depth;while(startNode.nodeName=='BR'||s.offset==startNode.nodeValue.length){start++;s=context.fn.getOffset(start);startNode=s.node;startDepth=s.depth;} |
577 | 578 | if(s.offset>0&&s.node.nodeName=='#text'){startNode=startNode.splitText(s.offset);context.fn.purgeOffsets();} |
| 579 | +if(markers[i].splitPs&&startNode.parentNode.nodeName=='P'){var startP=startNode.ownerDocument.createElement('p');while(startNode.parentNode.firstChild!=startNode){startP.appendChild(startNode.parentNode.firstChild);} |
| 580 | +if(startP.firstChild){startNode.parentNode.insertBefore(startP,startNode);}} |
578 | 581 | var end=markers[i].end;var e=context.fn.getOffset(end);if(!e){continue;} |
579 | | -var endNode=e.node;var endDepth=e.depth;if(e.offset<e.length-1&&e.node.nodeName=='#text'){endNode.splitText(e.offset+1);context.fn.purgeOffsets();} |
| 582 | +var endNode=e.node;var endDepth=e.depth;if(e.offset<e.length-1&&e.node.nodeName=='#text'){endNode.splitText(e.offset);context.fn.purgeOffsets();} |
| 583 | +if(markers[i].splitPs&&endNode.parentNode.nodeName=='P'&&endNode.parentNode.parentNode){var endP=endNode.parentNode;while(endP.firstChild!=endNode){endP.parentNode.insertBefore(endP.firstChild,endP);} |
| 584 | +endP.parentNode.insertBefore(endNode,endP);if(!endP.firstChild){endP.parentNode.removeChild(endP);}} |
580 | 585 | if(endNode.nodeName=='BR'){endNode=e.lastTextNode;endDepth=e.lastTextNodeDepth;} |
581 | 586 | 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;}} |
582 | 587 | else if(startDepth<endDepth){for(var j=0;j<endDepth-startDepth&&ca2;j++){ca2=ca2.parentNode.lastChild==ca2?ca2.parentNode:null;}} |
583 | 588 | while(ca1&&ca2&&ca1.parentNode&&ca2.parentNode&&ca1.parentNode!=ca2.parentNode&&ca1.parentNode.firstChild&&ca2.parentNode.lastChild){ca1=ca1.parentNode.firstChild==ca1?ca1.parentNode:null;ca2=ca2.parentNode.lastChild==ca2?ca2.parentNode:null;} |
584 | | -if(ca1&&ca2&&ca1.parentNode){var anchor=markers[i].getAnchor(ca1,ca2);if(!anchor){var newNode=ca1.ownerDocument.createElement('span');var commonAncestor=ca1.parentNode;if(commonAncestor.nodeName=='P'&&commonAncestor.parentNode){commonAncestor=commonAncestor.parentNode;ca1=ca1.parentNode;ca2=ca2.parentNode;} |
585 | | -var nextNode=ca2.nextSibling;if(markers[i].anchor=='wrap'){var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;} |
| 589 | +if(ca1&&ca2&&ca1.parentNode){var anchor=markers[i].getAnchor(ca1,ca2);if(!anchor){var newNode=ca1.ownerDocument.createElement('span');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;} |
586 | 590 | 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);}} |
587 | 591 | $(newNode).data('marker',markers[i]).addClass('wikiEditor-highlight');visited[i]=newNode;markers[i].afterWrap(newNode,markers[i]);}else{visited[i]=anchor;$(anchor).data('marker',markers[i]);markers[i].onSkip(anchor);}}} |
588 | 592 | var j=0;context.$content.find('.wikiEditor-highlight').each(function(){if(visited[j]==this){j++;return true;} |
— | — | @@ -618,9 +622,9 @@ |
619 | 623 | $('#wikiEditor-'+context.instance+'-dialog-watch').hide();else if($('#wpWatchthis').is(':checked')) |
620 | 624 | $('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={'browsers':{'ltr':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},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++;} |
621 | 625 | 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;}}} |
622 | | -if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',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;} |
623 | | -var model=new $.wikiEditor.modules.templateEditor.fn.model($(this).text());if(!model.isCollapsible()){return;} |
624 | | -var $template=$(this).wrap('<div class="wikiEditor-template"></div>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(function(){createDialog($template);}).prependTo($template);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(toggleWikiTextEditor)).insertAfter($template.find('.wikiEditor-template-name'));function toggleWikiTextEditor(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed');var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());} |
| 626 | +if(endIndex!=-1){var model=new $.wikiEditor.modules.templateEditor.fn.model(context.fn.getContents().substring(tokenArray[beginIndex].offset,tokenArray[endIndex].offset));markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',splitPs:model.isCollapsible(),afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize,beforeUnwrap:function(node){$(node).data('display').remove();},onSkip:function(){},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},model:model});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('setupDone')!='undefined'){return;} |
| 627 | +var model=$(this).data('marker').model;if(!model.isCollapsible()){$(this).addClass('wikiEditor-template-text');return;} |
| 628 | +var $template=$(this).wrap('<div class="wikiEditor-template"></div>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(function(){createDialog($template);}).prependTo($template);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(toggleWikiTextEditor)).insertAfter($template.find('.wikiEditor-template-name'));$(this).data('setupDone',true);function toggleWikiTextEditor(){var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed');var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());} |
625 | 629 | else{$wikitext.text($template.data('model').getText());} |
626 | 630 | return false;};function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$displayDiv.unbind('mousedown');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};function createDialog($templateDiv){var $wikitext=$templateDiv.children('.wikiEditor-template-text');var templateModel=new $.wikiEditor.modules.templateEditor.fn.model($wikitext.text());$templateDiv.data('model',templateModel);var $dialog=$("<div></div>");var $title=$("<div>"+templateModel.getName()+"</div>").addClass('wikiEditor-template-dialog-title');var $table=$("<table></table>").addClass('wikiEditor-template-dialog-table').appendTo($dialog);var allInitialParams=templateModel.getAllInitialParams();for(var paramIndex in allInitialParams){var param=allInitialParams[paramIndex];if(typeof param.name=='undefined'){continue;} |
627 | 631 | 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);} |
— | — | @@ -662,7 +666,7 @@ |
663 | 667 | if(!context.modules.toc.$toc.data('collapsed')){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
664 | 668 | context.$ui.find('.tab-toc').outerHeight());} |
665 | 669 | context.modules.toc.$toc.data('previousWidth',context.$wikitext.width());},mark:function(context,event){var hash='';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;} |
666 | | -h++;markers.push({index:h,start:tokenArray[i].tokenStart,end:tokenArray[i].offset,type:'toc',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');if($(node).data('section')!=marker.index){$(node).removeClass('wikiEditor-toc-section-'+$(node).data('section')).addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);}},getAnchor:function(ca1,ca2){return $(ca1.parentNode.previousSibling).is('.wikiEditor-toc-header')?ca1.parentNode.previousSibling:null;}});hash+=tokenArray[i].match[2]+'\n';outline.push({'text':tokenArray[i].match[2],'level':tokenArray[i].match[1].length,'index':h});} |
| 670 | +h++;markers.push({index:h,start:tokenArray[i].tokenStart,end:tokenArray[i].offset,type:'toc',anchor:'before',splitPs:false,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');if($(node).data('section')!=marker.index){$(node).removeClass('wikiEditor-toc-section-'+$(node).data('section')).addClass('wikiEditor-toc-section-'+marker.index).data('section',marker.index);}},getAnchor:function(ca1,ca2){return $(ca1.parentNode.previousSibling).is('.wikiEditor-toc-header')?ca1.parentNode.previousSibling:null;}});hash+=tokenArray[i].match[2]+'\n';outline.push({'text':tokenArray[i].match[2],'level':tokenArray[i].match[1].length,'index':h});} |
667 | 671 | if(typeof context.modules.toc.lastHash=='undefined'||context.modules.toc.lastHash!==hash){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);context.modules.toc.lastHash=hash;}}},exp:[{'regex':/^(={1,6})([^\r\n]+?)\1\s*$/m,'label':'TOC_HEADER','markAfter':true}],fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} |
668 | 672 | $.wikiEditor.modules.toc.cfg.rtl=config.rtl;$.wikiEditor.modules.toc.cfg.flexProperty=config.rtl?'marginLeft':'marginRight';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($.wikiEditor.modules.toc.cfg.flexProperty,(-1*fixedWidth)+'px').children().css($.wikiEditor.modules.toc.cfg.flexProperty,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($.wikiEditor.modules.toc.cfg.rtl?'right':'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($.wikiEditor.modules.toc.cfg.flexProperty,'').css({'position':'absolute','float':'none','left':$.wikiEditor.modules.toc.cfg.rtl?'auto':0,'right':$.wikiEditor.modules.toc.cfg.rtl?0:'auto'}).children().css($.wikiEditor.modules.toc.cfg.flexProperty,'');context.$ui.find('.wikiEditor-ui-right').css({'width':'auto','position':'absolute','float':'none','right':$.wikiEditor.modules.toc.cfg.rtl?'auto':0,'left':$.wikiEditor.modules.toc.cfg.rtl?0:'auto'});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');} |
669 | 673 | context.$wikitext.css({'position':'','height':''});context.$ui.find('.wikiEditor-ui-right').css($.wikiEditor.modules.toc.cfg.flexProperty,'').css({'position':'','left':'','right':'','float':'','top':'','height':''});context.$ui.find('.wikiEditor-ui-left').css({'width':'','position':'','left':'','float':'','right':''});} |