1/* RocketWishlist JS Files */ 2 3/** 4 * Display wishlists dropdown. 5 */ 6$(document).on('click', '.js-rocketwishlist-show-wishlist-dropdown', function(e) { 7 e.preventDefault(); 8 9 $(this).popover('hide'); 10 if ($(this).hasClass('js-rocketwishlist-dropdown-wishlist-active')) { 11 return; 12 } 13 14 $(this).addClass('js-rocketwishlist-dropdown-wishlist-active'); 15 $.ajax({ 16 type: 'POST', 17 url: wishlistAjaxCtrl, 18 data: { 19 id_customer: prestashop.customer.id, 20 id_product: $(this).data('id_product'), 21 id_product_attribute: $(this).data('id_product_attribute'), 22 action: $(this).data('action') 23 }, 24 dataType: 'json', 25 }) 26 .done(function(resp) { 27 $('.js-rocketwishlist-dropdown-wishlist > div').hide().html(resp.dropdown).fadeIn(); 28 }); 29}); 30 31/** 32 * Add product into a list. 33 */ 34$(document).on('click', '.js-rocketwishlist-add-to-wishlist', function(e) { 35 e.preventDefault(); 36 37 var fromDropDownList = false; 38 $(this).attr('disabled', true).addClass('js-activebtnfav'); 39 if (typeof $(this).data('fromdd') !== "undefined") { 40 fromDropDownList = true; 41 } 42 43 var data = { 44 action: $(this).data('action'), 45 id_product: $(this).data('id_product'), 46 id_product_attribute: $(this).data('id_product_attribute'), 47 id_wishlist: $(this).data('id_wishlist'), 48 cancel: $(this).data('cancel'), 49 fromDd: fromDropDownList 50 } 51 52 cancel = false; 53 if (typeof data.cancel !== "undefined") { 54 cancel = true; 55 } 56 57 addToWishlist(data, cancel); 58}); 59 60/** 61 * Remove product from a list. 62 */ 63$(document).on('click', '.js-rocketwishlist-remove-product', function (e) { 64 e.preventDefault(); 65 66 var selector = $(this).data('id_product') + '-' + $(this).data('id_product_attribute'); 67 $.ajax({ 68 type: 'POST', 69 url: wishlistAjaxCtrl, 70 data: { 71 action: $(this).data('action'), 72 id_product: $(this).data('id_product'), 73 id_product_attribute: $(this).data('id_product_attribute'), 74 id_wishlist: $(this).data('id_wishlist'), 75 }, 76 dataType: 'json' 77 }) 78 .done(function(resp) { 79 var product_line = $('.js-line-id-' + selector).clone().removeClass('js-line-id-' + selector).addClass('js-line-id-' + selector + '-duplicate').addClass('u-d-none'); 80 $('.js-line-id-' + selector).before(product_line); 81 $('.js-line-id-' + selector).html(resp.confirmation); 82 }); 83}); 84 85function addToWishlist(data, cancel = false) 86{ 87 $.ajax({ 88 type: 'POST', 89 url: wishlistAjaxCtrl, 90 data: data, 91 dataType: 'json' 92 }) 93 .done(function(resp) { 94 if (cancel) { 95 var selector = data.id_product + '-' + data.id_product_attribute; 96 if (data.id_product_attribute === '') { 97 selector = data.id_product + '-0'; 98 } 99 var product_line = $('.js-line-id-' + selector + '-duplicate').html(); 100 $('.js-line-id-' + selector + '-duplicate').remove(); 101 $('.js-line-id-' + selector).html(product_line); 102 } else { 103 showConf(resp, data.fromDd); 104 } 105 }) 106 .always(function(resp) { 107 $('.js-activebtnfav').removeAttr('disabled').removeClass('js-activebtnfav'); 108 $('.js-activebtnfav').removeAttr('disabled'); 109 }); 110} 111 112function showConf(resp, fromDd) 113{ 114 if (rw_popover) { 115 // $('.js-rocketwishlist-show-wishlist-dropdown').popover('hide'); 116 $('.popover').popover('dispose'); 117 118 var selector = '.js-activebtnfav'; 119 if (fromDd) { 120 var selector = '.js-rocketwishlist-dropdown-wishlist .js-rocketwishlist-dropdown-wishlist-active'; 121 } 122 123 $(selector).popover({ 124 title: resp.title, 125 content: resp.confirmation, 126 html: true, 127 placement: 'top' 128 }).popover('show'); 129 } else { 130 $('.modal').modal('hide'); 131 $('#rocketwishlist-modal').html(resp.confirmation).modal('show'); 132 } 133} 134 135/** 136 * Move product between two list. 137 */ 138$(document).on('click', '.js-rocketwishlist-move-product', function (e) { 139 e.preventDefault(); 140 141 var selector = $(this).data('id_product') + '-' + $(this).data('id_product_attribute'); 142 $.ajax({ 143 type: 'POST', 144 url: wishlistAjaxCtrl, 145 data: { 146 action: $(this).data('action'), 147 old_id_wishlist: $(this).data('old_id_wishlist'), 148 new_id_wishlist: $(this).data('new_id_wishlist'), 149 id_product: $(this).data('id_product'), 150 id_product_attribute: $(this).data('id_product_attribute'), 151 }, 152 dataType: 'json' 153 }) 154 .done(function(resp) {
155 $('.js-line-id-' + selector).html(resp.confirmation) 156 }); 157}); 158 159/** 160 * Display form to create new wishlist. 161 */ 162$(document).on('click', '.js-rocketwishlist-display-modal-add-wishlist', function (e) { 163 e.preventDefault(); 164 165 $.ajax({ 166 type: 'POST', 167 url: wishlistAjaxCtrl, 168 data: { 169 action: $(this).data('action'), 170 }, 171 dataType: 'json' 172 }) 173 .done(function(resp) { 174 $('.modal').modal('hide'); 175 $('#rocketwishlist-modal').html(resp.form).modal('show'); 176 }); 177}); 178 179/** 180 * Create new wishlist. 181 */ 182$(document).on('click', '.js-rocketwishlist-add-wishlist', function (e) { 183 e.preventDefault(); 184 185 $.ajax({ 186 type: 'POST', 187 url: wishlistAjaxCtrl, 188 data: { 189 action: $(this).data('action'), 190 name: $('[name="wishlist_name"]').val(), 191 private: $('[name="wishlist_private"]').is(':checked'), 192 default: $('[name="wishlist_default"]').is(':checked'), 193 }, 194 dataType: 'json' 195 }) 196 .done(function(resp) { 197 window.location = resp.linkNewList; 198 }); 199}); 200 201/** 202 * Delete wishlist. 203 */ 204$(document).on('click', '.js-rocketwishlist-delete-wishlist', function (e) { 205 e.preventDefault(); 206 207 $.ajax({ 208 type: 'POST', 209 url: wishlistAjaxCtrl, 210 data: { 211 action: $(this).data('action'), 212 id_wishlist: $(this).data('id_wishlist'), 213 }, 214 dataType: 'json' 215 }) 216 .done(function(resp) { 217 window.location = resp.linkWishlists; 218 }); 219}); 220 221/** 222 * Display form to update wishlist. 223 */ 224$(document).on('click', '.js-rocketwishlist-display-modal-update-wishlist', function (e) { 225 e.preventDefault(); 226 227 $.ajax({ 228 type: 'POST', 229 url: wishlistAjaxCtrl, 230 data: { 231 action: $(this).data('action'), 232 id_wishlist: $(this).data('id_wishlist'), 233 }, 234 dataType: 'json' 235 }) 236 .done(function(resp) { 237 $('.modal').modal('hide'); 238 $('#rocketwishlist-modal').html(resp.form).modal('show'); 239 }); 240}); 241 242/** 243 * Update wishlist. 244 */ 245$(document).on('click', '.js-rocketwishlist-update-wishlist', function (e) { 246 e.preventDefault(); 247 248 $.ajax({ 249 type: 'POST', 250 url: wishlistAjaxCtrl, 251 data: { 252 action: $(this).data('action'), 253 id_wishlist: $('[name="id_wishlist"]').val(), 254 name: $('[name="wishlist_name"]').val(), 255 private: $('[name="wishlist_private"]').is(':checked'), 256 default: $('[name="wishlist_default"]').is(':checked'), 257 }, 258 dataType: 'json' 259 }) 260 .done(function(resp) { 261 window.location = resp.linkReload; 262 }); 263}); 264 265/** 266 * Add all products to cart 267 */ 268$(document).on('click', '.js-rocketwishlist-add-all-products-to-cart', function (e) { 269 e.preventDefault(); 270 271 var products = $('input[name="products_to_add[]"]').map(function() { 272 return $(this).val(); 273 }).get(); 274 275 $.ajax({ 276 type: 'POST', 277 url: wishlistAjaxCtrl, 278 data: { 279 action: $(this).data('action'), 280 products: products, 281 }, 282 dataType: 'json', 283 }) 284 .done(function(resp) { 285 $('.modal').modal('hide'); 286 $('#rocketwishlist-modal').html(resp.confirmation).modal('show'); 287 }); 288}); 289 290/** 291 * Display share wishlist 292 */ 293$(document).on('click', '.js-rocketwishlist-display-share-wishlist', function (e) { 294 e.preventDefault(); 295 296 $.ajax({ 297 type: 'POST', 298 url: wishlistAjaxCtrl, 299 data: { 300 action: $(this).data('action'), 301 id_wishlist: $(this).data('id_wishlist'), 302 }, 303 dataType: 'json', 304 }) 305 .done(function(resp) { 306 $('.modal').modal('hide'); 307 $('#rocketwishlist-modal').html(resp.form).modal('show'); 308 }); 309}); 310 311// Hide add to wishlist popover 312$(window).click(function() { 313 $('.popover').click(function(event){ 314 event.stopPropagation(); 315 }); 316 $('.popover.fade.bs-popover-top.show').hide(); 317}); 318 319//Add to wishlist button 320$(document).on('ready', () => { 321 addToWishlistBtn(); 322}); 323 324prestashop.on('updateProductList', () => { 325 addToWishlistBtn(); 326}); 327 328function addToWishlistBtn() { 329 $('[data-action="add_to_wishlist"]').on('click', (e) => { 330 let target = $(e.target).closest('.js-rocketwishlist-add-to-wis
330hlist'); 331 target.find('.js-rocketwishlist-add-icon').addClass('u-d-none'); 332 target.find('.js-rocketwishlist-added-icon').removeClass('u-d-none'); 333 }); 334};
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.