r62263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62262‎ | r62263 | r62264 >
Date:21:16, 10 February 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Fix offset calculation to account for the fact that <br>s are now always wrapped in <p>s
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.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,7 +72,7 @@
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' => 27 ),
76 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 118 ),
 76+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 119 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 48 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 12 ),
@@ -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' => 238 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 239 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 238 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 239 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -1162,13 +1162,13 @@
11631163 var t = context.fn.traverser( context.$content );
11641164 var pos = 0, lastTextNode = null, lastTextNodeDepth = null;
11651165 while ( t ) {
1166 - if ( t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
 1166+ if ( t.node.nodeName != '#text' && t.node.nodeName != 'BR' ) {
11671167 t = t.next();
11681168 continue;
11691169 }
11701170 var nextPos = t.node.nodeName == '#text' ? pos + t.node.nodeValue.length : pos + 1;
11711171 var nextT = t.next();
1172 - var leavingP = t.node.nodeName != 'P' && t.inP && nextT && ( !nextT.inP || nextT.inP != t.inP );
 1172+ var leavingP = t.node.nodeName == '#text' && t.inP && nextT && ( !nextT.inP || nextT.inP != t.inP );
11731173 context.offsets[pos] = {
11741174 'node': t.node,
11751175 'offset': 0,
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -7595,13 +7595,13 @@
75967596 var t = context.fn.traverser( context.$content );
75977597 var pos = 0, lastTextNode = null, lastTextNodeDepth = null;
75987598 while ( t ) {
7599 - if ( t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
 7599+ if ( t.node.nodeName != '#text' && t.node.nodeName != 'BR' ) {
76007600 t = t.next();
76017601 continue;
76027602 }
76037603 var nextPos = t.node.nodeName == '#text' ? pos + t.node.nodeValue.length : pos + 1;
76047604 var nextT = t.next();
7605 - var leavingP = t.node.nodeName != 'P' && t.inP && nextT && ( !nextT.inP || nextT.inP != t.inP );
 7605+ var leavingP = t.node.nodeName == '#text' && t.inP && nextT && ( !nextT.inP || nextT.inP != t.inP );
76067606 context.offsets[pos] = {
76077607 'node': t.node,
76087608 'offset': 0,
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -529,8 +529,8 @@
530530 var lowerBound=-1;for(var o in context.offsets){if(o>offset){break;}
531531 lowerBound=o;}
532532 if(!(lowerBound in context.offsets)){return null;}
533 -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.node.nodeName!='P'){t=t.next();continue;}
534 -var nextPos=t.node.nodeName=='#text'?pos+t.node.nodeValue.length:pos+1;var nextT=t.next();var leavingP=t.node.nodeName!='P'&&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};}
 533+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;}
 534+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};}
535535 pos=nextPos+(leavingP?1:0);if(t.node.nodeName=='#text'){lastTextNode=t.node;lastTextNodeDepth=t.depth;}
536536 t=nextT;}},'saveSelection':function(){if(!$.browser.msie){return;}
537537 context.$iframe[0].contentWindow.focus();context.savedSelection=context.$iframe[0].contentWindow.document.selection.createRange();},'restoreSelection':function(){if(!$.browser.msie||context.savedSelection===null){return;}

Follow-up revisions

RevisionCommit summaryAuthorDate
r62264wmf-deployment: Merge r62263 (UsabilityInitiative fix) from trunkcatrope21:19, 10 February 2010

Status & tagging log