User:Canadabonk/common.js: Difference between revisions
Content deleted Content added
Canadabonk (talk | contribs) No edit summary |
Canadabonk (talk | contribs) No edit summary |
||
Line 1:
importScript('User:Canadabonk/sandbox.js');
enableEditButton = true;
var defaultDarkMode = false;▼
enableDarkMode = true;
enableFullwide = true;
defaultFullwide = false;
$(document).ready(function () {
const $body = $('body');
// desktop/tablet only
if ($(window).width() > 850 && $body.is('
//add sidetools wrapper
Line 14 ⟶ 22:
// if toc exists, add toc to sidetools
if ($('#toc').length && enableTOC) {
//add button html
const tocbuttonhtml = '<div class="ct-toc"><span class="ct-sidetools-button"></span></div>';
Line 71 ⟶ 79:
//edit button begin
if ($('#ca-viewsource, #ca-edit').length && enableEditButton) {
sidetools.append('<div class="ct-edit"><a class="ct-sidetools-button"></a></div>');
const
Line 92 ⟶ 100:
}
} // end edit button
//fullwide button begin
if (enableFullwide && $(window).width() > 1083) {
sidetools.prepend('<div class="ct-fullwide"><span class="ct-sidetools-button"></span></div>');
const fullwideButton = $('.ct-fullwide');
const fullwideIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z"/></svg>';
fullwideButton.html(fullwideIcon);
fullwideButton.attr('title', 'Fullscreen');
if (defaultFullwide && localStorage.ctFullwide == null) {
localStorage.ctFullwide = true;
}
if (localStorage.ctFullwide) {
$body.addClass('fullwide');
}
fullwideButton.click(function(){
$body.toggleClass('fullwide');
if ($body.is('.fullwide')) {
localStorage.ctFullwide = true;
} else {
localStorage.ctFullwide = false;
}
});
}
} //end desktop
Line 109 ⟶ 143:
if (localStorage.ctDarkMode) {
$
}
darkModeIconToggle();
darkModeButton.click(function(){
$
darkModeIconToggle();
if ($body.is('
localStorage.ctDarkMode = true;
} else {
Line 124 ⟶ 158:
function darkModeIconToggle() {
if ($body.is('
darkModeButton.html(sunIcon);
darkModeButton.attr('title', 'Switch to light mode');
} else {
darkModeButton.html(moonIcon);
darkModeButton.attr('title', 'Switch to dark mode');
}
}
|