r61106 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61105‎ | r61106 | r61107 >
Date:22:39, 15 January 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Fix setSelection() for IE, works now
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
@@ -84,7 +84,7 @@
8585 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
8686 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ),
8787 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 22 ),
88 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 45 ),
 88+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 46 ),
8989 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 12 ),
9090 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 41 ),
9191 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ),
@@ -94,10 +94,10 @@
9595 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ),
9696 ),
9797 'combined' => array(
98 - array( 'src' => 'js/plugins.combined.js', 'version' => 143 ),
 98+ array( 'src' => 'js/plugins.combined.js', 'version' => 144 ),
9999 ),
100100 'minified' => array(
101 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 143 ),
 101+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 144 ),
102102 ),
103103 ),
104104 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -517,15 +517,16 @@
518518 sel.removeAllRanges();
519519 sel.addRange( range );
520520 context.$iframe[0].contentWindow.focus();
521 - } else if ( context.$iframe[0].contentWindow.document.selection ) {
522 - // FIXME: IE is still broken for when sc or ec is the <body>, needs more tweaking
523 - var range = document.selection.createRange();
 521+ } else if ( context.$iframe[0].contentWindow.document.body.createTextRange ) {
 522+ // IE
 523+ var range = context.$iframe[0].contentWindow.document.body.createTextRange();
524524 range.moveToElementText( sc );
525525 range.moveStart( 'character', options.start );
526 - var range2 = document.selection.createRange();
 526+ var range2 = context.$iframe[0].contentWindow.document.body.createTextRange();
527527 range2.moveToElementText( ec );
 528+ range2.collapse();
528529 range2.moveEnd( 'character', options.end );
529 - range.setEndPoint( EndToEnd, range2 );
 530+ range.setEndPoint( 'EndToEnd', range2 );
530531 range.select();
531532 }
532533 },
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6884,15 +6884,16 @@
68856885 sel.removeAllRanges();
68866886 sel.addRange( range );
68876887 context.$iframe[0].contentWindow.focus();
6888 - } else if ( context.$iframe[0].contentWindow.document.selection ) {
6889 - // FIXME: IE is still broken for when sc or ec is the <body>, needs more tweaking
6890 - var range = document.selection.createRange();
 6888+ } else if ( context.$iframe[0].contentWindow.document.body.createTextRange ) {
 6889+ // IE
 6890+ var range = context.$iframe[0].contentWindow.document.body.createTextRange();
68916891 range.moveToElementText( sc );
68926892 range.moveStart( 'character', options.start );
6893 - var range2 = document.selection.createRange();
 6893+ var range2 = context.$iframe[0].contentWindow.document.body.createTextRange();
68946894 range2.moveToElementText( ec );
 6895+ range2.collapse();
68956896 range2.moveEnd( 'character', options.end );
6896 - range.setEndPoint( EndToEnd, range2 );
 6897+ range.setEndPoint( 'EndToEnd', range2 );
68976898 range.select();
68986899 }
68996900 },
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -453,7 +453,7 @@
454454 if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){}
455455 context.$content.trigger('encapsulateSelection',[pre,options.peri,post,options.ownline,options.replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc.jquery?sc[0]:sc;ec=ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;}
456456 while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;}
457 -var range=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.selection){var range=document.selection.createRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=document.selection.createRange();range2.moveToElementText(ec);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'),parent=$('html');var y=$element.offset().top-context.$content.offset().top;y=parent.scrollTop()>0?y+html.scrollTop()-parent.scrollTop():y;if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);}
 457+var range=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'),parent=$('html');var y=$element.offset().top-context.$content.offset().top;y=parent.scrollTop()>0?y+html.scrollTop()-parent.scrollTop():y;if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);}
458458 $element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';}
459459 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 $([]);}
460460 if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;}

Status & tagging log