PageSourceSearch

https://spellmovies.com/wp-content/plugins/ss-woocommerce-myaccoun…/assets/js/sswcmaat.plugin.js?ver=7.1.2

js spellmovies.com collected 2026-09-24 11:40:07 UTC 18,043 bytes, 381 lines download raw bytes

1/**
2 * sswcmaat.plugin.js
3 * Custom JavaScript code required by the plugin
4 *
5 * @version 2.3.0
6 */
7jQuery(function ($) {
8
9    'use strict';
10
11    /**
12     * Adds more link to the tabs when narrow layout
13     *
14     * https://css-tricks.com/container-adapting-tabs-with-more-button/
15     */
16    function sswcmaat_morelink() {
17        var container = $('.woocommerce-MyAccount-navigation'),
18            primary = container.find(' > ul'),
19            primaryHTML = primary.html(),
20            primaryItems = container.find('ul > li:not(.-more)'),
21            secondary,
22            secondaryItems,
23            allItems,
24            moreLi,
25            moreBtn,
26            stopWidth,
27            hiddenItems,
28            primaryWidth;
29
30        container.addClass('--jsfied');
31
32        // insert "more" button and duplicate the list
33        primary.append('<li class="-more"><button type="button" aria-haspopup="true" aria-expanded="false">' + sswcmaat_localize.more_text + '<span class="arrow"></span></button><ul class="-secondary">' + primaryHTML + '</ul></li>');
34
35        $(document).trigger("sswcmaat-morelink-added");
36
37        secondary = container.find('.-secondary');
38        secondaryItems = secondary.find('li');
39        allItems = container.find('li');
40        moreLi = primary.find('.-more');
41        moreBtn = moreLi.find('button');
42
43        moreBtn.on('click', function (e) {
44            e.preventDefault();
45            container.toggleClass('--show-secondary');
46            moreBtn.attr('aria-expanded', container.hasClass('--show-secondary'));
47        });
48
49        function doAdapt() {
50            // Remove hidden class
51            allItems.removeClass('--hidden');
52
53            /* Set the matchMedia */
54            if ($('body').hasClass('tabs-vertical')) {
55                if (window.matchMedia('(min-width: 768px)').matches) {
56                    moreBtn.hide();
57                    container.removeClass('--show-secondary');
58                } else {
59                    moreBtn.show();
60                    container.addClass('--show-secondary');
61                }
62            }
63
64            // hide items that won't fit in the Primary
65            stopWidth = moreBtn.outerWidth();
66            hiddenItems = [];
67            primaryWidth = primary.outerWidth();
68            $.each(primaryItems, function (i) {
69                var item = $(this),
70                    itemWidth = item.outerWidth();
71                if (primaryWidth >= stopWidth + itemWidth) {
72                    stopWidth += itemWidth;
73                } else {
74                    item.addClass('--hidden');
75                    hiddenItems.push(i);
76                }
77            });
78
79            // toggle the visibility of More button and items in Secondary
80            if (!hiddenItems.length) {
81                moreLi.addClass('--hidden');
82                container.removeClass('--show-secondary');
83                moreBtn.attr('aria-expanded', false);
84            } else {
85                $.each(secondaryItems, function (i) {
86                    if (($.inArray(i, hiddenItems) === -1)) {
87                        $(this).addClass('--hidden');
88                    }
89                });
90            }
91        }
92
93        doAdapt();
94
95        $(window).on('resize', function () {
96            doAdapt();
97        });
98
99        // Close submenu when clicking on body
100        $(document).on('click', function () {
101            container.removeClass('--show-secondary');
102            moreBtn.attr('aria-expanded', false);
103        });
104
105        // Stop propagation for more link and submenu
106        $(document).on('click', '.woocommerce-MyAccount-navigation > ul > li.-more > .-secondary, .woocommerce-MyAccount-navigation > ul > li.-more > button', function (e) {
107            e.stopPropagation();
108        });
109    }
110
111    if (!sswcmaat_localize.disable_css && !sswcmaat_localize.disable_more) {
112        sswcmaat_morelink();
113    }
114
115    function sswcmaat() {
116        var requestRunning = false,
117            links = (sswcmaat_localize !== 'undefined' && sswcmaat_localize.internal_links) ? ".woocommerce-MyAccount-navigation > ul > li:not('.woocommerce-MyAccount-navigation-link--back-to-memberships') > a, .myaccount-menu > li > a, .myaccount-submenu li a, a.sswcmaat-ajax-link, .my_account_orders a:not('.track-button, .ywcars_button_refund, .mwb_track_order'), .woocommerce-Addresses a.edit, .woocommerce-order-details a:not('.ywcars_button_refund, .button-primary'), .woocommerce-order-details > p > a:not('.order-again'), .woodmart-my-account-links > div:not('.logout-link') > a" : ".woocommerce-MyAccount-navigation > ul > li:not('.woocommerce-MyAccount-navigation-link--back-to-memberships') > a, .myaccount-menu > li > a, .myaccount-submenu li a, .woodmart-my-account-links > div:not('.logout-link') > a",
118            exclude = (sswcmaat_localize !== 'undefined' && sswcmaat_localize.exclude_links) ? sswcmaat_localize.exclude_links : '',
119            default_container = $('.woocommerce-MyAccount-content'),
120            yith_container = $('#my-account-content'),
121            container = $(yith_container).length ? yith_container : default_container,
122            endpoint = $(yith_container).length ? ' #my-account-content' : ' .woocommerce-MyAccount-content',
123            link_text = $('.woocommerce-MyAccount-navigation > ul > li.is-active > a, .myaccount-menu > li.active > a, .myaccount-submenu > li.active > a').text(),
124            account_nav = $('.woocommerce-MyAccount-navigation > ul, .myaccount-menu, .myaccount-submenu, .woocommerce-MyAccount-navigation .-secondary'),
125            list_items = $(account_nav).find('li'),
126            id = 'sswcmaat-' + $.trim(link_text).replace(/\s/g, "%20"),
127            title_selector = (sswcmaat_localize !== 'undefined' && sswcmaat_localize.title_selector) ? sswcmaat_localize.title_selector : '.entry-title',
128            morelinks;
129
130        morelinks = $('.woocommerce-MyAccount-navigation > ul > li > ul.-secondary li a');
131
132        links = links + ',.woocommerce-MyAccount-navigation > ul > li > ul.-secondary li a';
133
134        if (sswcmaat_localize !== 'undefined' && sswcmaat_localize.extra_links) {
135            links = links + ',' + sswcmaat_localize.extra_links;
136        }
137
138        $(list_items).each(function () {
139            var txt = $(this).find('> a').text(),
140                idd = 'sswcmaat-' + $.trim(txt).replace(/\s/g, "%20");
141            $(this).addClass(idd);
142        });
143        // Set data loaded to true for first tab
144        if (!sswcmaat_localize.disable_cache) {
145            $('.woocommerce-MyAccount-navigation > ul > li.is-active > a, .myaccount-menu > li.active > a, .myaccount-submenu > li.active > a').attr('data-loaded', 'true');
146        }
147        // Update page heading text with current tab
148        if (link_text) {
149            $(title_selector).text(link_text);
150        }
151
152        // Update document title
153        if (sswcmaat_localize.change_doc_title && link_text) {
154            $(document).find('title').html(link_text + ' &ndash; ' + sswcmaat_localize.site_name);
155        }
156
157        // Wrap tab container
158        $(container).wrapInner('<div class="sswcmaat-tab">');
159        $(container).find('.sswcmaat-tab').attr('data-heading', link_text);
160
161        // create dummy holder
162        $(container).append('<div class="sswcmaat-loader">');
163        $('.sswcmaat-tab').attr('id', id);
164
165        if (links.length) {
166            $(document).on('click', links, function (e) {
167                // Do not ajaxify if it is a logout link
168                if ($(this).parent().hasClass('woocommerce-MyAccount-navigation-link--customer-logout')) {
169                    return;
170                }
171                if ($(this).is(exclude)) {
172                    return;
173                }
174                e.preventDefault();
175                var href = $(this).attr('href'),
176                    btn = $(this),
177                    btn_text = $(this).text(),
178                    order_btn_txt = '',
179                    id = 'sswcmaat-' + $.trim(btn_text).replace(/\s/g, "%20"),
180                    to_show = '',
181                    h_text = $(document).find(title_selector).text(),
182                    target_class = '',
183                    woo_info_msgs = '.woocommerce > .woocommerce-message, .woocommerce > .woocommerce-info, .woocommerce > .woocommerce-error';
184
185                /**
186                 * Check if it is a "View order" link
187                 * The text for "View" order button is same in all buttons
188                 * So append a unique order number
189                 */
190                if ($(this).is('.button.view')) {
191                    order_btn_txt = sswcmaat_find_order_number($(this).attr('href'));
192                    id = 'sswcmaat-view-' + order_btn_txt;
193                }
194
195                to_show = $(document.getElementById(id));
196
197                if (!$(btn).data('loaded')) {
198
199                    if (container.length) {
200                        $(container).find('.sswcmaat-tab').hide();
201                        $(container).addClass('sswcmaat-loading');
202                        if (!sswcmaat_localize.custom_preloader && !sswcmaat_localize.ie_check) {
203                            $(container).css({
204                                "background-image": "none"
205                            }).append('<div class="sswcmaat-loading-spinner"/>');
206                        }
207                        if (requestRunning) { // return if an ajax request is already running
208                            return;
209                        }
210                        requestRunning = true;
211
212                        // Remove error messages upon tab click
213                        $(woo_info_msgs).hide();
214                        $('.sswcmaat-tab').find(woo_info_msgs).show();
215                        $('.load-error').remove();
216
217                        $.ajax({
218                            url: href,
219                            timeout: (sswcmaat_localize !== 'undefined' && sswcmaat_localize.ajax_timeout) ? sswcmaat_localize.ajax_timeout : 30000,
220                            error: function (response, jqXHR, textStatus) {
221
222                                var not_loaded = sswcmaat_localize !== 'undefined' ? sswcmaat_localize.loading_error : '';
223
224                                $(container).append('<div class="woocommerce-error load-error">' + not_loaded + ' ' + textStatus + '</div>');
225                                $(container).removeClass('sswcmaat-loading');
226                                /*$(account_nav).find('> li').removeClass('is-active active');
227                                $(account_nav).find('a[href="' + active_li + '"]').parent('li').addClass('is-active active');*/
228                                requestRunning = false;
229                                return;
230
231                            },
232                            success: function (response) {
233
234                                var content = $(response).find(endpoint),
235                                    active_li = $(response).find('.woocommerce-MyAccount-navigation > ul > li.is-active > a, ul.myaccount-menu > li.active > a').attr('href');
236                                    //console.log(active_li);
237                                // Set data loaded to true only if caching enabled
238                                if (!sswcmaat_localize.disable_cache) {
239                                    $(btn).attr('data-loaded', 'true');
240                                }
241                                $(account_nav).find('> li').removeClass('is-active active');
242                                $(account_nav).find('a[href="' + active_li + '"]').parent('li').addClass('is-active active');
243
244                                if ($(this).is('.sswcmaat-ajax-link,.button.view')) {
245                                    target_class = $(this).closest('.sswcmaat-tab').attr('id');
246                                    $(account_nav).find('li.' + target_class).addClass('is-active active');
247                                }
248
249                                h_text = $(response).find(title_selector).text();
250
251                                // Load response into container
252                                $(container).find('.sswcmaat-loader').html($(content).html());
253
254                                // extract loaded content and convert into tab
255                                if ($(yith_container).length) {
256                                    $(container).find('.sswcmaat-loader').addClass('sswcmaat-tab').removeClass('sswcmaat-loader').attr('id', id).attr('data-heading', btn_text);
257                                } else {
258                                    $(container).find('.sswcmaat-loader').addClass('sswcmaat-tab').removeClass('woocommerce-MyAccount-content').removeClass('sswcmaat-loader').attr('id', id).attr('data-heading', btn_text);
259                                }
260
261                                // add dummy holder for next content
262                                $(container).append('<div class="sswcmaat-loader">');
263
264
265                                // Update page heading text
266                                $(title_selector).text(h_text);
267
268                                // Update document title
269                                if (sswcmaat_localize.change_doc_title) {
270                                    $(document).find('title').html(btn_text + ' &ndash; ' + sswcmaat_localize.site_name);
271                                }
272
273                                // Update browser URL
274                                if (sswcmaat_localize !== 'undefined' && !sswcmaat_localize.disable_history && history.pushState) {
275                                    history.pushState({}, '', href);
276                                }
277
278                                requestRunning = false;
279
280                                // Remove loading spinner
281                                $(container).removeClass('sswcmaat-loading');
282
283                                // trigger an event
284                                $(document).trigger("sswcmaat-loaded");
285
286                            } // success
287
288                        });
289                    } // container.length
290                } // if not btn.data('loaded')
291                else {
292
293                    $(account_nav).find('> li').removeClass('is-active active');
294                    $(account_nav).find('a[href="' + href + '"]').parent('li').addClass('is-active active');
295                    if ($(this).is('.sswcmaat-ajax-link,.button.view')) {
296                        target_class = $(this).closest('.sswcmaat-tab').attr('id');
297                        $(account_nav).find('li.' + target_class).addClass('is-active active');
298                    }
299                    // hide all tabs and show the one whose link is clicked
300                    $('.sswcmaat-tab').hide();
301                    $(to_show).show();
302
303                    // Update page heading text
304                    $(title_selector).text(to_show.data('heading'));
305
306                    // Update document title
307                    if (sswcmaat_localize.change_doc_title) {
308                        $(document).find('title').html(to_show.data('heading') + ' &ndash; ' + sswcmaat_localize.site_name);
309                    }
310
311                    // Update browser URL
312                    if (sswcmaat_localize !== 'undefined' && !sswcmaat_localize.disable_history && history.pushState) {
313                        history.pushState({}, '', href);
314                    }
315                }
316            });
317        } // links.length
318    } // sswcmat
319
320    if (sswcmaat_localize !== 'undefined' && !sswcmaat_localize.disable_ajax) {
321        sswcmaat();
322    }
323
324    /**
325     * Add support for YITH WooCommerce order tracking plugin
326     * https://wordpress.org/plugins/yith-woocommerce-order-tracking/
327     *
328     * Re initiates the YITH JavaScript code on sswcmaat-loaded event
329     */
330    $(document).on('sswcmaat-loaded', function () {
331        sswcmaat_yith_tracking_support();
332    });
333
334    function sswcmaat_yith_tracking_support() {
335        if (jQuery().tooltipster) {
336
337            $('.track-button').tooltipster();
338
339            $(document).on('mouseover', 'a.track-button', (function () {
340                $(this).tooltipster('content', $(this).attr('data-title'));
341            }));
342
343            if (typeof ywot !== 'undefined' && 1 !== ywot.p) {
344                $(document).on('click', "a.track-button", (function (e) {
345                    e.preventDefault();
346
347                    $(this).tooltipster('content', $(this).attr('data-title'));
348                }));
349            }
350        }
351
352        var originalDefaultLabel = $("label[for='ywot_tracking_code']").text();
353        var originalDefaultPlaceholder = $("#ywot_tracking_code").attr('placeholder');
354
355        /*
356        Change label and placeholder for BRT_WITH_PACKAGE_NUMBER carrier
357         */
358        jQuery('#ywot_carrier_id').on('change', function () {
359            var label = '';
360            var placeholder = '';
361            var currentCarrier = $(this).val();
362            if (currentCarrier === 'BRT_WITH_PACKAGE_NUMBER') {
363                label = 'Package Number';
364                placeholder = 'Enter package number';
365            } else {
366                label = originalDefaultLabel;
367                placeholder = originalDefaultPlaceholder;
368            }
369            $("label[for='ywot_tracking_code']").text(label);
370            $("#ywot_tracking_code").attr('placeholder', placeholder);
371        });
372    }
373
374    function sswcmaat_find_order_number(href) {
375        var url = href.split("/"),
376            isLastSlash = (url[url.length - 1] == "/") ? true : false,
377            order_num = url[url.length - (isLastSlash ? 2 : 1)];
378        return order_num;
379    }
380
381}); //$

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.