Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,20 +72,20 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.delayedBind.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' => 167 ), |
77 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 42 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 168 ), |
| 77 | + array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 43 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 21 ), |
80 | 80 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ), |
81 | 81 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ), |
82 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 55 ), |
| 82 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 56 ), |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 332 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 333 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 332 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 333 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | } |
120 | 120 | }, //mark |
121 | 121 | |
122 | | - keydown: function( context, event ){ |
| 122 | + keydown: function( context, event ) { |
123 | 123 | // reset our ignoreKeypress variable if it's set to true |
124 | 124 | if( context.$iframe.data( 'ignoreKeypress' ) ) context.$iframe.data( 'ignoreKeypress', false ); |
125 | 125 | var $evtElem = event.jQueryNode; |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -654,7 +654,7 @@ |
655 | 655 | // We need the traverser because there can be other weird stuff in between |
656 | 656 | |
657 | 657 | // Check for preceding text |
658 | | - var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ), true ).prev(); |
| 658 | + var t = new context.fn.rawTraverser( this.firstChild, this, $pre.get( 0 ), true ).prev(); |
659 | 659 | while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
660 | 660 | t = t.prev(); |
661 | 661 | } |
— | — | @@ -663,7 +663,7 @@ |
664 | 664 | } |
665 | 665 | |
666 | 666 | // Check for following text |
667 | | - t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ), true ).next(); |
| 667 | + t = new context.fn.rawTraverser( this.lastChild, this, $pre.get( 0 ), true ).next(); |
668 | 668 | while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
669 | 669 | t = t.next(); |
670 | 670 | } |
— | — | @@ -769,19 +769,16 @@ |
770 | 770 | /** |
771 | 771 | * Object used by traverser(). Don't use this unless you know what you're doing |
772 | 772 | */ |
773 | | - 'rawTraverser': function( node, depth, inP, ancestor, skipNoinclude ) { |
| 773 | + 'rawTraverser': function( node, inP, ancestor, skipNoinclude ) { |
774 | 774 | this.node = node; |
775 | | - this.depth = depth; |
776 | 775 | this.inP = inP; |
777 | 776 | this.ancestor = ancestor; |
778 | 777 | this.skipNoinclude = skipNoinclude; |
779 | 778 | this.next = function() { |
780 | 779 | var p = this.node; |
781 | | - var nextDepth = this.depth; |
782 | 780 | var nextInP = this.inP; |
783 | 781 | while ( p && !p.nextSibling ) { |
784 | 782 | p = p.parentNode; |
785 | | - nextDepth--; |
786 | 783 | if ( p == this.ancestor ) { |
787 | 784 | // We're back at the ancestor, stop here |
788 | 785 | p = null; |
— | — | @@ -805,23 +802,20 @@ |
806 | 803 | } |
807 | 804 | if ( p && p.firstChild ) { |
808 | 805 | p = p.firstChild; |
809 | | - nextDepth++; |
810 | 806 | if ( p.nodeName == "P" ) { |
811 | 807 | nextInP = p; |
812 | 808 | } |
813 | 809 | } |
814 | 810 | } while ( p && p.firstChild ); |
815 | 811 | // Instead of calling the rawTraverser constructor, inline it. This avoids function call overhead |
816 | | - return p ? { 'node': p, 'depth': nextDepth, 'inP': nextInP, 'ancestor': this.ancestor, |
| 812 | + return p ? { 'node': p, 'inP': nextInP, 'ancestor': this.ancestor, |
817 | 813 | 'skipNoinclude': this.skipNoinclude, 'next': this.next, 'prev': this.prev } : null; |
818 | 814 | }; |
819 | 815 | this.prev = function() { |
820 | 816 | var p = this.node; |
821 | | - var prevDepth = this.depth; |
822 | 817 | var prevInP = this.inP; |
823 | 818 | while ( p && !p.previousSibling ) { |
824 | 819 | p = p.parentNode; |
825 | | - prevDepth--; |
826 | 820 | if ( p == this.ancestor ) { |
827 | 821 | // We're back at the ancestor, stop here |
828 | 822 | p = null; |
— | — | @@ -845,14 +839,13 @@ |
846 | 840 | } |
847 | 841 | if ( p && p.lastChild ) { |
848 | 842 | p = p.lastChild; |
849 | | - prevDepth++; |
850 | 843 | if ( p.nodeName == "P" ) { |
851 | 844 | prevInP = p; |
852 | 845 | } |
853 | 846 | } |
854 | 847 | } while ( p && p.lastChild ); |
855 | 848 | // Instead of calling the rawTraverser constructor, inline it. This avoids function call overhead |
856 | | - return p ? { 'node': p, 'depth': prevDepth, 'inP': prevInP, 'ancestor': this.ancestor, |
| 849 | + return p ? { 'node': p, 'inP': prevInP, 'ancestor': this.ancestor, |
857 | 850 | 'skipNoinclude': this.skipNoinclude, 'next': this.next, 'prev': this.prev } : null; |
858 | 851 | }; |
859 | 852 | }, |
— | — | @@ -860,18 +853,14 @@ |
861 | 854 | * Get an object used to traverse the leaf nodes in the iframe DOM. This traversal skips leaf nodes |
862 | 855 | * inside an element with the wikiEditor-noinclude class. This basically wraps rawTraverser |
863 | 856 | * |
864 | | - * Usage: |
865 | | - * var t = context.fn.traverser( context.$content ); |
866 | | - * // t.node is the first textnode, t.depth is its depth |
867 | | - * t.goNext(); |
868 | | - * // t.node is the second textnode, t.depth is its depth |
869 | | - * // Trying to advance past the end will set t.node to null |
| 857 | + * @param start Node to start at |
| 858 | + * @return Traverser object, use .next() or .prev() to get a traverser object referring to the |
| 859 | + * previous/next node |
870 | 860 | */ |
871 | 861 | 'traverser': function( start ) { |
872 | 862 | // Find the leftmost leaf node in the tree |
873 | 863 | var startNode = start.jquery ? start.get( 0 ) : start; |
874 | 864 | var node = startNode; |
875 | | - var depth = 0; |
876 | 865 | var inP = node.nodeName == "P" ? node : null; |
877 | 866 | do { |
878 | 867 | // Filter nodes with the wikiEditor-noinclude class |
— | — | @@ -882,13 +871,12 @@ |
883 | 872 | } |
884 | 873 | if ( node && node.firstChild ) { |
885 | 874 | node = node.firstChild; |
886 | | - depth++; |
887 | 875 | if ( node.nodeName == "P" ) { |
888 | 876 | inP = node; |
889 | 877 | } |
890 | 878 | } |
891 | 879 | } while ( node && node.firstChild ); |
892 | | - return new context.fn.rawTraverser( node, depth, inP, startNode, true ); |
| 880 | + return new context.fn.rawTraverser( node, inP, startNode, true ); |
893 | 881 | }, |
894 | 882 | 'getOffset': function( offset ) { |
895 | 883 | if ( !context.offsets ) { |
— | — | @@ -914,9 +902,7 @@ |
915 | 903 | 'node': base.node, |
916 | 904 | 'offset': base.offset + offset - lowerBound, |
917 | 905 | 'length': base.length, |
918 | | - 'depth': base.depth, |
919 | | - 'lastTextNode': base.lastTextNode, |
920 | | - 'lastTextNodeDepth': base.lastTextNodeDepth |
| 906 | + 'lastTextNode': base.lastTextNode |
921 | 907 | }; |
922 | 908 | }, |
923 | 909 | 'purgeOffsets': function() { |
— | — | @@ -925,7 +911,7 @@ |
926 | 912 | 'refreshOffsets': function() { |
927 | 913 | context.offsets = [ ]; |
928 | 914 | var t = context.fn.traverser( context.$content ); |
929 | | - var pos = 0, lastTextNode = null, lastTextNodeDepth = null; |
| 915 | + var pos = 0, lastTextNode = null; |
930 | 916 | while ( t ) { |
931 | 917 | if ( t.node.nodeName != '#text' && t.node.nodeName != 'BR' ) { |
932 | 918 | t = t.next(); |
— | — | @@ -938,9 +924,7 @@ |
939 | 925 | 'node': t.node, |
940 | 926 | 'offset': 0, |
941 | 927 | 'length': nextPos - pos + ( leavingP ? 1 : 0 ), |
942 | | - 'depth': t.depth, |
943 | | - 'lastTextNode': lastTextNode, |
944 | | - 'lastTextNodeDepth': lastTextNodeDepth |
| 928 | + 'lastTextNode': lastTextNode |
945 | 929 | }; |
946 | 930 | if ( leavingP ) { |
947 | 931 | // <p>Foo</p> looks like "Foo\n", make it quack like it too |
— | — | @@ -949,15 +933,12 @@ |
950 | 934 | 'node': t.node, |
951 | 935 | 'offset': nextPos - pos, |
952 | 936 | 'length': nextPos - pos + 1, |
953 | | - 'depth': t.depth, |
954 | | - 'lastTextNode': lastTextNode, |
955 | | - 'lastTextNodeDepth': lastTextNodeDepth |
| 937 | + 'lastTextNode': lastTextNode |
956 | 938 | }; |
957 | 939 | } |
958 | 940 | pos = nextPos + ( leavingP ? 1 : 0 ); |
959 | 941 | if ( t.node.nodeName == '#text' ) { |
960 | 942 | lastTextNode = t.node; |
961 | | - lastTextNodeDepth = t.depth; |
962 | 943 | } |
963 | 944 | t = nextT; |
964 | 945 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -186,7 +186,6 @@ |
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | var startNode = s.node; |
190 | | - var startDepth = s.depth; |
191 | 190 | |
192 | 191 | // Don't wrap leading BRs, produces undesirable results |
193 | 192 | // FIXME: It's also possible that the offset is a bit high because getOffset() has incremented |
— | — | @@ -196,7 +195,6 @@ |
197 | 196 | start++; |
198 | 197 | s = context.fn.getOffset( start ); |
199 | 198 | startNode = s.node; |
200 | | - startDepth = s.depth; |
201 | 199 | } |
202 | 200 | |
203 | 201 | // The next marker starts somewhere in this textNode or at this BR |
— | — | @@ -218,7 +216,6 @@ |
219 | 217 | // with lastTextNode == oldStartNode, but that doesn't really matter |
220 | 218 | var subtracted = s.offset; |
221 | 219 | var oldLength = s.length; |
222 | | - var oldDepth = s.depth; |
223 | 220 | |
224 | 221 | var j, o; |
225 | 222 | // Update offset objects referring to oldStartNode |
— | — | @@ -237,7 +234,6 @@ |
238 | 235 | o.offset -= subtracted; |
239 | 236 | o.length -= subtracted; |
240 | 237 | o.lastTextNode = oldStartNode; |
241 | | - o.lastTextNodeDepth = oldDepth; |
242 | 238 | } |
243 | 239 | } |
244 | 240 | } |
— | — | @@ -251,7 +247,6 @@ |
252 | 248 | continue; |
253 | 249 | } |
254 | 250 | var endNode = e.node; |
255 | | - var endDepth = e.depth; |
256 | 251 | if ( e.offset + 1 < e.length - 1 && endNode.nodeName == '#text' ) { |
257 | 252 | // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode |
258 | 253 | var newEndNode = endNode; |
— | — | @@ -260,7 +255,7 @@ |
261 | 256 | // Update offset objects |
262 | 257 | var subtracted = e.offset + 1; |
263 | 258 | var oldLength = e.length; |
264 | | - var oldDepth = e.depth; |
| 259 | + |
265 | 260 | |
266 | 261 | var j, o; |
267 | 262 | // Update offset objects referring to oldEndNode |
— | — | @@ -278,7 +273,6 @@ |
279 | 274 | o.offset -= subtracted; |
280 | 275 | o.length -= subtracted; |
281 | 276 | o.lastTextNode = oldEndNode; |
282 | | - o.lastTextNodeDepth = oldDepth; |
283 | 277 | } |
284 | 278 | } |
285 | 279 | } |
— | — | @@ -286,14 +280,13 @@ |
287 | 281 | // Don't wrap trailing BRs, doing that causes weird issues |
288 | 282 | if ( endNode.nodeName == 'BR' ) { |
289 | 283 | endNode = e.lastTextNode; |
290 | | - endDepth = e.lastTextNodeDepth; |
291 | 284 | } |
292 | 285 | |
293 | 286 | // If startNode and endNode have different parents, we need to pull endNode and all textnodes in between |
294 | 287 | // into startNode's parent and replace </p><p> with <br> |
295 | 288 | if ( startNode.parentNode != endNode.parentNode ) { |
296 | 289 | var startP = $( startNode ).closest( 'p' ).get( 0 ); |
297 | | - var t = new context.fn.rawTraverser( startNode, 0, startP, context.$content.get( 0 ), false ); |
| 290 | + var t = new context.fn.rawTraverser( startNode, startP, context.$content.get( 0 ), false ); |
298 | 291 | var afterStart = startNode.nextSibling; |
299 | 292 | var lastP = startP; |
300 | 293 | var nextT = t.next(); |
— | — | @@ -341,7 +334,6 @@ |
342 | 335 | // Moving nodes around like this invalidates offset objects |
343 | 336 | // TODO: Update offset objects ourselves for performance. Requires rewriting this code block to be |
344 | 337 | // offset-based rather than traverser-based |
345 | | - context.fn.purgeOffsets(); |
346 | 338 | } |
347 | 339 | |
348 | 340 | // Now wrap everything between startNode and endNode (may be equal). |
— | — | @@ -412,11 +404,9 @@ |
413 | 405 | // Assume anchor == 'wrap' |
414 | 406 | $(this).replaceWith( this.childNodes ); |
415 | 407 | } |
| 408 | + context.fn.purgeOffsets(); |
416 | 409 | }); |
417 | 410 | |
418 | | - // Purge offsets after we're done |
419 | | - // TODO: Ideally this is not needed |
420 | | - context.fn.purgeOffsets(); |
421 | 411 | } |
422 | 412 | } |
423 | 413 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7197,7 +7197,7 @@ |
7198 | 7198 | // We need the traverser because there can be other weird stuff in between |
7199 | 7199 | |
7200 | 7200 | // Check for preceding text |
7201 | | - var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ), true ).prev(); |
| 7201 | + var t = new context.fn.rawTraverser( this.firstChild, this, $pre.get( 0 ), true ).prev(); |
7202 | 7202 | while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
7203 | 7203 | t = t.prev(); |
7204 | 7204 | } |
— | — | @@ -7206,7 +7206,7 @@ |
7207 | 7207 | } |
7208 | 7208 | |
7209 | 7209 | // Check for following text |
7210 | | - t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ), true ).next(); |
| 7210 | + t = new context.fn.rawTraverser( this.lastChild, this, $pre.get( 0 ), true ).next(); |
7211 | 7211 | while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
7212 | 7212 | t = t.next(); |
7213 | 7213 | } |
— | — | @@ -7312,19 +7312,16 @@ |
7313 | 7313 | /** |
7314 | 7314 | * Object used by traverser(). Don't use this unless you know what you're doing |
7315 | 7315 | */ |
7316 | | - 'rawTraverser': function( node, depth, inP, ancestor, skipNoinclude ) { |
| 7316 | + 'rawTraverser': function( node, inP, ancestor, skipNoinclude ) { |
7317 | 7317 | this.node = node; |
7318 | | - this.depth = depth; |
7319 | 7318 | this.inP = inP; |
7320 | 7319 | this.ancestor = ancestor; |
7321 | 7320 | this.skipNoinclude = skipNoinclude; |
7322 | 7321 | this.next = function() { |
7323 | 7322 | var p = this.node; |
7324 | | - var nextDepth = this.depth; |
7325 | 7323 | var nextInP = this.inP; |
7326 | 7324 | while ( p && !p.nextSibling ) { |
7327 | 7325 | p = p.parentNode; |
7328 | | - nextDepth--; |
7329 | 7326 | if ( p == this.ancestor ) { |
7330 | 7327 | // We're back at the ancestor, stop here |
7331 | 7328 | p = null; |
— | — | @@ -7348,23 +7345,20 @@ |
7349 | 7346 | } |
7350 | 7347 | if ( p && p.firstChild ) { |
7351 | 7348 | p = p.firstChild; |
7352 | | - nextDepth++; |
7353 | 7349 | if ( p.nodeName == "P" ) { |
7354 | 7350 | nextInP = p; |
7355 | 7351 | } |
7356 | 7352 | } |
7357 | 7353 | } while ( p && p.firstChild ); |
7358 | 7354 | // Instead of calling the rawTraverser constructor, inline it. This avoids function call overhead |
7359 | | - return p ? { 'node': p, 'depth': nextDepth, 'inP': nextInP, 'ancestor': this.ancestor, |
| 7355 | + return p ? { 'node': p, 'inP': nextInP, 'ancestor': this.ancestor, |
7360 | 7356 | 'skipNoinclude': this.skipNoinclude, 'next': this.next, 'prev': this.prev } : null; |
7361 | 7357 | }; |
7362 | 7358 | this.prev = function() { |
7363 | 7359 | var p = this.node; |
7364 | | - var prevDepth = this.depth; |
7365 | 7360 | var prevInP = this.inP; |
7366 | 7361 | while ( p && !p.previousSibling ) { |
7367 | 7362 | p = p.parentNode; |
7368 | | - prevDepth--; |
7369 | 7363 | if ( p == this.ancestor ) { |
7370 | 7364 | // We're back at the ancestor, stop here |
7371 | 7365 | p = null; |
— | — | @@ -7388,14 +7382,13 @@ |
7389 | 7383 | } |
7390 | 7384 | if ( p && p.lastChild ) { |
7391 | 7385 | p = p.lastChild; |
7392 | | - prevDepth++; |
7393 | 7386 | if ( p.nodeName == "P" ) { |
7394 | 7387 | prevInP = p; |
7395 | 7388 | } |
7396 | 7389 | } |
7397 | 7390 | } while ( p && p.lastChild ); |
7398 | 7391 | // Instead of calling the rawTraverser constructor, inline it. This avoids function call overhead |
7399 | | - return p ? { 'node': p, 'depth': prevDepth, 'inP': prevInP, 'ancestor': this.ancestor, |
| 7392 | + return p ? { 'node': p, 'inP': prevInP, 'ancestor': this.ancestor, |
7400 | 7393 | 'skipNoinclude': this.skipNoinclude, 'next': this.next, 'prev': this.prev } : null; |
7401 | 7394 | }; |
7402 | 7395 | }, |
— | — | @@ -7403,18 +7396,14 @@ |
7404 | 7397 | * Get an object used to traverse the leaf nodes in the iframe DOM. This traversal skips leaf nodes |
7405 | 7398 | * inside an element with the wikiEditor-noinclude class. This basically wraps rawTraverser |
7406 | 7399 | * |
7407 | | - * Usage: |
7408 | | - * var t = context.fn.traverser( context.$content ); |
7409 | | - * // t.node is the first textnode, t.depth is its depth |
7410 | | - * t.goNext(); |
7411 | | - * // t.node is the second textnode, t.depth is its depth |
7412 | | - * // Trying to advance past the end will set t.node to null |
| 7400 | + * @param start Node to start at |
| 7401 | + * @return Traverser object, use .next() or .prev() to get a traverser object referring to the |
| 7402 | + * previous/next node |
7413 | 7403 | */ |
7414 | 7404 | 'traverser': function( start ) { |
7415 | 7405 | // Find the leftmost leaf node in the tree |
7416 | 7406 | var startNode = start.jquery ? start.get( 0 ) : start; |
7417 | 7407 | var node = startNode; |
7418 | | - var depth = 0; |
7419 | 7408 | var inP = node.nodeName == "P" ? node : null; |
7420 | 7409 | do { |
7421 | 7410 | // Filter nodes with the wikiEditor-noinclude class |
— | — | @@ -7425,13 +7414,12 @@ |
7426 | 7415 | } |
7427 | 7416 | if ( node && node.firstChild ) { |
7428 | 7417 | node = node.firstChild; |
7429 | | - depth++; |
7430 | 7418 | if ( node.nodeName == "P" ) { |
7431 | 7419 | inP = node; |
7432 | 7420 | } |
7433 | 7421 | } |
7434 | 7422 | } while ( node && node.firstChild ); |
7435 | | - return new context.fn.rawTraverser( node, depth, inP, startNode, true ); |
| 7423 | + return new context.fn.rawTraverser( node, inP, startNode, true ); |
7436 | 7424 | }, |
7437 | 7425 | 'getOffset': function( offset ) { |
7438 | 7426 | if ( !context.offsets ) { |
— | — | @@ -7457,9 +7445,7 @@ |
7458 | 7446 | 'node': base.node, |
7459 | 7447 | 'offset': base.offset + offset - lowerBound, |
7460 | 7448 | 'length': base.length, |
7461 | | - 'depth': base.depth, |
7462 | | - 'lastTextNode': base.lastTextNode, |
7463 | | - 'lastTextNodeDepth': base.lastTextNodeDepth |
| 7449 | + 'lastTextNode': base.lastTextNode |
7464 | 7450 | }; |
7465 | 7451 | }, |
7466 | 7452 | 'purgeOffsets': function() { |
— | — | @@ -7468,7 +7454,7 @@ |
7469 | 7455 | 'refreshOffsets': function() { |
7470 | 7456 | context.offsets = [ ]; |
7471 | 7457 | var t = context.fn.traverser( context.$content ); |
7472 | | - var pos = 0, lastTextNode = null, lastTextNodeDepth = null; |
| 7458 | + var pos = 0, lastTextNode = null; |
7473 | 7459 | while ( t ) { |
7474 | 7460 | if ( t.node.nodeName != '#text' && t.node.nodeName != 'BR' ) { |
7475 | 7461 | t = t.next(); |
— | — | @@ -7481,9 +7467,7 @@ |
7482 | 7468 | 'node': t.node, |
7483 | 7469 | 'offset': 0, |
7484 | 7470 | 'length': nextPos - pos + ( leavingP ? 1 : 0 ), |
7485 | | - 'depth': t.depth, |
7486 | | - 'lastTextNode': lastTextNode, |
7487 | | - 'lastTextNodeDepth': lastTextNodeDepth |
| 7471 | + 'lastTextNode': lastTextNode |
7488 | 7472 | }; |
7489 | 7473 | if ( leavingP ) { |
7490 | 7474 | // <p>Foo</p> looks like "Foo\n", make it quack like it too |
— | — | @@ -7492,15 +7476,12 @@ |
7493 | 7477 | 'node': t.node, |
7494 | 7478 | 'offset': nextPos - pos, |
7495 | 7479 | 'length': nextPos - pos + 1, |
7496 | | - 'depth': t.depth, |
7497 | | - 'lastTextNode': lastTextNode, |
7498 | | - 'lastTextNodeDepth': lastTextNodeDepth |
| 7480 | + 'lastTextNode': lastTextNode |
7499 | 7481 | }; |
7500 | 7482 | } |
7501 | 7483 | pos = nextPos + ( leavingP ? 1 : 0 ); |
7502 | 7484 | if ( t.node.nodeName == '#text' ) { |
7503 | 7485 | lastTextNode = t.node; |
7504 | | - lastTextNodeDepth = t.depth; |
7505 | 7486 | } |
7506 | 7487 | t = nextT; |
7507 | 7488 | } |
— | — | @@ -8727,7 +8708,6 @@ |
8728 | 8709 | continue; |
8729 | 8710 | } |
8730 | 8711 | var startNode = s.node; |
8731 | | - var startDepth = s.depth; |
8732 | 8712 | |
8733 | 8713 | // Don't wrap leading BRs, produces undesirable results |
8734 | 8714 | // FIXME: It's also possible that the offset is a bit high because getOffset() has incremented |
— | — | @@ -8737,7 +8717,6 @@ |
8738 | 8718 | start++; |
8739 | 8719 | s = context.fn.getOffset( start ); |
8740 | 8720 | startNode = s.node; |
8741 | | - startDepth = s.depth; |
8742 | 8721 | } |
8743 | 8722 | |
8744 | 8723 | // The next marker starts somewhere in this textNode or at this BR |
— | — | @@ -8759,7 +8738,6 @@ |
8760 | 8739 | // with lastTextNode == oldStartNode, but that doesn't really matter |
8761 | 8740 | var subtracted = s.offset; |
8762 | 8741 | var oldLength = s.length; |
8763 | | - var oldDepth = s.depth; |
8764 | 8742 | |
8765 | 8743 | var j, o; |
8766 | 8744 | // Update offset objects referring to oldStartNode |
— | — | @@ -8778,7 +8756,6 @@ |
8779 | 8757 | o.offset -= subtracted; |
8780 | 8758 | o.length -= subtracted; |
8781 | 8759 | o.lastTextNode = oldStartNode; |
8782 | | - o.lastTextNodeDepth = oldDepth; |
8783 | 8760 | } |
8784 | 8761 | } |
8785 | 8762 | } |
— | — | @@ -8792,7 +8769,6 @@ |
8793 | 8770 | continue; |
8794 | 8771 | } |
8795 | 8772 | var endNode = e.node; |
8796 | | - var endDepth = e.depth; |
8797 | 8773 | if ( e.offset + 1 < e.length - 1 && endNode.nodeName == '#text' ) { |
8798 | 8774 | // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode |
8799 | 8775 | var newEndNode = endNode; |
— | — | @@ -8801,7 +8777,7 @@ |
8802 | 8778 | // Update offset objects |
8803 | 8779 | var subtracted = e.offset + 1; |
8804 | 8780 | var oldLength = e.length; |
8805 | | - var oldDepth = e.depth; |
| 8781 | + |
8806 | 8782 | |
8807 | 8783 | var j, o; |
8808 | 8784 | // Update offset objects referring to oldEndNode |
— | — | @@ -8819,7 +8795,6 @@ |
8820 | 8796 | o.offset -= subtracted; |
8821 | 8797 | o.length -= subtracted; |
8822 | 8798 | o.lastTextNode = oldEndNode; |
8823 | | - o.lastTextNodeDepth = oldDepth; |
8824 | 8799 | } |
8825 | 8800 | } |
8826 | 8801 | } |
— | — | @@ -8827,14 +8802,13 @@ |
8828 | 8803 | // Don't wrap trailing BRs, doing that causes weird issues |
8829 | 8804 | if ( endNode.nodeName == 'BR' ) { |
8830 | 8805 | endNode = e.lastTextNode; |
8831 | | - endDepth = e.lastTextNodeDepth; |
8832 | 8806 | } |
8833 | 8807 | |
8834 | 8808 | // If startNode and endNode have different parents, we need to pull endNode and all textnodes in between |
8835 | 8809 | // into startNode's parent and replace </p><p> with <br> |
8836 | 8810 | if ( startNode.parentNode != endNode.parentNode ) { |
8837 | 8811 | var startP = $( startNode ).closest( 'p' ).get( 0 ); |
8838 | | - var t = new context.fn.rawTraverser( startNode, 0, startP, context.$content.get( 0 ), false ); |
| 8812 | + var t = new context.fn.rawTraverser( startNode, startP, context.$content.get( 0 ), false ); |
8839 | 8813 | var afterStart = startNode.nextSibling; |
8840 | 8814 | var lastP = startP; |
8841 | 8815 | var nextT = t.next(); |
— | — | @@ -8882,7 +8856,6 @@ |
8883 | 8857 | // Moving nodes around like this invalidates offset objects |
8884 | 8858 | // TODO: Update offset objects ourselves for performance. Requires rewriting this code block to be |
8885 | 8859 | // offset-based rather than traverser-based |
8886 | | - context.fn.purgeOffsets(); |
8887 | 8860 | } |
8888 | 8861 | |
8889 | 8862 | // Now wrap everything between startNode and endNode (may be equal). |
— | — | @@ -8953,11 +8926,9 @@ |
8954 | 8927 | // Assume anchor == 'wrap' |
8955 | 8928 | $(this).replaceWith( this.childNodes ); |
8956 | 8929 | } |
| 8930 | + context.fn.purgeOffsets(); |
8957 | 8931 | }); |
8958 | 8932 | |
8959 | | - // Purge offsets after we're done |
8960 | | - // TODO: Ideally this is not needed |
8961 | | - context.fn.purgeOffsets(); |
8962 | 8933 | } |
8963 | 8934 | } |
8964 | 8935 | |
— | — | @@ -9380,7 +9351,7 @@ |
9381 | 9352 | } |
9382 | 9353 | }, //mark |
9383 | 9354 | |
9384 | | - keydown: function( context, event ){ |
| 9355 | + keydown: function( context, event ) { |
9385 | 9356 | // reset our ignoreKeypress variable if it's set to true |
9386 | 9357 | if( context.$iframe.data( 'ignoreKeypress' ) ) context.$iframe.data( 'ignoreKeypress', false ); |
9387 | 9358 | var $evtElem = event.jQueryNode; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -479,9 +479,9 @@ |
480 | 480 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
481 | 481 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'highlightLine':function($element,mode){if(!$element.is('p')){$element=$element.closest('p');} |
482 | 482 | $element.css('backgroundColor','#AACCFF');setTimeout(function(){$element.animate({'backgroundColor':'white'},'slow');},100);setTimeout(function(){$element.css('backgroundColor','white');},1000);},'htmlToText':function(html){if(html in context.htmlToTextMap){return context.htmlToTextMap[html];} |
483 | | -var origHTML=html;html=html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/\<br[^\>]*\>\<\/p\>/gi,'</p>').replace(/\<\/p\>\s*\<p[^\>]*\>/gi,"\n").replace(/\<br[^\>]*\>/gi,"\n").replace(/\<\/p\>(\n*)\<p[^\>]*\>/gi,"$1\n").replace(/\<p[^\>]*\><p[^\>]*\>/gi,'<p>').replace(/\<\/p\><\/p\>/gi,'</p>');var leading=html.match(/^\s*/)[0];var trailing=html.match(/\s*$/)[0];html=html.substr(leading.length,html.length-leading.length-trailing.length);var $pre=$('<pre>'+html+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t");});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,0,this,$pre.get(0),true).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
| 483 | +var origHTML=html;html=html.replace(/\r?\n/g,"").replace(/ /g," ").replace(/\<br[^\>]*\>\<\/p\>/gi,'</p>').replace(/\<\/p\>\s*\<p[^\>]*\>/gi,"\n").replace(/\<br[^\>]*\>/gi,"\n").replace(/\<\/p\>(\n*)\<p[^\>]*\>/gi,"$1\n").replace(/\<p[^\>]*\><p[^\>]*\>/gi,'<p>').replace(/\<\/p\><\/p\>/gi,'</p>');var leading=html.match(/^\s*/)[0];var trailing=html.match(/\s*$/)[0];html=html.substr(leading.length,html.length-leading.length-trailing.length);var $pre=$('<pre>'+html+'</pre>');$pre.find('.wikiEditor-noinclude').each(function(){$(this).remove();});$pre.find('.wikiEditor-tab').each(function(){$(this).text("\t");});$pre.find('br').each(function(){$(this).replaceWith("\n");});$pre.find('p').each(function(){var text=$(this).text();var t=new context.fn.rawTraverser(this.firstChild,this,$pre.get(0),true).prev();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.prev();} |
484 | 484 | if(t){text="\n"+text;} |
485 | | -t=new context.fn.rawTraverser(this.lastChild,0,this,$pre.get(0),true).next();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();} |
| 485 | +t=new context.fn.rawTraverser(this.lastChild,this,$pre.get(0),true).next();while(t&&t.node.nodeName!='#text'&&t.node.nodeName!='BR'&&t.node.nodeName!='P'){t=t.next();} |
486 | 486 | if(t&&!t.inP&&t.node.nodeName=='#text'&&t.node.nodeValue.charAt(0)!='\n'&&t.node.nodeValue.charAt(0)!='\r'){text+="\n";} |
487 | 487 | $(this).text(text);});var retval;if($.browser.msie){retval=$('<pre>'+$pre.html()+'</pre>').text().replace(/\r/g,'\n');}else{retval=$pre.text();} |
488 | 488 | return context.htmlToTextMap[origHTML]=leading+retval+trailing;},'beforeSelection':function(classname,strict){if(typeof classname=='undefined'){classname='';} |
— | — | @@ -495,23 +495,23 @@ |
496 | 496 | var classStr=' '+classname+' ';while(e){if(!strict&&(!classname||(' '+e.className+' ').indexOf(classStr)!=-1)){return $(e);} |
497 | 497 | var next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;} |
498 | 498 | e=next||e.parentNode;strict=false;} |
499 | | -return $([]);},'rawTraverser':function(node,depth,inP,ancestor,skipNoinclude){this.node=node;this.depth=depth;this.inP=inP;this.ancestor=ancestor;this.skipNoinclude=skipNoinclude;this.next=function(){var p=this.node;var nextDepth=this.depth;var nextInP=this.inP;while(p&&!p.nextSibling){p=p.parentNode;nextDepth--;if(p==this.ancestor){p=null;} |
| 499 | +return $([]);},'rawTraverser':function(node,inP,ancestor,skipNoinclude){this.node=node;this.inP=inP;this.ancestor=ancestor;this.skipNoinclude=skipNoinclude;this.next=function(){var p=this.node;var nextInP=this.inP;while(p&&!p.nextSibling){p=p.parentNode;if(p==this.ancestor){p=null;} |
500 | 500 | if(p&&p.nodeName=="P"){nextInP=null;}} |
501 | 501 | p=p?p.nextSibling:null;if(p&&p.nodeName=="P"){nextInP=p;} |
502 | 502 | do{if(this.skipNoinclude){while(p&&(' '+p.className+' ').indexOf(' wikiEditor-noinclude ')!=-1){p=p.nextSibling;}} |
503 | | -if(p&&p.firstChild){p=p.firstChild;nextDepth++;if(p.nodeName=="P"){nextInP=p;}}}while(p&&p.firstChild);return p?{'node':p,'depth':nextDepth,'inP':nextInP,'ancestor':this.ancestor,'skipNoinclude':this.skipNoinclude,'next':this.next,'prev':this.prev}:null;};this.prev=function(){var p=this.node;var prevDepth=this.depth;var prevInP=this.inP;while(p&&!p.previousSibling){p=p.parentNode;prevDepth--;if(p==this.ancestor){p=null;} |
| 503 | +if(p&&p.firstChild){p=p.firstChild;if(p.nodeName=="P"){nextInP=p;}}}while(p&&p.firstChild);return p?{'node':p,'inP':nextInP,'ancestor':this.ancestor,'skipNoinclude':this.skipNoinclude,'next':this.next,'prev':this.prev}:null;};this.prev=function(){var p=this.node;var prevInP=this.inP;while(p&&!p.previousSibling){p=p.parentNode;if(p==this.ancestor){p=null;} |
504 | 504 | if(p&&p.nodeName=="P"){prevInP=null;}} |
505 | 505 | p=p?p.previousSibling:null;if(p&&p.nodeName=="P"){prevInP=p;} |
506 | 506 | do{if(this.skipNoinclude){while(p&&(' '+p.className+' ').indexOf(' wikiEditor-noinclude ')!=-1){p=p.previousSibling;}} |
507 | | -if(p&&p.lastChild){p=p.lastChild;prevDepth++;if(p.nodeName=="P"){prevInP=p;}}}while(p&&p.lastChild);return p?{'node':p,'depth':prevDepth,'inP':prevInP,'ancestor':this.ancestor,'skipNoinclude':this.skipNoinclude,'next':this.next,'prev':this.prev}:null;};},'traverser':function(start){var startNode=start.jquery?start.get(0):start;var node=startNode;var depth=0;var inP=node.nodeName=="P"?node:null;do{while(node&&(' '+node.className+' ').indexOf(' wikiEditor-noinclude ')!=-1){node=node.nextSibling;} |
508 | | -if(node&&node.firstChild){node=node.firstChild;depth++;if(node.nodeName=="P"){inP=node;}}}while(node&&node.firstChild);return new context.fn.rawTraverser(node,depth,inP,startNode,true);},'getOffset':function(offset){if(!context.offsets){context.fn.refreshOffsets();} |
| 507 | +if(p&&p.lastChild){p=p.lastChild;if(p.nodeName=="P"){prevInP=p;}}}while(p&&p.lastChild);return p?{'node':p,'inP':prevInP,'ancestor':this.ancestor,'skipNoinclude':this.skipNoinclude,'next':this.next,'prev':this.prev}:null;};},'traverser':function(start){var startNode=start.jquery?start.get(0):start;var node=startNode;var inP=node.nodeName=="P"?node:null;do{while(node&&(' '+node.className+' ').indexOf(' wikiEditor-noinclude ')!=-1){node=node.nextSibling;} |
| 508 | +if(node&&node.firstChild){node=node.firstChild;if(node.nodeName=="P"){inP=node;}}}while(node&&node.firstChild);return new context.fn.rawTraverser(node,inP,startNode,true);},'getOffset':function(offset){if(!context.offsets){context.fn.refreshOffsets();} |
509 | 509 | if(offset in context.offsets){return context.offsets[offset];} |
510 | 510 | var lowerBound=-1;for(var o in context.offsets){if(o>offset){break;} |
511 | 511 | lowerBound=o;} |
512 | 512 | if(!(lowerBound in context.offsets)){return null;} |
513 | | -var base=context.offsets[lowerBound];return context.offsets[offset]={'node':base.node,'offset':base.offset+offset-lowerBound,'length':base.length,'depth':base.depth,'lastTextNode':base.lastTextNode,'lastTextNodeDepth':base.lastTextNodeDepth};},'purgeOffsets':function(){context.offsets=null;},'refreshOffsets':function(){context.offsets=[];var t=context.fn.traverser(context.$content);var pos=0,lastTextNode=null,lastTextNodeDepth=null;while(t){if(t.node.nodeName!='#text'&&t.node.nodeName!='BR'){t=t.next();continue;} |
514 | | -var nextPos=t.node.nodeName=='#text'?pos+t.node.nodeValue.length:pos+1;var nextT=t.next();var leavingP=t.node.nodeName=='#text'&&t.inP&&nextT&&(!nextT.inP||nextT.inP!=t.inP);context.offsets[pos]={'node':t.node,'offset':0,'length':nextPos-pos+(leavingP?1:0),'depth':t.depth,'lastTextNode':lastTextNode,'lastTextNodeDepth':lastTextNodeDepth};if(leavingP){context.offsets[nextPos]={'node':t.node,'offset':nextPos-pos,'length':nextPos-pos+1,'depth':t.depth,'lastTextNode':lastTextNode,'lastTextNodeDepth':lastTextNodeDepth};} |
515 | | -pos=nextPos+(leavingP?1:0);if(t.node.nodeName=='#text'){lastTextNode=t.node;lastTextNodeDepth=t.depth;} |
| 513 | +var base=context.offsets[lowerBound];return context.offsets[offset]={'node':base.node,'offset':base.offset+offset-lowerBound,'length':base.length,'lastTextNode':base.lastTextNode};},'purgeOffsets':function(){context.offsets=null;},'refreshOffsets':function(){context.offsets=[];var t=context.fn.traverser(context.$content);var pos=0,lastTextNode=null;while(t){if(t.node.nodeName!='#text'&&t.node.nodeName!='BR'){t=t.next();continue;} |
| 514 | +var nextPos=t.node.nodeName=='#text'?pos+t.node.nodeValue.length:pos+1;var nextT=t.next();var leavingP=t.node.nodeName=='#text'&&t.inP&&nextT&&(!nextT.inP||nextT.inP!=t.inP);context.offsets[pos]={'node':t.node,'offset':0,'length':nextPos-pos+(leavingP?1:0),'lastTextNode':lastTextNode};if(leavingP){context.offsets[nextPos]={'node':t.node,'offset':nextPos-pos,'length':nextPos-pos+1,'lastTextNode':lastTextNode};} |
| 515 | +pos=nextPos+(leavingP?1:0);if(t.node.nodeName=='#text'){lastTextNode=t.node;} |
516 | 516 | t=nextT;}},'saveSelection':function(){if(!$.browser.msie){return;} |
517 | 517 | context.$iframe[0].contentWindow.focus();context.savedSelection=context.$iframe[0].contentWindow.document.selection.createRange();},'restoreSelection':function(){if(!$.browser.msie||context.savedSelection===null){return;} |
518 | 518 | context.$iframe[0].contentWindow.focus();context.savedSelection.select();context.savedSelection=null;},'updateHistory':function(htmlChange){var newHTML=context.$content.html();var newSel=context.fn.getCaretPosition();if(context.history.length==0||(htmlChange&&context.oldDelayedHistoryPosition==context.historyPosition)){context.fn.purgeOffsets();context.oldDelayedSel=newSel;if(context.historyPosition<-1){context.history.splice(context.history.length+context.historyPosition+1);context.historyPosition=-1;} |
— | — | @@ -591,19 +591,18 @@ |
592 | 592 | if(context.modules.highlight.markersStr==markersStr){return;} |
593 | 593 | context.modules.highlight.markersStr=markersStr;var oldStarts=[];if(!context.modules.highlight.markersOldStarts){context.modules.highlight.markersOldStarts=[];} |
594 | 594 | var visited=[],v=0;for(var i=0;i<markers.length;i++){var start=markers[i].start;var s=context.fn.getOffset(start);if(!s){continue;} |
595 | | -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;} |
596 | | -if(s.offset>0&&s.node.nodeName=='#text'){var newStartNode=startNode.splitText(s.offset<s.node.nodeValue.length?s.offset:s.node.nodeValue.length-1);var oldStartNode=startNode;startNode=newStartNode;var subtracted=s.offset;var oldLength=s.length;var oldDepth=s.depth;var j,o;for(j=start-subtracted;j<start;j++){if(j in context.offsets){o=context.offsets[j];o.node=oldStartNode;o.length=subtracted;}} |
597 | | -for(j=start;j<start-subtracted+oldLength;j++){if(j in context.offsets){o=context.offsets[j];o.node=newStartNode;o.offset-=subtracted;o.length-=subtracted;o.lastTextNode=oldStartNode;o.lastTextNodeDepth=oldDepth;}}} |
| 595 | +var startNode=s.node;while(startNode.nodeName=='BR'||s.offset==startNode.nodeValue.length){start++;s=context.fn.getOffset(start);startNode=s.node;} |
| 596 | +if(s.offset>0&&s.node.nodeName=='#text'){var newStartNode=startNode.splitText(s.offset<s.node.nodeValue.length?s.offset:s.node.nodeValue.length-1);var oldStartNode=startNode;startNode=newStartNode;var subtracted=s.offset;var oldLength=s.length;var j,o;for(j=start-subtracted;j<start;j++){if(j in context.offsets){o=context.offsets[j];o.node=oldStartNode;o.length=subtracted;}} |
| 597 | +for(j=start;j<start-subtracted+oldLength;j++){if(j in context.offsets){o=context.offsets[j];o.node=newStartNode;o.offset-=subtracted;o.length-=subtracted;o.lastTextNode=oldStartNode;}}} |
598 | 598 | var end=markers[i].end;var e=context.fn.getOffset(end-1);if(!e){continue;} |
599 | | -var endNode=e.node;var endDepth=e.depth;if(e.offset+1<e.length-1&&endNode.nodeName=='#text'){var newEndNode=endNode;var oldEndNode=endNode.splitText(e.offset+1);var subtracted=e.offset+1;var oldLength=e.length;var oldDepth=e.depth;var j,o;for(j=end-subtracted;j<end;j++){if(j in context.offsets){o=context.offsets[j];o.node=oldEndNode;o.length=subtracted;}} |
600 | | -for(j=end;j<end-subtracted+oldLength;j++){if(j in context.offsets){o=context.offsets[j];o.node=newEndNode;o.offset-=subtracted;o.length-=subtracted;o.lastTextNode=oldEndNode;o.lastTextNodeDepth=oldDepth;}}} |
601 | | -if(endNode.nodeName=='BR'){endNode=e.lastTextNode;endDepth=e.lastTextNodeDepth;} |
602 | | -if(startNode.parentNode!=endNode.parentNode){var startP=$(startNode).closest('p').get(0);var t=new context.fn.rawTraverser(startNode,0,startP,context.$content.get(0),false);var afterStart=startNode.nextSibling;var lastP=startP;var nextT=t.next();while(nextT&&t.node!=endNode){t=nextT;nextT=t.next();if(t.node.parentNode!=startNode.parentNode){var oldParent=t.node.parentNode;if(afterStart){if(lastP!=t.inP){startNode.parentNode.insertBefore(startNode.ownerDocument.createElement('br'),afterStart);} |
| 599 | +var endNode=e.node;if(e.offset+1<e.length-1&&endNode.nodeName=='#text'){var newEndNode=endNode;var oldEndNode=endNode.splitText(e.offset+1);var subtracted=e.offset+1;var oldLength=e.length;var j,o;for(j=end-subtracted;j<end;j++){if(j in context.offsets){o=context.offsets[j];o.node=oldEndNode;o.length=subtracted;}} |
| 600 | +for(j=end;j<end-subtracted+oldLength;j++){if(j in context.offsets){o=context.offsets[j];o.node=newEndNode;o.offset-=subtracted;o.length-=subtracted;o.lastTextNode=oldEndNode;}}} |
| 601 | +if(endNode.nodeName=='BR'){endNode=e.lastTextNode;} |
| 602 | +if(startNode.parentNode!=endNode.parentNode){var startP=$(startNode).closest('p').get(0);var t=new context.fn.rawTraverser(startNode,startP,context.$content.get(0),false);var afterStart=startNode.nextSibling;var lastP=startP;var nextT=t.next();while(nextT&&t.node!=endNode){t=nextT;nextT=t.next();if(t.node.parentNode!=startNode.parentNode){var oldParent=t.node.parentNode;if(afterStart){if(lastP!=t.inP){startNode.parentNode.insertBefore(startNode.ownerDocument.createElement('br'),afterStart);} |
603 | 603 | if(!(oldParent.childNodes.length==1&&oldParent.firstChild.nodeName=='BR')){while(oldParent.firstChild){startNode.parentNode.insertBefore(oldParent.firstChild,afterStart);}}}else{if(lastP!=t.inP){startNode.parentNode.appendChild(startNode.ownerDocument.createElement('br'));} |
604 | 604 | if(!(oldParent.childNodes.length==1&&oldParent.firstChild.nodeName=='BR')){while(oldParent.firstChild){startNode.parentNode.appendChild(oldParent.firstChild);}}} |
605 | 605 | oldParent.parentNode.removeChild(oldParent);} |
606 | | -lastP=t.inP;} |
607 | | -context.fn.purgeOffsets();} |
| 606 | +lastP=t.inP;}} |
608 | 607 | var ca1=startNode,ca2=endNode;if(ca1&&ca2&&ca1.parentNode){var anchor=markers[i].getAnchor(ca1,ca2);if(!anchor){var commonAncestor=ca1.parentNode;if(markers[i].anchor=='wrap'){var newNode=ca1.ownerDocument.createElement('span');var nextNode=ca2.nextSibling;var n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;} |
609 | 608 | if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);} |
610 | 609 | anchor=newNode;}else if(markers[i].anchor=='tag'){anchor=commonAncestor;} |
— | — | @@ -611,7 +610,8 @@ |
612 | 611 | visited[v++]=anchor;}} |
613 | 612 | var j=0;context.$content.find('.wikiEditor-highlight').each(function(){if(visited[j]==this){j++;return true;} |
614 | 613 | var marker=$(this).data('marker');if(marker&&typeof marker.beforeUnwrap=='function') |
615 | | -marker.beforeUnwrap(this);if((marker&&marker.anchor=='tag')||$(this).is('p')){$(this).removeAttr('class');}else{$(this).replaceWith(this.childNodes);}});context.fn.purgeOffsets();}}};})(jQuery);(function($){$.wikiEditor.modules.preview={'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]}},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;} |
| 614 | +marker.beforeUnwrap(this);if((marker&&marker.anchor=='tag')||$(this).is('p')){$(this).removeAttr('class');}else{$(this).replaceWith(this.childNodes);} |
| 615 | +context.fn.purgeOffsets();});}}};})(jQuery);(function($){$.wikiEditor.modules.preview={'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',9.6]],'safari':[['>=',4]]}},fn:{create:function(context,config){if('initialized'in context.modules.preview){return;} |
616 | 616 | 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;} |
617 | 617 | context.modules.preview.$preview.find('.wikiEditor-preview-contents').empty();context.modules.preview.$preview.find('.wikiEditor-preview-loading').show();$.post(wgScriptPath+'/api.php',{'action':'parse','title':wgPageName,'text':wikitext,'prop':'text','pst':'','format':'json'},function(data){if(typeof data.parse=='undefined'||typeof data.parse.text=='undefined'||typeof data.parse.text['*']=='undefined'){return;} |
618 | 618 | context.modules.preview.previewText=wikitext;context.modules.preview.$preview.find('.wikiEditor-preview-loading').hide();context.modules.preview.$preview.find('.wikiEditor-preview-contents').html(data.parse.text['*']).find('a:not([href^=#])').click(function(){return false;});},'json');}});context.$changesTab=context.fn.addView({'name':'changes','titleMsg':'wikieditor-preview-changes-tab','init':function(context){var wikitext=context.fn.getContents();if(context.modules.preview.changesText==wikitext){return;} |