r64307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64306‎ | r64307 | r64308 >
Date:20:20, 28 March 2010
Author:adam
Status:ok
Tags:
Comment:
WikiEditor Toolbar: improvements to the ref dialog. Now supports ref tags with attributes
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,14 +16,14 @@
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' => 73),
 20+ array( 'src' => 'Modules/Toolbar/Toolbar.js', 'version' => 74 ),
2121 array( 'src' => 'Modules/TemplateEditor/TemplateEditor.js', 'version' => 6 ),
2222 ),
2323 'combined' => array(
24 - array( 'src' => 'WikiEditor.combined.js', 'version' => 77 ),
 24+ array( 'src' => 'WikiEditor.combined.js', 'version' => 78 ),
2525 ),
2626 'minified' => array(
27 - array( 'src' => 'WikiEditor.combined.min.js', 'version' => 77 ),
 27+ array( 'src' => 'WikiEditor.combined.min.js', 'version' => 78 ),
2828 ),
2929 );
3030 static $messages = array(
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.js
@@ -1442,15 +1442,15 @@
14431443 'wikieditor-toolbar-tool-reference-insert': function() {
14441444 var insertText = $j( '#wikieditor-toolbar-reference-text' ).val();
14451445 var whitespace = $j( '#wikieditor-toolbar-reference-dialog' ).data( 'whitespace' );
1446 - if ( whitespace ) insertText = whitespace[0] + insertText + whitespace[1];
 1446+ var attributes = $j( '#wikieditor-toolbar-reference-dialog' ).data( 'attributes' );
14471447 $j.wikiEditor.modules.toolbar.fn.doAction(
14481448 $j( this ).data( 'context' ),
14491449 {
14501450 type: 'replace',
14511451 options: {
1452 - pre: '<ref>',
 1452+ pre: whitespace[0] + '<ref' + attributes + '>',
14531453 peri: insertText,
1454 - post: '</ref>'
 1454+ post: '</ref>' + whitespace[1]
14551455 }
14561456 },
14571457 $j( this )
@@ -1472,13 +1472,14 @@
14731473 .$textarea.textSelection( 'getSelection' );
14741474 // set focus
14751475 $j( '#wikieditor-toolbar-reference-text' ).focus();
 1476+ $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [ '', '' ] );
14761477 if ( selection != '' ) {
14771478 var matches, text;
1478 - if ( ( matches = selection.match( /^(\s*)(<ref\>)([^\<]+)?(<\/ref\>)(\s*)$/ ) ) ) {
1479 - // <ref>foo</ref>
 1479+ if ( ( matches = selection.match( /^(\s*)<ref([^\>]*)>([^\<]*)<\/ref\>(\s*)$/ ) ) ) {
14801480 text = matches[3];
14811481 // Preserve whitespace when replacing
1482 - $j( '#wikieditor-toolbar-reference-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] );
 1482+ $j( '#wikieditor-toolbar-reference-dialog' ).data( 'whitespace', [ matches[1], matches[4] ] );
 1483+ $j( '#wikieditor-toolbar-reference-dialog' ).data( 'attributes', matches[2] );
14831484 } else {
14841485 text = selection;
14851486 }
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.combined.min.js
@@ -83,7 +83,7 @@
8484 <input type="text" id="wikieditor-toolbar-reference-text" />\
8585 </div>\
8686 </div></fieldset>\
87 - </div>',init:function(){$j(this).find('[rel]').each(function(){$j(this).text(mw.usability.getMsg($j(this).attr('rel')));});},dialog:{dialogClass:'wikiEditor-toolbar-dialog',width:590,buttons:{'wikieditor-toolbar-tool-reference-insert':function(){var insertText=$j('#wikieditor-toolbar-reference-text').val();var whitespace=$j('#wikieditor-toolbar-reference-dialog').data('whitespace');if(whitespace)insertText=whitespace[0]+insertText+whitespace[1];$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:'<ref>',peri:insertText,post:'</ref>'}},$j(this));$j('#wikieditor-toolbar-reference-text').val("");$j(this).dialog('close');},'wikieditor-toolbar-tool-reference-cancel':function(){$j(this).dialog('close');}},open:function(){var selection=$j(this).data('context').$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-reference-text').focus();if(selection!=''){var matches,text;if((matches=selection.match(/^(\s*)(<ref\>)([^\<]+)?(<\/ref\>)(\s*)$/))){text=matches[3];$j('#wikieditor-toolbar-reference-dialog').data('whitespace',[matches[1],matches[5]]);}else{text=selection;}
 87+ </div>',init:function(){$j(this).find('[rel]').each(function(){$j(this).text(mw.usability.getMsg($j(this).attr('rel')));});},dialog:{dialogClass:'wikiEditor-toolbar-dialog',width:590,buttons:{'wikieditor-toolbar-tool-reference-insert':function(){var insertText=$j('#wikieditor-toolbar-reference-text').val();var whitespace=$j('#wikieditor-toolbar-reference-dialog').data('whitespace');var attributes=$j('#wikieditor-toolbar-reference-dialog').data('attributes');$j.wikiEditor.modules.toolbar.fn.doAction($j(this).data('context'),{type:'replace',options:{pre:whitespace[0]+'<ref'+attributes+'>',peri:insertText,post:'</ref>'+whitespace[1]}},$j(this));$j('#wikieditor-toolbar-reference-text').val("");$j(this).dialog('close');},'wikieditor-toolbar-tool-reference-cancel':function(){$j(this).dialog('close');}},open:function(){var selection=$j(this).data('context').$textarea.textSelection('getSelection');$j('#wikieditor-toolbar-reference-text').focus();$j('#wikieditor-toolbar-link-dialog').data('whitespace',['','']);if(selection!=''){var matches,text;if((matches=selection.match(/^(\s*)<ref([^\>]*)>([^\<]*)<\/ref\>(\s*)$/))){text=matches[3];$j('#wikieditor-toolbar-reference-dialog').data('whitespace',[matches[1],matches[4]]);$j('#wikieditor-toolbar-reference-dialog').data('attributes',matches[2]);}else{text=selection;}
8888 $j('#wikieditor-toolbar-reference-text').val(text);}
8989 if(!($j(this).data('dialogkeypressset'))){$j(this).data('dialogkeypressset',true);$j(this).closest('.ui-dialog').keypress(function(e){if((e.keyCode||e.which)==13){var button=$j(this).data('dialogaction')||$j(this).find('button:first');button.click();e.preventDefault();}});$j(this).closest('.ui-dialog').find('button').focus(function(){$j(this).closest('.ui-dialog').data('dialogaction',this);});}}}},'insert-table':{filters:['#wpTextbox1.toolbar-dialogs'],titleMsg:'wikieditor-toolbar-tool-table-title',id:'wikieditor-toolbar-table-dialog',html:'\
9090 <div class="wikieditor-toolbar-dialog-wrapper">\
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toolbar/Toolbar.js
@@ -1393,15 +1393,15 @@
13941394 'wikieditor-toolbar-tool-reference-insert': function() {
13951395 var insertText = $j( '#wikieditor-toolbar-reference-text' ).val();
13961396 var whitespace = $j( '#wikieditor-toolbar-reference-dialog' ).data( 'whitespace' );
1397 - if ( whitespace ) insertText = whitespace[0] + insertText + whitespace[1];
 1397+ var attributes = $j( '#wikieditor-toolbar-reference-dialog' ).data( 'attributes' );
13981398 $j.wikiEditor.modules.toolbar.fn.doAction(
13991399 $j( this ).data( 'context' ),
14001400 {
14011401 type: 'replace',
14021402 options: {
1403 - pre: '<ref>',
 1403+ pre: whitespace[0] + '<ref' + attributes + '>',
14041404 peri: insertText,
1405 - post: '</ref>'
 1405+ post: '</ref>' + whitespace[1]
14061406 }
14071407 },
14081408 $j( this )
@@ -1423,13 +1423,14 @@
14241424 .$textarea.textSelection( 'getSelection' );
14251425 // set focus
14261426 $j( '#wikieditor-toolbar-reference-text' ).focus();
 1427+ $j( '#wikieditor-toolbar-link-dialog' ).data( 'whitespace', [ '', '' ] );
14271428 if ( selection != '' ) {
14281429 var matches, text;
1429 - if ( ( matches = selection.match( /^(\s*)(<ref\>)([^\<]+)?(<\/ref\>)(\s*)$/ ) ) ) {
1430 - // <ref>foo</ref>
 1430+ if ( ( matches = selection.match( /^(\s*)<ref([^\>]*)>([^\<]*)<\/ref\>(\s*)$/ ) ) ) {
14311431 text = matches[3];
14321432 // Preserve whitespace when replacing
1433 - $j( '#wikieditor-toolbar-reference-dialog' ).data( 'whitespace', [ matches[1], matches[5] ] );
 1433+ $j( '#wikieditor-toolbar-reference-dialog' ).data( 'whitespace', [ matches[1], matches[4] ] );
 1434+ $j( '#wikieditor-toolbar-reference-dialog' ).data( 'attributes', matches[2] );
14341435 } else {
14351436 text = selection;
14361437 }

Status & tagging log