PageSourceSearch

https://www.videotoybox.com/store/controls/Wishlist.js

js videotoybox.com collected 2026-10-06 16:22:15 UTC 10,751 bytes, 230 lines download raw bytes

1window.ac_wishlist = {
2
3    popovers: new Array(),
4
5    displayWishListPopOver: function (e, itemID, customerID, isCartItem = true, allowSaveForLater = true, isSmallCartWidget = false) {
6        var wishListTitle = $('#hdWishlistTitleLabel').val();
7        if ((!customerID || customerID == 0) && !allowSaveForLater) {
8            var title = "Must be logged in <a class='close'>&times;</a>";
9            var content = '<a href="/store/Login.aspx?progress=false&r=' + location.href + '">Please login/register to use ' + wishListTitle + '</a>';
10            ac_wishlist.setPopoverData(e, title, content, isSmallCartWidget);
11        }
12        else {
13            jQuery.ajax({
14                type: "POST",
15                contentType: "application/json; charset=utf-8",
16                url: "/Store/Controls/ScriptService.asmx/GetWishLists",
17                dataType: "json"
18            }).done(function (result) {
19                var content = "";
20                if (result.d[0].Success) {
21                    content = "<div class='wishlistPopover'>";
22                    if (isSmallCartWidget) {
23                        content = "<div class='wishlistPopover stick-smallcartWidget'>"; // a marker to stop close small cart widget
24                    }
25                   
26                    if (allowSaveForLater) {
27                        if (isCartItem)
28                            content += "<a href='' class='MoveToNewWishListLink popover-content' onClick='window.ac_wishlist.saveForLater(" + itemID + ", " + isCartItem + "); return false;'> Default</a></br></br>";
29                        else
30                            content += "<a href='' class='AddToWishListLink popover-content' onclick='window.ac_wishlist.addToWishList(0); return false;'>Default</a></br></br>";
31                    }
32
33                    for (var i = 0; i < result.d.length; i++) {
34                        if (result.d[i].CartInfoID != 0) {
35                            if (isCartItem)
36                                content += "<a href='' class='MoveToWishListLink popover-content' onclick='window.ac_wishlist.moveToWishList(" + itemID + ", " + result.d[i].CartInfoID + "); return false;'>" + result.d[i].CartName + "</a></br></br>";
37                            else
38                                content += "<a href='' class='AddToWishListLink popover-content' onclick='window.ac_wishlist.addToWishList(" + result.d[i].CartInfoID + "); return false;'>" + result.d[i].CartName + "</a></br></br>";
39                        }
40                    }
41                    content += '<a href="" class="MoveToNewWishListLink popover-content" onClick="window.ac_wishlist.displayNewWishListPopOver(' + "'" + e.id + "', " + itemID + ", " + isCartItem + "," + isSmallCartWidget + '); return false;"> [Create New ' + wishListTitle + ']</a></br>';
42                    content += "</div>";
43                }
44                else {
45                    // If we get here, it probably means the user's session was timed out, but they haven't refreshed their page.
46                    // In that case, we will try to automatically put item in save for later list (how it normally works when logged out)
47                    if (allowSaveForLater) {
48                        if (isCartItem) {
49                            ac_wishlist.moveToWishList(itemID, 0, true);
50                        }
51                        else {
52                            ac_wishlist.addToWishList(0);
53                        }
54                    }
55                    else {
56                        // We are in the save for later cart area. Just display a request to login link
57                        var title = "Must be logged in <a class='close'>&times;</a>";
58                        var content = '<a href="/store/Login.aspx?progress=false&r=' + location.href + '">Please login to move this item' + wishListTitle + '</a>';
59                        ac_wishlist.setPopoverData(e, title, content, isSmallCartWidget);
60                        return;
61                    }
62                }
63
64                var moveToWishlistText = $('#hdMoveToWishlistLabel').val();
65                var title = moveToWishlistText + " <a class='close'>&times;</a>";
66                ac_wishlist.setPopoverData(e, title, content, isSmallCartWidget);
67            });
68        }
69        return false;
70    },
71
72    moveToWishList: function (cartItemID, cartInfoID, redirectToWishLists = false) {
73        var data = JSON.stringify({ cartItemID: cartItemID, cartInfoID: cartInfoID });
74        jQuery.ajax({
75            type: "POST",
76            contentType: "application/json; charset=utf-8",
77            url: "/Store/Controls/ScriptService.asmx/MoveToWishList",
78            dataType: "json",
79            data: data
80        }).done(function (result) {
81          if (result.d.Success) {
82            // Would love to remove the item from asp listview without having to reload or cause a submit.
83            // Or even just hide it via javaScript, however it proved quite difficult. So we are just reloading the page to
84            // rebind the SaveForLater list
85            if (redirectToWishLists) {
86              window.location.replace("/store/wishlist.aspx");
87            }
88            else {
89              window.location.reload();
90            }
91          }
92          else {
93            alert(result.d.Message);
94          }
95        });
96    },
97
98    addToWishList: function (cartInfoID) {
99        $('#hfWishListID').val(cartInfoID);
100        $('#hbtnAddToWishlist').click();
101    },
102
103    displayNewWishListPopOver: function (e, cartItemID, isCartItem = true, isSmallCartWidget = false) {
104        // debugger;
105        window.event.stopPropagation(); // to stop smallcart overlay close on click
106        // Hide any existing bootstrap 5 popovers
107        ac_wishlist.popovers.forEach(x => x.dispose());
108        ac_wishlist.popovers = [];
109
110        var wishListTitle = $('#hdWishlistTitleLabel').val();
111        var newWishListClasses = "popover-content ";
112        if (isSmallCartWidget) {
113            newWishListClasses += " stick-smallcartWidget";
114        }
115
116        var content = '<input type="text" placeholder ="New ' + wishListTitle + ' Name" class = "' + newWishListClasses + '" id="new-wish-list-name_' + cartItemID + '"></br></br>';
117        content += '<button type="button" class="popover-content btn btn-primary SaveForLaterCreateNewListButton" style="width: 100%" onclick="window.ac_wishlist.createListAndMoveItem(' + cartItemID + ', ' + isCartItem + ');">Create ' + wishListTitle + '</button>'
118        var title = "Create New " + wishListTitle + "<a class='close' >&times;</a>";
119        ac_wishlist.setPopoverData($('#' + e), title, content, isSmallCartWidget);
120    },
121
122    saveForLater: function (itemID, isCartItem = true) {
123        if (isCartItem) {
124            ac_wishlist.moveToWishList(itemID, 0);
125        }
126    },
127
128    createListAndMoveItem: function (itemID, isCartItem = true) {
129        var listSelector = "#new-wish-list-name_" + itemID;
130        var listName = $(listSelector)[0].value;
131        var data = JSON.stringify({ listName: listName });
132        jQuery.ajax({
133            type: "POST",
134            contentType: "application/json; charset=utf-8",
135            url: "/Store/Controls/ScriptService.asmx/CreateWishList",
136            dataType: "json",
137            data: data
138        }).done(function (result) {
139            if (result.d.Success) {
140                if (isCartItem)
141                    ac_wishlist.moveToWishList(itemID, result.d.CartInfoID);
142                else
143                    ac_wishlist.addToWishList(result.d.CartInfoID);
144            }
145            else
146                console.log(result.d.Message);
147        });
148    },
149
150    setPopoverData: function (e, title, content, isSmallCartWidget = false) {
151        var preV5Popover = $(e).data('bs.popover');
152
153        if (preV5Popover) {
154            if (title || title != '') {
155                if (preV5Popover.options != undefined && preV5Popover.options.title != undefined)
156                    preV5Popover.options.title = title;
157                else if (preV5Popover.config != undefined && preV5Popover.config.title != undefined)
158                    preV5Popover.config.title = title;
159            }
160
161            // This fixes a bootstrap bug that causes
162            // onclick handlers to not render
163            // https://github.com/twbs/bootstrap/issues/28290
164            if (preV5Popover.config != undefined)
165                preV5Popover.config.sanitize = false;
166            $(e).attr('data-content', content);
167            $(e).attr('data-container', 'body');
168            $(e).popover('show');
169
170        }
171        else {
172
173            var customClasses = "wishlistPopover";
174            if (isSmallCartWidget) {
175                customClasses = "wishlistPopover stick-smallcartWidget";
176            }
177
178            var options = {
179                "content": content,
180                "title": title,
181                "sanitize": false,
182                "customClass": customClasses,
183                "html": true,
184                "placement": "top",
185                "conatiner": 'body'
186            };
187
188            popover = new bootstrap.Popover(e, options);
189            popover.show();
190            ac_wishlist.popovers.push(popover);
191        }
192    },
193
194    hidePopovers: function (e) {
195        if (e) {
196            $(e).parents(".WishListPopoverButton[data-original-title]").popover('hide');
197        } else {
198            $(".WishListPopoverButton[data-original-title]").popover('hide');
199        }
200
201        // Handle Bootstrap 5 popovers
202        ac_wishlist.popovers.forEach(x => x.dispose());
203        ac_wishlist.popovers = [];
204    }
205};
206
207$(document).ready(function () {
208    //Initialize popovers
209    $('.WishListPopoverButton').popover();
210});
211
212// Hide popover when clicking 'X'
213$(document).on("click", ".wishlistPopover .close", function () {
214    ac_wishlist.hidePopovers(this);
215});
216
217// Hide popover on blur
218$('html').click(function (e) {
219    //debugger;
220    //foundation4 theme uses .popover-header, .popover-body instead of .popover-title and .popover-body
221    var evntTarget = $(e.target);
222    if (!evntTarget.is(".popover, .popover-title, .popover-content, .WishListPopoverButton, .popover-header, .popover-body")) {
223        ac_wishlist.hidePopovers();
224
225    } else if (evntTarget.is(".stick-smallcartWidget") ||
226        (evntTarget.closest("div.popover").find(".stick-smallcartWidget").length > 0)) {
227
228      e.stopPropagation(); // to stop small cart overlay to close in case it is called from small cart
229    }
230});

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.