Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php |
— | — | @@ -16,16 +16,16 @@ |
17 | 17 | array( 'src' => 'Modules/Preview/Preview.js', 'version' => 6 ), |
18 | 18 | array( 'src' => 'Modules/Publish/Publish.js', 'version' => 6 ), |
19 | 19 | 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 ), |
21 | 21 | array( 'src' => 'Modules/TemplateEditor/TemplateEditor.js', 'version' => 6 ), |
22 | 22 | array( 'src' => 'Modules/Templates/Templates.js', 'version' => 1 ), |
23 | 23 | array( 'src' => 'Modules/AddMediaWizard/AddMediaWizard.js', 'version' => 6 ), |
24 | 24 | ), |
25 | 25 | 'combined' => array( |
26 | | - array( 'src' => 'WikiEditor.combined.js', 'version' => 97 ), |
| 26 | + array( 'src' => 'WikiEditor.combined.js', 'version' => 98 ), |
27 | 27 | ), |
28 | 28 | 'minified' => array( |
29 | | - array( 'src' => 'WikiEditor.combined.min.js', 'version' => 97 ), |
| 29 | + array( 'src' => 'WikiEditor.combined.min.js', 'version' => 98 ), |
30 | 30 | ), |
31 | 31 | ); |
32 | 32 | static $messages = array( |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js |
— | — | @@ -1468,8 +1468,19 @@ |
1469 | 1469 | // Preserve whitespace when replacing |
1470 | 1470 | $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
1471 | 1471 | } 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 | + } |
1473 | 1483 | } |
| 1484 | + |
1474 | 1485 | // Change the value by calling val() doesn't trigger the change event, so let's do that ourselves |
1475 | 1486 | if ( typeof text != 'undefined' ) |
1476 | 1487 | $j( '#wikieditor-toolbar-link-int-text' ).val( text ).change(); |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | insertText=escTarget;else if(text=='') |
70 | 70 | insertText='['+escTarget+']';else |
71 | 71 | 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)]);}} |
73 | 73 | if(typeof text!='undefined') |
74 | 74 | $j('#wikieditor-toolbar-link-int-text').val(text).change();if(typeof target!='undefined') |
75 | 75 | $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 @@ |
1420 | 1420 | // Preserve whitespace when replacing |
1421 | 1421 | $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] ); |
1422 | 1422 | } 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 | + } |
1424 | 1434 | } |
| 1435 | + |
1425 | 1436 | // Change the value by calling val() doesn't trigger the change event, so let's do that ourselves |
1426 | 1437 | if ( typeof text != 'undefined' ) |
1427 | 1438 | $j( '#wikieditor-toolbar-link-int-text' ).val( text ).change(); |