Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -147,22 +147,28 @@ |
148 | 148 | */ |
149 | 149 | 'toggleToc' : function( $toggleLink ) { |
150 | 150 | 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 | + } |
160 | 172 | } else { |
161 | | - $tocList.slideUp( 'fast' ); |
162 | | - $toggleLink.text( mw.msg( 'showtoc' ) ); |
163 | | - $.cookie( 'mw_hidetoc', '1', { |
164 | | - expires: 30, |
165 | | - path: '/' |
166 | | - } ); |
167 | 173 | return false; |
168 | 174 | } |
169 | 175 | }, |