r61278 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61277‎ | r61278 | r61279 >
Date:00:00, 20 January 2010
Author:tparscal
Status:ok
Tags:
Comment:
Webkit needed the iframe to be focused before any selection ranges could be used.
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' => 54
 157+ 'version' => 55
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' => 157 ),
 195+ array( 'src' => 'js/plugins.combined.js', 'version' => 158 ),
196196 ),
197197 'minified' => array(
198 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 157 ),
 198+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 158 ),
199199 ),
200200 ),
201201 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -587,6 +587,8 @@
588588 var e;
589589 if ( context.$iframe[0].contentWindow.getSelection ) {
590590 // Firefox and Opera
 591+ // This needs to be here for webkit, or the selection is invalid
 592+ context.$iframe[0].contentWindow.focus();
591593 var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 );
592594 // Start at the selection's start and traverse the DOM backwards
593595 // This is done by traversing an element's children first, then the
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -7068,6 +7068,8 @@
70697069 var e;
70707070 if ( context.$iframe[0].contentWindow.getSelection ) {
70717071 // Firefox and Opera
 7072+ // This needs to be here for webkit, or the selection is invalid
 7073+ context.$iframe[0].contentWindow.focus();
70727074 var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 );
70737075 // Start at the selection's start and traverse the DOM backwards
70747076 // This is done by traversing an element's children first, then the
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -463,7 +463,7 @@
464464 var range=context.$iframe[0].contentWindow.document.createRange();range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.body.createTextRange){var range=context.$iframe[0].contentWindow.document.body.createTextRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=context.$iframe[0].contentWindow.document.body.createTextRange();range2.moveToElementText(ec);range2.collapse();range2.moveEnd('character',options.end);range.setEndPoint('EndToEnd',range2);range.select();}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parentHtml=$('html'),parentBody=$('body');var y=$element.offset().top;if(!$.browser.msie){y=parentHtml.scrollTop()>0?y+html.scrollTop()-parentHtml.scrollTop():y;y=parentBody.scrollTop()>0?y+body.scrollTop()-parentBody.scrollTop():y;}
465465 if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);body.scrollTop(y);}
466466 $element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';}
467 -var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);}
 467+var e;if(context.$iframe[0].contentWindow.getSelection){context.$iframe[0].contentWindow.focus();var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);}
468468 if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;}
469469 while(newE&&newE.lastChild){newE=newE.lastChild;}
470470 e=newE;}

Status & tagging log