PageSourceSearch

https://www.samsonite.co.th/on/demandware.static/Sites-MonoSamsoni…/v1790777665174/js/personalisationPanel.js

js samsonite.co.th collected 2026-09-30 14:39:17 UTC 19,540 bytes, 125 lines download raw bytes

vendor: 3,688 bytes, lines 1-88
1/******/ (function(modules) { // webpackBootstrap
2/******/ 	// The module cache
3/******/ 	var installedModules = {};
4/******/
5/******/ 	// The require function
6/******/ 	function __webpack_require__(moduleId) {
7/******/
8/******/ 		// Check if module is in cache
9/******/ 		if(installedModules[moduleId]) {
10/******/ 			return installedModules[moduleId].exports;
11/******/ 		}
12/******/ 		// Create a new module (and put it into the cache)
13/******/ 		var module = installedModules[moduleId] = {
14/******/ 			i: moduleId,
15/******/ 			l: false,
16/******/ 			exports: {}
17/******/ 		};
18/******/
19/******/ 		// Execute the module function
20/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ 		// Flag the module as loaded
23/******/ 		module.l = true;
24/******/
25/******/ 		// Return the exports of the module
26/******/ 		return module.exports;
27/******/ 	}
28/******/
29/******/
30/******/ 	// expose the modules object (__webpack_modules__)
31/******/ 	__webpack_require__.m = modules;
32/******/
33/******/ 	// expose the module cache
34/******/ 	__webpack_require__.c = installedModules;
35/******/
36/******/ 	// define getter function for harmony exports
37/******/ 	__webpack_require__.d = function(exports, name, getter) {
38/******/ 		if(!__webpack_require__.o(exports, name)) {
39/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
40/******/ 		}
41/******/ 	};
42/******/
43/******/ 	// define __esModule on exports
44/******/ 	__webpack_require__.r = function(exports) {
45/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47/******/ 		}
48/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
49/******/ 	};
50/******/
51/******/ 	// create a fake namespace object
52/******/ 	// mode & 1: value is a module id, require it
53/******/ 	// mode & 2: merge all properties of value into the ns
54/******/ 	// mode & 4: return value when already ns object
55/******/ 	// mode & 8|1: behave like require
56/******/ 	__webpack_require__.t = function(value, mode) {
57/******/ 		if(mode & 1) value = __webpack_require__(value);
58/******/ 		if(mode & 8) return value;
59/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60/******/ 		var ns = Object.create(null);
61/******/ 		__webpack_require__.r(ns);
62/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64/******/ 		return ns;
65/******/ 	};
66/******/
67/******/ 	// getDefaultExport function for compatibility with non-harmony modules
68/******/ 	__webpack_require__.n = function(module) {
69/******/ 		var getter = module && module.__esModule ?
70/******/ 			function getDefault() { return module['default']; } :
71/******/ 			function getModuleExports() { return module; };
72/******/ 		__webpack_require__.d(getter, 'a', getter);
73/******/ 		return getter;
74/******/ 	};
75/******/
76/******/ 	// Object.prototype.hasOwnProperty.call
77/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78/******/
79/******/ 	// __webpack_public_path__
80/******/ 	__webpack_require__.p = "";
81/******/
82/******/
83/******/ 	// Load entry module and return exports
84/******/ 	return __webpack_require__(__webpack_require__.s = "./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/personalisationPanel.js");
85/******/ })
86/************************************************************************/
87/******/ ({
88
89/***/ "../storefront-reference-architecture/cartridges/app_storefront_base/cartridge/client/default/js/util.js":
90/*!***************************************************************************************************************!*\
91  !*** ../storefront-reference-architecture/cartridges/app_storefront_base/cartridge/client/default/js/util.js ***!
92  \***************************************************************************************************************/
93/*! no static exports found */
94/***/ (function(module, exports, __webpack_require__) {
95
96"use strict";
97eval("\n\nmodule.exports = function (include) {\n    if (typeof include === 'function') {\n        include();\n    } else if (typeof include === 'object') {\n        Object.keys(include).forEach(function (key) {\n            if (typeof include[key] === 'function') {\n                include[key]();\n            }\n        });\n    }\n};\n\n\n//# sourceURL=webpack:///../storefront-reference-architecture/cartridges/app_storefront_base/cartridge/client/default/js/util.js?");
98
99/***/ }),
100
101/***/ "./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/personalisationPanel.js":
102/*!*****************************************************************************************************!*\
103  !*** ./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/personalisationPanel.js ***!
104  \*****************************************************************************************************/
105/*! no static exports found */
106/***/ (function(module, exports, __webpack_require__) {
107
108"use strict";
109eval("\n\nvar processInclude = __webpack_require__(/*! base/util */ \"../storefront-reference-architecture/cartridges/app_storefront_base/cartridge/client/default/js/util.js\");\n\n$(document).ready(function () {\n    processInclude(__webpack_require__(/*! ./product/personalisationPanel */ \"./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/product/personalisationPanel.js\"));\n});\n\n\n//# sourceURL=webpack:///./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/personalisationPanel.js?");
110
111/***/ }),
112
113/***/ "./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/product/personalisationPanel.js":
114/*!*************************************************************************************************************!*\
115  !*** ./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/product/personalisationPanel.js ***!
116  \*************************************************************************************************************/
117/*! no static exports found */
118/***/ (function(module, exports, __webpack_require__) {
119
120"use strict";
121eval("\n\n/**\n * Show the requested tab pane and mark its tab active.\n * @param {string} tab - 'emboss' or 'engrave'\n */\nfunction activateTab(tab) {\n    var sidebar = $('.monogram-sidebar');\n    sidebar.find('.js-pers-tab').removeClass('is-active');\n    sidebar.find('.js-pers-tab[data-tab=\"' + tab + '\"]').addClass('is-active');\n    sidebar.find('.js-pers-pane-emboss').toggleClass('d-none', tab !== 'emboss');\n    sidebar.find('.js-pers-pane-engrave').toggleClass('d-none', tab !== 'engrave');\n\n    if (tab === 'emboss') {\n        var loader = $('.js-emboss-loader');\n        var embossPane = sidebar.find('.js-pers-pane-emboss');\n        if (loader.length && !embossPane.children().length) {\n            loader.trigger('click');\n        }\n    }\n\n    if (tab === 'engrave') {\n        var engravePane = sidebar.find('.js-pers-pane-engrave');\n        var cartUuid = sidebar.attr('data-cart-uuid');\n        var engraveSource = cartUuid\n            ? $('.js-engraving-' + cartUuid + ' .js-personalise-sidebar .personalise-body')\n            : $('.js-personalise-sidebar-pdp .personalise-body');\n        if (engravePane.length && engraveSource.length && !engravePane.children().length) {\n            engravePane.html(engraveSource.html());\n            engravePane.find('.js-engraving-input-text').trigger('input');\n        }\n    }\n}\n\n/**\n * Open the slide-in panel on a given tab.\n * @param {string} tab - 'emboss' or 'engrave'\n */\nfunction openPanel(tab) {\n    $('html').addClass('sidebar-opened');\n    $('.monogram-sidebar').addClass('active');\n    $('.monogram-overlay').removeClass('d-none');\n    activateTab(tab);\n}\n\n/**\n * Read the cart line-item uuid from an Edit control's product card.\n * @param {Object} el - the clicked Edit element\n * @return {string} the line-item uuid, or an empty string when off the cart\n */\nfunction cartLineUuid(el) {\n    var classes = $(el).closest('.product-info').attr('class') || '';\n    var match = classes.match(/uuid-([a-z0-9]+)/i);\n    return match ? match[1] : '';\n}\n\n/**\n * On the cart, set the active line and show only the tabs available on it (added or addable).\n * @param {Object} el - the clicked add/edit element\n */\nfunction showCartTabs(el) {\n    var info = $(el).closest('.product-info');\n    var hasMonogram = info.find('.product-monogram-card').length > 0 || info.find('.add-monogram-button').length > 0;\n    var hasEngraving = info.find('.product-engraving-card').not('.d-none').length > 0\n        || info.find('.js-add-personalise-cart').length > 0;\n\n    if (info.length && (hasMonogram || hasEngraving)) {\n        var sidebar = $('.monogram-sidebar');\n        sidebar.attr('data-cart-uuid', cartLineUuid(el));\n        sidebar.find('.js-pers-tab[data-tab=\"emboss\"]').toggleClass('d-none', !hasMonogram);\n        sidebar.find('.js-pers-tab[data-tab=\"engrave\"]').toggleClass('d-none', !hasEngraving);\n    }\n}\n\n/**\n * On the cart, show the line's tabs then activate one.\n * @param {Object} editEl - the clicked add/edit element\n * @param {string} tab - the tab to activate\n */\nfunction syncCartTabs(editEl, tab) {\n    showCartTabs(editEl);\n    activateTab(tab);\n}\n\n/**\n * When a cart tab is opened with an empty pane, load that personalisation for the active line.\n * @param {string} tab - the tab that was opened\n */\nfunction loadCartPaneIfEmpty(tab) {\n    var sidebar = $('.monogram-sidebar');\n    var uuid = sidebar.attr('data-cart-uuid');\n\n    if (!uuid) {\n        return;\n    }\n\n    var line = $('.product-info.uuid-' + uuid);\n\n    if (tab === 'engrave' && !sidebar.find('.js-pers-pane-engrave').children().length) {\n        var editEngrave = $('.js-edit-personalise-cart[data-uuid=\"' + uuid + '\"]').first();
121\n        var addEngrave = $('.js-add-personalise-cart[data-uuid=\"' + uuid + '\"]').first();\n        (editEngrave.length ? editEngrave : addEngrave).trigger('click');\n    } else if (tab === 'emboss' && !sidebar.find('.js-pers-pane-emboss').children().length) {\n        var editMonogram = line.find('.edit-monogram').first();\n        var addMonogram = line.find('.add-monogram-button').first();\n        (editMonogram.length ? editMonogram : addMonogram).trigger('click');\n    }\n}\n\n/**\n * Toggle the single CTA / chip state as features are added or removed.\n */\nfunction updatePersonalisationState() {\n    var cta = $('.js-personalise-cta');\n    if (!cta.length) {\n        return;\n    }\n\n    var hasMonogram = String(cta.attr('data-has-monogram')) === 'true';\n    var hasEngraving = String(cta.attr('data-has-engraving')) === 'true';\n    var monogramAdded = $('.monogram-added').length && !$('.monogram-added').hasClass('d-none');\n    var engravingAdded = $('.js-engraving-added, .js-personalise-added').length\n        && !$('.js-engraving-added, .js-personalise-added').hasClass('d-none');\n    var show = true;\n    var label = cta.attr('data-label-default');\n    var tab = hasMonogram ? 'emboss' : 'engrave';\n\n    if (!hasMonogram && !hasEngraving) {\n        cta.addClass('d-none');\n        return;\n    }\n\n    if (!monogramAdded && !engravingAdded) {\n        show = true;\n    } else if (monogramAdded && engravingAdded) {\n        show = false;\n    } else if (monogramAdded && hasEngraving && !engravingAdded) {\n        label = cta.attr('data-label-add-engraving');\n        tab = 'engrave';\n    } else if (engravingAdded && hasMonogram && !monogramAdded) {\n        label = cta.attr('data-label-add-monogram');\n        tab = 'emboss';\n    } else {\n        show = false;\n    }\n\n    cta.toggleClass('d-none', !show);\n    if (show) {\n        cta.attr('data-default-tab', tab);\n        cta.find('.pers-cta-label').html(label);\n    }\n}\n\n/**\n * Reflect a priced tag on the embossing submit button and subtitle (backpackLoopTag tags cost money).\n * @param {string} price - the selected tag's formatted price, or empty for free\n */\nfunction setMonogramSubmitPrice(price) {\n    var sidebar = $('.monogram-sidebar');\n    var button = sidebar.find('.btn-mono-submit, .btn-mono-cart-submit');\n\n    if (button.length) {\n        var withPrice = button.attr('data-label-withprice');\n        var defaultLabel = button.attr('data-label-default');\n\n        if (price && withPrice) {\n            button.text(withPrice.replace('{0}', price));\n        } else if (defaultLabel) {\n            button.text(defaultLabel);\n        }\n    }\n\n    var subtitle = sidebar.find('.pers-subtitle');\n\n    if (subtitle.length) {\n        var pricedSubtitle = subtitle.attr('data-label-priced');\n        var freeSubtitle = subtitle.attr('data-label-free');\n\n        if (price && pricedSubtitle) {\n            subtitle.text(pricedSubtitle);\n        } else if (freeSubtitle) {\n            subtitle.text(freeSubtitle);\n        }\n    }\n}\n\nvar personalisationPanel = {\n    /**\n     * Bind the PDP CTA to open the panel on its default tab\n     */\n    initCta: function () {\n        $('body').on('click', '.js-personalise-cta', function () {\n            var defaultTab = $(this).attr('data-default-tab') || 'emboss';\n            openPanel(defaultTab);\n        });\n    },\n    /**\n     * Bind the tab buttons to switch the active pane\n     */\n    initTabs: function () {\n        $('body').on('click', '.js-pers-tab', function () {\n            var tab = $(this).data('tab');\n            activateTab(tab);\n            loadCartPaneIfEmpty(tab);\n        });\n    },\n    /**\n     * Route a chip's Edit action to the matching tab\n     */\n    initEditRouting: function () {\n        $('body').on('click', '.edit-monogram', function () {\n            syncCartTabs(this, 'emboss');\n        });\n        $('body').on('click', '.js-engraving-edit-pdp', function () {\n            activateTab('engrave');\n        });\n        $('body').on('click', '.js-edit-personalise-cart', function () {\n            syncCartTabs(this, 'engrave');\n        });\n    },\n    /**\n     * On the cart, route the add buttons to the matching tab\n     */\n    init
121CartAddRouting: function () {\n        $('body').on('click', '.js-add-personalise-cart', function () {\n            syncCartTabs(this, 'engrave');\n        });\n        $('body').on('click', '.add-monogram-button', function () {\n            showCartTabs(this);\n        });\n    },\n    /**\n     * Activate the embossing tab once its pane has (re)loaded\n     */\n    initMonogramTabSync: function () {\n        $('body').on('monogram:afterShowPopup', function () {\n            if ($('.monogram-sidebar .js-pers-tab').length) {\n                activateTab('emboss');\n            }\n        });\n    },\n    /**\n     * Show the selected tag's price on the submit button (backpackLoopTag)\n     */\n    initMonogramPrice: function () {\n        $('body').on('click', '.monogram-tag-size', function () {\n            setMonogramSubmitPrice($(this).siblings('.prices').text().trim());\n        });\n        $('body').on('monogram:afterShowPopup', function () {\n            var selectedTag = $('.monogram-sidebar .monogram-tag-size.selected');\n            setMonogramSubmitPrice(selectedTag.length ? selectedTag.siblings('.prices').text().trim() : '');\n        });\n    },\n    /**\n     * Bind \"Clear all\" to reset the embossing selections\n     */\n    initClearAll: function () {\n        $('body').on('click', '.js-monogram-clear', function (e) {\n            e.preventDefault();\n            var pane = $('.monogram-sidebar .js-pers-pane-emboss');\n            pane.find('.monogram-input').val('').removeClass('selected');\n            pane.find('.monogram-input').first().addClass('selected');\n            pane.find('.symbol-action').removeClass('selected');\n            pane.find('.monogram-color').removeClass('selected').first().addClass('selected');\n            pane.find('.monogram-preview-text').html('');\n            pane.find('.patch-item').first().trigger('click');\n            pane.find('.monogram-input').first().trigger('keyup');\n        });\n    },\n    /**\n     * Reset personalisation on variant change: empty the panes, hide the after-add chips, clear the stored values\n     */\n    initVariationReset: function () {\n        $('body').on('product:afterAttributeSelect', function () {\n            $('.monogram-sidebar .js-pers-pane-emboss').empty();\n            $('.monogram-sidebar .js-pers-pane-engrave').empty();\n            $('.monogram-added').addClass('d-none');\n            $('.product-monogram-value').val('');\n            $('.js-engraving-added, .js-personalise-added').addClass('d-none');\n            $('.product-engraving-value, .product-personalise-value').val('');\n        });\n    },\n    /**\n     * Recompute the CTA and panel tabs when the variant changes (mirrors the legacy per-section show/hide).\n     */\n    initVariantAvailability: function () {\n        $('body').on('product:afterAttributeSelect', function (e, response) {\n            var cta = $('.js-personalise-cta');\n            if (!cta.length || !response || !response.data || !response.data.product) {\n                return;\n            }\n            var product = response.data.product;\n            var loader = $('.js-emboss-loader');\n            if (loader.length && product.id) {\n                var loaderUrl = loader.attr('data-url');\n                if (loaderUrl) {\n                    var updatedUrl = loaderUrl.replace(/([?&]pid=)[^&]*/, '$1' + encodeURIComponent(product.id));\n                    loader.attr('data-url', updatedUrl);\n                }\n            }\n            var hasMonogram = Boolean(product.isShowMonogramService || product.monogramType === 'backpackLoopTag');\n            var hasEngraving = Boolean(product.isEngraving);\n            if (!hasEngraving && product.options && product.options.length) {\n                product.options.forEach(function (option) {\n                    if (option.id === 'personalise') {\n                        hasEngraving = true;\n                    }\n                });\n            }\n            cta.attr('data-has-monogram', hasMonogram);\n            cta.attr('data-has-engraving', hasEngraving);\n            $('.monogram-sidebar .js-pers-tab[data-tab=\"emboss\"]').toggleClass('d-none', !hasMonogram);\n            $('.monogram-sidebar .js-pers-tab[data-tab=\"engrave\"]').toggleClass('d-none', !hasEngraving);\n            setTimeout(updatePersonalisationState, 0);\n        });\n    },\n    /**\n     * Recompute the CTA / chip state on personalisation add and remove events\n     */\n    initVisibilityWatchers: function () {\n        updatePersonalisationState();\n        $('body').on('updateMonogramPDP', function () {\n            setTimeout(updatePersonalisationState, 0);\n        });\n        $('body').on('click', '.js-engraving-save, .remove-monogram, .js-remove-personalise-pdp', function () {\n            setTimeout(updatePersonalisationState, 0);\n        });\n    }\n};\n\nmodule.exports = personalisationPanel;\n\n\n//# sourceURL=webpack:///./cartridges/app_custom_samsoniteth_merge/cartridge/client/default/js/product/personalisationPanel.js?"
vendor: 26 bytes, lines 121-125
121);
122
123/***/ })
124
125/******/ });

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.