PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.5.4
Secure Custom Fields v6.5.4
6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / assets / build / js / acf-input.js
secure-custom-fields / assets / build / js Last commit date
commands 1 year ago pro 1 year ago acf-escaped-html-notice.asset.php 1 year ago acf-escaped-html-notice.js 1 year ago acf-escaped-html-notice.js.map 1 year ago acf-escaped-html-notice.min.asset.php 1 year ago acf-escaped-html-notice.min.js 1 year ago acf-field-group.asset.php 1 year ago acf-field-group.js 1 year ago acf-field-group.js.map 1 year ago acf-field-group.min.asset.php 1 year ago acf-field-group.min.js 1 year ago acf-input.asset.php 1 year ago acf-input.js 1 year ago acf-input.js.map 1 year ago acf-input.min.asset.php 1 year ago acf-input.min.js 1 year ago acf-internal-post-type.asset.php 1 year ago acf-internal-post-type.js 1 year ago acf-internal-post-type.js.map 1 year ago acf-internal-post-type.min.asset.php 1 year ago acf-internal-post-type.min.js 1 year ago acf.asset.php 1 year ago acf.js 1 year ago acf.js.map 1 year ago acf.min.asset.php 1 year ago acf.min.js 1 year ago index.php 1 year ago scf-bindings.asset.php 1 year ago scf-bindings.js 1 year ago scf-bindings.js.map 1 year ago scf-bindings.min.asset.php 1 year ago scf-bindings.min.js 1 year ago
acf-input.js
11601 lines
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/_acf-compatibility.js":
5 /*!*********************************************!*\
6 !*** ./assets/src/js/_acf-compatibility.js ***!
7 \*********************************************/
8 /***/ (() => {
9
10 (function ($, undefined) {
11 /**
12 * acf.newCompatibility
13 *
14 * Inserts a new __proto__ object compatibility layer
15 *
16 * @date 15/2/18
17 * @since ACF 5.6.9
18 *
19 * @param object instance The object to modify.
20 * @param object compatibilty Optional. The compatibility layer.
21 * @return object compatibilty
22 */
23
24 acf.newCompatibility = function (instance, compatibilty) {
25 // defaults
26 compatibilty = compatibilty || {};
27
28 // inherit __proto_-
29 compatibilty.__proto__ = instance.__proto__;
30
31 // inject
32 instance.__proto__ = compatibilty;
33
34 // reference
35 instance.compatibility = compatibilty;
36
37 // return
38 return compatibilty;
39 };
40
41 /**
42 * acf.getCompatibility
43 *
44 * Returns the compatibility layer for a given instance
45 *
46 * @date 13/3/18
47 * @since ACF 5.6.9
48 *
49 * @param object instance The object to look in.
50 * @return object|null compatibility The compatibility object or null on failure.
51 */
52
53 acf.getCompatibility = function (instance) {
54 return instance.compatibility || null;
55 };
56
57 /**
58 * acf (compatibility)
59 *
60 * Compatibility layer for the acf object
61 *
62 * @date 15/2/18
63 * @since ACF 5.6.9
64 *
65 * @param void
66 * @return void
67 */
68
69 var _acf = acf.newCompatibility(acf, {
70 // storage
71 l10n: {},
72 o: {},
73 fields: {},
74 // changed function names
75 update: acf.set,
76 add_action: acf.addAction,
77 remove_action: acf.removeAction,
78 do_action: acf.doAction,
79 add_filter: acf.addFilter,
80 remove_filter: acf.removeFilter,
81 apply_filters: acf.applyFilters,
82 parse_args: acf.parseArgs,
83 disable_el: acf.disable,
84 disable_form: acf.disable,
85 enable_el: acf.enable,
86 enable_form: acf.enable,
87 update_user_setting: acf.updateUserSetting,
88 prepare_for_ajax: acf.prepareForAjax,
89 is_ajax_success: acf.isAjaxSuccess,
90 remove_el: acf.remove,
91 remove_tr: acf.remove,
92 str_replace: acf.strReplace,
93 render_select: acf.renderSelect,
94 get_uniqid: acf.uniqid,
95 serialize_form: acf.serialize,
96 esc_html: acf.strEscape,
97 str_sanitize: acf.strSanitize
98 });
99 _acf._e = function (k1, k2) {
100 // defaults
101 k1 = k1 || '';
102 k2 = k2 || '';
103
104 // compatibility
105 var compatKey = k2 ? k1 + '.' + k2 : k1;
106 var compats = {
107 'image.select': 'Select Image',
108 'image.edit': 'Edit Image',
109 'image.update': 'Update Image'
110 };
111 if (compats[compatKey]) {
112 return acf.__(compats[compatKey]);
113 }
114
115 // try k1
116 var string = this.l10n[k1] || '';
117
118 // try k2
119 if (k2) {
120 string = string[k2] || '';
121 }
122
123 // return
124 return string;
125 };
126 _acf.get_selector = function (s) {
127 // vars
128 var selector = '.acf-field';
129
130 // bail early if no search
131 if (!s) {
132 return selector;
133 }
134
135 // compatibility with object
136 if ($.isPlainObject(s)) {
137 if ($.isEmptyObject(s)) {
138 return selector;
139 } else {
140 for (var k in s) {
141 s = s[k];
142 break;
143 }
144 }
145 }
146
147 // append
148 selector += '-' + s;
149
150 // replace underscores (split/join replaces all and is faster than regex!)
151 selector = acf.strReplace('_', '-', selector);
152
153 // remove potential double up
154 selector = acf.strReplace('field-field-', 'field-', selector);
155
156 // return
157 return selector;
158 };
159 _acf.get_fields = function (s, $el, all) {
160 // args
161 var args = {
162 is: s || '',
163 parent: $el || false,
164 suppressFilters: all || false
165 };
166
167 // change 'field_123' to '.acf-field-123'
168 if (args.is) {
169 args.is = this.get_selector(args.is);
170 }
171
172 // return
173 return acf.findFields(args);
174 };
175 _acf.get_field = function (s, $el) {
176 // get fields
177 var $fields = this.get_fields.apply(this, arguments);
178
179 // return
180 if ($fields.length) {
181 return $fields.first();
182 } else {
183 return false;
184 }
185 };
186 _acf.get_closest_field = function ($el, s) {
187 return $el.closest(this.get_selector(s));
188 };
189 _acf.get_field_wrap = function ($el) {
190 return $el.closest(this.get_selector());
191 };
192 _acf.get_field_key = function ($field) {
193 return $field.data('key');
194 };
195 _acf.get_field_type = function ($field) {
196 return $field.data('type');
197 };
198 _acf.get_data = function ($el, defaults) {
199 return acf.parseArgs($el.data(), defaults);
200 };
201 _acf.maybe_get = function (obj, key, value) {
202 // default
203 if (value === undefined) {
204 value = null;
205 }
206
207 // get keys
208 keys = String(key).split('.');
209
210 // acf.isget
211 for (var i = 0; i < keys.length; i++) {
212 if (!obj.hasOwnProperty(keys[i])) {
213 return value;
214 }
215 obj = obj[keys[i]];
216 }
217 return obj;
218 };
219
220 /**
221 * hooks
222 *
223 * Modify add_action and add_filter functions to add compatibility with changed $field parameter
224 * Using the acf.add_action() or acf.add_filter() functions will interpret new field parameters as jQuery $field
225 *
226 * @date 12/5/18
227 * @since ACF 5.6.9
228 *
229 * @param void
230 * @return void
231 */
232
233 var compatibleArgument = function (arg) {
234 return arg instanceof acf.Field ? arg.$el : arg;
235 };
236 var compatibleArguments = function (args) {
237 return acf.arrayArgs(args).map(compatibleArgument);
238 };
239 var compatibleCallback = function (origCallback) {
240 return function () {
241 // convert to compatible arguments
242 if (arguments.length) {
243 var args = compatibleArguments(arguments);
244
245 // add default argument for 'ready', 'append' and 'load' events
246 } else {
247 var args = [$(document)];
248 }
249
250 // return
251 return origCallback.apply(this, args);
252 };
253 };
254 _acf.add_action = function (action, callback, priority, context) {
255 // handle multiple actions
256 var actions = action.split(' ');
257 var length = actions.length;
258 if (length > 1) {
259 for (var i = 0; i < length; i++) {
260 action = actions[i];
261 _acf.add_action.apply(this, arguments);
262 }
263 return this;
264 }
265
266 // single
267 var callback = compatibleCallback(callback);
268 return acf.addAction.apply(this, arguments);
269 };
270 _acf.add_filter = function (action, callback, priority, context) {
271 var callback = compatibleCallback(callback);
272 return acf.addFilter.apply(this, arguments);
273 };
274
275 /*
276 * acf.model
277 *
278 * This model acts as a scaffold for action.event driven modules
279 *
280 * @type object
281 * @date 8/09/2014
282 * @since ACF 5.0.0
283 *
284 * @param (object)
285 * @return (object)
286 */
287
288 _acf.model = {
289 actions: {},
290 filters: {},
291 events: {},
292 extend: function (args) {
293 // extend
294 var model = $.extend({}, this, args);
295
296 // setup actions
297 $.each(model.actions, function (name, callback) {
298 model._add_action(name, callback);
299 });
300
301 // setup filters
302 $.each(model.filters, function (name, callback) {
303 model._add_filter(name, callback);
304 });
305
306 // setup events
307 $.each(model.events, function (name, callback) {
308 model._add_event(name, callback);
309 });
310
311 // return
312 return model;
313 },
314 _add_action: function (name, callback) {
315 // split
316 var model = this,
317 data = name.split(' ');
318
319 // add missing priority
320 var name = data[0] || '',
321 priority = data[1] || 10;
322
323 // add action
324 acf.add_action(name, model[callback], priority, model);
325 },
326 _add_filter: function (name, callback) {
327 // split
328 var model = this,
329 data = name.split(' ');
330
331 // add missing priority
332 var name = data[0] || '',
333 priority = data[1] || 10;
334
335 // add action
336 acf.add_filter(name, model[callback], priority, model);
337 },
338 _add_event: function (name, callback) {
339 // vars
340 var model = this,
341 i = name.indexOf(' '),
342 event = i > 0 ? name.substr(0, i) : name,
343 selector = i > 0 ? name.substr(i + 1) : '';
344
345 // event
346 var fn = function (e) {
347 // append $el to event object
348 e.$el = $(this);
349
350 // append $field to event object (used in field group)
351 if (acf.field_group) {
352 e.$field = e.$el.closest('.acf-field-object');
353 }
354
355 // event
356 if (typeof model.event === 'function') {
357 e = model.event(e);
358 }
359
360 // callback
361 model[callback].apply(model, arguments);
362 };
363
364 // add event
365 if (selector) {
366 $(document).on(event, selector, fn);
367 } else {
368 $(document).on(event, fn);
369 }
370 },
371 get: function (name, value) {
372 // defaults
373 value = value || null;
374
375 // get
376 if (typeof this[name] !== 'undefined') {
377 value = this[name];
378 }
379
380 // return
381 return value;
382 },
383 set: function (name, value) {
384 // set
385 this[name] = value;
386
387 // function for 3rd party
388 if (typeof this['_set_' + name] === 'function') {
389 this['_set_' + name].apply(this);
390 }
391
392 // return for chaining
393 return this;
394 }
395 };
396
397 /*
398 * field
399 *
400 * This model sets up many of the field's interactions
401 *
402 * @type function
403 * @date 21/02/2014
404 * @since ACF 3.5.1
405 *
406 * @param n/a
407 * @return n/a
408 */
409
410 _acf.field = acf.model.extend({
411 type: '',
412 o: {},
413 $field: null,
414 _add_action: function (name, callback) {
415 // vars
416 var model = this;
417
418 // update name
419 name = name + '_field/type=' + model.type;
420
421 // add action
422 acf.add_action(name, function ($field) {
423 // focus
424 model.set('$field', $field);
425
426 // callback
427 model[callback].apply(model, arguments);
428 });
429 },
430 _add_filter: function (name, callback) {
431 // vars
432 var model = this;
433
434 // update name
435 name = name + '_field/type=' + model.type;
436
437 // add action
438 acf.add_filter(name, function ($field) {
439 // focus
440 model.set('$field', $field);
441
442 // callback
443 model[callback].apply(model, arguments);
444 });
445 },
446 _add_event: function (name, callback) {
447 // vars
448 var model = this,
449 event = name.substr(0, name.indexOf(' ')),
450 selector = name.substr(name.indexOf(' ') + 1),
451 context = acf.get_selector(model.type);
452
453 // add event
454 $(document).on(event, context + ' ' + selector, function (e) {
455 // vars
456 var $el = $(this);
457 var $field = acf.get_closest_field($el, model.type);
458
459 // bail early if no field
460 if (!$field.length) return;
461
462 // focus
463 if (!$field.is(model.$field)) {
464 model.set('$field', $field);
465 }
466
467 // append to event
468 e.$el = $el;
469 e.$field = $field;
470
471 // callback
472 model[callback].apply(model, [e]);
473 });
474 },
475 _set_$field: function () {
476 // callback
477 if (typeof this.focus === 'function') {
478 this.focus();
479 }
480 },
481 // depreciated
482 doFocus: function ($field) {
483 return this.set('$field', $field);
484 }
485 });
486
487 /**
488 * validation
489 *
490 * description
491 *
492 * @date 15/2/18
493 * @since ACF 5.6.9
494 *
495 * @param type $var Description. Default.
496 * @return type Description.
497 */
498
499 var _validation = acf.newCompatibility(acf.validation, {
500 remove_error: function ($field) {
501 acf.getField($field).removeError();
502 },
503 add_warning: function ($field, message) {
504 acf.getField($field).showNotice({
505 text: message,
506 type: 'warning',
507 timeout: 1000
508 });
509 },
510 fetch: acf.validateForm,
511 enableSubmit: acf.enableSubmit,
512 disableSubmit: acf.disableSubmit,
513 showSpinner: acf.showSpinner,
514 hideSpinner: acf.hideSpinner,
515 unlockForm: acf.unlockForm,
516 lockForm: acf.lockForm
517 });
518
519 /**
520 * tooltip
521 *
522 * description
523 *
524 * @date 15/2/18
525 * @since ACF 5.6.9
526 *
527 * @param type $var Description. Default.
528 * @return type Description.
529 */
530
531 _acf.tooltip = {
532 tooltip: function (text, $el) {
533 var tooltip = acf.newTooltip({
534 text: text,
535 target: $el
536 });
537
538 // return
539 return tooltip.$el;
540 },
541 temp: function (text, $el) {
542 var tooltip = acf.newTooltip({
543 text: text,
544 target: $el,
545 timeout: 250
546 });
547 },
548 confirm: function ($el, callback, text, button_y, button_n) {
549 var tooltip = acf.newTooltip({
550 confirm: true,
551 text: text,
552 target: $el,
553 confirm: function () {
554 callback(true);
555 },
556 cancel: function () {
557 callback(false);
558 }
559 });
560 },
561 confirm_remove: function ($el, callback) {
562 var tooltip = acf.newTooltip({
563 confirmRemove: true,
564 target: $el,
565 confirm: function () {
566 callback(true);
567 },
568 cancel: function () {
569 callback(false);
570 }
571 });
572 }
573 };
574
575 /**
576 * tooltip
577 *
578 * description
579 *
580 * @date 15/2/18
581 * @since ACF 5.6.9
582 *
583 * @param type $var Description. Default.
584 * @return type Description.
585 */
586
587 _acf.media = new acf.Model({
588 activeFrame: false,
589 actions: {
590 new_media_popup: 'onNewMediaPopup'
591 },
592 frame: function () {
593 return this.activeFrame;
594 },
595 onNewMediaPopup: function (popup) {
596 this.activeFrame = popup.frame;
597 },
598 popup: function (props) {
599 // update props
600 if (props.mime_types) {
601 props.allowedTypes = props.mime_types;
602 }
603 if (props.id) {
604 props.attachment = props.id;
605 }
606
607 // new
608 var popup = acf.newMediaPopup(props);
609
610 // append
611 /*
612 if( props.selected ) {
613 popup.selected = props.selected;
614 }
615 */
616
617 // return
618 return popup.frame;
619 }
620 });
621
622 /**
623 * Select2
624 *
625 * description
626 *
627 * @date 11/6/18
628 * @since ACF 5.6.9
629 *
630 * @param type $var Description. Default.
631 * @return type Description.
632 */
633
634 _acf.select2 = {
635 init: function ($select, args, $field) {
636 // compatible args
637 if (args.allow_null) {
638 args.allowNull = args.allow_null;
639 }
640 if (args.ajax_action) {
641 args.ajaxAction = args.ajax_action;
642 }
643 if ($field) {
644 args.field = acf.getField($field);
645 }
646
647 // return
648 return acf.newSelect2($select, args);
649 },
650 destroy: function ($select) {
651 return acf.getInstance($select).destroy();
652 }
653 };
654
655 /**
656 * postbox
657 *
658 * description
659 *
660 * @date 11/6/18
661 * @since ACF 5.6.9
662 *
663 * @param type $var Description. Default.
664 * @return type Description.
665 */
666
667 _acf.postbox = {
668 render: function (args) {
669 // compatible args
670 if (args.edit_url) {
671 args.editLink = args.edit_url;
672 }
673 if (args.edit_title) {
674 args.editTitle = args.edit_title;
675 }
676
677 // return
678 return acf.newPostbox(args);
679 }
680 };
681
682 /**
683 * acf.screen
684 *
685 * description
686 *
687 * @date 11/6/18
688 * @since ACF 5.6.9
689 *
690 * @param type $var Description. Default.
691 * @return type Description.
692 */
693
694 acf.newCompatibility(acf.screen, {
695 update: function () {
696 return this.set.apply(this, arguments);
697 },
698 fetch: acf.screen.check
699 });
700 _acf.ajax = acf.screen;
701 })(jQuery);
702
703 /***/ }),
704
705 /***/ "./assets/src/js/_acf-condition-types.js":
706 /*!***********************************************!*\
707 !*** ./assets/src/js/_acf-condition-types.js ***!
708 \***********************************************/
709 /***/ (() => {
710
711 (function ($, undefined) {
712 var __ = acf.__;
713 var parseString = function (val) {
714 return val ? '' + val : '';
715 };
716 var isEqualTo = function (v1, v2) {
717 return parseString(v1).toLowerCase() === parseString(v2).toLowerCase();
718 };
719
720 /**
721 * Checks if rule and selection are equal numbers.
722 *
723 * @param {string} v1 - The rule value to expect.
724 * @param {number|string|Array} v2 - The selected value to compare.
725 * @returns {boolean} Returns true if the values are equal numbers, otherwise returns false.
726 */
727 var isEqualToNumber = function (v1, v2) {
728 if (v2 instanceof Array) {
729 return v2.length === 1 && isEqualToNumber(v1, v2[0]);
730 }
731 return parseFloat(v1) === parseFloat(v2);
732 };
733 var isGreaterThan = function (v1, v2) {
734 return parseFloat(v1) > parseFloat(v2);
735 };
736 var isLessThan = function (v1, v2) {
737 return parseFloat(v1) < parseFloat(v2);
738 };
739 var inArray = function (v1, array) {
740 // cast all values as string
741 array = array.map(function (v2) {
742 return parseString(v2);
743 });
744 return array.indexOf(v1) > -1;
745 };
746 var containsString = function (haystack, needle) {
747 return parseString(haystack).indexOf(parseString(needle)) > -1;
748 };
749 var matchesPattern = function (v1, pattern) {
750 var regexp = new RegExp(parseString(pattern), 'gi');
751 return parseString(v1).match(regexp);
752 };
753 const conditionalSelect2 = function (field, type) {
754 const $select = $('<select></select>');
755 let queryAction = `acf/fields/${type}/query`;
756 if (type === 'user') {
757 queryAction = 'acf/ajax/query_users';
758 }
759 const ajaxData = {
760 action: queryAction,
761 field_key: field.data.key,
762 s: '',
763 type: field.data.key
764 };
765 const typeAttr = acf.escAttr(type);
766 const template = function (selection) {
767 return `<span class="acf-${typeAttr}-select-name acf-conditional-select-name">` + acf.escHtml(selection.text) + '</span>';
768 };
769 const resultsTemplate = function (results) {
770 let classes = results.text.startsWith('- ') ? `acf-${typeAttr}-select-name acf-${typeAttr}-select-sub-item` : `acf-${typeAttr}-select-name`;
771 return '<span class="' + classes + '">' + acf.escHtml(results.text) + '</span>' + `<span class="acf-${typeAttr}-select-id acf-conditional-select-id">` + (results.id ? results.id : '') + '</span>';
772 };
773 const select2Props = {
774 field: false,
775 ajax: true,
776 ajaxAction: queryAction,
777 ajaxData: function (data) {
778 ajaxData.paged = data.paged;
779 ajaxData.s = data.s;
780 ajaxData.conditional_logic = true;
781 ajaxData.include = $.isNumeric(data.s) ? Number(data.s) : '';
782 return acf.prepareForAjax(ajaxData);
783 },
784 escapeMarkup: function (markup) {
785 return acf.escHtml(markup);
786 },
787 templateSelection: template,
788 templateResult: resultsTemplate
789 };
790 $select.data('acfSelect2Props', select2Props);
791 return $select;
792 };
793 /**
794 * Adds condition for Page Link having Page Link equal to.
795 *
796 * @since ACF 6.3
797 */
798 var HasPageLink = acf.Condition.extend({
799 type: 'hasPageLink',
800 operator: '==',
801 label: __('Page is equal to'),
802 fieldTypes: ['page_link'],
803 match: function (rule, field) {
804 return isEqualTo(rule.value, field.val());
805 },
806 choices: function (fieldObject) {
807 return conditionalSelect2(fieldObject, 'page_link');
808 }
809 });
810 acf.registerConditionType(HasPageLink);
811
812 /**
813 * Adds condition for Page Link not equal to.
814 *
815 * @since ACF 6.3
816 */
817 var HasPageLinkNotEqual = acf.Condition.extend({
818 type: 'hasPageLinkNotEqual',
819 operator: '!==',
820 label: __('Page is not equal to'),
821 fieldTypes: ['page_link'],
822 match: function (rule, field) {
823 return !isEqualTo(rule.value, field.val());
824 },
825 choices: function (fieldObject) {
826 return conditionalSelect2(fieldObject, 'page_link');
827 }
828 });
829 acf.registerConditionType(HasPageLinkNotEqual);
830
831 /**
832 * Adds condition for Page Link containing a specific Page Link.
833 *
834 * @since ACF 6.3
835 */
836 var containsPageLink = acf.Condition.extend({
837 type: 'containsPageLink',
838 operator: '==contains',
839 label: __('Pages contain'),
840 fieldTypes: ['page_link'],
841 match: function (rule, field) {
842 const val = field.val();
843 const ruleVal = rule.value;
844 let match = false;
845 if (val instanceof Array) {
846 match = val.includes(ruleVal);
847 } else {
848 match = val === ruleVal;
849 }
850 return match;
851 },
852 choices: function (fieldObject) {
853 return conditionalSelect2(fieldObject, 'page_link');
854 }
855 });
856 acf.registerConditionType(containsPageLink);
857
858 /**
859 * Adds condition for Page Link not containing a specific Page Link.
860 *
861 * @since ACF 6.3
862 */
863 var containsNotPageLink = acf.Condition.extend({
864 type: 'containsNotPageLink',
865 operator: '!=contains',
866 label: __('Pages do not contain'),
867 fieldTypes: ['page_link'],
868 match: function (rule, field) {
869 const val = field.val();
870 const ruleVal = rule.value;
871 let match = true;
872 if (val instanceof Array) {
873 match = !val.includes(ruleVal);
874 } else {
875 match = val !== ruleVal;
876 }
877 return match;
878 },
879 choices: function (fieldObject) {
880 return conditionalSelect2(fieldObject, 'page_link');
881 }
882 });
883 acf.registerConditionType(containsNotPageLink);
884
885 /**
886 * Adds condition for when any page link is selected.
887 *
888 * @since ACF 6.3
889 */
890 var HasAnyPageLink = acf.Condition.extend({
891 type: 'hasAnyPageLink',
892 operator: '!=empty',
893 label: __('Has any page selected'),
894 fieldTypes: ['page_link'],
895 match: function (rule, field) {
896 let val = field.val();
897 if (val instanceof Array) {
898 val = val.length;
899 }
900 return !!val;
901 },
902 choices: function () {
903 return '<input type="text" disabled />';
904 }
905 });
906 acf.registerConditionType(HasAnyPageLink);
907
908 /**
909 * Adds condition for when no page link is selected.
910 *
911 * @since ACF 6.3
912 */
913 var HasNoPageLink = acf.Condition.extend({
914 type: 'hasNoPageLink',
915 operator: '==empty',
916 label: __('Has no page selected'),
917 fieldTypes: ['page_link'],
918 match: function (rule, field) {
919 let val = field.val();
920 if (val instanceof Array) {
921 val = val.length;
922 }
923 return !val;
924 },
925 choices: function () {
926 return '<input type="text" disabled />';
927 }
928 });
929 acf.registerConditionType(HasNoPageLink);
930
931 /**
932 * Adds condition for user field having user equal to.
933 *
934 * @since ACF 6.3
935 */
936 var HasUser = acf.Condition.extend({
937 type: 'hasUser',
938 operator: '==',
939 label: __('User is equal to'),
940 fieldTypes: ['user'],
941 match: function (rule, field) {
942 return isEqualToNumber(rule.value, field.val());
943 },
944 choices: function (fieldObject) {
945 return conditionalSelect2(fieldObject, 'user');
946 }
947 });
948 acf.registerConditionType(HasUser);
949
950 /**
951 * Adds condition for user field having user not equal to.
952 *
953 * @since ACF 6.3
954 */
955 var HasUserNotEqual = acf.Condition.extend({
956 type: 'hasUserNotEqual',
957 operator: '!==',
958 label: __('User is not equal to'),
959 fieldTypes: ['user'],
960 match: function (rule, field) {
961 return !isEqualToNumber(rule.value, field.val());
962 },
963 choices: function (fieldObject) {
964 return conditionalSelect2(fieldObject, 'user');
965 }
966 });
967 acf.registerConditionType(HasUserNotEqual);
968
969 /**
970 * Adds condition for user field containing a specific user.
971 *
972 * @since ACF 6.3
973 */
974 var containsUser = acf.Condition.extend({
975 type: 'containsUser',
976 operator: '==contains',
977 label: __('Users contain'),
978 fieldTypes: ['user'],
979 match: function (rule, field) {
980 const val = field.val();
981 const ruleVal = rule.value;
982 let match = false;
983 if (val instanceof Array) {
984 match = val.includes(ruleVal);
985 } else {
986 match = val === ruleVal;
987 }
988 return match;
989 },
990 choices: function (fieldObject) {
991 return conditionalSelect2(fieldObject, 'user');
992 }
993 });
994 acf.registerConditionType(containsUser);
995
996 /**
997 * Adds condition for user field not containing a specific user.
998 *
999 * @since ACF 6.3
1000 */
1001 var containsNotUser = acf.Condition.extend({
1002 type: 'containsNotUser',
1003 operator: '!=contains',
1004 label: __('Users do not contain'),
1005 fieldTypes: ['user'],
1006 match: function (rule, field) {
1007 const val = field.val();
1008 const ruleVal = rule.value;
1009 let match = true;
1010 if (val instanceof Array) {
1011 match = !val.includes(ruleVal);
1012 } else {
1013 match = !val === ruleVal;
1014 }
1015 },
1016 choices: function (fieldObject) {
1017 return conditionalSelect2(fieldObject, 'user');
1018 }
1019 });
1020 acf.registerConditionType(containsNotUser);
1021
1022 /**
1023 * Adds condition for when any user is selected.
1024 *
1025 * @since ACF 6.3
1026 */
1027 var HasAnyUser = acf.Condition.extend({
1028 type: 'hasAnyUser',
1029 operator: '!=empty',
1030 label: __('Has any user selected'),
1031 fieldTypes: ['user'],
1032 match: function (rule, field) {
1033 let val = field.val();
1034 if (val instanceof Array) {
1035 val = val.length;
1036 }
1037 return !!val;
1038 },
1039 choices: function () {
1040 return '<input type="text" disabled />';
1041 }
1042 });
1043 acf.registerConditionType(HasAnyUser);
1044
1045 /**
1046 * Adds condition for when no user is selected.
1047 *
1048 * @since ACF 6.3
1049 */
1050 var HasNoUser = acf.Condition.extend({
1051 type: 'hasNoUser',
1052 operator: '==empty',
1053 label: __('Has no user selected'),
1054 fieldTypes: ['user'],
1055 match: function (rule, field) {
1056 let val = field.val();
1057 if (val instanceof Array) {
1058 val = val.length;
1059 }
1060 return !val;
1061 },
1062 choices: function () {
1063 return '<input type="text" disabled />';
1064 }
1065 });
1066 acf.registerConditionType(HasNoUser);
1067
1068 /**
1069 * Adds condition for Relationship having Relationship equal to.
1070 *
1071 * @since ACF 6.3
1072 */
1073 var HasRelationship = acf.Condition.extend({
1074 type: 'hasRelationship',
1075 operator: '==',
1076 label: __('Relationship is equal to'),
1077 fieldTypes: ['relationship'],
1078 match: function (rule, field) {
1079 return isEqualToNumber(rule.value, field.val());
1080 },
1081 choices: function (fieldObject) {
1082 return conditionalSelect2(fieldObject, 'relationship');
1083 }
1084 });
1085 acf.registerConditionType(HasRelationship);
1086
1087 /**
1088 * Adds condition for selection having Relationship not equal to.
1089 *
1090 * @since ACF 6.3
1091 */
1092 var HasRelationshipNotEqual = acf.Condition.extend({
1093 type: 'hasRelationshipNotEqual',
1094 operator: '!==',
1095 label: __('Relationship is not equal to'),
1096 fieldTypes: ['relationship'],
1097 match: function (rule, field) {
1098 return !isEqualToNumber(rule.value, field.val());
1099 },
1100 choices: function (fieldObject) {
1101 return conditionalSelect2(fieldObject, 'relationship');
1102 }
1103 });
1104 acf.registerConditionType(HasRelationshipNotEqual);
1105
1106 /**
1107 * Adds condition for Relationship containing a specific Relationship.
1108 *
1109 * @since ACF 6.3
1110 */
1111 var containsRelationship = acf.Condition.extend({
1112 type: 'containsRelationship',
1113 operator: '==contains',
1114 label: __('Relationships contain'),
1115 fieldTypes: ['relationship'],
1116 match: function (rule, field) {
1117 const val = field.val();
1118 // Relationships are stored as strings, use float to compare to field's rule value.
1119 const ruleVal = parseInt(rule.value);
1120 let match = false;
1121 if (val instanceof Array) {
1122 match = val.includes(ruleVal);
1123 }
1124 return match;
1125 },
1126 choices: function (fieldObject) {
1127 return conditionalSelect2(fieldObject, 'relationship');
1128 }
1129 });
1130 acf.registerConditionType(containsRelationship);
1131
1132 /**
1133 * Adds condition for Relationship not containing a specific Relationship.
1134 *
1135 * @since ACF 6.3
1136 */
1137 var containsNotRelationship = acf.Condition.extend({
1138 type: 'containsNotRelationship',
1139 operator: '!=contains',
1140 label: __('Relationships do not contain'),
1141 fieldTypes: ['relationship'],
1142 match: function (rule, field) {
1143 const val = field.val();
1144 // Relationships are stored as strings, use float to compare to field's rule value.
1145 const ruleVal = parseInt(rule.value);
1146 let match = true;
1147 if (val instanceof Array) {
1148 match = !val.includes(ruleVal);
1149 }
1150 return match;
1151 },
1152 choices: function (fieldObject) {
1153 return conditionalSelect2(fieldObject, 'relationship');
1154 }
1155 });
1156 acf.registerConditionType(containsNotRelationship);
1157
1158 /**
1159 * Adds condition for when any relation is selected.
1160 *
1161 * @since ACF 6.3
1162 */
1163 var HasAnyRelation = acf.Condition.extend({
1164 type: 'hasAnyRelation',
1165 operator: '!=empty',
1166 label: __('Has any relationship selected'),
1167 fieldTypes: ['relationship'],
1168 match: function (rule, field) {
1169 let val = field.val();
1170 if (val instanceof Array) {
1171 val = val.length;
1172 }
1173 return !!val;
1174 },
1175 choices: function () {
1176 return '<input type="text" disabled />';
1177 }
1178 });
1179 acf.registerConditionType(HasAnyRelation);
1180
1181 /**
1182 * Adds condition for when no relation is selected.
1183 *
1184 * @since ACF 6.3
1185 */
1186 var HasNoRelation = acf.Condition.extend({
1187 type: 'hasNoRelation',
1188 operator: '==empty',
1189 label: __('Has no relationship selected'),
1190 fieldTypes: ['relationship'],
1191 match: function (rule, field) {
1192 let val = field.val();
1193 if (val instanceof Array) {
1194 val = val.length;
1195 }
1196 return !val;
1197 },
1198 choices: function () {
1199 return '<input type="text" disabled />';
1200 }
1201 });
1202 acf.registerConditionType(HasNoRelation);
1203
1204 /**
1205 * Adds condition for having post equal to.
1206 *
1207 * @since ACF 6.3
1208 */
1209 var HasPostObject = acf.Condition.extend({
1210 type: 'hasPostObject',
1211 operator: '==',
1212 label: __('Post is equal to'),
1213 fieldTypes: ['post_object'],
1214 match: function (rule, field) {
1215 return isEqualToNumber(rule.value, field.val());
1216 },
1217 choices: function (fieldObject) {
1218 return conditionalSelect2(fieldObject, 'post_object');
1219 }
1220 });
1221 acf.registerConditionType(HasPostObject);
1222
1223 /**
1224 * Adds condition for selection having post not equal to.
1225 *
1226 * @since ACF 6.3
1227 */
1228 var HasPostObjectNotEqual = acf.Condition.extend({
1229 type: 'hasPostObjectNotEqual',
1230 operator: '!==',
1231 label: __('Post is not equal to'),
1232 fieldTypes: ['post_object'],
1233 match: function (rule, field) {
1234 return !isEqualToNumber(rule.value, field.val());
1235 },
1236 choices: function (fieldObject) {
1237 return conditionalSelect2(fieldObject, 'post_object');
1238 }
1239 });
1240 acf.registerConditionType(HasPostObjectNotEqual);
1241
1242 /**
1243 * Adds condition for Relationship containing a specific Relationship.
1244 *
1245 * @since ACF 6.3
1246 */
1247 var containsPostObject = acf.Condition.extend({
1248 type: 'containsPostObject',
1249 operator: '==contains',
1250 label: __('Posts contain'),
1251 fieldTypes: ['post_object'],
1252 match: function (rule, field) {
1253 const val = field.val();
1254 const ruleVal = rule.value;
1255 let match = false;
1256 if (val instanceof Array) {
1257 match = val.includes(ruleVal);
1258 } else {
1259 match = val === ruleVal;
1260 }
1261 return match;
1262 },
1263 choices: function (fieldObject) {
1264 return conditionalSelect2(fieldObject, 'post_object');
1265 }
1266 });
1267 acf.registerConditionType(containsPostObject);
1268
1269 /**
1270 * Adds condition for Relationship not containing a specific Relationship.
1271 *
1272 * @since ACF 6.3
1273 */
1274 var containsNotPostObject = acf.Condition.extend({
1275 type: 'containsNotPostObject',
1276 operator: '!=contains',
1277 label: __('Posts do not contain'),
1278 fieldTypes: ['post_object'],
1279 match: function (rule, field) {
1280 const val = field.val();
1281 const ruleVal = rule.value;
1282 let match = true;
1283 if (val instanceof Array) {
1284 match = !val.includes(ruleVal);
1285 } else {
1286 match = val !== ruleVal;
1287 }
1288 return match;
1289 },
1290 choices: function (fieldObject) {
1291 return conditionalSelect2(fieldObject, 'post_object');
1292 }
1293 });
1294 acf.registerConditionType(containsNotPostObject);
1295
1296 /**
1297 * Adds condition for when any post is selected.
1298 *
1299 * @since ACF 6.3
1300 */
1301 var HasAnyPostObject = acf.Condition.extend({
1302 type: 'hasAnyPostObject',
1303 operator: '!=empty',
1304 label: __('Has any post selected'),
1305 fieldTypes: ['post_object'],
1306 match: function (rule, field) {
1307 let val = field.val();
1308 if (val instanceof Array) {
1309 val = val.length;
1310 }
1311 return !!val;
1312 },
1313 choices: function () {
1314 return '<input type="text" disabled />';
1315 }
1316 });
1317 acf.registerConditionType(HasAnyPostObject);
1318
1319 /**
1320 * Adds condition for when no post is selected.
1321 *
1322 * @since ACF 6.3
1323 */
1324 var HasNoPostObject = acf.Condition.extend({
1325 type: 'hasNoPostObject',
1326 operator: '==empty',
1327 label: __('Has no post selected'),
1328 fieldTypes: ['post_object'],
1329 match: function (rule, field) {
1330 let val = field.val();
1331 if (val instanceof Array) {
1332 val = val.length;
1333 }
1334 return !val;
1335 },
1336 choices: function () {
1337 return '<input type="text" disabled />';
1338 }
1339 });
1340 acf.registerConditionType(HasNoPostObject);
1341
1342 /**
1343 * Adds condition for taxonomy having term equal to.
1344 *
1345 * @since ACF 6.3
1346 */
1347 var HasTerm = acf.Condition.extend({
1348 type: 'hasTerm',
1349 operator: '==',
1350 label: __('Term is equal to'),
1351 fieldTypes: ['taxonomy'],
1352 match: function (rule, field) {
1353 return isEqualToNumber(rule.value, field.val());
1354 },
1355 choices: function (fieldObject) {
1356 return conditionalSelect2(fieldObject, 'taxonomy');
1357 }
1358 });
1359 acf.registerConditionType(HasTerm);
1360
1361 /**
1362 * Adds condition for taxonomy having term not equal to.
1363 *
1364 * @since ACF 6.3
1365 */
1366 var hasTermNotEqual = acf.Condition.extend({
1367 type: 'hasTermNotEqual',
1368 operator: '!==',
1369 label: __('Term is not equal to'),
1370 fieldTypes: ['taxonomy'],
1371 match: function (rule, field) {
1372 return !isEqualToNumber(rule.value, field.val());
1373 },
1374 choices: function (fieldObject) {
1375 return conditionalSelect2(fieldObject, 'taxonomy');
1376 }
1377 });
1378 acf.registerConditionType(hasTermNotEqual);
1379
1380 /**
1381 * Adds condition for taxonomy containing a specific term.
1382 *
1383 * @since ACF 6.3
1384 */
1385 var containsTerm = acf.Condition.extend({
1386 type: 'containsTerm',
1387 operator: '==contains',
1388 label: __('Terms contain'),
1389 fieldTypes: ['taxonomy'],
1390 match: function (rule, field) {
1391 const val = field.val();
1392 const ruleVal = rule.value;
1393 let match = false;
1394 if (val instanceof Array) {
1395 match = val.includes(ruleVal);
1396 }
1397 return match;
1398 },
1399 choices: function (fieldObject) {
1400 return conditionalSelect2(fieldObject, 'taxonomy');
1401 }
1402 });
1403 acf.registerConditionType(containsTerm);
1404
1405 /**
1406 * Adds condition for taxonomy not containing a specific term.
1407 *
1408 * @since ACF 6.3
1409 */
1410 var containsNotTerm = acf.Condition.extend({
1411 type: 'containsNotTerm',
1412 operator: '!=contains',
1413 label: __('Terms do not contain'),
1414 fieldTypes: ['taxonomy'],
1415 match: function (rule, field) {
1416 const val = field.val();
1417 const ruleVal = rule.value;
1418 let match = true;
1419 if (val instanceof Array) {
1420 match = !val.includes(ruleVal);
1421 }
1422 return match;
1423 },
1424 choices: function (fieldObject) {
1425 return conditionalSelect2(fieldObject, 'taxonomy');
1426 }
1427 });
1428 acf.registerConditionType(containsNotTerm);
1429
1430 /**
1431 * Adds condition for when any term is selected.
1432 *
1433 * @since ACF 6.3
1434 */
1435 var HasAnyTerm = acf.Condition.extend({
1436 type: 'hasAnyTerm',
1437 operator: '!=empty',
1438 label: __('Has any term selected'),
1439 fieldTypes: ['taxonomy'],
1440 match: function (rule, field) {
1441 let val = field.val();
1442 if (val instanceof Array) {
1443 val = val.length;
1444 }
1445 return !!val;
1446 },
1447 choices: function () {
1448 return '<input type="text" disabled />';
1449 }
1450 });
1451 acf.registerConditionType(HasAnyTerm);
1452
1453 /**
1454 * Adds condition for when no term is selected.
1455 *
1456 * @since ACF 6.3
1457 */
1458 var HasNoTerm = acf.Condition.extend({
1459 type: 'hasNoTerm',
1460 operator: '==empty',
1461 label: __('Has no term selected'),
1462 fieldTypes: ['taxonomy'],
1463 match: function (rule, field) {
1464 let val = field.val();
1465 if (val instanceof Array) {
1466 val = val.length;
1467 }
1468 return !val;
1469 },
1470 choices: function () {
1471 return '<input type="text" disabled />';
1472 }
1473 });
1474 acf.registerConditionType(HasNoTerm);
1475
1476 /**
1477 * hasValue
1478 *
1479 * @date 1/2/18
1480 * @since ACF 5.6.5
1481 *
1482 * @param void
1483 * @return void
1484 */
1485 var HasValue = acf.Condition.extend({
1486 type: 'hasValue',
1487 operator: '!=empty',
1488 label: __('Has any value'),
1489 fieldTypes: ['text', 'textarea', 'number', 'range', 'email', 'url', 'password', 'image', 'file', 'wysiwyg', 'oembed', 'select', 'checkbox', 'radio', 'button_group', 'link', 'google_map', 'date_picker', 'date_time_picker', 'time_picker', 'color_picker', 'icon_picker'],
1490 match: function (rule, field) {
1491 let val = field.val();
1492 if (val instanceof Array) {
1493 val = val.length;
1494 }
1495 return val ? true : false;
1496 },
1497 choices: function (fieldObject) {
1498 return '<input type="text" disabled />';
1499 }
1500 });
1501 acf.registerConditionType(HasValue);
1502
1503 /**
1504 * hasValue
1505 *
1506 * @date 1/2/18
1507 * @since ACF 5.6.5
1508 *
1509 * @param void
1510 * @return void
1511 */
1512 var HasNoValue = HasValue.extend({
1513 type: 'hasNoValue',
1514 operator: '==empty',
1515 label: __('Has no value'),
1516 match: function (rule, field) {
1517 return !HasValue.prototype.match.apply(this, arguments);
1518 }
1519 });
1520 acf.registerConditionType(HasNoValue);
1521
1522 /**
1523 * EqualTo
1524 *
1525 * @date 1/2/18
1526 * @since ACF 5.6.5
1527 *
1528 * @param void
1529 * @return void
1530 */
1531 var EqualTo = acf.Condition.extend({
1532 type: 'equalTo',
1533 operator: '==',
1534 label: __('Value is equal to'),
1535 fieldTypes: ['text', 'textarea', 'number', 'range', 'email', 'url', 'password'],
1536 match: function (rule, field) {
1537 if (acf.isNumeric(rule.value)) {
1538 return isEqualToNumber(rule.value, field.val());
1539 } else {
1540 return isEqualTo(rule.value, field.val());
1541 }
1542 },
1543 choices: function (fieldObject) {
1544 return '<input type="text" />';
1545 }
1546 });
1547 acf.registerConditionType(EqualTo);
1548
1549 /**
1550 * NotEqualTo
1551 *
1552 * @date 1/2/18
1553 * @since ACF 5.6.5
1554 *
1555 * @param void
1556 * @return void
1557 */
1558 var NotEqualTo = EqualTo.extend({
1559 type: 'notEqualTo',
1560 operator: '!=',
1561 label: __('Value is not equal to'),
1562 match: function (rule, field) {
1563 return !EqualTo.prototype.match.apply(this, arguments);
1564 }
1565 });
1566 acf.registerConditionType(NotEqualTo);
1567
1568 /**
1569 * PatternMatch
1570 *
1571 * @date 1/2/18
1572 * @since ACF 5.6.5
1573 *
1574 * @param void
1575 * @return void
1576 */
1577 var PatternMatch = acf.Condition.extend({
1578 type: 'patternMatch',
1579 operator: '==pattern',
1580 label: __('Value matches pattern'),
1581 fieldTypes: ['text', 'textarea', 'email', 'url', 'password', 'wysiwyg'],
1582 match: function (rule, field) {
1583 return matchesPattern(field.val(), rule.value);
1584 },
1585 choices: function (fieldObject) {
1586 return '<input type="text" placeholder="[a-z0-9]" />';
1587 }
1588 });
1589 acf.registerConditionType(PatternMatch);
1590
1591 /**
1592 * Contains
1593 *
1594 * @date 1/2/18
1595 * @since ACF 5.6.5
1596 *
1597 * @param void
1598 * @return void
1599 */
1600 var Contains = acf.Condition.extend({
1601 type: 'contains',
1602 operator: '==contains',
1603 label: __('Value contains'),
1604 fieldTypes: ['text', 'textarea', 'number', 'email', 'url', 'password', 'wysiwyg', 'oembed', 'select'],
1605 match: function (rule, field) {
1606 return containsString(field.val(), rule.value);
1607 },
1608 choices: function (fieldObject) {
1609 return '<input type="text" />';
1610 }
1611 });
1612 acf.registerConditionType(Contains);
1613
1614 /**
1615 * TrueFalseEqualTo
1616 *
1617 * @date 1/2/18
1618 * @since ACF 5.6.5
1619 *
1620 * @param void
1621 * @return void
1622 */
1623 var TrueFalseEqualTo = EqualTo.extend({
1624 type: 'trueFalseEqualTo',
1625 choiceType: 'select',
1626 fieldTypes: ['true_false'],
1627 choices: function (field) {
1628 return [{
1629 id: 1,
1630 text: __('Checked')
1631 }];
1632 }
1633 });
1634 acf.registerConditionType(TrueFalseEqualTo);
1635
1636 /**
1637 * TrueFalseNotEqualTo
1638 *
1639 * @date 1/2/18
1640 * @since ACF 5.6.5
1641 *
1642 * @param void
1643 * @return void
1644 */
1645 var TrueFalseNotEqualTo = NotEqualTo.extend({
1646 type: 'trueFalseNotEqualTo',
1647 choiceType: 'select',
1648 fieldTypes: ['true_false'],
1649 choices: function (field) {
1650 return [{
1651 id: 1,
1652 text: __('Checked')
1653 }];
1654 }
1655 });
1656 acf.registerConditionType(TrueFalseNotEqualTo);
1657
1658 /**
1659 * SelectEqualTo
1660 *
1661 * @date 1/2/18
1662 * @since ACF 5.6.5
1663 *
1664 * @param void
1665 * @return void
1666 */
1667 var SelectEqualTo = acf.Condition.extend({
1668 type: 'selectEqualTo',
1669 operator: '==',
1670 label: __('Value is equal to'),
1671 fieldTypes: ['select', 'checkbox', 'radio', 'button_group'],
1672 match: function (rule, field) {
1673 var val = field.val();
1674 if (val instanceof Array) {
1675 return inArray(rule.value, val);
1676 } else {
1677 return isEqualTo(rule.value, val);
1678 }
1679 },
1680 choices: function (fieldObject) {
1681 // vars
1682 var choices = [];
1683 var lines = fieldObject.$setting('choices textarea').val().split('\n');
1684
1685 // allow null
1686 if (fieldObject.$input('allow_null').prop('checked')) {
1687 choices.push({
1688 id: '',
1689 text: __('Null')
1690 });
1691 }
1692
1693 // loop
1694 lines.map(function (line) {
1695 // split
1696 line = line.split(':');
1697
1698 // default label to value
1699 line[1] = line[1] || line[0];
1700
1701 // append
1702 choices.push({
1703 id: line[0].trim(),
1704 text: line[1].trim()
1705 });
1706 });
1707
1708 // return
1709 return choices;
1710 }
1711 });
1712 acf.registerConditionType(SelectEqualTo);
1713
1714 /**
1715 * SelectNotEqualTo
1716 *
1717 * @date 1/2/18
1718 * @since ACF 5.6.5
1719 *
1720 * @param void
1721 * @return void
1722 */
1723 var SelectNotEqualTo = SelectEqualTo.extend({
1724 type: 'selectNotEqualTo',
1725 operator: '!=',
1726 label: __('Value is not equal to'),
1727 match: function (rule, field) {
1728 return !SelectEqualTo.prototype.match.apply(this, arguments);
1729 }
1730 });
1731 acf.registerConditionType(SelectNotEqualTo);
1732
1733 /**
1734 * GreaterThan
1735 *
1736 * @date 1/2/18
1737 * @since ACF 5.6.5
1738 *
1739 * @param void
1740 * @return void
1741 */
1742 var GreaterThan = acf.Condition.extend({
1743 type: 'greaterThan',
1744 operator: '>',
1745 label: __('Value is greater than'),
1746 fieldTypes: ['number', 'range'],
1747 match: function (rule, field) {
1748 var val = field.val();
1749 if (val instanceof Array) {
1750 val = val.length;
1751 }
1752 return isGreaterThan(val, rule.value);
1753 },
1754 choices: function (fieldObject) {
1755 return '<input type="number" />';
1756 }
1757 });
1758 acf.registerConditionType(GreaterThan);
1759
1760 /**
1761 * LessThan
1762 *
1763 * @date 1/2/18
1764 * @since ACF 5.6.5
1765 *
1766 * @param void
1767 * @return void
1768 */
1769 var LessThan = GreaterThan.extend({
1770 type: 'lessThan',
1771 operator: '<',
1772 label: __('Value is less than'),
1773 match: function (rule, field) {
1774 var val = field.val();
1775 if (val instanceof Array) {
1776 val = val.length;
1777 }
1778 if (val === undefined || val === null || val === false) {
1779 return true;
1780 }
1781 return isLessThan(val, rule.value);
1782 },
1783 choices: function (fieldObject) {
1784 return '<input type="number" />';
1785 }
1786 });
1787 acf.registerConditionType(LessThan);
1788
1789 /**
1790 * SelectedGreaterThan
1791 *
1792 * @date 1/2/18
1793 * @since ACF 5.6.5
1794 *
1795 * @param void
1796 * @return void
1797 */
1798 var SelectionGreaterThan = GreaterThan.extend({
1799 type: 'selectionGreaterThan',
1800 label: __('Selection is greater than'),
1801 fieldTypes: ['checkbox', 'select', 'post_object', 'page_link', 'relationship', 'taxonomy', 'user']
1802 });
1803 acf.registerConditionType(SelectionGreaterThan);
1804
1805 /**
1806 * SelectionLessThan
1807 *
1808 * @date 1/2/18
1809 * @since ACF 5.6.5
1810 *
1811 * @param void
1812 * @return void
1813 */
1814 var SelectionLessThan = LessThan.extend({
1815 type: 'selectionLessThan',
1816 label: __('Selection is less than'),
1817 fieldTypes: ['checkbox', 'select', 'post_object', 'page_link', 'relationship', 'taxonomy', 'user']
1818 });
1819 acf.registerConditionType(SelectionLessThan);
1820 })(jQuery);
1821
1822 /***/ }),
1823
1824 /***/ "./assets/src/js/_acf-condition.js":
1825 /*!*****************************************!*\
1826 !*** ./assets/src/js/_acf-condition.js ***!
1827 \*****************************************/
1828 /***/ (() => {
1829
1830 (function ($, undefined) {
1831 // vars
1832 var storage = [];
1833
1834 /**
1835 * acf.Condition
1836 *
1837 * description
1838 *
1839 * @date 23/3/18
1840 * @since ACF 5.6.9
1841 *
1842 * @param type $var Description. Default.
1843 * @return type Description.
1844 */
1845
1846 acf.Condition = acf.Model.extend({
1847 type: '',
1848 // used for model name
1849 operator: '==',
1850 // rule operator
1851 label: '',
1852 // label shown when editing fields
1853 choiceType: 'input',
1854 // input, select
1855 fieldTypes: [],
1856 // auto connect this conditions with these field types
1857
1858 data: {
1859 conditions: false,
1860 // the parent instance
1861 field: false,
1862 // the field which we query against
1863 rule: {} // the rule [field, operator, value]
1864 },
1865 events: {
1866 change: 'change',
1867 keyup: 'change',
1868 enableField: 'change',
1869 disableField: 'change'
1870 },
1871 setup: function (props) {
1872 $.extend(this.data, props);
1873 },
1874 getEventTarget: function ($el, event) {
1875 return $el || this.get('field').$el;
1876 },
1877 change: function (e, $el) {
1878 this.get('conditions').change(e);
1879 },
1880 match: function (rule, field) {
1881 return false;
1882 },
1883 calculate: function () {
1884 return this.match(this.get('rule'), this.get('field'));
1885 },
1886 choices: function (field) {
1887 return '<input type="text" />';
1888 }
1889 });
1890
1891 /**
1892 * acf.newCondition
1893 *
1894 * description
1895 *
1896 * @date 1/2/18
1897 * @since ACF 5.6.5
1898 *
1899 * @param type $var Description. Default.
1900 * @return type Description.
1901 */
1902
1903 acf.newCondition = function (rule, conditions) {
1904 // currently setting up conditions for fieldX, this field is the 'target'
1905 var target = conditions.get('field');
1906
1907 // use the 'target' to find the 'trigger' field.
1908 // - this field is used to setup the conditional logic events
1909 var field = target.getField(rule.field);
1910
1911 // bail early if no target or no field (possible if field doesn't exist due to HTML error)
1912 if (!target || !field) {
1913 return false;
1914 }
1915
1916 // vars
1917 var args = {
1918 rule: rule,
1919 target: target,
1920 conditions: conditions,
1921 field: field
1922 };
1923
1924 // vars
1925 var fieldType = field.get('type');
1926 var operator = rule.operator;
1927
1928 // get available conditions
1929 var conditionTypes = acf.getConditionTypes({
1930 fieldType: fieldType,
1931 operator: operator
1932 });
1933
1934 // instantiate
1935 var model = conditionTypes[0] || acf.Condition;
1936
1937 // instantiate
1938 var condition = new model(args);
1939
1940 // return
1941 return condition;
1942 };
1943
1944 /**
1945 * mid
1946 *
1947 * Calculates the model ID for a field type
1948 *
1949 * @date 15/12/17
1950 * @since ACF 5.6.5
1951 *
1952 * @param string type
1953 * @return string
1954 */
1955
1956 var modelId = function (type) {
1957 return acf.strPascalCase(type || '') + 'Condition';
1958 };
1959
1960 /**
1961 * acf.registerConditionType
1962 *
1963 * description
1964 *
1965 * @date 1/2/18
1966 * @since ACF 5.6.5
1967 *
1968 * @param type $var Description. Default.
1969 * @return type Description.
1970 */
1971
1972 acf.registerConditionType = function (model) {
1973 // vars
1974 var proto = model.prototype;
1975 var type = proto.type;
1976 var mid = modelId(type);
1977
1978 // store model
1979 acf.models[mid] = model;
1980
1981 // store reference
1982 storage.push(type);
1983 };
1984
1985 /**
1986 * acf.getConditionType
1987 *
1988 * description
1989 *
1990 * @date 1/2/18
1991 * @since ACF 5.6.5
1992 *
1993 * @param type $var Description. Default.
1994 * @return type Description.
1995 */
1996
1997 acf.getConditionType = function (type) {
1998 var mid = modelId(type);
1999 return acf.models[mid] || false;
2000 };
2001
2002 /**
2003 * acf.registerConditionForFieldType
2004 *
2005 * description
2006 *
2007 * @date 1/2/18
2008 * @since ACF 5.6.5
2009 *
2010 * @param type $var Description. Default.
2011 * @return type Description.
2012 */
2013
2014 acf.registerConditionForFieldType = function (conditionType, fieldType) {
2015 // get model
2016 var model = acf.getConditionType(conditionType);
2017
2018 // append
2019 if (model) {
2020 model.prototype.fieldTypes.push(fieldType);
2021 }
2022 };
2023
2024 /**
2025 * acf.getConditionTypes
2026 *
2027 * description
2028 *
2029 * @date 1/2/18
2030 * @since ACF 5.6.5
2031 *
2032 * @param type $var Description. Default.
2033 * @return type Description.
2034 */
2035
2036 acf.getConditionTypes = function (args) {
2037 // defaults
2038 args = acf.parseArgs(args, {
2039 fieldType: '',
2040 operator: ''
2041 });
2042
2043 // clone available types
2044 var types = [];
2045
2046 // loop
2047 storage.map(function (type) {
2048 // vars
2049 var model = acf.getConditionType(type);
2050 var ProtoFieldTypes = model.prototype.fieldTypes;
2051 var ProtoOperator = model.prototype.operator;
2052
2053 // check fieldType
2054 if (args.fieldType && ProtoFieldTypes.indexOf(args.fieldType) === -1) {
2055 return;
2056 }
2057
2058 // check operator
2059 if (args.operator && ProtoOperator !== args.operator) {
2060 return;
2061 }
2062
2063 // append
2064 types.push(model);
2065 });
2066
2067 // return
2068 return types;
2069 };
2070 })(jQuery);
2071
2072 /***/ }),
2073
2074 /***/ "./assets/src/js/_acf-conditions.js":
2075 /*!******************************************!*\
2076 !*** ./assets/src/js/_acf-conditions.js ***!
2077 \******************************************/
2078 /***/ (() => {
2079
2080 (function ($, undefined) {
2081 // vars
2082 var CONTEXT = 'conditional_logic';
2083
2084 /**
2085 * conditionsManager
2086 *
2087 * description
2088 *
2089 * @date 1/2/18
2090 * @since ACF 5.6.5
2091 *
2092 * @param type $var Description. Default.
2093 * @return type Description.
2094 */
2095
2096 var conditionsManager = new acf.Model({
2097 id: 'conditionsManager',
2098 priority: 20,
2099 // run actions later
2100
2101 actions: {
2102 new_field: 'onNewField'
2103 },
2104 onNewField: function (field) {
2105 if (field.has('conditions')) {
2106 field.getConditions().render();
2107 }
2108 }
2109 });
2110
2111 /**
2112 * acf.Field.prototype.getField
2113 *
2114 * Finds a field that is related to another field
2115 *
2116 * @date 1/2/18
2117 * @since ACF 5.6.5
2118 *
2119 * @param type $var Description. Default.
2120 * @return type Description.
2121 */
2122
2123 var getSiblingField = function (field, key) {
2124 // find sibling (very fast)
2125 var fields = acf.getFields({
2126 key: key,
2127 sibling: field.$el,
2128 suppressFilters: true
2129 });
2130
2131 // find sibling-children (fast)
2132 // needed for group fields, accordions, etc
2133 if (!fields.length) {
2134 fields = acf.getFields({
2135 key: key,
2136 parent: field.$el.parent(),
2137 suppressFilters: true
2138 });
2139 }
2140
2141 // Check for fields on other settings tabs (probably less fast).
2142 if (!fields.length && $('.acf-field-settings').length) {
2143 fields = acf.getFields({
2144 key: key,
2145 parent: field.$el.parents('.acf-field-settings:first'),
2146 suppressFilters: true
2147 });
2148 }
2149 if (!fields.length && $('#acf-basic-settings').length) {
2150 fields = acf.getFields({
2151 key: key,
2152 parent: $('#acf-basic-settings'),
2153 suppressFilters: true
2154 });
2155 }
2156
2157 // return
2158 if (fields.length) {
2159 return fields[0];
2160 }
2161 return false;
2162 };
2163 acf.Field.prototype.getField = function (key) {
2164 // get sibling field
2165 var field = getSiblingField(this, key);
2166
2167 // return early
2168 if (field) {
2169 return field;
2170 }
2171
2172 // move up through each parent and try again
2173 var parents = this.parents();
2174 for (var i = 0; i < parents.length; i++) {
2175 // get sibling field
2176 field = getSiblingField(parents[i], key);
2177
2178 // return early
2179 if (field) {
2180 return field;
2181 }
2182 }
2183
2184 // return
2185 return false;
2186 };
2187
2188 /**
2189 * acf.Field.prototype.getConditions
2190 *
2191 * Returns the field's conditions instance
2192 *
2193 * @date 1/2/18
2194 * @since ACF 5.6.5
2195 *
2196 * @param type $var Description. Default.
2197 * @return type Description.
2198 */
2199
2200 acf.Field.prototype.getConditions = function () {
2201 // instantiate
2202 if (!this.conditions) {
2203 this.conditions = new Conditions(this);
2204 }
2205
2206 // return
2207 return this.conditions;
2208 };
2209
2210 /**
2211 * Conditions
2212 *
2213 * description
2214 *
2215 * @date 1/2/18
2216 * @since ACF 5.6.5
2217 *
2218 * @param type $var Description. Default.
2219 * @return type Description.
2220 */
2221 var timeout = false;
2222 var Conditions = acf.Model.extend({
2223 id: 'Conditions',
2224 data: {
2225 field: false,
2226 // The field with "data-conditions" (target).
2227 timeStamp: false,
2228 // Reference used during "change" event.
2229 groups: [] // The groups of condition instances.
2230 },
2231 setup: function (field) {
2232 // data
2233 this.data.field = field;
2234
2235 // vars
2236 var conditions = field.get('conditions');
2237
2238 // detect groups
2239 if (conditions instanceof Array) {
2240 // detect groups
2241 if (conditions[0] instanceof Array) {
2242 // loop
2243 conditions.map(function (rules, i) {
2244 this.addRules(rules, i);
2245 }, this);
2246
2247 // detect rules
2248 } else {
2249 this.addRules(conditions);
2250 }
2251
2252 // detect rule
2253 } else {
2254 this.addRule(conditions);
2255 }
2256 },
2257 change: function (e) {
2258 // this function may be triggered multiple times per event due to multiple condition classes
2259 // compare timestamp to allow only 1 trigger per event
2260 if (this.get('timeStamp') === e.timeStamp) {
2261 return false;
2262 } else {
2263 this.set('timeStamp', e.timeStamp, true);
2264 }
2265
2266 // render condition and store result
2267 var changed = this.render();
2268 },
2269 render: function () {
2270 return this.calculate() ? this.show() : this.hide();
2271 },
2272 show: function () {
2273 return this.get('field').showEnable(this.cid, CONTEXT);
2274 },
2275 hide: function () {
2276 return this.get('field').hideDisable(this.cid, CONTEXT);
2277 },
2278 calculate: function () {
2279 // vars
2280 var pass = false;
2281
2282 // loop
2283 this.getGroups().map(function (group) {
2284 // ignore this group if another group passed
2285 if (pass) return;
2286
2287 // find passed
2288 var passed = group.filter(function (condition) {
2289 return condition.calculate();
2290 });
2291
2292 // if all conditions passed, update the global var
2293 if (passed.length == group.length) {
2294 pass = true;
2295 }
2296 });
2297 return pass;
2298 },
2299 hasGroups: function () {
2300 return this.data.groups != null;
2301 },
2302 getGroups: function () {
2303 return this.data.groups;
2304 },
2305 addGroup: function () {
2306 var group = [];
2307 this.data.groups.push(group);
2308 return group;
2309 },
2310 hasGroup: function (i) {
2311 return this.data.groups[i] != null;
2312 },
2313 getGroup: function (i) {
2314 return this.data.groups[i];
2315 },
2316 removeGroup: function (i) {
2317 this.data.groups[i].delete;
2318 return this;
2319 },
2320 addRules: function (rules, group) {
2321 rules.map(function (rule) {
2322 this.addRule(rule, group);
2323 }, this);
2324 },
2325 addRule: function (rule, group) {
2326 // defaults
2327 group = group || 0;
2328
2329 // vars
2330 var groupArray;
2331
2332 // get group
2333 if (this.hasGroup(group)) {
2334 groupArray = this.getGroup(group);
2335 } else {
2336 groupArray = this.addGroup();
2337 }
2338
2339 // instantiate
2340 var condition = acf.newCondition(rule, this);
2341
2342 // bail early if condition failed (field did not exist)
2343 if (!condition) {
2344 return false;
2345 }
2346
2347 // add rule
2348 groupArray.push(condition);
2349 },
2350 hasRule: function () {},
2351 getRule: function (rule, group) {
2352 // defaults
2353 rule = rule || 0;
2354 group = group || 0;
2355 return this.data.groups[group][rule];
2356 },
2357 removeRule: function () {}
2358 });
2359 })(jQuery);
2360
2361 /***/ }),
2362
2363 /***/ "./assets/src/js/_acf-field-accordion.js":
2364 /*!***********************************************!*\
2365 !*** ./assets/src/js/_acf-field-accordion.js ***!
2366 \***********************************************/
2367 /***/ (() => {
2368
2369 (function ($, undefined) {
2370 var i = 0;
2371 var Field = acf.Field.extend({
2372 type: 'accordion',
2373 wait: '',
2374 $control: function () {
2375 return this.$('.acf-fields:first');
2376 },
2377 initialize: function () {
2378 // Bail early if this is a duplicate of an existing initialized accordion.
2379 if (this.$el.hasClass('acf-accordion')) {
2380 return;
2381 }
2382
2383 // bail early if is cell
2384 if (this.$el.is('td')) return;
2385
2386 // endpoint
2387 if (this.get('endpoint')) {
2388 return this.remove();
2389 }
2390
2391 // vars
2392 var $field = this.$el;
2393 var $label = this.$labelWrap();
2394 var $input = this.$inputWrap();
2395 var $wrap = this.$control();
2396 var $instructions = $input.children('.description');
2397
2398 // force description into label
2399 if ($instructions.length) {
2400 $label.append($instructions);
2401 }
2402
2403 // table
2404 if (this.$el.is('tr')) {
2405 // vars
2406 var $table = this.$el.closest('table');
2407 var $newLabel = $('<div class="acf-accordion-title"/>');
2408 var $newInput = $('<div class="acf-accordion-content"/>');
2409 var $newTable = $('<table class="' + $table.attr('class') + '"/>');
2410 var $newWrap = $('<tbody/>');
2411
2412 // dom
2413 $newLabel.append($label.html());
2414 $newTable.append($newWrap);
2415 $newInput.append($newTable);
2416 $input.append($newLabel);
2417 $input.append($newInput);
2418
2419 // modify
2420 $label.remove();
2421 $wrap.remove();
2422 $input.attr('colspan', 2);
2423
2424 // update vars
2425 $label = $newLabel;
2426 $input = $newInput;
2427 $wrap = $newWrap;
2428 }
2429
2430 // add classes
2431 $field.addClass('acf-accordion');
2432 $label.addClass('acf-accordion-title');
2433 $input.addClass('acf-accordion-content');
2434
2435 // index
2436 i++;
2437
2438 // multi-expand
2439 if (this.get('multi_expand')) {
2440 $field.attr('multi-expand', 1);
2441 }
2442
2443 // open
2444 var order = acf.getPreference('this.accordions') || [];
2445 if (order[i - 1] !== undefined) {
2446 this.set('open', order[i - 1]);
2447 }
2448 if (this.get('open')) {
2449 $field.addClass('-open');
2450 $input.css('display', 'block'); // needed for accordion to close smoothly
2451 }
2452
2453 // add icon
2454 $label.prepend(accordionManager.iconHtml({
2455 open: this.get('open')
2456 }));
2457
2458 // classes
2459 // - remove 'inside' which is a #poststuff WP class
2460 var $parent = $field.parent();
2461 $wrap.addClass($parent.hasClass('-left') ? '-left' : '');
2462 $wrap.addClass($parent.hasClass('-clear') ? '-clear' : '');
2463
2464 // append
2465 $wrap.append($field.nextUntil('.acf-field-accordion', '.acf-field'));
2466
2467 // clean up
2468 $wrap.removeAttr('data-open data-multi_expand data-endpoint');
2469 }
2470 });
2471 acf.registerFieldType(Field);
2472
2473 /**
2474 * accordionManager
2475 *
2476 * Events manager for the acf accordion
2477 *
2478 * @date 14/2/18
2479 * @since ACF 5.6.9
2480 *
2481 * @param void
2482 * @return void
2483 */
2484
2485 var accordionManager = new acf.Model({
2486 actions: {
2487 unload: 'onUnload'
2488 },
2489 events: {
2490 'click .acf-accordion-title': 'onClick',
2491 'invalidField .acf-accordion': 'onInvalidField'
2492 },
2493 isOpen: function ($el) {
2494 return $el.hasClass('-open');
2495 },
2496 toggle: function ($el) {
2497 if (this.isOpen($el)) {
2498 this.close($el);
2499 } else {
2500 this.open($el);
2501 }
2502 },
2503 iconHtml: function (props) {
2504 // Use SVG inside Gutenberg editor.
2505 if (acf.isGutenberg()) {
2506 if (props.open) {
2507 return '<svg width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" class="acf-accordion-icon components-panel__arrow" aria-hidden="true" focusable="false"><path d="M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"></path></svg>';
2508 } else {
2509 return '<svg width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" class=" acf-accordion-icon components-panel__arrow" aria-hidden="true" focusable="false"><path d="M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"></path></svg>';
2510 }
2511 } else {
2512 if (props.open) {
2513 return '<i class="acf-accordion-icon dashicons dashicons-arrow-down"></i>';
2514 } else {
2515 return '<i class="acf-accordion-icon dashicons dashicons-arrow-right"></i>';
2516 }
2517 }
2518 },
2519 open: function ($el) {
2520 var duration = acf.isGutenberg() ? 0 : 300;
2521
2522 // open
2523 $el.find('.acf-accordion-content:first').slideDown(duration).css('display', 'block');
2524 $el.find('.acf-accordion-icon:first').replaceWith(this.iconHtml({
2525 open: true
2526 }));
2527 $el.addClass('-open');
2528
2529 // action
2530 acf.doAction('show', $el);
2531
2532 // close siblings
2533 if (!$el.attr('multi-expand')) {
2534 $el.siblings('.acf-accordion.-open').each(function () {
2535 accordionManager.close($(this));
2536 });
2537 }
2538 },
2539 close: function ($el) {
2540 var duration = acf.isGutenberg() ? 0 : 300;
2541
2542 // close
2543 $el.find('.acf-accordion-content:first').slideUp(duration);
2544 $el.find('.acf-accordion-icon:first').replaceWith(this.iconHtml({
2545 open: false
2546 }));
2547 $el.removeClass('-open');
2548
2549 // action
2550 acf.doAction('hide', $el);
2551 },
2552 onClick: function (e, $el) {
2553 // prevent Default
2554 e.preventDefault();
2555
2556 // open close
2557 this.toggle($el.parent());
2558 },
2559 onInvalidField: function (e, $el) {
2560 // bail early if already focused
2561 if (this.busy) {
2562 return;
2563 }
2564
2565 // disable functionality for 1sec (allow next validation to work)
2566 this.busy = true;
2567 this.setTimeout(function () {
2568 this.busy = false;
2569 }, 1000);
2570
2571 // open accordion
2572 this.open($el);
2573 },
2574 onUnload: function (e) {
2575 // vars
2576 var order = [];
2577
2578 // loop
2579 $('.acf-accordion').each(function () {
2580 var open = $(this).hasClass('-open') ? 1 : 0;
2581 order.push(open);
2582 });
2583
2584 // set
2585 if (order.length) {
2586 acf.setPreference('this.accordions', order);
2587 }
2588 }
2589 });
2590 })(jQuery);
2591
2592 /***/ }),
2593
2594 /***/ "./assets/src/js/_acf-field-button-group.js":
2595 /*!**************************************************!*\
2596 !*** ./assets/src/js/_acf-field-button-group.js ***!
2597 \**************************************************/
2598 /***/ (() => {
2599
2600 (function ($, undefined) {
2601 var Field = acf.Field.extend({
2602 type: 'button_group',
2603 events: {
2604 'click input[type="radio"]': 'onClick'
2605 },
2606 $control: function () {
2607 return this.$('.acf-button-group');
2608 },
2609 $input: function () {
2610 return this.$('input:checked');
2611 },
2612 setValue: function (val) {
2613 this.$('input[value="' + val + '"]').prop('checked', true).trigger('change');
2614 },
2615 onClick: function (e, $el) {
2616 // vars
2617 var $label = $el.parent('label');
2618 var selected = $label.hasClass('selected');
2619
2620 // remove previous selected
2621 this.$('.selected').removeClass('selected');
2622
2623 // add active class
2624 $label.addClass('selected');
2625
2626 // allow null
2627 if (this.get('allow_null') && selected) {
2628 $label.removeClass('selected');
2629 $el.prop('checked', false).trigger('change');
2630 }
2631 }
2632 });
2633 acf.registerFieldType(Field);
2634 })(jQuery);
2635
2636 /***/ }),
2637
2638 /***/ "./assets/src/js/_acf-field-checkbox.js":
2639 /*!**********************************************!*\
2640 !*** ./assets/src/js/_acf-field-checkbox.js ***!
2641 \**********************************************/
2642 /***/ (() => {
2643
2644 (function ($, undefined) {
2645 var Field = acf.Field.extend({
2646 type: 'checkbox',
2647 events: {
2648 'change input': 'onChange',
2649 'click .acf-add-checkbox': 'onClickAdd',
2650 'click .acf-checkbox-toggle': 'onClickToggle',
2651 'click .acf-checkbox-custom': 'onClickCustom'
2652 },
2653 $control: function () {
2654 return this.$('.acf-checkbox-list');
2655 },
2656 $toggle: function () {
2657 return this.$('.acf-checkbox-toggle');
2658 },
2659 $input: function () {
2660 return this.$('input[type="hidden"]');
2661 },
2662 $inputs: function () {
2663 return this.$('input[type="checkbox"]').not('.acf-checkbox-toggle');
2664 },
2665 getValue: function () {
2666 var val = [];
2667 this.$(':checked').each(function () {
2668 val.push($(this).val());
2669 });
2670 return val.length ? val : false;
2671 },
2672 onChange: function (e, $el) {
2673 // Vars.
2674 var checked = $el.prop('checked');
2675 var $label = $el.parent('label');
2676 var $toggle = this.$toggle();
2677
2678 // Add or remove "selected" class.
2679 if (checked) {
2680 $label.addClass('selected');
2681 } else {
2682 $label.removeClass('selected');
2683 }
2684
2685 // Update toggle state if all inputs are checked.
2686 if ($toggle.length) {
2687 var $inputs = this.$inputs();
2688
2689 // all checked
2690 if ($inputs.not(':checked').length == 0) {
2691 $toggle.prop('checked', true);
2692 } else {
2693 $toggle.prop('checked', false);
2694 }
2695 }
2696 },
2697 onClickAdd: function (e, $el) {
2698 var html = '<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input type="text" name="' + this.getInputName() + '[]" /></li>';
2699 $el.parent('li').before(html);
2700 $el.parent('li').parent().find('input[type="text"]').last().focus();
2701 },
2702 onClickToggle: function (e, $el) {
2703 // Vars.
2704 var checked = $el.prop('checked');
2705 var $inputs = this.$('input[type="checkbox"]');
2706 var $labels = this.$('label');
2707
2708 // Update "checked" state.
2709 $inputs.prop('checked', checked);
2710
2711 // Add or remove "selected" class.
2712 if (checked) {
2713 $labels.addClass('selected');
2714 } else {
2715 $labels.removeClass('selected');
2716 }
2717 },
2718 onClickCustom: function (e, $el) {
2719 var checked = $el.prop('checked');
2720 var $text = $el.next('input[type="text"]');
2721
2722 // checked
2723 if (checked) {
2724 $text.prop('disabled', false);
2725
2726 // not checked
2727 } else {
2728 $text.prop('disabled', true);
2729
2730 // remove
2731 if ($text.val() == '') {
2732 $el.parent('li').remove();
2733 }
2734 }
2735 }
2736 });
2737 acf.registerFieldType(Field);
2738 })(jQuery);
2739
2740 /***/ }),
2741
2742 /***/ "./assets/src/js/_acf-field-color-picker.js":
2743 /*!**************************************************!*\
2744 !*** ./assets/src/js/_acf-field-color-picker.js ***!
2745 \**************************************************/
2746 /***/ (() => {
2747
2748 (function ($, undefined) {
2749 var Field = acf.Field.extend({
2750 type: 'color_picker',
2751 wait: 'load',
2752 events: {
2753 duplicateField: 'onDuplicate'
2754 },
2755 $control: function () {
2756 return this.$('.acf-color-picker');
2757 },
2758 $input: function () {
2759 return this.$('input[type="hidden"]');
2760 },
2761 $inputText: function () {
2762 return this.$('input[type="text"]');
2763 },
2764 setValue: function (val) {
2765 // update input (with change)
2766 acf.val(this.$input(), val);
2767
2768 // update iris
2769 this.$inputText().iris('color', val);
2770 },
2771 initialize: function () {
2772 // vars
2773 var $input = this.$input();
2774 var $inputText = this.$inputText();
2775
2776 // event
2777 var onChange = function (e) {
2778 // timeout is required to ensure the $input val is correct
2779 setTimeout(function () {
2780 acf.val($input, $inputText.val());
2781 }, 1);
2782 };
2783
2784 // args
2785 var args = {
2786 defaultColor: false,
2787 palettes: true,
2788 hide: true,
2789 change: onChange,
2790 clear: onChange
2791 };
2792
2793 // filter
2794 var args = acf.applyFilters('color_picker_args', args, this);
2795
2796 // initialize
2797 $inputText.wpColorPicker(args);
2798 },
2799 onDuplicate: function (e, $el, $duplicate) {
2800 // The wpColorPicker library does not provide a destroy method.
2801 // Manually reset DOM by replacing elements back to their original state.
2802 $colorPicker = $duplicate.find('.wp-picker-container');
2803 $inputText = $duplicate.find('input[type="text"]');
2804 $colorPicker.replaceWith($inputText);
2805 }
2806 });
2807 acf.registerFieldType(Field);
2808 })(jQuery);
2809
2810 /***/ }),
2811
2812 /***/ "./assets/src/js/_acf-field-date-picker.js":
2813 /*!*************************************************!*\
2814 !*** ./assets/src/js/_acf-field-date-picker.js ***!
2815 \*************************************************/
2816 /***/ (() => {
2817
2818 (function ($, undefined) {
2819 var Field = acf.Field.extend({
2820 type: 'date_picker',
2821 events: {
2822 'blur input[type="text"]': 'onBlur',
2823 duplicateField: 'onDuplicate'
2824 },
2825 $control: function () {
2826 return this.$('.acf-date-picker');
2827 },
2828 $input: function () {
2829 return this.$('input[type="hidden"]');
2830 },
2831 $inputText: function () {
2832 return this.$('input[type="text"]');
2833 },
2834 initialize: function () {
2835 // save_format: compatibility with ACF < 5.0.0
2836 if (this.has('save_format')) {
2837 return this.initializeCompatibility();
2838 }
2839
2840 // vars
2841 var $input = this.$input();
2842 var $inputText = this.$inputText();
2843
2844 // args
2845 var args = {
2846 dateFormat: this.get('date_format'),
2847 altField: $input,
2848 altFormat: 'yymmdd',
2849 changeYear: true,
2850 yearRange: '-100:+100',
2851 changeMonth: true,
2852 showButtonPanel: true,
2853 firstDay: this.get('first_day')
2854 };
2855
2856 // filter
2857 args = acf.applyFilters('date_picker_args', args, this);
2858
2859 // add date picker
2860 acf.newDatePicker($inputText, args);
2861
2862 // action
2863 acf.doAction('date_picker_init', $inputText, args, this);
2864 },
2865 initializeCompatibility: function () {
2866 // vars
2867 var $input = this.$input();
2868 var $inputText = this.$inputText();
2869
2870 // get and set value from alt field
2871 $inputText.val($input.val());
2872
2873 // args
2874 var args = {
2875 dateFormat: this.get('date_format'),
2876 altField: $input,
2877 altFormat: this.get('save_format'),
2878 changeYear: true,
2879 yearRange: '-100:+100',
2880 changeMonth: true,
2881 showButtonPanel: true,
2882 firstDay: this.get('first_day')
2883 };
2884
2885 // filter for 3rd party customization
2886 args = acf.applyFilters('date_picker_args', args, this);
2887
2888 // backup
2889 var dateFormat = args.dateFormat;
2890
2891 // change args.dateFormat
2892 args.dateFormat = this.get('save_format');
2893
2894 // add date picker
2895 acf.newDatePicker($inputText, args);
2896
2897 // now change the format back to how it should be.
2898 $inputText.datepicker('option', 'dateFormat', dateFormat);
2899
2900 // action for 3rd party customization
2901 acf.doAction('date_picker_init', $inputText, args, this);
2902 },
2903 onBlur: function () {
2904 if (!this.$inputText().val()) {
2905 acf.val(this.$input(), '');
2906 }
2907 },
2908 onDuplicate: function (e, $el, $duplicate) {
2909 $duplicate.find('input[type="text"]').removeClass('hasDatepicker').removeAttr('id');
2910 }
2911 });
2912 acf.registerFieldType(Field);
2913
2914 // manager
2915 var datePickerManager = new acf.Model({
2916 priority: 5,
2917 wait: 'ready',
2918 initialize: function () {
2919 // vars
2920 var locale = acf.get('locale');
2921 var rtl = acf.get('rtl');
2922 var l10n = acf.get('datePickerL10n');
2923
2924 // bail early if no l10n
2925 if (!l10n) {
2926 return false;
2927 }
2928
2929 // bail early if no datepicker library
2930 if (typeof $.datepicker === 'undefined') {
2931 return false;
2932 }
2933
2934 // rtl
2935 l10n.isRTL = rtl;
2936
2937 // append
2938 $.datepicker.regional[locale] = l10n;
2939 $.datepicker.setDefaults(l10n);
2940 }
2941 });
2942
2943 // add
2944 acf.newDatePicker = function ($input, args) {
2945 // bail early if no datepicker library
2946 if (typeof $.datepicker === 'undefined') {
2947 return false;
2948 }
2949
2950 // defaults
2951 args = args || {};
2952
2953 // initialize
2954 $input.datepicker(args);
2955
2956 // wrap the datepicker (only if it hasn't already been wrapped)
2957 if ($('body > #ui-datepicker-div').exists()) {
2958 $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
2959 }
2960 };
2961 })(jQuery);
2962
2963 /***/ }),
2964
2965 /***/ "./assets/src/js/_acf-field-date-time-picker.js":
2966 /*!******************************************************!*\
2967 !*** ./assets/src/js/_acf-field-date-time-picker.js ***!
2968 \******************************************************/
2969 /***/ (() => {
2970
2971 (function ($, undefined) {
2972 var Field = acf.models.DatePickerField.extend({
2973 type: 'date_time_picker',
2974 $control: function () {
2975 return this.$('.acf-date-time-picker');
2976 },
2977 initialize: function () {
2978 // vars
2979 var $input = this.$input();
2980 var $inputText = this.$inputText();
2981
2982 // args
2983 var args = {
2984 dateFormat: this.get('date_format'),
2985 timeFormat: this.get('time_format'),
2986 altField: $input,
2987 altFieldTimeOnly: false,
2988 altFormat: 'yy-mm-dd',
2989 altTimeFormat: 'HH:mm:ss',
2990 changeYear: true,
2991 yearRange: '-100:+100',
2992 changeMonth: true,
2993 showButtonPanel: true,
2994 firstDay: this.get('first_day'),
2995 controlType: 'select',
2996 oneLine: true
2997 };
2998
2999 // filter
3000 args = acf.applyFilters('date_time_picker_args', args, this);
3001
3002 // add date time picker
3003 acf.newDateTimePicker($inputText, args);
3004
3005 // action
3006 acf.doAction('date_time_picker_init', $inputText, args, this);
3007 }
3008 });
3009 acf.registerFieldType(Field);
3010
3011 // manager
3012 var dateTimePickerManager = new acf.Model({
3013 priority: 5,
3014 wait: 'ready',
3015 initialize: function () {
3016 // vars
3017 var locale = acf.get('locale');
3018 var rtl = acf.get('rtl');
3019 var l10n = acf.get('dateTimePickerL10n');
3020
3021 // bail early if no l10n
3022 if (!l10n) {
3023 return false;
3024 }
3025
3026 // bail early if no datepicker library
3027 if (typeof $.timepicker === 'undefined') {
3028 return false;
3029 }
3030
3031 // rtl
3032 l10n.isRTL = rtl;
3033
3034 // append
3035 $.timepicker.regional[locale] = l10n;
3036 $.timepicker.setDefaults(l10n);
3037 }
3038 });
3039
3040 // add
3041 acf.newDateTimePicker = function ($input, args) {
3042 // bail early if no datepicker library
3043 if (typeof $.timepicker === 'undefined') {
3044 return false;
3045 }
3046
3047 // defaults
3048 args = args || {};
3049
3050 // initialize
3051 $input.datetimepicker(args);
3052
3053 // wrap the datepicker (only if it hasn't already been wrapped)
3054 if ($('body > #ui-datepicker-div').exists()) {
3055 $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
3056 }
3057 };
3058 })(jQuery);
3059
3060 /***/ }),
3061
3062 /***/ "./assets/src/js/_acf-field-file.js":
3063 /*!******************************************!*\
3064 !*** ./assets/src/js/_acf-field-file.js ***!
3065 \******************************************/
3066 /***/ (() => {
3067
3068 (function ($, undefined) {
3069 var Field = acf.models.ImageField.extend({
3070 type: 'file',
3071 $control: function () {
3072 return this.$('.acf-file-uploader');
3073 },
3074 $input: function () {
3075 return this.$('input[type="hidden"]:first');
3076 },
3077 validateAttachment: function (attachment) {
3078 // defaults
3079 attachment = attachment || {};
3080
3081 // WP attachment
3082 if (attachment.id !== undefined) {
3083 attachment = attachment.attributes;
3084 }
3085
3086 // args
3087 attachment = acf.parseArgs(attachment, {
3088 url: '',
3089 alt: '',
3090 title: '',
3091 filename: '',
3092 filesizeHumanReadable: '',
3093 icon: '/wp-includes/images/media/default.png'
3094 });
3095
3096 // return
3097 return attachment;
3098 },
3099 render: function (attachment) {
3100 // vars
3101 attachment = this.validateAttachment(attachment);
3102
3103 // update image
3104 this.$('img').attr({
3105 src: attachment.icon,
3106 alt: attachment.alt,
3107 title: attachment.title
3108 });
3109
3110 // update elements
3111 this.$('[data-name="title"]').text(attachment.title);
3112 this.$('[data-name="filename"]').text(attachment.filename).attr('href', attachment.url);
3113 this.$('[data-name="filesize"]').text(attachment.filesizeHumanReadable);
3114
3115 // vars
3116 var val = attachment.id || '';
3117
3118 // update val
3119 acf.val(this.$input(), val);
3120
3121 // update class
3122 if (val) {
3123 this.$control().addClass('has-value');
3124 } else {
3125 this.$control().removeClass('has-value');
3126 }
3127 },
3128 selectAttachment: function () {
3129 // vars
3130 var parent = this.parent();
3131 var multiple = parent && parent.get('type') === 'repeater';
3132
3133 // new frame
3134 var frame = acf.newMediaPopup({
3135 mode: 'select',
3136 title: acf.__('Select File'),
3137 field: this.get('key'),
3138 multiple: multiple,
3139 library: this.get('library'),
3140 allowedTypes: this.get('mime_types'),
3141 select: $.proxy(function (attachment, i) {
3142 if (i > 0) {
3143 this.append(attachment, parent);
3144 } else {
3145 this.render(attachment);
3146 }
3147 }, this)
3148 });
3149 },
3150 editAttachment: function () {
3151 // vars
3152 var val = this.val();
3153
3154 // bail early if no val
3155 if (!val) {
3156 return false;
3157 }
3158
3159 // popup
3160 var frame = acf.newMediaPopup({
3161 mode: 'edit',
3162 title: acf.__('Edit File'),
3163 button: acf.__('Update File'),
3164 attachment: val,
3165 field: this.get('key'),
3166 select: $.proxy(function (attachment, i) {
3167 this.render(attachment);
3168 }, this)
3169 });
3170 }
3171 });
3172 acf.registerFieldType(Field);
3173 })(jQuery);
3174
3175 /***/ }),
3176
3177 /***/ "./assets/src/js/_acf-field-google-map.js":
3178 /*!************************************************!*\
3179 !*** ./assets/src/js/_acf-field-google-map.js ***!
3180 \************************************************/
3181 /***/ (() => {
3182
3183 (function ($, undefined) {
3184 var Field = acf.Field.extend({
3185 type: 'google_map',
3186 map: false,
3187 wait: 'load',
3188 events: {
3189 'click a[data-name="clear"]': 'onClickClear',
3190 'click a[data-name="locate"]': 'onClickLocate',
3191 'click a[data-name="search"]': 'onClickSearch',
3192 'keydown .search': 'onKeydownSearch',
3193 'keyup .search': 'onKeyupSearch',
3194 'focus .search': 'onFocusSearch',
3195 'blur .search': 'onBlurSearch',
3196 showField: 'onShow'
3197 },
3198 $control: function () {
3199 return this.$('.acf-google-map');
3200 },
3201 $search: function () {
3202 return this.$('.search');
3203 },
3204 $canvas: function () {
3205 return this.$('.canvas');
3206 },
3207 setState: function (state) {
3208 // Remove previous state classes.
3209 this.$control().removeClass('-value -loading -searching');
3210
3211 // Determine auto state based of current value.
3212 if (state === 'default') {
3213 state = this.val() ? 'value' : '';
3214 }
3215
3216 // Update state class.
3217 if (state) {
3218 this.$control().addClass('-' + state);
3219 }
3220 },
3221 getValue: function () {
3222 var val = this.$input().val();
3223 if (val) {
3224 return JSON.parse(val);
3225 } else {
3226 return false;
3227 }
3228 },
3229 setValue: function (val, silent) {
3230 // Convert input value.
3231 var valAttr = '';
3232 if (val) {
3233 valAttr = JSON.stringify(val);
3234 }
3235
3236 // Update input (with change).
3237 acf.val(this.$input(), valAttr);
3238
3239 // Bail early if silent update.
3240 if (silent) {
3241 return;
3242 }
3243
3244 // Render.
3245 this.renderVal(val);
3246
3247 /**
3248 * Fires immediately after the value has changed.
3249 *
3250 * @date 12/02/2014
3251 * @since ACF 5.0.0
3252 *
3253 * @param object|string val The new value.
3254 * @param object map The Google Map instance.
3255 * @param object field The field instance.
3256 */
3257 acf.doAction('google_map_change', val, this.map, this);
3258 },
3259 renderVal: function (val) {
3260 // Value.
3261 if (val) {
3262 this.setState('value');
3263 this.$search().val(val.address);
3264 this.setPosition(val.lat, val.lng);
3265
3266 // No value.
3267 } else {
3268 this.setState('');
3269 this.$search().val('');
3270 this.map.marker.setVisible(false);
3271 }
3272 },
3273 newLatLng: function (lat, lng) {
3274 return new google.maps.LatLng(parseFloat(lat), parseFloat(lng));
3275 },
3276 setPosition: function (lat, lng) {
3277 // Update marker position.
3278 this.map.marker.setPosition({
3279 lat: parseFloat(lat),
3280 lng: parseFloat(lng)
3281 });
3282
3283 // Show marker.
3284 this.map.marker.setVisible(true);
3285
3286 // Center map.
3287 this.center();
3288 },
3289 center: function () {
3290 // Find marker position.
3291 var position = this.map.marker.getPosition();
3292 if (position) {
3293 var lat = position.lat();
3294 var lng = position.lng();
3295
3296 // Or find default settings.
3297 } else {
3298 var lat = this.get('lat');
3299 var lng = this.get('lng');
3300 }
3301
3302 // Center map.
3303 this.map.setCenter({
3304 lat: parseFloat(lat),
3305 lng: parseFloat(lng)
3306 });
3307 },
3308 initialize: function () {
3309 // Ensure Google API is loaded and then initialize map.
3310 withAPI(this.initializeMap.bind(this));
3311 },
3312 initializeMap: function () {
3313 // Get value ignoring conditional logic status.
3314 var val = this.getValue();
3315
3316 // Construct default args.
3317 var args = acf.parseArgs(val, {
3318 zoom: this.get('zoom'),
3319 lat: this.get('lat'),
3320 lng: this.get('lng')
3321 });
3322
3323 // Create Map.
3324 var mapArgs = {
3325 scrollwheel: false,
3326 zoom: parseInt(args.zoom),
3327 center: {
3328 lat: parseFloat(args.lat),
3329 lng: parseFloat(args.lng)
3330 },
3331 mapTypeId: google.maps.MapTypeId.ROADMAP,
3332 marker: {
3333 draggable: true,
3334 raiseOnDrag: true
3335 },
3336 autocomplete: {}
3337 };
3338 mapArgs = acf.applyFilters('google_map_args', mapArgs, this);
3339 var map = new google.maps.Map(this.$canvas()[0], mapArgs);
3340
3341 // Create Marker.
3342 var markerArgs = acf.parseArgs(mapArgs.marker, {
3343 draggable: true,
3344 raiseOnDrag: true,
3345 map: map
3346 });
3347 markerArgs = acf.applyFilters('google_map_marker_args', markerArgs, this);
3348 var marker = new google.maps.Marker(markerArgs);
3349
3350 // Maybe Create Autocomplete.
3351 var autocomplete = false;
3352 if (acf.isset(google, 'maps', 'places', 'Autocomplete')) {
3353 var autocompleteArgs = mapArgs.autocomplete || {};
3354 autocompleteArgs = acf.applyFilters('google_map_autocomplete_args', autocompleteArgs, this);
3355 autocomplete = new google.maps.places.Autocomplete(this.$search()[0], autocompleteArgs);
3356 autocomplete.bindTo('bounds', map);
3357 }
3358
3359 // Add map events.
3360 this.addMapEvents(this, map, marker, autocomplete);
3361
3362 // Append references.
3363 map.acf = this;
3364 map.marker = marker;
3365 map.autocomplete = autocomplete;
3366 this.map = map;
3367
3368 // Set position.
3369 if (val) {
3370 this.setPosition(val.lat, val.lng);
3371 }
3372
3373 /**
3374 * Fires immediately after the Google Map has been initialized.
3375 *
3376 * @date 12/02/2014
3377 * @since ACF 5.0.0
3378 *
3379 * @param object map The Google Map instance.
3380 * @param object marker The Google Map marker isntance.
3381 * @param object field The field instance.
3382 */
3383 acf.doAction('google_map_init', map, marker, this);
3384 },
3385 addMapEvents: function (field, map, marker, autocomplete) {
3386 // Click map.
3387 google.maps.event.addListener(map, 'click', function (e) {
3388 var lat = e.latLng.lat();
3389 var lng = e.latLng.lng();
3390 field.searchPosition(lat, lng);
3391 });
3392
3393 // Drag marker.
3394 google.maps.event.addListener(marker, 'dragend', function () {
3395 var lat = this.getPosition().lat();
3396 var lng = this.getPosition().lng();
3397 field.searchPosition(lat, lng);
3398 });
3399
3400 // Autocomplete search.
3401 if (autocomplete) {
3402 google.maps.event.addListener(autocomplete, 'place_changed', function () {
3403 var place = this.getPlace();
3404 field.searchPlace(place);
3405 });
3406 }
3407
3408 // Detect zoom change.
3409 google.maps.event.addListener(map, 'zoom_changed', function () {
3410 var val = field.val();
3411 if (val) {
3412 val.zoom = map.getZoom();
3413 field.setValue(val, true);
3414 }
3415 });
3416 },
3417 searchPosition: function (lat, lng) {
3418 //console.log('searchPosition', lat, lng );
3419
3420 // Start Loading.
3421 this.setState('loading');
3422
3423 // Query Geocoder.
3424 var latLng = {
3425 lat: lat,
3426 lng: lng
3427 };
3428 geocoder.geocode({
3429 location: latLng
3430 }, function (results, status) {
3431 //console.log('searchPosition', arguments );
3432
3433 // End Loading.
3434 this.setState('');
3435
3436 // Status failure.
3437 if (status !== 'OK') {
3438 this.showNotice({
3439 text: acf.__('Location not found: %s').replace('%s', status),
3440 type: 'warning'
3441 });
3442
3443 // Success.
3444 } else {
3445 var val = this.parseResult(results[0]);
3446
3447 // Override lat/lng to match user defined marker location.
3448 // Avoids issue where marker "snaps" to nearest result.
3449 val.lat = lat;
3450 val.lng = lng;
3451 this.val(val);
3452 }
3453 }.bind(this));
3454 },
3455 searchPlace: function (place) {
3456 //console.log('searchPlace', place );
3457
3458 // Bail early if no place.
3459 if (!place) {
3460 return;
3461 }
3462
3463 // Selecting from the autocomplete dropdown will return a rich PlaceResult object.
3464 // Be sure to over-write the "formatted_address" value with the one displayed to the user for best UX.
3465 if (place.geometry) {
3466 place.formatted_address = this.$search().val();
3467 var val = this.parseResult(place);
3468 this.val(val);
3469
3470 // Searching a custom address will return an empty PlaceResult object.
3471 } else if (place.name) {
3472 this.searchAddress(place.name);
3473 }
3474 },
3475 searchAddress: function (address) {
3476 //console.log('searchAddress', address );
3477
3478 // Bail early if no address.
3479 if (!address) {
3480 return;
3481 }
3482
3483 // Allow "lat,lng" search.
3484 var latLng = address.split(',');
3485 if (latLng.length == 2) {
3486 var lat = parseFloat(latLng[0]);
3487 var lng = parseFloat(latLng[1]);
3488 if (lat && lng) {
3489 return this.searchPosition(lat, lng);
3490 }
3491 }
3492
3493 // Start Loading.
3494 this.setState('loading');
3495
3496 // Query Geocoder.
3497 geocoder.geocode({
3498 address: address
3499 }, function (results, status) {
3500 //console.log('searchPosition', arguments );
3501
3502 // End Loading.
3503 this.setState('');
3504
3505 // Status failure.
3506 if (status !== 'OK') {
3507 this.showNotice({
3508 text: acf.__('Location not found: %s').replace('%s', status),
3509 type: 'warning'
3510 });
3511
3512 // Success.
3513 } else {
3514 var val = this.parseResult(results[0]);
3515
3516 // Override address data with parameter allowing custom address to be defined in search.
3517 val.address = address;
3518
3519 // Update value.
3520 this.val(val);
3521 }
3522 }.bind(this));
3523 },
3524 searchLocation: function () {
3525 //console.log('searchLocation' );
3526
3527 // Check HTML5 geolocation.
3528 if (!navigator.geolocation) {
3529 return alert(acf.__('Sorry, this browser does not support geolocation'));
3530 }
3531
3532 // Start Loading.
3533 this.setState('loading');
3534
3535 // Query Geolocation.
3536 navigator.geolocation.getCurrentPosition(
3537 // Success.
3538 function (results) {
3539 // End Loading.
3540 this.setState('');
3541
3542 // Search position.
3543 var lat = results.coords.latitude;
3544 var lng = results.coords.longitude;
3545 this.searchPosition(lat, lng);
3546 }.bind(this),
3547 // Failure.
3548 function (error) {
3549 this.setState('');
3550 }.bind(this));
3551 },
3552 /**
3553 * parseResult
3554 *
3555 * Returns location data for the given GeocoderResult object.
3556 *
3557 * @date 15/10/19
3558 * @since ACF 5.8.6
3559 *
3560 * @param object obj A GeocoderResult object.
3561 * @return object
3562 */
3563 parseResult: function (obj) {
3564 // Construct basic data.
3565 var result = {
3566 address: obj.formatted_address,
3567 lat: obj.geometry.location.lat(),
3568 lng: obj.geometry.location.lng()
3569 };
3570
3571 // Add zoom level.
3572 result.zoom = this.map.getZoom();
3573
3574 // Add place ID.
3575 if (obj.place_id) {
3576 result.place_id = obj.place_id;
3577 }
3578
3579 // Add place name.
3580 if (obj.name) {
3581 result.name = obj.name;
3582 }
3583
3584 // Create search map for address component data.
3585 var map = {
3586 street_number: ['street_number'],
3587 street_name: ['street_address', 'route'],
3588 city: ['locality', 'postal_town'],
3589 state: ['administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'administrative_area_level_4', 'administrative_area_level_5'],
3590 post_code: ['postal_code'],
3591 country: ['country']
3592 };
3593
3594 // Loop over map.
3595 for (var k in map) {
3596 var keywords = map[k];
3597
3598 // Loop over address components.
3599 for (var i = 0; i < obj.address_components.length; i++) {
3600 var component = obj.address_components[i];
3601 var component_type = component.types[0];
3602
3603 // Look for matching component type.
3604 if (keywords.indexOf(component_type) !== -1) {
3605 // Append to result.
3606 result[k] = component.long_name;
3607
3608 // Append short version.
3609 if (component.long_name !== component.short_name) {
3610 result[k + '_short'] = component.short_name;
3611 }
3612 }
3613 }
3614 }
3615
3616 /**
3617 * Filters the parsed result.
3618 *
3619 * @date 18/10/19
3620 * @since ACF 5.8.6
3621 *
3622 * @param object result The parsed result value.
3623 * @param object obj The GeocoderResult object.
3624 */
3625 return acf.applyFilters('google_map_result', result, obj, this.map, this);
3626 },
3627 onClickClear: function () {
3628 this.val(false);
3629 },
3630 onClickLocate: function () {
3631 this.searchLocation();
3632 },
3633 onClickSearch: function () {
3634 this.searchAddress(this.$search().val());
3635 },
3636 onFocusSearch: function (e, $el) {
3637 this.setState('searching');
3638 },
3639 onBlurSearch: function (e, $el) {
3640 // Get saved address value.
3641 var val = this.val();
3642 var address = val ? val.address : '';
3643
3644 // Remove 'is-searching' if value has not changed.
3645 if ($el.val() === address) {
3646 this.setState('default');
3647 }
3648 },
3649 onKeyupSearch: function (e, $el) {
3650 // Clear empty value.
3651 if (!$el.val()) {
3652 this.val(false);
3653 }
3654 },
3655 // Prevent form from submitting.
3656 onKeydownSearch: function (e, $el) {
3657 if (e.which == 13) {
3658 e.preventDefault();
3659 $el.blur();
3660 }
3661 },
3662 // Center map once made visible.
3663 onShow: function () {
3664 if (this.map) {
3665 this.setTimeout(this.center);
3666 }
3667 }
3668 });
3669 acf.registerFieldType(Field);
3670
3671 // Vars.
3672 var loading = false;
3673 var geocoder = false;
3674
3675 /**
3676 * withAPI
3677 *
3678 * Loads the Google Maps API library and triggers callback.
3679 *
3680 * @date 28/3/19
3681 * @since ACF 5.7.14
3682 *
3683 * @param function callback The callback to execute.
3684 * @return void
3685 */
3686
3687 function withAPI(callback) {
3688 // Check if geocoder exists.
3689 if (geocoder) {
3690 return callback();
3691 }
3692
3693 // Check if geocoder API exists.
3694 if (acf.isset(window, 'google', 'maps', 'Geocoder')) {
3695 geocoder = new google.maps.Geocoder();
3696 return callback();
3697 }
3698
3699 // Geocoder will need to be loaded. Hook callback to action.
3700 acf.addAction('google_map_api_loaded', callback);
3701
3702 // Bail early if already loading API.
3703 if (loading) {
3704 return;
3705 }
3706
3707 // load api
3708 var url = acf.get('google_map_api');
3709 if (url) {
3710 // Set loading status.
3711 loading = true;
3712
3713 // Load API
3714 $.ajax({
3715 url: url,
3716 dataType: 'script',
3717 cache: true,
3718 success: function () {
3719 geocoder = new google.maps.Geocoder();
3720 acf.doAction('google_map_api_loaded');
3721 }
3722 });
3723 }
3724 }
3725 })(jQuery);
3726
3727 /***/ }),
3728
3729 /***/ "./assets/src/js/_acf-field-icon-picker.js":
3730 /*!*************************************************!*\
3731 !*** ./assets/src/js/_acf-field-icon-picker.js ***!
3732 \*************************************************/
3733 /***/ (() => {
3734
3735 (function ($, undefined) {
3736 const Field = acf.Field.extend({
3737 type: 'icon_picker',
3738 wait: 'load',
3739 events: {
3740 showField: 'scrollToSelectedIcon',
3741 'input .acf-icon_url': 'onUrlChange',
3742 'click .acf-icon-picker-list-icon': 'onIconClick',
3743 'focus .acf-icon-picker-list-icon-radio': 'onIconRadioFocus',
3744 'blur .acf-icon-picker-list-icon-radio': 'onIconRadioBlur',
3745 'keydown .acf-icon-picker-list-icon-radio': 'onIconKeyDown',
3746 'input .acf-icon-list-search-input': 'onIconSearch',
3747 'keydown .acf-icon-list-search-input': 'onIconSearchKeyDown',
3748 'click .acf-icon-picker-media-library-button': 'onMediaLibraryButtonClick',
3749 'click .acf-icon-picker-media-library-preview': 'onMediaLibraryButtonClick'
3750 },
3751 $typeInput() {
3752 return this.$('input[type="hidden"][data-hidden-type="type"]:first');
3753 },
3754 $valueInput() {
3755 return this.$('input[type="hidden"][data-hidden-type="value"]:first');
3756 },
3757 $tabButton() {
3758 return this.$('.acf-tab-button');
3759 },
3760 $selectedIcon() {
3761 return this.$('.acf-icon-picker-list-icon.active');
3762 },
3763 $selectedRadio() {
3764 return this.$('.acf-icon-picker-list-icon.active input');
3765 },
3766 $iconsList() {
3767 return this.$('.acf-icon-list:visible');
3768 },
3769 $mediaLibraryButton() {
3770 return this.$('.acf-icon-picker-media-library-button');
3771 },
3772 initialize() {
3773 // Set up actions hook callbacks.
3774 this.addActions();
3775
3776 // Initialize the state of the icon picker.
3777 let typeAndValue = {
3778 type: this.$typeInput().val(),
3779 value: this.$valueInput().val()
3780 };
3781
3782 // Store the type and value object.
3783 this.set('typeAndValue', typeAndValue);
3784
3785 // Any time any acf tab is clicked, we will re-scroll to the selected icon.
3786 $('.acf-tab-button').on('click', () => {
3787 this.initializeIconLists(this.get('typeAndValue'));
3788 });
3789
3790 // Fire the action which lets people know the state has been updated.
3791 acf.doAction(this.get('name') + '/type_and_value_change', typeAndValue);
3792 this.initializeIconLists(typeAndValue);
3793 this.alignMediaLibraryTabToCurrentValue(typeAndValue);
3794 },
3795 addActions() {
3796 // Set up an action listener for when the type and value changes.
3797 acf.addAction(this.get('name') + '/type_and_value_change', newTypeAndValue => {
3798 // Align the visual state of each tab to the current value.
3799 this.alignIconListTabsToCurrentValue(newTypeAndValue);
3800 this.alignMediaLibraryTabToCurrentValue(newTypeAndValue);
3801 this.alignUrlTabToCurrentValue(newTypeAndValue);
3802 });
3803 },
3804 updateTypeAndValue(type, value) {
3805 const typeAndValue = {
3806 type,
3807 value
3808 };
3809
3810 // Update the values in the hidden fields, which are what will actually be saved.
3811 acf.val(this.$typeInput(), type);
3812 acf.val(this.$valueInput(), value);
3813
3814 // Fire an action to let each tab set itself according to the typeAndValue state.
3815 acf.doAction(this.get('name') + '/type_and_value_change', typeAndValue);
3816
3817 // Set the state.
3818 this.set('typeAndValue', typeAndValue);
3819 },
3820 scrollToSelectedIcon() {
3821 const innerElement = this.$selectedIcon();
3822
3823 // If no icon is selected, do nothing.
3824 if (innerElement.length === 0) {
3825 return;
3826 }
3827 const scrollingDiv = innerElement.closest('.acf-icon-list');
3828 scrollingDiv.scrollTop(0);
3829 const distance = innerElement.position().top - 50;
3830 if (distance === 0) {
3831 return;
3832 }
3833 scrollingDiv.scrollTop(distance);
3834 },
3835 initializeIconLists(typeAndValue) {
3836 const self = this;
3837 this.$('.acf-icon-list').each(function (i) {
3838 const tabName = $(this).data('parent-tab');
3839 const icons = self.getIconsList(tabName) || [];
3840 self.set(tabName, icons);
3841 self.renderIconList($(this));
3842 if (typeAndValue.type === tabName) {
3843 // Select the correct icon.
3844 self.selectIcon($(this), typeAndValue.value, false).then(() => {
3845 // Scroll to the selected icon.
3846 self.scrollToSelectedIcon();
3847 });
3848 }
3849 });
3850 },
3851 alignIconListTabsToCurrentValue(typeAndValue) {
3852 const icons = this.$('.acf-icon-list').filter(function () {
3853 return $(this).data('parent-tab') !== typeAndValue.type;
3854 });
3855 const self = this;
3856 icons.each(function () {
3857 self.unselectIcon($(this));
3858 });
3859 },
3860 renderIconHTML(tabName, icon) {
3861 const id = `${this.get('name')}-${icon.key}`;
3862 let style = '';
3863 if ('dashicons' !== tabName) {
3864 style = `background: center / contain url( ${acf.strEscape(icon.url)} ) no-repeat;`;
3865 }
3866 return `<div class="${tabName} ${acf.strEscape(icon.key)} acf-icon-picker-list-icon" role="radio" data-icon="${acf.strEscape(icon.key)}" style="${style}" title="${acf.strEscape(icon.label)}">
3867 <label for="${acf.strEscape(id)}">${acf.strEscape(icon.label)}</label>
3868 <input id="${acf.strEscape(id)}" type="radio" class="acf-icon-picker-list-icon-radio" name="acf-icon-picker-list-icon-radio" value="${acf.strEscape(icon.key)}">
3869 </div>`;
3870 },
3871 renderIconList($el) {
3872 const tabName = $el.data('parent-tab');
3873 const icons = this.get(tabName);
3874 $el.empty();
3875 if (icons) {
3876 icons.forEach(icon => {
3877 const iconHTML = this.renderIconHTML(tabName, icon);
3878 $el.append(iconHTML);
3879 });
3880 }
3881 },
3882 getIconsList(tabName) {
3883 if ('dashicons' === tabName) {
3884 const iconPickeri10n = acf.get('iconPickeri10n') || [];
3885 return Object.entries(iconPickeri10n).map(([key, value]) => {
3886 return {
3887 key,
3888 label: value
3889 };
3890 });
3891 }
3892 return acf.get(`iconPickerIcons_${tabName}`);
3893 },
3894 getIconsBySearch(searchTerm, tabName) {
3895 const lowercaseSearchTerm = searchTerm.toLowerCase();
3896 const icons = this.getIconsList(tabName);
3897 const filteredIcons = icons.filter(function (icon) {
3898 const lowercaseIconLabel = icon.label.toLowerCase();
3899 return lowercaseIconLabel.indexOf(lowercaseSearchTerm) > -1;
3900 });
3901 return filteredIcons;
3902 },
3903 selectIcon($el, icon, setFocus = true) {
3904 this.set('selectedIcon', icon);
3905
3906 // Select the new one.
3907 const $newIcon = $el.find('.acf-icon-picker-list-icon[data-icon="' + icon + '"]');
3908 $newIcon.addClass('active');
3909 const $input = $newIcon.find('input');
3910 const thePromise = $input.prop('checked', true).promise();
3911 if (setFocus) {
3912 $input.trigger('focus');
3913 }
3914 this.updateTypeAndValue($el.data('parent-tab'), icon);
3915 return thePromise;
3916 },
3917 unselectIcon($el) {
3918 // Remove the currently active dashicon, if any.
3919 $el.find('.acf-icon-picker-list-icon').removeClass('active');
3920 this.set('selectedIcon', false);
3921 },
3922 onIconRadioFocus(e) {
3923 const icon = e.target.value;
3924 const $tabs = this.$(e.target).closest('.acf-icon-picker-tabs');
3925 const $iconsList = $tabs.find('.acf-icon-list');
3926 const $newIcon = $iconsList.find('.acf-icon-picker-list-icon[data-icon="' + icon + '"]');
3927 $newIcon.addClass('focus');
3928
3929 // If this is a different icon than previously selected, select it.
3930 if (this.get('selectedIcon') !== icon) {
3931 this.unselectIcon($iconsList);
3932 this.selectIcon($iconsList, icon);
3933 }
3934 },
3935 onIconRadioBlur(e) {
3936 const icon = this.$(e.target);
3937 const iconParent = icon.parent();
3938 iconParent.removeClass('focus');
3939 },
3940 onIconClick(e) {
3941 e.preventDefault();
3942 const $iconList = this.$(e.target).closest('.acf-icon-list');
3943 const $iconElement = this.$(e.target);
3944 const icon = $iconElement.find('input').val();
3945 const $newIconElement = $iconList.find('.acf-icon-picker-list-icon[data-icon="' + icon + '"]');
3946
3947 // By forcing focus on the input, we fire onIconRadioFocus.
3948 $newIconElement.find('input').prop('checked', true).trigger('focus');
3949 },
3950 onIconSearch(e) {
3951 const $tabs = this.$(e.target).closest('.acf-icon-picker-tabs');
3952 const $iconList = $tabs.find('.acf-icon-list');
3953 const tabName = $tabs.data('tab');
3954 const searchTerm = e.target.value;
3955 const filteredIcons = this.getIconsBySearch(searchTerm, tabName);
3956 if (filteredIcons.length > 0 || !searchTerm) {
3957 this.set(tabName, filteredIcons);
3958 $tabs.find('.acf-icon-list-empty').hide();
3959 $tabs.find('.acf-icon-list ').show();
3960 this.renderIconList($iconList);
3961
3962 // Announce change of data to screen readers.
3963 wp.a11y.speak(acf.get('iconPickerA11yStrings').newResultsFoundForSearchTerm, 'polite');
3964 } else {
3965 // Truncate the search term if it's too long.
3966 const visualSearchTerm = searchTerm.length > 30 ? searchTerm.substring(0, 30) + '&hellip;' : searchTerm;
3967 $tabs.find('.acf-icon-list ').hide();
3968 $tabs.find('.acf-icon-list-empty').find('.acf-invalid-icon-list-search-term').text(visualSearchTerm);
3969 $tabs.find('.acf-icon-list-empty').css('display', 'flex');
3970 $tabs.find('.acf-icon-list-empty').show();
3971
3972 // Announce change of data to screen readers.
3973 wp.a11y.speak(acf.get('iconPickerA11yStrings').noResultsForSearchTerm, 'polite');
3974 }
3975 },
3976 onIconSearchKeyDown(e) {
3977 // Check if the pressed key is Enter (key code 13)
3978 if (e.which === 13) {
3979 // Prevent submitting the entire form if someone presses enter after searching.
3980 e.preventDefault();
3981 }
3982 },
3983 onIconKeyDown(e) {
3984 if (e.which === 13) {
3985 // If someone presses enter while an icon is focused, prevent the form from submitting.
3986 e.preventDefault();
3987 }
3988 },
3989 alignMediaLibraryTabToCurrentValue(typeAndValue) {
3990 const type = typeAndValue.type;
3991 const value = typeAndValue.value;
3992 if (type !== 'media_library' && type !== 'dashicons') {
3993 // Hide the preview container on the media library tab.
3994 this.$('.acf-icon-picker-media-library-preview').hide();
3995 }
3996 if (type === 'media_library') {
3997 const previewUrl = this.get('mediaLibraryPreviewUrl');
3998 // Set the image file preview src.
3999 this.$('.acf-icon-picker-media-library-preview-img img').attr('src', previewUrl);
4000
4001 // Hide the dashicon preview.
4002 this.$('.acf-icon-picker-media-library-preview-dashicon').hide();
4003
4004 // Show the image file preview.
4005 this.$('.acf-icon-picker-media-library-preview-img').show();
4006
4007 // Show the preview container (it may have been hidden if nothing was ever selected yet).
4008 this.$('.acf-icon-picker-media-library-preview').show();
4009 }
4010 if (type === 'dashicons') {
4011 // Set the dashicon preview class.
4012 this.$('.acf-icon-picker-media-library-preview-dashicon .dashicons').attr('class', 'dashicons ' + value);
4013
4014 // Hide the image file preview.
4015 this.$('.acf-icon-picker-media-library-preview-img').hide();
4016
4017 // Show the dashicon preview.
4018 this.$('.acf-icon-picker-media-library-preview-dashicon').show();
4019
4020 // Show the preview container (it may have been hidden if nothing was ever selected yet).
4021 this.$('.acf-icon-picker-media-library-preview').show();
4022 }
4023 },
4024 async onMediaLibraryButtonClick(e) {
4025 e.preventDefault();
4026 await this.selectAndReturnAttachment().then(attachment => {
4027 // When an attachment is selected, update the preview and the hidden fields.
4028 this.set('mediaLibraryPreviewUrl', attachment.attributes.url);
4029 this.updateTypeAndValue('media_library', attachment.id);
4030 });
4031 },
4032 selectAndReturnAttachment() {
4033 return new Promise(resolve => {
4034 acf.newMediaPopup({
4035 mode: 'select',
4036 type: 'image',
4037 title: acf.__('Select Image'),
4038 field: this.get('key'),
4039 multiple: false,
4040 library: 'all',
4041 allowedTypes: 'image',
4042 select: resolve
4043 });
4044 });
4045 },
4046 alignUrlTabToCurrentValue(typeAndValue) {
4047 if (typeAndValue.type !== 'url') {
4048 this.$('.acf-icon_url').val('');
4049 }
4050 },
4051 onUrlChange(event) {
4052 const currentValue = event.target.value;
4053 this.updateTypeAndValue('url', currentValue);
4054 }
4055 });
4056 acf.registerFieldType(Field);
4057 })(jQuery);
4058
4059 /***/ }),
4060
4061 /***/ "./assets/src/js/_acf-field-image.js":
4062 /*!*******************************************!*\
4063 !*** ./assets/src/js/_acf-field-image.js ***!
4064 \*******************************************/
4065 /***/ (() => {
4066
4067 (function ($, undefined) {
4068 var Field = acf.Field.extend({
4069 type: 'image',
4070 $control: function () {
4071 return this.$('.acf-image-uploader');
4072 },
4073 $input: function () {
4074 return this.$('input[type="hidden"]:first');
4075 },
4076 events: {
4077 'click a[data-name="add"]': 'onClickAdd',
4078 'click a[data-name="edit"]': 'onClickEdit',
4079 'click a[data-name="remove"]': 'onClickRemove',
4080 'change input[type="file"]': 'onChange'
4081 },
4082 initialize: function () {
4083 // add attribute to form
4084 if (this.get('uploader') === 'basic') {
4085 this.$el.closest('form').attr('enctype', 'multipart/form-data');
4086 }
4087 },
4088 validateAttachment: function (attachment) {
4089 // Use WP attachment attributes when available.
4090 if (attachment && attachment.attributes) {
4091 attachment = attachment.attributes;
4092 }
4093
4094 // Apply defaults.
4095 attachment = acf.parseArgs(attachment, {
4096 id: 0,
4097 url: '',
4098 alt: '',
4099 title: '',
4100 caption: '',
4101 description: '',
4102 width: 0,
4103 height: 0
4104 });
4105
4106 // Override with "preview size".
4107 var size = acf.isget(attachment, 'sizes', this.get('preview_size'));
4108 if (size) {
4109 attachment.url = size.url;
4110 attachment.width = size.width;
4111 attachment.height = size.height;
4112 }
4113
4114 // Return.
4115 return attachment;
4116 },
4117 render: function (attachment) {
4118 attachment = this.validateAttachment(attachment);
4119
4120 // Update DOM.
4121 this.$('img').attr({
4122 src: attachment.url,
4123 alt: attachment.alt
4124 });
4125 if (attachment.id) {
4126 this.val(attachment.id);
4127 this.$control().addClass('has-value');
4128 } else {
4129 this.val('');
4130 this.$control().removeClass('has-value');
4131 }
4132 },
4133 // create a new repeater row and render value
4134 append: function (attachment, parent) {
4135 // create function to find next available field within parent
4136 var getNext = function (field, parent) {
4137 // find existing file fields within parent
4138 var fields = acf.getFields({
4139 key: field.get('key'),
4140 parent: parent.$el
4141 });
4142
4143 // find the first field with no value
4144 for (var i = 0; i < fields.length; i++) {
4145 if (!fields[i].val()) {
4146 return fields[i];
4147 }
4148 }
4149
4150 // return
4151 return false;
4152 };
4153
4154 // find existing file fields within parent
4155 var field = getNext(this, parent);
4156
4157 // add new row if no available field
4158 if (!field) {
4159 parent.$('.acf-button:last').trigger('click');
4160 field = getNext(this, parent);
4161 }
4162
4163 // render
4164 if (field) {
4165 field.render(attachment);
4166 }
4167 },
4168 selectAttachment: function () {
4169 // vars
4170 var parent = this.parent();
4171 var multiple = parent && parent.get('type') === 'repeater';
4172
4173 // new frame
4174 var frame = acf.newMediaPopup({
4175 mode: 'select',
4176 type: 'image',
4177 title: acf.__('Select Image'),
4178 field: this.get('key'),
4179 multiple: multiple,
4180 library: this.get('library'),
4181 allowedTypes: this.get('mime_types'),
4182 select: $.proxy(function (attachment, i) {
4183 if (i > 0) {
4184 this.append(attachment, parent);
4185 } else {
4186 this.render(attachment);
4187 }
4188 }, this)
4189 });
4190 },
4191 editAttachment: function () {
4192 // vars
4193 var val = this.val();
4194
4195 // bail early if no val
4196 if (!val) return;
4197
4198 // popup
4199 var frame = acf.newMediaPopup({
4200 mode: 'edit',
4201 title: acf.__('Edit Image'),
4202 button: acf.__('Update Image'),
4203 attachment: val,
4204 field: this.get('key'),
4205 select: $.proxy(function (attachment, i) {
4206 this.render(attachment);
4207 }, this)
4208 });
4209 },
4210 removeAttachment: function () {
4211 this.render(false);
4212 },
4213 onClickAdd: function (e, $el) {
4214 this.selectAttachment();
4215 },
4216 onClickEdit: function (e, $el) {
4217 this.editAttachment();
4218 },
4219 onClickRemove: function (e, $el) {
4220 this.removeAttachment();
4221 },
4222 onChange: function (e, $el) {
4223 var $hiddenInput = this.$input();
4224 if (!$el.val()) {
4225 $hiddenInput.val('');
4226 }
4227 acf.getFileInputData($el, function (data) {
4228 $hiddenInput.val($.param(data));
4229 });
4230 }
4231 });
4232 acf.registerFieldType(Field);
4233 })(jQuery);
4234
4235 /***/ }),
4236
4237 /***/ "./assets/src/js/_acf-field-link.js":
4238 /*!******************************************!*\
4239 !*** ./assets/src/js/_acf-field-link.js ***!
4240 \******************************************/
4241 /***/ (() => {
4242
4243 (function ($, undefined) {
4244 var Field = acf.Field.extend({
4245 type: 'link',
4246 events: {
4247 'click a[data-name="add"]': 'onClickEdit',
4248 'click a[data-name="edit"]': 'onClickEdit',
4249 'click a[data-name="remove"]': 'onClickRemove',
4250 'change .link-node': 'onChange'
4251 },
4252 $control: function () {
4253 return this.$('.acf-link');
4254 },
4255 $node: function () {
4256 return this.$('.link-node');
4257 },
4258 getValue: function () {
4259 // vars
4260 var $node = this.$node();
4261
4262 // return false if empty
4263 if (!$node.attr('href')) {
4264 return false;
4265 }
4266
4267 // return
4268 return {
4269 title: $node.html(),
4270 url: $node.attr('href'),
4271 target: $node.attr('target')
4272 };
4273 },
4274 setValue: function (val) {
4275 // default
4276 val = acf.parseArgs(val, {
4277 title: '',
4278 url: '',
4279 target: ''
4280 });
4281
4282 // vars
4283 var $div = this.$control();
4284 var $node = this.$node();
4285
4286 // remove class
4287 $div.removeClass('-value -external');
4288
4289 // add class
4290 if (val.url) $div.addClass('-value');
4291 if (val.target === '_blank') $div.addClass('-external');
4292
4293 // update text
4294 this.$('.link-title').html(val.title);
4295 this.$('.link-url').attr('href', val.url).text(val.url);
4296
4297 // update node
4298 $node.html(val.title);
4299 $node.attr('href', val.url);
4300 $node.attr('target', val.target);
4301
4302 // update inputs
4303 this.$('.input-title').val(val.title);
4304 this.$('.input-target').val(val.target);
4305 this.$('.input-url').val(val.url).trigger('change');
4306 },
4307 onClickEdit: function (e, $el) {
4308 acf.wpLink.open(this.$node());
4309 },
4310 onClickRemove: function (e, $el) {
4311 this.setValue(false);
4312 },
4313 onChange: function (e, $el) {
4314 // get the changed value
4315 var val = this.getValue();
4316
4317 // update inputs
4318 this.setValue(val);
4319 }
4320 });
4321 acf.registerFieldType(Field);
4322
4323 // manager
4324 acf.wpLink = new acf.Model({
4325 getNodeValue: function () {
4326 var $node = this.get('node');
4327 return {
4328 title: acf.decode($node.html()),
4329 url: $node.attr('href'),
4330 target: $node.attr('target')
4331 };
4332 },
4333 setNodeValue: function (val) {
4334 var $node = this.get('node');
4335 $node.text(val.title);
4336 $node.attr('href', val.url);
4337 $node.attr('target', val.target);
4338 $node.trigger('change');
4339 },
4340 getInputValue: function () {
4341 return {
4342 title: $('#wp-link-text').val(),
4343 url: $('#wp-link-url').val(),
4344 target: $('#wp-link-target').prop('checked') ? '_blank' : ''
4345 };
4346 },
4347 setInputValue: function (val) {
4348 $('#wp-link-text').val(val.title);
4349 $('#wp-link-url').val(val.url);
4350 $('#wp-link-target').prop('checked', val.target === '_blank');
4351 },
4352 open: function ($node) {
4353 // add events
4354 this.on('wplink-open', 'onOpen');
4355 this.on('wplink-close', 'onClose');
4356
4357 // set node
4358 this.set('node', $node);
4359
4360 // create textarea
4361 var $textarea = $('<textarea id="acf-link-textarea" style="display:none;"></textarea>');
4362 $('body').append($textarea);
4363
4364 // vars
4365 var val = this.getNodeValue();
4366
4367 // open popup
4368 wpLink.open('acf-link-textarea', val.url, val.title, null);
4369 },
4370 onOpen: function () {
4371 // always show title (WP will hide title if empty)
4372 $('#wp-link-wrap').addClass('has-text-field');
4373
4374 // set inputs
4375 var val = this.getNodeValue();
4376 this.setInputValue(val);
4377
4378 // Update button text.
4379 if (val.url && wpLinkL10n) {
4380 $('#wp-link-submit').val(wpLinkL10n.update);
4381 }
4382 },
4383 close: function () {
4384 wpLink.close();
4385 },
4386 onClose: function () {
4387 // Bail early if no node.
4388 // Needed due to WP triggering this event twice.
4389 if (!this.has('node')) {
4390 return false;
4391 }
4392
4393 // Determine context.
4394 var $submit = $('#wp-link-submit');
4395 var isSubmit = $submit.is(':hover') || $submit.is(':focus');
4396
4397 // Set value
4398 if (isSubmit) {
4399 var val = this.getInputValue();
4400 this.setNodeValue(val);
4401 }
4402
4403 // Cleanup.
4404 this.off('wplink-open');
4405 this.off('wplink-close');
4406 $('#acf-link-textarea').remove();
4407 this.set('node', null);
4408 }
4409 });
4410 })(jQuery);
4411
4412 /***/ }),
4413
4414 /***/ "./assets/src/js/_acf-field-oembed.js":
4415 /*!********************************************!*\
4416 !*** ./assets/src/js/_acf-field-oembed.js ***!
4417 \********************************************/
4418 /***/ (() => {
4419
4420 (function ($, undefined) {
4421 var Field = acf.Field.extend({
4422 type: 'oembed',
4423 events: {
4424 'click [data-name="clear-button"]': 'onClickClear',
4425 'keypress .input-search': 'onKeypressSearch',
4426 'keyup .input-search': 'onKeyupSearch',
4427 'change .input-search': 'onChangeSearch'
4428 },
4429 $control: function () {
4430 return this.$('.acf-oembed');
4431 },
4432 $input: function () {
4433 return this.$('.input-value');
4434 },
4435 $search: function () {
4436 return this.$('.input-search');
4437 },
4438 getValue: function () {
4439 return this.$input().val();
4440 },
4441 getSearchVal: function () {
4442 return this.$search().val();
4443 },
4444 setValue: function (val) {
4445 // class
4446 if (val) {
4447 this.$control().addClass('has-value');
4448 } else {
4449 this.$control().removeClass('has-value');
4450 }
4451 acf.val(this.$input(), val);
4452 },
4453 showLoading: function (show) {
4454 acf.showLoading(this.$('.canvas'));
4455 },
4456 hideLoading: function () {
4457 acf.hideLoading(this.$('.canvas'));
4458 },
4459 maybeSearch: function () {
4460 // vars
4461 var prevUrl = this.val();
4462 var url = this.getSearchVal();
4463
4464 // no value
4465 if (!url) {
4466 return this.clear();
4467 }
4468
4469 // fix missing 'http://' - causes the oembed code to error and fail
4470 if (url.substr(0, 4) != 'http') {
4471 url = 'http://' + url;
4472 }
4473
4474 // bail early if no change
4475 if (url === prevUrl) return;
4476
4477 // clear existing timeout
4478 var timeout = this.get('timeout');
4479 if (timeout) {
4480 clearTimeout(timeout);
4481 }
4482
4483 // set new timeout
4484 var callback = $.proxy(this.search, this, url);
4485 this.set('timeout', setTimeout(callback, 300));
4486 },
4487 search: function (url) {
4488 const ajaxData = {
4489 action: 'acf/fields/oembed/search',
4490 s: url,
4491 field_key: this.get('key'),
4492 nonce: this.get('nonce')
4493 };
4494
4495 // clear existing timeout
4496 let xhr = this.get('xhr');
4497 if (xhr) {
4498 xhr.abort();
4499 }
4500
4501 // loading
4502 this.showLoading();
4503
4504 // query
4505 xhr = $.ajax({
4506 url: acf.get('ajaxurl'),
4507 data: acf.prepareForAjax(ajaxData),
4508 type: 'post',
4509 dataType: 'json',
4510 context: this,
4511 success: function (json) {
4512 // error
4513 if (!json || !json.html) {
4514 json = {
4515 url: false,
4516 html: ''
4517 };
4518 }
4519
4520 // update vars
4521 this.val(json.url);
4522 this.$('.canvas-media').html(json.html);
4523 },
4524 complete: function () {
4525 this.hideLoading();
4526 }
4527 });
4528 this.set('xhr', xhr);
4529 },
4530 clear: function () {
4531 this.val('');
4532 this.$search().val('');
4533 this.$('.canvas-media').html('');
4534 },
4535 onClickClear: function (e, $el) {
4536 this.clear();
4537 },
4538 onKeypressSearch: function (e, $el) {
4539 if (e.which == 13) {
4540 e.preventDefault();
4541 this.maybeSearch();
4542 }
4543 },
4544 onKeyupSearch: function (e, $el) {
4545 if ($el.val()) {
4546 this.maybeSearch();
4547 }
4548 },
4549 onChangeSearch: function (e, $el) {
4550 this.maybeSearch();
4551 }
4552 });
4553 acf.registerFieldType(Field);
4554 })(jQuery);
4555
4556 /***/ }),
4557
4558 /***/ "./assets/src/js/_acf-field-page-link.js":
4559 /*!***********************************************!*\
4560 !*** ./assets/src/js/_acf-field-page-link.js ***!
4561 \***********************************************/
4562 /***/ (() => {
4563
4564 (function ($, undefined) {
4565 var Field = acf.models.SelectField.extend({
4566 type: 'page_link'
4567 });
4568 acf.registerFieldType(Field);
4569 })(jQuery);
4570
4571 /***/ }),
4572
4573 /***/ "./assets/src/js/_acf-field-post-object.js":
4574 /*!*************************************************!*\
4575 !*** ./assets/src/js/_acf-field-post-object.js ***!
4576 \*************************************************/
4577 /***/ (() => {
4578
4579 (function ($, undefined) {
4580 var Field = acf.models.SelectField.extend({
4581 type: 'post_object'
4582 });
4583 acf.registerFieldType(Field);
4584 })(jQuery);
4585
4586 /***/ }),
4587
4588 /***/ "./assets/src/js/_acf-field-radio.js":
4589 /*!*******************************************!*\
4590 !*** ./assets/src/js/_acf-field-radio.js ***!
4591 \*******************************************/
4592 /***/ (() => {
4593
4594 (function ($, undefined) {
4595 var Field = acf.Field.extend({
4596 type: 'radio',
4597 events: {
4598 'click input[type="radio"]': 'onClick'
4599 },
4600 $control: function () {
4601 return this.$('.acf-radio-list');
4602 },
4603 $input: function () {
4604 return this.$('input:checked');
4605 },
4606 $inputText: function () {
4607 return this.$('input[type="text"]');
4608 },
4609 getValue: function () {
4610 var val = this.$input().val();
4611 if (val === 'other' && this.get('other_choice')) {
4612 val = this.$inputText().val();
4613 }
4614 return val;
4615 },
4616 onClick: function (e, $el) {
4617 // vars
4618 var $label = $el.parent('label');
4619 var selected = $label.hasClass('selected');
4620 var val = $el.val();
4621
4622 // remove previous selected
4623 this.$('.selected').removeClass('selected');
4624
4625 // add active class
4626 $label.addClass('selected');
4627
4628 // allow null
4629 if (this.get('allow_null') && selected) {
4630 $label.removeClass('selected');
4631 $el.prop('checked', false).trigger('change');
4632 val = false;
4633 }
4634
4635 // other
4636 if (this.get('other_choice')) {
4637 // enable
4638 if (val === 'other') {
4639 this.$inputText().prop('disabled', false);
4640
4641 // disable
4642 } else {
4643 this.$inputText().prop('disabled', true);
4644 }
4645 }
4646 }
4647 });
4648 acf.registerFieldType(Field);
4649 })(jQuery);
4650
4651 /***/ }),
4652
4653 /***/ "./assets/src/js/_acf-field-range.js":
4654 /*!*******************************************!*\
4655 !*** ./assets/src/js/_acf-field-range.js ***!
4656 \*******************************************/
4657 /***/ (() => {
4658
4659 (function ($, undefined) {
4660 var Field = acf.Field.extend({
4661 type: 'range',
4662 events: {
4663 'input input[type="range"]': 'onChange',
4664 'change input': 'onChange'
4665 },
4666 $input: function () {
4667 return this.$('input[type="range"]');
4668 },
4669 $inputAlt: function () {
4670 return this.$('input[type="number"]');
4671 },
4672 setValue: function (val) {
4673 this.busy = true;
4674
4675 // Update range input (with change).
4676 acf.val(this.$input(), val);
4677
4678 // Update alt input (without change).
4679 // Read in input value to inherit min/max validation.
4680 acf.val(this.$inputAlt(), this.$input().val(), true);
4681 this.busy = false;
4682 },
4683 onChange: function (e, $el) {
4684 if (!this.busy) {
4685 this.setValue($el.val());
4686 }
4687 }
4688 });
4689 acf.registerFieldType(Field);
4690 })(jQuery);
4691
4692 /***/ }),
4693
4694 /***/ "./assets/src/js/_acf-field-relationship.js":
4695 /*!**************************************************!*\
4696 !*** ./assets/src/js/_acf-field-relationship.js ***!
4697 \**************************************************/
4698 /***/ (() => {
4699
4700 (function ($, undefined) {
4701 var Field = acf.Field.extend({
4702 type: 'relationship',
4703 events: {
4704 'keypress [data-filter]': 'onKeypressFilter',
4705 'change [data-filter]': 'onChangeFilter',
4706 'keyup [data-filter]': 'onChangeFilter',
4707 'click .choices-list .acf-rel-item': 'onClickAdd',
4708 'keypress .choices-list .acf-rel-item': 'onKeypressFilter',
4709 'keypress .values-list .acf-rel-item': 'onKeypressFilter',
4710 'click [data-name="remove_item"]': 'onClickRemove',
4711 'touchstart .values-list .acf-rel-item': 'onTouchStartValues'
4712 },
4713 $control: function () {
4714 return this.$('.acf-relationship');
4715 },
4716 $list: function (list) {
4717 return this.$('.' + list + '-list');
4718 },
4719 $listItems: function (list) {
4720 return this.$list(list).find('.acf-rel-item');
4721 },
4722 $listItem: function (list, id) {
4723 return this.$list(list).find('.acf-rel-item[data-id="' + id + '"]');
4724 },
4725 getValue: function () {
4726 var val = [];
4727 this.$listItems('values').each(function () {
4728 val.push($(this).data('id'));
4729 });
4730 return val.length ? val : false;
4731 },
4732 newChoice: function (props) {
4733 return ['<li>', '<span tabindex="0" data-id="' + props.id + '" class="acf-rel-item">' + props.text + '</span>', '</li>'].join('');
4734 },
4735 newValue: function (props) {
4736 return ['<li>', '<input type="hidden" name="' + this.getInputName() + '[]" value="' + props.id + '" />', '<span tabindex="0" data-id="' + props.id + '" class="acf-rel-item acf-rel-item-remove">' + props.text, '<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>', '</span>', '</li>'].join('');
4737 },
4738 initialize: function () {
4739 // Delay initialization until "interacted with" or "in view".
4740 var delayed = this.proxy(acf.once(function () {
4741 // Add sortable.
4742 this.$list('values').sortable({
4743 items: 'li',
4744 forceHelperSize: true,
4745 forcePlaceholderSize: true,
4746 scroll: true,
4747 update: this.proxy(function () {
4748 this.$input().trigger('change');
4749 })
4750 });
4751
4752 // Avoid browser remembering old scroll position and add event.
4753 this.$list('choices').scrollTop(0).on('scroll', this.proxy(this.onScrollChoices));
4754
4755 // Fetch choices.
4756 this.fetch();
4757 }));
4758
4759 // Bind "interacted with".
4760 this.$el.one('mouseover', delayed);
4761 this.$el.one('focus', 'input', delayed);
4762
4763 // Bind "in view".
4764 acf.onceInView(this.$el, delayed);
4765 },
4766 onScrollChoices: function (e) {
4767 // bail early if no more results
4768 if (this.get('loading') || !this.get('more')) {
4769 return;
4770 }
4771
4772 // Scrolled to bottom
4773 var $list = this.$list('choices');
4774 var scrollTop = Math.ceil($list.scrollTop());
4775 var scrollHeight = Math.ceil($list[0].scrollHeight);
4776 var innerHeight = Math.ceil($list.innerHeight());
4777 var paged = this.get('paged') || 1;
4778 if (scrollTop + innerHeight >= scrollHeight) {
4779 // update paged
4780 this.set('paged', paged + 1);
4781
4782 // fetch
4783 this.fetch();
4784 }
4785 },
4786 onKeypressFilter: function (e, $el) {
4787 // Receive enter key when selecting relationship items.
4788 if ($el.hasClass('acf-rel-item-add') && e.which == 13) {
4789 this.onClickAdd(e, $el);
4790 }
4791 // Receive enter key when removing relationship items.
4792 if ($el.hasClass('acf-rel-item-remove') && e.which == 13) {
4793 this.onClickRemove(e, $el);
4794 }
4795 // don't submit form
4796 if (e.which == 13) {
4797 e.preventDefault();
4798 }
4799 },
4800 onChangeFilter: function (e, $el) {
4801 // vars
4802 var val = $el.val();
4803 var filter = $el.data('filter');
4804
4805 // Bail early if filter has not changed
4806 if (this.get(filter) === val) {
4807 return;
4808 }
4809
4810 // update attr
4811 this.set(filter, val);
4812 if (filter === 's') {
4813 // If val is numeric, limit results to include.
4814 if (parseInt(val)) {
4815 this.set('include', val);
4816 }
4817 }
4818
4819 // reset paged
4820 this.set('paged', 1);
4821
4822 // fetch
4823 if ($el.is('select')) {
4824 this.fetch();
4825
4826 // search must go through timeout
4827 } else {
4828 this.maybeFetch();
4829 }
4830 },
4831 onClickAdd: function (e, $el) {
4832 // vars
4833 var val = this.val();
4834 var max = parseInt(this.get('max'));
4835
4836 // can be added?
4837 if ($el.hasClass('disabled')) {
4838 return false;
4839 }
4840
4841 // validate
4842 if (max > 0 && val && val.length >= max) {
4843 // add notice
4844 this.showNotice({
4845 text: acf.__('Maximum values reached ( {max} values )').replace('{max}', max),
4846 type: 'warning'
4847 });
4848 return false;
4849 }
4850
4851 // disable
4852 $el.addClass('disabled');
4853
4854 // add
4855 var html = this.newValue({
4856 id: $el.data('id'),
4857 text: $el.html()
4858 });
4859 this.$list('values').append(html);
4860
4861 // trigger change
4862 this.$input().trigger('change');
4863 },
4864 onClickRemove: function (e, $el) {
4865 // Prevent default here because generic handler wont be triggered.
4866 e.preventDefault();
4867 let $span;
4868 // Behavior if triggered from tabbed event.
4869 if ($el.hasClass('acf-rel-item-remove')) {
4870 $span = $el;
4871 } else {
4872 // Behavior if triggered through click event.
4873 $span = $el.parent();
4874 }
4875
4876 // vars
4877 const $li = $span.parent();
4878 const id = $span.data('id');
4879
4880 // remove value
4881 $li.remove();
4882
4883 // show choice
4884 this.$listItem('choices', id).removeClass('disabled');
4885
4886 // trigger change
4887 this.$input().trigger('change');
4888 },
4889 onTouchStartValues: function (e, $el) {
4890 $(this.$listItems('values')).removeClass('relationship-hover');
4891 $el.addClass('relationship-hover');
4892 },
4893 maybeFetch: function () {
4894 // vars
4895 var timeout = this.get('timeout');
4896
4897 // abort timeout
4898 if (timeout) {
4899 clearTimeout(timeout);
4900 }
4901
4902 // fetch
4903 timeout = this.setTimeout(this.fetch, 300);
4904 this.set('timeout', timeout);
4905 },
4906 getAjaxData: function () {
4907 // load data based on element attributes
4908 var ajaxData = this.$control().data();
4909 for (var name in ajaxData) {
4910 ajaxData[name] = this.get(name);
4911 }
4912
4913 // extra
4914 ajaxData.action = 'acf/fields/relationship/query';
4915 ajaxData.field_key = this.get('key');
4916 ajaxData.nonce = this.get('nonce');
4917
4918 // Filter.
4919 ajaxData = acf.applyFilters('relationship_ajax_data', ajaxData, this);
4920
4921 // return
4922 return ajaxData;
4923 },
4924 fetch: function () {
4925 // abort XHR if this field is already loading AJAX data
4926 var xhr = this.get('xhr');
4927 if (xhr) {
4928 xhr.abort();
4929 }
4930
4931 // add to this.o
4932 var ajaxData = this.getAjaxData();
4933
4934 // clear html if is new query
4935 var $choiceslist = this.$list('choices');
4936 if (ajaxData.paged == 1) {
4937 $choiceslist.html('');
4938 }
4939
4940 // loading
4941 var $loading = $('<li><i class="acf-loading"></i> ' + acf.__('Loading') + '</li>');
4942 $choiceslist.append($loading);
4943 this.set('loading', true);
4944
4945 // callback
4946 var onComplete = function () {
4947 this.set('loading', false);
4948 $loading.remove();
4949 };
4950 var onSuccess = function (json) {
4951 // no results
4952 if (!json || !json.results || !json.results.length) {
4953 // prevent pagination
4954 this.set('more', false);
4955
4956 // add message
4957 if (this.get('paged') == 1) {
4958 this.$list('choices').append('<li>' + acf.__('No matches found') + '</li>');
4959 }
4960
4961 // return
4962 return;
4963 }
4964
4965 // set more (allows pagination scroll)
4966 this.set('more', json.more);
4967
4968 // get new results
4969 var html = this.walkChoices(json.results);
4970 var $html = $(html);
4971
4972 // apply .disabled to left li's
4973 var val = this.val();
4974 if (val && val.length) {
4975 val.map(function (id) {
4976 $html.find('.acf-rel-item[data-id="' + id + '"]').addClass('disabled');
4977 });
4978 }
4979
4980 // append
4981 $choiceslist.append($html);
4982
4983 // merge together groups
4984 var $prevLabel = false;
4985 var $prevList = false;
4986 $choiceslist.find('.acf-rel-label').each(function () {
4987 var $label = $(this);
4988 var $list = $label.siblings('ul');
4989 if ($prevLabel && $prevLabel.text() == $label.text()) {
4990 $prevList.append($list.children());
4991 $(this).parent().remove();
4992 return;
4993 }
4994
4995 // update vars
4996 $prevLabel = $label;
4997 $prevList = $list;
4998 });
4999 };
5000
5001 // get results
5002 var xhr = $.ajax({
5003 url: acf.get('ajaxurl'),
5004 dataType: 'json',
5005 type: 'post',
5006 data: acf.prepareForAjax(ajaxData),
5007 context: this,
5008 success: onSuccess,
5009 complete: onComplete
5010 });
5011
5012 // set
5013 this.set('xhr', xhr);
5014 },
5015 walkChoices: function (data) {
5016 // walker
5017 var walk = function (data) {
5018 // vars
5019 var html = '';
5020
5021 // is array
5022 if ($.isArray(data)) {
5023 data.map(function (item) {
5024 html += walk(item);
5025 });
5026
5027 // is item
5028 } else if ($.isPlainObject(data)) {
5029 // group
5030 if (data.children !== undefined) {
5031 html += '<li><span class="acf-rel-label">' + acf.escHtml(data.text) + '</span><ul class="acf-bl">';
5032 html += walk(data.children);
5033 html += '</ul></li>';
5034
5035 // single
5036 } else {
5037 html += '<li><span tabindex="0" class="acf-rel-item acf-rel-item-add" data-id="' + acf.escAttr(data.id) + '">' + acf.escHtml(data.text) + '</span></li>';
5038 }
5039 }
5040
5041 // return
5042 return html;
5043 };
5044 return walk(data);
5045 }
5046 });
5047 acf.registerFieldType(Field);
5048 })(jQuery);
5049
5050 /***/ }),
5051
5052 /***/ "./assets/src/js/_acf-field-select.js":
5053 /*!********************************************!*\
5054 !*** ./assets/src/js/_acf-field-select.js ***!
5055 \********************************************/
5056 /***/ (() => {
5057
5058 (function ($, undefined) {
5059 var Field = acf.Field.extend({
5060 type: 'select',
5061 select2: false,
5062 wait: 'load',
5063 events: {
5064 removeField: 'onRemove',
5065 duplicateField: 'onDuplicate'
5066 },
5067 $input: function () {
5068 return this.$('select');
5069 },
5070 initialize: function () {
5071 // vars
5072 var $select = this.$input();
5073
5074 // inherit data
5075 this.inherit($select);
5076
5077 // select2
5078 if (this.get('ui')) {
5079 // populate ajax_data (allowing custom attribute to already exist)
5080 var ajaxAction = this.get('ajax_action');
5081 if (!ajaxAction) {
5082 ajaxAction = 'acf/fields/' + this.get('type') + '/query';
5083 }
5084
5085 // select2
5086 this.select2 = acf.newSelect2($select, {
5087 field: this,
5088 ajax: this.get('ajax'),
5089 multiple: this.get('multiple'),
5090 placeholder: this.get('placeholder'),
5091 allowNull: this.get('allow_null'),
5092 tags: this.get('create_options'),
5093 ajaxAction: ajaxAction
5094 });
5095 }
5096 },
5097 onRemove: function () {
5098 if (this.select2) {
5099 this.select2.destroy();
5100 }
5101 },
5102 onDuplicate: function (e, $el, $duplicate) {
5103 if (this.select2) {
5104 $duplicate.find('.select2-container').remove();
5105 $duplicate.find('select').removeClass('select2-hidden-accessible');
5106 }
5107 }
5108 });
5109 acf.registerFieldType(Field);
5110 })(jQuery);
5111
5112 /***/ }),
5113
5114 /***/ "./assets/src/js/_acf-field-tab.js":
5115 /*!*****************************************!*\
5116 !*** ./assets/src/js/_acf-field-tab.js ***!
5117 \*****************************************/
5118 /***/ (() => {
5119
5120 (function ($, undefined) {
5121 // vars
5122 var CONTEXT = 'tab';
5123 var Field = acf.Field.extend({
5124 type: 'tab',
5125 wait: '',
5126 tabs: false,
5127 tab: false,
5128 events: {
5129 duplicateField: 'onDuplicate'
5130 },
5131 findFields: function () {
5132 let filter;
5133
5134 /**
5135 * Tabs in the admin UI that can be extended by third
5136 * parties have the child settings wrapped inside an extra div,
5137 * so we need to look for that instead of an adjacent .acf-field.
5138 */
5139 switch (this.get('key')) {
5140 case 'acf_field_settings_tabs':
5141 filter = '.acf-field-settings-main';
5142 break;
5143 case 'acf_field_group_settings_tabs':
5144 filter = '.field-group-settings-tab';
5145 break;
5146 case 'acf_browse_fields_tabs':
5147 filter = '.acf-field-types-tab';
5148 break;
5149 case 'acf_icon_picker_tabs':
5150 filter = '.acf-icon-picker-tabs';
5151 break;
5152 case 'acf_post_type_tabs':
5153 filter = '.acf-post-type-advanced-settings';
5154 break;
5155 case 'acf_taxonomy_tabs':
5156 filter = '.acf-taxonomy-advanced-settings';
5157 break;
5158 case 'acf_ui_options_page_tabs':
5159 filter = '.acf-ui-options-page-advanced-settings';
5160 break;
5161 default:
5162 filter = '.acf-field';
5163 }
5164 return this.$el.nextUntil('.acf-field-tab', filter);
5165 },
5166 getFields: function () {
5167 return acf.getFields(this.findFields());
5168 },
5169 findTabs: function () {
5170 return this.$el.prevAll('.acf-tab-wrap:first');
5171 },
5172 findTab: function () {
5173 return this.$('.acf-tab-button');
5174 },
5175 initialize: function () {
5176 // bail early if is td
5177 if (this.$el.is('td')) {
5178 this.events = {};
5179 return false;
5180 }
5181
5182 // vars
5183 var $tabs = this.findTabs();
5184 var $tab = this.findTab();
5185 var settings = acf.parseArgs($tab.data(), {
5186 endpoint: false,
5187 placement: '',
5188 before: this.$el
5189 });
5190
5191 // create wrap
5192 if (!$tabs.length || settings.endpoint) {
5193 this.tabs = new Tabs(settings);
5194 } else {
5195 this.tabs = $tabs.data('acf');
5196 }
5197
5198 // add tab
5199 this.tab = this.tabs.addTab($tab, this);
5200 },
5201 isActive: function () {
5202 return this.tab.isActive();
5203 },
5204 showFields: function () {
5205 // show fields
5206 this.getFields().map(function (field) {
5207 field.show(this.cid, CONTEXT);
5208 field.hiddenByTab = false;
5209 }, this);
5210 },
5211 hideFields: function () {
5212 // hide fields
5213 this.getFields().map(function (field) {
5214 field.hide(this.cid, CONTEXT);
5215 field.hiddenByTab = this.tab;
5216 }, this);
5217 },
5218 show: function (lockKey) {
5219 // show field and store result
5220 var visible = acf.Field.prototype.show.apply(this, arguments);
5221
5222 // check if now visible
5223 if (visible) {
5224 // show tab
5225 this.tab.show();
5226
5227 // check active tabs
5228 this.tabs.refresh();
5229 }
5230
5231 // return
5232 return visible;
5233 },
5234 hide: function (lockKey) {
5235 // hide field and store result
5236 var hidden = acf.Field.prototype.hide.apply(this, arguments);
5237
5238 // check if now hidden
5239 if (hidden) {
5240 // hide tab
5241 this.tab.hide();
5242
5243 // reset tabs if this was active
5244 if (this.isActive()) {
5245 this.tabs.reset();
5246 }
5247 }
5248
5249 // return
5250 return hidden;
5251 },
5252 enable: function (lockKey) {
5253 // enable fields
5254 this.getFields().map(function (field) {
5255 field.enable(CONTEXT);
5256 });
5257 },
5258 disable: function (lockKey) {
5259 // disable fields
5260 this.getFields().map(function (field) {
5261 field.disable(CONTEXT);
5262 });
5263 },
5264 onDuplicate: function (e, $el, $duplicate) {
5265 if (this.isActive()) {
5266 $duplicate.prevAll('.acf-tab-wrap:first').remove();
5267 }
5268 }
5269 });
5270 acf.registerFieldType(Field);
5271
5272 /**
5273 * tabs
5274 *
5275 * description
5276 *
5277 * @date 8/2/18
5278 * @since ACF 5.6.5
5279 *
5280 * @param type $var Description. Default.
5281 * @return type Description.
5282 */
5283
5284 var i = 0;
5285 var Tabs = acf.Model.extend({
5286 tabs: [],
5287 active: false,
5288 actions: {
5289 refresh: 'onRefresh',
5290 close_field_object: 'onCloseFieldObject'
5291 },
5292 data: {
5293 before: false,
5294 placement: 'top',
5295 index: 0,
5296 initialized: false
5297 },
5298 setup: function (settings) {
5299 // data
5300 $.extend(this.data, settings);
5301
5302 // define this prop to avoid scope issues
5303 this.tabs = [];
5304 this.active = false;
5305
5306 // vars
5307 var placement = this.get('placement');
5308 var $before = this.get('before');
5309 var $parent = $before.parent();
5310
5311 // add sidebar for left placement
5312 if (placement == 'left' && $parent.hasClass('acf-fields')) {
5313 $parent.addClass('-sidebar');
5314 }
5315
5316 // create wrap
5317 if ($before.is('tr')) {
5318 this.$el = $('<tr class="acf-tab-wrap"><td colspan="2"><ul class="acf-hl acf-tab-group"></ul></td></tr>');
5319 } else {
5320 let ulClass = 'acf-hl acf-tab-group';
5321 if (this.get('key') === 'acf_field_settings_tabs') {
5322 ulClass = 'acf-field-settings-tab-bar';
5323 }
5324 this.$el = $('<div class="acf-tab-wrap -' + placement + '"><ul class="' + ulClass + '"></ul></div>');
5325 }
5326
5327 // append
5328 $before.before(this.$el);
5329
5330 // set index
5331 this.set('index', i, true);
5332 i++;
5333 },
5334 initializeTabs: function () {
5335 // Bail if tabs are disabled.
5336 if ('acf_field_settings_tabs' === this.get('key') && $('#acf-field-group-fields').hasClass('hide-tabs')) {
5337 return;
5338 }
5339 var tab = false;
5340
5341 // check if we've got a saved default tab.
5342 var order = acf.getPreference('this.tabs') || false;
5343 if (order) {
5344 var groupIndex = this.get('index');
5345 var tabIndex = order[groupIndex];
5346 if (this.tabs[tabIndex] && this.tabs[tabIndex].isVisible()) {
5347 tab = this.tabs[tabIndex];
5348 }
5349 }
5350
5351 // If we've got a defaultTab provided by configuration, use that.
5352 if (!tab && this.data.defaultTab && this.data.defaultTab.isVisible()) {
5353 tab = this.data.defaultTab;
5354 }
5355
5356 // find first visible tab as our default.
5357 if (!tab) {
5358 tab = this.getVisible().shift();
5359 }
5360 if (tab) {
5361 this.selectTab(tab);
5362 } else {
5363 this.closeTabs();
5364 }
5365
5366 // set local variable used by tabsManager
5367 this.set('initialized', true);
5368 },
5369 getVisible: function () {
5370 return this.tabs.filter(function (tab) {
5371 return tab.isVisible();
5372 });
5373 },
5374 getActive: function () {
5375 return this.active;
5376 },
5377 setActive: function (tab) {
5378 return this.active = tab;
5379 },
5380 hasActive: function () {
5381 return this.active !== false;
5382 },
5383 isActive: function (tab) {
5384 var active = this.getActive();
5385 return active && active.cid === tab.cid;
5386 },
5387 closeActive: function () {
5388 if (this.hasActive()) {
5389 this.closeTab(this.getActive());
5390 }
5391 },
5392 openTab: function (tab) {
5393 // close existing tab
5394 this.closeActive();
5395
5396 // open
5397 tab.open();
5398
5399 // set active
5400 this.setActive(tab);
5401 },
5402 closeTab: function (tab) {
5403 // close
5404 tab.close();
5405
5406 // set active
5407 this.setActive(false);
5408 },
5409 closeTabs: function () {
5410 this.tabs.map(this.closeTab, this);
5411 },
5412 selectTab: function (tab) {
5413 // close other tabs
5414 this.tabs.map(function (t) {
5415 if (tab.cid !== t.cid) {
5416 this.closeTab(t);
5417 }
5418 }, this);
5419
5420 // open
5421 this.openTab(tab);
5422 },
5423 addTab: function ($a, field) {
5424 // create <li>
5425 var $li = $('<li>' + $a.outerHTML() + '</li>');
5426
5427 // add settings type class.
5428 var settingsType = $a.data('settings-type');
5429 if (settingsType) {
5430 $li.addClass('acf-settings-type-' + settingsType);
5431 }
5432
5433 // append
5434 this.$('ul').append($li);
5435
5436 // initialize
5437 var tab = new Tab({
5438 $el: $li,
5439 field: field,
5440 group: this
5441 });
5442
5443 // store
5444 this.tabs.push(tab);
5445 if ($a.data('selected')) {
5446 this.data.defaultTab = tab;
5447 }
5448
5449 // return
5450 return tab;
5451 },
5452 reset: function () {
5453 // close existing tab
5454 this.closeActive();
5455
5456 // find and active a tab
5457 return this.refresh();
5458 },
5459 refresh: function () {
5460 // bail early if active already exists
5461 if (this.hasActive()) {
5462 return false;
5463 }
5464 // find next active tab
5465 var tab = this.getVisible().shift();
5466 // open tab
5467 if (tab) {
5468 this.openTab(tab);
5469 }
5470
5471 // return
5472 return tab;
5473 },
5474 onRefresh: function () {
5475 // only for left placements
5476 if (this.get('placement') !== 'left') {
5477 return;
5478 }
5479
5480 // vars
5481 var $parent = this.$el.parent();
5482 var $list = this.$el.children('ul');
5483 var attribute = $parent.is('td') ? 'height' : 'min-height';
5484
5485 // find height (minus 1 for border-bottom)
5486 var height = $list.position().top + $list.outerHeight(true) - 1;
5487
5488 // add css
5489 $parent.css(attribute, height);
5490 },
5491 onCloseFieldObject: function (fieldObject) {
5492 const tab = this.getVisible().find(item => {
5493 const id = item.$el.closest('div[data-id]').data('id');
5494 if (fieldObject.data.id === id) {
5495 return item;
5496 }
5497 });
5498 if (tab) {
5499 // Wait for field group drawer to close
5500 setTimeout(() => {
5501 this.openTab(tab);
5502 }, 300);
5503 }
5504 }
5505 });
5506 var Tab = acf.Model.extend({
5507 group: false,
5508 field: false,
5509 events: {
5510 'click a': 'onClick'
5511 },
5512 index: function () {
5513 return this.$el.index();
5514 },
5515 isVisible: function () {
5516 return acf.isVisible(this.$el);
5517 },
5518 isActive: function () {
5519 return this.$el.hasClass('active');
5520 },
5521 open: function () {
5522 // add class
5523 this.$el.addClass('active');
5524
5525 // show field
5526 this.field.showFields();
5527 },
5528 close: function () {
5529 // remove class
5530 this.$el.removeClass('active');
5531
5532 // hide field
5533 this.field.hideFields();
5534 },
5535 onClick: function (e, $el) {
5536 // prevent default
5537 e.preventDefault();
5538
5539 // toggle
5540 this.toggle();
5541 },
5542 toggle: function () {
5543 // bail early if already active
5544 if (this.isActive()) {
5545 return;
5546 }
5547
5548 // toggle this tab
5549 this.group.openTab(this);
5550 }
5551 });
5552 var tabsManager = new acf.Model({
5553 priority: 50,
5554 actions: {
5555 prepare: 'render',
5556 append: 'render',
5557 unload: 'onUnload',
5558 show: 'render',
5559 invalid_field: 'onInvalidField'
5560 },
5561 findTabs: function () {
5562 return $('.acf-tab-wrap');
5563 },
5564 getTabs: function () {
5565 return acf.getInstances(this.findTabs());
5566 },
5567 render: function ($el) {
5568 this.getTabs().map(function (tabs) {
5569 if (!tabs.get('initialized')) {
5570 tabs.initializeTabs();
5571 }
5572 });
5573 },
5574 onInvalidField: function (field) {
5575 // bail early if busy
5576 if (this.busy) {
5577 return;
5578 }
5579
5580 // ignore if not hidden by tab
5581 if (!field.hiddenByTab) {
5582 return;
5583 }
5584
5585 // toggle tab
5586 field.hiddenByTab.toggle();
5587
5588 // ignore other invalid fields
5589 this.busy = true;
5590 this.setTimeout(function () {
5591 this.busy = false;
5592 }, 100);
5593 },
5594 onUnload: function () {
5595 // vars
5596 var order = [];
5597
5598 // loop
5599 this.getTabs().map(function (group) {
5600 // Do not save selected tab on field settings, or an acf-advanced-settings when unloading
5601 if (group.$el.children('.acf-field-settings-tab-bar').length || group.$el.parents('#acf-advanced-settings.postbox').length) {
5602 return true;
5603 }
5604 var active = group.hasActive() ? group.getActive().index() : 0;
5605 order.push(active);
5606 });
5607
5608 // bail if no tabs
5609 if (!order.length) {
5610 return;
5611 }
5612
5613 // update
5614 acf.setPreference('this.tabs', order);
5615 }
5616 });
5617 })(jQuery);
5618
5619 /***/ }),
5620
5621 /***/ "./assets/src/js/_acf-field-taxonomy.js":
5622 /*!**********************************************!*\
5623 !*** ./assets/src/js/_acf-field-taxonomy.js ***!
5624 \**********************************************/
5625 /***/ (() => {
5626
5627 (function ($, undefined) {
5628 var Field = acf.Field.extend({
5629 type: 'taxonomy',
5630 data: {
5631 ftype: 'select'
5632 },
5633 select2: false,
5634 wait: 'load',
5635 events: {
5636 'click a[data-name="add"]': 'onClickAdd',
5637 'click input[type="radio"]': 'onClickRadio',
5638 removeField: 'onRemove'
5639 },
5640 $control: function () {
5641 return this.$('.acf-taxonomy-field');
5642 },
5643 $input: function () {
5644 return this.getRelatedPrototype().$input.apply(this, arguments);
5645 },
5646 getRelatedType: function () {
5647 // vars
5648 var fieldType = this.get('ftype');
5649
5650 // normalize
5651 if (fieldType == 'multi_select') {
5652 fieldType = 'select';
5653 }
5654
5655 // return
5656 return fieldType;
5657 },
5658 getRelatedPrototype: function () {
5659 return acf.getFieldType(this.getRelatedType()).prototype;
5660 },
5661 getValue: function () {
5662 return this.getRelatedPrototype().getValue.apply(this, arguments);
5663 },
5664 setValue: function () {
5665 return this.getRelatedPrototype().setValue.apply(this, arguments);
5666 },
5667 initialize: function () {
5668 this.getRelatedPrototype().initialize.apply(this, arguments);
5669 },
5670 onRemove: function () {
5671 var proto = this.getRelatedPrototype();
5672 if (proto.onRemove) {
5673 proto.onRemove.apply(this, arguments);
5674 }
5675 },
5676 onClickAdd: function (e, $el) {
5677 // vars
5678 var field = this;
5679 var popup = false;
5680 var $form = false;
5681 var $name = false;
5682 var $parent = false;
5683 var $button = false;
5684 var $message = false;
5685 var notice = false;
5686
5687 // step 1.
5688 var step1 = function () {
5689 // popup
5690 popup = acf.newPopup({
5691 title: $el.attr('title'),
5692 loading: true,
5693 width: '300px'
5694 });
5695
5696 // ajax
5697 var ajaxData = {
5698 action: 'acf/fields/taxonomy/add_term',
5699 field_key: field.get('key'),
5700 nonce: field.get('nonce')
5701 };
5702
5703 // get HTML
5704 $.ajax({
5705 url: acf.get('ajaxurl'),
5706 data: acf.prepareForAjax(ajaxData),
5707 type: 'post',
5708 dataType: 'html',
5709 success: step2
5710 });
5711 };
5712
5713 // step 2.
5714 var step2 = function (html) {
5715 // update popup
5716 popup.loading(false);
5717 popup.content(html);
5718
5719 // vars
5720 $form = popup.$('form');
5721 $name = popup.$('input[name="term_name"]');
5722 $parent = popup.$('select[name="term_parent"]');
5723 $button = popup.$('.acf-submit-button');
5724
5725 // focus
5726 $name.trigger('focus');
5727
5728 // submit form
5729 popup.on('submit', 'form', step3);
5730 };
5731
5732 // step 3.
5733 var step3 = function (e, $el) {
5734 // prevent
5735 e.preventDefault();
5736 e.stopImmediatePropagation();
5737
5738 // basic validation
5739 if ($name.val() === '') {
5740 $name.trigger('focus');
5741 return false;
5742 }
5743
5744 // disable
5745 acf.startButtonLoading($button);
5746
5747 // ajax
5748 var ajaxData = {
5749 action: 'acf/fields/taxonomy/add_term',
5750 field_key: field.get('key'),
5751 nonce: field.get('nonce'),
5752 term_name: $name.val(),
5753 term_parent: $parent.length ? $parent.val() : 0
5754 };
5755 $.ajax({
5756 url: acf.get('ajaxurl'),
5757 data: acf.prepareForAjax(ajaxData),
5758 type: 'post',
5759 dataType: 'json',
5760 success: step4
5761 });
5762 };
5763
5764 // step 4.
5765 var step4 = function (json) {
5766 // enable
5767 acf.stopButtonLoading($button);
5768
5769 // remove prev notice
5770 if (notice) {
5771 notice.remove();
5772 }
5773
5774 // success
5775 if (acf.isAjaxSuccess(json)) {
5776 // clear name
5777 $name.val('');
5778
5779 // update term lists
5780 step5(json.data);
5781
5782 // notice
5783 notice = acf.newNotice({
5784 type: 'success',
5785 text: acf.getAjaxMessage(json),
5786 target: $form,
5787 timeout: 2000,
5788 dismiss: false
5789 });
5790 } else {
5791 // notice
5792 notice = acf.newNotice({
5793 type: 'error',
5794 text: acf.getAjaxError(json),
5795 target: $form,
5796 timeout: 2000,
5797 dismiss: false
5798 });
5799 }
5800
5801 // focus
5802 $name.trigger('focus');
5803 };
5804
5805 // step 5.
5806 var step5 = function (term) {
5807 // update parent dropdown
5808 var $option = $('<option value="' + term.term_id + '">' + term.term_label + '</option>');
5809 if (term.term_parent) {
5810 $parent.children('option[value="' + term.term_parent + '"]').after($option);
5811 } else {
5812 $parent.append($option);
5813 }
5814
5815 // add this new term to all taxonomy field
5816 var fields = acf.getFields({
5817 type: 'taxonomy'
5818 });
5819 fields.map(function (otherField) {
5820 if (otherField.get('taxonomy') == field.get('taxonomy')) {
5821 otherField.appendTerm(term);
5822 }
5823 });
5824
5825 // select
5826 field.selectTerm(term.term_id);
5827 };
5828
5829 // run
5830 step1();
5831 },
5832 appendTerm: function (term) {
5833 if (this.getRelatedType() == 'select') {
5834 this.appendTermSelect(term);
5835 } else {
5836 this.appendTermCheckbox(term);
5837 }
5838 },
5839 appendTermSelect: function (term) {
5840 this.select2.addOption({
5841 id: term.term_id,
5842 text: term.term_label
5843 });
5844 },
5845 appendTermCheckbox: function (term) {
5846 // vars
5847 var name = this.$('[name]:first').attr('name');
5848 var $ul = this.$('ul:first');
5849
5850 // allow multiple selection
5851 if (this.getRelatedType() == 'checkbox') {
5852 name += '[]';
5853 }
5854
5855 // create new li
5856 var $li = $(['<li data-id="' + term.term_id + '">', '<label>', '<input type="' + this.get('ftype') + '" value="' + term.term_id + '" name="' + name + '" /> ', '<span>' + term.term_name + '</span>', '</label>', '</li>'].join(''));
5857
5858 // find parent
5859 if (term.term_parent) {
5860 // vars
5861 var $parent = $ul.find('li[data-id="' + term.term_parent + '"]');
5862
5863 // update vars
5864 $ul = $parent.children('ul');
5865
5866 // create ul
5867 if (!$ul.exists()) {
5868 $ul = $('<ul class="children acf-bl"></ul>');
5869 $parent.append($ul);
5870 }
5871 }
5872
5873 // append
5874 $ul.append($li);
5875 },
5876 selectTerm: function (id) {
5877 if (this.getRelatedType() == 'select') {
5878 this.select2.selectOption(id);
5879 } else {
5880 var $input = this.$('input[value="' + id + '"]');
5881 $input.prop('checked', true).trigger('change');
5882 }
5883 },
5884 onClickRadio: function (e, $el) {
5885 // vars
5886 var $label = $el.parent('label');
5887 var selected = $label.hasClass('selected');
5888
5889 // remove previous selected
5890 this.$('.selected').removeClass('selected');
5891
5892 // add active class
5893 $label.addClass('selected');
5894
5895 // allow null
5896 if (this.get('allow_null') && selected) {
5897 $label.removeClass('selected');
5898 $el.prop('checked', false).trigger('change');
5899 }
5900 }
5901 });
5902 acf.registerFieldType(Field);
5903 })(jQuery);
5904
5905 /***/ }),
5906
5907 /***/ "./assets/src/js/_acf-field-time-picker.js":
5908 /*!*************************************************!*\
5909 !*** ./assets/src/js/_acf-field-time-picker.js ***!
5910 \*************************************************/
5911 /***/ (() => {
5912
5913 (function ($, undefined) {
5914 var Field = acf.models.DatePickerField.extend({
5915 type: 'time_picker',
5916 $control: function () {
5917 return this.$('.acf-time-picker');
5918 },
5919 initialize: function () {
5920 // vars
5921 var $input = this.$input();
5922 var $inputText = this.$inputText();
5923
5924 // args
5925 var args = {
5926 timeFormat: this.get('time_format'),
5927 altField: $input,
5928 altFieldTimeOnly: false,
5929 altTimeFormat: 'HH:mm:ss',
5930 showButtonPanel: true,
5931 controlType: 'select',
5932 oneLine: true,
5933 closeText: acf.get('dateTimePickerL10n').selectText,
5934 timeOnly: true
5935 };
5936
5937 // add custom 'Close = Select' functionality
5938 args.onClose = function (value, dp_instance, t_instance) {
5939 // vars
5940 var $close = dp_instance.dpDiv.find('.ui-datepicker-close');
5941
5942 // if clicking close button
5943 if (!value && $close.is(':hover')) {
5944 t_instance._updateDateTime();
5945 }
5946 };
5947
5948 // filter
5949 args = acf.applyFilters('time_picker_args', args, this);
5950
5951 // add date time picker
5952 acf.newTimePicker($inputText, args);
5953
5954 // action
5955 acf.doAction('time_picker_init', $inputText, args, this);
5956 }
5957 });
5958 acf.registerFieldType(Field);
5959
5960 // add
5961 acf.newTimePicker = function ($input, args) {
5962 // bail early if no datepicker library
5963 if (typeof $.timepicker === 'undefined') {
5964 return false;
5965 }
5966
5967 // defaults
5968 args = args || {};
5969
5970 // initialize
5971 $input.timepicker(args);
5972
5973 // wrap the datepicker (only if it hasn't already been wrapped)
5974 if ($('body > #ui-datepicker-div').exists()) {
5975 $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
5976 }
5977 };
5978 })(jQuery);
5979
5980 /***/ }),
5981
5982 /***/ "./assets/src/js/_acf-field-true-false.js":
5983 /*!************************************************!*\
5984 !*** ./assets/src/js/_acf-field-true-false.js ***!
5985 \************************************************/
5986 /***/ (() => {
5987
5988 (function ($, undefined) {
5989 var Field = acf.Field.extend({
5990 type: 'true_false',
5991 events: {
5992 'change .acf-switch-input': 'onChange',
5993 'focus .acf-switch-input': 'onFocus',
5994 'blur .acf-switch-input': 'onBlur',
5995 'keypress .acf-switch-input': 'onKeypress'
5996 },
5997 $input: function () {
5998 return this.$('input[type="checkbox"]');
5999 },
6000 $switch: function () {
6001 return this.$('.acf-switch');
6002 },
6003 getValue: function () {
6004 return this.$input().prop('checked') ? 1 : 0;
6005 },
6006 initialize: function () {
6007 this.render();
6008 },
6009 render: function () {
6010 // vars
6011 var $switch = this.$switch();
6012
6013 // bail early if no $switch
6014 if (!$switch.length) return;
6015
6016 // vars
6017 var $on = $switch.children('.acf-switch-on');
6018 var $off = $switch.children('.acf-switch-off');
6019 var width = Math.max($on.width(), $off.width());
6020
6021 // bail early if no width
6022 if (!width) return;
6023
6024 // set widths
6025 $on.css('min-width', width);
6026 $off.css('min-width', width);
6027 },
6028 switchOn: function () {
6029 this.$input().prop('checked', true);
6030 this.$switch().addClass('-on');
6031 },
6032 switchOff: function () {
6033 this.$input().prop('checked', false);
6034 this.$switch().removeClass('-on');
6035 },
6036 onChange: function (e, $el) {
6037 if ($el.prop('checked')) {
6038 this.switchOn();
6039 } else {
6040 this.switchOff();
6041 }
6042 },
6043 onFocus: function (e, $el) {
6044 this.$switch().addClass('-focus');
6045 },
6046 onBlur: function (e, $el) {
6047 this.$switch().removeClass('-focus');
6048 },
6049 onKeypress: function (e, $el) {
6050 // left
6051 if (e.keyCode === 37) {
6052 return this.switchOff();
6053 }
6054
6055 // right
6056 if (e.keyCode === 39) {
6057 return this.switchOn();
6058 }
6059 }
6060 });
6061 acf.registerFieldType(Field);
6062 })(jQuery);
6063
6064 /***/ }),
6065
6066 /***/ "./assets/src/js/_acf-field-url.js":
6067 /*!*****************************************!*\
6068 !*** ./assets/src/js/_acf-field-url.js ***!
6069 \*****************************************/
6070 /***/ (() => {
6071
6072 (function ($, undefined) {
6073 var Field = acf.Field.extend({
6074 type: 'url',
6075 events: {
6076 'keyup input[type="url"]': 'onkeyup'
6077 },
6078 $control: function () {
6079 return this.$('.acf-input-wrap');
6080 },
6081 $input: function () {
6082 return this.$('input[type="url"]');
6083 },
6084 initialize: function () {
6085 this.render();
6086 },
6087 isValid: function () {
6088 // vars
6089 var val = this.val();
6090
6091 // bail early if no val
6092 if (!val) {
6093 return false;
6094 }
6095
6096 // url
6097 if (val.indexOf('://') !== -1) {
6098 return true;
6099 }
6100
6101 // protocol relative url
6102 if (val.indexOf('//') === 0) {
6103 return true;
6104 }
6105
6106 // return
6107 return false;
6108 },
6109 render: function () {
6110 // add class
6111 if (this.isValid()) {
6112 this.$control().addClass('-valid');
6113 } else {
6114 this.$control().removeClass('-valid');
6115 }
6116 },
6117 onkeyup: function (e, $el) {
6118 this.render();
6119 }
6120 });
6121 acf.registerFieldType(Field);
6122 })(jQuery);
6123
6124 /***/ }),
6125
6126 /***/ "./assets/src/js/_acf-field-user.js":
6127 /*!******************************************!*\
6128 !*** ./assets/src/js/_acf-field-user.js ***!
6129 \******************************************/
6130 /***/ (() => {
6131
6132 (function ($, undefined) {
6133 var Field = acf.models.SelectField.extend({
6134 type: 'user'
6135 });
6136 acf.registerFieldType(Field);
6137 })(jQuery);
6138
6139 /***/ }),
6140
6141 /***/ "./assets/src/js/_acf-field-wysiwyg.js":
6142 /*!*********************************************!*\
6143 !*** ./assets/src/js/_acf-field-wysiwyg.js ***!
6144 \*********************************************/
6145 /***/ (() => {
6146
6147 (function ($, undefined) {
6148 var Field = acf.Field.extend({
6149 type: 'wysiwyg',
6150 wait: 'load',
6151 events: {
6152 'mousedown .acf-editor-wrap.delay': 'onMousedown',
6153 unmountField: 'disableEditor',
6154 remountField: 'enableEditor',
6155 removeField: 'disableEditor'
6156 },
6157 $control: function () {
6158 return this.$('.acf-editor-wrap');
6159 },
6160 $input: function () {
6161 return this.$('textarea');
6162 },
6163 getMode: function () {
6164 return this.$control().hasClass('tmce-active') ? 'visual' : 'text';
6165 },
6166 initialize: function () {
6167 // initializeEditor if no delay
6168 if (!this.$control().hasClass('delay')) {
6169 this.initializeEditor();
6170 }
6171 },
6172 initializeEditor: function () {
6173 // vars
6174 var $wrap = this.$control();
6175 var $textarea = this.$input();
6176 var args = {
6177 tinymce: true,
6178 quicktags: true,
6179 toolbar: this.get('toolbar'),
6180 mode: this.getMode(),
6181 field: this
6182 };
6183
6184 // generate new id
6185 var oldId = $textarea.attr('id');
6186 var newId = acf.uniqueId('acf-editor-');
6187
6188 // Backup textarea data.
6189 var inputData = $textarea.data();
6190 var inputVal = $textarea.val();
6191
6192 // rename
6193 acf.rename({
6194 target: $wrap,
6195 search: oldId,
6196 replace: newId,
6197 destructive: true
6198 });
6199
6200 // update id
6201 this.set('id', newId, true);
6202
6203 // apply data to new textarea (acf.rename creates a new textarea element due to destructive mode)
6204 // fixes bug where conditional logic "disabled" is lost during "screen_check"
6205 this.$input().data(inputData).val(inputVal);
6206
6207 // initialize
6208 acf.tinymce.initialize(newId, args);
6209 },
6210 onMousedown: function (e) {
6211 // prevent default
6212 e.preventDefault();
6213
6214 // remove delay class
6215 var $wrap = this.$control();
6216 $wrap.removeClass('delay');
6217 $wrap.find('.acf-editor-toolbar').remove();
6218
6219 // initialize
6220 this.initializeEditor();
6221 },
6222 enableEditor: function () {
6223 if (this.getMode() == 'visual') {
6224 acf.tinymce.enable(this.get('id'));
6225 }
6226 },
6227 disableEditor: function () {
6228 acf.tinymce.destroy(this.get('id'));
6229 }
6230 });
6231 acf.registerFieldType(Field);
6232 })(jQuery);
6233
6234 /***/ }),
6235
6236 /***/ "./assets/src/js/_acf-field.js":
6237 /*!*************************************!*\
6238 !*** ./assets/src/js/_acf-field.js ***!
6239 \*************************************/
6240 /***/ (() => {
6241
6242 (function ($, undefined) {
6243 // vars
6244 var storage = [];
6245
6246 /**
6247 * acf.Field
6248 *
6249 * description
6250 *
6251 * @date 23/3/18
6252 * @since ACF 5.6.9
6253 *
6254 * @param type $var Description. Default.
6255 * @return type Description.
6256 */
6257
6258 acf.Field = acf.Model.extend({
6259 // field type
6260 type: '',
6261 // class used to avoid nested event triggers
6262 eventScope: '.acf-field',
6263 // initialize events on 'ready'
6264 wait: 'ready',
6265 /**
6266 * setup
6267 *
6268 * Called during the constructor function to setup this field ready for initialization
6269 *
6270 * @date 8/5/18
6271 * @since ACF 5.6.9
6272 *
6273 * @param jQuery $field The field element.
6274 * @return void
6275 */
6276
6277 setup: function ($field) {
6278 // set $el
6279 this.$el = $field;
6280
6281 // inherit $field data
6282 this.inherit($field);
6283
6284 // inherit control data
6285 this.inherit(this.$control());
6286 },
6287 /**
6288 * val
6289 *
6290 * Sets or returns the field's value
6291 *
6292 * @date 8/5/18
6293 * @since ACF 5.6.9
6294 *
6295 * @param mixed val Optional. The value to set
6296 * @return mixed
6297 */
6298
6299 val: function (val) {
6300 // Set.
6301 if (val !== undefined) {
6302 return this.setValue(val);
6303
6304 // Get.
6305 } else {
6306 return this.prop('disabled') ? null : this.getValue();
6307 }
6308 },
6309 /**
6310 * getValue
6311 *
6312 * returns the field's value
6313 *
6314 * @date 8/5/18
6315 * @since ACF 5.6.9
6316 *
6317 * @param void
6318 * @return mixed
6319 */
6320
6321 getValue: function () {
6322 return this.$input().val();
6323 },
6324 /**
6325 * setValue
6326 *
6327 * sets the field's value and returns true if changed
6328 *
6329 * @date 8/5/18
6330 * @since ACF 5.6.9
6331 *
6332 * @param mixed val
6333 * @return boolean. True if changed.
6334 */
6335
6336 setValue: function (val) {
6337 return acf.val(this.$input(), val);
6338 },
6339 /**
6340 * __
6341 *
6342 * i18n helper to be removed
6343 *
6344 * @date 8/5/18
6345 * @since ACF 5.6.9
6346 *
6347 * @param type $var Description. Default.
6348 * @return type Description.
6349 */
6350
6351 __: function (string) {
6352 return acf._e(this.type, string);
6353 },
6354 /**
6355 * $control
6356 *
6357 * returns the control jQuery element used for inheriting data. Uses this.control setting.
6358 *
6359 * @date 8/5/18
6360 * @since ACF 5.6.9
6361 *
6362 * @param void
6363 * @return jQuery
6364 */
6365
6366 $control: function () {
6367 return false;
6368 },
6369 /**
6370 * $input
6371 *
6372 * returns the input jQuery element used for saving values. Uses this.input setting.
6373 *
6374 * @date 8/5/18
6375 * @since ACF 5.6.9
6376 *
6377 * @param void
6378 * @return jQuery
6379 */
6380
6381 $input: function () {
6382 return this.$('[name]:first');
6383 },
6384 /**
6385 * $inputWrap
6386 *
6387 * description
6388 *
6389 * @date 12/5/18
6390 * @since ACF 5.6.9
6391 *
6392 * @param type $var Description. Default.
6393 * @return type Description.
6394 */
6395
6396 $inputWrap: function () {
6397 return this.$('.acf-input:first');
6398 },
6399 /**
6400 * $inputWrap
6401 *
6402 * description
6403 *
6404 * @date 12/5/18
6405 * @since ACF 5.6.9
6406 *
6407 * @param type $var Description. Default.
6408 * @return type Description.
6409 */
6410
6411 $labelWrap: function () {
6412 return this.$('.acf-label:first');
6413 },
6414 /**
6415 * getInputName
6416 *
6417 * Returns the field's input name
6418 *
6419 * @date 8/5/18
6420 * @since ACF 5.6.9
6421 *
6422 * @param void
6423 * @return string
6424 */
6425
6426 getInputName: function () {
6427 return this.$input().attr('name') || '';
6428 },
6429 /**
6430 * parent
6431 *
6432 * returns the field's parent field or false on failure.
6433 *
6434 * @date 8/5/18
6435 * @since ACF 5.6.9
6436 *
6437 * @param void
6438 * @return object|false
6439 */
6440
6441 parent: function () {
6442 // vars
6443 var parents = this.parents();
6444
6445 // return
6446 return parents.length ? parents[0] : false;
6447 },
6448 /**
6449 * parents
6450 *
6451 * description
6452 *
6453 * @date 9/7/18
6454 * @since ACF 5.6.9
6455 *
6456 * @param type $var Description. Default.
6457 * @return type Description.
6458 */
6459
6460 parents: function () {
6461 // vars
6462 var $parents = this.$el.parents('.acf-field');
6463
6464 // convert
6465 var parents = acf.getFields($parents);
6466
6467 // return
6468 return parents;
6469 },
6470 show: function (lockKey, context) {
6471 // show field and store result
6472 var changed = acf.show(this.$el, lockKey);
6473
6474 // do action if visibility has changed
6475 if (changed) {
6476 this.prop('hidden', false);
6477 acf.doAction('show_field', this, context);
6478 if (context === 'conditional_logic') {
6479 this.setFieldSettingsLastVisible();
6480 }
6481 }
6482
6483 // return
6484 return changed;
6485 },
6486 hide: function (lockKey, context) {
6487 // hide field and store result
6488 var changed = acf.hide(this.$el, lockKey);
6489
6490 // do action if visibility has changed
6491 if (changed) {
6492 this.prop('hidden', true);
6493 acf.doAction('hide_field', this, context);
6494 if (context === 'conditional_logic') {
6495 this.setFieldSettingsLastVisible();
6496 }
6497 }
6498
6499 // return
6500 return changed;
6501 },
6502 setFieldSettingsLastVisible: function () {
6503 // Ensure this conditional logic trigger has happened inside a field settings tab.
6504 var $parents = this.$el.parents('.acf-field-settings-main');
6505 if (!$parents.length) return;
6506 var $fields = $parents.find('.acf-field');
6507 $fields.removeClass('acf-last-visible');
6508 $fields.not('.acf-hidden').last().addClass('acf-last-visible');
6509 },
6510 enable: function (lockKey, context) {
6511 // enable field and store result
6512 var changed = acf.enable(this.$el, lockKey);
6513
6514 // do action if disabled has changed
6515 if (changed) {
6516 this.prop('disabled', false);
6517 acf.doAction('enable_field', this, context);
6518 }
6519
6520 // return
6521 return changed;
6522 },
6523 disable: function (lockKey, context) {
6524 // disabled field and store result
6525 var changed = acf.disable(this.$el, lockKey);
6526
6527 // do action if disabled has changed
6528 if (changed) {
6529 this.prop('disabled', true);
6530 acf.doAction('disable_field', this, context);
6531 }
6532
6533 // return
6534 return changed;
6535 },
6536 showEnable: function (lockKey, context) {
6537 // enable
6538 this.enable.apply(this, arguments);
6539
6540 // show and return true if changed
6541 return this.show.apply(this, arguments);
6542 },
6543 hideDisable: function (lockKey, context) {
6544 // disable
6545 this.disable.apply(this, arguments);
6546
6547 // hide and return true if changed
6548 return this.hide.apply(this, arguments);
6549 },
6550 showNotice: function (props) {
6551 // ensure object
6552 if (typeof props !== 'object') {
6553 props = {
6554 text: props
6555 };
6556 }
6557
6558 // remove old notice
6559 if (this.notice) {
6560 this.notice.remove();
6561 }
6562
6563 // create new notice
6564 props.target = this.$inputWrap();
6565 this.notice = acf.newNotice(props);
6566 },
6567 removeNotice: function (timeout) {
6568 if (this.notice) {
6569 this.notice.away(timeout || 0);
6570 this.notice = false;
6571 }
6572 },
6573 showError: function (message, location = 'before') {
6574 // add class
6575 this.$el.addClass('acf-error');
6576
6577 // add message
6578 if (message !== undefined) {
6579 this.showNotice({
6580 text: message,
6581 type: 'error',
6582 dismiss: false,
6583 location: location
6584 });
6585 }
6586
6587 // action
6588 acf.doAction('invalid_field', this);
6589
6590 // add event
6591 this.$el.one('focus change', 'input, select, textarea', $.proxy(this.removeError, this));
6592 },
6593 removeError: function () {
6594 // remove class
6595 this.$el.removeClass('acf-error');
6596
6597 // remove notice
6598 this.removeNotice(250);
6599
6600 // action
6601 acf.doAction('valid_field', this);
6602 },
6603 trigger: function (name, args, bubbles) {
6604 // allow some events to bubble
6605 if (name == 'invalidField') {
6606 bubbles = true;
6607 }
6608
6609 // return
6610 return acf.Model.prototype.trigger.apply(this, [name, args, bubbles]);
6611 }
6612 });
6613
6614 /**
6615 * newField
6616 *
6617 * description
6618 *
6619 * @date 14/12/17
6620 * @since ACF 5.6.5
6621 *
6622 * @param type $var Description. Default.
6623 * @return type Description.
6624 */
6625
6626 acf.newField = function ($field) {
6627 // vars
6628 var type = $field.data('type');
6629 var mid = modelId(type);
6630 var model = acf.models[mid] || acf.Field;
6631
6632 // instantiate
6633 var field = new model($field);
6634
6635 // actions
6636 acf.doAction('new_field', field);
6637
6638 // return
6639 return field;
6640 };
6641
6642 /**
6643 * mid
6644 *
6645 * Calculates the model ID for a field type
6646 *
6647 * @date 15/12/17
6648 * @since ACF 5.6.5
6649 *
6650 * @param string type
6651 * @return string
6652 */
6653
6654 var modelId = function (type) {
6655 return acf.strPascalCase(type || '') + 'Field';
6656 };
6657
6658 /**
6659 * registerFieldType
6660 *
6661 * description
6662 *
6663 * @date 14/12/17
6664 * @since ACF 5.6.5
6665 *
6666 * @param type $var Description. Default.
6667 * @return type Description.
6668 */
6669
6670 acf.registerFieldType = function (model) {
6671 // vars
6672 var proto = model.prototype;
6673 var type = proto.type;
6674 var mid = modelId(type);
6675
6676 // store model
6677 acf.models[mid] = model;
6678
6679 // store reference
6680 storage.push(type);
6681 };
6682
6683 /**
6684 * acf.getFieldType
6685 *
6686 * description
6687 *
6688 * @date 1/2/18
6689 * @since ACF 5.6.5
6690 *
6691 * @param type $var Description. Default.
6692 * @return type Description.
6693 */
6694
6695 acf.getFieldType = function (type) {
6696 var mid = modelId(type);
6697 return acf.models[mid] || false;
6698 };
6699
6700 /**
6701 * acf.getFieldTypes
6702 *
6703 * description
6704 *
6705 * @date 1/2/18
6706 * @since ACF 5.6.5
6707 *
6708 * @param type $var Description. Default.
6709 * @return type Description.
6710 */
6711
6712 acf.getFieldTypes = function (args) {
6713 // defaults
6714 args = acf.parseArgs(args, {
6715 category: ''
6716 // hasValue: true
6717 });
6718
6719 // clone available types
6720 var types = [];
6721
6722 // loop
6723 storage.map(function (type) {
6724 // vars
6725 var model = acf.getFieldType(type);
6726 var proto = model.prototype;
6727
6728 // check operator
6729 if (args.category && proto.category !== args.category) {
6730 return;
6731 }
6732
6733 // append
6734 types.push(model);
6735 });
6736
6737 // return
6738 return types;
6739 };
6740 })(jQuery);
6741
6742 /***/ }),
6743
6744 /***/ "./assets/src/js/_acf-fields.js":
6745 /*!**************************************!*\
6746 !*** ./assets/src/js/_acf-fields.js ***!
6747 \**************************************/
6748 /***/ (() => {
6749
6750 (function ($, undefined) {
6751 /**
6752 * findFields
6753 *
6754 * Returns a jQuery selection object of acf fields.
6755 *
6756 * @date 14/12/17
6757 * @since ACF 5.6.5
6758 *
6759 * @param object $args {
6760 * Optional. Arguments to find fields.
6761 *
6762 * @type string key The field's key (data-attribute).
6763 * @type string name The field's name (data-attribute).
6764 * @type string type The field's type (data-attribute).
6765 * @type string is jQuery selector to compare against.
6766 * @type jQuery parent jQuery element to search within.
6767 * @type jQuery sibling jQuery element to search alongside.
6768 * @type limit int The number of fields to find.
6769 * @type suppressFilters bool Whether to allow filters to add/remove results. Default behaviour will ignore clone fields.
6770 * }
6771 * @return jQuery
6772 */
6773
6774 acf.findFields = function (args) {
6775 // vars
6776 var selector = '.acf-field';
6777 var $fields = false;
6778
6779 // args
6780 args = acf.parseArgs(args, {
6781 key: '',
6782 name: '',
6783 type: '',
6784 is: '',
6785 parent: false,
6786 sibling: false,
6787 limit: false,
6788 visible: false,
6789 suppressFilters: false,
6790 excludeSubFields: false
6791 });
6792
6793 // filter args
6794 if (!args.suppressFilters) {
6795 args = acf.applyFilters('find_fields_args', args);
6796 }
6797
6798 // key
6799 if (args.key) {
6800 selector += '[data-key="' + args.key + '"]';
6801 }
6802
6803 // type
6804 if (args.type) {
6805 selector += '[data-type="' + args.type + '"]';
6806 }
6807
6808 // name
6809 if (args.name) {
6810 selector += '[data-name="' + args.name + '"]';
6811 }
6812
6813 // is
6814 if (args.is) {
6815 selector += args.is;
6816 }
6817
6818 // visibility
6819 if (args.visible) {
6820 selector += ':visible';
6821 }
6822 if (!args.suppressFilters) {
6823 selector = acf.applyFilters('find_fields_selector', selector, args);
6824 }
6825
6826 // query
6827 if (args.parent) {
6828 $fields = args.parent.find(selector);
6829 // exclude sub fields if required (only if a parent is provided)
6830 if (args.excludeSubFields) {
6831 $fields = $fields.not(args.parent.find('.acf-is-subfields .acf-field'));
6832 }
6833 } else if (args.sibling) {
6834 $fields = args.sibling.siblings(selector);
6835 } else {
6836 $fields = $(selector);
6837 }
6838
6839 // filter
6840 if (!args.suppressFilters) {
6841 $fields = $fields.not('.acf-clone .acf-field');
6842 $fields = acf.applyFilters('find_fields', $fields);
6843 }
6844
6845 // limit
6846 if (args.limit) {
6847 $fields = $fields.slice(0, args.limit);
6848 }
6849
6850 // return
6851 return $fields;
6852 };
6853
6854 /**
6855 * findField
6856 *
6857 * Finds a specific field with jQuery
6858 *
6859 * @date 14/12/17
6860 * @since ACF 5.6.5
6861 *
6862 * @param string key The field's key.
6863 * @param jQuery $parent jQuery element to search within.
6864 * @return jQuery
6865 */
6866
6867 acf.findField = function (key, $parent) {
6868 return acf.findFields({
6869 key: key,
6870 limit: 1,
6871 parent: $parent,
6872 suppressFilters: true
6873 });
6874 };
6875
6876 /**
6877 * getField
6878 *
6879 * Returns a field instance
6880 *
6881 * @date 14/12/17
6882 * @since ACF 5.6.5
6883 *
6884 * @param jQuery|string $field jQuery element or field key.
6885 * @return object
6886 */
6887
6888 acf.getField = function ($field) {
6889 // allow jQuery
6890 if ($field instanceof jQuery) {
6891 // find fields
6892 } else {
6893 $field = acf.findField($field);
6894 }
6895
6896 // instantiate
6897 var field = $field.data('acf');
6898 if (!field) {
6899 field = acf.newField($field);
6900 }
6901
6902 // return
6903 return field;
6904 };
6905
6906 /**
6907 * getFields
6908 *
6909 * Returns multiple field instances
6910 *
6911 * @date 14/12/17
6912 * @since ACF 5.6.5
6913 *
6914 * @param jQuery|object $fields jQuery elements or query args.
6915 * @return array
6916 */
6917
6918 acf.getFields = function ($fields) {
6919 // allow jQuery
6920 if ($fields instanceof jQuery) {
6921 // find fields
6922 } else {
6923 $fields = acf.findFields($fields);
6924 }
6925
6926 // loop
6927 var fields = [];
6928 $fields.each(function () {
6929 var field = acf.getField($(this));
6930 fields.push(field);
6931 });
6932
6933 // return
6934 return fields;
6935 };
6936
6937 /**
6938 * findClosestField
6939 *
6940 * Returns the closest jQuery field element
6941 *
6942 * @date 9/4/18
6943 * @since ACF 5.6.9
6944 *
6945 * @param jQuery $el
6946 * @return jQuery
6947 */
6948
6949 acf.findClosestField = function ($el) {
6950 return $el.closest('.acf-field');
6951 };
6952
6953 /**
6954 * getClosestField
6955 *
6956 * Returns the closest field instance
6957 *
6958 * @date 22/1/18
6959 * @since ACF 5.6.5
6960 *
6961 * @param jQuery $el
6962 * @return object
6963 */
6964
6965 acf.getClosestField = function ($el) {
6966 var $field = acf.findClosestField($el);
6967 return this.getField($field);
6968 };
6969
6970 /**
6971 * addGlobalFieldAction
6972 *
6973 * Sets up callback logic for global field actions
6974 *
6975 * @date 15/6/18
6976 * @since ACF 5.6.9
6977 *
6978 * @param string action
6979 * @return void
6980 */
6981
6982 var addGlobalFieldAction = function (action) {
6983 // vars
6984 var globalAction = action;
6985 var pluralAction = action + '_fields'; // ready_fields
6986 var singleAction = action + '_field'; // ready_field
6987
6988 // global action
6989 var globalCallback = function ($el /*, arg1, arg2, etc*/) {
6990 //console.log( action, arguments );
6991
6992 // get args [$el, ...]
6993 var args = acf.arrayArgs(arguments);
6994 var extraArgs = args.slice(1);
6995
6996 // find fields
6997 var fields = acf.getFields({
6998 parent: $el
6999 });
7000
7001 // check
7002 if (fields.length) {
7003 // pluralAction
7004 var pluralArgs = [pluralAction, fields].concat(extraArgs);
7005 acf.doAction.apply(null, pluralArgs);
7006 }
7007 };
7008
7009 // plural action
7010 var pluralCallback = function (fields /*, arg1, arg2, etc*/) {
7011 //console.log( pluralAction, arguments );
7012
7013 // get args [fields, ...]
7014 var args = acf.arrayArgs(arguments);
7015 var extraArgs = args.slice(1);
7016
7017 // loop
7018 fields.map(function (field, i) {
7019 //setTimeout(function(){
7020 // singleAction
7021 var singleArgs = [singleAction, field].concat(extraArgs);
7022 acf.doAction.apply(null, singleArgs);
7023 //}, i * 100);
7024 });
7025 };
7026
7027 // add actions
7028 acf.addAction(globalAction, globalCallback);
7029 acf.addAction(pluralAction, pluralCallback);
7030
7031 // also add single action
7032 addSingleFieldAction(action);
7033 };
7034
7035 /**
7036 * addSingleFieldAction
7037 *
7038 * Sets up callback logic for single field actions
7039 *
7040 * @date 15/6/18
7041 * @since ACF 5.6.9
7042 *
7043 * @param string action
7044 * @return void
7045 */
7046
7047 var addSingleFieldAction = function (action) {
7048 // vars
7049 var singleAction = action + '_field'; // ready_field
7050 var singleEvent = action + 'Field'; // readyField
7051
7052 // single action
7053 var singleCallback = function (field /*, arg1, arg2, etc*/) {
7054 //console.log( singleAction, arguments );
7055
7056 // get args [field, ...]
7057 var args = acf.arrayArgs(arguments);
7058 var extraArgs = args.slice(1);
7059
7060 // action variations (ready_field/type=image)
7061 var variations = ['type', 'name', 'key'];
7062 variations.map(function (variation) {
7063 // vars
7064 var prefix = '/' + variation + '=' + field.get(variation);
7065
7066 // singleAction
7067 args = [singleAction + prefix, field].concat(extraArgs);
7068 acf.doAction.apply(null, args);
7069 });
7070
7071 // event
7072 if (singleFieldEvents.indexOf(action) > -1) {
7073 field.trigger(singleEvent, extraArgs);
7074 }
7075 };
7076
7077 // add actions
7078 acf.addAction(singleAction, singleCallback);
7079 };
7080
7081 // vars
7082 var globalFieldActions = ['prepare', 'ready', 'load', 'append', 'remove', 'unmount', 'remount', 'sortstart', 'sortstop', 'show', 'hide', 'unload'];
7083 var singleFieldActions = ['valid', 'invalid', 'enable', 'disable', 'new', 'duplicate'];
7084 var singleFieldEvents = ['remove', 'unmount', 'remount', 'sortstart', 'sortstop', 'show', 'hide', 'unload', 'valid', 'invalid', 'enable', 'disable', 'duplicate'];
7085
7086 // add
7087 globalFieldActions.map(addGlobalFieldAction);
7088 singleFieldActions.map(addSingleFieldAction);
7089
7090 /**
7091 * fieldsEventManager
7092 *
7093 * Manages field actions and events
7094 *
7095 * @date 15/12/17
7096 * @since ACF 5.6.5
7097 *
7098 * @param void
7099 * @param void
7100 */
7101
7102 var fieldsEventManager = new acf.Model({
7103 id: 'fieldsEventManager',
7104 events: {
7105 'click .acf-field a[href="#"]': 'onClick',
7106 'change .acf-field': 'onChange'
7107 },
7108 onClick: function (e) {
7109 // prevent default of any link with an href of #
7110 e.preventDefault();
7111 },
7112 onChange: function () {
7113 // preview hack allows post to save with no title or content
7114 $('#_acf_changed').val(1);
7115 if (acf.isGutenbergPostEditor()) {
7116 try {
7117 wp.data.dispatch('core/editor').editPost({
7118 meta: {
7119 _acf_changed: 1
7120 }
7121 });
7122 } catch (error) {
7123 console.log('ACF: Failed to update _acf_changed meta', error);
7124 }
7125 }
7126 }
7127 });
7128 var duplicateFieldsManager = new acf.Model({
7129 id: 'duplicateFieldsManager',
7130 actions: {
7131 duplicate: 'onDuplicate',
7132 duplicate_fields: 'onDuplicateFields'
7133 },
7134 onDuplicate: function ($el, $el2) {
7135 var fields = acf.getFields({
7136 parent: $el
7137 });
7138 if (fields.length) {
7139 var $fields = acf.findFields({
7140 parent: $el2
7141 });
7142 acf.doAction('duplicate_fields', fields, $fields);
7143 }
7144 },
7145 onDuplicateFields: function (fields, duplicates) {
7146 fields.map(function (field, i) {
7147 acf.doAction('duplicate_field', field, $(duplicates[i]));
7148 });
7149 }
7150 });
7151 })(jQuery);
7152
7153 /***/ }),
7154
7155 /***/ "./assets/src/js/_acf-helpers.js":
7156 /*!***************************************!*\
7157 !*** ./assets/src/js/_acf-helpers.js ***!
7158 \***************************************/
7159 /***/ (() => {
7160
7161 (function ($, undefined) {
7162 /**
7163 * refreshHelper
7164 *
7165 * description
7166 *
7167 * @date 1/7/18
7168 * @since ACF 5.6.9
7169 *
7170 * @param type $var Description. Default.
7171 * @return type Description.
7172 */
7173
7174 var refreshHelper = new acf.Model({
7175 priority: 90,
7176 actions: {
7177 new_field: 'refresh',
7178 show_field: 'refresh',
7179 hide_field: 'refresh',
7180 remove_field: 'refresh',
7181 unmount_field: 'refresh',
7182 remount_field: 'refresh'
7183 },
7184 refresh: function () {
7185 acf.refresh();
7186 }
7187 });
7188
7189 /**
7190 * mountHelper
7191 *
7192 * Adds compatibility for the 'unmount' and 'remount' actions added in 5.8.0
7193 *
7194 * @date 7/3/19
7195 * @since ACF 5.7.14
7196 *
7197 * @param void
7198 * @return void
7199 */
7200 var mountHelper = new acf.Model({
7201 priority: 1,
7202 actions: {
7203 sortstart: 'onSortstart',
7204 sortstop: 'onSortstop'
7205 },
7206 onSortstart: function ($item) {
7207 acf.doAction('unmount', $item);
7208 },
7209 onSortstop: function ($item) {
7210 acf.doAction('remount', $item);
7211 }
7212 });
7213
7214 /**
7215 * sortableHelper
7216 *
7217 * Adds compatibility for sorting a <tr> element
7218 *
7219 * @date 6/3/18
7220 * @since ACF 5.6.9
7221 *
7222 * @param void
7223 * @return void
7224 */
7225
7226 var sortableHelper = new acf.Model({
7227 actions: {
7228 sortstart: 'onSortstart'
7229 },
7230 onSortstart: function ($item, $placeholder) {
7231 // if $item is a tr, apply some css to the elements
7232 if ($item.is('tr')) {
7233 // replace $placeholder children with a single td
7234 // fixes "width calculation issues" due to conditional logic hiding some children
7235 $placeholder.html('<td style="padding:0;" colspan="' + $placeholder.children().length + '"></td>');
7236
7237 // add helper class to remove absolute positioning
7238 $item.addClass('acf-sortable-tr-helper');
7239
7240 // set fixed widths for children
7241 $item.children().each(function () {
7242 $(this).width($(this).width());
7243 });
7244
7245 // mimic height
7246 $placeholder.height($item.height() + 'px');
7247
7248 // remove class
7249 $item.removeClass('acf-sortable-tr-helper');
7250 }
7251 }
7252 });
7253
7254 /**
7255 * duplicateHelper
7256 *
7257 * Fixes browser bugs when duplicating an element
7258 *
7259 * @date 6/3/18
7260 * @since ACF 5.6.9
7261 *
7262 * @param void
7263 * @return void
7264 */
7265
7266 var duplicateHelper = new acf.Model({
7267 actions: {
7268 after_duplicate: 'onAfterDuplicate'
7269 },
7270 onAfterDuplicate: function ($el, $el2) {
7271 // get original values
7272 var vals = [];
7273 $el.find('select').each(function (i) {
7274 vals.push($(this).val());
7275 });
7276
7277 // set duplicate values
7278 $el2.find('select').each(function (i) {
7279 $(this).val(vals[i]);
7280 });
7281 }
7282 });
7283
7284 /**
7285 * tableHelper
7286 *
7287 * description
7288 *
7289 * @date 6/3/18
7290 * @since ACF 5.6.9
7291 *
7292 * @param type $var Description. Default.
7293 * @return type Description.
7294 */
7295
7296 var tableHelper = new acf.Model({
7297 id: 'tableHelper',
7298 priority: 20,
7299 actions: {
7300 refresh: 'renderTables'
7301 },
7302 renderTables: function ($el) {
7303 // loop
7304 var self = this;
7305 $('.acf-table:visible').each(function () {
7306 self.renderTable($(this));
7307 });
7308 },
7309 renderTable: function ($table) {
7310 // vars
7311 var $ths = $table.find('> thead > tr:visible > th[data-key]');
7312 var $tds = $table.find('> tbody > tr:visible > td[data-key]');
7313
7314 // bail early if no thead
7315 if (!$ths.length || !$tds.length) {
7316 return false;
7317 }
7318
7319 // visibility
7320 $ths.each(function (i) {
7321 // vars
7322 var $th = $(this);
7323 var key = $th.data('key');
7324 var $cells = $tds.filter('[data-key="' + key + '"]');
7325 var $hidden = $cells.filter('.acf-hidden');
7326
7327 // always remove empty and allow cells to be hidden
7328 $cells.removeClass('acf-empty');
7329
7330 // hide $th if all cells are hidden
7331 if ($cells.length === $hidden.length) {
7332 acf.hide($th);
7333
7334 // force all hidden cells to appear empty
7335 } else {
7336 acf.show($th);
7337 $hidden.addClass('acf-empty');
7338 }
7339 });
7340
7341 // clear width
7342 $ths.css('width', 'auto');
7343
7344 // get visible
7345 $ths = $ths.not('.acf-hidden');
7346
7347 // vars
7348 var availableWidth = 100;
7349 var colspan = $ths.length;
7350
7351 // set custom widths first
7352 var $fixedWidths = $ths.filter('[data-width]');
7353 $fixedWidths.each(function () {
7354 var width = $(this).data('width');
7355 $(this).css('width', width + '%');
7356 availableWidth -= width;
7357 });
7358
7359 // set auto widths
7360 var $auoWidths = $ths.not('[data-width]');
7361 if ($auoWidths.length) {
7362 var width = availableWidth / $auoWidths.length;
7363 $auoWidths.css('width', width + '%');
7364 availableWidth = 0;
7365 }
7366
7367 // avoid stretching issue
7368 if (availableWidth > 0) {
7369 $ths.last().css('width', 'auto');
7370 }
7371
7372 // update colspan on collapsed
7373 $tds.filter('.-collapsed-target').each(function () {
7374 // vars
7375 var $td = $(this);
7376
7377 // check if collapsed
7378 if ($td.parent().hasClass('-collapsed')) {
7379 $td.attr('colspan', $ths.length);
7380 } else {
7381 $td.removeAttr('colspan');
7382 }
7383 });
7384 }
7385 });
7386
7387 /**
7388 * fieldsHelper
7389 *
7390 * description
7391 *
7392 * @date 6/3/18
7393 * @since ACF 5.6.9
7394 *
7395 * @param type $var Description. Default.
7396 * @return type Description.
7397 */
7398
7399 var fieldsHelper = new acf.Model({
7400 id: 'fieldsHelper',
7401 priority: 30,
7402 actions: {
7403 refresh: 'renderGroups'
7404 },
7405 renderGroups: function () {
7406 // loop
7407 var self = this;
7408 $('.acf-fields:visible').each(function () {
7409 self.renderGroup($(this));
7410 });
7411 },
7412 renderGroup: function ($el) {
7413 // vars
7414 var top = 0;
7415 var height = 0;
7416 var $row = $();
7417
7418 // get fields
7419 var $fields = $el.children('.acf-field[data-width]:visible');
7420
7421 // bail early if no fields
7422 if (!$fields.length) {
7423 return false;
7424 }
7425
7426 // bail early if is .-left
7427 if ($el.hasClass('-left')) {
7428 $fields.removeAttr('data-width');
7429 $fields.css('width', 'auto');
7430 return false;
7431 }
7432
7433 // reset fields
7434 $fields.removeClass('-r0 -c0').css({
7435 'min-height': 0
7436 });
7437
7438 // loop
7439 $fields.each(function (i) {
7440 // vars
7441 var $field = $(this);
7442 var position = $field.position();
7443 var thisTop = Math.ceil(position.top);
7444 var thisLeft = Math.ceil(position.left);
7445
7446 // detect change in row
7447 if ($row.length && thisTop > top) {
7448 // set previous heights
7449 $row.css({
7450 'min-height': height + 'px'
7451 });
7452
7453 // update position due to change in row above
7454 position = $field.position();
7455 thisTop = Math.ceil(position.top);
7456 thisLeft = Math.ceil(position.left);
7457
7458 // reset vars
7459 top = 0;
7460 height = 0;
7461 $row = $();
7462 }
7463
7464 // rtl
7465 if (acf.get('rtl')) {
7466 thisLeft = Math.ceil($field.parent().width() - (position.left + $field.outerWidth()));
7467 }
7468
7469 // add classes
7470 if (thisTop == 0) {
7471 $field.addClass('-r0');
7472 } else if (thisLeft == 0) {
7473 $field.addClass('-c0');
7474 }
7475
7476 // get height after class change
7477 // - add 1 for subpixel rendering
7478 var thisHeight = Math.ceil($field.outerHeight()) + 1;
7479
7480 // set height
7481 height = Math.max(height, thisHeight);
7482
7483 // set y
7484 top = Math.max(top, thisTop);
7485
7486 // append
7487 $row = $row.add($field);
7488 });
7489
7490 // clean up
7491 if ($row.length) {
7492 $row.css({
7493 'min-height': height + 'px'
7494 });
7495 }
7496 }
7497 });
7498
7499 /**
7500 * Adds a body class when holding down the "shift" key.
7501 *
7502 * @date 06/05/2020
7503 * @since ACF 5.9.0
7504 */
7505 var bodyClassShiftHelper = new acf.Model({
7506 id: 'bodyClassShiftHelper',
7507 events: {
7508 keydown: 'onKeyDown',
7509 keyup: 'onKeyUp'
7510 },
7511 isShiftKey: function (e) {
7512 return e.keyCode === 16;
7513 },
7514 onKeyDown: function (e) {
7515 if (this.isShiftKey(e)) {
7516 $('body').addClass('acf-keydown-shift');
7517 }
7518 },
7519 onKeyUp: function (e) {
7520 if (this.isShiftKey(e)) {
7521 $('body').removeClass('acf-keydown-shift');
7522 }
7523 }
7524 });
7525 })(jQuery);
7526
7527 /***/ }),
7528
7529 /***/ "./assets/src/js/_acf-media.js":
7530 /*!*************************************!*\
7531 !*** ./assets/src/js/_acf-media.js ***!
7532 \*************************************/
7533 /***/ (() => {
7534
7535 (function ($, undefined) {
7536 /**
7537 * acf.newMediaPopup
7538 *
7539 * description
7540 *
7541 * @date 10/1/18
7542 * @since ACF 5.6.5
7543 *
7544 * @param type $var Description. Default.
7545 * @return type Description.
7546 */
7547
7548 acf.newMediaPopup = function (args) {
7549 // args
7550 var popup = null;
7551 var args = acf.parseArgs(args, {
7552 mode: 'select',
7553 // 'select', 'edit'
7554 title: '',
7555 // 'Upload Image'
7556 button: '',
7557 // 'Select Image'
7558 type: '',
7559 // 'image', ''
7560 field: false,
7561 // field instance
7562 allowedTypes: '',
7563 // '.jpg, .png, etc'
7564 library: 'all',
7565 // 'all', 'uploadedTo'
7566 multiple: false,
7567 // false, true, 'add'
7568 attachment: 0,
7569 // the attachment to edit
7570 autoOpen: true,
7571 // open the popup automatically
7572 open: function () {},
7573 // callback after close
7574 select: function () {},
7575 // callback after select
7576 close: function () {} // callback after close
7577 });
7578
7579 // initialize
7580 if (args.mode == 'edit') {
7581 popup = new acf.models.EditMediaPopup(args);
7582 } else {
7583 popup = new acf.models.SelectMediaPopup(args);
7584 }
7585
7586 // open popup (allow frame customization before opening)
7587 if (args.autoOpen) {
7588 setTimeout(function () {
7589 popup.open();
7590 }, 1);
7591 }
7592
7593 // action
7594 acf.doAction('new_media_popup', popup);
7595
7596 // return
7597 return popup;
7598 };
7599
7600 /**
7601 * getPostID
7602 *
7603 * description
7604 *
7605 * @date 10/1/18
7606 * @since ACF 5.6.5
7607 *
7608 * @param type $var Description. Default.
7609 * @return type Description.
7610 */
7611
7612 var getPostID = function () {
7613 var postID = acf.get('post_id');
7614 return acf.isNumeric(postID) ? postID : 0;
7615 };
7616
7617 /**
7618 * acf.getMimeTypes
7619 *
7620 * description
7621 *
7622 * @date 11/1/18
7623 * @since ACF 5.6.5
7624 *
7625 * @param type $var Description. Default.
7626 * @return type Description.
7627 */
7628
7629 acf.getMimeTypes = function () {
7630 return this.get('mimeTypes');
7631 };
7632 acf.getMimeType = function (name) {
7633 // vars
7634 var allTypes = acf.getMimeTypes();
7635
7636 // search
7637 if (allTypes[name] !== undefined) {
7638 return allTypes[name];
7639 }
7640
7641 // some types contain a mixed key such as "jpg|jpeg|jpe"
7642 for (var key in allTypes) {
7643 if (key.indexOf(name) !== -1) {
7644 return allTypes[key];
7645 }
7646 }
7647
7648 // return
7649 return false;
7650 };
7651
7652 /**
7653 * MediaPopup
7654 *
7655 * description
7656 *
7657 * @date 10/1/18
7658 * @since ACF 5.6.5
7659 *
7660 * @param type $var Description. Default.
7661 * @return type Description.
7662 */
7663
7664 var MediaPopup = acf.Model.extend({
7665 id: 'MediaPopup',
7666 data: {},
7667 defaults: {},
7668 frame: false,
7669 setup: function (props) {
7670 $.extend(this.data, props);
7671 },
7672 initialize: function () {
7673 // vars
7674 var options = this.getFrameOptions();
7675
7676 // add states
7677 this.addFrameStates(options);
7678
7679 // create frame
7680 var frame = wp.media(options);
7681
7682 // add args reference
7683 frame.acf = this;
7684
7685 // add events
7686 this.addFrameEvents(frame, options);
7687
7688 // store frame
7689 this.frame = frame;
7690 },
7691 open: function () {
7692 this.frame.open();
7693 },
7694 close: function () {
7695 this.frame.close();
7696 },
7697 remove: function () {
7698 this.frame.detach();
7699 this.frame.remove();
7700 },
7701 getFrameOptions: function () {
7702 // vars
7703 var options = {
7704 title: this.get('title'),
7705 multiple: this.get('multiple'),
7706 library: {},
7707 states: []
7708 };
7709
7710 // type
7711 if (this.get('type')) {
7712 options.library.type = this.get('type');
7713 }
7714
7715 // type
7716 if (this.get('library') === 'uploadedTo') {
7717 options.library.uploadedTo = getPostID();
7718 }
7719
7720 // attachment
7721 if (this.get('attachment')) {
7722 options.library.post__in = [this.get('attachment')];
7723 }
7724
7725 // button
7726 if (this.get('button')) {
7727 options.button = {
7728 text: this.get('button')
7729 };
7730 }
7731
7732 // return
7733 return options;
7734 },
7735 addFrameStates: function (options) {
7736 // create query
7737 var Query = wp.media.query(options.library);
7738
7739 // add _acfuploader
7740 // this is super wack!
7741 // if you add _acfuploader to the options.library args, new uploads will not be added to the library view.
7742 // this has been traced back to the wp.media.model.Query initialize function (which can't be overridden)
7743 // Adding any custom args will cause the Attachments to not observe the uploader queue
7744 // To bypass this security issue, we add in the args AFTER the Query has been initialized
7745 // options.library._acfuploader = settings.field;
7746 if (this.get('field') && acf.isset(Query, 'mirroring', 'args')) {
7747 Query.mirroring.args._acfuploader = this.get('field');
7748 }
7749
7750 // add states
7751 options.states.push(
7752 // main state
7753 new wp.media.controller.Library({
7754 library: Query,
7755 multiple: this.get('multiple'),
7756 title: this.get('title'),
7757 priority: 20,
7758 filterable: 'all',
7759 editable: true,
7760 allowLocalEdits: true
7761 }));
7762
7763 // edit image functionality (added in WP 3.9)
7764 if (acf.isset(wp, 'media', 'controller', 'EditImage')) {
7765 options.states.push(new wp.media.controller.EditImage());
7766 }
7767 },
7768 addFrameEvents: function (frame, options) {
7769 // log all events
7770 //frame.on('all', function( e ) {
7771 // console.log( 'frame all: %o', e );
7772 //});
7773
7774 // add class
7775 frame.on('open', function () {
7776 this.$el.closest('.media-modal').addClass('acf-media-modal -' + this.acf.get('mode'));
7777 }, frame);
7778
7779 // edit image view
7780 // source: media-views.js:2410 editImageContent()
7781 frame.on('content:render:edit-image', function () {
7782 var image = this.state().get('image');
7783 var view = new wp.media.view.EditImage({
7784 model: image,
7785 controller: this
7786 }).render();
7787 this.content.set(view);
7788
7789 // after creating the wrapper view, load the actual editor via an ajax call
7790 view.loadEditor();
7791 }, frame);
7792
7793 // update toolbar button
7794 //frame.on( 'toolbar:create:select', function( toolbar ) {
7795 // toolbar.view = new wp.media.view.Toolbar.Select({
7796 // text: frame.options._button,
7797 // controller: this
7798 // });
7799 //}, frame );
7800
7801 // on select
7802 frame.on('select', function () {
7803 // vars
7804 var selection = frame.state().get('selection');
7805
7806 // if selecting images
7807 if (selection) {
7808 // loop
7809 selection.each(function (attachment, i) {
7810 frame.acf.get('select').apply(frame.acf, [attachment, i]);
7811 });
7812 }
7813 });
7814
7815 // on close
7816 frame.on('close', function () {
7817 // callback and remove
7818 setTimeout(function () {
7819 frame.acf.get('close').apply(frame.acf);
7820 frame.acf.remove();
7821 }, 1);
7822 });
7823 }
7824 });
7825
7826 /**
7827 * acf.models.SelectMediaPopup
7828 *
7829 * description
7830 *
7831 * @date 10/1/18
7832 * @since ACF 5.6.5
7833 *
7834 * @param type $var Description. Default.
7835 * @return type Description.
7836 */
7837
7838 acf.models.SelectMediaPopup = MediaPopup.extend({
7839 id: 'SelectMediaPopup',
7840 setup: function (props) {
7841 // default button
7842 if (!props.button) {
7843 props.button = acf._x('Select', 'verb');
7844 }
7845
7846 // parent
7847 MediaPopup.prototype.setup.apply(this, arguments);
7848 },
7849 addFrameEvents: function (frame, options) {
7850 // plupload
7851 // adds _acfuploader param to validate uploads
7852 if (acf.isset(_wpPluploadSettings, 'defaults', 'multipart_params')) {
7853 // add _acfuploader so that Uploader will inherit
7854 _wpPluploadSettings.defaults.multipart_params._acfuploader = this.get('field');
7855
7856 // remove acf_field so future Uploaders won't inherit
7857 frame.on('open', function () {
7858 delete _wpPluploadSettings.defaults.multipart_params._acfuploader;
7859 });
7860 }
7861
7862 // browse
7863 frame.on('content:activate:browse', function () {
7864 // vars
7865 var toolbar = false;
7866
7867 // populate above vars making sure to allow for failure
7868 // perhaps toolbar does not exist because the frame open is Upload Files
7869 try {
7870 toolbar = frame.content.get().toolbar;
7871 } catch (e) {
7872 console.log(e);
7873 return;
7874 }
7875
7876 // callback
7877 frame.acf.customizeFilters.apply(frame.acf, [toolbar]);
7878 });
7879
7880 // parent
7881 MediaPopup.prototype.addFrameEvents.apply(this, arguments);
7882 },
7883 customizeFilters: function (toolbar) {
7884 // vars
7885 var filters = toolbar.get('filters');
7886
7887 // image
7888 if (this.get('type') == 'image') {
7889 // update all
7890 filters.filters.all.text = acf.__('All images');
7891
7892 // remove some filters
7893 delete filters.filters.audio;
7894 delete filters.filters.video;
7895 delete filters.filters.image;
7896
7897 // update all filters to show images
7898 $.each(filters.filters, function (i, filter) {
7899 filter.props.type = filter.props.type || 'image';
7900 });
7901 }
7902
7903 // specific types
7904 if (this.get('allowedTypes')) {
7905 // convert ".jpg, .png" into ["jpg", "png"]
7906 var allowedTypes = this.get('allowedTypes').split(' ').join('').split('.').join('').split(',');
7907
7908 // loop
7909 allowedTypes.map(function (name) {
7910 // get type
7911 var mimeType = acf.getMimeType(name);
7912
7913 // bail early if no type
7914 if (!mimeType) return;
7915
7916 // create new filter
7917 var newFilter = {
7918 text: mimeType,
7919 props: {
7920 status: null,
7921 type: mimeType,
7922 uploadedTo: null,
7923 orderby: 'date',
7924 order: 'DESC'
7925 },
7926 priority: 20
7927 };
7928
7929 // append
7930 filters.filters[mimeType] = newFilter;
7931 });
7932 }
7933
7934 // uploaded to post
7935 if (this.get('library') === 'uploadedTo') {
7936 // vars
7937 var uploadedTo = this.frame.options.library.uploadedTo;
7938
7939 // remove some filters
7940 delete filters.filters.unattached;
7941 delete filters.filters.uploaded;
7942
7943 // add uploadedTo to filters
7944 $.each(filters.filters, function (i, filter) {
7945 filter.text += ' (' + acf.__('Uploaded to this post') + ')';
7946 filter.props.uploadedTo = uploadedTo;
7947 });
7948 }
7949
7950 // add _acfuploader to filters
7951 var field = this.get('field');
7952 $.each(filters.filters, function (k, filter) {
7953 filter.props._acfuploader = field;
7954 });
7955
7956 // add _acfuploader to search
7957 var search = toolbar.get('search');
7958 search.model.attributes._acfuploader = field;
7959
7960 // render (custom function added to prototype)
7961 if (filters.renderFilters) {
7962 filters.renderFilters();
7963 }
7964 }
7965 });
7966
7967 /**
7968 * acf.models.EditMediaPopup
7969 *
7970 * description
7971 *
7972 * @date 10/1/18
7973 * @since ACF 5.6.5
7974 *
7975 * @param type $var Description. Default.
7976 * @return type Description.
7977 */
7978
7979 acf.models.EditMediaPopup = MediaPopup.extend({
7980 id: 'SelectMediaPopup',
7981 setup: function (props) {
7982 // default button
7983 if (!props.button) {
7984 props.button = acf._x('Update', 'verb');
7985 }
7986
7987 // parent
7988 MediaPopup.prototype.setup.apply(this, arguments);
7989 },
7990 addFrameEvents: function (frame, options) {
7991 // add class
7992 frame.on('open', function () {
7993 // add class
7994 this.$el.closest('.media-modal').addClass('acf-expanded');
7995
7996 // set to browse
7997 if (this.content.mode() != 'browse') {
7998 this.content.mode('browse');
7999 }
8000
8001 // set selection
8002 var state = this.state();
8003 var selection = state.get('selection');
8004 var attachment = wp.media.attachment(frame.acf.get('attachment'));
8005 selection.add(attachment);
8006 }, frame);
8007
8008 // parent
8009 MediaPopup.prototype.addFrameEvents.apply(this, arguments);
8010 }
8011 });
8012
8013 /**
8014 * customizePrototypes
8015 *
8016 * description
8017 *
8018 * @date 11/1/18
8019 * @since ACF 5.6.5
8020 *
8021 * @param type $var Description. Default.
8022 * @return type Description.
8023 */
8024
8025 var customizePrototypes = new acf.Model({
8026 id: 'customizePrototypes',
8027 wait: 'ready',
8028 initialize: function () {
8029 // bail early if no media views
8030 if (!acf.isset(window, 'wp', 'media', 'view')) {
8031 return;
8032 }
8033
8034 // fix bug where CPT without "editor" does not set post.id setting which then prevents uploadedTo from working
8035 var postID = getPostID();
8036 if (postID && acf.isset(wp, 'media', 'view', 'settings', 'post')) {
8037 wp.media.view.settings.post.id = postID;
8038 }
8039
8040 // customize
8041 this.customizeAttachmentsButton();
8042 this.customizeAttachmentsRouter();
8043 this.customizeAttachmentFilters();
8044 this.customizeAttachmentCompat();
8045 this.customizeAttachmentLibrary();
8046 },
8047 customizeAttachmentsButton: function () {
8048 // validate
8049 if (!acf.isset(wp, 'media', 'view', 'Button')) {
8050 return;
8051 }
8052
8053 // Extend
8054 var Button = wp.media.view.Button;
8055 wp.media.view.Button = Button.extend({
8056 // Fix bug where "Select" button appears blank after editing an image.
8057 // Do this by simplifying Button initialize function and avoid deleting this.options.
8058 initialize: function () {
8059 var options = _.defaults(this.options, this.defaults);
8060 this.model = new Backbone.Model(options);
8061 this.listenTo(this.model, 'change', this.render);
8062 }
8063 });
8064 },
8065 customizeAttachmentsRouter: function () {
8066 // validate
8067 if (!acf.isset(wp, 'media', 'view', 'Router')) {
8068 return;
8069 }
8070
8071 // vars
8072 var Parent = wp.media.view.Router;
8073
8074 // extend
8075 wp.media.view.Router = Parent.extend({
8076 addExpand: function () {
8077 // vars
8078 var $a = $(['<a href="#" class="acf-expand-details">', '<span class="is-closed"><i class="acf-icon -left -small"></i>' + acf.__('Expand Details') + '</span>', '<span class="is-open"><i class="acf-icon -right -small"></i>' + acf.__('Collapse Details') + '</span>', '</a>'].join(''));
8079
8080 // add events
8081 $a.on('click', function (e) {
8082 e.preventDefault();
8083 var $div = $(this).closest('.media-modal');
8084 if ($div.hasClass('acf-expanded')) {
8085 $div.removeClass('acf-expanded');
8086 } else {
8087 $div.addClass('acf-expanded');
8088 }
8089 });
8090
8091 // append
8092 this.$el.append($a);
8093 },
8094 initialize: function () {
8095 // initialize
8096 Parent.prototype.initialize.apply(this, arguments);
8097
8098 // add buttons
8099 this.addExpand();
8100
8101 // return
8102 return this;
8103 }
8104 });
8105 },
8106 customizeAttachmentFilters: function () {
8107 // validate
8108 if (!acf.isset(wp, 'media', 'view', 'AttachmentFilters', 'All')) {
8109 return;
8110 }
8111
8112 // vars
8113 var Parent = wp.media.view.AttachmentFilters.All;
8114
8115 // renderFilters
8116 // copied from media-views.js:6939
8117 Parent.prototype.renderFilters = function () {
8118 // Build `<option>` elements.
8119 this.$el.html(_.chain(this.filters).map(function (filter, value) {
8120 return {
8121 el: $('<option></option>').val(value).html(filter.text)[0],
8122 priority: filter.priority || 50
8123 };
8124 }, this).sortBy('priority').pluck('el').value());
8125 };
8126 },
8127 customizeAttachmentCompat: function () {
8128 // validate
8129 if (!acf.isset(wp, 'media', 'view', 'AttachmentCompat')) {
8130 return;
8131 }
8132
8133 // vars
8134 var AttachmentCompat = wp.media.view.AttachmentCompat;
8135 var timeout = false;
8136
8137 // extend
8138 wp.media.view.AttachmentCompat = AttachmentCompat.extend({
8139 render: function () {
8140 // WP bug
8141 // When multiple media frames exist on the same page (WP content, WYSIWYG, image, file ),
8142 // WP creates multiple instances of this AttachmentCompat view.
8143 // Each instance will attempt to render when a new modal is created.
8144 // Use a property to avoid this and only render once per instance.
8145 if (this.rendered) {
8146 return this;
8147 }
8148
8149 // render HTML
8150 AttachmentCompat.prototype.render.apply(this, arguments);
8151
8152 // when uploading, render is called twice.
8153 // ignore first render by checking for #acf-form-data element
8154 if (!this.$('#acf-form-data').length) {
8155 return this;
8156 }
8157
8158 // clear timeout
8159 clearTimeout(timeout);
8160
8161 // setTimeout
8162 timeout = setTimeout($.proxy(function () {
8163 this.rendered = true;
8164 acf.doAction('append', this.$el);
8165 }, this), 50);
8166
8167 // return
8168 return this;
8169 },
8170 save: function (event) {
8171 var data = {};
8172 if (event) {
8173 event.preventDefault();
8174 }
8175
8176 //_.each( this.$el.serializeArray(), function( pair ) {
8177 // data[ pair.name ] = pair.value;
8178 //});
8179
8180 // Serialize data more thoroughly to allow checkbox inputs to save.
8181 data = acf.serializeForAjax(this.$el);
8182 this.controller.trigger('attachment:compat:waiting', ['waiting']);
8183 this.model.saveCompat(data).always(_.bind(this.postSave, this));
8184 }
8185 });
8186 },
8187 customizeAttachmentLibrary: function () {
8188 // validate
8189 if (!acf.isset(wp, 'media', 'view', 'Attachment', 'Library')) {
8190 return;
8191 }
8192
8193 // vars
8194 var AttachmentLibrary = wp.media.view.Attachment.Library;
8195
8196 // extend
8197 wp.media.view.Attachment.Library = AttachmentLibrary.extend({
8198 render: function () {
8199 // vars
8200 var popup = acf.isget(this, 'controller', 'acf');
8201 var attributes = acf.isget(this, 'model', 'attributes');
8202
8203 // check vars exist to avoid errors
8204 if (popup && attributes) {
8205 // show errors
8206 if (attributes.acf_errors) {
8207 this.$el.addClass('acf-disabled');
8208 }
8209
8210 // disable selected
8211 var selected = popup.get('selected');
8212 if (selected && selected.indexOf(attributes.id) > -1) {
8213 this.$el.addClass('acf-selected');
8214 }
8215 }
8216
8217 // render
8218 return AttachmentLibrary.prototype.render.apply(this, arguments);
8219 },
8220 /*
8221 * toggleSelection
8222 *
8223 * This function is called before an attachment is selected
8224 * A good place to check for errors and prevent the 'select' function from being fired
8225 *
8226 * @type function
8227 * @date 29/09/2016
8228 * @since ACF 5.4.0
8229 *
8230 * @param options (object)
8231 * @return n/a
8232 */
8233
8234 toggleSelection: function (options) {
8235 // vars
8236 // source: wp-includes/js/media-views.js:2880
8237 var collection = this.collection,
8238 selection = this.options.selection,
8239 model = this.model,
8240 single = selection.single();
8241
8242 // vars
8243 var frame = this.controller;
8244 var errors = acf.isget(this, 'model', 'attributes', 'acf_errors');
8245 var $sidebar = frame.$el.find('.media-frame-content .media-sidebar');
8246
8247 // remove previous error
8248 $sidebar.children('.acf-selection-error').remove();
8249
8250 // show attachment details
8251 $sidebar.children().removeClass('acf-hidden');
8252
8253 // add message
8254 if (frame && errors) {
8255 // vars
8256 var filename = acf.isget(this, 'model', 'attributes', 'filename');
8257
8258 // hide attachment details
8259 // Gallery field continues to show previously selected attachment...
8260 $sidebar.children().addClass('acf-hidden');
8261
8262 // append message
8263 $sidebar.prepend(['<div class="acf-selection-error">', '<span class="selection-error-label">' + acf.__('Restricted') + '</span>', '<span class="selection-error-filename">' + filename + '</span>', '<span class="selection-error-message">' + errors + '</span>', '</div>'].join(''));
8264
8265 // reset selection (unselects all attachments)
8266 selection.reset();
8267
8268 // set single (attachment displayed in sidebar)
8269 selection.single(model);
8270
8271 // return and prevent 'select' form being fired
8272 return;
8273 }
8274
8275 // return
8276 return AttachmentLibrary.prototype.toggleSelection.apply(this, arguments);
8277 }
8278 });
8279 }
8280 });
8281 })(jQuery);
8282
8283 /***/ }),
8284
8285 /***/ "./assets/src/js/_acf-postbox.js":
8286 /*!***************************************!*\
8287 !*** ./assets/src/js/_acf-postbox.js ***!
8288 \***************************************/
8289 /***/ (() => {
8290
8291 (function ($, undefined) {
8292 /**
8293 * postboxManager
8294 *
8295 * Manages postboxes on the screen.
8296 *
8297 * @date 25/5/19
8298 * @since ACF 5.8.1
8299 *
8300 * @param void
8301 * @return void
8302 */
8303 var postboxManager = new acf.Model({
8304 wait: 'prepare',
8305 priority: 1,
8306 initialize: function () {
8307 (acf.get('postboxes') || []).map(acf.newPostbox);
8308 }
8309 });
8310
8311 /**
8312 * acf.getPostbox
8313 *
8314 * Returns a postbox instance.
8315 *
8316 * @date 23/9/18
8317 * @since ACF 5.7.7
8318 *
8319 * @param mixed $el Either a jQuery element or the postbox id.
8320 * @return object
8321 */
8322 acf.getPostbox = function ($el) {
8323 // allow string parameter
8324 if (typeof arguments[0] == 'string') {
8325 $el = $('#' + arguments[0]);
8326 }
8327
8328 // return instance
8329 return acf.getInstance($el);
8330 };
8331
8332 /**
8333 * acf.getPostboxes
8334 *
8335 * Returns an array of postbox instances.
8336 *
8337 * @date 23/9/18
8338 * @since ACF 5.7.7
8339 *
8340 * @param void
8341 * @return array
8342 */
8343 acf.getPostboxes = function () {
8344 return acf.getInstances($('.acf-postbox'));
8345 };
8346
8347 /**
8348 * acf.newPostbox
8349 *
8350 * Returns a new postbox instance for the given props.
8351 *
8352 * @date 20/9/18
8353 * @since ACF 5.7.6
8354 *
8355 * @param object props The postbox properties.
8356 * @return object
8357 */
8358 acf.newPostbox = function (props) {
8359 return new acf.models.Postbox(props);
8360 };
8361
8362 /**
8363 * acf.models.Postbox
8364 *
8365 * The postbox model.
8366 *
8367 * @date 20/9/18
8368 * @since ACF 5.7.6
8369 *
8370 * @param void
8371 * @return void
8372 */
8373 acf.models.Postbox = acf.Model.extend({
8374 data: {
8375 id: '',
8376 key: '',
8377 style: 'default',
8378 label: 'top',
8379 edit: ''
8380 },
8381 setup: function (props) {
8382 // compatibility
8383 if (props.editLink) {
8384 props.edit = props.editLink;
8385 }
8386
8387 // extend data
8388 $.extend(this.data, props);
8389
8390 // set $el
8391 this.$el = this.$postbox();
8392 },
8393 $postbox: function () {
8394 return $('#' + this.get('id'));
8395 },
8396 $hide: function () {
8397 return $('#' + this.get('id') + '-hide');
8398 },
8399 $hideLabel: function () {
8400 return this.$hide().parent();
8401 },
8402 $hndle: function () {
8403 return this.$('> .hndle');
8404 },
8405 $handleActions: function () {
8406 return this.$('> .postbox-header .handle-actions');
8407 },
8408 $inside: function () {
8409 return this.$('> .inside');
8410 },
8411 isVisible: function () {
8412 return this.$el.hasClass('acf-hidden');
8413 },
8414 isHiddenByScreenOptions: function () {
8415 return this.$el.hasClass('hide-if-js') || this.$el.css('display') == 'none';
8416 },
8417 initialize: function () {
8418 // Add default class.
8419 this.$el.addClass('acf-postbox');
8420
8421 // Add field group style class (ignore in block editor).
8422 if (acf.get('editor') !== 'block') {
8423 var style = this.get('style');
8424 if (style !== 'default') {
8425 this.$el.addClass(style);
8426 }
8427 }
8428
8429 // Add .inside class.
8430 this.$inside().addClass('acf-fields').addClass('-' + this.get('label'));
8431
8432 // Append edit link.
8433 var edit = this.get('edit');
8434 if (edit) {
8435 var html = '<a href="' + edit + '" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="' + acf.__('Edit field group') + '"></a>';
8436 var $handleActions = this.$handleActions();
8437 if ($handleActions.length) {
8438 $handleActions.prepend(html);
8439 } else {
8440 this.$hndle().append(html);
8441 }
8442 }
8443
8444 // Show postbox.
8445 this.show();
8446 },
8447 show: function () {
8448 // If disabled by screen options, set checked to false and return.
8449 if (this.$el.hasClass('hide-if-js')) {
8450 this.$hide().prop('checked', false);
8451 return;
8452 }
8453
8454 // Show label.
8455 this.$hideLabel().show();
8456
8457 // toggle on checkbox
8458 this.$hide().prop('checked', true);
8459
8460 // Show postbox
8461 this.$el.show().removeClass('acf-hidden');
8462
8463 // Do action.
8464 acf.doAction('show_postbox', this);
8465 },
8466 enable: function () {
8467 acf.enable(this.$el, 'postbox');
8468 },
8469 showEnable: function () {
8470 this.enable();
8471 this.show();
8472 },
8473 hide: function () {
8474 // Hide label.
8475 this.$hideLabel().hide();
8476
8477 // Hide postbox
8478 this.$el.hide().addClass('acf-hidden');
8479
8480 // Do action.
8481 acf.doAction('hide_postbox', this);
8482 },
8483 disable: function () {
8484 acf.disable(this.$el, 'postbox');
8485 },
8486 hideDisable: function () {
8487 this.disable();
8488 this.hide();
8489 },
8490 html: function (html) {
8491 // Update HTML.
8492 this.$inside().html(html);
8493
8494 // Do action.
8495 acf.doAction('append', this.$el);
8496 }
8497 });
8498 })(jQuery);
8499
8500 /***/ }),
8501
8502 /***/ "./assets/src/js/_acf-screen.js":
8503 /*!**************************************!*\
8504 !*** ./assets/src/js/_acf-screen.js ***!
8505 \**************************************/
8506 /***/ (() => {
8507
8508 (function ($, undefined) {
8509 acf.screen = new acf.Model({
8510 active: true,
8511 xhr: false,
8512 timeout: false,
8513 wait: 'load',
8514 events: {
8515 'change #page_template': 'onChange',
8516 'change #parent_id': 'onChange',
8517 'change #post-formats-select': 'onChange',
8518 'change .categorychecklist': 'onChange',
8519 'change .tagsdiv': 'onChange',
8520 'change .acf-taxonomy-field[data-save="1"]': 'onChange',
8521 'change #product-type': 'onChange'
8522 },
8523 isPost: function () {
8524 return acf.get('screen') === 'post';
8525 },
8526 isUser: function () {
8527 return acf.get('screen') === 'user';
8528 },
8529 isTaxonomy: function () {
8530 return acf.get('screen') === 'taxonomy';
8531 },
8532 isAttachment: function () {
8533 return acf.get('screen') === 'attachment';
8534 },
8535 isNavMenu: function () {
8536 return acf.get('screen') === 'nav_menu';
8537 },
8538 isWidget: function () {
8539 return acf.get('screen') === 'widget';
8540 },
8541 isComment: function () {
8542 return acf.get('screen') === 'comment';
8543 },
8544 getPageTemplate: function () {
8545 var $el = $('#page_template');
8546 return $el.length ? $el.val() : null;
8547 },
8548 getPageParent: function (e, $el) {
8549 var $el = $('#parent_id');
8550 return $el.length ? $el.val() : null;
8551 },
8552 getPageType: function (e, $el) {
8553 return this.getPageParent() ? 'child' : 'parent';
8554 },
8555 getPostType: function () {
8556 return $('#post_type').val();
8557 },
8558 getPostFormat: function (e, $el) {
8559 var $el = $('#post-formats-select input:checked');
8560 if ($el.length) {
8561 var val = $el.val();
8562 return val == '0' ? 'standard' : val;
8563 }
8564 return null;
8565 },
8566 getPostCoreTerms: function () {
8567 // vars
8568 var terms = {};
8569
8570 // serialize WP taxonomy postboxes
8571 var data = acf.serialize($('.categorydiv, .tagsdiv'));
8572
8573 // use tax_input (tag, custom-taxonomy) when possible.
8574 // this data is already formatted in taxonomy => [terms].
8575 if (data.tax_input) {
8576 terms = data.tax_input;
8577 }
8578
8579 // append "category" which uses a different name
8580 if (data.post_category) {
8581 terms.category = data.post_category;
8582 }
8583
8584 // convert any string values (tags) into array format
8585 for (var tax in terms) {
8586 if (!acf.isArray(terms[tax])) {
8587 terms[tax] = terms[tax].split(/,[\s]?/);
8588 }
8589 }
8590
8591 // return
8592 return terms;
8593 },
8594 getPostTerms: function () {
8595 // Get core terms.
8596 var terms = this.getPostCoreTerms();
8597
8598 // loop over taxonomy fields and add their values
8599 acf.getFields({
8600 type: 'taxonomy'
8601 }).map(function (field) {
8602 // ignore fields that don't save
8603 if (!field.get('save')) {
8604 return;
8605 }
8606
8607 // vars
8608 var val = field.val();
8609 var tax = field.get('taxonomy');
8610
8611 // check val
8612 if (val) {
8613 // ensure terms exists
8614 terms[tax] = terms[tax] || [];
8615
8616 // ensure val is an array
8617 val = acf.isArray(val) ? val : [val];
8618
8619 // append
8620 terms[tax] = terms[tax].concat(val);
8621 }
8622 });
8623
8624 // add WC product type
8625 if ((productType = this.getProductType()) !== null) {
8626 terms.product_type = [productType];
8627 }
8628
8629 // remove duplicate values
8630 for (var tax in terms) {
8631 terms[tax] = acf.uniqueArray(terms[tax]);
8632 }
8633
8634 // return
8635 return terms;
8636 },
8637 getProductType: function () {
8638 var $el = $('#product-type');
8639 return $el.length ? $el.val() : null;
8640 },
8641 check: function () {
8642 // bail early if not for post
8643 if (acf.get('screen') !== 'post') {
8644 return;
8645 }
8646
8647 // abort XHR if is already loading AJAX data
8648 if (this.xhr) {
8649 this.xhr.abort();
8650 }
8651
8652 // vars
8653 var ajaxData = acf.parseArgs(this.data, {
8654 action: 'acf/ajax/check_screen',
8655 screen: acf.get('screen'),
8656 exists: []
8657 });
8658
8659 // post id
8660 if (this.isPost()) {
8661 ajaxData.post_id = acf.get('post_id');
8662 }
8663
8664 // post type
8665 if ((postType = this.getPostType()) !== null) {
8666 ajaxData.post_type = postType;
8667 }
8668
8669 // page template
8670 if ((pageTemplate = this.getPageTemplate()) !== null) {
8671 ajaxData.page_template = pageTemplate;
8672 }
8673
8674 // page parent
8675 if ((pageParent = this.getPageParent()) !== null) {
8676 ajaxData.page_parent = pageParent;
8677 }
8678
8679 // page type
8680 if ((pageType = this.getPageType()) !== null) {
8681 ajaxData.page_type = pageType;
8682 }
8683
8684 // post format
8685 if ((postFormat = this.getPostFormat()) !== null) {
8686 ajaxData.post_format = postFormat;
8687 }
8688
8689 // post terms
8690 if ((postTerms = this.getPostTerms()) !== null) {
8691 ajaxData.post_terms = postTerms;
8692 }
8693
8694 // add array of existing postboxes to increase performance and reduce JSON HTML
8695 acf.getPostboxes().map(function (postbox) {
8696 ajaxData.exists.push(postbox.get('key'));
8697 });
8698
8699 // filter
8700 ajaxData = acf.applyFilters('check_screen_args', ajaxData);
8701
8702 // success
8703 var onSuccess = function (json) {
8704 // Render post screen.
8705 if (acf.get('screen') == 'post') {
8706 this.renderPostScreen(json);
8707
8708 // Render user screen.
8709 } else if (acf.get('screen') == 'user') {
8710 this.renderUserScreen(json);
8711 }
8712
8713 // action
8714 acf.doAction('check_screen_complete', json, ajaxData);
8715 };
8716
8717 // ajax
8718 this.xhr = $.ajax({
8719 url: acf.get('ajaxurl'),
8720 data: acf.prepareForAjax(ajaxData),
8721 type: 'post',
8722 dataType: 'json',
8723 context: this,
8724 success: onSuccess
8725 });
8726 },
8727 onChange: function (e, $el) {
8728 this.setTimeout(this.check, 1);
8729 },
8730 renderPostScreen: function (data) {
8731 // Helper function to copy events
8732 var copyEvents = function ($from, $to) {
8733 var events = $._data($from[0]).events;
8734 for (var type in events) {
8735 for (var i = 0; i < events[type].length; i++) {
8736 $to.on(type, events[type][i].handler);
8737 }
8738 }
8739 };
8740
8741 // Helper function to sort metabox.
8742 var sortMetabox = function (id, ids) {
8743 // Find position of id within ids.
8744 var index = ids.indexOf(id);
8745
8746 // Bail early if index not found.
8747 if (index == -1) {
8748 return false;
8749 }
8750
8751 // Loop over metaboxes behind (in reverse order).
8752 for (var i = index - 1; i >= 0; i--) {
8753 if ($('#' + ids[i]).length) {
8754 return $('#' + ids[i]).after($('#' + id));
8755 }
8756 }
8757
8758 // Loop over metaboxes infront.
8759 for (var i = index + 1; i < ids.length; i++) {
8760 if ($('#' + ids[i]).length) {
8761 return $('#' + ids[i]).before($('#' + id));
8762 }
8763 }
8764
8765 // Return false if not sorted.
8766 return false;
8767 };
8768
8769 // Keep track of visible and hidden postboxes.
8770 data.visible = [];
8771 data.hidden = [];
8772
8773 // Show these postboxes.
8774 data.results = data.results.map(function (result, i) {
8775 // vars
8776 var postbox = acf.getPostbox(result.id);
8777
8778 // Prevent "acf_after_title" position in Block Editor.
8779 if (acf.isGutenberg() && result.position == 'acf_after_title') {
8780 result.position = 'normal';
8781 }
8782
8783 // Create postbox if doesn't exist.
8784 if (!postbox) {
8785 var wpMinorVersion = parseFloat(acf.get('wp_version'));
8786 if (wpMinorVersion >= 5.5) {
8787 var postboxHeader = ['<div class="postbox-header">', '<h2 class="hndle ui-sortable-handle">', '<span>' + acf.escHtml(result.title) + '</span>', '</h2>', '<div class="handle-actions hide-if-no-js">', '<button type="button" class="handlediv" aria-expanded="true">', '<span class="screen-reader-text">Toggle panel: ' + acf.escHtml(result.title) + '</span>', '<span class="toggle-indicator" aria-hidden="true"></span>', '</button>', '</div>', '</div>'].join('');
8788 } else {
8789 var postboxHeader = ['<button type="button" class="handlediv" aria-expanded="true">', '<span class="screen-reader-text">Toggle panel: ' + acf.escHtml(result.title) + '</span>', '<span class="toggle-indicator" aria-hidden="true"></span>', '</button>', '<h2 class="hndle ui-sortable-handle">', '<span>' + acf.escHtml(result.title) + '</span>', '</h2>'].join('');
8790 }
8791
8792 // Ensure result.classes is set.
8793 if (!result.classes) result.classes = '';
8794
8795 // Create it.
8796 var $postbox = $(['<div id="' + result.id + '" class="postbox ' + result.classes + '">', postboxHeader, '<div class="inside">', result.html, '</div>', '</div>'].join(''));
8797
8798 // Create new hide toggle.
8799 if ($('#adv-settings').length) {
8800 var $prefs = $('#adv-settings .metabox-prefs');
8801 var $label = $(['<label for="' + result.id + '-hide">', '<input class="hide-postbox-tog" name="' + result.id + '-hide" type="checkbox" id="' + result.id + '-hide" value="' + result.id + '" checked="checked">', ' ' + result.title, '</label>'].join(''));
8802
8803 // Copy default WP events onto checkbox.
8804 copyEvents($prefs.find('input').first(), $label.find('input'));
8805
8806 // Append hide label
8807 $prefs.append($label);
8808 }
8809
8810 // Copy default WP events onto metabox.
8811 if ($('.postbox').length) {
8812 copyEvents($('.postbox .handlediv').first(), $postbox.children('.handlediv'));
8813 copyEvents($('.postbox .hndle').first(), $postbox.children('.hndle'));
8814 }
8815
8816 // Append metabox to the bottom of "side-sortables".
8817 if (result.position === 'side') {
8818 $('#' + result.position + '-sortables').append($postbox);
8819
8820 // Prepend metabox to the top of "normal-sortbables".
8821 } else {
8822 $('#' + result.position + '-sortables').prepend($postbox);
8823 }
8824
8825 // Position metabox amongst existing ACF metaboxes within the same location.
8826 var order = [];
8827 data.results.map(function (_result) {
8828 if (result.position === _result.position && $('#' + result.position + '-sortables #' + _result.id).length) {
8829 order.push(_result.id);
8830 }
8831 });
8832 sortMetabox(result.id, order);
8833
8834 // Check 'sorted' for user preference.
8835 if (data.sorted) {
8836 // Loop over each position (acf_after_title, side, normal).
8837 for (var position in data.sorted) {
8838 let order = data.sorted[position];
8839 if (typeof order !== 'string') {
8840 continue;
8841 }
8842
8843 // Explode string into array of ids.
8844 order = order.split(',');
8845
8846 // Position metabox relative to order.
8847 if (sortMetabox(result.id, order)) {
8848 break;
8849 }
8850 }
8851 }
8852
8853 // Initalize it (modifies HTML).
8854 postbox = acf.newPostbox(result);
8855
8856 // Trigger action.
8857 acf.doAction('append', $postbox);
8858 acf.doAction('append_postbox', postbox);
8859 }
8860
8861 // show postbox
8862 postbox.showEnable();
8863
8864 // append
8865 data.visible.push(result.id);
8866
8867 // Return result (may have changed).
8868 return result;
8869 });
8870
8871 // Hide these postboxes.
8872 acf.getPostboxes().map(function (postbox) {
8873 if (data.visible.indexOf(postbox.get('id')) === -1) {
8874 // Hide postbox.
8875 postbox.hideDisable();
8876
8877 // Append to data.
8878 data.hidden.push(postbox.get('id'));
8879 }
8880 });
8881
8882 // Update style.
8883 $('#acf-style').html(data.style);
8884
8885 // Do action.
8886 acf.doAction('refresh_post_screen', data);
8887 },
8888 renderUserScreen: function (json) {}
8889 });
8890
8891 /**
8892 * gutenScreen
8893 *
8894 * Adds compatibility with the Gutenberg edit screen.
8895 *
8896 * @date 11/12/18
8897 * @since ACF 5.8.0
8898 *
8899 * @param void
8900 * @return void
8901 */
8902 var gutenScreen = new acf.Model({
8903 // Keep a reference to the most recent post attributes.
8904 postEdits: {},
8905 // Wait until assets have been loaded.
8906 wait: 'prepare',
8907 initialize: function () {
8908 // Bail early if not Gutenberg.
8909 if (!acf.isGutenbergPostEditor()) {
8910 return;
8911 }
8912
8913 // Listen for changes (use debounced version as this can fires often).
8914 wp.data.subscribe(acf.debounce(this.onChange).bind(this));
8915
8916 // Customize "acf.screen.get" functions.
8917 acf.screen.getPageTemplate = this.getPageTemplate;
8918 acf.screen.getPageParent = this.getPageParent;
8919 acf.screen.getPostType = this.getPostType;
8920 acf.screen.getPostFormat = this.getPostFormat;
8921 acf.screen.getPostCoreTerms = this.getPostCoreTerms;
8922
8923 // Disable unload
8924 acf.unload.disable();
8925
8926 // Refresh metaboxes since WP 5.3.
8927 var wpMinorVersion = parseFloat(acf.get('wp_version'));
8928 if (wpMinorVersion >= 5.3) {
8929 this.addAction('refresh_post_screen', this.onRefreshPostScreen);
8930 }
8931
8932 // Trigger "refresh" after WP has moved metaboxes into place.
8933 wp.domReady(acf.refresh);
8934 },
8935 onChange: function () {
8936 // Determine attributes that can trigger a refresh.
8937 var attributes = ['template', 'parent', 'format'];
8938
8939 // Append taxonomy attribute names to this list.
8940 (wp.data.select('core').getTaxonomies() || []).map(function (taxonomy) {
8941 attributes.push(taxonomy.rest_base);
8942 });
8943
8944 // Get relevant current post edits.
8945 var _postEdits = wp.data.select('core/editor').getPostEdits();
8946 var postEdits = {};
8947 attributes.map(function (k) {
8948 if (_postEdits[k] !== undefined) {
8949 postEdits[k] = _postEdits[k];
8950 }
8951 });
8952
8953 // Detect change.
8954 if (JSON.stringify(postEdits) !== JSON.stringify(this.postEdits)) {
8955 this.postEdits = postEdits;
8956
8957 // Check screen.
8958 acf.screen.check();
8959 }
8960 },
8961 getPageTemplate: function () {
8962 return wp.data.select('core/editor').getEditedPostAttribute('template');
8963 },
8964 getPageParent: function (e, $el) {
8965 return wp.data.select('core/editor').getEditedPostAttribute('parent');
8966 },
8967 getPostType: function () {
8968 return wp.data.select('core/editor').getEditedPostAttribute('type');
8969 },
8970 getPostFormat: function (e, $el) {
8971 return wp.data.select('core/editor').getEditedPostAttribute('format');
8972 },
8973 getPostCoreTerms: function () {
8974 // vars
8975 var terms = {};
8976
8977 // Loop over taxonomies.
8978 var taxonomies = wp.data.select('core').getTaxonomies() || [];
8979 taxonomies.map(function (taxonomy) {
8980 // Append selected taxonomies to terms object.
8981 var postTerms = wp.data.select('core/editor').getEditedPostAttribute(taxonomy.rest_base);
8982 if (postTerms) {
8983 terms[taxonomy.slug] = postTerms;
8984 }
8985 });
8986
8987 // return
8988 return terms;
8989 },
8990 /**
8991 * onRefreshPostScreen
8992 *
8993 * Fires after the Post edit screen metaboxs are refreshed to update the Block Editor API state.
8994 *
8995 * @date 11/11/19
8996 * @since ACF 5.8.7
8997 *
8998 * @param object data The "check_screen" JSON response data.
8999 * @return void
9000 */
9001 onRefreshPostScreen: function (data) {
9002 // Extract vars.
9003 var select = wp.data.select('core/edit-post');
9004 var dispatch = wp.data.dispatch('core/edit-post');
9005
9006 // Load current metabox locations and data.
9007 var locations = {};
9008 select.getActiveMetaBoxLocations().map(function (location) {
9009 locations[location] = select.getMetaBoxesPerLocation(location);
9010 });
9011
9012 // Generate flat array of existing ids.
9013 var ids = [];
9014 for (var k in locations) {
9015 locations[k].map(function (m) {
9016 ids.push(m.id);
9017 });
9018 }
9019
9020 // Append new ACF metaboxes (ignore those which already exist).
9021 data.results.filter(function (r) {
9022 return ids.indexOf(r.id) === -1;
9023 }).map(function (result, i) {
9024 // Ensure location exists.
9025 var location = result.position;
9026 locations[location] = locations[location] || [];
9027
9028 // Append.
9029 locations[location].push({
9030 id: result.id,
9031 title: result.title
9032 });
9033 });
9034
9035 // Remove hidden ACF metaboxes.
9036 for (var k in locations) {
9037 locations[k] = locations[k].filter(function (m) {
9038 return data.hidden.indexOf(m.id) === -1;
9039 });
9040 }
9041
9042 // Update state.
9043 dispatch.setAvailableMetaBoxesPerLocation(locations);
9044 }
9045 });
9046 })(jQuery);
9047
9048 /***/ }),
9049
9050 /***/ "./assets/src/js/_acf-select2.js":
9051 /*!***************************************!*\
9052 !*** ./assets/src/js/_acf-select2.js ***!
9053 \***************************************/
9054 /***/ (() => {
9055
9056 (function ($, undefined) {
9057 /**
9058 * acf.newSelect2
9059 *
9060 * description
9061 *
9062 * @date 13/1/18
9063 * @since ACF 5.6.5
9064 *
9065 * @param type $var Description. Default.
9066 * @return type Description.
9067 */
9068
9069 acf.newSelect2 = function ($select, props) {
9070 // defaults
9071 props = acf.parseArgs(props, {
9072 allowNull: false,
9073 placeholder: '',
9074 multiple: false,
9075 field: false,
9076 ajax: false,
9077 tags: false,
9078 ajaxAction: '',
9079 ajaxData: function (data) {
9080 return data;
9081 },
9082 ajaxResults: function (json) {
9083 return json;
9084 },
9085 escapeMarkup: false,
9086 templateSelection: false,
9087 templateResult: false,
9088 dropdownCssClass: '',
9089 suppressFilters: false
9090 });
9091
9092 // initialize
9093 if (getVersion() == 4) {
9094 var select2 = new Select2_4($select, props);
9095 } else {
9096 var select2 = new Select2_3($select, props);
9097 }
9098
9099 // actions
9100 acf.doAction('new_select2', select2);
9101
9102 // return
9103 return select2;
9104 };
9105
9106 /**
9107 * getVersion
9108 *
9109 * description
9110 *
9111 * @date 13/1/18
9112 * @since ACF 5.6.5
9113 *
9114 * @param type $var Description. Default.
9115 * @return type Description.
9116 */
9117
9118 function getVersion() {
9119 // v4
9120 if (acf.isset(window, 'jQuery', 'fn', 'select2', 'amd')) {
9121 return 4;
9122 }
9123
9124 // v3
9125 if (acf.isset(window, 'Select2')) {
9126 return 3;
9127 }
9128
9129 // return
9130 return false;
9131 }
9132
9133 /**
9134 * Select2
9135 *
9136 * description
9137 *
9138 * @date 13/1/18
9139 * @since ACF 5.6.5
9140 *
9141 * @param type $var Description. Default.
9142 * @return type Description.
9143 */
9144
9145 var Select2 = acf.Model.extend({
9146 setup: function ($select, props) {
9147 $.extend(this.data, props);
9148 this.$el = $select;
9149 },
9150 initialize: function () {},
9151 selectOption: function (value) {
9152 var $option = this.getOption(value);
9153 if (!$option.prop('selected')) {
9154 $option.prop('selected', true).trigger('change');
9155 }
9156 },
9157 unselectOption: function (value) {
9158 var $option = this.getOption(value);
9159 if ($option.prop('selected')) {
9160 $option.prop('selected', false).trigger('change');
9161 }
9162 },
9163 getOption: function (value) {
9164 return this.$('option[value="' + value + '"]');
9165 },
9166 addOption: function (option) {
9167 // defaults
9168 option = acf.parseArgs(option, {
9169 id: '',
9170 text: '',
9171 selected: false
9172 });
9173
9174 // vars
9175 var $option = this.getOption(option.id);
9176
9177 // append
9178 if (!$option.length) {
9179 $option = $('<option></option>');
9180 $option.html(option.text);
9181 $option.attr('value', option.id);
9182 $option.prop('selected', option.selected);
9183 this.$el.append($option);
9184 }
9185
9186 // chain
9187 return $option;
9188 },
9189 getValue: function () {
9190 // vars
9191 var val = [];
9192 var $options = this.$el.find('option:selected');
9193
9194 // bail early if no selected
9195 if (!$options.exists()) {
9196 return val;
9197 }
9198
9199 // sort by attribute
9200 $options = $options.sort(function (a, b) {
9201 return +a.getAttribute('data-i') - +b.getAttribute('data-i');
9202 });
9203
9204 // loop
9205 $options.each(function () {
9206 var $el = $(this);
9207 val.push({
9208 $el: $el,
9209 id: $el.attr('value'),
9210 text: $el.text()
9211 });
9212 });
9213
9214 // return
9215 return val;
9216 },
9217 mergeOptions: function () {},
9218 getChoices: function () {
9219 // callback
9220 var crawl = function ($parent) {
9221 // vars
9222 var choices = [];
9223
9224 // loop
9225 $parent.children().each(function () {
9226 // vars
9227 var $child = $(this);
9228
9229 // optgroup
9230 if ($child.is('optgroup')) {
9231 choices.push({
9232 text: $child.attr('label'),
9233 children: crawl($child)
9234 });
9235
9236 // option
9237 } else {
9238 choices.push({
9239 id: $child.attr('value'),
9240 text: $child.text()
9241 });
9242 }
9243 });
9244
9245 // return
9246 return choices;
9247 };
9248
9249 // crawl
9250 return crawl(this.$el);
9251 },
9252 getAjaxData: function (params) {
9253 // vars
9254 var ajaxData = {
9255 action: this.get('ajaxAction'),
9256 s: params.term || '',
9257 paged: params.page || 1
9258 };
9259
9260 // field helper
9261 var field = this.get('field');
9262 if (field) {
9263 ajaxData.field_key = field.get('key');
9264 if (field.get('nonce')) {
9265 ajaxData.nonce = field.get('nonce');
9266 }
9267 }
9268
9269 // callback
9270 var callback = this.get('ajaxData');
9271 if (callback) {
9272 ajaxData = callback.apply(this, [ajaxData, params]);
9273 }
9274
9275 // filter
9276 ajaxData = acf.applyFilters('select2_ajax_data', ajaxData, this.data, this.$el, field || false, this);
9277
9278 // return
9279 return acf.prepareForAjax(ajaxData);
9280 },
9281 getAjaxResults: function (json, params) {
9282 // defaults
9283 json = acf.parseArgs(json, {
9284 results: false,
9285 more: false
9286 });
9287
9288 // callback
9289 var callback = this.get('ajaxResults');
9290 if (callback) {
9291 json = callback.apply(this, [json, params]);
9292 }
9293
9294 // filter
9295 json = acf.applyFilters('select2_ajax_results', json, params, this);
9296
9297 // return
9298 return json;
9299 },
9300 processAjaxResults: function (json, params) {
9301 // vars
9302 var json = this.getAjaxResults(json, params);
9303
9304 // change more to pagination
9305 if (json.more) {
9306 json.pagination = {
9307 more: true
9308 };
9309 }
9310
9311 // merge together groups
9312 setTimeout($.proxy(this.mergeOptions, this), 1);
9313
9314 // return
9315 return json;
9316 },
9317 destroy: function () {
9318 // destroy via api
9319 if (this.$el.data('select2')) {
9320 this.$el.select2('destroy');
9321 }
9322
9323 // destroy via HTML (duplicating HTML does not contain data)
9324 this.$el.siblings('.select2-container').remove();
9325 }
9326 });
9327
9328 /**
9329 * Select2_4
9330 *
9331 * description
9332 *
9333 * @date 13/1/18
9334 * @since ACF 5.6.5
9335 *
9336 * @param type $var Description. Default.
9337 * @return type Description.
9338 */
9339
9340 var Select2_4 = Select2.extend({
9341 initialize: function () {
9342 // vars
9343 var $select = this.$el;
9344 var options = {
9345 width: '100%',
9346 allowClear: this.get('allowNull'),
9347 placeholder: this.get('placeholder'),
9348 multiple: this.get('multiple'),
9349 escapeMarkup: this.get('escapeMarkup'),
9350 templateSelection: this.get('templateSelection'),
9351 templateResult: this.get('templateResult'),
9352 dropdownCssClass: this.get('dropdownCssClass'),
9353 suppressFilters: this.get('suppressFilters'),
9354 data: []
9355 };
9356 if (this.get('tags')) {
9357 options.tags = true;
9358 options.tokenSeparators = [','];
9359 }
9360
9361 // Clear empty templateSelections, templateResults, or dropdownCssClass.
9362 if (!options.templateSelection) {
9363 delete options.templateSelection;
9364 }
9365 if (!options.templateResult) {
9366 delete options.templateResult;
9367 }
9368 if (!options.dropdownCssClass) {
9369 delete options.dropdownCssClass;
9370 }
9371
9372 // Only use the template if SelectWoo is not loaded to work around https://github.com/woocommerce/woocommerce/pull/30473
9373 if (!acf.isset(window, 'jQuery', 'fn', 'selectWoo')) {
9374 if (!options.templateSelection) {
9375 options.templateSelection = function (selection) {
9376 var $selection = $('<span class="acf-selection"></span>');
9377 $selection.html(options.escapeMarkup(selection.text));
9378 $selection.data('element', selection.element);
9379 return $selection;
9380 };
9381 }
9382 } else {
9383 delete options.templateSelection;
9384 delete options.templateResult;
9385 }
9386
9387 // Use a default, filterable escapeMarkup if not provided.
9388 if (!options.escapeMarkup) {
9389 options.escapeMarkup = function (markup) {
9390 if (typeof markup !== 'string') {
9391 return markup;
9392 }
9393 if (this.suppressFilters) {
9394 return acf.strEscape(markup);
9395 }
9396 return acf.applyFilters('select2_escape_markup', acf.strEscape(markup), markup, $select, this.data, field || false, this);
9397 };
9398 }
9399
9400 // multiple
9401 if (options.multiple) {
9402 // reorder options
9403 this.getValue().map(function (item) {
9404 item.$el.detach().appendTo($select);
9405 });
9406 }
9407
9408 // Temporarily remove conflicting attribute.
9409 var attrAjax = $select.attr('data-ajax');
9410 if (attrAjax !== undefined) {
9411 $select.removeData('ajax');
9412 $select.removeAttr('data-ajax');
9413 }
9414
9415 // ajax
9416 if (this.get('ajax')) {
9417 options.ajax = {
9418 url: acf.get('ajaxurl'),
9419 delay: 250,
9420 dataType: 'json',
9421 type: 'post',
9422 cache: false,
9423 data: $.proxy(this.getAjaxData, this),
9424 processResults: $.proxy(this.processAjaxResults, this)
9425 };
9426 }
9427
9428 // filter for 3rd party customization
9429 if (!options.suppressFilters) {
9430 var field = this.get('field');
9431 options = acf.applyFilters('select2_args', options, $select, this.data, field || false, this);
9432 }
9433 // add select2
9434 $select.select2(options);
9435
9436 // get container (Select2 v4 does not return this from constructor)
9437 var $container = $select.next('.select2-container');
9438
9439 // multiple
9440 if (options.multiple) {
9441 // vars
9442 var $ul = $container.find('ul');
9443
9444 // sortable
9445 $ul.sortable({
9446 stop: function (e) {
9447 // loop
9448 $ul.find('.select2-selection__choice').each(function () {
9449 // Attempt to use .data if it exists (select2 version < 4.0.6) or use our template data instead.
9450 if ($(this).data('data')) {
9451 var $option = $($(this).data('data').element);
9452 } else {
9453 var $option = $($(this).find('span.acf-selection').data('element'));
9454 }
9455
9456 // detach and re-append to end
9457 $option.detach().appendTo($select);
9458 });
9459
9460 // trigger change on input (JS error if trigger on select)
9461 $select.trigger('change');
9462 }
9463 });
9464
9465 // on select, move to end
9466 $select.on('select2:select', this.proxy(function (e) {
9467 this.getOption(e.params.data.id).detach().appendTo(this.$el);
9468 }));
9469 }
9470
9471 // add handler to auto-focus searchbox (for jQuery 3.6)
9472 $select.on('select2:open', () => {
9473 $('.select2-container--open .select2-search__field').get(-1).focus();
9474 });
9475
9476 // add class
9477 $container.addClass('-acf');
9478
9479 // Add back temporarily removed attr.
9480 if (attrAjax !== undefined) {
9481 $select.attr('data-ajax', attrAjax);
9482 }
9483
9484 // action for 3rd party customization
9485 if (!options.suppressFilters) {
9486 acf.doAction('select2_init', $select, options, this.data, field || false, this);
9487 }
9488 },
9489 mergeOptions: function () {
9490 // vars
9491 var $prevOptions = false;
9492 var $prevGroup = false;
9493
9494 // loop
9495 $('.select2-results__option[role="group"]').each(function () {
9496 // vars
9497 var $options = $(this).children('ul');
9498 var $group = $(this).children('strong');
9499
9500 // compare to previous
9501 if ($prevGroup && $prevGroup.text() === $group.text()) {
9502 $prevOptions.append($options.children());
9503 $(this).remove();
9504 return;
9505 }
9506
9507 // update vars
9508 $prevOptions = $options;
9509 $prevGroup = $group;
9510 });
9511 }
9512 });
9513
9514 /**
9515 * Select2_3
9516 *
9517 * description
9518 *
9519 * @date 13/1/18
9520 * @since ACF 5.6.5
9521 *
9522 * @param type $var Description. Default.
9523 * @return type Description.
9524 */
9525
9526 var Select2_3 = Select2.extend({
9527 initialize: function () {
9528 // vars
9529 var $select = this.$el;
9530 var value = this.getValue();
9531 var multiple = this.get('multiple');
9532 var options = {
9533 width: '100%',
9534 allowClear: this.get('allowNull'),
9535 placeholder: this.get('placeholder'),
9536 separator: '||',
9537 multiple: this.get('multiple'),
9538 data: this.getChoices(),
9539 escapeMarkup: function (string) {
9540 return acf.escHtml(string);
9541 },
9542 dropdownCss: {
9543 'z-index': '999999999'
9544 },
9545 initSelection: function (element, callback) {
9546 if (multiple) {
9547 callback(value);
9548 } else {
9549 callback(value.shift());
9550 }
9551 }
9552 };
9553 // get hidden input
9554 var $input = $select.siblings('input');
9555 if (!$input.length) {
9556 $input = $('<input type="hidden" />');
9557 $select.before($input);
9558 }
9559
9560 // set input value
9561 inputValue = value.map(function (item) {
9562 return item.id;
9563 }).join('||');
9564 $input.val(inputValue);
9565
9566 // multiple
9567 if (options.multiple) {
9568 // reorder options
9569 value.map(function (item) {
9570 item.$el.detach().appendTo($select);
9571 });
9572 }
9573
9574 // remove blank option as we have a clear all button
9575 if (options.allowClear) {
9576 options.data = options.data.filter(function (item) {
9577 return item.id !== '';
9578 });
9579 }
9580
9581 // remove conflicting atts
9582 $select.removeData('ajax');
9583 $select.removeAttr('data-ajax');
9584
9585 // ajax
9586 if (this.get('ajax')) {
9587 options.ajax = {
9588 url: acf.get('ajaxurl'),
9589 quietMillis: 250,
9590 dataType: 'json',
9591 type: 'post',
9592 cache: false,
9593 data: $.proxy(this.getAjaxData, this),
9594 results: $.proxy(this.processAjaxResults, this)
9595 };
9596 }
9597
9598 // filter for 3rd party customization
9599 var field = this.get('field');
9600 options = acf.applyFilters('select2_args', options, $select, this.data, field || false, this);
9601
9602 // add select2
9603 $input.select2(options);
9604
9605 // get container
9606 var $container = $input.select2('container');
9607
9608 // helper to find this select's option
9609 var getOption = $.proxy(this.getOption, this);
9610
9611 // multiple
9612 if (options.multiple) {
9613 // vars
9614 var $ul = $container.find('ul');
9615
9616 // sortable
9617 $ul.sortable({
9618 stop: function () {
9619 // loop
9620 $ul.find('.select2-search-choice').each(function () {
9621 // vars
9622 var data = $(this).data('select2Data');
9623 var $option = getOption(data.id);
9624
9625 // detach and re-append to end
9626 $option.detach().appendTo($select);
9627 });
9628
9629 // trigger change on input (JS error if trigger on select)
9630 $select.trigger('change');
9631 }
9632 });
9633 }
9634
9635 // on select, create option and move to end
9636 $input.on('select2-selecting', function (e) {
9637 // vars
9638 var item = e.choice;
9639 var $option = getOption(item.id);
9640
9641 // create if doesn't exist
9642 if (!$option.length) {
9643 $option = $('<option value="' + item.id + '">' + item.text + '</option>');
9644 }
9645
9646 // detach and re-append to end
9647 $option.detach().appendTo($select);
9648 });
9649
9650 // add class
9651 $container.addClass('-acf');
9652
9653 // action for 3rd party customization
9654 acf.doAction('select2_init', $select, options, this.data, field || false, this);
9655
9656 // change
9657 $input.on('change', function () {
9658 var val = $input.val();
9659 if (val.indexOf('||')) {
9660 val = val.split('||');
9661 }
9662 $select.val(val).trigger('change');
9663 });
9664
9665 // hide select
9666 $select.hide();
9667 },
9668 mergeOptions: function () {
9669 // vars
9670 var $prevOptions = false;
9671 var $prevGroup = false;
9672
9673 // loop
9674 $('#select2-drop .select2-result-with-children').each(function () {
9675 // vars
9676 var $options = $(this).children('ul');
9677 var $group = $(this).children('.select2-result-label');
9678
9679 // compare to previous
9680 if ($prevGroup && $prevGroup.text() === $group.text()) {
9681 $prevGroup.append($options.children());
9682 $(this).remove();
9683 return;
9684 }
9685
9686 // update vars
9687 $prevOptions = $options;
9688 $prevGroup = $group;
9689 });
9690 },
9691 getAjaxData: function (term, page) {
9692 // create Select2 v4 params
9693 var params = {
9694 term: term,
9695 page: page
9696 };
9697
9698 // filter
9699 var field = this.get('field');
9700 params = acf.applyFilters('select2_ajax_data', params, this.data, this.$el, field || false, this);
9701 // return
9702 return Select2.prototype.getAjaxData.apply(this, [params]);
9703 }
9704 });
9705
9706 // manager
9707 var select2Manager = new acf.Model({
9708 priority: 5,
9709 wait: 'prepare',
9710 actions: {
9711 duplicate: 'onDuplicate'
9712 },
9713 initialize: function () {
9714 // vars
9715 var locale = acf.get('locale');
9716 var rtl = acf.get('rtl');
9717 var l10n = acf.get('select2L10n');
9718 var version = getVersion();
9719
9720 // bail early if no l10n
9721 if (!l10n) {
9722 return false;
9723 }
9724
9725 // bail early if 'en'
9726 if (locale.indexOf('en') === 0) {
9727 return false;
9728 }
9729
9730 // initialize
9731 if (version == 4) {
9732 this.addTranslations4();
9733 } else if (version == 3) {
9734 this.addTranslations3();
9735 }
9736 },
9737 addTranslations4: function () {
9738 // vars
9739 var l10n = acf.get('select2L10n');
9740 var locale = acf.get('locale');
9741
9742 // modify local to match html[lang] attribute (used by Select2)
9743 locale = locale.replace('_', '-');
9744
9745 // select2L10n
9746 var select2L10n = {
9747 errorLoading: function () {
9748 return l10n.load_fail;
9749 },
9750 inputTooLong: function (args) {
9751 var overChars = args.input.length - args.maximum;
9752 if (overChars > 1) {
9753 return l10n.input_too_long_n.replace('%d', overChars);
9754 }
9755 return l10n.input_too_long_1;
9756 },
9757 inputTooShort: function (args) {
9758 var remainingChars = args.minimum - args.input.length;
9759 if (remainingChars > 1) {
9760 return l10n.input_too_short_n.replace('%d', remainingChars);
9761 }
9762 return l10n.input_too_short_1;
9763 },
9764 loadingMore: function () {
9765 return l10n.load_more;
9766 },
9767 maximumSelected: function (args) {
9768 var maximum = args.maximum;
9769 if (maximum > 1) {
9770 return l10n.selection_too_long_n.replace('%d', maximum);
9771 }
9772 return l10n.selection_too_long_1;
9773 },
9774 noResults: function () {
9775 return l10n.matches_0;
9776 },
9777 searching: function () {
9778 return l10n.searching;
9779 }
9780 };
9781
9782 // append
9783 jQuery.fn.select2.amd.define('select2/i18n/' + locale, [], function () {
9784 return select2L10n;
9785 });
9786 },
9787 addTranslations3: function () {
9788 // vars
9789 var l10n = acf.get('select2L10n');
9790 var locale = acf.get('locale');
9791
9792 // modify local to match html[lang] attribute (used by Select2)
9793 locale = locale.replace('_', '-');
9794
9795 // select2L10n
9796 var select2L10n = {
9797 formatMatches: function (matches) {
9798 if (matches > 1) {
9799 return l10n.matches_n.replace('%d', matches);
9800 }
9801 return l10n.matches_1;
9802 },
9803 formatNoMatches: function () {
9804 return l10n.matches_0;
9805 },
9806 formatAjaxError: function () {
9807 return l10n.load_fail;
9808 },
9809 formatInputTooShort: function (input, min) {
9810 var remainingChars = min - input.length;
9811 if (remainingChars > 1) {
9812 return l10n.input_too_short_n.replace('%d', remainingChars);
9813 }
9814 return l10n.input_too_short_1;
9815 },
9816 formatInputTooLong: function (input, max) {
9817 var overChars = input.length - max;
9818 if (overChars > 1) {
9819 return l10n.input_too_long_n.replace('%d', overChars);
9820 }
9821 return l10n.input_too_long_1;
9822 },
9823 formatSelectionTooBig: function (maximum) {
9824 if (maximum > 1) {
9825 return l10n.selection_too_long_n.replace('%d', maximum);
9826 }
9827 return l10n.selection_too_long_1;
9828 },
9829 formatLoadMore: function () {
9830 return l10n.load_more;
9831 },
9832 formatSearching: function () {
9833 return l10n.searching;
9834 }
9835 };
9836
9837 // ensure locales exists
9838 $.fn.select2.locales = $.fn.select2.locales || {};
9839
9840 // append
9841 $.fn.select2.locales[locale] = select2L10n;
9842 $.extend($.fn.select2.defaults, select2L10n);
9843 },
9844 onDuplicate: function ($el, $el2) {
9845 $el2.find('.select2-container').remove();
9846 }
9847 });
9848 })(jQuery);
9849
9850 /***/ }),
9851
9852 /***/ "./assets/src/js/_acf-tinymce.js":
9853 /*!***************************************!*\
9854 !*** ./assets/src/js/_acf-tinymce.js ***!
9855 \***************************************/
9856 /***/ (() => {
9857
9858 (function ($, undefined) {
9859 acf.tinymce = {
9860 /*
9861 * defaults
9862 *
9863 * This function will return default mce and qt settings
9864 *
9865 * @type function
9866 * @date 18/8/17
9867 * @since ACF 5.6.0
9868 *
9869 * @param $post_id (int)
9870 * @return $post_id (int)
9871 */
9872
9873 defaults: function () {
9874 // bail early if no tinyMCEPreInit
9875 if (typeof tinyMCEPreInit === 'undefined') return false;
9876
9877 // vars
9878 var defaults = {
9879 tinymce: tinyMCEPreInit.mceInit.acf_content,
9880 quicktags: tinyMCEPreInit.qtInit.acf_content
9881 };
9882
9883 // return
9884 return defaults;
9885 },
9886 /*
9887 * initialize
9888 *
9889 * This function will initialize the tinymce and quicktags instances
9890 *
9891 * @type function
9892 * @date 18/8/17
9893 * @since ACF 5.6.0
9894 *
9895 * @param $post_id (int)
9896 * @return $post_id (int)
9897 */
9898
9899 initialize: function (id, args) {
9900 // defaults
9901 args = acf.parseArgs(args, {
9902 tinymce: true,
9903 quicktags: true,
9904 toolbar: 'full',
9905 mode: 'visual',
9906 // visual,text
9907 field: false
9908 });
9909
9910 // tinymce
9911 if (args.tinymce) {
9912 this.initializeTinymce(id, args);
9913 }
9914
9915 // quicktags
9916 if (args.quicktags) {
9917 this.initializeQuicktags(id, args);
9918 }
9919 },
9920 /*
9921 * initializeTinymce
9922 *
9923 * This function will initialize the tinymce instance
9924 *
9925 * @type function
9926 * @date 18/8/17
9927 * @since ACF 5.6.0
9928 *
9929 * @param $post_id (int)
9930 * @return $post_id (int)
9931 */
9932
9933 initializeTinymce: function (id, args) {
9934 // vars
9935 var $textarea = $('#' + id);
9936 var defaults = this.defaults();
9937 var toolbars = acf.get('toolbars');
9938 var field = args.field || false;
9939 var $field = field.$el || false;
9940
9941 // bail early
9942 if (typeof tinymce === 'undefined') return false;
9943 if (!defaults) return false;
9944
9945 // check if exists
9946 if (tinymce.get(id)) {
9947 return this.enable(id);
9948 }
9949
9950 // settings
9951 var init = $.extend({}, defaults.tinymce, args.tinymce);
9952 init.id = id;
9953 init.selector = '#' + id;
9954
9955 // toolbar
9956 var toolbar = args.toolbar;
9957 if (toolbar && toolbars && toolbars[toolbar]) {
9958 for (var i = 1; i <= 4; i++) {
9959 init['toolbar' + i] = toolbars[toolbar][i] || '';
9960 }
9961 }
9962
9963 // event
9964 init.setup = function (ed) {
9965 ed.on('change', function (e) {
9966 ed.save(); // save to textarea
9967 $textarea.trigger('change');
9968 });
9969
9970 // Fix bug where Gutenberg does not hear "mouseup" event and tries to select multiple blocks.
9971 ed.on('mouseup', function (e) {
9972 var event = new MouseEvent('mouseup');
9973 window.dispatchEvent(event);
9974 });
9975
9976 // Temporarily comment out. May not be necessary due to wysiwyg field actions.
9977 //ed.on('unload', function(e) {
9978 // acf.tinymce.remove( id );
9979 //});
9980 };
9981
9982 // disable wp_autoresize_on (no solution yet for fixed toolbar)
9983 init.wp_autoresize_on = false;
9984
9985 // Enable wpautop allowing value to save without <p> tags.
9986 // Only if the "TinyMCE Advanced" plugin hasn't already set this functionality.
9987 if (!init.tadv_noautop) {
9988 init.wpautop = true;
9989 }
9990
9991 // hook for 3rd party customization
9992 init = acf.applyFilters('wysiwyg_tinymce_settings', init, id, field);
9993
9994 // z-index fix (caused too many conflicts)
9995 //if( acf.isset(tinymce,'ui','FloatPanel') ) {
9996 // tinymce.ui.FloatPanel.zIndex = 900000;
9997 //}
9998
9999 // store settings
10000 tinyMCEPreInit.mceInit[id] = init;
10001
10002 // visual tab is active
10003 if (args.mode == 'visual') {
10004 // init
10005 var result = tinymce.init(init);
10006
10007 // get editor
10008 var ed = tinymce.get(id);
10009
10010 // validate
10011 if (!ed) {
10012 return false;
10013 }
10014
10015 // add reference
10016 ed.acf = args.field;
10017
10018 // action
10019 acf.doAction('wysiwyg_tinymce_init', ed, ed.id, init, field);
10020 }
10021 },
10022 /*
10023 * initializeQuicktags
10024 *
10025 * This function will initialize the quicktags instance
10026 *
10027 * @type function
10028 * @date 18/8/17
10029 * @since ACF 5.6.0
10030 *
10031 * @param $post_id (int)
10032 * @return $post_id (int)
10033 */
10034
10035 initializeQuicktags: function (id, args) {
10036 // vars
10037 var defaults = this.defaults();
10038
10039 // bail early
10040 if (typeof quicktags === 'undefined') return false;
10041 if (!defaults) return false;
10042
10043 // settings
10044 var init = $.extend({}, defaults.quicktags, args.quicktags);
10045 init.id = id;
10046
10047 // filter
10048 var field = args.field || false;
10049 var $field = field.$el || false;
10050 init = acf.applyFilters('wysiwyg_quicktags_settings', init, init.id, field);
10051
10052 // store settings
10053 tinyMCEPreInit.qtInit[id] = init;
10054
10055 // init
10056 var ed = quicktags(init);
10057
10058 // validate
10059 if (!ed) {
10060 return false;
10061 }
10062
10063 // generate HTML
10064 this.buildQuicktags(ed);
10065
10066 // action for 3rd party customization
10067 acf.doAction('wysiwyg_quicktags_init', ed, ed.id, init, field);
10068 },
10069 /*
10070 * buildQuicktags
10071 *
10072 * This function will build the quicktags HTML
10073 *
10074 * @type function
10075 * @date 18/8/17
10076 * @since ACF 5.6.0
10077 *
10078 * @param $post_id (int)
10079 * @return $post_id (int)
10080 */
10081
10082 buildQuicktags: function (ed) {
10083 var canvas,
10084 name,
10085 settings,
10086 theButtons,
10087 html,
10088 ed,
10089 id,
10090 i,
10091 use,
10092 instanceId,
10093 defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
10094 canvas = ed.canvas;
10095 name = ed.name;
10096 settings = ed.settings;
10097 html = '';
10098 theButtons = {};
10099 use = '';
10100 instanceId = ed.id;
10101
10102 // set buttons
10103 if (settings.buttons) {
10104 use = ',' + settings.buttons + ',';
10105 }
10106 for (i in edButtons) {
10107 if (!edButtons[i]) {
10108 continue;
10109 }
10110 id = edButtons[i].id;
10111 if (use && defaults.indexOf(',' + id + ',') !== -1 && use.indexOf(',' + id + ',') === -1) {
10112 continue;
10113 }
10114 if (!edButtons[i].instance || edButtons[i].instance === instanceId) {
10115 theButtons[id] = edButtons[i];
10116 if (edButtons[i].html) {
10117 html += edButtons[i].html(name + '_');
10118 }
10119 }
10120 }
10121 if (use && use.indexOf(',dfw,') !== -1) {
10122 theButtons.dfw = new QTags.DFWButton();
10123 html += theButtons.dfw.html(name + '_');
10124 }
10125 if ('rtl' === document.getElementsByTagName('html')[0].dir) {
10126 theButtons.textdirection = new QTags.TextDirectionButton();
10127 html += theButtons.textdirection.html(name + '_');
10128 }
10129 ed.toolbar.innerHTML = html;
10130 ed.theButtons = theButtons;
10131 if (typeof jQuery !== 'undefined') {
10132 jQuery(document).triggerHandler('quicktags-init', [ed]);
10133 }
10134 },
10135 disable: function (id) {
10136 this.destroyTinymce(id);
10137 },
10138 remove: function (id) {
10139 this.destroyTinymce(id);
10140 },
10141 destroy: function (id) {
10142 this.destroyTinymce(id);
10143 },
10144 destroyTinymce: function (id) {
10145 // bail early
10146 if (typeof tinymce === 'undefined') return false;
10147
10148 // get editor
10149 var ed = tinymce.get(id);
10150
10151 // bail early if no editor
10152 if (!ed) return false;
10153
10154 // save
10155 ed.save();
10156
10157 // destroy editor
10158 ed.destroy();
10159
10160 // return
10161 return true;
10162 },
10163 enable: function (id) {
10164 this.enableTinymce(id);
10165 },
10166 enableTinymce: function (id) {
10167 // bail early
10168 if (typeof switchEditors === 'undefined') return false;
10169
10170 // bail early if not initialized
10171 if (typeof tinyMCEPreInit.mceInit[id] === 'undefined') return false;
10172
10173 // Ensure textarea element is visible
10174 // - Fixes bug in block editor when switching between "Block" and "Document" tabs.
10175 $('#' + id).show();
10176
10177 // toggle
10178 switchEditors.go(id, 'tmce');
10179
10180 // return
10181 return true;
10182 }
10183 };
10184 var editorManager = new acf.Model({
10185 // hook in before fieldsEventManager, conditions, etc
10186 priority: 5,
10187 actions: {
10188 prepare: 'onPrepare',
10189 ready: 'onReady'
10190 },
10191 onPrepare: function () {
10192 // find hidden editor which may exist within a field
10193 var $div = $('#acf-hidden-wp-editor');
10194
10195 // move to footer
10196 if ($div.exists()) {
10197 $div.appendTo('body');
10198 }
10199 },
10200 onReady: function () {
10201 // Restore wp.editor functions used by tinymce removed in WP5.
10202 if (acf.isset(window, 'wp', 'oldEditor')) {
10203 wp.editor.autop = wp.oldEditor.autop;
10204 wp.editor.removep = wp.oldEditor.removep;
10205 }
10206
10207 // bail early if no tinymce
10208 if (!acf.isset(window, 'tinymce', 'on')) return;
10209
10210 // restore default activeEditor
10211 tinymce.on('AddEditor', function (data) {
10212 // vars
10213 var editor = data.editor;
10214
10215 // bail early if not 'acf'
10216 if (editor.id.substr(0, 3) !== 'acf') return;
10217
10218 // override if 'content' exists
10219 editor = tinymce.editors.content || editor;
10220
10221 // update vars
10222 tinymce.activeEditor = editor;
10223 wpActiveEditor = editor.id;
10224 });
10225 }
10226 });
10227 })(jQuery);
10228
10229 /***/ }),
10230
10231 /***/ "./assets/src/js/_acf-unload.js":
10232 /*!**************************************!*\
10233 !*** ./assets/src/js/_acf-unload.js ***!
10234 \**************************************/
10235 /***/ (() => {
10236
10237 (function ($, undefined) {
10238 acf.unload = new acf.Model({
10239 wait: 'load',
10240 active: true,
10241 changed: false,
10242 actions: {
10243 validation_failure: 'startListening',
10244 validation_success: 'stopListening'
10245 },
10246 events: {
10247 'change form .acf-field': 'startListening',
10248 'submit form': 'stopListening'
10249 },
10250 enable: function () {
10251 this.active = true;
10252 },
10253 disable: function () {
10254 this.active = false;
10255 },
10256 reset: function () {
10257 this.stopListening();
10258 },
10259 startListening: function () {
10260 // bail early if already changed, not active
10261 if (this.changed || !this.active) {
10262 return;
10263 }
10264
10265 // update
10266 this.changed = true;
10267
10268 // add event
10269 $(window).on('beforeunload', this.onUnload);
10270 },
10271 stopListening: function () {
10272 // update
10273 this.changed = false;
10274
10275 // remove event
10276 $(window).off('beforeunload', this.onUnload);
10277 },
10278 onUnload: function () {
10279 return acf.__('The changes you made will be lost if you navigate away from this page');
10280 }
10281 });
10282 })(jQuery);
10283
10284 /***/ }),
10285
10286 /***/ "./assets/src/js/_acf-validation.js":
10287 /*!******************************************!*\
10288 !*** ./assets/src/js/_acf-validation.js ***!
10289 \******************************************/
10290 /***/ (() => {
10291
10292 (function ($, undefined) {
10293 /**
10294 * Validator
10295 *
10296 * The model for validating forms
10297 *
10298 * @date 4/9/18
10299 * @since ACF 5.7.5
10300 *
10301 * @param void
10302 * @return void
10303 */
10304 var Validator = acf.Model.extend({
10305 /** @var string The model identifier. */
10306 id: 'Validator',
10307 /** @var object The model data. */
10308 data: {
10309 /** @var array The form errors. */
10310 errors: [],
10311 /** @var object The form notice. */
10312 notice: null,
10313 /** @var string The form status. loading, invalid, valid */
10314 status: ''
10315 },
10316 /** @var object The model events. */
10317 events: {
10318 'changed:status': 'onChangeStatus'
10319 },
10320 /**
10321 * addErrors
10322 *
10323 * Adds errors to the form.
10324 *
10325 * @date 4/9/18
10326 * @since ACF 5.7.5
10327 *
10328 * @param array errors An array of errors.
10329 * @return void
10330 */
10331 addErrors: function (errors) {
10332 errors.map(this.addError, this);
10333 },
10334 /**
10335 * addError
10336 *
10337 * Adds and error to the form.
10338 *
10339 * @date 4/9/18
10340 * @since ACF 5.7.5
10341 *
10342 * @param object error An error object containing input and message.
10343 * @return void
10344 */
10345 addError: function (error) {
10346 this.data.errors.push(error);
10347 },
10348 /**
10349 * hasErrors
10350 *
10351 * Returns true if the form has errors.
10352 *
10353 * @date 4/9/18
10354 * @since ACF 5.7.5
10355 *
10356 * @param void
10357 * @return bool
10358 */
10359 hasErrors: function () {
10360 return this.data.errors.length;
10361 },
10362 /**
10363 * clearErrors
10364 *
10365 * Removes any errors.
10366 *
10367 * @date 4/9/18
10368 * @since ACF 5.7.5
10369 *
10370 * @param void
10371 * @return void
10372 */
10373 clearErrors: function () {
10374 return this.data.errors = [];
10375 },
10376 /**
10377 * getErrors
10378 *
10379 * Returns the forms errors.
10380 *
10381 * @date 4/9/18
10382 * @since ACF 5.7.5
10383 *
10384 * @param void
10385 * @return array
10386 */
10387 getErrors: function () {
10388 return this.data.errors;
10389 },
10390 /**
10391 * getFieldErrors
10392 *
10393 * Returns the forms field errors.
10394 *
10395 * @date 4/9/18
10396 * @since ACF 5.7.5
10397 *
10398 * @param void
10399 * @return array
10400 */
10401 getFieldErrors: function () {
10402 // vars
10403 var errors = [];
10404 var inputs = [];
10405
10406 // loop
10407 this.getErrors().map(function (error) {
10408 // bail early if global
10409 if (!error.input) return;
10410
10411 // update if exists
10412 var i = inputs.indexOf(error.input);
10413 if (i > -1) {
10414 errors[i] = error;
10415
10416 // update
10417 } else {
10418 errors.push(error);
10419 inputs.push(error.input);
10420 }
10421 });
10422
10423 // return
10424 return errors;
10425 },
10426 /**
10427 * getGlobalErrors
10428 *
10429 * Returns the forms global errors (errors without a specific input).
10430 *
10431 * @date 4/9/18
10432 * @since ACF 5.7.5
10433 *
10434 * @param void
10435 * @return array
10436 */
10437 getGlobalErrors: function () {
10438 // return array of errors that contain no input
10439 return this.getErrors().filter(function (error) {
10440 return !error.input;
10441 });
10442 },
10443 /**
10444 * showErrors
10445 *
10446 * Displays all errors for this form.
10447 *
10448 * @since ACF 5.7.5
10449 *
10450 * @param {string} [location=before] - The location to add the error, before or after the input. Default before. Since ACF 6.3.
10451 * @return void
10452 */
10453 showErrors: function (location = 'before') {
10454 // bail early if no errors
10455 if (!this.hasErrors()) {
10456 return;
10457 }
10458
10459 // vars
10460 var fieldErrors = this.getFieldErrors();
10461 var globalErrors = this.getGlobalErrors();
10462
10463 // vars
10464 var errorCount = 0;
10465 var $scrollTo = false;
10466
10467 // loop
10468 fieldErrors.map(function (error) {
10469 // get input
10470 var $input = this.$('[name="' + error.input + '"]').first();
10471
10472 // if $_POST value was an array, this $input may not exist
10473 if (!$input.length) {
10474 $input = this.$('[name^="' + error.input + '"]').first();
10475 }
10476
10477 // bail early if input doesn't exist
10478 if (!$input.length) {
10479 return;
10480 }
10481
10482 // increase
10483 errorCount++;
10484
10485 // get field
10486 var field = acf.getClosestField($input);
10487
10488 // make sure the postbox containing this field is not hidden by screen options
10489 ensureFieldPostBoxIsVisible(field.$el);
10490
10491 // show error
10492 field.showError(error.message, location);
10493
10494 // set $scrollTo
10495 if (!$scrollTo) {
10496 $scrollTo = field.$el;
10497 }
10498 }, this);
10499
10500 // errorMessage
10501 var errorMessage = acf.__('Validation failed');
10502 globalErrors.map(function (error) {
10503 errorMessage += '. ' + error.message;
10504 });
10505 if (errorCount == 1) {
10506 errorMessage += '. ' + acf.__('1 field requires attention');
10507 } else if (errorCount > 1) {
10508 errorMessage += '. ' + acf.__('%d fields require attention').replace('%d', errorCount);
10509 }
10510
10511 // notice
10512 if (this.has('notice')) {
10513 this.get('notice').update({
10514 type: 'error',
10515 text: errorMessage
10516 });
10517 } else {
10518 var notice = acf.newNotice({
10519 type: 'error',
10520 text: errorMessage,
10521 target: this.$el
10522 });
10523 this.set('notice', notice);
10524 }
10525
10526 // If in a modal, don't try to scroll.
10527 if (this.$el.parents('.acf-popup-box').length) {
10528 return;
10529 }
10530
10531 // if no $scrollTo, set to message
10532 if (!$scrollTo) {
10533 $scrollTo = this.get('notice').$el;
10534 }
10535
10536 // timeout
10537 setTimeout(function () {
10538 $('html, body').animate({
10539 scrollTop: $scrollTo.offset().top - $(window).height() / 2
10540 }, 500);
10541 }, 10);
10542 },
10543 /**
10544 * onChangeStatus
10545 *
10546 * Update the form class when changing the 'status' data
10547 *
10548 * @date 4/9/18
10549 * @since ACF 5.7.5
10550 *
10551 * @param object e The event object.
10552 * @param jQuery $el The form element.
10553 * @param string value The new status.
10554 * @param string prevValue The old status.
10555 * @return void
10556 */
10557 onChangeStatus: function (e, $el, value, prevValue) {
10558 this.$el.removeClass('is-' + prevValue).addClass('is-' + value);
10559 },
10560 /**
10561 * validate
10562 *
10563 * Validates the form via AJAX.
10564 *
10565 * @date 4/9/18
10566 * @since ACF 5.7.5
10567 *
10568 * @param object args A list of settings to customize the validation process.
10569 * @return bool True if the form is valid.
10570 */
10571 validate: function (args) {
10572 // default args
10573 args = acf.parseArgs(args, {
10574 // trigger event
10575 event: false,
10576 // reset the form after submit
10577 reset: false,
10578 // loading callback
10579 loading: function () {},
10580 // complete callback
10581 complete: function () {},
10582 // failure callback
10583 failure: function () {},
10584 // success callback
10585 success: function ($form) {
10586 $form.submit();
10587 }
10588 });
10589
10590 // return true if is valid - allows form submit
10591 if (this.get('status') == 'valid') {
10592 return true;
10593 }
10594
10595 // return false if is currently validating - prevents form submit
10596 if (this.get('status') == 'validating') {
10597 return false;
10598 }
10599
10600 // return true if no ACF fields exist (no need to validate)
10601 if (!this.$('.acf-field').length) {
10602 return true;
10603 }
10604
10605 // if event is provided, create a new success callback.
10606 if (args.event) {
10607 var event = $.Event(null, args.event);
10608 args.success = function () {
10609 acf.enableSubmit($(event.target)).trigger(event);
10610 };
10611 }
10612
10613 // action for 3rd party
10614 acf.doAction('validation_begin', this.$el);
10615
10616 // lock form
10617 acf.lockForm(this.$el);
10618
10619 // loading callback
10620 args.loading(this.$el, this);
10621
10622 // update status
10623 this.set('status', 'validating');
10624
10625 // success callback
10626 var onSuccess = function (json) {
10627 // validate
10628 if (!acf.isAjaxSuccess(json)) {
10629 return;
10630 }
10631
10632 // filter
10633 var data = acf.applyFilters('validation_complete', json.data, this.$el, this);
10634
10635 // add errors
10636 if (!data.valid) {
10637 this.addErrors(data.errors);
10638 }
10639 };
10640
10641 // complete
10642 var onComplete = function () {
10643 // unlock form
10644 acf.unlockForm(this.$el);
10645
10646 // failure
10647 if (this.hasErrors()) {
10648 // update status
10649 this.set('status', 'invalid');
10650
10651 // action
10652 acf.doAction('validation_failure', this.$el, this);
10653
10654 // display errors
10655 this.showErrors();
10656
10657 // failure callback
10658 args.failure(this.$el, this);
10659
10660 // success
10661 } else {
10662 // update status
10663 this.set('status', 'valid');
10664
10665 // remove previous error message
10666 if (this.has('notice')) {
10667 this.get('notice').update({
10668 type: 'success',
10669 text: acf.__('Validation successful'),
10670 timeout: 1000
10671 });
10672 }
10673
10674 // action
10675 acf.doAction('validation_success', this.$el, this);
10676 acf.doAction('submit', this.$el);
10677
10678 // success callback (submit form)
10679 args.success(this.$el, this);
10680
10681 // lock form
10682 acf.lockForm(this.$el);
10683
10684 // reset
10685 if (args.reset) {
10686 this.reset();
10687 }
10688 }
10689
10690 // complete callback
10691 args.complete(this.$el, this);
10692
10693 // clear errors
10694 this.clearErrors();
10695 };
10696
10697 // serialize form data
10698 var data = acf.serialize(this.$el);
10699 data.action = 'acf/validate_save_post';
10700
10701 // ajax
10702 $.ajax({
10703 url: acf.get('ajaxurl'),
10704 data: acf.prepareForAjax(data, true),
10705 type: 'post',
10706 dataType: 'json',
10707 context: this,
10708 success: onSuccess,
10709 complete: onComplete
10710 });
10711
10712 // return false to fail validation and allow AJAX
10713 return false;
10714 },
10715 /**
10716 * setup
10717 *
10718 * Called during the constructor function to setup this instance
10719 *
10720 * @date 4/9/18
10721 * @since ACF 5.7.5
10722 *
10723 * @param jQuery $form The form element.
10724 * @return void
10725 */
10726 setup: function ($form) {
10727 // set $el
10728 this.$el = $form;
10729 },
10730 /**
10731 * reset
10732 *
10733 * Rests the validation to be used again.
10734 *
10735 * @date 6/9/18
10736 * @since ACF 5.7.5
10737 *
10738 * @param void
10739 * @return void
10740 */
10741 reset: function () {
10742 // reset data
10743 this.set('errors', []);
10744 this.set('notice', null);
10745 this.set('status', '');
10746
10747 // unlock form
10748 acf.unlockForm(this.$el);
10749 }
10750 });
10751
10752 /**
10753 * getValidator
10754 *
10755 * Returns the instance for a given form element.
10756 *
10757 * @date 4/9/18
10758 * @since ACF 5.7.5
10759 *
10760 * @param jQuery $el The form element.
10761 * @return object
10762 */
10763 var getValidator = function ($el) {
10764 // instantiate
10765 var validator = $el.data('acf');
10766 if (!validator) {
10767 validator = new Validator($el);
10768 }
10769
10770 // return
10771 return validator;
10772 };
10773
10774 /**
10775 * A helper function to generate a Validator for a block form, so .addErrors can be run via block logic.
10776 *
10777 * @since ACF 6.3
10778 *
10779 * @param $el The jQuery block form wrapper element.
10780 * @return bool
10781 */
10782 acf.getBlockFormValidator = function ($el) {
10783 return getValidator($el);
10784 };
10785
10786 /**
10787 * A helper function for the Validator.validate() function.
10788 * Returns true if form is valid, or fetches a validation request and returns false.
10789 *
10790 * @since ACF 5.6.9
10791 *
10792 * @param object args A list of settings to customize the validation process.
10793 * @return bool
10794 */
10795 acf.validateForm = function (args) {
10796 return getValidator(args.form).validate(args);
10797 };
10798
10799 /**
10800 * acf.enableSubmit
10801 *
10802 * Enables a submit button and returns the element.
10803 *
10804 * @date 30/8/18
10805 * @since ACF 5.7.4
10806 *
10807 * @param jQuery $submit The submit button.
10808 * @return jQuery
10809 */
10810 acf.enableSubmit = function ($submit) {
10811 return $submit.removeClass('disabled').removeAttr('disabled');
10812 };
10813
10814 /**
10815 * acf.disableSubmit
10816 *
10817 * Disables a submit button and returns the element.
10818 *
10819 * @date 30/8/18
10820 * @since ACF 5.7.4
10821 *
10822 * @param jQuery $submit The submit button.
10823 * @return jQuery
10824 */
10825 acf.disableSubmit = function ($submit) {
10826 return $submit.addClass('disabled').attr('disabled', true);
10827 };
10828
10829 /**
10830 * acf.showSpinner
10831 *
10832 * Shows the spinner element.
10833 *
10834 * @date 4/9/18
10835 * @since ACF 5.7.5
10836 *
10837 * @param jQuery $spinner The spinner element.
10838 * @return jQuery
10839 */
10840 acf.showSpinner = function ($spinner) {
10841 $spinner.addClass('is-active'); // add class (WP > 4.2)
10842 $spinner.css('display', 'inline-block'); // css (WP < 4.2)
10843 return $spinner;
10844 };
10845
10846 /**
10847 * acf.hideSpinner
10848 *
10849 * Hides the spinner element.
10850 *
10851 * @date 4/9/18
10852 * @since ACF 5.7.5
10853 *
10854 * @param jQuery $spinner The spinner element.
10855 * @return jQuery
10856 */
10857 acf.hideSpinner = function ($spinner) {
10858 $spinner.removeClass('is-active'); // add class (WP > 4.2)
10859 $spinner.css('display', 'none'); // css (WP < 4.2)
10860 return $spinner;
10861 };
10862
10863 /**
10864 * acf.lockForm
10865 *
10866 * Locks a form by disabling its primary inputs and showing a spinner.
10867 *
10868 * @date 4/9/18
10869 * @since ACF 5.7.5
10870 *
10871 * @param jQuery $form The form element.
10872 * @return jQuery
10873 */
10874 acf.lockForm = function ($form) {
10875 // vars
10876 var $wrap = findSubmitWrap($form);
10877 var $submit = $wrap.find('.button, [type="submit"]').not('.acf-nav, .acf-repeater-add-row');
10878 var $spinner = $wrap.find('.spinner, .acf-spinner');
10879
10880 // hide all spinners (hides the preview spinner)
10881 acf.hideSpinner($spinner);
10882
10883 // lock
10884 acf.disableSubmit($submit);
10885 acf.showSpinner($spinner.last());
10886 return $form;
10887 };
10888
10889 /**
10890 * acf.unlockForm
10891 *
10892 * Unlocks a form by enabling its primary inputs and hiding all spinners.
10893 *
10894 * @date 4/9/18
10895 * @since ACF 5.7.5
10896 *
10897 * @param jQuery $form The form element.
10898 * @return jQuery
10899 */
10900 acf.unlockForm = function ($form) {
10901 // vars
10902 var $wrap = findSubmitWrap($form);
10903 var $submit = $wrap.find('.button, [type="submit"]').not('.acf-nav, .acf-repeater-add-row');
10904 var $spinner = $wrap.find('.spinner, .acf-spinner');
10905
10906 // unlock
10907 acf.enableSubmit($submit);
10908 acf.hideSpinner($spinner);
10909 return $form;
10910 };
10911
10912 /**
10913 * findSubmitWrap
10914 *
10915 * An internal function to find the 'primary' form submit wrapping element.
10916 *
10917 * @date 4/9/18
10918 * @since ACF 5.7.5
10919 *
10920 * @param jQuery $form The form element.
10921 * @return jQuery
10922 */
10923 var findSubmitWrap = function ($form) {
10924 // default post submit div
10925 var $wrap = $form.find('#submitdiv');
10926 if ($wrap.length) {
10927 return $wrap;
10928 }
10929
10930 // 3rd party publish box
10931 var $wrap = $form.find('#submitpost');
10932 if ($wrap.length) {
10933 return $wrap;
10934 }
10935
10936 // term, user
10937 var $wrap = $form.find('p.submit').last();
10938 if ($wrap.length) {
10939 return $wrap;
10940 }
10941
10942 // front end form
10943 var $wrap = $form.find('.acf-form-submit');
10944 if ($wrap.length) {
10945 return $wrap;
10946 }
10947
10948 // ACF 6.2 options page modal
10949 var $wrap = $('#acf-create-options-page-form .acf-actions');
10950 if ($wrap.length) {
10951 return $wrap;
10952 }
10953
10954 // ACF 6.0+ headerbar submit
10955 var $wrap = $('.acf-headerbar-actions');
10956 if ($wrap.length) {
10957 return $wrap;
10958 }
10959
10960 // default
10961 return $form;
10962 };
10963
10964 /**
10965 * A debounced function to trigger a form submission.
10966 *
10967 * @date 15/07/2020
10968 * @since ACF 5.9.0
10969 *
10970 * @param type Var Description.
10971 * @return type Description.
10972 */
10973 var submitFormDebounced = acf.debounce(function ($form) {
10974 $form.submit();
10975 });
10976
10977 /**
10978 * Ensure field is visible for validation errors
10979 *
10980 * @date 20/10/2021
10981 * @since ACF 5.11.0
10982 */
10983 var ensureFieldPostBoxIsVisible = function ($el) {
10984 // Find the postbox element containing this field.
10985 var $postbox = $el.parents('.acf-postbox');
10986 if ($postbox.length) {
10987 var acf_postbox = acf.getPostbox($postbox);
10988 if (acf_postbox && acf_postbox.isHiddenByScreenOptions()) {
10989 // Rather than using .show() here, we don't want the field to appear next reload.
10990 // So just temporarily show the field group so validation can complete.
10991 acf_postbox.$el.removeClass('hide-if-js');
10992 acf_postbox.$el.css('display', '');
10993 }
10994 }
10995 };
10996
10997 /**
10998 * Ensure metaboxes which contain browser validation failures are visible.
10999 *
11000 * @date 20/10/2021
11001 * @since ACF 5.11.0
11002 */
11003 var ensureInvalidFieldVisibility = function () {
11004 // Load each ACF input field and check it's browser validation state.
11005 var $inputs = $('.acf-field input');
11006 $inputs.each(function () {
11007 if (!this.checkValidity()) {
11008 // Field is invalid, so we need to make sure it's metabox is visible.
11009 ensureFieldPostBoxIsVisible($(this));
11010 }
11011 });
11012 };
11013
11014 /**
11015 * acf.validation
11016 *
11017 * Global validation logic
11018 *
11019 * @date 4/4/18
11020 * @since ACF 5.6.9
11021 *
11022 * @param void
11023 * @return void
11024 */
11025
11026 acf.validation = new acf.Model({
11027 /** @var string The model identifier. */
11028 id: 'validation',
11029 /** @var bool The active state. Set to false before 'prepare' to prevent validation. */
11030 active: true,
11031 /** @var string The model initialize time. */
11032 wait: 'prepare',
11033 /** @var object The model actions. */
11034 actions: {
11035 ready: 'addInputEvents',
11036 append: 'addInputEvents'
11037 },
11038 /** @var object The model events. */
11039 events: {
11040 'click input[type="submit"]': 'onClickSubmit',
11041 'click button[type="submit"]': 'onClickSubmit',
11042 'click #save-post': 'onClickSave',
11043 'submit form#post': 'onSubmitPost',
11044 'submit form': 'onSubmit'
11045 },
11046 /**
11047 * initialize
11048 *
11049 * Called when initializing the model.
11050 *
11051 * @date 4/9/18
11052 * @since ACF 5.7.5
11053 *
11054 * @param void
11055 * @return void
11056 */
11057 initialize: function () {
11058 // check 'validation' setting
11059 if (!acf.get('validation')) {
11060 this.active = false;
11061 this.actions = {};
11062 this.events = {};
11063 }
11064 },
11065 /**
11066 * enable
11067 *
11068 * Enables validation.
11069 *
11070 * @date 4/9/18
11071 * @since ACF 5.7.5
11072 *
11073 * @param void
11074 * @return void
11075 */
11076 enable: function () {
11077 this.active = true;
11078 },
11079 /**
11080 * disable
11081 *
11082 * Disables validation.
11083 *
11084 * @date 4/9/18
11085 * @since ACF 5.7.5
11086 *
11087 * @param void
11088 * @return void
11089 */
11090 disable: function () {
11091 this.active = false;
11092 },
11093 /**
11094 * reset
11095 *
11096 * Rests the form validation to be used again
11097 *
11098 * @date 6/9/18
11099 * @since ACF 5.7.5
11100 *
11101 * @param jQuery $form The form element.
11102 * @return void
11103 */
11104 reset: function ($form) {
11105 getValidator($form).reset();
11106 },
11107 /**
11108 * addInputEvents
11109 *
11110 * Adds 'invalid' event listeners to HTML inputs.
11111 *
11112 * @date 4/9/18
11113 * @since ACF 5.7.5
11114 *
11115 * @param jQuery $el The element being added / readied.
11116 * @return void
11117 */
11118 addInputEvents: function ($el) {
11119 // Bug exists in Safari where custom "invalid" handling prevents draft from saving.
11120 if (acf.get('browser') === 'safari') return;
11121
11122 // vars
11123 var $inputs = $('.acf-field [name]', $el);
11124
11125 // check
11126 if ($inputs.length) {
11127 this.on($inputs, 'invalid', 'onInvalid');
11128 }
11129 },
11130 /**
11131 * onInvalid
11132 *
11133 * Callback for the 'invalid' event.
11134 *
11135 * @date 4/9/18
11136 * @since ACF 5.7.5
11137 *
11138 * @param object e The event object.
11139 * @param jQuery $el The input element.
11140 * @return void
11141 */
11142 onInvalid: function (e, $el) {
11143 // prevent default
11144 // - prevents browser error message
11145 // - also fixes chrome bug where 'hidden-by-tab' field throws focus error
11146 e.preventDefault();
11147
11148 // vars
11149 var $form = $el.closest('form');
11150
11151 // check form exists
11152 if ($form.length) {
11153 // add error to validator
11154 getValidator($form).addError({
11155 input: $el.attr('name'),
11156 message: acf.strEscape(e.target.validationMessage)
11157 });
11158
11159 // trigger submit on $form
11160 // - allows for "save", "preview" and "publish" to work
11161 submitFormDebounced($form);
11162 }
11163 },
11164 /**
11165 * onClickSubmit
11166 *
11167 * Callback when clicking submit.
11168 *
11169 * @date 4/9/18
11170 * @since ACF 5.7.5
11171 *
11172 * @param object e The event object.
11173 * @param jQuery $el The input element.
11174 * @return void
11175 */
11176 onClickSubmit: function (e, $el) {
11177 // Some browsers (safari) force their browser validation before our AJAX validation,
11178 // so we need to make sure fields are visible earlier than showErrors()
11179 ensureInvalidFieldVisibility();
11180
11181 // store the "click event" for later use in this.onSubmit()
11182 this.set('originalEvent', e);
11183 },
11184 /**
11185 * onClickSave
11186 *
11187 * Set ignore to true when saving a draft.
11188 *
11189 * @date 4/9/18
11190 * @since ACF 5.7.5
11191 *
11192 * @param object e The event object.
11193 * @param jQuery $el The input element.
11194 * @return void
11195 */
11196 onClickSave: function (e, $el) {
11197 this.set('ignore', true);
11198 },
11199 /**
11200 * onSubmitPost
11201 *
11202 * Callback when the 'post' form is submit.
11203 *
11204 * @date 5/3/19
11205 * @since ACF 5.7.13
11206 *
11207 * @param object e The event object.
11208 * @param jQuery $el The input element.
11209 * @return void
11210 */
11211 onSubmitPost: function (e, $el) {
11212 // Check if is preview.
11213 if ($('input#wp-preview').val() === 'dopreview') {
11214 // Ignore validation.
11215 this.set('ignore', true);
11216
11217 // Unlock form to fix conflict with core "submit.edit-post" event causing all submit buttons to be disabled.
11218 acf.unlockForm($el);
11219 }
11220 },
11221 /**
11222 * onSubmit
11223 *
11224 * Callback when the form is submit.
11225 *
11226 * @date 4/9/18
11227 * @since ACF 5.7.5
11228 *
11229 * @param object e The event object.
11230 * @param jQuery $el The input element.
11231 * @return void
11232 */
11233 onSubmit: function (e, $el) {
11234 // Allow form to submit if...
11235 if (
11236 // Validation has been disabled.
11237 !this.active ||
11238 // Or this event is to be ignored.
11239 this.get('ignore') ||
11240 // Or this event has already been prevented.
11241 e.isDefaultPrevented()) {
11242 // Return early and call reset function.
11243 return this.allowSubmit();
11244 }
11245
11246 // Validate form.
11247 var valid = acf.validateForm({
11248 form: $el,
11249 event: this.get('originalEvent')
11250 });
11251
11252 // If not valid, stop event to prevent form submit.
11253 if (!valid) {
11254 e.preventDefault();
11255 }
11256 },
11257 /**
11258 * allowSubmit
11259 *
11260 * Resets data during onSubmit when the form is allowed to submit.
11261 *
11262 * @date 5/3/19
11263 * @since ACF 5.7.13
11264 *
11265 * @param void
11266 * @return void
11267 */
11268 allowSubmit: function () {
11269 // Reset "ignore" state.
11270 this.set('ignore', false);
11271
11272 // Reset "originalEvent" object.
11273 this.set('originalEvent', false);
11274
11275 // Return true
11276 return true;
11277 }
11278 });
11279 var gutenbergValidation = new acf.Model({
11280 wait: 'prepare',
11281 initialize: function () {
11282 // Bail early if not Gutenberg.
11283 if (!acf.isGutenberg()) {
11284 return;
11285 }
11286
11287 // Customize the editor.
11288 this.customizeEditor();
11289 },
11290 customizeEditor: function () {
11291 // Extract vars.
11292 var editor = wp.data.dispatch('core/editor');
11293 var editorSelect = wp.data.select('core/editor');
11294 var notices = wp.data.dispatch('core/notices');
11295
11296 // Backup original method.
11297 var savePost = editor.savePost;
11298
11299 // Listen for changes to post status and perform actions:
11300 // a) Enable validation for "publish" action.
11301 // b) Remember last non "publish" status used for restoring after validation fail.
11302 var useValidation = false;
11303 var lastPostStatus = '';
11304 wp.data.subscribe(function () {
11305 var postStatus = editorSelect.getEditedPostAttribute('status');
11306 useValidation = postStatus === 'publish' || postStatus === 'future';
11307 lastPostStatus = postStatus !== 'publish' ? postStatus : lastPostStatus;
11308 });
11309
11310 // Create validation version.
11311 editor.savePost = function (options) {
11312 options = options || {};
11313
11314 // Backup vars.
11315 var _this = this;
11316 var _args = arguments;
11317
11318 // Perform validation within a Promise.
11319 return new Promise(function (resolve, reject) {
11320 // Bail early if is autosave or preview.
11321 if (options.isAutosave || options.isPreview) {
11322 return resolve('Validation ignored (autosave).');
11323 }
11324
11325 // Bail early if validation is not needed.
11326 if (!useValidation) {
11327 return resolve('Validation ignored (draft).');
11328 }
11329
11330 // Check if we've currently got an ACF block selected which is failing validation, but might not be presented yet.
11331 if ('undefined' !== typeof acf.blockInstances) {
11332 const selectedBlockId = wp.data.select('core/block-editor').getSelectedBlockClientId();
11333 if (selectedBlockId && selectedBlockId in acf.blockInstances) {
11334 const acfBlockState = acf.blockInstances[selectedBlockId];
11335 if (acfBlockState.validation_errors) {
11336 // Deselect the block to show the error and lock the save.
11337 acf.debug('Rejecting save because the block editor has a invalid ACF block selected.');
11338 notices.createErrorNotice(acf.__('An ACF Block on this page requires attention before you can save.'), {
11339 id: 'acf-validation',
11340 isDismissible: true
11341 });
11342 wp.data.dispatch('core/editor').lockPostSaving('acf/block/' + selectedBlockId);
11343 wp.data.dispatch('core/block-editor').selectBlock(false);
11344 return reject('ACF Validation failed for selected block.');
11345 }
11346 }
11347 }
11348
11349 // Validate the editor form.
11350 var valid = acf.validateForm({
11351 form: $('#editor'),
11352 reset: true,
11353 complete: function ($form, validator) {
11354 // Always unlock the form after AJAX.
11355 editor.unlockPostSaving('acf');
11356 },
11357 failure: function ($form, validator) {
11358 // Get validation error and append to Gutenberg notices.
11359 var notice = validator.get('notice');
11360 notices.createErrorNotice(notice.get('text'), {
11361 id: 'acf-validation',
11362 isDismissible: true
11363 });
11364 notice.remove();
11365
11366 // Restore last non "publish" status.
11367 if (lastPostStatus) {
11368 editor.editPost({
11369 status: lastPostStatus
11370 });
11371 }
11372
11373 // Reject promise and prevent savePost().
11374 reject('Validation failed.');
11375 },
11376 success: function () {
11377 notices.removeNotice('acf-validation');
11378
11379 // Resolve promise and allow savePost().
11380 resolve('Validation success.');
11381 }
11382 });
11383
11384 // Resolve promise and allow savePost() if no validation is needed.
11385 if (valid) {
11386 resolve('Validation bypassed.');
11387
11388 // Otherwise, lock the form and wait for AJAX response.
11389 } else {
11390 editor.lockPostSaving('acf');
11391 }
11392 }).then(function () {
11393 return savePost.apply(_this, _args);
11394 }, err => {
11395 // Nothing to do here, user is alerted of validation issues.
11396 });
11397 };
11398 }
11399 });
11400 })(jQuery);
11401
11402 /***/ })
11403
11404 /******/ });
11405 /************************************************************************/
11406 /******/ // The module cache
11407 /******/ var __webpack_module_cache__ = {};
11408 /******/
11409 /******/ // The require function
11410 /******/ function __webpack_require__(moduleId) {
11411 /******/ // Check if module is in cache
11412 /******/ var cachedModule = __webpack_module_cache__[moduleId];
11413 /******/ if (cachedModule !== undefined) {
11414 /******/ return cachedModule.exports;
11415 /******/ }
11416 /******/ // Create a new module (and put it into the cache)
11417 /******/ var module = __webpack_module_cache__[moduleId] = {
11418 /******/ // no module.id needed
11419 /******/ // no module.loaded needed
11420 /******/ exports: {}
11421 /******/ };
11422 /******/
11423 /******/ // Execute the module function
11424 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
11425 /******/
11426 /******/ // Return the exports of the module
11427 /******/ return module.exports;
11428 /******/ }
11429 /******/
11430 /************************************************************************/
11431 /******/ /* webpack/runtime/compat get default export */
11432 /******/ (() => {
11433 /******/ // getDefaultExport function for compatibility with non-harmony modules
11434 /******/ __webpack_require__.n = (module) => {
11435 /******/ var getter = module && module.__esModule ?
11436 /******/ () => (module['default']) :
11437 /******/ () => (module);
11438 /******/ __webpack_require__.d(getter, { a: getter });
11439 /******/ return getter;
11440 /******/ };
11441 /******/ })();
11442 /******/
11443 /******/ /* webpack/runtime/define property getters */
11444 /******/ (() => {
11445 /******/ // define getter functions for harmony exports
11446 /******/ __webpack_require__.d = (exports, definition) => {
11447 /******/ for(var key in definition) {
11448 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
11449 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
11450 /******/ }
11451 /******/ }
11452 /******/ };
11453 /******/ })();
11454 /******/
11455 /******/ /* webpack/runtime/hasOwnProperty shorthand */
11456 /******/ (() => {
11457 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
11458 /******/ })();
11459 /******/
11460 /******/ /* webpack/runtime/make namespace object */
11461 /******/ (() => {
11462 /******/ // define __esModule on exports
11463 /******/ __webpack_require__.r = (exports) => {
11464 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
11465 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
11466 /******/ }
11467 /******/ Object.defineProperty(exports, '__esModule', { value: true });
11468 /******/ };
11469 /******/ })();
11470 /******/
11471 /************************************************************************/
11472 var __webpack_exports__ = {};
11473 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
11474 (() => {
11475 "use strict";
11476 /*!************************************!*\
11477 !*** ./assets/src/js/acf-input.js ***!
11478 \************************************/
11479 __webpack_require__.r(__webpack_exports__);
11480 /* harmony import */ var _acf_field_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_acf-field.js */ "./assets/src/js/_acf-field.js");
11481 /* harmony import */ var _acf_field_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_acf_field_js__WEBPACK_IMPORTED_MODULE_0__);
11482 /* harmony import */ var _acf_fields_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_acf-fields.js */ "./assets/src/js/_acf-fields.js");
11483 /* harmony import */ var _acf_fields_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_acf_fields_js__WEBPACK_IMPORTED_MODULE_1__);
11484 /* harmony import */ var _acf_field_accordion_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_acf-field-accordion.js */ "./assets/src/js/_acf-field-accordion.js");
11485 /* harmony import */ var _acf_field_accordion_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_acf_field_accordion_js__WEBPACK_IMPORTED_MODULE_2__);
11486 /* harmony import */ var _acf_field_button_group_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./_acf-field-button-group.js */ "./assets/src/js/_acf-field-button-group.js");
11487 /* harmony import */ var _acf_field_button_group_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_acf_field_button_group_js__WEBPACK_IMPORTED_MODULE_3__);
11488 /* harmony import */ var _acf_field_checkbox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./_acf-field-checkbox.js */ "./assets/src/js/_acf-field-checkbox.js");
11489 /* harmony import */ var _acf_field_checkbox_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_acf_field_checkbox_js__WEBPACK_IMPORTED_MODULE_4__);
11490 /* harmony import */ var _acf_field_color_picker_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./_acf-field-color-picker.js */ "./assets/src/js/_acf-field-color-picker.js");
11491 /* harmony import */ var _acf_field_color_picker_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_acf_field_color_picker_js__WEBPACK_IMPORTED_MODULE_5__);
11492 /* harmony import */ var _acf_field_date_picker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./_acf-field-date-picker.js */ "./assets/src/js/_acf-field-date-picker.js");
11493 /* harmony import */ var _acf_field_date_picker_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_acf_field_date_picker_js__WEBPACK_IMPORTED_MODULE_6__);
11494 /* harmony import */ var _acf_field_date_time_picker_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./_acf-field-date-time-picker.js */ "./assets/src/js/_acf-field-date-time-picker.js");
11495 /* harmony import */ var _acf_field_date_time_picker_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_acf_field_date_time_picker_js__WEBPACK_IMPORTED_MODULE_7__);
11496 /* harmony import */ var _acf_field_google_map_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./_acf-field-google-map.js */ "./assets/src/js/_acf-field-google-map.js");
11497 /* harmony import */ var _acf_field_google_map_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_acf_field_google_map_js__WEBPACK_IMPORTED_MODULE_8__);
11498 /* harmony import */ var _acf_field_icon_picker_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./_acf-field-icon-picker.js */ "./assets/src/js/_acf-field-icon-picker.js");
11499 /* harmony import */ var _acf_field_icon_picker_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_acf_field_icon_picker_js__WEBPACK_IMPORTED_MODULE_9__);
11500 /* harmony import */ var _acf_field_image_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./_acf-field-image.js */ "./assets/src/js/_acf-field-image.js");
11501 /* harmony import */ var _acf_field_image_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_acf_field_image_js__WEBPACK_IMPORTED_MODULE_10__);
11502 /* harmony import */ var _acf_field_file_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./_acf-field-file.js */ "./assets/src/js/_acf-field-file.js");
11503 /* harmony import */ var _acf_field_file_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_acf_field_file_js__WEBPACK_IMPORTED_MODULE_11__);
11504 /* harmony import */ var _acf_field_link_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./_acf-field-link.js */ "./assets/src/js/_acf-field-link.js");
11505 /* harmony import */ var _acf_field_link_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_acf_field_link_js__WEBPACK_IMPORTED_MODULE_12__);
11506 /* harmony import */ var _acf_field_oembed_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./_acf-field-oembed.js */ "./assets/src/js/_acf-field-oembed.js");
11507 /* harmony import */ var _acf_field_oembed_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_acf_field_oembed_js__WEBPACK_IMPORTED_MODULE_13__);
11508 /* harmony import */ var _acf_field_radio_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./_acf-field-radio.js */ "./assets/src/js/_acf-field-radio.js");
11509 /* harmony import */ var _acf_field_radio_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_acf_field_radio_js__WEBPACK_IMPORTED_MODULE_14__);
11510 /* harmony import */ var _acf_field_range_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./_acf-field-range.js */ "./assets/src/js/_acf-field-range.js");
11511 /* harmony import */ var _acf_field_range_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_acf_field_range_js__WEBPACK_IMPORTED_MODULE_15__);
11512 /* harmony import */ var _acf_field_relationship_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./_acf-field-relationship.js */ "./assets/src/js/_acf-field-relationship.js");
11513 /* harmony import */ var _acf_field_relationship_js__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_acf_field_relationship_js__WEBPACK_IMPORTED_MODULE_16__);
11514 /* harmony import */ var _acf_field_select_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./_acf-field-select.js */ "./assets/src/js/_acf-field-select.js");
11515 /* harmony import */ var _acf_field_select_js__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_acf_field_select_js__WEBPACK_IMPORTED_MODULE_17__);
11516 /* harmony import */ var _acf_field_tab_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./_acf-field-tab.js */ "./assets/src/js/_acf-field-tab.js");
11517 /* harmony import */ var _acf_field_tab_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_acf_field_tab_js__WEBPACK_IMPORTED_MODULE_18__);
11518 /* harmony import */ var _acf_field_post_object_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./_acf-field-post-object.js */ "./assets/src/js/_acf-field-post-object.js");
11519 /* harmony import */ var _acf_field_post_object_js__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_acf_field_post_object_js__WEBPACK_IMPORTED_MODULE_19__);
11520 /* harmony import */ var _acf_field_page_link_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./_acf-field-page-link.js */ "./assets/src/js/_acf-field-page-link.js");
11521 /* harmony import */ var _acf_field_page_link_js__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_acf_field_page_link_js__WEBPACK_IMPORTED_MODULE_20__);
11522 /* harmony import */ var _acf_field_user_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./_acf-field-user.js */ "./assets/src/js/_acf-field-user.js");
11523 /* harmony import */ var _acf_field_user_js__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(_acf_field_user_js__WEBPACK_IMPORTED_MODULE_21__);
11524 /* harmony import */ var _acf_field_taxonomy_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./_acf-field-taxonomy.js */ "./assets/src/js/_acf-field-taxonomy.js");
11525 /* harmony import */ var _acf_field_taxonomy_js__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(_acf_field_taxonomy_js__WEBPACK_IMPORTED_MODULE_22__);
11526 /* harmony import */ var _acf_field_time_picker_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./_acf-field-time-picker.js */ "./assets/src/js/_acf-field-time-picker.js");
11527 /* harmony import */ var _acf_field_time_picker_js__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(_acf_field_time_picker_js__WEBPACK_IMPORTED_MODULE_23__);
11528 /* harmony import */ var _acf_field_true_false_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./_acf-field-true-false.js */ "./assets/src/js/_acf-field-true-false.js");
11529 /* harmony import */ var _acf_field_true_false_js__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(_acf_field_true_false_js__WEBPACK_IMPORTED_MODULE_24__);
11530 /* harmony import */ var _acf_field_url_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./_acf-field-url.js */ "./assets/src/js/_acf-field-url.js");
11531 /* harmony import */ var _acf_field_url_js__WEBPACK_IMPORTED_MODULE_25___default = /*#__PURE__*/__webpack_require__.n(_acf_field_url_js__WEBPACK_IMPORTED_MODULE_25__);
11532 /* harmony import */ var _acf_field_wysiwyg_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./_acf-field-wysiwyg.js */ "./assets/src/js/_acf-field-wysiwyg.js");
11533 /* harmony import */ var _acf_field_wysiwyg_js__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(_acf_field_wysiwyg_js__WEBPACK_IMPORTED_MODULE_26__);
11534 /* harmony import */ var _acf_condition_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./_acf-condition.js */ "./assets/src/js/_acf-condition.js");
11535 /* harmony import */ var _acf_condition_js__WEBPACK_IMPORTED_MODULE_27___default = /*#__PURE__*/__webpack_require__.n(_acf_condition_js__WEBPACK_IMPORTED_MODULE_27__);
11536 /* harmony import */ var _acf_conditions_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./_acf-conditions.js */ "./assets/src/js/_acf-conditions.js");
11537 /* harmony import */ var _acf_conditions_js__WEBPACK_IMPORTED_MODULE_28___default = /*#__PURE__*/__webpack_require__.n(_acf_conditions_js__WEBPACK_IMPORTED_MODULE_28__);
11538 /* harmony import */ var _acf_condition_types_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./_acf-condition-types.js */ "./assets/src/js/_acf-condition-types.js");
11539 /* harmony import */ var _acf_condition_types_js__WEBPACK_IMPORTED_MODULE_29___default = /*#__PURE__*/__webpack_require__.n(_acf_condition_types_js__WEBPACK_IMPORTED_MODULE_29__);
11540 /* harmony import */ var _acf_unload_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./_acf-unload.js */ "./assets/src/js/_acf-unload.js");
11541 /* harmony import */ var _acf_unload_js__WEBPACK_IMPORTED_MODULE_30___default = /*#__PURE__*/__webpack_require__.n(_acf_unload_js__WEBPACK_IMPORTED_MODULE_30__);
11542 /* harmony import */ var _acf_postbox_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./_acf-postbox.js */ "./assets/src/js/_acf-postbox.js");
11543 /* harmony import */ var _acf_postbox_js__WEBPACK_IMPORTED_MODULE_31___default = /*#__PURE__*/__webpack_require__.n(_acf_postbox_js__WEBPACK_IMPORTED_MODULE_31__);
11544 /* harmony import */ var _acf_media_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./_acf-media.js */ "./assets/src/js/_acf-media.js");
11545 /* harmony import */ var _acf_media_js__WEBPACK_IMPORTED_MODULE_32___default = /*#__PURE__*/__webpack_require__.n(_acf_media_js__WEBPACK_IMPORTED_MODULE_32__);
11546 /* harmony import */ var _acf_screen_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./_acf-screen.js */ "./assets/src/js/_acf-screen.js");
11547 /* harmony import */ var _acf_screen_js__WEBPACK_IMPORTED_MODULE_33___default = /*#__PURE__*/__webpack_require__.n(_acf_screen_js__WEBPACK_IMPORTED_MODULE_33__);
11548 /* harmony import */ var _acf_select2_js__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./_acf-select2.js */ "./assets/src/js/_acf-select2.js");
11549 /* harmony import */ var _acf_select2_js__WEBPACK_IMPORTED_MODULE_34___default = /*#__PURE__*/__webpack_require__.n(_acf_select2_js__WEBPACK_IMPORTED_MODULE_34__);
11550 /* harmony import */ var _acf_tinymce_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./_acf-tinymce.js */ "./assets/src/js/_acf-tinymce.js");
11551 /* harmony import */ var _acf_tinymce_js__WEBPACK_IMPORTED_MODULE_35___default = /*#__PURE__*/__webpack_require__.n(_acf_tinymce_js__WEBPACK_IMPORTED_MODULE_35__);
11552 /* harmony import */ var _acf_validation_js__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./_acf-validation.js */ "./assets/src/js/_acf-validation.js");
11553 /* harmony import */ var _acf_validation_js__WEBPACK_IMPORTED_MODULE_36___default = /*#__PURE__*/__webpack_require__.n(_acf_validation_js__WEBPACK_IMPORTED_MODULE_36__);
11554 /* harmony import */ var _acf_helpers_js__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./_acf-helpers.js */ "./assets/src/js/_acf-helpers.js");
11555 /* harmony import */ var _acf_helpers_js__WEBPACK_IMPORTED_MODULE_37___default = /*#__PURE__*/__webpack_require__.n(_acf_helpers_js__WEBPACK_IMPORTED_MODULE_37__);
11556 /* harmony import */ var _acf_compatibility_js__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./_acf-compatibility.js */ "./assets/src/js/_acf-compatibility.js");
11557 /* harmony import */ var _acf_compatibility_js__WEBPACK_IMPORTED_MODULE_38___default = /*#__PURE__*/__webpack_require__.n(_acf_compatibility_js__WEBPACK_IMPORTED_MODULE_38__);
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597 })();
11598
11599 /******/ })()
11600 ;
11601 //# sourceMappingURL=acf-input.js.map