Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ), |
76 | 76 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 172 ), |
77 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 43 ), |
| 77 | + array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 44 ), |
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 ), |
— | — | @@ -82,10 +82,10 @@ |
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' => 341 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 342 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 341 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 342 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -202,40 +202,10 @@ |
203 | 203 | // Split off the prefix |
204 | 204 | // This leaves the prefix in the current node and puts |
205 | 205 | // the rest in a new node which is our start node |
206 | | - var newStartNode = startNode.splitText( s.offset < s.node.nodeValue.length ? |
| 206 | + startNode = startNode.splitText( s.offset < s.node.nodeValue.length ? |
207 | 207 | s.offset : s.node.nodeValue.length - 1 |
208 | 208 | ); |
209 | | - var oldStartNode = startNode; |
210 | | - startNode = newStartNode; |
211 | | - |
212 | | - // Update offset objects. We don't need purgeOffsets(), simply |
213 | | - // manipulating the existing offset objects will suffice |
214 | | - // FIXME: This manipulates context.offsets directly, which is ugly, |
215 | | - // but the performance improvement vs. purgeOffsets() is worth it |
216 | | - // This code doesn't set lastTextNode to newStartNode for offset objects |
217 | | - // with lastTextNode == oldStartNode, but that doesn't really matter |
218 | | - var subtracted = s.offset; |
219 | | - var oldLength = s.length; |
220 | | - |
221 | | - var j, o; |
222 | | - // Update offset objects referring to oldStartNode |
223 | | - for ( j = start - subtracted; j < start; j++ ) { |
224 | | - if ( j in context.offsets ) { |
225 | | - o = context.offsets[j]; |
226 | | - o.node = oldStartNode; |
227 | | - o.length = subtracted; |
228 | | - } |
229 | | - } |
230 | | - // Update offset objects referring to newStartNode |
231 | | - for ( j = start; j < start - subtracted + oldLength; j++ ) { |
232 | | - if ( j in context.offsets ) { |
233 | | - o = context.offsets[j]; |
234 | | - o.node = newStartNode; |
235 | | - o.offset -= subtracted; |
236 | | - o.length -= subtracted; |
237 | | - o.lastTextNode = oldStartNode; |
238 | | - } |
239 | | - } |
| 209 | + context.fn.purgeOffsets(); |
240 | 210 | } |
241 | 211 | |
242 | 212 | var end = markers[i].end; |
— | — | @@ -249,32 +219,10 @@ |
250 | 220 | var endNode = e.node; |
251 | 221 | if ( e.offset + 1 < e.length - 1 && endNode.nodeName == '#text' ) { |
252 | 222 | // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode |
253 | | - var newEndNode = endNode; |
254 | | - var oldEndNode = endNode.splitText( e.offset + 1 ); |
| 223 | + var endNode = endNode.splitText( e.offset + 1 ); |
255 | 224 | |
256 | 225 | // Update offset objects |
257 | | - var subtracted = e.offset + 1; |
258 | | - var oldLength = e.length; |
259 | | - |
260 | | - |
261 | | - var j, o; |
262 | | - // Update offset objects referring to oldEndNode |
263 | | - for ( j = end - subtracted; j < end; j++ ) { |
264 | | - if ( j in context.offsets ) { |
265 | | - o = context.offsets[j]; |
266 | | - o.node = oldEndNode; |
267 | | - o.length = subtracted; |
268 | | - } |
269 | | - } |
270 | | - for ( j = end; j < end - subtracted + oldLength; j++ ) { |
271 | | - if ( j in context.offsets ) { |
272 | | - o = context.offsets[j]; |
273 | | - o.node = newEndNode; |
274 | | - o.offset -= subtracted; |
275 | | - o.length -= subtracted; |
276 | | - o.lastTextNode = oldEndNode; |
277 | | - } |
278 | | - } |
| 226 | + context.fn.purgeOffsets(); |
279 | 227 | } |
280 | 228 | |
281 | 229 | // Don't wrap trailing BRs, doing that causes weird issues |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -8736,40 +8736,10 @@ |
8737 | 8737 | // Split off the prefix |
8738 | 8738 | // This leaves the prefix in the current node and puts |
8739 | 8739 | // the rest in a new node which is our start node |
8740 | | - var newStartNode = startNode.splitText( s.offset < s.node.nodeValue.length ? |
| 8740 | + startNode = startNode.splitText( s.offset < s.node.nodeValue.length ? |
8741 | 8741 | s.offset : s.node.nodeValue.length - 1 |
8742 | 8742 | ); |
8743 | | - var oldStartNode = startNode; |
8744 | | - startNode = newStartNode; |
8745 | | - |
8746 | | - // Update offset objects. We don't need purgeOffsets(), simply |
8747 | | - // manipulating the existing offset objects will suffice |
8748 | | - // FIXME: This manipulates context.offsets directly, which is ugly, |
8749 | | - // but the performance improvement vs. purgeOffsets() is worth it |
8750 | | - // This code doesn't set lastTextNode to newStartNode for offset objects |
8751 | | - // with lastTextNode == oldStartNode, but that doesn't really matter |
8752 | | - var subtracted = s.offset; |
8753 | | - var oldLength = s.length; |
8754 | | - |
8755 | | - var j, o; |
8756 | | - // Update offset objects referring to oldStartNode |
8757 | | - for ( j = start - subtracted; j < start; j++ ) { |
8758 | | - if ( j in context.offsets ) { |
8759 | | - o = context.offsets[j]; |
8760 | | - o.node = oldStartNode; |
8761 | | - o.length = subtracted; |
8762 | | - } |
8763 | | - } |
8764 | | - // Update offset objects referring to newStartNode |
8765 | | - for ( j = start; j < start - subtracted + oldLength; j++ ) { |
8766 | | - if ( j in context.offsets ) { |
8767 | | - o = context.offsets[j]; |
8768 | | - o.node = newStartNode; |
8769 | | - o.offset -= subtracted; |
8770 | | - o.length -= subtracted; |
8771 | | - o.lastTextNode = oldStartNode; |
8772 | | - } |
8773 | | - } |
| 8743 | + context.fn.purgeOffsets(); |
8774 | 8744 | } |
8775 | 8745 | |
8776 | 8746 | var end = markers[i].end; |
— | — | @@ -8783,32 +8753,10 @@ |
8784 | 8754 | var endNode = e.node; |
8785 | 8755 | if ( e.offset + 1 < e.length - 1 && endNode.nodeName == '#text' ) { |
8786 | 8756 | // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode |
8787 | | - var newEndNode = endNode; |
8788 | | - var oldEndNode = endNode.splitText( e.offset + 1 ); |
| 8757 | + var endNode = endNode.splitText( e.offset + 1 ); |
8789 | 8758 | |
8790 | 8759 | // Update offset objects |
8791 | | - var subtracted = e.offset + 1; |
8792 | | - var oldLength = e.length; |
8793 | | - |
8794 | | - |
8795 | | - var j, o; |
8796 | | - // Update offset objects referring to oldEndNode |
8797 | | - for ( j = end - subtracted; j < end; j++ ) { |
8798 | | - if ( j in context.offsets ) { |
8799 | | - o = context.offsets[j]; |
8800 | | - o.node = oldEndNode; |
8801 | | - o.length = subtracted; |
8802 | | - } |
8803 | | - } |
8804 | | - for ( j = end; j < end - subtracted + oldLength; j++ ) { |
8805 | | - if ( j in context.offsets ) { |
8806 | | - o = context.offsets[j]; |
8807 | | - o.node = newEndNode; |
8808 | | - o.offset -= subtracted; |
8809 | | - o.length -= subtracted; |
8810 | | - o.lastTextNode = oldEndNode; |
8811 | | - } |
8812 | | - } |
| 8760 | + context.fn.purgeOffsets(); |
8813 | 8761 | } |
8814 | 8762 | |
8815 | 8763 | // Don't wrap trailing BRs, doing that causes weird issues |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -593,11 +593,9 @@ |
594 | 594 | context.modules.highlight.markersStr=markersStr;var oldStarts=[];if(!context.modules.highlight.markersOldStarts){context.modules.highlight.markersOldStarts=[];} |
595 | 595 | 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;} |
596 | 596 | var startNode=s.node;while(startNode.nodeName=='BR'||s.offset==startNode.nodeValue.length){start++;s=context.fn.getOffset(start);startNode=s.node;} |
597 | | -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;}} |
598 | | -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;}}} |
| 597 | +if(s.offset>0&&s.node.nodeName=='#text'){startNode=startNode.splitText(s.offset<s.node.nodeValue.length?s.offset:s.node.nodeValue.length-1);context.fn.purgeOffsets();} |
599 | 598 | var end=markers[i].end;var e=context.fn.getOffset(end-1);if(!e){continue;} |
600 | | -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;}} |
601 | | -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;}}} |
| 599 | +var endNode=e.node;if(e.offset+1<e.length-1&&endNode.nodeName=='#text'){var endNode=endNode.splitText(e.offset+1);context.fn.purgeOffsets();} |
602 | 600 | if(endNode.nodeName=='BR'){endNode=e.lastTextNode;} |
603 | 601 | 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);} |
604 | 602 | 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'));} |