summaryrefslogtreecommitdiff
blob: c598c65c7c75901d95baf5742c77b2e355d0b43e (plain)
1
function WMP_DISCONNECT(){var JSObject=this;this.type="wmp_disconnect",this.DOMDoc,this.send_btn,this.redirectTo,this.submitUrl,this.init=function(){WMPJSInterface=window.parent.WMPJSInterface,this.send_btn=jQuery("#"+this.type+"_send_btn",this.DOMDoc).get(0),this.addButtonsActions()},this.addButtonsActions=function(){jQuery(this.send_btn).unbind("click"),jQuery(this.send_btn).bind("click",function(){JSObject.disableButton(this),JSObject.sendData()}),JSObject.enableButton(this.send_btn)},this.enableButton=function(e){jQuery(e).css("cursor","pointer"),jQuery(e).animate({opacity:1},100)},this.disableButton=function(e){jQuery(e).unbind("click"),jQuery(e).animate({opacity:.4},100),jQuery(e).css("cursor","default")},this.sendData=function(){var isConfirmed=confirm("Are you sure you want to disconnect from Appticles?");isConfirmed&&(WMPJSInterface.Preloader.start(),jQuery.ajax({url:JSObject.submitURL,type:"get",data:{apiKey:jQuery("#"+JSObject.type+"_apikey",JSObject.DOMDoc).val()},dataType:"jsonp",success:function(responseJSON){WMPJSInterface.Preloader.remove(100);var JSON=eval(responseJSON),response=Boolean(Number(String(JSON.status)));jQuery.post(ajaxurl,{action:"wmp_premium_disconnect",api_key:jQuery("#"+JSObject.type+"_apikey",JSObject.DOMDoc).val(),active:"0"},function(e){if(e=Boolean(Number(String(e))),1==e)window.location.href=JSObject.redirectTo;else{var t="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:t})}})},error:function(e){WMPJSInterface.Preloader.remove(100),WMPJSInterface.Loader.display({message:"Disconnect endpoint is unreachable. Please contact support."})}}))}}