(function($){$.widget("lws.lws_styling_panel",{options:{stygen:undefined,},_create:function(){this.stygen=this.options.stygen;this.element.addClass("lwss-css-inputs");this.myInput=$("<input>").addClass("lwss-merge-css").attr("type","hidden").appendTo(this.element);this.myMainPanel=$("<div>").addClass("lwss-sp-main").appendTo(this.element);this.activeClass="";this._addEventPanel();this._addColorPanel();this._addTabsPanel();this._setTab("Text")},_bind:function(fn,me){return function(){return fn.apply(me,arguments)}},_addEventPanel:function(){this.myEventPanel=$("<div>").addClass("lwss-sp lwss-sp-event").appendTo(this.myMainPanel);myEventSelector=$("<div>").addClass("lwss-sp-event-icon lws-icon lws-icon-cursor").appendTo(this.myEventPanel);mySelectorLabel=$("<span>").html("Events").appendTo(myEventSelector);eventsDiv=$("<div>").addClass("lwss-sp-div lwss-sp-events-div").appendTo(this.myEventPanel);idleEvent=$("<div>").addClass("lwss-sp-events lws-icon lws-icon-idle").data("Event","idle").appendTo(eventsDiv);idleLabel=$("<div>").addClass("lwss-sp-events-label").html("Idle").appendTo(idleEvent);overEvent=$("<div>").addClass("lwss-sp-events lws-icon lws-icon-over").data("Event","hover").appendTo(eventsDiv);overLabel=$("<div>").addClass("lwss-sp-events-label").html("Over").appendTo(overEvent);clickEvent=$("<div>").addClass("lwss-sp-events lws-icon lws-icon-click").data("Event","focus").appendTo(eventsDiv);clickLabel=$("<div>").addClass("lwss-sp-events-label").html("Focus").appendTo(clickEvent);var me=this;$(".lwss-sp-events").on('click',function(){me.setEvent($(this).data("Event"))})},_addColorPanel:function(){this.myColorPanel=$("<div>").addClass("lwss-sp-color").appendTo(this.myMainPanel);myColorSelector=$("<div>").addClass("lwss-sp-color-selector lws-icon lws-icon-dropper").appendTo(this.myColorPanel);mySelectorLabel=$("<span>").html("Colors").appendTo(myColorSelector);colorsDiv=$("<div>").addClass("lwss-sp-div lwss-sp-colors-div").appendTo(this.myColorPanel);myColor=$("<div>").appendTo(colorsDiv).lwss_colorButton({"icon":"lws-icon lws-icon-text","showvalue":!1,"property":"color"});myBackgroundColor=$("<div>").appendTo(colorsDiv).lwss_colorButton({"icon":"lws-icon lws-icon-inkpot","showvalue":!1,"property":"background-color"})},_addTabsPanel:function(){this.myTabsPanel=$("<div>").addClass("lwss-sp-tabs-panel").appendTo(this.myMainPanel);this.myTabsSelectors=$("<ul>").addClass("lwss-sp-tselectors").appendTo(this.myTabsPanel);this.myTabs=$("<div>").addClass("lwss-sp-tabs").appendTo(this.myTabsPanel);this._addTextTab();this._addDisplayTab();this._addBorderTab();this._addContentTab();this.myTabsSelectors.on('mouseleave',this._bind(this._tSelLeave,this))},_addTextTab:function(){myTextSelector=$("<li>").addClass("lwss-sp-tselectors-text lwss_tselector lws-icon lws-icon-text").data("Tab","Text").appendTo(this.myTabsSelectors);mySelectorLabel=$("<span>").html("Text").appendTo(myTextSelector);myTextTab=$("<div>").addClass("lwss-sp-tabs-text lwss_sp_tab").data("Tab","Text").appendTo(this.myTabs);myTextSelector.on('mouseenter',this._bind(this._tSelEnter,this));var me=this;myTextSelector.on('click',function(){me._setTab($(this).data("Tab"))});myFirstLine=$("<div>").addClass("lwss-sp-tab-line").appendTo(myTextTab)
selValues=["100","200","300","normal","500","600","bold","800","900"];myFontWeight=$("<div>").appendTo(myFirstLine).lwss_select({"icon":"lws-icon lws-icon-text-2","cssColor":"lwss-ttext-color","property":"font-weight","values":selValues});myFontSize=$("<div>").appendTo(myFirstLine).lwss_size({"icon":"lws-icon lws-icon-scale-vertical","cssColor":"lwss-ttext-color","property":"font-size"});myLineHeight=$("<div>").appendTo(myFirstLine).lwss_size({"icon":"lws-icon lws-icon-line-height","cssColor":"lwss-ttext-color","property":"line-height"});selValues=["none","left","center","right","justify","inherit"];myTextAlign=$("<div>").appendTo(myFirstLine).lwss_select({"icon":"lws-icon lws-icon-align-left","cssColor":"lwss-ttext-color","property":"text-align","values":selValues});mySecondLine=$("<div>").addClass("lwss-sp-tab-line").appendTo(myTextTab)
selValues=["none","uppercase","capitalize","lowercase","initial","inherit"];myTextTransform=$("<div>").appendTo(mySecondLine).lwss_select({"icon":"lws-icon lws-icon-caps-small","cssColor":"lwss-ttext-color","property":"text-transform","values":selValues});selValues=["normal","italic","oblique","initial","inherit"];myTextItalic=$("<div>").appendTo(mySecondLine).lwss_select({"icon":"lws-icon lws-icon-italic","cssColor":"lwss-ttext-color","property":"font-style","values":selValues});selValues=["none","underline","overline","line-through","initial","inherit"];myTextDecoration=$("<div>").appendTo(mySecondLine).lwss_select({"icon":"lws-icon lws-icon-underline","cssColor":"lwss-ttext-color","property":"text-decoration","values":selValues})},_addDisplayTab:function(){myDisplaySelector=$("<li>").addClass("lwss-sp-tselectors-display lwss_tselector lws-icon lws-icon-full-screen").data("Tab","Display").appendTo(this.myTabsSelectors);mySelectorLabel=$("<span>").html("Display").appendTo(myDisplaySelector);myDisplayTab=$("<div>").addClass("lwss-sp-tabs-display lwss_sp_tab").data("Tab","Display").appendTo(this.myTabs);myDisplaySelector.on('mouseenter',this._bind(this._tSelEnter,this));var me=this;myDisplaySelector.on('click',function(){me._setTab($(this).data("Tab"))});myFirstLine=$("<div>").addClass("lwss-sp-tab-line").appendTo(myDisplayTab)
myMargin=$("<div>").appendTo(myFirstLine).lwss_4values({"icon":"lws-icon lws-icon-margin-left","cssColor":"lwss-tdisplay-color","property":"margin"});myPosition=$("<div>").appendTo(myFirstLine).lwss_4values({"icon":"lws-icon lws-icon-enlarge","cssColor":"lwss-tdisplay-color","property":"position"});mySecondLine=$("<div>").addClass("lwss-sp-tab-line").appendTo(myDisplayTab)
myPadding=$("<div>").appendTo(mySecondLine).lwss_4values({"icon":"lws-icon lws-icon-artboard","cssColor":"lwss-tdisplay-color","property":"padding"});myWidth=$("<div>").appendTo(mySecondLine).lwss_size({"icon":"lws-icon lws-icon-resize-h","cssColor":"lwss-tdisplay-color","property":"width"});myHeight=$("<div>").appendTo(mySecondLine).lwss_size({"icon":"lws-icon lws-icon-resize-v","cssColor":"lwss-tdisplay-color","property":"height"})},_addBorderTab:function(){myBorderSelector=$("<li>").addClass("lwss-sp-tselectors-border lwss_tselector lws-icon lws-icon-border").data("Tab","Border").appendTo(this.myTabsSelectors);mySelectorLabel=$("<span>").html("Border").appendTo(myBorderSelector);myBorderTab=$("<div>").addClass("lwss-sp-tabs-border lwss_sp_tab").data("Tab","Border").appendTo(this.myTabs);myBorderSelector.on('mouseenter',this._bind(this._tSelEnter,this));var me=this;myBorderSelector.on('click',function(){me._setTab($(this).data("Tab"))});myFirstLine=$("<div>").addClass("lwss-sp-tab-line").appendTo(myBorderTab)
myBorderWidth=$("<div>").appendTo(myFirstLine).lwss_4values({"icon":"lws-icon lws-icon-border-width","cssColor":"lwss-tborder-color","property":"border-width"});myBorderColor=$("<div>").appendTo(myFirstLine).lwss_colorButton({"icon":"lws-icon lws-icon-border","cssColor":"lwss-tborder-color","showvalue":!0,"property":"border-color"});mySecondLine=$("<div>").addClass("lwss-sp-tab-line").appendTo(myBorderTab)
myBorderRadius=$("<div>").appendTo(mySecondLine).lwss_4values({"icon":"lws-icon lws-icon-border-radius","cssColor":"lwss-tborder-color","property":"border-radius"});var selValues=["none","solid","dotted","dashed","double","groove","ridge","inset","outset","initial","inherit","hidden"]
myBorderStyle=$("<div>").appendTo(mySecondLine).lwss_select({"icon":"lws-icon lws-icon-border-style","cssColor":"lwss-tborder-color","property":"border-style","values":selValues})},_addContentTab:function(){myContentSelector=$("<li>").addClass("lwss-sp-tselectors-content lwss_tselector lws-icon lws-icon-edit").data("Tab","Content").appendTo(this.myTabsSelectors);mySelectorLabel=$("<span>").html("Content").appendTo(myContentSelector);myContentTab=$("<div>").addClass("lwss-sp-tabs-content lwss_sp_tab").data("Tab","Content").appendTo(this.myTabs);myContentSelector.on('mouseenter',this._bind(this._tSelEnter,this));var me=this;myContentSelector.on('click',function(){me._setTab($(this).data("Tab"))});myContentEditor=$("<div>").addClass("lwss-content-widget").appendTo(myContentTab).lwss_text_editor()},_tSelEnter:function(event){var Selector=$(event.delegateTarget);var me=this;this.element.find(".lwss_tselector").each(function(){if($(this).data("Tab")==Selector.data("Tab")){$(this).stop(!0,!1).animate({width:"100px"},200)}else{$(this).stop(!0,!1).animate({width:"30px"},200)}})},_tSelLeave:function(event){var me=this;this.element.find(".lwss_tselector").each(function(){if($(this).data("Tab")==me.activeSelector.data("Tab")){$(this).stop(!0,!1).animate({width:"100px"},200)}else{$(this).stop(!0,!1).animate({width:"30px"},200)}})},_setTab:function(tabName){this.activeTab=tabName;var me=this;this.element.find(".lwss_tselector").each(function(){if($(this).data("Tab")==me.activeTab){me.activeSelector=$(this);$(this).width(100)}else{$(this).width(30)}});this.element.find(".lwss_sp_tab").each(function(){if($(this).data("Tab")==me.activeTab){$(this).show()}else{$(this).hide()}})},setEvent:function(eventName){this.currentEvent=eventName;$(".lwss-sp-events").each(function(){$(this).removeClass("active");if($(this).data("Event")==eventName){$(this).addClass("active")}});var me=this;if(this.activeClass!=''){me._loadValues();me.stygen.element.find(me.activeClass).each(function(){$(this).removeClass("hovered");$(this).removeClass("focused");var currentValues=me.activeClassValues[me.currentEvent];if(currentValues!=undefined)$(this).css(currentValues);if(me.currentEvent=="hover")$(this).addClass("hovered");if(me.currentEvent=="hover")$(this).addClass("focused");})}},_resetValues:function(){if(this.activeClass!=""){var me=this;me.stygen.element.find(me.activeClass).each(function(){$(this).removeClass("hovered");$(this).removeClass("focused")})}
this.myEventPanel.show();this.activeClass="";this.activeClassValues=undefined;this.currentEvent="idle";this.element.find(".lwss_value").off("change",this._applyValues)
this.element.find(".lwss_value").each(function(){$(this).val(null).trigger("change")});this.element.find(".lwss_value").on("change",this._applyValues)},_applyValues:function(){var me=$(this).closest(".lwss_styling_panel").data("lws-lws_styling_panel");value=$(this).val();property=$(this).data("css");me.activeClassValues[me.currentEvent][property]=value;me.stygen.element.find(me.activeClass).each(function(){$(this).css(me.activeClassValues[me.currentEvent])});me.stygen.placeSelectors();me.stygen.makeCssChain()},_loadValues:function(){var me=this;this.element.find(".lwss_value").off("change",this._applyValues)
var currentValues=me.activeClassValues[me.currentEvent];if(currentValues!=undefined){this.element.find(".lwss_value").each(function(){if(currentValues[$(this).data("css")]!=undefined){$(this).val(currentValues[$(this).data("css")]).trigger("change")}})}
this.element.find(".lwss_value").on("change",this._applyValues)},openStylingPanel:function(className,inputId,currentItem){this._resetValues();this.activeClass=className;var classes=className.split(".");this.inputId=inputId;this.activeClassValues=this.stygen.masterObject[this.activeClass].cssValues;if(this.activeClassValues.hover==undefined&&this.activeClassValues.focus==undefined){this.myEventPanel.hide()}
if((-1!=jQuery.inArray("lwss_modify",classes))||('text'==currentItem.data('editable'))){this.myTabsPanel.find(".lwss-content-widget").lwss_text_editor("setId",this.inputId);this.myTabsPanel.find(".lwss-sp-tselectors-content").show();this._setTab("Content")}else{this.myTabsPanel.find(".lwss-sp-tselectors-content").hide();this._setTab("Text")}
this.setEvent("idle");this.stygen.makeCssChain()},resetActiveValues:function(){if(this.activeClass!=""){this.activeClassValues=this.stygen.masterObject[this.activeClass].cssValues;this._loadValues()}},})})(jQuery)