1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
|
(()=>{var t={482:()=>{!function(t){var e=acf.Field.extend({type:"flexible_content",wait:"",events:{'click [data-name="add-layout"]':"onClickAdd",'click [data-name="duplicate-layout"]':"onClickDuplicate",'click [data-name="remove-layout"]':"onClickRemove",'click [data-name="collapse-layout"]':"onClickCollapse",showField:"onShow",unloadField:"onUnload",mouseover:"onHover"},$control:function(){return this.$(".acf-flexible-content:first")},$layoutsWrap:function(){return this.$(".acf-flexible-content:first > .values")},$layouts:function(){return this.$(".acf-flexible-content:first > .values > .layout")},$layout:function(t){return this.$(".acf-flexible-content:first > .values > .layout:eq("+t+")")},$clonesWrap:function(){return this.$(".acf-flexible-content:first > .clones")},$clones:function(){return this.$(".acf-flexible-content:first > .clones > .layout")},$clone:function(t){return this.$('.acf-flexible-content:first > .clones > .layout[data-layout="'+t+'"]')},$actions:function(){return this.$(".acf-actions:last")},$button:function(){return this.$(".acf-actions:last .button")},$popup:function(){return this.$(".tmpl-popup:last")},getPopupHTML:function(){var e=this.$popup().html(),a=t(e),i=this.$layouts();return a.find("[data-layout]").each((function(){var e=t(this),a=e.data("min")||0,n=e.data("max")||0,s=e.data("layout")||"",o=function(e){return i.filter((function(){return t(this).data("layout")===e})).length}(s);if(n&&o>=n)e.addClass("disabled");else if(a&&o<a){var r=a-o,l=acf.__("{required} {label} {identifier} required (min {min})"),c=acf._n("layout","layouts",r);l=(l=(l=(l=l.replace("{required}",r)).replace("{label}",s)).replace("{identifier}",c)).replace("{min}",a),e.append('<span class="badge" title="'+l+'">'+r+"</span>")}})),a.outerHTML()},getValue:function(){return this.$layouts().length},allowRemove:function(){var t=parseInt(this.get("min"));return!t||t<this.val()},allowAdd:function(){var t=parseInt(this.get("max"));return!t||t>this.val()},isFull:function(){var t=parseInt(this.get("max"));return t&&this.val()>=t},addSortable:function(t){1!=this.get("max")&&this.$layoutsWrap().sortable({items:"> .layout",handle:"> .acf-fc-layout-handle",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,stop:function(e,a){t.render()},update:function(e,a){t.$input().trigger("change")}})},addCollapsed:function(){var e=i.load(this.get("key"));if(!e)return!1;this.$layouts().each((function(a){e.indexOf(a)>-1&&t(this).addClass("-collapsed")}))},addUnscopedEvents:function(e){this.on("invalidField",".layout",(function(a){e.onInvalidField(a,t(this))}))},initialize:function(){this.addUnscopedEvents(this),this.addCollapsed(),acf.disable(this.$clonesWrap(),this.cid),this.render()},render:function(){this.$layouts().each((function(e){t(this).find(".acf-fc-layout-order:first").html(e+1)})),0==this.val()?this.$control().addClass("-empty"):this.$control().removeClass("-empty"),this.isFull()?this.$button().addClass("disabled"):this.$button().removeClass("disabled")},onShow:function(t,e,a){var i=acf.getFields({is:":visible",parent:this.$el});acf.doAction("show_fields",i)},validateAdd:function(){if(this.allowAdd())return!0;var t=this.get("max"),e=acf.__("This field has a limit of {max} {label} {identifier}"),a=acf._n("layout","layouts",t);return e=(e=(e=e.replace("{max}",t)).replace("{label}","")).replace("{identifier}",a),this.showNotice({text:e,type:"warning"}),!1},onClickAdd:function(t,e){if(!this.validateAdd())return!1;var i=null;e.hasClass("acf-icon")&&(i=e.closest(".layout")).addClass("-hover");var n=new a({target:e,targetConfirm:!1,text:this.getPopupHTML(),context:this,confirm:function(t,e){e.hasClass("disabled")||this.add({layout:e.data("layout"),before:i})},cancel:function(){i&&i.removeClass("-hover")}});n.on("click","[data-layout]","onConfirm")},add:function(t){if(t=acf.parseArgs(t,{layout:"",before:!1}),!this.allowAdd())return!1;var e=acf.duplicate({target:this.$clone(t.layout),append:this.proxy((function(e,a){t.before?t.before.before(a):this.$layoutsWrap().append(a),acf.enable(a,this.cid),this.render()}))});return this.$input().trigger(
|