User:Canadabonk/common.js: Difference between revisions
Content deleted Content added
Canadabonk (talk | contribs) No edit summary |
Canadabonk (talk | contribs) No edit summary |
||
Line 20: | Line 20: | ||
// get contents of toc |
// get contents of toc |
||
const sidetoc = $('.ct-toc'); |
|||
⚫ | |||
$('#toc').find('ul').first().clone().appendTo('.ct-toc, #CosmosRailInner'); |
|||
⚫ | |||
const stickytoc = $('.ct-stickytoc'); |
const stickytoc = $('.ct-stickytoc'); |
||
Line 37: | Line 38: | ||
hideOnClickOutside('.ct-toc', '.ct-stickytoc'); |
hideOnClickOutside('.ct-toc', '.ct-stickytoc'); |
||
/ |
// siderail toc |
||
const railtoc = $('.ct-railtoc'); |
|||
$('#CosmosRailInner').find('ul').first().wrap('<section class="module ct-railtoc"></section>'); |
|||
railtoc.prepend('<div><h3>Contents</h3><span class="ct-toc-move">Move to sidetools</span></div>'); |
|||
if (localStorage.tocInRail) { |
|||
sidetoc.hide(); |
|||
railtoc.show(); |
|||
} else { |
|||
railtoc.hide(); |
|||
} |
|||
$('.ct-toc-move').click(function(){ |
$('.ct-toc-move').click(function(){ |
||
if ( |
if (sidetoc.is(':visible')) { |
||
sidetoc.hide(); |
|||
railtoc.show(); |
|||
localStorage.tocInRail = true; |
|||
} else { |
|||
railtoc.hide(); |
|||
sidetoc.show; |
|||
localStorage.removeItem('tocInRail'); |
|||
} |
} |
||
}); |
}); |
||
} |
} |