!function(){"use strict";var e=window.wp.htmlEntities;window["jquery-ui-sortable"];const t=jQuery(".wp-list-table tbody");function n(o){if("children"===o)return void window.location.reload();const i=jQuery.parseJSON(o),{new_pos:r}=i;for(const t in r){if("next"===t)continue;const n=document.getElementById(`inline_${t}`);if(null!==n&&r.hasOwnProperty(t)){const o=n.querySelector(".menu_order");if(void 0!==r[t].menu_order){null!==o&&(o.textContent=r[t].menu_order);const i=n.querySelector(".post_parent");null!==i&&(i.textContent=r[t].post_parent);let l=null;const a=n.querySelector(".post_title");null!==a&&(l=a.innerHTML);let s=0;for(;s<r[t].depth;)l=`&mdash; ${l}`,s++;const d=n.parentNode.querySelector(".row-title");null!==d&&null!==l&&(d.textContent=(0,e.decodeEntities)(l))}else null!==o&&(o.textContent=r[t])}}i.next?jQuery.post(window.ajaxurl,{action:"simple_page_ordering",id:i.next.id,previd:i.next.previd,nextid:i.next.nextid,start:i.next.start,_wpnonce:window.simple_page_ordering_localized_data._wpnonce,excluded:JSON.stringify(i.next.excluded)},n):(jQuery(".spo-updating-row").removeClass("spo-updating-row").find(".check-column").removeClass("spinner is-active"),t.removeClass("spo-updating").sortable("enable"))}t.sortable({items:"> tr",cursor:"move",axis:"y",containment:"table.widefat",cancel:"input, textarea, button, select, option, .inline-edit-row",distance:2,opacity:.8,tolerance:"pointer",create(){jQuery(document).keydown((function(e){const n=e.key||e.keyCode;"Escape"!==n&&"Esc"!==n&&27!==n||(t.sortable("option","preventUpdate",!0),t.sortable("cancel"))}))},start(e,t){"undefined"!==typeof inlineEditPost&&inlineEditPost.revert(),t.placeholder.height(t.item.height()),t.placeholder.empty()},helper(e,t){const n=t.children();for(let e=0;e<n.length;e++){const t=jQuery(n[e]);t.width(t.width())}return t},stop(e,n){t.sortable("option","preventUpdate")&&t.sortable("option","preventUpdate",!1),n.item.children().css("width","")},update(e,o){if(t.sortable("option","preventUpdate"))return void t.sortable("option","preventUpdate",!1);t.sortable("disable").addClass("spo-updating"),o.item.addClass("spo-updating-row"),o.item.find(".check-column").addClass("spinner is-active");const i=o.item[0].id.substr(5);let r=!1;const l=o.item.prev();l.length>0&&(r=l.attr("id").substr(5));let a=!1;const s=o.item.next();s.length>0&&(a=s.attr("id").substr(5)),jQuery.post(window.ajaxurl,{action:"simple_page_ordering",id:i,previd:r,nextid:a,_wpnonce:window.simple_page_ordering_localized_data._wpnonce},n);const d=document.querySelectorAll("tr.iedit");let p=d.length;for(;p--;)p%2===0?jQuery(d[p]).addClass("alternate"):jQuery(d[p]).removeClass("alternate")}}),jQuery((function(){jQuery("#simple-page-ordering-reset").on("click",(function(e){e.preventDefault();const t=jQuery(this).data("posttype");window.confirm(window.simple_page_ordering_localized_data.confirmation_msg)&&jQuery.post(window.ajaxurl,{action:"reset_simple_page_ordering",post_type:t,_wpnonce:window.simple_page_ordering_localized_data._wpnonce},(function(){window.location.reload()}))}))}))}();