1/* 2* 2017 Singleton software 3* 4* @author Singleton software <[email protected]> 5* @copyright 2017 Singleton software 6*/ 7 8var succesFixedMessageTimeout = undefined; 9var succesBootstrapAlertMessageTimeout = undefined; 10 11$(document).ready(function() { 12 // do pola addToCardProducts sa vkladaju produkty vlozene do kosika v emite "updateCart" aby sa dali vytihanut potom po emite "updatedCart", ktory je bez parametrov 13 var addToCardProducts = []; 14 // hned po kliknuti na vlozenie do kosika sa vykona emit "updateCart" s parametrami 15 prestashop.on('updateCart', function (event) { 16 if (event.reason.linkAction == 'add-to-cart') { 17 $("body").addClass("atc"); 18 if ($("#product_page_product_id[value='" + event.reason.idProduct + "']").parents(".modal:eq(0)").length == 1) { 19 // kontrola ci sa jedna o produkt z modalu detailu produktu 20 productInfo = {'idProduct' : event.reason.idProduct, 'idProductAttribute' : event.reason.idProductAttribute, 'addedFromProductPage' : true, 'isModal' : true}; 21 addToCardProducts.push(productInfo); 22 if (progress_wheel) { 23 showProgressWheel(productInfo); 24 } 25 } else { 26 // kontrola ci sa jedna o produkt z detailu produktu 27 productInfo = {'idProduct' : event.reason.idProduct, 'idProductAttribute' : event.reason.idProductAttribute, 'addedFromProductPage' : ($("#product_page_product_id[value='" + event.reason.idProduct + "']").length == 1), 'isModal' : false}; 28 addToCardProducts.push(productInfo); 29 if (progress_wheel) { 30 showProgressWheel(productInfo); 31 } 32 } 33 if (greaterThan1750) { 34 setTimeout(function() { 35 if (typeof addToCardProducts[0] !== 'undefined') { 36 product = addToCardProducts[0]; 37 if (progress_wheel) { 38 $('.preLoading').remove(); 39 } 40 if ((animation_places == 1 && product.addedFromProductPage) || (animation_places == 2 && !product.addedFromProductPage) || (animation_places == 3)) { 41 if (scroll_to_cart) { 42 scrollToCart(); 43 } 44 if ((product.isModal && fly_to_card_from_modal && fly_to_card) || (!product.isModal && fly_to_card)) { 45 flyToCart(product); 46 } else { 47 selectAnimationAndEffect(product); 48 } 49 } 50 addToCardProducts.splice(0,1); 51 } 52 }, 1000); 53 } 54 } 55 }); 56 // po tom ako sa vlozi produkt do kosika sa zavola emit "updatedCart" 57 prestashop.on('updatedCart', function (event) { 58 if (typeof addToCardProducts[0] !== 'undefined') { 59 product = addToCardProducts[0]; 60 if (progress_wheel) { 61 $('.preLoading').remove(); 62 } 63 if ((animation_places == 1 && product.addedFromProductPage) || (animation_places == 2 && !product.addedFromProductPage) || (animation_places == 3)) { 64 if (scroll_to_cart) { 65 scrollToCart(); 66 } 67 if ((product.isModal && fly_to_card_from_modal && fly_to_card) || (!product.isModal && fly_to_card)) { 68 flyToCart(product); 69 } else { 70 selectAnimationAndEffect(product); 71 } 72 } 73 addToCardProducts.splice(0,1); 74 } 75 }); 76}); 77 78function flyToCart(product) { 79 $('.flyerClone').remove(); 80 // v preste 1.7.x neexistuje moznost vlozit do kosika z katalogu produktov, preto je product.addedFromProductPage vzdy TRUE 81 if (product.addedFromProductPage) { 82 if (product.isModal) { 83 productImage = $(thumbnail_parent_path + "[data-id-product='" + product.idProduct + "'] img:eq(0)"); 84 } else { 85 productImage = $('#product_page_product_id[value="' + product.idProduct + '"]').parents("#main").find("img#tns1-item0"); 86 } 87 if (fly_to_card_image_type) { 88 flyer = '#custom_flyer'; 89 //vyrata sa pozicia z kade ma odlietat custom flyer - vycentrovanie do stredu obrazku 90 flyerTopOffset = $(productImage).offset().top + (($(productImage).height() / 2) - ($(flyer).height() / 2)); 91 flyerLeftOffset = $(productImage).offset().left + (($(productImage).width() / 2) - ($(flyer).width() / 2)); 92 } else { 93 flyer = productImage; 94 flyerTopOffset = $(flyer).offset().top; 95 flyerLeftOffset = $(flyer).offset().left; 96 } 97 } else { 98 productImage = $(thumbnail_parent_path + "[data-id-product='" + product.idProduct + "'] img:eq(0)"); 99 if (fly_to_card_image_type) { 100 flyer = '#custom_flyer'; 101 //vyrata sa pozicia z kade ma odlietat custom flyer - vycentrovanie do stredu obrazku 102 flyerTopOffset = $(productImage).offset().top + (($(productImage).height() / 2) - ($(flyer).height() / 2)); 103 flyerLeftOffset = $(productImage).offset().left + (($(productImage).width() / 2) - ($(flyer).width() / 2)); 104 } else { 105 flyer = productImage; 106 flyerTopOffset = $(flyer).offset().top; 107 flyerLeftOffset = $(flyer).offset().left; 108 } 109 } 110 111 flyingTo = $(small_cart_path); 112 divider = 3; 113 flyerClone = $(flyer).clone(); 114 flyerClone.addClass('flyerClone'); 115 $(flyerClone).css({width: $(flyer).width(), 'height': 'auto', position: 'absolute', top: flyerTopOffset + "px", left: flyerLeftOffset + "px", opacity: 1, 'z-index': 9999999}); 116 $('body').append($(flyerClone)); 117 flyerWidth = (fly_to_card_image_type ? $(flyer).width() : ($(flyer).width() / divider)); 118 flyerHeight = (fly_to_card_image_type ? $(flyer).height() : ($(flyer).height() / divider)); 119 120 $(flyerClone).animate({ 121 opacity: (fly_to_card_fade_out ? 0.4 : 1), 122 left: ($(flyingTo).offset().left + ($(flyingTo).width() / 2) - (flyerW
122idth / 2)) + 12, 123 top: $(flyingTo).offset().top, 124 width: flyerWidth, 125 height: flyerHeight 126 }, fly_to_card_speed, 127 function () { 128 $(flyerClone).fadeOut('fast', function () { 129 selectAnimationAndEffect(product); 130 }); 131 }); 132} 133 134function scrollToCart() { 135 $('html, body').animate({ 136 'scrollTop' : $(small_cart_path).position().top 137 }); 138} 139 140function shakeWithCart() { 141 $(small_cart_path).effect("shake", { 142 times: shake_counts 143 }, 130); 144} 145 146function addToCardSuccesFixedMessage(product) { 147 if ($('.succesFixedMessageClass').length > 0) { //pokial sa pridava do kosika skor ako je este zobrazena hlaska 148 if (automatically_message_hide) { 149 clearTimeout(succesFixedMessageTimeout); 150 } 151 removeSuccesFixedMessage(true, product); 152 } else { 153 succesFixedMessageDisplay(product); 154 } 155} 156 157function removeSuccesFixedMessage(displayMessageAfterRemove, product) { 158 $(".succesFixedMessageClass").fadeOut(500, function() { 159 $(".succesFixedMessageClass").remove(); 160 if (displayMessageAfterRemove) { 161 succesFixedMessageDisplay(product); 162 } 163 }); 164} 165 166function succesFixedMessageDisplay(product) { 167 messageElement = "<div class='succesFixedMessageClass' style='padding: 3px;display:none'><div class='succesFixedMessageWindowClass alert'><span>" + getMessageText(message_text, product) + "</span><button type='button' class='close' data-dismiss='alert'>×</button></div></div>"; 168 $("body").append(messageElement); 169 $('.succesFixedMessageClass').fadeIn(500); 170 if (message_location == 0) 171 $(".succesFixedMessageClass").css("top","0px"); //pridanie hlasky hore 172 else
173 $(".succesFixedMessageClass").css("bottom","0px"); //pridanie hlasky dole 174 $(".succesFixedMessageWindowClass").css({"background" : background_message_color, "color" : text_message_color, "font-size" : text_message_size}); 175 if (automatically_message_hide) { 176 succesFixedMessageTimeout = setTimeout(function() { 177 removeSuccesFixedMessage(false, product); 178 }, message_hide_time); 179 } 180} 181 182function addToCardSuccesBootstrapAlertMessage(product) { 183 if ($('.succesBootstrapAlertMessage').length > 0) { //pokial sa pridava do kosika skor ako je este zobrazena hlaska 184 if (automatically_message_hide) { 185 clearTimeout(succesBootstrapAlertMessageTimeout); 186 } 187 removeSuccesBootstrapAlertMessage(true, product); 188 } else { 189 succesBootstrapAlertMessageDisplay(product); 190 } 191} 192 193function removeSuccesBootstrapAlertMessage(displayMessageAfterRemove, product) { 194 $(".succesBootstrapAlertMessage").fadeOut(500, function(){ 195 $(".succesBootstrapAlertMessage").remove(); 196 if (displayMessageAfterRemove) { 197 succesBootstrapAlertMessageDisplay(product); 198 } 199 }); 200} 201 202function succesBootstrapAlertMessageDisplay(product) { 203 messageElement = "<div class='succesBootstrapAlertMessage alert' style='display:none'><span>" + getMessageText(message_text, product) + "</span><button type='button' class='close' data-dismiss='alert'>×</button></div>"; 204 $("#wrapper .container").prepend(messageElement); 205 $('.succesBootstrapAlertMessage').fadeIn(500); 206 $(".succesBootstrapAlertMessage").css({"margin-bottom": "18px", "background" : background_message_color, "color" : text_message_color, "font-size" : text_message_size}); 207 if (automatically_message_hide) { 208 succesBootstrapAlertMessageTimeout = setTimeout(function() { 209 removeSuccesBootstrapAlertMessage(false, product); 210 }, message_hide_time); 211 } 212} 213 214function addToCardSuccesPopUpMessage(product) { 215 $("#blockcart-modal .modal-header").hide(); 216 $("#blockcart-modal .modal-body .row").empty(); 217 $("#blockcart-modal .modal-body").css({"background" : background_message_color, "color" : text_message_color, "font-size" : text_message_size}); 218 $("#blockcart-modal .modal-body .row").html(getMessageText(message_text, product)).css("text-align", "center"); 219 if (automatically_message_hide) { 220 setTimeout(function() { 221 $('#blockcart-modal').modal('hide').on('hidden.bs.modal', function (e) { 222 if ($(".modal-backdrop").length > 0) { 223 $(".modal-backdrop").remove(); 224 } 225 }); 226 }, message_hide_time); 227 } 228} 229 230function getMessageText(originalMessageText, product) { 231 originalMessageText = originalMessageText.replace('{NAME}', product.name); 232 originalMessageText = originalMessageText.replace('{LINKED_NAME}', '<a style="color:' + text_message_color + '" href=' + product.link + '>' + product.name + '</a>'); 233 if(product.hasAttributes) 234 originalMessageText = originalMessageText.replace('{ATTRIBUTES}', product.attributes); 235 else 236 originalMessageText = originalMessageText.replace('{ATTRIBUTES}', ''); 237 originalMessageText = originalMessageText.replace('{PRICE}', product.price); 238 originalMessageText = originalMessageText.replace('{QUANTITY}', product.quantity); 239 return originalMessageText; 240} 241 242function selectAnimationAndEffect(product) { 243 if (shake_effect) { 244 shakeWithCart(); 245 } 246 // pri ps17 nepridu v parametry product do tejto fn potrebne veci pre zobrazenie v sprave, preto si musim volat tieto info cez ajax 247 if (type_of_message == 1 || type_of_message == 2 || type_of_message == 3) { 248 data = { 249 'action': 'quickview', 250 'id_product': product.idProduct, 251 'id_product_attribute': product.idProductAttribute 252 }; 253 $.post(prestashop.urls.pages.product, data, null, 'json').then(function(resp) { 254 attributes = []; 255 $.each(resp.product.attributes, function(index, value) { 256 attributes.push(value.name); 257 }); 258 product = {'name' : resp.product.name, 'link' : resp.product.url, 'price' : resp.product.price, 'quantity' : ((product.addedFromProductPage && typeof $("#quantity_wanted").val() != "undefined") ? $("#quantity_wanted").val() : 1), 'hasAttributes' : (attributes.length > 0), 'attributes' : attributes.join(", ")}; 259 if (type_of_message == 1) { 260 addToCardSuccesFixedMessage(product); 261 } else if (type_of_message == 2) { 262 addToCardSuccesBootstrapAlertMessage(product); 263 } else if (type_of_message == 3) { 264 addToCardSuccesPopUpMessage(product); 265 showModalAtc(); 266 } 267 }); 268 } else if (type_of_message == 4) { 269 showModalAtc(); 270 } 271 redirectToOrder(); 272} 273 274function showProgressWheel(callerElement) { 275 if (callerElement.addedFromProductPage) { 276 if (callerElement.isModal) { 277 $(thumbnail_parent_path + "[data-id-product='" + callerElement.idProduct + "'] .add-to-cart[data-link-action='add-to-cart']").css('position', 'relative').append('<span class="preLoading"></span>'); 278 } else { 279 $('#product_page_product_id[value="' + callerElement.idProduct + '"]').parents("#main").find(".add-to-cart[data-button-action='add-to-cart']").css('position', 'relative').append('<span class="preLoading"></span>'); 280 } 281 } else { 282 $(thumbnail_parent_path + "[data-id-product='" + callerElement.idProduct + "'] .add-to-cart[data-button-action='add-to-cart']").css('position', 'relative').append('<span class="preLoading"></span>'); 283 } 284} 285 286function redirectToOrder() { 287 if (redirect_to_order) { 288 setTimeout(function() { 289 isRedirected = window.open(link_to_order, '_blank'); 290 if (!isRedirected || isRedirected.closed || typeof isRedirected.closed == 'undefined') { 291 location.href = link_to_order; 292 } 293 }, (redirect_after * 1000)); 294 } 295} 296 297//fn, ktora zabezpeci ze nativny modal zo spravou o produkte po vlozeni do kosika, bude zobrazeny len vtedy a v takom
297case ako chceme 298//je zobrazovany pri type_of_message = 3 a type_of_message = 4 a az po odleteny obr do kosika 299function showModalAtc() { 300 modalAtc = $('#blockcart-modal'); 301 if (modalAtc.length) { 302 modalAtc.remove(); 303 } 304 if ($(".modal-backdrop").length > 0) { 305 $(".modal-backdrop").remove(); 306 } 307 $("body").removeClass("atc"); 308 modalAtc.modal('show').on('hidden.bs.modal', function (e) { 309 if ($(".modal-backdrop").length > 0) { 310 $(".modal-backdrop").remove(); 311 } 312 }); 313}
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.