summaryrefslogtreecommitdiff
blob: a5b56d9de7b408493c298c3e2f5c799060e98d2b (plain)
1
function WMP_EDIT_THEME(){var JSObject=this;this.type="wmp_edittheme",this.form,this.DOMDoc,this.send_btn,this.enableCustomSelects=0,this.init=function(){WMPJSInterface=window.parent.WMPJSInterface,this.send_btn=jQuery("#"+this.type+"_send_btn",this.DOMDoc).get(0),this.form=this.DOMDoc.getElementById(this.type+"_form"),this.addButtonsActions(),null!=this.form&&(this.initCustomColors(),this.initCustomSelects())},this.initCustomColors=function(){jQuery('input[name^="'+JSObject.type+'_customcolor"]').wpColorPicker(),jQuery('input[name="'+JSObject.type+'_colorscheme"]').click(function(){0==jQuery(this).val()?jQuery(".color-schemes-custom").show():jQuery(".color-schemes-custom").hide()})},this.initCustomSelects=function(){1==this.enableCustomSelects&&(jQuery("#"+JSObject.type+"_fontheadlines").selectBoxIt(),jQuery("#"+JSObject.type+"_fontsubtitles").selectBoxIt(),jQuery("#"+JSObject.type+"_fontparagraphs").selectBoxIt())},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.submitForm=function(){return WMPJSInterface.AjaxUpload.dosubmit(JSObject.form,{onStart:JSObject.startUploadingData,onComplete:JSObject.completeUploadingData})},this.sendData=function(){jQuery("#"+this.form.id,this.DOMDoc).unbind("submit"),jQuery("#"+this.form.id,this.DOMDoc).bind("submit",function(){JSObject.submitForm()}),jQuery("#"+this.form.id,this.DOMDoc).submit(),JSObject.disableButton(JSObject.send_btn)},this.startUploadingData=function(){return WMPJSInterface.Preloader.start(),setTimeout(function(){var e=JSObject.form.elements;for(nElems=e.length,j=0;j<nElems;j++)e[j].disabled=!0},300),!0},this.completeUploadingData=function(responseJSON){jQuery("#"+JSObject.form.id,JSObject.DOMDoc).unbind("submit"),jQuery("#"+JSObject.form.id,JSObject.DOMDoc).bind("submit",function(){return!1}),WMPJSInterface.Preloader.remove(100);var JSON=eval("("+responseJSON+")"),response=Boolean(Number(String(JSON.status)));if(1==response&&0==JSON.messages.length){var message="Your app has been successfully modified!";WMPJSInterface.Loader.display({message:message})}else if(0==JSON.messages.length){var message="There was an error. Please reload the page and try again.";WMPJSInterface.Loader.display({message:message})}else for(var i=0;i<JSON.messages.length;i++)WMPJSInterface.Loader.display({message:JSON.messages[i]});setTimeout(function(){var e=JSObject.form.elements;for(nElems=e.length,j=0;j<nElems;j++)e[j].disabled=!1},300),JSObject.addButtonsActions()}}