r61345 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61344‎ | r61345 | r61346 >
Date:23:15, 21 January 2010
Author:tparscal
Status:deferred (Comments)
Tags:
Comment:
Switched use of a completely undefined variable "range" to selection - however the part of beforeSelection that is suposed to handle cases where the selection is between elements is not working.
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
@@ -153,7 +153,7 @@
154154 array(
155155 'src' => 'js/plugins/jquery.wikiEditor.js',
156156 'class' => 'j.wikiEditor',
157 - 'version' => 57
 157+ 'version' => 58
158158 ),
159159 array(
160160 'src' => 'js/plugins/jquery.wikiEditor.highlight.js',
@@ -191,10 +191,10 @@
192192 'version' => 1 ),
193193 ),
194194 'combined' => array(
195 - array( 'src' => 'js/plugins.combined.js', 'version' => 164 ),
 195+ array( 'src' => 'js/plugins.combined.js', 'version' => 165 ),
196196 ),
197197 'minified' => array(
198 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 164 ),
 198+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 165 ),
199199 ),
200200 ),
201201 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -608,7 +608,8 @@
609609 // (usually inside the <body> between two <br>s). Go to the rightmost
610610 // child of the node just before the selection
611611 var newE = e.firstChild;
612 - for ( var i = 0; i < range.startOffset - 1 && newE; i++ ) {
 612+ for ( var i = 0; i < selection.startOffset - 1 && newE; i++ ) {
 613+ console.log( i );
613614 newE = newE.nextSibling;
614615 }
615616 while ( newE && newE.lastChild ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -7089,7 +7089,8 @@
70907090 // (usually inside the <body> between two <br>s). Go to the rightmost
70917091 // child of the node just before the selection
70927092 var newE = e.firstChild;
7093 - for ( var i = 0; i < range.startOffset - 1 && newE; i++ ) {
 7093+ for ( var i = 0; i < selection.startOffset - 1 && newE; i++ ) {
 7094+ console.log( i );
70947095 newE = newE.nextSibling;
70957096 }
70967097 while ( newE && newE.lastChild ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -464,7 +464,7 @@
465465 var topBound=html.scrollTop()>body.scrollTop()?html.scrollTop():body.scrollTop(),bottomBound=topBound+context.$iframe.height();if(force||y<topBound||y>bottomBound){html.scrollTop(y);body.scrollTop(y);}
466466 $element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';}
467467 var e;if(context.$iframe[0].contentWindow.getSelection){var selection=context.$iframe[0].contentWindow.getSelection();if(selection.baseNode!==null){e=selection.getRangeAt(0).startContainer;}else{return $([]);}}else if(context.$iframe[0].contentWindow.document.selection){return $([]);}
468 -if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;}
 468+if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<selection.startOffset-1&&newE;i++){console.log(i);newE=newE.nextSibling;}
469469 while(newE&&newE.lastChild){newE=newE.lastChild;}
470470 e=newE;}
471471 while(e){if($(e).is(selector)&&!strict)

Comments

#Comment by Catrope (talk | contribs)   15:08, 22 January 2010

Embarassing oversight on my part, will fix this properly. Note that selection is defined in the Firefox/Webkit branch and will be undefined in IE because it takes a different branch; this is either a bug in the relevant JS engine or a confusing quirk of JS (lack of brace-level scope enforcement).

There's also a console.log() in there, I'll take care of that while I'm at it.

Status & tagging log