1
|
function WMP_SEND_FEEDBACK(){var t=this;this.type="wmp_feedback",this.form,this.DOMDoc,this.feedbackEmail,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.initValidation()},this.initValidation=function(){this.validator=jQuery("#"+this.form.id,this.DOMDoc).validate({rules:{wmp_feedback_email:{required:!0,email:!0},wmp_feedback_name:{required:!0},wmp_feedback_message:{required:!0}},errorPlacement:function(e,i){var r=i[0].id.split("_"),o=r.length>1?r[r.length-1]:r[0],a=jQuery("#error_"+o+"_container",t.DOMDoc);e.appendTo(a)},errorElement:"span"});var e=jQuery("#"+this.type+"_name",this.DOMDoc);e.data("holder",e.attr("placeholder")),e.focusin(function(){jQuery(this).attr("placeholder","")}).focusout(function(){jQuery(this).attr("placeholder",jQuery(this).data("holder"))});var i=jQuery("#"+this.type+"_email",this.DOMDoc);i.data("holder",i.attr("placeholder")),i.focusin(function(){jQuery(this).attr("placeholder","")}).focusout(function(){jQuery(this).attr("placeholder",jQuery(this).data("holder"))});var r=jQuery("#"+this.type+"_message",this.DOMDoc);r.data("holder",r.attr("placeholder")),r.focusin(function(){jQuery(this).attr("placeholder","")}).focusout(function(){jQuery(this).attr("placeholder",jQuery(this).data("holder"))})},this.addButtonsActions=function(){jQuery(this.send_btn).unbind("click"),jQuery(this.send_btn).bind("click",function(){t.disableButton(this),t.validate()}),t.enableButton(this.send_btn)},this.enableButton=function(t){jQuery(t).css("cursor","pointer"),jQuery(t).animate({opacity:1},100)},this.disableButton=function(t){jQuery(t).unbind("click"),jQuery(t).animate({opacity:.4},100),jQuery(t).css("cursor","default")},this.scrollToError=function(e){var i=jQuery("html,body",t.DOMDoc),r=parseInt(jQuery("html,body").scrollTop())||parseInt(jQuery("body").scrollTop()),o=i.get(0).clientHeight;parseInt(i.offset().top);r>e?jQuery(i).animate({scrollTop:e-20},1e3):e>r+o&&jQuery(i).animate({scrollTop:r+o},1e3)},this.validate=function(){jQuery(this.form).validate().form();var e=[];for(var i in this.validator.invalid){var r=jQuery(this.form[i]);e.push(r.offset().top)}0==e.length?t.sendData():(e.sort(function(t,e){return t-e}),t.scrollToError(e[0]),t.addButtonsActions())},this.submitForm=function(){return WMPJSInterface.AjaxUpload.dosubmit(t.form,{onStart:t.startUploadingData,onComplete:t.completeUploadingData})},this.sendData=function(){jQuery("#"+this.form.id,this.DOMDoc).unbind("submit"),jQuery("#"+this.form.id,this.DOMDoc).bind("submit",function(){t.submitForm()}),jQuery("#"+this.form.id,this.DOMDoc).submit(),t.disableButton(t.send_btn)},this.startUploadingData=function(){var e="Please wait...";return WMPJSInterface.Preloader.start({message:e}),setTimeout(function(){var e=t.form.elements;for(nElems=e.length,j=0;j<nElems;j++)e[j].disabled=!0},300),jQuery(".feedback",t.DOMDoc).animate({opacity:.4},300),!0},this.completeUploadingData=function(e){if(jQuery("#"+t.form.id,t.DOMDoc).unbind("submit"),jQuery("#"+t.form.id,t.DOMDoc).bind("submit",function(){return!1}),e=Boolean(Number(String(e))),WMPJSInterface.Preloader.remove(100),e){var i="Thank you for your message, we'll be in touch with you soon!";WMPJSInterface.Loader.display({message:i}),t.form.reset()}else{var i='We were unable to send the message because your mail() function is probably disabled. Please send your message directly to <a href="mailto:'+t.feedbackEmail+'">'+t.feedbackEmail+"</a>.";WMPJSInterface.Loader.display({message:i,time:15e3})}setTimeout(function(){var e=t.form.elements;for(nElems=e.length,j=0;j<nElems;j++)e[j].disabled=!1},300),t.addButtonsActions(),jQuery(".feedback",t.DOMDoc).animate({opacity:1},300)}}
|