PageSourceSearch

https://store.kai-group.com/js/sys/goods_ajax_bookmark.js

js kai-group.com collected 2026-09-24 17:55:26 UTC 9,828 bytes, 195 lines download raw bytes

1var ecblib = ecblib || {};
2ecblib.goods_ajax_bookmark = ecblib.goods_ajax_bookmark || {};
3
4jQuery(document).ready(function() {
5    jQuery(function () {
6        var _goods_ajax_bookmark = ecblib.goods_ajax_bookmark;
7        jQuery(document).on("click", ".js-cancel-modal", function() {
8            var id = jQuery(this).attr("data-target-modal");
9            var attrUrl = ecblib.sys.wwwroot + "/shop/customer/bookmark.aspx?goods=" + jQuery(this).attr("data-goods") + "&crsirefo_hidden=" + jQuery('#js_crsirefo_hidden').val();
10            jQuery('[class*="favorite-cancel--btn"]').attr("href", attrUrl);
11            if (jQuery(this).attr("class").indexOf("variation") == -1) {
12                var attrArea = jQuery(this).closest('[class^="pane-goods"]').attr("class").indexOf("footer") != -1 ? ".pane-goods-footer" : ".pane-goods-right-side";
13                jQuery('[class*="favorite-cancel--btn"]').attr("data-area", attrArea);
14            } else {
15                jQuery("#bookmarkmodal_goods_name").text(jQuery(this).attr("data-goods-name"));
16            }
17            ecblib.ui.dialog(id, {
18                quit : function(action) {
19                    action.close();
20                },
21                buttons : {
22                    'btncancel' : function(action) {
23                        action.close();
24                    }
25                }
26            });
27        });
28    });
29
30    var $btn_bookmark = jQuery(".js-animation-bookmark");
31    $btn_bookmark.off("click");
32    jQuery(document).on("click", ".js-animation-bookmark", function(e) {
33        var isRegisted = jQuery(this).attr("class").indexOf("cancel") != -1 ? true : false;
34        var originalText;
35        var goodsKind = "";
36        var attachTarget = "";
37        var attachElement = "";
38        var goodsCode = "";
39        var removeFlg = false;
40        var attachUrl = "javascript:void(0)";
41        var loadStart = function(elem) {
42            goodsCode = jQuery(elem).attr("href").substring(jQuery(elem).attr("href").indexOf("goods="), jQuery(elem).attr("href").indexOf("&crsirefo")).replace("goods=", "");
43            goodsKind = jQuery(elem).attr("class").indexOf("variation") != -1 ? "variation" : "goods";
44            if (jQuery(elem).attr("class").indexOf("cancel") != -1) {
45                if (goodsKind != "variation") {
46                    elem = jQuery(jQuery(elem).attr("data-area")).find('[class*="registed"]:not(.block-goods-list--favorite-registed--btn)');
47                } else {
48                    elem = jQuery("[data-goods="+goodsCode+"]");
49                }
50                removeFlg = true;
51                attachUrl = ecblib.sys.wwwroot + "/shop/customer/bookmark.aspx?goods=" + goodsCode + "&crsirefo_hidden=" + jQuery('#js_crsirefo_hidden').val();
52            }
53            jQuery(elem).attr("data-bookmark-click","true");
54            originalText = jQuery(elem).html();
55            attachTarget = jQuery(elem).closest('[class^="pane-goods"]').attr("class").indexOf("footer") != -1 ? ".pane-goods-right-side" : ".pane-goods-footer";
56            attachElement = removeFlg ? jQuery(attachTarget).find(".block-goods-favorite-registed--btn") : jQuery(attachTarget).find(".block-goods-favorite--btn");
57            jQuery(elem).html('<i class="js-animation-bookmark-in-progress fa fa-spinner fa-pulse fa-fw"></i><span class="sr-only">お待ちください...</span></a>');
58            return elem;
59        };
60        var loadEnd = function(elem, iserror, msg, btntxt) {
61            if (!iserror) {
62                ecblib.ui.showToolTip(jQuery(".js-animation-bookmark-in-progress"), { tooltip : msg, diptimeSec : 2 });
63                setTimeout(function() {
64                        if (!jQuery(elem).hasClass("invalid-guest-bookmark")) {
65                            jQuery(elem).attr("href", attachUrl);
66                            if (!removeFlg) {
67                                jQuery(elem).removeClass("js-animation-bookmark block-"+goodsKind+"-favorite--btn");
68                                jQuery(elem).addClass("block-"+goodsKind+"-favorite-registed--btn js-cancel-modal");
69                                jQuery(elem).attr("data-goods", goodsCode);
70                                jQuery(elem).attr("data-target-modal", "cancel-modal");
71                                if (goodsKind != "variation") {
72                                    jQuery(elem).html(btntxt);
73                                    attachElement.attr("href", attachUrl);
74                                    attachElement.html(btntxt);
75                                    attachElement.removeClass("js-animation-bookmark block-goods-favorite--btn");
76                                    attachElement.addClass("block-goods-favorite-registed--btn js-cancel-modal");
77                                    attachElement.attr("data-goods", goodsCode);
78                                    attachElement.attr("data-target-modal", "cancel-modal");
79                                } else {
80                                    jQuery(elem).html(originalText);
81                                }
82                            } else {
83                                jQuery(elem).addClass("js-animation-bookmark block-"
83+goodsKind+"-favorite--btn");
84                                jQuery(elem).removeClass("block-"+goodsKind+"-favorite-registed--btn js-cancel-modal");
85                                jQuery(elem).removeAttr("data-goods data-target-modal");
86                                if (goodsKind != "variation") {
87                                    jQuery(elem).html(btntxt);
88                                    attachElement.attr("href", attachUrl);
89                                    attachElement.html(btntxt);
90                                    attachElement.addClass("js-animation-bookmark block-goods-favorite--btn");
91                                    attachElement.removeClass("block-goods-favorite-registed--btn js-cancel-modal");
92                                    attachElement.removeAttr("data-goods data-target-modal");
93                                } else {
94                                    jQuery(elem).html(originalText);
95                                }
96                            }
97                        } else {
98                            jQuery(elem).html(originalText);
99                        }
100                    }, 2400);
101            } else {
102                jQuery(elem).html(originalText);
103            }
104            
105            jQuery(elem).removeAttr("data-bookmark-click");
106        };
107        var addBookmark = function(b, g) {
108            // お気に入りボタンのAjax処理が完了していなければ処理を終了する
109            if (jQuery(b).attr("data-bookmark-click") == "true") {
110                return false;
111            }
112            
113            var o = loadStart(b);
114            jQuery.ajax({
115                async: true,
116                type: "POST",
117                url: ecblib.sys.wwwroot + "/shop/customer/bookmarkajax.aspx",
118                data: {
119                    "goods": g,
120                    "crsirefo_hidden": jQuery('#js_crsirefo_hidden').val()
121                },
122                cache: false,
123                ifModified: false,
124                dataType: "json",
125                success: function(contents) {
126                    setTimeout(function() {
127                        loadEnd(o, false, contents.msg, contents.btntxt);
128                    }, 400);
129                    if (contents.isGuestBookmarkRedirect) {
130                        location.href = ecblib.sys.wwwroot + "/shop/customer/bookmark_guest.aspx";
131                    }
132                    if (contents.isBookmarkRedirect) {
133                        location.href = ecblib.sys.wwwroot + "/shop/customer/bookmark.aspx";
134                    }
135                },
136                error: function(xhr, status, thrown) {
137                    loadEnd(o, true);
138                    alert(ecblib.msg.goods_ajax_bookmark.SESSION_EXPIRED);
139                    return false;
140                }
141            });
142            return true;
143        };
144        var removeBookmark = function(b, g) {
145            // お気に入りボタンのAjax処理が完了していなければ処理を終了する
146            if (jQuery(b).attr("data-bookmark-click") == "true") {
147                return false;
148            }
149            
150            var o = loadStart(b);
151            jQuery.ajax({
152                async: true,
153                type: "POST",
154                url: ecblib.sys.wwwroot + "/shop/customer/bookmarkajax.aspx",
155                data: {
156                    "goods": g,
157                    "crsirefo_hidden": jQuery('#js_crsirefo_hidden').val(),
158                    "remove_flg": "True"
159                },
160                cache: false,
161                ifModified: false,
162                dataType: "json",
163                success: function(contents) {
164                    setTimeout(function() {
165                        loadEnd(o, false, contents.msg, contents.btntxt);
166                    }, 400);
167                },
168                error: function(xhr, status, thrown) {
169                    loadEnd(o, true);
170                    alert(ecblib.msg.goods_ajax_bookmark.SESSION_EXPIRED);
171                    return false;
172                }
173            });
174            return true;
175        };
176        if (!jQuery(this).length) {
177            return false;
178        }
179        var href = jQuery(this).attr("href");
180        var re = new RegExp("goods=([0-9A-Za-z_\-]+)");
181        var matches = href.match(re);
182        var goods = "";
183        if (matches && matches.length == 2) {
184            goods = matches[1];
185        } else {
186            return true;
187        }
188        if (!isRegisted) {
189            addBookmark(this, goods);
190        } else {
191            removeBookmark(this, goods);
192        }
193        return false;
194    });
195});

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.