1/* 2* 2007-2011 PrestaShop 3* 4* NOTICE OF LICENSE 5* 6* This source file is subject to the Academic Free License (AFL 3.0) 7* that is bundled with this package in the file LICENSE.txt. 8* It is also available through the world-wide-web at this URL: 9* http://opensource.org/licenses/afl-3.0.php 10* If you did not receive a copy of the license and are unable to 11* obtain it through the world-wide-web, please send an email 12* to [email protected] so we can send you a copy immediately. 13* 14* DISCLAIMER 15* 16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 17* versions in the future. If you wish to customize PrestaShop for your 18* needs please refer to http://www.prestashop.com for more information. 19* 20* @author PrestaShop SA <[email protected]> 21* @copyright 2007-2011 PrestaShop SA 22* @version Release: $Revision: 9525 $ 23* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24* International Registered Trademark & Property of PrestaShop SA 25*/ 26 27 28//JS Object : update the cart by ajax actions 29var ajaxCart = { 30 31 //override every button in the page in relation to the cart 32 overrideButtonsInThePage : function(){ 33 //for every 'add' buttons... 34 $('.ajax_add_to_cart_button').unbind('click').click(function(){ 35 var idProduct = $(this).attr('rel').replace('ajax_id_product_', ''); 36 if ($(this).attr('disabled') != 'disabled') 37 ajaxCart.add(idProduct, null, false, this); 38 return false; 39 }); 40 //for product page 'add' button... 41 $('body#product p#add_to_cart input').unbind('click').click(function(){ 42 ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null); 43 return false; 44 }); 45 46 //for 'delete' buttons in the cart block... 47 $('#cart_block_list .ajax_cart_block_remove_link').unbind('click').click(function(){ 48 // Customized product management 49 var customizationId = 0; 50 var productId = 0; 51 var productAttributeId = 0; 52 if ($($(this).parent().parent()).attr('name') == 'customization') 53 // Reverse two levels: a >> div >> li 54 var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]"); 55 else 56 var customizableProductDiv = $($(this).parent()).find("div[id^=deleteCustomizableProduct_]"); 57 if (customizableProductDiv && $(customizableProductDiv).length) 58 { 59 $(customizableProductDiv).each(function(){ 60 var ids = $(this).attr('id').split('_'); 61 if (typeof(ids[1]) != 'undefined') 62 { 63 customizationId = parseInt(ids[1]); 64 productId = parseInt(ids[2]); 65 if (typeof(ids[3]) != 'undefined') 66 productAttributeId = parseInt(ids[3]); 67 return false; 68 } 69 }); 70 } 71 72 // Common product management 73 if (!customizationId) 74 { 75 //retrieve idProduct and idCombination from the displayed product in the block cart 76 var firstCut = $(this).parent().parent().attr('id').replace('cart_block_product_', ''); 77 firstCut = firstCut.replace('deleteCustomizableProduct_', ''); 78 ids = firstCut.split('_'); 79 productId = parseInt(ids[0]); 80 if (typeof(ids[1]) != 'undefined') 81 productAttributeId = parseInt(ids[1]); 82 } 83 84 // Removing product from the cart 85 ajaxCart.remove(productId, productAttributeId, customizationId); 86 return false; 87 }); 88 }, 89 90 // try to expand the cart 91 expand : function(){ 92 $(['left_column', 'right_column']).each(function(id, parentId) 93 { 94 if ($('#'+parentId+' #cart_block #cart_block_list').hasClass('collapsed')) 95 { 96 $('#'+parentId+' #cart_block #cart_block_summary').slideUp(200, function(){ 97 $(this).addClass('collapsed').removeClass('expanded'); 98 $('#'+parentId+' #cart_block #cart_block_list').slideDown({ 99 duration: 600, 100 complete: function(){$(this).addClass('expanded').removeClass('collapsed');} 101 }); 102 }); 103 // toogle the button expand/collapse button 104 $('#'+parentId+' #cart_block h4 span#block_cart_expand').fadeOut('slow', function(){ 105 $('#'+parentId+' #cart_block h4 span#block_cart_collapse').fadeIn('fast'); 106 }); 107 108 // save the expand statut in the user cookie 109 $.ajax({ 110 type: 'GET', 111 url: baseDir + 'modules/blockcart/blockcart-set-collapse.php', 112 async: true, 113 data: 'ajax_blockcart_display=expand' + '&rand=' + new Date().getTime() 114 }); 115 } 116 }); 117 }, 118 // cart to fix display when using back and previous browsers buttons 119 refresh : function(){
120 //send the ajax request to the server 121 $.ajax({ 122 type: 'GET', 123 url: baseDir + 'cart.php', 124 async: true, 125 cache: false, 126 dataType : "json", 127 data: 'ajax=true&token=' + static_token, 128 success: function(jsonData) 129 { 130 ajaxCart.updateCart(jsonData); 131 }, 132 error: function(XMLHttpRequest, textStatus, errorThrown) { 133 //alert("TECHNICAL ERROR: unable to refresh the cart.\n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); 134 } 135 }); 136 }, 137 138 // try to collapse the cart 139 collapse : function(){ 140return; 141 142 if ($('#cart_block #cart_block_list').hasClass('expanded')) 143 { 144 $('#cart_block #cart_block_list').slideUp('slow', function(){ 145 $(this).addClass('collapsed').removeClass('expanded'); 146 $('#cart_block #cart_block_summary').slideDown(700, function(){ 147 $(this).addClass('expanded').removeClass('collapsed'); 148 }); 149 }); 150 $('#cart_block h4 span#block_cart_collapse').fadeOut('slow', function(){ 151 $('#cart_block h4 span#block_cart_expand').fadeIn('fast'); 152 }); 153 154 // save the expand statut in the user cookie 155 $.ajax({ 156 type: 'GET', 157 url: baseDir + 'modules/blockcart/blockcart-set-collapse.php', 158 async: true, 159 data: 'ajax_blockcart_display=collapse' + '&rand=' + new Date().getTime() 160 }); 161 } 162 }, 163 164 // Update the cart information 165 updateCartInformation : function (jsonData, addedFromProductPage) 166 { 167 ajaxCart.updateCart(jsonData); 168 169 //reactive the button when adding has finished 170 if (addedFromProductPage) 171 $('body#product p#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled'); 172 else 173 $('.ajax_add_to_cart_button').removeAttr('disabled'); 174 }, 175 176 // add a product in the cart via ajax 177 add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist){ 178 if (addedFromProductPage && !checkCustomizations()) 179 { 180 alert(fieldRequired); 181 return ; 182 } 183 emptyCustomizations(); 184 //disabled the button when adding to do not double add if user double click 185 if (addedFromProductPage) 186 { 187 $('body#product p#add_to_cart input').attr('disabled', 'disabled').removeClass('exclusive').addClass('exclusive_disabled'); 188 $('.filled').removeClass('filled'); 189 } 190 else 191 $(callerElement).attr('disabled', 'disabled'); 192 193 if ($('#cart_block #cart_block_list').hasClass('collapsed')) 194 this.expand(); 195 //send the ajax request to the server 196 $.ajax({ 197 type: 'POST', 198 url: baseDir + 'cart.php', 199 async: true, 200 cache: false, 201 dataType : "json", 202 data: 'add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''), 203 success: function(jsonData,textStatus,jqXHR) 204 { 205 // add appliance to whishlist module 206 if (whishlist && !jsonData.errors) 207 WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]); 208 209 // add the picture to the cart 210 var $element = $(callerElement).parent().parent().find('a.product_image img,a.product_img_link img'); 211 if (!$element.length) 212 $element = $('#bigpic'); 213 var $picture = $element.clone(); 214 var pictureOffsetOriginal = $element.offset(); 215 216 if ($picture.size()) 217 $picture.css({'position': 'absolute', 'top': pictureOffsetOriginal.top, 'left': pictureOffsetOriginal.left}); 218 219 var pictureOffset = $picture.offset(); 220 var cartBlockOffset = $('#cart_block').offset(); 221 222 // Check if the block cart is activated for the animation 223 if (cartBlockOffset != undefined && $picture.size()) 224 { 225 $picture.appendTo('body'); 226 $picture.css({ 'position': 'absolute', 'top': $picture.css('top'), 'left': $picture.css('left') }) 227 .animate({ 'width': $element.attr('width')*0.66, 'height': $element.attr('height')*0.66, 'opacity': 0.2, 'top': cartBlockOffset.top + 30, 'left': cartBlockOffset.left + 15 }, 1000) 228 .fadeOut(100, function() { 229 ajaxCart.updateCartInformation(jsonData, addedFromProductPage); 230 }); 231 } 232 else 233 ajaxCart.updateCartInformation(jsonData, addedFromProductPage); 234 }, 235 error: function(XMLHttpRequest, textStatus, errorThrown) 236 { 237 alert("TECHNICAL ERROR: unable to add the product.\n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); 238 //reactive the button when adding has finished 239 if (addedFromProductPage) 240 $('body#product p#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled'); 241 else 242 $(callerElement).removeAttr('disabled'); 243 } 244 }); 245 }, 246 247 //remove a product from the cart via ajax 248 remove : function(idProduct, idCombination, customizationId){
249 //send the ajax request to the server 250 $.ajax({ 251 type: 'POST', 252 url: baseDir + 'cart.php', 253 async: true, 254 cache: false, 255 dataType : "json", 256 data: 'delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&token=' + static_token + '&ajax=true', 257 success: function(jsonData) { 258 ajaxCart.updateCart(jsonData); 259 if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc') 260 deletProductFromSummary(idProduct+'_'+idCombination); 261 }, 262 error: function() {alert('ERROR: unable to delete the product');} 263 }); 264 }, 265 266 //hide the products displayed in the page but no more in the json data 267 hideOldProducts : function(jsonData) { 268 $(['left_column', 'right_column']).each(function(id, parentId) 269 { 270 //delete an eventually removed product of the displayed cart (only if cart is not empty!) 271 if($('#cart_block #cart_block_list dl.products').length > 0) 272 { 273 var removedProductId = null; 274 var removedProductData = null; 275 var removedProductDomId = null; 276 //look for a product to delete... 277 $('#'+parentId+' #cart_block_list dl.products dt').each(function() 278 { 279 //retrieve idProduct and idCombination from the displayed product in the block cart 280 var domIdProduct = $(this).attr('id'); 281 var firstCut = domIdProduct.replace('cart_block_product_', ''); 282 var ids = firstCut.split('_'); 283 284 //try to know if the current product is still in the new list 285 var stayInTheCart = false; 286 for (aProduct in jsonData.products) 287 { 288 //we've called the variable aProduct because IE6 bug if this variable is called product 289 //if product has attributes 290 if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1])) 291 { 292 stayInTheCart = true; 293 // update the product customization display (when the product is still in the cart) 294 ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], domIdProduct); 295 } 296 } 297 //remove product if it's no more in the cart 298 if(!stayInTheCart) 299 { 300 removedProductId = $(this).attr('id'); 301 //return false; // Regarding that the customer can only remove products one by one, we break the loop 302 } 303 304 //if there is a removed product, delete it from the displayed block cart 305 if (removedProductId != null) 306 { 307 var firstCut = removedProductId.replace('cart_block_product_', ''); 308 var ids = firstCut.split('_'); 309 310 $('#'+parentId+' #'+removedProductId).addClass('strike').fadeTo('slow', 0, function(){ 311 $(this).slideUp('slow', function(){ 312 $(this).remove(); 313 //if the cart is now empty, show the 'no product in the cart' message 314 if($('#'+parentId+' #cart_block dl.products dt').length == 0) 315 { 316 $('#'+parentId+' p#cart_block_no_products').slideDown('fast'); 317 $('#'+parentId+' div#cart_block dl.products').remove(); 318 } 319 }); 320 }); 321 $('#'+parentId+' dd#cart_block_combination_of_' + ids[0] + (ids[1] ? '_'+ids[1] : '') ).fadeTo('fast', 0, function(){ 322 $(this).slideUp('fast', function(){ 323 $(this).remove(); 324 }); 325 }); 326 } 327 }); 328 } 329 }); 330 }, 331 332 hideOldProductCustomizations : function (product, domIdProduct) 333 { 334 $(['left_column', 'right_column']).each(function(id, parentId) 335 { 336 var customizationList = $('#'+parentId+' #cart_block #cart_block_list ul#customization_' + product['id'] + '_' + product['idCombination']); 337 if(customizationList.length > 0) 338 { 339 $(customizationList).find("li").each(function(){ 340 $(this).find("div").each(function() { 341 var customizationDiv = $(this).attr('id'); 342 var tmp = customizationDiv.replace('deleteCustomizableProduct_', ''); 343 var ids = tmp.split('_'); 344 if ((parseInt(product.idCombination) == parseInt(ids[2])) && !ajaxCart.doesCustomizationStillExist(product, ids[0])) 345 $('#' + customizationDiv).parent().addClass('strike').fadeTo('slow', 0, function(){ 346 $(this).slideUp('slow'); 347 $(this).remove(); 348 }); 349 }); 350 }); 351 } 352 var removeLinks = $('#'+parentId+' #cart_block_product_' + domIdProduct).find('a.ajax_cart_block_remove_link'); 353 if (!product.hasCustomizedDatas && !removeLinks.length) 354 $('#'+parentId+' #' + domIdProduct + ' span.remove_link').html('<a class="ajax_cart_block_remove_link" rel="nofollow" href="' + baseDir + 'cart.php?delete&id_product=' + product['id'] + '&ipa=' + product['idCombination'] + '&
354token=' + static_token + '" title="' + removingLinkText + '"> </a>'); 355 }); 356 }, 357 358 doesCustomizationStillExist : function (product, customizationId) 359 { 360 var exists = false; 361 362 $(product.customizedDatas).each(function() { 363 if (this.customizationId == customizationId) 364 { 365 exists = true; 366 // This return does not mean that we found nothing but simply break the loop 367 return false; 368 } 369 }); 370 return (exists); 371 }, 372 373 //refresh display of vouchers (needed for vouchers in % of the total) 374 refreshVouchers : function (jsonData) { 375 if (jsonData.discounts.length == 0) 376 $('#vouchers').remove(); 377 else 378 { 379 $('.bloc_cart_voucher').each(function(){ 380 var idElmt = $(this).attr('id').replace('bloc_cart_voucher_',''); 381 var toDelete = true; 382 for (i=0;i<jsonData.discounts.length;i++) 383 { 384 if (jsonData.discounts[i].id == idElmt) 385 { 386 $('#bloc_cart_voucher_' + idElmt + ' td.price').text(jsonData.discounts[i].price); 387 toDelete = false; 388 } 389 } 390 if (toDelete) 391 { 392 $('#bloc_cart_voucher_' + idElmt).fadeTo('fast', 0, function(){ 393 $(this).remove(); 394 }); 395 } 396 }); 397 } 398 399 400 }, 401 402 // Update product quantity 403 updateProductQuantity : function (product, quantity) { 404 $(['left_column', 'right_column']).each(function(id, parentId) 405 { 406 $('#'+parentId+' dt#cart_block_product_' + product.id + (product.idCombination ? '_' + product.idCombination : '') + ' .quantity').fadeTo('fast', 0, function() { 407 $(this).text(quantity); 408 $(this).fadeTo('fast', 1, function(){ 409 $(this).fadeTo('fast', 0, function(){ 410 $(this).fadeTo('fast', 1, function(){ 411 $(this).fadeTo('fast', 0, function(){ 412 $(this).fadeTo('fast', 1); 413 }); 414 }); 415 }); 416 }); 417 }); 418 }); 419 }, 420 421 422 //display the products witch are in json data but not already displayed 423 displayNewProducts : function(jsonData) { 424 $(['left_column', 'right_column']).each(function(id, parentId) 425 { 426 //add every new products or update displaying of every updated products 427 $(jsonData.products).each(function(){ 428 //fix ie6 bug (one more item 'undefined' in IE6) 429 if (this.id != undefined) 430 { 431 //create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty) 432 if ($('#'+parentId+' div#cart_block dl.products').length == 0) 433 $('#'+parentId+' p#cart_block_no_products').fadeTo('fast', 0, function(){ 434 $(this).slideUp('fast').fadeTo(0, 1); 435 }).before('<dl class="products"></dl>'); 436 437 //if product is not in the displayed cart, add a new product's line 438 var domIdProduct = this.id + (this.idCombination ? '_' + this.idCombination : ''); 439 var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0'); 440 if($('#'+parentId+' #cart_block dt#cart_block_product_'+ domIdProduct ).length == 0) 441 { 442 var productId = parseInt(this.id); 443 var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0); 444 var content = '<dt class="hidden" id="cart_block_product_' + domIdProduct + '">'; 445 content += '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>x</span>'; 446 var name = (this.name.length > 12 ? this.name.substring(0, 10) + '...' : this.name); 447 content += '<a href="' + this.link + '" title="' + this.name + '">' + name + '</a>'; 448 content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseDir + 'cart.php?delete&id_product=' + productId + '&
448token=' + static_token + (this.hasAttributes ? '&ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>'; 449 content += '<span class="price">' + this.priceByLine + '</span>'; 450 content += '</dt>'; 451 if (this.hasAttributes) 452 content += '<dd id="cart_block_combination_of_' + domIdProduct + '" class="hidden"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a>'; 453 if (this.hasCustomizedDatas) 454 content += ajaxCart.displayNewCustomizedDatas(this); 455 if (this.hasAttributes) content += '</dd>'; 456 $('#'+parentId+' #cart_block dl.products').append(content); 457 } 458 //else update the product's line 459 else{ 460 var jsonProduct = this; 461 if($('#'+parentId+' dt#cart_block_product_' + domIdProduct + ' .quantity').text() != jsonProduct.quantity || $('dt#cart_block_product_' + domIdProduct + ' .price').text() != jsonProduct.priceByLine) 462 { 463 // Usual product 464 $('#'+parentId+' dt#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine); 465 ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.quantity); 466 467 // Customized product 468 if (jsonProduct.hasCustomizedDatas) 469 { 470 customizationFormatedDatas = ajaxCart.displayNewCustomizedDatas(jsonProduct); 471 if (!$('#'+parentId+' #cart_block ul#customization_' + domIdProductAttribute).length) 472 { 473 if (jsonProduct.hasAttributes) 474 $('#'+parentId+' #cart_block dd#cart_block_combination_of_' + domIdProduct).append(customizationFormatedDatas); 475 else 476 $('#'+parentId+' #cart_block dl.products').append(customizationFormatedDatas); 477 } 478 else 479 $('#'+parentId+' #cart_block ul#customization_' + domIdProductAttribute).append(customizationFormatedDatas); 480 } 481 } 482 } 483 $('#'+parentId+' #cart_block dl.products .hidden').slideDown('slow').removeClass('hidden'); 484 485 var removeLinks = $('#'+parentId+' #cart_block_product_' + domIdProduct).find('a.ajax_cart_block_remove_link'); 486 if (this.hasCustomizedDatas && removeLinks.length) 487 $(removeLinks).each(function() { 488 $(this).remove(); 489 }); 490 } 491 }); 492 }); 493 }, 494 495 displayNewCustomizedDatas : function(product) 496 { 497 $(['left_column', 'right_column']).each(function(id, parentId) 498 { 499 var content = ''; 500 var productId = parseInt(product.id); 501 var productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination); 502 var hasAlreadyCustomizations = $('#'+parentId+' #cart_block ul#customization_' + productId + '_' + productAttributeId).length; 503 504 if (!hasAlreadyCustomizations) 505 { 506 if (!product.hasAttributes) content += '<dd id="cart_block_combination_of_' + productId + '" class="hidden">'; 507 content += '<ul class="cart_block_customizations" id="customization_' + productId + '_' + productAttributeId + '">'; 508 } 509 510 $(product.customizedDatas).each(function(){ 511 var done = 0; 512 customizationId = parseInt(this.customizationId); 513 productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination); 514 // If the customization is already displayed on the cart, no update's needed 515 if($('#'+parentId+' #cart_block').find("div[id^=deleteCustomizableProduct_" + customizationId + "_]").length) 516 return (''); 517 content += '<li name="customization"><div class="deleteCustomizableProduct" id="deleteCustomizableProduct_' + customizationId + '_' + productId + '_' + (productAttributeId ? productAttributeId : '0') + '"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseDir + 'cart.php?delete&id_product=' + productId + '&ipa=' + productAttributeId + '&id_customization=' + customizationId + '&
517token=' + static_token + '"> </a></div><span class="quantity-formated"><span class="quantity">' + parseInt(this.quantity) + '</span>x</span>'; 518 519 // Give to the customized product the first textfield value as name 520 $(this.datas).each(function(){ 521 if (this['type'] == CUSTOMIZE_TEXTFIELD) 522 { 523 $(this.datas).each(function(){ 524 if (this['index'] == 0) 525 { 526 content += this.truncatedValue.replace(/<br \/>/g, ' '); 527 done = 1; 528 return false; 529 } 530 }) 531 } 532 }); 533 534 // If the customized product did not have any textfield, it will have the customizationId as name 535 if (!done) 536 content += customizationIdMessage + customizationId; 537 if (!hasAlreadyCustomizations) content += '</li>'; 538 // Field cleaning 539 if (customizationId) 540 { 541 $('#'+parentId+' #uploadable_files li div.customizationUploadBrowse img').remove(); 542 $('#'+parentId+' #text_fields li input').attr('value', ''); 543 } 544 }); 545 546 if (!hasAlreadyCustomizations) 547 { 548 content += '</ul>'; 549 if (!product.hasAttributes) content += '</dd>'; 550 } 551 return (content); 552 }); 553 }, 554 555 556 //genarally update the display of the cart 557 updateCart : function(jsonData) { 558 //user errors display 559 if (jsonData.hasError) 560 { 561 var errors = ''; 562 for(error in jsonData.errors) 563 //IE6 bug fix 564 if(error != 'indexOf') 565 errors += jsonData.errors[error] + "\n"; 566 alert(errors); 567 } 568 else 569 { 570 ajaxCart.updateCartEverywhere(jsonData); 571 ajaxCart.hideOldProducts(jsonData); 572 ajaxCart.displayNewProducts(jsonData); 573 ajaxCart.refreshVouchers(jsonData); 574 575 //update 'first' and 'last' item classes 576 $(['left_column', 'right_column']).each(function(id, parentId) 577 { 578 $('#'+parentId+' #cart_block dl.products dt').removeClass('first_item').removeClass('last_item').removeClass('item'); 579 $('#'+parentId+' #cart_block dl.products dt:first').addClass('first_item'); 580 $('#'+parentId+' #cart_block dl.products dt:not(:first,:last)').addClass('item'); 581 $('#'+parentId+' #cart_block dl.products dt:last').addClass('last_item'); 582 }); 583 584 //reset the onlick events in relation to the cart block (it allow to bind the onclick event to the new 'delete' buttons added) 585 ajaxCart.overrideButtonsInThePage(); 586 } 587 }, 588 589 //update general cart informations everywhere in the page 590 updateCartEverywhere : function(jsonData) { 591 $('.ajax_cart_total').text(jsonData.productTotal); 592 $('.ajax_cart_shipping_cost').text(jsonData.shippingCost); 593 $('.ajax_cart_tax_cost').text(jsonData.taxCost); 594 $('.cart_block_wrapping_cost').text(jsonData.wrappingCost); 595 $('.ajax_block_cart_total').text(jsonData.total); 596 if(parseInt(jsonData.nbTotalProducts) > 0) 597 { 598 $('.ajax_cart_no_product').hide(); 599 $('.ajax_cart_quantity').text(jsonData.nbTotalProducts); 600 $('.ajax_cart_quantity').fadeIn('slow'); 601 $('.ajax_cart_total').fadeIn('slow'); 602 603 if(parseInt(jsonData.nbTotalProducts) > 1) 604 { 605 $('.ajax_cart_product_txt').each( function () { 606 $(this).hide (); 607 }); 608 609 $('.ajax_cart_product_txt_s').each( function () { 610 $(this).show(); 611 }); 612 613 } 614 else 615 { 616 $('.ajax_cart_product_txt').each( function () { 617 $(this).show(); 618 }); 619 620 $('.ajax_cart_product_txt_s').each( function () { 621 $(this).hide(); 622 }); 623 } 624 } 625 else 626 { 627 $('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each( function () { 628 $(this).hide(); 629 }); 630 $('.ajax_cart_no_product').show('slow'); 631 } 632 } 633}; 634 635//when document is loaded... 636$(document).ready(function(){ 637 638 // expand/collapse management 639 $('#block_cart_collapse').click(function(){ 640 ajaxCart.collapse(); 641 }); 642 $('#block_cart_expand').click(function(){ 643 ajaxCart.expand(); 644 }); 645 ajaxCart.overrideButtonsInThePage(); 646 ajaxCart.refresh(); 647}); 648
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.