Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -21,16 +21,16 @@ |
22 | 22 | array( 'src' => 'css/suggestions.css', 'version' => 5 ), |
23 | 23 | array( 'src' => 'css/wikiEditor.css', 'version' => 4 ), |
24 | 24 | 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 ), |
26 | 26 | array( 'src' => 'css/wikiEditor.toc.css', 'version' => 5 ), |
27 | 27 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ), |
28 | 28 | ), |
29 | 29 | 'combined' => array( |
30 | | - array( 'src' => 'css/combined.css', 'version' => 7 ), |
| 30 | + array( 'src' => 'css/combined.css', 'version' => 8 ), |
31 | 31 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ), |
32 | 32 | ), |
33 | 33 | 'minified' => array( |
34 | | - array( 'src' => 'css/combined.min.css', 'version' => 7 ), |
| 34 | + array( 'src' => 'css/combined.min.css', 'version' => 8 ), |
35 | 35 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ), |
36 | 36 | ), |
37 | 37 | ) |
— | — | @@ -61,18 +61,18 @@ |
62 | 62 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ), |
63 | 63 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 0 ), |
64 | 64 | 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 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ), |
67 | 67 | 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 ), |
70 | 70 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2x' ), |
71 | 71 | ), |
72 | 72 | 'combined' => array( |
73 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 17 ), |
| 73 | + array( 'src' => 'js/plugins.combined.js', 'version' => 18 ), |
74 | 74 | ), |
75 | 75 | 'minified' => array( |
76 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 17 ), |
| 76 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 18 ), |
77 | 77 | ), |
78 | 78 | ), |
79 | 79 | ); |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 28; |
| 23 | +$wgEditToolbarStyleVersion = 29; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | } |
94 | 94 | |
95 | 95 | /* Put suggestions (default z-index 99) on top of dialogs (z-index 1002) */ |
96 | | -div.os-suggest { |
| 96 | +div.suggestions { |
97 | 97 | z-index: 1099; |
98 | 98 | } |
99 | 99 | /* wikiEditor toc module */ |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | .ui-widget table td{ |
85 | 85 | padding:0.5em; |
86 | 86 | } |
87 | | -div.os-suggest{ |
| 87 | +div.suggestions{ |
88 | 88 | z-index:1099; |
89 | 89 | } |
90 | 90 | .wikiEditor-ui-text{ |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -845,6 +845,21 @@ |
846 | 846 | } |
847 | 847 | return getCaret( this.get( 0 ) ); |
848 | 848 | }, |
| 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 | +}, |
849 | 864 | /** |
850 | 865 | * Ported from Wikia's LinkSuggest extension |
851 | 866 | * https://svn.wikia-code.com/wikia/trunk/extensions/wikia/LinkSuggest |
— | — | @@ -1162,9 +1177,51 @@ |
1163 | 1178 | .data( 'context', context ) |
1164 | 1179 | .appendTo( $( 'body' ) ) |
1165 | 1180 | .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 | + }); |
1167 | 1187 | } |
1168 | 1188 | } |
| 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 | + }); |
1169 | 1226 | } |
1170 | 1227 | }, |
1171 | 1228 | 'modules': {} |
— | — | @@ -1792,7 +1849,7 @@ |
1793 | 1850 | } ); |
1794 | 1851 | } |
1795 | 1852 | ) |
1796 | | - .bind( 'mouseup scrollToPosition', |
| 1853 | + .bind( 'mouseup scrollToPosition focus', |
1797 | 1854 | function( event ) { |
1798 | 1855 | var context = $(this).data( 'context' ); |
1799 | 1856 | $(this).eachAsync( { |
— | — | @@ -1802,15 +1859,22 @@ |
1803 | 1860 | } |
1804 | 1861 | } ); |
1805 | 1862 | } |
1806 | | - ); |
| 1863 | + ) |
| 1864 | + .blur( function() { |
| 1865 | + $.wikiEditor.modules.toc.fn.unhighlight( context ); |
| 1866 | + }); |
1807 | 1867 | }, |
| 1868 | + |
| 1869 | + unhighlight: function( context ) { |
| 1870 | + context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' ); |
| 1871 | + }, |
1808 | 1872 | /** |
1809 | 1873 | * Highlight the section the cursor is currently within |
1810 | 1874 | * |
1811 | 1875 | * @param {Object} context |
1812 | 1876 | */ |
1813 | 1877 | update: function( context ) { |
1814 | | - context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' ); |
| 1878 | + $.wikiEditor.modules.toc.fn.unhighlight( context ); |
1815 | 1879 | var position = context.$textarea.getCaretPosition(); |
1816 | 1880 | var section = 0; |
1817 | 1881 | if ( context.data.outline.length > 0 ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1) |
61 | 61 | 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;} |
62 | 62 | 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));} |
64 | 64 | 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++;} |
65 | 65 | if(charInLine>lineLength){if(lastSpaceInLine>0){charInLine=charInLine-lastSpaceInLine;lastSpaceInLine=0;row++;}}} |
66 | 66 | 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 @@ |
77 | 77 | if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);} |
78 | 78 | 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];} |
79 | 79 | 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;} |
81 | 82 | $sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,data[type][section]));} |
82 | 83 | break;case'groups':if(!('section'in data)){continue;} |
83 | 84 | 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 @@ |
124 | 125 | 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);} |
125 | 126 | $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]));}} |
126 | 127 | $.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++;} |
128 | 129 | section=Math.max(0,section);} |
129 | 130 | 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;} |
130 | 131 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |