From 115fca376e1470014a94376d82a62c00167a6b4a Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sat, 15 Apr 2017 08:45:25 +0200 Subject: [PATCH] Use .toc instead of #toc as selector for TOC Since 1bf5a652 multiple TOCs are supported. In CSS the selector #toc is kept for backward compatibility for uses in the content. Change-Id: I07036c0d5782420fc127781a15c675fc7e6fafaf --- resources/src/mediawiki.legacy/commonPrint.css | 3 ++- resources/src/mediawiki/mediawiki.toc.print.css | 1 + .../suites/resources/mediawiki/mediawiki.toc.test.js | 11 ++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/src/mediawiki.legacy/commonPrint.css b/resources/src/mediawiki.legacy/commonPrint.css index e3e80d858c..b4418e58c0 100644 --- a/resources/src/mediawiki.legacy/commonPrint.css +++ b/resources/src/mediawiki.legacy/commonPrint.css @@ -121,7 +121,8 @@ img { margin: 0 !important; /* stylelint-disable-line declaration-no-important */ } -#toc { +#toc, +.toc { background-color: #f9f9f9; border: 1pt solid #aaa; padding: 5px; diff --git a/resources/src/mediawiki/mediawiki.toc.print.css b/resources/src/mediawiki/mediawiki.toc.print.css index da2c08fd91..5f6eb2586d 100644 --- a/resources/src/mediawiki/mediawiki.toc.print.css +++ b/resources/src/mediawiki/mediawiki.toc.print.css @@ -1,4 +1,5 @@ #toc.tochidden, +.toc.tochidden, .toctoggle { display: none; } diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js index 70a7e35e52..8786993869 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js @@ -7,9 +7,9 @@ } ) ); QUnit.asyncTest( 'toggleToc', function ( assert ) { - var tocHtml, $toggleLink, $tocList; + var tocHtml, $toc, $toggleLink, $tocList; - assert.strictEqual( $( '#toc' ).length, 0, 'There is no table of contents on the page at the beginning' ); + assert.strictEqual( $( '.toc' ).length, 0, 'There is no table of contents on the page at the beginning' ); tocHtml = '
' + '
' + @@ -17,11 +17,12 @@ '
' + '' + '
'; - $( tocHtml ).appendTo( '#qunit-fixture' ); + $toc = $( tocHtml ); + $( '#qunit-fixture' ).append( $toc ); mw.hook( 'wikipage.content' ).fire( $( '#qunit-fixture' ) ); - $tocList = $( '#toc ul:first' ); - $toggleLink = $( '#toc .togglelink' ); + $tocList = $toc.find( 'ul:first' ); + $toggleLink = $toc.find( '.togglelink' ); assert.strictEqual( $toggleLink.length, 1, 'Toggle link is added to the table of contents' ); -- 2.20.1