PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
← All changes | assets/js/admin/admin.js +48 -14 2.3.12.3.2 View file →
@@ -1,6 +1,12 @@
1 1 "use strict";
2 2
3 +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
4 +function _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."); }
5 +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6 +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7 +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8 +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
3 9 function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4 10 ;
5 11 (function ($, window, document, undefined) {
6 12 'use strict';
@@ -17,8 +23,14 @@
17 23 if ($(e.target).hasClass('merchant-backup-file') || $(e.target).hasClass('merchant-search-field')) {
18 24 return;
19 25 }
20 26
27 + // Nothing in the preview is a setting. Its controls are there to be played
28 + // with, so a module whose mock-up has working fields cannot dirty the form.
29 + if ($(e.target).closest('.merchant-module-page-preview').length) {
30 + return;
31 + }
32 +
21 33 // The licence key and the module feedback textarea save through their
22 34 // own handlers, so editing them leaves the save bar alone.
23 35 if (!$(e.target).is('.merchant-module-question-answer-textarea, .merchant-license-code-input')) {
24 36 if (!merchant.show_save) {
@@ -486,9 +498,25 @@
486 498 init: function init() {
487 499 this.initiate_datepicker();
488 500 this.events();
489 501 },
502 + // Date() cannot parse the bare 'H:i' a time-only picker stores, so pin it to today.
503 + parseInitialDate: function parseInitialDate(value, fieldOptions) {
504 + if (!value) {
505 + return [];
506 + }
507 + if (fieldOptions.onlyTimepicker && /^\d{1,2}:\d{2}$/.test(value)) {
508 + var _value$split = value.split(':'),
509 + _value$split2 = _slicedToArray(_value$split, 2),
510 + hours = _value$split2[0],
511 + minutes = _value$split2[1];
512 + return [new Date(new Date().setHours(Number(hours), Number(minutes), 0, 0))];
513 + }
514 + var date = new Date(value);
515 + return isNaN(date) ? [] : [date];
516 + },
490 517 initiate_datepicker: function initiate_datepicker() {
518 + var self = this;
491 519 var elements = $('.merchant-module-page-setting-field .merchant-datetime-field');
492 520 if (elements.length === 0) {
493 521 return;
494 522 }
@@ -493,11 +521,12 @@
493 521 return;
494 522 }
495 523 elements.each(function (index) {
496 524 var input = $(this).find('input'),
525 + fieldOptions = $(this).data('options') || {},
497 526 options = {
498 527 locale: JSON.parse(merchant_datepicker_locale),
499 - selectedDates: input.val() ? [new Date(input.val())] : [],
528 + selectedDates: self.parseInitialDate(input.val(), fieldOptions),
500 529 onSelect: function onSelect(_ref) {
501 530 var date = _ref.date,
502 531 formattedDate = _ref.formattedDate,
503 532 datepicker = _ref.datepicker;
@@ -508,23 +537,20 @@
508 537 }
509 538 input.trigger('change.merchant');
510 539 input.trigger('change.merchant-datepicker', [formattedDate, input, options, index]);
511 540 }
512 - },
513 - fieldOptions = $(this).data('options');
541 + };
514 542 // add buttons to fieldOptions
515 543 fieldOptions.buttons = ['clear'];
516 - if (fieldOptions) {
517 - if (fieldOptions.minDate !== undefined && fieldOptions.minDate === 'today') {
518 - fieldOptions.minDate = new Date();
519 - if (fieldOptions.timeZone !== undefined && fieldOptions.timeZone !== '') {
520 - fieldOptions.minDate = new Date(fieldOptions.minDate.toLocaleString('en-US', {
521 - timeZone: fieldOptions.timeZone
522 - }));
523 - }
544 + if (fieldOptions.minDate !== undefined && fieldOptions.minDate === 'today') {
545 + fieldOptions.minDate = new Date();
546 + if (fieldOptions.timeZone !== undefined && fieldOptions.timeZone !== '') {
547 + fieldOptions.minDate = new Date(fieldOptions.minDate.toLocaleString('en-US', {
548 + timeZone: fieldOptions.timeZone
549 + }));
524 550 }
525 - options = Object.assign(options, fieldOptions);
526 551 }
552 + options = Object.assign(options, fieldOptions);
527 553 var datepickerObj = new AirDatepicker(input.getPath(), options);
528 554 input.attr('readonly', true);
529 555 $(document).trigger('initiated.merchant-datepicker', [datepickerObj, input, options, index]);
530 556 });
@@ -2142,9 +2168,9 @@
2142 2168 parent.find('.merchant-selected-products-preview ul').append($(this));
2143 2169 parent.find('.merchant-selections-products-preview').html('').hide();
2144 2170 parent.find('.merchant-search-field').val('').change();
2145 2171 if (oldValue === '') {
2146 - valueField.val($(this).data('id'));
2172 + valueField.val($(this).data('id')).change();
2147 2173 } else {
2148 2174 if (!multiple) {
2149 2175 valueField.val($(this).data('id')).change();
2150 2176 } else {
@@ -2503,9 +2529,17 @@
2503 2529 });
2504 2530 $(document).on('dragenter', '.merchant-upload-button-drag-drop', function (e) {
2505 2531 $(this).closest('.merchant-module-page-setting-field-upload').find('.merchant-upload-button').click();
2506 2532 });
2507 - var initSelectAjax = function initSelectAjax($selectAjax) {
2533 +
2534 + // Callers pass a collection, and reading the source off a collection would give
2535 + // every select the first field's source, so each field is set up on its own.
2536 + var initSelectAjax = function initSelectAjax($selectAjaxFields) {
2537 + $selectAjaxFields.each(function () {
2538 + initSelectAjaxField($(this));
2539 + });
2540 + };
2541 + var initSelectAjaxField = function initSelectAjaxField($selectAjax) {
2508 2542 var $select = $selectAjax.find('select');
2509 2543 var $source = $select.data('source');
2510 2544 var $config = window.merchant_admin_options;
2511 2545 var $object = {