(function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null};var overlay=$("
");$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");$("#lean_overlay").click(function(){close_modal(modal_id)});$(o.closeButton).click(function(){close_modal(modal_id)});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth(); $("#lean_overlay").css({"display":"block",opacity:0});$("#lean_overlay").fadeTo(200,o.overlay);$(modal_id).css({"display":"block","position":"fixed","opacity":0,"z-index":11000,"left":50+"%","margin-left":-(modal_width/2)+"px","top":o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault()})});function close_modal(modal_id){$("#lean_overlay").fadeOut(200);$(modal_id).css({"display":"none"})}}})})(jQuery); if (typeof isValidEmailAddress != 'function') { function isValidEmailAddress(emailAddress) { var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i; return pattern.test(emailAddress); }; } $(document).ready(function(){ var apply_on = 'in'; var html = 'BEVAKA'; if(apply_on == 'before') { $(document).find('.product-description-wrapper').before(html); }else if(apply_on == 'after'){ $(document).find('.product-description-wrapper').after(html); }else{ $(document).find('.product-description-wrapper').append(html); } $(document).find('body').append(' '); $("#watchers-add-btn").leanModal(); $('head').append(''); $('#watchers-add-btn').show(); }); $(document).on('submit', '.qs-watchers-add', function(evt){ evt.preventDefault(); var email_field = $(this).find('input[type=text]'); var email_address = email_field.val(); var product_id = $(this).find('input[name=pid_watch]').val(); var variant_id = $(this).find('input[name=vid_watch]').val(); if( !isValidEmailAddress( email_address ) ) { email_field.addClass('shake animated').css({'border':'1px solid red'}); }else{ // submit $.post('/da/apps/productwatchers/add', { email_address: email_address, product_id: product_id, variant_id: variant_id }, function(response) { if(response.error) { email_field.addClass('shake animated').css({'border':'1px solid red'}); }else{ $('.qs-watchers-add').slideUp(); $('#signup-header h2').slideUp(); $('#watchers-add-form-box').find('#signup-header').html(response.text_thankyou).fadeIn(); } }); } });