r56204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56203‎ | r56204 | r56205 >
Date:18:52, 11 September 2009
Author:catrope
Status:ok
Tags:
Comment:
Bump style versions, recombine JS&CSS for my recent commit spree
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.min.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -21,16 +21,16 @@
2222 array( 'src' => 'css/suggestions.css', 'version' => 5 ),
2323 array( 'src' => 'css/wikiEditor.css', 'version' => 4 ),
2424 array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 5 ),
25 - array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 1 ),
 25+ array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 2 ),
2626 array( 'src' => 'css/wikiEditor.toc.css', 'version' => 5 ),
2727 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ),
2828 ),
2929 'combined' => array(
30 - array( 'src' => 'css/combined.css', 'version' => 7 ),
 30+ array( 'src' => 'css/combined.css', 'version' => 8 ),
3131 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ),
3232 ),
3333 'minified' => array(
34 - array( 'src' => 'css/combined.min.css', 'version' => 7 ),
 34+ array( 'src' => 'css/combined.min.css', 'version' => 8 ),
3535 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ),
3636 ),
3737 )
@@ -61,18 +61,18 @@
6262 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ),
6363 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 0 ),
6464 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 2 ),
65 - array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 9 ),
 65+ array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 10 ),
6666 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ),
6767 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ),
68 - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 1 ),
69 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 6 ),
 68+ array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 2 ),
 69+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 7 ),
7070 array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2x' ),
7171 ),
7272 'combined' => array(
73 - array( 'src' => 'js/plugins.combined.js', 'version' => 17 ),
 73+ array( 'src' => 'js/plugins.combined.js', 'version' => 18 ),
7474 ),
7575 'minified' => array(
76 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 17 ),
 76+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 18 ),
7777 ),
7878 ),
7979 );
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 = 28;
 23+$wgEditToolbarStyleVersion = 29;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;
Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -92,7 +92,7 @@
9393 }
9494
9595 /* Put suggestions (default z-index 99) on top of dialogs (z-index 1002) */
96 -div.os-suggest {
 96+div.suggestions {
9797 z-index: 1099;
9898 }
9999 /* wikiEditor toc module */
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -83,7 +83,7 @@
8484 .ui-widget table td{
8585 padding:0.5em;
8686 }
87 -div.os-suggest{
 87+div.suggestions{
8888 z-index:1099;
8989 }
9090 .wikiEditor-ui-text{
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -845,6 +845,21 @@
846846 }
847847 return getCaret( this.get( 0 ) );
848848 },
 849+setSelection: function( start, end ) {
 850+ return this.each( function() {
 851+ if ( this.selectionStart || this.selectionStart == '0' ) {
 852+ this.selectionStart = start;
 853+ this.selectionEnd = end;
 854+ } else if ( document.body.createTextRange ) {
 855+ var selection = document.body.createTextRange;
 856+ selection.setToElementText( this );
 857+ var length = selection.text.length;
 858+ selection.moveStart( 'character', start );
 859+ selection.moveEnd( 'character', -length + end );
 860+ selection.select();
 861+ }
 862+ });
 863+},
849864 /**
850865 * Ported from Wikia's LinkSuggest extension
851866 * https://svn.wikia-code.com/wikia/trunk/extensions/wikia/LinkSuggest
@@ -1162,9 +1177,51 @@
11631178 .data( 'context', context )
11641179 .appendTo( $( 'body' ) )
11651180 .each( module.init )
1166 - .dialog( configuration );
 1181+ .dialog( configuration )
 1182+ .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize )
 1183+ .find( '.ui-tabs' ).bind( 'tabsshow', function() {
 1184+ $(this).closest( '.ui-dialog-content' ).each(
 1185+ $.wikiEditor.modules.dialogs.fn.resize );
 1186+ });
11671187 }
11681188 }
 1189+ },
 1190+
 1191+ /**
 1192+ * Resize a dialog so its contents fit
 1193+ *
 1194+ * Usage: dialog.each( resize ); or dialog.bind( 'blah', resize );
 1195+ */
 1196+ resize: function() {
 1197+ var wrapper = $(this).closest( '.ui-dialog' );
 1198+ // Make sure elements don't wrapped so we get an accurate idea
 1199+ // of whether they really fit. Also temporarily show hidden
 1200+ // elements.
 1201+
 1202+ // Work around jQuery bug where <div style="display:inline;" />
 1203+ // inside a dialog is both :visible and :hidden
 1204+ var oldHidden = $(this).find( '*' ).not( ':visible' );
 1205+
 1206+ // Save the style attributes of the hidden elements to restore
 1207+ // them later. Calling hide() after show() messes up for
 1208+ // elements hidden with a class
 1209+ oldHidden.each( function() {
 1210+ $(this).data( 'oldstyle', $(this).attr( 'style' ) );
 1211+ });
 1212+ oldHidden.show();
 1213+ var oldWS = $(this).css( 'white-space' );
 1214+ $(this).css( 'white-space', 'nowrap' );
 1215+
 1216+ if ( wrapper.width() <= $(this).get(0).scrollWidth ) {
 1217+ $(this).width( $(this).get(0).scrollWidth );
 1218+ wrapper.width( wrapper.get(0).scrollWidth );
 1219+ $(this).dialog( { 'width': wrapper.width() } );
 1220+ }
 1221+
 1222+ $(this).css( 'white-space', oldWS );
 1223+ oldHidden.each( function() {
 1224+ $(this).attr( 'style', $(this).data( 'oldstyle' ) );
 1225+ });
11691226 }
11701227 },
11711228 'modules': {}
@@ -1792,7 +1849,7 @@
17931850 } );
17941851 }
17951852 )
1796 - .bind( 'mouseup scrollToPosition',
 1853+ .bind( 'mouseup scrollToPosition focus',
17971854 function( event ) {
17981855 var context = $(this).data( 'context' );
17991856 $(this).eachAsync( {
@@ -1802,15 +1859,22 @@
18031860 }
18041861 } );
18051862 }
1806 - );
 1863+ )
 1864+ .blur( function() {
 1865+ $.wikiEditor.modules.toc.fn.unhighlight( context );
 1866+ });
18071867 },
 1868+
 1869+ unhighlight: function( context ) {
 1870+ context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' );
 1871+ },
18081872 /**
18091873 * Highlight the section the cursor is currently within
18101874 *
18111875 * @param {Object} context
18121876 */
18131877 update: function( context ) {
1814 - context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' );
 1878+ $.wikiEditor.modules.toc.fn.unhighlight( context );
18151879 var position = context.$textarea.getCaretPosition();
18161880 var section = 0;
18171881 if ( context.data.outline.length > 0 ) {
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -59,7 +59,7 @@
6060 if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1)
6161 if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));caretPos=rawPreText.replace(/\r\n/g,"\n").length;}else if(e.selectionStart||e.selectionStart=='0'){caretPos=e.selectionStart;}
6262 return caretPos;}
63 -return getCaret(this.get(0));},scrollToCaretPosition:function(pos){function getLineLength(e){return Math.floor(e.scrollWidth/($.os.name=='linux'?7:8));}
 63+return getCaret(this.get(0));},setSelection:function(start,end){return this.each(function(){if(this.selectionStart||this.selectionStart=='0'){this.selectionStart=start;this.selectionEnd=end;}else if(document.body.createTextRange){var selection=document.body.createTextRange;selection.setToElementText(this);var length=selection.text.length;selection.moveStart('character',start);selection.moveEnd('character',-length+end);selection.select();}});},scrollToCaretPosition:function(pos){function getLineLength(e){return Math.floor(e.scrollWidth/($.os.name=='linux'?7:8));}
6464 function getCaretScrollPosition(e){var text=e.value.replace(/\r/g,"");var caret=$(e).getCaretPosition();var lineLength=getLineLength(e);var row=0;var charInLine=0;var lastSpaceInLine=0;for(i=0;i<caret;i++){charInLine++;if(text.charAt(i)==" "){lastSpaceInLine=charInLine;}else if(text.charAt(i)=="\n"){lastSpaceInLine=0;charInLine=0;row++;}
6565 if(charInLine>lineLength){if(lastSpaceInLine>0){charInLine=charInLine-lastSpaceInLine;lastSpaceInLine=0;row++;}}}
6666 var nextSpace=0;for(j=caret;j<caret+lineLength;j++){if(text.charAt(j)==" "||text.charAt(j)=="\n"||caret==text.length){nextSpace=j;break;}}
@@ -76,7 +76,8 @@
7777 if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}
7878 context.$textarea.scrollToCaretPosition(0);return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
7979 for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');for(msg in configuration.buttons){configuration.buttons[gM(msg)]=configuration.buttons[msg];delete configuration.buttons[msg];}
80 -$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);}}}},'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;}
 80+$('<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);});}}},resize:function(){var wrapper=$(this).closest('.ui-dialog');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()});}
 81+$(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;}
8182 $sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,data[type][section]));}
8283 break;case'groups':if(!('section'in data)){continue;}
8384 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]));}
@@ -123,7 +124,7 @@
124125 return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);var $selectedIndex=$index.find('*[rel='+selected+']');if($selectedIndex.size()==0){selected=$index.children().eq(0).attr('rel');$.cookie(cookie,selected);}
125126 $pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}}
126127 $.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;}
127 -context.modules.$toc=$('<div></div>').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');$.wikiEditor.modules.toc.fn.build(context,config);context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css('width','12em').css('marginTop',-(context.$ui.find('.wikiEditor-ui-bottom').height()));context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);context.$textarea.bind('keyup encapsulateSelection',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});});},update:function(context){context.modules.$toc.find('a').removeClass('currentSelection');var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
 128+context.modules.$toc=$('<div></div>').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');$.wikiEditor.modules.toc.fn.build(context,config);context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css('width','12em').css('marginTop',-(context.$ui.find('.wikiEditor-ui-bottom').height()));context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);context.$textarea.bind('keyup encapsulateSelection',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
128129 section=Math.max(0,section);}
129130 context.modules.$toc.find('a.section-'+section).addClass('currentSelection');}},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;}
130131 sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}}

Status & tagging log