woocommerce/assets/js/admin/term-ordering.min.js

1 line
1.9 KiB
JavaScript

jQuery(function(e){var t="table.wp-list-table",n='.column-handle input[name="term_id"]';0===e(t).find(".column-handle").length&&(e(t).find("tr:not(.inline-edit-row)").append('<td class="column-handle"></td>'),n=".check-column input"),e(t).find(".column-handle").show(),e(document).ajaxComplete(function(n,i,d){i&&4===i.readyState&&200===i.status&&d.data&&0<=d.data.indexOf("_inline_edit")&&(e(t).find(".column-handle").show(),e(document.body).trigger("init_tooltips"))}),e(t).sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",handle:".column-handle",axis:"y",forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"product-cat-placeholder",scrollSensitivity:40,start:function(e,t){t.item.hasClass("alternate")||t.item.css("background-color","#ffffff"),t.item.children("td, th").css("border-bottom-width","0"),t.item.css("outline","1px solid #aaa")},stop:function(e,t){t.item.removeAttr("style"),t.item.children("td, th").css("border-bottom-width","1px")},update:function(i,d){var o,a,l=d.item.find(n).val(),r=d.item.find(".parent").html(),c=d.item.prev().find(n).val(),m=d.item.next().find(n).val();c!==undefined&&(o=d.item.prev().find(".parent").html())!==r&&(c=undefined),m!==undefined&&(a=d.item.next().find(".parent").html())!==r&&(m=undefined),c===undefined&&m===undefined||m===undefined&&a===c||m!==undefined&&o===l?e(t).sortable("cancel"):(d.item.find(".check-column input").hide(),d.item.find(".check-column").append('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />'),e.post(ajaxurl,{action:"woocommerce_term_ordering",id:l,nextid:m,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){"children"===e?window.location.reload():(d.item.find(".check-column input").show(),d.item.find(".check-column").find("img").remove())}),e("table.widefat tbody tr").each(function(){jQuery("table.widefat tbody tr").index(this)%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")}))}})});