-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslim.js
100 lines (88 loc) · 2.69 KB
/
slim.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
$(function(){
'use strict';
/////////////////// START: TEMPLATE SETTINGS /////////////////////
var loc = window.location.pathname;
var path = loc.split('/');
var isRtl = false;
var newloc = '';
// inject additional link tag for header skin
$('head').append('<link id="headerSkin" rel="stylesheet" href="">');
// show/hide template options panel
$('body').on('click', '.template-options-btn', function(e){
e.preventDefault();
$('.template-options-wrapper').toggleClass('show');
});
// set current page to light mode
$('body').on('click', '.skin-light-mode', function(e){
e.preventDefault();
newloc = loc.replace('template-dark', 'template');
$(location).attr('href', newloc);
});
// set current page to dark mode
$('body').on('click', '.skin-dark-mode', function(e){
e.preventDefault();
if(loc.indexOf('template-dark') >= 0) {
newloc = loc;
} else {
newloc = loc.replace('template', 'template-dark');
}
$(location).attr('href', newloc);
});
// set current page to rtl/ltr direction
$('body').on('click', '.slim-direction', function(){
var val = $(this).val();
if(val === 'rtl') {
if(!isRtl) {
if(path[3]) {
newloc = '/slim/'+path[2]+'-rtl/'+path[3];
} else {
newloc = '/slim/'+path[2]+'-rtl/';
}
$(location).attr('href', newloc);
}
} else {
if(isRtl) {
if(path[3]) {
newloc = '/slim/'+path[2].replace('-rtl','')+'/'+path[3];
} else {
newloc = '/slim/'+path[2].replace('-rtl','')+'/';
}
$(location).attr('href', newloc);
}
}
});
// toggles header to sticky
$('body').on('click', '.sticky-header', function(){
var val = $(this).val();
if(val === 'yes') {
$.cookie('sticky-header', 'true');
$('body').addClass('slim-sticky-header');
} else {
$.removeCookie('sticky-header');
$('body').removeClass('slim-sticky-header');
}
});
// set skin to header
$('body').on('click', '.header-skin', function(){
var val = $(this).val();
if(val !== 'default') {
$.cookie('header-skin', val);
$('#headerSkin').attr('href','../css/slim.'+val+'.css');
} else {
$.removeCookie('header-skin');
$('#headerSkin').attr('href', '');
}
});
// set page to wide
$('body').on('click', '.full-width', function(){
var val = $(this).val();
if(val === 'yes') {
$.cookie('full-width', 'true');
$('body').addClass('slim-full-width');
} else {
$.removeCookie('full-width');
$('body').removeClass('slim-full-width');
}
});
/////////////////// END: TEMPLATE SETTINGS /////////////////////
});