r58321 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58320‎ | r58321 | r58322 >
Date:16:06, 29 October 2009
Author:adam
Status:deferred
Tags:
Comment:
Moving collapsing TOC into the main TOC plugin and making it an optional setting
Modified paths:
  • /trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.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/css/wikiEditor.toc.css (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.toc.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.tocCollapse.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.toc.css
@@ -73,4 +73,29 @@
7474 padding-top: 0.5em;
7575 padding-bottom: 0.5em;
7676 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;
77102 }
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -178,6 +178,31 @@
179179 padding-top: 0.5em;
180180 padding-bottom: 0.5em;
181181 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;
182207 }/* wikiEditor toolbar module */
183208
184209 .wikiEditor-ui-toolbar {
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -166,6 +166,26 @@
167167 padding-bottom:0.5em;
168168 border-bottom:solid 1px #DDDDDD;
169169 }
 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+}
170190 .wikiEditor-ui-toolbar{
171191 position:relative;
172192 width:100%;
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.php
@@ -27,7 +27,7 @@
2828 $wgNavigableTOCUserEnable = true;
2929
3030 // Bump the version number every time you change any of the .css/.js files
31 -$wgNavigableTOCStyleVersion = 3;
 31+$wgNavigableTOCStyleVersion = 4;
3232
3333 /* Setup */
3434
Index: trunk/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php
@@ -16,7 +16,7 @@
1717 */
1818 public static function addTOC( &$toolbar ) {
1919 global $wgNavigableTOCStyleVersion, $wgUser;
20 - global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable;
 20+ global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable, $wgNavigableTOCCollapseEnable;
2121
2222 if ( $wgNavigableTOCGlobalEnable || ( $wgNavigableTOCUserEnable && $wgUser->getOption( 'usenavigabletoc' ) ) ) {
2323 // Adds script to document
@@ -24,6 +24,11 @@
2525 UsabilityInitiativeHooks::addScript(
2626 'NavigableTOC/NavigableTOC.js', $wgNavigableTOCStyleVersion
2727 );
 28+ UsabilityInitiativeHooks::addVariables(
 29+ array(
 30+ 'wgNavigableTOCCollapseEnable' => $wgNavigableTOCCollapseEnable
 31+ )
 32+ );
2833 }
2934 return true;
3035 }
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -22,15 +22,15 @@
2323 array( 'src' => 'css/wikiEditor.css', 'version' => 4 ),
2424 array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 7 ),
2525 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 ),
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' => 12 ),
 30+ array( 'src' => 'css/combined.css', 'version' => 13 ),
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' => 12 ),
 34+ array( 'src' => 'css/combined.min.css', 'version' => 13 ),
3535 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2' ),
3636 ),
3737 )
@@ -72,13 +72,13 @@
7373 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 12 ),
7474 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 17 ),
7575 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 ),
7777 ),
7878 'combined' => array(
79 - array( 'src' => 'js/plugins.combined.js', 'version' => 53 ),
 79+ array( 'src' => 'js/plugins.combined.js', 'version' => 54 ),
8080 ),
8181 'minified' => array(
82 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 53 ),
 82+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 54 ),
8383 ),
8484 ),
8585 );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -142,7 +142,7 @@
143143 $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]));}}
144144 $.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;}
145145 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++;}
147147 section=Math.max(0,section);}
148148 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)
149149 context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight)
@@ -153,6 +153,7 @@
154154 $.trackAction('ntoc.heading');event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));}
155155 list.append(item);}
156156 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;}
157158 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;}
158159 var startLevel=0;for(var c=0;c<text.length;c++){if(text.charAt(c)=='='){startLevel++;}else{break;}}
159160 var endLevel=0;for(var c=text.length-1;c>=0;c--){if(text.charAt(c)=='='){endLevel++;}else{break;}}
@@ -162,4 +163,4 @@
163164 if(nLevel<=0){nLevel=1;}
164165 outline[i].nLevel=nLevel;lastLevel=outline[i].level;}
165166 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 @@
3434 );
3535 // Make some css modifications to make room for the toc on the right...
3636 // 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 ) } );
3838 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 );
4040 // Add the TOC to the document
4141 $.wikiEditor.modules.toc.fn.build( context, config );
4242 context.$textarea
@@ -161,6 +161,40 @@
162162 }
163163 return list;
164164 }
 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+ }
165199 // Build outline from wikitext
166200 var outline = [];
167201 var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() );
@@ -228,10 +262,15 @@
229263 structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } );
230264 }
231265 context.modules.$toc.html( buildList( structure ) );
 266+ if(wgNavigableTOCCollapseEnable) context.modules.$toc.append( buildCollapseBar() );
232267 context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } );
233268 // Cache the outline for later use
234269 context.data.outline = outline;
235270 }
236271 }
237272
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 @@
22612261 );
22622262 // Make some css modifications to make room for the toc on the right...
22632263 // 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 ) } );
22652265 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 );
22672267 // Add the TOC to the document
22682268 $.wikiEditor.modules.toc.fn.build( context, config );
22692269 context.$textarea
@@ -2388,6 +2388,40 @@
23892389 }
23902390 return list;
23912391 }
 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+ }
23922426 // Build outline from wikitext
23932427 var outline = [];
23942428 var wikitext = $.wikiEditor.fixOperaBrokenness( context.$textarea.val() );
@@ -2455,10 +2489,15 @@
24562490 structure.unshift( { 'text': wgPageName.replace(/_/g, ' '), 'level': 1, 'index': 0, 'position': 0 } );
24572491 }
24582492 context.modules.$toc.html( buildList( structure ) );
 2493+ if(wgNavigableTOCCollapseEnable) context.modules.$toc.append( buildCollapseBar() );
24592494 context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } );
24602495 // Cache the outline for later use
24612496 context.data.outline = outline;
24622497 }
24632498 }
24642499
2465 -}; } ) ( jQuery );
 2500+};
 2501+$.wikiEditor.modules.toc.defaults = {
 2502+ width: "13em"
 2503+}
 2504+} ) ( jQuery );

Follow-up revisions

RevisionCommit summaryAuthorDate
r58343NavigableTOC: Add $wgNavigableTOCCollapseEnable (introduced in r58321) to Nav...catrope21:59, 29 October 2009

Status & tagging log