r58981 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58980‎ | r58981 | r58982 >
Date:22:38, 12 November 2009
Author:catrope
Status:deferred
Tags:
Comment:
NavigableTOC: Fix up the TOC collapse/resize code big time so it hurts my eyes less and somewhat works again; it's still broken in various ways. Also added some FIXMEs
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toc/Toc.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.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.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.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -19,7 +19,7 @@
2020 'base_sets' => array(
2121 'raw' => array(
2222 array( 'src' => 'css/suggestions.css', 'version' => 6 ),
23 - array( 'src' => 'css/wikiEditor.css', 'version' => 5 ),
 23+ array( 'src' => 'css/wikiEditor.css', 'version' => 6 ),
2424 array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 7 ),
2525 array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 2 ),
2626 array( 'src' => 'css/wikiEditor.toc.css', 'version' => 16 ),
@@ -27,11 +27,11 @@
2828 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ),
2929 ),
3030 'combined' => array(
31 - array( 'src' => 'css/combined.css', 'version' => 23 ),
 31+ array( 'src' => 'css/combined.css', 'version' => 24 ),
3232 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ),
3333 ),
3434 'minified' => array(
35 - array( 'src' => 'css/combined.min.css', 'version' => 23 ),
 35+ array( 'src' => 'css/combined.min.css', 'version' => 24 ),
3636 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ),
3737 ),
3838 )
@@ -70,17 +70,17 @@
7171 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ),
7272 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ),
7373 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 20 ),
74 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 15 ),
75 - array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 27 ),
 74+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 16 ),
 75+ array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 28 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 9 ),
77 - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 35 ),
 77+ array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 36 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 3 ),
7979 ),
8080 'combined' => array(
81 - array( 'src' => 'js/plugins.combined.js', 'version' => 75 ),
 81+ array( 'src' => 'js/plugins.combined.js', 'version' => 76 ),
8282 ),
8383 'minified' => array(
84 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 75 ),
 84+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 76 ),
8585 ),
8686 ),
8787 );
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.css
@@ -52,10 +52,12 @@
5353 float: left;
5454 width: 100%;
5555 }
 56+/*
5657 .wikiEditor-tabs {
5758 float: left;
5859 width: 50%;
5960 }
 61+*/
6062 .wikiEditor-buttons {
6163 float: right;
6264 width: 50%;
Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -102,10 +102,12 @@
103103 float: left;
104104 width: 100%;
105105 }
 106+/*
106107 .wikiEditor-tabs {
107108 float: left;
108109 width: 50%;
109110 }
 111+*/
110112 .wikiEditor-buttons {
111113 float: right;
112114 width: 50%;
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -95,10 +95,12 @@
9696 float:left;
9797 width:100%;
9898 }
 99+/*
99100 .wikiEditor-tabs{
100101 float:left;
101102 width:50%;
102103 }
 104+*/
103105 .wikiEditor-buttons{
104106 float:right;
105107 width:50%;
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php
@@ -82,6 +82,10 @@
8383 'wgNavigableTOCCollapseEnable',
8484 'wgNavigableTOCResizable'
8585 ),
 86+ 'messages' => array(
 87+ 'wikieditor-toc-show',
 88+ 'wikieditor-toc-hide',
 89+ ),
8690 ),
8791 'toolbar' => array(
8892 'i18n' => 'WikiEditorToolbar',
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Toc/Toc.i18n.php
@@ -13,6 +13,8 @@
1414 */
1515 $messages['en'] = array(
1616 'wikieditor-toc-preference' => 'Enable navigable table of contents',
 17+ 'wikieditor-toc-show' => 'Show contents',
 18+ 'wikieditor-toc-hide' => 'Hide contents',
1719 );
1820
1921 /** Message documentation (Message documentation)
@@ -21,6 +23,8 @@
2224 */
2325 $messages['qqq'] = array(
2426 'wikieditor-toc-preference' => "Option at [[Special:Preferences]], tab ''{{int:prefs-editing}}''",
 27+ 'wikieditor-toc-show' => 'Label of the show/hide link when the navigable table of contents is hidden',
 28+ 'wikieditor-toc-hide' => 'Label of the show/hide link when the navigable table of contents is visible',
2529 );
2630
2731 /** Arabic (العربية)
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -357,11 +357,14 @@
358358 // Insert the contents one line at a time
359359 // insertNode() inserts at the beginning, so this has
360360 // to happen in reverse order
 361+ var lastNode;
361362 for ( var i = insertLines.length - 1; i >= 0; i-- ) {
362363 range.insertNode( document.createTextNode( insertLines[i] ) );
363364 if ( i > 0 )
364 - range.insertNode( document.createElement( 'br' ) );
 365+ lastNode = range.insertNode( document.createElement( 'br' ) );
365366 }
 367+ if ( lastNode )
 368+ context.fn.scrollToTop( lastNode );
366369
367370 // ...
368371 // Scroll the textarea to the inserted text
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -563,27 +563,31 @@
564564 build : function( context, config ) {
565565 var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.$toolbar );
566566 if( wgNavigableTOCCollapseEnable ) {
 567+ // FIXME: This code is duplicated from the TOC plugin and doesn't belong here;
 568+ // the TOC drag thingy should be in the TOC plugin instead
567569 // placeholder for drag control creation code
 570+ /*
568571 $dragControl = $( '<div />' ).addClass( 'tab' ).attr( 'id', 'wikiEditor-ui-toc-resize-grip' )
569572 .append( '<a href="#" title="Drag to resize"></a>' )
570573 .bind( 'mousedown', function() {
571574 $( '#wikiEditor-ui-toc' )
572575 .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() );
573576 $()
574 - .bind( 'mousemove', {'context': context}, $.wikiEditor.modules.toc.fn.drag )
575 - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag );
 577+ .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag )
 578+ .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag );
576579 $(context.$iframe[0].contentWindow.document)
577 - .bind( 'mousemove', {'context': context}, function( e ){
 580+ .bind( 'mousemove', function() {
578581 parent.top.$j().trigger("mousemove", e.pageX);
579 - return false;
 582+ return false;
580583 } )
581 - .bind( 'mouseup', {'context': context}, function( e ){
 584+ .bind( 'mouseup', function() {
582585 parent.top.$j().trigger("mouseup");
583 - return false;
 586+ return false;
584587 });
585588 return false;
586589 })
587590 context.modules.$toolbar.append( $dragControl );
 591+ */
588592 }
589593 var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.$toolbar );
590594 context.modules.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -25,7 +25,7 @@
2626 if ( '$toc' in context.modules ) {
2727 return;
2828 }
29 - /*
 29+
3030 context.initialWidth = $.wikiEditor.modules.toc.defaultWidth;
3131 if( wgNavigableTOCResizable ) {
3232 if( !$.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) ) {
@@ -37,7 +37,7 @@
3838 context.initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' );
3939 }
4040 }
41 - */
 41+
4242 var height = context.$ui.find( '.wikiEditor-ui-left' ).height();
4343 context.modules.$toc = $( '<div />' )
4444 .addClass( 'wikiEditor-ui-toc' )
@@ -49,9 +49,9 @@
5050 context.$ui.find( '.wikiEditor-ui-left' ).height()
5151 );
5252 context.$ui.find( '.wikiEditor-ui-left' )
53 - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth)
 53+ .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth )
5454 .children()
55 - .css('marginRight', $.wikiEditor.modules.toc.defaultWidth );
 55+ .css( 'marginRight', $.wikiEditor.modules.toc.defaultWidth );
5656
5757 // Add the TOC to the document
5858 $.wikiEditor.modules.toc.fn.build( context, config );
@@ -121,46 +121,50 @@
122122 /**
123123 * Collapse the contents module
124124 *
125 - * @param {Object} context
 125+ * @param {Object} event Event object with context as data
126126 */
127 - collapse: function( context ) {
128 - var $toc = $( '#wikiEditor-ui-toc' );
129 - if( !$toc.data( 'openWidth' ) ) {
 127+ collapse: function( event ) {
 128+ var context = event.data;
 129+ var $toc = context.modules.$toc;
 130+ if( !$toc.data( 'openWidth' ) ) {
130131 $toc.data( 'openWidth', $toc.width() );
131132 }
132 - var $toolbar = $( '#wikiEditor-ui-toolbar .tab-toc' )
 133+ context.$ui.find( '.tab-toc' )
133134 .unbind( 'click', $.wikiEditor.modules.toc.fn.collapse )
134 - .bind( 'click', $.wikiEditor.modules.toc.fn.expand )
 135+ .bind( 'click', context, $.wikiEditor.modules.toc.fn.expand )
135136 .children( 'a' )
136 - .text( 'Show Contents' );
 137+ .text( gM( 'wikieditor-toc-show' ) );
137138
138139 $toc
139 - .animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } )
140 - .prev()
141 - .animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } );
142 - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', '1px' );
 140+ //.animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } )
 141+ .animate( { 'width': 1 }, 'fast' );
 142+ //.prev()
 143+ //.animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } );
 144+ $.cookie( 'wikiEditor-' + context.instance + '-toc-width', 1 );
143145 return false;
144146 },
145147
146148 /**
147149 * Expand the contents module
148150 *
149 - * @param {Object} context
 151+ * @param {Object} event Event object with context as data
150152 */
151 - expand: function( context ) {
152 - $( '#wikiEditor-ui-toolbar .tab-toc' )
 153+ expand: function( event) {
 154+ var context = event.data;
 155+ context.$ui.find( '.tab-toc' )
153156 .unbind( 'click', $.wikiEditor.modules.toc.fn.expand )
154 - .bind( 'click', $.wikiEditor.modules.toc.fn.collapse )
 157+ .bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse )
155158 .children( 'a' )
156 - .text( 'Hide Contents' );
157 - $( '#wikiEditor-ui-toc' )
 159+ .text( gM( 'wikieditor-toc-hide' ) );
 160+ context.modules.$toc
158161 .show()
159 - .animate( { 'width': $( '#wikiEditor-ui-toc' ).data( 'openWidth' )}, 'fast', function() {
160 - $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' );
161 - } )
162 - .prev()
163 - .animate( { 'marginRight': $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) }, 'fast' );
164 - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) );
 162+ .animate( { 'width': context.modules.$toc.data( 'openWidth' ) }, 'fast' );
 163+ //.animate( { 'width': context.modules.$toc.data( 'openWidth' )}, 'fast', function() {
 164+ // $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' );
 165+ //} )
 166+ //.prev()
 167+ //.animate( { 'marginRight': context.modules.$toc.data( 'openWidth' ) }, 'fast' );
 168+ $.cookie( 'wikiEditor-' + context.instance + '-toc-width', context.modules.$toc.data( 'openWidth' ) );
165169 return false;
166170 },
167171 /**
@@ -169,13 +173,22 @@
170174 * @param {object} e
171175 */
172176 drag: function( e, pageX ) {
173 - var mR = pageX ? pageX :
174 - (e.pageX - e.data.context.$ui.find( '.wikiEditor-ui-left' ).offset().left);
175 - mR = e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - mR;
176 - if( mR < 26 || mR > e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - 250) return false;
177 - e.data.context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', "-"+mR+'px' )
178 - .children().css('marginRight', mR+'px');
179 - e.data.context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR+'px' );
 177+ var context = e.data;
 178+ var mR;
 179+ // This used to be done with a ternary expression, but for some reason that
 180+ // returned NaN in some cases. Even this seems to be buggy in that .offset().left
 181+ // is sometimes 0.
 182+ // FIXME: We should ditch the whole thing and use jQuery UI Resizable if possible
 183+ if ( pageX )
 184+ mR = pageX;
 185+ else
 186+ mR = e.pageX - context.$ui.find( '.wikiEditor.ui-left' ).offset().left;
 187+ mR = context.$ui.find( '.wikiEditor-ui-left' ).width() - mR;
 188+ if( mR < 26 || mR > context.$ui.find( '.wikiEditor-ui-left' ).width() - 250)
 189+ return false;
 190+ context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', -mR )
 191+ .children().css('marginRight', mR);
 192+ context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR );
180193 return false;
181194 },
182195 /**
@@ -184,19 +197,21 @@
185198 * @param {object} e
186199 */
187200 stopDrag: function( e ) {
 201+ var context = e.data;
188202 $()
189203 .unbind( 'mousemove', $.wikiEditor.modules.toc.fn.drag )
190204 .unbind( 'mouseup', $.wikiEditor.modules.toc.fn.stopDrag );
191 - $(e.data.context.$iframe[0].contentWindow.document)
 205+ $(context.$iframe[0].contentWindow.document)
192206 .unbind( 'mousemove' )
193207 .unbind( 'mouseup' );
194 - if( $( '#wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) {
195 - $.wikiEditor.modules.toc.fn.collapse( e.data.context );
 208+ if( context.$ui.find( '.wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) {
 209+ $.wikiEditor.modules.toc.fn.collapse( { data: context } );
196210 } else {
197 - $( '#wikiEditor-ui-left' ).trigger( 'mouseup' );
198 - $( '#wikiEditor-ui-right' )
199 - .data( 'openWidth', $( '#wikiEditor-ui-right' ).width() + 'px' );
200 - $.cookie( 'wikiEditor-' + e.data.context.instance + '-toc-width', $( '#wikiEditor-ui-right' ).width() + 'px' );
 211+ context.$ui.find( '.wikiEditor-ui-left' ).trigger( 'mouseup' );
 212+ context.$ui.find( '.wikiEditor-ui-right' )
 213+ .data( 'openWidth', context.$ui.find( '.wikiEditor-ui-right' ).width() );
 214+ $.cookie( 'wikiEditor-' + context.instance + '-toc-width',
 215+ context.$ui.find( '.wikiEditor-ui-right' ).width() );
201216 }
202217 return false;
203218 },
@@ -258,17 +273,18 @@
259274 return list;
260275 }
261276 function buildCollapseBar() {
262 - $( '.wikiEditor-ui-toc ul:first' ).css( 'width', '147px' )
 277+ // FIXME: Move this to a .css file
 278+ context.modules.$toc.find( 'ul:first' ).css( 'width', '147px' )
263279 .css( 'margin-left', '19px' ).css( 'border-left', '1px solid #DDDDDD' );
264280 var $collapseBar = $( '<div />' )
265281 .addClass( 'wikiEditor-ui-toc-collapse-open' )
266282 .attr( 'id', 'wikiEditor-ui-toc-collapse' )
267 - .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth)
 283+ .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth )
268284 .bind( 'mouseup', function() {
269285 var $e = $(this);
270286 var close = $e.hasClass( 'wikiEditor-ui-toc-collapse-open' );
271287 if( close ) {
272 - $( '#wikiEditor-ui-toc-collapse' )
 288+ $e
273289 .removeClass( 'wikiEditor-ui-toc-collapse-open' );
274290 $e.parent()
275291 .animate( { 'width': $e.outerWidth() }, 'fast', function() {
@@ -276,65 +292,63 @@
277293 } )
278294 .prev()
279295 .animate( { 'marginRight': $e.outerWidth() + 1 }, 'fast', function() {
280 - $( '#wikiEditor-ui-toc-collapse' )
 296+ $e
281297 .addClass( 'wikiEditor-ui-toc-collapse-closed' );
282298 });
283299 } else {
284 - $( '#wikiEditor-ui-toc-collapse' )
 300+ $e
285301 .removeClass( 'wikiEditor-ui-toc-collapse-closed' );
286302 $e.siblings().show()
287303 .parent()
288304 .animate( { 'width': $e.data( 'openWidth' ) }, 'fast' )
289305 .prev()
290306 .animate( { 'marginRight': $e.data( 'openWidth' ) }, 'fast', function() {
291 - $( '#wikiEditor-ui-toc-collapse' )
 307+ $e
292308 .addClass( 'wikiEditor-ui-toc-collapse-open' );
293309 });
294310 }
295311
296312 });
297 - return $collapseBar;
 313+ return $collapseBar;
298314 }
299315 function buildResizeControls() {
300316 var $resizeControlVertical = $( '<div />' )
301317 .attr( 'id', 'wikiEditor-ui-toc-resize-vertical')
302318 .bind( 'mousedown', function() {
303 - $( '#wikiEditor-ui-toc' )
304 - .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() );
 319+ context.modules.$toc
 320+ .data( 'openWidth', context.modules.$toc.width() );
305321 $()
306 - .bind( 'mousemove', { 'context': context }, $.wikiEditor.modules.toc.fn.drag )
307 - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag );
 322+ .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag )
 323+ .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag );
308324 $(context.$iframe[0].contentWindow.document)
309 - .bind( 'mousemove', {'context': context}, function( e ){
310 - parent.top.$j().trigger("mousemove", e.pageX);
 325+ .bind( 'mousemove', function( e ) {
 326+ parent.top.$j().trigger("mousemove", e.pageX);
311327 return false;
312328 } )
313 - .bind( 'mouseup', {'context': context}, function( e ){
314 - parent.top.$j().trigger("mouseup");
315 - return false;
 329+ .bind( 'mouseup', function() {
 330+ parent.top.$j().trigger("mouseup");
 331+ return false;
316332 });
317333 return false;
318334 });
319335
320336 var $collapseControl = $( '<div />' ).addClass( 'tab' ).addClass( 'tab-toc' )
321 - .append( '<a href="#"></a>' );
322 - if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != '1px' ) {
323 - $collapseControl.bind( 'click', function() {
324 - $.wikiEditor.modules.toc.fn.collapse( context );
325 - } )
326 - .find( 'a' ).text( 'Hide Contents' );
327 - } else {
328 - $collapseControl.bind( 'click', function() {
329 - $.wikiEditor.modules.toc.fn.expand( context );
330 - } )
331 - .find( 'a' ).text( 'Show Contents' );
 337+ .append( '<a href="#" />' );
 338+ if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != 1 ) {
 339+ $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse )
 340+ .find( 'a' ).text( gM( 'wikieditor-toc-hide' ) );
 341+ } else {
 342+ $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.expand )
 343+ .find( 'a' ).text( gM( 'wikieditor-toc-show' ) );
332344 }
333345 $collapseControl.insertBefore( context.modules.$toc );
334346
335 - if( !$( '#wikiEditor-ui-toc' ).data( 'openWidth' ) ) {
336 - $( '#wikiEditor-ui-toc' ).data( 'openWidth', context.initialWidth == '1px' ?
 347+ if( !context.modules.$toc.data( 'openWidth' ) ) {
 348+ context.modules.$toc.data( 'openWidth', context.initialWidth == 1 ?
337349 $.wikiEditor.modules.toc.defaultWidth : context.initialWidth );
338350 }
 351+ if ( context.initialWidth == 1 )
 352+ $.wikiEditor.modules.toc.fn.collapse( { data: context } );
339353 return $resizeControlVertical;
340354 }
341355
@@ -400,7 +414,7 @@
401415
402416 if(wgNavigableTOCResizable) {
403417 context.modules.$toc.append( buildResizeControls() );
404 - }else if(wgNavigableTOCCollapseEnable){
 418+ } else if(wgNavigableTOCCollapseEnable) {
405419 context.modules.$toc.append( buildCollapseBar() );
406420 }
407421 context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1655,11 +1655,14 @@
16561656 // Insert the contents one line at a time
16571657 // insertNode() inserts at the beginning, so this has
16581658 // to happen in reverse order
 1659+ var lastNode;
16591660 for ( var i = insertLines.length - 1; i >= 0; i-- ) {
16601661 range.insertNode( document.createTextNode( insertLines[i] ) );
16611662 if ( i > 0 )
1662 - range.insertNode( document.createElement( 'br' ) );
 1663+ lastNode = range.insertNode( document.createElement( 'br' ) );
16631664 }
 1665+ if ( lastNode )
 1666+ context.fn.scrollToTop( lastNode );
16641667
16651668 // ...
16661669 // Scroll the textarea to the inserted text
@@ -2472,27 +2475,31 @@
24732476 build : function( context, config ) {
24742477 var $tabs = $( '<div />' ).addClass( 'tabs' ).appendTo( context.modules.$toolbar );
24752478 if( wgNavigableTOCCollapseEnable ) {
 2479+ // FIXME: This code is duplicated from the TOC plugin and doesn't belong here;
 2480+ // the TOC drag thingy should be in the TOC plugin instead
24762481 // placeholder for drag control creation code
 2482+ /*
24772483 $dragControl = $( '<div />' ).addClass( 'tab' ).attr( 'id', 'wikiEditor-ui-toc-resize-grip' )
24782484 .append( '<a href="#" title="Drag to resize"></a>' )
24792485 .bind( 'mousedown', function() {
24802486 $( '#wikiEditor-ui-toc' )
24812487 .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() );
24822488 $()
2483 - .bind( 'mousemove', {'context': context}, $.wikiEditor.modules.toc.fn.drag )
2484 - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag );
 2489+ .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag )
 2490+ .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag );
24852491 $(context.$iframe[0].contentWindow.document)
2486 - .bind( 'mousemove', {'context': context}, function( e ){
 2492+ .bind( 'mousemove', function() {
24872493 parent.top.$j().trigger("mousemove", e.pageX);
2488 - return false;
 2494+ return false;
24892495 } )
2490 - .bind( 'mouseup', {'context': context}, function( e ){
 2496+ .bind( 'mouseup', function() {
24912497 parent.top.$j().trigger("mouseup");
2492 - return false;
 2498+ return false;
24932499 });
24942500 return false;
24952501 })
24962502 context.modules.$toolbar.append( $dragControl );
 2503+ */
24972504 }
24982505 var $sections = $( '<div />' ).addClass( 'sections' ).appendTo( context.modules.$toolbar );
24992506 context.modules.$toolbar.append( $( '<div />' ).css( 'clear', 'both' ) );
@@ -2560,7 +2567,7 @@
25612568 if ( '$toc' in context.modules ) {
25622569 return;
25632570 }
2564 - /*
 2571+
25652572 context.initialWidth = $.wikiEditor.modules.toc.defaultWidth;
25662573 if( wgNavigableTOCResizable ) {
25672574 if( !$.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) ) {
@@ -2572,7 +2579,7 @@
25732580 context.initialWidth = $.cookie( 'wikiEditor-' + context.instance + '-toc-width' );
25742581 }
25752582 }
2576 - */
 2583+
25772584 var height = context.$ui.find( '.wikiEditor-ui-left' ).height();
25782585 context.modules.$toc = $( '<div />' )
25792586 .addClass( 'wikiEditor-ui-toc' )
@@ -2584,9 +2591,9 @@
25852592 context.$ui.find( '.wikiEditor-ui-left' ).height()
25862593 );
25872594 context.$ui.find( '.wikiEditor-ui-left' )
2588 - .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth)
 2595+ .css( 'marginRight', "-" + $.wikiEditor.modules.toc.defaultWidth )
25892596 .children()
2590 - .css('marginRight', $.wikiEditor.modules.toc.defaultWidth );
 2597+ .css( 'marginRight', $.wikiEditor.modules.toc.defaultWidth );
25912598
25922599 // Add the TOC to the document
25932600 $.wikiEditor.modules.toc.fn.build( context, config );
@@ -2656,46 +2663,50 @@
26572664 /**
26582665 * Collapse the contents module
26592666 *
2660 - * @param {Object} context
 2667+ * @param {Object} event Event object with context as data
26612668 */
2662 - collapse: function( context ) {
2663 - var $toc = $( '#wikiEditor-ui-toc' );
2664 - if( !$toc.data( 'openWidth' ) ) {
 2669+ collapse: function( event ) {
 2670+ var context = event.data;
 2671+ var $toc = context.modules.$toc;
 2672+ if( !$toc.data( 'openWidth' ) ) {
26652673 $toc.data( 'openWidth', $toc.width() );
26662674 }
2667 - var $toolbar = $( '#wikiEditor-ui-toolbar .tab-toc' )
 2675+ context.$ui.find( '.tab-toc' )
26682676 .unbind( 'click', $.wikiEditor.modules.toc.fn.collapse )
2669 - .bind( 'click', $.wikiEditor.modules.toc.fn.expand )
 2677+ .bind( 'click', context, $.wikiEditor.modules.toc.fn.expand )
26702678 .children( 'a' )
2671 - .text( 'Show Contents' );
 2679+ .text( gM( 'wikieditor-toc-show' ) );
26722680
26732681 $toc
2674 - .animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } )
2675 - .prev()
2676 - .animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } );
2677 - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', '1px' );
 2682+ //.animate( { 'width': '1px' }, 'fast', function() { $(this).hide(); } )
 2683+ .animate( { 'width': 1 }, 'fast' );
 2684+ //.prev()
 2685+ //.animate( {'marginRight': '1px'}, 'fast', function() { $(this).css('marginRight', '-1px'); } );
 2686+ $.cookie( 'wikiEditor-' + context.instance + '-toc-width', 1 );
26782687 return false;
26792688 },
26802689
26812690 /**
26822691 * Expand the contents module
26832692 *
2684 - * @param {Object} context
 2693+ * @param {Object} event Event object with context as data
26852694 */
2686 - expand: function( context ) {
2687 - $( '#wikiEditor-ui-toolbar .tab-toc' )
 2695+ expand: function( event) {
 2696+ var context = event.data;
 2697+ context.$ui.find( '.tab-toc' )
26882698 .unbind( 'click', $.wikiEditor.modules.toc.fn.expand )
2689 - .bind( 'click', $.wikiEditor.modules.toc.fn.collapse )
 2699+ .bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse )
26902700 .children( 'a' )
2691 - .text( 'Hide Contents' );
2692 - $( '#wikiEditor-ui-toc' )
 2701+ .text( gM( 'wikieditor-toc-hide' ) );
 2702+ context.modules.$toc
26932703 .show()
2694 - .animate( { 'width': $( '#wikiEditor-ui-toc' ).data( 'openWidth' )}, 'fast', function() {
2695 - $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' );
2696 - } )
2697 - .prev()
2698 - .animate( { 'marginRight': $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) }, 'fast' );
2699 - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', $( '#wikiEditor-ui-toc' ).data( 'openWidth' ) );
 2704+ .animate( { 'width': context.modules.$toc.data( 'openWidth' ) }, 'fast' );
 2705+ //.animate( { 'width': context.modules.$toc.data( 'openWidth' )}, 'fast', function() {
 2706+ // $( '#wikiEditor-ui-text textarea' ).trigger( 'mouseup' );
 2707+ //} )
 2708+ //.prev()
 2709+ //.animate( { 'marginRight': context.modules.$toc.data( 'openWidth' ) }, 'fast' );
 2710+ $.cookie( 'wikiEditor-' + context.instance + '-toc-width', context.modules.$toc.data( 'openWidth' ) );
27002711 return false;
27012712 },
27022713 /**
@@ -2704,13 +2715,22 @@
27052716 * @param {object} e
27062717 */
27072718 drag: function( e, pageX ) {
2708 - var mR = pageX ? pageX :
2709 - (e.pageX - e.data.context.$ui.find( '.wikiEditor-ui-left' ).offset().left);
2710 - mR = e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - mR;
2711 - if( mR < 26 || mR > e.data.context.$ui.find( '.wikiEditor-ui-left' ).width() - 250) return false;
2712 - e.data.context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', "-"+mR+'px' )
2713 - .children().css('marginRight', mR+'px');
2714 - e.data.context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR+'px' );
 2719+ var context = e.data;
 2720+ var mR;
 2721+ // This used to be done with a ternary expression, but for some reason that
 2722+ // returned NaN in some cases. Even this seems to be buggy in that .offset().left
 2723+ // is sometimes 0.
 2724+ // FIXME: We should ditch the whole thing and use jQuery UI Resizable if possible
 2725+ if ( pageX )
 2726+ mR = pageX;
 2727+ else
 2728+ mR = e.pageX - context.$ui.find( '.wikiEditor.ui-left' ).offset().left;
 2729+ mR = context.$ui.find( '.wikiEditor-ui-left' ).width() - mR;
 2730+ if( mR < 26 || mR > context.$ui.find( '.wikiEditor-ui-left' ).width() - 250)
 2731+ return false;
 2732+ context.$ui.find( '.wikiEditor-ui-left' ).css( 'marginRight', -mR )
 2733+ .children().css('marginRight', mR);
 2734+ context.$ui.find( '.wikiEditor-ui-right' ).css( 'width', mR );
27152735 return false;
27162736 },
27172737 /**
@@ -2719,19 +2739,21 @@
27202740 * @param {object} e
27212741 */
27222742 stopDrag: function( e ) {
 2743+ var context = e.data;
27232744 $()
27242745 .unbind( 'mousemove', $.wikiEditor.modules.toc.fn.drag )
27252746 .unbind( 'mouseup', $.wikiEditor.modules.toc.fn.stopDrag );
2726 - $(e.data.context.$iframe[0].contentWindow.document)
 2747+ $(context.$iframe[0].contentWindow.document)
27272748 .unbind( 'mousemove' )
27282749 .unbind( 'mouseup' );
2729 - if( $( '#wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) {
2730 - $.wikiEditor.modules.toc.fn.collapse( e.data.context );
 2750+ if( context.$ui.find( '.wikiEditor-ui-right' ).width() < 50 && wgNavigableTOCCollapseEnable ) {
 2751+ $.wikiEditor.modules.toc.fn.collapse( { data: context } );
27312752 } else {
2732 - $( '#wikiEditor-ui-left' ).trigger( 'mouseup' );
2733 - $( '#wikiEditor-ui-right' )
2734 - .data( 'openWidth', $( '#wikiEditor-ui-right' ).width() + 'px' );
2735 - $.cookie( 'wikiEditor-' + e.data.context.instance + '-toc-width', $( '#wikiEditor-ui-right' ).width() + 'px' );
 2753+ context.$ui.find( '.wikiEditor-ui-left' ).trigger( 'mouseup' );
 2754+ context.$ui.find( '.wikiEditor-ui-right' )
 2755+ .data( 'openWidth', context.$ui.find( '.wikiEditor-ui-right' ).width() );
 2756+ $.cookie( 'wikiEditor-' + context.instance + '-toc-width',
 2757+ context.$ui.find( '.wikiEditor-ui-right' ).width() );
27362758 }
27372759 return false;
27382760 },
@@ -2793,17 +2815,18 @@
27942816 return list;
27952817 }
27962818 function buildCollapseBar() {
2797 - $( '.wikiEditor-ui-toc ul:first' ).css( 'width', '147px' )
 2819+ // FIXME: Move this to a .css file
 2820+ context.modules.$toc.find( 'ul:first' ).css( 'width', '147px' )
27982821 .css( 'margin-left', '19px' ).css( 'border-left', '1px solid #DDDDDD' );
27992822 var $collapseBar = $( '<div />' )
28002823 .addClass( 'wikiEditor-ui-toc-collapse-open' )
28012824 .attr( 'id', 'wikiEditor-ui-toc-collapse' )
2802 - .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth)
 2825+ .data( 'openWidth', $.wikiEditor.modules.toc.defaultWidth )
28032826 .bind( 'mouseup', function() {
28042827 var $e = $(this);
28052828 var close = $e.hasClass( 'wikiEditor-ui-toc-collapse-open' );
28062829 if( close ) {
2807 - $( '#wikiEditor-ui-toc-collapse' )
 2830+ $e
28082831 .removeClass( 'wikiEditor-ui-toc-collapse-open' );
28092832 $e.parent()
28102833 .animate( { 'width': $e.outerWidth() }, 'fast', function() {
@@ -2811,65 +2834,63 @@
28122835 } )
28132836 .prev()
28142837 .animate( { 'marginRight': $e.outerWidth() + 1 }, 'fast', function() {
2815 - $( '#wikiEditor-ui-toc-collapse' )
 2838+ $e
28162839 .addClass( 'wikiEditor-ui-toc-collapse-closed' );
28172840 });
28182841 } else {
2819 - $( '#wikiEditor-ui-toc-collapse' )
 2842+ $e
28202843 .removeClass( 'wikiEditor-ui-toc-collapse-closed' );
28212844 $e.siblings().show()
28222845 .parent()
28232846 .animate( { 'width': $e.data( 'openWidth' ) }, 'fast' )
28242847 .prev()
28252848 .animate( { 'marginRight': $e.data( 'openWidth' ) }, 'fast', function() {
2826 - $( '#wikiEditor-ui-toc-collapse' )
 2849+ $e
28272850 .addClass( 'wikiEditor-ui-toc-collapse-open' );
28282851 });
28292852 }
28302853
28312854 });
2832 - return $collapseBar;
 2855+ return $collapseBar;
28332856 }
28342857 function buildResizeControls() {
28352858 var $resizeControlVertical = $( '<div />' )
28362859 .attr( 'id', 'wikiEditor-ui-toc-resize-vertical')
28372860 .bind( 'mousedown', function() {
2838 - $( '#wikiEditor-ui-toc' )
2839 - .data( 'openWidth', $( '#wikiEditor-ui-toc' ).width() );
 2861+ context.modules.$toc
 2862+ .data( 'openWidth', context.modules.$toc.width() );
28402863 $()
2841 - .bind( 'mousemove', { 'context': context }, $.wikiEditor.modules.toc.fn.drag )
2842 - .bind( 'mouseup', {'context': context}, $.wikiEditor.modules.toc.fn.stopDrag );
 2864+ .bind( 'mousemove', context, $.wikiEditor.modules.toc.fn.drag )
 2865+ .bind( 'mouseup', context, $.wikiEditor.modules.toc.fn.stopDrag );
28432866 $(context.$iframe[0].contentWindow.document)
2844 - .bind( 'mousemove', {'context': context}, function( e ){
2845 - parent.top.$j().trigger("mousemove", e.pageX);
 2867+ .bind( 'mousemove', function( e ) {
 2868+ parent.top.$j().trigger("mousemove", e.pageX);
28462869 return false;
28472870 } )
2848 - .bind( 'mouseup', {'context': context}, function( e ){
2849 - parent.top.$j().trigger("mouseup");
2850 - return false;
 2871+ .bind( 'mouseup', function() {
 2872+ parent.top.$j().trigger("mouseup");
 2873+ return false;
28512874 });
28522875 return false;
28532876 });
28542877
28552878 var $collapseControl = $( '<div />' ).addClass( 'tab' ).addClass( 'tab-toc' )
2856 - .append( '<a href="#"></a>' );
2857 - if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != '1px' ) {
2858 - $collapseControl.bind( 'click', function() {
2859 - $.wikiEditor.modules.toc.fn.collapse( context );
2860 - } )
2861 - .find( 'a' ).text( 'Hide Contents' );
2862 - } else {
2863 - $collapseControl.bind( 'click', function() {
2864 - $.wikiEditor.modules.toc.fn.expand( context );
2865 - } )
2866 - .find( 'a' ).text( 'Show Contents' );
 2879+ .append( '<a href="#" />' );
 2880+ if( $.cookie( 'wikiEditor-' + context.instance + '-toc-width' ) != 1 ) {
 2881+ $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.collapse )
 2882+ .find( 'a' ).text( gM( 'wikieditor-toc-hide' ) );
 2883+ } else {
 2884+ $collapseControl.bind( 'click', context, $.wikiEditor.modules.toc.fn.expand )
 2885+ .find( 'a' ).text( gM( 'wikieditor-toc-show' ) );
28672886 }
28682887 $collapseControl.insertBefore( context.modules.$toc );
28692888
2870 - if( !$( '#wikiEditor-ui-toc' ).data( 'openWidth' ) ) {
2871 - $( '#wikiEditor-ui-toc' ).data( 'openWidth', context.initialWidth == '1px' ?
 2889+ if( !context.modules.$toc.data( 'openWidth' ) ) {
 2890+ context.modules.$toc.data( 'openWidth', context.initialWidth == 1 ?
28722891 $.wikiEditor.modules.toc.defaultWidth : context.initialWidth );
28732892 }
 2893+ if ( context.initialWidth == 1 )
 2894+ $.wikiEditor.modules.toc.fn.collapse( { data: context } );
28742895 return $resizeControlVertical;
28752896 }
28762897
@@ -2935,7 +2956,7 @@
29362957
29372958 if(wgNavigableTOCResizable) {
29382959 context.modules.$toc.append( buildResizeControls() );
2939 - }else if(wgNavigableTOCCollapseEnable){
 2960+ } else if(wgNavigableTOCCollapseEnable) {
29402961 context.modules.$toc.append( buildCollapseBar() );
29412962 }
29422963 context.modules.$toc.find( 'div' ).autoEllipse( { 'position': 'right', 'tooltip': true } );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -92,9 +92,10 @@
9393 var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0)
9494 pre="\n"+options.pre;if(range.endContainer==range.commonAncestorContainer)
9595 post+="\n";}
96 -var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();for(var i=insertLines.length-1;i>=0;i--){range.insertNode(document.createTextNode(insertLines[i]));if(i>0)
97 -range.insertNode(document.createElement('br'));}
98 -return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<body.scrollTop()||y>body.scrollTop()+body.height())
 96+var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(document.createTextNode(insertLines[i]));if(i>0)
 97+lastNode=range.insertNode(document.createElement('br'));}
 98+if(lastNode)
 99+context.fn.scrollToTop(lastNode);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var body=context.$content.closest('body');var y=$element.offset().top-context.$content.offset().top;if(force||y<body.scrollTop()||y>body.scrollTop()+body.height())
99100 body.scrollTop(y);}};}
100101 if(arguments.length>0&&typeof arguments[0]=='object'){if(context.$content)
101102 context.api.addModule(context,arguments[0]);else{var args=arguments;setTimeout(function(){context.api.addModule(context,args[0]);},2);}}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){if(context.$content)
@@ -152,16 +153,19 @@
153154 $section=$('<div />').attr({'class':'booklet section section-'+id,'rel':id}).append($index).append($pages);$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,page,$pages,$index);break;}
154155 if($section!==null&&id!=='main'){var show=selected==id;$section.css('display',show?'block':'none');}
155156 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);}
156 -$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);if(wgNavigableTOCCollapseEnable){$dragControl=$('<div />').addClass('tab').attr('id','wikiEditor-ui-toc-resize-grip').append('<a href="#" title="Drag to resize"></a>').bind('mousedown',function(){$('#wikiEditor-ui-toc').data('openWidth',$('#wikiEditor-ui-toc').width());$().bind('mousemove',{'context':context},$.wikiEditor.modules.toc.fn.drag).bind('mouseup',{'context':context},$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).bind('mousemove',{'context':context},function(e){parent.top.$j().trigger("mousemove",e.pageX);return false;}).bind('mouseup',{'context':context},function(e){parent.top.$j().trigger("mouseup");return false;});return false;})
157 -context.modules.$toolbar.append($dragControl);}
 157+$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);if(wgNavigableTOCCollapseEnable){}
158158 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]));}}
159159 $.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:{},defaultWidth:'13em',fn:{create:function(context,config){if('$toc'in context.modules){return;}
 160+context.initialWidth=$.wikiEditor.modules.toc.defaultWidth;if(wgNavigableTOCResizable){if(!$.cookie('wikiEditor-'+context.instance+'-toc-width')){$.cookie('wikiEditor-'+context.instance+'-toc-width',$.wikiEditor.modules.toc.defaultWidth);}else{context.initialWidth=$.cookie('wikiEditor-'+context.instance+'-toc-width');}}
160161 var height=context.$ui.find('.wikiEditor-ui-left').height();context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').data('context',context);context.$ui.find('.wikiEditor-ui-right').css('width',$.wikiEditor.modules.toc.defaultWidth).append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-left').height());context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+$.wikiEditor.modules.toc.defaultWidth).children().css('marginRight',$.wikiEditor.modules.toc.defaultWidth);$.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.textSelection('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++;}
161162 section=Math.max(0,section);}
162163 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)
163164 context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight)
164 -context.modules.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(context){var $toc=$('#wikiEditor-ui-toc');if(!$toc.data('openWidth')){$toc.data('openWidth',$toc.width());}
165 -var $toolbar=$('#wikiEditor-ui-toolbar .tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.collapse).bind('click',$.wikiEditor.modules.toc.fn.expand).children('a').text('Show Contents');$toc.animate({'width':'1px'},'fast',function(){$(this).hide();}).prev().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight','-1px');});$.cookie('wikiEditor-'+context.instance+'-toc-width','1px');return false;},expand:function(context){$('#wikiEditor-ui-toolbar .tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.expand).bind('click',$.wikiEditor.modules.toc.fn.collapse).children('a').text('Hide Contents');$('#wikiEditor-ui-toc').show().animate({'width':$('#wikiEditor-ui-toc').data('openWidth')},'fast',function(){$('#wikiEditor-ui-text textarea').trigger('mouseup');}).prev().animate({'marginRight':$('#wikiEditor-ui-toc').data('openWidth')},'fast');$.cookie('wikiEditor-'+context.instance+'-toc-width',$('#wikiEditor-ui-toc').data('openWidth'));return false;},drag:function(e,pageX){var mR=pageX?pageX:(e.pageX-e.data.context.$ui.find('.wikiEditor-ui-left').offset().left);mR=e.data.context.$ui.find('.wikiEditor-ui-left').width()-mR;if(mR<26||mR>e.data.context.$ui.find('.wikiEditor-ui-left').width()-250)return false;e.data.context.$ui.find('.wikiEditor-ui-left').css('marginRight',"-"+mR+'px').children().css('marginRight',mR+'px');e.data.context.$ui.find('.wikiEditor-ui-right').css('width',mR+'px');return false;},stopDrag:function(e){$().unbind('mousemove',$.wikiEditor.modules.toc.fn.drag).unbind('mouseup',$.wikiEditor.modules.toc.fn.stopDrag);$(e.data.context.$iframe[0].contentWindow.document).unbind('mousemove').unbind('mouseup');if($('#wikiEditor-ui-right').width()<50&&wgNavigableTOCCollapseEnable){$.wikiEditor.modules.toc.fn.collapse(e.data.context);}else{$('#wikiEditor-ui-left').trigger('mouseup');$('#wikiEditor-ui-right').data('openWidth',$('#wikiEditor-ui-right').width()+'px');$.cookie('wikiEditor-'+e.data.context.instance+'-toc-width',$('#wikiEditor-ui-right').width()+'px');}
 165+context.modules.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var context=event.data;var $toc=context.modules.$toc;if(!$toc.data('openWidth')){$toc.data('openWidth',$toc.width());}
 166+context.$ui.find('.tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.collapse).bind('click',context,$.wikiEditor.modules.toc.fn.expand).children('a').text(gM('wikieditor-toc-show'));$toc.animate({'width':1},'fast');$.cookie('wikiEditor-'+context.instance+'-toc-width',1);return false;},expand:function(event){var context=event.data;context.$ui.find('.tab-toc').unbind('click',$.wikiEditor.modules.toc.fn.expand).bind('click',context,$.wikiEditor.modules.toc.fn.collapse).children('a').text(gM('wikieditor-toc-hide'));context.modules.$toc.show().animate({'width':context.modules.$toc.data('openWidth')},'fast');$.cookie('wikiEditor-'+context.instance+'-toc-width',context.modules.$toc.data('openWidth'));return false;},drag:function(e,pageX){var context=e.data;var mR;if(pageX)
 167+mR=pageX;else
 168+mR=e.pageX-context.$ui.find('.wikiEditor.ui-left').offset().left;mR=context.$ui.find('.wikiEditor-ui-left').width()-mR;if(mR<26||mR>context.$ui.find('.wikiEditor-ui-left').width()-250)
 169+return false;context.$ui.find('.wikiEditor-ui-left').css('marginRight',-mR).children().css('marginRight',mR);context.$ui.find('.wikiEditor-ui-right').css('width',mR);return false;},stopDrag:function(e){var context=e.data;$().unbind('mousemove',$.wikiEditor.modules.toc.fn.drag).unbind('mouseup',$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).unbind('mousemove').unbind('mouseup');if(context.$ui.find('.wikiEditor-ui-right').width()<50&&wgNavigableTOCCollapseEnable){$.wikiEditor.modules.toc.fn.collapse({data:context});}else{context.$ui.find('.wikiEditor-ui-left').trigger('mouseup');context.$ui.find('.wikiEditor-ui-right').data('openWidth',context.$ui.find('.wikiEditor-ui-right').width());$.cookie('wikiEditor-'+context.instance+'-toc-width',context.$ui.find('.wikiEditor-ui-right').width());}
166170 return false;},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;}
167171 sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}}
168172 return sections;}
@@ -170,10 +174,11 @@
171175 div.html('&nbsp;');var item=$('<li />').append(div);if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));}
172176 list.append(item);}
173177 return list;}
174 -function buildCollapseBar(){$('.wikiEditor-ui-toc ul:first').css('width','147px').css('margin-left','19px').css('border-left','1px solid #DDDDDD');var $collapseBar=$('<div />').addClass('wikiEditor-ui-toc-collapse-open').attr('id','wikiEditor-ui-toc-collapse').data('openWidth',$.wikiEditor.modules.toc.defaultWidth).bind('mouseup',function(){var $e=$(this);var close=$e.hasClass('wikiEditor-ui-toc-collapse-open');if(close){$('#wikiEditor-ui-toc-collapse').removeClass('wikiEditor-ui-toc-collapse-open');$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').addClass('wikiEditor-ui-toc-collapse-closed');});}else{$('#wikiEditor-ui-toc-collapse').removeClass('wikiEditor-ui-toc-collapse-closed');$e.siblings().show().parent().animate({'width':$e.data('openWidth')},'fast').prev().animate({'marginRight':$e.data('openWidth')},'fast',function(){$('#wikiEditor-ui-toc-collapse').addClass('wikiEditor-ui-toc-collapse-open');});}});return $collapseBar;}
175 -function buildResizeControls(){var $resizeControlVertical=$('<div />').attr('id','wikiEditor-ui-toc-resize-vertical').bind('mousedown',function(){$('#wikiEditor-ui-toc').data('openWidth',$('#wikiEditor-ui-toc').width());$().bind('mousemove',{'context':context},$.wikiEditor.modules.toc.fn.drag).bind('mouseup',{'context':context},$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).bind('mousemove',{'context':context},function(e){parent.top.$j().trigger("mousemove",e.pageX);return false;}).bind('mouseup',{'context':context},function(e){parent.top.$j().trigger("mouseup");return false;});return false;});var $collapseControl=$('<div />').addClass('tab').addClass('tab-toc').append('<a href="#"></a>');if($.cookie('wikiEditor-'+context.instance+'-toc-width')!='1px'){$collapseControl.bind('click',function(){$.wikiEditor.modules.toc.fn.collapse(context);}).find('a').text('Hide Contents');}else{$collapseControl.bind('click',function(){$.wikiEditor.modules.toc.fn.expand(context);}).find('a').text('Show Contents');}
176 -$collapseControl.insertBefore(context.modules.$toc);if(!$('#wikiEditor-ui-toc').data('openWidth')){$('#wikiEditor-ui-toc').data('openWidth',context.initialWidth=='1px'?$.wikiEditor.modules.toc.defaultWidth:context.initialWidth);}
177 -return $resizeControlVertical;}
 178+function buildCollapseBar(){context.modules.$toc.find('ul:first').css('width','147px').css('margin-left','19px').css('border-left','1px solid #DDDDDD');var $collapseBar=$('<div />').addClass('wikiEditor-ui-toc-collapse-open').attr('id','wikiEditor-ui-toc-collapse').data('openWidth',$.wikiEditor.modules.toc.defaultWidth).bind('mouseup',function(){var $e=$(this);var close=$e.hasClass('wikiEditor-ui-toc-collapse-open');if(close){$e.removeClass('wikiEditor-ui-toc-collapse-open');$e.parent().animate({'width':$e.outerWidth()},'fast',function(){$(this).find('ul:first').hide();}).prev().animate({'marginRight':$e.outerWidth()+1},'fast',function(){$e.addClass('wikiEditor-ui-toc-collapse-closed');});}else{$e.removeClass('wikiEditor-ui-toc-collapse-closed');$e.siblings().show().parent().animate({'width':$e.data('openWidth')},'fast').prev().animate({'marginRight':$e.data('openWidth')},'fast',function(){$e.addClass('wikiEditor-ui-toc-collapse-open');});}});return $collapseBar;}
 179+function buildResizeControls(){var $resizeControlVertical=$('<div />').attr('id','wikiEditor-ui-toc-resize-vertical').bind('mousedown',function(){context.modules.$toc.data('openWidth',context.modules.$toc.width());$().bind('mousemove',context,$.wikiEditor.modules.toc.fn.drag).bind('mouseup',context,$.wikiEditor.modules.toc.fn.stopDrag);$(context.$iframe[0].contentWindow.document).bind('mousemove',function(e){parent.top.$j().trigger("mousemove",e.pageX);return false;}).bind('mouseup',function(){parent.top.$j().trigger("mouseup");return false;});return false;});var $collapseControl=$('<div />').addClass('tab').addClass('tab-toc').append('<a href="#" />');if($.cookie('wikiEditor-'+context.instance+'-toc-width')!=1){$collapseControl.bind('click',context,$.wikiEditor.modules.toc.fn.collapse).find('a').text(gM('wikieditor-toc-hide'));}else{$collapseControl.bind('click',context,$.wikiEditor.modules.toc.fn.expand).find('a').text(gM('wikieditor-toc-show'));}
 180+$collapseControl.insertBefore(context.modules.$toc);if(!context.modules.$toc.data('openWidth')){context.modules.$toc.data('openWidth',context.initialWidth==1?$.wikiEditor.modules.toc.defaultWidth:context.initialWidth);}
 181+if(context.initialWidth==1)
 182+$.wikiEditor.modules.toc.fn.collapse({data:context});return $resizeControlVertical;}
178183 var outline=[];var h=0;context.$content.contents().each(function(){if(this.nodeName!='#text')
179184 return;var text=this.textContent;var match=text.match(/^(={1,6})(.*?)\1\s*$/);if(!match)
180185 return;var div;if($(this).parent().is('div')&&$(this).parent().children().size()==1)

Status & tagging log