r61577 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61576‎ | r61577 | r61578 >
Date:15:19, 27 January 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 22281) Ownline was broken in Firefox when the cursor was at the very beginning of the article. Also fixed another JS error
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,8 +72,8 @@
7373 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ),
7575 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 26 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 73 ),
77 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 24 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 74 ),
 77+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 25 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 45 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 11 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 74 ),
@@ -82,10 +82,10 @@
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 185 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 186 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 185 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 186 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -450,7 +450,8 @@
451451 }
452452 // TODO: Will this still work with syntax highlighting?
453453 // When the selection ends at the end of a line, it'll have endContainer == body
454 - if ( range.endContainer != body ) {
 454+ // and endOffset != 0
 455+ if ( range.endContainer != body || range.endOffset == 0 ) {
455456 post += "\n";
456457 }
457458 }
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -174,8 +174,9 @@
175175 startNode = startNode.splitText( s.offset );
176176 }
177177 // Don't wrap leading BRs, produces undesirable results
178 - while ( startNode.nodeName == 'BR' && start + 1 in offsets ) {
 178+ while ( startNode.nodeName == 'BR' ) {
179179 start++;
 180+ s = context.fn.getOffset( start );
180181 startNode = s.node;
181182 startDepth = s.depth;
182183 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6874,7 +6874,8 @@
68756875 }
68766876 // TODO: Will this still work with syntax highlighting?
68776877 // When the selection ends at the end of a line, it'll have endContainer == body
6878 - if ( range.endContainer != body ) {
 6878+ // and endOffset != 0
 6879+ if ( range.endContainer != body || range.endOffset == 0 ) {
68796880 post += "\n";
68806881 }
68816882 }
@@ -7736,8 +7737,9 @@
77377738 startNode = startNode.splitText( s.offset );
77387739 }
77397740 // Don't wrap leading BRs, produces undesirable results
7740 - while ( startNode.nodeName == 'BR' && start + 1 in offsets ) {
 7741+ while ( startNode.nodeName == 'BR' ) {
77417742 start++;
 7743+ s = context.fn.getOffset( start );
77427744 startNode = s.node;
77437745 startDepth = s.depth;
77447746 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -455,7 +455,7 @@
456456 return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selTextArr;var selectAfter=false;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}
457457 if(options.splitlines){selTextArr=selText.split(/\n/);}
458458 if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){var body=context.$content.get(0);if(range.startOffset!=0&&range.startContainer!=body){pre="\n"+options.pre;}
459 -if(range.endContainer!=body){post+="\n";}}
 459+if(range.endContainer!=body||range.endOffset==0){post+="\n";}}
460460 var insertText="";if(options.splitlines){for(var i=0;i<selTextArr.length;i++){insertText=insertText+pre+selTextArr[i]+post;if(i!=selTextArr.length-1)insertText+="\n";}}else{insertText=pre+selText+post;}
461461 var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(context.$iframe[0].contentWindow.document.createTextNode(insertLines[i]));if(i>0){lastNode=range.insertNode(context.$iframe[0].contentWindow.document.createElement('br'));}}
462462 if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){context.$iframe[0].contentWindow.focus();var range=context.$iframe[0].contentWindow.document.selection.createRange();if(options.ownline&&range.moveStart){var range2=context.$iframe[0].contentWindow.document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){pre="\n"+pre;}
@@ -510,7 +510,7 @@
511511 tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}}
512512 tokenArray.sort(function(a,b){return a.offset-b.offset||a.tokenStart-b.tokenStart;});context.fn.trigger('scan');},mark:function(context,division,tokens){var markers=context.modules.highlight.markers=[];context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});for(var i=0;i<markers.length;i++){var start=markers[i].start;var s=context.fn.getOffset(start);if(!s){continue;}
513513 var startNode=s.node;var startDepth=s.depth;if(s.offset>0){startNode=startNode.splitText(s.offset);}
514 -while(startNode.nodeName=='BR'&&start+1 in offsets){start++;startNode=s.node;startDepth=s.depth;}
 514+while(startNode.nodeName=='BR'){start++;s=context.fn.getOffset(start);startNode=s.node;startDepth=s.depth;}
515515 var end=markers[i].end;var e=context.fn.getOffset(end);if(!e){continue;}
516516 var endNode=e.node;var endDepth=e.depth;if(e.offset<e.length-1){endNode.splitText(e.offset+1);}
517517 if(endNode.nodeName=='BR'){endNode=e.lastTextNode;endDepth=e.lastTextNodeDepth;}

Follow-up revisions

RevisionCommit summaryAuthorDate
r61637UsabilityInitiative: Rewrite the Firefox branch of ownline handling to be mor...catrope16:00, 28 January 2010

Status & tagging log