summaryrefslogtreecommitdiff
blob: 2cd2e5363bd2dc5125f3080596ae1812da36394c (plain)
1
function WMP_EDIT_PAGES(){var t=this;this.type="wmp_editpages",this.form,this.DOMDoc,this.changingStatus=!1,this.init=function(){WMPJSInterface=window.parent.WMPJSInterface,this.form=this.DOMDoc.getElementById(this.type+"_form"),null!=this.form&&(this.initPages(),this.initListActions())},this.initListActions=function(){jQuery("ul.pages li div.row",this.DOMDoc).on("click",t.changeStatus)},this.initPages=function(){jQuery("#"+t.type+"_warning a.close-x",this.form).on("click",function(){jQuery("#"+t.type+"_warning",t.DOMDoc).hide()})},this.changeStatus=function(){var e=jQuery(this).closest("li").attr("data-page-id"),i=jQuery(this).closest("li");if(confirm("Are you sure you want to change the status for this page?")){var a,s=jQuery(".status",i);a=0==s.hasClass("active")?"active":"inactive",0==t.changingStatus&&(WMPJSInterface.Preloader.start(),jQuery.post(ajaxurl,{action:"wmp_content_status",id:e,status:a,type:"page"},function(e){if(t.changingStatus=!1,WMPJSInterface.Preloader.remove(100),1==(e=Boolean(Number(String(e))))){s.addClass(a),s.removeClass("active"==a?"inactive":"active"),s.text(a);var i="The status of this page has been changed.";WMPJSInterface.Loader.display({message:i}),jQuery("li span.active.main-page",t.form).length>0?jQuery("#"+t.type+"_warning",t.DOMDoc).hide():jQuery("#"+t.type+"_warning",t.DOMDoc).show()}else{i="There was an error. Please reload the page and try again in few seconds or contact the plugin administrator if the problem persists.";WMPJSInterface.Loader.display({message:i})}}))}}}