(function($){$.widget("lws.lws_themer",{_create:function(){this.isOpen=!1;this.cssValues=lwsBase64.toObj(this.element.data('cssvalues'));this.prefix=this.element.data('prefix');this.bgLight=this.element.data('type');this.input=this.element.find('.lws_themer_chain');this.element.on("change",".lws-cp-input",this._bind(this._changedValue,this));this.element.on("click",".lws-themer-themsel-button",this._bind(this._themeSelButton,this));this.element.on("click",".lws-themer-lb-light",this._bind(this._selBg,this));this.element.on("click",".lws-themer-lb-dark",this._bind(this._selBg,this));this.element.on("click",".lws-themer-theme-div",this._bind(this._selTheme,this));this._setBackground()
this._setInitValues();this._setThemesSelectors();this._makeCssChain()},_bind:function(fn,me){return function(){return fn.apply(me,arguments)}},_setInitValues:function(){var me=this;this.element.find('.lws-color-picker').each(function(){var selector=me.prefix+this.id;var color=me.cssValues[selector]==undefined?'#aaaaaa':me.cssValues[selector];$(this).find('.lws-cp-input').val(color);$(this).find('.lws-cp-demo').css("background-color",color)})},_setThemesSelectors:function(){var me=this;this.element.find('.lws-themer-theme-div').each(function(){var title=$(this).data('title');var colors=lwsBase64.toObj($(this).data('colors'))
var titleColor=($(this).data('type')=="light")?"#666666":"#eeeeee";$("<div>",{'class':'lws-themer-tobj-colcont',}).append($("<div>",{'class':'lws-themer-tobj-main','css':{'background-color':colors[me.prefix+"main-color"]}})).append($("<div>",{'class':'lws-themer-tobj-smalls',}).append($("<div>",{'class':'lws-themer-tobj-small tobj-first','css':{'background-color':colors[me.prefix+"second-color"]}})).append($("<div>",{'class':'lws-themer-tobj-small','css':{'background-color':colors[me.prefix+"third-color"]}})).append($("<div>",{'class':'lws-themer-tobj-small','css':{'background-color':colors[me.prefix+"fourth-color"]}})).append($("<div>",{'class':'lws-themer-tobj-small','css':{'background-color':colors[me.prefix+"text-color"]}})).append($("<div>",{'class':'lws-themer-tobj-small','css':{'background-color':colors[me.prefix+"title-color"]}})).append($("<div>",{'class':'lws-themer-tobj-small tobj-last','css':{'background-color':colors[me.prefix+"highlight-color"]}}))).appendTo(this);$("<div>",{'class':'lws-themer-tobj-title','html':title,'css':{'color':titleColor}}).appendTo(this)})},_setBackground:function(){if(this.bgLight=="dark"){this.element.find('.lws-themer-top').css("background-color",'#2a3333')}else{this.element.find('.lws-themer-top').css("background-color",'#ffffff')}},_selBg:function(event){button=$(event.currentTarget);if(button.hasClass("lws-themer-lb-light")){this.bgLight="light"}else{this.bgLight="dark"}
this._setBackground();this._makeCssChain()},_themeSelButton:function(){if(!this.isOpen){this.element.find('.lws-themer-themes-panel').css('display','flex');this.isOpen=!0}else{this.element.find('.lws-themer-themes-panel').css('display','none');this.isOpen=!1}},_selTheme:function(event){var theme=$(event.currentTarget);var themeColors=lwsBase64.toObj(theme.data('colors'));this.bgLight=theme.data('type');this._setBackground();var me=this;this.element.find('.lws-color-picker').each(function(){var selector=me.prefix+this.id;$(this).find('.lws-cp-input').val(themeColors[selector]).trigger("change")});this.element.find('.lws-themer-themes-panel').css('display','none');this.isOpen=!1},_changedValue:function(event){var pickerInput=$(event.currentTarget);var picker=pickerInput.closest('.lws-color-picker');var selector=this.prefix+picker[0].id;document.documentElement.style.setProperty(selector,pickerInput.val());this._makeCssChain()},_makeCssChain:function(){var cssChain=':root{';var me=this;this.element.find('.lws-color-picker').each(function(){var selector=me.prefix+this.id;var cssValue=$(this).find('.lws-cp-input').val();cssChain+=selector+':'+cssValue+';'});cssChain+='--type:'+this.bgLight+';';cssChain+='}';this.input.val(lwsBase64.encode(cssChain))},})})(jQuery)
jQuery(function($){$(".lws_themer").lws_themer()})