Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-smart-filters   php

Repository URL to install this package:

Version: 2.2.1 

/ interface-builder / assets / js / cx-interface-builder.min.js

!function(h){"use strict";var o={init:function(){this.component.init(),h(document).on("cxFramework:interfaceBuilder:component",this.component.init.bind(this.component)),this.control.init(),h(document).on("cxFramework:interfaceBuilder:control",this.control.init.bind(this.control))},component:{tabClass:".cx-tab",accordionClass:".cx-accordion",toggleClass:".cx-toggle",buttonClass:".cx-component__button",contentClass:".cx-settings__content",buttonActiveClass:"active",showClass:"show",localStorage:{},controlConditions:window.cxInterfaceBuilder.conditions||{},controlValues:window.cxInterfaceBuilder.fields||{},conditionState:{},init:function(){this.localStorage=this.getState()||{},this.componentInit(this.tabClass),this.componentInit(this.accordionClass),this.componentInit(this.toggleClass),this.addEvent(),this.conditionsHandleInit()},addEvent:function(){h("body").off("click.cxInterfaceBuilder").on("click.cxInterfaceBuilder",this.tabClass+" "+this.buttonClass+", "+this.toggleClass+" "+this.buttonClass+", "+this.accordionClass+" "+this.buttonClass,this.componentClick.bind(this))},conditionsHandleInit:function(){var a=this;h(window).on("cx-switcher-change",function(t){var e=t.controlName,i=t.controlStatus;a.updateConditionRules(e,i),a.renderConditionRules()}),h(window).on("cx-select-change",function(t){var e=t.controlName,i=t.controlStatus;a.updateConditionRules(e,i),a.renderConditionRules()}),h(window).on("cx-select2-change",function(t){var e=t.controlName,i=t.controlStatus;a.updateConditionRules(e,i),a.renderConditionRules()}),h(window).on("cx-radio-change",function(t){var e=t.controlName,i=t.controlStatus;a.updateConditionRules(e,i),a.renderConditionRules()}),h(window).on("cx-checkbox-change",function(t){var e=t.controlName,i=t.controlStatus,n={};h.each(i[e],function(t,e){n[t]=o.utils.filterBoolValue(e)}),a.updateConditionRules(e,n),a.renderConditionRules()}),this.generateConditionRules(),a.renderConditionRules()},generateConditionRules:function(){var i=this;h.each(this.controlConditions,function(t,e){h.each(e,function(t,e){i.controlValues.hasOwnProperty(t)&&(i.conditionState[t]=i.controlValues[t])})})},updateConditionRules:function(t,e){this.conditionState[t]=e},renderConditionRules:function(){var a=this;h.each(this.controlConditions,function(t,e){var i=h('.cx-control[data-control-name="'+t+'"]'),n=!0;i.addClass("cx-control-hidden"),h.each(e,function(t,i){if(n=!0,a.conditionState.hasOwnProperty(t)){switch(typeof i){case"string":a.conditionState[t]===i&&(n=!1);break;case"boolean":a.conditionState[t].toString()===i.toString()&&(n=!1);break;default:"string"==typeof a.conditionState[t]&&("true"===a.conditionState[t]&&(a.conditionState[t]=!0),"false"===a.conditionState[t]&&(a.conditionState[t]=!1)),-1!==i.indexOf(a.conditionState[t])&&(n=!1)}"object"==typeof a.conditionState[t]&&(n=!1,h.each(a.conditionState[t],function(t,e){if(!e&&-1!==i.indexOf(t))return!(n=!0)}))}if(n)return!1}),n?i.addClass("cx-control-hidden"):i.removeClass("cx-control-hidden")})},componentInit:function(i){var n=this,t=h(i),a=null,s=null,o=null,c="";t.each(function(t,e){switch(e=h(e),a=e.data("compotent-id"),i){case n.toggleClass:n.localStorage[a]&&n.localStorage[a].length&&(c=n.localStorage[a].join(", ")),h(n.contentClass,e).not(c).addClass(n.showClass).prevAll(n.buttonClass).addClass(n.buttonActiveClass);break;case n.tabClass:case n.accordionClass:n.localStorage[a]?(o=n.localStorage[a][0],s=h('[data-content-id="'+o+'"]',e)):(s=h(n.buttonClass,e).eq(0),o=s.data("content-id")),n.showElement(s,e,o)}})},componentClick:function(t){var e,i=h(t.target),n=i.closest(this.tabClass+", "+this.accordionClass+", "+this.toggleClass),a=new RegExp(this.tabClass+"|"+this.accordionClass+"|"+this.toggleClass),s=n[0].className.match(a)[0].replace(" ","."),o=i.data("content-id"),c=n.data("compotent-id"),r=i.hasClass(this.buttonActiveClass);switch(s){case this.tabClass:r||(this.hideElement(n),this.showElement(i,n,o),this.localStorage[c]=new Array(o),this.setState());break;case this.accordionClass:this.hideElement(n),r?this.localStorage[c]={}:(this.showElement(i,n,o),this.localStorage[c]=new Array(o)),this.setState();break;case this.toggleClass:i.toggleClass(this.buttonActiveClass).nextAll(o).toggleClass(this.showClass),Array.isArray(this.localStorage[c])?-1!==(e=this.localStorage[c].indexOf(o))?this.localStorage[c].splice(e,1):this.localStorage[c].push(o):this.localStorage[c]=new Array(o),this.setState()}return i.blur(),!1},showElement:function(t,e,i){t.addClass(this.buttonActiveClass),e.data("content-id",i),h(i,e).addClass(this.showClass)},hideElement:function(t){var e=t.data("content-id");h('[data-content-id="'+e+'"]',t).removeClass(this.buttonActiveClass),h(e,t).removeClass(this.showClass)},getState:function(){try{return JSON.parse(localStorage.getItem("interface-builder"))}catch(t){return!1}},setState:function(){try{localStorage.setItem("interface-builder",JSON.stringify(this.localStorage))}catch(t){return!1}}},control:{init:function(){this.switcher.init(),this.checkbox.init(),this.radio.init(),this.slider.init(),this.select.init(),this.media.init(),this.colorpicker.init(),this.iconpicker.init(),this.dimensions.init(),this.wysiwyg.init(),this.repeater.init()},switcher:{switcherClass:".cx-switcher-wrap",trueClass:".cx-input-switcher-true",falseClass:".cx-input-switcher-false",init:function(){h("body").on("click.cxSwitcher",this.switcherClass,this.switchState.bind(this))},switchState:function(t){var e=h(t.currentTarget),i=h(this.trueClass,e),n=h(this.falseClass,e),a=i[0].checked,s=h(t.currentTarget).closest(".cx-control-switcher").data("control-name");i.prop("checked",!a),n.prop("checked",!!a),a=i[0].checked,h(window).trigger({type:"cx-switcher-change",controlName:s,controlStatus:a})}},checkbox:{inputClass:'.cx-checkbox-input[type="hidden"]:not([name*="__i__"])',itemClass:".cx-checkbox-label, .cx-checkbox-item",init:function(){h("body").on("click.cxCheckbox",this.itemClass,this.switchState.bind(this))},switchState:function(t){var e,i=h(t.currentTarget).siblings(this.inputClass),n=i[0].checked,a=h(t.currentTarget).closest(".cx-control-checkbox"),s=a.data("control-name");i.val(n?"false":"true").attr("checked",!n),e=o.utils.serializeObject(a),h(window).trigger({type:"cx-checkbox-change",controlName:s,controlStatus:e})}},radio:{inputClass:'.cx-radio-input:not([name*="__i__"])',init:function(){h("body").on("click.cxRadio",this.inputClass,this.switchState.bind(this))},switchState:function(t){var e=h(t.currentTarget),i=h(t.currentTarget).closest(".cx-control-radio").data("control-name");h(window).trigger({type:"cx-radio-change",controlName:i,controlStatus:h(e).val()})}},slider:{init:function(){h("body").on("input.cxSlider change.cxSlider",".cx-slider-unit, .cx-ui-stepper-input",this.changeHandler.bind(this))},changeHandler:function(t){var e=h(t.currentTarget),a=e.val(),i=e.closest(".cx-slider-wrap"),n=e.closest(".cx-ui-container").data("settings"),s=e.hasClass("cx-slider-unit")?".cx-ui-stepper-input":".cx-slider-unit";if(h(s,i).val(a),n.range_label){var o=h(".cx-slider-range-label",i),c=n.range_labels;if(0==+a)return o.html(c[+a].label),o.css("color",c[+a].color),!1;Object.keys(c).reduce(function(t,e,i,n){return+t<+a&&+a<=+e&&(o.html(c[+e].label),o.css("color",c[+e].color)),e})}}},select:{selectClass:'.cx-ui-select[data-filter="false"]:not([name*="__i__"])',select2Class:'.cx-ui-select[data-filter="true"]:not([name*="__i__"]), .cx-ui-select[multiple]:not([name*="__i__"])',selectClearClass:".cx-ui-select-clear",init:function(){h(document).on("ready.cxSelect",this.selectRender.bind(this)).on("cx-control-init",this.selectRender.bind(this)).on("click.cxSelect",this.selectClearClass,this.clearSelect)},clearSelect:function(t){t.preventDefault(),h(this).siblings("select").val(null).trigger("change")},selectRender:function(t){var e=t._target?t._target:h("body");h(this.selectClass,e).each(this.selectInit.bind(this)),h(this.select2Class,e).each(this.select2Init.bind(this))},selectInit:function(t,e){var i=h(e),n=i.attr("id");i.change(function(t){h(window).trigger({type:"cx-select-change",controlName:n,controlStatus:h(t.target).val()})})},select2Init:function(t,e){var i=h(e),n=i.attr("id"),a={placeholder:i.data("placeholder")},s=i.data("post-type"),o=i.data("exclude"),c=i.data("action");c&&s&&(a.ajax={url:function(){return ajaxurl+"?action="+c+"&post_type="+i.data("post-type")+"&exclude="+o},dataType:"json"},a.minimumInputLength=3),i.select2(a).on("change.cxSelect2",function(t){h(window).trigger({type:"cx-select2-change",controlName:n,controlStatus:h(t.target).val()})})}},media:{init:function(){h(document).on("ready.cxMedia",this.mediaRender.bind(this)).on("cx-control-init",this.mediaRender.bind(this))},mediaRender:function(t){var e=t._target?t._target:h("body"),i=h(".cx-upload-button",e);i.each(function(){var t=h(this),e=t.closest(".cx-ui-media-wrap"),d={input:h(".cx-upload-input",e),img_holder:h(".cx-upload-preview",e),title_text:t.data("title"),multiple:t.data("multi-upload"),library_type:t.data("library-type")},u=wp.media.frames.file_frame=wp.media({title:d.title_text,button:{text:d.title_text},multiple:d.multiple,library:{type:d.library_type}});if(!e.has('input[name*="__i__"]')[0]){t.off("click.cx-media").on("click.cx-media",function(){return u.open(),!1}),t.data("multi-upload")&&u.on("open",function(){var e=u.state().get("selection"),t=d.input.val();t&&(t=t.split(",")).forEach(function(t){e.add(wp.media.attachment(t))})}),u.on("select",function(){var t=u.state().get("selection").toJSON(),e=0,i="",n=h(".cx-all-images-wrap",d.img_holder),a="",s="";for(d.multiple&&(s=",");t[e];){var o=t[e],c=o.id,r="",l="";switch(o.mime){case"image/jpeg":case"image/png":case"image/gif":void 0!==o.sizes&&(r=o.sizes.thumbnail?o.sizes.thumbnail.url:o.sizes.full.url),l='<img  src="'+r+'" alt="" data-img-attr="'+c+'">';break;case"image/x-icon":l='<span class="dashicons dashicons-format-image"></span>';break;case"video/mpeg":case"video/mp4":case"video/quicktime":case"video/webm":case"video/ogg":l='<span class="dashicons dashicons-format-video"></span>';break;case"audio/mpeg":case"audio/wav":case"audio/ogg":l='<span class="dashicons dashicons-format-audio"></span>'}a+='<div class="cx-image-wrap"><div class="inner"><div class="preview-holder"  data-id-attr="'+c+'"><div class="centered">'+l+'</div></div><a class="cx-remove-image" href="#"><i class="dashicons dashicons-no"></i></a><span class="title">'+o.title+"</span></div></div>",i+=s+c,e++}d.input.val(i.replace(/(^,)/,"")).trigger("change"),n.html(a)});e.on("click",".cx-remove-image",function(){return function(t){var e=t.closest(".cx-ui-media-wrap"),i=h(".cx-upload-input",e),n=t.parent().parent(".cx-image-wrap"),a=h(".preview-holder",n).data("id-attr"),s=i.attr("value"),o=new RegExp(a+"(,*)","i");s=(s=s.replace(o,"")).replace(/(,$)/,""),i.attr({value:s}).trigger("change"),n.remove()}(h(this)),!1})}}),i[0]&&h(".cx-all-images-wrap",e).sortable({items:"div.cx-image-wrap",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"cx-media-thumb-sortable-placeholder",start:function(){},stop:function(){},update:function(){var e="";h(".cx-image-wrap",this).each(function(){var t=h(".preview-holder",this).data("id-attr");e=e+t+","}),e=e.substr(0,e.lastIndexOf(",")),h(this).parent().siblings(".cx-element-wrap").find("input.cx-upload-input").val(e).trigger("change")}})}},colorpicker:{init:function(){h(document).on("ready.cxColorpicker",this.render.bind(this)).on("cx-control-init",this.render.bind(this))},render:function(t){var e=t._target?t._target:h("body"),i=h('input.cx-ui-colorpicker:not([name*="__i__"])',e);i[0]&&i.wpColorPicker()}},iconpicker:{iconSets:{},iconSetsKey:"cx-icon-sets",init:function(){h(document).on("ready.cxIconpicker",this.setIconsSets.bind(this,window.CxIconSets)).on("ready.cxIconpicker",this.render.bind(this)).on("cx-control-init",this.render.bind(this))},setIconsSets:function(t){var e,i=this;t&&(e=t.response?t.response.CxIconSets:t,h.each(e,function(t,e){i.iconSets[t]=e}),i.setState(i.iconSetsKey,i.iconSets))},getIconsSets:function(){var t=this.getState(this.iconSetsKey);t&&(this.iconSets=t)},render:function(t){var e,i,n,a=t._target?t._target:h("body"),s=h('.cx-ui-iconpicker:not([name*="__i__"])',a),o=this;s[0]&&(this.getIconsSets(),s.each(function(){e=h(this),i=e.data("set"),n=o.iconSets[i],e.length&&n.icons&&e.iconpicker({icons:n.icons,iconBaseClass:n.iconBase,iconClassPrefix:n.iconPrefix,animation:!1,fullClassFormatter:function(t){return n.iconBase+" "+n.iconPrefix+t}}).on("iconpickerUpdated",function(){h(this).trigger("change")}),n&&h("head").append('<link rel="stylesheet" type="text/css" href="'+n.iconCSS+'"">')}))},getState:function(t){try{return JSON.parse(window.sessionStorage.getItem(t))}catch(t){return!1}},setState:function(t,e){try{window.sessionStorage.setItem(t,JSON.stringify(e))}catch(t){return!1}}},dimensions:{container:".cx-ui-dimensions",isLinked:".cx-ui-dimensions__is-linked",units:".cx-ui-dimensions__unit",unitsInput:'input[name*="[units]"]',linkedInput:'input[name*="[is_linked]"]',valuesInput:".cx-ui-dimensions__val",init:function(){h("body").on("click",this.isLinked,{self:this},this.switchLinked).on("click",this.units,{self:this},this.switchUnits).on("input",this.valuesInput+".is-linked",{self:this},this.changeLinked)},render:function(t){},switchLinked:function(t){var e=t.data.self,i=h(this),n=i.closest(e.container),a=n.find(e.linkedInput),s=n.find(e.valuesInput),o=a.val();0===parseInt(o)?(a.val(1),i.addClass("is-linked"),s.addClass("is-linked")):(a.val(0),i.removeClass("is-linked"),s.removeClass("is-linked"))},switchUnits:function(t){var e=t.data.self,i=h(this),n=i.data("unit"),a=i.closest(e.container),s=a.find(e.unitsInput),o=a.find(e.valuesInput),c=a.data("range");i.hasClass("is-active")||(i.addClass("is-active").siblings(e.units).removeClass("is-active"),s.val(n),o.attr({min:c[n].min,max:c[n].max,step:c[n].step}))},changeLinked:function(t){var e=t.data.self,i=h(this),n=i.closest(".cx-ui-dimensions__values");h(e.valuesInput,n).val(i.val())}},wysiwyg:{editorSettings:{tinymce:{wpautop:!0,toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,spellchecker,wp_adv,dfw",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help"},quicktags:{buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,dfw"},mediaButtons:!0},init:function(){h(document).on("cx-control-init",this.render.bind(this)),h(window).on("cx-repeater-sortable-stop",this.reInit.bind(this))},render:function(t){var i=this,e=t._target?t._target:h("body"),n=h('textarea.cx-ui-wysiwyg:not([name*="__i__"])',e);n[0]&&n.each(function(){var t=h(this),e=t.attr("id");t.data("init")||(void 0!==window.wp.editor.initialize?window.wp.editor.initialize(e,i.editorSettings):window.wp.oldEditor.initialize(e,i.editorSettings),t.data("init",!0))})},reInit:function(t){var e=this,i=t._item,n=h("textarea.wp-editor-area",i);n[0]&&n.each(function(){var t=h(this).attr("id");void 0!==window.wp.editor.initialize?(window.wp.editor.remove(t),window.wp.editor.initialize(t,e.editorSettings)):(window.wp.oldEditor.remove(t),window.wp.oldEditor.initialize(t,e.editorSettings))})}},repeater:{repeaterContainerClass:".cx-ui-repeater-container",repeaterListClass:".cx-ui-repeater-list",repeaterItemClass:".cx-ui-repeater-item",repeaterItemHandleClass:".cx-ui-repeater-actions-box",repeaterTitleClass:".cx-ui-repeater-title",addItemButtonClass:".cx-ui-repeater-add",removeItemButtonClass:".cx-ui-repeater-remove",toggleItemButtonClass:".cx-ui-repeater-toggle",minItemClass:"cx-ui-repeater-min",sortablePlaceholderClass:"sortable-placeholder",init:function(){h(document).on("ready.cxRepeat",this.addEvents.bind(this))},addEvents:function(){h("body").on("click",this.addItemButtonClass,{self:this},this.addItem).on("click",this.removeItemButtonClass,{self:this},this.removeItem).on("click",this.toggleItemButtonClass,{self:this},this.toggleItem).on("change",this.repeaterListClass+" input, "+this.repeaterListClass+" textarea, "+this.repeaterListClass+" select",{self:this},this.changeWrapperLable).on("sortable-init",{self:this},this.sortableItem),h(document).on("cx-control-init",{self:this},this.sortableItem),this.triggers()},triggers:function(t){return h("body").trigger("sortable-init"),t&&h(document).trigger("cx-control-init",{target:t}),this},addItem:function(t){var e=t.data.self,i=h(this).prev(e.repeaterListClass),n=i.data("index"),a=i.data("name"),s=wp.template(a),o=i.data("widget-id"),c={index:n},r=i.parent().closest(e.repeaterListClass);(o="__i__"!==o?o:i.attr("id"))&&(c.widgetId=o),r.length&&(c.parentIndex=parseInt(r.data("index"),10)-1),i.append(s(c)),n++,i.data("index",n),e.triggers(h(e.repeaterItemClass+":last",i)).stopDefaultEvent(t)},removeItem:function(t){var e=t.data.self,i=h(this).closest(e.repeaterListClass);e.applyChanges(i),h(this).closest(e.repeaterItemClass).remove(),e.triggers().stopDefaultEvent(t)},toggleItem:function(t){var e=t.data.self;h(this).closest(e.repeaterItemClass).toggleClass(e.minItemClass),e.stopDefaultEvent(t)},sortableItem:function(t){var i,n=t.data.self;h(n.repeaterListClass).each(function(t,e){i=h(e),h(e).data("sortable-init")?i.sortable("refresh"):i.sortable({items:n.repeaterItemClass,handle:n.repeaterItemHandleClass,cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,distance:2,tolerance:"pointer",helper:function(t,e){return e.clone().find(":input").attr("name",function(t,e){return"sort_"+parseInt(1e5*Math.random(),10).toString()+"_"+e}).end()},start:function(t,e){h(window).trigger({type:"cx-repeater-sortable-start",_item:e.item})},stop:function(t,e){h(window).trigger({type:"cx-repeater-sortable-stop",_item:e.item})},opacity:.65,placeholder:n.sortablePlaceholderClass,create:function(){i.data("sortable-init",!0)},update:function(t,e){var i=h(t.target);n.applyChanges(i)}})})},changeWrapperLable:function(t){var e,i,n=t.data.self,a=h(n.repeaterListClass).data("title-field"),s=h(this);a&&s.closest("."+a+"-wrap")[0]&&(e=s.val(),i=s.closest(n.repeaterItemClass),h(n.repeaterTitleClass,i).html(e)),n.stopDefaultEvent(t)},applyChanges:function(t){return void 0!==wp.customize&&h("input[name]:first, select[name]:first",t).change(),this},stopDefaultEvent:function(t){return t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),this}}},utils:{serializeObject:function(t){var e,a=this,s={},i={},o={validate:/^[a-zA-Z][a-zA-Z0-9_-]*(?:\[(?:\d*|[a-zA-Z0-9_-]+)\])*$/,key:/[a-zA-Z0-9_-]+|(?=\[\])/g,push:/^$/,fixed:/^\d+$/,named:/^[a-zA-Z0-9_-]+$/};return this.build=function(t,e,i){return t[e]=i,t},this.push_counter=function(t){return void 0===i[t]&&(i[t]=0),i[t]++},e="FORM"===t[0].tagName?t.serializeArray():t.find("input, textarea, select").serializeArray(),h.each(e,function(){var t,e,i,n;if(o.validate.test(this.name)){for(e=this.name.match(o.key),i=this.value,n=this.name;void 0!==(t=e.pop());)n=n.replace(new RegExp("\\["+t+"\\]$"),""),t.match(o.push)?i=a.build([],a.push_counter(n),i):t.match(o.fixed)?i=a.build([],t,i):t.match(o.named)&&(i=a.build({},t,i));s=h.extend(!0,s,i)}}),s},filterBoolValue:function(t){var e=+t;return isNaN(e)?!!String(t).toLowerCase().replace(!1,""):!!e}}};o.init()}(jQuery,window._);