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

1 line
1.7 KiB
JavaScript

/* Modifided script from the simple-page-ordering plugin */jQuery(document).ready(function(e){e("table.widefat.wp-list-table tbody th, table.widefat tbody td").css("cursor","move");e("table.widefat.wp-list-table").sortable({items:"tbody tr:not(.inline-edit-row)",cursor:"move",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(t,n){var r=n.item.find(".check-column input").val(),i=n.item.find(".parent").html(),s=n.item.prev().find(".check-column input").val(),o=n.item.next().find(".check-column input").val(),u=undefined;if(s!=undefined){var u=n.item.prev().find(".parent").html();u!=i&&(s=undefined)}var a=undefined;if(o!=undefined){a=n.item.next().find(".parent").html();a!=i&&(o=undefined)}if(s==undefined&&o==undefined||o==undefined&&a==s||o!=undefined&&u==r){e("table.widefat.wp-list-table").sortable("cancel");return}n.item.find(".check-column input").hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />');e.post(ajaxurl,{action:"woocommerce_term_ordering",id:r,nextid:o,thetaxonomy:woocommerce_term_ordering_params.taxonomy},function(e){e=="children"?window.location.reload():n.item.find(".check-column input").show().siblings("img").remove()});e("table.widefat tbody tr").each(function(){var e=jQuery("table.widefat tbody tr").index(this);e%2==0?jQuery(this).addClass("alternate"):jQuery(this).removeClass("alternate")})}})});