1if (typeof wolfgangs.overlay !== 'undefined') { 2 wolfgangs.overlay.sticky = { 3 element: null, 4 overlay: null, 5 parent: null, 6 build: function () { 7 this.element = new Foundation.Sticky(this.overlay); 8 }, 9 destroy: function () { 10 this.element.foundation('_destroy'); 11 } 12 }; 13 wolfgangs.overlay.emailregex = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/; // borrowed from http://emailregex.com/ 14 wolfgangs.overlay.writeCookie = function () { 15 var isKnownUser = wolfgangs.session && wolfgangs.session.MembershipType !== -1; 16 if (isKnownUser) { 17 Cookies.set(wolfgangs.overlay.configuration.name, 'true', { expires: wolfgangs.overlay.configuration.intervalDaysForKnown, path: '/' }); 18 } else { 19 Cookies.set(wolfgangs.overlay.configuration.name, 'true', { expires: wolfgangs.overlay.configuration.intervalDays, path: '/' }); 20 } 21 }; 22 wolfgangs.overlay.submitEmail = function (email, callback) { 23 if (wolfgangs.overlay.emailregex.test(email)) { 24 jQuery.ajax({ 25 "url": wolfgangs.page.services + "SubscribeWithPromo", 26 "data": { 27 "emailAddress": email 28 }, 29 "success": function (data) { 30 "use strict"; 31 //alert(data.Result); 32 callback(data.Result, data.Message); 33 }, 34 error: function () { 35 callback(-2, 'An unknown error has occured'); 36 } 37 }); 38 } else { 39 callback(-1, 'Please enter a valid email address') 40 } 41 } 42 wolfgangs.overlay.show = function () { 43 var writeCookie = this.writeCookie; // declare some vars here because of ES5 block-scoping 44 var submitEmail = this.submitEmail; 45 var name = this.configuration.name; 46 jQuery.ajax({ 47 url: wolfgangs.page.services + 'GetRawContentPageAsHtml', 48 data: { 49 FilePath: '/content/overlays/' + this.configuration.name + '.htm' 50 }, 51 success: function (data) {
52 var $overlay = jQuery(data.content).filter('.floating-overlay'); 53 54 $overlay.find('.icon-cancel').on('click', function (e) { 55 e.preventDefault(); 56 e.stopPropagation(); 57 $overlay.remove(); 58 jQuery("body").removeClass("screen").removeClass(name); 59 writeCookie(); 60 }); 61 var $input = $overlay.find('.input input'); 62 $overlay.find('.button.expand').on('click', function (e) { 63 e.preventDefault(); 64 e.stopPropagation(); 65 $overlay.addClass('expand'); 66 jQuery("body").addClass("screen"); 67 // ther user has clicked to expand the overlay, so focus on the input for them 68 $input.focus(); 69 }); 70 71 var $button = $overlay.find('.button.submit').on('click', function (e) { 72 e.preventDefault(); 73 e.stopPropagation(); 74 75 submitEmail(jQuery.trim($input.val()), function (responseCode, message) { 76 77 switch (responseCode) { 78 case 1: // success 79 80 writeCookie(); 81 $overlay.find('p').html(message); 82 83 $input.css("display", "none"); 84 $button.text('OK'); 85 86 $button.unbind("click"); 87 $button.on('click', function (e) { 88 e.preventDefault(); 89 e.stopPropagation(); 90 $overlay.remove(); 91 jQuery("body").removeClass("screen").removeClass(name); 92 93 94 }); 95 96 break; 97 case 2: 98 $overlay.find('p').html(message); 99 $input.css("display", "none"); 100 $button.text('OK'); 101 102 $button.unbind("click"); 103 $button.on('click', function (e) { 104 e.preventDefault(); 105 e.stopPropagation(); 106 $overlay.remove(); 107 jQuery("body").removeClass("screen").removeClass(name); 108 109 110 }); 111 112 break; 113 case -1: 114 $overlay.addClass('invalid-email'); 115 break; 116 case 0: 117 // $overlay.addClass('invalid-email'); 118 $overlay.remove(); 119 jQuery("body").removeClass("screen").removeClass(name); 120 break; 121 default: 122 $overlay.remove(); 123 jQuery("body").removeClass("screen").removeClass(name); 124 125 break; 126 } 127 }) 128 }); 129 130 $input.on('keypress', function (e) { 131 if ($overlay.hasClass('invalid-email')) { 132 $overlay.removeClass('invalid-email'); 133 } 134 if ($overlay.hasClass('error')) { 135 $overlay.removeClass('error').find('.large .input').removeAttr('data-error-message'); 136 } 137 if (e.which === 13) { 138 e.preventDefault(); 139 e.stopPropagation(); 140 $button.trigger('click'); // so we don't have to write this code twice 141 } 142 }); 143 // delay making the overlay visible to the user because matt was seeing a jump after the Foundation Sticky JS finished loading 144 $overlay.addClass('hidden'); 145 setTimeout(function() { $overlay.removeClass('hidden'); }, 2000); 146 jQuery("body").addClass(name); 147 if ($overlay.data('sticky')) {
148 wolfgangs.overlay.sticky.overlay = $overlay 149 wolfgangs.overlay.sticky.parent = jQuery('<div id="overlay_sticky_container" data-sticky-container="true"></div>'); 150 jQuery("#site_body > div").prepend(wolfgangs.overlay.sticky.parent); 151 wolfgangs.overlay.sticky.parent.append(wolfgangs.overlay.sticky.overlay); 152 wolfgangs.overlay.sticky.build(); 153 } else { 154 jQuery("body").append($overlay); 155 } 156 } 157 158 }); 159 }; 160 wolfgangs.overlay.check = function () { 161 var cookie = Cookies.get(this.configuration.name); 162 var isKnownUser = wolfgangs.session && wolfgangs.session.MembershipType !== -1; 163 var suppressForKnownUser = isKnownUser && this.configuration.intervalDaysForKnown === -1; 164 if (!cookie && !suppressForKnownUser) { 165 this.show(); 166 } 167 } 168 wolfgangs.overlay.init = function () { 169 this.check(); 170 var $inp = jQuery('.input input'); 171 // $inp.focus(); 172 // $inp.setSelectionRange(1, 2); 173 } 174 wolfgangs.overlay.init(); 175 jQuery("html").on("statechangecomplete", function (e) { 176 "use strict"; 177 wolfgangs.overlay.check(); 178 }); 179}
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.