1 line
24 KiB
JavaScript
1 line
24 KiB
JavaScript
|
!function(n){new acf.Model({id:"fieldGroupManager",events:{"submit #post":"onSubmit",'click a[href="#"]':"onClick","click .submitdelete":"onClickTrash"},filters:{find_fields_args:"filterFindFieldArgs"},onSubmit:function(e,t){var i=n("#titlewrap #title");i.val()||(e.preventDefault(),acf.unlockForm(t),alert(acf.__("Field group title is required")),i.trigger("focus"))},onClick:function(e){e.preventDefault()},onClickTrash:function(e){confirm(acf.__("Move to trash. Are you sure?"))||e.preventDefault()},filterFindFieldArgs:function(e){return e.visible=!0,e}}),new acf.Model({id:"screenOptionsManager",wait:"prepare",events:{change:"onChange"},initialize:function(){var e=n("#adv-settings"),t=n("#acf-append-show-on-screen");e.find(".metabox-prefs").append(t.html()),e.find(".metabox-prefs br").remove(),t.remove(),this.$el=n("#acf-field-key-hide"),this.render()},isChecked:function(){return this.$el.prop("checked")},onChange:function(e,t){var i=this.isChecked()?1:0;acf.updateUserSetting("show_field_keys",i),this.render()},render:function(){this.isChecked()?n("#acf-field-group-fields").addClass("show-field-keys"):n("#acf-field-group-fields").removeClass("show-field-keys")}}),new acf.Model({actions:{new_field:"onNewField"},onNewField:function(e){var t,i;e.has("append")&&(i=e.get("append"),(t=e.$el.siblings('[data-name="'+i+'"]').first()).length&&((t=(i=t.children(".acf-input")).children("ul")).length||(i.wrapInner('<ul class="acf-hl"><li></li></ul>'),t=i.children("ul")),i=e.$(".acf-input").html(),i=n("<li>"+i+"</li>"),t.append(i),t.attr("data-cols",t.children().length),e.remove()))}})}(jQuery),function(r){acf.FieldObject=acf.Model.extend({eventScope:".acf-field-object",events:{"click .edit-field":"onClickEdit","click .delete-field":"onClickDelete","click .duplicate-field":"duplicate","click .move-field":"move","change .field-type":"onChangeType","change .field-required":"onChangeRequired","blur .field-label":"onChangeLabel","blur .field-name":"onChangeName",change:"onChange",changed:"onChanged"},data:{id:0,key:"",type:""},setup:function(e){this.$el=e,this.inherit(e),this.prop("ID"),this.prop("parent"),this.prop("menu_order")},$input:function(e){return r("#"+this.getInputId()+"-"+e)},$meta:function(){return this.$(".meta:first")},$handle:function(){return this.$(".handle:first")},$settings:function(){return this.$(".settings:first")},$setting:function(e){return this.$(".acf-field-settings:first > .acf-field-setting-"+e)},getParent:function(){return acf.getFieldObjects({child:this.$el,limit:1}).pop()},getParents:function(){return acf.getFieldObjects({child:this.$el})},getFields:function(){return acf.getFieldObjects({parent:this.$el})},getInputName:function(){return"acf_fields["+this.get("id")+"]"},getInputId:function(){return"acf_fields-"+this.get("id")},newInput:function(e,t){var i=this.getInputId(),n=this.getInputName();e&&(i+="-"+e,n+="["+e+"]");t=r("<input />").attr({id:i,name:n,value:t});return this.$("> .meta").append(t),t},getProp:function(e){if(this.has(e))return this.get(e);var t=this.$input(e),t=t.length?t.val():null;return this.set(e,t,!0),t},setProp:function(e,t){var i=this.$input(e);i.val();return i.length||(i=this.newInput(e,t)),null===t?i.remove():i.val(t),this.has(e)?this.set(e,t):this.set(e,t,!0),this},prop:function(e,t){return void 0!==t?this.setProp(e,t):this.getProp(e)},props:function(t){Object.keys(t).map(function(e){this.setProp(e,t[e])},this)},getLabel:function(){var e=this.prop("label");return e=""===e?acf.__("(no label)"):e},getName:function(){return this.prop("name")},getType:function(){return this.prop("type")},getTypeLabel:function(){var e=this.prop("type"),t=acf.get("fieldTypes");return t[e]?t[e].label:e},getKey:function(){return this.prop("key")},initialize:function(){this.addProFields()},addProFields:function(){var e;acf.data.fieldTypes.hasOwnProperty("clone")||((e=r(".field-type").not(".acf-free-field-type")).find('optgroup option[value="group"]').parent().append('<option value="null" disabled="disabled">'+acf.__("Repeater (Pro only)")+'</option><option value="null" disabled="disabled">'+acf.__("Flexible
|