1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3/******/ // The require scope 4/******/ var __webpack_require__ = {}; 5/******/ 6/************************************************************************/ 7/******/ /* webpack/runtime/compat get default export */ 8/******/ (() => { 9/******/ // getDefaultExport function for compatibility with non-harmony modules 10/******/ __webpack_require__.n = (module) => { 11/******/ var getter = module && module.__esModule ? 12/******/ () => (module['default']) : 13/******/ () => (module); 14/******/ __webpack_require__.d(getter, { a: getter }); 15/******/ return getter; 16/******/ }; 17/******/ })(); 18/******/ 19/******/ /* webpack/runtime/define property getters */ 20/******/ (() => { 21/******/ // define getter functions for harmony exports 22/******/ __webpack_require__.d = (exports, definition) => { 23/******/ for(var key in definition) { 24/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 25/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 26/******/ } 27/******/ } 28/******/ }; 29/******/ })(); 30/******/ 31/******/ /* webpack/runtime/hasOwnProperty shorthand */ 32/******/ (() => { 33/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 34/******/ })(); 35/******/ 36/************************************************************************/ 37 38;// external "jQuery" 39const external_jQuery_namespaceObject = window["jQuery"]; 40var external_jQuery_default = /*#__PURE__*/__webpack_require__.n(external_jQuery_namespaceObject); 41;// ./src/js/user-my-account.js 42/*global moment, wc_bookings_user_my_account_params*/ 43 44external_jQuery_default()(document).ready(function ($) { 45 var localTimezone = moment.tz.guess(); 46 var shouldDisplayNotices = false; 47 48 // Confirm booking cancellation. 49 $('.booking-cancel').on('click', 'a.cancel', function () { 50 return window.confirm(wc_bookings_user_my_account_params.cancel_confirmation); 51 }); 52 53 /** 54 * Callback that checks if we should convert or add timezone string to the booking time. 55 * 56 * Since admin does not know what timezone the user is in, it is not possible to set a proper 57 * local timezone for the booking manually create by admin. If timezone conversion is enabled 58 * and the user timezone is different then admin timezone the user will see wrong start and end times. 59 * 60 * Because the booking start and end time are filterable, it's possible for those times to use different 61 * format. We validate the time and only convert times that use the same format as Bookings is using. 62 * 63 * Reference: https://github.com/woocommerce/woocommerce-bookings/issues/2650 64 * 65 * @param {element index } index 66 * @param {jQuery element } element 67 */ 68 var maybeConvertDateTime = function (index, element) { 69 var elementTimezone = $(element).data('timezone'); 70 var elementTime = $(element).text().trim(); 71 if ($(element).data('allDay') === 'yes') { 72 // Don't adjust for day availability type events. 73 return; 74 } 75 if (elementTimezone === localTimezone) { 76 return; 77 } 78 79 // If the format is changed, only add timezone string. 80 if (!moment(elementTime, wc_bookings_user_my_account_params.datetime_format, true).isValid()) { 81 $(element).text(elementTime + ' ' + elementTimezone); 82 shouldDisplayNotices = true; 83 return; 84 } 85 var formattedDate = moment // eslint-disable-line vars-on-top 86 .tz(elementTime, wc_bookings_user_my_account_params.datetime_format, elementTimezone).tz(localTimezone).format(wc_bookings_user_my_account_params.datetime_format); 87 $(element).text(formattedDate); 88 }; 89 if (!wc_bookings_user_my_account_params.timezone_conversion) { 90 // No conversion necessary, don't adjust the time display. 91 return; 92 } 93 if (!localTimezone) { 94 // Local timezone not found. We can't compare the bookings timezone to local - abort! 95 return; 96 } 97 $('.my_account_bookings').find('tbody .booking-start-date').each(maybeConvertDateTime); 98 $('.my_account_bookings').find('tbody .booking-end-date').each(maybeConvertDateTime); 99 $('.woocommerce-order-details').find('.wc-booking-summary-list .booking-start-date').each(maybeConvertDateTime); 100 $('.woocommerce-order-details').find('.wc-booking-summary-list .booking-end-date').each(maybeConvertDateTime); 101 102 // Inform user about the display of timezones for some of the items. 103 if (shouldDisplayNotices) { 104 $('.bookings-my-account-notice').text(wc_bookings_user_my_account_params.timezone_notice + ' ' + localTimezone + '.').show(); 105 } 106}); 107/******/ })() 108; 109//# sourceMappingURL=user-my-account.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.