r58425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58424‎ | r58425 | r58426 >
Date:11:36, 2 November 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditToolbar: (bug 21220) Selected value not copied to page title field in IE/Opera
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)
  • /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
@@ -68,17 +68,17 @@
6969 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
7070 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
7171 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
72 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 16 ),
 72+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 17 ),
7373 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ),
7474 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 18 ),
7575 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 8 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 25 ),
7777 ),
7878 'combined' => array(
79 - array( 'src' => 'js/plugins.combined.js', 'version' => 57 ),
 79+ array( 'src' => 'js/plugins.combined.js', 'version' => 58 ),
8080 ),
8181 'minified' => array(
82 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 57 ),
 82+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 58 ),
8383 ),
8484 ),
8585 );
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -1138,10 +1138,9 @@
11391139 '^' + RegExp.escape( wgServer + wgArticlePath )
11401140 .replace( /\\\$1/g, '(.*)' ) + '$'
11411141 ) );
1142 -
1143 - $j( '#edittoolbar-link-int-target' ).focus();
11441142 // Pre-fill the text fields based on the current selection
11451143 var selection = $j(this).data( 'context' ).$textarea.getSelection();
 1144+ $j( '#edittoolbar-link-int-target' ).focus();
11461145 $j( '#edittoolbar-link-dialog' ).data( 'whitespace', [ '', '' ] );
11471146 if ( selection != '' ) {
11481147 var target, text, type;
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.min.js
@@ -58,7 +58,7 @@
5959 insertText=escTarget;else if(text=='')
6060 insertText='['+escTarget+']';else
6161 insertText='['+escTarget+' '+escText+']';}
62 -insertText=whitespace[0]+insertText+whitespace[1];$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:insertText}},$j(this));$j('#edittoolbar-link-int-target, #edittoolbar-link-int-text').val('');$j('#edittoolbar-link-type-int, #edittoolbar-link-type-ext').attr('checked','');$j(this).dialog('close');},'edittoolbar-tool-link-cancel':function(){$j(this).dialog('close');}},open:function(){$j(this).data('articlePathRegex',new RegExp('^'+RegExp.escape(wgServer+wgArticlePath).replace(/\\\$1/g,'(.*)')+'$'));$j('#edittoolbar-link-int-target').focus();var selection=$j(this).data('context').$textarea.getSelection();$j('#edittoolbar-link-dialog').data('whitespace',['','']);if(selection!=''){var target,text,type;var matches;if((matches=selection.match(/^(\s*)\[\[([^\]\|]+)(\|([^\]\|]*))?\]\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:matches[2]);type='int';$j('#edittoolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else if((matches=selection.match(/^(\s*)\[([^\] ]+)( ([^\]]+))?\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:'');type='ext';$j('#edittoolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else{target=text=selection;}
 62+insertText=whitespace[0]+insertText+whitespace[1];$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:insertText}},$j(this));$j('#edittoolbar-link-int-target, #edittoolbar-link-int-text').val('');$j('#edittoolbar-link-type-int, #edittoolbar-link-type-ext').attr('checked','');$j(this).dialog('close');},'edittoolbar-tool-link-cancel':function(){$j(this).dialog('close');}},open:function(){$j(this).data('articlePathRegex',new RegExp('^'+RegExp.escape(wgServer+wgArticlePath).replace(/\\\$1/g,'(.*)')+'$'));var selection=$j(this).data('context').$textarea.getSelection();$j('#edittoolbar-link-int-target').focus();$j('#edittoolbar-link-dialog').data('whitespace',['','']);if(selection!=''){var target,text,type;var matches;if((matches=selection.match(/^(\s*)\[\[([^\]\|]+)(\|([^\]\|]*))?\]\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:matches[2]);type='int';$j('#edittoolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else if((matches=selection.match(/^(\s*)\[([^\] ]+)( ([^\]]+))?\](\s*)$/))){target=matches[2];text=(matches[4]?matches[4]:'');type='ext';$j('#edittoolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else{target=text=selection;}
6363 if(typeof text!='undefined')
6464 $j('#edittoolbar-link-int-text').val(text).change();if(typeof target!='undefined')
6565 $j('#edittoolbar-link-int-target').val(target).change();if(typeof type!='undefined')
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -19,7 +19,7 @@
2020 /* Configuration */
2121
2222 // Bump the version number every time you change any of the .css/.js files
23 -$wgEditToolbarStyleVersion = 68;
 23+$wgEditToolbarStyleVersion = 69;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js
@@ -3,12 +3,17 @@
44 */
55 ( function( $ ) { $.fn.extend( {
66
 7+/**
 8+ * Get the currently selected text in this textarea. Will focus the textarea
 9+ * in some browsers (IE/Opera)
 10+ */
711 getSelection: function() {
812 var e = this.jquery ? this[0] : this;
913 var retval = '';
1014 if ( e.style.display == 'none' ) {
1115 // Do nothing
1216 } else if ( document.selection && document.selection.createRange ) {
 17+ e.focus();
1318 var range = document.selection.createRange();
1419 retval = range.text;
1520 } else if ( e.selectionStart || e.selectionStart == '0' ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -924,12 +924,17 @@
925925 */
926926 ( function( $ ) { $.fn.extend( {
927927
 928+/**
 929+ * Get the currently selected text in this textarea. Will focus the textarea
 930+ * in some browsers (IE/Opera)
 931+ */
928932 getSelection: function() {
929933 var e = this.jquery ? this[0] : this;
930934 var retval = '';
931935 if ( e.style.display == 'none' ) {
932936 // Do nothing
933937 } else if ( document.selection && document.selection.createRange ) {
 938+ e.focus();
934939 var range = document.selection.createRange();
935940 retval = range.text;
936941 } else if ( e.selectionStart || e.selectionStart == '0' ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -51,7 +51,7 @@
5252 context.data.$container.hide();if(typeof context.config.special.select=='function'){context.config.special.select.call($special,context.data.$textbox);}
5353 context.data.$textbox.focus();})).appendTo($('body'));$(this).attr('autocomplete','off').keydown(function(e){context.data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;context.data.keypressedCount=0;switch(context.data.keypressed){case 40:e.preventDefault();e.stopImmediatePropagation();break;case 38:case 27:case 13:if(context.data.$container.is(':visible')){e.preventDefault();e.stopImmediatePropagation();}}}).keypress(function(e){context.data.keypressedCount++;$.suggestions.keypress(e,context,context.data.keypressed);}).keyup(function(e){if(context.data.keypressedCount==0){$.suggestions.keypress(e,context,context.data.keypressed);}}).blur(function(){if(context.data.mouseDownOn.size()>0){return;}
5454 context.data.$container.hide();$.suggestions.cancel(context);});}
55 -$(this).data('suggestions-context',context);});return returnValue!==null?returnValue:$(this);};})(jQuery);(function($){$.fn.extend({getSelection:function(){var e=this.jquery?this[0]:this;var retval='';if(e.style.display=='none'){}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);}
 55+$(this).data('suggestions-context',context);});return returnValue!==null?returnValue:$(this);};})(jQuery);(function($){$.fn.extend({getSelection:function(){var e=this.jquery?this[0]:this;var retval='';if(e.style.display=='none'){}else if(document.selection&&document.selection.createRange){e.focus();var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);}
5656 return retval;},encapsulateSelection:function(pre,peri,post,ownline,replace){return this.each(function(){function checkSelectedText(){if(!selText){selText=peri;isSample=true;}else if(replace){selText=peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}}
5757 var selText=$(this).getSelection();var isSample=false;if(this.style.display=='none'){}else if(this.selectionStart||this.selectionStart=='0'){$(this).focus();var startPos=this.selectionStart;var endPos=this.selectionEnd;checkSelectedText();if(ownline){if(startPos!=0&&this.value.charAt(startPos-1)!="\n"){pre="\n"+pre;}
5858 if(this.value.charAt(endPos)!="\n"){post+="\n";}}

Follow-up revisions

RevisionCommit summaryAuthorDate
r59185acaifix: Some IE fixes. This should fix bug 21492, bug 21220, bug 21248 and b...catrope23:01, 17 November 2009
r59204wmf-deployment: Merging usability changes from trunk...catrope18:53, 18 November 2009

Status & tagging log