-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathterms-order.js
More file actions
2 lines (2 loc) · 2.51 KB
/
terms-order.js
File metadata and controls
2 lines (2 loc) · 2.51 KB
1
2
(()=>{"use strict";const e={template:"",tags:jQuery("#cld-tax-items"),tagDelimiter:wp.i18n._x(",","tag delimiter")||",",startId:null,_init(){if(!this.tags.length)return;const e=this;this._sortable(),"undefined"!=typeof wpAjax&&(wpAjax.procesParseAjaxResponse=wpAjax.parseAjaxResponse,wpAjax.parseAjaxResponse=function(t,a,s){const i=wpAjax.procesParseAjaxResponse(t,a,s);if(!i.errors&&i.responses[0]&&jQuery('[data-taxonomy="'+i.responses[0].what+'"]').length){const t=jQuery(i.responses[0].data).find("label").last().text().trim();e._pushItem(i.responses[0].what,t)}return i}),void 0!==window.tagBox&&(window.tagBox.processflushTags=window.tagBox.flushTags,window.tagBox.flushTags=function(t,a,s){if(void 0===s){const s=t.prop("id"),i=jQuery("input.newtag",t),n=(a=a||!1)?jQuery(a).text():i.val(),r=window.tagBox.clean(n).split(e.tagDelimiter);for(const t in r){const a=s+":"+r[t];jQuery('[data-item="'+a+'"]').length||e._pushItem(a,r[t])}}return this.processflushTags(t,a,s)},window.tagBox.processTags=window.tagBox.parseTags,window.tagBox.parseTags=function(t){const a=t.id,s=a.split("-check-num-")[1],i=a.split("-check-num-")[0],n=jQuery(t).closest(".tagsdiv").find(".the-tags"),r=window.tagBox.clean(n.val()).split(e.tagDelimiter)[s];(new wp.api.collections.Tags).fetch({data:{slug:r}}).done(a=>{const s=!!a.length&&jQuery('[data-item="'+i+":"+a[0].id+'"]');s.length?s.remove():(jQuery(`.cld-tax-order-list-item:contains(${r})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",function(){const t=jQuery(this),a=t.val(),s=t.is(":checked"),i=t.parent().text().trim();!0===s?e.tags.find(`[data-item="category:${a}"]`).length||e._pushItem(`category:${a}`,i):e.tags.find(`[data-item="category:${a}"]`).remove()})},_createItem(e,t){const a=jQuery("<li/>"),s=jQuery("<span/>"),i=jQuery("<input/>");return a.addClass("cld-tax-order-list-item").attr("data-item",e),i.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),s.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),a.append(s).append(t).append(i),a},_pushItem(e,t){const a=this._createItem(e,t);this.tags.append(a)},_sortable(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};void 0!==window.CLDN&&(e._init(),jQuery("[data-wp-lists] .selectit input[checked]").each((e,t)=>{jQuery(t).trigger("change")}))})();
//# sourceMappingURL=terms-order.js.map