Make sure the TOC is there when toggleToc is called. Although the function calling...
authorKrinkle <krinkle@users.mediawiki.org>
Fri, 24 Dec 2010 13:44:24 +0000 (13:44 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Fri, 24 Dec 2010 13:44:24 +0000 (13:44 +0000)
resources/mediawiki.util/mediawiki.util.js

index 6b4534e..5f61236 100644 (file)
                 */
                'toggleToc' : function( $toggleLink ) {
                        var $tocList = $( '#toc ul:first' );
-
-                       if ( $tocList.is( ':hidden' ) ) {
-                               $tocList.slideDown( 'fast' );
-                               $toggleLink.text( mw.msg( 'hidetoc' ) );
-                               $.cookie( 'mw_hidetoc', null, {
-                                       expires: 30,
-                                       path: '/'
-                               } );
-                               return true;
+                       
+                       // This function shouldn't be called if there's no TOC,
+                       // but just in case...
+                       if ( $tocList.size() ) {
+                               if ( $tocList.is( ':hidden' ) ) {
+                                       $tocList.slideDown( 'fast' );
+                                       $toggleLink.text( mw.msg( 'hidetoc' ) );
+                                       $.cookie( 'mw_hidetoc', null, {
+                                               expires: 30,
+                                               path: '/'
+                                       } );
+                                       return true;
+                               } else {
+                                       $tocList.slideUp( 'fast' );
+                                       $toggleLink.text( mw.msg( 'showtoc' ) );
+                                       $.cookie( 'mw_hidetoc', '1', {
+                                               expires: 30,
+                                               path: '/'
+                                       } );
+                                       return false;
+                               }
                        } else {
-                               $tocList.slideUp( 'fast' );
-                               $toggleLink.text( mw.msg( 'showtoc' ) );
-                               $.cookie( 'mw_hidetoc', '1', {
-                                       expires: 30,
-                                       path: '/'
-                               } );
                                return false;
                        }
                },