r84385 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84384‎ | r84385 | r84386 >
Date:14:50, 20 March 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r84384
Modified paths:
  • /branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js
@@ -3,6 +3,20 @@
44 */
55 ( function( $ ) {
66 $.fn.textSelection = function( command, options ) {
 7+
 8+/**
 9+ * Helper function to get an IE TextRange object for an element
 10+ */
 11+function rangeForElementIE( e ) {
 12+ if ( e.nodeName.toLowerCase() == 'input' ) {
 13+ return e.createTextRange();
 14+ } else {
 15+ var sel = document.body.createTextRange();
 16+ sel.moveToElementText( e );
 17+ return sel;
 18+ }
 19+}
 20+
721 var fn = {
822 /**
923 * Get the contents of the textarea
@@ -148,15 +162,11 @@
149163 // Create range containing text in the selection
150164 var periRange = document.selection.createRange().duplicate();
151165 // Create range containing text before the selection
152 - var preRange = document.body.createTextRange();
153 - // Select all the text
154 - preRange.moveToElementText(e);
 166+ var preRange = rangeForElementIE( e );
155167 // Move the end where we need it
156168 preRange.setEndPoint("EndToStart", periRange);
157169 // Create range containing text after the selection
158 - var postRange = document.body.createTextRange();
159 - // Select all the text
160 - postRange.moveToElementText(e);
 170+ var postRange = rangeForElementIE( e );
161171 // Move the start where we need it
162172 postRange.setEndPoint("StartToEnd", periRange);
163173 // Load the text values we need to compare
@@ -233,8 +243,7 @@
234244 this.selectionEnd = options.end;
235245 }
236246 } else if ( document.body.createTextRange ) {
237 - var selection = document.body.createTextRange();
238 - selection.moveToElementText( this );
 247+ var selection = rangeForElementIE( this );
239248 var length = this.value.length;
240249 // IE doesn't count \n when computing the offset, so we won't either
241250 var newLines = this.value.match( /\n/g );
Property changes on: branches/wmf/1.17wmf1/resources/jquery/jquery.textSelection.js
___________________________________________________________________
Added: svn:mergeinfo
242251 Merged /branches/sqlite/resources/jquery/jquery.textSelection.js:r58211-58321
243252 Merged /trunk/phase3/resources/jquery/jquery.textSelection.js:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,81833,83212,83590,84384
244253 Merged /branches/new-installer/phase3/resources/jquery/jquery.textSelection.js:r43664-66004
245254 Merged /branches/wmf-deployment/resources/jquery/jquery.textSelection.js:r60970
246255 Merged /branches/REL1_15/phase3/resources/jquery/jquery.textSelection.js:r51646
247256 Merged /branches/wmf/1.16wmf4/resources/jquery/jquery.textSelection.js:r67177,69199,76243,77266

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84384In $.textSelection, treat <input> elements differently from other elements (s...catrope14:48, 20 March 2011

Status & tagging log