(function(d,b){b.FormController=can.Control.extend({optionCtrlsByForm:{},formsReady:!1,expectedFormsList:[],availabilityFormList:function(){var a={};switch(b.Vars.page.type){case "slider":a={SliderFormController:!1};break;case "slide":a={SlideFormController:!1,LayerSettingsForm:!1,StyleEditorForm:!1}}return a}(),init:function(){this.expectedFormsList=Object.keys(this.availabilityFormList)},resetOptions:function(){console.log("SUPER resetOptions")},registerCtrls:function(a,c){this.optionCtrlsByForm[a]=
c},getCtrls:function(a){return this.optionCtrlsByForm.hasOwnProperty(a)?this.optionCtrlsByForm[a]:!1},ready:function(){var a=this.shortName;if(-1<d.inArray(a,this.expectedFormsList)){var c=!0,e=this.expectedFormsList.length;this.availabilityFormList[a]=!0;for(a=0;a<e;a++)c=c&&this.availabilityFormList[this.expectedFormsList[a]];can.event.dispatch.call(this,"formReady");c&&(this.formsReady=!0,can.event.dispatch.call(b.FormController,"allFormsReady"))}}},{id:null,element:null,optionControllers:{},settings:{},
dependency:{},disabled_dependency:{},optionsContainer:"page",dependencyTypes:{dependency:"visibility",disabled_dependency:"disabled"},init:function(a,c){this.element=a;this.settings=c;this.id=b.Vars.page.id;this.dependency={};this.disabled_dependency={};this.setOptionControllers();this.updateOptionControllers();this.showAllDependencies();b.FormController.registerCtrls(this.optionsContainer,this.optionControllers);can.trigger(this,"initFinish")},setOptionControllers:function(){var a=this,c=a.element.find(".mpsl-option"),
b={showErrorType:this.settings.showErrorType};d.each(c,function(c,g){var h=a.createOptionController(d(g),b),l=h.getName();a.optionControllers[l]=h})},updateOptionControllers:function(){var a=this;d.each(b.Vars[this.optionsContainer].options,function(c,b){b.hasOwnProperty("actions")&&d.each(b.actions,function(b,e){a.optionControllers.hasOwnProperty(c)&&a.optionControllers[c].addAction(b,e)});b.hasOwnProperty("helpers")&&d.each(b.helpers,function(b,e){a.optionControllers.hasOwnProperty(c)&&a.optionControllers[c].addHelper(e,
a.optionControllers[e])});b.hasOwnProperty("options")&&d.each(b.options,function(c,b){b.hasOwnProperty("helpers")&&d.each(b.helpers,function(b,e){a.optionControllers.hasOwnProperty(c)&&a.optionControllers[c].addHelper(e,a.optionControllers[e])})})})},createOptionController:function(a,c){var e;e=a.attr("data-mpsl-option-type");var f=a.hasClass("mpsl-nested-option"),g="";f&&(g=a.attr("data-parent-name"),g=this.optionControllers[g]);d.extend(c,{isNested:f,parentOption:f?g:{},form:this});switch(e){case "text":e=
new b.TextControl(d(a),c);break;case "number":e=new b.NumberControl(d(a),c);break;case "textarea":e=new b.TextareaControl(d(a),c);break;case "tiny_mce":e=new b.TinyMCEControl(d(a),c);break;case "checkbox":e=new b.CheckboxControl(d(a),c);break;case "select":e=new b.SelectControl(d(a),c);break;case "radio_group":e=new b.RadioGroupControl(d(a),c);break;case "radio_buttons":e=new b.RadioButtonsControl(d(a),c);break;case "button_group":e=new b.ButtonGroupControl(d(a),c);break;case "action_group":e=new b.ActionGroupControl(d(a),
c);break;case "pretty_select":e=new b.PrettySelectControl(d(a),c);break;case "library_image":e=new b.ImageLibraryControl(d(a),c);break;case "library_video":e=new b.VideoLibraryControl(d(a),c);break;case "image_url":e=new b.ImageUrlControl(d(a),c);break;case "hidden":e=new b.HiddenControl(d(a),c);break;case "alias":e=new b.AliasControl(d(a),c);break;case "shortcode":e=new b.ShortcodeControl(d(a),c);break;case "align_table":e=new b.AlignTableControl(d(a),c);break;case "datepicker":e=new b.DatePickerControl(d(a),
c);break;case "codemirror":e=new b.CodeMirrorControl(d(a),c);break;case "style_editor":e=new b.StyleEditorControl(d(a),c);break;case "multiple":e=new b.MultipleControl(d(a),c);break;case "font_picker":e=new b.FontPickerControl(d(a),c);break;case "color_picker":e=new b.ColorPickerControl(d(a),c);break;case "text_shadow":e=new b.TextShadowControl(d(a),c);break;case "animation_control":e=new b.AnimationControl(d(a),c);break;case "weight_clone_select":e=new b.WeightCloneSelectControl(d(a),c);break;default:e=
new b.OptionControl(d(a),c)}this.addDependency(e);return e},addDependency:function(a,c){var b=this;if("undefined"===typeof c)return d.each(this.dependencyTypes,function(c){b.addDependency(a,c)}),!1;var f=a.getDependency(c);"undefined"!==typeof f&&("object"===typeof f.value&&(f.value=[f.operator,f.value.join(",")].join(";")),this[c][f.parameter]||(this[c][f.parameter]={}),this[c][f.parameter][f.value]||(this[c][f.parameter][f.value]=[]),this[c][f.parameter][f.value].push(a.getName()))},showDependencedOptions:function(a,
c){var b=this;if("undefined"===typeof c)return d.each(this.dependencyTypes,function(c){b.showDependencedOptions(a,c)}),!1;var f,g,h=!1,l=b.dependencyTypes[c];if(b[c].hasOwnProperty(a)){var m=b.optionControllers[a],n=m.getValue();d.isArray(n)||(n=[n]);d.each(b[c][a],function(k,p){k=k.split(";");g=k[0];k=k[1].split(",");d.each(k,function(a,c){k[a]=m.fixValueType(c)});d.each(p,function(m,p){h=!1;b.optionControllers[a].isOptionEnabled(l)&&(f=[],d.each(n,function(a,c){f[a]=d.grep(k,function(a){return a==
c});f[a]=!("!IN"===g?f[a].length:!f[a].length)}),"IN"===g?h=-1<d.inArray(!0,f):"!IN"===g?h=-1===d.inArray(!1,f):(h=d.grep(f,function(a){return!0===a}),h=h.length===k.length&&-1===d.inArray(!1,f)));b.optionControllers[p][h?"enable":"disable"](l);b.showDependencedOptions(b.optionControllers[p].getName(),c)})})}},showAllDependencies:function(){var a=this;d.each(this.dependencyTypes,function(c,b){d.each(a[c],function(b,e){a.showDependencedOptions(b,c)})})},verifyOptions:function(){var a=!0;d.each(this.optionControllers,
function(c,b){if(b.isOptionEnabled()&&b.isOptionEnabled("disabled")&&!b.verifyOption())return a=!1});return a},getFormData:function(){var a={};d.each(this.optionControllers,function(c,b){var d=b.getGroupName();"undefined"===typeof a[d]&&(a[d]={});b.isOptionEnabled()&&(a[d][c]=b.getValue())});return a},getOptionsList:function(){var a={};d.each(this.optionControllers,function(c,b){b.isOptionEnabled()&&(a[c]=b.getValue())});return a},getOption:function(a){return"undefined"===typeof this.optionControllers[a]?
!1:this.optionControllers[a]},render:function(){}})})(jQuery,MPSL);
(function(d,b){b.OptionControl=can.Control.extend({defaults:{}},{settings:{},controls:[],helpers:{},actions:{},element:null,form:null,isNested:!1,isLayoutDependent:!1,parentOption:{},childOptions:{},showErrorType:"popup",containerType:"",setup:function(a,c){this._super(a,c);this.setElement(a)},init:function(a,c){this.elementWrapper=a.closest(".mpsl-option-wrapper");a.closest(".mpsl_layers_wrapper").length?this.containerType="layer":a.closest(".mpsl-style-editor-wrapper").length?this.containerType=
"preset":this.containerType="page";this.name=a.attr("data-name");this.group=a.closest("[data-group]").attr("data-group");this.helpers={};this.actions={};this.form=c.form;this.isNested=c.isNested;this.parentOption=c.parentOption;this.childOptions={};this.isNested&&this.parentOption.addChild(this);c.hasOwnProperty("showErrorType")&&(this.showErrorType=c.showErrorType);this.settings=b.Vars[this.containerType].options[this.name];this.isMultiValue=this.settings.hasOwnProperty("list");this.isLayoutDependent=
this.settings.hasOwnProperty("layout_dependent")&&this.settings.layout_dependent;this.disabledEnabled=this.enabled=this.valid=!0},setElement:function(a){this.element=a.find("input")},addChild:function(a){this.childOptions[a.getName()]=a},getName:function(){return this.name},getLabel:function(){return this.settings.hasOwnProperty("label")&&this.settings.label?this.settings.label:this.settings.hasOwnProperty("label2")&&this.settings.label2?this.settings.label2:this.getName()},getDependency:function(a){return this.settings[a]},
getGroupName:function(){return this.group},getValue:function(){return this.element.val()},setValue:function(a,c){this.element.val(a);"undefined"!==typeof c&&c?can.trigger(this.element,"silentChange"):this.element.change()},isAdjustment:function(){return!1},getDefault:function(){var a=this.settings["default"];this.form.optionControllers.hasOwnProperty(this.name)&&this.isLayoutDependent&&(a=a[b.Layout.getLayout()]);return a},showError:function(a){b.Functions.showMessage(a,b.Functions.MSG_ERROR_TYPE)},
hideError:function(){},verifyOption:function(){return!0},isValid:function(){return this.valid},isOptionEnabled:function(a){switch("undefined"===typeof a?"visibility":a){case "visibility":return this.enabled;case "disabled":return this.disabledEnabled}return!1},enable:function(a){switch("undefined"===typeof a?"visibility":a){case "visibility":this.enabled=!0;this.elementWrapper.removeClass("mpsl-dependency-hide");break;case "disabled":this.disabledEnabled=!0,this.element.removeAttr("disabled")}},disable:function(a){switch("undefined"===
typeof a?"visibility":a){case "visibility":this.enabled=!1;this.elementWrapper.addClass("mpsl-dependency-hide");break;case "disabled":this.disabledEnabled=!1,this.element.attr("disabled","disabled")}},linkForm:function(a){this.form=a},addHelper:function(a,c){this.helpers[a]=c},addAction:function(a,c){var b=this;this.actions[a]={};d.each(c,function(c,d){b.actions[a][c]={};b.actions[a][c].ctrl=b.form.optionControllers[c];b.actions[a][c].value=d})},fixValueType:function(a){return a},change:function(){this.form.showDependencedOptions(this.getName());
this.verifyOption()&&this.form.render()},silentChange:function(){}})})(jQuery,MPSL);(function(d,b){b.TextControl=b.OptionControl.extend({},{verifyOption:function(){if(this.settings.hasOwnProperty("required")&&1==this.settings.required){if(""===this.getValue())return this.showError(b.Vars.lang.emptyInputError.replace("%s",this.getLabel())),!1}else this.hideError();return!0}})})(jQuery,MPSL);
(function(d,b){b.NumberControl=b.OptionControl.extend({},{verifyOption:function(){var a=this.getValue();if(!a)return this.settings.hasOwnProperty("required")&&this.settings.required?(this.showError(b.Vars.lang.emptyInputError.replace("%s",this.getLabel())),!1):!0;if(!(new RegExp(/^[+-]?(\d+[.])?\d+$/)).test(a))return this.showError(b.Vars.lang.validate_digitals_only.replace("%s",this.getLabel())),!1;if(this.settings.hasOwnProperty("min")&&a<this.settings.min)return this.showError(b.Vars.lang.validate_less_min.replace("%s",
this.getLabel()).replace("%d",this.settings.min)),!1;if(this.settings.hasOwnProperty("max")&&a>this.settings.max)return this.showError(b.Vars.lang.validate_greater_max.replace("%s",this.getLabel()).replace("%d",this.settings.max)),!1;this.hideError();return!0},"input keydown":function(a,c){var b=this.getValue(),b=!isNaN(parseFloat(b))&&isFinite(b)?parseFloat(b):0;"38"==c.keyCode?this.setValue(b+1):"40"==c.keyCode&&this.setValue(b-1)}})})(jQuery,MPSL);
(function(d,b){b.TextareaControl=b.OptionControl.extend({},{setElement:function(a){this.element=a.find("textarea")}})})(jQuery,MPSL);
(function(d,b){b.TinyMCEControl=b.OptionControl.extend({},{ready:null,editorWrapper:null,editorArea:null,init:function(a,c){this._super(a,c);this.editorWrapper=a.find(".wp-editor-wrap");this.editorArea=a.find("#mpsl-text");this.initTinyMCE()},initTinyMCE:function(){var a=this,c=b.Vars.settings.alt_prefix+a.name,e=d.Deferred();this.ready=e.promise();if("4"===tinyMCE.majorVersion)tinyMCE.on("AddEditor",function(a){if(a.editor.id===c)a.editor.on("init",function(c){e.resolve(a.editor)})});else tinyMCE.onAddEditor.add(function(a,
b){b.editorId===c&&b.onInit.add(function(a){e.resolve(a)})});d.when(a.ready).then(function(c){a.editor=c;a.element.find(".wp-switch-editor.switch-tmce").on("click",a.proxy("change"));a.editorArea.on("change keyup paste blur",a.proxy("change"));if("4"===tinyMCE.majorVersion)c.on("keyup change",a.proxy("change"));else a.editor.onKeyUp.add(a.proxy("change")),a.editor.onChange.add(a.proxy("change"));a.editor.addCommand("mpsl_post_macros",a.proxy("change"))})},getValue:function(){return this.editor?this.editorWrapper.hasClass("tmce-active")?
this.editor.getContent():this.editorArea.val():""},setValue:function(a,c){c="undefined"!==typeof c?c:!1;this.editor&&(this.editor.undoManager.clear(),this.editorWrapper.hasClass("tmce-active")?this.editor.setContent(a):this.editorArea.val(a),c||this.element.change())},setElement:function(a){this.element=a}})})(jQuery,MPSL);
(function(d,b){b.CodeMirrorControl=b.TextareaControl.extend({refreshEditors:function(a){a="undefined"===typeof a?d("body"):a;a.length&&(a.hasClass("mpsl-option-codemirror")?a.find(".CodeMirror").get(0).CodeMirror.refresh():a.find(".mpsl-option-codemirror .CodeMirror").each(function(){this.CodeMirror.refresh()}))}},{codeMirrorElement:{},init:function(a,c){this._super(a,c);this.CodeMirrorObj=CodeMirror.fromTextArea(this.element.get(0),{lineNumbers:!0,mode:"undefined"!==typeof this.settings.mode?this.settings.mode:
null});this.codeMirrorElement=this.element.next();this.CodeMirrorObj.on("change",this.proxy("onCodemirrorChange"))},onCodemirrorChange:function(){var a=this;if(this.codeMirrorElement.is(":visible"))var c=setTimeout(function(){a.element.change();clearTimeout(c)},1)},getValue:function(){return this.CodeMirrorObj.getValue()},setValue:function(a,c){this.CodeMirrorObj.setValue(a);"undefined"!==typeof c&&c||this.element.change()},enable:function(a){"disabled"===a?this.CodeMirrorObj.setOption("readOnly",
!1):this._super(a)},disable:function(a){"disabled"===a?this.CodeMirrorObj.setOption("readOnly","nocursor"):this._super(a)}})})(jQuery,MPSL);
(function(d,b){b.CheckboxControl=b.OptionControl.extend({},{getValue:function(){return 1<this.element.length?this.element.filter(":checked").map(function(a,c){return d(c).val()}).get():this.element.is(":checked")},setValue:function(a,c){var b=this;this.element.attr("checked",!1);d.isArray(a)?d.each(a,function(a,c){b.element.filter('[value="'+c+'"]').attr("checked",!0)}):this.element.attr("checked",a);"undefined"!==typeof c&&c||this.element.change()},fixValueType:function(a){if(this.isMultiValue)return a;
switch(typeof a){case "string":return 1==a;case "boolean":return a;default:return Boolean(a)}}})})(jQuery,MPSL);
(function(d,b){b.SelectControl=b.OptionControl.extend({},{dynamicList:{},relatedCtrl:{},relatedEl:{},listAttrSettings:{},optionClone:null,optionCloneCtrl:null,$optionClone:null,init:function(a,c){this._super(a,c);this.dynamicList={};this.relatedCtrl={};this.relatedEl={};var d=b.Vars[this.containerType].options[this.getName()];this.listAttrSettings="undefined"===typeof d?null:d.listAttrSettings;can.bind.call(this.form,"initFinish",this.proxy("initFinish"))},initFinish:function(){this.settings.hasOwnProperty("dynamicList")&&
(this.dynamicList=this.settings.dynamicList,this.relatedCtrl=this.helpers[this.dynamicList.parameter],this.relatedEl=this.relatedCtrl.element,this.relatedEl.on("change silentChange",this.proxy("onRelatedChange")),can.trigger(this.relatedEl,"change silentChange"))},onRelatedChange:function(a){a=this.relatedCtrl.getDependsOnValue();a=this.getRelatedHtml(a);this.element.html(a)},getRelatedValues:function(a){a=this.relatedEl.find('[value="'+a+'"]').attr(this.dynamicList.attr);return this.parseAttr(a,
this.relatedCtrl.listAttrSettings[this.dynamicList.attr])},getRelatedHtml:function(a){var c=[];a=this.getRelatedValues(a);var b=null!==this.getValue()?this.getValue():this.getDefault();d.each(a,function(a,d){c.push('<option value="'+d.value+'" '+(d.value==b?'selected="selected"':"")+">"+d.label+"</option>")});return c},setValue:function(a,c){var b={hasBeenSet:!0,value:a};this.element.find('[value="'+a+'"]').length||(a=this.getDefault(),b.hasBeenSet=!1,b.value=a);this._super(a,c);return b},isAdjustment:function(){return!0},
parseAttr:function(a,c){if("undefined"===typeof a||!a)return[];switch(c.type){case "split":a=a.split(c.delimiter);d.each(a,function(c,b){a[c]={value:b,label:"string"===typeof b&&1<=b.length?b[0].toUpperCase()+b.substr(1):b}});break;case "json":a=JSON.parse(a)}return a},setElement:function(a){this.element=a.find("select")},keydown:function(a,c){this.element.change()},getDependsOnValue:function(){return this.getValue()}})})(jQuery,MPSL);
(function(d,b){b.FontPickerControl=b.SelectControl.extend({},{ladedClass:"mpsl-font-loaded",curNormalFont:"",init:function(a,c){this._super(a,c);this.element.on("silentChange",this.proxy("onSilentChange"))},change:function(){this._super();this.onAnyChange()},onSilentChange:function(){this.onAnyChange()},onAnyChange:function(){this.curNormalFont=b.Scope.styleEditorForm.preset.getOption(this.name);this.loadFont(this.element.find("option:selected"))},loadFont:function(a){if(a.length&&!a.hasClass(this.ladedClass)){var c=
a.val();if(c){var b=a.attr("data-variants");if("undefined"!==typeof b){var f=[],b=this.parseAttr(b,this.listAttrSettings["data-variants"]);d.each(b,function(a,c){c.value&&(c.value="normal"===c.value?"regular":c.value,f.push(c.value),c.value="regular"===c.value?"italic":c.value+"italic",f.push(c.value))});f=f.join(",");c=d("<link/>",{rel:"stylesheet",type:"text/css","class":"mpsl-admin-font-link",href:location.protocol+"//fonts.googleapis.com/css?family="+c+(f?":"+f:"")});d("head").append(c);a.addClass(this.ladedClass)}}}},
getDependsOnValue:function(){var a=this._super(),c=a;b.Scope.styleModeSwitcher.isMode(b.StyleEditorModeSwitcher.HOVER_MODE)&&!a&&this.curNormalFont&&this.element.find('[value="'+this.curNormalFont+'"]')&&(c=this.curNormalFont);return c}})})(jQuery,MPSL);
(function(d,b){b.RadioGroupControl=b.OptionControl.extend({},{getValue:function(){return this.element.filter(":checked").val()},setValue:function(a,c){this.element.attr("checked",!1);this.element.filter('[value="'+a+'"]').attr("checked",!0);"undefined"!==typeof c&&c||this.element.change()}})})(jQuery,MPSL);
(function(d,b){b.RadioButtonsControl=b.RadioGroupControl.extend({},{init:function(a,c){this._super(a,c);this.element.parent().buttonset()},setValue:function(a,c){this.element.attr("checked",!1).next("label").removeClass("button-primary");this.element.filter('[value="'+a+'"]').attr("checked",!0).next("label").addClass("button-primary");"undefined"!==typeof c&&c||this.element.change()},change:function(a,c){b.OptionControl.prototype.change.apply(this,arguments);this.element.next("label").removeClass("button-primary");
this.element.filter(":checked").next("label").addClass("button-primary")}})})(jQuery,MPSL);
(function(d,b){b.ButtonGroupControl=b.OptionControl.extend({},{setElement:function(a){this.element=a.find("button")},getValue:function(){return this.element.filter(".active").val()},setValue:function(a,c){this.element.removeClass("active").filter('[value="'+a+'"]').addClass("active");"undefined"!==typeof c&&c||this.element.change()},".button click":function(a){this.element.removeClass("active");a.addClass("active");this.change()}})})(jQuery,MPSL);
(function(d,b){b.ActionGroupControl=b.OptionControl.extend({},{getValue:function(){return""},setValue:function(a,c){"undefined"!==typeof c&&c||this.element.change()},".actions > a click":function(a){d.each(this.actions[a.attr("value")],function(a,b){b.ctrl.setValue(b.value)});this.change()}})})(jQuery,MPSL);
(function(d,b){b.AliasControl=b.OptionControl.extend({},{verifyOption:function(){var a=!1,a=this.getValue();(new RegExp(/^[-_a-zA-Z0-9]{1,250}$/)).test(a)?a=!0:(this.showError(b.Vars.lang.aliasNotValidPattern),a=!1);return a}})})(jQuery,MPSL);
(function(d,b){b.ImageLibraryControl=b.OptionControl.extend({defaults:{id:"mpsl-media-library",multiple:!1,describe:!1,toolbar:"select",sidebar:"settings",content:"upload",router:"browse",menu:"default",searchable:!0,filterable:!1,sortable:!1,title:"tmp Title",button:{text:"tmp Text"},library:{type:"image"},contentUserSetting:!0,syncSelection:!0}},{frame:null,init:function(a,c){this._super(a,c);this.frame=wp.media({id:"mpsl-add-image-"+this.name,multiple:!1,describe:!1,toolbar:"select",sidebar:"settings",
content:"upload",router:"browse",menu:"default",searchable:!0,filterable:!1,sortable:!1,title:this.settings.label,button:{text:this.settings.select_label},library:{type:"image"},contentUserSetting:!0,syncSelection:!0});this.frame.on("open",this.proxy("onFrameOpen"));this.frame.on("select",this.proxy("onFrameSelect"));this.frame.on("close",this.proxy("onFrameClose"))},onFrameOpen:function(){var a=this.getValue();if(""!==a){var c=this.frame.state().get("selection"),a=wp.media.attachment(a);a.fetch();
c.add(a?[a]:[])}},onFrameSelect:function(){var a=this,c=this.frame.state().get("selection").models[0].attributes;wp.media.attachment(c.id).fetch().done(function(){a.setValue(c.id,!0);d.each(a.helpers,function(){this.setValue(c.url)})})},onFrameClose:function(){},".mpsl-option-library-image-btn click":function(){this.frame.open()},".mpsl-option-library-image-remove click":function(){this.setValue("",!0);d.each(this.helpers,function(){this.setValue("")})}})})(jQuery,MPSL);
(function(d,b){b.VideoLibraryControl=b.OptionControl.extend({},{frame:null,init:function(a,c){this._super(a,c);var b=this.settings.hasOwnProperty("button_label")?this.settings.button_label:"Add Video",b={id:"mpsl-add-video-"+this.name,multiple:!1,describe:!1,toolbar:"select",sidebar:"settings",content:"upload",router:"browse",menu:"default",searchable:!0,filterable:!1,sortable:!1,title:this.settings.label,button:{text:b},library:{type:"video"},contentUserSetting:!0,syncSelection:!0};wp.media.attachment(this.getValue()).fetch();
this.frame=wp.media(b);this.frame.on("open",this.proxy("onFrameOpen"));this.frame.on("select",this.proxy("onFrameSelect"));this.frame.on("close",this.proxy("onFrameClose"))},onFrameOpen:function(){var a=this.getValue();if(""!==a){var c=this.frame.state().get("selection"),a=wp.media.attachment(a);a.fetch();c.add(a?[a]:[])}},onFrameSelect:function(){var a=this.frame.state().get("selection").models[0].attributes;wp.media.attachment(a.id).fetch();this.setValue(a.id)},onFrameClose:function(){},".mpsl-option-library-video-btn click":function(){this.frame.open()}})})(jQuery,
MPSL);(function(d,b){b.ImageUrlControl=b.OptionControl.extend({},{".mpsl-option-image-load-btn click":function(){this.change()}})})(jQuery,MPSL);(function(d,b){b.ShortcodeControl=b.OptionControl.extend({},{})})(jQuery,MPSL);(function(d,b){b.HiddenControl=b.OptionControl.extend({},{})})(jQuery,MPSL);
(function(d,b){b.AlignTableControl=b.OptionControl.extend({},{table:{},init:function(a,c){this._super(a,c);this.table=a.find(".mpsl-align-table")},setElement:function(a){this.element=a},".mpsl-align-table a click":function(a){var c=a.attr("data-hor");a=a.attr("data-vert");var d=b.Vars.layer.defaults.offset_x,f=b.Vars.layer.defaults.offset_y;this.childOptions.hor_align.setValue(c,!0);this.childOptions.vert_align.setValue(a,!0);this.childOptions.offset_x.setValue(d,!0);this.childOptions.offset_y.setValue(f,
!0);this.selectBullet(c,a);this.change()},getValue:function(){return{hor:this.childOptions.hor_align.getValue(),vert:this.childOptions.vert_align.getValue()}},setValue:function(a,c){this.selectBullet(a.hor,a.vert);"undefined"!==typeof c&&c||this.element.change()},selectBullet:function(a,c){this.table.find("a.selected").removeClass("selected").end().find('a[data-hor="'+a+'"][data-vert="'+c+'"]').addClass("selected")}})})(jQuery,MPSL);
(function(d,b){b.DatePickerControl=b.OptionControl.extend({},{init:function(a,c){this._super(a,c);this.element.datepicker({dateFormat:"dd-mm-yy 00:00"})},verifyOption:function(){var a=this.getValue();if(""===a)return!0;a=a.match(new RegExp(/^(\d{2})-(\d{2})-(\d{4})\s(\d{2}):(\d{2})$/));return null===a?(this.showError(b.Vars.lang.validate_invalid_date_format.replace("%s",this.getLabel())),!1):1>a[1]||31<a[1]?(this.showError(b.Vars.lang.validate_invalid_day.replace("%s",this.getLabel()).replace("%day",
a[1])),!1):1>a[2]||12<a[2]?(this.showError(b.Vars.lang.validate_invalid_month.replace("%s",this.getLabel()).replace("%month",a[2])),!1):1970>a[3]||2037<a[3]?(this.showError(b.Vars.lang.validate_invalid_year.replace("%s",this.getLabel()).replace("%year",a[3]).replace("%minYear",1970).replace("%maxYear",2037)),!1):0>a[4]||23<a[4]?(this.showError(b.Vars.lang.validate_invalid_hour.replace("%s",this.getLabel()).replace("%hour",a[4])),!1):0>a[5]||59<a[5]?(this.showError(b.Vars.lang.validate_invalid_minute.replace("%s",
this.getLabel()).replace("%minute",a[5])),!1):!0}})})(jQuery,MPSL);
(function(d,b){b.StyleEditorControl=b.OptionControl.extend({},{editorEl:null,init:function(a,c){this._super(a,c);this.editorEl=d("#mpsl-style-editor-modal");this.input=a.children(".mpsl-layer-style-value");this.list=a.children(".mpsl-layer-style-list");this.globalListEl=d("#mpsl-layer-preset-list-child-wrapper");this.addPreset("",b.Vars.lang.none,"head");can.bind.call(this.editorEl,"create",this.proxy("onEditorCreate"));can.bind.call(this.globalListEl,"presetAdd",this.proxy("onPresetAdd"));can.bind.call(this.globalListEl,
"presetRemove",this.proxy("onPresetRemove"));can.bind.call(this.globalListEl,"presetUpdate",this.proxy("onPresetUpdate"))},onEditorCreate:function(a,c){c.linkControl(this)},addPreset:function(a,c,b){b&&(a=d("<option>",{value:a,text:c}),"head"===b?this.list.find("optgroup:first").before(a):this.list.find(".mpsl-layer-style-list-group-"+b).append(a))},onPresetAdd:function(a,c){var d=null;switch(c.preset.getType()){case b.LayerPreset.PRIVATE:d="head";break;case b.LayerPreset.CUSTOM:d="custom";break;
case b.LayerPreset.DEFAULT:d="default"}d&&this.addPreset(c.name,c.isPrivate?b.Vars.lang.layer_preset_private_name:c.label,d)},onPresetRemove:function(a,c){this.list.find('[value="'+c.name+'"]').remove()},onPresetUpdate:function(a,c){this.list.find('[value="'+c.name+'"]').text(c.label)},selectPreset:function(a){this.list.find('[value="'+a+'"]').attr("selected","selected")},".mpsl-edit-layer-style click":function(){this.editorEl.dialog("open")},getValue:function(){return this.input.val()},setValue:function(a,
c){this.input.val(a);this.selectPreset(a);(c="undefined"!==typeof c?c:!1)||this.element.change();can.trigger(this,"freeChange",{silent:c,value:a})}})})(jQuery,MPSL);
(function(d,b){b.ColorPickerControl=b.OptionControl.extend({},{colorPickerEl:null,init:function(a,c){this._super(a,c);var e=d(),e="preset"===this.containerType?this.element.closest(".mpsl-style-editor-content"):this.element.closest(".mpsl-option-wrapper");this.colorPickerEl=this.element.spectrum({appendTo:e,cancelText:b.Vars.lang.cancel,chooseText:b.Vars.lang.choose,color:"",allowEmpty:!0,showInput:!0,showAlpha:!0,preferredFormat:"hex3"})},getValue:function(){var a=this.colorPickerEl.spectrum("get");
return a?a.toRgbString():""},setValue:function(a,c){this.colorPickerEl.spectrum("set",a);"undefined"!==typeof c&&c||this.element.change()},enable:function(a){"disabled"===a?this.colorPickerEl.spectrum("enable"):this._super(a)},disable:function(a){"disabled"===a?this.colorPickerEl.spectrum("disable"):this._super(a)}})})(jQuery,MPSL);
(function(d,b){b.MultipleControl=b.OptionControl.extend({},{setElement:function(a){this.element=a.find("textarea")},getValue:function(){return JSON.parse(this._super())},setValue:function(a,c){this._super(JSON.stringify(a),c)}})})(jQuery,MPSL);
(function(d,b){b.TextShadowControl=b.OptionControl.extend({},{init:function(a,c){this._super(a,c)},setElement:function(a){this.element=a},getValue:function(){var a=this.childOptions.text_shadow_hor_len.getValue(),c=this.childOptions.text_shadow_vert_len.getValue(),b=this.childOptions.text_shadow_radius.getValue(),d=this.childOptions.text_shadow_color.getValue();if(""===a&&""===c&&""===b&&""===d)return"";a=(a?a:0)+this.childOptions.text_shadow_hor_len.settings.unit;c=(c?c:0)+this.childOptions.text_shadow_vert_len.settings.unit;
b=(b?b:0)+this.childOptions.text_shadow_radius.settings.unit;return[a,c,b,d].join(" ")},setValue:function(a,c){"undefined"!==typeof c&&c?can.trigger(this.element,"silentChange"):this.element.change()}})})(jQuery,MPSL);
(function(d,b){b.AnimationControl=b.OptionControl.extend({},{editorEl:null,previewEl:null,animation:null,duration:null,timingFunction:null,startAnimation:null,init:function(a,c){this._super(a,c);this.editorEl=d("#mpsl-animation-"+this.name);this.previewEl=this.editorEl.find(".mpsl-animation-preview-wrapper");this.previewEl[0].addEventListener("animationend",function(){d(this).attr("class","mpsl-animation-preview-wrapper mpsl-animated")},!1);can.bind.call(this.form,"initFinish",this.proxy("formInitFinish"))},
formInitFinish:function(){var a=this;this.animation=this.getChildOption("animation");this.duration=this.getChildOption("duration");this.timingFunction=this.getChildOption("timing_function");this.editorEl.dialog({resizable:!1,draggable:!1,autoOpen:!1,modal:!0,width:1E3,height:d(window).height()/1.7,title:b.Vars.lang["animation-modal"],closeText:"",dialogClass:"mpsl-animation-editor-dialog",position:{my:"center",at:"center",of:window},open:function(c){d("body").css("overflow","hidden");a.fixDialog();
a.applyAnimation()},beforeClose:function(){d("body").css("overflow","inherit")}});"end"===this.settings.animation_type&&(this.startAnimation=this.animation.helpers.end_animation.helpers.start_animation);this.editorEl.find(".mpsl-animation-apply").on("click",this.proxy("applyValues"));this.editorEl.find(".mpsl-animation-close").on("click",function(){a.editorEl.dialog("close")});this.editorEl.find(".mpsl-play-animation").on("click",this.proxy("applyAnimation"));this.animation.on("change",this.proxy("applyAnimation"));
this.duration.on("change",this.proxy("applyAnimation"));this.timingFunction.on("change",this.proxy("applyAnimation"));d(window).on("resize",this.proxy("onWindowResize"))},getChildOption:function(a){return this.childOptions[this.settings.animation_type+"_"+a+"_clone"]},applyAnimation:function(){var a="auto"===this.animation.getValue()?this.startAnimation.getValue().replace("In","Out"):this.animation.getValue(),c=this.duration.getValue(),b=this.timingFunction.getValue();this.previewEl.css({"-webkit-animation-duration":c+
"ms","animation-duration":c+"ms"});this.previewEl.attr("class","mpsl-animation-preview-wrapper mpsl-animated");this.previewEl.addClass(" mpsl-"+a+" mpsl-"+b)},applyValues:function(){if(!this.verifyCloneValues())return!1;d.each(this.childOptions,function(a,c){d.each(c.helpers,function(a,b){b.setValue(c.getValue())})});this.editorEl.dialog("close")},loadValues:function(){d.each(this.childOptions,function(a,c){d.each(c.helpers,function(a,b){c.setValue(b.getValue())})})},verifyOriginalValues:function(){var a=
!0;d.each(this.childOptions,function(c,b){d.each(b.helpers,function(c,b){if(!b.verifyOption())return a=!1});if(!a)return!1});return a},verifyCloneValues:function(){var a=!0;d.each(this.childOptions,function(c,b){if(!b.verifyOption())return a=!1;if(!a)return!1});return a},".mpsl-edit-animation-btn click":function(){this.verifyOriginalValues()&&(this.loadValues(),this.editorEl.dialog("open"))},setElement:function(a){this.element=a},getValue:function(){return!1},setValue:function(){},change:function(){},
onWindowResize:function(){this.editorEl.dialog("isOpen")&&this.fixDialog()},fixDialog:function(){var a=d(window).height()/1.7;178<a&&(this.editorEl.dialog("option","height",0<a?a:0),this.editorEl.dialog("option","position",{my:"center",at:"center",of:window}))}})})(jQuery,MPSL);
(function(d,b){b.PrettySelectControl=b.OptionControl.extend({},{setElement:function(a){this.element=a.find("ul")},setValue:function(a){this.setActive(this.element.find('li[data-value="'+a+'"]'))},getValue:function(){return this.element.find("li.active").attr("data-value")},setActive:function(a){a.addClass("active").siblings().removeClass("active")},"li click":function(a){this.setActive(a);this.element.change()}})})(jQuery,MPSL);
(function(d,b){b.WeightCloneSelectControl=b.SelectControl.extend({},{init:function(a,c){this._super(a,c);can.event.on.call(b.FormController,"allFormsReady",this.proxy(function(){can.event.on.call(this.helpers.preset,"freeChange",this.proxy("onPresetChange"));can.bind.call(b.Scope.layerPresetList.element,"presetApply",this.proxy("onPresetChange"))}))},onPresetChange:function(a,c){if(!b.Scope.layerSettingsForm.isResettingOptionsMode()){var e=b.Scope.workground.getCurrent();if(e&&e.isType(["html","button"])){var f=
c instanceof b.LayerPreset?c.getName():c.value,g=[],g="";f&&("private"===f?g=e.getOption("private_styles").style["font-family"]:(f=b.Scope.layerPresetList.getByName(f))&&f.getOption("font-family")&&(g=f.getOption("font-family")));var g=b.LayerPreset.getFontWeightsByFont(g),h=e.getLayoutOption(this.name),l=!0,m=[];d.each(g,function(a,b){var c="";b.value==h&&(c='selected="selected"',l=!1);m.push('<option value="'+b.value+'" '+c+">"+b.label+"</option>")});this.element.html(m);if(l){for(var n in g)break;
e.setOptionValue(this.name,g[n].value)}}}}})})(jQuery,MPSL);
