-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle-customizer.js
270 lines (237 loc) · 12.1 KB
/
style-customizer.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2006, 2014 Klaus Hartl
* Released under the MIT license
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function c(a){return h.raw?a:encodeURIComponent(a)}function d(a){return h.raw?a:decodeURIComponent(a)}function e(a){return c(h.json?JSON.stringify(a):String(a))}function f(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(b," ")),h.json?JSON.parse(a):a}catch(c){}}function g(b,c){var d=h.raw?b:f(b);return a.isFunction(c)?c(d):d}var b=/\+/g,h=a.cookie=function(b,f,i){if(arguments.length>1&&!a.isFunction(f)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[c(b),"=",e(f),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=b?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=d(p.shift()),r=p.join("=");if(b&&b===q){l=g(r,f);break}b||void 0===(r=g(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
/*
Template Name:
Template URI:
Description:
Author URI:
Version: 1.0
NOTE: This is js of style customizer, This file Change the styling of color,
backgrond patterns, Background images and box layout of the actual Template.
so you can change as your requirement.
*/
/* style-customizer */
jQuery(document).ready(function($) {
/*************************
Left sidebar
*************************/
style_switcher = $('.style-customizer'),
panelWidth = style_switcher.outerWidth(true);
$('.style-customizer .opener').on("click", function(){
var $this = $(this);
if ($(".style-customizer.closed").length>0) {
style_switcher.animate({"left" : "0px"});
$(".style-customizer.closed").removeClass("closed");
$(".style-customizer").addClass("opened");
} else {
$(".style-customizer.opened").removeClass("opened");
$(".style-customizer").addClass("closed");
style_switcher.animate({"left" : '-' + panelWidth});
}
return false;
});
/*************************
style change
*************************/
var link = $('link[data-style="styles"]'),
link_no_cookie = $('link[data-style="styles-no-cookie"]');
/****************************************
Resume from last selected style
****************************************/
var tp_stylesheet = $.cookie('tp_stylesheet'),
footer_bg = $.cookie('footer_bg'),
customizer_mode = $.cookie('customizer_mode'),
pattern = $.cookie('pattern');
$(".style-customizer .selected").removeClass("selected");
if (!($.cookie('tp_stylesheet'))) {
$.cookie('tp_stylesheet', 'skin-default', 30);
tp_stylesheet = $.cookie('tp_stylesheet');
$('.style-customizer .styleChange li[data-style="'+tp_stylesheet+'"]').addClass("selected");
} else {
if (link.length>0) {
link.attr('href','css/color/' + tp_stylesheet + '.css');
$('.style-customizer .styleChange li[data-style="'+tp_stylesheet+'"]').addClass("selected");
if ($(".swicher-title-page-dark").length>0) {
document.getElementById("logo_img").src="images/customizer/logo/logo_dark_swicher-title_" + tp_stylesheet + ".png";
} else {
if ($("#logo_img").length>0) {
document.getElementById("logo_img").src="images/customizer/logo/logo_" + tp_stylesheet + ".png";
};
if ($("#logo_dark_img").length>0) {
document.getElementById("logo_dark_img").src="images/customizer/logo/dark/logo_" + tp_stylesheet + ".png";
};
if ($("#logo-footer").length>0) {
document.getElementById("logo-footer").src="images/customizer/logo/logo_" + tp_stylesheet + ".png";
};
};
};
};
if (!($.cookie('customizer_mode'))) {
$.cookie('customizer_mode', 'wide-layout', 30);
customizer_mode = $.cookie('customizer_mode');
$("body").addClass(customizer_mode);
$('.style-customizer .layoutstyle li[data-style="wide-layout"]').addClass("selected");
} else {
if (customizer_mode=="boxed-layout") {
$("body").addClass(customizer_mode);
$("body").removeClass("wide-layout");
$('.style-customizer .layoutstyle li[data-style="boxed-layout"]').addClass("selected");
$('.style-customizer .layoutstyle li[data-style="wide-layout"]').removeClass("selected");
$(".owl-carousel .container").css("marginLeft", "0");
} else {
$("body").addClass(customizer_mode);
$("body").removeClass("boxed-layout pattern-0 pattern-1 pattern-2 main-bg-1 main-bg-2");
$('.style-customizer .layoutstyle li[data-style="boxed-layout"]').removeClass("selected");
$('.style-customizer .layoutstyle li[data-style="wide-layout"]').addClass("selected");
$(".owl-carousel .container").css("marginLeft", "auto");
};
};
if ((customizer_mode =="boxed-layout") && $.cookie('pattern')) {
$('.style-customizer .patternChange li[data-style="'+pattern+'"]').addClass("selected");
$("body").removeClass("pattern-0 pattern-1 pattern-2 main-bg-1 main-bg-2");
$("body").addClass(pattern);
} else if (customizer_mode =="boxed-layout") {
$("body").removeClass("pattern-0 pattern-1 pattern-2 main-bg-1 main-bg-2");
$('.style-customizer .patternChange li[data-style="pattern-0"]').addClass("selected");
} else {
$('.style-customizer .patternChange li.selected').removeClass("selected");
$("body").removeClass("pattern-0 pattern-1 pattern-2 main-bg-1 main-bg-2");
};
/*************************
Color Changer
*************************/
$('.style-customizer .styleChange li').on('click',function(){
if (link.length>0) {
var $this = $(this),
tp_stylesheet = $this.data('style');
$(".style-customizer .styleChange .selected").removeClass("selected");
$this.addClass("selected");
link.attr('href', 'css/color/' + tp_stylesheet + '.css');
if ($(".swicher-title-page-dark").length>0) {
document.getElementById("logo_img").src="images/customizer/logo/logo_dark_swicher-title_" + tp_stylesheet + ".png";
} else {
if ($("#logo_img").length>0) {
document.getElementById("logo_img").src="images/customizer/logo/logo_" + tp_stylesheet + ".png";
};
if ($("#logo_dark_img").length>0) {
document.getElementById("logo_dark_img").src="images/customizer/logo/dark/logo_" + tp_stylesheet + ".png";
};
if ($("#logo-footer").length>0) {
document.getElementById("logo-footer").src="images/customizer/logo/logo_" + tp_stylesheet + ".png";
};
};
$.cookie('tp_stylesheet', tp_stylesheet, 30);
} else {
var $this = $(this),
tp_stylesheet_no_cookie = $this.data('style');
$(".style-customizer .styleChange .selected").removeClass("selected");
$this.addClass("selected");
link_no_cookie.attr('href', 'css/color/' + tp_stylesheet_no_cookie + '.css');
if ($(".swicher-title-page-dark").length>0) {
document.getElementById("logo_img").src="images/customizer/logo/logo_dark_swicher-title_" + tp_stylesheet_no_cookie + ".png";
} else {
if ($("#logo_img").length>0) {
document.getElementById("logo_img").src="images/customizer/logo/logo_" + tp_stylesheet_no_cookie + ".png";
};
if ($("#logo_dark_img").length>0) {
document.getElementById("logo_dark_img").src="images/customizer/logo/dark/logo_" + tp_stylesheet_no_cookie + ".png";
};
if ($("#logo-footer").length>0) {
document.getElementById("logo-footer").src="images/customizer/logo/logo_" + tp_stylesheet_no_cookie + ".png";
};
};
};
});
/*************************
Patterns Changer
*************************/
$('.style-customizer .patternChange li').on('click',function(){
var $this = $(this),
pattern = $this.data('style');
$(".style-customizer .patternChange .selected").removeClass("selected");
$this.addClass("selected");
$("body").removeClass("pattern-0 pattern-1 pattern-2 main-bg-1 main-bg-2");
$("body").addClass(pattern);
$("body").addClass("boxed-layout");
$('.style-customizer .layoutstyle li[data-style="boxed-layout"]').addClass("selected");
$('.style-customizer .layoutstyle li[data-style="wide-layout"]').removeClass("selected");
$(".owl-carousel .container").css("marginLeft", "0");
$(".style-customizer select").val("boxed-layout");
$.cookie('pattern', pattern, 30);
$.cookie('customizer_mode', 'boxed-layout', 30);
$(window).trigger('resize');
});
/*********************************************
layout Changer (boxed Layout)
**********************************************/
$('.style-customizer .layoutstyle li.boxed-layout').on('click',function(){
$("body").addClass("boxed-layout");
$("body").removeClass("wide-layout");
$('.style-customizer .layoutstyle li[data-style="boxed-layout"]').addClass("selected");
$('.style-customizer .layoutstyle li[data-style="wide-layout"]').removeClass("selected");
$(".owl-carousel .container").css("marginLeft", "0");
$.cookie('customizer_mode', 'boxed-layout', 30);
if ($.cookie('pattern')) {
var pattern = $.cookie('pattern');
$('.style-customizer .patternChange li[data-style="'+pattern+'"]').addClass("selected");
$("body").removeClass("pattern-0 pattern-1 pattern-2 main-bg-1 main-bg-2");
$("body").addClass(pattern);
} else {
$('.style-customizer .patternChange li[data-style="pattern-0"]').addClass("selected");
}
$(window).trigger('resize');
});
/*********************************************
layout Changer (Wide Layout)
**********************************************/
$('.style-customizer .layoutstyle li.wide-layout').on('click',function(){
$("body").addClass("wide-layout");
$("body").removeClass("boxed-layout pattern-0 pattern-1 main-bg-1 main-bg-2");
$("body").removeClass("");
$('.style-customizer .layoutstyle li[data-style="boxed-layout"]').removeClass("selected");
$('.style-customizer .layoutstyle li[data-style="wide-layout"]').addClass("selected");
$(".owl-carousel .container").css("marginLeft", "auto");
$('.style-customizer .patternChange li.selected').removeClass("selected");
$.cookie('customizer_mode', 'wide-layout', 30);
$(window).trigger('resize');
});
/**************************************
Reset all customize styles
**************************************/
$('.style-customizer .resetAll li a.button-reset').on('click',function() {
$.cookie('customizer_mode', 'wide-layout', 30);
$("body").addClass("wide-layout");
$("body").removeClass("boxed-layout");
$('.style-customizer .layoutstyle li[data-style="boxed-layout"]').removeClass("selected");
$('.style-customizer .layoutstyle li[data-style="wide-layout"]').addClass("selected");
$(".owl-carousel .container").css("marginLeft", "auto");
$('.style-customizer .patternChange li.selected').removeClass("selected");
//patterns and backgrond change
$.cookie('pattern', 'pattern-0', 30);
$("body").removeClass("reset pattern-0 pattern-1 pattern-2 main-bg-1 main-bg-2");
$(".style-customizer .patternChange .selected").removeClass("selected");
//Logo change
$.cookie('tp_stylesheet', 'skin-default', 30);
var tp_stylesheet = 'skin-default';
$('.style-customizer .styleChange li.selected').removeClass("selected");
$('.style-customizer .styleChange li[data-style="'+tp_stylesheet+'"]').addClass("selected");
link.attr('href', 'css/color/' + tp_stylesheet + '.css');
if ($("#logo_img").length>0) {
document.getElementById("logo_img").src="images/customizer/logo/logo_" + tp_stylesheet + ".png";
};
if ($("#logo_dark_img").length>0) {
document.getElementById("logo_dark_img").src="images/customizer/logo/dark/logo_" + tp_stylesheet + ".png";
};
if ($("#logo-footer").length>0) {
document.getElementById("logo-footer").src="images/customizer/logo/logo_" + tp_stylesheet + ".png";
};
$(window).trigger('resize');
$('.desktopTopFixed').removeClass('desktopTopFixed');
});
});