PageSourceSearch

https://www.acad-ciencias.pt/wp-content/plugins/auxin-elements/public/assets/js/scripts.js?ver=2.17.21

js acad-ciencias.pt collected 2026-09-25 08:56:37 UTC 12,581 bytes, 303 lines download raw bytes

1;(function($, window, document, undefined){
2    var AuxinRemoveCartContent = function() {
3        // Remove cart content
4        $(document).on( 'click', '.aux-remove-cart-content', function(e) {
5            e.preventDefault();
6            
7            var $thisbutton = $(this);
8            var product_id   = $(this).data("product_id");
9            var cart_item_key= $(this).data("cart_item_key");
10            var verify_nonce = $(this).data("verify_nonce");
11            var $cartBoxEl   = $(this).closest('.aux-cart-wrapper').addClass('aux-cart-remove-in-progress');
12
13            if ( typeof auxin_cart_options === 'undefined' ) {
14                auxin_cart_options = '';
15            }
16
17            $.ajax({
18                type: 'POST',
19                dataType: 'json',
20                url: auxin.ajax_url,
21                data: {
22                    action: "auxels_remove_from_cart",
23                    product_id: product_id,
24                    cart_item_key: cart_item_key,
25                    verify_nonce: verify_nonce,
26                    args        : auxin_cart_options,
27                },
28                success: function( response ){
29                    // Remove old notification
30                    $(".woocommerce-message, .woocommerce-error").remove();
31                    // Start Notifications
32                    if( response.success ) {
33                        $('.aux-hidden-blocks').append( response.data.notif );
34
35                        if( parseInt(response.data.total) === 0 ) {
36                            $('.aux-card-dropdown').html(response.data.empty);
37                            $('.aux-cart-contents').find('span').remove();
38                        } else {
39                            $('.aux-card-item').filter(function(){
40                                return $(this).data('cart_item_key') == cart_item_key;
41                            }).remove();
42                            $('.aux-cart-contents').find('span').text(response.data.count);
43                        }
44                        $(".aux-cart-subtotal").each(function() {
45							$(this).find('.woocommerce-Price-amount').html(response.data.total);
46                        });
47                        $cartBoxEl.removeClass('aux-cart-remove-in-progress');
48
49                        $( document.body ).trigger( 'removed_from_cart', [ response.data.fragments, response.data.cart_hash, $thisbutton, response.data.items ] );
50                    } else {
51                        $('.aux-hidden-blocks').append( response.data );
52                    }
53                    // check to be sure offcanvas cart style is always visible in mobile
54                    $('#offcart .aux-cart-wrapper .aux-card-dropdown').removeClass('aux-phone-off');
55                }
56            });
57
58        });
59    };
60
61    var AuxinAjaxAddToCart = function() {
62        // Add Content to Cart
63        $(document).on( 'click', '.aux-ajax-add-to-cart', function(e) {
64            var $thisbutton = $(this);
65            var productType  = $(this).data("product-type");
66
67            if ( productType !== 'simple' ) {
68                return;
69            }
70
71            $thisbutton.removeClass( 'added' );
72			$thisbutton.addClass( 'loading' );
73
74            if ( typeof auxin_cart_options === 'undefined' ) {
75                auxin_cart_options = '';
76            }
77
78            e.preventDefault();
79
80            var product_id   = $(this).data("product_id");
81            var quantity     = $(this).data("quantity");
82            var verify_nonce = $(this).data("verify_nonce");
83            var $cartBoxEl   = $('.aux-cart-wrapper');
84            var hasAnimation = $cartBoxEl.hasClass('aux-basket-animation') ? true : false;
85
86            $cartBoxEl.trigger('AuxCartInProgress');
87
88            if ( $(this).parents('.aux-shop-quicklook-modal') ) {
89                quantity = $(this).parents('.aux-shop-quicklook-modal').find('.quantity input').val();
90            }
91
92            var data = {};
93
94            $.each( $thisbutton.data(), function( key, value ) {
95				data[ key ] = value;
96			});
97
98            // Fetch data attributes in $thisbutton. Give preference to data-attributes because they can be directly modified by javascript
99			// while `.data` are jquery specific memory stores.
100			$.each( $thisbutton[0].dataset, function( key, value ) {
101				data[ key ] = value;
102			});
103            
104            // Trigger event.
105			$( document.body ).trigger( 'adding_to_cart', [ $thisbutton, data ] );
106
107            $.ajax({
108                type: 'POST',
109                dataType: 'json',
110                url: auxin.ajax_url,
111                data: {
112                    action      : "auxels_add_to_cart",
113                    args        : auxin_cart_options,
114                    product_id  : product_id,
115                    quantity    : quantity,
116                    verify_nonce: verify_nonce
117                },
118                success: function( response ){
119                    // Remove old notification
120                    $(".woocommerce-message, .woocommerce-error").remove();
121                    // Start Notifications
122                    if( response.success ) {
123                        $('.aux-hidden-blocks').append( response.data.notif );
124
125                        setTimeout( function(){
126                            if ( hasAnimation ) {
127                                // $cartBoxEl.on('AuxCartProgressAnimationDone', function(e) {
128                                    $cartBoxEl.find('.aux-card-dropdown').html( response.data.items );
129                                    $cartBoxEl.find('.aux-shopping-basket').html( response.data.total );
130                                    $cartBoxEl.trigger('AuxCartUpdated');
131                                    $( document.body ).trigger( 'added_to_cart', [ response.data.fragments, response.data.cart_hash, $thisbutton ] );
132                                // });
133                            } else {
134                                $cartBoxEl.find('.aux-card-dropdown').html( response.data.items );
135                                $cartBoxEl.find('.aux-shopping-basket').html( response.data.total );
136                                $cartBoxEl.trigger('AuxCartUpdated');
137                                $( document.body ).trigger( 'added_to_cart', [ response.data.fragments, response.data.cart_hash, $thisbutton, response.data.items ] );
138                            }
139                            // check to be sure offcanvas cart style is always visible in mobile
140                            $('#offcart .aux-cart-wrapper .aux-card-dropdown').removeClass('aux-phone-off');
141                        }, 150);
142                    } else {
143                        $('.aux-hidden-blocks').append( response.data );
144                    }
145
146                }
147
148            });
149
150        });
151
152        $(document.body).on( 'wc_fragments_refreshed', function(){
153
154            var $cartBoxEl   = $('.aux-cart-wrapper');
155            var hasAnimation = $cartBoxEl.hasClass('aux-basket-animation') ? true : false;
156
157            if ( typeof auxin_cart_options === 'undefined' ) {
158                auxin_cart_options = '';
159            }
160
161            $.ajax({
162                type: 'POST',
163                dataType: 'json',
164                url: auxin.ajax_url,
165                data: {
166                    action      : "auxels_get_refreshed_fragments",
167                    args        : auxin_cart_options,
168                },
169                success: function( response ){
170                    // Remove old notification
171                    $(".woocommerce-message, .woocommerce-error").remove();
172                    // Start Notifications
173                    if( response.success ) {
174
175                        setTimeout( function(){
176                            if ( hasAnimation ) {
177                                $cartBoxEl.find('.aux-card-dropdown').html( response.data.items );
178                                $cartBoxEl.find('.aux-shopping-basket').html( response.data.total );
179                                $cartBoxEl.trigger('AuxCartUpdated');
180                            } else {
181                                $cartBoxEl.find('.aux-card-dropdown').html( response.data.items );
182                                $cartBoxEl.find('.aux-shopping-basket').html( response.data.total );
183                                $cartBoxEl.trigger('AuxCartUpdated');
184                            }
185                        }, 150);
186                    } else {
187                        $('.aux-hidden-blocks').append( response.data );
188                    }
189
190                }
191
192            });
193
194        });
195
196    };
197
198    var AjaxRecentProductsPagination = function () {
199        $('a.page-numbers').on('click', function (e) { 
200            if ( !$(this).parents('.aux-widget-recent-products').length) {
201                return;
202            }
203            e.preventDefault();
204            var $widgetWrapper = $(this).parents('.elementor-widget-container').length ? $(this).parents('.elementor-widget-container') : $(this).parents('.elementor-widget'),
205                widgetData = $widgetWrapper.find('.aux-recent-products-wrapper').data('widget-data'),
206                paged = $(this).data('paged');
207
208            $widgetWrapper.find('.aux-widget-recent-products').addClass('loading');
209            $widgetWrapper.find('.aux-isotope-animated .aux-items-loading').removeClass('aux-loading-hide');
210            $.ajax({
211                url: auxin.ajax_url,
212                type: 'GET',
213                data: {
214                    action: 'aux_the_recent_products',
215                    data: widgetData,
216                    paged: paged,
217                    auxinNonce: auxin.nonce
218                }
219            }).done(function (response) {
220                if (response) {
221                    $widgetWrapper.empty();
222                    $widgetWrapper.append(response);
223                    $(document).trigger('auxin_the_recent_products_widget_updated');
224                }
225            });
226        });
227    }
228
229    var AuxinSelectEelement = function () {
230
231        $('.aux-select-element').each(function () {
232            var $element = $(this);
233            var action = $element.data('action');
234            if (action == 'click') {
235                $element.find('.current').on('click', function () {
236                    $(this).siblings('.list').toggleClass('show');
237                })
238
239            } else {
240                $element.hover(function () {
241                        $element.find('.list').addClass('show');
242                    }, function () {
243                        $element.find('.list').removeClass('show');
244                    }
245                );
246            }
247
248            $element.find('.option').on('click', function () {
249                var markup = $(this).html();
250                $element.find('.current .selected').html(markup);
251                $element.find('.list').toggleClass('show');
252            });
253
254            $(document).on('click', function (e) {
255                if (!$(e.target).parents('.aux-select-element').length) {
256                    $element.find('.list').removeClass('show');
257                }
258            });
259        })
260    }
261
262    $(document).ready(function(){
263        AuxinRemoveCartContent();
264        AuxinAjaxAddToCart();
265        AjaxRecentProductsPagination();
266        $(document).on('auxin_the_recent_products_widget_updated', function () {
267            AjaxRecentProductsPagination();
268        });
269
270        AuxinSelectEelement();
271    });
272
273     $.fn.AuxinCartAnimationHandler = function() {
274        $headerCartWrapper = $(this).find('.aux-cart-wrapper');
275        $headerCartWrapper.trigger('AuxCartProgressAnimationDone');
276
277        if ( ! $headerCartWrapper.hasClass('aux-basket-animation') ) {
278            return
279        }
280
281        $headerCartWrapper.on('AuxCartInProgress', function(e) {
282            $headerCartWrapper.addClass('aux-cart-in-progress');
283        });
284
285        $headerCartWrapper.on('animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', function(e) {
286            if ( e.originalEvent.animationName === 'FillBasket') {
287                $headerCartWrapper.removeClass('aux-cart-in-progress');
288                $headerCartWrapper.trigger('AuxCartProgressAnimationDone');
289            }
290        });
291
292        $headerCartWrapper.on('AuxCartUpdated', function(e) {
293            $headerCartWrapper.addClass('aux-cart-updated-animation');
294        });
295    }
296
297    $('body').AuxinCartAnimationHandler();
298
299    $(document.body).on( 'wc_cart_emptied', function(){
300        $('.aux-shopping-basket .aux-cart-contents span').html('0');
301    });
302
303})(jQuery,window,document);

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.