1//NotifyWhenAvailable 2var clickedButtons; 3var lastProductId = null; 4var lastQuantity = null; 5var origAddToCart = window.addToCart; 6var nwaAddToCart; 7var nwaAddToCartSelector = 'button#button-cart[onclick], [onclick^="cart.add"], [onclick^="addToCart"], [onclick^="mgk_cart.add"], [onclick^="ee_cart.add"], [onclick^="cart_theme.add"], .button[data-clk]'; 8 9nwaAddToCart = function(product_id, quantity) { 10 $('.alert, .text-danger').remove(); 11 $('.form-group').removeClass('has-error'); 12 $('#cart > button').button('reset'); 13 14 $('#NotifyWhenAvailable_popup').detach().appendTo('body'); 15 var btn = clickedButtons; 16 17 offset = $(btn).offset(); 18 19 $('div#NotifyWhenAvailable_popup').fadeIn('slow'); 20 $(".NWA_popover-content").load("index.php?route=extension/module/notifywhenavailable/shownotifywhenavailableform&product_id="+product_id, function() { 21 var window_width = $(window).width(); 22 var window_height = $(window).height(); 23 24 if(window_width >= 600 && window_width <= 1024) { 25 26 if($('.modal-backdrop').length < 1) { 27 $('<div class="modal-backdrop fade in"></div>').appendTo(document.body); 28 } else { 29 $('.modal-backdrop').css('display','block'); 30 } 31 32 $('body').css('overflow-y', 'hidden'); 33 34 $('.NWA_popover.bottom .arrow').css('display','none'); 35 36 $('div#NotifyWhenAvailable_popup').css({ 37 top: '50%', 38 left: '50%', 39 position: 'fixed', 40 'margin-top': -$('div.nwa-inner-wrapper').height()/2, 41 'margin-left': -$('div#NotifyWhenAvailable_popup').width()/2, 42 43 }); 44 } 45 else if (window_width < 600) { 46 if($('.modal-backdrop').length < 1) { 47 $('<div class="modal-backdrop fade in"></div>').appendTo(document.body); 48 } else { 49 $('.modal-backdrop').css('display','block'); 50 } 51 52 $('body').css('overflow-y', 'hidden'); 53 54 $('.NWA_popover.bottom .arrow').css('display','none'); 55 56 $('div#NotifyWhenAvailable_popup').css({ 57 top: 'calc(50% - 50%)', 58 left: 'calc(50% - 140px)', 59 position: 'fixed', 60 // 'margin-top': -$('.nwa-inner-wrapper').height()/2, 61 // 'margin-left': -$('.nwa-inner-wrapper').width()/2, 62 }); 63 } else { 64 $('div#NotifyWhenAvailable_popup').css({ 65 top: offset.top, 66 left: ((offset.left-$('div#NotifyWhenAvailable_popup').width()/2) + $('#button-cart').width()/2) 67 }); 68 } 69 }); 70}; 71 72function nwa(e, product_id, quantity) { 73 e.preventDefault(); 74 e.stopPropagation(); 75 e.stopImmediatePropagation(); 76 clickedButtons = e.target; 77 nwaAddToCart(product_id, quantity); 78} 79 80var checkQuantityNWA = function(product_ids) { 81 82 $.ajax({ 83 url: 'index.php?route=extension/module/notifywhenavailable/checkQuantityNWA', 84 type: 'post', 85 data: {product_ids: product_ids}, 86 dataType: 'json', 87 success: function(json) { 88 if(json) { 89 $(nwaAddToCartSelector).each(function(i,e){ 90 91 var rpAttr = $(this).attr('onclick'); 92 var params = null; 93 if (typeof rpAttr === 'undefined' || rpAttr === false) { 94 if ($(this).attr('data-clk')) { 95 var params = $(this).attr('data-clk').match(/\d+/); 96 } else { 97 params = [$('input[type="hidden"][name="product_id"]').val()]; 98 } 99 } else { 100 params = $(this).attr('onclick').match(/\d+/); 101 } 102 103 var rpAttr = $(this).attr('onclick'); 104 if (typeof rpAttr === 'undefined' || rpAttr === false) { 105 params = [$('input[type="hidden"][name="product_id"]').val()]; 106 } 107 var params = $(this).attr('onclick').match(/\d+/); 108 var func_call = 'nwa(event, '; 109 var button = $(this); 110 if (params) { 111 if (params[0]) { 112 func_call += params[0]; 113 if (params[1]) { 114 func_call += ', ' + params[1]; 115 } else { 116 func_call += ', 1'; 117 } 118 } 119 } 120 func_call += ');'; 121 for (i in json) { 122 if(!json[i].PO && json[i].product_id == params[0]) { 123 button.attr('onclick', func_call); 124 button.prop('disabled', false); 125 button.find('span').html(json[i]['NWA_text']); 126 button.attr('data-hint',json[i]['NWA_text']); 127 button.attr('data-original-title', 'Notify Me!'); 128 button.addClass('NWA-btn-action'); 129 if(button.parents('.cart').hasClass('outofstock')) { 130 button.parents('.cart').removeClass('outofstock'); 131 } 132 } 133 } 134 }); 135 } 136 } 137 }); 138 139}; 140 141var rescanPage = function(old_product_ids) { 142 var check_product_ids = []; 143 if ($('input[type="hidden"][name="product_id"]').length == 1) { 144 check_product_ids.push($('input[type="hidden"][name="product_id"]').val()); 145 } 146 $(nwaAddToCartSelector).each(function(i,e){ 147 var rpAttr = $(this).attr('onclick'); 148 if (typeof rpAttr === 'undefined' || rpAttr === false) { 149 return; 150 } 151 var params = $(this).attr('onclick').match(/\d+/); 152 check_product_ids.push(params[0]); 153 }); 154 console.log(check_product_ids); 155 checkQuantityNWA(check_product_ids); 156} 157 158$(document).ready(function() { 159 var check_product_ids = []; 160 $(nwaAddToCartSelector).each(function(i,e){ 161 var rpAttr = $(this).attr('onclick'); 162 if (typeof rpAttr === 'undefined' || rpAttr === false) { 163 return; 164 } 165 if ($(this).attr('data-clk')) { 166 var params = $(this).attr('data-clk').match(/\d+/); 167 } else { 168 var params = $(this).attr('onclick').match(/\d+/); 169 } 170 171 var rpAttr = $(this).attr('onclick'); 172 if (typeof rpAttr === 'undefined' || rpAttr === false) { 173 return; 174 } 175 var params = $(this).attr('onclick').match(/\d+/); 176 check_product_ids.push(params[0]); 177 }); 178 179 checkQuantityNWA(check_product_ids); 180 181 $(document).click(function(event) { 182 if (!$(event.target).is("#NotifyWhenAvailable_popup, #button-nwa-duplicate, #button-nwa-duplicate span, button[lkmwa=true], input[lkmwa=true], .NWA_popover-title, .arrow, .NWA_popover-content, #NWAYourName, #NWAYourEmail, #NWAYourComment, #NWAYourComment, #NWACaptchaImage, #NWACaptcha, #NotifyWhenAvailableSubmit, #NotifyWhenAvailable_popup p, #NotifyWhenAvailable_popup span, .NWA_popover, #NotifyWhenAvailableForm, .NWAError, input.NWA_popover_field_error, #button-cart, #NWAPrivacyPolicy, #NWAPrivacyPolicy *")) { 183 $('div#NotifyWhenAvailable_popup').fadeOut(300); 184 $('.modal-backdrop').fadeOut(300); 185 $('body').css('overflow-y', 'inherit'); 186 } 187 }); 188 189 var rescanTimer = null; 190 $(document).bind('DOMNodeInserted', function(event) { 191 var insertedEl = $(event.target); 192 if (!insertedEl.is(nwaAddToCartSelector) && insertedEl.find(nwaAddToCartSelector).length == 0) return; 193 if (rescanTimer != null) { 194 clearTimeout(rescanTimer); 195 } 196 rescanTimer = setTimeout(rescanPage.bind(null, check_product_ids), 1000); 197 }); 198});
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.