Plugin Directory

Changeset 3325775


Ignore:
Timestamp:
07/10/2025 02:39:09 PM (9 months ago)
Author:
spapril
Message:

v4.0.3

Location:
showpass
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • showpass/trunk/js/showpass-custom.js

    r3310142 r3325775  
    11(function ($, window, document) {
    2 
    32    const getParams = (element) => {
    43        return {
    5             'theme-primary': $(element).attr('data-color') || $('#option_widget_color').val() || '',
    6             'keep-shopping': $(element).attr('data-shopping') || $('#option_keep_shopping').val() || 'true',
    7             'theme-dark': $(element).attr('data-theme') || $('#option_theme_dark').val() || '',
    8             'show-description': $(element).attr('data-show-description') || $('#option_show_widget_description').val() || 'false',
    9             'show-specific-tickets': $(element).attr('data-show-specific-tickets') || ''
    10         }
    11     }
     4            "theme-primary":
     5                $(element).attr("data-color") ||
     6                $("#option_widget_color").val() ||
     7                "",
     8            "keep-shopping":
     9                $(element).attr("data-shopping") ||
     10                $("#option_keep_shopping").val() ||
     11                "true",
     12            "theme-dark":
     13                $(element).attr("data-theme") ||
     14                $("#option_theme_dark").val() ||
     15                "",
     16            "show-description":
     17                $(element).attr("data-show-description") ||
     18                $("#option_show_widget_description").val() ||
     19                "false",
     20            "show-specific-tickets":
     21                $(element).attr("data-show-specific-tickets") || "",
     22        };
     23    };
    1224
    1325    /**
     
    2840    }
    2941
    30     function init () {
    31         $(window).on('load', function () {
    32 
    33             showpass.tickets.addCartCountListener(function(count) {
    34                 let html = '';
     42    function init() {
     43        $(window).on("load", function () {
     44            showpass.tickets.addCartCountListener(function (count) {
     45                let html = "";
    3546                if (count > 0) {
    36                     html = 'Shopping Cart (' + count + ')';
    37                     Cookies.set('cart', html);
    38                     $('.showpass-cart-button span').html(html);
     47                    html = "Shopping Cart (" + count + ")";
     48                    Cookies.set("cart", html);
     49                    $(".showpass-cart-button span").html(html);
    3950                } else {
    40                     html = 'Shopping Cart';
    41                     Cookies.set('cart', html);
    42                     $('.showpass-cart-button span').html(html);
     51                    html = "Shopping Cart";
     52                    Cookies.set("cart", html);
     53                    $(".showpass-cart-button span").html(html);
    4354                }
    4455            });
     
    4758            function getQueryStrings() {
    4859                let assoc = {};
    49                 let decode = function(s) {
     60                let decode = function (s) {
    5061                    return decodeURIComponent(s.replace(/\+/g, " "));
    5162                };
    5263                let queryString = location.search.substring(1);
    53                 var keyValues = queryString.split('&');
     64                var keyValues = queryString.split("&");
    5465
    5566                for (var i in keyValues) {
    56                     var key = keyValues[i].split('=');
     67                    var key = keyValues[i].split("=");
    5768                    if (key.length > 1) {
    5869                        assoc[decode(key[0])] = decode(key[1]);
     
    6576            // SET AFFILIATE COOKIE
    6677            if (!$.isEmptyObject(qs) && qs.aff) {
    67                 Cookies.set('affiliate', qs.aff, {
    68                     expires: 7
     78                Cookies.set("affiliate", qs.aff, {
     79                    expires: 7,
    6980                });
    7081            }
     
    7283            // SET AUTO OPEN COOKIE
    7384            if (!$.isEmptyObject(qs) && qs.auto) {
    74                 Cookies.set('auto', qs.auto, {
    75                     expires: 7
     85                Cookies.set("auto", qs.auto, {
     86                    expires: 7,
    7687                });
    7788            }
    78 
    7989        });
    8090
    81         $(document).ready(function() {
     91        $(document).ready(function () {
    8292            function getQueryStrings() {
    8393                var assoc = {};
    84                 var decode = function(s) {
     94                var decode = function (s) {
    8595                    return decodeURIComponent(s.replace(/\+/g, " "));
    8696                };
    8797                var queryString = location.search.substring(1);
    88                 var keyValues = queryString.split('&');
     98                var keyValues = queryString.split("&");
    8999
    90100                for (var i in keyValues) {
    91                     var key = keyValues[i].split('=');
     101                    var key = keyValues[i].split("=");
    92102                    if (key.length > 1) {
    93103                        assoc[decode(key[0])] = decode(key[1]);
     
    102112                var slug = qs.auto;
    103113                let params = {
    104                     'theme-primary': $('#option_widget_color').val(),
    105                     'keep-shopping': $('#option_keep_shopping').val(),
    106                     'show-description': $('#option_show_widget_description').val()
     114                    "theme-primary": $("#option_widget_color").val(),
     115                    "keep-shopping": $("#option_keep_shopping").val(),
     116                    "show-description": $(
     117                        "#option_show_widget_description"
     118                    ).val(),
    107119                };
    108                 setTimeout(function() {
    109                     Cookies.remove('auto');
     120                setTimeout(function () {
     121                    Cookies.remove("auto");
    110122                    showpass.tickets.eventPurchaseWidget(slug, params);
    111123                }, 500);
    112124            }
    113125
    114             $('body').on('click', '.open-calendar-widget', function(e) {
     126            $("body").on("click", ".open-calendar-widget", function (e) {
    115127                e.preventDefault();
    116128
    117                 let id = $(this).attr('data-org-id');
     129                let id = $(this).attr("data-org-id");
    118130                let params = {
    119                     'theme-primary': $(this).attr('data-color') || $('#option_widget_color').val(),
    120                     'keep-shopping': false,
    121                     'tags': $(this).attr('data-tags')
     131                    "theme-primary":
     132                        $(this).attr("data-color") ||
     133                        $("#option_widget_color").val(),
     134                    "keep-shopping": false,
     135                    tags: $(this).attr("data-tags"),
    122136                };
    123137
     
    126140
    127141            function initializeShowpassEmbeddedWidgets() {
    128                 const embeddedCalendarWidget = document.getElementById('showpass-calendar-widget');
    129 
    130                 const embeddedCartWidget = document.getElementById('showpass-cart-widget');
    131                
     142                const embeddedCalendarWidget = document.getElementById(
     143                    "showpass-calendar-widget"
     144                );
     145
     146                const embeddedCartWidget = document.getElementById(
     147                    "showpass-cart-widget"
     148                );
     149
    132150                // Check for embedded event/product/membership widgets - look for elements with IDs starting with 'showpass-'
    133151                // and containing '-widget-'
    134152                const embeddedPurchaseWidgets = [];
    135                 document.querySelectorAll('[id^="showpass-"][id*="-widget-"]').forEach(widget => {
    136                     embeddedPurchaseWidgets.push(widget);
    137                 });
    138 
    139                 if (embeddedCalendarWidget || embeddedPurchaseWidgets.length > 0 || embeddedCartWidget) {
     153                document
     154                    .querySelectorAll('[id^="showpass-"][id*="-widget-"]')
     155                    .forEach((widget) => {
     156                        embeddedPurchaseWidgets.push(widget);
     157                    });
     158
     159                if (
     160                    embeddedCalendarWidget ||
     161                    embeddedPurchaseWidgets.length > 0 ||
     162                    embeddedCartWidget
     163                ) {
    140164                    let script = document.createElement("script");
    141165                    script.type = "text/javascript";
    142                     script.src = 'https://showpass.com/static/dist/sdk.js';
    143 
    144                     let useBeta = $('#option_use_showpass_beta').val();
    145                     let useDemo = $('#option_use_showpass_demo').val();
     166                    script.src = "https://showpass.com/static/dist/sdk.js";
     167
     168                    let useBeta = $("#option_use_showpass_beta").val();
     169                    let useDemo = $("#option_use_showpass_demo").val();
    146170                    if (useBeta) {
    147                         script.src = 'https://beta.showpass.com/static/dist/sdk.js';
     171                        script.src =
     172                            "https://beta.showpass.com/static/dist/sdk.js";
    148173                    } else if (useDemo) {
    149                         script.src = 'https://demo.showpass.com/static/dist/sdk.js';
    150                     }
    151 
    152                     script.onload = function() {
     174                        script.src =
     175                            "https://demo.showpass.com/static/dist/sdk.js";
     176                    }
     177
     178                    script.onload = function () {
    153179                        if (embeddedCalendarWidget) {
    154                             const id = embeddedCalendarWidget.getAttribute('data-org-id');
     180                            const id =
     181                                embeddedCalendarWidget.getAttribute(
     182                                    "data-org-id"
     183                                );
    155184                            let params = {
    156                                 'theme-primary': $('#option_widget_color').val(),
     185                                "theme-primary": $(
     186                                    "#option_widget_color"
     187                                ).val(),
    157188                            };
    158                             if (embeddedCalendarWidget.getAttribute('data-tags')) {
     189                            if (
     190                                embeddedCalendarWidget.getAttribute("data-tags")
     191                            ) {
    159192                                const tags = {
    160                                     tags: embeddedCalendarWidget.getAttribute('data-tags')
     193                                    tags: embeddedCalendarWidget.getAttribute(
     194                                        "data-tags"
     195                                    ),
    161196                                };
    162197                                params = Object.assign(params, tags);
    163198                            }
    164                             showpass.tickets.calendarWidget(id, params, 'showpass-calendar-widget');
     199                            showpass.tickets.calendarWidget(
     200                                id,
     201                                params,
     202                                "showpass-calendar-widget"
     203                            );
    165204                        }
    166205
    167206                        if (embeddedCartWidget) {
    168207                            let params = {
    169                                 'theme-primary': $('#option_widget_color').val() || '',
    170                                 'keep-shopping': $('#option_keep_shopping').val() || 'true',
    171                                 'theme-dark': $('#option_theme_dark').val() || '',
     208                                "theme-primary":
     209                                    $("#option_widget_color").val() || "",
     210                                "keep-shopping":
     211                                    $("#option_keep_shopping").val() || "true",
     212                                "theme-dark":
     213                                    $("#option_theme_dark").val() || "",
    172214                            };
    173                             showpass.tickets.checkoutWidget(params, 'showpass-cart-widget');
     215                            showpass.tickets.checkoutWidget(
     216                                params,
     217                                "showpass-cart-widget"
     218                            );
    174219                        }
    175220
    176221                        if (embeddedPurchaseWidgets.length > 0) {
    177                             embeddedPurchaseWidgets.forEach(function(widget) {
    178                                 const slug = widget.getAttribute('data-slug');
    179                                 const widgetType = widget.getAttribute('data-type') || 'event'; // Default to event if not specified
    180                                
     222                            embeddedPurchaseWidgets.forEach(function (widget) {
     223                                const slug = widget.getAttribute("data-slug");
     224                                const widgetType =
     225                                    widget.getAttribute("data-type") || "event"; // Default to event if not specified
     226
    181227                                let params = getParams(widget);
    182                                
    183                                 if (widgetType === 'product') {
    184                                     showpass.tickets.productPurchaseWidget(slug, params, widget.id);
    185                                 } else if (widgetType === 'membership') {
    186                                     showpass.tickets.membershipPurchaseWidget(slug, params, widget.id);
     228
     229                                if (widgetType === "product") {
     230                                    showpass.tickets.productPurchaseWidget(
     231                                        slug,
     232                                        params,
     233                                        widget.id
     234                                    );
     235                                } else if (widgetType === "membership") {
     236                                    showpass.tickets.membershipPurchaseWidget(
     237                                        slug,
     238                                        params,
     239                                        widget.id
     240                                    );
    187241                                } else {
    188242                                    // Default to event widget
    189                                     showpass.tickets.eventPurchaseWidget(slug, params, widget.id);
     243                                    showpass.tickets.eventPurchaseWidget(
     244                                        slug,
     245                                        params,
     246                                        widget.id
     247                                    );
    190248                                }
    191249                            });
     
    199257
    200258            const openShowpassWidget = (slug, params, widgetType) => {
    201                 if (widgetType === 'product') {
     259                if (widgetType === "product") {
    202260                    showpass.tickets.productPurchaseWidget(slug, params);
    203                 } else if (widgetType === 'membership') {
     261                } else if (widgetType === "membership") {
    204262                    showpass.tickets.membershipPurchaseWidget(slug, params);
    205263                } else {
     
    207265                    showpass.tickets.eventPurchaseWidget(slug, params);
    208266                }
    209             }
    210 
    211             $('body').on('click', '.open-membership-widget', function(e) {
     267            };
     268
     269            $("body").on("click", ".open-membership-widget", function (e) {
    212270                e.preventDefault();
    213271
    214                 let id = $(this).attr('id');
     272                let id = $(this).attr("id");
    215273                let params = getParams(this);
    216274
    217                 if ($(this).attr('data-tracking')) {
    218                     params['tracking-id'] = $(this).attr('data-tracking');
     275                if ($(this).attr("data-tracking")) {
     276                    params["tracking-id"] = $(this).attr("data-tracking");
    219277                }
    220278
    221279                // Overwrite tracking-id if set in URL
    222                 if (Cookies.get('affiliate')) {
    223                     params['tracking-id'] = Cookies.get('affiliate');
    224                 }
    225 
    226                 openShowpassWidget(id, params, 'membership');
    227             });
    228 
    229             $('body').on('click', '.open-ticket-widget', function (e) {
     280                if (Cookies.get("affiliate")) {
     281                    params["tracking-id"] = Cookies.get("affiliate");
     282                }
     283
     284                openShowpassWidget(id, params, "membership");
     285            });
     286
     287            $("body").on("click", ".open-ticket-widget", function (e) {
    230288                e.preventDefault();
    231289
    232                 let slug = $(this).attr('id');
     290                let slug = $(this).attr("id");
    233291                let params = getParams(this);
    234292
    235                 if ($(this).attr('data-tracking')) {
    236                     params['tracking-id'] = $(this).attr('data-tracking');
     293                if ($(this).attr("data-tracking")) {
     294                    params["tracking-id"] = $(this).attr("data-tracking");
    237295                }
    238296
    239297                // Overwrite tracking-id if set in URL
    240                 if (Cookies.get('affiliate')) {
    241                     params['tracking-id'] = Cookies.get('affiliate');
    242                 }
    243 
    244                 openShowpassWidget(slug, params, 'event');
    245             });
    246 
    247             $('body').on('click', '.open-product-widget', function(e) {
     298                if (Cookies.get("affiliate")) {
     299                    params["tracking-id"] = Cookies.get("affiliate");
     300                }
     301
     302                openShowpassWidget(slug, params, "event");
     303            });
     304
     305            $("body").on("click", ".open-product-widget", function (e) {
    248306                e.preventDefault();
    249307
    250                 let id = $(this).attr('id');
     308                let id = $(this).attr("id");
    251309                let params = getParams(this);
    252310
    253                 if ($(this).attr('data-tracking')) {
    254                     params['tracking-id'] = $(this).attr('data-tracking');
     311                if ($(this).attr("data-tracking")) {
     312                    params["tracking-id"] = $(this).attr("data-tracking");
    255313                }
    256314
    257315                // Overwrite tracking-id if set in URL
    258                 if (Cookies.get('affiliate')) {
    259                     params['tracking-id'] = Cookies.get('affiliate');
    260                 }
    261 
    262                 openShowpassWidget(id, params, 'product');
    263             });
    264 
    265             $('body').on('click', 'a[href*="showpass.com"].force-showpass-widget', function(e) {
    266                 e.preventDefault();
    267                
    268                 let slug;
    269                 const href = $(this).attr('href');
    270 
    271                 if (href.includes('/m/')) {
    272                     // For membership URLs
    273                     slug = href.split('/m/')[1];
    274                 } else {
    275                     try {
    276                         const url = new URL(href);
    277                         slug = url.pathname.substring(1); // Remove leading slash
    278                     } catch (e) {
    279                         slug = href.split('.com/')[1];
    280                     }
    281                 }
    282                
    283                 let params = getParams(this);
    284                
    285                 if ($(this).attr('data-tracking')) {
    286                     params['tracking-id'] = $(this).attr('data-tracking');
    287                 }
    288                
    289                 // Overwrite tracking-id if set in URL
    290                 if (Cookies.get('affiliate')) {
    291                     params['tracking-id'] = Cookies.get('affiliate');
    292                 }
    293 
    294                 let widgetType = 'event';
    295                 if (href.includes('/m/')) {
    296                     widgetType = 'membership';
    297                 }
    298 
    299                 if ($(this).attr('data-type')) {
    300                     widgetType = $(this).attr('data-type');
    301                 }
    302                
    303                 openShowpassWidget(slug, params, widgetType);
    304             });
    305 
    306             $('.showpass-cart-button').on('click', function(e) {
     316                if (Cookies.get("affiliate")) {
     317                    params["tracking-id"] = Cookies.get("affiliate");
     318                }
     319
     320                openShowpassWidget(id, params, "product");
     321            });
     322
     323            $("body").on(
     324                "click",
     325                'a[href*="showpass.com"].force-showpass-widget',
     326                function (e) {
     327                    e.preventDefault();
     328
     329                    let slug;
     330                    const href = $(this).attr("href");
     331
     332                    if (href.includes("/m/")) {
     333                        // For membership URLs
     334                        slug = href.split("/m/")[1];
     335                    } else {
     336                        try {
     337                            const url = new URL(href);
     338                            slug = url.pathname.substring(1); // Remove leading slash
     339                        } catch (e) {
     340                            slug = href.split(".com/")[1];
     341                        }
     342                    }
     343
     344                    let params = getParams(this);
     345
     346                    if ($(this).attr("data-tracking")) {
     347                        params["tracking-id"] = $(this).attr("data-tracking");
     348                    }
     349
     350                    // Overwrite tracking-id if set in URL
     351                    if (Cookies.get("affiliate")) {
     352                        params["tracking-id"] = Cookies.get("affiliate");
     353                    }
     354
     355                    let widgetType = "event";
     356                    if (href.includes("/m/")) {
     357                        widgetType = "membership";
     358                    }
     359
     360                    if ($(this).attr("data-type")) {
     361                        widgetType = $(this).attr("data-type");
     362                    }
     363
     364                    openShowpassWidget(slug, params, widgetType);
     365                }
     366            );
     367
     368            $(".showpass-cart-button").on("click", function (e) {
    307369                e.preventDefault();
    308370                let params = getParams(this);
     
    310372            });
    311373
    312             if (Cookies.get('cart')) {
    313                 $('.showpass-cart-button span').html(Cookies.get('cart'));
     374            if (Cookies.get("cart")) {
     375                $(".showpass-cart-button span").html(Cookies.get("cart"));
    314376            }
    315377
    316378            /*
    317             * Related events select box widget toggle
    318             */
    319 
    320             $('.showpass-date-select').on('change', function(e) {
     379             * Related events select box widget toggle
     380             */
     381
     382            $(".showpass-date-select").on("change", function (e) {
    321383                var slug = $(this).val();
    322                 if (slug != '') {
     384                if (slug != "") {
    323385                    let params = getParams(this);
    324386
    325                     if (Cookies.get('affiliate')) {
    326                         params['tracking-id'] = Cookies.get('affiliate');
     387                    if (Cookies.get("affiliate")) {
     388                        params["tracking-id"] = Cookies.get("affiliate");
    327389                    }
    328390
     
    330392                }
    331393            });
    332 
    333394        });
    334395
    335 
    336396        /**
    337          * Shared function to decorate iframe - we default to cookie version because its more reliable
    338          * @param {object} showpass widget iframe object
     397         * Shared function to decorate iframe - handles both cookie-based tracking and query parameters
     398         * @param {HTMLIFrameElement} iFrame - The iframe element to decorate
    339399         */
    340400        const decorateIframe = (iFrame) => {
    341             // For analytics.js (UA)
    342             // We use the linker provided by analytics.js to decorate the iframe src
    343             let gobj = window[window.GoogleAnalyticsObject];
    344             if (gobj) {
    345                 let tracker = gobj.getAll()[0];
    346                 let linker = new window.gaplugins.Linker(tracker);
    347                 iFrame.src = linker.decorate(iFrame.src);
    348             }
    349 
     401            if (!iFrame || !iFrame.src) {
     402                console.warn("Invalid iframe provided to decorateIframe");
     403                return;
     404            }
     405
     406            // Prevent multiple decorations
     407            if (iFrame.dataset.decorated) {
     408                return;
     409            }
     410
     411            let url = new URL(iFrame.src);
     412
     413            // 1. Handle cookie-based tracking (GA and Facebook)
    350414            if (typeof document.cookie === "string" && document.cookie !== "") {
    351                 // Get the _ga from cookies and parse it to extract client_id and session_id.
    352                 // This is used as a fallback for GTM implementations.
     415                // Parse cookies into an object
    353416                let cookie = {};
    354417                document.cookie.split(";").forEach(function (el) {
     
    358421                    cookie[key] = value;
    359422                });
     423
    360424                // Parse the _ga cookie to extract client_id and session_id.
    361                 // A _ga cookie will look something like GA1.1.1194072907.1685136322
     425                // A _ga cookie typically looks like GA1.1.1194072907.1685136322
    362426                const gaCookie = cookie["_ga"];
    363427                if (gaCookie) {
    364                     const client_id = gaCookie.substring(6); // using the example above, this will return "1194072907.1685136322"
     428                    const client_id = gaCookie.substring(6); // Example: "1194072907.1685136322"
    365429                    const session_id = client_id.split(".")[1]; // ["1194072907", "1685136322"]
    366430
     
    369433                        !isNaN(Number(session_id))
    370434                    ) {
    371                         let url = new URL(iFrame.src);
    372435                        url.searchParams.append("parent_client_id", client_id);
    373436                        url.searchParams.append(
     
    375438                            session_id
    376439                        );
    377                         iFrame.src = url.toString();
    378                     }
    379                 }
    380             }
    381 
    382             // Pass the parent page's referrer to our iFrame.
    383             // When the referrer is unavailable (ie. direct visit), the web-app
    384             // should not inject and GA4 defaults to the default behaviour.
     440                    }
     441                }
     442
     443                // Add fbclid from _fbc cookie if present and properly formatted
     444                const fbcCookie = cookie["_fbc"];
     445                if (fbcCookie) {
     446                    const parts = fbcCookie.split(".");
     447                    // Expecting exactly 4 parts; use the last part as fbclid
     448                    if (parts.length === 4) {
     449                        url.searchParams.append("fbclid", parts[3]);
     450                    }
     451                }
     452            }
     453
     454            // 2. Pass the parent page's referrer to our iFrame
    385455            const referrer = document.referrer || "";
    386456            if (referrer) {
    387                 let url = new URL(iFrame.src);
    388457                url.searchParams.append("parent_document_referrer", referrer);
    389                 iFrame.src = url.toString();
    390             }
    391         }
    392 
    393         /*
    394         * Decorate iFrame for GA cross domain tracking
    395         * This only works for pop ups, for embedded calendar we need to use a watcher
    396         */
    397         const mutationObserver = new MutationObserver(function(mutations) {
    398             mutations.forEach(function(mutation) {
    399                 if (mutation.target.className.includes('showpass-widget-body') && document) {
    400 
    401                     let iFrame = document.getElementById('showpass-widget');
    402 
    403                     // if query params already exist, exit
    404                     let queryParams = new URLSearchParams(iFrame.src);
     458            }
     459
     460            // 3. Add current page query parameters
     461            // This is REQUIRED for the checkout widget to work properly with Affirm redirects
     462            const currentUrl = new URL(window.location.href);
     463            const queryParams = currentUrl.searchParams;
     464
     465            if (queryParams.toString()) {
     466                queryParams.forEach((value, key) => {
     467                    // Check if parameter already exists in iframe src to avoid duplicates
     468                    if (!url.searchParams.has(key)) {
     469                        url.searchParams.append(key, value);
     470                    }
     471                });
     472            }
     473
     474            // Update iframe src and mark as decorated
     475            iFrame.src = url.toString();
     476            iFrame.dataset.decorated = "true";
     477
     478            console.log(
     479                "Decorated iframe with tracking parameters:",
     480                url.toString()
     481            );
     482        };
     483
     484        /**
     485         * Sets up observer to watch for ANY Showpass iframe anywhere in the document
     486         * Handles both popup widgets and embedded widgets
     487         */
     488        const setupShowpassIframeObserver = () => {
     489            const documentObserver = new MutationObserver((mutations) => {
     490                mutations.forEach((mutation) => {
     491                    if (mutation.type === "childList") {
     492                        mutation.addedNodes.forEach((node) => {
     493                            if (node.nodeType === Node.ELEMENT_NODE) {
     494                                // Check if the node itself is a Showpass iframe
     495                                if (
     496                                    node.tagName === "IFRAME" &&
     497                                    node.src &&
     498                                    node.src.includes("showpass.com") &&
     499                                    !node.dataset.decorated
     500                                ) {
     501                                    decorateIframe(node);
     502                                }
     503
     504                                // Look for any Showpass iframes within the added node
     505                                if (node.getElementsByTagName) {
     506                                    const iframes = node.getElementsByTagName('iframe');
     507                                    for (let iframe of iframes) {
     508                                        if (iframe.src && iframe.src.includes("showpass.com") && !iframe.dataset.decorated) {
     509                                            decorateIframe(iframe);
     510                                        }
     511                                    }
     512                                }
     513                            }
     514                        });
     515                    }
     516
     517                    // Also watch for src attribute changes on existing iframes
    405518                    if (
    406                         queryParams.get("parent_client_id") ||
    407                         queryParams.get("parent_session_id") ||
    408                         queryParams.get("parent_document_referrer")
     519                        mutation.type === "attributes" &&
     520                        mutation.attributeName === "src"
    409521                    ) {
    410                         return;
    411                     }
    412                     decorateIframe(iFrame);
    413                 }
    414             });
    415         });
    416 
    417         mutationObserver.observe(document.documentElement, { attributes: true });
    418 
    419         let calendarDIV = document.getElementById("showpass-calendar-widget");
    420         if (calendarDIV) {
    421             /** Wrap IFrame for embeded calendar */
    422             function wrapIFrame(iFrame) {
    423                 clearInterval(findIFrameInterval);
    424                 decorateIframe(iFrame);
    425             }
    426             const findIFrameInterval = setInterval(findIFrame, 100);
    427             function findIFrame() {
    428                 let iFrame = document.getElementsByClassName("showpass-widget-iframe");
    429                 if (iFrame && iFrame[0] && iFrame[0].src) {
    430                 wrapIFrame(iFrame[0]);
    431             }
    432         }
     522                        const target = mutation.target;
     523                        if (
     524                            target.tagName === "IFRAME" &&
     525                            target.src &&
     526                            target.src.includes("showpass.com") &&
     527                            !target.dataset.decorated
     528                        ) {
     529                            decorateIframe(target);
     530                        }
     531                    }
     532                });
     533            });
     534
     535            documentObserver.observe(document.body, {
     536                childList: true,
     537                subtree: true,
     538                attributes: true,
     539                attributeFilter: ["src"],
     540            });
     541
     542            return documentObserver;
     543        };
     544
     545        // Initialize the observer automatically
     546        setupShowpassIframeObserver();
    433547    }
    434 }})(jQuery, window, document);
     548})(jQuery, window, document);
  • showpass/trunk/readme.txt

    r3323928 r3325775  
    33Requires at least: 4.9
    44Tested up to: 6.4.3
    5 Stable tag: 4.0.2
     5Stable tag: 4.0.3
    66Requires PHP: 5.4.45
    77Contributors: marcshowpass, spapril, spzachary, cgarrovillosp
     
    5656== Changelog ==
    5757
     58= 4.0.3 =
     59* Fix analytics tracking for embedded widgets
     60
    5861= 4.0.2 =
    5962* Fix file caching
  • showpass/trunk/showpass-wordpress-plugin.php

    r3323927 r3325775  
    66 Description: List events, display event details and products. Use the Showpass purchase widget for on site ticket & product purchases all with easy to use shortcodes. See our git repo here for full documentation. https://github.com/showpass/showpass-wordpress-plugin
    77 Author: Showpass / Up In Code Inc.
    8  Version: 4.0.2
     8 Version: 4.0.3
    99 Author URI: https://www.showpass.com
    1010 */
    1111
    12 define('SHOWPASS_PLUGIN_VERSION', '4.0.2');
     12define('SHOWPASS_PLUGIN_VERSION', '4.0.3');
    1313
    1414if (! defined('ABSPATH')) {
Note: See TracChangeset for help on using the changeset viewer.