PageSourceSearch

https://www.borderstates.com/_ui/responsive/common/js/acc.myListAddTo.js

js borderstates.com collected 2026-10-03 21:44:18 UTC 16,618 bytes, 309 lines download raw bytes

1ACC.myListAddTo = {
2
3    _autoload: [
4        "bindMyListAddTo"
5    ],
6
7    bindMyListAddTo : function(){
8        ACC.myListAddTo.showListDialog();
9        $(document).on('click', '#addOrCreateWishList', function () {
10            ACC.myListAddTo.addOrCreateWishListPopup();
11            return false;
12        });
13
14        if ($('.wishlistname').length) {
15            $.get(ACC.config.encodedContextPath + "/wishlist/getAllWishLists", // url
16                function (data, textStatus, jqXHR) { // success
17                    // callback
18
19                    var options = '<option value="Create a New List">Choose Existing List</option>';
20
21                    for (var i = 0; i < data.length; i++) {
22                        options += '<option value="' + ACC.sanitizer.escapeXml(data[i].listId) + '">' + data[i].name + '</option>';
23
24                    }
25                    $(".wishlistname").empty().append(options);
26
27                });
28        }
29        if ($('.addCartTowishlistname').length) {
30
31            $.get(ACC.config.encodedContextPath + "/wishlist/getAllWishLists", // url
32                function (data, textStatus, jqXHR) { // success
33                    // callback
34
35                    var options = '<option value="Create a New List">Choose Existing List</option>';
36
37                    for (var i = 0; i < data.length; i++) {
38                        options += '<option value="' + ACC.sanitizer.escapeXml(data[i]) + '">' + data[i] + '</option>';
39
40                    }
41                    $(".addCartTowishlistname").empty().append(options);
42
43                });
44        }
45    },
46        
47    closeColorboxPopup: function() {
48       parent.$.colorbox.close();
49    },
50
51    addOrCreateWishListPopup: function(){
52        $("#showWishList input[type='text']").val('');
53        $('#showWishList select.wishlistname').val("Create a New List");
54        $('#showWishList select.privacylevel').val("private");
55        $("#showWishList input").prop('disabled', false);
56        $("#showWishList").dialog({
57            autoOpen: false
58        });
59        $("#showWishList").dialog('open');
60        return false;
61    },
62    showListDialog: function(){
63        $('#showWishList').dialog({
64            modal: true,
65            autoOpen: false,
66            width: "564px",
67            title: 'Add to My List',
68            dialogClass: 'add-mylist',
69            buttons: {
70                "Cancel": function () {
71                    $(this).closest('.ui-dialog-content').dialog('close');
72                },
73                "Add to My List": function () {
74                    $(this).closest('.ui-dialog-content').dialog('close');
75                    if ($('.wishlistname').val() != "Create a New List") {
76                        var form = document.getElementById("addToCartForm");
77                        bseQuantity = form.elements.qty.value;
78                        productCode = form.elements.productCodePost.value;
79                        productName = form.elements.productNamePost.value;
80                        productPrice = form.elements.productPricePost.value;
81                        productManufacturer = form.elements.productManufacturer.value;
82                        $.post(ACC.config.encodedContextPath + "/wishlist/add", {
83                                listId: $('.wishlistname').val(),
84                                bseQuantity: form.elements.qty.value,
85                                productCode: form.elements.productCodePost.value,
86                                productName: form.elements.productNamePost.value,
87                                productPrice: form.elements.productPricePost.value,
88                                productManufacturer: form.elements.productManufacturer.value
89                            },
90                            function (data, status) {
91                                var page = "wishListPage";
92                                var statusText = data.Status;
93                                if (page == "wishListPage") {
94                                    ACC.gtm.addToWishList_gtm(productCode, productName, productPrice, productManufacturer, bseQuantity);
95                                    var poupHeader = (!$(".errorMsgs p." + data.Status + "Header").text().trim()) ? data.Status : $(".errorMsgs p." + data.Status + "Header").text();
96                                    ACC.colorbox.open(poupHeader, {
97                                        html: "<div><p>" + $(".errorMsgs p." + data.Status).text() + "</p><button class='btn-small js-close-colorbox-popup'>OK</button></div>",
98                                        width: "380px",
99                                        initialWidth: "380px",
100                                        overlayClose: false,
101                                        fixed: true,
102                                        className: "nonResponsive",
103                                        onLoad: function () {
104                                            $("#cboxClose").remove();
105                                        },
106                                        onClosed: function () {
107                                            if (data.Status == "ProductAdded") {
108                                                // reload();
109                                            }
110                                        }
111                                    });
112                                    $('.js-close-colorbox-popup').on("click", ACC.myListAddTo.closeColorboxPopup);
113                                }
114                            });
115                    } else {
116                        var page = "wishListPage";
117                        var form = document.getElementById("addToCartForm");
118                        bseQuantity = form.elements.qty.value;
119                        productCode = form.elements.productCodePost.value;
120                        productName = form.elements.productNamePost.value;
121                        productPrice = form.elements.productPricePost.value;
122                        productManufacturer = form.elements.productManufacturer.value;
123                        $.post(ACC.config.encodedContextPath + "/wishlist/create-wishlist-addProduct",
124                            {
125                                wishlistName: $("#listname").val(),
126                                privacyLevel: $("#privacylevel").val(),
127                                bseQuantity: form.elements.qty.value,
128                                productCode: form.elements.productCodePost.value,
129                                productName: form.elements.productNamePost.value,
130                                productPrice: form.elements.productPricePost.value,
131                                productManufacturer: form.elements.productManufacturer.value
132                            },
133                            function (data, status) {
134                                var statusText = data.Status;
135                                if (page == "wishListPage") {
136                                    ACC.gtm.addToWishList_gtm(productCode, productName, productPrice, productManufacturer, bseQuantity);
137                                    var poupHeader = (!$(".errorMsgs p." + data.Status + "Header").text().trim()) ? data.Status : $(".errorMsgs p." + data.Status + "Header").text();
138                                    ACC.colorbox.open(poupHeader, {
139                                        html: "<div><p>" + $(".errorMsgs p." + data.Status).text() + "</p><button class='btn-small js-close-colorbox-popup'>OK</button></div>",
140                                        width: "380px",
141                                        initialWidth: "380px",
142                                        overlayClose: false,
143                                        fixed: true,
144                                        className: "nonResponsive",
145                                        onLoad: function () {
146                                            $("#cboxClose").remove();
147                                        },
148                                        onClosed: function () {
149                                            var newWishListName = $("#listname").val()
150                                            $(".wishlistname").append(new Option(newWishListName,data.ListId));
151                                            if (data.Status == "ProductAdded") {
152                                                //reload();
153                                            }
154                                        }
155                                    });
156                                    $('.js-close-colorbox-popup').on("click", ACC.myListAddTo.closeColorboxPopup);
157                                }
158                            });
159                    }
160                }
161            },
162            create: function () {
163                $(window).resize(function () {
164                    $('#showWishList').parent().position({
165                        my: "center",
166                        at: "center",
167                        of: window
168                    });
169                });
170                $(window).scroll(function () {
171                    $('#showWishList').parent().position({
172                        my: "center",
173                        at: "center",
174                        of: window
175                    });
176                });
177            }
178        }).parent().position({
179            my: "center center",
180            at: "center center+20",
181            of: window
182        });
183    },
184
185    addToWishListOnCart: function (productCode, productName, productPrice, productManufacturer, bseQuantity) {
186
187        $('#showWishListOnCart_' + productCode).dialog({
188            modal: true,
189            autoOpen: false,
190            width: "564px",
191            title: 'Add to My List',
192            dialogClass: 'add-mylist',
193            buttons: {
194                "Cancel": function () {
195                    $(this).closest('.ui-dialog-content').dialog('close');
196                },
197                "Add to My List": function () {
198                    $(this).closest('.ui-dialog-content').dialog('close');
199                    selectOptions = $('#showWishListOnCart_' + productC
199ode + ' #wishlistname');
200
201                    if (selectOptions.val() != "Create a New List") {
202
203                        $.post(ACC.config.encodedContextPath + "/wishlist/add", {
204                                listId: selectOptions.children("option:selected").val(),
205                                productCode: productCode,
206                            },
207                            function (data, status) {
208                                var page = "wishListPage";
209                                var statusText = data.Status;
210                                if (page == "wishListPage") {
211                                    ACC.gtm.addToWishList_gtm(productCode, productName, productPrice, productManufacturer, bseQuantity);
212                                    var poupHeader = (!$(".showWishListOnCarterrorMsgs p." + data.Status + "Header").text().trim()) ? data.Status : $(".showWishListOnCarterrorMsgs p." + data.Status + "Header").text();
213                                    ACC.colorbox.open(poupHeader, {
214                                        html: "<div><p>" + $(" .showWishListOnCarterrorMsgs p." + data.Status).text() + "</p><button class='btn-small js-close-colorbox-popup'>OK</button></div>",
215                                        width: "380px",
216                                        initialWidth: "380px",
217                                        overlayClose: false,
218                                        fixed: true,
219                                        className: "nonResponsive",
220                                        onLoad: function () {
221                                            $("#cboxClose").remove();
222                                        },
223                                        onClosed: function () {
224                                            if (data.Status == "ProductAdded") {
225                                                // reload();
226                                            }
227                                        }
228                                    });
229                                    $('.js-close-colorbox-popup').on("click", ACC.myListAddTo.closeColorboxPopup);
230                                }
231                            });
232                    } else {
233                        var page = "wishListPage";
234                        $.post(ACC.config.encodedContextPath + "/wishlist/create-wishlist-addProduct",
235                            {
236                                wishlistName: $('#showWishListOnCart_' + productCode + ' #listname').val(),
237                                productCode: productCode,
238                                privacyLevel: $('#showWishListOnCart_' + productCode + ' #privacylevel').val()
239                            },
240
241                            function (data, status) {
242                                var statusText = data.Status;
243                                if (page == "wishListPage") {
244                                    ACC.gtm.addToWishList_gtm(productCode, productName, productPrice, productManufacturer, bseQuantity);
245                                    var poupHeader = (!$(".showWishListOnCarterrorMsgs p." + data.Status + "Header").text().trim()) ? data.Status : $(".showWishListOnCarterrorMsgs p." + data.Status + "Header").text();
246                                    ACC.colorbox.open(poupHeader, {
247                                        html: "<div><p>" + $(" .showWishListOnCarterrorMsgs p." + data.Status).text() + "</p><button class='btn-small js-close-colorbox-popup'>OK</button></div>",
248                                        width: "380px",
249                                        initialWidth: "380px",
250                                        overlayClose: false,
251                                        fixed: true,
252                                        className: "nonResponsive",
253                                        onLoad: function () {
254                                            $("#cboxClose").remove();
255                                        },
256                                        onClosed: function () {
257                                            var newWishListName = $('#showWishListOnCart_' + productC
257ode + ' #listname').val();
258                                            $(".wishlistname").append(new Option(newWishListName, newWishListName));
259                                            if (data.Status == "ProductAdded") {
260                                                //reload();
261                                            }
262                                        }
263                                    });
264                                    $('.js-close-colorbox-popup').on("click", ACC.myListAddTo.closeColorboxPopup);
265                                }
266                            });
267                    }
268                }
269            },
270            create: function () {
271                $(window).resize(function () {
272                    $('#showWishListOnCart_' + productCode).parent().position({
273                        my: "center",
274                        at: "center",
275                        of: window
276                    });
277                });
278                $(window).scroll(function () {
279                    $('#showWishListOnCart_' + productCode).parent().position({
280                        my: "center",
281                        at: "center",
282                        of: window
283                    });
284                });
285            }
286        }).parent().position({
287            my: "center center",
288            at: "center center+20",
289            of: window
290        });
291
292        $('#showWishListOnCart_' + productCode + ' #wishlistname').on("change", function () {
293            $('#showWishListOnCart_' + productCode + ' #listname').prop("disabled", $('#showWishListOnCart_' + productCode + ' select').val() != "Create a New List");
294            $('#showWishListOnCart_' + productCode + ' #listname').val('');
295        });
296
297        $('#showWishListOnCart_' + productCode + ' #listname').val('');
298        $('#showWishListOnCart_' + productCode + ' select.wishlistname').val("Create a New List");
299        $('#showWishListOnCart_' + productCode + ' select.privacylevel').val("private");
300        $('#showWishListOnCart_' + productCode + ' #listname').prop('disabled', false);
301        $('#showWishListOnCart_' + productCode).dialog({
302            autoOpen: false
303        });
304        $('#showWishListOnCart_' + productCode).dialog("open");
305        return false;
306
307    }
308
309};

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.