PageSourceSearch

https://www.sportvision.ba/nb-public/themes/nbshop5_v5_8/_static/j…/nbshop.productfavorite.js?ver=1053_5.2

js sportvision.ba collected 2026-09-26 11:07:56 UTC 15,186 bytes, 371 lines download raw bytes

1/* NB SHOP Demo JS script
2 * By NB SHOP & NB SOFT
3 * www.nbsoft.rs www.nbshop.rs
4 * NB SOFT Licensed.
5 */
6function NbProductFavorite(){
7
8    var handleFavoriteProduct = function($elements){
9
10        if($elements.hasClass('nb_finit')){
11            return false
12        }else{
13            $elements.addClass('nb_finit')
14        }
15
16        var addFavoriteProductSession = function($favIcon){
17
18            $.ajax({
19                type: "POST",
20                url: nb_active_page_url,
21                data: {
22                    nbAjax: 1,
23                    nbTask: 'product_favorites',
24                    flag: "yes",
25                    ajax: "yes",
26                    task: "add_session_favorites_product",
27                    productId: $favIcon.parents('.product-item').length
28                        ? $favIcon.parents('.product-item').data('productid')
29                        : $favIcon.data('productid'),
30                    typeObject: $favIcon.data('favoritetypeobject') === 'undefined'
31                        ? 'product'
32                        : $favIcon.data('favoritetypeobject')
33                },
34                contentType: "application/x-www-form-urlencoded;charset=UTF-8",
35                dataType: 'json',
36                success: function(ret) {
37                    if (ret.flag){
38
39                    }else{
40                        toastr.error(ret.info);
41                    }
42                }
43            });
44        };
45
46        var favoriteProduct = function($favIcon){
47
48            let eventId = generateEventId();
49
50            if(!nbshopJS.logged_in){
51                addFavoriteProductSession($favIcon);
52                nbshopJS.getLoginModal().modal('show');
53            } else {
54                $.ajax({
55                    type: "POST",
56                    url: nb_active_page_url,
57                    data: {
58                        nbAjax: 1,
59                        nbTask: 'product_favorites',
60                        flag: "yes",
61                        ajax: "yes",
62                        task: "add_favorites_product",
63                        productId: $favIcon.parents('.product-item').length
64                            ? $favIcon.parents('.product-item').data('productid')
65                            : $favIcon.data('productid'),
66                        typeObject: $favIcon.data('favoritetypeobject') === 'undefined'
67                            ? 'product'
68                            : $favIcon.data('favoritetypeobject')
69                    },
70                    contentType: "application/x-www-form-urlencoded;charset=UTF-8",
71                    dataType: 'json',
72                    success: function(ret) {
73                        if (ret.flag) {
74                            console.log(ret);
75                            if(ret.quantity === "1"){
76                                $("#last-piece-modal").modal('show');
77                            }
78                            $favIcon.data('favoriteid', ret.id);
79                            $favIcon.attr('data-content', $favIcon.data('favorite-text-delete'));
80                            $favIcon.attr('data-original-title', $favIcon.data('favorite-text-delete'));
81                            var delFavText = '<span class="icon icon-heart-f"></span><span class="text">'+$favIcon.data('favorite-text-delete')+'</span>';
82                            if ($favIcon.parents('.products-detail-wrapper').length) {
83                                $favIcon.html(delFavText);
84                            }
85
86                            if($favIcon.parents('.product-item').length){
87                                $favIcon.parents('.product-item').find('.favorite').addClass('active');
88                                var buttonNoNotifyMe = $favIcon.parents('.product-item').find('.notifyme');
89                                if(typeof(buttonNoNotifyMe.data('button-no-notify-me')) != 'undefined' && buttonNoNotifyMe.data('button-no-notify-me') != null){
90                                    buttonNoNotifyMe.text(buttonNoNotifyMe.data('button-no-notify-me'));
91                                    buttonNoNotifyMe.data('favoriteid', ret.id)
92                                }
93
94                                buttonNoNotifyMe.addClass('active');
95
96                            }else{
97                                $favIcon.addClass('active');
98                            }
99
100                            let productId = nbMetricObject.NB_METRIC_DATA.id;
101
102                            if( typeof $($favIcon).closest(".product-item") !== "undefined" && $($favIcon).closest(".product-item").length > 0) {
103                                productId = $($favIcon).closest(".product-item").data('productid');
104                            }
105
106                            toastr.success(ret.info);
107                            refreshFavoritesList();
108                            nbshopJS.CustomEventTrigger('addToFavoritesProduct', { id: productId, event_id: eventId });
109                            var favoriteTotal = (parseInt($('.favorite-header-total').html()) + 1);
110                            $('.favorite-header-total').html(favoriteTotal);
111                        } else{
112                            toastr.error(ret.info);
113                        }
114                        $favIcon.removeClass('pulse');
115                    }
116                });
117            }
118        };
119
120        var unfavoriteProduct = function($favIcon){
121            if(!nbshopJS.logged_in){
122                nbshopJS.getLoginModal().modal('show');
123            } else {
124                $.ajax({
125                    type: "POST",
126                    url: nb_active_page_url,
127                    data: {
128                        nbAjax: 1,
129                        nbTask: 'product_favorites',
130                        flag: "yes",
131                        ajax: "yes",
132                        task: "delete_favorites_product",
133                        id: $favIcon.data('favoriteid'),
134                        typeObject: $favIcon.data('favoritetypeobject') === 'undefined'
135                            ? 'product'
136                            : $favIcon.data('favoritetypeobject')
137                    },
138                    contentType: "application/x-www-form-urlencoded;charset=UTF-8",
139                    dataType: 'json',
140                    success: function(ret) {
141                        if (ret.flag) {
142
143                            $favIcon.attr('data-content', $favIcon.data('favorite-text-add'));
144                            $favIcon.attr('data-original-title', $favIcon.data('favorite-text-add'));
145                            var addFavText = '<span class="icon icon-heart"></span><span class="text">'+$favIcon.data('favorite-text-add')+'</span>';
146                            if ($favIcon.parents('.products-detail-wrapper').length) {
147                                $favIcon.html(addFavText);
148                            }
149
150                            if($favIcon.parents('.product-item').length){
151                                $favIcon.parents('.product-item').find('.favorite').removeClass('active');
152                                var buttonNotifyMe = $favIcon.parents('.product-item').find('.notifyme');
153                                if(typeof(buttonNotifyMe.data('button-notify-me')) != 'undefined' && buttonNotifyMe.data('button-notify-me') != null){
154                                    buttonNotifyMe.text(buttonNotifyMe.data('button-notify-me'));
155                                }
156                                buttonNotifyMe.removeClass('active');
157                            }else{
158                                $favIcon.removeClass('active');
159                            }
160
161                            let productId = nbMetricObject.NB_METRIC_DATA.id;
162
163                            if( typeof $($favIcon).closest(".product-item") !== "undefined" && $($favIcon).closest(".product-item").length > 0) {
164                                productId = $($favIcon).closest(".product-item").data('productid');
165                            }
166
167                            toastr.info(ret.info);
168                            refreshFavoritesList();
169                            nbshopJS.CustomEventTrigger('removeFavoritesProduct', {id: productId});
170                            var favoriteTotal = (parseInt($('.favorite-header-total').html()) - 1);
171                            $('.favorite-header-total').html(favoriteTotal);
172                        } else{
173                            toastr.error(ret.info);
174                        }
175                        $favIcon.removeClass('pulse');
176                    }
177                });
178            }
179        };
180
181        $elements.click(function(e){
182
183            var $favIcon = $(this);
184
185            e.preventDefault();
186            e.stopPropagation();
187
188            // Sakrivanje toltip-a, zato sto tooltip ostaje prikazan nakon sto se klikne na dugme cak i kad se menja slajd
189            $favIcon.popover('hide');
190            $favIcon.tooltip('hide');
191
192            $favIcon.addClass('pulse');
193            if($favIcon.hasClass('active')){
194                unfavoriteProduct($favIcon);
195            } else {
196                favoriteProduct($favIcon);
197            }
198        });
199    };
200
201    return {
202        init: function(){
203            handleFavoriteProduct($('.favorite'));
204        },
205        handleFavoriteProduct: handleFavoriteProduct,
206    };
207
208};
209
210window.nbProductFavorite = new NbProductFavorite();
211
212$(document).ready(function(){
213    nbProductFavorite.init();
214});
215
216function deleteFavoritesProduct(thisElement, id, e) {
217    e.preventDefault();
218    e.stopPropagation();
219    bootbox.confirm(thisElement.data('question'), function(result) {
220        if(!result) return;
221        $.ajax({
222            type: "POST",
223            url: nb_active_page_url,
224            data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=delete_favorites_product&id='+id,
225            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
226            dataType: 'json',
227            success: function(ret) {
228                if (ret.flag) {
229                    refreshFavoritesList();
230                } else{
231                    toastr.error(ret.info);
232                }
233            }
234        });
235    });
236}
237
238function deleteFavoritesList(thisElement) {
239    bootbox.confirm(thisElement.data('question'), function(result) {
240        if(!result) return;
241        $.ajax({
242            type: "POST",
243            url: nb_active_page_url,
244            data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=delete_list_favorites',
245            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
246            dataType: 'json',
247            success: function(ret) {
248                if (ret.flag) {
249                    refreshFavoritesList();
250                } else{
251                    toastr.error(ret.info);
252                }
253            }
254        });
255    });
256}
257
258function refreshFavoritesList() {
259    $.ajax({
260        type: "POST",
261        url: nb_active_page_url,
262        data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=refresh_list_favorites',
263        contentType: "application/x-www-form-urlencoded;charset=UTF-8",
264        success: function(ret) {
265            if (ret) {
266                $("#myfavorites").html(ret);
267            }
268        }
269    });
270}
271
272//vise objekata koristi istu funkciju
273function deleteFavoritesObject(thisElement, id, typeObject, e) {
274    e.preventDefault();
275    e.stopPropagation();
276    bootbox.confirm(thisElement.data('question'), function(result) {
277        if(!result) return;
278        $.ajax({
279            type: "POST",
280            url: nb_active_page_url,
281            data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=delete_favorites_product&id='+id+'&typeObject='+typeObject,
282            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
283            dataType: 'json',
284            success: function(ret) {
285                if (ret.flag) {
286                    window.location = thisElement.data('url');
287                    //refreshFavoritesObjectList(typeObject);
288                } else{
289                    toastr.error(ret.info);
290                }
291            }
292        });
293    });
294}
295
296function deleteFavoritesObjectList(thisElement, typeObject) {
297    bootbox.confirm(thisElement.data('question'), function(result) {
298        if(!result) return;
299        $.ajax({
300            type: "POST",
301            url: nb_active_page_url,
302            data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=delete_list_favorites&typeObject='+typeObject,
303            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
304            dataType: 'json',
305            success: function(ret) {
306                if (ret.flag){
307                    //refreshFavoritesObjectList(typeObject);
308                    window.location = thisElement.data('url');
309                } else{
310                    toastr.error(ret.info);
311                }
312            }
313        });
314    });
315}
316
317function sendFavoritesProductForQuery(thisElement, typeObject, productUserFavoritesGroupId){
318    bootbox.confirm(thisElement.data('question'), function(result) {
319        if(!result) return;
320        $.ajax({
321            type: "POST",
322            url: nb_active_page_url,
323            data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=send_favorites_product_for_query&typeObject='+typeObject+'&productUserFavoritesGroupId='+productUserFavoritesGroupId,
324            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
325            dataType: 'json',
326            success: function(ret) {
327                if (ret.flag){
328                    //refreshFavoritesObjectList(typeObject);
329                    window.location = thisElement.data('url');
330                } else{
331                    toastr.error(ret.info);
332                }
333            }
334        });
335    });
336}
337
338function deleteFavoritesProductGroup(thisElement, typeObject, productUserFavoritesGroupId){
339    bootbox.confirm(thisElement.data('question'), function(result) {
340        if(!result) return;
341        $.ajax({
342            type: "POST",
343            url: nb_active_page_url,
344            data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=delete_favorites_product_group&typeObject='+typeObject+'&productUserFavoritesGroupId='+productUserFavoritesGroupId,
345            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
346            dataType: 'json',
347            success: function(ret) {
348                if (ret.flag){
349                    //refreshFavoritesObjectList(typeObject);
350                    window.location = thisElement.data('url');
351                } else{
352                    toastr.error(ret.info);
353                }
354            }
355        });
356    });
357}
358
359function refreshFavoritesObjectList(typeObject) {
360    $.ajax({
361        type: "POST",
362        url: nb_active_page_url,
363        data: 'nbAjax=1&nbTask=product_favorites&flag=yes&ajax=yes&task=refresh_list_favorites&typeObject='+typeObject,
364        contentType: "application/x-www-form-urlencoded;charset=UTF-8",
365        success: function(ret) {
366            if (ret) {
367                $(".tab_content_favorites_"+typeObject).html(ret);
368            }
369        }
370    });
371}

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.