r67543 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67542‎ | r67543 | r67544 >
Date:15:50, 7 June 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 23578) When inserting links using link dialog, put selected spaces outside link
Modified paths:
  • /trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php
@@ -16,16 +16,16 @@
1717 array( 'src' => 'Modules/Preview/Preview.js', 'version' => 6 ),
1818 array( 'src' => 'Modules/Publish/Publish.js', 'version' => 6 ),
1919 array( 'src' => 'Modules/Toc/Toc.js', 'version' => 7 ),
20 - array( 'src' => 'Modules/Toolbar/Toolbar.js', 'version' => 92 ),
 20+ array( 'src' => 'Modules/Toolbar/Toolbar.js', 'version' => 93 ),
2121 array( 'src' => 'Modules/TemplateEditor/TemplateEditor.js', 'version' => 6 ),
2222 array( 'src' => 'Modules/Templates/Templates.js', 'version' => 1 ),
2323 array( 'src' => 'Modules/AddMediaWizard/AddMediaWizard.js', 'version' => 6 ),
2424 ),
2525 'combined' => array(
26 - array( 'src' => 'WikiEditor.combined.js', 'version' => 97 ),
 26+ array( 'src' => 'WikiEditor.combined.js', 'version' => 98 ),
2727 ),
2828 'minified' => array(
29 - array( 'src' => 'WikiEditor.combined.min.js', 'version' => 97 ),
 29+ array( 'src' => 'WikiEditor.combined.min.js', 'version' => 98 ),
3030 ),
3131 );
3232 static $messages = array(
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js
@@ -1468,8 +1468,19 @@
14691469 // Preserve whitespace when replacing
14701470 $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] );
14711471 } else {
1472 - target = text = selection;
 1472+ // Trim any leading and trailing whitespace from the selection,
 1473+ // but preserve it when replacing
 1474+ target = text = $j.trim( selection );
 1475+ if ( target.length < selection.length ) {
 1476+ $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [
 1477+ selection.substr( 0, selection.indexOf( target.charAt( 0 ) ) ),
 1478+ selection.substr(
 1479+ selection.lastIndexOf( target.charAt( target.length - 1 ) ) + 1
 1480+ ) ]
 1481+ );
 1482+ }
14731483 }
 1484+
14741485 // Change the value by calling val() doesn't trigger the change event, so let's do that ourselves
14751486 if ( typeof text != 'undefined' )
14761487 $j( '#wikieditor-toolbar-link-int-text' ).val( text ).change();
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js
@@ -68,7 +68,7 @@
6969 insertText=escTarget;else if(text=='')
7070 insertText='['+escTarget+']';else
7171 insertText='['+escTarget+' '+escText+']';}
72 -if(whitespace)insertText=whitespace[0]+insertText+whitespace[1];$j(this).dialog('close');$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:insertText}},$j(this));$j('#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text').val('');$j('#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext').attr('checked','');},'wikieditor-toolbar-tool-link-cancel':function(){var context=$j(this).data('context');context.fn.restoreStuffForIE();$j(this).dialog('close');}},open:function(){$j(this).data('articlePathRegex',new RegExp('^'+RegExp.escape(wgServer+wgArticlePath).replace(/\\\$1/g,'(.*)')+'$'));var context=$j(this).data('context');context.fn.restoreStuffForIE();context.fn.saveStuffForIE();var selection=context.$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-link-int-target').focus();$j('#wikieditor-toolbar-link-int-target').change();$j('#wikieditor-toolbar-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('#wikieditor-toolbar-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('#wikieditor-toolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else{target=text=selection;}
 72+if(whitespace)insertText=whitespace[0]+insertText+whitespace[1];$j(this).dialog('close');$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:insertText}},$j(this));$j('#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text').val('');$j('#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext').attr('checked','');},'wikieditor-toolbar-tool-link-cancel':function(){var context=$j(this).data('context');context.fn.restoreStuffForIE();$j(this).dialog('close');}},open:function(){$j(this).data('articlePathRegex',new RegExp('^'+RegExp.escape(wgServer+wgArticlePath).replace(/\\\$1/g,'(.*)')+'$'));var context=$j(this).data('context');context.fn.restoreStuffForIE();context.fn.saveStuffForIE();var selection=context.$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-link-int-target').focus();$j('#wikieditor-toolbar-link-int-target').change();$j('#wikieditor-toolbar-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('#wikieditor-toolbar-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('#wikieditor-toolbar-link-dialog').data('whitespace',[matches[1],matches[5]]);}else{target=text=$j.trim(selection);if(target.length<selection.length){$j('#wikieditor-toolbar-link-dialog').data('whitespace',[selection.substr(0,selection.indexOf(target.charAt(0))),selection.substr(selection.lastIndexOf(target.charAt(target.length-1))+1)]);}}
7373 if(typeof text!='undefined')
7474 $j('#wikieditor-toolbar-link-int-text').val(text).change();if(typeof target!='undefined')
7575 $j('#wikieditor-toolbar-link-int-target').val(target).change();if(typeof type!='undefined')
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js
@@ -1419,8 +1419,19 @@
14201420 // Preserve whitespace when replacing
14211421 $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] );
14221422 } else {
1423 - target = text = selection;
 1423+ // Trim any leading and trailing whitespace from the selection,
 1424+ // but preserve it when replacing
 1425+ target = text = $j.trim( selection );
 1426+ if ( target.length < selection.length ) {
 1427+ $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [
 1428+ selection.substr( 0, selection.indexOf( target.charAt( 0 ) ) ),
 1429+ selection.substr(
 1430+ selection.lastIndexOf( target.charAt( target.length - 1 ) ) + 1
 1431+ ) ]
 1432+ );
 1433+ }
14241434 }
 1435+
14251436 // Change the value by calling val() doesn't trigger the change event, so let's do that ourselves
14261437 if ( typeof text != 'undefined' )
14271438 $j( '#wikieditor-toolbar-link-int-text' ).val( text ).change();

Status & tagging log