Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.toc.css |
— | — | @@ -73,4 +73,29 @@ |
74 | 74 | padding-top: 0.5em; |
75 | 75 | padding-bottom: 0.5em; |
76 | 76 | border-bottom: solid 1px #DDDDDD; |
| 77 | +} |
| 78 | + |
| 79 | +/* Collapsing changes */ |
| 80 | + |
| 81 | +/* these first two should probably be conditionally applied */ |
| 82 | +/* suggestions for doing that welcome */ |
| 83 | +.wikiEditor-ui-toc ul { |
| 84 | + width:132px; |
| 85 | + float:left; |
| 86 | +} |
| 87 | +.wikiEditor-ui-toc ul ul { |
| 88 | + float:none; |
| 89 | + width:auto; |
| 90 | +} |
| 91 | +#wikiEditor-ui-toc-collapse { |
| 92 | + height:100%; |
| 93 | + width:18px; |
| 94 | + float:left; |
| 95 | +} |
| 96 | +.wikiEditor-ui-toc-collapse-open { |
| 97 | + background:#f3f3f3 url(../images/wikiEditor/toc/close.png) 4px 50% no-repeat; |
| 98 | + border-left:1px solid #DDDDDD; |
| 99 | +} |
| 100 | +.wikiEditor-ui-toc-collapse-closed { |
| 101 | + background:#f3f3f3 url(../images/wikiEditor/toc/open.png) 4px 50% no-repeat; |
77 | 102 | } |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -178,6 +178,31 @@ |
179 | 179 | padding-top: 0.5em; |
180 | 180 | padding-bottom: 0.5em; |
181 | 181 | border-bottom: solid 1px #DDDDDD; |
| 182 | +} |
| 183 | + |
| 184 | +/* Collapsing changes */ |
| 185 | + |
| 186 | +/* these first two should probably be conditionally applied */ |
| 187 | +/* suggestions for doing that welcome */ |
| 188 | +.wikiEditor-ui-toc ul { |
| 189 | + width:132px; |
| 190 | + float:left; |
| 191 | +} |
| 192 | +.wikiEditor-ui-toc ul ul { |
| 193 | + float:none; |
| 194 | + width:auto; |
| 195 | +} |
| 196 | +#wikiEditor-ui-toc-collapse { |
| 197 | + height:100%; |
| 198 | + width:18px; |
| 199 | + float:left; |
| 200 | +} |
| 201 | +.wikiEditor-ui-toc-collapse-open { |
| 202 | + background:#f3f3f3 url(../images/wikiEditor/toc/close.png) 4px 50% no-repeat; |
| 203 | + border-left:1px solid #DDDDDD; |
| 204 | +} |
| 205 | +.wikiEditor-ui-toc-collapse-closed { |
| 206 | + background:#f3f3f3 url(../images/wikiEditor/toc/open.png) 4px 50% no-repeat; |
182 | 207 | }/* wikiEditor toolbar module */ |
183 | 208 | |
184 | 209 | .wikiEditor-ui-toolbar { |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -166,6 +166,26 @@ |
167 | 167 | padding-bottom:0.5em; |
168 | 168 | border-bottom:solid 1px #DDDDDD; |
169 | 169 | } |
| 170 | +.wikiEditor-ui-toc ul{ |
| 171 | +width:132px; |
| 172 | +float:left; |
| 173 | +} |
| 174 | +.wikiEditor-ui-toc ul ul{ |
| 175 | +float:none; |
| 176 | +width:auto; |
| 177 | +} |
| 178 | +#wikiEditor-ui-toc-collapse{ |
| 179 | +height:100%; |
| 180 | +width:18px; |
| 181 | +float:left; |
| 182 | +} |
| 183 | +.wikiEditor-ui-toc-collapse-open{ |
| 184 | +background:#f3f3f3 url(../images/wikiEditor/toc/close.png) 4px 50% no-repeat; |
| 185 | +border-left:1px solid #DDDDDD; |
| 186 | +} |
| 187 | +.wikiEditor-ui-toc-collapse-closed{ |
| 188 | +background:#f3f3f3 url(../images/wikiEditor/toc/open.png) 4px 50% no-repeat; |
| 189 | +} |
170 | 190 | .wikiEditor-ui-toolbar{ |
171 | 191 | position:relative; |
172 | 192 | width:100%; |
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | $wgNavigableTOCUserEnable = true; |
29 | 29 | |
30 | 30 | // Bump the version number every time you change any of the .css/.js files |
31 | | -$wgNavigableTOCStyleVersion = 3; |
| 31 | +$wgNavigableTOCStyleVersion = 4; |
32 | 32 | |
33 | 33 | /* Setup */ |
34 | 34 | |
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | */ |
18 | 18 | public static function addTOC( &$toolbar ) { |
19 | 19 | global $wgNavigableTOCStyleVersion, $wgUser; |
20 | | - global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable; |
| 20 | + global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable, $wgNavigableTOCCollapseEnable; |
21 | 21 | |
22 | 22 | if ( $wgNavigableTOCGlobalEnable || ( $wgNavigableTOCUserEnable && $wgUser->getOption( 'usenavigabletoc' ) ) ) { |
23 | 23 | // Adds script to document |
— | — | @@ -24,6 +24,11 @@ |
25 | 25 | UsabilityInitiativeHooks::addScript( |
26 | 26 | 'NavigableTOC/NavigableTOC.js', $wgNavigableTOCStyleVersion |
27 | 27 | ); |
| 28 | + UsabilityInitiativeHooks::addVariables( |
| 29 | + array( |
| 30 | + 'wgNavigableTOCCollapseEnable' => $wgNavigableTOCCollapseEnable |
| 31 | + ) |
| 32 | + ); |
28 | 33 | } |
29 | 34 | return true; |
30 | 35 | } |
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -22,15 +22,15 @@ |
23 | 23 | array( 'src' => 'css/wikiEditor.css', 'version' => 4 ), |
24 | 24 | array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 7 ), |
25 | 25 | array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 2 ), |
26 | | - array( 'src' => 'css/wikiEditor.toc.css', 'version' => 6 ), |
| 26 | + array( 'src' => 'css/wikiEditor.toc.css', 'version' => 7 ), |
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' => 12 ), |
| 30 | + array( 'src' => 'css/combined.css', 'version' => 13 ), |
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' => 12 ), |
| 34 | + array( 'src' => 'css/combined.min.css', 'version' => 13 ), |
35 | 35 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ), |
36 | 36 | ), |
37 | 37 | ) |
— | — | @@ -72,13 +72,13 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 17 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 7 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 22 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 23 ), |
77 | 77 | ), |
78 | 78 | 'combined' => array( |
79 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 53 ), |
| 79 | + array( 'src' => 'js/plugins.combined.js', 'version' => 54 ), |
80 | 80 | ), |
81 | 81 | 'minified' => array( |
82 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 53 ), |
| 82 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 54 ), |
83 | 83 | ), |
84 | 84 | ), |
85 | 85 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -142,7 +142,7 @@ |
143 | 143 | $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]));}} |
144 | 144 | $.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));var $section=s.$sections.find('.section:visible');if($section.size()){$sections.animate({'height':$section.outerHeight()},$section.outerHeight()*2);}}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;} |
145 | 145 | context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');var height=context.$ui.find('.wikiEditor-ui-bottom').height() |
146 | | -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','marginTop':-(height)});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(250,'mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');context.$textarea.delayedBindCancel(250,'mouseup scrollToPosition focus keyup encapsulateSelection change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('div').removeClass('current');},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++;} |
| 146 | +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':$.wikiEditor.modules.toc.defaults.width,'marginTop':-(height)});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),$.wikiEditor.modules.toc.defaults.width);$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(250,'mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');context.$textarea.delayedBindCancel(250,'mouseup scrollToPosition focus keyup encapsulateSelection change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('div').removeClass('current');},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++;} |
147 | 147 | section=Math.max(0,section);} |
148 | 148 | var sectionLink=context.modules.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.$toc.offset().top;var scrollTop=context.modules.$toc.scrollTop();var divHeight=context.modules.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
149 | 149 | context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
— | — | @@ -153,6 +153,7 @@ |
154 | 154 | $.trackAction('ntoc.heading');event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
155 | 155 | list.append(item);} |
156 | 156 | return list;} |
| 157 | +function buildCollapseBar(){var $collapseBar=$('<div />').addClass('wikiEditor-ui-toc-collapse-open').attr('id','wikiEditor-ui-toc-collapse').data('oWidth',$.wikiEditor.modules.toc.defaults.width).bind('mouseup',function(){var $e=$(this);var close=$e.hasClass('wikiEditor-ui-toc-collapse-open');if(close){$e.parent().animate({'width':$e.outerWidth()},'fast',function(){$(this).find('ul:first').hide();}).prev().animate({'marginRight':$e.outerWidth()+1},'fast',function(){$('#wikiEditor-ui-toc-collapse').removeClass('wikiEditor-ui-toc-collapse-open').addClass('wikiEditor-ui-toc-collapse-closed');});}else{$e.siblings().show().parent().animate({'width':$e.data('oWidth')},'fast').prev().animate({'marginRight':$e.data('oWidth')},'fast',function(){$('#wikiEditor-ui-toc-collapse').removeClass('wikiEditor-ui-toc-collapse-closed').addClass('wikiEditor-ui-toc-collapse-open');});}});return $collapseBar;} |
157 | 158 | var outline=[];var wikitext=$.wikiEditor.fixOperaBrokenness(context.$textarea.val());var headings=wikitext.match(/^={1,6}[^=\n][^\n]*={1,6}\s*$/gm);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=$.trim(headings[h]);var position=wikitext.indexOf(text,offset);if(position>=offset){offset=position+text.length;}else if(position==-1){continue;} |
158 | 159 | var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}} |
159 | 160 | var endLevel=0;for(var c=text.length-1;c>=0;c--){if(text.charAt(c)=='='){endLevel++;}else{break;}} |
— | — | @@ -162,4 +163,4 @@ |
163 | 164 | if(nLevel<=0){nLevel=1;} |
164 | 165 | outline[i].nLevel=nLevel;lastLevel=outline[i].level;} |
165 | 166 | var structure=buildStructure(outline);if($('input[name=wpSection]').val()==''){structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'position':0});} |
166 | | -context.modules.$toc.html(buildList(structure));context.modules.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};})(jQuery); |
\ No newline at end of file |
| 167 | +context.modules.$toc.html(buildList(structure));if(wgNavigableTOCCollapseEnable)context.modules.$toc.append(buildCollapseBar());context.modules.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};$.wikiEditor.modules.toc.defaults={width:"13em"}})(jQuery); |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.tocCollapse.js |
— | — | @@ -1,92 +0,0 @@ |
2 | | -/* TOC Module for wikiEditor */ |
3 | | -( function( $ ) { $.wikiEditor.modules.tocCollapse = { |
4 | | - |
5 | | -/** |
6 | | - * API accessible functions |
7 | | - */ |
8 | | -api: { |
9 | | - // |
10 | | -}, |
11 | | -/** |
12 | | - * Internally used functions |
13 | | - */ |
14 | | -fn: { |
15 | | - /** |
16 | | - * Creates a table of contents module within a wikiEditor |
17 | | - * |
18 | | - * @param {Object} context Context object of editor to create module in |
19 | | - * @param {Object} config Configuration object to create module from |
20 | | - */ |
21 | | - create: function( context, config ) { |
22 | | - |
23 | | - context.$ui.find( '.wikiEditor-ui-bottom' ) |
24 | | - .append( context.modules.$toc ); |
25 | | - |
26 | | - if ( '$toc' in context.modules ) { |
27 | | - return; |
28 | | - } |
29 | | - context.modules.$tocCollapse = $( '<div />' ) |
30 | | - .addClass( 'wikiEditor-ui-toc' ) |
31 | | - .attr( 'id', 'wikiEditor-ui-toc' ); |
32 | | - // If we ask for this later (after we insert the TOC) then in IE this measurement will be incorrect |
33 | | - var height = context.$ui.find( '.wikiEditor-ui-bottom' ).height() |
34 | | - context.$ui.find( '.wikiEditor-ui-bottom' ) |
35 | | - .append( context.modules.$toc ); |
36 | | - context.modules.$toc.height( |
37 | | - context.$ui.find( '.wikiEditor-ui-bottom' ).height() |
38 | | - ); |
39 | | - // Make some css modifications to make room for the toc on the right... |
40 | | - // Perhaps this could be configurable? |
41 | | - context.modules.$toc.css( { 'width': $.wikiEditor.modules.toc.defaults.width, 'marginTop': -( height ) } ); |
42 | | - context.$ui.find( '.wikiEditor-ui-text' ) |
43 | | - .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), $.wikiEditor.modules.toc.defaults.width ); |
44 | | - // Add the TOC to the document |
45 | | - $.wikiEditor.modules.tocCollapse.fn.build( context, config ); |
46 | | - }, |
47 | | - |
48 | | - /** |
49 | | - * Builds table of contents |
50 | | - * |
51 | | - * @param {Object} context |
52 | | - */ |
53 | | - build: function( context ) { |
54 | | - function buildCollapseBar() { |
55 | | - var $collapseBar = $( '<div />' ) |
56 | | - .addClass( 'wikiEditor-ui-toc-collapse-open' ) |
57 | | - .attr( 'id', 'wikiEditor-ui-toc-colapse' ) |
58 | | - .data( 'oWidth', $.wikiEditor.modules.toc.defaults.width) |
59 | | - .bind('mouseup', function(){ |
60 | | - var $e = $(this); |
61 | | - var close = $e.hasClass('wikiEditor-ui-toc-collapse-open'); |
62 | | - if(close) { |
63 | | - $e.parent() |
64 | | - .animate( {'width': $e.outerWidth()}, 'fast', function() { |
65 | | - $(this).find('ul:first').hide(); |
66 | | - } ) |
67 | | - .prev() |
68 | | - .animate( {'marginRight': $e.outerWidth()}, 'fast', function(){ |
69 | | - $('#wikiEditor-ui-toc-colapse') |
70 | | - .removeClass('wikiEditor-ui-toc-collapse-open') |
71 | | - .addClass('wikiEditor-ui-toc-collapse-closed'); |
72 | | - }); |
73 | | - } else { |
74 | | - $e.siblings().show() |
75 | | - .parent() |
76 | | - .animate( {'width': $e.data('oWidth')}, 'fast' ) |
77 | | - .prev() |
78 | | - .animate( {'marginRight': $e.data('oWidth')}, 'fast', function(){ |
79 | | - $('#wikiEditor-ui-toc-colapse') |
80 | | - .removeClass('wikiEditor-ui-toc-collapse-closed') |
81 | | - .addClass('wikiEditor-ui-toc-collapse-open'); |
82 | | - }); |
83 | | - } |
84 | | - |
85 | | - }); |
86 | | - return $collapseBar; |
87 | | - |
88 | | - } |
89 | | - context.modules.$tocCollapse.html( buildCollapseBar() ); |
90 | | - } |
91 | | -} |
92 | | - |
93 | | -}; } ) ( jQuery ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -33,9 +33,9 @@ |
34 | 34 | ); |
35 | 35 | // Make some css modifications to make room for the toc on the right... |
36 | 36 | // Perhaps this could be configurable? |
37 | | - context.modules.$toc.css( { 'width': '12em', 'marginTop': -( height ) } ); |
| 37 | + context.modules.$toc.css( { 'width': $.wikiEditor.modules.toc.defaults.width, 'marginTop': -( height ) } ); |
38 | 38 | context.$ui.find( '.wikiEditor-ui-text' ) |
39 | | - .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), '12em' ); |
| 39 | + .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), $.wikiEditor.modules.toc.defaults.width ); |
40 | 40 | // Add the TOC to the document |
41 | 41 | $.wikiEditor.modules.toc.fn.build( context, config ); |
42 | 42 | context.$textarea |
— | — | @@ -161,6 +161,40 @@ |
162 | 162 | } |
163 | 163 | return list; |
164 | 164 | } |
| 165 | + function buildCollapseBar() { |
| 166 | + var $collapseBar = $( '<div />' ) |
| 167 | + .addClass( 'wikiEditor-ui-toc-collapse-open' ) |
| 168 | + .attr( 'id', 'wikiEditor-ui-toc-collapse' ) |
| 169 | + .data( 'oWidth', $.wikiEditor.modules.toc.defaults.width) |
| 170 | + .bind('mouseup', function(){ |
| 171 | + var $e = $(this); |
| 172 | + var close = $e.hasClass('wikiEditor-ui-toc-collapse-open'); |
| 173 | + if(close) { |
| 174 | + $e.parent() |
| 175 | + .animate( {'width': $e.outerWidth()}, 'fast', function() { |
| 176 | + $(this).find('ul:first').hide(); |
| 177 | + } ) |
| 178 | + .prev() |
| 179 | + .animate( {'marginRight': $e.outerWidth() + 1 }, 'fast', function(){ |
| 180 | + $('#wikiEditor-ui-toc-collapse') |
| 181 | + .removeClass('wikiEditor-ui-toc-collapse-open') |
| 182 | + .addClass('wikiEditor-ui-toc-collapse-closed'); |
| 183 | + }); |
| 184 | + } else { |
| 185 | + $e.siblings().show() |
| 186 | + .parent() |
| 187 | + .animate( {'width': $e.data('oWidth')}, 'fast' ) |
| 188 | + .prev() |
| 189 | + .animate( {'marginRight': $e.data('oWidth')}, 'fast', function(){ |
| 190 | + $('#wikiEditor-ui-toc-collapse') |
| 191 | + .removeClass('wikiEditor-ui-toc-collapse-closed') |
| 192 | + .addClass('wikiEditor-ui-toc-collapse-open'); |
| 193 | + }); |
| 194 | + } |
| 195 | + |
| 196 | + }); |
| 197 | + return $collapseBar; |
| 198 | + } |
165 | 199 | // Build outline from wikitext |
166 | 200 | var outline = []; |
167 | 201 | var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ); |
— | — | @@ -228,10 +262,15 @@ |
229 | 263 | structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } ); |
230 | 264 | } |
231 | 265 | context.modules.$toc.html( buildList( structure ) ); |
| 266 | + if(wgNavigableTOCCollapseEnable) context.modules.$toc.append( buildCollapseBar() ); |
232 | 267 | context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
233 | 268 | // Cache the outline for later use |
234 | 269 | context.data.outline = outline; |
235 | 270 | } |
236 | 271 | } |
237 | 272 | |
238 | | -}; } ) ( jQuery ); |
| 273 | +}; |
| 274 | +$.wikiEditor.modules.toc.defaults = { |
| 275 | + width: "13em" |
| 276 | +} |
| 277 | +} ) ( jQuery ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -2260,9 +2260,9 @@ |
2261 | 2261 | ); |
2262 | 2262 | // Make some css modifications to make room for the toc on the right... |
2263 | 2263 | // Perhaps this could be configurable? |
2264 | | - context.modules.$toc.css( { 'width': '12em', 'marginTop': -( height ) } ); |
| 2264 | + context.modules.$toc.css( { 'width': $.wikiEditor.modules.toc.defaults.width, 'marginTop': -( height ) } ); |
2265 | 2265 | context.$ui.find( '.wikiEditor-ui-text' ) |
2266 | | - .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), '12em' ); |
| 2266 | + .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), $.wikiEditor.modules.toc.defaults.width ); |
2267 | 2267 | // Add the TOC to the document |
2268 | 2268 | $.wikiEditor.modules.toc.fn.build( context, config ); |
2269 | 2269 | context.$textarea |
— | — | @@ -2388,6 +2388,40 @@ |
2389 | 2389 | } |
2390 | 2390 | return list; |
2391 | 2391 | } |
| 2392 | + function buildCollapseBar() { |
| 2393 | + var $collapseBar = $( '<div />' ) |
| 2394 | + .addClass( 'wikiEditor-ui-toc-collapse-open' ) |
| 2395 | + .attr( 'id', 'wikiEditor-ui-toc-collapse' ) |
| 2396 | + .data( 'oWidth', $.wikiEditor.modules.toc.defaults.width) |
| 2397 | + .bind('mouseup', function(){ |
| 2398 | + var $e = $(this); |
| 2399 | + var close = $e.hasClass('wikiEditor-ui-toc-collapse-open'); |
| 2400 | + if(close) { |
| 2401 | + $e.parent() |
| 2402 | + .animate( {'width': $e.outerWidth()}, 'fast', function() { |
| 2403 | + $(this).find('ul:first').hide(); |
| 2404 | + } ) |
| 2405 | + .prev() |
| 2406 | + .animate( {'marginRight': $e.outerWidth()+1}, 'fast', function(){ |
| 2407 | + $('#wikiEditor-ui-toc-collapse') |
| 2408 | + .removeClass('wikiEditor-ui-toc-collapse-open') |
| 2409 | + .addClass('wikiEditor-ui-toc-collapse-closed'); |
| 2410 | + }); |
| 2411 | + } else { |
| 2412 | + $e.siblings().show() |
| 2413 | + .parent() |
| 2414 | + .animate( {'width': $e.data('oWidth')}, 'fast' ) |
| 2415 | + .prev() |
| 2416 | + .animate( {'marginRight': $e.data('oWidth')}, 'fast', function(){ |
| 2417 | + $('#wikiEditor-ui-toc-collapse') |
| 2418 | + .removeClass('wikiEditor-ui-toc-collapse-closed') |
| 2419 | + .addClass('wikiEditor-ui-toc-collapse-open'); |
| 2420 | + }); |
| 2421 | + } |
| 2422 | + |
| 2423 | + }); |
| 2424 | + return $collapseBar; |
| 2425 | + } |
2392 | 2426 | // Build outline from wikitext |
2393 | 2427 | var outline = []; |
2394 | 2428 | var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() ); |
— | — | @@ -2455,10 +2489,15 @@ |
2456 | 2490 | structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } ); |
2457 | 2491 | } |
2458 | 2492 | context.modules.$toc.html( buildList( structure ) ); |
| 2493 | + if(wgNavigableTOCCollapseEnable) context.modules.$toc.append( buildCollapseBar() ); |
2459 | 2494 | context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } ); |
2460 | 2495 | // Cache the outline for later use |
2461 | 2496 | context.data.outline = outline; |
2462 | 2497 | } |
2463 | 2498 | } |
2464 | 2499 | |
2465 | | -}; } ) ( jQuery ); |
| 2500 | +}; |
| 2501 | +$.wikiEditor.modules.toc.defaults = { |
| 2502 | + width: "13em" |
| 2503 | +} |
| 2504 | +} ) ( jQuery ); |