From 9bb94e83199159982e2a5e99dbb7e527495faba4 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Thu, 3 Apr 2014 16:25:10 +0200 Subject: [PATCH] WikiEditor: Remove old unmaintained ToC module Change-Id: I0f53a68e50fc950d7f407ee81b2bf0d81ef4948d --- WikiEditor.hooks.php | 18 +- WikiEditor.php | 26 - i18n/en.json | 5 +- modules/ext.wikiEditor.toc.js | 7 - modules/jquery.wikiEditor.toc.css | 204 ------ modules/jquery.wikiEditor.toc.js | 700 -------------------- modules/jquery.wikiEditor.toolbar.js | 6 - tests/selenium/WikiEditorSeleniumConfig.php | 3 +- tests/selenium/WikiEditorTestSuite.php | 1 - 9 files changed, 3 insertions(+), 967 deletions(-) delete mode 100644 modules/ext.wikiEditor.toc.js delete mode 100644 modules/jquery.wikiEditor.toc.css delete mode 100644 modules/jquery.wikiEditor.toc.js diff --git a/WikiEditor.hooks.php b/WikiEditor.hooks.php index 89f27f48..a91cd332 100644 --- a/WikiEditor.hooks.php +++ b/WikiEditor.hooks.php @@ -140,23 +140,7 @@ class WikiEditorHooks { 'modules' => array( 'ext.wikiEditor.publish', ), - ), - 'toc' => array( - 'preferences' => array( - // Ideally this key would be 'wikieditor-toc' - 'usenavigabletoc' => array( - 'type' => 'toggle', - 'label-message' => 'wikieditor-toc-preference', - 'section' => 'editing/labs', - ), - ), - 'requirements' => array( - 'usenavigabletoc' => true, - ), - 'modules' => array( - 'ext.wikiEditor.toc', - ), - ), + ) ); /* Static Methods */ diff --git a/WikiEditor.php b/WikiEditor.php index 2d67b0a3..4dd3f542 100644 --- a/WikiEditor.php +++ b/WikiEditor.php @@ -37,8 +37,6 @@ $wgWikiEditorFeatures = array( /* I-frame dependent (do not deploy!) */ - // Failry stable table of contents - 'toc' => array( 'global' => false, 'user' => true ), // Pretty broken template collapsing/editing 'templateEditor' => array( 'global' => false, 'user' => false ), // Bare-bones (probably broken) template collapsing @@ -179,18 +177,6 @@ $wgResourceModules += array( 'jquery.wikiEditor.iframe', ), ), - 'jquery.wikiEditor.toc' => $wikiEditorTpl + array( - 'scripts' => 'jquery.wikiEditor.toc.js', - 'styles' => 'jquery.wikiEditor.toc.css', - 'dependencies' => array( - 'jquery.wikiEditor', - 'jquery.wikiEditor.iframe', - 'jquery.ui.draggable', - 'jquery.ui.resizable', - 'jquery.autoEllipsis', - 'jquery.color', - ), - ), 'jquery.wikiEditor.toolbar' => $wikiEditorTpl + array( 'scripts' => 'jquery.wikiEditor.toolbar.js', 'styles' => 'jquery.wikiEditor.toolbar.css', @@ -498,18 +484,6 @@ $wgResourceModules += array( 'jquery.wikiEditor.templates', ), ), - 'ext.wikiEditor.toc' => $wikiEditorTpl + array( - 'scripts' => 'ext.wikiEditor.toc.js', - 'dependencies' => array( - 'ext.wikiEditor', - 'ext.wikiEditor.highlight', - 'jquery.wikiEditor.toc', - ), - 'messages' => array( - 'wikieditor-toc-show', - 'wikieditor-toc-hide', - ), - ), 'ext.wikiEditor.tests.toolbar' => $wikiEditorTpl + array( 'scripts' => 'ext.wikiEditor.tests.toolbar.js', 'dependencies' => 'ext.wikiEditor.toolbar', diff --git a/i18n/en.json b/i18n/en.json index 4d8fd5ca..fda8b917 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -29,9 +29,6 @@ "wikieditor-template-editor-dialog-submit": "Update", "wikieditor-template-editor-dialog-cancel": "Cancel", "wikieditor-templates-preference": "Enable template collapsing", - "wikieditor-toc-preference": "Enable navigable table of contents", - "wikieditor-toc-show": "Show contents", - "wikieditor-toc-hide": "Hide contents", "wikieditor-toolbar": "Editing toolbar", "wikieditor-toolbar-desc": "Edit page toolbar with enhanced usability", "wikieditor-toolbar-preference": "Enable enhanced editing toolbar", @@ -237,4 +234,4 @@ "wikieditor-toolbar-help-content-indent-description": "Indent", "wikieditor-toolbar-help-content-indent-syntax": "Normal text
:Indented text
::Indented text", "wikieditor-toolbar-help-content-indent-result": "Normal text
Indented text
Indented text
" -} \ No newline at end of file +} diff --git a/modules/ext.wikiEditor.toc.js b/modules/ext.wikiEditor.toc.js deleted file mode 100644 index 1fc542c5..00000000 --- a/modules/ext.wikiEditor.toc.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * JavaScript for WikiEditor Table of Contents - */ -jQuery( document ).ready( function ( $ ) { - // Add table of contents module - $( '#wpTextbox1' ).wikiEditor( 'addModule', 'toc' ); -} ); diff --git a/modules/jquery.wikiEditor.toc.css b/modules/jquery.wikiEditor.toc.css deleted file mode 100644 index c7976176..00000000 --- a/modules/jquery.wikiEditor.toc.css +++ /dev/null @@ -1,204 +0,0 @@ -/* - * CSS for WikiEditor Table of Contents jQuery plugin - */ - -.wikiEditor-ui-toc { - /* height and width are set dynamically */ - /*float: right;*/ - padding: 0; - overflow: auto; - overflow-x: hidden; -} - -.wikiEditor-ui-toc { - border-left: 1px solid silver; -} - -.wikiEditor-ui-toc ul { - padding: 0; - margin: 0; - list-style: none; - /* IE needs to be told in great detail how to act, or it misbehaves */ - list-style-image: none; - list-style-position: outside; - list-style-type: none; - width: 100%; -} - -.tab-toc { - /* Should match the toolbar */ - /* @embed */ - background-image: url(images/toolbar/base.png); - background-position: left top; - background-repeat: repeat-x; - height: 26px; - padding: 3px 0; - line-height: 26px; - padding-left: 1em; - border-bottom: 1px solid silver; - white-space: nowrap; - overflow: hidden; -} - -.tab-toc a { - outline: none; -} - -.wikiEditor-ui-toc li { - padding: 0; - margin: 0; -} - -.wikiEditor-ui-toc ul ul { - padding: 0; - margin: 0; - margin-bottom: 0 !important; - margin-top: 0 !important; - list-style: none; - background-image: none; -} - -.wikiEditor-ui-toc ul li div { - display: block; - font-size: 0.9em; - cursor: pointer; - color: #0645ad; -} - -.wikiEditor-ui-toc ul li div { - padding: 0.125em; - padding-left: 1em; -} - -.wikiEditor-ui-toc ul ul li div { - padding-left: 2em; -} - -.wikiEditor-ui-toc ul ul ul li div { - padding-left: 3em; -} - -.wikiEditor-ui-toc ul ul ul ul li div { - padding-left: 4em; -} - -.wikiEditor-ui-toc ul ul ul ul ul li div { - padding-left: 5em; -} - -.wikiEditor-ui-toc ul ul ul ul ul ul li div { - padding-left: 6em; -} - -.wikiEditor-ui-toc ul li div.current { - background-color: #FAFAFA; - color: #333333; -} - -.wikiEditor-ui-toc ul li div.section-0 { - font-size: 1em; - padding-top: 0.5em; - padding-bottom: 0.5em; - border-bottom: 1px solid #DDDDDD; -} -/* Collapsing changes */ -.wikiEditor-ui-toc { - overflow-y: hidden; - position: relative; -} - -.wikiEditor-ui-toc ul { - overflow-y: auto; - overflow-x: hidden; - height: 100%; - margin-bottom: 0 !important; -} - -.wikiEditor-ui-toc ul ul { - float: none; - height: auto; -} -#wikiEditor-ui-toc-collapse { - height: 100%; - width: 18px; - position: absolute; - top: 0; - left: 0; -} - -.wikiEditor-ui-toc-collapse-open { - /* @embed */ - background: #f3f3f3 url(images/toc/close.png) 4px 50% no-repeat; - border-left: 1px solid #DDDDDD; -} - -.wikiEditor-ui-toc-collapse-closed { - /* @embed */ - background: #f3f3f3 url(images/toc/open.png) 4px 50% no-repeat; -} - -/* Resizing Changes */ -.wikiEditor-ui-toc-resize-vertical, -.ui-resizable-w { - width: 4px; - position: absolute; - top: 0; - left: 0; - height: 100%; - cursor: ew-resize; -} - -.wikiEditor-ui .wikiEditor-ui-right { - overflow: visible; -} - -.wikiEditor-ui-right .ui-resizable-w { - left: 0 !important; - z-index: 0; -} - -.wikiEditor-ui-right .wikiEditor-ui-toc-resize-grip { - width: 5px; - height: 12px; - padding: 3px; - position: absolute; - top: 7px; - left: -12px !important; - cursor: ew-resize; - /* @embed */ - background: url(images/toc/grip.png) 50% 50% no-repeat; - z-index: 0; -} - -.wikiEditor-ui-toolbar .tab-toc { - float: right; - margin: 3px 16px 3px 3px; - line-height: 26px; -} - -.wikiEditor-ui-toc-expandControl { - position: absolute; - z-index: 2; - top: 0; - right: 10px; - height: 26px; - padding: 3px 0; - line-height: 26px; - padding-right: 1em; - white-space: nowrap; - overflow: hidden; -} - -.wikiEditor-ui-text textarea { - resize: none; -} - -.wikiEditor-ui-text textarea:focus { - outline: none; -} - -/* Self Clearing for the wikiText view */ -.wikiEditor-ui-view-wikiText { - overflow: auto; - width: 100%; -} diff --git a/modules/jquery.wikiEditor.toc.js b/modules/jquery.wikiEditor.toc.js deleted file mode 100644 index 3f186db6..00000000 --- a/modules/jquery.wikiEditor.toc.js +++ /dev/null @@ -1,700 +0,0 @@ -/* TOC Module for wikiEditor */ -/*jshint onevar:false */ -( function ( $, mw ) { $.wikiEditor.modules.toc = { - -/** - * Compatability map - */ -browsers: { - // Left-to-right languages - ltr: { - msie: [['>=', 7]], - firefox: [['>=', 3]], - opera: [['>=', 10]], - safari: [['>=', 4]], - chrome: [['>=', 4]] - }, - // Right-to-left languages - rtl: { - msie: [['>=', 8]], - firefox: [['>=', 3]], - opera: [['>=', 10]], - safari: [['>=', 4]], - chrome: [['>=', 4]] - } -}, -/** - * Core Requirements - */ -req: [ 'iframe' ], -/** - * Configuration - */ -cfg: { - // Default width of table of contents - defaultWidth: '166px', - // Minimum width to allow resizing to before collapsing the table of contents - used when resizing and collapsing - minimumWidth: '70px', - // Minimum width of the wikiText area - textMinimumWidth: '450px', - // The style property to be used for positioning the flexible module in regular mode - flexProperty: 'marginRight', - // Boolean var indicating text direction - rtl: false -}, -/** - * API accessible functions - */ -api: { - // -}, -/** - * Event handlers - */ -evt: { - /** - * @param context - * @param event - */ - change: function( context ) { - $.wikiEditor.modules.toc.fn.update( context ); - }, - /** - * @param context - * @param event - */ - ready: function( context ) { - // Add the TOC to the document - $.wikiEditor.modules.toc.fn.build( context ); - if ( !context.$content ) { - return; - } - context.$content.parent() - .blur( function() { - var context = event.data.context; - $.wikiEditor.modules.toc.fn.unhighlight( context ); - }); - $.wikiEditor.modules.toc.fn.improveUI(); - $.wikiEditor.modules.toc.evt.resize( context ); - }, - /** - * @param context - * @param event - */ - resize: function( context ) { - var availableWidth = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ), - totalMinWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) + - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ); - context.$ui.find( '.wikiEditor-ui-right' ) - .resizable( 'option', 'maxWidth', availableWidth ); - if ( context.modules.toc.$toc.data( 'positionMode' ) !== 'disabled' && - context.$wikitext.width() < totalMinWidth ) { - $.wikiEditor.modules.toc.fn.disable( context ); - } else if ( context.modules.toc.$toc.data( 'positionMode' ) === 'disabled' && - context.$wikitext.width() > totalMinWidth ) { - $.wikiEditor.modules.toc.fn.enable( context ); - } else if ( context.modules.toc.$toc.data( 'positionMode' ) === 'regular' && - context.$ui.find( '.wikiEditor-ui-right' ).width() > availableWidth ) { - //switch mode - $.wikiEditor.modules.toc.fn.switchLayout( context ); - } else if ( context.modules.toc.$toc.data( 'positionMode' ) === 'goofy' && - context.modules.toc.$toc.data( 'previousWidth' ) < context.$wikitext.width() ) { - //switch mode - $.wikiEditor.modules.toc.fn.switchLayout( context ); - } - if ( context.modules.toc.$toc.data( 'positionMode' ) === 'goofy' ) { - context.modules.toc.$toc.find( 'div' ).autoEllipsis( - { 'position': 'right', 'tooltip': true, 'restoreText': true } - ); - } - // reset the height of the TOC - if ( !context.modules.toc.$toc.data( 'collapsed' ) ){ - context.modules.toc.$toc.height( - context.$ui.find( '.wikiEditor-ui-left' ).height() - - context.$ui.find( '.tab-toc' ).outerHeight() - ); - } - - // store the width of the view for comparison on next resize - context.modules.toc.$toc.data( 'previousWidth', context.$wikitext.width() ); - }, - /** - * @param context - * @param event - */ - mark: function( context ) { - var hash = ''; - var markers = context.modules.highlight.markers; - var tokenArray = context.modules.highlight.tokenArray; - var outline = context.data.outline = []; - var h = 0; - for ( var i = 0; i < tokenArray.length; i++ ) { - if ( tokenArray[i].label !== 'TOC_HEADER' ) { - continue; - } - h++; - markers.push( { - index: h, - start: tokenArray[i].tokenStart, - end: tokenArray[i].offset, - type: 'toc', - anchor: 'tag', - afterWrap: function( node ) { - var marker = $( node ).data( 'marker' ); - $( node ).addClass( 'wikiEditor-toc-header' ) - .addClass( 'wikiEditor-toc-section-' + marker.index ) - .data( 'section', marker.index ); - }, - beforeUnwrap: function( node ) { - $( node ).removeClass( 'wikiEditor-toc-header' ) - .removeClass( 'wikiEditor-toc-section-' + $( node ).data( 'section' ) ); - }, - onSkip: function( node ) { - var marker = $( node ).data( 'marker' ); - if ( $( node ).data( 'section' ) !== marker.index ) { - $( node ) - .removeClass( 'wikiEditor-toc-section-' + $( node ).data( 'section' ) ) - .addClass( 'wikiEditor-toc-section-' + marker.index ) - .data( 'section', marker.index ); - } - }, - getAnchor: function( ca1 ) { - return $( ca1.parentNode ).is( '.wikiEditor-toc-header' ) ? - ca1.parentNode : null; - } - } ); - hash += tokenArray[i].match[2] + '\n'; - outline.push ( { - 'text': tokenArray[i].match[2], - 'level': tokenArray[i].match[1].length, - 'index': h - } ); - } - // Only update the TOC if it's been changed - we do this by comparing a hash of the headings this time to last - if ( typeof context.modules.toc.lastHash === 'undefined' || context.modules.toc.lastHash !== hash ) { - $.wikiEditor.modules.toc.fn.build( context ); - $.wikiEditor.modules.toc.fn.update( context ); - // Remember the changed version - context.modules.toc.lastHash = hash; - } - } -}, -exp: [ - { 'regex': /^(={1,6})([^\r\n]+?)\1\s*$/m, 'label': 'TOC_HEADER', 'markAfter': true } -], -/** - * Internally used functions - */ -fn: { - /** - * Creates a table of contents module within a wikiEditor - * - * @param {Object} context Context object of editor to create module in - * @param {Object} config Configuration object to create module from - */ - create: function( context ) { - if ( '$toc' in context.modules.toc ) { - return; - } - $.wikiEditor.modules.toc.cfg.rtl = $( 'body' ).is( '.rtl' ); - $.wikiEditor.modules.toc.cfg.flexProperty = $.wikiEditor.modules.toc.cfg.rtl ? 'marginLeft' : 'marginRight'; - context.$ui.find( '.wikiEditor-ui-left' ).height(); - context.modules.toc.$toc = $( '
' ) - .addClass( 'wikiEditor-ui-toc' ) - .data( 'context', context ) - .data( 'positionMode', 'regular' ) - .data( 'collapsed', false ); - context.$ui.find( '.wikiEditor-ui-right' ) - .append( context.modules.toc.$toc ); - context.modules.toc.$toc.height( - context.$ui.find( '.wikiEditor-ui-left' ).height() - ); - $.wikiEditor.modules.toc.fn.redraw( context, $.wikiEditor.modules.toc.cfg.defaultWidth ); - }, - redraw: function( context, fixedWidth ) { - fixedWidth = parseFloat( fixedWidth ); - if ( context.modules.toc.$toc.data( 'positionMode' ) === 'regular' ) { - context.$ui.find( '.wikiEditor-ui-right' ) - .css( 'width', fixedWidth + 'px' ); - context.$ui.find( '.wikiEditor-ui-left' ) - .css( $.wikiEditor.modules.toc.cfg.flexProperty, ( -1 * fixedWidth ) + 'px' ) - .children() - .css( $.wikiEditor.modules.toc.cfg.flexProperty, fixedWidth + 'px' ); - } else if( context.modules.toc.$toc.data( 'positionMode' ) === 'goofy' ) { - context.$ui.find( '.wikiEditor-ui-left' ) - .css( 'width', fixedWidth ); - context.$ui.find( '.wikiEditor-ui-right' ) - .css( $.wikiEditor.modules.toc.cfg.rtl ? 'right': 'left', fixedWidth ); - context.$wikitext.css( 'height', context.$ui.find( '.wikiEditor-ui-right' ).height() ); - } - }, - switchLayout: function( context ) { - var width; - context.$ui.find( '.wikiEditor-ui-right' ).height(); - if ( context.modules.toc.$toc.data( 'positionMode' ) === 'regular' && - !context.modules.toc.$toc.data( 'collapsed' ) - ) { - // store position mode - context.modules.toc.$toc.data( 'positionMode', 'goofy' ); - // store the width of the TOC, to ensure we dont allow it to be larger than this when switching back - context.modules.toc.$toc.data( 'positionModeChangeAt', - context.$ui.find( '.wikiEditor-ui-right' ).width() ); - width = $.wikiEditor.modules.toc.cfg.textMinimumWidth; - // set our styles for goofy mode - context.$ui.find( '.wikiEditor-ui-left' ) - .css( $.wikiEditor.modules.toc.cfg.flexProperty, '') - .css( { 'position': 'absolute', 'float': 'none', - 'left': $.wikiEditor.modules.toc.cfg.rtl ? 'auto': 0, - 'right' : $.wikiEditor.modules.toc.cfg.rtl ? 0 : 'auto' } ) - .children() - .css( $.wikiEditor.modules.toc.cfg.flexProperty, '' ); - context.$ui.find( '.wikiEditor-ui-right' ) - .css( { 'width': 'auto', 'position': 'absolute', 'float': 'none', - 'right': $.wikiEditor.modules.toc.cfg.rtl ? 'auto': 0, - 'left' : $.wikiEditor.modules.toc.cfg.rtl ? 0 : 'auto' } ); - context.$wikitext - .css( 'position', 'relative' ); - } else if ( context.modules.toc.$toc.data( 'positionMode' ) === 'goofy' ) { - // store position mode - context.modules.toc.$toc.data( 'positionMode', 'regular' ); - // set width - width = context.$wikitext.width() - context.$ui.find( '.wikiEditor-ui-left' ).width(); - if ( width > context.modules.toc.$toc.data( 'positionModeChangeAt' ) ) { - width = context.modules.toc.$toc.data( 'positionModeChangeAt' ); - } - // set our styles for regular mode - context.$wikitext - .css( { 'position': '', 'height': '' } ); - context.$ui.find( '.wikiEditor-ui-right' ) - .css( $.wikiEditor.modules.toc.cfg.flexProperty, '' ) - .css( { 'position': '', 'left': '', 'right': '', 'float': '', 'top': '', 'height': '' } ); - context.$ui.find( '.wikiEditor-ui-left' ) - .css( { 'width': '', 'position': '', 'left': '', 'float': '', 'right': '' } ); - } - $.wikiEditor.modules.toc.fn.redraw( context, width ); - }, - disable: function( context ) { - if ( context.modules.toc.$toc.data( 'collapsed' ) ) { - context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); - } else { - if( context.modules.toc.$toc.data( 'positionMode' ) === 'goofy' ) { - $.wikiEditor.modules.toc.fn.switchLayout( context ); - } - context.$ui.find( '.wikiEditor-ui-right' ).hide(); - context.$ui.find( '.wikiEditor-ui-left' ) - .css( $.wikiEditor.modules.toc.cfg.flexProperty, '' ) - .children() - .css( $.wikiEditor.modules.toc.cfg.flexProperty, '' ); - } - context.modules.toc.$toc.data( 'positionMode', 'disabled' ); - }, - enable: function( context ) { - context.modules.toc.$toc.data( 'positionMode', 'regular' ); - if ( context.modules.toc.$toc.data( 'collapsed' ) ) { - context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).show(); - } else { - context.$ui.find( '.wikiEditor-ui-right' ).show(); - $.wikiEditor.modules.toc.fn.redraw( context, $.wikiEditor.modules.toc.cfg.minimumWidth ); - context.modules.toc.$toc.find( 'div' ).autoEllipsis( - { 'position': 'right', 'tooltip': true, 'restoreText': true } - ); - } - }, - unhighlight: function( context ) { - // FIXME: For some reason, IE calls this function twice, the first time with context undefined - // Investigate this when you have time please! In the meantime, the user interaction is working just - // fine because the second call is valid - if ( context ) { - context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); - } - }, - /** - * Highlight the section the cursor is currently within - * - * @param {Object} context - */ - update: function () { - //temporarily commenting this out because it is causing all kinds of cursor - //and text jumping issues in IE. WIll get back to this --pdhanda - /* - var div = context.fn.beforeSelection( 'wikiEditor-toc-header' ); - if ( div === null ) { - // beforeSelection couldn't figure it out, keep the old highlight state - return; - } - - $.wikiEditor.modules.toc.fn.unhighlight( context ); - var section = div.data( 'section' ) || 0; - if ( context.data.outline.length > 0 ) { - var sectionLink = context.modules.toc.$toc.find( 'div.section-' + section ); - sectionLink.addClass( 'current' ); - - // Scroll the highlighted link into view if necessary - var relTop = sectionLink.offset().top - context.modules.toc.$toc.offset().top; - - var scrollTop = context.modules.toc.$toc.scrollTop(); - var divHeight = context.modules.toc.$toc.height(); - var sectionHeight = sectionLink.height(); - if ( relTop < 0 ) - // Scroll up - context.modules.toc.$toc.scrollTop( scrollTop + relTop ); - else if ( relTop + sectionHeight > divHeight ) - // Scroll down - context.modules.toc.$toc.scrollTop( scrollTop + relTop + sectionHeight - divHeight ); - } - */ - }, - - /** - * Collapse the contents module - * - * @param {Object} event Event object with context as data - */ - collapse: function () { - var $this = $( this ), - context = $this.data( 'context' ); - if ( context.modules.toc.$toc.data( 'positionMode' ) === 'goofy' ) { - $.wikiEditor.modules.toc.fn.switchLayout( context ); - } - var pT = $this.parent().position().top - 1; - context.modules.toc.$toc.data( 'collapsed', true ); - var leftParam = {}, leftChildParam = {}; - leftParam[ $.wikiEditor.modules.toc.cfg.flexProperty ] = '-1px'; - leftChildParam[ $.wikiEditor.modules.toc.cfg.flexProperty ] = '1px'; - context.$ui.find( '.wikiEditor-ui-left' ) - .animate( leftParam, 'fast', function() { - $( this ).css( $.wikiEditor.modules.toc.cfg.flexProperty, 0 ); - } ) - .children() - .animate( leftChildParam, 'fast', function() { - $( this ).css( $.wikiEditor.modules.toc.cfg.flexProperty, 0 ); - } ); - context.$ui.find( '.wikiEditor-ui-right' ) - .css( { - 'marginTop' : '1px', - 'position' : 'absolute', - 'left' : $.wikiEditor.modules.toc.cfg.rtl ? 0 : 'auto', - 'right' : $.wikiEditor.modules.toc.cfg.rtl ? 'auto' : 0, - 'top' : pT } ) - .fadeOut( 'fast', function() { - $( this ).hide() - .css( { 'marginTop': '0', 'width': '1px' } ); - context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).fadeIn( 'fast' ); - // Let the UI know things have moved around - context.fn.trigger( 'tocCollapse' ); - context.fn.trigger( 'resize' ); - } ); - - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', 0 ); - return false; - }, - - /** - * Expand the contents module - * - * @param {Object} event Event object with context as data - */ - expand: function () { - var $this = $( this ), - context = $this.data( 'context' ), - openWidth = parseFloat( context.modules.toc.$toc.data( 'openWidth' ) ), - availableSpace = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ); - if ( availableSpace < $.wikiEditor.modules.toc.cfg.textMinmumWidth ) { - return false; - } - context.modules.toc.$toc.data( 'collapsed', false ); - // check if we've got enough room to open to our stored width - if ( availableSpace < openWidth ) { - openWidth = availableSpace; - } - context.$ui.find( '.wikiEditor-ui-toc-expandControl' ).hide(); - var leftParam = {}, leftChildParam = {}; - leftParam[ $.wikiEditor.modules.toc.cfg.flexProperty ] = parseFloat( openWidth ) * -1; - leftChildParam[ $.wikiEditor.modules.toc.cfg.flexProperty ] = openWidth; - context.$ui.find( '.wikiEditor-ui-left' ) - .animate( leftParam, 'fast' ) - .children() - .animate( leftChildParam, 'fast' ); - context.$ui.find( '.wikiEditor-ui-right' ) - .show() - .css( 'marginTop', '1px' ) - .animate( { 'width' : openWidth }, 'fast', function() { - context.$content.trigger( 'mouseup' ); - $( this ).css( { - 'marginTop' : '0', - 'position' : 'relative', - 'right' : 'auto', - 'left' : 'auto', - 'top': 'auto' } ); - context.fn.trigger( 'tocExpand' ); - context.fn.trigger( 'resize' ); - } ); - $.cookie( 'wikiEditor-' + context.instance + '-toc-width', - context.modules.toc.$toc.data( 'openWidth' ) ); - return false; - }, - /** - * Builds table of contents - * - * @param {Object} context - */ - build: function( context ) { - /** - * Builds a structured outline from flat outline - * - * @param {Object} outline Array of objects with level fields - */ - 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; - } - sections[sections.length] = outline[i]; - } else if ( outline[i].nLevel < level ) { - break; - } - } - return sections; - } - /** - * Builds unordered list HTML object from structured outline - * - * @param {Object} structure Structured outline - */ - function buildList( structure ) { - var list = $( '