diff --git a/controls/js/script.js b/controls/js/script.js index d4f799da8..a9f858895 100644 --- a/controls/js/script.js +++ b/controls/js/script.js @@ -3063,7 +3063,7 @@ wp.customize.controlConstructor.repeater = wp.customize.Control.extend( { data = data || {}; data[ dataField ] = data[ dataField ] || ''; - $select = jQuery( dropdown ).selectWoo( selectWooOptions ).val( data[ dataField ] ); + $select = jQuery( dropdown ).selectWoo( selectWooOptions ).val( data[ dataField ] || jQuery( dropdown ).val() ); this.container.on( 'change', '.repeater-field select', function( event ) { diff --git a/controls/js/script.min.js b/controls/js/script.min.js index 9da30d628..103a22b1b 100644 --- a/controls/js/script.min.js +++ b/controls/js/script.min.js @@ -1 +1 @@ -if(_.isUndefined(window.kirkiSetSettingValue))var kirkiSetSettingValue={set:function(i,n){var e,a=this,t=wp.customize.settings.controls[i];if(_.isUndefined(t))return!0;switch(a.setValue(i,n),t.type){case"kirki-background":_.isUndefined(n["background-color"])||a.setColorPicker(a.findElement(i,".kirki-color-control"),n["background-color"]),a.findElement(i,".placeholder, .thumbnail").removeClass().addClass("placeholder").html("No file selected"),_.each(["background-repeat","background-position"],function(e){_.isUndefined(n[e])||a.setSelectWoo(a.findElement(i,"."+e+" select"),n[e])}),_.each(["background-size","background-attachment"],function(e){jQuery(a.findElement(i,"."+e+' input[value="'+n+'"]')).prop("checked",!0)}),e=JSON.stringify(n).replace(/'/g,"'"),jQuery(a.findElement(i,".background-hidden-value").attr("value",e)).trigger("change");break;case"kirki-code":jQuery(a.findElement(i,".CodeMirror"))[0].CodeMirror.setValue(n);break;case"checkbox":case"kirki-switch":case"kirki-toggle":n=1===n||"1"===n||!0===n,jQuery(a.findElement(i,"input")).prop("checked",n),wp.customize.instance(i).set(n);break;case"kirki-select":case"kirki-fontawesome":a.setSelectWoo(a.findElement(i,"select"),n);break;case"kirki-slider":jQuery(a.findElement(i,"input")).prop("value",n),jQuery(a.findElement(i,".kirki_range_value .value")).html(n);break;case"kirki-generic":(_.isUndefined(t.choices)||_.isUndefined(t.choices.element))&&(t.choices.element="input"),jQuery(a.findElement(i,t.choices.element)).prop("value",n);break;case"kirki-color":a.setColorPicker(a.findElement(i,".kirki-color-control"),n);break;case"kirki-multicheck":a.findElement(i,"input").each(function(){jQuery(this).prop("checked",!1)}),_.each(n,function(e,t){jQuery(a.findElement(i,'input[value="'+n[t]+'"]')).prop("checked",!0)});break;case"kirki-multicolor":_.each(n,function(e,t){a.setColorPicker(a.findElement(i,".multicolor-index-"+t),e)});break;case"kirki-radio-buttonset":case"kirki-radio-image":case"kirki-radio":case"kirki-dashicons":case"kirki-color-palette":case"kirki-palette":jQuery(a.findElement(i,'input[value="'+n+'"]')).prop("checked",!0);break;case"kirki-typography":_.each(["font-family","variant"],function(e){_.isUndefined(n[e])||a.setSelectWoo(a.findElement(i,"."+e+" select"),n[e])}),_.each(["font-size","line-height","letter-spacing","word-spacing"],function(e){_.isUndefined(n[e])||jQuery(a.findElement(i,"."+e+" input")).prop("value",n[e])}),_.isUndefined(n.color)||a.setColorPicker(a.findElement(i,".kirki-color-control"),n.color),e=JSON.stringify(n).replace(/'/g,"'"),jQuery(a.findElement(i,".typography-hidden-value").attr("value",e)).trigger("change");break;case"kirki-dimensions":_.each(n,function(e,t){jQuery(a.findElement(i,"."+t+" input")).prop("value",e)});break;case"kirki-repeater":case"kirki-custom":break;default:jQuery(a.findElement(i,"input")).prop("value",n)}},setColorPicker:function(e,t){e.attr("data-default-color",t).data("default-color",t).wpColorPicker("color",t)},setSelectWoo:function(e,t){jQuery(e).selectWoo().val(t).trigger("change")},setTextarea:function(e,t){jQuery(e).prop("value",t)},findElement:function(e,t){return wp.customize.control(e).container.find(t)},setValue:function(e,t,i){i=_.isUndefined(i)?100:parseInt(i,10),wp.customize.instance(e).set({}),setTimeout(function(){wp.customize.instance(e).set(t)},i)}};(kirki={initialized:!1,initialize:function(){this.initialized||(setTimeout(function(){kirki.util.webfonts.standard.initialize(),kirki.util.webfonts.google.initialize()},150),this.initialized=!0)}}).initialize();var kirki=kirki||{};kirki=(kirki=jQuery.extend(kirki,{control:{"kirki-radio":{init:function(e){this.template(e),kirki.input.radio.init(e)},template:function(e){var t=wp.template("kirki-input-radio");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,default:e.params.default,value:kirki.setting.get(e.id),choices:e.params.choices}))}},"kirki-color":{init:function(e){this.template(e),kirki.input.color.init(e)},template:function(e){var t=wp.template("kirki-input-color");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,mode:e.params.mode,inputAttrs:e.params.inputAttrs,"data-palette":e.params.palette,"data-default-color":e.params.default,"data-alpha":e.params.choices.alpha,value:kirki.setting.get(e.id)}))}},"kirki-generic":{init:function(e){this.template(e),_.isUndefined(e.params)||_.isUndefined(e.params.choices)||_.isUndefined(e.params.choices.element)||"textarea"!==e.params.choices.element?kirki.input.genericInput.init(e):kirki.input.textarea.init(e)},template:function(e){var t,i={label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,choices:e.params.choices,value:kirki.setting.get(e.id)};if(!_.isUndefined(e.params)&&!_.isUndefined(e.params.choices)&&!_.isUndefined(e.params.choices.element)&&"textarea"===e.params.choices.element)return t=wp.template("kirki-input-textarea"),void e.container.html(t(i));t=wp.template("kirki-input-generic"),e.container.html(t(i))}},"kirki-number":{init:function(e){this.template(e),kirki.input.number.init(e)},template:function(e){var t=wp.template("kirki-input-number");e.container.html(t(args={label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,choices:e.params.choices,value:kirki.setting.get(e.id)}))}},"kirki-select":{init:function(e){this.template(e),kirki.input.select.init(e)},template:function(e){var t=wp.template("kirki-input-select");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,choices:e.params.choices,value:kirki.setting.get(e.id),multiple:e.params.multiple||1,placeholder:e.params.placeholder}))}}}}))||{},kirki=(kirki=jQuery.extend(kirki,{input:{radio:{init:function(e){jQuery('input[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},color:{init:function(e){var t,i=jQuery('.kirki-color-control[data-id="'+e.id+'"]');e.choices=e.choices||{},_.isEmpty(e.choices)&&e.params.choices&&(e.choices=e.params.choices),_.isEmpty(e.choices)||i.wpColorPicker(e.choices),setTimeout(function(){(t=jQuery('.kirki-input-container[data-id="'+e.id+'"] .wp-picker-clear')).length&&t.click(function(){kirki.setting.set(e.id,"")})},200),i.wpColorPicker({change:function(){setTimeout(function(){kirki.setting.set(e.id,i.val())},20)}})}},genericInput:{init:function(e){jQuery('input[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},textarea:{init:function(e){jQuery('textarea[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},select:{init:function(e){var t,i=jQuery('select[data-id="'+e.id+'"]'),n=parseInt(i.data("multiple"),10),a={escapeMarkup:function(e){return e}};e.params.placeholder&&(a.placeholder=e.params.placeholder,a.allowClear=!0),1=i.params.choices.max?t:t+i.params.choices.step,n.val(e),n.trigger("change")}),t.click(function(){var e,t=parseFloat(n.val());e=t<=i.params.choices.min?t:t-i.params.choices.step,n.val(e),n.trigger("change")}),n.on("change keyup paste click",function(){kirki.setting.set(i.id,jQuery(this).val())})}},image:{getTemplate:function(e){var t,i="";return e=_.defaults(e,{label:"",description:"",inputAttrs:"","data-id":"",choices:{},value:""}),_.isUndefined(e.choices)||_.isUndefined(e.choices.save_as)||e.choices.save_as,t=e.value,_.isObject(e.value)&&!_.isUndefined(e.value.url)&&(t=e.value.url),i+="",i+='
',e.value.url||""!==t?i+='
':i+='
'+kirkiL10n.noFileSelected+"
",i+='
',i+='",e.default&&""!==e.default&&(i+='",i+="
",'
'+i+"
"},init:function(e){}}}}))||{},kirki=(kirki=jQuery.extend(kirki,{setting:{get:function(e){var t=e.split("["),i="",n=0,a="";return _.each(t,function(e,t){e=e.replace("]",""),0===t?i=e:i+="["+e+"]",_.isUndefined(wp.customize.instance(i))||(a=wp.customize.instance(i).get(),n=t),n"),i.params.content.attr("id","customize-control-"+e.replace(/]/g,"").replace(/\[/g,"-")),i.params.content.attr("class","customize-control customize-control-"+i.params.type)),this.propertyElements=[],wp.customize.Control.prototype.initialize.call(this,e,i)},_setUpSettingRootLinks:function(){var n=this;n.container.find("[data-customize-setting-link]").each(function(){var i=jQuery(this);wp.customize(i.data("customizeSettingLink"),function(e){var t=new wp.customize.Element(i);n.elements.push(t),t.sync(e),t.set(e())})})},_setUpSettingPropertyLinks:function(){var n=this;n.setting&&n.container.find("[data-customize-setting-property-link]").each(function(){var t,e=jQuery(this),i=e.data("customizeSettingPropertyLink");t=new wp.customize.Element(e),n.propertyElements.push(t),t.set(n.setting()[i]),t.bind(function(e){var t=n.setting();e!==t[i]&&((t=_.clone(t))[i]=e,n.setting.set(t))}),n.setting.bind(function(e){e[i]!==t.get()&&t.set(e[i])})})},ready:function(){var e=this;e._setUpSettingRootLinks(),e._setUpSettingPropertyLinks(),wp.customize.Control.prototype.ready.call(e),e.deferred.embedded.done(function(){e.initKirkiControl(e)})},embed:function(){var t=this,e=t.section();e&&wp.customize.section(e,function(e){"kirki-expanded"===e.params.type||e.expanded()||wp.customize.settings.autofocus.control===t.id?t.actuallyEmbed():e.expanded.bind(function(e){e&&t.actuallyEmbed()})})},actuallyEmbed:function(){"resolved"!==this.deferred.embedded.state()&&(this.renderContent(),this.deferred.embedded.resolve())},focus:function(e){this.actuallyEmbed(),wp.customize.Control.prototype.focus.call(this,e)},initKirkiControl:function(e){void 0===kirki.control[e.params.type]?this.container.on("change keyup paste click","input",function(){e.setting.set(jQuery(this).val())}):kirki.control[e.params.type].init(e)}})}(),_.each(kirki.control,function(e,t){wp.customize.controlConstructor[t]=wp.customize.kirkiDynamicControl.extend({})}),wp.customize.controlConstructor["kirki-background"]=wp.customize.Control.extend({ready:function(){"use strict";!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(this):this.initKirkiControl()},initKirkiControl:function(){var o=this,e=o.setting._value,t=o.container.find(".kirki-color-control");(_.isUndefined(e["background-image"])||""===e["background-image"])&&(o.container.find(".background-wrapper > .background-repeat").hide(),o.container.find(".background-wrapper > .background-position").hide(),o.container.find(".background-wrapper > .background-size").hide(),o.container.find(".background-wrapper > .background-attachment").hide()),t.wpColorPicker({change:function(){setTimeout(function(){o.saveValue("background-color",t.val())},100)}}),o.container.on("change",".background-repeat select",function(){o.saveValue("background-repeat",jQuery(this).val())}),o.container.on("change click",".background-size input",function(){o.saveValue("background-size",jQuery(this).val())}),o.container.on("change",".background-position select",function(){o.saveValue("background-position",jQuery(this).val())}),o.container.on("change click",".background-attachment input",function(){o.saveValue("background-attachment",jQuery(this).val())}),o.container.on("click",".background-image-upload-button",function(e){var r=wp.media({multiple:!1}).open().on("select",function(){var e,t,i,n=r.state().get("selection").first(),a=n.toJSON().sizes.full.url;_.isUndefined(n.toJSON().sizes.medium)?_.isUndefined(n.toJSON().sizes.thumbnail)||(a=n.toJSON().sizes.thumbnail.url):a=n.toJSON().sizes.medium.url,e=n.toJSON().sizes.full.url,n.toJSON().id,n.toJSON().width,n.toJSON().height,""!==e&&o.container.find(".background-wrapper > .background-repeat, .background-wrapper > .background-position, .background-wrapper > .background-size, .background-wrapper > .background-attachment").show(),o.saveValue("background-image",e),t=o.container.find(".placeholder, .thumbnail"),i=o.container.find(".background-image-upload-remove-button"),t.length&&t.removeClass().addClass("thumbnail thumbnail-image").html(''),i.length&&i.show()});e.preventDefault()}),o.container.on("click",".background-image-upload-remove-button",function(e){var t,i;e.preventDefault(),o.saveValue("background-image",""),t=o.container.find(".placeholder, .thumbnail"),i=o.container.find(".background-image-upload-remove-button"),o.container.find(".background-wrapper > .background-repeat").hide(),o.container.find(".background-wrapper > .background-position").hide(),o.container.find(".background-wrapper > .background-size").hide(),o.container.find(".background-wrapper > .background-attachment").hide(),t.length&&t.removeClass().addClass("placeholder").html("No file selected"),i.length&&i.hide()})},saveValue:function(e,t){var i=jQuery("#customize-control-"+this.id.replace("[","-").replace("]","")+" .background-hidden-value"),n=this.setting._value;n[e]=t,jQuery(i).attr("value",JSON.stringify(n)).trigger("change"),this.setting.set(n)}}),wp.customize.controlConstructor["kirki-color-palette"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-dashicons"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-date"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e=this,t=e.selector+" input.datepicker";jQuery(t).datepicker({dateFormat:"yy-mm-dd"}),e.container.find(".kirki-controls-loading-spinner").hide(),this.container.on("change keyup paste","input.datepicker",function(){e.setting.set(jQuery(this).val())})}}),wp.customize.controlConstructor["kirki-dimension"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this;t.kirkiNotifications(),this.container.on("change keyup paste","input",function(){e=jQuery(this).val(),t.setting.set(e)})},kirkiNotifications:function(){wp.customize(this.id,function(i){i.bind(function(e){var t="long_title";!1===kirki.util.validate.cssValue(e)?i.notifications.add(t,new wp.customize.Notification(t,{type:"warning",message:dimensionkirkiL10n["invalid-value"]})):i.notifications.remove(t)})})}}),wp.customize.controlConstructor["kirki-dimensions"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this.params.choices.controls,i={},n=[];for(_.each(t,function(e,t){!0===e&&n.push(t)}),e=0;e