r57939 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57938‎ | r57939 | r57940 >
Date:00:33, 20 October 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditToolbar: Add smartness to the link dialog so it detects URLs pointing to wiki pages and pops up a dialog asking the user whether they want to make an internal link instead. Also recombine for r57921
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.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.wikiEditor.dialogs.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -68,7 +68,7 @@
6969 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 16 ),
7070 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ),
7171 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 12 ),
72 - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 5 ),
 72+ array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 6 ),
7373 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 21 ),
7474 ),
7575 'combined' => array(
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php
@@ -59,6 +59,9 @@
6060 'edittoolbar-tool-link-int-target-status-invalid',
6161 'edittoolbar-tool-link-int-target-status-loading',
6262 'edittoolbar-tool-link-int-invalid',
 63+ 'edittoolbar-tool-link-lookslikeinternal',
 64+ 'edittoolbar-tool-link-lookslikeinternal-int',
 65+ 'edittoolbar-tool-link-lookslikeinternal-ext',
6366 'edittoolbar-tool-file',
6467 'edittoolbar-tool-file-pre',
6568 'edittoolbar-tool-file-example',
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -1005,12 +1005,35 @@
10061006 else
10071007 insertText = '[[' + target + '|' + escapeInternalText( text ) + ']]';
10081008 } else {
 1009+ // Prepend http:// if there is no protocol
 1010+ if ( !target.match( /^[a-z]+:\/\/./ ) )
 1011+ target = 'http://' + target;
 1012+
 1013+ // Detect if this is really an internal link in disguise
 1014+ var match = target.match( $j(this).data( 'articlePathRegex' ) );
 1015+ if ( match && !$j(this).data( 'ignoreLooksInternal' ) ) {
 1016+ var buttons = { };
 1017+ var that = this;
 1018+ buttons[ gM( 'edittoolbar-tool-link-lookslikeinternal-int' ) ] = function() {
 1019+ $j( '#edittoolbar-link-int-target' ).val( match[1] ).change();
 1020+ $j(this).dialog( 'close' );
 1021+ };
 1022+ buttons[ gM( 'edittoolbar-tool-link-lookslikeinternal-ext' ) ] = function() {
 1023+ $j(that).data( 'ignoreLooksInternal', true );
 1024+ $j(that).closest( '.ui-dialog' ).find( 'button:first' ).click();
 1025+ $j(that).data( 'ignoreLooksInternal', false );
 1026+ $j(this).dialog( 'close' );
 1027+ };
 1028+ $j.wikiEditor.modules.dialogs.quickDialog(
 1029+ gM( 'edittoolbar-tool-link-lookslikeinternal', match[1] ),
 1030+ { buttons: buttons }
 1031+ );
 1032+ return;
 1033+ }
 1034+
10091035 var escTarget = escapeExternalTarget( target );
10101036 var escText = escapeExternalText( text );
1011 - // Prepend http:// if there is no protocol
1012 - if ( !escTarget.match( /^[a-z]+:\/\/./ ) ) {
1013 - escTarget = 'http://' + escTarget;
1014 - }
 1037+
10151038 if ( escTarget == escText )
10161039 insertText = escTarget;
10171040 else if ( text == '' )
@@ -1033,6 +1056,12 @@
10341057 }
10351058 },
10361059 open: function() {
 1060+ // Cache the articlepath regex
 1061+ $j(this).data( 'articlePathRegex', new RegExp(
 1062+ '^' + RegExp.escape( wgServer + wgArticlePath )
 1063+ .replace( /\\\$1/g, '(.*)' ) + '$'
 1064+ ) );
 1065+
10371066 $j( '#edittoolbar-link-int-target' ).focus();
10381067 // Pre-fill the text fields based on the current selection
10391068 var selection = $j(this).data( 'context' ).$textarea.getSelection();
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php
@@ -41,6 +41,9 @@
4242 'edittoolbar-tool-link-int-target-status-invalid' => 'Invalid title',
4343 'edittoolbar-tool-link-int-target-status-loading' => 'Checking page existence...',
4444 'edittoolbar-tool-link-int-invalid' => 'The title you specified is invalid.',
 45+ 'edittoolbar-tool-link-lookslikeinternal' => 'The URL you specified looks like it was intended as a link to another wiki page. Do you want to make it an internal link?',
 46+ 'edittoolbar-tool-link-lookslikeinternal-int' => 'Internal link',
 47+ 'edittoolbar-tool-link-lookslikeinternal-ext' => 'External link',
4548 'edittoolbar-tool-file' => 'Embedded file',
4649 'edittoolbar-tool-file-pre' => '$1{{ns:file}}:',
4750 'edittoolbar-tool-file-example' => 'Example.jpg',
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 = 59;
 23+$wgEditToolbarStyleVersion = 60;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js
@@ -137,6 +137,16 @@
138138 });
139139 }
140140 },
141 -'modules': {}
 141+modules: {},
 142+quickDialog: function( body, settings ) {
 143+ $( '<div />' )
 144+ .text( body )
 145+ .appendTo( $( 'body' ) )
 146+ .dialog( $.extend( {
 147+ bgiframe: true,
 148+ modal: true
 149+ }, settings ) )
 150+ .dialog( 'open' );
 151+}
142152
143153 }; } ) ( jQuery );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -263,11 +263,11 @@
264264 collapsible: 'li.collapsible',
265265 shifting: false,
266266 expandCondition: function(eleWidth) {
267 - return ( $('#left-navigation').position().left + $('#left-navigation').width() - 4)
 267+ return ( $('#left-navigation').position().left + $('#left-navigation').width())
268268 < ($('#right-navigation').position().left - eleWidth);
269269 },
270270 collapseCondition: function() {
271 - return ( $('#left-navigation').position().left + $('#left-navigation').width() + 4)
 271+ return ( $('#left-navigation').position().left + $('#left-navigation').width())
272272 > $('#right-navigation').position().left;
273273 }
274274 },
@@ -1609,7 +1609,17 @@
16101610 });
16111611 }
16121612 },
1613 -'modules': {}
 1613+modules: {},
 1614+quickDialog: function( body, settings ) {
 1615+ $( '<div />' )
 1616+ .text( body )
 1617+ .appendTo( $( 'body' ) )
 1618+ .dialog( $.extend( {
 1619+ bgiframe: true,
 1620+ modal: true
 1621+ }, settings ) )
 1622+ .dialog( 'open' );
 1623+}
16141624
16151625 }; } ) ( jQuery );
16161626 /**
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -18,7 +18,7 @@
1919 $text.attr('title',text);}});};})(jQuery);(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);}
2020 return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';}
2121 if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';}
22 -r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);(function($){$.fn.collapsibleTabs=function($$options){if(!this.length)return this;var $settings=$.extend({},$.collapsibleTabs.defaults,$$options);this.each(function(){var $this=$(this);$.collapsibleTabs.instances=($.collapsibleTabs.instances.length==0?$this:$.collapsibleTabs.instances.add($this));$this.data('collapsibleTabsSettings',$settings);$this.children($settings.collapsible).each(function(){var $collapsible=$(this);$collapsible.data('collapsibleTabsSettings',{'expandedContainer':$settings.expandedContainer,'collapsedContainer':$settings.collapsedContainer,'expandedWidth':$collapsible.width(),'prevElement':$collapsible.prev()});});});if(!$.collapsibleTabs.boundEvent)$(window).delayedBind('500','resize',function(){$.collapsibleTabs.handleResize();});$.collapsibleTabs.handleResize();return this;};$.collapsibleTabs={instances:[],boundEvent:null,defaults:{expandedContainer:'#p-views ul',collapsedContainer:'#p-cactions ul',collapsible:'li.collapsible',shifting:false,expandCondition:function(eleWidth){return($('#left-navigation').position().left+$('#left-navigation').width()-4)<($('#right-navigation').position().left-eleWidth);},collapseCondition:function(){return($('#left-navigation').position().left+$('#left-navigation').width()+4)>$('#right-navigation').position().left;}},handleResize:function(e){$.collapsibleTabs.instances.each(function(){var $this=$(this),data=$this.data('collapsibleTabsSettings');if(data.shifting)return;if($this.children(data.collapsible).length>0&&data.collapseCondition()){$this.trigger("beforeTabCollapse");$.collapsibleTabs.moveToCollapsed($this.children(data.collapsible+':last'));}
 22+r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);(function($){$.fn.collapsibleTabs=function($$options){if(!this.length)return this;var $settings=$.extend({},$.collapsibleTabs.defaults,$$options);this.each(function(){var $this=$(this);$.collapsibleTabs.instances=($.collapsibleTabs.instances.length==0?$this:$.collapsibleTabs.instances.add($this));$this.data('collapsibleTabsSettings',$settings);$this.children($settings.collapsible).each(function(){var $collapsible=$(this);$collapsible.data('collapsibleTabsSettings',{'expandedContainer':$settings.expandedContainer,'collapsedContainer':$settings.collapsedContainer,'expandedWidth':$collapsible.width(),'prevElement':$collapsible.prev()});});});if(!$.collapsibleTabs.boundEvent)$(window).delayedBind('500','resize',function(){$.collapsibleTabs.handleResize();});$.collapsibleTabs.handleResize();return this;};$.collapsibleTabs={instances:[],boundEvent:null,defaults:{expandedContainer:'#p-views ul',collapsedContainer:'#p-cactions ul',collapsible:'li.collapsible',shifting:false,expandCondition:function(eleWidth){return($('#left-navigation').position().left+$('#left-navigation').width())<($('#right-navigation').position().left-eleWidth);},collapseCondition:function(){return($('#left-navigation').position().left+$('#left-navigation').width())>$('#right-navigation').position().left;}},handleResize:function(e){$.collapsibleTabs.instances.each(function(){var $this=$(this),data=$this.data('collapsibleTabsSettings');if(data.shifting)return;if($this.children(data.collapsible).length>0&&data.collapseCondition()){$this.trigger("beforeTabCollapse");$.collapsibleTabs.moveToCollapsed($this.children(data.collapsible+':last'));}
2323 if($(data.collapsedContainer+' '+data.collapsible).length>0&&data.expandCondition($(data.collapsedContainer).children(data.collapsible+":first").data('collapsibleTabsSettings').expandedWidth)){$this.trigger("beforeTabExpand");$.collapsibleTabs.moveToExpanded(data.collapsedContainer+" "+data.collapsible+':first');}});},moveToCollapsed:function(ele){var $moving=$(ele);var data=$moving.data('collapsibleTabsSettings');$(data.expandedContainer).data('collapsibleTabsSettings').shifting=true;$moving.remove().prependTo(data.collapsedContainer).data('collapsibleTabsSettings',data);$(data.expandedContainer).data('collapsibleTabsSettings').shifting=false;$.collapsibleTabs.handleResize();},moveToExpanded:function(ele){var $moving=$(ele);var data=$moving.data('collapsibleTabsSettings');$(data.expandedContainer).data('collapsibleTabsSettings').shifting=true;$moving.remove().insertAfter(data.prevElement).data('collapsibleTabsSettings',data);$(data.expandedContainer).data('collapsibleTabsSettings').shifting=false;$.collapsibleTabs.handleResize();}};})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
2424 var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
2525 expires='; expires='+date.toUTCString();}
@@ -93,7 +93,7 @@
9494 configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration).bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI)
9595 maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){$(this).width($(this).get(0).scrollWidth);wrapper.width(wrapper.get(0).scrollWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-
9696 (wrapper.width()-oldWidth)/2);}
97 -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},'modules':{}};})(jQuery);(function($){$.wikiEditor.modules.toolbar={api:{addToToolbar:function(context,data){for(type in data){switch(type){case'sections':var $sections=context.modules.$toolbar.find('div.sections');var $tabs=context.modules.$toolbar.find('div.tabs');for(section in data[type]){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));continue;}
 97+$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.toolbar={api:{addToToolbar:function(context,data){for(type in data){switch(type){case'sections':var $sections=context.modules.$toolbar.find('div.sections');var $tabs=context.modules.$toolbar.find('div.tabs');for(section in data[type]){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));continue;}
9898 $sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,data[type][section]));$section=$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},'fast');}}
9999 break;case'groups':if(!('section'in data)){continue;}
100100 var $section=context.modules.$toolbar.find('div[rel='+data.section+'].section');for(group in data[type]){$section.append($.wikiEditor.modules.toolbar.fn.buildGroup(context,group,data[type][group]));}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57921Addressing Roan's feedback on r57918adam21:41, 19 October 2009

Status & tagging log