mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-02 11:11:21 +01:00
Theme color now stored in localStorage (Stays constant even after browser is closed)
This commit is contained in:
parent
bf3044cb03
commit
7e743a4eaf
@ -1,6 +1,8 @@
|
||||
$(function () {
|
||||
skinChanger();
|
||||
|
||||
setSkin();
|
||||
|
||||
setSkinListHeightAndScroll(true);
|
||||
$(window).resize(function () {
|
||||
setSkinListHeightAndScroll(false);
|
||||
@ -18,17 +20,40 @@ function skinChanger() {
|
||||
$body.removeClass('theme-' + existTheme);
|
||||
$this.addClass('active');
|
||||
|
||||
$body.addClass('theme-' + $this.data('theme'));
|
||||
var theme = $this.data('theme');
|
||||
$body.addClass('theme-' + theme);
|
||||
localStorage.setItem("plan_skin", theme.toString());
|
||||
});
|
||||
}
|
||||
|
||||
function setSkin() {
|
||||
var theme = localStorage.getItem("plan_skin");
|
||||
if (theme === null) {
|
||||
theme = 'light-green'
|
||||
}
|
||||
var body = document.getElementsByTagName('body')[0];
|
||||
|
||||
var classes = body.className.split(' ');
|
||||
var themeClass;
|
||||
for (i = 0; i < classes.length; i++) {
|
||||
if (classes[i].startsWith('theme')) {
|
||||
themeClass = classes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
body.classList.remove(themeClass);
|
||||
body.classList.add('theme-' + theme);
|
||||
localStorage.setItem("plan_skin", theme);
|
||||
}
|
||||
|
||||
//Skin tab content set height and show scroll
|
||||
function setSkinListHeightAndScroll(isFirstTime) {
|
||||
var height = $(window).height() - ($('.navbar').innerHeight() + $('.right-sidebar .nav-tabs').outerHeight());
|
||||
var $el = $('.demo-choose-skin');
|
||||
|
||||
if (!isFirstTime){
|
||||
$el.slimScroll({ destroy: true }).height('auto');
|
||||
if (!isFirstTime) {
|
||||
$el.slimScroll({destroy: true}).height('auto');
|
||||
$el.parent().find('.slimScrollBar, .slimScrollRail').remove();
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@
|
||||
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
var tabs = document.getElementsByClassName("tab");
|
||||
var slideIndex = window.sessionStorage.getItem("AnalysisSlideIndex");
|
||||
var slideIndex = window.sessionStorage.getItem("NetworkSlideIndex");
|
||||
if (slideIndex === null) {
|
||||
slideIndex = 0;
|
||||
}
|
||||
@ -384,7 +384,7 @@
|
||||
if (slideIndex < 0) {
|
||||
slideIndex = max
|
||||
}
|
||||
window.sessionStorage.setItem("AnalysisSlideIndex", slideIndex);
|
||||
window.sessionStorage.setItem("NetworkSlideIndex", slideIndex);
|
||||
var value = slideIndex * percent;
|
||||
x.style.transition = "0.5s";
|
||||
x.style.transform = "translate3d(" + value + "%,0px,0)";
|
||||
|
@ -562,7 +562,7 @@
|
||||
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
var tabs = document.getElementsByClassName("tab");
|
||||
var slideIndex = window.sessionStorage.getItem("AnalysisSlideIndex");
|
||||
var slideIndex = window.sessionStorage.getItem("InspectSlideIndex");
|
||||
if (slideIndex === null) {
|
||||
slideIndex = 0;
|
||||
}
|
||||
@ -602,7 +602,7 @@
|
||||
if (slideIndex < 0) {
|
||||
slideIndex = max
|
||||
}
|
||||
window.sessionStorage.setItem("AnalysisSlideIndex", slideIndex);
|
||||
window.sessionStorage.setItem("InspectSlideIndex", slideIndex);
|
||||
var value = slideIndex * percent;
|
||||
x.style.transition = "0.5s";
|
||||
x.style.transform = "translate3d(" + value + "%,0px,0)";
|
||||
|
Loading…
Reference in New Issue
Block a user