PageSourceSearch

https://investidorinstitucional.com.br/wp-content/plugins/enhancer…/assets/js/frontend.js?ver=5.5.0

js investidorinstitucional.com.br collected 2026-10-02 05:52:17 UTC 8,559 bytes, 199 lines download raw bytes

1/* global enr_frontend_params */
2
3jQuery( function( $ ) {
4    'use strict';
5
6    var is_blocked = function( $node ) {
7        return $node.is( '.processing' ) || $node.parents( '.processing' ).length;
8    };
9
10    /**
11     * Block a node visually for processing.
12     *
13     * @param {JQuery Object} $node
14     */
15    var block = function( $node ) {
16        $.blockUI.defaults.overlayCSS.cursor = 'wait';
17
18        if ( ! is_blocked( $node ) ) {
19            $node.addClass( 'processing' ).block( {
20                message : null,
21                overlayCSS : {
22                    background : '#fff',
23                    opacity : 0.6
24                }
25            } );
26        }
27    };
28
29    /**
30     * Unblock a node after processing is complete.
31     *
32     * @param {JQuery Object} $node
33     */
34    var unblock = function( $node ) {
35        $node.removeClass( 'processing' ).unblock();
36    };
37
38    // Hide variable level limit notice when it is limited to variation level
39    if ( 'yes' === enr_frontend_params.hide_variable_limited_notice && $( 'form.variations_form' ).length && $( 'form.variations_form' ).find( '.limited-subscription-notice' ).length ) {
40        $( 'form.variations_form' ).find( '.limited-subscription-notice' ).hide();
41    }
42
43    function maybeProcessSwitchRequest() {
44        if ( window.location.href.indexOf( 'switch-subscription' ) != - 1 && window.location.href.indexOf( 'item' ) != - 1 ) {
45            $( '.product form.cart' ).prop( 'action', '' );
46        }
47    }
48
49    /**
50     * Handle product page subscribe events.
51     */
52    var wcs_variations_form = {
53        variationForm : $( '.variations_form' ),
54        cartForm : $( 'form.cart' ),
55        init : function() {
56            $( document ).on( 'found_variation.wc-variation-form', this.onFoundVariation );
57            $( document ).on( 'reset_data', this.onResetVariation );
58        },
59        onFoundVariation : function( evt, variation ) {
60            wcs_variations_form.onResetVariation();
61
62            if ( variation.enr_limited_subscription_notice ) {
63                wcs_variations_form.variationForm.find( '.woocommerce-variation-add-to-cart' ).after( variation.enr_limited_subscription_notice );
64            }
65
66            if ( variation.enr_resubscribe_link ) {
67                wcs_variations_form.variationForm.find( '.woocommerce-variation-add-to-cart' ).after( variation.enr_resubscribe_link );
68            }
69
70            if ( variation.enr_subscribe_now_form ) {
71                wcs_variations_form.variationForm.find( '.woocommerce-variation-add-to-cart' ).before( variation.enr_subscribe_now_form );
72                wcs_variations_form.variationForm.find( '.single_add_to_cart_button' ).text( variation.enr_single_add_to_cart_text );
73                wcs_variations_form.variationForm.find( '.enr-subscribe-now-wrapper #enr_subscribe_now' ).change();
74            }
75
76            maybeProcessSwitchRequest();
77        },
78        onResetVariation : function() {
79            if ( wcs_variations_form.variationForm.find( '.enr-variation-wrapper' ).length ) {
80                wcs_variations_form.variationForm.find( '.enr-variation-wrapper' ).remove();
81            }
82
83            if ( wcs_variations_form.variationForm.find( '.enr-subscribe-now-wrapper' ).length ) {
84                wcs_variations_form.variationForm.find( '.enr-subscribe-now-wrapper' ).parent().remove();
85            }
86
87            wcs_variations_form.variationForm.find( '.single_add_to_cart_button' ).removeClass( 'enr_single_subscribe_button' ).text( enr_frontend_params.single_add_to_cart_text );
88        },
89    };
90
91    /**
92     * Handle subscribe now events.
93     */
94    var wcs_subscribe_now = {
95        wrapper : $( '.enr-subscribe-now-wrapper' ),
96        init : function() {
97            if ( ! enr_frontend_params.is_user_logged_in && enr_frontend_params.is_checkout && this.wrapper.length > 0 ) {
98                if ( enr_frontend_params.cart_level_subscribed ) {
99                    this.wrapper.find( 'input,select' ).each( function( e, element ) {
100                        $( element ).prop( 'disabled', true );
101                    } );
102                } else {
103                    this.wrapper.hide();
104                }
105                return;
106            }
107
108            $( document ).on( 'change', '#enr_subscribe_now,#enr_subscribe_plans,#enr_subscribe_period,#enr_subscribe_period_interval,#enr_subscribe_length', this.onChange );
109            $( document ).on( 'updated_wc_div, updated_cart_totals', this.mayBeShowForm );
110            $( document ).on( 'enr_update_subscribe_now', this.updateAction );
111
112            if ( this.wrapper.length > 0 ) {
113                this.wrapper.find( '#enr_subscribe_now' ).change();
114                maybeProcessSwitchRequest();
115            }
116        },
117        showForm : function( node ) {
118            var wrapper = node;
119            wrapper = node.closest( '.enr-subscribe-now-wrapper' );
120
121            if ( wrapper.length > 0 ) {
122                if ( wrapper.find( '#enr_subscribe_now' ).is( ':checked' ) ) {
123                    wrapper.find( 'tr:gt(0)' ).slideDown();
124                } else {
125                    wrapper.find( 'tr:gt(0)' ).slideUp();
126                }
127            }
128        },
129        mayBeShowForm : function() {
130            wcs_subscribe_now.showForm( wcs_subscribe_now.wrapper );
131        },
132        onChange : function( event ) {
133            event.preventDefault();
134            $( document ).trigger( 'enr_update_subscribe_now', [ $( event.currentTarget ) ] );
135        },
136        updateAction : function( e, $this, args = {} ) {
137            var refreshed = args.refreshed || false,
138                    $data = {
139                        action : '_enr_subscribe_now',
140                        security : enr_frontend_params.subscribe_now_nonce,
141                        is_switch_request : enr_frontend_params.is_switch_request,
142                        data : $this.closest( '.enr-subscribe-now-wrapper' ).find( ':input[name]' ).serialize(),
143                    };
144
145            $data = $.extend( $data, args );
146
147            wcs_subscribe_now.showForm( $this );
148            block( wcs_subscribe_now.getNode() );
149
150            $.ajax( {
151                type : 'POST',
152                url : enr_frontend_params.ajax_url,
153                data : $data,
154                success : function( response ) {
155                    if ( response.success ) {
156                        $this.closest( response.data.subscribe_wrapper_class ).empty().append( response.data.html );
157                        wcs_subscribe_now.showForm( $this );
158
159                        if ( $( '.single_add_to_cart_button' ).length ) {
160                            if ( '1' !== enr_frontend_params.is_switch_request && $this.closest( '.enr-subscribe-now-wrapper' ).find( '#enr_subscribe_now' ).is( ':checked' ) ) {
161                                $( '.single_add_to_cart_button' ).addClass( 'enr_single_subscribe_button' ).text( enr_frontend_params.subscribe_now_button_text );
162                            } else {
163                                $( '.single_add_to_cart_button' ).removeClass( 'enr_single_subscribe_button' ).text( enr_frontend_params.single_add_to_cart_text );
164                            }
165                        }
166
167                        if ( false === response.data.refresh || true === refreshed ) {
168                            $( document.body ).trigger( 'update_checkout' );
169
170                            if ( $( '.woocommerce-cart-form' ).length ) {
171                                $( document.body ).trigger( 'wc_update_cart' );
172                            }
173                        } else {
174                            $( document ).trigger( 'enr_update_subscribe_now', [ $this, { refreshed : true } ] );
175                        }
176
177                        $( document.body ).trigger( 'enr_subscribe_form_submitted_success' );
178                    }
179                },
180                complete : function() {
181                    unblock( wcs_subscribe_now.getNode() );
182                }
183            } );
184            return false;
185        },
186        getNode : function() {
187            if ( $( '.woocommerce-cart-form' ).length ) {
188                return $( 'div.cart_totals' );
189            } else if ( $( '.woocommerce-checkout' ).length ) {
190                return $( '.woocommerce-checkout-payment, .woocommerce-checkout-review-order-table' ).closest( 'form' );
191            } else {
192                return $( '.enr-subscribe-now-wrapper' );
193            }
194        },
195    };
196
197    wcs_variations_form.init();
198    wcs_subscribe_now.init();
199} );

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.