1jQuery.namespace( 'SS.com.Newsletters.frontend.modules' ); 2 3SS.com.Newsletters.frontend.modules.NewsletterSubscribe = function( moduleUniqueClass, moduleSettings, captchaWidgetId,popup) 4{ 5 var me = this; 6 this.module = $('.' + moduleUniqueClass); 7 this.uniqueCls = moduleUniqueClass; 8 this.formHelper = this.module.find('form').data('formHelper'); 9 this.confirmation = this.module.find('.confirmation-wrapper'); 10 this.confirmationIsTooltip = false; 11 this.moduleSettings = moduleSettings; 12 this.captchaWidgetId = captchaWidgetId; 13 this.isPopup = popup; 14 15 this.init(); 16}; 17 18SS.com.Newsletters.frontend.modules.NewsletterSubscribe.prototype = { 19 20 /** 21 * Init listeners and set the confirmation top position if it's a tooltip 22 */ 23 init: function() 24 { 25 var me = this; 26 if(this.isPopup){ 27 var newModuleCls = this.uniqueCls+'-popup'; 28 if(this.moduleSettings.popup_delay && !this.delayStarted){ 29 this.delayStarted = true; 30 setTimeout(function(){ 31 me.init(); 32 }, parseInt(this.moduleSettings.popup_delay) * 1000); 33 return; 34 35 } 36 37 this.newsLetterPopup = new SS.customAlert({ 38 width: 300, 39 modal:false, 40 cls:'newsletter-subscribe-popup', 41 draggable:false, 42 modalConfig: {color: '#000000'}, 43 title: this.moduleSettings.title ? this.moduleSettings.title : '" "', 44 msg:'<div class="'+newModuleCls+'"></div>', 45 buttons: {ok: false}, 46 bodyClass:'newsletterAlertVisible', 47 callback:function(){} 48 49 }); 50 this.module.appendTo($('.'+newModuleCls)); 51 } 52 53 var me = this; 54 55 if( this.confirmation.hasClass('tooltip') ){ 56 this.confirmationIsTooltip = true; 57 this.confirmation.css({ 58 top: -this.confirmation.height() + 'px' 59 }); 60 } 61 62 if (me.captchaWidgetId !== null) { 63 this.formHelper.form.on('beforeFormHelperSubmit', function (event, allValues) { 64 allValues["g-recaptcha-response"] = grecaptcha.getResponse(me.captchaWidgetId); 65 }); 66 67 this.formHelper.form.on('resetFormHelper', function (event) { 68 // We need to re-render the captcha 69 me.captchaWidgetId = grecaptcha.render(me.module.find('.g-recaptcha')[0], { 70 'sitekey': me.moduleSettings.captcha_site_key 71 }); 72 }) 73 } 74 75 this.formHelper.form.on('formHelperError',function(event, responseData, textStatus, jqXHR, errorThrown){ 76 77 }); 78 this.formHelper.form.on('formHelperSuccess',function(event, responseData, textStatus, jqXHR){ 79 if(responseData.attachment){ 80 window.open(responseData.attachment); 81 } 82 me.showConfirmation(); 83 me.formHelper.form.trigger('reset'); 84 }); 85 }, 86 87 /** 88 * Function that is showing the confirmation message after Ajax success. 89 * Return to the form after 5 seconds. 90 */ 91 showConfirmation: function() 92 { 93 var me = this; 94 me.module.addClass('with-confirmation-message'); 95 if( this.confirmationIsTooltip ){ 96 me.confirmation.fadeIn(200); 97 setTimeout(function(){ 98 me.confirmation.fadeOut(200); 99 if(me.moduleSettings.hide_if_registered == 1){ 100 me.module.slideUp(200); 101 } 102 me.module.removeClass('with-confirmation-message'); 103 },5000); 104 }else{ 105 this.formHelper.form.fadeOut(200,function(){ 106 me.confirmation.fadeIn(200); 107 setTimeout(function(){ 108 if(me.moduleSettings.hide_if_registered != 1){ 109 me.confirmation.fadeOut(200,function(){ 110 me.formHelper.form.fadeIn(200); 111 }); 112 }else{ 113 me.module.slideUp(200); 114 } 115 if(me.newsLetterPopup){ 116 me.newsLetterPopup._dom.find('.closeAlert').click(); 117 } 118 me.module.removeClass('with-confirmation-message'); 119 },5000); 120 }); 121 } 122 } 123 124};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.