1import fancyboxPlugin from '../plugins/fancybox-2.1.3.js'; 2 3var feature_popup_forced = window.location.search.includes('feature_popup_forced=1'); 4 5var feature_popup = { 6 7 init: function() { 8 9 $('#feature_popup_close_popup_link, #feature_popup_signup_close_popup_link a') 10 .off() 11 .click(function() { 12 window.galleries.feature_popup.close(); 13 return false; 14 }) 15 ; 16 17 $('a.feature_popup_link') 18 .off() 19 .click(function() { 20 // For accessibility - tracks which element to refocus on 21 try { 22 h.accessibility.global_variables.element_to_refocus_to = $(this); 23 } catch(error) { 24 console.error(error); 25 } 26 if ($('body').hasClass('slide-nav-active')) { 27 $('#top_nav_reveal').trigger('click'); 28 } 29 30 window.galleries.feature_popup.open(); 31 32 33 return false; 34 }) 35 ; 36 37 38 if (!$('body').hasClass('splash-loader-active')) { 39 40 if ($('#feature_popup_container').hasClass('auto_popup')) { 41 window.galleries.feature_popup.auto_popup(false, ('id_' + $('#feature_popup_container').attr('data-popup-id'))); 42 } 43 } 44 45 46 if ($('#feature_popup_container').hasClass('auto_popup_exit')) { 47 // Exit intent 48 if (!h.getCookie('shown_feature_popup_exit_intent')) { 49 setTimeout(function() { 50 var exit_intent_timeout; 51 $(document).off('mouseout.exitintent').on("mouseout.exitintent", function(evt) { 52 exit_intent_timeout = setTimeout(function() { 53 if(evt.toElement === null && evt.relatedTarget === null) { 54 $(evt.currentTarget).off('mouseout.exitintent'); 55 $(evt.currentTarget).off('mouseover.exitintent'); 56 window.galleries.feature_popup.auto_popup(true, 'exit_intent'); 57 } 58 }, 750); 59 }); 60 $(document).off('mouseover.exitintent').on("mouseover.exitintent", function(evt) { 61 if (typeof exit_intent_timeout != 'undefined') { 62 clearTimeout(exit_intent_timeout); 63 } 64 }); 65 }, 2000); 66 } 67 } 68 69 }, 70 71 open: function() { 72 73 $('body').addClass('feature_popup_active'); 74 75 setTimeout(function() { 76 $('body').addClass('feature_popup_visible'); 77 78 79 if (typeof h.accessibility != 'undefined') { 80 h.accessibility.on_popup_opening($('#feature_popup_box'), $('#feature_popup_box').find('input[type!="hidden"]:first'), '#feature_popup_close_popup_link a'); 81 } 82 83 window.galleries.feature_popup.after_popup(); 84 85 86 87 if (typeof $.fn.lazyload.fire === "function") { 88 $.fn.lazyload.fire($('#feature_popup_content .lazyload_wrapper')); 89 } 90 }, 50); 91 92 }, 93 94 close: function() { 95 96 $('body').removeClass('feature_popup_visible'); 97 setTimeout(function() { 98 $('body').removeClass('feature_popup_active'); 99 }, 400); 100 101 102 if (typeof h.accessibility != 'undefined') { 103 h.accessibility.on_popup_closing(); 104 } 105 106 }, 107 108 current_path_popup: function() { 109 110 //check the current path 111 var current_path = window.location.pathname; 112 113 var obj_to_return = {'id': null, 'has_popup': false, 'filepaths': ''} 114 115 //check our popup directory 116 var popup_placements = JSON.parse(document.getElementById('feature_popup_directory').value); 117 118 119 //Do we have a popup for this path? 120 for(let i = 0; i < popup_placements.length; i++) { 121 122 let obj = popup_placements[i]; 123 124 if (obj.filepaths.includes(current_path)) { 125 126 obj_to_return = {'id': obj.id, 'has_popup': true, 'filepaths': obj.filepaths} 127 128 break; //dont allow multiple popups on one page 129 } 130 131 } 132 133 return obj_to_return 134 }, 135 136 // load_dynamic_popup_content_then_auto_popup: function(popup_id) { 137 138 // var constructed_url = "/feature_popups/" + popup_id + '/' 139 // // Do ajax call here for popup and replace content 140 // $.ajax({ 141 // url: constructed_url, 142 // data: 'modal=1&inline=1', 143 // cache: false, 144 // dataType: 'html', 145 // success: function(data) { 146 // $('#feature_popup_dynamic_content').html(data); 147 // window.galleries.feature_popup.auto_popup(false, ('id_' + popup_id)); 148 // } 149 // }); 150 // }, 151 152 153 auto_popup: function(instant, context_name) { 154 155 156 157 instant = typeof instant != 'undefined' ? instant : false;
158 context_name = typeof context_name != 'undefined' ? '_' + context_name : ''; 159 160 if ($('#feature_popup_container').hasClass('auto_popup')) { 161 162 var timeout = 1000; 163 var expiry = 3600; 164 165 if ($('#feature_popup_container').attr('data-timeout')) { 166 timeout = parseFloat($('#feature_popup_container').attr('data-timeout'))*1000; 167 } 168 169 if ($('#feature_popup_container').attr('data-cookie-expiry')){ 170 expiry = parseFloat($('#feature_popup_container').attr('data-cookie-expiry')); 171 } 172 173 if (typeof feature_popup_timeout != 'undefined') { 174 clearTimeout(feature_popup_timeout); 175 } 176 177 if (feature_popup_forced) { 178 timeout = 1000; 179 } 180 if (instant) { 181 timeout = 0; 182 } 183 184 185 var feature_popup_timeout = setTimeout(function() { 186 187 if (!$('body').hasClass('protected-path-login-mode')) { 188 189 if(instant || !h.getCookie('shown_feature_popup' + context_name) || feature_popup_forced){ 190 191 var element_in_focus = $(':focus'); 192 if (element_in_focus.length < 1) { 193 element_in_focus = $('#logo a'); 194 } 195 196 try { 197 h.accessibility.global_variables.element_to_refocus_to = element_in_focus; 198 } catch(error) { 199 console.error(error); 200 } 201 202 window.galleries.feature_popup.open(); 203 204 $(document).off('mouseover.exitintent'); 205 $(document).off('mouseout.exitintent'); 206 207 h.setCookie('shown_feature_popup' + context_name, 'true', '', expiry); // Set cookie for chosen seconds 208 } 209 } 210 }, timeout); 211 } 212 }, 213 214 after_popup: function() { 215 216 } 217 218} 219 220window.galleries = window.galleries || {}; 221window.galleries.feature_popup = feature_popup; 222export default feature_popup;
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.