r78959 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78958‎ | r78959 | r78960 >
Date:13:44, 24 December 2010
Author:krinkle
Status:ok
Tags:
Comment:
Make sure the TOC is there when toggleToc is called. Although the function calling it checks it too, it could be called by a third party, or the TOC could've dissapeared :O (Follow-up r78941)
Modified paths:
  • /trunk/phase3/resources/mediawiki.util/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js
@@ -147,22 +147,28 @@
148148 */
149149 'toggleToc' : function( $toggleLink ) {
150150 var $tocList = $( '#toc ul:first' );
151 -
152 - if ( $tocList.is( ':hidden' ) ) {
153 - $tocList.slideDown( 'fast' );
154 - $toggleLink.text( mw.msg( 'hidetoc' ) );
155 - $.cookie( 'mw_hidetoc', null, {
156 - expires: 30,
157 - path: '/'
158 - } );
159 - return true;
 151+
 152+ // This function shouldn't be called if there's no TOC,
 153+ // but just in case...
 154+ if ( $tocList.size() ) {
 155+ if ( $tocList.is( ':hidden' ) ) {
 156+ $tocList.slideDown( 'fast' );
 157+ $toggleLink.text( mw.msg( 'hidetoc' ) );
 158+ $.cookie( 'mw_hidetoc', null, {
 159+ expires: 30,
 160+ path: '/'
 161+ } );
 162+ return true;
 163+ } else {
 164+ $tocList.slideUp( 'fast' );
 165+ $toggleLink.text( mw.msg( 'showtoc' ) );
 166+ $.cookie( 'mw_hidetoc', '1', {
 167+ expires: 30,
 168+ path: '/'
 169+ } );
 170+ return false;
 171+ }
160172 } else {
161 - $tocList.slideUp( 'fast' );
162 - $toggleLink.text( mw.msg( 'showtoc' ) );
163 - $.cookie( 'mw_hidetoc', '1', {
164 - expires: 30,
165 - path: '/'
166 - } );
167173 return false;
168174 }
169175 },

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78941Porting tocToggle to ResourceLoader...krinkle00:55, 24 December 2010

Status & tagging log