r54716 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54715‎ | r54716 | r54717 >
Date:13:25, 10 August 2009
Author:catrope
Status:deferred
Tags:
Comment:
Fix up r54704: always skip insertion when the textarea is hidden, not just in Firefox
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.textSelection.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -49,16 +49,16 @@
5050 array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ),
5151 array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 3 ),
5252 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ),
53 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 5 ),
 53+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 6 ),
5454 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ),
5555 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 6 ),
5656 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 4 ),
5757 ),
5858 'combined' => array(
59 - array( 'src' => 'js/plugins.combined.js', 'version' => 8 ),
 59+ array( 'src' => 'js/plugins.combined.js', 'version' => 9 ),
6060 ),
6161 'minified' => array(
62 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 8 ),
 62+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 9 ),
6363 ),
6464 ),
6565 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -30,7 +30,9 @@
3131 var e = this.jquery ? this[0] : this;
3232 var selText;
3333 var isSample = false;
34 - if ( document.selection && document.selection.createRange ) {
 34+ if ( e.style.display == 'none' ) {
 35+ // Do nothing
 36+ } else if ( document.selection && document.selection.createRange ) {
3537 // IE/Opera
3638 if ( document.documentElement && document.documentElement.scrollTop ) {
3739 var winScroll = document.documentElement.scrollTop;
@@ -55,7 +57,7 @@
5658 } else if ( document.body ) {
5759 document.body.scrollTop = winScroll;
5860 }
59 - } else if ( e.style.display != 'none' && ( e.selectionStart || e.selectionStart == '0' ) ) {
 61+ } else if ( e.selectionStart || e.selectionStart == '0' ) {
6062 // Mozilla
6163 var textScroll = e.scrollTop;
6264 $(this).focus();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -287,7 +287,9 @@
288288 var e = this.jquery ? this[0] : this;
289289 var selText;
290290 var isSample = false;
291 - if ( document.selection && document.selection.createRange ) {
 291+ if ( e.style.display == 'none' ) {
 292+ // Do nothing
 293+ } else if ( document.selection && document.selection.createRange ) {
292294 // IE/Opera
293295 if ( document.documentElement && document.documentElement.scrollTop ) {
294296 var winScroll = document.documentElement.scrollTop;
@@ -312,7 +314,7 @@
313315 } else if ( document.body ) {
314316 document.body.scrollTop = winScroll;
315317 }
316 - } else if ( e.style.display != 'none' && ( e.selectionStart || e.selectionStart == '0' ) ) {
 318+ } else if ( e.selectionStart || e.selectionStart == '0' ) {
317319 // Mozilla
318320 var textScroll = e.scrollTop;
319321 $(this).focus();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -19,10 +19,10 @@
2020 expires='; expires='+date.toUTCString();}
2121 var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
2222 return cookieValue;}};(function($){$.fn.extend({encapsulateSelection:function(pre,peri,post){function checkSelectedText(){if(!selText){selText=peri;isSample=true;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' '}}
23 -var e=this.jquery?this[0]:this;var selText;var isSample=false;if(document.selection&&document.selection.createRange){if(document.documentElement&&document.documentElement.scrollTop){var winScroll=document.documentElement.scrollTop;}else if(document.body){var winScroll=document.body.scrollTop;}
 23+var e=this.jquery?this[0]:this;var selText;var isSample=false;if(e.style.display=='none'){}else if(document.selection&&document.selection.createRange){if(document.documentElement&&document.documentElement.scrollTop){var winScroll=document.documentElement.scrollTop;}else if(document.body){var winScroll=document.body.scrollTop;}
2424 $(this).focus();var range=document.selection.createRange();selText=range.text;checkSelectedText();range.text=pre+selText+post;if(isSample&&range.moveStart){if(window.opera){post=post.replace(/\n/g,'');}
2525 range.moveStart('character',-post.length-selText.length);range.moveEnd('character',-post.length);}
26 -range.select();if(document.documentElement&&document.documentElement.scrollTop){document.documentElement.scrollTop=winScroll}else if(document.body){document.body.scrollTop=winScroll;}}else if(e.style.display!='none'&&(e.selectionStart||e.selectionStart=='0')){var textScroll=e.scrollTop;$(this).focus();var startPos=e.selectionStart;var endPos=e.selectionEnd;selText=e.value.substring(startPos,endPos);checkSelectedText();e.value=e.value.substring(0,startPos)+pre+selText+post+
 26+range.select();if(document.documentElement&&document.documentElement.scrollTop){document.documentElement.scrollTop=winScroll}else if(document.body){document.body.scrollTop=winScroll;}}else if(e.selectionStart||e.selectionStart=='0'){var textScroll=e.scrollTop;$(this).focus();var startPos=e.selectionStart;var endPos=e.selectionEnd;selText=e.value.substring(startPos,endPos);checkSelectedText();e.value=e.value.substring(0,startPos)+pre+selText+post+
2727 e.value.substring(endPos,e.value.length);if(isSample){e.selectionStart=startPos+pre.length;e.selectionEnd=startPos+pre.length+selText.length;}else{e.selectionStart=startPos+pre.length+selText.length+post.length;e.selectionEnd=e.selectionStart;}
2828 e.scrollTop=textScroll;}
2929 $(this).trigger('encapsulateSelection',[pre,peri,post]);},getCaretPosition:function(){function getCaret(e){var caretPos=0;if($.browser.msie){var postFinished=false;var periFinished=false;var postFinished=false;var preText,rawPreText,periText;var rawPeriText,postText,rawPostText;var periRange=document.selection.createRange().duplicate();var preRange=document.body.createTextRange();preRange.moveToElementText(e);preRange.setEndPoint("EndToStart",periRange);var postRange=document.body.createTextRange();postRange.moveToElementText(e);postRange.setEndPoint("StartToEnd",periRange);preText=rawPreText=preRange.text;periText=rawPeriText=periRange.text;postText=rawPostText=postRange.text;do{if(!postFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){postFinished=true;}else{preRange.moveEnd("character",-1)

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54704EditToolbar: Prevent JS error occurring when trying to access selectionStart ...catrope09:49, 10 August 2009

Status & tagging log