r97466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97465‎ | r97466 | r97467 >
Date:11:07, 19 September 2011
Author:santhosh
Status:ok (Comments)
Tags:
Comment:
Remove webkit specific slow code with generic approach with the help of jquery.textselection encapsulateSelection method with optional selectionStart and selectionEnd.
This patch was not applied Bug 30130 since a curser positioning issue was found, but later found that the issue is there even without extension and leaving it open.
Modified paths:
  • /trunk/extensions/Narayam/js/ext.narayam.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Narayam/js/ext.narayam.core.js
@@ -242,35 +242,14 @@
243243 input = input.substring( divergingPos );
244244 replacement = replacement.substring( divergingPos );
245245
246 - // TODO: use better browser detection as $.browser may be moved out
247 - // from jQuery core
248 - if ( $.browser.webkit ) {
249 - // Webkit browser have a bug:
250 - // https://bugs.webkit.org/show_bug.cgi?id=66630
251 - // TODO: remove when webkit bug is handled
252 - // in jQuery.textSelection.js
253 -
254 - replaceString($this, startPos - input.length + 1, endPos, replacement);
255 - // Calculate new position for caret to be set
256 - var newCaretPosition = startPos - input.length + 1 + replacement.length;
257 - // Update caret postion
258 - $this.textSelection( 'setSelection', {
259 - 'start': newCaretPosition,
260 - 'end': newCaretPosition
 246+ $this.textSelection( 'encapsulateSelection', {
 247+ 'peri': replacement,
 248+ 'replace': true,
 249+ 'selectPeri': false,
 250+ 'selectionStart': startPos - input.length + 1,
 251+ 'selectionEnd': endPos
 252+
261253 } );
262 - }
263 - else {
264 - // Select and replace the text
265 - $this.textSelection( 'setSelection', {
266 - 'start': startPos - input.length + 1,
267 - 'end': endPos
268 - } );
269 - $this.textSelection( 'encapsulateSelection', {
270 - 'peri': replacement,
271 - 'replace': true,
272 - 'selectPeri': false
273 - } );
274 - }
275254
276255 e.stopPropagation();
277256 return false;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96415Applying workaround locally within the extension Narayam for webkit browsers ...junaidpv11:39, 7 September 2011
r96579(bug 30130) Add selectionStart and selectionEnd parameters to encapsulateSele...catrope16:05, 8 September 2011

Comments

#Comment by Junaidpv (talk | contribs)   17:44, 19 September 2011

Clearly it does not work for me! I checked with r97465 and it breaks when I applied this revision.

#Comment by Junaidpv (talk | contribs)   07:27, 20 September 2011

Sorry, it is working.

I did not update Mediawiki core, which includes r96579 and that is required for this to work.

#Comment by Catrope (talk | contribs)   08:43, 20 September 2011

Fixed now.

Status & tagging log