Files
old-v2-backend/wordpress/wp-content/plugins/advanced-custom-fields-pro/pro/assets/js/acf-pro-input.min.js

1 line
17 KiB
JavaScript
Raw Normal View History

2018-06-25 00:00:37 +02:00
!function($){acf.fields.repeater=acf.field.extend({type:"repeater",$el:null,$input:null,$table:null,$tbody:null,$clone:null,actions:{ready:"initialize",append:"initialize",show:"show"},events:{'click a[data-event="add-row"]':"_add",'click a[data-event="remove-row"]':"_remove",'click a[data-event="collapse-row"]':"_collapse","mouseenter td.order":"_mouseenter"},focus:function(){this.$el=this.$field.find(".acf-repeater:first"),this.$input=this.$el.children("input"),this.$table=this.$el.children("table"),this.$tbody=this.$table.children("tbody"),this.$clone=this.$tbody.children("tr.acf-clone"),this.o=acf.get_data(this.$el,{min:0,max:0}),this.o.min=parseInt(this.o.min),this.o.max=parseInt(this.o.max)},initialize:function(){acf.disable_form(this.$clone,"repeater"),this.render()},show:function(){this.$tbody.find(".acf-field:visible").each(function(){acf.do_action("show_field",$(this))})},count:function(){return this.$tbody.children().length-1},render:function(){var e=this.$el.find("> .acf-actions .button");this.$tbody.children().each(function(e){$(this).find("> td.order > span").html(e+1)}),0==this.count()?this.$el.addClass("-empty"):this.$el.removeClass("-empty"),this.o.max>0&&this.count()>=this.o.max?e.addClass("disabled"):e.removeClass("disabled")},add:function(e){if(e=e||this.$clone,this.o.max>0&&this.count()>=this.o.max)return alert(acf._e("repeater","max").replace("{max}",this.o.max)),!1;var t=this.$field;return $el=acf.duplicate(this.$clone),$el.removeClass("acf-clone"),acf.enable_form($el,"repeater"),e.before($el),this.doFocus(t),this.render(),acf.validation.remove_error(this.$field),this.sync(),$el},remove:function(e){var t=this;if(this.count()<=this.o.min)return alert(acf._e("repeater","min").replace("{min}",this.o.min)),!1;acf.do_action("remove",e),acf.remove_tr(e,function(){t.$input.trigger("change"),t.render(),t.sync(),acf.do_action("refresh",t.$field)})},sync:function(){var e="collapsed_"+this.$field.data("key"),t=[];this.$tbody.children().each(function(e){$(this).hasClass("-collapsed")&&t.push(e)}),acf.update_user_setting(e,t.join(","))},_mouseenter:function(e){if(!this.$tbody.hasClass("ui-sortable")&&1!=this.o.max){var t=this;this.$tbody.sortable({items:"> tr",handle:"> td.order",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,stop:function(e,a){t.render()},update:function(e,a){t.$input.trigger("change")}})}},_add:function(e){$row=!1,e.$el.hasClass("acf-icon")&&($row=e.$el.closest(".acf-row")),this.add($row)},_remove:function(e){var t=this,a=e.$el.closest(".acf-row");a.addClass("-hover"),acf.tooltip.confirm_remove(e.$el,function(e){a.removeClass("-hover"),e&&t.remove(a)})},_collapse:function(e){var t=e.$el.closest(".acf-row"),a=this.$field;t.hasClass("-collapsed")?(t.removeClass("-collapsed"),acf.do_action("show",t,"collapse")):(t.addClass("-collapsed"),acf.do_action("hide",t,"collapse")),this.set("$field",a).sync(),acf.do_action("refresh",this.$field)}})}(jQuery),function($){acf.fields.flexible_content=acf.field.extend({type:"flexible_content",$el:null,$input:null,$values:null,$clones:null,actions:{ready:"initialize",append:"initialize",show:"show"},events:{'click [data-name="add-layout"]':"_open",'click [data-name="remove-layout"]':"_remove",'click [data-name="collapse-layout"]':"_collapse","mouseenter .acf-fc-layout-handle":"_mouseenter"},focus:function(){this.$el=this.$field.find(".acf-flexible-content:first"),this.$input=this.$el.children("input"),this.$values=this.$el.children(".values"),this.$clones=this.$el.children(".clones"),this.o=acf.get_data(this.$el),this.o.min=this.o.min||0,this.o.max=this.o.max||0},count:function(){return this.$values.children(".layout").length},initialize:function(){acf.disable_form(this.$clones,"flexible_content"),this.render()},show:function(){this.$values.find(".acf-field:visible").each(function(){acf.do_action("show_field",$(this))})},render:function(){var e=this,t=this.$el.find("> .acf-actions .button");this.$values.children(".layout").each(function(e){$(this).find("> .acf-fc-layout-handle .acf-fc-layout-order").html(e+1)}),0==this.count()?this.$el.addClass("empty"):