summaryrefslogtreecommitdiff
blob: fa6e88cddadb5cc7555b1757a3f41d3683d3031b (plain)
1
function WMP_SWITCH_THEME(){var a=this;this.type="wmp_themes",this.DOMDoc,this.selectedTheme,this.savingTheme=!1,this.init=function(){WMPJSInterface=window.parent.WMPJSInterface,this.initSelectButtons()},this.initSelectButtons=function(){jQuery("."+a.type+"_select").click(function(){var b=Number(jQuery(this).attr("data-theme"));if(b!=a.selectedTheme){if(1==a.savingTheme)return;confirm("This setting will change the appearance of your app and reset your color schemes and fonts. Are you sure you want to continue?")&&a.switchTheme(b)}})},this.switchTheme=function(b){WMPJSInterface.Preloader.start({message:"Switching theme ..."}),a.savingTheme=!0,jQuery.get(ajaxurl,{action:"wmp_theme_switch",theme:b},function(c){if(WMPJSInterface.Preloader.remove(100),a.savingTheme=!1,c=Boolean(Number(String(c)))){var d=jQuery("."+a.type+'_select[data-theme="'+String(b)+'"]'),e=d.closest(".theme");jQuery(".corner",e).addClass("active"),d.hide(),jQuery(".text-select",e).text("Enabled");var f=jQuery("."+a.type+'_select[data-theme="'+String(a.selectedTheme)+'"]');f.closest(".actions").show();var g=f.closest(".theme");jQuery(".corner",g).removeClass("active"),f.show(),jQuery(".text-select",g).text("Activate"),a.selectedTheme=b;var h="Your mobile app theme has been successfully changed.";WMPJSInterface.Loader.display({message:h})}else{var h="There was an error. Please reload the page and try again.";WMPJSInterface.Loader.display({message:h})}})}}