(function($){$.fn.unwink=function(){this.removeClass("lwss-repeat-wink");this.stop(!0);this.css('opacity',0)};$.fn.wink=function(){$(".lwss-repeat-wink").unwink();var delay=800;function repeatWink(){$(".lwss-repeat-wink").animate({opacity:1},delay).animate({opacity:0.7},delay,repeatWink)};this.addClass("lwss-repeat-wink");repeatWink();return this};$.fn.getCursorPosition=function(){var input=this.get(0);if(!input)return;if('selectionStart' in input){return(input.selectionDirection!='backward'?input.selectionStart:input.selectionEnd)}else if(document.selection){input.trigger('focus');var sel=document.selection.createRange();var selLen=document.selection.createRange().text.length;sel.moveStart('character',-input.value.length);return sel.text.length-selLen}}
$.fn.mergeInputs=function(src){var dest=this;var items=[];if(dest.val().length>0)
items=JSON.parse(dest.val());var found=!1;for(var i=0;i<items.length;i++){if(items[i][src.attr('name')]!=undefined){if(src.val().length<=0)
items.splice(i,1);else items[i][src.attr('name')]=src.val();found=!0;break}}
if(!found&&src.val().length>0){var elt={};elt[src.attr('name')]=src.val();items.push(elt)}
dest.val(JSON.stringify(items));return dest};$.fn.demoNormalCSS=function(){var elt=$(this);var main=elt.closest(".lwss-css-editor");var style=main.find("input.lwss-merge-css").val().split(';');for(var i=0,len=style.length;i<len;i++){var attr=style[i].split(':');if(attr[0]=='color'||attr[0]=='background-color')
elt.css(attr[0],attr[1]);}}
$.fn.demoHoverCSS=function(){var elt=$(this);var main=elt.closest(".lwss-css-editor");var style=main.find("input.lwss-merge-css").val().split(';');for(var i=0,len=style.length;i<len;i++){if(style[i].startsWith("hover-")){var attr=style[i].split(':');elt.css(attr[0].substring(6),attr[1])}}}
$.fn.demoFocusCSS=function(){var elt=$(this);var main=elt.closest(".lwss-css-editor");var style=main.find("input.lwss-merge-css").val().split(';');for(var i=0,len=style.length;i<len;i++){if(style[i].startsWith("active-")){var attr=style[i].split(':');elt.css(attr[0].substring(7),attr[1])}}}
$.fn.mergeCSS=function(demoOnly){var elt=this;var main=elt.hasClass("lwss-css-inputs")?elt:elt.closest(".lwss-css-inputs");var str='';var colorSet=!1;var bgColorSet=!1;main.find("input[data-css]").each(function(){if($(this).val().trim().length>0)
str+=$(this).data("css")+":"+$(this).val()+";";colorSet|=($(this).data("css")=='color');bgColorSet|=($(this).data("css")=='background-color')});main.find("select[data-css]").each(function(){if($(this).val().trim().length>0)
str+=$(this).data("css")+":"+$(this).val()+";";colorSet|=($(this).data("css")=='color');bgColorSet|=($(this).data("css")=='background-color')});main.find(".lwss-btn-color-demo[data-css]").each(function(){str+=$(this).data("css")+":"+$(this).css('background-color')+";";colorSet|=($(this).data("css")=='color');bgColorSet|=($(this).data("css")=='background-color')});if(demoOnly==undefined||!demoOnly)
main.find("input.lwss-merge-css").val(str);elt.closest(".lwss-css-editor").find(".lwss-css-example").each(function(){$(this).attr("style",str);if(!colorSet)$(this).css("color",($(this).lwsIsDark()?"white":"black"));if(!bgColorSet)$(this).css("background-color",($(this).lwsIsDark("color")?"white":"black"));});elt.closest(".lwss-css-editor").find(".lwss-toggle-states-N").each(function(){$(this).demoNormalCSS()});elt.closest(".lwss-css-editor").find(".lwss-toggle-states-O").each(function(){$(this).demoHoverCSS()});elt.closest(".lwss-css-editor").find(".lwss-toggle-states-F").each(function(){$(this).demoFocusCSS()});return elt}
$.fn.toggleBtn=function(){return this.each(function(){var src=$(this);var base='lws-btn-toggle-';var txt=(src.data('text')!=undefined?src.data('text'):'');src.css('display','none');var btn=src.next('.lws-btn-toggle');if(btn.length==0){btn=$("<div class='lws-btn-toggle'><span>"+txt+"</span></div>").insertAfter(src);if(src.data('class')!=undefined)
btn.addClass(src.data('class'));btn.on('click',function(){var state=(btn.hasClass(base+'on')?'off':'on');src.val(src.data(state));btn.removeClass(base+'on '+base+'off').addClass(base+state);src.trigger("change")})}
btn.removeClass(base+'on '+base+'off').addClass(src.val()==src.data('on')?base+'on':base+'off')})}})(jQuery)
jQuery(function($){$("input[data-master]").on('change',function(){$(this).mergeInputs($("input[name='"+$(this).data("master")+"']"))});$("input[data-master]").on('keyup',function(){$(this).mergeInputs($("input[name='"+$(this).data("master")+"']"))});function specificWink(elt){var target=".lwss-bloc-mark-"+elt.data("css");var v=elt.val().split(" ");if(v.length>1){var len=0,pos=0,cur=elt.getCursorPosition();for(pos=0;pos<v.length;pos++){len+=1+v[pos].length;if(len>cur)break}
if(v.length==2){target+=".lwss-bloc-mark-"+(pos==0?"v":"h")}else if(pos<4){var dest=["u","r","d","l"];target+=".lwss-bloc-mark-"+dest[pos]}}
elt.closest(".lwss-css-editor").find(target).wink()}
$(".lwss-tooltip[data-tooltip]").on('mouseover',function(){$('#lwss-tooltip-widget').remove();var tt=$(this).data("tooltip");if(tt.length>0)
$("<div id='lwss-tooltip-widget'>"+tt+"</div>").insertAfter($(this)).on('mouseleave',function(){$(this).remove()});return!1});$(".lwss-bloc-inputs input[data-css]").on('focusin',function(){specificWink($(this))}).on('keyup',function(){var t=$(this).data("css");specificWink($(this))}).on('click',function(){var t=$(this).data("css");specificWink($(this))}).on('focusout',function(){$(this).closest(".lwss-css-editor").find(".lwss-bloc-mark").unwink()});$(".lwss-css-inputs input[data-css]").on('change',function(){$(this).mergeCSS()});$(".lwss-css-inputs select[data-css]").on('change',function(){$(this).mergeCSS()});$(".lwss-css-inputs").each(function(){$(this).mergeCSS(!0)});$('.lws-font-size-part').on('change',function(){var p=$(this).closest('.lwss-text-size-select');var d=p.find("input[type='hidden']");if(d.length>0){d.val(p.find("input[data-part='val']").val()+p.find("select[data-part='unit']").val());d.trigger("change")}});$('.lws-src-btn-toggle').toggleBtn();$('.lwss-reset-btn').on('click',function(e){var id=$(e.target).attr('id');$("[data-source='"+id+"'][data-lwss]").each(function(){var me=$(this);if(me.hasClass('lwss-btn-color-demo')){me.css('background-color',me.data('lwss'));me.parent().find(".lwss-btn-color-value").html(me.data('lwss'));me.mergeCSS(!0)}else if(me.hasClass('lws-src-btn-toggle')){me.val(me.data('lwss'));me.toggleBtn();me.trigger('change')}else{me.val(me.data('lwss'));me.trigger('change')}
var main=me.hasClass("lwss-css-inputs")?me:me.closest(".lwss-css-inputs");if(main.length>0)main.find("input.lwss-merge-css").val('');})});function lwssButtonExampleRestoreColor(elt){var main=elt.closest(".lwss-css-editor");var style=main.find("input.lwss-merge-css").val().split(';');for(var i=0,len=style.length;i<len;i++){if(style[i].match('^(?!hover-|active-).*color.*')){var attr=style[i].split(':');elt.css(attr[0],attr[1])}}}
$('.lwss-button-example').on('hover',function(){$(this).demoHoverCSS()},function(){lwssButtonExampleRestoreColor($(this))});$('.lwss-button-example').on('mousedown',function(){$(this).demoFocusCSS()});$('.lwss-button-example').on('mouseup',function(){$(this).demoHoverCSS()});$('.lwss-input-button-toggle').on('click',function(){$(".lwss-hide-on-clic-out").fadeOut();$(".lwss-fold-on-clic-out").slideUp();if($(this).data('target')!=undefined){var elt=$(this).closest('.lwss-css-inputs').find($(this).data('target'));if(elt.is(':hidden'))elt.slideDown();return!1}})})