1ACC.addtodonationwishlistaction = { 2 3 _autoload : [ 4 [ "bindToAddToDonationWishlistActionButton", $(".add_to_donation_wishlist_form").length != 0 ] ], 5 6 bindToAddToDonationWishlistActionButton : function() { 7 var addToDonationWishlistForm = $('.add_to_donation_wishlist_form'); 8 addToDonationWishlistForm.ajaxForm({ 9 beforeSerialize: ACC.addtodonationwishlistaction.updateQty, 10 beforeSubmit : ACC.addtodonationwishlistaction.showRequest, 11 success : ACC.addtodonationwishlistaction.displayAddToDonationWishlistPopup, 12 error : function() { 13 window.location.reload(); 14 } 15 }); 16 setTimeout(function() { 17 $ajaxCallEvent = true; 18 //check with Uday to look and refactor the use of $ajaxCallEvent in this file 19 }, 2000); 20 }, 21 showRequest : function(arr, $form, options) { 22 if ($ajaxCallEvent) { 23 $ajaxCallEvent = false; 24 return true; 25 } 26 return true; 27 28 }, 29 updateQty: function($form, options) { 30 // read qty and update in Donation wishlist form 31 if($(".js-qty-selector .js-qty-selector-input").length === 1){ 32 $form.find("input[name='qty']").val($(".js-qty-selector .js-qty-selector-input").val()); 33 }else{ 34 var qty = $form.closest(".product-item").find('.add_to_cart_form').find('.sku-quantity').val(); 35 $form.find("input[name='qty']").val(qty > 0 ? qty : 1); 36 } 37 return true; 38 }, 39 displayAddToDonationWishlistPopup : function(donationWishlistResult,statusText, xhr, formElement) { 40 if (donationWishlistResult.addToDonationWishlistLayer === undefined) { 41 window.location.reload(); 42 } else { 43 $ajaxCallEvent = true; 44 $('#addToDonationWishlistLayer').remove(); 45 var titleHeader = $('#addToDonationWishlistTitle').html(); 46 47 ACC.colorbox.open(titleHeader, { 48 html : donationWishlistResult.addToDonationWishlistLayer, 49 width: "660px", 50 onComplete: function(){ 51 $("#addToDonationWishlistLayer img").on('load', function() { 52 $.colorbox.resize(); 53 $(this).off('load'); 54 }); 55 56 // Observed modal for mutations (content from DY) and resize as needed 57 var modalEl = document.getElementById('cboxLoadedContent'); 58 observeDOM(modalEl, function(m){ 59 $(modalEl).addClass('dy-enabled'); 60 setTimeout(function(){ $.colorbox.resize(); }, 500); 61 }); 62 } 63 }); 64 $(".js-mini-cart-close-button").click(function(ev){ 65 ev.preventDefault(); 66 ACC.colorbox.close(); 67 }); 68 } 69 } 70}; 71function getWishlist(wishlist){ 72 $("input[name='wislistId']").val(wishlist); 73} 74 75function submitWishlist(wishlist){ 76 $('div').removeClass('dropdown-item-highlighted'); 77 $("input[name='wislistId']").val(wishlist); 78 var addToDonationWishlistForm=$("#addToDonationWishlistForm"); 79 addToDonationWishlistForm.ajaxForm({ 80 beforeSerialize: ACC.addtodonationwishlistaction.updateQty, 81 beforeSubmit : ACC.addtodonationwishlistaction.showRequest, 82 success : function() { 83 $('.dropdown-item.'+wishlist).addClass('dropdown-item-highlighted'); 84 }, 85 error : function() { 86 window.location.reload(); 87 } 88 }); 89 setTimeout(function() { 90 $ajaxCallEvent = true; 91 }, 2000); 92 $("#addToDonationWishlistForm").submit(); 93} 94 95 96//Mutation Observer to watch for changes in the content from DY 97var observeDOM = (function(){ 98 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; 99 100 return function( obj, callback ){ 101 if( !obj || !obj.nodeType === 1 ) return; // validation 102 103 if( MutationObserver ){ 104 // define a new observer 105 var obs = new MutationObserver(function(mutations, observer){ 106 callback(mutations); 107 }) 108 // have the observer observe foo for changes in children 109 obs.observe( obj, { childList:true, subtree:true }); 110 } 111 else if( window.addEventListener ){ 112 obj.addEventListener('DOMNodeInserted', callback, false); 113 obj.addEventListener('DOMNodeRemoved', callback, false); 114 } 115 } 116})();
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.