- gitlist.git
- public
- js
- theme-switcher.js
This file ( 2kB ) exceeds the allowed full mode (48 kb) size.
The editor full hight is disabled, only scrolling is allowed..
If you wish to edit a file, it is recommended to use the scroll mode as some users do not like the full height
mode, although some users like it.
document.addEventListener("DOMContentLoaded", function(event) {
const themes = require('./themes.js')
const themeList = $('#theme-list');
const menuResponsive = require('./menu-responsive')
const debounceResize = menuResponsive({
menuList: themeList,
})
const Cookies = require('js-cookie')
const themeCookieName = 'gitlist-bootstrap-theme'
function getThemeCookie() {
const theme = Cookies.get(themeCookieName)
return theme || 'bootstrap-cosmo';
}
gitlist.getThemeCookie = getThemeCookie;
function setThemeCookie(theme) {
Cookies.set(themeCookieName, theme, { expires: 3650, path: '/' });
}
const currentCookie = getThemeCookie('gitlist-bootstrap-theme');
for(let key in themes) {
const menu = '<li class="' + (currentCookie === key ? 'active' : '') + '" style="text-transform: capitalize"><a href="#" data-theme="' + key + '" class="theme-link">' + key.substring(10) + '</a></li>';
themeList.append(menu);
}
gitlist.setCodeMirrorTheme(getThemeCookie())
const themesheet = $('#bootstrap-theme');
$('.theme-link').click(function(event){
debounceResize();
themeList.find('.active').removeClass('active');
const $this = $(this);
$this.parent().addClass('active');
const themeurl = themes[$this.attr('data-theme')];
setThemeCookie($this.attr('data-theme'));
const href = (gitlist.basepath === '/' ? '' : gitlist.basepath) + themeurl;
themesheet.attr('href', href);
gitlist.setCodeMirrorTheme(getThemeCookie())
event.preventDefault();
});
});