r67995 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67994‎ | r67995 | r67996 >
Date:14:09, 14 June 2010
Author:catrope
Status:ok (Comments)
Tags:
Comment:
UsabilityInitiative: (bug 23927) Don't select special characters after inserting them
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.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)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php
@@ -20,10 +20,10 @@
2121 array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 17 ),
2222 ),
2323 'combined' => array(
24 - array( 'src' => 'Vector.combined.js', 'version' => 51 ),
 24+ array( 'src' => 'Vector.combined.js', 'version' => 52 ),
2525 ),
2626 'minified' => array(
27 - array( 'src' => 'Vector.combined.min.js', 'version' => 51 ),
 27+ array( 'src' => 'Vector.combined.min.js', 'version' => 52 ),
2828 ),
2929 );
3030 static $modules = array(
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js
@@ -5,9 +5,9 @@
66 if ( !wgVectorEnabledModules.collapsiblenav ) {
77 return true;
88 }
9 -
 9+
1010 /* Browser Support */
11 -
 11+
1212 var map = {
1313 // Left-to-right languages
1414 'ltr': {
@@ -34,9 +34,9 @@
3535 if ( !mw.usability.testBrowser( map ) ) {
3636 return true;
3737 }
38 -
 38+
3939 /* Bucket Testing */
40 -
 40+
4141 // Fallback to old version
4242 var version = 1;
4343 // Allow new version override
@@ -55,9 +55,9 @@
5656 }
5757 }
5858 }
59 -
 59+
6060 /* Special Language Portal Handling */
61 -
 61+
6262 // Language portal splitting feature (if it's turned on)
6363 if ( version == 2 ) {
6464 // How many links to show in the primary languages portal
@@ -151,9 +151,9 @@
152152 // Always show the primary interwiki language portal
153153 $j( '#p-lang' ).addClass( 'persistent' );
154154 }
155 -
 155+
156156 /* General Portal Modification */
157 -
 157+
158158 // Always show the first portal
159159 $j( '#mw-panel > div.portal:first' ).addClass( 'first persistent' );
160160 // Apply a class to the entire panel to activate styles
@@ -191,9 +191,9 @@
192192 .find( 'div.body' )
193193 .slideToggle( 'fast' );
194194 }
195 -
 195+
196196 /* Tab Indexing */
197 -
 197+
198198 var $headings = $j( '#mw-panel > div.portal:not(.persistent) > h5' );
199199 // Get the highest tab index
200200 var tabIndex = mw.usability.getMaxTabIndex() + 1;
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -73,10 +73,10 @@
7474 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
7575 array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 17 ),
7676 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 22 ),
77 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 35 ),
 77+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 36 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 193 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ),
80 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 67 ),
 80+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 68 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 26 ),
8282 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 98 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
@@ -88,10 +88,10 @@
8989 array( 'src' => 'js/thirdparty/contentCollector.js', 'version' => 2 ),
9090 ),
9191 'combined' => array(
92 - array( 'src' => 'js/plugins.combined.js', 'version' => 425 ),
 92+ array( 'src' => 'js/plugins.combined.js', 'version' => 426 ),
9393 ),
9494 'minified' => array(
95 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 426 ),
 95+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 427 ),
9696 ),
9797 ),
9898 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -80,7 +80,7 @@
8181 selText = selText.replace( /\r?\n/g, "\r\n" );
8282 options.post = options.post.replace( /\r?\n/g, "\r\n" );
8383 }
84 - if ( isSample ) {
 84+ if ( isSample && options.selectPeri ) {
8585 this.selectionStart = startPos + options.pre.length;
8686 this.selectionEnd = startPos + options.pre.length + selText.length;
8787 } else {
@@ -114,7 +114,7 @@
115115 }
116116 checkSelectedText();
117117 range.text = options.pre + selText + options.post;
118 - if ( isSample && range.moveStart ) {
 118+ if ( isSample && options.selectPeri && range.moveStart ) {
119119 range.moveStart( 'character', - options.post.length - selText.length );
120120 range.moveEnd( 'character', - options.post.length );
121121 }
@@ -356,7 +356,8 @@
357357 'peri': '', // Text to insert between pre and post and select afterwards
358358 'post': '', // Text to insert after the cursor/selection
359359 'ownline': false, // Put the inserted text on a line of its own
360 - 'replace': false // If there is a selection, replace it with peri instead of leaving it alone
 360+ 'replace': false, // If there is a selection, replace it with peri instead of leaving it alone
 361+ 'selectPeri': true // Select the peri text if it was inserted (but not if there was a selection and replace==false)
361362 }, options );
362363 break;
363364 case 'getCaretPosition':
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -542,7 +542,8 @@
543543 'action' : {
544544 'type' : 'replace',
545545 'options' : {
546 - 'peri' : character
 546+ 'peri' : character,
 547+ 'selectPeri': false
547548 }
548549 }
549550 };
@@ -552,7 +553,8 @@
553554 'action' : {
554555 'type' : 'replace',
555556 'options' : {
556 - 'peri' : character[1]
 557+ 'peri' : character[1],
 558+ 'selectPeri': false
557559 }
558560 }
559561 };
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6600,7 +6600,7 @@
66016601 selText = selText.replace( /\r?\n/g, "\r\n" );
66026602 options.post = options.post.replace( /\r?\n/g, "\r\n" );
66036603 }
6604 - if ( isSample ) {
 6604+ if ( isSample && options.selectPeri ) {
66056605 this.selectionStart = startPos + options.pre.length;
66066606 this.selectionEnd = startPos + options.pre.length + selText.length;
66076607 } else {
@@ -6634,7 +6634,7 @@
66356635 }
66366636 checkSelectedText();
66376637 range.text = options.pre + selText + options.post;
6638 - if ( isSample && range.moveStart ) {
 6638+ if ( isSample && options.selectPeri && range.moveStart ) {
66396639 range.moveStart( 'character', - options.post.length - selText.length );
66406640 range.moveEnd( 'character', - options.post.length );
66416641 }
@@ -6876,7 +6876,8 @@
68776877 'peri': '', // Text to insert between pre and post and select afterwards
68786878 'post': '', // Text to insert after the cursor/selection
68796879 'ownline': false, // Put the inserted text on a line of its own
6880 - 'replace': false // If there is a selection, replace it with peri instead of leaving it alone
 6880+ 'replace': false, // If there is a selection, replace it with peri instead of leaving it alone
 6881+ 'selectPeri': true // Select the peri text if it was inserted (but not if there was a selection and replace==false)
68816882 }, options );
68826883 break;
68836884 case 'getCaretPosition':
@@ -11719,7 +11720,8 @@
1172011721 'action' : {
1172111722 'type' : 'replace',
1172211723 'options' : {
11723 - 'peri' : character
 11724+ 'peri' : character,
 11725+ 'selectPeri': false
1172411726 }
1172511727 }
1172611728 };
@@ -11729,7 +11731,8 @@
1173011732 'action' : {
1173111733 'type' : 'replace',
1173211734 'options' : {
11733 - 'peri' : character[1]
 11735+ 'peri' : character[1],
 11736+ 'selectPeri': false
1173411737 }
1173511738 }
1173611739 };
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -434,11 +434,11 @@
435435 if(this.value.charAt(endPos)!="\n"){options.post+="\n";}}
436436 this.value=this.value.substring(0,startPos)+options.pre+selText+options.post+
437437 this.value.substring(endPos,this.value.length);this.scrollTop=scrollTop;if(window.opera){options.pre=options.pre.replace(/\r?\n/g,"\r\n");selText=selText.replace(/\r?\n/g,"\r\n");options.post=options.post.replace(/\r?\n/g,"\r\n");}
438 -if(isSample){this.selectionStart=startPos+options.pre.length;this.selectionEnd=startPos+options.pre.length+selText.length;}else{this.selectionStart=startPos+options.pre.length+selText.length+
 438+if(isSample&&options.selectPeri){this.selectionStart=startPos+options.pre.length;this.selectionEnd=startPos+options.pre.length+selText.length;}else{this.selectionStart=startPos+options.pre.length+selText.length+
439439 options.post.length;this.selectionEnd=this.selectionStart;}}else if(document.selection&&document.selection.createRange){$(this).focus();if(context){context.fn.restoreStuffForIE();}
440440 var selText=$(this).textSelection('getSelection');var scrollTop=this.scrollTop;var range=document.selection.createRange();if(options.ownline&&range.moveStart){var range2=document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){options.pre="\n"+options.pre;}
441441 var range3=document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){options.post+="\n";}}
442 -checkSelectedText();range.text=options.pre+selText+options.post;if(isSample&&range.moveStart){range.moveStart('character',-options.post.length-selText.length);range.moveEnd('character',-options.post.length);}
 442+checkSelectedText();range.text=options.pre+selText+options.post;if(isSample&&options.selectPeri&&range.moveStart){range.moveStart('character',-options.post.length-selText.length);range.moveEnd('character',-options.post.length);}
443443 range.select();this.scrollTop=scrollTop;}
444444 $(this).trigger('encapsulateSelection',[options.pre,options.peri,options.post,options.ownline,options.replace]);});},getCaretPosition:function(options){function getCaret(e){var caretPos=0,endPos=0;if($.browser.msie){var preFinished=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(!preFinished){if(preRange.compareEndPoints("StartToEnd",preRange)==0){preFinished=true;}else{preRange.moveEnd("character",-1)
445445 if(preRange.text==preText){rawPreText+="\r\n";}else{preFinished=true;}}}
@@ -457,7 +457,7 @@
458458 $(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.body.createTextRange();var savedRange=document.selection.createRange();var pos=$(this).textSelection('getCaretPosition');var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop)
459459 this.scrollTop+=range.offsetTop;else if(options.force){range.move('character',-1);range.select();}
460460 savedRange.select();}
461 -$(this).trigger('scrollToPosition');});}};switch(command){case'encapsulateSelection':options=$.extend({'pre':'','peri':'','post':'','ownline':false,'replace':false},options);break;case'getCaretPosition':options=$.extend({'startAndEnd':false},options);break;case'setSelection':options=$.extend({'start':undefined,'end':undefined,'startContainer':undefined,'endContainer':undefined},options);if(options.end===undefined)
 461+$(this).trigger('scrollToPosition');});}};switch(command){case'encapsulateSelection':options=$.extend({'pre':'','peri':'','post':'','ownline':false,'replace':false,'selectPeri':true},options);break;case'getCaretPosition':options=$.extend({'startAndEnd':false},options);break;case'setSelection':options=$.extend({'start':undefined,'end':undefined,'startContainer':undefined,'endContainer':undefined},options);if(options.end===undefined)
462462 options.end=options.start;if(options.endContainer==undefined)
463463 options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;}
464464 var context=$(this).data('wikiEditor-context');var hasIframe=context!==undefined&&context.$iframe!==undefined;var needSave=false;if(hasIframe&&context.savedSelection!==null){context.fn.restoreSelection();needSave=true;}
@@ -797,7 +797,7 @@
798798 return $page;},buildHeading:function(context,headings){var html='<tr>';for(heading in headings){html+='<th>'+$.wikiEditor.autoMsg(headings[heading],['html','text'])+'</th>';}
799799 return html;},buildRow:function(context,row){var html='<tr>';for(cell in row){html+='<td class="cell cell-'+cell+'" valign="top"><span>'+
800800 $.wikiEditor.autoMsg(row[cell],['html','text'])+'</span></td>';}
801 -html+='</tr>';return html;},buildCharacter:function(character,actions){if(typeof character=='string'){character={'label':character,'action':{'type':'replace','options':{'peri':character}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'replace','options':{'peri':character[1]}}};}
 801+html+='</tr>';return html;},buildCharacter:function(character,actions){if(typeof character=='string'){character={'label':character,'action':{'type':'replace','options':{'peri':character,'selectPeri':false}}};}else if(0 in character&&1 in character){character={'label':character[0],'action':{'type':'replace','options':{'peri':character[1],'selectPeri':false}}};}
802802 if('action'in character&&'label'in character){actions[character.label]=character.action;return'<span rel="'+character.label+'">'+character.label+'</span>';}},buildTab:function(context,id,section){var selected=$.cookie('wikiEditor-'+context.instance+'-toolbar-section');if(selected!=null){$.cookie('wikiEditor-'+context.instance+'-toolbar-section',selected,{expires:30,path:'/'});}
803803 return $('<span />').attr({'class':'tab tab-'+id,'rel':id}).append($('<a />').addClass(selected==id?'current':null).attr('href','#').text($.wikiEditor.autoMsg(section,'label')).data('context',context).mouseup(function(e){$(this).blur();}).mousedown(function(e){e.preventDefault();return false;}).click(function(e){var $sections=$(this).data('context').$ui.find('.sections');var $section=$(this).data('context').$ui.find('.section-'+$(this).parent().attr('rel'));var show=$section.css('display')=='none';$previousSections=$section.parent().find('.section-visible');$previousSections.css('position','absolute');$previousSections.removeClass('section-visible');$previousSections.fadeOut('fast',function(){$(this).css('position','relative');});$(this).parent().parent().find('a').removeClass('current');$sections.css('overflow','hidden');function animate($this){$sections.css('display','block').animate({'height':$section.outerHeight()},$section.outerHeight()*2,function(){$(this).css('overflow','visible').css('height','auto');context.fn.trigger('resize');});}
804804 if(show){$section.addClass('section-visible');$section.fadeIn('fast');if($section.hasClass('loading')){$this=$(this);$this.addClass('current loading');setTimeout(function(){$section.trigger('loadSection');animate($(this));$this.removeClass('loading');},1000);}else{animate($(this));$(this).addClass('current');}}else{$sections.css('height',$section.outerHeight()).animate({'height':'hide'},$section.outerHeight()*2,function(){$(this).css({'overflow':'visible','height':0});context.fn.trigger('resize');});}

Follow-up revisions

RevisionCommit summaryAuthorDate
r680271.16wmf4: Merge Vector and UsabilityInitiative fixes from trunk: r67836, r678...catrope20:25, 14 June 2010

Comments

#Comment by Trevor Parscal (WMF) (talk | contribs)   18:16, 14 June 2010

OK, but FYI - the editor is still is selecting them for the iframe version.

#Comment by Catrope (talk | contribs)   18:17, 14 June 2010

Good point. That's hardly a priority at this point, though.

Status & tagging log