PageSourceSearch

https://www.columbiasportswear.es/on/demandware.static/Sites-Colum…/-/es_ES/v1790387193019/js/notifyMe.js

js columbiasportswear.es collected 2026-09-26 10:35:11 UTC 15,706 bytes, 417 lines download raw bytes

vendor: 3,632 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 = "./.tmp/app_col_eu_core/js/notifyMe.js");
85/******/ })
86/************************************************************************/
87/******/ ({
88
89/***/ "./.tmp/app_col_eu_core/js/components/formValidation.js":
90/*!**************************************************************!*\
91  !*** ./.tmp/app_col_eu_core/js/components/formValidation.js ***!
92  \**************************************************************/
93/*! no static exports found */
94/***/ (function(module, exports, __webpack_require__) {
95
96"use strict";
97
98
99/**
100 * Remove all validation. Should be called every time before revalidating form
101 * @param {element} form - Form to be cleared
102 * @returns {void}
103 */
104function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
105function clearFormErrors(form) {
106  $(form).find('.form-control.is-invalid').removeClass('is-invalid');
107}
108module.exports = function (formElement, payload) {
109  // clear form validation first
110  clearFormErrors(formElement);
111  if (_typeof(payload) === 'object' && payload.fields) {
112    Object.keys(payload.fields).forEach(function (key) {
113      if (payload.fields[key]) {
114        var feedbackElement = $(formElement).find('[name="' + key + '"]').parent().children('.invalid-feedback');
115        if (feedbackElement.length > 0) {
116          if (Array.isArray(payload[key])) {
117            feedbackElement.html(payload.fields[key].join('<br/>'));
118          } else {
119            feedbackElement.html(payload.fields[key]);
120          }
121          feedbackElement.siblings('.form-control').addClass('is-invalid');
122        }
123      }
124    });
125  }
126  if (payload && payload.error) {
127    // Modified to leverage alerts component
128    var $formElement = $(formElement);
129    var $form = $formElement.prop('tagName') === 'FORM' ? $formElement : $formElement.closest('form');
130    $form.alert({
131      content: payload.error.join('<br/>'),
132      theme: 'danger',
133      attachment: 'prepend',
134      autoClose: false
135    });
136  }
137};
138
139/***/ }),
140
141/***/ "./.tmp/app_col_eu_core/js/components/processInclude.js":
142/*!**************************************************************!*\
143  !*** ./.tmp/app_col_eu_core/js/components/processInclude.js ***!
144  \**************************************************************/
145/*! no static exports found */
146/***/ (function(module, exports, __webpack_require__) {
147
148"use strict";
149
150
151function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
152module.exports = function (include) {
153  if (typeof include === 'function') {
154    include();
155  } else if (_typeof(include) === 'object') {
156    Object.keys(include).forEach(function (key) {
157      if (typeof include[key] === 'function') {
158        include[key]();
159      }
160    });
161  }
162};
163
164/***/ }),
165
166/***/ "./.tmp/app_col_eu_core/js/notifyMe.js":
167/*!*********************************************!*\
168  !*** ./.tmp/app_col_eu_core/js/notifyMe.js ***!
169  \*********************************************/
170/*! no static exports found */
171/***/ (function(module, exports, __webpack_require__) {
172
173"use strict";
174
175
176var processInclude = __webpack_require__(/*! ./components/processInclude */ "./.tmp/app_col_eu_core/js/components/processInclude.js");
177$(document).ready(function () {
178  processInclude(__webpack_require__(/*! ./notifyMe/notifyMe */ "./.tmp/app_col_eu_core/js/notifyMe/notifyMe.js"));
179});
180
181/***/ }),
182
183/***/ "./.tmp/app_col_eu_core/js/notifyMe/notifyMe.js":
184/*!******************************************************!*\
185  !*** ./.tmp/app_col_eu_core/js/notifyMe/notifyMe.js ***!
186  \******************************************************/
187/*! no static exports found */
188/***/ (function(module, exports, __webpack_require__) {
189
190"use strict";
191
192
193/**
194 * File includes the ajax call to submit the notifyMe form
195 */
196function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
197function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
198function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
199function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
200function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
201function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
202var formValidation = __webpack_require__(/*! ../components/formValidation */ "./.tmp/app_col_eu_core/js/components/formValidation.js");
203
204/**
205 * Add error message to invalid feedback container
206 * @param  {string} message validation error message
207 * @return {void}
208 */
209function showValidationFeedback(message) {
210  $('.invalid-feedback').text(message).show();
211}
212
213/**
214 * Clears and hides the invalid feedback container
215 * @return {void}
216 */
217function clearValidationFeedback() {
218  $('.is-invalid').removeClass('is-invalid');
219  $('.invalid-feedback').empty().hide();
220}
221
222/**
223 * Validates HTML input fields
224 * @param  {HTMLElement} inputElem HTML input element to be validated
225 * @return {array} is input valid, validation message
226 */
227function checkValidInput(inputElem) {
228  inputElem.setCustomValidity('');
229  if (!inputElem.checkValidity()) {
230    // if input is invalid
231    $(inputElem).addClass('is-invalid').closest('.form-group').addClass('is-invalid');
232    return [false, inputElem.validationMessage];
233  }
234  return [true, ''];
235}
236
237/**
238 * Validates form by checking each input
239 * @return {boolean} is form valid
240 */
241function validateNotifyMeForm() {
242  clearValidationFeedback();
243  if ($('.notifyMeForm')[0] && !$('.notifyMeForm')[0].checkValidity()) {
244    // if form invalid
245    var errors = '';
246    $('.notifyMeForm div.material-text-input').find('input').each(function () {
247      // loop through inputs
248      var _checkValidInput = checkValidInput(this),
249        _checkValidInput2 = _slicedToArray(_checkValidInput, 2),
250        validationResult = _checkValidInput2[0],
251        validationResponse = _checkValidInput2[1];
252      if (!validationResult) {
253        // if input is invalid
254        errors += validationResponse + ' '; // add error message
255      }
256    });
257
258    if (errors) {
259      showValidationFeedback(errors); // display error messages
260      return false;
261    }
262  }
263  return true;
264}
265
266/**
267 * If the form is valid submit it
268 * @return {boolean} is form valid
269 */
270function submitNotifyMeForm() {
271  var isValid = validateNotifyMeForm();
272  if (isValid) {
273    // if form is valid
274    $('.notifyMeForm').trigger('submit');
275    $('.notify-me.btn').hide();
276  }
277  return isValid;
278}
279
280/**
281 * Handles AJAX success response
282 * @param  {Object} data AJAX return data
283 * @return {void}
284 */
285function handleNotifyMeSuccess(data) {
286  // hide velocity message and form (prevent duplicate submission)
287  $('.product__message--velocity').removeClass('product__message--velocity--notifyme').hide();
288  $('.notifyMeForm').hide();
289  // show response message
290  $('.notifyMeFormMessage').html(data.message).show();
291}
292
293/**
294 * Changes form submit to make AJAX call
295 * @return {void}
296 */
297function registerNotifyMeForm() {
298  $(document).on('submit', '.notifyMeForm', function (e) {
299    var form = $(this);
300    e.preventDefault();
301    var url = form.attr('action');
302    if (!this.elements.variantPID.value) {
303      throw new Error('Notify Me: product variant not selected, invalid request.');
304    }
305    $.spinner().start();
306    $.ajax({
307      url: url,
308      type: 'POST',
309      dataType: 'json',
310      data: form.serialize(),
311      success: function success(data) {
312        if (!data.success && data.success === false && 'fields' in data) {
313          formValidation(form, data);
314        } else {
315          handleNotifyMeSuccess(data);
316        }
317        $.spinner().stop();
318      },
319      error: function error() {
320        $.spinner().stop();
321      }
322    });
323  });
324}
325
326/**
327 * Builds the Notify Me form
328 * @param {boolean|undefined} hideForm create notify me form without unhiding it
329 * @return {void}
330 */
331function createNotifyMeForm(hideForm) {
332  var $formContainer = $('.js-notifyMeFormContainer');
333  var $button = $('.notify-me.btn');
334  if ($button.data('cta') === 'showForm') {
335    /**
336     * Instead of remote including the Notify Me form
337     * when the page is loaded, only make the call
338     * when the form is requested (lazy load)
339     */
340    if ($button.data('is-loading')) {
341      return;
342    }
343    var lazyLoadUrl = $button.data('lazy-load-url');
344    if (!hideForm) {
345      // show form
346      $formContainer.show();
347    }
348    if ($formContainer.is(':empty')) {
349      /**
350       * Mark as loading before the call returns so rapid clicks by the user
351       * doesn't load the form multiple times.
352       */
353      $button.data('is-loading', true);
354      $.ajax({
355        url: lazyLoadUrl,
356        method: 'GET',
357        success: function success(responseHTML) {
358          $formContainer.append(responseHTML);
359
360          // form creation event will prep form for validation
361          $formContainer.find('form').trigger('form:created');
362
363          // add variant ID to variant form input
364          $formContainer.find('#variantPID').val($button.data('pid'));
365
366          // hide response message
367          $formContainer.find('.notifyMeFormMessage').empty().hide();
368
369          // register listener for form submission
370          $button.data('cta', 'submitForm');
371          registerNotifyMeForm();
372        },
373        complete: function complete() {
374          $button.data('is-loading', false);
375        }
376      });
377    } else {
378      // show form in case it is hidden
379      $formContainer.find('.notifyMeForm').show();
380      $button.data('cta', 'submitForm');
381    }
382  } else if ($button.data('cta') === 'submitForm') {
383    submitNotifyMeForm();
384  }
385}
386module.exports = {
387  init: function init() {
388    $(document).on('click', '.notify-me.btn', function () {
389      createNotifyMeForm();
390    });
391    $(window).on('product:triggerNotifyMe', function (e, options) {
392      var hideForm = options && options.hideForm;
393      createNotifyMeForm(hideForm);
394    });
395    $(document).on('change blur', '.notifyMeForm input', function (e) {
396      clearValidationFeedback();
397      var _checkValidInput3 = checkValidInput(this),
398        _checkValidInput4 = _slicedToArray(_checkValidInput3, 2),
399        validationResult = _checkValidInput4[0],
400        validationResponse = _checkValidInput4[1];
401      if (!$(e.target).val()) {
402        $(e.target).closest('.focus-fill').removeClass('focus-fill');
403      }
404      if (!validationResult) {
405        showValidationFeedback(validationResponse);
406      }
407    });
408    $(document).on('focus', '.notifyMeForm input', function (e) {
409      $(e.target).closest('.form-group').addClass('focus-fill');
410    });
411  }
412};
413
414/***/ })
414
415
416/******/ });
417//# sourceMappingURL=notifyMe.js.map

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.