Advanced Custom Fields - Version 5.7.0

Version Description

  • Core: Major JavaScript updates
  • Core: Improved conditional logic with new types and more supported fields
  • Core: Improved localization and internationalization
  • Repeater field: Improved logic that remembers collapsed row states
  • Repeater field: Added support to collapse multiple rows (hold shift)
  • API: Improved lookup to find fields without a reference value
  • Language: Added Croatian translation - Thanks to Vlado Bosnjak
  • Language: Updated Italian translation - thanks to Davide Pant
  • Language: Updated Romanian translation - thanks to Ionut Staicu
  • Language: Updated German translation - thanks to Ralf Koller
  • Language: Updated Arabic translation - thanks to Karim Ramadan
  • Language: Updated Portuguese translation - thanks to Pedro Mendona
Download this release

Release Info

Developer elliotcondon
Plugin Icon 128x128 Advanced Custom Fields
Version 5.7.0
Comparing to
See all releases

Code changes from version 5.6.10 to 5.7.0

Files changed (53) hide show
  1. README.md +0 -25
  2. acf.php +5 -38
  3. assets/css/acf-field-group.css +34 -9
  4. assets/css/acf-global.css +110 -69
  5. assets/css/acf-input.css +116 -103
  6. assets/js/acf-field-group.js +1990 -2658
  7. assets/js/acf-field-group.min.js +1 -1
  8. assets/js/acf-input.js +11649 -12689
  9. assets/js/acf-input.min.js +4 -3
  10. includes/admin/admin-field-group.php +39 -89
  11. includes/admin/admin.php +1 -1
  12. includes/admin/tools/class-acf-admin-tool-export.php +5 -1
  13. includes/admin/views/field-group-field-conditional-logic.php +29 -32
  14. includes/admin/views/field-group-field.php +15 -18
  15. includes/admin/views/field-group-fields.php +2 -2
  16. includes/admin/views/field-group-locations.php +1 -1
  17. includes/admin/views/field-group-options.php +23 -18
  18. includes/admin/views/install-network.php +9 -11
  19. includes/admin/views/install.php +9 -10
  20. includes/api/api-field.php +23 -27
  21. includes/api/api-helpers.php +48 -10
  22. includes/api/api-input.php +3 -3
  23. includes/assets.php +477 -0
  24. includes/compatibility.php +4 -9
  25. includes/fields.php +96 -84
  26. includes/fields/class-acf-field-checkbox.php +6 -1
  27. includes/fields/class-acf-field-date_picker.php +20 -47
  28. includes/fields/class-acf-field-date_time_picker.php +24 -22
  29. includes/fields/class-acf-field-file.php +25 -9
  30. includes/fields/class-acf-field-google-map.php +57 -55
  31. includes/fields/class-acf-field-image.php +25 -8
  32. includes/fields/class-acf-field-oembed.php +11 -24
  33. includes/fields/class-acf-field-radio.php +6 -1
  34. includes/fields/class-acf-field-relationship.php +27 -9
  35. includes/fields/class-acf-field-select.php +52 -45
  36. includes/fields/class-acf-field-taxonomy.php +37 -59
  37. includes/fields/class-acf-field-true_false.php +12 -2
  38. includes/fields/class-acf-field-wysiwyg.php +42 -45
  39. includes/form.php +277 -0
  40. includes/forms/form-attachment.php +20 -64
  41. includes/forms/form-comment.php +5 -1
  42. includes/forms/form-customizer.php +5 -7
  43. includes/forms/form-post.php +8 -6
  44. includes/forms/form-taxonomy.php +38 -66
  45. includes/forms/form-user.php +117 -220
  46. includes/forms/form-widget.php +32 -83
  47. includes/input.php +0 -522
  48. includes/media.php +24 -74
  49. includes/updates.php +127 -123
  50. includes/walkers/class-acf-walker-nav-menu-edit.php +1 -1
  51. includes/walkers/class-acf-walker-taxonomy-field.php +1 -1
  52. lang/acf-ar.mo +0 -0
  53. lang/acf-ar.po +2 -3
README.md DELETED
@@ -1,25 +0,0 @@
1
- # Advanced Custom Fields
2
-
3
- Welcome to the official Advanced Custom Fields repository on GitHub. ACF is a WordPress plugin used to take full control of your edit screens & custom field data.
4
-
5
- Looking for ACF version 4? Please use the [previous ACF repository](https://github.com/elliotcondon/acf).
6
-
7
- Upgrading from ACF version 4? Please read our [Upgrading from v4 to v5 guide](https://www.advancedcustomfields.com/resources/upgrading-v4-v5/).
8
-
9
- ## Documentation
10
-
11
- Do you need help getting started with ACF, or do you have questions about one of the ACF features? You can [search through our documentation here](https://www.advancedcustomfields.com/resources). If you don't find the answers you're looking for, you can [submit a support ticket](https://support.advancedcustomfields.com/new-ticket/) or start a new forum thread in the [support forum](https://support.advancedcustomfields.com/).
12
-
13
- ## Support
14
-
15
- This repository is not suitable for support. Please don't use our issue tracker for support requests, but for core issues only.
16
- Support can take place in the appropriate channels:
17
-
18
- * Email based ticket system
19
- * Community forum
20
-
21
- These channels can be accessed from our [support website](https://support.advancedcustomfields.com/).
22
-
23
- ## Contributing
24
-
25
- If you have a patch, or stumbled upon an issue with ACF core, you can contribute this back to the code. Please create a new github issue with as much information as possible.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
acf.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: https://www.advancedcustomfields.com/
5
  Description: Customise WordPress with powerful, professional and intuitive fields.
6
- Version: 5.6.10
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  Copyright: Elliot Condon
@@ -18,7 +18,7 @@ if( ! class_exists('ACF') ) :
18
  class ACF {
19
 
20
  /** @var string The plugin version number */
21
- var $version = '5.6.10';
22
 
23
  /** @var array The plugin settings array */
24
  var $settings = array();
@@ -140,11 +140,12 @@ class ACF {
140
 
141
 
142
  // core
 
143
  acf_include('includes/ajax.php');
144
  acf_include('includes/cache.php');
145
  acf_include('includes/compatibility.php');
146
  acf_include('includes/deprecated.php');
147
- acf_include('includes/input.php');
148
  acf_include('includes/json.php');
149
  acf_include('includes/local.php');
150
  acf_include('includes/loop.php');
@@ -194,7 +195,6 @@ class ACF {
194
  add_action('init', array($this, 'init'), 5);
195
  add_action('init', array($this, 'register_post_types'), 5);
196
  add_action('init', array($this, 'register_post_status'), 5);
197
- add_action('init', array($this, 'register_assets'), 5);
198
 
199
 
200
  // filters
@@ -480,39 +480,6 @@ class ACF {
480
  }
481
 
482
 
483
- /*
484
- * register_assets
485
- *
486
- * This function will register scripts and styles
487
- *
488
- * @type function
489
- * @date 22/10/2015
490
- * @since 5.3.2
491
- *
492
- * @param n/a
493
- * @return n/a
494
- */
495
-
496
- function register_assets() {
497
-
498
- // vars
499
- $version = acf_get_setting('version');
500
- $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
501
-
502
-
503
- // scripts
504
- wp_register_script('acf-input', acf_get_url("assets/js/acf-input{$min}.js"), array('jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-resizable'), $version );
505
- wp_register_script('acf-field-group', acf_get_url("assets/js/acf-field-group{$min}.js"), array('acf-input'), $version );
506
-
507
-
508
- // styles
509
- wp_register_style('acf-global', acf_get_url('assets/css/acf-global.css'), array(), $version );
510
- wp_register_style('acf-input', acf_get_url('assets/css/acf-input.css'), array('acf-global'), $version );
511
- wp_register_style('acf-field-group', acf_get_url('assets/css/acf-field-group.css'), array('acf-input'), $version );
512
-
513
- }
514
-
515
-
516
  /*
517
  * posts_where
518
  *
@@ -742,4 +709,4 @@ acf();
742
 
743
  endif; // class_exists check
744
 
745
- ?>
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: https://www.advancedcustomfields.com/
5
  Description: Customise WordPress with powerful, professional and intuitive fields.
6
+ Version: 5.7.0
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  Copyright: Elliot Condon
18
  class ACF {
19
 
20
  /** @var string The plugin version number */
21
+ var $version = '5.7.0';
22
 
23
  /** @var array The plugin settings array */
24
  var $settings = array();
140
 
141
 
142
  // core
143
+ acf_include('includes/assets.php');
144
  acf_include('includes/ajax.php');
145
  acf_include('includes/cache.php');
146
  acf_include('includes/compatibility.php');
147
  acf_include('includes/deprecated.php');
148
+ acf_include('includes/form.php');
149
  acf_include('includes/json.php');
150
  acf_include('includes/local.php');
151
  acf_include('includes/loop.php');
195
  add_action('init', array($this, 'init'), 5);
196
  add_action('init', array($this, 'register_post_types'), 5);
197
  add_action('init', array($this, 'register_post_status'), 5);
 
198
 
199
 
200
  // filters
480
  }
481
 
482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
  /*
484
  * posts_where
485
  *
709
 
710
  endif; // class_exists check
711
 
712
+ ?>
assets/css/acf-field-group.css CHANGED
@@ -58,7 +58,6 @@
58
  box-shadow: none;
59
  /* metabox */
60
  /* links */
61
- /* no fields */
62
  /* table header */
63
  /* show keys */
64
  /* fields */
@@ -75,10 +74,6 @@
75
  outline: none;
76
  box-shadow: none;
77
  }
78
- #acf-field-group-fields .no-fields-message {
79
- padding: 15px 15px;
80
- background: #fff;
81
- }
82
  #acf-field-group-fields .li-field-order {
83
  width: 20%;
84
  }
@@ -109,6 +104,16 @@
109
  #acf-field-group-fields .acf-field-list {
110
  background: #F9F9F9;
111
  margin-top: -1px;
 
 
 
 
 
 
 
 
 
 
112
  }
113
  /* field object */
114
  .acf-field-object {
@@ -118,6 +123,20 @@
118
  /* meta */
119
  /* handle */
120
  /* open */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  /* hover */
122
  /* settings */
123
  /* conditional logic */
@@ -207,7 +226,8 @@
207
  .acf-field-object.open > .handle .acf-required {
208
  color: #fff;
209
  }
210
- .acf-field-object:hover > .handle .row-options {
 
211
  visibility: visible;
212
  }
213
  .acf-field-object > .settings {
@@ -230,6 +250,7 @@
230
  }
231
  .rule-groups .rule-group {
232
  margin: 0 0 5px;
 
233
  }
234
  .rule-groups .rule-group h4 {
235
  margin: 0 0 3px;
@@ -246,15 +267,19 @@
246
  .rule-groups .rule-group td.remove {
247
  width: 28px;
248
  vertical-align: middle;
 
 
249
  visibility: hidden;
250
  }
251
- .rule-groups .rule-group tr:hover td.remove {
252
  visibility: visible;
253
  }
254
- /* Don't allow user to delete the first field group */
255
- .rule-groups .rule-group:first-child tr:first-child td.remove {
256
  visibility: hidden !important;
257
  }
 
 
 
258
  /*---------------------------------------------------------------------------------------------
259
  *
260
  * Options
58
  box-shadow: none;
59
  /* metabox */
60
  /* links */
 
61
  /* table header */
62
  /* show keys */
63
  /* fields */
74
  outline: none;
75
  box-shadow: none;
76
  }
 
 
 
 
77
  #acf-field-group-fields .li-field-order {
78
  width: 20%;
79
  }
104
  #acf-field-group-fields .acf-field-list {
105
  background: #F9F9F9;
106
  margin-top: -1px;
107
+ /* no fields */
108
+ /* empty */
109
+ }
110
+ #acf-field-group-fields .acf-field-list .no-fields-message {
111
+ padding: 15px 15px;
112
+ background: #fff;
113
+ display: none;
114
+ }
115
+ #acf-field-group-fields .acf-field-list.-empty .no-fields-message {
116
+ display: block;
117
  }
118
  /* field object */
119
  .acf-field-object {
123
  /* meta */
124
  /* handle */
125
  /* open */
126
+ /*
127
+ // debug
128
+ &[data-save="meta"] {
129
+ > .handle {
130
+ border-left: #ffb700 solid 5px !important;
131
+ }
132
+ }
133
+
134
+ &[data-save="settings"] {
135
+ > .handle {
136
+ border-left: #0ec563 solid 5px !important;
137
+ }
138
+ }
139
+ */
140
  /* hover */
141
  /* settings */
142
  /* conditional logic */
226
  .acf-field-object.open > .handle .acf-required {
227
  color: #fff;
228
  }
229
+ .acf-field-object:hover > .handle .row-options,
230
+ .acf-field-object.-hover > .handle .row-options {
231
  visibility: visible;
232
  }
233
  .acf-field-object > .settings {
250
  }
251
  .rule-groups .rule-group {
252
  margin: 0 0 5px;
253
+ /* Don't allow user to delete the first field group */
254
  }
255
  .rule-groups .rule-group h4 {
256
  margin: 0 0 3px;
267
  .rule-groups .rule-group td.remove {
268
  width: 28px;
269
  vertical-align: middle;
270
+ }
271
+ .rule-groups .rule-group td.remove a {
272
  visibility: hidden;
273
  }
274
+ .rule-groups .rule-group tr:hover td.remove a {
275
  visibility: visible;
276
  }
277
+ .rule-groups .rule-group:first-child tr:first-child td.remove a {
 
278
  visibility: hidden !important;
279
  }
280
+ .rule-groups .rule-group select:empty {
281
+ background: #f8f8f8;
282
+ }
283
  /*---------------------------------------------------------------------------------------------
284
  *
285
  * Options
assets/css/acf-global.css CHANGED
@@ -16,14 +16,6 @@
16
  * General
17
  *
18
  *--------------------------------------------------------------------------------------------*/
19
- /* box-sizing */
20
- /*
21
- [class^="acf-"] {
22
- -webkit-box-sizing: border-box;
23
- -moz-box-sizing: border-box;
24
- box-sizing: border-box;
25
- }
26
- */
27
  /* Horizontal List */
28
  .acf-hl {
29
  padding: 0;
@@ -71,18 +63,15 @@
71
  padding: 0;
72
  float: none;
73
  }
74
- /* Full width */
75
- img.acf-fw {
76
- width: 100%;
77
  }
78
- /* Browser */
79
- .acf-visible {
80
- display: block;
81
- visibility: visible;
82
  }
83
- .acf-hidden {
84
- display: none;
85
- visibility: visible;
86
  }
87
  /* Float */
88
  .acf-fl {
@@ -178,6 +167,7 @@ img.acf-fw {
178
  padding: 5px 10px;
179
  position: absolute;
180
  font-size: 12px;
 
181
  z-index: 900000;
182
  /* tip */
183
  /* positions */
@@ -229,6 +219,9 @@ img.acf-fw {
229
  border-left-color: #2F353E;
230
  border-right-width: 0;
231
  }
 
 
 
232
  /* confirm */
233
  .acf-tooltip.-confirm {
234
  z-index: 900001;
@@ -240,9 +233,42 @@ img.acf-fw {
240
  .acf-tooltip.-confirm a:hover {
241
  text-decoration: underline;
242
  }
243
- .acf-tooltip.-confirm a.-red {
244
  color: #F55E4F;
245
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  /*---------------------------------------------------------------------------------------------
247
  *
248
  * callout
@@ -614,48 +640,52 @@ a.acf-icon.-cancel.grey:hover {
614
  .acf-box .footer p {
615
  margin: 0;
616
  }
617
- /* error */
618
- .acf-error-message {
 
 
 
 
619
  position: relative;
620
  display: block;
621
- background: #F55E4F;
622
  margin: 5px 0 15px;
623
- padding: 1px 12px;
624
- min-height: 0px;
625
- border-left: #dd4232 solid 4px;
626
  }
627
- .acf-error-message p {
628
- font-size: 13px !important;
629
  line-height: 1.5;
630
  margin: 0.5em 0;
631
- padding: 2px;
632
  text-shadow: none;
633
- color: #fff;
634
  }
635
- .acf-error-message .acf-icon {
636
  position: absolute;
 
637
  top: 9px;
638
  right: 12px;
639
- background-color: #dd4232;
640
- border-color: transparent;
641
  color: #fff;
 
642
  }
643
- /* important to include .-cancel to override .acf-icon.-cancel class */
644
- .acf-error-message .acf-icon.-cancel:hover {
645
- background-color: #191e23;
646
- color: #F55E4F;
647
  }
648
- /* success */
649
- .acf-error-message.-success {
650
- background-color: #46b450;
651
- border-color: #32973b;
652
  }
653
- .acf-error-message.-success .acf-icon {
654
- background-color: #32973b;
 
655
  }
656
- .acf-error-message.-success .acf-icon.-cancel:hover {
657
- background-color: #191e23;
658
- color: #46b450;
 
 
 
 
659
  }
660
  /*--------------------------------------------------------------------------------------------
661
  *
@@ -955,6 +985,7 @@ html[dir="rtl"] .acf-columns-2 .acf-column-2 {
955
  left: 0;
956
  right: 0;
957
  bottom: 0;
 
958
  }
959
  #acf-popup .bg {
960
  position: absolute;
@@ -965,59 +996,69 @@ html[dir="rtl"] .acf-columns-2 .acf-column-2 {
965
  z-index: 0;
966
  background: rgba(0, 0, 0, 0.25);
967
  }
 
 
 
 
 
 
968
  #acf-popup .acf-popup-box {
969
- position: absolute;
 
970
  z-index: 1;
971
- width: 300px;
972
- height: 300px;
973
- left: 50%;
974
- top: 50%;
975
- margin: -150px 0 0 -150px;
976
  border-color: #aaaaaa;
 
 
 
 
 
977
  }
978
- #acf-popup .title .acf-icon {
 
 
 
 
979
  position: absolute;
980
  top: 10px;
981
  right: 10px;
982
  }
983
- html[dir="rtl"] #acf-popup .title .acf-icon {
984
  right: auto;
985
  left: 10px;
986
  }
987
- #acf-popup .acf-popup-box .inner,
 
 
 
 
988
  #acf-popup .acf-popup-box .loading {
989
  position: absolute;
990
- top: 44px;
991
  left: 0;
992
  right: 0;
993
  bottom: 0;
994
- z-index: 1;
995
- }
996
- #acf-popup .acf-popup-box .loading {
997
- background: rgba(0, 0, 0, 0.1);
998
  z-index: 2;
999
- border-top: #DDDDDD solid 1px;
1000
  display: none;
1001
  }
1002
- #acf-popup .acf-popup-box .loading .acf-loading {
1003
  position: absolute;
1004
  top: 50%;
1005
  left: 50%;
1006
- margin: -10px 0 0 -10px;
1007
  }
1008
- #acf-popup .inner > *:first-child {
1009
- margin-top: 0;
1010
- }
1011
- /* submit p */
1012
  .acf-submit {
1013
  margin-bottom: 0;
 
1014
  }
1015
  .acf-submit span {
1016
  float: right;
1017
  color: #999;
1018
  }
1019
- .acf-submit .acf-loading {
1020
- display: none;
1021
  }
1022
  .acf-submit .button {
1023
  margin-right: 5px;
@@ -1129,7 +1170,7 @@ html[dir="rtl"] #acf-popup .title .acf-icon {
1129
  width: 25%;
1130
  }
1131
  /* mobile */
1132
- @media screen and (max-width: 782px) {
1133
  .acf-hl[data-cols] {
1134
  margin-left: 0;
1135
  margin-right: 0;
16
  * General
17
  *
18
  *--------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
19
  /* Horizontal List */
20
  .acf-hl {
21
  padding: 0;
63
  padding: 0;
64
  float: none;
65
  }
66
+ /* Visibility */
67
+ .acf-hidden {
68
+ display: none !important;
69
  }
70
+ .acf-empty {
71
+ display: table-cell !important;
 
 
72
  }
73
+ .acf-empty * {
74
+ display: none !important;
 
75
  }
76
  /* Float */
77
  .acf-fl {
167
  padding: 5px 10px;
168
  position: absolute;
169
  font-size: 12px;
170
+ line-height: 1.4em;
171
  z-index: 900000;
172
  /* tip */
173
  /* positions */
219
  border-left-color: #2F353E;
220
  border-right-width: 0;
221
  }
222
+ .acf-tooltip .acf-overlay {
223
+ z-index: -1;
224
+ }
225
  /* confirm */
226
  .acf-tooltip.-confirm {
227
  z-index: 900001;
233
  .acf-tooltip.-confirm a:hover {
234
  text-decoration: underline;
235
  }
236
+ .acf-tooltip.-confirm a[data-event="confirm"] {
237
  color: #F55E4F;
238
  }
239
+ .acf-overlay {
240
+ position: fixed;
241
+ top: 0;
242
+ bottom: 0;
243
+ left: 0;
244
+ right: 0;
245
+ cursor: default;
246
+ }
247
+ .acf-tooltip-target {
248
+ position: relative;
249
+ z-index: 900002;
250
+ }
251
+ /*---------------------------------------------------------------------------------------------
252
+ *
253
+ * loading
254
+ *
255
+ *---------------------------------------------------------------------------------------------*/
256
+ .acf-loading-overlay {
257
+ position: absolute;
258
+ top: 0;
259
+ bottom: 0;
260
+ left: 0;
261
+ right: 0;
262
+ cursor: default;
263
+ z-index: 99;
264
+ background: rgba(249, 249, 249, 0.5);
265
+ }
266
+ .acf-loading-overlay i {
267
+ position: absolute;
268
+ top: 50%;
269
+ left: 50%;
270
+ transform: translate(-50%, -50%);
271
+ }
272
  /*---------------------------------------------------------------------------------------------
273
  *
274
  * callout
640
  .acf-box .footer p {
641
  margin: 0;
642
  }
643
+ /*--------------------------------------------------------------------------------------------
644
+ *
645
+ * acf-notice
646
+ *
647
+ *--------------------------------------------------------------------------------------------*/
648
+ .acf-notice {
649
  position: relative;
650
  display: block;
651
+ color: #fff;
652
  margin: 5px 0 15px;
653
+ padding: 3px 12px;
654
+ background: #2a9bd9;
655
+ border-left: #2183b9 solid 4px;
656
  }
657
+ .acf-notice p {
658
+ font-size: 13px;
659
  line-height: 1.5;
660
  margin: 0.5em 0;
 
661
  text-shadow: none;
662
+ color: inherit;
663
  }
664
+ .acf-notice a.acf-notice-dismiss {
665
  position: absolute;
666
+ border-color: transparent;
667
  top: 9px;
668
  right: 12px;
 
 
669
  color: #fff;
670
+ background: rgba(0, 0, 0, 0.1);
671
  }
672
+ .acf-notice a.acf-notice-dismiss:hover {
673
+ background: rgba(0, 0, 0, 0.2);
 
 
674
  }
675
+ .acf-notice.-dismiss {
676
+ padding-right: 40px;
 
 
677
  }
678
+ .acf-notice.-error {
679
+ background: #F55E4F;
680
+ border-color: #f33b28;
681
  }
682
+ .acf-notice.-success {
683
+ background: #46b450;
684
+ border-color: #3b9743;
685
+ }
686
+ .acf-notice.-warning {
687
+ background: #fd8d3b;
688
+ border-color: #fd7613;
689
  }
690
  /*--------------------------------------------------------------------------------------------
691
  *
985
  left: 0;
986
  right: 0;
987
  bottom: 0;
988
+ text-align: center;
989
  }
990
  #acf-popup .bg {
991
  position: absolute;
996
  z-index: 0;
997
  background: rgba(0, 0, 0, 0.25);
998
  }
999
+ #acf-popup:before {
1000
+ content: '';
1001
+ display: inline-block;
1002
+ height: 100%;
1003
+ vertical-align: middle;
1004
+ }
1005
  #acf-popup .acf-popup-box {
1006
+ display: inline-block;
1007
+ vertical-align: middle;
1008
  z-index: 1;
1009
+ min-width: 300px;
1010
+ min-height: 160px;
 
 
 
1011
  border-color: #aaaaaa;
1012
+ box-shadow: 0 5px 30px -5px rgba(0, 0, 0, 0.25);
1013
+ text-align: left;
1014
+ }
1015
+ html[dir="rtl"] #acf-popup .acf-popup-box {
1016
+ text-align: right;
1017
  }
1018
+ #acf-popup .acf-popup-box .title {
1019
+ min-height: 15px;
1020
+ line-height: 15px;
1021
+ }
1022
+ #acf-popup .acf-popup-box .title .acf-icon {
1023
  position: absolute;
1024
  top: 10px;
1025
  right: 10px;
1026
  }
1027
+ html[dir="rtl"] #acf-popup .acf-popup-box .title .acf-icon {
1028
  right: auto;
1029
  left: 10px;
1030
  }
1031
+ #acf-popup .acf-popup-box .inner {
1032
+ min-height: 50px;
1033
+ padding: 0;
1034
+ margin: 15px;
1035
+ }
1036
  #acf-popup .acf-popup-box .loading {
1037
  position: absolute;
1038
+ top: 45px;
1039
  left: 0;
1040
  right: 0;
1041
  bottom: 0;
 
 
 
 
1042
  z-index: 2;
1043
+ background: rgba(0, 0, 0, 0.1);
1044
  display: none;
1045
  }
1046
+ #acf-popup .acf-popup-box .loading i {
1047
  position: absolute;
1048
  top: 50%;
1049
  left: 50%;
1050
+ transform: translate(-50%, -50%);
1051
  }
 
 
 
 
1052
  .acf-submit {
1053
  margin-bottom: 0;
1054
+ line-height: 28px;
1055
  }
1056
  .acf-submit span {
1057
  float: right;
1058
  color: #999;
1059
  }
1060
+ .acf-submit span.-error {
1061
+ color: #dd4232;
1062
  }
1063
  .acf-submit .button {
1064
  margin-right: 5px;
1170
  width: 25%;
1171
  }
1172
  /* mobile */
1173
+ @media screen and (max-width: 640px) {
1174
  .acf-hl[data-cols] {
1175
  margin-left: 0;
1176
  margin-right: 0;
assets/css/acf-input.css CHANGED
@@ -52,24 +52,33 @@
52
  .acf-field .acf-input > p.description {
53
  margin-top: 5px;
54
  }
55
- .acf-field .acf-error-message {
56
- background: #F55E4F;
57
- color: #fff;
58
- margin: 0 0 10px;
59
- display: inline-block;
60
- border-radius: 3px;
61
- border-left: none;
62
  }
63
- .acf-field .acf-error-message:after {
64
- content: "";
65
- display: block;
66
- width: 0;
67
- height: 0;
68
- border: transparent 5px solid;
69
- border-top-color: #F55E4F;
70
- position: absolute;
71
- bottom: -10px;
72
- left: 10px;
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
  .acf-fieldtd,
75
  .acf-fieldtr {
@@ -216,7 +225,7 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-label {
216
  html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
217
  float: right;
218
  }
219
- @media screen and (max-width: 782px) {
220
  .acf-fields.-left > .acf-field:before {
221
  display: none;
222
  }
@@ -265,9 +274,6 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
265
  *--------------------------------------------------------------------------------------------*/
266
  .acf-postbox {
267
  position: relative;
268
- /* position high */
269
- /* inside */
270
- /* hndle */
271
  }
272
  #acf_after_title-sortables .acf-postbox {
273
  margin: 20px 0 0;
@@ -293,8 +299,7 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
293
  .acf-postbox > .hndle .acf-hndle-cog:hover {
294
  color: #777777;
295
  }
296
- .acf-postbox > .hndle:hover .acf-hndle-cog,
297
- .acf-postbox > .hndle.hover .acf-hndle-cog {
298
  display: block;
299
  }
300
  .acf-postbox .acf-replace-with-fields {
@@ -777,7 +782,7 @@ html[dir="rtl"] ul.acf-checkbox-list input[type="radio"] {
777
  background: #48a8f4;
778
  }
779
  .acf-button-group input {
780
- display: none;
781
  }
782
  .acf-button-group label {
783
  margin: 0 0 0 -1px;
@@ -1291,6 +1296,9 @@ html[dir="rtl"] .acf-relationship .selection .values .acf-icon {
1291
  outline: none;
1292
  box-shadow: none;
1293
  }
 
 
 
1294
  html[dir="rtl"] .acf-tab-group li {
1295
  margin: 0 0 0 0.5em;
1296
  }
@@ -1329,7 +1337,7 @@ html[dir="rtl"] .acf-tab-group li {
1329
  /* mobile */
1330
  /* rtl */
1331
  }
1332
- @media screen and (max-width: 782px) {
1333
  .acf-fields.-left > .acf-tab-wrap .acf-tab-group {
1334
  padding-left: 10px;
1335
  }
@@ -1571,8 +1579,7 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
1571
  border-bottom: #DFDFDF solid 1px;
1572
  padding: 5px 10px;
1573
  }
1574
- .acf-oembed .title h4,
1575
- .acf-oembed .title input[type="text"] {
1576
  margin: 0;
1577
  font-size: 14px;
1578
  line-height: 30px;
@@ -1584,16 +1591,9 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
1584
  font-family: inherit;
1585
  cursor: text;
1586
  }
1587
- .acf-oembed .title .search {
1588
- height: auto;
1589
- border: 0 none;
1590
- }
1591
  .acf-oembed .title .acf-actions {
1592
  padding: 6px;
1593
  }
1594
- .acf-oembed .title:hover .acf-actions {
1595
- display: block;
1596
- }
1597
  .acf-oembed .canvas {
1598
  position: relative;
1599
  min-height: 250px;
@@ -1613,28 +1613,15 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
1613
  position: absolute;
1614
  top: 50%;
1615
  left: 50%;
1616
- margin: -21px 0 0 -21px;
1617
  z-index: 0;
1618
  height: 42px;
1619
  width: 42px;
1620
  font-size: 42px;
1621
  color: #999;
1622
  }
1623
- .acf-oembed .canvas .canvas-loading {
1624
- position: absolute;
1625
- top: 0;
1626
- left: 0;
1627
- right: 0;
1628
- bottom: 0;
1629
  background: rgba(255, 255, 255, 0.9);
1630
- display: none;
1631
- z-index: 2;
1632
- }
1633
- .acf-oembed .canvas .canvas-loading i {
1634
- position: absolute;
1635
- top: 50%;
1636
- left: 50%;
1637
- margin: -10px 0 0 -10px;
1638
  }
1639
  .acf-oembed .canvas .canvas-error {
1640
  position: absolute;
@@ -1651,42 +1638,14 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
1651
  display: inline;
1652
  }
1653
  .acf-oembed.has-value .canvas {
1654
- min-height: 0;
1655
- }
1656
- /* states */
1657
- .acf-oembed .title-value {
1658
- display: none;
1659
- }
1660
- .acf-oembed .title-search {
1661
- display: block;
1662
- }
1663
- .acf-oembed.has-value .title-value {
1664
- display: block;
1665
- }
1666
- .acf-oembed.has-value .title-search {
1667
- display: none;
1668
- }
1669
- .acf-oembed.has-value .canvas .acf-icon {
1670
- display: none;
1671
- }
1672
- .acf-oembed.is-editing .title-value {
1673
- display: none;
1674
- }
1675
- .acf-oembed.is-editing .title-search {
1676
- display: block;
1677
- }
1678
- .acf-oembed.is-loading .canvas-loading {
1679
- display: block;
1680
  }
1681
- .acf-oembed.is-loading .title .acf-icon {
1682
- display: none;
1683
  }
1684
- .acf-oembed.has-error .canvas-error {
1685
  display: block;
1686
  }
1687
- .acf-oembed.has-error .canvas .acf-icon {
1688
- display: none;
1689
- }
1690
  /*--------------------------------------------------------------------------------------------
1691
  *
1692
  * Image
@@ -1871,7 +1830,7 @@ html[dir="rtl"] .acf-file-uploader .file-info {
1871
  .acf-taxonomy-field:hover .acf-actions {
1872
  display: block;
1873
  }
1874
- .acf-taxonomy-field[data-type="select"] .acf-actions {
1875
  padding: 0;
1876
  margin: -9px;
1877
  }
@@ -2193,7 +2152,6 @@ tr.acf-accordion + tr.acf-accordion {
2193
  /* misc */
2194
  .media-modal {
2195
  /* compat-item */
2196
- /* fix % margin which causes .acf-uploadedTo to drop down below select */
2197
  /* allow line breaks in upload error */
2198
  /* fix required span */
2199
  /* sidebar */
@@ -2203,18 +2161,6 @@ tr.acf-accordion + tr.acf-accordion {
2203
  .media-modal .compat-field-acf-blank {
2204
  display: none !important;
2205
  }
2206
- .media-modal select.attachment-filters {
2207
- margin-right: 6px !important;
2208
- vertical-align: middle;
2209
- }
2210
- .media-modal .acf-uploadedTo {
2211
- line-height: 28px;
2212
- height: 28px;
2213
- display: inline-block;
2214
- position: relative;
2215
- margin: 11px 6px 0 0;
2216
- vertical-align: middle;
2217
- }
2218
  .media-modal .upload-error-message {
2219
  white-space: pre-wrap;
2220
  }
@@ -2262,6 +2208,7 @@ tr.acf-accordion + tr.acf-accordion {
2262
  line-height: 18px;
2263
  color: #AAAAAA;
2264
  font-size: 12px;
 
2265
  }
2266
  .media-modal .acf-expand-details:focus,
2267
  .media-modal .acf-expand-details:active {
@@ -2288,6 +2235,11 @@ tr.acf-accordion + tr.acf-accordion {
2288
  .media-modal .acf-expand-details .is-closed {
2289
  display: block;
2290
  }
 
 
 
 
 
2291
  /* expanded */
2292
  .media-modal.acf-expanded {
2293
  /* toggle */
@@ -2371,6 +2323,18 @@ tr.acf-accordion + tr.acf-accordion {
2371
  .acf-media-modal .media-embed .setting.link-to {
2372
  display: none;
2373
  }
 
 
 
 
 
 
 
 
 
 
 
 
2374
  /*---------------------------------------------------------------------------------------------
2375
  *
2376
  * ACF Media Model (Select Mode)
@@ -2390,7 +2354,6 @@ tr.acf-accordion + tr.acf-accordion {
2390
  /* hide elements */
2391
  /* full width */
2392
  /* tidy up incorrect distance */
2393
- /* WP4 */
2394
  /* title box shadow (to match media grid) */
2395
  /* sidebar */
2396
  /* mobile md */
@@ -2411,9 +2374,6 @@ tr.acf-accordion + tr.acf-accordion {
2411
  right: 0;
2412
  }
2413
  .acf-media-modal.-edit .media-frame-content {
2414
- top: 56px;
2415
- }
2416
- body.major-4 .acf-media-modal.-edit .media-frame-content {
2417
  top: 50px;
2418
  }
2419
  .acf-media-modal.-edit .media-frame-title {
@@ -2499,7 +2459,7 @@ body.major-4 .acf-media-modal.-edit .media-frame-content {
2499
  }
2500
  .form-table > tbody > .acf-field > .acf-label {
2501
  padding: 20px 10px 20px 0;
2502
- width: 200px;
2503
  /* rtl */
2504
  }
2505
  html[dir="rtl"] .form-table > tbody > .acf-field > .acf-label {
@@ -2526,6 +2486,62 @@ html[dir="rtl"] .form-table > tbody > .acf-tab-wrap td {
2526
  .form-table > tbody .form-table th.acf-th {
2527
  width: auto;
2528
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2529
  /*--------------------------------------------------------------------------------------------
2530
  *
2531
  * Term
@@ -2592,9 +2608,6 @@ p.submit .acf-spinner {
2592
  font-weight: normal;
2593
  margin: 0;
2594
  }
2595
- .widget form > .acf-error-message {
2596
- margin-top: 15px;
2597
- }
2598
  /*--------------------------------------------------------------------------------------------
2599
  *
2600
  * Nav Menu
52
  .acf-field .acf-input > p.description {
53
  margin-top: 5px;
54
  }
55
+ .acf-field .acf-notice {
56
+ margin: 0 0 15px;
57
+ background: #edf2ff;
58
+ color: #2183b9;
59
+ border: none;
 
 
60
  }
61
+ .acf-field .acf-notice .acf-notice-dismiss {
62
+ background: transparent;
63
+ color: inherit;
64
+ }
65
+ .acf-field .acf-notice .acf-notice-dismiss:hover {
66
+ background: #fff;
67
+ }
68
+ .acf-field .acf-notice.-dismiss {
69
+ padding-right: 40px;
70
+ }
71
+ .acf-field .acf-notice.-error {
72
+ background: #ffe6e6;
73
+ color: #d12626;
74
+ }
75
+ .acf-field .acf-notice.-success {
76
+ background: #eefbe8;
77
+ color: #32a23b;
78
+ }
79
+ .acf-field .acf-notice.-warning {
80
+ background: #fff3e6;
81
+ color: #d16226;
82
  }
83
  .acf-fieldtd,
84
  .acf-fieldtr {
225
  html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
226
  float: right;
227
  }
228
+ @media screen and (max-width: 640px) {
229
  .acf-fields.-left > .acf-field:before {
230
  display: none;
231
  }
274
  *--------------------------------------------------------------------------------------------*/
275
  .acf-postbox {
276
  position: relative;
 
 
 
277
  }
278
  #acf_after_title-sortables .acf-postbox {
279
  margin: 20px 0 0;
299
  .acf-postbox > .hndle .acf-hndle-cog:hover {
300
  color: #777777;
301
  }
302
+ .acf-postbox:hover > .hndle .acf-hndle-cog {
 
303
  display: block;
304
  }
305
  .acf-postbox .acf-replace-with-fields {
782
  background: #48a8f4;
783
  }
784
  .acf-button-group input {
785
+ display: none !important;
786
  }
787
  .acf-button-group label {
788
  margin: 0 0 0 -1px;
1296
  outline: none;
1297
  box-shadow: none;
1298
  }
1299
+ .acf-tab-group li a:empty {
1300
+ display: none;
1301
+ }
1302
  html[dir="rtl"] .acf-tab-group li {
1303
  margin: 0 0 0 0.5em;
1304
  }
1337
  /* mobile */
1338
  /* rtl */
1339
  }
1340
+ @media screen and (max-width: 640px) {
1341
  .acf-fields.-left > .acf-tab-wrap .acf-tab-group {
1342
  padding-left: 10px;
1343
  }
1579
  border-bottom: #DFDFDF solid 1px;
1580
  padding: 5px 10px;
1581
  }
1582
+ .acf-oembed .title .input-search {
 
1583
  margin: 0;
1584
  font-size: 14px;
1585
  line-height: 30px;
1591
  font-family: inherit;
1592
  cursor: text;
1593
  }
 
 
 
 
1594
  .acf-oembed .title .acf-actions {
1595
  padding: 6px;
1596
  }
 
 
 
1597
  .acf-oembed .canvas {
1598
  position: relative;
1599
  min-height: 250px;
1613
  position: absolute;
1614
  top: 50%;
1615
  left: 50%;
1616
+ transform: translate(-50%, -50%);
1617
  z-index: 0;
1618
  height: 42px;
1619
  width: 42px;
1620
  font-size: 42px;
1621
  color: #999;
1622
  }
1623
+ .acf-oembed .canvas .acf-loading-overlay {
 
 
 
 
 
1624
  background: rgba(255, 255, 255, 0.9);
 
 
 
 
 
 
 
 
1625
  }
1626
  .acf-oembed .canvas .canvas-error {
1627
  position: absolute;
1638
  display: inline;
1639
  }
1640
  .acf-oembed.has-value .canvas {
1641
+ min-height: 50;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1642
  }
1643
+ .acf-oembed.has-value .input-search {
1644
+ font-weight: bold;
1645
  }
1646
+ .acf-oembed.has-value .title:hover .acf-actions {
1647
  display: block;
1648
  }
 
 
 
1649
  /*--------------------------------------------------------------------------------------------
1650
  *
1651
  * Image
1830
  .acf-taxonomy-field:hover .acf-actions {
1831
  display: block;
1832
  }
1833
+ .acf-taxonomy-field[data-ftype="select"] .acf-actions {
1834
  padding: 0;
1835
  margin: -9px;
1836
  }
2152
  /* misc */
2153
  .media-modal {
2154
  /* compat-item */
 
2155
  /* allow line breaks in upload error */
2156
  /* fix required span */
2157
  /* sidebar */
2161
  .media-modal .compat-field-acf-blank {
2162
  display: none !important;
2163
  }
 
 
 
 
 
 
 
 
 
 
 
 
2164
  .media-modal .upload-error-message {
2165
  white-space: pre-wrap;
2166
  }
2208
  line-height: 18px;
2209
  color: #AAAAAA;
2210
  font-size: 12px;
2211
+ /* mobile sm */
2212
  }
2213
  .media-modal .acf-expand-details:focus,
2214
  .media-modal .acf-expand-details:active {
2235
  .media-modal .acf-expand-details .is-closed {
2236
  display: block;
2237
  }
2238
+ @media (max-width: 640px) {
2239
+ .media-modal .acf-expand-details {
2240
+ display: none;
2241
+ }
2242
+ }
2243
  /* expanded */
2244
  .media-modal.acf-expanded {
2245
  /* toggle */
2323
  .acf-media-modal .media-embed .setting.link-to {
2324
  display: none;
2325
  }
2326
+ @media screen and (min-width: 1024px) {
2327
+ .acf-media-modal .media-modal-content .media-frame .media-toolbar-secondary {
2328
+ max-width: none;
2329
+ }
2330
+ .acf-media-modal .media-modal-content .media-frame .media-toolbar-secondary select.attachment-filters {
2331
+ width: auto;
2332
+ min-width: 150px;
2333
+ max-width: none;
2334
+ margin: 11px 6px 0 0;
2335
+ vertical-align: middle;
2336
+ }
2337
+ }
2338
  /*---------------------------------------------------------------------------------------------
2339
  *
2340
  * ACF Media Model (Select Mode)
2354
  /* hide elements */
2355
  /* full width */
2356
  /* tidy up incorrect distance */
 
2357
  /* title box shadow (to match media grid) */
2358
  /* sidebar */
2359
  /* mobile md */
2374
  right: 0;
2375
  }
2376
  .acf-media-modal.-edit .media-frame-content {
 
 
 
2377
  top: 50px;
2378
  }
2379
  .acf-media-modal.-edit .media-frame-title {
2459
  }
2460
  .form-table > tbody > .acf-field > .acf-label {
2461
  padding: 20px 10px 20px 0;
2462
+ width: 210px;
2463
  /* rtl */
2464
  }
2465
  html[dir="rtl"] .form-table > tbody > .acf-field > .acf-label {
2486
  .form-table > tbody .form-table th.acf-th {
2487
  width: auto;
2488
  }
2489
+ #your-profile,
2490
+ #createuser {
2491
+ /* override for user css */
2492
+ /* allow sub fields to display correctly */
2493
+ }
2494
+ #your-profile .acf-field input[type="text"],
2495
+ #createuser .acf-field input[type="text"],
2496
+ #your-profile .acf-field input[type="password"],
2497
+ #createuser .acf-field input[type="password"],
2498
+ #your-profile .acf-field input[type="number"],
2499
+ #createuser .acf-field input[type="number"],
2500
+ #your-profile .acf-field input[type="search"],
2501
+ #createuser .acf-field input[type="search"],
2502
+ #your-profile .acf-field input[type="email"],
2503
+ #createuser .acf-field input[type="email"],
2504
+ #your-profile .acf-field input[type="url"],
2505
+ #createuser .acf-field input[type="url"],
2506
+ #your-profile .acf-field select,
2507
+ #createuser .acf-field select {
2508
+ max-width: 25em;
2509
+ }
2510
+ #your-profile .acf-field textarea,
2511
+ #createuser .acf-field textarea {
2512
+ max-width: 500px;
2513
+ }
2514
+ #your-profile .acf-field .acf-field input[type="text"],
2515
+ #createuser .acf-field .acf-field input[type="text"],
2516
+ #your-profile .acf-field .acf-field input[type="password"],
2517
+ #createuser .acf-field .acf-field input[type="password"],
2518
+ #your-profile .acf-field .acf-field input[type="number"],
2519
+ #createuser .acf-field .acf-field input[type="number"],
2520
+ #your-profile .acf-field .acf-field input[type="search"],
2521
+ #createuser .acf-field .acf-field input[type="search"],
2522
+ #your-profile .acf-field .acf-field input[type="email"],
2523
+ #createuser .acf-field .acf-field input[type="email"],
2524
+ #your-profile .acf-field .acf-field input[type="url"],
2525
+ #createuser .acf-field .acf-field input[type="url"],
2526
+ #your-profile .acf-field .acf-field textarea,
2527
+ #createuser .acf-field .acf-field textarea,
2528
+ #your-profile .acf-field .acf-field select,
2529
+ #createuser .acf-field .acf-field select {
2530
+ max-width: none;
2531
+ }
2532
+ #registerform h2 {
2533
+ margin: 1em 0;
2534
+ }
2535
+ #registerform .acf-field .acf-label {
2536
+ margin-bottom: 0;
2537
+ }
2538
+ #registerform .acf-field .acf-label label {
2539
+ font-weight: normal;
2540
+ font-size: 14px;
2541
+ }
2542
+ #registerform p.submit {
2543
+ text-align: right;
2544
+ }
2545
  /*--------------------------------------------------------------------------------------------
2546
  *
2547
  * Term
2608
  font-weight: normal;
2609
  margin: 0;
2610
  }
 
 
 
2611
  /*--------------------------------------------------------------------------------------------
2612
  *
2613
  * Nav Menu
assets/js/acf-field-group.js CHANGED
@@ -1,2929 +1,2411 @@
1
- (function($){
2
 
3
- acf.field_group = acf.model.extend({
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- // vars
6
- $fields: null,
7
- $locations: null,
8
- $options: null,
9
 
10
- actions: {
11
- 'ready': 'init'
 
 
12
  },
13
 
14
- events: {
15
- 'submit #post': 'submit',
16
- 'click a[href="#"]': 'preventDefault',
17
- 'click .submitdelete': 'trash',
18
- 'mouseenter .acf-field-list': 'sortable'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  },
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- /*
23
- * init
24
- *
25
- * This function will run on document ready and initialize the module
26
- *
27
- * @type function
28
- * @date 8/04/2014
29
- * @since 5.0.0
30
- *
31
- * @param n/a
32
- * @return n/a
33
- */
34
 
35
- init: function(){
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
- // $el
38
- this.$fields = $('#acf-field-group-fields');
39
- this.$locations = $('#acf-field-group-locations');
40
- this.$options = $('#acf-field-group-options');
41
 
 
 
 
42
 
43
- // disable validation
44
- acf.validation.active = 0;
45
-
46
  },
47
 
 
 
 
48
 
49
- /*
50
- * sortable
51
- *
52
- * This function will add sortable to the feild group list
53
- * sortable is added on mouseover to speed up page load
54
- *
55
- * @type function
56
- * @date 28/10/2015
57
- * @since 5.3.2
58
- *
59
- * @param $post_id (int)
60
- * @return $post_id (int)
61
- */
62
 
63
- sortable: function( e ){
64
-
65
- // bail early if already sortable
66
- if( e.$el.hasClass('ui-sortable') ) {
67
-
68
- return;
69
-
70
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
 
 
72
 
73
  // vars
74
- var self = this;
 
75
 
 
 
76
 
77
- // sortable
78
- e.$el.sortable({
79
- handle: '.acf-sortable-handle',
80
- connectWith: '.acf-field-list',
81
- start: function(e, ui){
82
- ui.placeholder.height( ui.item.height() );
83
- },
84
- update: function(event, ui){
85
-
86
- // vars
87
- var $el = ui.item;
88
-
89
-
90
- // render
91
- self.render_fields();
92
-
93
-
94
- // actions
95
- acf.do_action('sortstop', $el);
96
-
97
- }
98
- });
99
 
100
- },
101
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- /*
104
- * preventDefault
105
- *
106
- * This helper will preventDefault on all events for empty links
107
- *
108
- * @type function
109
- * @date 18/08/2015
110
- * @since 5.2.3
111
- *
112
- * @param $post_id (int)
113
- * @return $post_id (int)
114
- */
115
 
116
- preventDefault: function( e ){
 
 
 
 
 
117
 
118
- e.preventDefault();
 
 
 
119
 
 
 
120
  },
121
 
122
-
123
- /*
124
- * get_selector
125
- *
126
- * This function will return a valid selector for finding a field object
127
- *
128
- * @type function
129
- * @date 15/01/2015
130
- * @since 5.1.5
131
- *
132
- * @param s (string)
133
- * @return (string)
134
- */
135
-
136
- get_selector: function( s ) {
137
 
138
- // defaults
139
- s = s || '';
 
140
 
 
 
141
 
142
- // vars
143
- var selector = '.acf-field-object';
144
 
145
-
146
- // search
147
- if( s ) {
148
-
149
- // append
150
- selector += '-' + s;
151
-
152
-
153
- // replace underscores (split/join replaces all and is faster than regex!)
154
- selector = selector.split('_').join('-');
155
 
156
- }
 
157
 
 
 
 
 
 
158
 
159
- // return
160
- return selector;
 
 
 
161
 
 
 
 
 
 
 
 
 
 
162
  },
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
- /*
166
- * render_fields
167
- *
168
- * This function is triggered by a change in field order, and will update the field icon number
169
- *
170
- * @type function
171
- * @date 8/04/2014
172
- * @since 5.0.0
173
- *
174
- * @param n/a
175
- * @return n/a
176
- */
177
 
178
- render_fields: function(){
179
 
180
- // reference
181
- var self = this;
 
182
 
 
 
 
 
 
183
 
184
- // update order numbers
185
- $('.acf-field-list').each(function(){
186
-
187
- // vars
188
- var $fields = $(this).children('.acf-field-object');
189
-
190
-
191
- // loop over fields
192
- $fields.each(function( i ){
193
-
194
- // update meta
195
- self.update_field_meta( $(this), 'menu_order', i );
196
-
197
-
198
- // update icon number
199
- $(this).children('.handle').find('.acf-icon').html( i+1 );
200
-
201
- });
202
-
203
-
204
- // show no fields message
205
- if( !$fields.exists() ){
206
-
207
- $(this).children('.no-fields-message').show();
208
-
209
- } else {
210
-
211
- $(this).children('.no-fields-message').hide();
212
-
213
- }
214
-
215
  });
 
216
 
 
 
217
  },
218
 
219
-
220
- /*
221
- * get_field_meta
222
- *
223
- * This function will return an input value for a field
224
- *
225
- * @type function
226
- * @date 8/04/2014
227
- * @since 5.0.0
228
- *
229
- * @param $el
230
- * @param name
231
- * @return (string)
232
- */
233
-
234
- get_field_meta: function( $el, name ){
235
-
236
- //console.log( 'get_field_meta(%o, %o)', $el, name );
237
 
238
- // vars
239
- var $input = $el.find('> .meta > .input-' + name);
240
-
241
-
242
- // bail early if no input
243
- if( !$input.exists() ) {
244
-
245
- //console.log( '- aborted due to no input' );
246
- return false;
247
-
248
  }
249
 
 
 
 
 
250
 
251
- // return
252
- return $input.val();
253
 
 
 
254
  },
255
 
256
-
257
- /*
258
- * update_field_meta
259
- *
260
- * This function will update an input value for a field
261
- *
262
- * @type function
263
- * @date 8/04/2014
264
- * @since 5.0.0
265
- *
266
- * @param $el
267
- * @param name
268
- * @param value
269
- * @return n/a
270
- */
271
-
272
- update_field_meta: function( $el, name, value ){
273
 
274
- //console.log( 'update_field_meta(%o, %o, %o)', $el, name, value );
 
 
275
 
276
- // vars
277
- var $input = $el.find('> .meta > .input-' + name);
278
-
279
-
280
- // create hidden input if doesn't exist
281
- if( !$input.exists() ) {
282
-
283
- // vars
284
- var html = $el.find('> .meta > .input-ID').outerHTML();
285
-
286
-
287
- // replcae
288
- html = acf.str_replace('ID', name, html);
289
-
290
-
291
- // update $input
292
- $input = $(html);
293
-
294
-
295
- // reset value
296
- $input.val( value );
297
-
298
-
299
- // append
300
- $el.children('.meta').append( $input );
301
-
302
- //console.log( '- created new input' );
303
-
304
  }
305
 
306
-
307
- // bail early if no change
308
- if( $input.val() == value ) {
309
 
310
- //console.log( '- aborted due to no change in input value' );
311
- return;
 
312
  }
313
 
 
314
 
315
- // update value
316
- $input.val( value );
317
-
318
-
319
- // bail early if updating save
320
- if( name == 'save' ) {
321
-
322
- //console.log( '- aborted due to name == save' );
323
- return;
324
 
 
 
 
 
325
  }
326
 
327
-
328
- // meta has changed, update save
329
- this.save_field( $el, 'meta' );
330
 
331
  },
332
 
 
 
 
 
 
 
 
333
 
334
- /*
335
- * delete_field_meta
336
- *
337
- * This function will return an input value for a field
338
- *
339
- * @type function
340
- * @date 8/04/2014
341
- * @since 5.0.0
342
- *
343
- * @param $el
344
- * @param name
345
- * @return (string)
346
- */
347
 
348
- delete_field_meta: function( $el, name ){
349
 
350
- //console.log( 'delete_field_meta(%o, %o, %o)', $el, name );
351
-
352
- // vars
353
- var $input = $el.find('> .meta > .input-' + name);
354
-
355
-
356
- // bail early if not exists
357
- if( !$input.exists() ) {
358
-
359
- //console.log( '- aborted due to no input' );
360
- return;
361
-
362
  }
363
 
364
-
365
- // remove
366
- $input.remove();
367
-
368
-
369
- // meta has changed, update save
370
- this.save_field( $el, 'meta' );
371
-
372
  },
373
 
 
 
 
374
 
375
- /*
376
- * save_field
377
- *
378
- * This function will update the changed input for a given field making sure it is saved on submit
379
- *
380
- * @type function
381
- * @date 8/04/2014
382
- * @since 5.0.0
383
- *
384
- * @param $el
385
- * @return n/a
386
- */
387
 
388
- save_field: function( $el, type ){
389
-
390
- //console.log('save_field(%o %o)', $el, type);
391
-
392
- // defaults
393
- type = type || 'settings';
394
-
 
 
395
 
 
 
 
 
 
 
396
  // vars
397
- var value = this.get_field_meta( $el, 'save' );
398
-
399
-
400
- // bail early if already 'settings'
401
- if( value == 'settings' ) {
402
-
403
- return;
404
-
405
- }
406
 
 
 
407
 
408
- // bail early if no change
409
- if( value == type ) {
410
-
411
- return;
412
-
413
  }
414
 
 
 
 
 
 
415
 
416
- // update meta
417
- this.update_field_meta( $el, 'save', type );
418
 
 
 
419
 
420
  // action for 3rd party customization
421
- acf.do_action('save_field', $el, type);
422
-
 
 
 
423
  },
424
 
 
 
 
425
 
426
- /*
427
- * submit
428
- *
429
- * This function is triggered when submitting the form and provides validation prior to posting the data
430
- *
431
- * @type function
432
- * @date 8/04/2014
433
- * @since 5.0.0
434
- *
435
- * @param n/a
436
- * @return (boolean)
437
- */
438
 
439
- submit: function( e ){
440
 
441
- // reference
442
- var self = this;
 
 
 
 
443
 
 
 
 
 
 
 
 
 
 
444
 
445
  // vars
446
- var $title = $('#titlewrap #title');
447
 
 
 
 
448
 
449
- // title empty
450
- if( !$title.val() ) {
451
-
452
- // prevent default
453
- e.preventDefault();
454
-
455
-
456
- // unlock form
457
- acf.validation.toggle( e.$el, 'unlock' );
458
-
459
-
460
- // alert
461
- alert( acf._e('title_is_required') );
462
-
463
-
464
- // focus
465
- $title.focus();
466
-
467
- }
468
 
469
-
470
- // close / delete fields
471
- $('.acf-field-object').each(function(){
472
-
473
- // vars
474
- var save = self.get_field_meta( $(this), 'save'),
475
- ID = self.get_field_meta( $(this), 'ID'),
476
- open = $(this).hasClass('open');
477
-
478
-
479
- // close
480
- if( open ) {
481
-
482
- self.close_field( $(this) );
483
-
484
- }
485
-
486
-
487
- // remove unnecessary inputs
488
- if( save == 'settings' ) {
489
-
490
- // allow all settings to save (new field, changed field)
491
-
492
- } else if( save == 'meta' ) {
493
-
494
- $(this).children('.settings').find('[name^="acf_fields[' + ID + ']"]').remove();
495
-
496
- } else {
497
-
498
- $(this).find('[name^="acf_fields[' + ID + ']"]').remove();
499
-
500
- }
501
-
502
- });
503
-
504
  },
505
 
 
 
 
506
 
507
- /*
508
- * trash
509
- *
510
- * This function is triggered when moving the field group to trash
511
- *
512
- * @type function
513
- * @date 8/04/2014
514
- * @since 5.0.0
515
- *
516
- * @param n/a
517
- * @return (boolean)
518
- */
519
-
520
- trash: function( e ){
521
 
522
- var result = confirm( acf._e('move_to_trash') );
 
523
 
524
- if( !result ) {
525
-
526
- e.preventDefault();
527
-
 
 
528
  }
529
 
 
 
 
 
 
 
 
 
530
  },
531
 
532
-
533
- /*
534
- * render_field
535
- *
536
- * This function will update the field's info
537
- *
538
- * @type function
539
- * @date 8/04/2014
540
- * @since 5.0.0
541
- *
542
- * @param $el
543
- * @return n/a
544
- */
545
-
546
- render_field: function( $el ){
547
 
548
  // vars
549
- var label = $el.find('.field-label:first').val(),
550
- name = $el.find('.field-name:first').val(),
551
- type = $el.find('.field-type:first option:selected').text(),
552
- required = $el.find('.field-required:first').prop('checked'),
553
- $handle = $el.children('.handle');
554
-
555
-
556
- // update label
557
- $handle.find('.li-field-label strong a').html( label );
558
 
 
 
 
 
559
 
560
- // update required
561
- $handle.find('.li-field-label .acf-required').remove();
 
562
 
563
- if( required ) {
564
-
565
- $handle.find('.li-field-label strong').append('<span class="acf-required">*</span>');
566
 
 
 
 
567
  }
568
 
 
 
 
 
 
569
 
570
- // update name
571
- $handle.find('.li-field-name').text( name );
572
-
573
-
574
- // update type
575
- $handle.find('.li-field-type').text( type );
576
-
577
 
578
  // action for 3rd party customization
579
- acf.do_action('render_field_handle', $el, $handle);
580
-
581
  },
582
 
583
-
584
- /*
585
- * edit_field
586
- *
587
- * This function is triggered when clicking on a field. It will open / close a fields settings
588
- *
589
- * @type function
590
- * @date 8/04/2014
591
- * @since 5.0.0
592
- *
593
- * @param $el
594
- * @return n/a
595
- */
596
-
597
- edit_field: function( $field ){
598
 
599
- // toggle
600
- if( $field.hasClass('open') ) {
 
601
 
602
- this.close_field( $field );
603
-
604
  } else {
 
 
605
 
606
- this.open_field( $field );
607
-
 
608
  }
609
-
 
 
610
  },
611
 
612
-
613
- /*
614
- * open_field
615
- *
616
- * This function will open a fields settings
617
- *
618
- * @type function
619
- * @date 8/04/2014
620
- * @since 5.0.0
621
- *
622
- * @param $el
623
- * @return n/a
624
- */
625
-
626
- open_field: function( $el ){
627
 
628
- // bail early if already open
629
- if( $el.hasClass('open') ) {
 
630
 
631
- return false;
632
-
 
 
633
  }
634
-
635
-
636
- // add class
637
- $el.addClass('open');
638
-
639
-
640
- // action for 3rd party customization
641
- acf.do_action('open_field', $el);
642
-
643
-
644
- // animate toggle
645
- $el.children('.settings').animate({ 'height' : 'toggle' }, 250 );
646
-
647
  },
648
 
649
-
650
- /*
651
- * close_field
652
- *
653
- * This function will open a fields settings
654
- *
655
- * @type function
656
- * @date 8/04/2014
657
- * @since 5.0.0
658
- *
659
- * @param $el
660
- * @return n/a
661
- */
662
-
663
- close_field: function( $el ){
664
 
665
- // bail early if already closed
666
- if( !$el.hasClass('open') ) {
 
667
 
668
- return false;
669
-
 
670
  }
671
-
672
-
673
- // remove class
674
- $el.removeClass('open');
675
-
676
-
677
- // action for 3rd party customization
678
- acf.do_action('close_field', $el);
679
-
680
-
681
- // animate toggle
682
- $el.children('.settings').animate({ 'height' : 'toggle' }, 250 );
683
-
684
  },
685
 
686
-
687
- /*
688
- * wipe_field
689
- *
690
- * This function will prepare a new field by updating the input names
691
- *
692
- * @type function
693
- * @date 8/04/2014
694
- * @since 5.0.0
695
- *
696
- * @param $el
697
- * @return n/a
698
- */
699
-
700
- wipe_field: function( $el ){
701
 
702
- // vars
703
- var id = $el.attr('data-id'),
704
- key = $el.attr('data-key'),
705
- new_id = acf.get_uniqid(),
706
- new_key = 'field_' + new_id;
 
707
 
 
 
 
 
708
 
709
- // update attr
710
- $el.attr('data-id', new_id);
711
- $el.attr('data-key', new_key);
712
- $el.attr('data-orig', key);
713
 
 
 
 
 
 
714
 
715
- // update hidden inputs
716
- this.update_field_meta( $el, 'ID', '' );
717
- this.update_field_meta( $el, 'key', new_key );
718
 
 
 
 
 
 
 
 
 
 
719
 
720
- // update attributes
721
- $el.find('[id*="' + id + '"]').each(function(){
722
 
723
- $(this).attr('id', $(this).attr('id').replace(id, new_id) );
724
-
 
 
 
 
 
 
 
 
 
725
  });
 
 
 
726
 
727
- $el.find('[name*="' + id + '"]').each(function(){
728
-
729
- $(this).attr('name', $(this).attr('name').replace(id, new_id) );
730
-
 
731
  });
732
 
 
 
 
 
 
 
 
 
 
733
 
734
- // update key
735
- $el.find('> .handle .pre-field-key').text( new_key );
736
-
737
-
738
- // remove sortable classes
739
- $el.find('.ui-sortable').removeClass('ui-sortable');
740
-
741
-
742
- // action for 3rd party customization
743
- acf.do_action('wipe_field', $el);
744
-
745
  },
746
 
747
-
748
- /*
749
- * add_field
750
- *
751
- * This function will add a new field to a field list
752
- *
753
- * @type function
754
- * @date 8/04/2014
755
- * @since 5.0.0
756
- *
757
- * @param $fields
758
- * @return n/a
759
- */
760
-
761
- add_field: function( $fields ){
762
-
763
- // clone tr
764
- var $el = $( $('#tmpl-acf-field').html() ),
765
- $label = $el.find('.field-label:first'),
766
- $name = $el.find('.field-name:first');
767
-
768
-
769
- // update names
770
- this.wipe_field( $el );
771
 
 
 
772
 
773
- // append to table
774
- $fields.append( $el );
 
 
 
 
775
 
 
 
776
 
777
- // clear name
778
- $label.val('');
779
- $name.val('');
780
 
 
 
 
 
 
 
781
 
782
- // focus after form has dropped down
 
783
  setTimeout(function(){
784
-
785
  $label.focus();
786
-
787
  }, 251);
788
 
 
 
 
 
 
789
 
790
- // update order numbers
791
- this.render_fields();
 
 
 
792
 
 
 
 
 
 
 
 
 
793
 
794
- // trigger append
795
- acf.do_action('append', $el);
796
-
797
-
798
- // open up form
799
- this.edit_field( $el );
800
-
801
 
802
- // action for 3rd party customization
803
- acf.do_action('add_field', $el);
 
 
804
 
 
 
 
805
  },
806
 
807
-
808
- /*
809
- * duplicate_field
810
- *
811
- * This function will duplicate a field
812
- *
813
- * @type function
814
- * @date 8/04/2014
815
- * @since 5.0.0
816
- *
817
- * @param $el
818
- * @return $el2
819
- */
820
-
821
- duplicate_field: function( $el ){
822
-
823
- // allow acf to modify DOM
824
- acf.do_action('before_duplicate', $el);
825
-
826
 
827
  // vars
828
- var $el2 = $el.clone(),
829
- $label = $el2.find('.field-label:first'),
830
- $name = $el2.find('.field-name:first');
831
-
832
-
833
- // remove JS functionality
834
- acf.do_action('remove', $el2);
835
-
836
-
837
- // update names
838
- this.wipe_field( $el2 );
839
-
840
-
841
- // allow acf to modify DOM
842
- acf.do_action('after_duplicate', $el, $el2);
843
-
844
-
845
- // append to table
846
- $el.after( $el2 );
847
-
848
 
849
- // trigger append
850
- acf.do_action('append', $el2);
 
 
851
 
 
 
 
852
 
853
- // focus after form has dropped down
854
- setTimeout(function(){
 
855
 
856
- $label.focus();
857
-
858
- }, 251);
859
-
 
860
 
861
- // update order numbers
862
- this.render_fields();
 
 
863
 
 
 
 
 
 
 
 
 
 
 
 
864
 
865
- // open up form
866
- if( $el.hasClass('open') ) {
 
 
 
867
 
868
- this.close_field( $el );
 
 
 
 
 
 
 
 
 
 
 
869
 
870
- } else {
871
-
872
- this.open_field( $el2 );
 
 
873
 
874
- }
875
-
876
-
877
- // update new_field label / name
878
- var label = $label.val(),
879
- name = $name.val(),
880
- end = name.split('_').pop(),
881
- copy = acf._e('copy');
882
-
883
 
884
- // look at last word
885
- if( end.indexOf(copy) === 0 ) {
886
 
887
- var i = end.replace(copy, '') * 1;
888
- i = i ? i+1 : 2;
 
889
 
890
- // replace
891
- label = label.replace( end, copy + i );
892
- name = name.replace( end, copy + i );
 
 
893
 
894
- } else {
 
895
 
896
- label += ' (' + copy + ')';
897
- name += '_' + copy;
898
 
899
- }
900
-
901
-
902
- $label.val( label );
903
- $name.val( name );
904
-
905
-
906
- // save field
907
- this.save_field( $el2 );
908
-
909
-
910
- // render field
911
- this.render_field( $el2 );
 
 
 
912
 
 
 
 
 
 
 
 
 
913
 
914
- // action for 3rd party customization
915
- acf.do_action('duplicate_field', $el2);
916
 
 
 
 
917
 
918
- // return
919
- return $el2;
 
 
920
 
 
 
 
 
 
921
  },
922
 
923
-
924
- /*
925
- * move_field
926
- *
927
- * This function will launch a popup to move a field to another field group
928
- *
929
- * @type function
930
- * @date 8/04/2014
931
- * @since 5.0.0
932
- *
933
- * @param $field
934
- * @return n/a
935
- */
936
-
937
- move_field: function( $field ){
938
 
939
- // reference
940
- var self = this;
 
 
941
 
 
 
 
 
942
 
943
- // AJAX data
944
- var ajax_data = acf.prepare_for_ajax({
945
- action: 'acf/field_group/move_field',
946
- field_id: this.get_field_meta( $field, 'ID' )
947
- });
948
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
949
 
950
- // vars
951
- var warning = false;
952
-
953
-
954
- // validate
955
- if( !ajax_data.field_id ) {
956
-
957
- // Case: field not saved to DB
958
- warning = true;
959
-
960
- } else if( this.get_field_meta( $field, 'save' ) == 'settings' ) {
961
-
962
- // Case: field's settings have changed
963
- warning = true;
964
-
965
- } else {
966
-
967
- // Case: sub field's settings have changed
968
- $field.find('.acf-field-object').each(function(){
969
-
970
- if( !self.get_field_meta( $(this), 'ID' ) ) {
971
-
972
- // Case: field not saved to DB
973
- warning = true;
974
- return false;
975
-
976
- } else if( self.get_field_meta( $(this), 'save' ) == 'settings' ) {
977
-
978
- // Case: field's settings have changed
979
- warning = true;
980
-
981
- }
982
-
983
- });
984
-
985
- }
986
-
987
-
988
- // bail early if can't move
989
- if( warning ) {
990
-
991
- alert( acf._e('move_field_warning') );
992
- return;
993
-
994
- }
995
-
996
-
997
- // open popup
998
- acf.open_popup({
999
- title : acf._e('move_field'),
1000
- loading : true,
1001
- height : 145
1002
- });
1003
-
1004
-
1005
- // get HTML
1006
- $.ajax({
1007
- url: acf.get('ajaxurl'),
1008
- data: ajax_data,
1009
- type: 'post',
1010
- dataType: 'html',
1011
- success: function(html){
1012
-
1013
- self.move_field_confirm( $field, html );
1014
-
1015
- }
1016
- });
1017
-
1018
- },
1019
-
1020
-
1021
- /*
1022
- * move_field_confirm
1023
- *
1024
- * This function will move a field to another field group
1025
- *
1026
- * @type function
1027
- * @date 8/04/2014
1028
- * @since 5.0.0
1029
- *
1030
- * @param $post_id (int)
1031
- * @return $post_id (int)
1032
- */
1033
-
1034
- move_field_confirm: function( $field, html ){
1035
-
1036
- // reference
1037
- var self = this;
1038
-
1039
-
1040
- // update popup
1041
- acf.update_popup({
1042
- content : html
1043
- });
1044
-
1045
-
1046
- // AJAX data
1047
- var ajax_data = acf.prepare_for_ajax({
1048
- 'action' : 'acf/field_group/move_field',
1049
- 'field_id' : this.get_field_meta($field, 'ID'),
1050
- 'field_group_id' : 0
1051
- });
1052
-
1053
-
1054
- // submit form
1055
- $('#acf-move-field-form').on('submit', function(){
1056
-
1057
- ajax_data.field_group_id = $(this).find('select').val();
1058
-
1059
-
1060
- // get HTML
1061
- $.ajax({
1062
- url: acf.get('ajaxurl'),
1063
- data: ajax_data,
1064
- type: 'post',
1065
- dataType: 'html',
1066
- success: function(html){
1067
-
1068
- acf.update_popup({
1069
- content : html
1070
- });
1071
-
1072
-
1073
- // remove the field without actually deleting it
1074
- self.remove_field( $field );
1075
-
1076
- }
1077
- });
1078
-
1079
- return false;
1080
-
1081
- });
1082
-
1083
- },
1084
-
1085
-
1086
- /*
1087
- * delete_field
1088
- *
1089
- * This function will delete a field
1090
- *
1091
- * @type function
1092
- * @date 8/04/2014
1093
- * @since 5.0.0
1094
- *
1095
- * @param $el
1096
- * @param animation
1097
- * @return n/a
1098
- */
1099
-
1100
- delete_field: function( $el, animation ){
1101
-
1102
- // defaults
1103
- animation = animation || true;
1104
-
1105
-
1106
- // vars
1107
- var id = this.get_field_meta($el, 'ID');
1108
-
1109
-
1110
- // add to remove list
1111
- if( id ) {
1112
-
1113
- var $input = $('#_acf_delete_fields');
1114
- $input.val( $input.val() + '|' + id );
1115
-
1116
- }
1117
-
1118
-
1119
- // action for 3rd party customization
1120
- acf.do_action('delete_field', $el);
1121
-
1122
-
1123
- // bail early if no animation
1124
- if( animation ) {
1125
-
1126
- this.remove_field( $el );
1127
-
1128
- }
1129
-
1130
- },
1131
-
1132
-
1133
- /*
1134
- * remove_field
1135
- *
1136
- * This function will visualy remove a field
1137
- *
1138
- * @type function
1139
- * @date 24/10/2014
1140
- * @since 5.0.9
1141
- *
1142
- * @param $el
1143
- * @param animation
1144
- * @return n/a
1145
- */
1146
-
1147
- remove_field: function( $el ){
1148
-
1149
- // reference
1150
- var self = this;
1151
-
1152
-
1153
- // vars
1154
- var $field_list = $el.closest('.acf-field-list');
1155
-
1156
-
1157
- // set layout
1158
- $el.css({
1159
- height : $el.height(),
1160
- width : $el.width(),
1161
- position : 'absolute'
1162
- });
1163
-
1164
-
1165
- // wrap field
1166
- $el.wrap( '<div class="temp-field-wrap" style="height:' + $el.height() + 'px"></div>' );
1167
-
1168
-
1169
- // fade $el
1170
- $el.animate({ opacity : 0 }, 250);
1171
-
1172
-
1173
- // close field
1174
- var end_height = 0,
1175
- $show = false;
1176
-
1177
-
1178
- if( !$field_list.children('.acf-field-object').length ) {
1179
-
1180
- $show = $field_list.children('.no-fields-message');
1181
- end_height = $show.outerHeight();
1182
-
1183
- }
1184
-
1185
- $el.parent('.temp-field-wrap').animate({ height : end_height }, 250, function(){
1186
-
1187
- // show another element
1188
- if( $show ) {
1189
-
1190
- $show.show();
1191
-
1192
- }
1193
-
1194
-
1195
- // action for 3rd party customization
1196
- acf.do_action('remove', $(this));
1197
-
1198
-
1199
- // remove $el
1200
- $(this).remove();
1201
-
1202
-
1203
- // render fields becuase they have changed
1204
- self.render_fields();
1205
-
1206
- });
1207
-
1208
- },
1209
-
1210
-
1211
- /*
1212
- * change_field_type
1213
- *
1214
- * This function will update the field's settings based on the new field type
1215
- *
1216
- * @type function
1217
- * @date 8/04/2014
1218
- * @since 5.0.0
1219
- *
1220
- * @param $select
1221
- * @return n/a
1222
- */
1223
-
1224
- change_field_type: function( $select ){
1225
-
1226
- // vars
1227
- var $tbody = $select.closest('tbody'),
1228
- $el = $tbody.closest('.acf-field-object'),
1229
- $parent = $el.parent().closest('.acf-field-object'),
1230
-
1231
- key = $el.attr('data-key'),
1232
- old_type = $el.attr('data-type'),
1233
- new_type = $select.val();
1234
-
1235
-
1236
- // update class
1237
- $el.removeClass( 'acf-field-object-' + acf.str_replace('_', '-', old_type) );
1238
- $el.addClass( 'acf-field-object-' + acf.str_replace('_', '-', new_type) );
1239
-
1240
-
1241
- // update atts
1242
- $el.attr('data-type', new_type);
1243
- $el.data('type', new_type);
1244
-
1245
-
1246
- // abort XHR if this field is already loading AJAX data
1247
- if( $el.data('xhr') ) {
1248
-
1249
- $el.data('xhr').abort();
1250
-
1251
- }
1252
-
1253
-
1254
- // get settings
1255
- var $settings = $tbody.children('.acf-field[data-setting="' + old_type + '"]');
1256
-
1257
- // save field settings html
1258
- acf.update( key + '_settings_' + old_type, $settings );
1259
-
1260
- // remove settings
1261
- $settings.detach();
1262
-
1263
- // render field
1264
- this.render_field( $el );
1265
-
1266
-
1267
- // show field options if they already exist
1268
- $newettings = acf.get( key + '_settings_' + new_type );
1269
-
1270
- if( $newettings ) {
1271
-
1272
- // append settings
1273
- $tbody.children('.acf-field[data-name="conditional_logic"]').before( $newettings );
1274
-
1275
-
1276
- // remove field settings html
1277
- acf.update( key + '_settings_' + new_type, false );
1278
-
1279
-
1280
- // trigger event
1281
- acf.do_action('change_field_type', $el);
1282
-
1283
-
1284
- // return
1285
- return;
1286
- }
1287
-
1288
-
1289
- // add loading
1290
- var $tr = $('<tr class="acf-field"><td class="acf-label"></td><td class="acf-input"><div class="acf-loading"></div></td></tr>');
1291
-
1292
-
1293
- // add $tr
1294
- $tbody.children('.acf-field[data-name="conditional_logic"]').before( $tr );
1295
-
1296
-
1297
- var ajax_data = {
1298
- action : 'acf/field_group/render_field_settings',
1299
- nonce : acf.o.nonce,
1300
- parent : acf.o.post_id,
1301
- field_group : acf.o.post_id,
1302
- prefix : $select.attr('name').replace('[type]', ''),
1303
- type : new_type
1304
- };
1305
-
1306
-
1307
- // parent
1308
- if( $parent.exists() ) {
1309
-
1310
- ajax_data.parent = this.get_field_meta( $parent, 'ID' );
1311
-
1312
- }
1313
-
1314
-
1315
- // ajax
1316
- var xhr = $.ajax({
1317
- url: acf.o.ajaxurl,
1318
- data: ajax_data,
1319
- type: 'post',
1320
- dataType: 'html',
1321
- success: function( html ){
1322
-
1323
- // bail early if no html
1324
- if( !html ) {
1325
-
1326
- return;
1327
-
1328
- }
1329
-
1330
-
1331
- // vars
1332
- var $new_tr = $(html);
1333
-
1334
-
1335
- // replace
1336
- $tr.after( $new_tr );
1337
-
1338
-
1339
- // trigger event
1340
- acf.do_action('append', $new_tr);
1341
- acf.do_action('change_field_type', $el);
1342
-
1343
-
1344
- },
1345
- complete : function(){
1346
-
1347
- // this function will also be triggered by $el.data('xhr').abort();
1348
- $tr.remove();
1349
-
1350
- }
1351
- });
1352
-
1353
-
1354
- // update el data
1355
- $el.data('xhr', xhr);
1356
-
1357
- },
1358
-
1359
- /*
1360
- * change_field_label
1361
- *
1362
- * This function is triggered when changing the field's label
1363
- *
1364
- * @type function
1365
- * @date 8/04/2014
1366
- * @since 5.0.0
1367
- *
1368
- * @param $el
1369
- * @return n/a
1370
- */
1371
-
1372
- change_field_label: function( $el ) {
1373
-
1374
- // vars
1375
- var $label = $el.find('.field-label:first'),
1376
- $name = $el.find('.field-name:first'),
1377
- type = $el.attr('data-type');
1378
-
1379
-
1380
- // render name
1381
- if( $name.val() == '' ) {
1382
-
1383
- // vars
1384
- var s = $label.val();
1385
-
1386
-
1387
- // sanitize
1388
- s = acf.str_sanitize(s);
1389
-
1390
-
1391
- // update name
1392
- $name.val( s ).trigger('change');
1393
-
1394
- }
1395
-
1396
-
1397
- // render field
1398
- this.render_field( $el );
1399
-
1400
-
1401
- // action for 3rd party customization
1402
- acf.do_action('change_field_label', $el);
1403
-
1404
- },
1405
-
1406
- /*
1407
- * change_field_name
1408
- *
1409
- * This function is triggered when changing the field's name
1410
- *
1411
- * @type function
1412
- * @date 8/04/2014
1413
- * @since 5.0.0
1414
- *
1415
- * @param $el
1416
- * @return n/a
1417
- */
1418
-
1419
- change_field_name: function( $el ) {
1420
-
1421
- // vars
1422
- var $name = $el.find('.field-name:first');
1423
-
1424
- if( $name.val().substr(0, 6) === 'field_' ) {
1425
-
1426
- alert( acf._e('field_name_start') );
1427
-
1428
- setTimeout(function(){
1429
-
1430
- $name.focus();
1431
-
1432
- }, 1);
1433
-
1434
- }
1435
-
1436
-
1437
- // action for 3rd party customization
1438
- acf.do_action('change_field_name', $el);
1439
-
1440
- }
1441
-
1442
- });
1443
-
1444
-
1445
- /*
1446
- * field
1447
- *
1448
- * This model will handle field events
1449
- *
1450
- * @type function
1451
- * @date 19/08/2015
1452
- * @since 5.2.3
1453
- *
1454
- * @param $post_id (int)
1455
- * @return $post_id (int)
1456
- */
1457
-
1458
- acf.field_group.field = acf.model.extend({
1459
-
1460
- events: {
1461
- 'click .edit-field': 'edit',
1462
- 'click .duplicate-field': 'duplicate',
1463
- 'click .move-field': 'move',
1464
- 'click .delete-field': 'delete',
1465
- 'click .add-field': 'add',
1466
-
1467
- 'change .field-type': 'change_type',
1468
- 'blur .field-label': 'change_label',
1469
- 'blur .field-name': 'change_name',
1470
-
1471
- 'keyup .field-label': 'render',
1472
- 'keyup .field-name': 'render',
1473
- 'change .field-required': 'render',
1474
-
1475
- 'change .acf-field-object input': 'save',
1476
- 'change .acf-field-object textarea': 'save',
1477
- 'change .acf-field-object select': 'save'
1478
- },
1479
-
1480
- event: function( e ){
1481
-
1482
- // append $field
1483
- e.$field = e.$el.closest('.acf-field-object');
1484
-
1485
-
1486
- // return
1487
- return e;
1488
-
1489
- },
1490
-
1491
-
1492
- /*
1493
- * events
1494
- *
1495
- * description
1496
- *
1497
- * @type function
1498
- * @date 19/08/2015
1499
- * @since 5.2.3
1500
- *
1501
- * @param $post_id (int)
1502
- * @return $post_id (int)
1503
- */
1504
-
1505
- edit: function( e ){
1506
-
1507
- acf.field_group.edit_field( e.$field );
1508
-
1509
- },
1510
-
1511
- duplicate: function( e ){
1512
-
1513
- acf.field_group.duplicate_field( e.$field );
1514
-
1515
- },
1516
-
1517
- move: function( e ){
1518
-
1519
- acf.field_group.move_field( e.$field );
1520
-
1521
- },
1522
-
1523
- delete: function( e ){
1524
-
1525
- acf.field_group.delete_field( e.$field );
1526
-
1527
- },
1528
-
1529
- add: function( e ){
1530
-
1531
- var $list = e.$el.closest('.acf-field-list-wrap').children('.acf-field-list');
1532
-
1533
- acf.field_group.add_field( $list );
1534
-
1535
- },
1536
-
1537
- change_type: function( e ){
1538
-
1539
- acf.field_group.change_field_type( e.$el );
1540
-
1541
- },
1542
-
1543
- change_label: function( e ){
1544
-
1545
- acf.field_group.change_field_label( e.$field );
1546
-
1547
- },
1548
-
1549
- change_name: function( e ){
1550
-
1551
- acf.field_group.change_field_name( e.$field );
1552
-
1553
- },
1554
-
1555
- render: function( e ){
1556
-
1557
- acf.field_group.render_field( e.$field );
1558
-
1559
- },
1560
-
1561
- save: function( e ){
1562
-
1563
- acf.field_group.save_field( e.$field );
1564
-
1565
- }
1566
-
1567
- });
1568
-
1569
-
1570
- /*
1571
- * conditions
1572
- *
1573
- * This model will handle conditional logic events
1574
- *
1575
- * @type function
1576
- * @date 19/08/2015
1577
- * @since 5.2.3
1578
- *
1579
- * @param $post_id (int)
1580
- * @return $post_id (int)
1581
- */
1582
-
1583
- acf.field_group.conditional_logic = acf.model.extend({
1584
-
1585
- actions: {
1586
- 'open_field': 'render_field',
1587
- 'change_field_label': 'render_fields',
1588
- 'change_field_type': 'render_fields'
1589
- },
1590
-
1591
- events: {
1592
- 'click .add-conditional-rule': 'add_rule',
1593
- 'click .add-conditional-group': 'add_group',
1594
- 'click .remove-conditional-rule': 'remove_rule',
1595
- 'change .conditional-toggle': 'change_toggle',
1596
- 'change .conditional-rule-param': 'change_param'
1597
- },
1598
-
1599
-
1600
- /*
1601
- * render_fields
1602
- *
1603
- * description
1604
- *
1605
- * @type function
1606
- * @date 19/08/2015
1607
- * @since 5.2.3
1608
- *
1609
- * @param $post_id (int)
1610
- * @return $post_id (int)
1611
- */
1612
-
1613
- render_fields: function(){
1614
-
1615
- var self = this;
1616
-
1617
- $('.acf-field-object.open').each(function(){
1618
-
1619
- self.render_field( $(this) );
1620
-
1621
- });
1622
-
1623
- },
1624
-
1625
-
1626
- /*
1627
- * render_field
1628
- *
1629
- * This function will render the conditional logic fields for a given field
1630
- *
1631
- * @type function
1632
- * @date 8/04/2014
1633
- * @since 5.0.0
1634
- *
1635
- * @param $field
1636
- * @return n/a
1637
- */
1638
-
1639
- render_field: function( $field ){
1640
-
1641
- // reference
1642
- var self = this;
1643
-
1644
-
1645
- // vars
1646
- var key = $field.attr('data-key');
1647
- var $lists = $field.parents('.acf-field-list');
1648
- var $tr = $field.find('.acf-field-setting-conditional_logic:last');
1649
-
1650
-
1651
- // choices
1652
- var choices = [];
1653
-
1654
-
1655
- // loop over ancestor lists
1656
- $.each( $lists, function( i ){
1657
-
1658
- // vars
1659
- var group = (i == 0) ? acf._e('sibling_fields') : acf._e('parent_fields');
1660
-
1661
-
1662
- // loop over fields
1663
- $(this).children('.acf-field-object').each(function(){
1664
-
1665
- // vars
1666
- var $this_field = $(this),
1667
- this_key = $this_field.attr('data-key'),
1668
- this_type = $this_field.attr('data-type'),
1669
- this_label = $this_field.find('.field-label:first').val();
1670
-
1671
-
1672
- // validate
1673
- if( $.inArray(this_type, ['select', 'checkbox', 'true_false', 'radio', 'button_group']) === -1 ) {
1674
-
1675
- return;
1676
-
1677
- } else if( this_key == key ) {
1678
-
1679
- return;
1680
-
1681
- }
1682
-
1683
-
1684
- // add this field to available triggers
1685
- choices.push({
1686
- value: this_key,
1687
- label: this_label,
1688
- group: group
1689
- });
1690
-
1691
- });
1692
-
1693
- });
1694
-
1695
-
1696
- // empty?
1697
- if( !choices.length ) {
1698
-
1699
- choices.push({
1700
- value: '',
1701
- label: acf._e('no_fields')
1702
- });
1703
-
1704
- }
1705
-
1706
-
1707
- // create select fields
1708
- $tr.find('.rule').each(function(){
1709
-
1710
- self.render_rule( $(this), choices );
1711
-
1712
- });
1713
-
1714
- },
1715
-
1716
-
1717
- /*
1718
- * populate_triggers
1719
- *
1720
- * description
1721
- *
1722
- * @type function
1723
- * @date 22/08/2015
1724
- * @since 5.2.3
1725
- *
1726
- * @param $post_id (int)
1727
- * @return $post_id (int)
1728
- */
1729
-
1730
- render_rule: function( $tr, triggers ) {
1731
-
1732
- // vars
1733
- var $trigger = $tr.find('.conditional-rule-param'),
1734
- $value = $tr.find('.conditional-rule-value');
1735
-
1736
-
1737
- // populate triggers
1738
- if( triggers ) {
1739
-
1740
- acf.render_select( $trigger, triggers );
1741
-
1742
- }
1743
-
1744
-
1745
- // vars
1746
- var $field = $('.acf-field-object[data-key="' + $trigger.val() + '"]'),
1747
- field_type = $field.attr('data-type'),
1748
- choices = [];
1749
-
1750
-
1751
- // populate choices
1752
- if( field_type == "true_false" ) {
1753
-
1754
- choices.push({
1755
- 'value': 1,
1756
- 'label': acf._e('checked')
1757
- });
1758
-
1759
- // select
1760
- } else if( field_type == "select" || field_type == "checkbox" || field_type == "radio" || field_type == "button_group" ) {
1761
-
1762
- // vars
1763
- var lines = $field.find('.acf-field[data-name="choices"] textarea').val().split("\n");
1764
-
1765
- $.each(lines, function(i, line){
1766
-
1767
- // explode
1768
- line = line.split(':');
1769
-
1770
-
1771
- // default label to value
1772
- line[1] = line[1] || line[0];
1773
-
1774
-
1775
- // append
1776
- choices.push({
1777
- 'value': $.trim( line[0] ),
1778
- 'label': $.trim( line[1] )
1779
- });
1780
-
1781
- });
1782
-
1783
-
1784
- // allow null
1785
- var $allow_null = $field.find('.acf-field[data-name="allow_null"]');
1786
-
1787
- if( $allow_null.exists() ) {
1788
-
1789
- if( $allow_null.find('input:checked').val() == '1' ) {
1790
-
1791
- choices.unshift({
1792
- 'value': '',
1793
- 'label': acf._e('null')
1794
- });
1795
-
1796
- }
1797
-
1798
- }
1799
-
1800
- }
1801
-
1802
-
1803
- // update select
1804
- acf.render_select( $value, choices );
1805
-
1806
- },
1807
-
1808
-
1809
- /*
1810
- * change_toggle
1811
- *
1812
- * This function is triggered by changing the 'Conditional Logic' radio button
1813
- *
1814
- * @type function
1815
- * @date 8/04/2014
1816
- * @since 5.0.0
1817
- *
1818
- * @param $input
1819
- * @return n/a
1820
- */
1821
-
1822
- change_toggle: function( e ){
1823
-
1824
- // vars
1825
- var $input = e.$el,
1826
- checked = e.$el.prop('checked'),
1827
- $td = $input.closest('.acf-input');
1828
-
1829
-
1830
- if( checked ) {
1831
-
1832
- $td.find('.rule-groups').show();
1833
- $td.find('.rule-groups').find('[name]').prop('disabled', false);
1834
-
1835
- } else {
1836
-
1837
- $td.find('.rule-groups').hide();
1838
- $td.find('.rule-groups').find('[name]').prop('disabled', true);
1839
-
1840
- }
1841
-
1842
- },
1843
-
1844
-
1845
- /*
1846
- * change_trigger
1847
- *
1848
- * This function is triggered by changing a 'Conditional Logic' trigger
1849
- *
1850
- * @type function
1851
- * @date 8/04/2014
1852
- * @since 5.0.0
1853
- *
1854
- * @param $select
1855
- * @return n/a
1856
- */
1857
-
1858
- change_param: function( e ){
1859
-
1860
- // vars
1861
- var $rule = e.$el.closest('.rule');
1862
-
1863
-
1864
- // render
1865
- this.render_rule( $rule );
1866
-
1867
- },
1868
-
1869
-
1870
- /*
1871
- * add_rule
1872
- *
1873
- * This function will add a new rule below the specified $tr
1874
- *
1875
- * @type function
1876
- * @date 8/04/2014
1877
- * @since 5.0.0
1878
- *
1879
- * @param $tr
1880
- * @return n/a
1881
- */
1882
-
1883
- add_rule: function( e ){
1884
-
1885
- // vars
1886
- var $tr = e.$el.closest('tr');
1887
 
 
 
 
 
 
 
1888
 
1889
- // duplicate
1890
- $tr2 = acf.duplicate( $tr );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1891
 
 
 
1892
 
1893
- // save field
1894
- $tr2.find('select:first').trigger('change');
1895
-
1896
  },
1897
 
1898
-
1899
- /*
1900
- * remove_rule
1901
- *
1902
- * This function will remove the $tr and potentially the group
1903
- *
1904
- * @type function
1905
- * @date 8/04/2014
1906
- * @since 5.0.0
1907
- *
1908
- * @param $tr
1909
- * @return n/a
1910
- */
1911
-
1912
- remove_rule: function( e ){
1913
 
1914
  // vars
1915
- var $tr = e.$el.closest('tr');
1916
-
1917
-
1918
- // save field
1919
- $tr.find('select:first').trigger('change');
1920
-
1921
 
1922
- if( $tr.siblings('tr').length == 0 ) {
1923
-
1924
- // remove group
1925
- $tr.closest('.rule-group').remove();
1926
-
1927
  }
1928
 
1929
-
1930
- // remove tr
1931
- $tr.remove();
1932
-
1933
-
1934
- },
1935
-
1936
-
1937
- /*
1938
- * add_group
1939
- *
1940
- * This function will add a new rule group to the given $groups container
1941
- *
1942
- * @type function
1943
- * @date 8/04/2014
1944
- * @since 5.0.0
1945
- *
1946
- * @param $tr
1947
- * @return n/a
1948
- */
1949
-
1950
- add_group: function( e ){
1951
-
1952
- // vars
1953
- var $groups = e.$el.closest('.rule-groups'),
1954
- $group = $groups.find('.rule-group:last');
1955
-
1956
-
1957
- // duplicate
1958
- $group2 = acf.duplicate( $group );
1959
-
1960
-
1961
- // update h4
1962
- $group2.find('h4').text( acf._e('or') );
1963
-
1964
-
1965
- // remove all tr's except the first one
1966
- $group2.find('tr:not(:first)').remove();
1967
-
1968
-
1969
- // save field
1970
- $group2.find('select:first').trigger('change');
1971
-
1972
  }
1973
-
1974
  });
1975
 
 
 
 
1976
 
1977
- /*
1978
- * locations
1979
  *
1980
- * This model will handle location rule events
1981
  *
1982
- * @type function
1983
- * @date 19/08/2015
1984
- * @since 5.2.3
1985
  *
1986
- * @param $post_id (int)
1987
- * @return $post_id (int)
1988
  */
1989
 
1990
- acf.field_group.locations = acf.model.extend({
1991
-
1992
- events: {
1993
- 'click .add-location-rule': 'add_rule',
1994
- 'click .add-location-group': 'add_group',
1995
- 'click .remove-location-rule': 'remove_rule',
1996
- 'change .refresh-location-rule': 'change_rule'
1997
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1998
 
 
 
 
 
 
1999
 
2000
- /*
2001
- * add_rule
2002
- *
2003
- * This function will add a new rule below the specified $tr
2004
- *
2005
- * @type function
2006
- * @date 8/04/2014
2007
- * @since 5.0.0
2008
- *
2009
- * @param $tr
2010
- * @return n/a
2011
- */
2012
 
2013
- add_rule: function( e ){
2014
-
2015
- // vars
2016
- var $tr = e.$el.closest('tr');
2017
-
2018
-
2019
- // duplicate
2020
- $tr2 = acf.duplicate( $tr );
2021
-
2022
-
2023
- // action
2024
- //acf.do_action('add_location_rule', $tr2);
2025
-
2026
- },
2027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2028
 
2029
- /*
2030
- * remove_rule
2031
- *
2032
- * This function will remove the $tr and potentially the group
2033
- *
2034
- * @type function
2035
- * @date 8/04/2014
2036
- * @since 5.0.0
2037
- *
2038
- * @param $tr
2039
- * @return n/a
2040
- */
2041
 
2042
- remove_rule: function( e ){
2043
-
2044
- // vars
2045
- var $tr = e.$el.closest('tr');
2046
-
2047
-
2048
- // action
2049
- //acf.do_action('remove_location_rule', $tr);
2050
-
2051
-
2052
- // remove
2053
- if( $tr.siblings('tr').length == 0 ) {
2054
-
2055
- // remove group
2056
- $tr.closest('.rule-group').remove();
2057
-
2058
- } else {
2059
-
2060
- // remove tr
2061
- $tr.remove();
2062
-
2063
- }
2064
-
2065
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2066
 
 
 
 
2067
 
2068
- /*
2069
- * add_group
2070
- *
2071
- * This function will add a new rule group to the given $groups container
2072
- *
2073
- * @type function
2074
- * @date 8/04/2014
2075
- * @since 5.0.0
2076
- *
2077
- * @param $tr
2078
- * @return n/a
2079
- */
2080
-
2081
- add_group: function( e ){
2082
-
2083
- // vars
2084
- var $groups = e.$el.closest('.rule-groups'),
2085
- $group = $groups.find('.rule-group:last');
2086
-
2087
-
2088
- // duplicate
2089
- $group2 = acf.duplicate( $group );
2090
-
2091
-
2092
- // update h4
2093
- $group2.find('h4').text( acf._e('or') );
2094
-
2095
-
2096
- // remove all tr's except the first one
2097
- $group2.find('tr:not(:first)').remove();
2098
-
2099
 
2100
  // vars
2101
- //var $tr = $group2.find('tr');
2102
-
2103
 
2104
- // action
2105
- //acf.do_action('add_location_rule', $tr);
 
 
 
2106
 
 
 
2107
  },
2108
 
 
 
 
2109
 
2110
- /*
2111
- * change_rule
2112
- *
2113
- * This function is triggered when changing a location rule trigger
2114
- *
2115
- * @type function
2116
- * @date 8/04/2014
2117
- * @since 5.0.0
2118
- *
2119
- * @param $select
2120
- * @return n/a
2121
- */
2122
-
2123
- change_rule: function( e ){
2124
-
2125
- // vars
2126
- var $rule = e.$el.closest('tr');
2127
- var $group = $rule.closest('.rule-group');
2128
- var prefix = $rule.find('td.param select').attr('name').replace('[param]', '');
2129
-
2130
-
2131
- // ajax data
2132
- var ajaxdata = {
2133
- action: 'acf/field_group/render_location_rule',
2134
- rule: acf.serialize( $rule, prefix ),
2135
- };
2136
-
2137
-
2138
- // append to data
2139
- ajaxdata.rule.id = $rule.attr('data-id');
2140
- ajaxdata.rule.group = $group.attr('data-id');
2141
-
2142
-
2143
- // ajax
2144
- $.ajax({
2145
- url: acf.get('ajaxurl'),
2146
- data: acf.prepare_for_ajax(ajaxdata),
2147
- type: 'post',
2148
- dataType: 'html',
2149
- success: function( html ){
2150
-
2151
- // bail early if no html
2152
- if( !html ) return;
2153
-
2154
-
2155
- // update
2156
- $rule.replaceWith( html );
2157
-
2158
-
2159
- // action
2160
- //acf.do_action('change_location_rule', $rule);
2161
 
2162
- }
2163
- });
2164
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2165
  }
2166
  });
2167
 
 
 
 
 
 
 
 
 
 
 
 
 
2168
 
2169
  /*
2170
- * field
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2171
  *
2172
- * This model sets up many of the field's interactions
2173
  *
2174
- * @type function
2175
- * @date 21/02/2014
2176
- * @since 3.5.1
2177
  *
2178
- * @param n/a
2179
- * @return n/a
2180
  */
2181
 
2182
- acf.field_group.field_object = acf.model.extend({
 
 
 
 
 
 
 
 
 
 
 
2183
 
2184
- // vars
2185
- type: '',
2186
- o: {},
2187
- $field: null,
2188
- $settings: null,
2189
 
2190
- tag: function( tag ) {
2191
-
2192
- // vars
2193
- var type = this.type;
2194
-
2195
-
2196
- // explode, add 'field' and implode
2197
- // - open => open_field
2198
- // - change_type => change_field_type
2199
- var tags = tag.split('_');
2200
- tags.splice(1, 0, 'field');
2201
- tag = tags.join('_');
2202
-
2203
-
2204
- // add type
2205
- if( type ) {
2206
- tag += '/type=' + type;
2207
- }
2208
-
2209
-
2210
- // return
2211
- return tag;
2212
-
2213
  },
2214
 
2215
- selector: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2216
 
2217
- // vars
2218
- var selector = '.acf-field-object';
2219
- var type = this.type;
 
2220
 
2221
-
2222
- // add type
2223
- if( type ) {
2224
- selector += '-' + type;
2225
- selector = acf.str_replace('_', '-', selector);
2226
  }
2227
-
2228
-
2229
- // return
2230
- return selector;
2231
-
2232
  },
2233
 
2234
- _add_action: function( name, callback ) {
2235
 
2236
  // vars
2237
- var model = this;
2238
-
2239
 
2240
- // add action
2241
- acf.add_action( this.tag(name), function( $field ){
2242
-
2243
- // focus
2244
- model.set('$field', $field);
2245
-
2246
-
2247
- // callback
2248
- model[ callback ].apply(model, arguments);
2249
-
2250
  });
2251
-
2252
  },
2253
 
2254
- _add_filter: function( name, callback ) {
 
 
 
 
 
 
 
2255
 
2256
  // vars
2257
- var model = this;
2258
-
 
 
2259
 
2260
- // add action
2261
- acf.add_filter( this.tag(name), function( $field ){
2262
 
2263
- // focus
2264
- model.set('$field', $field);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2265
 
 
 
 
 
2266
 
2267
- // callback
2268
- model[ callback ].apply(model, arguments);
 
2269
 
 
 
2270
  });
2271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2272
  },
2273
 
2274
- _add_event: function( name, callback ) {
 
 
 
 
 
2275
 
2276
  // vars
2277
- var model = this;
2278
- var event = name.substr(0,name.indexOf(' '));
2279
- var selector = name.substr(name.indexOf(' ')+1);
2280
- var context = this.selector();
 
 
 
 
 
 
 
 
2281
 
 
 
 
2282
 
2283
- // add event
2284
- $(document).on(event, context + ' ' + selector, function( e ){
2285
-
2286
- // append $el to event object
2287
- e.$el = $(this);
2288
- e.$field = e.$el.closest('.acf-field-object');
2289
-
2290
-
2291
- // focus
2292
- model.set('$field', e.$field);
2293
-
2294
-
2295
- // callback
2296
- model[ callback ].apply(model, [e]);
2297
-
2298
  });
2299
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2300
  },
2301
 
2302
- _set_$field: function(){
 
 
 
 
 
2303
 
2304
  // vars
2305
- this.o = this.$field.data();
 
 
 
 
 
 
 
 
 
 
 
 
2306
 
 
 
 
2307
 
2308
- // els
2309
- this.$settings = this.$field.find('> .settings > table > tbody');
 
 
2310
 
 
 
 
 
2311
 
2312
- // focus
2313
- this.focus();
 
2314
 
2315
- },
2316
-
2317
- focus: function(){
 
 
 
 
2318
 
2319
- // do nothing
 
 
 
2320
 
 
 
2321
  },
2322
 
2323
- setting: function( name ) {
2324
-
2325
- return this.$settings.find('> .acf-field-setting-' + name);
2326
-
2327
- }
2328
-
2329
- });
2330
-
2331
-
2332
- /*
2333
- * field
2334
- *
2335
- * This model fires actions and filters for registered fields
2336
- *
2337
- * @type function
2338
- * @date 21/02/2014
2339
- * @since 3.5.1
2340
- *
2341
- * @param n/a
2342
- * @return n/a
2343
- */
2344
-
2345
- acf.field_group.field_objects = acf.model.extend({
2346
-
2347
- actions: {
2348
- 'save_field' : '_save_field',
2349
- 'open_field' : '_open_field',
2350
- 'close_field' : '_close_field',
2351
- 'wipe_field' : '_wipe_field',
2352
- 'add_field' : '_add_field',
2353
- 'duplicate_field' : '_duplicate_field',
2354
- 'delete_field' : '_delete_field',
2355
- 'change_field_type' : '_change_field_type',
2356
- 'change_field_label' : '_change_field_label',
2357
- 'change_field_name' : '_change_field_name',
2358
- 'render_field_settings' : '_render_field_settings'
2359
  },
2360
 
2361
- _save_field: function( $el ){
2362
-
2363
- acf.do_action('save_field/type=' + $el.data('type'), $el);
2364
-
2365
  },
2366
 
2367
- _open_field: function( $el ){
2368
-
2369
- acf.do_action('open_field/type=' + $el.data('type'), $el);
2370
- acf.do_action('render_field_settings', $el);
2371
 
2372
- },
2373
-
2374
- _close_field: function( $el ){
2375
 
2376
- acf.do_action('close_field/type=' + $el.data('type'), $el);
 
2377
 
2378
- },
2379
-
2380
- _wipe_field: function( $el ){
2381
 
2382
- acf.do_action('wipe_field/type=' + $el.data('type'), $el);
 
2383
 
 
 
2384
  },
2385
 
2386
- _add_field: function( $el ){
2387
-
2388
- acf.do_action('add_field/type=' + $el.data('type'), $el);
2389
-
2390
  },
2391
 
2392
- _duplicate_field: function( $el ){
 
 
 
2393
 
2394
- acf.do_action('duplicate_field/type=' + $el.data('type'), $el);
 
2395
 
 
 
 
2396
  },
2397
 
2398
- _delete_field: function( $el ){
2399
 
2400
- acf.do_action('delete_field/type=' + $el.data('type'), $el);
 
2401
 
2402
- },
2403
-
2404
- _change_field_type: function( $el ){
2405
 
2406
- acf.do_action('change_field_type/type=' + $el.data('type'), $el);
2407
- acf.do_action('render_field_settings', $el);
2408
  },
2409
 
2410
- _change_field_label: function( $el ){
2411
 
2412
- acf.do_action('change_field_label/type=' + $el.data('type'), $el);
 
2413
 
 
 
2414
  },
2415
 
2416
- _change_field_name: function( $el ){
2417
 
2418
- acf.do_action('change_field_name/type=' + $el.data('type'), $el);
 
2419
 
2420
- },
2421
-
2422
- _render_field_settings: function( $el ){
2423
 
2424
- acf.do_action('render_field_settings/type=' + $el.data('type'), $el);
 
 
 
2425
 
 
 
2426
  }
2427
-
2428
  });
2429
 
 
2430
 
2431
 
2432
- /*
2433
- * Append
2434
  *
2435
- * This model handles all logic to append fields together
2436
  *
2437
- * @type function
2438
- * @date 12/02/2015
2439
- * @since 5.5.0
2440
  *
2441
- * @param n/a
2442
- * @return n/a
2443
  */
2444
 
2445
- acf.field_group.append = acf.model.extend({
2446
-
2447
  actions: {
2448
- 'render_field_settings' : '_render_field_settings'
2449
  },
2450
 
2451
- render: function( $el ){
2452
-
2453
- // vars
2454
- var append = $el.data('append');
2455
-
2456
-
2457
- // find sibling
2458
- $sibling = $el.siblings('[data-name="' + append + '"]');
2459
-
2460
-
2461
- // bail early if no sibling
2462
- if( !$sibling.exists() ) return;
2463
-
2464
 
2465
  // vars
2466
- var $wrap = $sibling.children('.acf-input'),
2467
- $ul = $wrap.children('.acf-hl');
2468
 
2469
-
2470
- // append ul if doesn't exist
2471
- if( !$ul.exists() ) {
2472
-
2473
- $wrap.wrapInner('<ul class="acf-hl"><li></li></ul>');
2474
 
2475
- $ul = $wrap.children('.acf-hl');
2476
-
2477
- }
2478
-
2479
-
2480
- // create $li
2481
- var $li = $('<li></li>').append( $el.children('.acf-input').children() );
2482
-
2483
-
2484
- // append $li
2485
- $ul.append( $li );
2486
-
2487
-
2488
- // update cols
2489
- $ul.attr('data-cols', $ul.children().length );
2490
-
2491
-
2492
- // remove
2493
- $el.remove();
2494
-
2495
- },
2496
-
2497
- _render_field_settings: function( $el ){
2498
-
2499
- // reference
2500
- var self = this;
2501
-
2502
-
2503
- // loop
2504
- $el.find('.acf-field[data-append]').each(function(){
2505
 
2506
- self.render( $(this) );
2507
-
2508
  });
2509
 
2510
- }
2511
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2512
  });
 
 
 
2513
 
 
 
 
 
 
 
 
 
 
 
 
2514
 
 
 
 
 
 
 
2515
 
2516
- /*
2517
- * Select
2518
  *
2519
- * This field type requires some extra logic for its settings
2520
  *
2521
- * @type function
2522
- * @date 24/10/13
2523
- * @since 5.0.0
2524
  *
2525
- * @param n/a
2526
- * @return n/a
2527
  */
2528
 
2529
- var acf_settings_select = acf.field_group.field_object.extend({
2530
 
2531
- type: 'select',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2532
 
2533
- actions: {
2534
- 'render_settings': 'render'
2535
- },
 
2536
 
2537
- events: {
2538
- 'change .acf-field-setting-ui input': 'render'
2539
- },
 
2540
 
2541
- render: function( $el ){
2542
-
2543
- // ui checked
2544
- if( this.setting('ui input[type="checkbox"]').prop('checked') ) {
2545
-
2546
- this.setting('ajax').show();
2547
-
2548
- // ui not checked
2549
- } else {
2550
-
2551
- this.setting('ajax').hide();
2552
- this.setting('ajax input[type="checkbox"]').prop('checked', false).trigger('change');
2553
-
2554
- }
2555
-
2556
- }
2557
 
2558
- });
 
 
 
2559
 
 
 
 
2560
 
2561
- /*
2562
- * Radio
2563
  *
2564
- * This field type requires some extra logic for its settings
2565
  *
2566
- * @type function
2567
- * @date 24/10/13
2568
- * @since 5.0.0
2569
  *
2570
- * @param n/a
2571
- * @return n/a
2572
  */
2573
 
2574
- var acf_settings_radio = acf.field_group.field_object.extend({
2575
 
2576
- type: 'radio',
 
 
 
2577
 
2578
- actions: {
2579
- 'render_settings': 'render'
2580
- },
 
 
2581
 
2582
- events: {
2583
- 'change .acf-field-setting-other_choice input': 'render'
2584
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2585
 
2586
- render: function( $el ){
2587
-
2588
- // other_choice checked
2589
- if( this.setting('other_choice input[type="checkbox"]').prop('checked') ) {
2590
-
2591
- this.setting('save_other_choice').show();
2592
-
2593
- // other_choice not checked
2594
- } else {
2595
-
2596
- this.setting('save_other_choice').hide();
2597
- this.setting('save_other_choice input[type="checkbox"]').prop('checked', false).trigger('change');
2598
-
2599
- }
2600
-
2601
- }
2602
 
2603
- });
2604
-
 
 
 
 
 
 
 
 
2605
 
2606
- /*
2607
- * Radio
2608
  *
2609
- * This field type requires some extra logic for its settings
2610
  *
2611
- * @type function
2612
- * @date 24/10/13
2613
- * @since 5.0.0
2614
  *
2615
- * @param n/a
2616
- * @return n/a
2617
  */
2618
 
2619
- var acf_settings_checkbox = acf.field_group.field_object.extend({
2620
 
2621
- type: 'checkbox',
 
2622
 
2623
- actions: {
2624
- 'render_settings': 'render'
2625
- },
2626
 
2627
- events: {
2628
- 'change .acf-field-setting-allow_custom input': 'render'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2629
  },
2630
 
2631
- render: function( $el ){
2632
 
2633
- // other_choice checked
2634
- if( this.setting('allow_custom input[type="checkbox"]').prop('checked') ) {
 
 
2635
 
2636
- this.setting('save_custom').show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2637
 
2638
- // other_choice not checked
2639
- } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2640
 
2641
- this.setting('save_custom').hide();
2642
- this.setting('save_custom input[type="checkbox"]').prop('checked', false).trigger('change');
2643
 
2644
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2645
 
2646
- }
2647
-
2648
- });
2649
-
 
 
 
2650
 
2651
- /*
2652
- * True false
2653
  *
2654
- * This field type requires some extra logic for its settings
2655
  *
2656
- * @type function
2657
- * @date 24/10/13
2658
- * @since 5.0.0
2659
  *
2660
- * @param n/a
2661
- * @return n/a
2662
  */
2663
 
2664
- var acf_settings_true_false = acf.field_group.field_object.extend({
2665
 
2666
- type: 'true_false',
2667
 
2668
- actions: {
2669
- 'render_settings': 'render'
 
 
2670
  },
2671
 
2672
- events: {
2673
- 'change .acf-field-setting-ui input': 'render'
 
 
 
 
2674
  },
2675
 
2676
- render: function( $el ){
2677
 
2678
- // ui checked
2679
- if( this.setting('ui input[type="checkbox"]').prop('checked') ) {
2680
 
2681
- this.setting('ui_on_text').show();
2682
- this.setting('ui_off_text').show();
 
 
 
 
 
 
 
 
 
2683
 
2684
- // ui not checked
2685
- } else {
2686
 
2687
- this.setting('ui_on_text').hide();
2688
- this.setting('ui_off_text').hide();
2689
-
2690
- }
2691
-
2692
- }
 
 
 
 
 
 
 
 
 
2693
 
2694
- });
 
 
2695
 
2696
-
2697
- /*
2698
- * Date Picker
2699
- *
2700
- * This field type requires some extra logic for its settings
2701
- *
2702
- * @type function
2703
- * @date 24/10/13
2704
- * @since 5.0.0
2705
- *
2706
- * @param n/a
2707
- * @return n/a
2708
- */
2709
-
2710
- var acf_settings_date_picker = acf.field_group.field_object.extend({
2711
 
2712
- type: 'date_picker',
 
 
 
 
 
 
2713
 
2714
- actions: {
2715
- 'render_settings': 'render'
 
2716
  },
2717
 
2718
- events: {
2719
- 'change .acf-field-setting-display_format input': 'render',
2720
- 'change .acf-field-setting-return_format input': 'render'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2721
  },
2722
 
2723
- render: function( $el ){
 
 
 
 
 
 
 
 
 
 
 
2724
 
2725
- this.render_list( this.setting('display_format') );
2726
- this.render_list( this.setting('return_format') );
2727
 
 
 
 
 
 
 
 
 
 
2728
  },
2729
 
2730
- render_list: function( $setting ){
2731
 
2732
  // vars
2733
- var $ul = $setting.find('ul'),
2734
- $radio = $ul.find('input[type="radio"]:checked'),
2735
- $other = $ul.find('input[type="text"]');
 
2736
 
 
 
 
 
 
 
 
 
 
2737
 
2738
- // display val
2739
- if( $radio.val() != 'other' ) {
2740
 
2741
- $other.val( $radio.val() );
2742
-
2743
- }
 
 
2744
 
2745
- }
2746
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2747
  });
2748
 
 
 
 
2749
 
2750
- /*
2751
- * Date Time Picker
2752
  *
2753
- * This field type requires some extra logic for its settings
2754
  *
2755
- * @type function
2756
- * @date 24/10/13
2757
- * @since 5.0.0
2758
  *
2759
- * @param n/a
2760
- * @return n/a
2761
  */
2762
 
2763
- var acf_settings_date_time_picker = acf_settings_date_picker.extend({
2764
 
2765
- type: 'date_time_picker'
 
2766
 
2767
- });
2768
-
2769
-
2770
- /*
2771
- * Time Picker
2772
- *
2773
- * This field type requires some extra logic for its settings
2774
- *
2775
- * @type function
2776
- * @date 24/10/13
2777
- * @since 5.0.0
2778
- *
2779
- * @param n/a
2780
- * @return n/a
2781
- */
2782
-
2783
- var acf_settings_date_time_picker = acf_settings_date_picker.extend({
2784
 
2785
- type: 'time_picker'
 
 
2786
 
2787
- });
2788
-
2789
-
2790
- /*
2791
- * tab
2792
- *
2793
- * description
2794
- *
2795
- * @type function
2796
- * @date 12/02/2015
2797
- * @since 5.1.5
2798
- *
2799
- * @param $post_id (int)
2800
- * @return $post_id (int)
2801
- */
2802
-
2803
- var acf_settings_tab = acf.field_group.field_object.extend({
2804
 
2805
- type: 'tab',
 
 
2806
 
2807
- actions: {
2808
- 'render_settings': 'render'
 
 
 
 
 
 
 
 
2809
  },
2810
 
2811
- render: function( $el ){
2812
 
2813
- // clear name
2814
- this.setting('name input').val('').trigger('change');
 
2815
 
 
 
 
 
 
 
2816
 
2817
- // clear required
2818
- this.setting('required input[type="checkbox"]').prop('checked', false).trigger('change');
2819
 
2820
- }
 
 
 
 
 
 
 
 
 
 
 
2821
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2822
  });
2823
 
 
 
 
 
 
2824
 
2825
- /*
2826
- * message
2827
  *
2828
- * description
2829
  *
2830
- * @type function
2831
- * @date 12/02/2015
2832
- * @since 5.1.5
2833
  *
2834
- * @param $post_id (int)
2835
- * @return $post_id (int)
2836
  */
2837
 
2838
- var acf_settings_message = acf_settings_tab.extend({
2839
 
2840
- type: 'message'
 
 
 
2841
 
2842
- });
2843
-
 
 
 
 
 
 
 
 
 
 
 
 
 
2844
 
2845
- /*
2846
- * screen
2847
  *
2848
- * description
2849
  *
2850
- * @type function
2851
- * @date 23/07/2015
2852
- * @since 5.2.3
2853
  *
2854
- * @param $post_id (int)
2855
- * @return $post_id (int)
2856
  */
2857
 
2858
- acf.field_group.screen = acf.model.extend({
2859
 
2860
- actions: {
2861
- 'ready': 'ready'
2862
- },
 
 
2863
 
2864
- events: {
2865
- 'click #acf-field-key-hide': 'toggle'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2866
  },
2867
 
2868
- ready: function(){
2869
 
2870
  // vars
2871
- var $el = $('#adv-settings'),
2872
- $append = $el.find('#acf-append-show-on-screen');
2873
-
2874
 
2875
- // append
2876
- $el.find('.metabox-prefs').append( $append.html() );
 
 
 
 
2877
 
2878
 
2879
- // move br
2880
- $el.find('.metabox-prefs br').remove();
2881
 
 
 
 
2882
 
2883
- // remove
2884
- $append.remove();
2885
 
2886
 
2887
- // render
2888
- this.render();
 
 
 
 
 
 
 
 
 
2889
 
2890
  },
2891
 
2892
- toggle: function( e ){
2893
 
2894
  // vars
2895
- var val = e.$el.prop('checked') ? 1 : 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
2896
 
 
 
 
2897
 
2898
- // update user setting
2899
- acf.update_user_setting('show_field_keys', val);
 
 
 
2900
 
2901
 
2902
- // render $fields
2903
- this.render();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2904
 
2905
  },
2906
 
2907
- render: function(){
2908
 
2909
  // vars
2910
- var options = acf.serialize( $('#adv-settings') );
 
2911
 
 
 
2912
 
2913
- // toggle class
2914
- var $fields = acf.field_group.$fields;
2915
 
 
 
 
 
 
 
2916
 
2917
- // show field keys
2918
- if( options.show_field_keys ) {
2919
 
2920
- $fields.addClass('show-field-keys');
 
 
2921
 
2922
- } else {
2923
-
2924
- $fields.removeClass('show-field-keys');
2925
-
2926
- }
2927
 
2928
  }
2929
 
@@ -2931,241 +2413,91 @@
2931
 
2932
 
2933
  /*
2934
- * sub fields
2935
  *
2936
- * description
2937
  *
2938
  * @type function
2939
- * @date 31/1/17
2940
- * @since 5.5.6
2941
  *
2942
- * @param $post_id (int)
2943
- * @return $post_id (int)
2944
  */
2945
 
2946
- acf.field_group.sub_fields = acf.model.extend({
2947
 
2948
  actions: {
2949
- 'open_field': 'update_field_parent',
2950
- 'sortstop': 'update_field_parent',
2951
- 'duplicate_field': 'duplicate_field',
2952
- 'delete_field': 'delete_field',
2953
- 'change_field_type': 'change_field_type'
2954
- },
2955
-
2956
-
2957
- /*
2958
- * fix_conditional_logic
2959
- *
2960
- * This function will update sub field conditional logic rules after duplication
2961
- *
2962
- * @type function
2963
- * @date 10/06/2014
2964
- * @since 5.0.0
2965
- *
2966
- * @param $fields (jquery selection)
2967
- * @return n/a
2968
- */
2969
-
2970
- fix_conditional_logic : function( $fields ){
2971
-
2972
- // build refernce
2973
- var ref = {};
2974
-
2975
- $fields.each(function(){
2976
-
2977
- ref[ $(this).attr('data-orig') ] = $(this).attr('data-key');
2978
-
2979
- });
2980
-
2981
-
2982
- $fields.find('.conditional-rule-param').each(function(){
2983
-
2984
- // vars
2985
- var key = $(this).val();
2986
-
2987
-
2988
- // bail early if val is not a ref key
2989
- if( !(key in ref) ) {
2990
-
2991
- return;
2992
-
2993
- }
2994
-
2995
-
2996
- // add option if doesn't yet exist
2997
- if( ! $(this).find('option[value="' + ref[key] + '"]').exists() ) {
2998
-
2999
- $(this).append('<option value="' + ref[key] + '">' + ref[key] + '</option>');
3000
-
3001
- }
3002
-
3003
-
3004
- // set new val
3005
- $(this).val( ref[key] );
3006
-
3007
- });
3008
-
3009
- },
3010
-
3011
-
3012
- /*
3013
- * update_field_parent
3014
- *
3015
- * This function will update field meta such as parent
3016
- *
3017
- * @type function
3018
- * @date 8/04/2014
3019
- * @since 5.0.0
3020
- *
3021
- * @param $el
3022
- * @return n/a
3023
- */
3024
-
3025
- update_field_parent: function( $el ){
3026
-
3027
- // bail early if not div.field (flexible content tr)
3028
- if( !$el.hasClass('acf-field-object') ) return;
3029
-
3030
-
3031
- // vars
3032
- var $parent = $el.parent().closest('.acf-field-object'),
3033
- val = acf.get('post_id');
3034
-
3035
-
3036
- // find parent
3037
- if( $parent.exists() ) {
3038
-
3039
- // set as parent ID
3040
- val = acf.field_group.get_field_meta( $parent, 'ID' );
3041
-
3042
-
3043
- // if parent is new, no ID exists
3044
- if( !val ) {
3045
-
3046
- val = acf.field_group.get_field_meta( $parent, 'key' );
3047
-
3048
- }
3049
-
3050
- }
3051
-
3052
-
3053
- // update parent
3054
- acf.field_group.update_field_meta( $el, 'parent', val );
3055
-
3056
-
3057
- // action for 3rd party customization
3058
- acf.do_action('update_field_parent', $el, $parent);
3059
-
3060
- },
3061
-
3062
-
3063
- /*
3064
- * duplicate_field
3065
- *
3066
- * This function is triggered when duplicating a field
3067
- *
3068
- * @type function
3069
- * @date 8/04/2014
3070
- * @since 5.0.0
3071
- *
3072
- * @param $el
3073
- * @return n/a
3074
- */
3075
-
3076
- duplicate_field: function( $el ) {
3077
-
3078
- // vars
3079
- var $fields = $el.find('.acf-field-object');
3080
-
3081
-
3082
- // bail early if $fields are empty
3083
- if( !$fields.exists() ) {
3084
-
3085
- return;
3086
-
3087
- }
3088
-
3089
 
3090
- // loop over sub fields
3091
- $fields.each(function(){
3092
-
3093
- // vars
3094
- var $parent = $(this).parent().closest('.acf-field-object'),
3095
- key = acf.field_group.get_field_meta( $parent, 'key');
3096
-
3097
-
3098
- // wipe field
3099
- acf.field_group.wipe_field( $(this) );
3100
-
3101
-
3102
- // update parent
3103
- acf.field_group.update_field_meta( $(this), 'parent', key );
3104
-
3105
-
3106
- // save field
3107
- acf.field_group.save_field( $(this) );
3108
-
3109
-
3110
- });
3111
-
3112
-
3113
- // fix conditional logic rules
3114
- this.fix_conditional_logic( $fields );
3115
-
3116
- },
3117
-
3118
-
3119
- /*
3120
- * delete_field
3121
- *
3122
- * This function is triggered when deleting a field
3123
- *
3124
- * @type function
3125
- * @date 8/04/2014
3126
- * @since 5.0.0
3127
- *
3128
- * @param $el
3129
- * @return n/a
3130
- */
3131
-
3132
- delete_field : function( $el ){
3133
-
3134
- $el.find('.acf-field-object').each(function(){
3135
-
3136
- acf.field_group.delete_field( $(this), false );
3137
-
3138
- });
3139
-
3140
- },
3141
-
3142
-
3143
- /*
3144
- * change_field_type
3145
- *
3146
- * This function is triggered when changing a field type
3147
- *
3148
- * @type function
3149
- * @date 7/06/2014
3150
- * @since 5.0.0
3151
- *
3152
- * @param $post_id (int)
3153
- * @return $post_id (int)
3154
- */
3155
-
3156
- change_field_type : function( $el ) {
3157
-
3158
- $el.find('.acf-field-object').each(function(){
3159
-
3160
- acf.field_group.delete_field( $(this), false );
3161
-
3162
- });
3163
 
3164
- }
 
 
 
 
 
 
 
 
 
 
 
 
3165
 
 
 
 
3166
  });
3167
 
3168
  })(jQuery);
3169
 
3170
  // @codekit-prepend "../js/field-group.js";
 
 
 
 
 
 
3171
 
1
+ (function($, undefined){
2
 
3
+ /**
4
+ * fieldGroupManager
5
+ *
6
+ * Generic field group functionality
7
+ *
8
+ * @date 15/12/17
9
+ * @since 5.7.0
10
+ *
11
+ * @param void
12
+ * @return void
13
+ */
14
+
15
+ var fieldGroupManager = new acf.Model({
16
 
17
+ id: 'fieldGroupManager',
 
 
 
18
 
19
+ events: {
20
+ 'submit #post': 'onSubmit',
21
+ 'click a[href="#"]': 'onClick',
22
+ 'click .submitdelete': 'onClickTrash',
23
  },
24
 
25
+ filters: {
26
+ 'find_fields_args': 'filterFindFieldArgs'
27
+ },
28
+
29
+ onSubmit: function( e, $el ){
30
+
31
+ // vars
32
+ var $title = $('#titlewrap #title');
33
+
34
+ // empty
35
+ if( !$title.val() ) {
36
+
37
+ // prevent default
38
+ e.preventDefault();
39
+
40
+ // unlock form
41
+ acf.validation.unlockForm( $el );
42
+
43
+ // alert
44
+ alert( acf.__('Field group title is required') );
45
+
46
+ // focus
47
+ $title.focus();
48
+ }
49
+ },
50
+
51
+ onClick: function( e ){
52
+ e.preventDefault();
53
+ },
54
+
55
+ onClickTrash: function( e ){
56
+ var result = confirm( acf.__('Move to trash. Are you sure?') );
57
+ if( !result ) {
58
+ e.preventDefault();
59
+ }
60
  },
61
 
62
+ filterFindFieldArgs: function( args ){
63
+ args.visible = true;
64
+ return args;
65
+ }
66
+ });
67
+
68
+
69
+ /**
70
+ * screenOptionsManager
71
+ *
72
+ * Screen options functionality
73
+ *
74
+ * @date 15/12/17
75
+ * @since 5.7.0
76
+ *
77
+ * @param void
78
+ * @return void
79
+ */
80
+
81
+ var screenOptionsManager = new acf.Model({
82
 
83
+ id: 'screenOptionsManager',
84
+ wait: 'prepare',
 
 
 
 
 
 
 
 
 
 
85
 
86
+ events: {
87
+ 'change': 'onChange'
88
+ },
89
+
90
+ initialize: function(){
91
+
92
+ // vars
93
+ var $div = $('#adv-settings');
94
+ var $append = $('#acf-append-show-on-screen');
95
+
96
+ // append
97
+ $div.find('.metabox-prefs').append( $append.html() );
98
+ $div.find('.metabox-prefs br').remove();
99
 
100
+ // clean up
101
+ $append.remove();
 
 
102
 
103
+ // initialize
104
+ this.$el = $('#acf-field-key-hide');
105
+ this.addEvents();
106
 
107
+ // render
108
+ this.render();
 
109
  },
110
 
111
+ isChecked: function(){
112
+ return this.$el.prop('checked');
113
+ },
114
 
115
+ onChange: function( e, $el ) {
116
+ var val = this.isChecked() ? 1 : 0;
117
+ acf.updateUserSetting('show_field_keys', val);
118
+ this.render();
119
+ },
 
 
 
 
 
 
 
 
120
 
121
+ render: function(){
122
+ if( this.isChecked() ) {
123
+ $('#acf-field-group-fields').addClass('show-field-keys');
124
+ } else {
125
+ $('#acf-field-group-fields').removeClass('show-field-keys');
 
 
126
  }
127
+ }
128
+
129
+ });
130
+
131
+
132
+ /**
133
+ * appendFieldManager
134
+ *
135
+ * Appends fields together
136
+ *
137
+ * @date 15/12/17
138
+ * @since 5.7.0
139
+ *
140
+ * @param void
141
+ * @return void
142
+ */
143
+
144
+ var appendFieldManager = new acf.Model({
145
+
146
+ actions: {
147
+ 'new_field' : 'onNewField'
148
+ },
149
+
150
+ onNewField: function( field ){
151
 
152
+ // bail ealry if not append
153
+ if( !field.has('append') ) return;
154
 
155
  // vars
156
+ var append = field.get('append');
157
+ var $sibling = field.$el.siblings('[data-name="' + append + '"]').first();
158
 
159
+ // bail early if no sibling
160
+ if( !$sibling.length ) return;
161
 
162
+ // ul
163
+ var $div = $sibling.children('.acf-input');
164
+ var $ul = $div.children('ul');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
+ // create ul
167
+ if( !$ul.length ) {
168
+ $div.wrapInner('<ul class="acf-hl"><li></li></ul>');
169
+ $ul = $div.children('ul');
170
+ }
171
+
172
+ // li
173
+ var html = field.$('.acf-input').html();
174
+ var $li = $('<li>' + html + '</li>');
175
+ $ul.append( $li );
176
+ $ul.attr('data-cols', $ul.children().length );
177
+
178
+ // clean up
179
+ field.remove();
180
+ }
181
+ });
182
+
183
+ })(jQuery);
184
+
185
+ (function($, undefined){
186
+
187
+ acf.FieldObject = acf.Model.extend({
188
 
189
+ // class used to avoid nested event triggers
190
+ eventScope: '.acf-field-object',
 
 
 
 
 
 
 
 
 
 
191
 
192
+ // events
193
+ events: {
194
+ 'click .edit-field': 'onClickEdit',
195
+ 'click .delete-field': 'onClickDelete',
196
+ 'click .duplicate-field': 'duplicate',
197
+ 'click .move-field': 'move',
198
 
199
+ 'change .field-type': 'onChangeType',
200
+ 'change .field-required': 'onChangeRequired',
201
+ 'blur .field-label': 'onChangeLabel',
202
+ 'blur .field-name': 'onChangeName',
203
 
204
+ 'change': 'onChange',
205
+ 'changed': 'onChanged',
206
  },
207
 
208
+ // data
209
+ data: {
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
+ // Similar to ID, but used for HTML puposes.
212
+ // It is possbile for a new field to have an ID of 0, but an id of 'field_123' */
213
+ id: 0,
214
 
215
+ // The field key ('field_123')
216
+ key: '',
217
 
218
+ // The field type (text, image, etc)
219
+ type: '',
220
 
221
+ // The $post->ID of this field
222
+ //ID: 0,
 
 
 
 
 
 
 
 
223
 
224
+ // The field's parent
225
+ //parent: 0,
226
 
227
+ // The menu order
228
+ //menu_order: 0
229
+ },
230
+
231
+ setup: function( $field ){
232
 
233
+ // set $el
234
+ this.$el = $field;
235
+
236
+ // inherit $field data (id, key, type)
237
+ this.inherit( $field );
238
 
239
+ // load additional props
240
+ // - this won't trigger 'changed'
241
+ this.prop('ID');
242
+ this.prop('parent');
243
+ this.prop('menu_order');
244
+ },
245
+
246
+ $input: function( name ){
247
+ return $('#' + this.getInputId() + '-' + name);
248
  },
249
 
250
+ $settings: function(){
251
+ return this.$('.acf-field-settings:first > .acf-field');
252
+ },
253
+
254
+ $setting: function( name ){
255
+ return this.$('.acf-field-settings:first > .acf-field-setting-' + name);
256
+ },
257
+
258
+ getParent: function(){
259
+ return acf.getFieldObjects({ child: this.$el, limit: 1 }).pop();
260
+ },
261
+
262
+ getParents: function(){
263
+ return acf.getFieldObjects({ child: this.$el });
264
+ },
265
+
266
+ getFields: function(){
267
+ return acf.getFieldObjects({ parent: this.$el });
268
+ },
269
+
270
+ getInputName: function(){
271
+ return 'acf_fields[' + this.get('id') + ']';
272
+ },
273
 
274
+ getInputId: function(){
275
+ return 'acf_fields-' + this.get('id');
276
+ },
 
 
 
 
 
 
 
 
 
277
 
278
+ newInput: function( name, value ){
279
 
280
+ // vars
281
+ var inputId = this.getInputId();
282
+ var inputName = this.getInputName();
283
 
284
+ // append name
285
+ if( name ) {
286
+ inputId += '-'+name;
287
+ inputName += '['+name+']';
288
+ }
289
 
290
+ // create input (avoid HTML + JSON value issues)
291
+ var $input = $('<input />').attr({
292
+ id: inputId,
293
+ name: inputName,
294
+ value: value
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  });
296
+ this.$('> .meta').append( $input );
297
 
298
+ // return
299
+ return $input;
300
  },
301
 
302
+ getProp: function( name ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
+ // check data
305
+ if( this.has(name) ) {
306
+ return this.get(name);
 
 
 
 
 
 
 
307
  }
308
 
309
+ // get input value
310
+ var $input = this.$input( name );
311
+ //console.log($input );
312
+ var value = $input.length ? $input.val() : null;
313
 
314
+ // set data silently (cache)
315
+ this.set(name, value, true);
316
 
317
+ // return
318
+ return value;
319
  },
320
 
321
+ setProp: function( name, value ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
 
323
+ // get input
324
+ var $input = this.$input( name );
325
+ var prevVal = $input.val();
326
 
327
+ // create if new
328
+ if( !$input.length ) {
329
+ $input = this.newInput( name, value );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  }
331
 
332
+ // remove
333
+ if( value === null ) {
334
+ $input.remove();
335
 
336
+ // update
337
+ } else {
338
+ $input.val( value );
339
  }
340
 
341
+ //console.log('setProp', name, value, this);
342
 
343
+ // set data silently (cache)
344
+ if( !this.has(name) ) {
345
+ //console.log('setting silently');
346
+ this.set(name, value, true);
 
 
 
 
 
347
 
348
+ // set data allowing 'change' event to fire
349
+ } else {
350
+ //console.log('setting loudly!');
351
+ this.set(name, value);
352
  }
353
 
354
+ // return
355
+ return this;
 
356
 
357
  },
358
 
359
+ prop: function( name, value ){
360
+ if( value !== undefined ) {
361
+ return this.setProp( name, value );
362
+ } else {
363
+ return this.getProp( name );
364
+ }
365
+ },
366
 
367
+ props: function( props ){
368
+ Object.keys( props ).map(function( key ){
369
+ this.setProp( key, props[key] );
370
+ }, this);
371
+ },
 
 
 
 
 
 
 
 
372
 
373
+ getLabel: function(){
374
 
375
+ // get label with empty default
376
+ var label = this.prop('label');
377
+ if( label === '' ) {
378
+ label = acf.__('(no label)')
 
 
 
 
 
 
 
 
379
  }
380
 
381
+ // return
382
+ return label;
 
 
 
 
 
 
383
  },
384
 
385
+ getName: function(){
386
+ return this.prop('name');
387
+ },
388
 
389
+ getType: function(){
390
+ return this.prop('type');
391
+ },
 
 
 
 
 
 
 
 
 
392
 
393
+ getTypeLabel: function(){
394
+ var type = this.prop('type');
395
+ var types = acf.get('fieldTypes');
396
+ return ( types[type] ) ? types[type].label : type;
397
+ },
398
+
399
+ getKey: function(){
400
+ return this.prop('key');
401
+ },
402
 
403
+ initialize: function(){
404
+ // do nothing
405
+ },
406
+
407
+ render: function(){
408
+
409
  // vars
410
+ var $handle = this.$('.handle:first');
411
+ var menu_order = this.prop('menu_order');
412
+ var label = this.getLabel();
413
+ var name = this.prop('name');
414
+ var type = this.getTypeLabel();
415
+ var key = this.prop('key');
416
+ var required = this.$input('required').prop('checked');
 
 
417
 
418
+ // update menu order
419
+ $handle.find('.acf-icon').html( parseInt(menu_order) + 1 );
420
 
421
+ // update required
422
+ if( required ) {
423
+ label += ' <span class="acf-required">*</span>';
 
 
424
  }
425
 
426
+ // update label
427
+ $handle.find('.li-field-label strong a').html( label );
428
+
429
+ // update name
430
+ $handle.find('.li-field-name').text( name );
431
 
432
+ // update type
433
+ $handle.find('.li-field-type').text( type );
434
 
435
+ // update key
436
+ $handle.find('.li-field-key').text( key );
437
 
438
  // action for 3rd party customization
439
+ acf.doAction('render_field_object', this);
440
+ },
441
+
442
+ refresh: function(){
443
+ acf.doAction('refresh_field_object', this);
444
  },
445
 
446
+ isOpen: function() {
447
+ return this.$el.hasClass('open');
448
+ },
449
 
450
+ onClickEdit: function( e ){
451
+ this.isOpen() ? this.close() : this.open();
452
+ },
 
 
 
 
 
 
 
 
 
453
 
454
+ open: function(){
455
 
456
+ // vars
457
+ var $settings = this.$el.children('.settings');
458
+
459
+ // open
460
+ $settings.slideDown();
461
+ this.$el.addClass('open');
462
 
463
+ // action (open)
464
+ acf.doAction('open_field_object', this);
465
+ this.trigger('openFieldObject');
466
+
467
+ // action (show)
468
+ acf.doAction('show', $settings);
469
+ },
470
+
471
+ close: function(){
472
 
473
  // vars
474
+ var $settings = this.$el.children('.settings');
475
 
476
+ // close
477
+ $settings.slideUp();
478
+ this.$el.removeClass('open');
479
 
480
+ // action (close)
481
+ acf.doAction('close_field_object', this);
482
+ this.trigger('closeFieldObject');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
 
484
+ // action (hide)
485
+ acf.doAction('hide', $settings);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  },
487
 
488
+ serialize: function(){
489
+ return acf.serialize( this.$el, this.getInputName() );
490
+ },
491
 
492
+ save: function( type ){
 
 
 
 
 
 
 
 
 
 
 
 
 
493
 
494
+ // defaults
495
+ type = type || 'settings'; // meta, settings
496
 
497
+ // vars
498
+ var save = this.getProp('save');
499
+
500
+ // bail if already saving settings
501
+ if( save === 'settings' ) {
502
+ return;
503
  }
504
 
505
+ // prop
506
+ this.setProp('save', type);
507
+
508
+ // debug
509
+ this.$el.attr('data-save', type);
510
+
511
+ // action
512
+ acf.doAction('save_field_object', this, type);
513
  },
514
 
515
+ submit: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
 
517
  // vars
518
+ var inputName = this.getInputName();
519
+ var save = this.get('save');
 
 
 
 
 
 
 
520
 
521
+ // close
522
+ if( this.isOpen() ) {
523
+ this.close();
524
+ }
525
 
526
+ // allow all inputs to save
527
+ if( save == 'settings' ) {
528
+ // do nothing
529
 
530
+ // allow only meta inputs to save
531
+ } else if( save == 'meta' ) {
532
+ this.$('> .settings [name^="' + inputName + '"]').remove();
533
 
534
+ // prevent all inputs from saving
535
+ } else {
536
+ this.$('[name^="' + inputName + '"]').remove();
537
  }
538
 
539
+ // action
540
+ acf.doAction('submit_field_object', this);
541
+ },
542
+
543
+ onChange: function( e, $el ){
544
 
545
+ // save settings
546
+ this.save();
 
 
 
 
 
547
 
548
  // action for 3rd party customization
549
+ acf.doAction('change_field_object', this);
 
550
  },
551
 
552
+ onChanged: function( e, $el, name, value ){
553
+
554
+ // ignore 'save'
555
+ if( name == 'save' ) {
556
+ return;
557
+ }
 
 
 
 
 
 
 
 
 
558
 
559
+ // save meta
560
+ if( ['menu_order', 'parent'].indexOf(name) > -1 ) {
561
+ this.save('meta');
562
 
563
+ // save field
 
564
  } else {
565
+ this.save();
566
+ }
567
 
568
+ // render
569
+ if( ['menu_order', 'label', 'required', 'name', 'type', 'key'].indexOf(name) > -1 ) {
570
+ this.render();
571
  }
572
+
573
+ // action for 3rd party customization
574
+ acf.doAction('change_field_object_' + name, this, value);
575
  },
576
 
577
+ onChangeLabel: function( e, $el ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
 
579
+ // set
580
+ var label = $el.val();
581
+ this.set('label', label);
582
 
583
+ // render name
584
+ if( this.prop('name') == '' ) {
585
+ var name = acf.applyFilters('generate_field_object_name', acf.strSanitize(label), this);
586
+ this.prop('name', name);
587
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
588
  },
589
 
590
+ onChangeName: function( e, $el){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
 
592
+ // set
593
+ var name = $el.val();
594
+ this.set('name', name);
595
 
596
+ // error
597
+ if( name.substr(0, 6) === 'field_' ) {
598
+ alert( acf.__('The string "field_" may not be used at the start of a field name') );
599
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
600
  },
601
 
602
+ onChangeRequired: function( e, $el ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
 
604
+ // set
605
+ var required = $el.prop('checked') ? 1 : 0;
606
+ this.set('required', required);
607
+ },
608
+
609
+ delete: function( args ){
610
 
611
+ // defaults
612
+ args = acf.parseArgs(args, {
613
+ animate: true
614
+ });
615
 
616
+ // add to remove list
617
+ var id = this.prop('ID');
 
 
618
 
619
+ if( id ) {
620
+ var $input = $('#_acf_delete_fields');
621
+ var newVal = $input.val() + '|' + id;
622
+ $input.val( newVal );
623
+ }
624
 
625
+ // action
626
+ acf.doAction('delete_field_object', this);
 
627
 
628
+ // animate
629
+ if( args.animate ) {
630
+ this.removeAnimate();
631
+ } else {
632
+ this.remove();
633
+ }
634
+ },
635
+
636
+ onClickDelete: function( e, $el ){
637
 
638
+ // add class
639
+ this.$el.addClass('-hover');
640
 
641
+ // add tooltip
642
+ var self = this;
643
+ var tooltip = acf.newTooltip({
644
+ confirmRemove: true,
645
+ target: $el,
646
+ confirm: function(){
647
+ self.delete( true );
648
+ },
649
+ cancel: function(){
650
+ self.$el.removeClass('-hover');
651
+ }
652
  });
653
+ },
654
+
655
+ removeAnimate: function(){
656
 
657
+ // vars
658
+ var field = this;
659
+ var $list = this.$el.parent();
660
+ var $fields = acf.findFieldObjects({
661
+ sibling: this.$el
662
  });
663
 
664
+ // remove
665
+ acf.remove({
666
+ target: this.$el,
667
+ endHeight: $fields.length ? 0 : 50,
668
+ complete: function(){
669
+ field.remove();
670
+ acf.doAction('removed_field_object', field, $list);
671
+ }
672
+ });
673
 
674
+ // action
675
+ acf.doAction('remove_field_object', field, $list);
 
 
 
 
 
 
 
 
 
676
  },
677
 
678
+ duplicate: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
679
 
680
+ // vars
681
+ var newKey = acf.uniqid('field_');
682
 
683
+ // duplicate
684
+ var $newField = acf.duplicate({
685
+ target: this.$el,
686
+ search: this.get('id'),
687
+ replace: newKey,
688
+ });
689
 
690
+ // set new key
691
+ $newField.attr('data-key', newKey);
692
 
693
+ // get instance
694
+ var newField = acf.getFieldObject( $newField );
 
695
 
696
+ // open / close
697
+ if( this.isOpen() ) {
698
+ this.close();
699
+ } else {
700
+ newField.open();
701
+ }
702
 
703
+ // focus label
704
+ var $label = newField.$setting('label input');
705
  setTimeout(function(){
 
706
  $label.focus();
 
707
  }, 251);
708
 
709
+ // update newField label / name
710
+ var label = newField.prop('label');
711
+ var name = newField.prop('name');
712
+ var end = name.split('_').pop();
713
+ var copy = acf.__('copy');
714
 
715
+ // increase suffix "1"
716
+ if( $.isNumeric(end) ) {
717
+ var i = (end*1) + 1;
718
+ label = label.replace( end, i );
719
+ name = name.replace( end, i );
720
 
721
+ // increase suffix "(copy1)"
722
+ } else if( end.indexOf(copy) === 0 ) {
723
+ var i = end.replace(copy, '') * 1;
724
+ i = i ? i+1 : 2;
725
+
726
+ // replace
727
+ label = label.replace( end, copy + i );
728
+ name = name.replace( end, copy + i );
729
 
730
+ // add default "(copy)"
731
+ } else {
732
+ label += ' (' + copy + ')';
733
+ name += '_' + copy;
734
+ }
 
 
735
 
736
+ newField.prop('ID', 0);
737
+ newField.prop('label', label);
738
+ newField.prop('name', name);
739
+ newField.prop('key', newKey);
740
 
741
+ // action
742
+ acf.doAction('duplicate_field_object', this, newField);
743
+ acf.doAction('append_field_object', newField);
744
  },
745
 
746
+ wipe: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
747
 
748
  // vars
749
+ var prevId = this.get('id');
750
+ var prevKey = this.get('key');
751
+ var newKey = acf.uniqid('field_');
752
+
753
+ // rename
754
+ acf.rename({
755
+ target: this.$el,
756
+ search: prevId,
757
+ replace: newKey,
758
+ });
 
 
 
 
 
 
 
 
 
 
759
 
760
+ // data
761
+ this.set('id', newKey);
762
+ this.set('prevId', prevId);
763
+ this.set('prevKey', prevKey);
764
 
765
+ // props
766
+ this.prop('key', newKey);
767
+ this.prop('ID', 0);
768
 
769
+ // attr
770
+ this.$el.attr('data-key', newKey);
771
+ this.$el.attr('data-id', newKey);
772
 
773
+ // action
774
+ acf.doAction('wipe_field_object', this);
775
+ },
776
+
777
+ move: function(){
778
 
779
+ // helper
780
+ var hasChanged = function( field ){
781
+ return (field.get('save') == 'settings');
782
+ };
783
 
784
+ // vars
785
+ var changed = hasChanged(this);
786
+
787
+ // has sub fields changed
788
+ if( !changed ) {
789
+ acf.getFieldObjects({
790
+ parent: this.$el
791
+ }).map(function( field ){
792
+ changed = hasChanged(field) || field.changed;
793
+ });
794
+ }
795
 
796
+ // bail early if changed
797
+ if( changed ) {
798
+ alert( acf.__('This field cannot be moved until its changes have been saved') );
799
+ return;
800
+ }
801
 
802
+ // step 1.
803
+ var id = this.prop('ID');
804
+ var field = this;
805
+ var popup = false;
806
+ var step1 = function(){
807
+
808
+ // popup
809
+ popup = acf.newPopup({
810
+ title: acf.__('Move Custom Field'),
811
+ loading: true,
812
+ width: '300px'
813
+ });
814
 
815
+ // ajax
816
+ var ajaxData = {
817
+ action: 'acf/field_group/move_field',
818
+ field_id: id
819
+ };
820
 
821
+ // get HTML
822
+ $.ajax({
823
+ url: acf.get('ajaxurl'),
824
+ data: acf.prepareForAjax(ajaxData),
825
+ type: 'post',
826
+ dataType: 'html',
827
+ success: step2
828
+ });
829
+ };
830
 
831
+ var step2 = function( html ){
 
832
 
833
+ // update popup
834
+ popup.loading(false);
835
+ popup.content(html);
836
 
837
+ // submit form
838
+ popup.on('submit', 'form', step3);
839
+ };
840
+
841
+ var step3 = function( e, $el ){
842
 
843
+ // prevent
844
+ e.preventDefault();
845
 
846
+ // disable
847
+ acf.startButtonLoading( popup.$('.button') );
848
 
849
+ // ajax
850
+ var ajaxData = {
851
+ action: 'acf/field_group/move_field',
852
+ field_id: id,
853
+ field_group_id: popup.$('select').val()
854
+ };
855
+
856
+ // get HTML
857
+ $.ajax({
858
+ url: acf.get('ajaxurl'),
859
+ data: acf.prepareForAjax(ajaxData),
860
+ type: 'post',
861
+ dataType: 'html',
862
+ success: step4
863
+ });
864
+ };
865
 
866
+ var step4 = function( html ){
867
+
868
+ // update popup
869
+ popup.content(html);
870
+
871
+ // remove element
872
+ field.removeAnimate();
873
+ };
874
 
875
+ // start
876
+ step1();
877
 
878
+ },
879
+
880
+ onChangeType: function( e, $el ){
881
 
882
+ // clea previous timout
883
+ if( this.changeTimeout ) {
884
+ clearTimeout(this.changeTimeout);
885
+ }
886
 
887
+ // set new timeout
888
+ // - prevents changing type multiple times whilst user types in newType
889
+ this.changeTimeout = this.setTimeout(function(){
890
+ this.changeType( $el.val() );
891
+ }, 300);
892
  },
893
 
894
+ changeType: function( newType ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
895
 
896
+ // vars
897
+ var prevType = this.prop('type');
898
+ var prevClass = acf.strSlugify( 'acf-field-object-' + prevType );
899
+ var newClass = acf.strSlugify( 'acf-field-object-' + newType );
900
 
901
+ // update props
902
+ this.$el.removeClass(prevClass).addClass(newClass);
903
+ this.$el.attr('data-type', newType);
904
+ this.$el.data('type', newType);
905
 
906
+ // abort XHR if this field is already loading AJAX data
907
+ if( this.has('xhr') ) {
908
+ this.get('xhr').abort();
909
+ }
 
910
 
911
+ // store settings
912
+ var $tbody = this.$('> .settings > table > tbody');
913
+ var $settings = $tbody.children('[data-setting="' + prevType + '"]');
914
+ this.set( 'settings-' + prevType, $settings );
915
+ $settings.detach();
916
+
917
+ // show settings
918
+ if( this.has('settings-' + newType) ) {
919
+ var $newSettings = this.get('settings-' + newType);
920
+ this.$setting('conditional_logic').before( $newSettings );
921
+ this.set('type', newType);
922
+ //this.refresh();
923
+ return;
924
+ }
925
 
926
+ // load settings
927
+ var $loading = $('<tr class="acf-field"><td class="acf-label"></td><td class="acf-input"><div class="acf-loading"></div></td></tr>');
928
+ this.$setting('conditional_logic').before( $loading );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
929
 
930
+ // ajax
931
+ var ajaxData = {
932
+ action: 'acf/field_group/render_field_settings',
933
+ field: this.serialize(),
934
+ prefix: this.getInputName()
935
+ };
936
 
937
+ // ajax
938
+ var xhr = $.ajax({
939
+ url: acf.get('ajaxurl'),
940
+ data: acf.prepareForAjax(ajaxData),
941
+ type: 'post',
942
+ dataType: 'html',
943
+ context: this,
944
+ success: function( html ){
945
+
946
+ // bail early if no settings
947
+ if( !html ) return;
948
+
949
+ // append settings
950
+ $loading.after( html );
951
+
952
+ // events
953
+ acf.doAction('append', $tbody);
954
+ },
955
+ complete: function(){
956
+ // also triggered by xhr.abort();
957
+ $loading.remove();
958
+ this.set('type', newType);
959
+ //this.refresh();
960
+ }
961
+ });
962
 
963
+ // set
964
+ this.set('xhr', xhr);
965
 
 
 
 
966
  },
967
 
968
+ updateParent: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
969
 
970
  // vars
971
+ var ID = acf.get('post_id');
 
 
 
 
 
972
 
973
+ // check parent
974
+ var parent = this.getParent();
975
+ if( parent ) {
976
+ ID = parent.prop('ID') || parent.prop('key');
 
977
  }
978
 
979
+ // update
980
+ this.prop('parent', ID);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
981
  }
982
+
983
  });
984
 
985
+ })(jQuery);
986
+
987
+ (function($, undefined){
988
 
989
+ /**
990
+ * mid
991
  *
992
+ * Calculates the model ID for a field type
993
  *
994
+ * @date 15/12/17
995
+ * @since 5.6.5
 
996
  *
997
+ * @param string type
998
+ * @return string
999
  */
1000
 
1001
+ var modelId = function( type ) {
1002
+ return acf.strPascalCase( type || '' ) + 'FieldSetting';
1003
+ };
1004
+
1005
+ /**
1006
+ * registerFieldType
1007
+ *
1008
+ * description
1009
+ *
1010
+ * @date 14/12/17
1011
+ * @since 5.6.5
1012
+ *
1013
+ * @param type $var Description. Default.
1014
+ * @return type Description.
1015
+ */
1016
+
1017
+ acf.registerFieldSetting = function( model ){
1018
+ var proto = model.prototype;
1019
+ var mid = modelId(proto.type + ' ' + proto.name);
1020
+ this.models[ mid ] = model;
1021
+ };
1022
+
1023
+ /**
1024
+ * newField
1025
+ *
1026
+ * description
1027
+ *
1028
+ * @date 14/12/17
1029
+ * @since 5.6.5
1030
+ *
1031
+ * @param type $var Description. Default.
1032
+ * @return type Description.
1033
+ */
1034
+
1035
+ acf.newFieldSetting = function( field ){
1036
 
1037
+ // vars
1038
+ var type = field.get('setting') || '';
1039
+ var name = field.get('name') || '';
1040
+ var mid = modelId( type + ' ' + name );
1041
+ var model = acf.models[ mid ] || null;
1042
 
1043
+ // bail ealry if no setting
1044
+ if( model === null ) return false;
 
 
 
 
 
 
 
 
 
 
1045
 
1046
+ // instantiate
1047
+ var setting = new model( field );
 
 
 
 
 
 
 
 
 
 
 
 
1048
 
1049
+ // return
1050
+ return setting;
1051
+ };
1052
+
1053
+ /**
1054
+ * acf.getFieldSetting
1055
+ *
1056
+ * description
1057
+ *
1058
+ * @date 19/4/18
1059
+ * @since 5.6.9
1060
+ *
1061
+ * @param type $var Description. Default.
1062
+ * @return type Description.
1063
+ */
1064
+
1065
+ acf.getFieldSetting = function( field ) {
1066
 
1067
+ // allow jQuery
1068
+ if( field instanceof jQuery ) {
1069
+ field = acf.getField(field);
1070
+ }
 
 
 
 
 
 
 
 
1071
 
1072
+ // return
1073
+ return field.setting;
1074
+ };
1075
+
1076
+ /**
1077
+ * settingsManager
1078
+ *
1079
+ * description
1080
+ *
1081
+ * @date 6/1/18
1082
+ * @since 5.6.5
1083
+ *
1084
+ * @param type $var Description. Default.
1085
+ * @return type Description.
1086
+ */
1087
+
1088
+ var settingsManager = new acf.Model({
1089
+ actions: {
1090
+ 'new_field': 'onNewField'
 
 
 
 
1091
  },
1092
+ onNewField: function( field ){
1093
+ field.setting = acf.newFieldSetting( field );
1094
+ }
1095
+ });
1096
+
1097
+ /**
1098
+ * acf.FieldSetting
1099
+ *
1100
+ * description
1101
+ *
1102
+ * @date 6/1/18
1103
+ * @since 5.6.5
1104
+ *
1105
+ * @param type $var Description. Default.
1106
+ * @return type Description.
1107
+ */
1108
+
1109
+ acf.FieldSetting = acf.Model.extend({
1110
+
1111
+ field: false,
1112
+ type: '',
1113
+ name: '',
1114
+ wait: 'ready',
1115
+ eventScope: '.acf-field',
1116
 
1117
+ events: {
1118
+ 'change': 'render'
1119
+ },
1120
 
1121
+ setup: function( field ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1122
 
1123
  // vars
1124
+ var $field = field.$el;
 
1125
 
1126
+ // set props
1127
+ this.$el = $field;
1128
+ this.field = field;
1129
+ this.$fieldObject = $field.closest('.acf-field-object');
1130
+ this.fieldObject = acf.getFieldObject( this.$fieldObject );
1131
 
1132
+ // inherit data
1133
+ $.extend(this.data, field.data);
1134
  },
1135
 
1136
+ initialize: function(){
1137
+ this.render();
1138
+ },
1139
 
1140
+ render: function(){
1141
+ // do nothing
1142
+ }
1143
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1144
 
1145
+ /*
1146
+ * Date Picker
1147
+ *
1148
+ * This field type requires some extra logic for its settings
1149
+ *
1150
+ * @type function
1151
+ * @date 24/10/13
1152
+ * @since 5.0.0
1153
+ *
1154
+ * @param n/a
1155
+ * @return n/a
1156
+ */
1157
+
1158
+ var DisplayFormatFieldSetting = acf.FieldSetting.extend({
1159
+ type: '',
1160
+ name: '',
1161
+ render: function(){
1162
+ var $input = this.$('input[type="radio"]:checked');
1163
+ if( $input.val() != 'other' ) {
1164
+ this.$('input[type="text"]').val( $input.val() );
1165
+ }
1166
  }
1167
  });
1168
 
1169
+ var DatePickerDisplayFormatFieldSetting = DisplayFormatFieldSetting.extend({
1170
+ type: 'date_picker',
1171
+ name: 'display_format'
1172
+ });
1173
+
1174
+ var DatePickerReturnFormatFieldSetting = DisplayFormatFieldSetting.extend({
1175
+ type: 'date_picker',
1176
+ name: 'return_format'
1177
+ });
1178
+
1179
+ acf.registerFieldSetting( DatePickerDisplayFormatFieldSetting );
1180
+ acf.registerFieldSetting( DatePickerReturnFormatFieldSetting );
1181
 
1182
  /*
1183
+ * Date Time Picker
1184
+ *
1185
+ * This field type requires some extra logic for its settings
1186
+ *
1187
+ * @type function
1188
+ * @date 24/10/13
1189
+ * @since 5.0.0
1190
+ *
1191
+ * @param n/a
1192
+ * @return n/a
1193
+ */
1194
+
1195
+ var DateTimePickerDisplayFormatFieldSetting = DisplayFormatFieldSetting.extend({
1196
+ type: 'date_time_picker',
1197
+ name: 'display_format'
1198
+ });
1199
+
1200
+ var DateTimePickerReturnFormatFieldSetting = DisplayFormatFieldSetting.extend({
1201
+ type: 'date_time_picker',
1202
+ name: 'return_format'
1203
+ });
1204
+
1205
+ acf.registerFieldSetting( DateTimePickerDisplayFormatFieldSetting );
1206
+ acf.registerFieldSetting( DateTimePickerReturnFormatFieldSetting );
1207
+
1208
+ /*
1209
+ * Time Picker
1210
+ *
1211
+ * This field type requires some extra logic for its settings
1212
+ *
1213
+ * @type function
1214
+ * @date 24/10/13
1215
+ * @since 5.0.0
1216
+ *
1217
+ * @param n/a
1218
+ * @return n/a
1219
+ */
1220
+
1221
+ var TimePickerDisplayFormatFieldSetting = DisplayFormatFieldSetting.extend({
1222
+ type: 'time_picker',
1223
+ name: 'display_format'
1224
+ });
1225
+
1226
+ var TimePickerReturnFormatFieldSetting = DisplayFormatFieldSetting.extend({
1227
+ name: 'time_picker',
1228
+ name: 'return_format'
1229
+ });
1230
+
1231
+ acf.registerFieldSetting( TimePickerDisplayFormatFieldSetting );
1232
+ acf.registerFieldSetting( TimePickerReturnFormatFieldSetting );
1233
+
1234
+ })(jQuery);
1235
+
1236
+ (function($, undefined){
1237
+
1238
+ /**
1239
+ * ConditionalLogicFieldSetting
1240
  *
1241
+ * description
1242
  *
1243
+ * @date 3/2/18
1244
+ * @since 5.6.5
 
1245
  *
1246
+ * @param type $var Description. Default.
1247
+ * @return type Description.
1248
  */
1249
 
1250
+ var ConditionalLogicFieldSetting = acf.FieldSetting.extend({
1251
+ type: '',
1252
+ name: 'conditional_logic',
1253
+ events: {
1254
+ 'change .conditions-toggle': 'onChangeToggle',
1255
+ 'click .add-conditional-group': 'onClickAddGroup',
1256
+ 'focus .condition-rule-field': 'onFocusField',
1257
+ 'change .condition-rule-field': 'onChangeField',
1258
+ 'change .condition-rule-operator': 'onChangeOperator',
1259
+ 'click .add-conditional-rule': 'onClickAdd',
1260
+ 'click .remove-conditional-rule': 'onClickRemove'
1261
+ },
1262
 
1263
+ $rule: false,
 
 
 
 
1264
 
1265
+ scope: function( $rule ){
1266
+ this.$rule = $rule;
1267
+ return this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1268
  },
1269
 
1270
+ ruleData: function( name, value ){
1271
+ return this.$rule.data.apply( this.$rule, arguments );
1272
+ },
1273
+
1274
+ $input: function( name ){
1275
+ return this.$rule.find('.condition-rule-' + name);
1276
+ },
1277
+
1278
+ $td: function( name ){
1279
+ return this.$rule.find('td.' + name);
1280
+ },
1281
+
1282
+ $toggle: function(){
1283
+ return this.$('.conditions-toggle');
1284
+ },
1285
+
1286
+ $control: function(){
1287
+ return this.$('.rule-groups');
1288
+ },
1289
+
1290
+ $groups: function(){
1291
+ return this.$('.rule-group');
1292
+ },
1293
+
1294
+ $rules: function(){
1295
+ return this.$('.rule');
1296
+ },
1297
+
1298
+ open: function(){
1299
+ var $div = this.$control();
1300
+ $div.show();
1301
+ acf.enable( $div );
1302
+ },
1303
+
1304
+ close: function(){
1305
+ var $div = this.$control();
1306
+ $div.hide();
1307
+ acf.disable( $div );
1308
+ },
1309
+
1310
+ render: function(){
1311
 
1312
+ // show
1313
+ if( this.$toggle().prop('checked') ) {
1314
+ this.renderRules();
1315
+ this.open();
1316
 
1317
+ // hide
1318
+ } else {
1319
+ this.close();
 
 
1320
  }
 
 
 
 
 
1321
  },
1322
 
1323
+ renderRules: function(){
1324
 
1325
  // vars
1326
+ var self = this;
 
1327
 
1328
+ // loop
1329
+ this.$rules().each(function(){
1330
+ self.renderRule( $(this) );
 
 
 
 
 
 
 
1331
  });
 
1332
  },
1333
 
1334
+ renderRule: function( $rule ){
1335
+ this.scope( $rule );
1336
+ this.renderField();
1337
+ this.renderOperator();
1338
+ this.renderValue();
1339
+ },
1340
+
1341
+ renderField: function(){
1342
 
1343
  // vars
1344
+ var choices = [];
1345
+ var validFieldTypes = [];
1346
+ var cid = this.fieldObject.cid;
1347
+ var $select = this.$input('field');
1348
 
1349
+ // loop
1350
+ acf.getFieldObjects().map(function( fieldObject ){
1351
 
1352
+ // vars
1353
+ var choice = {
1354
+ id: fieldObject.getKey(),
1355
+ text: fieldObject.getLabel()
1356
+ };
1357
+
1358
+ // bail early if is self
1359
+ if( fieldObject.cid === cid ) {
1360
+ choice.text += acf.__('(this field)');
1361
+ choice.disabled = true;
1362
+ }
1363
+
1364
+ // get selected field conditions
1365
+ var conditionTypes = acf.getConditionTypes({
1366
+ fieldType: fieldObject.getType()
1367
+ });
1368
 
1369
+ // bail early if no types
1370
+ if( !conditionTypes.length ) {
1371
+ choice.disabled = true;
1372
+ }
1373
 
1374
+ // calulate indents
1375
+ var indents = fieldObject.getParents().length;
1376
+ choice.text = '- '.repeat(indents) + choice.text;
1377
 
1378
+ // append
1379
+ choices.push(choice);
1380
  });
1381
 
1382
+ // allow for scenario where only one field exists
1383
+ if( !choices.length ) {
1384
+ choices.push({
1385
+ id: '',
1386
+ text: acf.__('No toggle fields available'),
1387
+ });
1388
+ }
1389
+
1390
+ // render
1391
+ acf.renderSelect( $select, choices );
1392
+
1393
+ // set
1394
+ this.ruleData('field', $select.val());
1395
  },
1396
 
1397
+ renderOperator: function(){
1398
+
1399
+ // bail early if no field selected
1400
+ if( !this.ruleData('field') ) {
1401
+ return;
1402
+ }
1403
 
1404
  // vars
1405
+ var $select = this.$input('operator');
1406
+ var val = $select.val();
1407
+ var choices = [];
1408
+
1409
+ // set saved value on first render
1410
+ // - this allows the 2nd render to correctly select an option
1411
+ if( $select.val() === null ) {
1412
+ acf.renderSelect($select, [{
1413
+ id: this.ruleData('operator'),
1414
+ text: ''
1415
+ }]);
1416
+ }
1417
 
1418
+ // get selected field
1419
+ var $field = acf.findFieldObject( this.ruleData('field') );
1420
+ var field = acf.getFieldObject( $field );
1421
 
1422
+ // get selected field conditions
1423
+ var conditionTypes = acf.getConditionTypes({
1424
+ fieldType: field.getType()
 
 
 
 
 
 
 
 
 
 
 
 
1425
  });
1426
 
1427
+ // html
1428
+ conditionTypes.map(function( model ){
1429
+ choices.push({
1430
+ id: model.prototype.operator,
1431
+ text: acf.strEscape(model.prototype.label)
1432
+ });
1433
+ });
1434
+
1435
+ // render
1436
+ acf.renderSelect( $select, choices );
1437
+
1438
+ // set
1439
+ this.ruleData('operator', $select.val());
1440
  },
1441
 
1442
+ renderValue: function(){
1443
+
1444
+ // bail early if no field selected
1445
+ if( !this.ruleData('field') || !this.ruleData('operator') ) {
1446
+ return;
1447
+ }
1448
 
1449
  // vars
1450
+ var $select = this.$input('value');
1451
+ var $td = this.$td('value');
1452
+ var val = $select.val();
1453
+
1454
+ // get selected field
1455
+ var $field = acf.findFieldObject( this.ruleData('field') );
1456
+ var field = acf.getFieldObject( $field );
1457
+
1458
+ // get selected field conditions
1459
+ var conditionTypes = acf.getConditionTypes({
1460
+ fieldType: field.getType(),
1461
+ operator: this.ruleData('operator')
1462
+ });
1463
 
1464
+ // html
1465
+ var conditionType = conditionTypes[0].prototype;
1466
+ var choices = conditionType.choices( field );
1467
 
1468
+ // create html: array
1469
+ if( choices instanceof Array ) {
1470
+ var $newSelect = $('<select></select>');
1471
+ acf.renderSelect( $newSelect, choices );
1472
 
1473
+ // create html: string (<input />)
1474
+ } else {
1475
+ var $newSelect = $(choices);
1476
+ }
1477
 
1478
+ // append
1479
+ $select.detach();
1480
+ $td.html( $newSelect );
1481
 
1482
+ // copy attrs
1483
+ // timeout needed to avoid browser bug where "disabled" attribute is not applied
1484
+ setTimeout(function(){
1485
+ ['class', 'name', 'id'].map(function( attr ){
1486
+ $newSelect.attr( attr, $select.attr(attr));
1487
+ });
1488
+ }, 0);
1489
 
1490
+ // select existing value (if not a disabled input)
1491
+ if( !$newSelect.prop('disabled') ) {
1492
+ acf.val( $newSelect, val, true );
1493
+ }
1494
 
1495
+ // set
1496
+ this.ruleData('value', $newSelect.val());
1497
  },
1498
 
1499
+ onChangeToggle: function(){
1500
+ this.render();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1501
  },
1502
 
1503
+ onClickAddGroup: function( e, $el ){
1504
+ this.addGroup();
 
 
1505
  },
1506
 
1507
+ addGroup: function(){
 
 
 
1508
 
1509
+ // vars
1510
+ var $group = this.$('.rule-group:last');
 
1511
 
1512
+ // duplicate
1513
+ var $group2 = acf.duplicate( $group );
1514
 
1515
+ // update h4
1516
+ $group2.find('h4').text( acf.__('or') );
 
1517
 
1518
+ // remove all tr's except the first one
1519
+ $group2.find('tr').not(':first').remove();
1520
 
1521
+ // save field
1522
+ this.fieldObject.save();
1523
  },
1524
 
1525
+ onFocusField: function( e, $el ){
1526
+ this.renderField();
 
 
1527
  },
1528
 
1529
+ onChangeField: function( e, $el ){
1530
+
1531
+ // scope
1532
+ this.scope( $el.closest('.rule') );
1533
 
1534
+ // set data
1535
+ this.ruleData('field', $el.val());
1536
 
1537
+ // render
1538
+ this.renderOperator();
1539
+ this.renderValue();
1540
  },
1541
 
1542
+ onChangeOperator: function( e, $el ){
1543
 
1544
+ // scope
1545
+ this.scope( $el.closest('.rule') );
1546
 
1547
+ // set data
1548
+ this.ruleData('operator', $el.val());
 
1549
 
1550
+ // render
1551
+ this.renderValue();
1552
  },
1553
 
1554
+ onClickAdd: function( e, $el ){
1555
 
1556
+ // duplciate
1557
+ var $rule = acf.duplicate( $el.closest('.rule') );
1558
 
1559
+ // render
1560
+ this.renderRule( $rule );
1561
  },
1562
 
1563
+ onClickRemove: function( e, $el ){
1564
 
1565
+ // vars
1566
+ var $rule = $el.closest('.rule');
1567
 
1568
+ // save field
1569
+ this.fieldObject.save();
 
1570
 
1571
+ // remove group
1572
+ if( $rule.siblings('.rule').length == 0 ) {
1573
+ $rule.closest('.rule-group').remove();
1574
+ }
1575
 
1576
+ // remove
1577
+ $rule.remove();
1578
  }
 
1579
  });
1580
 
1581
+ acf.registerFieldSetting( ConditionalLogicFieldSetting );
1582
 
1583
 
1584
+ /**
1585
+ * conditionalLogicHelper
1586
  *
1587
+ * description
1588
  *
1589
+ * @date 20/4/18
1590
+ * @since 5.6.9
 
1591
  *
1592
+ * @param type $var Description. Default.
1593
+ * @return type Description.
1594
  */
1595
 
1596
+ var conditionalLogicHelper = new acf.Model({
 
1597
  actions: {
1598
+ 'duplicate_field_objects': 'onDuplicateFieldObjects',
1599
  },
1600
 
1601
+ onDuplicateFieldObjects: function( children, newField, prevField ){
 
 
 
 
 
 
 
 
 
 
 
 
1602
 
1603
  // vars
1604
+ var data = {};
1605
+ var $selects = $();
1606
 
1607
+ // reference change in key
1608
+ children.map(function( child ){
 
 
 
1609
 
1610
+ // store reference of changed key
1611
+ data[ child.get('prevKey') ] = child.get('key');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1612
 
1613
+ // append condition select
1614
+ $selects = $selects.add( child.$('.condition-rule-field') );
1615
  });
1616
 
1617
+ // loop
1618
+ $selects.each(function(){
1619
+
1620
+ // vars
1621
+ var $select = $(this);
1622
+ var val = $select.val();
1623
+
1624
+ // bail early if val is not a ref key
1625
+ if( !val || !data[val] ) {
1626
+ return;
1627
+ }
1628
+
1629
+ // modify selected option
1630
+ $select.find('option:selected').attr('value', data[val]);
1631
+
1632
+ // set new val
1633
+ $select.val( data[val] );
1634
+
1635
+ });
1636
+ },
1637
  });
1638
+ })(jQuery);
1639
+
1640
+ (function($, undefined){
1641
 
1642
+ /**
1643
+ * acf.findFieldObject
1644
+ *
1645
+ * Returns a single fieldObject $el for a given field key
1646
+ *
1647
+ * @date 1/2/18
1648
+ * @since 5.7.0
1649
+ *
1650
+ * @param string key The field key
1651
+ * @return jQuery
1652
+ */
1653
 
1654
+ acf.findFieldObject = function( key ){
1655
+ return acf.findFieldObjects({
1656
+ key: key,
1657
+ limit: 1
1658
+ });
1659
+ };
1660
 
1661
+ /**
1662
+ * acf.findFieldObjects
1663
  *
1664
+ * Returns an array of fieldObject $el for the given args
1665
  *
1666
+ * @date 1/2/18
1667
+ * @since 5.7.0
 
1668
  *
1669
+ * @param object args
1670
+ * @return jQuery
1671
  */
1672
 
1673
+ acf.findFieldObjects = function( args ){
1674
 
1675
+ // vars
1676
+ args = args || {};
1677
+ var selector = '.acf-field-object';
1678
+ var $fields = false;
1679
+
1680
+ // args
1681
+ args = acf.parseArgs(args, {
1682
+ id: '',
1683
+ key: '',
1684
+ type: '',
1685
+ limit: false,
1686
+ list: null,
1687
+ parent: false,
1688
+ sibling: false,
1689
+ child: false,
1690
+ });
1691
+
1692
+ // id
1693
+ if( args.id ) {
1694
+ selector += '[data-id="' + args.id + '"]';
1695
+ }
1696
 
1697
+ // key
1698
+ if( args.key ) {
1699
+ selector += '[data-key="' + args.key + '"]';
1700
+ }
1701
 
1702
+ // type
1703
+ if( args.type ) {
1704
+ selector += '[data-type="' + args.type + '"]';
1705
+ }
1706
 
1707
+ // query
1708
+ if( args.list ) {
1709
+ $fields = args.list.children( selector );
1710
+ } else if( args.parent ) {
1711
+ $fields = args.parent.find( selector );
1712
+ } else if( args.sibling ) {
1713
+ $fields = args.sibling.siblings( selector );
1714
+ } else if( args.child ) {
1715
+ $fields = args.child.parents( selector );
1716
+ } else {
1717
+ $fields = $( selector );
1718
+ }
 
 
 
 
1719
 
1720
+ // limit
1721
+ if( args.limit ) {
1722
+ $fields = $fields.slice( 0, args.limit );
1723
+ }
1724
 
1725
+ // return
1726
+ return $fields;
1727
+ };
1728
 
1729
+ /**
1730
+ * acf.getFieldObject
1731
  *
1732
+ * Returns a single fieldObject instance for a given $el|key
1733
  *
1734
+ * @date 1/2/18
1735
+ * @since 5.7.0
 
1736
  *
1737
+ * @param string|jQuery $field The field $el or key
1738
+ * @return jQuery
1739
  */
1740
 
1741
+ acf.getFieldObject = function( $field ){
1742
 
1743
+ // allow key
1744
+ if( typeof $field === 'string' ) {
1745
+ $field = acf.findFieldObject( $field );
1746
+ }
1747
 
1748
+ // instantiate
1749
+ var field = $field.data('acf');
1750
+ if( !field ) {
1751
+ field = acf.newFieldObject( $field );
1752
+ }
1753
 
1754
+ // return
1755
+ return field;
1756
+ };
1757
+
1758
+ /**
1759
+ * acf.getFieldObjects
1760
+ *
1761
+ * Returns an array of fieldObject instances for the given args
1762
+ *
1763
+ * @date 1/2/18
1764
+ * @since 5.7.0
1765
+ *
1766
+ * @param object args
1767
+ * @return array
1768
+ */
1769
+
1770
+ acf.getFieldObjects = function( args ){
1771
 
1772
+ // query
1773
+ var $fields = acf.findFieldObjects( args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1774
 
1775
+ // loop
1776
+ var fields = [];
1777
+ $fields.each(function(){
1778
+ var field = acf.getFieldObject( $(this) );
1779
+ fields.push( field );
1780
+ });
1781
+
1782
+ // return
1783
+ return fields;
1784
+ };
1785
 
1786
+ /**
1787
+ * acf.newFieldObject
1788
  *
1789
+ * Initializes and returns a new FieldObject instance
1790
  *
1791
+ * @date 1/2/18
1792
+ * @since 5.7.0
 
1793
  *
1794
+ * @param jQuery $field The field $el
1795
+ * @return object
1796
  */
1797
 
1798
+ acf.newFieldObject = function( $field ){
1799
 
1800
+ // instantiate
1801
+ var field = new acf.FieldObject( $field );
1802
 
1803
+ // action
1804
+ acf.doAction('new_field_object', field);
 
1805
 
1806
+ // return
1807
+ return field;
1808
+ };
1809
+
1810
+ /**
1811
+ * actionManager
1812
+ *
1813
+ * description
1814
+ *
1815
+ * @date 15/12/17
1816
+ * @since 5.6.5
1817
+ *
1818
+ * @param type $var Description. Default.
1819
+ * @return type Description.
1820
+ */
1821
+
1822
+ var eventManager = new acf.Model({
1823
+
1824
+ priority: 5,
1825
+
1826
+ initialize: function(){
1827
+
1828
+ // actions
1829
+ var actions = [
1830
+ 'prepare',
1831
+ 'ready',
1832
+ 'append',
1833
+ 'remove'
1834
+ ];
1835
+
1836
+ // loop
1837
+ actions.map(function( action ){
1838
+ this.addFieldActions( action );
1839
+ }, this);
1840
  },
1841
 
1842
+ addFieldActions: function( action ){
1843
 
1844
+ // vars
1845
+ var pluralAction = action + '_field_objects'; // ready_field_objects
1846
+ var singleAction = action + '_field_object'; // ready_field_object
1847
+ var singleEvent = action + 'FieldObject'; // readyFieldObject
1848
 
1849
+ // global action
1850
+ var callback = function( $el /*, arg1, arg2, etc*/ ){
1851
+
1852
+ // vars
1853
+ var fieldObjects = acf.getFieldObjects({ parent: $el });
1854
+
1855
+ // call plural
1856
+ if( fieldObjects.length ) {
1857
+
1858
+ /// get args [$el, arg1]
1859
+ var args = acf.arrayArgs( arguments );
1860
+
1861
+ // modify args [pluralAction, fields, arg1]
1862
+ args.splice(0, 1, pluralAction, fieldObjects);
1863
+ acf.doAction.apply(null, args);
1864
+ }
1865
+ };
1866
 
1867
+ // plural action
1868
+ var pluralCallback = function( fieldObjects /*, arg1, arg2, etc*/ ){
1869
+
1870
+ /// get args [fields, arg1]
1871
+ var args = acf.arrayArgs( arguments );
1872
+
1873
+ // modify args [singleAction, fields, arg1]
1874
+ args.unshift(singleAction);
1875
+
1876
+ // loop
1877
+ fieldObjects.map(function( fieldObject ){
1878
+
1879
+ // modify args [singleAction, field, arg1]
1880
+ args[1] = fieldObject;
1881
+ acf.doAction.apply(null, args);
1882
+ });
1883
+ };
1884
 
1885
+ // single action
1886
+ var singleCallback = function( fieldObject /*, arg1, arg2, etc*/ ){
1887
 
1888
+ /// get args [$field, arg1]
1889
+ var args = acf.arrayArgs( arguments );
1890
+
1891
+ // modify args [singleAction, $field, arg1]
1892
+ args.unshift(singleAction);
1893
+
1894
+ // action variations (ready_field/type=image)
1895
+ var variations = ['type', 'name', 'key'];
1896
+ variations.map(function( variation ){
1897
+ args[0] = singleAction + '/' + variation + '=' + fieldObject.get(variation);
1898
+ acf.doAction.apply(null, args);
1899
+ });
1900
+
1901
+ // modify args [arg1]
1902
+ args.splice(0, 2);
1903
+
1904
+ // event
1905
+ fieldObject.trigger(singleEvent, args);
1906
+ };
1907
 
1908
+ // add actions
1909
+ acf.addAction(action, callback, 5);
1910
+ acf.addAction(pluralAction, pluralCallback, 5);
1911
+ acf.addAction(singleAction, singleCallback, 5);
1912
+
1913
+ }
1914
+ });
1915
 
1916
+ /**
1917
+ * fieldManager
1918
  *
1919
+ * description
1920
  *
1921
+ * @date 4/1/18
1922
+ * @since 5.6.5
 
1923
  *
1924
+ * @param type $var Description. Default.
1925
+ * @return type Description.
1926
  */
1927
 
1928
+ var fieldManager = new acf.Model({
1929
 
1930
+ id: 'fieldManager',
1931
 
1932
+ events: {
1933
+ 'submit #post': 'onSubmit',
1934
+ 'mouseenter .acf-field-list': 'onHoverSortable',
1935
+ 'click .add-field': 'onClickAdd',
1936
  },
1937
 
1938
+ actions: {
1939
+ 'removed_field_object': 'onRemovedField',
1940
+ 'sortstop_field_object': 'onReorderField',
1941
+ 'delete_field_object': 'onDeleteField',
1942
+ 'change_field_object_type': 'onChangeFieldType',
1943
+ 'duplicate_field_object': 'onDuplicateField'
1944
  },
1945
 
1946
+ onSubmit: function( e, $el ){
1947
 
1948
+ // vars
1949
+ var fields = acf.getFieldObjects();
1950
 
1951
+ // loop
1952
+ fields.map(function( field ){
1953
+ field.submit();
1954
+ });
1955
+ },
1956
+
1957
+ setFieldMenuOrder: function( field ){
1958
+ this.renderFields( field.$el.parent() );
1959
+ },
1960
+
1961
+ onHoverSortable: function( e, $el ){
1962
 
1963
+ // bail early if already sortable
1964
+ if( $el.hasClass('ui-sortable') ) return;
1965
 
1966
+ // sortable
1967
+ $el.sortable({
1968
+ handle: '.acf-sortable-handle',
1969
+ connectWith: '.acf-field-list',
1970
+ start: function( e, ui ){
1971
+ var field = acf.getFieldObject( ui.item );
1972
+ ui.placeholder.height( ui.item.height() );
1973
+ acf.doAction('sortstart_field_object', field, $el);
1974
+ },
1975
+ update: function( e, ui ){
1976
+ var field = acf.getFieldObject( ui.item );
1977
+ acf.doAction('sortstop_field_object', field, $el);
1978
+ }
1979
+ });
1980
+ },
1981
 
1982
+ onRemovedField: function( field, $list ){
1983
+ this.renderFields( $list );
1984
+ },
1985
 
1986
+ onReorderField: function( field, $list ){
1987
+ field.updateParent();
1988
+ this.renderFields( $list );
1989
+ },
 
 
 
 
 
 
 
 
 
 
 
1990
 
1991
+ onDeleteField: function( field ){
1992
+
1993
+ // delete children
1994
+ field.getFields().map(function( child ){
1995
+ child.delete({ animate: false });
1996
+ });
1997
+ },
1998
 
1999
+ onChangeFieldType: function( field ){
2000
+ // this caused sub fields to disapear if changing type back...
2001
+ //this.onDeleteField( field );
2002
  },
2003
 
2004
+ onDuplicateField: function( field, newField ){
2005
+
2006
+ // check for children
2007
+ var children = newField.getFields();
2008
+ if( children.length ) {
2009
+
2010
+ // loop
2011
+ children.map(function( child ){
2012
+
2013
+ // wipe field
2014
+ child.wipe();
2015
+
2016
+ // update parent
2017
+ child.updateParent();
2018
+ });
2019
+
2020
+ // action
2021
+ acf.doAction('duplicate_field_objects', children, newField, field);
2022
+ }
2023
+
2024
+ // set menu order
2025
+ this.setFieldMenuOrder( newField );
2026
  },
2027
 
2028
+ renderFields: function( $list ){
2029
+
2030
+ // vars
2031
+ var fields = acf.getFieldObjects({
2032
+ list: $list
2033
+ });
2034
+
2035
+ // no fields
2036
+ if( !fields.length ) {
2037
+ $list.addClass('-empty');
2038
+ return;
2039
+ }
2040
 
2041
+ // has fields
2042
+ $list.removeClass('-empty');
2043
 
2044
+ // prop
2045
+ fields.map(function( field, i ){
2046
+ field.prop('menu_order', i);
2047
+ });
2048
+ },
2049
+
2050
+ onClickAdd: function( e, $el ){
2051
+ var $list = $el.closest('.acf-tfoot').siblings('.acf-field-list');
2052
+ this.addField( $list );
2053
  },
2054
 
2055
+ addField: function( $list ){
2056
 
2057
  // vars
2058
+ var html = $('#tmpl-acf-field').html();
2059
+ var $el = $(html);
2060
+ var prevId = $el.data('id');
2061
+ var newKey = acf.uniqid('field_');
2062
 
2063
+ // duplicate
2064
+ var $newField = acf.duplicate({
2065
+ target: $el,
2066
+ search: prevId,
2067
+ replace: newKey,
2068
+ append: function( $el, $el2 ){
2069
+ $list.append( $el2 );
2070
+ }
2071
+ });
2072
 
2073
+ // get instance
2074
+ var newField = acf.getFieldObject( $newField );
2075
 
2076
+ // props
2077
+ newField.prop('key', newKey);
2078
+ newField.prop('ID', 0);
2079
+ newField.prop('label', '');
2080
+ newField.prop('name', '');
2081
 
2082
+ // attr
2083
+ $newField.attr('data-key', newKey);
2084
+ $newField.attr('data-id', newKey);
2085
+
2086
+ // update parent prop
2087
+ newField.updateParent();
2088
+
2089
+ // focus label
2090
+ var $label = newField.$input('label');
2091
+ setTimeout(function(){
2092
+ $label.focus();
2093
+ }, 251);
2094
+
2095
+ // open
2096
+ newField.open();
2097
+
2098
+ // set menu order
2099
+ this.renderFields( $list );
2100
+
2101
+ // action
2102
+ acf.doAction('add_field_object', newField);
2103
+ acf.doAction('append_field_object', newField);
2104
+ }
2105
  });
2106
 
2107
+ })(jQuery);
2108
+
2109
+ (function($, undefined){
2110
 
2111
+ /**
2112
+ * locationManager
2113
  *
2114
+ * Field group location rules functionality
2115
  *
2116
+ * @date 15/12/17
2117
+ * @since 5.7.0
 
2118
  *
2119
+ * @param void
2120
+ * @return void
2121
  */
2122
 
2123
+ var locationManager = new acf.Model({
2124
 
2125
+ id: 'locationManager',
2126
+ wait: 'ready',
2127
 
2128
+ events: {
2129
+ 'click .add-location-rule': 'onClickAddRule',
2130
+ 'click .add-location-group': 'onClickAddGroup',
2131
+ 'click .remove-location-rule': 'onClickRemoveRule',
2132
+ 'change .refresh-location-rule': 'onChangeRemoveRule'
2133
+ },
2134
+
2135
+ initialize: function(){
2136
+ this.$el = $('#acf-field-group-locations');
2137
+ },
 
 
 
 
 
 
 
2138
 
2139
+ onClickAddRule: function( e, $el ){
2140
+ this.addRule( $el.closest('tr') );
2141
+ },
2142
 
2143
+ onClickRemoveRule: function( e, $el ){
2144
+ this.removeRule( $el.closest('tr') );
2145
+ },
2146
+
2147
+ onChangeRemoveRule: function( e, $el ){
2148
+ this.changeRule( $el.closest('tr') );
2149
+ },
 
 
 
 
 
 
 
 
 
 
2150
 
2151
+ onClickAddGroup: function( e, $el ){
2152
+ this.addGroup();
2153
+ },
2154
 
2155
+ addRule: function( $tr ){
2156
+ acf.duplicate( $tr );
2157
+ },
2158
+
2159
+ removeRule: function( $tr ){
2160
+ if( $tr.siblings('tr').length == 0 ) {
2161
+ $tr.closest('.rule-group').remove();
2162
+ } else {
2163
+ $tr.remove();
2164
+ }
2165
  },
2166
 
2167
+ changeRule: function( $rule ){
2168
 
2169
+ // vars
2170
+ var $group = $rule.closest('.rule-group');
2171
+ var prefix = $rule.find('td.param select').attr('name').replace('[param]', '');
2172
 
2173
+ // ajaxdata
2174
+ var ajaxdata = {};
2175
+ ajaxdata.action = 'acf/field_group/render_location_rule';
2176
+ ajaxdata.rule = acf.serialize( $rule, prefix );
2177
+ ajaxdata.rule.id = $rule.data('id');
2178
+ ajaxdata.rule.group = $group.data('id');
2179
 
2180
+ // temp disable
2181
+ acf.disable( $rule.find('td.value') );
2182
 
2183
+ // ajax
2184
+ $.ajax({
2185
+ url: acf.get('ajaxurl'),
2186
+ data: acf.prepareForAjax(ajaxdata),
2187
+ type: 'post',
2188
+ dataType: 'html',
2189
+ success: function( html ){
2190
+ if( !html ) return;
2191
+ $rule.replaceWith( html );
2192
+ }
2193
+ });
2194
+ },
2195
 
2196
+ addGroup: function(){
2197
+
2198
+ // vars
2199
+ var $group = this.$('.rule-group:last');
2200
+
2201
+ // duplicate
2202
+ $group2 = acf.duplicate( $group );
2203
+
2204
+ // update h4
2205
+ $group2.find('h4').text( acf.__('or') );
2206
+
2207
+ // remove all tr's except the first one
2208
+ $group2.find('tr').not(':first').remove();
2209
+ }
2210
  });
2211
 
2212
+ })(jQuery);
2213
+
2214
+ (function($, undefined){
2215
+
2216
+ var _acf = acf.getCompatibility( acf );
2217
 
2218
+ /**
2219
+ * fieldGroupCompatibility
2220
  *
2221
+ * Compatibility layer for extinct acf.field_group
2222
  *
2223
+ * @date 15/12/17
2224
+ * @since 5.7.0
 
2225
  *
2226
+ * @param void
2227
+ * @return void
2228
  */
2229
 
2230
+ _acf.field_group = {
2231
 
2232
+ save_field: function( $field, type ){
2233
+ type = (type !== undefined) ? type : 'settings';
2234
+ acf.getFieldObject( $field ).save( type );
2235
+ },
2236
 
2237
+ delete_field: function( $field, animate ){
2238
+ animate = (animate !== undefined) ? animate : true;
2239
+ acf.getFieldObject( $field ).delete({
2240
+ animate: animate
2241
+ });
2242
+ },
2243
+
2244
+ update_field_meta: function( $field, name, value ){
2245
+ acf.getFieldObject( $field ).prop( name, value );
2246
+ },
2247
+
2248
+ delete_field_meta: function( $field, name ){
2249
+ acf.getFieldObject( $field ).prop( name, null );
2250
+ }
2251
+ };
2252
 
2253
+ /**
2254
+ * fieldGroupCompatibility.field_object
2255
  *
2256
+ * Compatibility layer for extinct acf.field_group.field_object
2257
  *
2258
+ * @date 15/12/17
2259
+ * @since 5.7.0
 
2260
  *
2261
+ * @param void
2262
+ * @return void
2263
  */
2264
 
2265
+ _acf.field_group.field_object = acf.model.extend({
2266
 
2267
+ // vars
2268
+ type: '',
2269
+ o: {},
2270
+ $field: null,
2271
+ $settings: null,
2272
 
2273
+ tag: function( tag ) {
2274
+
2275
+ // vars
2276
+ var type = this.type;
2277
+
2278
+
2279
+ // explode, add 'field' and implode
2280
+ // - open => open_field
2281
+ // - change_type => change_field_type
2282
+ var tags = tag.split('_');
2283
+ tags.splice(1, 0, 'field');
2284
+ tag = tags.join('_');
2285
+
2286
+
2287
+ // add type
2288
+ if( type ) {
2289
+ tag += '/type=' + type;
2290
+ }
2291
+
2292
+
2293
+ // return
2294
+ return tag;
2295
+
2296
  },
2297
 
2298
+ selector: function(){
2299
 
2300
  // vars
2301
+ var selector = '.acf-field-object';
2302
+ var type = this.type;
 
2303
 
2304
+
2305
+ // add type
2306
+ if( type ) {
2307
+ selector += '-' + type;
2308
+ selector = acf.str_replace('_', '-', selector);
2309
+ }
2310
 
2311
 
2312
+ // return
2313
+ return selector;
2314
 
2315
+ },
2316
+
2317
+ _add_action: function( name, callback ) {
2318
 
2319
+ // vars
2320
+ var model = this;
2321
 
2322
 
2323
+ // add action
2324
+ acf.add_action( this.tag(name), function( $field ){
2325
+
2326
+ // focus
2327
+ model.set('$field', $field);
2328
+
2329
+
2330
+ // callback
2331
+ model[ callback ].apply(model, arguments);
2332
+
2333
+ });
2334
 
2335
  },
2336
 
2337
+ _add_filter: function( name, callback ) {
2338
 
2339
  // vars
2340
+ var model = this;
2341
+
2342
+
2343
+ // add action
2344
+ acf.add_filter( this.tag(name), function( $field ){
2345
+
2346
+ // focus
2347
+ model.set('$field', $field);
2348
+
2349
+
2350
+ // callback
2351
+ model[ callback ].apply(model, arguments);
2352
+
2353
+ });
2354
 
2355
+ },
2356
+
2357
+ _add_event: function( name, callback ) {
2358
 
2359
+ // vars
2360
+ var model = this;
2361
+ var event = name.substr(0,name.indexOf(' '));
2362
+ var selector = name.substr(name.indexOf(' ')+1);
2363
+ var context = this.selector();
2364
 
2365
 
2366
+ // add event
2367
+ $(document).on(event, context + ' ' + selector, function( e ){
2368
+
2369
+ // append $el to event object
2370
+ e.$el = $(this);
2371
+ e.$field = e.$el.closest('.acf-field-object');
2372
+
2373
+
2374
+ // focus
2375
+ model.set('$field', e.$field);
2376
+
2377
+
2378
+ // callback
2379
+ model[ callback ].apply(model, [e]);
2380
+
2381
+ });
2382
 
2383
  },
2384
 
2385
+ _set_$field: function(){
2386
 
2387
  // vars
2388
+ this.o = this.$field.data();
2389
+
2390
 
2391
+ // els
2392
+ this.$settings = this.$field.find('> .settings > table > tbody');
2393
 
 
 
2394
 
2395
+ // focus
2396
+ this.focus();
2397
+
2398
+ },
2399
+
2400
+ focus: function(){
2401
 
2402
+ // do nothing
 
2403
 
2404
+ },
2405
+
2406
+ setting: function( name ) {
2407
 
2408
+ return this.$settings.find('> .acf-field-setting-' + name);
 
 
 
 
2409
 
2410
  }
2411
 
2413
 
2414
 
2415
  /*
2416
+ * field
2417
  *
2418
+ * This model fires actions and filters for registered fields
2419
  *
2420
  * @type function
2421
+ * @date 21/02/2014
2422
+ * @since 3.5.1
2423
  *
2424
+ * @param n/a
2425
+ * @return n/a
2426
  */
2427
 
2428
+ var actionManager = new acf.Model({
2429
 
2430
  actions: {
2431
+ 'open_field_object': 'onOpenFieldObject',
2432
+ 'close_field_object': 'onCloseFieldObject',
2433
+ 'add_field_object': 'onAddFieldObject',
2434
+ 'duplicate_field_object': 'onDuplicateFieldObject',
2435
+ 'delete_field_object': 'onDeleteFieldObject',
2436
+ 'change_field_object_type': 'onChangeFieldObjectType',
2437
+ 'change_field_object_label': 'onChangeFieldObjectLabel',
2438
+ 'change_field_object_name': 'onChangeFieldObjectName',
2439
+ 'change_field_object_parent': 'onChangeFieldObjectParent',
2440
+ 'sortstop_field_object': 'onChangeFieldObjectParent'
2441
+ },
2442
+
2443
+ onOpenFieldObject: function( field ){
2444
+ acf.doAction('open_field', field.$el);
2445
+ acf.doAction('open_field/type=' + field.get('type'), field.$el);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2446
 
2447
+ acf.doAction('render_field_settings', field.$el);
2448
+ acf.doAction('render_field_settings/type=' + field.get('type'), field.$el);
2449
+ },
2450
+
2451
+ onCloseFieldObject: function( field ){
2452
+ acf.doAction('close_field', field.$el);
2453
+ acf.doAction('close_field/type=' + field.get('type'), field.$el);
2454
+ },
2455
+
2456
+ onAddFieldObject: function( field ){
2457
+ acf.doAction('add_field', field.$el);
2458
+ acf.doAction('add_field/type=' + field.get('type'), field.$el);
2459
+ },
2460
+
2461
+ onDuplicateFieldObject: function( field ){
2462
+ acf.doAction('duplicate_field', field.$el);
2463
+ acf.doAction('duplicate_field/type=' + field.get('type'), field.$el);
2464
+ },
2465
+
2466
+ onDeleteFieldObject: function( field ){
2467
+ acf.doAction('delete_field', field.$el);
2468
+ acf.doAction('delete_field/type=' + field.get('type'), field.$el);
2469
+ },
2470
+
2471
+ onChangeFieldObjectType: function( field ){
2472
+ acf.doAction('change_field_type', field.$el);
2473
+ acf.doAction('change_field_type/type=' + field.get('type'), field.$el);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2474
 
2475
+ acf.doAction('render_field_settings', field.$el);
2476
+ acf.doAction('render_field_settings/type=' + field.get('type'), field.$el);
2477
+ },
2478
+
2479
+ onChangeFieldObjectLabel: function( field ){
2480
+ acf.doAction('change_field_label', field.$el);
2481
+ acf.doAction('change_field_label/type=' + field.get('type'), field.$el);
2482
+ },
2483
+
2484
+ onChangeFieldObjectName: function( field ){
2485
+ acf.doAction('change_field_name', field.$el);
2486
+ acf.doAction('change_field_name/type=' + field.get('type'), field.$el);
2487
+ },
2488
 
2489
+ onChangeFieldObjectParent: function( field ){
2490
+ acf.doAction('update_field_parent', field.$el);
2491
+ }
2492
  });
2493
 
2494
  })(jQuery);
2495
 
2496
  // @codekit-prepend "../js/field-group.js";
2497
+ // @codekit-prepend "../js/field-group-field.js";
2498
+ // @codekit-prepend "../js/field-group-settings.js";
2499
+ // @codekit-prepend "../js/field-group-conditions.js";
2500
+ // @codekit-prepend "../js/field-group-fields.js";
2501
+ // @codekit-prepend "../js/field-group-locations.js";
2502
+ // @codekit-prepend "../js/field-group-compatibility.js";
2503
 
assets/js/acf-field-group.min.js CHANGED
@@ -1 +1 @@
1
- !function($){acf.field_group=acf.model.extend({$fields:null,$locations:null,$options:null,actions:{ready:"init"},events:{"submit #post":"submit",'click a[href="#"]':"preventDefault","click .submitdelete":"trash","mouseenter .acf-field-list":"sortable"},init:function(){this.$fields=$("#acf-field-group-fields"),this.$locations=$("#acf-field-group-locations"),this.$options=$("#acf-field-group-options"),acf.validation.active=0},sortable:function(e){if(!e.$el.hasClass("ui-sortable")){var t=this;e.$el.sortable({handle:".acf-sortable-handle",connectWith:".acf-field-list",start:function(e,t){t.placeholder.height(t.item.height())},update:function(e,i){var a=i.item;t.render_fields(),acf.do_action("sortstop",a)}})}},preventDefault:function(e){e.preventDefault()},get_selector:function(e){e=e||"";var t=".acf-field-object";return e&&(t+="-"+e,t=t.split("_").join("-")),t},render_fields:function(){var e=this;$(".acf-field-list").each(function(){var t=$(this).children(".acf-field-object");t.each(function(t){e.update_field_meta($(this),"menu_order",t),$(this).children(".handle").find(".acf-icon").html(t+1)}),t.exists()?$(this).children(".no-fields-message").hide():$(this).children(".no-fields-message").show()})},get_field_meta:function(e,t){var i=e.find("> .meta > .input-"+t);return!!i.exists()&&i.val()},update_field_meta:function(e,t,i){var a=e.find("> .meta > .input-"+t);if(!a.exists()){var n=e.find("> .meta > .input-ID").outerHTML();n=acf.str_replace("ID",t,n),a=$(n),a.val(i),e.children(".meta").append(a)}a.val()!=i&&(a.val(i),"save"!=t&&this.save_field(e,"meta"))},delete_field_meta:function(e,t){var i=e.find("> .meta > .input-"+t);i.exists()&&(i.remove(),this.save_field(e,"meta"))},save_field:function(e,t){t=t||"settings";var i=this.get_field_meta(e,"save");"settings"!=i&&i!=t&&(this.update_field_meta(e,"save",t),acf.do_action("save_field",e,t))},submit:function(e){var t=this,i=$("#titlewrap #title");i.val()||(e.preventDefault(),acf.validation.toggle(e.$el,"unlock"),alert(acf._e("title_is_required")),i.focus()),$(".acf-field-object").each(function(){var e=t.get_field_meta($(this),"save"),i=t.get_field_meta($(this),"ID");$(this).hasClass("open")&&t.close_field($(this)),"settings"==e||("meta"==e?$(this).children(".settings").find('[name^="acf_fields['+i+']"]').remove():$(this).find('[name^="acf_fields['+i+']"]').remove())})},trash:function(e){confirm(acf._e("move_to_trash"))||e.preventDefault()},render_field:function(e){var t=e.find(".field-label:first").val(),i=e.find(".field-name:first").val(),a=e.find(".field-type:first option:selected").text(),n=e.find(".field-required:first").prop("checked"),d=e.children(".handle");d.find(".li-field-label strong a").html(t),d.find(".li-field-label .acf-required").remove(),n&&d.find(".li-field-label strong").append('<span class="acf-required">*</span>'),d.find(".li-field-name").text(i),d.find(".li-field-type").text(a),acf.do_action("render_field_handle",e,d)},edit_field:function(e){e.hasClass("open")?this.close_field(e):this.open_field(e)},open_field:function(e){if(e.hasClass("open"))return!1;e.addClass("open"),acf.do_action("open_field",e),e.children(".settings").animate({height:"toggle"},250)},close_field:function(e){if(!e.hasClass("open"))return!1;e.removeClass("open"),acf.do_action("close_field",e),e.children(".settings").animate({height:"toggle"},250)},wipe_field:function(e){var t=e.attr("data-id"),i=e.attr("data-key"),a=acf.get_uniqid(),n="field_"+a;e.attr("data-id",a),e.attr("data-key",n),e.attr("data-orig",i),this.update_field_meta(e,"ID",""),this.update_field_meta(e,"key",n),e.find('[id*="'+t+'"]').each(function(){$(this).attr("id",$(this).attr("id").replace(t,a))}),e.find('[name*="'+t+'"]').each(function(){$(this).attr("name",$(this).attr("name").replace(t,a))}),e.find("> .handle .pre-field-key").text(n),e.find(".ui-sortable").removeClass("ui-sortable"),acf.do_action("wipe_field",e)},add_field:function(e){var t=$($("#tmpl-acf-field").html()),i=t.find(".field-label:first"),a=t.find(".field-name:first");this.wipe_field(t),e.append(t),i.val(""),a.val(""),setTimeout(function(){i.focus()},251),this.render_fields(),acf.do_action("append",t),this.edit_field(t),acf.do_action("add_field",t)},duplicate_field:function(e){acf.do_action("before_duplicate",e);var t=e.clone(),i=t.find(".field-label:first"),a=t.find(".field-name:first");acf.do_action("remove",t),this.wipe_field(t),acf.do_action("after_duplicate",e,t),e.after(t),acf.do_action("append",t),setTimeout(function(){i.focus()},251),this.render_fields(),e.hasClass("open")?this.close_field(e):this.open_field(t);var n=i.val(),d=a.val(),l=d.split("_").pop(),f=acf._e("copy");if(0===l.indexOf(f)){var c=1*l.replace(f,"");c=c?c+1:2,n=n.replace(l,f+c),d=d.replace(l,f+c)}else n+=" ("+f+")",d+="_"+f;return i.val(n),a.val(d),this.save_field(t),this.render_field(t),acf.do_action("duplicate_field",t),t},move_field:function(e){var t=this,i=acf.prepare_for_ajax({action:"acf/field_group/move_field",field_id:this.get_field_meta(e,"ID")}),a=!1;if(i.field_id?"settings"==this.get_field_meta(e,"save")?a=!0:e.find(".acf-field-object").each(function(){if(!t.get_field_meta($(this),"ID"))return a=!0,!1;"settings"==t.get_field_meta($(this),"save")&&(a=!0)}):a=!0,a)return void alert(acf._e("move_field_warning"));acf.open_popup({title:acf._e("move_field"),loading:!0,height:145}),$.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"html",success:function(i){t.move_field_confirm(e,i)}})},move_field_confirm:function(e,t){var i=this;acf.update_popup({content:t});var a=acf.prepare_for_ajax({action:"acf/field_group/move_field",field_id:this.get_field_meta(e,"ID"),field_group_id:0});$("#acf-move-field-form").on("submit",function(){return a.field_group_id=$(this).find("select").val(),$.ajax({url:acf.get("ajaxurl"),data:a,type:"post",dataType:"html",success:function(t){acf.update_popup({content:t}),i.remove_field(e)}}),!1})},delete_field:function(e,t){t=t||!0;var i=this.get_field_meta(e,"ID");if(i){var a=$("#_acf_delete_fields");a.val(a.val()+"|"+i)}acf.do_action("delete_field",e),t&&this.remove_field(e)},remove_field:function(e){var t=this,i=e.closest(".acf-field-list");e.css({height:e.height(),width:e.width(),position:"absolute"}),e.wrap('<div class="temp-field-wrap" style="height:'+e.height()+'px"></div>'),e.animate({opacity:0},250);var a=0,n=!1;i.children(".acf-field-object").length||(n=i.children(".no-fields-message"),a=n.outerHeight()),e.parent(".temp-field-wrap").animate({height:a},250,function(){n&&n.show(),acf.do_action("remove",$(this)),$(this).remove(),t.render_fields()})},change_field_type:function(e){var t=e.closest("tbody"),i=t.closest(".acf-field-object"),a=i.parent().closest(".acf-field-object"),n=i.attr("data-key"),d=i.attr("data-type"),l=e.val();i.removeClass("acf-field-object-"+acf.str_replace("_","-",d)),i.addClass("acf-field-object-"+acf.str_replace("_","-",l)),i.attr("data-type",l),i.data("type",l),i.data("xhr")&&i.data("xhr").abort();var f=t.children('.acf-field[data-setting="'+d+'"]');if(acf.update(n+"_settings_"+d,f),f.detach(),this.render_field(i),$newettings=acf.get(n+"_settings_"+l),$newettings)return t.children('.acf-field[data-name="conditional_logic"]').before($newettings),acf.update(n+"_settings_"+l,!1),void acf.do_action("change_field_type",i);var c=$('<tr class="acf-field"><td class="acf-label"></td><td class="acf-input"><div class="acf-loading"></div></td></tr>');t.children('.acf-field[data-name="conditional_logic"]').before(c);var r={action:"acf/field_group/render_field_settings",nonce:acf.o.nonce,parent:acf.o.post_id,field_group:acf.o.post_id,prefix:e.attr("name").replace("[type]",""),type:l};a.exists()&&(r.parent=this.get_field_meta(a,"ID"));var o=$.ajax({url:acf.o.ajaxurl,data:r,type:"post",dataType:"html",success:function(e){if(e){var t=$(e);c.after(t),acf.do_action("append",t),acf.do_action("change_field_type",i)}},complete:function(){c.remove()}});i.data("xhr",o)},change_field_label:function(e){var t=e.find(".field-label:first"),i=e.find(".field-name:first"),a=e.attr("data-type");if(""==i.val()){var n=t.val();n=acf.str_sanitize(n),i.val(n).trigger("change")}this.render_field(e),acf.do_action("change_field_label",e)},change_field_name:function(e){var t=e.find(".field-name:first");"field_"===t.val().substr(0,6)&&(alert(acf._e("field_name_start")),setTimeout(function(){t.focus()},1)),acf.do_action("change_field_name",e)}}),acf.field_group.field=acf.model.extend({events:{"click .edit-field":"edit","click .duplicate-field":"duplicate","click .move-field":"move","click .delete-field":"delete","click .add-field":"add","change .field-type":"change_type","blur .field-label":"change_label","blur .field-name":"change_name","keyup .field-label":"render","keyup .field-name":"render","change .field-required":"render","change .acf-field-object input":"save","change .acf-field-object textarea":"save","change .acf-field-object select":"save"},event:function(e){return e.$field=e.$el.closest(".acf-field-object"),e},edit:function(e){acf.field_group.edit_field(e.$field)},duplicate:function(e){acf.field_group.duplicate_field(e.$field)},move:function(e){acf.field_group.move_field(e.$field)},delete:function(e){acf.field_group.delete_field(e.$field)},add:function(e){var t=e.$el.closest(".acf-field-list-wrap").children(".acf-field-list");acf.field_group.add_field(t)},change_type:function(e){acf.field_group.change_field_type(e.$el)},change_label:function(e){acf.field_group.change_field_label(e.$field)},change_name:function(e){acf.field_group.change_field_name(e.$field)},render:function(e){acf.field_group.render_field(e.$field)},save:function(e){acf.field_group.save_field(e.$field)}}),acf.field_group.conditional_logic=acf.model.extend({actions:{open_field:"render_field",change_field_label:"render_fields",change_field_type:"render_fields"},events:{"click .add-conditional-rule":"add_rule","click .add-conditional-group":"add_group","click .remove-conditional-rule":"remove_rule","change .conditional-toggle":"change_toggle","change .conditional-rule-param":"change_param"},render_fields:function(){var e=this;$(".acf-field-object.open").each(function(){e.render_field($(this))})},render_field:function(e){var t=this,i=e.attr("data-key"),a=e.parents(".acf-field-list"),n=e.find(".acf-field-setting-conditional_logic:last"),d=[];$.each(a,function(e){var t=0==e?acf._e("sibling_fields"):acf._e("parent_fields");$(this).children(".acf-field-object").each(function(){var e=$(this),a=e.attr("data-key"),n=e.attr("data-type"),l=e.find(".field-label:first").val();-1!==$.inArray(n,["select","checkbox","true_false","radio","button_group"])&&a!=i&&d.push({value:a,label:l,group:t})})}),d.length||d.push({value:"",label:acf._e("no_fields")}),n.find(".rule").each(function(){t.render_rule($(this),d)})},render_rule:function(e,t){var i=e.find(".conditional-rule-param"),a=e.find(".conditional-rule-value");t&&acf.render_select(i,t);var n=$('.acf-field-object[data-key="'+i.val()+'"]'),d=n.attr("data-type"),l=[];if("true_false"==d)l.push({value:1,label:acf._e("checked")});else if("select"==d||"checkbox"==d||"radio"==d||"button_group"==d){var f=n.find('.acf-field[data-name="choices"] textarea').val().split("\n");$.each(f,function(e,t){t=t.split(":"),t[1]=t[1]||t[0],l.push({value:$.trim(t[0]),label:$.trim(t[1])})});var c=n.find('.acf-field[data-name="allow_null"]');c.exists()&&"1"==c.find("input:checked").val()&&l.unshift({value:"",label:acf._e("null")})}acf.render_select(a,l)},change_toggle:function(e){var t=e.$el,i=e.$el.prop("checked"),a=t.closest(".acf-input");i?(a.find(".rule-groups").show(),a.find(".rule-groups").find("[name]").prop("disabled",!1)):(a.find(".rule-groups").hide(),a.find(".rule-groups").find("[name]").prop("disabled",!0))},change_param:function(e){var t=e.$el.closest(".rule");this.render_rule(t)},add_rule:function(e){var t=e.$el.closest("tr");$tr2=acf.duplicate(t),$tr2.find("select:first").trigger("change")},remove_rule:function(e){var t=e.$el.closest("tr");t.find("select:first").trigger("change"),0==t.siblings("tr").length&&t.closest(".rule-group").remove(),t.remove()},add_group:function(e){var t=e.$el.closest(".rule-groups"),i=t.find(".rule-group:last");$group2=acf.duplicate(i),$group2.find("h4").text(acf._e("or")),$group2.find("tr:not(:first)").remove(),$group2.find("select:first").trigger("change")}}),acf.field_group.locations=acf.model.extend({events:{"click .add-location-rule":"add_rule","click .add-location-group":"add_group","click .remove-location-rule":"remove_rule","change .refresh-location-rule":"change_rule"},add_rule:function(e){var t=e.$el.closest("tr");$tr2=acf.duplicate(t)},remove_rule:function(e){var t=e.$el.closest("tr");0==t.siblings("tr").length?t.closest(".rule-group").remove():t.remove()},add_group:function(e){var t=e.$el.closest(".rule-groups"),i=t.find(".rule-group:last");$group2=acf.duplicate(i),$group2.find("h4").text(acf._e("or")),$group2.find("tr:not(:first)").remove()},change_rule:function(e){var t=e.$el.closest("tr"),i=t.closest(".rule-group"),a=t.find("td.param select").attr("name").replace("[param]",""),n={action:"acf/field_group/render_location_rule",rule:acf.serialize(t,a)};n.rule.id=t.attr("data-id"),n.rule.group=i.attr("data-id"),$.ajax({url:acf.get("ajaxurl"),data:acf.prepare_for_ajax(n),type:"post",dataType:"html",success:function(e){e&&t.replaceWith(e)}})}}),acf.field_group.field_object=acf.model.extend({type:"",o:{},$field:null,$settings:null,tag:function(e){var t=this.type,i=e.split("_");return i.splice(1,0,"field"),e=i.join("_"),t&&(e+="/type="+t),e},selector:function(){var e=".acf-field-object",t=this.type;return t&&(e+="-"+t,e=acf.str_replace("_","-",e)),e},_add_action:function(e,t){var i=this;acf.add_action(this.tag(e),function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_filter:function(e,t){var i=this;acf.add_filter(this.tag(e),function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_event:function(e,t){var i=this,a=e.substr(0,e.indexOf(" ")),n=e.substr(e.indexOf(" ")+1),d=this.selector();$(document).on(a,d+" "+n,function(e){e.$el=$(this),e.$field=e.$el.closest(".acf-field-object"),i.set("$field",e.$field),i[t].apply(i,[e])})},_set_$field:function(){this.o=this.$field.data(),this.$settings=this.$field.find("> .settings > table > tbody"),this.focus()},focus:function(){},setting:function(e){return this.$settings.find("> .acf-field-setting-"+e)}}),acf.field_group.field_objects=acf.model.extend({actions:{save_field:"_save_field",open_field:"_open_field",close_field:"_close_field",wipe_field:"_wipe_field",add_field:"_add_field",duplicate_field:"_duplicate_field",delete_field:"_delete_field",change_field_type:"_change_field_type",change_field_label:"_change_field_label",change_field_name:"_change_field_name",render_field_settings:"_render_field_settings"},_save_field:function(e){acf.do_action("save_field/type="+e.data("type"),e)},_open_field:function(e){acf.do_action("open_field/type="+e.data("type"),e),acf.do_action("render_field_settings",e)},_close_field:function(e){acf.do_action("close_field/type="+e.data("type"),e)},_wipe_field:function(e){acf.do_action("wipe_field/type="+e.data("type"),e)},_add_field:function(e){acf.do_action("add_field/type="+e.data("type"),e)},_duplicate_field:function(e){acf.do_action("duplicate_field/type="+e.data("type"),e)},_delete_field:function(e){acf.do_action("delete_field/type="+e.data("type"),e)},_change_field_type:function(e){acf.do_action("change_field_type/type="+e.data("type"),e),acf.do_action("render_field_settings",e)},_change_field_label:function(e){acf.do_action("change_field_label/type="+e.data("type"),e)},_change_field_name:function(e){acf.do_action("change_field_name/type="+e.data("type"),e)},_render_field_settings:function(e){acf.do_action("render_field_settings/type="+e.data("type"),e)}}),acf.field_group.append=acf.model.extend({actions:{render_field_settings:"_render_field_settings"},render:function(e){var t=e.data("append");if($sibling=e.siblings('[data-name="'+t+'"]'),$sibling.exists()){var i=$sibling.children(".acf-input"),a=i.children(".acf-hl");a.exists()||(i.wrapInner('<ul class="acf-hl"><li></li></ul>'),a=i.children(".acf-hl"));var n=$("<li></li>").append(e.children(".acf-input").children());a.append(n),a.attr("data-cols",a.children().length),e.remove()}},_render_field_settings:function(e){var t=this;e.find(".acf-field[data-append]").each(function(){t.render($(this))})}});var e=acf.field_group.field_object.extend({type:"select",actions:{render_settings:"render"},events:{"change .acf-field-setting-ui input":"render"},render:function(e){this.setting('ui input[type="checkbox"]').prop("checked")?this.setting("ajax").show():(this.setting("ajax").hide(),this.setting('ajax input[type="checkbox"]').prop("checked",!1).trigger("change"))}}),t=acf.field_group.field_object.extend({type:"radio",actions:{render_settings:"render"},events:{"change .acf-field-setting-other_choice input":"render"},render:function(e){this.setting('other_choice input[type="checkbox"]').prop("checked")?this.setting("save_other_choice").show():(this.setting("save_other_choice").hide(),this.setting('save_other_choice input[type="checkbox"]').prop("checked",!1).trigger("change"))}}),i=acf.field_group.field_object.extend({type:"checkbox",actions:{render_settings:"render"},events:{"change .acf-field-setting-allow_custom input":"render"},render:function(e){this.setting('allow_custom input[type="checkbox"]').prop("checked")?this.setting("save_custom").show():(this.setting("save_custom").hide(),this.setting('save_custom input[type="checkbox"]').prop("checked",!1).trigger("change"))}}),a=acf.field_group.field_object.extend({type:"true_false",actions:{render_settings:"render"},events:{"change .acf-field-setting-ui input":"render"},render:function(e){this.setting('ui input[type="checkbox"]').prop("checked")?(this.setting("ui_on_text").show(),this.setting("ui_off_text").show()):(this.setting("ui_on_text").hide(),this.setting("ui_off_text").hide())}}),n=acf.field_group.field_object.extend({type:"date_picker",actions:{render_settings:"render"},events:{"change .acf-field-setting-display_format input":"render","change .acf-field-setting-return_format input":"render"},render:function(e){this.render_list(this.setting("display_format")),this.render_list(this.setting("return_format"))},render_list:function(e){var t=e.find("ul"),i=t.find('input[type="radio"]:checked'),a=t.find('input[type="text"]');"other"!=i.val()&&a.val(i.val())}}),d=n.extend({type:"date_time_picker"}),d=n.extend({type:"time_picker"}),l=acf.field_group.field_object.extend({type:"tab",actions:{render_settings:"render"},render:function(e){this.setting("name input").val("").trigger("change"),this.setting('required input[type="checkbox"]').prop("checked",!1).trigger("change")}}),f=l.extend({type:"message"});acf.field_group.screen=acf.model.extend({actions:{ready:"ready"},events:{"click #acf-field-key-hide":"toggle"},ready:function(){var e=$("#adv-settings"),t=e.find("#acf-append-show-on-screen");e.find(".metabox-prefs").append(t.html()),e.find(".metabox-prefs br").remove(),t.remove(),this.render()},toggle:function(e){var t=e.$el.prop("checked")?1:0;acf.update_user_setting("show_field_keys",t),this.render()},render:function(){var e=acf.serialize($("#adv-settings")),t=acf.field_group.$fields;e.show_field_keys?t.addClass("show-field-keys"):t.removeClass("show-field-keys")}}),acf.field_group.sub_fields=acf.model.extend({actions:{open_field:"update_field_parent",sortstop:"update_field_parent",duplicate_field:"duplicate_field",delete_field:"delete_field",change_field_type:"change_field_type"},fix_conditional_logic:function(e){var t={};e.each(function(){t[$(this).attr("data-orig")]=$(this).attr("data-key")}),e.find(".conditional-rule-param").each(function(){var e=$(this).val();e in t&&($(this).find('option[value="'+t[e]+'"]').exists()||$(this).append('<option value="'+t[e]+'">'+t[e]+"</option>"),$(this).val(t[e]))})},update_field_parent:function(e){if(e.hasClass("acf-field-object")){var t=e.parent().closest(".acf-field-object"),i=acf.get("post_id");t.exists()&&((i=acf.field_group.get_field_meta(t,"ID"))||(i=acf.field_group.get_field_meta(t,"key"))),acf.field_group.update_field_meta(e,"parent",i),acf.do_action("update_field_parent",e,t)}},duplicate_field:function(e){var t=e.find(".acf-field-object");t.exists()&&(t.each(function(){var e=$(this).parent().closest(".acf-field-object"),t=acf.field_group.get_field_meta(e,"key");acf.field_group.wipe_field($(this)),acf.field_group.update_field_meta($(this),"parent",t),acf.field_group.save_field($(this))}),this.fix_conditional_logic(t))},delete_field:function(e){e.find(".acf-field-object").each(function(){acf.field_group.delete_field($(this),!1)})},change_field_type:function(e){e.find(".acf-field-object").each(function(){acf.field_group.delete_field($(this),!1)})}})}(jQuery);
1
+ !function($,e){var t=new acf.Model({id:"fieldGroupManager",events:{"submit #post":"onSubmit",'click a[href="#"]':"onClick","click .submitdelete":"onClickTrash"},filters:{find_fields_args:"filterFindFieldArgs"},onSubmit:function(e,t){var i=$("#titlewrap #title");i.val()||(e.preventDefault(),acf.validation.unlockForm(t),alert(acf.__("Field group title is required")),i.focus())},onClick:function(e){e.preventDefault()},onClickTrash:function(e){confirm(acf.__("Move to trash. Are you sure?"))||e.preventDefault()},filterFindFieldArgs:function(e){return e.visible=!0,e}}),i=new acf.Model({id:"screenOptionsManager",wait:"prepare",events:{change:"onChange"},initialize:function(){var e=$("#adv-settings"),t=$("#acf-append-show-on-screen");e.find(".metabox-prefs").append(t.html()),e.find(".metabox-prefs br").remove(),t.remove(),this.$el=$("#acf-field-key-hide"),this.addEvents(),this.render()},isChecked:function(){return this.$el.prop("checked")},onChange:function(e,t){var i=this.isChecked()?1:0;acf.updateUserSetting("show_field_keys",i),this.render()},render:function(){this.isChecked()?$("#acf-field-group-fields").addClass("show-field-keys"):$("#acf-field-group-fields").removeClass("show-field-keys")}}),n=new acf.Model({actions:{new_field:"onNewField"},onNewField:function(e){if(e.has("append")){var t=e.get("append"),i=e.$el.siblings('[data-name="'+t+'"]').first();if(i.length){var n=i.children(".acf-input"),a=n.children("ul");a.length||(n.wrapInner('<ul class="acf-hl"><li></li></ul>'),a=n.children("ul"));var c=e.$(".acf-input").html(),l=$("<li>"+c+"</li>");a.append(l),a.attr("data-cols",a.children().length),e.remove()}}}})}(jQuery),function($,e){acf.FieldObject=acf.Model.extend({eventScope:".acf-field-object",events:{"click .edit-field":"onClickEdit","click .delete-field":"onClickDelete","click .duplicate-field":"duplicate","click .move-field":"move","change .field-type":"onChangeType","change .field-required":"onChangeRequired","blur .field-label":"onChangeLabel","blur .field-name":"onChangeName",change:"onChange",changed:"onChanged"},data:{id:0,key:"",type:""},setup:function(e){this.$el=e,this.inherit(e),this.prop("ID"),this.prop("parent"),this.prop("menu_order")},$input:function(e){return $("#"+this.getInputId()+"-"+e)},$settings:function(){return this.$(".acf-field-settings:first > .acf-field")},$setting:function(e){return this.$(".acf-field-settings:first > .acf-field-setting-"+e)},getParent:function(){return acf.getFieldObjects({child:this.$el,limit:1}).pop()},getParents:function(){return acf.getFieldObjects({child:this.$el})},getFields:function(){return acf.getFieldObjects({parent:this.$el})},getInputName:function(){return"acf_fields["+this.get("id")+"]"},getInputId:function(){return"acf_fields-"+this.get("id")},newInput:function(e,t){var i=this.getInputId(),n=this.getInputName();e&&(i+="-"+e,n+="["+e+"]");var a=$("<input />").attr({id:i,name:n,value:t});return this.$("> .meta").append(a),a},getProp:function(e){if(this.has(e))return this.get(e);var t=this.$input(e),i=t.length?t.val():null;return this.set(e,i,!0),i},setProp:function(e,t){var i=this.$input(e),n=i.val();return i.length||(i=this.newInput(e,t)),null===t?i.remove():i.val(t),this.has(e)?this.set(e,t):this.set(e,t,!0),this},prop:function(e,t){return void 0!==t?this.setProp(e,t):this.getProp(e)},props:function(e){Object.keys(e).map(function(t){this.setProp(t,e[t])},this)},getLabel:function(){var e=this.prop("label");return""===e&&(e=acf.__("(no label)")),e},getName:function(){return this.prop("name")},getType:function(){return this.prop("type")},getTypeLabel:function(){var e=this.prop("type"),t=acf.get("fieldTypes");return t[e]?t[e].label:e},getKey:function(){return this.prop("key")},initialize:function(){},render:function(){var e=this.$(".handle:first"),t=this.prop("menu_order"),i=this.getLabel(),n=this.prop("name"),a=this.getTypeLabel(),c=this.prop("key"),l=this.$input("required").prop("checked");e.find(".acf-icon").html(parseInt(t)+1),l&&(i+=' <span class="acf-required">*</span>'),e.find(".li-field-label strong a").html(i),e.find(".li-field-name").text(n),e.find(".li-field-type").text(a),e.find(".li-field-key").text(c),acf.doAction("render_field_object",this)},refresh:function(){acf.doAction("refresh_field_object",this)},isOpen:function(){return this.$el.hasClass("open")},onClickEdit:function(e){this.isOpen()?this.close():this.open()},open:function(){var e=this.$el.children(".settings");e.slideDown(),this.$el.addClass("open"),acf.doAction("open_field_object",this),this.trigger("openFieldObject"),acf.doAction("show",e)},close:function(){var e=this.$el.children(".settings");e.slideUp(),this.$el.removeClass("open"),acf.doAction("close_field_object",this),this.trigger("closeFieldObject"),acf.doAction("hide",e)},serialize:function(){return acf.serialize(this.$el,this.getInputName())},save:function(e){e=e||"settings","settings"!==this.getProp("save")&&(this.setProp("save",e),this.$el.attr("data-save",e),acf.doAction("save_field_object",this,e))},submit:function(){var e=this.getInputName(),t=this.get("save");this.isOpen()&&this.close(),"settings"==t||("meta"==t?this.$('> .settings [name^="'+e+'"]').remove():this.$('[name^="'+e+'"]').remove()),acf.doAction("submit_field_object",this)},onChange:function(e,t){this.save(),acf.doAction("change_field_object",this)},onChanged:function(e,t,i,n){"save"!=i&&(["menu_order","parent"].indexOf(i)>-1?this.save("meta"):this.save(),["menu_order","label","required","name","type","key"].indexOf(i)>-1&&this.render(),acf.doAction("change_field_object_"+i,this,n))},onChangeLabel:function(e,t){var i=t.val();if(this.set("label",i),""==this.prop("name")){var n=acf.applyFilters("generate_field_object_name",acf.strSanitize(i),this);this.prop("name",n)}},onChangeName:function(e,t){var i=t.val();this.set("name",i),"field_"===i.substr(0,6)&&alert(acf.__('The string "field_" may not be used at the start of a field name'))},onChangeRequired:function(e,t){var i=t.prop("checked")?1:0;this.set("required",i)},delete:function(e){e=acf.parseArgs(e,{animate:!0});var t=this.prop("ID");if(t){var i=$("#_acf_delete_fields"),n=i.val()+"|"+t;i.val(n)}acf.doAction("delete_field_object",this),e.animate?this.removeAnimate():this.remove()},onClickDelete:function(e,t){this.$el.addClass("-hover");var i=this,n=acf.newTooltip({confirmRemove:!0,target:t,confirm:function(){i.delete(!0)},cancel:function(){i.$el.removeClass("-hover")}})},removeAnimate:function(){var e=this,t=this.$el.parent(),i=acf.findFieldObjects({sibling:this.$el});acf.remove({target:this.$el,endHeight:i.length?0:50,complete:function(){e.remove(),acf.doAction("removed_field_object",e,t)}}),acf.doAction("remove_field_object",e,t)},duplicate:function(){var e=acf.uniqid("field_"),t=acf.duplicate({target:this.$el,search:this.get("id"),replace:e});t.attr("data-key",e);var i=acf.getFieldObject(t);this.isOpen()?this.close():i.open();var n=i.$setting("label input");setTimeout(function(){n.focus()},251);var a=i.prop("label"),c=i.prop("name"),l=c.split("_").pop(),o=acf.__("copy");if($.isNumeric(l)){var r=1*l+1;a=a.replace(l,r),c=c.replace(l,r)}else if(0===l.indexOf(o)){var r=1*l.replace(o,"");r=r?r+1:2,a=a.replace(l,o+r),c=c.replace(l,o+r)}else a+=" ("+o+")",c+="_"+o;i.prop("ID",0),i.prop("label",a),i.prop("name",c),i.prop("key",e),acf.doAction("duplicate_field_object",this,i),acf.doAction("append_field_object",i)},wipe:function(){var e=this.get("id"),t=this.get("key"),i=acf.uniqid("field_");acf.rename({target:this.$el,search:e,replace:i}),this.set("id",i),this.set("prevId",e),this.set("prevKey",t),this.prop("key",i),this.prop("ID",0),this.$el.attr("data-key",i),this.$el.attr("data-id",i),acf.doAction("wipe_field_object",this)},move:function(){var e=function(e){return"settings"==e.get("save")},t=e(this);if(t||acf.getFieldObjects({parent:this.$el}).map(function(i){t=e(i)||i.changed}),t)return void alert(acf.__("This field cannot be moved until its changes have been saved"));var i=this.prop("ID"),n=this,a=!1,c=function(e){a.loading(!1),a.content(e),a.on("submit","form",l)},l=function(e,t){e.preventDefault(),acf.startButtonLoading(a.$(".button"));var n={action:"acf/field_group/move_field",field_id:i,field_group_id:a.$("select").val()};$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(n),type:"post",dataType:"html",success:o})},o=function(e){a.content(e),n.removeAnimate()};!function(){a=acf.newPopup({title:acf.__("Move Custom Field"),loading:!0,width:"300px"});var e={action:"acf/field_group/move_field",field_id:i};$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"html",success:c})}()},onChangeType:function(e,t){this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=this.setTimeout(function(){this.changeType(t.val())},300)},changeType:function(e){var t=this.prop("type"),i=acf.strSlugify("acf-field-object-"+t),n=acf.strSlugify("acf-field-object-"+e);this.$el.removeClass(i).addClass(n),this.$el.attr("data-type",e),this.$el.data("type",e),this.has("xhr")&&this.get("xhr").abort();var a=this.$("> .settings > table > tbody"),c=a.children('[data-setting="'+t+'"]');if(this.set("settings-"+t,c),c.detach(),this.has("settings-"+e)){var l=this.get("settings-"+e);return this.$setting("conditional_logic").before(l),void this.set("type",e)}var o=$('<tr class="acf-field"><td class="acf-label"></td><td class="acf-input"><div class="acf-loading"></div></td></tr>');this.$setting("conditional_logic").before(o);var r={action:"acf/field_group/render_field_settings",field:this.serialize(),prefix:this.getInputName()},d=$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(r),type:"post",dataType:"html",context:this,success:function(e){e&&(o.after(e),acf.doAction("append",a))},complete:function(){o.remove(),this.set("type",e)}});this.set("xhr",d)},updateParent:function(){var e=acf.get("post_id"),t=this.getParent();t&&(e=t.prop("ID")||t.prop("key")),this.prop("parent",e)}})}(jQuery),function($,e){var t=function(e){return acf.strPascalCase(e||"")+"FieldSetting"};acf.registerFieldSetting=function(e){var i=e.prototype,n=t(i.type+" "+i.name);this.models[n]=e},acf.newFieldSetting=function(e){var i=e.get("setting")||"",n=e.get("name")||"",a=t(i+" "+n),c=acf.models[a]||null;return null!==c&&new c(e)},acf.getFieldSetting=function(e){return e instanceof jQuery&&(e=acf.getField(e)),e.setting};var i=new acf.Model({actions:{new_field:"onNewField"},onNewField:function(e){e.setting=acf.newFieldSetting(e)}});acf.FieldSetting=acf.Model.extend({field:!1,type:"",name:"",wait:"ready",eventScope:".acf-field",events:{change:"render"},setup:function(e){var t=e.$el;this.$el=t,this.field=e,this.$fieldObject=t.closest(".acf-field-object"),this.fieldObject=acf.getFieldObject(this.$fieldObject),$.extend(this.data,e.data)},initialize:function(){this.render()},render:function(){}});var n=acf.FieldSetting.extend({type:"",name:"",render:function(){var e=this.$('input[type="radio"]:checked');"other"!=e.val()&&this.$('input[type="text"]').val(e.val())}}),a=n.extend({type:"date_picker",name:"display_format"}),c=n.extend({type:"date_picker",name:"return_format"});acf.registerFieldSetting(a),acf.registerFieldSetting(c);var l=n.extend({type:"date_time_picker",name:"display_format"}),o=n.extend({type:"date_time_picker",name:"return_format"});acf.registerFieldSetting(l),acf.registerFieldSetting(o);var r=n.extend({type:"time_picker",name:"display_format"}),d=n.extend({name:"time_picker",name:"return_format"});acf.registerFieldSetting(r),acf.registerFieldSetting(d)}(jQuery),function($,e){var t=acf.FieldSetting.extend({type:"",name:"conditional_logic",events:{"change .conditions-toggle":"onChangeToggle","click .add-conditional-group":"onClickAddGroup","focus .condition-rule-field":"onFocusField","change .condition-rule-field":"onChangeField","change .condition-rule-operator":"onChangeOperator","click .add-conditional-rule":"onClickAdd","click .remove-conditional-rule":"onClickRemove"},$rule:!1,scope:function(e){return this.$rule=e,this},ruleData:function(e,t){return this.$rule.data.apply(this.$rule,arguments)},$input:function(e){return this.$rule.find(".condition-rule-"+e)},$td:function(e){return this.$rule.find("td."+e)},$toggle:function(){return this.$(".conditions-toggle")},$control:function(){return this.$(".rule-groups")},$groups:function(){return this.$(".rule-group")},$rules:function(){return this.$(".rule")},open:function(){var e=this.$control();e.show(),acf.enable(e)},close:function(){var e=this.$control();e.hide(),acf.disable(e)},render:function(){this.$toggle().prop("checked")?(this.renderRules(),this.open()):this.close()},renderRules:function(){var e=this;this.$rules().each(function(){e.renderRule($(this))})},renderRule:function(e){this.scope(e),this.renderField(),this.renderOperator(),this.renderValue()},renderField:function(){var e=[],t=[],i=this.fieldObject.cid,n=this.$input("field");acf.getFieldObjects().map(function(t){var n={id:t.getKey(),text:t.getLabel()};t.cid===i&&(n.text+=acf.__("(this field)"),n.disabled=!0),acf.getConditionTypes({fieldType:t.getType()}).length||(n.disabled=!0);var a=t.getParents().length;n.text="- ".repeat(a)+n.text,e.push(n)}),e.length||e.push({id:"",text:acf.__("No toggle fields available")}),acf.renderSelect(n,e),this.ruleData("field",n.val())},renderOperator:function(){if(this.ruleData("field")){var e=this.$input("operator"),t=e.val(),i=[];null===e.val()&&acf.renderSelect(e,[{id:this.ruleData("operator"),text:""}]);var n=acf.findFieldObject(this.ruleData("field")),a=acf.getFieldObject(n);acf.getConditionTypes({fieldType:a.getType()}).map(function(e){i.push({id:e.prototype.operator,text:acf.strEscape(e.prototype.label)})}),acf.renderSelect(e,i),this.ruleData("operator",e.val())}},renderValue:function(){if(this.ruleData("field")&&this.ruleData("operator")){var e=this.$input("value"),t=this.$td("value"),i=e.val(),n=acf.findFieldObject(this.ruleData("field")),a=acf.getFieldObject(n),c=acf.getConditionTypes({fieldType:a.getType(),operator:this.ruleData("operator")}),l=c[0].prototype,o=l.choices(a);if(o instanceof Array){var r=$("<select></select>");acf.renderSelect(r,o)}else var r=$(o);e.detach(),t.html(r),setTimeout(function(){["class","name","id"].map(function(t){r.attr(t,e.attr(t))})},0),r.prop("disabled")||acf.val(r,i,!0),this.ruleData("value",r.val())}},onChangeToggle:function(){this.render()},onClickAddGroup:function(e,t){this.addGroup()},addGroup:function(){var e=this.$(".rule-group:last"),t=acf.duplicate(e);t.find("h4").text(acf.__("or")),t.find("tr").not(":first").remove(),this.fieldObject.save()},onFocusField:function(e,t){this.renderField()},onChangeField:function(e,t){this.scope(t.closest(".rule")),this.ruleData("field",t.val()),this.renderOperator(),this.renderValue()},onChangeOperator:function(e,t){this.scope(t.closest(".rule")),this.ruleData("operator",t.val()),this.renderValue()},onClickAdd:function(e,t){var i=acf.duplicate(t.closest(".rule"));this.renderRule(i)},onClickRemove:function(e,t){var i=t.closest(".rule");this.fieldObject.save(),0==i.siblings(".rule").length&&i.closest(".rule-group").remove(),i.remove()}});acf.registerFieldSetting(t);var i=new acf.Model({actions:{duplicate_field_objects:"onDuplicateFieldObjects"},onDuplicateFieldObjects:function(e,t,i){var n={},a=$();e.map(function(e){n[e.get("prevKey")]=e.get("key"),a=a.add(e.$(".condition-rule-field"))}),a.each(function(){var e=$(this),t=e.val();t&&n[t]&&(e.find("option:selected").attr("value",n[t]),e.val(n[t]))})}})}(jQuery),function($,e){acf.findFieldObject=function(e){return acf.findFieldObjects({key:e,limit:1})},acf.findFieldObjects=function(e){e=e||{};var t=".acf-field-object",i=!1;return e=acf.parseArgs(e,{id:"",key:"",type:"",limit:!1,list:null,parent:!1,sibling:!1,child:!1}),e.id&&(t+='[data-id="'+e.id+'"]'),e.key&&(t+='[data-key="'+e.key+'"]'),e.type&&(t+='[data-type="'+e.type+'"]'),i=e.list?e.list.children(t):e.parent?e.parent.find(t):e.sibling?e.sibling.siblings(t):e.child?e.child.parents(t):$(t),e.limit&&(i=i.slice(0,e.limit)),i},acf.getFieldObject=function(e){"string"==typeof e&&(e=acf.findFieldObject(e));var t=e.data("acf");return t||(t=acf.newFieldObject(e)),t},acf.getFieldObjects=function(e){var t=acf.findFieldObjects(e),i=[];return t.each(function(){var e=acf.getFieldObject($(this));i.push(e)}),i},acf.newFieldObject=function(e){var t=new acf.FieldObject(e);return acf.doAction("new_field_object",t),t};var t=new acf.Model({priority:5,initialize:function(){["prepare","ready","append","remove"].map(function(e){this.addFieldActions(e)},this)},addFieldActions:function(e){var t=e+"_field_objects",i=e+"_field_object",n=e+"FieldObject",a=function(e){var i=acf.getFieldObjects({parent:e});if(i.length){var n=acf.arrayArgs(arguments);n.splice(0,1,t,i),acf.doAction.apply(null,n)}},c=function(e){var t=acf.arrayArgs(arguments);t.unshift(i),e.map(function(e){t[1]=e,acf.doAction.apply(null,t)})},l=function(e){var t=acf.arrayArgs(arguments);t.unshift(i),["type","name","key"].map(function(n){t[0]=i+"/"+n+"="+e.get(n),acf.doAction.apply(null,t)}),t.splice(0,2),e.trigger(n,t)};acf.addAction(e,a,5),acf.addAction(t,c,5),acf.addAction(i,l,5)}}),i=new acf.Model({id:"fieldManager",events:{"submit #post":"onSubmit","mouseenter .acf-field-list":"onHoverSortable","click .add-field":"onClickAdd"},actions:{removed_field_object:"onRemovedField",sortstop_field_object:"onReorderField",delete_field_object:"onDeleteField",change_field_object_type:"onChangeFieldType",duplicate_field_object:"onDuplicateField"},onSubmit:function(e,t){acf.getFieldObjects().map(function(e){e.submit()})},setFieldMenuOrder:function(e){this.renderFields(e.$el.parent())},onHoverSortable:function(e,t){t.hasClass("ui-sortable")||t.sortable({handle:".acf-sortable-handle",connectWith:".acf-field-list",start:function(e,i){var n=acf.getFieldObject(i.item);i.placeholder.height(i.item.height()),acf.doAction("sortstart_field_object",n,t)},update:function(e,i){var n=acf.getFieldObject(i.item);acf.doAction("sortstop_field_object",n,t)}})},onRemovedField:function(e,t){this.renderFields(t)},onReorderField:function(e,t){e.updateParent(),this.renderFields(t)},onDeleteField:function(e){e.getFields().map(function(e){e.delete({animate:!1})})},onChangeFieldType:function(e){},onDuplicateField:function(e,t){var i=t.getFields();i.length&&(i.map(function(e){e.wipe(),e.updateParent()}),acf.doAction("duplicate_field_objects",i,t,e)),this.setFieldMenuOrder(t)},renderFields:function(e){var t=acf.getFieldObjects({list:e});if(!t.length)return void e.addClass("-empty");e.removeClass("-empty"),t.map(function(e,t){e.prop("menu_order",t)})},onClickAdd:function(e,t){var i=t.closest(".acf-tfoot").siblings(".acf-field-list");this.addField(i)},addField:function(e){var t=$("#tmpl-acf-field").html(),i=$(t),n=i.data("id"),a=acf.uniqid("field_"),c=acf.duplicate({target:i,search:n,replace:a,append:function(t,i){e.append(i)}}),l=acf.getFieldObject(c);l.prop("key",a),l.prop("ID",0),l.prop("label",""),l.prop("name",""),c.attr("data-key",a),c.attr("data-id",a),l.updateParent();var o=l.$input("label");setTimeout(function(){o.focus()},251),l.open(),this.renderFields(e),acf.doAction("add_field_object",l),acf.doAction("append_field_object",l)}})}(jQuery),function($,e){var t=new acf.Model({id:"locationManager",wait:"ready",events:{"click .add-location-rule":"onClickAddRule","click .add-location-group":"onClickAddGroup","click .remove-location-rule":"onClickRemoveRule","change .refresh-location-rule":"onChangeRemoveRule"},initialize:function(){this.$el=$("#acf-field-group-locations")},onClickAddRule:function(e,t){this.addRule(t.closest("tr"))},onClickRemoveRule:function(e,t){this.removeRule(t.closest("tr"))},onChangeRemoveRule:function(e,t){this.changeRule(t.closest("tr"))},onClickAddGroup:function(e,t){this.addGroup()},addRule:function(e){acf.duplicate(e)},removeRule:function(e){0==e.siblings("tr").length?e.closest(".rule-group").remove():e.remove()},changeRule:function(e){var t=e.closest(".rule-group"),i=e.find("td.param select").attr("name").replace("[param]",""),n={};n.action="acf/field_group/render_location_rule",n.rule=acf.serialize(e,i),n.rule.id=e.data("id"),n.rule.group=t.data("id"),acf.disable(e.find("td.value")),$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(n),type:"post",dataType:"html",success:function(t){t&&e.replaceWith(t)}})},addGroup:function(){var e=this.$(".rule-group:last");$group2=acf.duplicate(e),$group2.find("h4").text(acf.__("or")),$group2.find("tr").not(":first").remove()}})}(jQuery),function($,e){var t=acf.getCompatibility(acf);t.field_group={save_field:function(e,t){t=void 0!==t?t:"settings",acf.getFieldObject(e).save(t)},delete_field:function(e,t){t=void 0===t||t,acf.getFieldObject(e).delete({animate:t})},update_field_meta:function(e,t,i){acf.getFieldObject(e).prop(t,i)},delete_field_meta:function(e,t){acf.getFieldObject(e).prop(t,null)}},t.field_group.field_object=acf.model.extend({type:"",o:{},$field:null,$settings:null,tag:function(e){var t=this.type,i=e.split("_");return i.splice(1,0,"field"),e=i.join("_"),t&&(e+="/type="+t),e},selector:function(){var e=".acf-field-object",t=this.type;return t&&(e+="-"+t,e=acf.str_replace("_","-",e)),e},_add_action:function(e,t){var i=this;acf.add_action(this.tag(e),function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_filter:function(e,t){var i=this;acf.add_filter(this.tag(e),function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_event:function(e,t){var i=this,n=e.substr(0,e.indexOf(" ")),a=e.substr(e.indexOf(" ")+1),c=this.selector();$(document).on(n,c+" "+a,function(e){e.$el=$(this),e.$field=e.$el.closest(".acf-field-object"),i.set("$field",e.$field),i[t].apply(i,[e])})},_set_$field:function(){this.o=this.$field.data(),this.$settings=this.$field.find("> .settings > table > tbody"),this.focus()},focus:function(){},setting:function(e){return this.$settings.find("> .acf-field-setting-"+e)}});var i=new acf.Model({actions:{open_field_object:"onOpenFieldObject",close_field_object:"onCloseFieldObject",add_field_object:"onAddFieldObject",duplicate_field_object:"onDuplicateFieldObject",delete_field_object:"onDeleteFieldObject",change_field_object_type:"onChangeFieldObjectType",change_field_object_label:"onChangeFieldObjectLabel",change_field_object_name:"onChangeFieldObjectName",change_field_object_parent:"onChangeFieldObjectParent",sortstop_field_object:"onChangeFieldObjectParent"},onOpenFieldObject:function(e){acf.doAction("open_field",e.$el),acf.doAction("open_field/type="+e.get("type"),e.$el),acf.doAction("render_field_settings",e.$el),acf.doAction("render_field_settings/type="+e.get("type"),e.$el)},onCloseFieldObject:function(e){acf.doAction("close_field",e.$el),acf.doAction("close_field/type="+e.get("type"),e.$el)},onAddFieldObject:function(e){acf.doAction("add_field",e.$el),acf.doAction("add_field/type="+e.get("type"),e.$el)},onDuplicateFieldObject:function(e){acf.doAction("duplicate_field",e.$el),acf.doAction("duplicate_field/type="+e.get("type"),e.$el)},onDeleteFieldObject:function(e){acf.doAction("delete_field",e.$el),acf.doAction("delete_field/type="+e.get("type"),e.$el)},onChangeFieldObjectType:function(e){acf.doAction("change_field_type",e.$el),acf.doAction("change_field_type/type="+e.get("type"),e.$el),acf.doAction("render_field_settings",e.$el),acf.doAction("render_field_settings/type="+e.get("type"),e.$el)},onChangeFieldObjectLabel:function(e){acf.doAction("change_field_label",e.$el),acf.doAction("change_field_label/type="+e.get("type"),e.$el)},onChangeFieldObjectName:function(e){acf.doAction("change_field_name",e.$el),acf.doAction("change_field_name/type="+e.get("type"),e.$el)},onChangeFieldObjectParent:function(e){acf.doAction("update_field_parent",e.$el)}})}(jQuery);
assets/js/acf-input.js CHANGED
@@ -1,14577 +1,13537 @@
1
- ( function( window, undefined ) {
2
- "use strict";
3
-
4
- /**
5
- * Handles managing all events for whatever you plug it into. Priorities for hooks are based on lowest to highest in
6
- * that, lowest priority hooks are fired first.
7
- */
8
- var EventManager = function() {
9
- /**
10
- * Maintain a reference to the object scope so our public methods never get confusing.
11
- */
12
- var MethodsAvailable = {
13
- removeFilter : removeFilter,
14
- applyFilters : applyFilters,
15
- addFilter : addFilter,
16
- removeAction : removeAction,
17
- doAction : doAction,
18
- addAction : addAction,
19
- storage : getStorage
20
- };
21
-
22
- /**
23
- * Contains the hooks that get registered with this EventManager. The array for storage utilizes a "flat"
24
- * object literal such that looking up the hook utilizes the native object literal hash.
25
- */
26
- var STORAGE = {
27
- actions : {},
28
- filters : {}
29
- };
30
-
31
- function getStorage() {
32
-
33
- return STORAGE;
34
-
35
- };
36
-
37
- /**
38
- * Adds an action to the event manager.
39
- *
40
- * @param action Must contain namespace.identifier
41
- * @param callback Must be a valid callback function before this action is added
42
- * @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
43
- * @param [context] Supply a value to be used for this
44
- */
45
- function addAction( action, callback, priority, context ) {
46
- if( typeof action === 'string' && typeof callback === 'function' ) {
47
- priority = parseInt( ( priority || 10 ), 10 );
48
- _addHook( 'actions', action, callback, priority, context );
49
- }
50
-
51
- return MethodsAvailable;
52
- }
53
-
54
- /**
55
- * Performs an action if it exists. You can pass as many arguments as you want to this function; the only rule is
56
- * that the first argument must always be the action.
57
- */
58
- function doAction( /* action, arg1, arg2, ... */ ) {
59
- var args = Array.prototype.slice.call( arguments );
60
- var action = args.shift();
61
-
62
- if( typeof action === 'string' ) {
63
- _runHook( 'actions', action, args );
64
- }
65
-
66
- return MethodsAvailable;
67
- }
68
-
69
- /**
70
- * Removes the specified action if it contains a namespace.identifier & exists.
71
- *
72
- * @param action The action to remove
73
- * @param [callback] Callback function to remove
74
- */
75
- function removeAction( action, callback ) {
76
- if( typeof action === 'string' ) {
77
- _removeHook( 'actions', action, callback );
78
- }
79
-
80
- return MethodsAvailable;
81
- }
82
-
83
- /**
84
- * Adds a filter to the event manager.
85
- *
86
- * @param filter Must contain namespace.identifier
87
- * @param callback Must be a valid callback function before this action is added
88
- * @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
89
- * @param [context] Supply a value to be used for this
90
- */
91
- function addFilter( filter, callback, priority, context ) {
92
- if( typeof filter === 'string' && typeof callback === 'function' ) {
93
- priority = parseInt( ( priority || 10 ), 10 );
94
- _addHook( 'filters', filter, callback, priority, context );
95
- }
96
-
97
- return MethodsAvailable;
98
- }
99
-
100
- /**
101
- * Performs a filter if it exists. You should only ever pass 1 argument to be filtered. The only rule is that
102
- * the first argument must always be the filter.
103
- */
104
- function applyFilters( /* filter, filtered arg, arg2, ... */ ) {
105
- var args = Array.prototype.slice.call( arguments );
106
- var filter = args.shift();
107
-
108
- if( typeof filter === 'string' ) {
109
- return _runHook( 'filters', filter, args );
110
- }
111
-
112
- return MethodsAvailable;
113
- }
114
-
115
- /**
116
- * Removes the specified filter if it contains a namespace.identifier & exists.
117
- *
118
- * @param filter The action to remove
119
- * @param [callback] Callback function to remove
120
- */
121
- function removeFilter( filter, callback ) {
122
- if( typeof filter === 'string') {
123
- _removeHook( 'filters', filter, callback );
124
- }
125
-
126
- return MethodsAvailable;
127
- }
128
-
129
- /**
130
- * Removes the specified hook by resetting the value of it.
131
- *
132
- * @param type Type of hook, either 'actions' or 'filters'
133
- * @param hook The hook (namespace.identifier) to remove
134
- * @private
135
- */
136
- function _removeHook( type, hook, callback, context ) {
137
- if ( !STORAGE[ type ][ hook ] ) {
138
- return;
139
- }
140
- if ( !callback ) {
141
- STORAGE[ type ][ hook ] = [];
142
- } else {
143
- var handlers = STORAGE[ type ][ hook ];
144
- var i;
145
- if ( !context ) {
146
- for ( i = handlers.length; i--; ) {
147
- if ( handlers[i].callback === callback ) {
148
- handlers.splice( i, 1 );
149
- }
150
- }
151
- }
152
- else {
153
- for ( i = handlers.length; i--; ) {
154
- var handler = handlers[i];
155
- if ( handler.callback === callback && handler.context === context) {
156
- handlers.splice( i, 1 );
157
- }
158
- }
159
- }
160
- }
161
- }
162
-
163
- /**
164
- * Adds the hook to the appropriate storage container
165
- *
166
- * @param type 'actions' or 'filters'
167
- * @param hook The hook (namespace.identifier) to add to our event manager
168
- * @param callback The function that will be called when the hook is executed.
169
- * @param priority The priority of this hook. Must be an integer.
170
- * @param [context] A value to be used for this
171
- * @private
172
- */
173
- function _addHook( type, hook, callback, priority, context ) {
174
- var hookObject = {
175
- callback : callback,
176
- priority : priority,
177
- context : context
178
- };
179
-
180
- // Utilize 'prop itself' : http://jsperf.com/hasownproperty-vs-in-vs-undefined/19
181
- var hooks = STORAGE[ type ][ hook ];
182
- if( hooks ) {
183
- hooks.push( hookObject );
184
- hooks = _hookInsertSort( hooks );
185
- }
186
- else {
187
- hooks = [ hookObject ];
188
- }
189
-
190
- STORAGE[ type ][ hook ] = hooks;
191
- }
192
-
193
- /**
194
- * Use an insert sort for keeping our hooks organized based on priority. This function is ridiculously faster
195
- * than bubble sort, etc: http://jsperf.com/javascript-sort
196
- *
197
- * @param hooks The custom array containing all of the appropriate hooks to perform an insert sort on.
198
- * @private
199
- */
200
- function _hookInsertSort( hooks ) {
201
- var tmpHook, j, prevHook;
202
- for( var i = 1, len = hooks.length; i < len; i++ ) {
203
- tmpHook = hooks[ i ];
204
- j = i;
205
- while( ( prevHook = hooks[ j - 1 ] ) && prevHook.priority > tmpHook.priority ) {
206
- hooks[ j ] = hooks[ j - 1 ];
207
- --j;
208
- }
209
- hooks[ j ] = tmpHook;
210
- }
211
-
212
- return hooks;
213
- }
214
-
215
- /**
216
- * Runs the specified hook. If it is an action, the value is not modified but if it is a filter, it is.
217
- *
218
- * @param type 'actions' or 'filters'
219
- * @param hook The hook ( namespace.identifier ) to be ran.
220
- * @param args Arguments to pass to the action/filter. If it's a filter, args is actually a single parameter.
221
- * @private
222
- */
223
- function _runHook( type, hook, args ) {
224
- var handlers = STORAGE[ type ][ hook ];
225
-
226
- if ( !handlers ) {
227
- return (type === 'filters') ? args[0] : false;
228
- }
229
-
230
- var i = 0, len = handlers.length;
231
- if ( type === 'filters' ) {
232
- for ( ; i < len; i++ ) {
233
- args[ 0 ] = handlers[ i ].callback.apply( handlers[ i ].context, args );
234
- }
235
- } else {
236
- for ( ; i < len; i++ ) {
237
- handlers[ i ].callback.apply( handlers[ i ].context, args );
238
- }
239
- }
240
-
241
- return ( type === 'filters' ) ? args[ 0 ] : true;
242
- }
243
-
244
- // return all of the publicly available methods
245
- return MethodsAvailable;
246
-
247
- };
248
-
249
- window.wp = window.wp || {};
250
- window.wp.hooks = window.wp.hooks || new EventManager();
251
-
252
- } )( window );
253
-
254
-
255
- var acf;
256
-
257
- (function($){
258
-
259
-
260
- /*
261
- * exists
262
- *
263
- * This function will return true if a jQuery selection exists
264
- *
265
- * @type function
266
- * @date 8/09/2014
267
- * @since 5.0.0
268
- *
269
- * @param n/a
270
- * @return (boolean)
271
- */
272
-
273
- $.fn.exists = function() {
274
-
275
- return $(this).length>0;
276
-
277
- };
278
-
279
-
280
- /*
281
- * outerHTML
282
- *
283
- * This function will return a string containing the HTML of the selected element
284
- *
285
- * @type function
286
- * @date 19/11/2013
287
- * @since 5.0.0
288
- *
289
- * @param $.fn
290
- * @return (string)
291
- */
292
-
293
- $.fn.outerHTML = function() {
294
-
295
- return $(this).get(0).outerHTML;
296
-
297
- };
298
-
299
-
300
- acf = {
301
-
302
- // vars
303
- l10n: {},
304
- o: {},
305
-
306
-
307
- /*
308
- * update
309
- *
310
- * This function will update a value found in acf.o
311
- *
312
- * @type function
313
- * @date 8/09/2014
314
- * @since 5.0.0
315
- *
316
- * @param k (string) the key
317
- * @param v (mixed) the value
318
- * @return n/a
319
- */
320
-
321
- update: function( k, v ){
322
-
323
- this.o[ k ] = v;
324
-
325
- },
326
-
327
-
328
- /*
329
- * get
330
- *
331
- * This function will return a value found in acf.o
332
- *
333
- * @type function
334
- * @date 8/09/2014
335
- * @since 5.0.0
336
- *
337
- * @param k (string) the key
338
- * @return v (mixed) the value
339
- */
340
-
341
- get: function( k ){
342
-
343
- if( typeof this.o[ k ] !== 'undefined' ) {
344
-
345
- return this.o[ k ];
346
-
347
- }
348
-
349
- return null;
350
-
351
- },
352
-
353
-
354
- /*
355
- * _e
356
- *
357
- * This functiln will return a string found in acf.l10n
358
- *
359
- * @type function
360
- * @date 8/09/2014
361
- * @since 5.0.0
362
- *
363
- * @param k1 (string) the first key to look for
364
- * @param k2 (string) the second key to look for
365
- * @return string (string)
366
- */
367
-
368
- _e: function( k1, k2 ){
369
-
370
- // defaults
371
- k2 = k2 || false;
372
-
373
-
374
- // get context
375
- var string = this.l10n[ k1 ] || '';
376
-
377
-
378
- // get string
379
- if( k2 ) {
380
-
381
- string = string[ k2 ] || '';
382
-
383
- }
384
-
385
-
386
- // return
387
- return string;
388
-
389
- },
390
-
391
-
392
- /*
393
- * add_action
394
- *
395
- * This function uses wp.hooks to mimics WP add_action
396
- *
397
- * @type function
398
- * @date 8/09/2014
399
- * @since 5.0.0
400
- *
401
- * @param
402
- * @return
403
- */
404
-
405
- add_action: function() {
406
-
407
- // vars
408
- var a = arguments[0].split(' '),
409
- l = a.length;
410
-
411
-
412
- // loop
413
- for( var i = 0; i < l; i++) {
414
-
415
- /*
416
- // allow for special actions
417
- if( a[i].indexOf('initialize') !== -1 ) {
418
-
419
- a.push( a[i].replace('initialize', 'ready') );
420
- a.push( a[i].replace('initialize', 'append') );
421
- l = a.length;
422
-
423
- continue;
424
- }
425
- */
426
-
427
-
428
- // prefix action
429
- arguments[0] = 'acf/' + a[i];
430
-
431
-
432
- // add
433
- wp.hooks.addAction.apply(this, arguments);
434
-
435
- }
436
-
437
-
438
- // return
439
- return this;
440
-
441
- },
442
-
443
-
444
- /*
445
- * remove_action
446
- *
447
- * This function uses wp.hooks to mimics WP remove_action
448
- *
449
- * @type function
450
- * @date 8/09/2014
451
- * @since 5.0.0
452
- *
453
- * @param
454
- * @return
455
- */
456
-
457
- remove_action: function() {
458
-
459
- // prefix action
460
- arguments[0] = 'acf/' + arguments[0];
461
-
462
- wp.hooks.removeAction.apply(this, arguments);
463
-
464
- return this;
465
-
466
- },
467
-
468
-
469
- /*
470
- * do_action
471
- *
472
- * This function uses wp.hooks to mimics WP do_action
473
- *
474
- * @type function
475
- * @date 8/09/2014
476
- * @since 5.0.0
477
- *
478
- * @param
479
- * @return
480
- */
481
-
482
- do_action: function() { //console.log('acf.do_action(%o)', arguments);
483
-
484
- // prefix action
485
- arguments[0] = 'acf/' + arguments[0];
486
-
487
- wp.hooks.doAction.apply(this, arguments);
488
-
489
- return this;
490
-
491
- },
492
-
493
-
494
- /*
495
- * add_filter
496
- *
497
- * This function uses wp.hooks to mimics WP add_filter
498
- *
499
- * @type function
500
- * @date 8/09/2014
501
- * @since 5.0.0
502
- *
503
- * @param
504
- * @return
505
- */
506
-
507
- add_filter: function() {
508
-
509
- // prefix action
510
- arguments[0] = 'acf/' + arguments[0];
511
-
512
- wp.hooks.addFilter.apply(this, arguments);
513
-
514
- return this;
515
-
516
- },
517
-
518
-
519
- /*
520
- * remove_filter
521
- *
522
- * This function uses wp.hooks to mimics WP remove_filter
523
- *
524
- * @type function
525
- * @date 8/09/2014
526
- * @since 5.0.0
527
- *
528
- * @param
529
- * @return
530
- */
531
-
532
- remove_filter: function() {
533
-
534
- // prefix action
535
- arguments[0] = 'acf/' + arguments[0];
536
-
537
- wp.hooks.removeFilter.apply(this, arguments);
538
-
539
- return this;
540
-
541
- },
542
-
543
-
544
- /*
545
- * apply_filters
546
- *
547
- * This function uses wp.hooks to mimics WP apply_filters
548
- *
549
- * @type function
550
- * @date 8/09/2014
551
- * @since 5.0.0
552
- *
553
- * @param
554
- * @return
555
- */
556
-
557
- apply_filters: function() { //console.log('acf.apply_filters(%o)', arguments);
558
-
559
- // prefix action
560
- arguments[0] = 'acf/' + arguments[0];
561
-
562
- return wp.hooks.applyFilters.apply(this, arguments);
563
-
564
- },
565
-
566
-
567
- /*
568
- * get_selector
569
- *
570
- * This function will return a valid selector for finding a field object
571
- *
572
- * @type function
573
- * @date 15/01/2015
574
- * @since 5.1.5
575
- *
576
- * @param s (string)
577
- * @return (string)
578
- */
579
-
580
- get_selector: function( s ) {
581
-
582
- // defaults
583
- s = s || '';
584
-
585
-
586
- // vars
587
- var selector = '.acf-field';
588
-
589
-
590
- // compatibility with object
591
- if( $.isPlainObject(s) ) {
592
-
593
- if( $.isEmptyObject(s) ) {
594
-
595
- s = '';
596
-
597
- } else {
598
-
599
- for( k in s ) { s = s[k]; break; }
600
-
601
- }
602
-
603
- }
604
-
605
-
606
- // search
607
- if( s ) {
608
-
609
- // append
610
- selector += '-' + s;
611
-
612
-
613
- // replace underscores (split/join replaces all and is faster than regex!)
614
- selector = selector.split('_').join('-');
615
-
616
-
617
- // remove potential double up
618
- selector = selector.split('field-field-').join('field-');
619
-
620
- }
621
-
622
-
623
- // return
624
- return selector;
625
-
626
- },
627
-
628
-
629
- /*
630
- * get_fields
631
- *
632
- * This function will return a jQuery selection of fields
633
- *
634
- * @type function
635
- * @date 8/09/2014
636
- * @since 5.0.0
637
- *
638
- * @param args (object)
639
- * @param $el (jQuery) element to look within
640
- * @param all (boolean) return all fields or allow filtering (for repeater)
641
- * @return $fields (jQuery)
642
- */
643
-
644
- get_fields: function( s, $el, all ){
645
-
646
- // debug
647
- //console.log( 'acf.get_fields(%o, %o, %o)', args, $el, all );
648
- //console.time("acf.get_fields");
649
-
650
-
651
- // defaults
652
- s = s || '';
653
- $el = $el || false;
654
- all = all || false;
655
-
656
-
657
- // vars
658
- var selector = this.get_selector(s);
659
-
660
-
661
- // get child fields
662
- var $fields = $( selector, $el );
663
-
664
-
665
- // append context to fields if also matches selector.
666
- // * Required for field group 'change_filed_type' append $tr to work
667
- if( $el !== false ) {
668
-
669
- $el.each(function(){
670
-
671
- if( $(this).is(selector) ) {
672
-
673
- $fields = $fields.add( $(this) );
674
-
675
- }
676
-
677
- });
678
-
679
- }
680
-
681
-
682
- // filter out fields
683
- if( !all ) {
684
-
685
- // remove clone fields
686
- $fields = $fields.not('.acf-clone .acf-field');
687
-
688
-
689
- // filter
690
- $fields = acf.apply_filters('get_fields', $fields);
691
-
692
- }
693
-
694
-
695
- //console.log('get_fields(%o, %o, %o) %o', s, $el, all, $fields);
696
- //console.log('acf.get_fields(%o):', this.get_selector(s) );
697
- //console.timeEnd("acf.get_fields");
698
-
699
-
700
- // return
701
- return $fields;
702
-
703
- },
704
-
705
-
706
- /*
707
- * get_field
708
- *
709
- * This function will return a jQuery selection based on a field key
710
- *
711
- * @type function
712
- * @date 8/09/2014
713
- * @since 5.0.0
714
- *
715
- * @param field_key (string)
716
- * @param $el (jQuery) element to look within
717
- * @return $field (jQuery)
718
- */
719
-
720
- get_field: function( s, $el ){
721
-
722
- // defaults
723
- s = s || '';
724
- $el = $el || false;
725
-
726
-
727
- // get fields
728
- var $fields = this.get_fields(s, $el, true);
729
-
730
-
731
- // check if exists
732
- if( $fields.exists() ) {
733
-
734
- return $fields.first();
735
-
736
- }
737
-
738
-
739
- // return
740
- return false;
741
-
742
- },
743
-
744
-
745
- /*
746
- * get_closest_field
747
- *
748
- * This function will return the closest parent field
749
- *
750
- * @type function
751
- * @date 8/09/2014
752
- * @since 5.0.0
753
- *
754
- * @param $el (jQuery) element to start from
755
- * @param args (object)
756
- * @return $field (jQuery)
757
- */
758
-
759
- get_closest_field : function( $el, s ){
760
-
761
- // defaults
762
- s = s || '';
763
-
764
-
765
- // return
766
- return $el.closest( this.get_selector(s) );
767
-
768
- },
769
-
770
-
771
- /*
772
- * get_field_wrap
773
- *
774
- * This function will return the closest parent field
775
- *
776
- * @type function
777
- * @date 8/09/2014
778
- * @since 5.0.0
779
- *
780
- * @param $el (jQuery) element to start from
781
- * @return $field (jQuery)
782
- */
783
-
784
- get_field_wrap: function( $el ){
785
-
786
- return $el.closest( this.get_selector() );
787
-
788
- },
789
-
790
-
791
- /*
792
- * get_field_key
793
- *
794
- * This function will return the field's key
795
- *
796
- * @type function
797
- * @date 8/09/2014
798
- * @since 5.0.0
799
- *
800
- * @param $field (jQuery)
801
- * @return (string)
802
- */
803
-
804
- get_field_key: function( $field ){
805
-
806
- return $field.data('key');
807
-
808
- },
809
-
810
-
811
- /*
812
- * get_field_type
813
- *
814
- * This function will return the field's type
815
- *
816
- * @type function
817
- * @date 8/09/2014
818
- * @since 5.0.0
819
- *
820
- * @param $field (jQuery)
821
- * @return (string)
822
- */
823
-
824
- get_field_type: function( $field ){
825
-
826
- return $field.data('type');
827
-
828
- },
829
-
830
-
831
- /*
832
- * get_data
833
- *
834
- * This function will return attribute data for a given elemnt
835
- *
836
- * @type function
837
- * @date 8/09/2014
838
- * @since 5.0.0
839
- *
840
- * @param $el (jQuery)
841
- * @param name (mixed)
842
- * @return (mixed)
843
- */
844
-
845
- get_data: function( $el, defaults ){
846
-
847
- // get data
848
- var data = $el.data();
849
-
850
-
851
- // defaults
852
- if( typeof defaults === 'object' ) {
853
-
854
- data = this.parse_args( data, defaults );
855
-
856
- }
857
-
858
-
859
- // return
860
- return data;
861
-
862
- },
863
-
864
-
865
- /*
866
- * get_uniqid
867
- *
868
- * This function will return a unique string ID
869
- *
870
- * @type function
871
- * @date 8/09/2014
872
- * @since 5.0.0
873
- *
874
- * @param prefix (string)
875
- * @param more_entropy (boolean)
876
- * @return (string)
877
- */
878
-
879
- get_uniqid : function( prefix, more_entropy ){
880
-
881
- // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
882
- // + revised by: Kankrelune (http://www.webfaktory.info/)
883
- // % note 1: Uses an internal counter (in php_js global) to avoid collision
884
- // * example 1: uniqid();
885
- // * returns 1: 'a30285b160c14'
886
- // * example 2: uniqid('foo');
887
- // * returns 2: 'fooa30285b1cd361'
888
- // * example 3: uniqid('bar', true);
889
- // * returns 3: 'bara20285b23dfd1.31879087'
890
- if (typeof prefix === 'undefined') {
891
- prefix = "";
892
- }
893
-
894
- var retId;
895
- var formatSeed = function (seed, reqWidth) {
896
- seed = parseInt(seed, 10).toString(16); // to hex str
897
- if (reqWidth < seed.length) { // so long we split
898
- return seed.slice(seed.length - reqWidth);
899
- }
900
- if (reqWidth > seed.length) { // so short we pad
901
- return Array(1 + (reqWidth - seed.length)).join('0') + seed;
902
- }
903
- return seed;
904
- };
905
-
906
- // BEGIN REDUNDANT
907
- if (!this.php_js) {
908
- this.php_js = {};
909
- }
910
- // END REDUNDANT
911
- if (!this.php_js.uniqidSeed) { // init seed with big random int
912
- this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
913
- }
914
- this.php_js.uniqidSeed++;
915
-
916
- retId = prefix; // start with prefix, add current milliseconds hex string
917
- retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
918
- retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
919
- if (more_entropy) {
920
- // for more entropy we add a float lower to 10
921
- retId += (Math.random() * 10).toFixed(8).toString();
922
- }
923
-
924
- return retId;
925
-
926
- },
927
-
928
-
929
- /*
930
- * serialize_form
931
- *
932
- * This function will create an object of data containing all form inputs within an element
933
- *
934
- * @type function
935
- * @date 8/09/2014
936
- * @since 5.0.0
937
- *
938
- * @param $el (jQuery selection)
939
- * @return $post_id (int)
940
- */
941
-
942
- serialize_form: function(){
943
-
944
- return this.serialize.apply( this, arguments );
945
-
946
- },
947
-
948
- serialize: function( $el, prefix ){
949
-
950
- // defaults
951
- prefix = prefix || '';
952
-
953
-
954
- // vars
955
- var data = {};
956
- var names = {};
957
- var values = $el.find('select, textarea, input').serializeArray();
958
-
959
-
960
- // populate data
961
- $.each( values, function( i, pair ) {
962
-
963
- // vars
964
- var name = pair.name;
965
- var value = pair.value;
966
-
967
-
968
- // prefix
969
- if( prefix ) {
970
-
971
- // bail early if does not contain
972
- if( name.indexOf(prefix) !== 0 ) return;
973
-
974
-
975
- // remove prefix
976
- name = name.slice(prefix.length);
977
-
978
-
979
- // name must not start as array piece
980
- if( name.slice(0, 1) == '[' ) {
981
-
982
- name = name.slice(1).replace(']', '');
983
-
984
- }
985
-
986
- }
987
-
988
-
989
- // initiate name
990
- if( name.slice(-2) === '[]' ) {
991
-
992
- // remove []
993
- name = name.slice(0, -2);
994
-
995
-
996
- // initiate counter
997
- if( typeof names[ name ] === 'undefined'){
998
-
999
- names[ name ] = -1;
1000
-
1001
- }
1002
-
1003
-
1004
- // increase counter
1005
- names[ name ]++;
1006
-
1007
-
1008
- // add key
1009
- name += '[' + names[ name ] +']';
1010
- }
1011
-
1012
-
1013
- // append to data
1014
- data[ name ] = value;
1015
-
1016
- });
1017
-
1018
-
1019
- //console.log('serialize', data);
1020
-
1021
-
1022
- // return
1023
- return data;
1024
-
1025
- },
1026
-
1027
-
1028
- /*
1029
- * remove_tr
1030
- *
1031
- * This function will remove a tr element with animation
1032
- *
1033
- * @type function
1034
- * @date 8/09/2014
1035
- * @since 5.0.0
1036
- *
1037
- * @param $tr (jQuery selection)
1038
- * @param callback (function) runs on complete
1039
- * @return n/a
1040
- */
1041
-
1042
- remove_tr : function( $tr, callback ){
1043
-
1044
- // vars
1045
- var height = $tr.height(),
1046
- children = $tr.children().length;
1047
-
1048
-
1049
- // add class
1050
- $tr.addClass('acf-remove-element');
1051
-
1052
-
1053
- // after animation
1054
- setTimeout(function(){
1055
-
1056
- // remove class
1057
- $tr.removeClass('acf-remove-element');
1058
-
1059
-
1060
- // vars
1061
- $tr.html('<td style="padding:0; height:' + height + 'px" colspan="' + children + '"></td>');
1062
-
1063
-
1064
- $tr.children('td').animate({ height : 0}, 250, function(){
1065
-
1066
- $tr.remove();
1067
-
1068
- if( typeof(callback) == 'function' ) {
1069
-
1070
- callback();
1071
-
1072
- }
1073
-
1074
-
1075
- });
1076
-
1077
-
1078
- }, 250);
1079
-
1080
- },
1081
-
1082
-
1083
- /*
1084
- * remove_el
1085
- *
1086
- * This function will remove an element with animation
1087
- *
1088
- * @type function
1089
- * @date 8/09/2014
1090
- * @since 5.0.0
1091
- *
1092
- * @param $el (jQuery selection)
1093
- * @param callback (function) runs on complete
1094
- * @param end_height (int)
1095
- * @return n/a
1096
- */
1097
-
1098
- remove_el : function( $el, callback, end_height ){
1099
-
1100
- // defaults
1101
- end_height = end_height || 0;
1102
-
1103
-
1104
- // vars
1105
- var height = $el.height(),
1106
- width = $el.width(),
1107
- margin = $el.css('margin'),
1108
- outer_height = $el.outerHeight(true);
1109
-
1110
-
1111
- // action
1112
- acf.do_action('remove', $el);
1113
-
1114
-
1115
- // create wrap
1116
- $el.wrap('<div class="acf-temp-remove" style="height:' + outer_height + 'px"></div>');
1117
- var $wrap = $el.parent();
1118
-
1119
-
1120
- // set pos
1121
- $el.css({
1122
- height: height,
1123
- width: width,
1124
- margin: margin,
1125
- position: 'absolute'
1126
- });
1127
-
1128
-
1129
- // fade
1130
- setTimeout(function(){
1131
-
1132
- // aniamte
1133
- $wrap.css({
1134
- opacity: 0,
1135
- height: end_height
1136
- });
1137
-
1138
- }, 50);
1139
-
1140
-
1141
- // animate complete
1142
- setTimeout(function(){
1143
-
1144
- // remove wrap
1145
- $wrap.remove();
1146
-
1147
-
1148
- // callback
1149
- if( typeof(callback) == 'function' ) {
1150
- callback.apply(this, arguments);
1151
- }
1152
-
1153
- }, 301);
1154
-
1155
- },
1156
-
1157
-
1158
- /*
1159
- * isset
1160
- *
1161
- * This function will return true if an object key exists
1162
- *
1163
- * @type function
1164
- * @date 8/09/2014
1165
- * @since 5.0.0
1166
- *
1167
- * @param (object)
1168
- * @param key1 (string)
1169
- * @param key2 (string)
1170
- * @param ...
1171
- * @return (boolean)
1172
- */
1173
-
1174
- isset : function(){
1175
-
1176
- var a = arguments,
1177
- l = a.length,
1178
- c = null,
1179
- undef;
1180
-
1181
- if (l === 0) {
1182
- throw new Error('Empty isset');
1183
- }
1184
-
1185
- c = a[0];
1186
-
1187
- for (i = 1; i < l; i++) {
1188
-
1189
- if (a[i] === undef || c[ a[i] ] === undef) {
1190
- return false;
1191
- }
1192
-
1193
- c = c[ a[i] ];
1194
-
1195
- }
1196
-
1197
- return true;
1198
-
1199
- },
1200
-
1201
-
1202
- /*
1203
- * maybe_get
1204
- *
1205
- * This function will attempt to return a value and return null if not possible
1206
- *
1207
- * @type function
1208
- * @date 8/09/2014
1209
- * @since 5.0.0
1210
- *
1211
- * @param obj (object) the array to look within
1212
- * @param key (key) the array key to look for. Nested values may be found using '/'
1213
- * @param value (mixed) the value returned if not found
1214
- * @return (mixed)
1215
- */
1216
-
1217
- maybe_get: function( obj, key, value ){
1218
-
1219
- // default
1220
- if( typeof value == 'undefined' ) value = null;
1221
-
1222
-
1223
- // convert type to string and split
1224
- keys = String(key).split('.');
1225
-
1226
-
1227
- // loop through keys
1228
- for( var i in keys ) {
1229
-
1230
- // vars
1231
- var key = keys[i];
1232
-
1233
-
1234
- // bail ealry if not set
1235
- if( typeof obj[ key ] === 'undefined' ) {
1236
-
1237
- return value;
1238
-
1239
- }
1240
-
1241
-
1242
- // update obj
1243
- obj = obj[ key ];
1244
-
1245
- }
1246
-
1247
-
1248
- // return
1249
- return obj;
1250
-
1251
- },
1252
-
1253
-
1254
- /*
1255
- * open_popup
1256
- *
1257
- * This function will create and open a popup modal
1258
- *
1259
- * @type function
1260
- * @date 8/09/2014
1261
- * @since 5.0.0
1262
- *
1263
- * @param args (object)
1264
- * @return n/a
1265
- */
1266
-
1267
- open_popup : function( args ){
1268
-
1269
- // vars
1270
- $popup = $('body > #acf-popup');
1271
-
1272
-
1273
- // already exists?
1274
- if( $popup.exists() ) {
1275
-
1276
- return update_popup(args);
1277
-
1278
- }
1279
-
1280
-
1281
- // template
1282
- var tmpl = [
1283
- '<div id="acf-popup">',
1284
- '<div class="acf-popup-box acf-box">',
1285
- '<div class="title"><h3></h3><a href="#" class="acf-icon -cancel grey acf-close-popup"></a></div>',
1286
- '<div class="inner"></div>',
1287
- '<div class="loading"><i class="acf-loading"></i></div>',
1288
- '</div>',
1289
- '<div class="bg"></div>',
1290
- '</div>'
1291
- ].join('');
1292
-
1293
-
1294
- // append
1295
- $('body').append( tmpl );
1296
-
1297
-
1298
- $('#acf-popup').on('click', '.bg, .acf-close-popup', function( e ){
1299
-
1300
- e.preventDefault();
1301
-
1302
- acf.close_popup();
1303
-
1304
- });
1305
-
1306
-
1307
- // update
1308
- return this.update_popup(args);
1309
-
1310
- },
1311
-
1312
-
1313
- /*
1314
- * update_popup
1315
- *
1316
- * This function will update the content within a popup modal
1317
- *
1318
- * @type function
1319
- * @date 8/09/2014
1320
- * @since 5.0.0
1321
- *
1322
- * @param args (object)
1323
- * @return n/a
1324
- */
1325
-
1326
- update_popup : function( args ){
1327
-
1328
- // vars
1329
- $popup = $('#acf-popup');
1330
-
1331
-
1332
- // validate
1333
- if( !$popup.exists() )
1334
- {
1335
- return false
1336
- }
1337
-
1338
-
1339
- // defaults
1340
- args = $.extend({}, {
1341
- title : '',
1342
- content : '',
1343
- width : 0,
1344
- height : 0,
1345
- loading : false
1346
- }, args);
1347
-
1348
-
1349
- if( args.title ) {
1350
-
1351
- $popup.find('.title h3').html( args.title );
1352
-
1353
- }
1354
-
1355
- if( args.content ) {
1356
-
1357
- $inner = $popup.find('.inner:first');
1358
-
1359
- $inner.html( args.content );
1360
-
1361
- acf.do_action('append', $inner);
1362
-
1363
- // update height
1364
- $inner.attr('style', 'position: relative;');
1365
- args.height = $inner.outerHeight();
1366
- $inner.removeAttr('style');
1367
-
1368
- }
1369
-
1370
- if( args.width ) {
1371
-
1372
- $popup.find('.acf-popup-box').css({
1373
- 'width' : args.width,
1374
- 'margin-left' : 0 - (args.width / 2)
1375
- });
1376
-
1377
- }
1378
-
1379
- if( args.height ) {
1380
-
1381
- // add h3 height (44)
1382
- args.height += 44;
1383
-
1384
- $popup.find('.acf-popup-box').css({
1385
- 'height' : args.height,
1386
- 'margin-top' : 0 - (args.height / 2)
1387
- });
1388
-
1389
- }
1390
-
1391
-
1392
- if( args.loading ) {
1393
-
1394
- $popup.find('.loading').show();
1395
-
1396
- } else {
1397
-
1398
- $popup.find('.loading').hide();
1399
-
1400
- }
1401
-
1402
- return $popup;
1403
- },
1404
-
1405
-
1406
- /*
1407
- * close_popup
1408
- *
1409
- * This function will close and remove a popup modal
1410
- *
1411
- * @type function
1412
- * @date 8/09/2014
1413
- * @since 5.0.0
1414
- *
1415
- * @param n/a
1416
- * @return n/a
1417
- */
1418
-
1419
- close_popup : function(){
1420
-
1421
- // vars
1422
- $popup = $('#acf-popup');
1423
-
1424
-
1425
- // already exists?
1426
- if( $popup.exists() )
1427
- {
1428
- $popup.remove();
1429
- }
1430
-
1431
- },
1432
-
1433
-
1434
- /*
1435
- * update_user_setting
1436
- *
1437
- * This function will send an AJAX request to update a user setting
1438
- *
1439
- * @type function
1440
- * @date 8/09/2014
1441
- * @since 5.0.0
1442
- *
1443
- * @param $post_id (int)
1444
- * @return $post_id (int)
1445
- */
1446
-
1447
- update_user_setting : function( name, value ) {
1448
-
1449
- // ajax
1450
- $.ajax({
1451
- url : acf.get('ajaxurl'),
1452
- dataType : 'html',
1453
- type : 'post',
1454
- data : acf.prepare_for_ajax({
1455
- 'action' : 'acf/update_user_setting',
1456
- 'name' : name,
1457
- 'value' : value
1458
- })
1459
- });
1460
-
1461
- },
1462
-
1463
-
1464
- /*
1465
- * prepare_for_ajax
1466
- *
1467
- * This function will prepare data for an AJAX request
1468
- *
1469
- * @type function
1470
- * @date 8/09/2014
1471
- * @since 5.0.0
1472
- *
1473
- * @param args (object)
1474
- * @return args
1475
- */
1476
-
1477
- prepare_for_ajax : function( args ) {
1478
-
1479
- // vars
1480
- var data = {};
1481
-
1482
-
1483
- // $.ajax() expects all args to be 'non-nested'
1484
- $.each(args, function(k,v){
1485
-
1486
- // object
1487
- if( $.isPlainObject(v) && !$.isEmptyObject(v) ) {
1488
-
1489
- // loop
1490
- $.each(v, function(k2,v2){
1491
-
1492
- // convert string
1493
- k2 = k2 + '';
1494
-
1495
-
1496
- // vars
1497
- var i = k2.indexOf('[');
1498
-
1499
-
1500
- // starts with [
1501
- if( i == 0 ) {
1502
-
1503
- k2 = k + k2;
1504
-
1505
- // contains [
1506
- } else if( i > 0 ) {
1507
-
1508
- k2 = k + '[' + k2.slice(0, i) + ']' + k2.slice(i);
1509
-
1510
- // no [
1511
- } else {
1512
-
1513
- k2 = k + '[' + k2 + ']';
1514
-
1515
- }
1516
-
1517
-
1518
- // append
1519
- data[k2] = v2;
1520
-
1521
- });
1522
-
1523
- // else
1524
- } else {
1525
-
1526
- data[k] = v;
1527
-
1528
- }
1529
-
1530
- });
1531
-
1532
-
1533
- // required
1534
- data.nonce = acf.get('nonce');
1535
- data.post_id = acf.get('post_id');
1536
-
1537
-
1538
- // filter for 3rd party customization
1539
- data = acf.apply_filters('prepare_for_ajax', data);
1540
-
1541
-
1542
- // return
1543
- return data;
1544
-
1545
- },
1546
-
1547
-
1548
- /*
1549
- * is_ajax_success
1550
- *
1551
- * This function will return true for a successful WP AJAX response
1552
- *
1553
- * @type function
1554
- * @date 8/09/2014
1555
- * @since 5.0.0
1556
- *
1557
- * @param json (object)
1558
- * @return (boolean)
1559
- */
1560
-
1561
- is_ajax_success : function( json ) {
1562
-
1563
- if( json && json.success ) {
1564
-
1565
- return true;
1566
-
1567
- }
1568
-
1569
- return false;
1570
-
1571
- },
1572
-
1573
-
1574
- /*
1575
- * get_ajax_message
1576
- *
1577
- * This function will return an object containing error/message information
1578
- *
1579
- * @type function
1580
- * @date 8/09/2014
1581
- * @since 5.0.0
1582
- *
1583
- * @param json (object)
1584
- * @return (boolean)
1585
- */
1586
-
1587
- get_ajax_message: function( json ) {
1588
-
1589
- // vars
1590
- var message = {
1591
- text: '',
1592
- type: 'error'
1593
- };
1594
-
1595
-
1596
- // bail early if no json
1597
- if( !json ) {
1598
-
1599
- return message;
1600
-
1601
- }
1602
-
1603
-
1604
- // PHP error (too may themes will have warnings / errors. Don't show these in ACF taxonomy popup)
1605
- /*
1606
- if( typeof json === 'string' ) {
1607
-
1608
- message.text = json;
1609
- return message;
1610
-
1611
- }
1612
- */
1613
-
1614
-
1615
- // success
1616
- if( json.success ) {
1617
-
1618
- message.type = 'success';
1619
-
1620
- }
1621
-
1622
-
1623
- // message
1624
- if( json.data && json.data.message ) {
1625
-
1626
- message.text = json.data.message;
1627
-
1628
- }
1629
-
1630
-
1631
- // error
1632
- if( json.data && json.data.error ) {
1633
-
1634
- message.text = json.data.error;
1635
-
1636
- }
1637
-
1638
-
1639
- // return
1640
- return message;
1641
-
1642
- },
1643
-
1644
-
1645
- /*
1646
- * is_in_view
1647
- *
1648
- * This function will return true if a jQuery element is visible in browser
1649
- *
1650
- * @type function
1651
- * @date 8/09/2014
1652
- * @since 5.0.0
1653
- *
1654
- * @param $el (jQuery)
1655
- * @return (boolean)
1656
- */
1657
-
1658
- is_in_view: function( $el ) {
1659
-
1660
- // vars
1661
- var elemTop = $el.offset().top,
1662
- elemBottom = elemTop + $el.height();
1663
-
1664
-
1665
- // bail early if hidden
1666
- if( elemTop === elemBottom ) {
1667
-
1668
- return false;
1669
-
1670
- }
1671
-
1672
-
1673
- // more vars
1674
- var docViewTop = $(window).scrollTop(),
1675
- docViewBottom = docViewTop + $(window).height();
1676
-
1677
-
1678
- // return
1679
- return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
1680
-
1681
- },
1682
-
1683
-
1684
- /*
1685
- * val
1686
- *
1687
- * This function will update an elements value and trigger the change event if different
1688
- *
1689
- * @type function
1690
- * @date 16/10/2014
1691
- * @since 5.0.9
1692
- *
1693
- * @param $el (jQuery)
1694
- * @param val (mixed)
1695
- * @return n/a
1696
- */
1697
-
1698
- val: function( $el, val ){
1699
-
1700
- // vars
1701
- var orig = $el.val();
1702
-
1703
-
1704
- // update value
1705
- $el.val( val );
1706
-
1707
-
1708
- // trigger change
1709
- if( val != orig ) {
1710
-
1711
- $el.trigger('change');
1712
-
1713
- }
1714
-
1715
- },
1716
-
1717
-
1718
- /*
1719
- * str_replace
1720
- *
1721
- * This function will perform a str replace similar to php function str_replace
1722
- *
1723
- * @type function
1724
- * @date 1/05/2015
1725
- * @since 5.2.3
1726
- *
1727
- * @param $search (string)
1728
- * @param $replace (string)
1729
- * @param $subject (string)
1730
- * @return (string)
1731
- */
1732
-
1733
- str_replace: function( search, replace, subject ) {
1734
-
1735
- return subject.split(search).join(replace);
1736
-
1737
- },
1738
-
1739
-
1740
- /*
1741
- * str_sanitize
1742
- *
1743
- * description
1744
- *
1745
- * @type function
1746
- * @date 4/06/2015
1747
- * @since 5.2.3
1748
- *
1749
- * @param $post_id (int)
1750
- * @return $post_id (int)
1751
- */
1752
-
1753
- str_sanitize: function( string ) {
1754
-
1755
- // chars (https://jsperf.com/replace-foreign-characters)
1756
- var map = {
1757
- "À": "A",
1758
- "Á": "A",
1759
- "Â": "A",
1760
- "Ã": "A",
1761
- "Ä": "A",
1762
- "Å": "A",
1763
- "Æ": "AE",
1764
- "Ç": "C",
1765
- "È": "E",
1766
- "É": "E",
1767
- "Ê": "E",
1768
- "Ë": "E",
1769
- "Ì": "I",
1770
- "Í": "I",
1771
- "Î": "I",
1772
- "Ï": "I",
1773
- "Ð": "D",
1774
- "Ñ": "N",
1775
- "Ò": "O",
1776
- "Ó": "O",
1777
- "Ô": "O",
1778
- "Õ": "O",
1779
- "Ö": "O",
1780
- "Ø": "O",
1781
- "Ù": "U",
1782
- "Ú": "U",
1783
- "Û": "U",
1784
- "Ü": "U",
1785
- "Ý": "Y",
1786
- "ß": "s",
1787
- "à": "a",
1788
- "á": "a",
1789
- "â": "a",
1790
- "ã": "a",
1791
- "ä": "a",
1792
- "å": "a",
1793
- "æ": "ae",
1794
- "ç": "c",
1795
- "è": "e",
1796
- "é": "e",
1797
- "ê": "e",
1798
- "ë": "e",
1799
- "ì": "i",
1800
- "í": "i",
1801
- "î": "i",
1802
- "ï": "i",
1803
- "ñ": "n",
1804
- "ò": "o",
1805
- "ó": "o",
1806
- "ô": "o",
1807
- "õ": "o",
1808
- "ö": "o",
1809
- "ø": "o",
1810
- "ù": "u",
1811
- "ú": "u",
1812
- "û": "u",
1813
- "ü": "u",
1814
- "ý": "y",
1815
- "ÿ": "y",
1816
- "Ā": "A",
1817
- "ā": "a",
1818
- "Ă": "A",
1819
- "ă": "a",
1820
- "Ą": "A",
1821
- "ą": "a",
1822
- "Ć": "C",
1823
- "ć": "c",
1824
- "Ĉ": "C",
1825
- "ĉ": "c",
1826
- "Ċ": "C",
1827
- "ċ": "c",
1828
- "Č": "C",
1829
- "č": "c",
1830
- "Ď": "D",
1831
- "ď": "d",
1832
- "Đ": "D",
1833
- "đ": "d",
1834
- "Ē": "E",
1835
- "ē": "e",
1836
- "Ĕ": "E",
1837
- "ĕ": "e",
1838
- "Ė": "E",
1839
- "ė": "e",
1840
- "Ę": "E",
1841
- "ę": "e",
1842
- "Ě": "E",
1843
- "ě": "e",
1844
- "Ĝ": "G",
1845
- "ĝ": "g",
1846
- "Ğ": "G",
1847
- "ğ": "g",
1848
- "Ġ": "G",
1849
- "ġ": "g",
1850
- "Ģ": "G",
1851
- "ģ": "g",
1852
- "Ĥ": "H",
1853
- "ĥ": "h",
1854
- "Ħ": "H",
1855
- "ħ": "h",
1856
- "Ĩ": "I",
1857
- "ĩ": "i",
1858
- "Ī": "I",
1859
- "ī": "i",
1860
- "Ĭ": "I",
1861
- "ĭ": "i",
1862
- "Į": "I",
1863
- "į": "i",
1864
- "İ": "I",
1865
- "ı": "i",
1866
- "IJ": "IJ",
1867
- "ij": "ij",
1868
- "Ĵ": "J",
1869
- "ĵ": "j",
1870
- "Ķ": "K",
1871
- "ķ": "k",
1872
- "Ĺ": "L",
1873
- "ĺ": "l",
1874
- "Ļ": "L",
1875
- "ļ": "l",
1876
- "Ľ": "L",
1877
- "ľ": "l",
1878
- "Ŀ": "L",
1879
- "ŀ": "l",
1880
- "Ł": "l",
1881
- "ł": "l",
1882
- "Ń": "N",
1883
- "ń": "n",
1884
- "Ņ": "N",
1885
- "ņ": "n",
1886
- "Ň": "N",
1887
- "ň": "n",
1888
- "ʼn": "n",
1889
- "Ō": "O",
1890
- "ō": "o",
1891
- "Ŏ": "O",
1892
- "ŏ": "o",
1893
- "Ő": "O",
1894
- "ő": "o",
1895
- "Œ": "OE",
1896
- "œ": "oe",
1897
- "Ŕ": "R",
1898
- "ŕ": "r",
1899
- "Ŗ": "R",
1900
- "ŗ": "r",
1901
- "Ř": "R",
1902
- "ř": "r",
1903
- "Ś": "S",
1904
- "ś": "s",
1905
- "Ŝ": "S",
1906
- "ŝ": "s",
1907
- "Ş": "S",
1908
- "ş": "s",
1909
- "Š": "S",
1910
- "š": "s",
1911
- "Ţ": "T",
1912
- "ţ": "t",
1913
- "Ť": "T",
1914
- "ť": "t",
1915
- "Ŧ": "T",
1916
- "ŧ": "t",
1917
- "Ũ": "U",
1918
- "ũ": "u",
1919
- "Ū": "U",
1920
- "ū": "u",
1921
- "Ŭ": "U",
1922
- "ŭ": "u",
1923
- "Ů": "U",
1924
- "ů": "u",
1925
- "Ű": "U",
1926
- "ű": "u",
1927
- "Ų": "U",
1928
- "ų": "u",
1929
- "Ŵ": "W",
1930
- "ŵ": "w",
1931
- "Ŷ": "Y",
1932
- "ŷ": "y",
1933
- "Ÿ": "Y",
1934
- "Ź": "Z",
1935
- "ź": "z",
1936
- "Ż": "Z",
1937
- "ż": "z",
1938
- "Ž": "Z",
1939
- "ž": "z",
1940
- "ſ": "s",
1941
- "ƒ": "f",
1942
- "Ơ": "O",
1943
- "ơ": "o",
1944
- "Ư": "U",
1945
- "ư": "u",
1946
- "Ǎ": "A",
1947
- "ǎ": "a",
1948
- "Ǐ": "I",
1949
- "ǐ": "i",
1950
- "Ǒ": "O",
1951
- "ǒ": "o",
1952
- "Ǔ": "U",
1953
- "ǔ": "u",
1954
- "Ǖ": "U",
1955
- "ǖ": "u",
1956
- "Ǘ": "U",
1957
- "ǘ": "u",
1958
- "Ǚ": "U",
1959
- "ǚ": "u",
1960
- "Ǜ": "U",
1961
- "ǜ": "u",
1962
- "Ǻ": "A",
1963
- "ǻ": "a",
1964
- "Ǽ": "AE",
1965
- "ǽ": "ae",
1966
- "Ǿ": "O",
1967
- "ǿ": "o",
1968
-
1969
- // extra
1970
- ' ': '_',
1971
- '\'': '',
1972
- '?': '',
1973
- '/': '',
1974
- '\\': '',
1975
- '.': '',
1976
- ',': '',
1977
- '`': '',
1978
- '>': '',
1979
- '<': '',
1980
- '"': '',
1981
- '[': '',
1982
- ']': '',
1983
- '|': '',
1984
- '{': '',
1985
- '}': '',
1986
- '(': '',
1987
- ')': ''
1988
- };
1989
-
1990
-
1991
- // vars
1992
- var regexp = /\W/g,
1993
- mapping = function (c) { return (typeof map[c] !== 'undefined') ? map[c] : c; };
1994
-
1995
-
1996
- // replace
1997
- string = string.replace(regexp, mapping);
1998
-
1999
-
2000
- // lower case
2001
- string = string.toLowerCase();
2002
-
2003
-
2004
- // return
2005
- return string;
2006
-
2007
- },
2008
-
2009
-
2010
- /*
2011
- * addslashes
2012
- *
2013
- * This function mimics the PHP addslashes function.
2014
- * Returns a string with backslashes before characters that need to be escaped.
2015
- *
2016
- * @type function
2017
- * @date 9/1/17
2018
- * @since 5.5.0
2019
- *
2020
- * @param text (string)
2021
- * @return (string)
2022
- */
2023
-
2024
- addslashes: function(text){
2025
-
2026
- return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2027
-
2028
- },
2029
-
2030
-
2031
- /**
2032
- * esc_html
2033
- *
2034
- * This function will escape HTML characters for safe use
2035
- *
2036
- * @source https://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
2037
- * @date 20/9/17
2038
- * @since 5.6.3
2039
- *
2040
- * @param n/a
2041
- * @return n/a
2042
- */
2043
-
2044
- esc_html: function( string ){
2045
-
2046
- var entityMap = {
2047
- '&': '&amp;',
2048
- '<': '&lt;',
2049
- '>': '&gt;',
2050
- '"': '&quot;',
2051
- "'": '&#39;',
2052
- '/': '&#x2F;',
2053
- '`': '&#x60;',
2054
- '=': '&#x3D;'
2055
- };
2056
-
2057
- return String(string).replace(/[&<>"'`=\/]/g, function (s) {
2058
- return entityMap[s];
2059
- });
2060
-
2061
- },
2062
-
2063
-
2064
- /*
2065
- * render_select
2066
- *
2067
- * This function will update a select field with new choices
2068
- *
2069
- * @type function
2070
- * @date 8/04/2014
2071
- * @since 5.0.0
2072
- *
2073
- * @param $select
2074
- * @param choices
2075
- * @return n/a
2076
- */
2077
-
2078
- render_select: function( $select, choices ){
2079
-
2080
- // vars
2081
- var value = $select.val();
2082
-
2083
-
2084
- // clear choices
2085
- $select.html('');
2086
-
2087
-
2088
- // bail early if no choices
2089
- if( !choices ) {
2090
-
2091
- return;
2092
-
2093
- }
2094
-
2095
-
2096
- // populate choices
2097
- $.each(choices, function( i, item ){
2098
-
2099
- // vars
2100
- var $optgroup = $select;
2101
-
2102
-
2103
- // add group
2104
- if( item.group ) {
2105
-
2106
- $optgroup = $select.find('optgroup[label="' + item.group + '"]');
2107
-
2108
- if( !$optgroup.exists() ) {
2109
-
2110
- $optgroup = $('<optgroup label="' + item.group + '"></optgroup>');
2111
-
2112
- $select.append( $optgroup );
2113
-
2114
- }
2115
-
2116
- }
2117
-
2118
-
2119
- // append select
2120
- $optgroup.append( '<option value="' + item.value + '">' + acf.esc_html(item.label) + '</option>' );
2121
-
2122
-
2123
- // selectedIndex
2124
- if( value == item.value ) {
2125
-
2126
- $select.prop('selectedIndex', i);
2127
-
2128
- }
2129
-
2130
- });
2131
-
2132
- },
2133
-
2134
-
2135
- /*
2136
- * duplicate
2137
- *
2138
- * This function will duplicate and return an element
2139
- *
2140
- * @type function
2141
- * @date 22/08/2015
2142
- * @since 5.2.3
2143
- *
2144
- * @param $el (jQuery) object to be duplicated
2145
- * @param attr (string) attrbute name where $el id can be found
2146
- * @return $el2 (jQuery)
2147
- */
2148
-
2149
- duplicate: function( args ){
2150
-
2151
- //console.time('duplicate');
2152
-
2153
-
2154
- // backwards compatibility
2155
- // - array of settings added in v5.4.6
2156
- if( typeof args.length !== 'undefined' ) args = { $el: args };
2157
-
2158
-
2159
- // defaults
2160
- args = acf.parse_args(args, {
2161
- $el: false,
2162
- search: '',
2163
- replace: '',
2164
- before: function( $el ){},
2165
- after: function( $el, $el2 ){},
2166
- append: function( $el, $el2 ){ $el.after( $el2 ); }
2167
- });
2168
-
2169
-
2170
- // vars
2171
- var $el = args.$el,
2172
- $el2;
2173
-
2174
-
2175
- // search
2176
- if( !args.search ) args.search = $el.attr('data-id');
2177
-
2178
-
2179
- // replace
2180
- if( !args.replace ) args.replace = acf.get_uniqid();
2181
-
2182
-
2183
- // before
2184
- // - allow acf to modify DOM
2185
- // - fixes bug where select field option is not selected
2186
- args.before.apply( this, [$el] );
2187
- acf.do_action('before_duplicate', $el);
2188
-
2189
-
2190
- // clone
2191
- var $el2 = $el.clone();
2192
-
2193
-
2194
- // remove acf-clone (may be a clone)
2195
- $el2.removeClass('acf-clone');
2196
-
2197
-
2198
- // remove JS functionality
2199
- acf.do_action('remove', $el2);
2200
-
2201
-
2202
- // find / replace
2203
- if( args.search ) {
2204
-
2205
- // replace data
2206
- $el2.attr('data-id', args.replace);
2207
-
2208
-
2209
- // replace ids
2210
- $el2.find('[id*="' + args.search + '"]').each(function(){
2211
-
2212
- $(this).attr('id', $(this).attr('id').replace(args.search, args.replace) );
2213
-
2214
- });
2215
-
2216
-
2217
- // replace names
2218
- $el2.find('[name*="' + args.search + '"]').each(function(){
2219
-
2220
- $(this).attr('name', $(this).attr('name').replace(args.search, args.replace) );
2221
-
2222
- });
2223
-
2224
-
2225
- // replace label for
2226
- $el2.find('label[for*="' + args.search + '"]').each(function(){
2227
-
2228
- $(this).attr('for', $(this).attr('for').replace(args.search, args.replace) );
2229
-
2230
- });
2231
-
2232
- }
2233
-
2234
-
2235
- // remove ui-sortable
2236
- $el2.find('.ui-sortable').removeClass('ui-sortable');
2237
-
2238
-
2239
- // after
2240
- // - allow acf to modify DOM
2241
- acf.do_action('after_duplicate', $el, $el2 );
2242
- args.after.apply( this, [$el, $el2] );
2243
-
2244
-
2245
- // append
2246
- args.append.apply( this, [$el, $el2] );
2247
-
2248
-
2249
- // add JS functionality
2250
- // - allow element to be moved into a visible position before fire action
2251
- setTimeout(function(){
2252
-
2253
- acf.do_action('append', $el2);
2254
-
2255
- }, 1);
2256
-
2257
-
2258
- //console.timeEnd('duplicate');
2259
-
2260
-
2261
- // return
2262
- return $el2;
2263
-
2264
- },
2265
-
2266
- decode: function( string ){
2267
-
2268
- return $('<textarea/>').html( string ).text();
2269
-
2270
- },
2271
-
2272
-
2273
- /*
2274
- * parse_args
2275
- *
2276
- * This function will merge together defaults and args much like the WP wp_parse_args function
2277
- *
2278
- * @type function
2279
- * @date 11/04/2016
2280
- * @since 5.3.8
2281
- *
2282
- * @param args (object)
2283
- * @param defaults (object)
2284
- * @return args
2285
- */
2286
-
2287
- parse_args: function( args, defaults ) {
2288
-
2289
- // defaults
2290
- if( typeof args !== 'object' ) args = {};
2291
- if( typeof defaults !== 'object' ) defaults = {};
2292
-
2293
-
2294
- // return
2295
- return $.extend({}, defaults, args);
2296
-
2297
- },
2298
-
2299
-
2300
- /*
2301
- * enqueue_script
2302
- *
2303
- * This function will append a script to the page
2304
- *
2305
- * @source https://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/
2306
- * @type function
2307
- * @date 27/08/2016
2308
- * @since 5.4.0
2309
- *
2310
- * @param url (string)
2311
- * @param callback (function)
2312
- * @return na
2313
- */
2314
-
2315
- enqueue_script: function( url, callback ) {
2316
-
2317
- // vars
2318
- var script = document.createElement('script');
2319
-
2320
-
2321
- // atts
2322
- script.type = "text/javascript";
2323
- script.src = url;
2324
- script.async = true;
2325
-
2326
-
2327
- // ie
2328
- if( script.readyState ) {
2329
-
2330
- script.onreadystatechange = function(){
2331
-
2332
- if( script.readyState == 'loaded' || script.readyState == 'complete' ){
2333
-
2334
- script.onreadystatechange = null;
2335
- callback();
2336
-
2337
- }
2338
-
2339
- };
2340
-
2341
- // normal browsers
2342
- } else {
2343
-
2344
- script.onload = function(){
2345
- callback();
2346
- };
2347
-
2348
- }
2349
-
2350
-
2351
- // append
2352
- document.body.appendChild(script);
2353
-
2354
- }
2355
-
2356
- };
2357
-
2358
-
2359
- /*
2360
- * acf.model
2361
- *
2362
- * This model acts as a scafold for action.event driven modules
2363
- *
2364
- * @type object
2365
- * @date 8/09/2014
2366
- * @since 5.0.0
2367
- *
2368
- * @param (object)
2369
- * @return (object)
2370
- */
2371
-
2372
- acf.model = {
2373
-
2374
- // vars
2375
- actions: {},
2376
- filters: {},
2377
- events: {},
2378
-
2379
- extend: function( args ){
2380
-
2381
- // extend
2382
- var model = $.extend( {}, this, args );
2383
-
2384
-
2385
- // setup actions
2386
- $.each(model.actions, function( name, callback ){
2387
-
2388
- model._add_action( name, callback );
2389
-
2390
- });
2391
-
2392
-
2393
- // setup filters
2394
- $.each(model.filters, function( name, callback ){
2395
-
2396
- model._add_filter( name, callback );
2397
-
2398
- });
2399
-
2400
-
2401
- // setup events
2402
- $.each(model.events, function( name, callback ){
2403
-
2404
- model._add_event( name, callback );
2405
-
2406
- });
2407
-
2408
-
2409
- // return
2410
- return model;
2411
-
2412
- },
2413
-
2414
- _add_action: function( name, callback ) {
2415
-
2416
- // split
2417
- var model = this,
2418
- data = name.split(' ');
2419
-
2420
-
2421
- // add missing priority
2422
- var name = data[0] || '',
2423
- priority = data[1] || 10;
2424
-
2425
-
2426
- // add action
2427
- acf.add_action(name, model[ callback ], priority, model);
2428
-
2429
- },
2430
-
2431
- _add_filter: function( name, callback ) {
2432
-
2433
- // split
2434
- var model = this,
2435
- data = name.split(' ');
2436
-
2437
-
2438
- // add missing priority
2439
- var name = data[0] || '',
2440
- priority = data[1] || 10;
2441
-
2442
-
2443
- // add action
2444
- acf.add_filter(name, model[ callback ], priority, model);
2445
-
2446
- },
2447
-
2448
- _add_event: function( name, callback ) {
2449
-
2450
- // vars
2451
- var model = this,
2452
- i = name.indexOf(' '),
2453
- event = (i > 0) ? name.substr(0,i) : name,
2454
- selector = (i > 0) ? name.substr(i+1) : '';
2455
-
2456
-
2457
- // event
2458
- var fn = function( e ){
2459
-
2460
- // append $el to event object
2461
- e.$el = $(this);
2462
-
2463
-
2464
- // event
2465
- if( typeof model.event === 'function' ) {
2466
- e = model.event( e );
2467
- }
2468
-
2469
-
2470
- // callback
2471
- model[ callback ].apply(model, arguments);
2472
-
2473
- };
2474
-
2475
-
2476
- // add event
2477
- if( selector ) {
2478
- $(document).on(event, selector, fn);
2479
- } else {
2480
- $(document).on(event, fn);
2481
- }
2482
-
2483
- },
2484
-
2485
- get: function( name, value ){
2486
-
2487
- // defaults
2488
- value = value || null;
2489
-
2490
-
2491
- // get
2492
- if( typeof this[ name ] !== 'undefined' ) {
2493
-
2494
- value = this[ name ];
2495
-
2496
- }
2497
-
2498
-
2499
- // return
2500
- return value;
2501
-
2502
- },
2503
-
2504
-
2505
- set: function( name, value ){
2506
-
2507
- // set
2508
- this[ name ] = value;
2509
-
2510
-
2511
- // function for 3rd party
2512
- if( typeof this[ '_set_' + name ] === 'function' ) {
2513
-
2514
- this[ '_set_' + name ].apply(this);
2515
-
2516
- }
2517
-
2518
-
2519
- // return for chaining
2520
- return this;
2521
-
2522
- }
2523
-
2524
- };
2525
-
2526
-
2527
- /*
2528
- * field
2529
- *
2530
- * This model sets up many of the field's interactions
2531
- *
2532
- * @type function
2533
- * @date 21/02/2014
2534
- * @since 3.5.1
2535
- *
2536
- * @param n/a
2537
- * @return n/a
2538
- */
2539
-
2540
- acf.field = acf.model.extend({
2541
-
2542
- // vars
2543
- type: '',
2544
- o: {},
2545
- $field: null,
2546
-
2547
- _add_action: function( name, callback ) {
2548
-
2549
- // vars
2550
- var model = this;
2551
-
2552
-
2553
- // update name
2554
- name = name + '_field/type=' + model.type;
2555
-
2556
-
2557
- // add action
2558
- acf.add_action(name, function( $field ){
2559
-
2560
- // focus
2561
- model.set('$field', $field);
2562
-
2563
-
2564
- // callback
2565
- model[ callback ].apply(model, arguments);
2566
-
2567
- });
2568
-
2569
- },
2570
-
2571
- _add_filter: function( name, callback ) {
2572
-
2573
- // vars
2574
- var model = this;
2575
-
2576
-
2577
- // update name
2578
- name = name + '_field/type=' + model.type;
2579
-
2580
-
2581
- // add action
2582
- acf.add_filter(name, function( $field ){
2583
-
2584
- // focus
2585
- model.set('$field', $field);
2586
-
2587
-
2588
- // callback
2589
- model[ callback ].apply(model, arguments);
2590
-
2591
- });
2592
-
2593
- },
2594
-
2595
- _add_event: function( name, callback ) {
2596
-
2597
- // vars
2598
- var model = this,
2599
- event = name.substr(0,name.indexOf(' ')),
2600
- selector = name.substr(name.indexOf(' ')+1),
2601
- context = acf.get_selector(model.type);
2602
-
2603
-
2604
- // add event
2605
- $(document).on(event, context + ' ' + selector, function( e ){
2606
-
2607
- // vars
2608
- var $el = $(this);
2609
- var $field = acf.get_closest_field( $el, model.type );
2610
-
2611
-
2612
- // bail early if no field
2613
- if( !$field.length ) return;
2614
-
2615
-
2616
- // focus
2617
- if( !$field.is(model.$field) ) {
2618
- model.set('$field', $field);
2619
- }
2620
-
2621
-
2622
- // append to event
2623
- e.$el = $el;
2624
- e.$field = $field;
2625
-
2626
-
2627
- // callback
2628
- model[ callback ].apply(model, [e]);
2629
-
2630
- });
2631
-
2632
- },
2633
-
2634
- _set_$field: function(){
2635
-
2636
- // callback
2637
- if( typeof this.focus === 'function' ) {
2638
- this.focus();
2639
- }
2640
-
2641
- },
2642
-
2643
- // depreciated
2644
- doFocus: function( $field ){
2645
-
2646
- return this.set('$field', $field);
2647
-
2648
- }
2649
-
2650
- });
2651
-
2652
-
2653
- /*
2654
- * field
2655
- *
2656
- * This model fires actions and filters for registered fields
2657
- *
2658
- * @type function
2659
- * @date 21/02/2014
2660
- * @since 3.5.1
2661
- *
2662
- * @param n/a
2663
- * @return n/a
2664
- */
2665
-
2666
- acf.fields = acf.model.extend({
2667
-
2668
- actions: {
2669
- 'prepare' : '_prepare',
2670
- 'prepare_field' : '_prepare_field',
2671
- 'ready' : '_ready',
2672
- 'ready_field' : '_ready_field',
2673
- 'append' : '_append',
2674
- 'append_field' : '_append_field',
2675
- 'load' : '_load',
2676
- 'load_field' : '_load_field',
2677
- 'remove' : '_remove',
2678
- 'remove_field' : '_remove_field',
2679
- 'sortstart' : '_sortstart',
2680
- 'sortstart_field' : '_sortstart_field',
2681
- 'sortstop' : '_sortstop',
2682
- 'sortstop_field' : '_sortstop_field',
2683
- 'show' : '_show',
2684
- 'show_field' : '_show_field',
2685
- 'hide' : '_hide',
2686
- 'hide_field' : '_hide_field'
2687
- },
2688
-
2689
- // prepare
2690
- _prepare: function( $el ){
2691
-
2692
- acf.get_fields('', $el).each(function(){
2693
-
2694
- acf.do_action('prepare_field', $(this));
2695
-
2696
- });
2697
-
2698
- },
2699
-
2700
- _prepare_field: function( $el ){
2701
-
2702
- acf.do_action('prepare_field/type=' + $el.data('type'), $el);
2703
-
2704
- },
2705
-
2706
- // ready
2707
- _ready: function( $el ){
2708
-
2709
- acf.get_fields('', $el).each(function(){
2710
-
2711
- acf.do_action('ready_field', $(this));
2712
-
2713
- });
2714
-
2715
- },
2716
-
2717
- _ready_field: function( $el ){
2718
-
2719
- acf.do_action('ready_field/type=' + $el.data('type'), $el);
2720
-
2721
- },
2722
-
2723
- // append
2724
- _append: function( $el ){
2725
-
2726
- acf.get_fields('', $el).each(function(){
2727
-
2728
- acf.do_action('append_field', $(this));
2729
-
2730
- });
2731
-
2732
- },
2733
-
2734
- _append_field: function( $el ){
2735
-
2736
- acf.do_action('append_field/type=' + $el.data('type'), $el);
2737
-
2738
- },
2739
-
2740
- // load
2741
- _load: function( $el ){
2742
-
2743
- acf.get_fields('', $el).each(function(){
2744
-
2745
- acf.do_action('load_field', $(this));
2746
-
2747
- });
2748
-
2749
- },
2750
-
2751
- _load_field: function( $el ){
2752
-
2753
- acf.do_action('load_field/type=' + $el.data('type'), $el);
2754
-
2755
- },
2756
-
2757
- // remove
2758
- _remove: function( $el ){
2759
-
2760
- acf.get_fields('', $el).each(function(){
2761
-
2762
- acf.do_action('remove_field', $(this));
2763
-
2764
- });
2765
-
2766
- },
2767
-
2768
- _remove_field: function( $el ){
2769
-
2770
- acf.do_action('remove_field/type=' + $el.data('type'), $el);
2771
-
2772
- },
2773
-
2774
- // sortstart
2775
- _sortstart: function( $el, $placeholder ){
2776
-
2777
- acf.get_fields('', $el).each(function(){
2778
-
2779
- acf.do_action('sortstart_field', $(this), $placeholder);
2780
-
2781
- });
2782
-
2783
- },
2784
-
2785
- _sortstart_field: function( $el, $placeholder ){
2786
-
2787
- acf.do_action('sortstart_field/type=' + $el.data('type'), $el, $placeholder);
2788
-
2789
- },
2790
-
2791
- // sortstop
2792
- _sortstop: function( $el, $placeholder ){
2793
-
2794
- acf.get_fields('', $el).each(function(){
2795
-
2796
- acf.do_action('sortstop_field', $(this), $placeholder);
2797
-
2798
- });
2799
-
2800
- },
2801
-
2802
- _sortstop_field: function( $el, $placeholder ){
2803
-
2804
- acf.do_action('sortstop_field/type=' + $el.data('type'), $el, $placeholder);
2805
-
2806
- },
2807
-
2808
-
2809
- // hide
2810
- _hide: function( $el, context ){
2811
-
2812
- acf.get_fields('', $el).each(function(){
2813
-
2814
- acf.do_action('hide_field', $(this), context);
2815
-
2816
- });
2817
-
2818
- },
2819
-
2820
- _hide_field: function( $el, context ){
2821
-
2822
- acf.do_action('hide_field/type=' + $el.data('type'), $el, context);
2823
-
2824
- },
2825
-
2826
- // show
2827
- _show: function( $el, context ){
2828
-
2829
- acf.get_fields('', $el).each(function(){
2830
-
2831
- acf.do_action('show_field', $(this), context);
2832
-
2833
- });
2834
-
2835
- },
2836
-
2837
- _show_field: function( $el, context ){
2838
-
2839
- acf.do_action('show_field/type=' + $el.data('type'), $el, context);
2840
-
2841
- }
2842
-
2843
- });
2844
-
2845
-
2846
- /*
2847
- * ready
2848
- *
2849
- * description
2850
- *
2851
- * @type function
2852
- * @date 19/02/2014
2853
- * @since 5.0.0
2854
- *
2855
- * @param $post_id (int)
2856
- * @return $post_id (int)
2857
- */
2858
-
2859
- $(document).ready(function(){
2860
-
2861
- // action for 3rd party customization
2862
- acf.do_action('ready', $('body'));
2863
-
2864
- });
2865
-
2866
-
2867
- /*
2868
- * load
2869
- *
2870
- * description
2871
- *
2872
- * @type function
2873
- * @date 19/02/2014
2874
- * @since 5.0.0
2875
- *
2876
- * @param $post_id (int)
2877
- * @return $post_id (int)
2878
- */
2879
-
2880
- $(window).on('load', function(){
2881
-
2882
- // action for 3rd party customization
2883
- acf.do_action('load', $('body'));
2884
-
2885
- });
2886
-
2887
-
2888
- /*
2889
- * layout
2890
- *
2891
- * This model handles the width layout for fields
2892
- *
2893
- * @type function
2894
- * @date 21/02/2014
2895
- * @since 3.5.1
2896
- *
2897
- * @param n/a
2898
- * @return n/a
2899
- */
2900
-
2901
- acf.layout = acf.model.extend({
2902
-
2903
- actions: {
2904
- 'refresh 99': 'refresh'
2905
- },
2906
-
2907
- refresh: function( $el ){
2908
-
2909
- // defaults
2910
- $el = $el || $('body');
2911
-
2912
-
2913
- // render
2914
- this.render_tables( $el );
2915
- this.render_groups( $el );
2916
-
2917
- },
2918
-
2919
- render_tables: function( $el ){
2920
-
2921
- // reference
2922
- var self = this;
2923
-
2924
-
2925
- // vars
2926
- var $tables = $el.find('.acf-table:visible');
2927
-
2928
-
2929
- // appent self
2930
- if( $el.is('table') ) {
2931
- $tables = $tables.add( $el );
2932
- } else if( $el.is('tr') ) {
2933
- $tables = $tables.add( $el.closest('table') );
2934
- }
2935
-
2936
-
2937
- // loop
2938
- $tables.each(function(){
2939
-
2940
- self.render_table( $(this) );
2941
-
2942
- });
2943
-
2944
- },
2945
-
2946
- render_table: function( $table ){
2947
-
2948
- // vars
2949
- var $ths = $table.find('> thead th.acf-th'),
2950
- colspan = 1,
2951
- available_width = 100;
2952
-
2953
-
2954
- // bail early if no $ths
2955
- if( !$ths.exists() ) return;
2956
-
2957
-
2958
- // vars
2959
- var $trs = $table.find('> tbody > tr'),
2960
- $tds = $trs.find('> td.acf-field');
2961
-
2962
-
2963
- // remove clones if has visible rows
2964
- if( $trs.hasClass('acf-clone') && $trs.length > 1 ) {
2965
-
2966
- $tds = $trs.not('.acf-clone').find('> td.acf-field');
2967
-
2968
- }
2969
-
2970
-
2971
- // render th/td visibility
2972
- $ths.each(function(){
2973
-
2974
- // vars
2975
- var $th = $(this),
2976
- key = $th.attr('data-key'),
2977
- $td = $tds.filter('[data-key="'+key+'"]');
2978
-
2979
- // clear class
2980
- $td.removeClass('appear-empty');
2981
- $th.removeClass('hidden-by-conditional-logic');
2982
-
2983
-
2984
- // no td
2985
- if( !$td.exists() ) {
2986
-
2987
- // do nothing
2988
-
2989
- // if all td are hidden
2990
- } else if( $td.not('.hidden-by-conditional-logic').length == 0 ) {
2991
-
2992
- $th.addClass('hidden-by-conditional-logic');
2993
-
2994
- // if 1 or more td are visible
2995
- } else {
2996
-
2997
- $td.filter('.hidden-by-conditional-logic').addClass('appear-empty');
2998
-
2999
- }
3000
-
3001
- });
3002
-
3003
-
3004
-
3005
- // clear widths
3006
- $ths.css('width', 'auto');
3007
-
3008
-
3009
- // update $ths
3010
- $ths = $ths.not('.hidden-by-conditional-logic');
3011
-
3012
-
3013
- // set colspan
3014
- colspan = $ths.length;
3015
-
3016
-
3017
- // set custom widths first
3018
- $ths.filter('[data-width]').each(function(){
3019
-
3020
- // vars
3021
- var width = parseInt( $(this).attr('data-width') );
3022
-
3023
-
3024
- // remove from available
3025
- available_width -= width;
3026
-
3027
-
3028
- // set width
3029
- $(this).css('width', width + '%');
3030
-
3031
- });
3032
-
3033
-
3034
- // update $ths
3035
- $ths = $ths.not('[data-width]');
3036
-
3037
-
3038
- // set custom widths first
3039
- $ths.each(function(){
3040
-
3041
- // cal width
3042
- var width = available_width / $ths.length;
3043
-
3044
-
3045
- // set width
3046
- $(this).css('width', width + '%');
3047
-
3048
- });
3049
-
3050
-
3051
- // update colspan
3052
- $table.find('.acf-row .acf-field.-collapsed-target').removeAttr('colspan');
3053
- $table.find('.acf-row.-collapsed .acf-field.-collapsed-target').attr('colspan', colspan);
3054
-
3055
- },
3056
-
3057
- render_groups: function( $el ){
3058
-
3059
- // reference
3060
- var self = this;
3061
-
3062
-
3063
- // vars
3064
- var $groups = $el.find('.acf-fields:visible');
3065
-
3066
-
3067
- // appent self if is '.acf-fields'
3068
- if( $el && $el.is('.acf-fields') ) {
3069
-
3070
- $groups = $groups.add( $el );
3071
-
3072
- }
3073
-
3074
-
3075
- // loop
3076
- $groups.each(function(){
3077
-
3078
- self.render_group( $(this) );
3079
-
3080
- });
3081
-
3082
- },
3083
-
3084
- render_group: function( $el ){
3085
-
3086
- // vars
3087
- var $els = $(),
3088
- top = 0,
3089
- height = 0,
3090
- cell = -1;
3091
-
3092
-
3093
- // get fields
3094
- var $fields = $el.children('.acf-field[data-width]:visible');
3095
-
3096
-
3097
- // bail early if no fields
3098
- if( !$fields.exists() ) return;
3099
-
3100
-
3101
- // bail ealry if is .-left
3102
- if( $el.hasClass('-left') ) {
3103
-
3104
- $fields.removeAttr('data-width');
3105
- $fields.css('width', 'auto');
3106
- return;
3107
-
3108
- }
3109
-
3110
-
3111
- // reset fields
3112
- $fields.removeClass('-r0 -c0').css({'min-height': 0});
3113
-
3114
-
3115
- // loop
3116
- $fields.each(function( i ){
3117
-
3118
- // vars
3119
- var $el = $(this),
3120
- this_top = $el.position().top;
3121
-
3122
-
3123
- // set top
3124
- if( i == 0 ) top = this_top;
3125
-
3126
-
3127
- // detect new row
3128
- if( this_top != top ) {
3129
-
3130
- // set previous heights
3131
- $els.css({'min-height': (height+1)+'px'});
3132
-
3133
- // reset
3134
- $els = $();
3135
- top = $el.position().top; // don't use variable as this value may have changed due to min-height css
3136
- height = 0;
3137
- cell = -1;
3138
-
3139
- }
3140
-
3141
-
3142
- // increase
3143
- cell++;
3144
-
3145
-
3146
- // set height
3147
- height = ($el.outerHeight() > height) ? $el.outerHeight() : height;
3148
-
3149
-
3150
- // append
3151
- $els = $els.add( $el );
3152
-
3153
-
3154
- // add classes
3155
- if( this_top == 0 ) {
3156
-
3157
- $el.addClass('-r0');
3158
-
3159
- } else if( cell == 0 ) {
3160
-
3161
- $el.addClass('-c0');
3162
-
3163
- }
3164
-
3165
- });
3166
-
3167
-
3168
- // clean up
3169
- if( $els.exists() ) {
3170
-
3171
- $els.css({'min-height': (height+1)+'px'});
3172
-
3173
- }
3174
-
3175
- }
3176
-
3177
- });
3178
-
3179
-
3180
- /*
3181
- * Force revisions
3182
- *
3183
- * description
3184
- *
3185
- * @type function
3186
- * @date 19/02/2014
3187
- * @since 5.0.0
3188
- *
3189
- * @param $post_id (int)
3190
- * @return $post_id (int)
3191
- */
3192
-
3193
- $(document).on('change', '.acf-field input, .acf-field textarea, .acf-field select', function(){
3194
-
3195
- // preview hack
3196
- var $input = $('#_acf_changed');
3197
- if( $input.length ) $input.val(1);
3198
-
3199
-
3200
- // action for 3rd party customization
3201
- acf.do_action('change', $(this));
3202
-
3203
- });
3204
-
3205
-
3206
- /*
3207
- * preventDefault helper
3208
- *
3209
- * This function will prevent default of any link with an href of #
3210
- *
3211
- * @type function
3212
- * @date 24/07/2014
3213
- * @since 5.0.0
3214
- *
3215
- * @param $post_id (int)
3216
- * @return $post_id (int)
3217
- */
3218
-
3219
- $(document).on('click', '.acf-field a[href="#"]', function( e ){
3220
-
3221
- e.preventDefault();
3222
-
3223
- });
3224
-
3225
-
3226
- /*
3227
- * unload
3228
- *
3229
- * This model handles the unload prompt
3230
- *
3231
- * @type function
3232
- * @date 21/02/2014
3233
- * @since 3.5.1
3234
- *
3235
- * @param n/a
3236
- * @return n/a
3237
- */
3238
-
3239
- acf.unload = acf.model.extend({
3240
-
3241
- locked: 1,
3242
- active: 1,
3243
- changed: 0,
3244
-
3245
- filters: {
3246
- 'validation_complete': 'validation_complete'
3247
- },
3248
-
3249
- actions: {
3250
- 'ready': 'ready',
3251
- 'change': 'on',
3252
- 'submit': 'off'
3253
- },
3254
-
3255
- ready: function(){
3256
-
3257
- // unlock in 1s to avoid JS 'trigger change' bugs
3258
- setTimeout(function(){
3259
-
3260
- acf.unload.locked = 0;
3261
-
3262
- }, 1000);
3263
-
3264
- },
3265
-
3266
- events: {
3267
- 'submit form': 'off'
3268
- },
3269
-
3270
- validation_complete: function( json, $form ){
3271
-
3272
- if( json && json.errors ) {
3273
-
3274
- this.on();
3275
-
3276
- }
3277
-
3278
- // return
3279
- return json;
3280
-
3281
- },
3282
-
3283
- on: function(){
3284
-
3285
- // bail ealry if already changed, not active, or still locked
3286
- if( this.changed || !this.active || this.locked ) {
3287
-
3288
- return;
3289
-
3290
- }
3291
-
3292
-
3293
- // update
3294
- this.changed = 1;
3295
-
3296
-
3297
- // add event
3298
- $(window).on('beforeunload', this.unload);
3299
-
3300
- },
3301
-
3302
- off: function(){
3303
-
3304
- // update
3305
- this.changed = 0;
3306
-
3307
-
3308
- // remove event
3309
- $(window).off('beforeunload', this.unload);
3310
-
3311
- },
3312
-
3313
- unload: function(){
3314
-
3315
- // alert string
3316
- return acf._e('unload');
3317
-
3318
- }
3319
-
3320
- });
3321
-
3322
-
3323
- acf.tooltip = acf.model.extend({
3324
-
3325
- events: {
3326
- 'mouseenter .acf-js-tooltip': '_on',
3327
- 'mouseup .acf-js-tooltip': '_off',
3328
- 'mouseleave .acf-js-tooltip': '_off'
3329
- },
3330
-
3331
- tooltip: function( text, $el ){
3332
-
3333
- // vars
3334
- var $tooltip = $('<div class="acf-tooltip">' + text + '</div>');
3335
-
3336
-
3337
- // append
3338
- $('body').append( $tooltip );
3339
-
3340
-
3341
- // position
3342
- var tolerance = 10;
3343
- target_w = $el.outerWidth(),
3344
- target_h = $el.outerHeight(),
3345
- target_t = $el.offset().top,
3346
- target_l = $el.offset().left,
3347
- tooltip_w = $tooltip.outerWidth(),
3348
- tooltip_h = $tooltip.outerHeight();
3349
-
3350
-
3351
- // calculate top
3352
- var top = target_t - tooltip_h,
3353
- left = target_l + (target_w / 2) - (tooltip_w / 2);
3354
-
3355
-
3356
- // too far left
3357
- if( left < tolerance ) {
3358
-
3359
- $tooltip.addClass('right');
3360
-
3361
- left = target_l + target_w;
3362
- top = target_t + (target_h / 2) - (tooltip_h / 2);
3363
-
3364
-
3365
- // too far right
3366
- } else if( (left + tooltip_w + tolerance) > $(window).width() ) {
3367
-
3368
- $tooltip.addClass('left');
3369
-
3370
- left = target_l - tooltip_w;
3371
- top = target_t + (target_h / 2) - (tooltip_h / 2);
3372
-
3373
-
3374
- // too far top
3375
- } else if( top - $(window).scrollTop() < tolerance ) {
3376
-
3377
- $tooltip.addClass('bottom');
3378
-
3379
- top = target_t + target_h;
3380
-
3381
- } else {
3382
-
3383
- $tooltip.addClass('top');
3384
-
3385
- }
3386
-
3387
-
3388
- // update css
3389
- $tooltip.css({ 'top': top, 'left': left });
3390
-
3391
-
3392
- // return
3393
- return $tooltip;
3394
-
3395
- },
3396
-
3397
- temp: function( text, $el ){
3398
-
3399
- // tooltip
3400
- var $el = this.tooltip( text, $el );
3401
- var time = 0;
3402
-
3403
-
3404
- // wait 250
3405
- time += 250;
3406
-
3407
-
3408
- // add class
3409
- setTimeout(function(){
3410
-
3411
- $el.addClass('acf-fade-up');
3412
-
3413
- }, time);
3414
-
3415
-
3416
- // wait 250
3417
- time += 250;
3418
-
3419
-
3420
- // remove
3421
- setTimeout(function(){
3422
-
3423
- $el.remove();
3424
-
3425
- }, time);
3426
-
3427
- },
3428
-
3429
- confirm: function( $el, callback, text, button_y, button_n ){
3430
-
3431
- // defaults
3432
- text = text || acf._e('are_you_sure');
3433
- button_y = button_y || '<a href="#" class="acf-confirm-y">'+acf._e('yes')+'</a>';
3434
- button_n = button_n || '<a href="#" class="acf-confirm-n">'+acf._e('No')+'</a>';
3435
-
3436
-
3437
- // vars
3438
- var $tooltip = this.tooltip( text + ' ' + button_y + ' ' + button_n , $el);
3439
-
3440
-
3441
- // add class
3442
- $tooltip.addClass('-confirm');
3443
-
3444
-
3445
- // events
3446
- var event = function( e, result ){
3447
-
3448
- // prevent all listeners
3449
- e.preventDefault();
3450
- e.stopImmediatePropagation();
3451
-
3452
-
3453
- // remove events
3454
- $el.off('click', event_y);
3455
- $tooltip.off('click', '.acf-confirm-y', event_y);
3456
- $tooltip.off('click', '.acf-confirm-n', event_n);
3457
- $('body').off('click', event_n);
3458
-
3459
-
3460
- // remove tooltip
3461
- $tooltip.remove();
3462
-
3463
-
3464
- // callback
3465
- callback.apply(null, [result]);
3466
-
3467
- };
3468
-
3469
- var event_y = function( e ){
3470
- event( e, true );
3471
- };
3472
-
3473
- var event_n = function( e ){
3474
- event( e, false );
3475
- };
3476
-
3477
-
3478
- // add events
3479
- $tooltip.on('click', '.acf-confirm-y', event_y);
3480
- $tooltip.on('click', '.acf-confirm-n', event_n);
3481
- $el.on('click', event_y);
3482
- $('body').on('click', event_n);
3483
-
3484
- },
3485
-
3486
- confirm_remove: function( $el, callback ){
3487
-
3488
- // vars
3489
- text = false; // default
3490
- button_y = '<a href="#" class="acf-confirm-y -red">'+acf._e('remove')+'</a>';
3491
- button_n = '<a href="#" class="acf-confirm-n">'+acf._e('cancel')+'</a>';
3492
-
3493
-
3494
- // confirm
3495
- this.confirm( $el, callback, false, button_y, button_n );
3496
-
3497
- },
3498
-
3499
- _on: function( e ){
3500
-
3501
- // vars
3502
- var title = e.$el.attr('title');
3503
-
3504
-
3505
- // bail ealry if no title
3506
- if( !title ) return;
3507
-
3508
-
3509
- // create tooltip
3510
- var $tooltip = this.tooltip( title, e.$el );
3511
-
3512
-
3513
- // store as data
3514
- e.$el.data('acf-tooltip', {
3515
- 'title': title,
3516
- '$el': $tooltip
3517
- });
3518
-
3519
-
3520
- // clear title to avoid default browser tooltip
3521
- e.$el.attr('title', '');
3522
-
3523
- },
3524
-
3525
- _off: function( e ){
3526
-
3527
- // vars
3528
- var tooltip = e.$el.data('acf-tooltip');
3529
-
3530
-
3531
- // bail early if no data
3532
- if( !tooltip ) return;
3533
-
3534
-
3535
- // remove tooltip
3536
- tooltip.$el.remove();
3537
-
3538
-
3539
- // restore title
3540
- e.$el.attr('title', tooltip.title);
3541
- }
3542
-
3543
- });
3544
-
3545
-
3546
- acf.postbox = acf.model.extend({
3547
-
3548
- events: {
3549
- 'mouseenter .acf-postbox .handlediv': 'on',
3550
- 'mouseleave .acf-postbox .handlediv': 'off'
3551
- },
3552
-
3553
- on: function( e ){
3554
-
3555
- e.$el.siblings('.hndle').addClass('hover');
3556
-
3557
- },
3558
-
3559
- off: function( e ){
3560
-
3561
- e.$el.siblings('.hndle').removeClass('hover');
3562
-
3563
- },
3564
-
3565
- render: function( args ){
3566
-
3567
- // defaults
3568
- args = $.extend({}, {
3569
- id: '',
3570
- key: '',
3571
- style: 'default',
3572
- label: 'top',
3573
- edit_url: '',
3574
- edit_title: '',
3575
- visibility: true
3576
- }, args);
3577
-
3578
-
3579
- // vars
3580
- var $postbox = $('#' + args.id),
3581
- $toggle = $('#' + args.id + '-hide'),
3582
- $label = $toggle.parent();
3583
-
3584
-
3585
-
3586
- // add class
3587
- $postbox.addClass('acf-postbox');
3588
- $label.addClass('acf-postbox-toggle');
3589
-
3590
-
3591
- // remove class
3592
- $postbox.removeClass('hide-if-js');
3593
- $label.removeClass('hide-if-js');
3594
-
3595
-
3596
- // field group style
3597
- if( args.style !== 'default' ) {
3598
-
3599
- $postbox.addClass( args.style );
3600
-
3601
- }
3602
-
3603
-
3604
- // .inside class
3605
- $postbox.children('.inside').addClass('acf-fields').addClass('-' + args.label);
3606
-
3607
-
3608
- // visibility
3609
- if( args.visibility ) {
3610
-
3611
- $toggle.prop('checked', true);
3612
-
3613
- } else {
3614
-
3615
- $postbox.addClass('acf-hidden');
3616
- $label.addClass('acf-hidden');
3617
-
3618
- }
3619
-
3620
-
3621
- // edit_url
3622
- if( args.edit_url ) {
3623
-
3624
- $postbox.children('.hndle').append('<a href="' + args.edit_url + '" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="' + args.edit_title + '"></a>');
3625
-
3626
- }
3627
-
3628
- }
3629
-
3630
- });
3631
-
3632
-
3633
- /**
3634
- * panel
3635
- *
3636
- * This model handles .acf-panel JS
3637
- *
3638
- * @date 21/10/17
3639
- * @since 5.6.3
3640
- *
3641
- * @param n/a
3642
- * @return n/a
3643
- */
3644
-
3645
- var acf_panel = acf.model.extend({
3646
-
3647
- events: {
3648
- 'click .acf-panel-title': '_click',
3649
- },
3650
-
3651
- _click: function( e ){
3652
-
3653
- // prevent Defailt
3654
- e.preventDefault();
3655
-
3656
-
3657
- // open close
3658
- this.toggle( e.$el.parent() );
3659
-
3660
- },
3661
-
3662
- is_open: function( $el ) {
3663
- return $el.hasClass('-open');
3664
- },
3665
-
3666
- toggle: function( $el ){
3667
-
3668
- // is open
3669
- if( this.is_open($el) ) {
3670
- this.close( $el );
3671
- } else {
3672
- this.open( $el );
3673
- }
3674
-
3675
- },
3676
-
3677
- open: function( $el ){
3678
- $el.addClass('-open');
3679
- $el.find('.acf-panel-title i').attr('class', 'dashicons dashicons-arrow-down');
3680
- },
3681
-
3682
- close: function( $el ){
3683
- $el.removeClass('-open');
3684
- $el.find('.acf-panel-title i').attr('class', 'dashicons dashicons-arrow-right');
3685
- }
3686
-
3687
- });
3688
-
3689
-
3690
- /**
3691
- * acf_h2_notice
3692
- *
3693
- * This model will move the .acf-notice element quickly without the WP flicker
3694
- *
3695
- * @date 21/10/17
3696
- * @since 5.6.3
3697
- *
3698
- * @param n/a
3699
- * @return n/a
3700
- */
3701
-
3702
- acf.notice = acf.model.extend({
3703
-
3704
- actions: {
3705
- 'prepare': 'prepare',
3706
- },
3707
-
3708
- prepare: function(){
3709
-
3710
- // vars
3711
- var $notice = $('.acf-notice');
3712
-
3713
-
3714
- // move
3715
- if( $notice.length ) {
3716
- $('h1:first').after( $notice );
3717
- }
3718
-
3719
- },
3720
-
3721
- html: function( text, type ){
3722
-
3723
- },
3724
-
3725
- success: function( text ){
3726
-
3727
-
3728
- },
3729
-
3730
- error: function( text ){
3731
-
3732
- },
3733
-
3734
- warning: function( text ){
3735
-
3736
- },
3737
-
3738
- information: function( text ){
3739
-
3740
- }
3741
-
3742
- });
3743
-
3744
-
3745
- // Preferences
3746
- var preferences = localStorage.getItem('acf');
3747
- preferences = preferences ? JSON.parse(preferences) : {};
3748
-
3749
-
3750
- /**
3751
- * getPreferenceName
3752
- *
3753
- * Gets the true preference name.
3754
- * Converts "this.thing" to "thing-123" if editing post 123.
3755
- *
3756
- * @date 11/11/17
3757
- * @since 5.6.5
3758
- *
3759
- * @param string name
3760
- * @return string
3761
- */
3762
-
3763
- var getPreferenceName = function( name ){
3764
- if( name.substr(0, 5) === 'this.' ) {
3765
- name = name.substr(5) + '-' + acf.get('post_id');
3766
- }
3767
- return name;
3768
- };
3769
-
3770
-
3771
- /**
3772
- * acf.getPreference
3773
- *
3774
- * Gets a preference setting or null if not set.
3775
- *
3776
- * @date 11/11/17
3777
- * @since 5.6.5
3778
- *
3779
- * @param string name
3780
- * @return mixed
3781
- */
3782
-
3783
- acf.getPreference = function( name ){
3784
- name = getPreferenceName( name );
3785
- return preferences[ name ] || null;
3786
- }
3787
-
3788
-
3789
- /**
3790
- * acf.setPreference
3791
- *
3792
- * Sets a preference setting.
3793
- *
3794
- * @date 11/11/17
3795
- * @since 5.6.5
3796
- *
3797
- * @param string name
3798
- * @param mixed value
3799
- * @return n/a
3800
- */
3801
-
3802
- acf.setPreference = function( name, value ){
3803
- name = getPreferenceName( name );
3804
- if( value === null ) {
3805
- delete preferences[ name ];
3806
- } else {
3807
- preferences[ name ] = value;
3808
- }
3809
- localStorage.setItem('acf', JSON.stringify(preferences));
3810
- }
3811
-
3812
-
3813
- /**
3814
- * acf.removePreference
3815
- *
3816
- * Removes a preference setting.
3817
- *
3818
- * @date 11/11/17
3819
- * @since 5.6.5
3820
- *
3821
- * @param string name
3822
- * @return n/a
3823
- */
3824
-
3825
- acf.removePreference = function( name ){
3826
- acf.setPreference(name, null);
3827
- };
3828
-
3829
-
3830
- /**
3831
- * acf.lock
3832
- *
3833
- * Creates a "lock" on an element for a given type and key
3834
- *
3835
- * @date 22/2/18
3836
- * @since 5.6.9
3837
- *
3838
- * @param jQuery $el The element to lock.
3839
- * @param string type The type of lock such as "condition" or "visibility".
3840
- * @param string key The key that will be used to unlock.
3841
- * @return void
3842
- */
3843
-
3844
- var getLocks = function( $el, type ){
3845
- return $el.data('acf-lock-'+type) || [];
3846
- };
3847
-
3848
- var setLocks = function( $el, type, locks ){
3849
- $el.data('acf-lock-'+type, locks);
3850
- }
3851
-
3852
- acf.lock = function( $el, type, key ){
3853
- var locks = getLocks( $el, type );
3854
- var i = locks.indexOf(key);
3855
- if( i < 0 ) {
3856
- locks.push( key );
3857
- setLocks( $el, type, locks );
3858
- }
3859
- };
3860
-
3861
- /**
3862
- * acf.unlock
3863
- *
3864
- * Unlocks a "lock" on an element for a given type and key
3865
- *
3866
- * @date 22/2/18
3867
- * @since 5.6.9
3868
- *
3869
- * @param jQuery $el The element to lock.
3870
- * @param string type The type of lock such as "condition" or "visibility".
3871
- * @param string key The key that will be used to unlock.
3872
- * @return void
3873
- */
3874
-
3875
- acf.unlock = function( $el, type, key ){
3876
- var locks = getLocks( $el, type );
3877
- var i = locks.indexOf(key);
3878
- if( i > -1 ) {
3879
- locks.splice(i, 1);
3880
- setLocks( $el, type, locks );
3881
- }
3882
-
3883
- // return true if is unlocked (no locks)
3884
- return (locks.length === 0);
3885
- };
3886
-
3887
- /**
3888
- * acf.isLocked
3889
- *
3890
- * Returns true if a lock exists for a given type
3891
- *
3892
- * @date 22/2/18
3893
- * @since 5.6.9
3894
- *
3895
- * @param jQuery $el The element to lock.
3896
- * @param string type The type of lock such as "condition" or "visibility".
3897
- * @return void
3898
- */
3899
-
3900
- acf.isLocked = function( $el, type ){
3901
- return ( getLocks( $el, type ).length > 0 );
3902
- };
3903
-
3904
- /**
3905
- * acf.show
3906
- *
3907
- * description
3908
- *
3909
- * @date 9/2/18
3910
- * @since 5.6.5
3911
- *
3912
- * @param type $var Description. Default.
3913
- * @return type Description.
3914
- */
3915
-
3916
- acf.show = function( $el, lockKey ){
3917
-
3918
- // unlock
3919
- if( lockKey ) {
3920
- acf.unlock($el, 'hidden', lockKey);
3921
- }
3922
-
3923
- // bail early if $el is still locked
3924
- if( acf.isLocked($el, 'hidden') ) {
3925
- //console.log( 'still locked', getLocks( $el, 'hidden' ));
3926
- return false;
3927
- }
3928
-
3929
- // $el is hidden, remove class and return true due to change in visibility
3930
- if( $el.hasClass('acf-hidden') ) {
3931
- $el.removeClass('acf-hidden');
3932
- return true;
3933
-
3934
- // $el is visible, return false due to no change in visibility
3935
- } else {
3936
- return false;
3937
- }
3938
- };
3939
-
3940
- /**
3941
- * enable
3942
- *
3943
- * description
3944
- *
3945
- * @date 12/3/18
3946
- * @since 5.6.9
3947
- *
3948
- * @param type $var Description. Default.
3949
- * @return type Description.
3950
- */
3951
-
3952
- var enable = function( $el, lockKey ){
3953
-
3954
- // check class. Allow .acf-disabled to overrule all JS
3955
- if( $el.hasClass('acf-disabled') ) {
3956
- return false;
3957
- }
3958
-
3959
- // unlock
3960
- if( lockKey ) {
3961
- acf.unlock($el, 'disabled', lockKey);
3962
- }
3963
-
3964
- // bail early if $el is still locked
3965
- if( acf.isLocked($el, 'disabled') ) {
3966
- return false;
3967
- }
3968
-
3969
- // $el is disabled, remove prop and return true due to change
3970
- if( $el.prop('disabled') ) {
3971
- $el.prop('disabled', false);
3972
- return true;
3973
-
3974
- // $el is enabled, return false due to no change
3975
- } else {
3976
- return false;
3977
- }
3978
- };
3979
-
3980
- /**
3981
- * acf.enable
3982
- *
3983
- * description
3984
- *
3985
- * @date 9/2/18
3986
- * @since 5.6.5
3987
- *
3988
- * @param type $var Description. Default.
3989
- * @return type Description.
3990
- */
3991
-
3992
- acf.enable = function( $el, lockKey ){
3993
-
3994
- // enable single input
3995
- if( $el.attr('name') ) {
3996
- return enable( $el, lockKey );
3997
- }
3998
-
3999
- // find and enable child inputs
4000
- // return false if 'any' inputs are still disabled
4001
- var results = true;
4002
- $el.find('[name]').each(function(){
4003
- var result = enable( $(this), lockKey );
4004
- if( !result ) {
4005
- results = false;
4006
- }
4007
- });
4008
- return results;
4009
- };
4010
-
4011
-
4012
- /**
4013
- * disable
4014
- *
4015
- * description
4016
- *
4017
- * @date 12/3/18
4018
- * @since 5.6.9
4019
- *
4020
- * @param type $var Description. Default.
4021
- * @return type Description.
4022
- */
4023
-
4024
- var disable = function( $el, lockKey ){
4025
-
4026
- // lock
4027
- if( lockKey ) {
4028
- acf.lock($el, 'disabled', lockKey);
4029
- }
4030
-
4031
- // $el is disabled, return false due to no change
4032
- if( $el.prop('disabled') ) {
4033
- return false;
4034
-
4035
- // $el is enabled, add prop and return true due to change
4036
- } else {
4037
- $el.prop('disabled', true);
4038
- return true;
4039
- }
4040
- };
4041
-
4042
-
4043
- /**
4044
- * acf.disable
4045
- *
4046
- * description
4047
- *
4048
- * @date 9/2/18
4049
- * @since 5.6.5
4050
- *
4051
- * @param type $var Description. Default.
4052
- * @return type Description.
4053
- */
4054
-
4055
- acf.disable = function( $el, lockKey ){
4056
-
4057
- // disable single input
4058
- if( $el.attr('name') ) {
4059
- return disable( $el, lockKey );
4060
- }
4061
-
4062
- // find and enable child inputs
4063
- // return false if 'any' inputs did not change
4064
- var results = true;
4065
- $el.find('[name]').each(function(){
4066
- var result = disable( $(this), lockKey );
4067
- if( !result ) {
4068
- results = false;
4069
- }
4070
- });
4071
- return results;
4072
- };
4073
-
4074
- // compatibility
4075
- acf.enable_el = acf.enable;
4076
- acf.enable_form = acf.enable;
4077
-
4078
- acf.disable_el = acf.disable;
4079
- acf.disable_form = acf.disable;
4080
-
4081
-
4082
- /**
4083
- * acf.hide
4084
- *
4085
- * description
4086
- *
4087
- * @date 9/2/18
4088
- * @since 5.6.5
4089
- *
4090
- * @param type $var Description. Default.
4091
- * @return type Description.
4092
- */
4093
-
4094
- acf.hide = function( $el, lockKey ){
4095
-
4096
- // lock
4097
- if( lockKey ) {
4098
- acf.lock($el, 'hidden', lockKey);
4099
- }
4100
-
4101
- // $el is hidden, return false due to no change in visibility
4102
- if( $el.hasClass('acf-hidden') ) {
4103
- return false;
4104
-
4105
- // $el is visible, add class and return true due to change in visibility
4106
- } else {
4107
- $el.addClass('acf-hidden');
4108
- return true;
4109
- }
4110
- };
4111
-
4112
-
4113
- /**
4114
- * acf.isHidden
4115
- *
4116
- * description
4117
- *
4118
- * @date 9/2/18
4119
- * @since 5.6.5
4120
- *
4121
- * @param type $var Description. Default.
4122
- * @return type Description.
4123
- */
4124
-
4125
- acf.isHidden = function( $el ){
4126
- return $el.hasClass('acf-hidden');
4127
- };
4128
-
4129
-
4130
- /**
4131
- * acf.isVisible
4132
- *
4133
- * description
4134
- *
4135
- * @date 9/2/18
4136
- * @since 5.6.5
4137
- *
4138
- * @param type $var Description. Default.
4139
- * @return type Description.
4140
- */
4141
-
4142
- acf.isVisible = function( $el ){
4143
- return !acf.isHidden( $el );
4144
- };
4145
-
4146
- /*
4147
- * Sortable
4148
- *
4149
- * These functions will hook into the start and stop of a jQuery sortable event and modify the item and placeholder
4150
- *
4151
- * @type function
4152
- * @date 12/11/2013
4153
- * @since 5.0.0
4154
- *
4155
- * @param $post_id (int)
4156
- * @return $post_id (int)
4157
- */
4158
-
4159
- $(document).on('sortstart', function( event, ui ) {
4160
- acf.do_action('sortstart', ui.item, ui.placeholder);
4161
- });
4162
-
4163
- $(document).on('sortstop', function( event, ui ) {
4164
- acf.do_action('sortstop', ui.item, ui.placeholder);
4165
- });
4166
-
4167
- acf.add_action('sortstart', function( $item, $placeholder ){
4168
-
4169
- // if $item is a tr, apply some css to the elements
4170
- if( $item.is('tr') ) {
4171
-
4172
- // temp set as relative to find widths
4173
- $item.css('position', 'relative');
4174
-
4175
-
4176
- // set widths for td children
4177
- $item.children().each(function(){
4178
-
4179
- $(this).width($(this).width());
4180
-
4181
- });
4182
-
4183
-
4184
- // revert position css
4185
- $item.css('position', 'absolute');
4186
-
4187
-
4188
- // add markup to the placeholder
4189
- $placeholder.html('<td style="height:' + $item.height() + 'px; padding:0;" colspan="' + $item.children('td').length + '"></td>');
4190
-
4191
- }
4192
-
4193
- });
4194
-
4195
-
4196
-
4197
- /*
4198
- * before & after duplicate
4199
- *
4200
- * This function will modify the DOM before it is cloned. Primarily fixes a cloning issue with select elements
4201
- *
4202
- * @type function
4203
- * @date 16/05/2014
4204
- * @since 5.0.0
4205
- *
4206
- * @param $post_id (int)
4207
- * @return $post_id (int)
4208
- */
4209
-
4210
- acf.add_action('before_duplicate', function( $orig ){
4211
-
4212
- // add 'selected' class
4213
- $orig.find('select option:selected').addClass('selected');
4214
-
4215
- });
4216
-
4217
- acf.add_action('after_duplicate', function( $orig, $duplicate ){
4218
-
4219
- // set select values
4220
- $duplicate.find('select').each(function(){
4221
-
4222
- // vars
4223
- var $select = $(this);
4224
-
4225
-
4226
- // bail early if is 'Stylized UI'
4227
- //if( $select.data('ui') ) return;
4228
-
4229
-
4230
- // vars
4231
- var val = [];
4232
-
4233
-
4234
- // loop
4235
- $select.find('option.selected').each(function(){
4236
-
4237
- val.push( $(this).val() );
4238
-
4239
- });
4240
-
4241
-
4242
- // set val
4243
- $select.val( val );
4244
-
4245
- });
4246
-
4247
-
4248
- // remove 'selected' class
4249
- $orig.find('select option.selected').removeClass('selected');
4250
- $duplicate.find('select option.selected').removeClass('selected');
4251
-
4252
- });
4253
-
4254
-
4255
-
4256
- /*
4257
- acf.test_rtl = acf.model.extend({
4258
-
4259
- actions: {
4260
- 'ready': 'ready',
4261
- },
4262
-
4263
- ready: function(){
4264
-
4265
- $('html').attr('dir', 'rtl');
4266
-
4267
- }
4268
-
4269
- });
4270
- */
4271
-
4272
-
4273
-
4274
- /*
4275
-
4276
-
4277
- console.time("acf_test_ready");
4278
- console.time("acf_test_load");
4279
-
4280
- acf.add_action('ready', function(){
4281
-
4282
- console.timeEnd("acf_test_ready");
4283
-
4284
- }, 999);
4285
-
4286
- acf.add_action('load', function(){
4287
-
4288
- console.timeEnd("acf_test_load");
4289
-
4290
- }, 999);
4291
- */
4292
-
4293
-
4294
- /*
4295
- * indexOf
4296
- *
4297
- * This function will provide compatibility for ie8
4298
- *
4299
- * @type function
4300
- * @date 5/3/17
4301
- * @since 5.5.10
4302
- *
4303
- * @param n/a
4304
- * @return n/a
4305
- */
4306
-
4307
- if( !Array.prototype.indexOf ) {
4308
-
4309
- Array.prototype.indexOf = function(val) {
4310
- return $.inArray(val, this);
4311
- };
4312
-
4313
- }
4314
-
4315
- })(jQuery);
4316
-
4317
- (function($){
4318
-
4319
- acf.ajax = acf.model.extend({
4320
-
4321
- active: false,
4322
- actions: {
4323
- 'ready': 'ready'
4324
- },
4325
- events: {
4326
- 'change #page_template': '_change_template',
4327
- 'change #parent_id': '_change_parent',
4328
- 'change #post-formats-select input': '_change_format',
4329
- 'change .categorychecklist input': '_change_term',
4330
- 'change .categorychecklist select': '_change_term',
4331
- 'change .acf-taxonomy-field[data-save="1"] input': '_change_term',
4332
- 'change .acf-taxonomy-field[data-save="1"] select': '_change_term'
4333
- },
4334
- o: {
4335
- //'post_id': 0,
4336
- //'page_template': 0,
4337
- //'page_parent': 0,
4338
- //'page_type': 0,
4339
- //'post_format': 0,
4340
- //'post_taxonomy': 0
4341
- },
4342
- xhr: null,
4343
-
4344
- update: function( k, v ){
4345
-
4346
- this.o[ k ] = v;
4347
-
4348
- return this;
4349
-
4350
- },
4351
-
4352
- get: function( k ){
4353
-
4354
- return this.o[ k ] || null;
4355
-
4356
- },
4357
-
4358
- ready: function(){
4359
-
4360
- // update post_id
4361
- this.update('post_id', acf.get('post_id'));
4362
-
4363
-
4364
- // active
4365
- this.active = true;
4366
-
4367
- },
4368
-
4369
- /*
4370
- timeout: null,
4371
- maybe_fetch: function(){
4372
-
4373
- // reference
4374
- var self = this;
4375
-
4376
-
4377
- // abort timeout
4378
- if( this.timeout ) {
4379
-
4380
- clearTimeout( this.timeout );
4381
-
4382
- }
4383
-
4384
-
4385
- // fetch
4386
- this.timeout = setTimeout(function(){
4387
-
4388
- self.fetch();
4389
-
4390
- }, 100);
4391
-
4392
- },
4393
- */
4394
-
4395
- fetch: function(){
4396
-
4397
- // bail early if not active
4398
- if( !this.active ) return;
4399
-
4400
- // bail early if not for post
4401
- if( acf.get('screen') !== 'post' ) return;
4402
-
4403
- // bail early if no ajax
4404
- if( !acf.get('ajax') ) return;
4405
-
4406
-
4407
- // abort XHR if is already loading AJAX data
4408
- if( this.xhr ) {
4409
-
4410
- this.xhr.abort();
4411
-
4412
- }
4413
-
4414
-
4415
- // vars
4416
- var self = this,
4417
- data = this.o;
4418
-
4419
-
4420
- // add action url
4421
- data.action = 'acf/post/get_field_groups';
4422
-
4423
-
4424
- // add ignore
4425
- data.exists = [];
4426
-
4427
- $('.acf-postbox').not('.acf-hidden').each(function(){
4428
-
4429
- data.exists.push( $(this).attr('id').substr(4) );
4430
-
4431
- });
4432
-
4433
-
4434
- // ajax
4435
- this.xhr = $.ajax({
4436
- url: acf.get('ajaxurl'),
4437
- data: acf.prepare_for_ajax( data ),
4438
- type: 'post',
4439
- dataType: 'json',
4440
-
4441
- success: function( json ){
4442
-
4443
- if( acf.is_ajax_success( json ) ) {
4444
-
4445
- self.render( json.data );
4446
-
4447
- }
4448
-
4449
- }
4450
- });
4451
-
4452
- },
4453
 
4454
- render: function( json ){
4455
-
4456
- // hide
4457
- $('.acf-postbox').addClass('acf-hidden');
4458
- $('.acf-postbox-toggle').addClass('acf-hidden');
4459
-
4460
-
4461
- // reset style
4462
- $('#acf-style').html('');
4463
-
4464
-
4465
- // show the new postboxes
4466
- $.each(json, function( k, field_group ){
4467
-
4468
- // vars
4469
- var $postbox = $('#acf-' + field_group.key),
4470
- $toggle = $('#acf-' + field_group.key + '-hide'),
4471
- $label = $toggle.parent();
4472
-
4473
-
4474
- // show
4475
- // use show() to force display when postbox has been hidden by 'Show on screen' toggle
4476
- $postbox.removeClass('acf-hidden hide-if-js').show();
4477
- $label.removeClass('acf-hidden hide-if-js').show();
4478
- $toggle.prop('checked', true);
4479
-
4480
-
4481
- // replace HTML if needed
4482
- var $replace = $postbox.find('.acf-replace-with-fields');
4483
-
4484
- if( $replace.exists() ) {
4485
-
4486
- $replace.replaceWith( field_group.html );
4487
-
4488
- acf.do_action('append', $postbox);
4489
-
4490
- }
4491
-
4492
-
4493
- // update style if needed
4494
- if( k === 0 ) {
4495
-
4496
- $('#acf-style').html( field_group.style );
4497
-
4498
- }
4499
-
4500
-
4501
- // enable inputs
4502
- $postbox.find('.acf-hidden-by-postbox').prop('disabled', false);
4503
-
4504
- });
4505
-
4506
-
4507
- // disable inputs
4508
- $('.acf-postbox.acf-hidden').find('select, textarea, input').not(':disabled').each(function(){
4509
-
4510
- $(this).addClass('acf-hidden-by-postbox').prop('disabled', true);
4511
-
4512
- });
4513
-
4514
- },
4515
 
4516
- sync_taxonomy_terms: function(){
4517
-
4518
- // vars
4519
- var values = [''];
4520
-
4521
-
4522
- // loop over term lists
4523
- $('.categorychecklist, .acf-taxonomy-field').each(function(){
4524
-
4525
- // vars
4526
- var $el = $(this),
4527
- $checkbox = $el.find('input[type="checkbox"]').not(':disabled'),
4528
- $radio = $el.find('input[type="radio"]').not(':disabled'),
4529
- $select = $el.find('select').not(':disabled'),
4530
- $hidden = $el.find('input[type="hidden"]').not(':disabled');
4531
-
4532
-
4533
- // bail early if not a field which saves taxonomy terms to post
4534
- if( $el.is('.acf-taxonomy-field') && $el.attr('data-save') != '1' ) {
4535
-
4536
- return;
4537
-
4538
- }
4539
-
4540
-
4541
- // bail early if in attachment
4542
- if( $el.closest('.media-frame').exists() ) {
4543
-
4544
- return;
4545
-
4546
- }
4547
-
4548
-
4549
- // checkbox
4550
- if( $checkbox.exists() ) {
4551
-
4552
- $checkbox.filter(':checked').each(function(){
4553
-
4554
- values.push( $(this).val() );
4555
-
4556
- });
4557
-
4558
- } else if( $radio.exists() ) {
4559
-
4560
- $radio.filter(':checked').each(function(){
4561
-
4562
- values.push( $(this).val() );
4563
-
4564
- });
4565
-
4566
- } else if( $select.exists() ) {
4567
-
4568
- $select.find('option:selected').each(function(){
4569
-
4570
- values.push( $(this).val() );
4571
-
4572
- });
4573
-
4574
- } else if( $hidden.exists() ) {
4575
-
4576
- $hidden.each(function(){
4577
-
4578
- // ignor blank values
4579
- if( ! $(this).val() ) {
4580
-
4581
- return;
4582
-
4583
- }
4584
-
4585
- values.push( $(this).val() );
4586
-
4587
- });
4588
-
4589
- }
4590
-
4591
- });
4592
 
4593
-
4594
- // filter duplicates
4595
- values = values.filter (function (v, i, a) { return a.indexOf (v) == i });
4596
-
4597
-
4598
- // update screen
4599
- this.update( 'post_taxonomy', values ).fetch();
4600
-
4601
- },
4602
-
4603
-
4604
- /*
4605
- * events
4606
- *
4607
- * description
4608
- *
4609
- * @type function
4610
- * @date 29/09/2015
4611
- * @since 5.2.3
4612
- *
4613
- * @param $post_id (int)
4614
- * @return $post_id (int)
4615
- */
4616
-
4617
- _change_template: function( e ){
4618
-
4619
- // vars
4620
- var page_template = e.$el.val();
4621
-
4622
-
4623
- // update & fetch
4624
- this.update('page_template', page_template).fetch();
4625
-
4626
- },
4627
-
4628
- _change_parent: function( e ){
4629
-
4630
- // vars
4631
- var page_type = 'parent',
4632
- page_parent = 0;
4633
-
4634
-
4635
- // if is child
4636
- if( e.$el.val() != "" ) {
4637
-
4638
- page_type = 'child';
4639
- page_parent = e.$el.val();
4640
-
4641
- }
4642
-
4643
- // update & fetch
4644
- this.update('page_type', page_type).update('page_parent', page_parent).fetch();
4645
-
4646
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4647
 
4648
- _change_format: function( e ){
4649
-
4650
- // vars
4651
- var post_format = e.$el.val();
4652
-
4653
-
4654
- // default
4655
- if( post_format == '0' ) {
4656
-
4657
- post_format = 'standard';
4658
-
4659
  }
4660
-
4661
-
4662
- // update & fetch
4663
- this.update('post_format', post_format).fetch();
4664
-
4665
- },
4666
-
4667
- _change_term: function( e ){
4668
-
4669
- // reference
4670
- var self = this;
4671
-
4672
-
4673
- // bail early if within media popup
4674
- if( e.$el.closest('.media-frame').exists() ) {
4675
-
4676
- return;
4677
-
4678
  }
4679
-
4680
-
4681
- // set timeout to fix issue with chrome which does not register the change has yet happened
4682
- setTimeout(function(){
4683
-
4684
- self.sync_taxonomy_terms();
4685
-
4686
- }, 1);
4687
-
4688
-
 
 
 
 
4689
  }
4690
 
4691
- });
4692
-
4693
 
4694
- })(jQuery);
4695
-
4696
- (function($){
4697
 
4698
- acf.fields.button_group = acf.field.extend({
4699
-
4700
- type: 'button_group',
4701
- $div: null,
4702
-
4703
- events: {
4704
- 'click input[type="radio"]': 'click'
4705
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4706
 
4707
- focus: function(){
4708
-
4709
- // focus on $select
4710
- this.$div = this.$field.find('.acf-button-group');
4711
-
4712
-
4713
- // get options
4714
- this.o = acf.get_data(this.$div, {
4715
- allow_null: 0
4716
- });
4717
-
4718
- },
4719
 
4720
- click: function( e ){
4721
-
4722
- // vars
4723
- var $radio = e.$el;
4724
- var $label = $radio.parent('label');
4725
- var selected = $label.hasClass('selected');
4726
-
4727
-
4728
- // remove previous selected
4729
- this.$div.find('.selected').removeClass('selected');
4730
-
4731
-
4732
- // add active class
4733
- $label.addClass('selected');
4734
-
4735
-
4736
- // allow null
4737
- if( this.o.allow_null && selected ) {
4738
-
4739
- // unselect
4740
- e.$el.prop('checked', false);
4741
- $label.removeClass('selected');
4742
-
4743
-
4744
- // trigger change
4745
- e.$el.trigger('change');
4746
-
4747
- }
4748
-
4749
- }
4750
 
4751
- });
4752
-
4753
- })(jQuery);
4754
-
4755
- (function($){
4756
 
4757
- acf.fields.checkbox = acf.field.extend({
4758
-
4759
- type: 'checkbox',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4760
 
4761
- events: {
4762
- 'change input': '_change',
4763
- 'click .acf-add-checkbox': '_add'
4764
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4765
 
 
 
 
4766
 
4767
- /*
4768
- * focus
4769
- *
4770
- * This function will setup variables when focused on a field
4771
- *
4772
- * @type function
4773
- * @date 12/04/2016
4774
- * @since 5.3.8
4775
- *
4776
- * @param n/a
4777
- * @return n/a
4778
- */
4779
 
4780
- focus: function(){
4781
-
4782
- // get elements
4783
- this.$ul = this.$field.find('ul');
4784
- this.$input = this.$field.find('input[type="hidden"]');
4785
-
4786
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4787
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4788
 
4789
- add: function(){
4790
-
4791
- // vars
4792
- var name = this.$input.attr('name') + '[]';
4793
-
4794
-
4795
- // vars
4796
- var html = '<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input type="text" name="'+name+'" /></li>';
4797
-
4798
-
4799
- // append
4800
- this.$ul.find('.acf-add-checkbox').parent('li').before( html );
4801
-
4802
- },
4803
 
4804
- _change: function( e ){
 
4805
 
4806
  // vars
4807
- var $ul = this.$ul,
4808
- $inputs = $ul.find('input[type="checkbox"]').not('.acf-checkbox-toggle'),
4809
- checked = e.$el.is(':checked');
4810
-
4811
-
4812
- // is toggle?
4813
- if( e.$el.hasClass('acf-checkbox-toggle') ) {
4814
-
4815
- // toggle all
4816
- $inputs.prop('checked', checked).trigger('change');
4817
-
4818
-
4819
- // return
4820
- return;
4821
-
4822
- }
4823
-
4824
 
4825
- // is custom
4826
- if( e.$el.hasClass('acf-checkbox-custom') ) {
4827
-
4828
- // vars
4829
- var $text = e.$el.next('input[type="text"]');
4830
 
 
 
 
4831
 
4832
- // toggle disabled
4833
- e.$el.next('input[type="text"]').prop('disabled', !checked);
 
 
4834
 
 
 
4835
 
4836
- // remove complelety if no value
4837
- if( !checked && $text.val() == '' ) {
4838
-
4839
- e.$el.parent('li').remove();
 
4840
 
 
 
 
 
 
4841
  }
4842
- }
4843
-
4844
-
4845
- // bail early if no toggle
4846
- if( !$ul.find('.acf-checkbox-toggle').exists() ) {
4847
-
4848
- return;
4849
 
 
 
4850
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4851
 
4852
-
4853
- // determine if all inputs are checked
4854
- var checked = ( $inputs.not(':checked').length == 0 );
4855
-
4856
-
4857
- // update toggle
4858
- $ul.find('.acf-checkbox-toggle').prop('checked', checked);
4859
-
4860
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4861
 
4862
- _add: function( e ){
4863
-
4864
- this.add();
4865
-
 
4866
  }
4867
 
4868
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4869
 
4870
- })(jQuery);
4871
-
4872
- (function($){
 
 
 
 
 
 
 
 
4873
 
4874
- acf.fields.color_picker = acf.field.extend({
4875
 
4876
- type: 'color_picker',
4877
- $input: null,
4878
- $hidden: null,
4879
-
4880
- actions: {
4881
- 'ready': 'initialize',
4882
- 'append': 'initialize'
4883
- },
 
 
 
 
 
 
 
 
 
 
 
4884
 
4885
- focus: function(){
 
4886
 
4887
- this.$input = this.$field.find('input[type="text"]');
4888
- this.$hidden = this.$field.find('input[type="hidden"]');
 
 
4889
 
4890
- },
4891
 
4892
- initialize: function(){
4893
-
4894
- // reference
4895
- var $input = this.$input,
4896
- $hidden = this.$hidden;
4897
-
4898
 
4899
- // trigger change function
4900
- var change_hidden = function(){
4901
-
4902
- // timeout is required to ensure the $input val is correct
4903
- setTimeout(function(){
4904
-
4905
- acf.val( $hidden, $input.val() );
4906
-
4907
- }, 1);
4908
-
4909
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4910
 
 
 
4911
 
4912
- // args
4913
- var args = {
4914
-
4915
- defaultColor: false,
4916
- palettes: true,
4917
- hide: true,
4918
- change: change_hidden,
4919
- clear: change_hidden
4920
 
4921
- }
4922
-
4923
-
4924
- // filter
4925
- var args = acf.apply_filters('color_picker_args', args, this.$field);
4926
-
4927
-
4928
- // iris
4929
- this.$input.wpColorPicker(args);
4930
 
4931
- }
 
4932
 
4933
- });
4934
-
4935
- })(jQuery);
4936
-
4937
- (function($, undefined){
4938
 
4939
- // constants
4940
- var CLASS = 'hidden-by-conditional-logic';
4941
- var CONTEXT = 'conditional_logic';
 
 
 
 
 
 
 
 
4942
 
4943
- // model
4944
- var conditionalLogic = acf.conditional_logic = acf.model.extend({
4945
 
4946
- // storage of fields that have conditions
4947
- conditions: {},
 
 
 
 
4948
 
4949
- // storage of fields that trigger a condition
4950
- triggers: {},
 
 
 
 
 
 
 
 
 
 
 
 
 
4951
 
4952
- // reference to parent element of both the trigger and target
4953
- $parent: false,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4954
 
4955
- // actions
4956
- actions: {
4957
- 'prepare 20': 'render',
4958
- 'append 20': 'render',
4959
- 'change': 'change'
4960
- },
4961
 
 
 
 
 
4962
 
4963
- /*
4964
- * add
4965
- *
4966
- * This function will add a set of conditional logic rules
4967
- *
4968
- * @type function
4969
- * @date 22/05/2015
4970
- * @since 5.2.3
4971
- *
4972
- * @param string target field key
4973
- * @param array conditions array of conditional logic groups
4974
- * @return $post_id (int)
4975
- */
4976
 
4977
- add: function( target, conditions ){
4978
-
4979
- // add triggers
4980
- for( var i in conditions ) {
4981
- var group = conditions[i];
4982
-
4983
- for( var k in group ) {
4984
- var rule = group[k];
4985
-
4986
- this.addTrigger( rule.field, target );
4987
- }
4988
- }
4989
-
4990
-
4991
- // add condition
4992
- this.setCondition( target, conditions );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4993
 
4994
- },
 
 
 
 
 
 
4995
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4996
 
4997
- /**
4998
- * getTrigger
4999
- *
5000
- * This function will return the fields that are triggered by this key.
5001
- *
5002
- * @date 15/11/17
5003
- * @since 5.6.5
5004
- *
5005
- * @param string key The trigger's key.
5006
- * @return mixed
5007
- */
5008
 
5009
- getTrigger: function( key ){
5010
- return this.triggers[ key ] || null;
5011
- },
5012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5013
 
5014
- /**
5015
- * setTrigger
5016
- *
5017
- * This function will set the fields that are triggered by this key.
5018
- *
5019
- * @date 15/11/17
5020
- * @since 5.6.5
5021
- *
5022
- * @param string key The trigger's key.
5023
- * @return mixed
5024
- */
5025
 
5026
- setTrigger: function( key, value ){
5027
- this.triggers[ key ] = value;
5028
- },
 
 
 
5029
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5030
 
5031
- /**
5032
- * addTrigger
5033
- *
5034
- * This function will add a reference for a field that triggers another field's visibility
5035
- *
5036
- * @date 15/11/17
5037
- * @since 5.6.5
5038
- *
5039
- * @param n/a
5040
- * @return n/a
5041
- */
5042
 
5043
- addTrigger: function( trigger, target ){
5044
-
5045
- // vars
5046
- var triggers = this.getTrigger( trigger ) || {};
5047
-
5048
- // append
5049
- triggers[ target ] = 1;
5050
-
5051
- // set
5052
- this.setTrigger(trigger, triggers);
5053
-
5054
- },
5055
 
 
 
5056
 
5057
- /**
5058
- * getConditions
5059
- *
5060
- * This function will return the conditions for all targets.
5061
- *
5062
- * @date 15/11/17
5063
- * @since 5.6.5
5064
- *
5065
- * @param string key The trigger's key.
5066
- * @return mixed
5067
- */
5068
 
5069
- getConditions: function(){
5070
- return this.conditions;
5071
- },
 
5072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5073
 
5074
- /**
5075
- * getCondition
5076
- *
5077
- * This function will return the conditions for a target.
5078
- *
5079
- * @date 15/11/17
5080
- * @since 5.6.5
5081
- *
5082
- * @param string key The trigger's key.
5083
- * @return mixed
5084
- */
5085
 
5086
- getCondition: function( key ){
5087
- return this.conditions[ key ] || null;
5088
- },
 
 
5089
 
 
 
 
 
5090
 
5091
- /**
5092
- * setCondition
5093
- *
5094
- * This function will set the conditions for a target.
5095
- *
5096
- * @date 15/11/17
5097
- * @since 5.6.5
5098
- *
5099
- * @param string key The trigger's key.
5100
- * @return mixed
5101
- */
 
 
 
 
 
 
 
 
 
5102
 
5103
- setCondition: function( key, value ){
5104
- this.conditions[ key ] = value;
5105
- },
 
5106
 
 
 
 
5107
 
5108
- /*
5109
- * render
5110
- *
5111
- * This function will render all fields
5112
- *
5113
- * @type function
5114
- * @date 22/05/2015
5115
- * @since 5.2.3
5116
- *
5117
- * @param $post_id (int)
5118
- * @return $post_id (int)
5119
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5120
 
5121
- render: function( $el ){
5122
-
5123
- // vars
5124
- $el = $el || false;
5125
-
5126
- // get targets
5127
- var $targets = acf.get_fields( '', $el, true );
5128
-
5129
- // render fields
5130
- this.renderFields( $targets );
5131
-
5132
- // action for 3rd party customization
5133
- acf.do_action('refresh', $el);
5134
-
5135
- },
5136
 
 
 
 
 
5137
 
5138
- /**
5139
- * findParent
5140
- *
5141
- * This function will find a parent that contains both the trigger and target
5142
- *
5143
- * @date 15/11/17
5144
- * @since 5.6.5
5145
- *
5146
- * @param n/a
5147
- * @return n/a
5148
- */
5149
 
5150
- findTarget: function( $trigger, target ){
5151
-
5152
- // vars
5153
- var self = this;
5154
-
5155
- // reset scope
5156
- this.$parent = false;
5157
-
5158
-
5159
- // find siblings
5160
- var selector = acf.get_selector( target );
5161
- var $targets = $trigger.siblings( selector );
5162
-
5163
- // return if found
5164
- if( $targets.length ) {
5165
- this.$parent = $trigger.parent();
5166
- return $targets;
5167
- }
5168
-
5169
-
5170
- // find all targets
5171
- var $targets = acf.get_fields(target, false, true);
5172
-
5173
- // refine scope if more than 1 found
5174
- if( $targets.length > 1 ) {
5175
-
5176
- // loop
5177
- $trigger.parents('.acf-row, .acf-table, .acf-fields').each(function(){
5178
-
5179
- // vars
5180
- var $parent = $(this);
5181
- var $child = $parent.find( $targets );
5182
-
5183
- // found
5184
- if( $child.length ) {
5185
- $targets = $child;
5186
- self.$parent = $parent;
5187
- return false;
5188
- }
5189
-
5190
- });
5191
-
5192
- }
5193
-
5194
- // return
5195
- return $targets;
5196
-
5197
- },
5198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5199
 
5200
- /*
5201
- * change
5202
- *
5203
- * This function is called when an input is changed and will render any fields which are considered targets of this trigger
5204
- *
5205
- * @type function
5206
- * @date 22/05/2015
5207
- * @since 5.2.3
5208
- *
5209
- * @param $post_id (int)
5210
- * @return $post_id (int)
5211
- */
5212
 
5213
- change: function( $input ){
5214
-
5215
- // vars
5216
- var $trigger = acf.get_field_wrap($input);
5217
- var key = $trigger.data('key');
5218
- var trigger = this.getTrigger(key);
5219
-
5220
- // bail early if this field is not a trigger
5221
- if( !trigger ) return false;
5222
-
5223
- // loop
5224
- for( var target in trigger ) {
5225
-
5226
- // get target(s)
5227
- var $targets = this.findTarget( $trigger, target );
5228
-
5229
- // render
5230
- this.renderFields( $targets );
5231
-
5232
  }
5233
-
5234
- // action for 3rd party customization
5235
- acf.do_action('refresh', this.$parent);
5236
-
5237
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
5238
 
 
 
 
 
5239
 
5240
- /*
5241
- * renderFields
5242
- *
5243
- * This function will render a selection of fields
5244
- *
5245
- * @type function
5246
- * @date 22/05/2015
5247
- * @since 5.2.3
5248
- *
5249
- * @param $post_id (int)
5250
- * @return $post_id (int)
5251
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
5252
 
5253
- renderFields: function( $targets ) {
 
 
 
5254
 
5255
- // reference
5256
- var self = this;
5257
-
5258
- // loop
5259
- $targets.each(function(){
5260
- self.renderField( $(this) );
5261
- });
5262
-
5263
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5264
 
 
 
5265
 
5266
- /*
5267
- * render_field
5268
- *
5269
- * This function will render a field
5270
- *
5271
- * @type function
5272
- * @date 22/05/2015
5273
- * @since 5.2.3
5274
- *
5275
- * @param $post_id (int)
5276
- * @return $post_id (int)
5277
- */
5278
 
5279
- renderField : function( $target ){
5280
-
5281
- // vars
5282
- var visibility = false;
5283
- var key = $target.data('key');
5284
- var condition = this.getCondition( key );
 
 
5285
 
5286
- // bail early if this field does not contain any conditional logic
5287
- if( !condition ) return false;
 
5288
 
5289
- // loop
5290
- for( var i = 0; i < condition.length; i++ ) {
5291
 
5292
  // vars
5293
- var group = condition[i],
5294
- match_group = true;
5295
 
5296
- // loop
5297
- for( var k = 0; k < group.length; k++ ) {
5298
-
5299
- // vars
5300
- var rule = group[k];
5301
 
5302
- // get trigger for rule
5303
- var $trigger = this.findTarget( $target, rule.field );
 
5304
 
5305
- // break if rule did not validate
5306
- if( !this.calculate(rule, $trigger, $target) ) {
5307
- match_group = false;
5308
- break;
5309
- }
5310
- }
5311
-
5312
- // set visibility if rule group did validate
5313
- if( match_group ) {
5314
- visibility = true;
5315
- break;
5316
- }
5317
- }
5318
-
5319
- // hide / show
5320
- if( visibility ) {
5321
- this.showField( $target, key );
5322
  } else {
5323
- this.hideField( $target, key );
5324
- }
5325
-
5326
- },
5327
-
5328
-
5329
- /*
5330
- * show_field
5331
- *
5332
- * This function will show a field
5333
- *
5334
- * @type function
5335
- * @date 22/05/2015
5336
- * @since 5.2.3
5337
- *
5338
- * @param $post_id (int)
5339
- * @return $post_id (int)
5340
- */
5341
-
5342
- showField: function( $field, lockKey ){
5343
-
5344
- // enable
5345
- acf.enable( $field, lockKey );
5346
-
5347
- // show field and store result
5348
- var changed = acf.show( $field, lockKey );
5349
-
5350
- // use changed to set cl class
5351
- if( changed ) {
5352
- $field.removeClass( CLASS );
5353
- }
5354
-
5355
- // always do action to avoid tab field bugs (fixed in 5.7)
5356
- acf.do_action('show_field', $field, CONTEXT);
5357
-
5358
- // return
5359
- return changed;
5360
- },
5361
-
5362
-
5363
- /*
5364
- * hide_field
5365
- *
5366
- * This function will hide a field
5367
- *
5368
- * @type function
5369
- * @date 22/05/2015
5370
- * @since 5.2.3
5371
- *
5372
- * @param $post_id (int)
5373
- * @return $post_id (int)
5374
- */
5375
-
5376
- hideField: function( $field, lockKey ){
5377
-
5378
- // disable
5379
- acf.disable( $field, lockKey );
5380
-
5381
- // hide field and store result
5382
- var changed = acf.hide( $field, lockKey );
5383
-
5384
- // use changed to set cl class
5385
- if( changed ) {
5386
- $field.addClass( CLASS );
5387
  }
5388
-
5389
- // always do action to avoid tab field bugs (fixed in 5.7)
5390
- acf.do_action('hide_field', $field, CONTEXT);
5391
-
5392
- // return
5393
- return changed;
5394
- },
5395
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5396
 
5397
- /*
5398
- * calculate
5399
- *
5400
- * This function will calculate if a rule matches based on the $trigger
5401
- *
5402
- * @type function
5403
- * @date 22/05/2015
5404
- * @since 5.2.3
5405
- *
5406
- * @param $post_id (int)
5407
- * @return $post_id (int)
5408
- */
5409
 
5410
- calculate: function( rule, $trigger, $target ){
5411
-
5412
- // bail early if $trigger could not be found
5413
- if( !$trigger || !$target ) return false;
5414
-
5415
-
5416
- // debug
5417
- //console.log( 'calculate(%o, %o, %o)', rule, $trigger, $target);
5418
-
5419
 
5420
  // vars
5421
- var match = false,
5422
- type = $trigger.data('type');
5423
 
5424
-
5425
- // input with :checked
5426
- if( type == 'true_false' || type == 'checkbox' || type == 'radio' || type == 'button_group' ) {
5427
-
5428
- match = this.calculate_checkbox( rule, $trigger );
5429
-
5430
-
5431
- } else if( type == 'select' ) {
5432
 
5433
- match = this.calculate_select( rule, $trigger );
5434
-
5435
- }
5436
-
5437
-
5438
- // reverse if 'not equal to'
5439
- if( rule.operator === "!=" ) {
5440
 
5441
- match = !match;
5442
-
5443
- }
5444
-
5445
-
5446
- // return
5447
- return match;
5448
-
5449
- },
5450
-
5451
- calculate_checkbox: function( rule, $trigger ){
5452
-
5453
- // look for selected input
5454
- var match = $trigger.find('input[value="' + rule.value + '"]:checked').exists();
5455
-
5456
-
5457
- // override for "allow null"
5458
- if( rule.value === '' && !$trigger.find('input:checked').exists() ) {
5459
 
5460
- match = true;
 
 
5461
 
5462
- }
5463
-
 
 
 
5464
 
5465
  // return
5466
- return match;
5467
-
5468
- },
5469
 
 
 
5470
 
5471
- calculate_select: function( rule, $trigger ){
5472
-
5473
- // vars
5474
- var $select = $trigger.find('select'),
5475
- val = $select.val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5476
 
 
5477
 
5478
- // check for no value
5479
- if( !val && !$.isNumeric(val) ) {
5480
-
5481
- val = '';
5482
-
 
 
 
 
 
 
 
 
 
5483
  }
5484
-
5485
-
5486
- // convert to array
5487
- if( !$.isArray(val) ) {
5488
-
5489
- val = [ val ];
5490
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5491
  }
5492
-
5493
-
5494
- // calc
5495
- match = ($.inArray(rule.value, val) > -1);
5496
 
5497
-
5498
- // return
5499
- return match;
5500
-
5501
  }
5502
-
5503
- });
5504
-
5505
-
5506
- // compatibility
5507
- conditionalLogic.show_field = conditionalLogic.showField;
5508
- conditionalLogic.hide_field = conditionalLogic.hideField;
5509
-
5510
 
5511
- })(jQuery);
 
 
 
 
 
 
5512
 
5513
- (function($){
5514
-
5515
- /*
5516
- * acf.datepicker
5517
- *
5518
- * description
5519
- *
5520
- * @type function
5521
- * @date 16/12/2015
5522
- * @since 5.3.2
5523
- *
5524
- * @param $post_id (int)
5525
- * @return $post_id (int)
5526
- */
5527
-
5528
- acf.datepicker = acf.model.extend({
5529
-
5530
- actions: {
5531
- 'ready 1': 'ready'
5532
- },
5533
-
5534
- ready: function(){
5535
-
5536
- // vars
5537
- var locale = acf.get('locale'),
5538
- rtl = acf.get('rtl')
5539
- l10n = acf._e('date_picker');
5540
-
5541
-
5542
- // bail ealry if no l10n (fiedl groups admin page)
5543
- if( !l10n ) return;
5544
-
5545
-
5546
- // bail ealry if no datepicker library
5547
- if( typeof $.datepicker === 'undefined' ) return;
5548
-
5549
-
5550
- // rtl
5551
- l10n.isRTL = rtl;
5552
-
5553
-
5554
- // append
5555
- $.datepicker.regional[ locale ] = l10n;
5556
- $.datepicker.setDefaults(l10n);
5557
-
5558
- },
5559
-
5560
-
5561
- /*
5562
- * init
5563
- *
5564
- * This function will initialize JS
5565
- *
5566
- * @type function
5567
- * @date 2/06/2016
5568
- * @since 5.3.8
5569
- *
5570
- * @param $input (jQuery selector)
5571
- * @param args (object)
5572
- * @return n/a
5573
- */
5574
-
5575
- init: function( $input, args ){
5576
-
5577
- // bail ealry if no datepicker library
5578
- if( typeof $.datepicker === 'undefined' ) return;
5579
-
5580
-
5581
- // defaults
5582
- args = args || {};
5583
-
5584
-
5585
- // add date picker
5586
- $input.datepicker( args );
5587
-
5588
-
5589
- // wrap the datepicker (only if it hasn't already been wrapped)
5590
- if( $('body > #ui-datepicker-div').exists() ) {
5591
-
5592
- $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
5593
-
5594
  }
5595
-
5596
- },
5597
-
5598
-
5599
- /*
5600
- * init
5601
- *
5602
- * This function will remove JS
5603
- *
5604
- * @type function
5605
- * @date 2/06/2016
5606
- * @since 5.3.8
5607
- *
5608
- * @param $input (jQuery selector)
5609
- * @return n/a
5610
- */
5611
-
5612
- destroy: function( $input ){
5613
-
5614
- // do nothing
5615
-
5616
  }
5617
-
5618
- });
5619
-
5620
- acf.fields.date_picker = acf.field.extend({
5621
-
5622
- type: 'date_picker',
5623
- $el: null,
5624
- $input: null,
5625
- $hidden: null,
5626
-
5627
- o: {},
5628
-
5629
- actions: {
5630
- 'ready': 'initialize',
5631
- 'append': 'initialize'
5632
- },
5633
-
5634
- events: {
5635
- 'blur input[type="text"]': 'blur'
5636
- },
5637
-
5638
- focus: function(){
5639
-
5640
- // get elements
5641
- this.$el = this.$field.find('.acf-date-picker');
5642
- this.$input = this.$el.find('input[type="text"]');
5643
- this.$hidden = this.$el.find('input[type="hidden"]');
5644
-
5645
-
5646
- // get options
5647
- this.o = acf.get_data( this.$el );
5648
-
5649
- },
5650
-
5651
- initialize: function(){
5652
-
5653
- // save_format - compatibility with ACF < 5.0.0
5654
- if( this.o.save_format ) {
5655
-
5656
- return this.initialize2();
5657
-
5658
  }
5659
-
5660
-
5661
- // create options
5662
- var args = {
5663
- dateFormat: this.o.date_format,
5664
- altField: this.$hidden,
5665
- altFormat: 'yymmdd',
5666
- changeYear: true,
5667
- yearRange: "-100:+100",
5668
- changeMonth: true,
5669
- showButtonPanel: true,
5670
- firstDay: this.o.first_day
5671
- };
5672
-
5673
-
5674
- // filter for 3rd party customization
5675
- args = acf.apply_filters('date_picker_args', args, this.$field);
5676
-
5677
-
5678
- // add date picker
5679
- acf.datepicker.init( this.$input, args );
5680
-
5681
-
5682
- // action for 3rd party customization
5683
- acf.do_action('date_picker_init', this.$input, args, this.$field);
5684
-
5685
- },
5686
-
5687
- initialize2: function(){
5688
-
5689
- // get and set value from alt field
5690
- this.$input.val( this.$hidden.val() );
5691
-
5692
-
5693
- // create options
5694
- var args = {
5695
- dateFormat: this.o.date_format,
5696
- altField: this.$hidden,
5697
- altFormat: this.o.save_format,
5698
- changeYear: true,
5699
- yearRange: "-100:+100",
5700
- changeMonth: true,
5701
- showButtonPanel: true,
5702
- firstDay: this.o.first_day
 
 
 
 
 
 
 
 
 
5703
  };
5704
-
5705
-
5706
- // filter for 3rd party customization
5707
- args = acf.apply_filters('date_picker_args', args, this.$field);
5708
-
5709
-
5710
- // backup
5711
- var dateFormat = args.dateFormat;
5712
-
5713
-
5714
- // change args.dateFormat
5715
- args.dateFormat = this.o.save_format;
5716
-
5717
-
5718
- // add date picker
5719
- acf.datepicker.init( this.$input, args );
5720
-
5721
-
5722
- // now change the format back to how it should be.
5723
- this.$input.datepicker( 'option', 'dateFormat', dateFormat );
5724
-
5725
-
5726
- // action for 3rd party customization
5727
- acf.do_action('date_picker_init', this.$input, args, this.$field);
5728
-
5729
- },
5730
-
5731
- blur: function(){
5732
-
5733
- if( !this.$input.val() ) {
5734
-
5735
- this.$hidden.val('');
5736
-
5737
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5738
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5739
  }
5740
-
5741
- });
 
 
 
5742
 
5743
- })(jQuery);
 
 
 
5744
 
5745
- (function($){
5746
 
5747
- /*
5748
- * acf.datepicker
 
 
 
5749
  *
5750
- * description
 
5751
  *
5752
- * @type function
5753
- * @date 16/12/2015
5754
- * @since 5.3.2
5755
  *
5756
- * @param $post_id (int)
5757
- * @return $post_id (int)
5758
  */
5759
 
5760
- acf.datetimepicker = acf.model.extend({
5761
-
5762
- actions: {
5763
- 'ready 1': 'ready'
5764
- },
5765
-
5766
- ready: function(){
5767
-
5768
- // vars
5769
- var locale = acf.get('locale'),
5770
- rtl = acf.get('rtl')
5771
- l10n = acf._e('date_time_picker');
5772
-
5773
-
5774
- // bail ealry if no l10n (fiedl groups admin page)
5775
- if( !l10n ) return;
5776
-
5777
-
5778
- // bail ealry if no timepicker library
5779
- if( typeof $.timepicker === 'undefined' ) return;
5780
-
5781
-
5782
- // rtl
5783
- l10n.isRTL = rtl;
5784
-
5785
-
5786
- // append
5787
- $.timepicker.regional[ locale ] = l10n;
5788
- $.timepicker.setDefaults(l10n);
5789
-
5790
- },
5791
-
5792
-
5793
- /*
5794
- * init
5795
- *
5796
- * This function will initialize JS
5797
- *
5798
- * @type function
5799
- * @date 2/06/2016
5800
- * @since 5.3.8
5801
- *
5802
- * @param $input (jQuery selector)
5803
- * @param args (object)
5804
- * @return n/a
5805
- */
5806
-
5807
- init: function( $input, args ){
5808
-
5809
- // bail ealry if no timepicker library
5810
- if( typeof $.timepicker === 'undefined' ) return;
5811
-
5812
-
5813
- // defaults
5814
- args = args || {};
5815
-
5816
-
5817
- // add date picker
5818
- $input.datetimepicker( args );
5819
-
5820
-
5821
- // wrap the datepicker (only if it hasn't already been wrapped)
5822
- if( $('body > #ui-datepicker-div').exists() ) {
5823
-
5824
- $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
5825
-
5826
- }
5827
-
5828
- },
5829
-
5830
-
5831
- /*
5832
- * init
5833
- *
5834
- * This function will remove JS
5835
- *
5836
- * @type function
5837
- * @date 2/06/2016
5838
- * @since 5.3.8
5839
- *
5840
- * @param $input (jQuery selector)
5841
- * @return n/a
5842
- */
5843
-
5844
- destroy: function( $input ){
5845
-
5846
- // do nothing
5847
-
5848
- }
5849
-
5850
- });
5851
-
5852
-
5853
- acf.fields.date_time_picker = acf.field.extend({
5854
-
5855
- type: 'date_time_picker',
5856
- $el: null,
5857
- $input: null,
5858
- $hidden: null,
5859
-
5860
- o: {},
5861
-
5862
- actions: {
5863
- 'ready': 'initialize',
5864
- 'append': 'initialize'
5865
- },
5866
-
5867
- events: {
5868
- 'blur input[type="text"]': 'blur'
5869
- },
5870
 
5871
- focus: function(){
5872
-
5873
- // get elements
5874
- this.$el = this.$field.find('.acf-date-time-picker');
5875
- this.$input = this.$el.find('input[type="text"]');
5876
- this.$hidden = this.$el.find('input[type="hidden"]');
5877
-
5878
-
5879
- // get options
5880
- this.o = acf.get_data( this.$el );
5881
-
5882
- },
 
 
 
5883
 
5884
- initialize: function(){
5885
-
5886
- // create options
5887
- var args = {
5888
- dateFormat: this.o.date_format,
5889
- timeFormat: this.o.time_format,
5890
- altField: this.$hidden,
5891
- altFieldTimeOnly: false,
5892
- altFormat: 'yy-mm-dd',
5893
- altTimeFormat: 'HH:mm:ss',
5894
- changeYear: true,
5895
- yearRange: "-100:+100",
5896
- changeMonth: true,
5897
- showButtonPanel: true,
5898
- firstDay: this.o.first_day,
5899
- controlType: 'select',
5900
- oneLine: true
5901
- };
5902
-
5903
-
5904
- // filter for 3rd party customization
5905
- args = acf.apply_filters('date_time_picker_args', args, this.$field);
5906
-
5907
-
5908
- // add date time picker
5909
- acf.datetimepicker.init( this.$input, args );
5910
-
5911
-
5912
- // action for 3rd party customization
5913
- acf.do_action('date_time_picker_init', this.$input, args, this.$field);
5914
-
5915
- },
5916
 
5917
- blur: function(){
5918
-
5919
- if( !this.$input.val() ) {
5920
-
5921
- this.$hidden.val('');
5922
-
5923
- }
5924
-
5925
- }
5926
 
5927
- });
5928
 
5929
- })(jQuery);
5930
 
5931
- (function($){
 
 
 
 
 
 
 
 
 
 
5932
 
5933
- acf.fields.file = acf.field.extend({
5934
-
5935
- type: 'file',
5936
- $el: null,
5937
- $input: null,
5938
-
5939
- actions: {
5940
- 'ready': 'initialize',
5941
- 'append': 'initialize'
5942
- },
5943
-
5944
- events: {
5945
- 'click a[data-name="add"]': 'add',
5946
- 'click a[data-name="edit"]': 'edit',
5947
- 'click a[data-name="remove"]': 'remove',
5948
- 'change input[type="file"]': 'change'
5949
- },
5950
-
5951
-
5952
- /*
5953
- * focus
5954
- *
5955
- * This function will setup variables when focused on a field
5956
- *
5957
- * @type function
5958
- * @date 12/04/2016
5959
- * @since 5.3.8
5960
- *
5961
- * @param n/a
5962
- * @return n/a
5963
- */
5964
 
5965
- focus: function(){
5966
-
5967
- // get elements
5968
- this.$el = this.$field.find('.acf-file-uploader');
5969
- this.$input = this.$el.find('input[type="hidden"]');
5970
-
5971
-
5972
- // get options
5973
- this.o = acf.get_data( this.$el );
5974
-
5975
- },
5976
 
 
 
5977
 
5978
- /*
5979
- * initialize
5980
- *
5981
- * This function is used to setup basic upload form attributes
5982
- *
5983
- * @type function
5984
- * @date 12/04/2016
5985
- * @since 5.3.8
5986
- *
5987
- * @param n/a
5988
- * @return n/a
5989
- */
5990
 
5991
- initialize: function(){
5992
-
5993
- // add attribute to form
5994
- if( this.o.uploader == 'basic' ) {
5995
-
5996
- this.$el.closest('form').attr('enctype', 'multipart/form-data');
5997
-
5998
- }
5999
-
6000
- },
6001
 
 
 
 
 
 
 
 
6002
 
6003
- /*
6004
- * prepare
6005
- *
6006
- * This function will prepare an object of attachment data
6007
- * selecting a library image vs embed an image via url return different data
6008
- * this function will keep the 2 consistent
6009
- *
6010
- * @type function
6011
- * @date 12/04/2016
6012
- * @since 5.3.8
6013
- *
6014
- * @param attachment (object)
6015
- * @return data (object)
6016
- */
6017
 
6018
- prepare: function( attachment ) {
6019
-
6020
- // defaults
6021
- attachment = attachment || {};
6022
-
6023
-
6024
- // bail ealry if already valid
6025
- if( attachment._valid ) return attachment;
6026
-
6027
-
6028
- // vars
6029
- var data = {
6030
- url: '',
6031
- alt: '',
6032
- title: '',
6033
- filename: '',
6034
- filesizeHumanReadable: '',
6035
- icon: '/wp-includes/images/media/default.png'
6036
- };
6037
-
6038
-
6039
- // wp image
6040
- if( attachment.id ) {
6041
-
6042
- // update data
6043
- data = attachment.attributes;
6044
-
6045
- }
6046
-
6047
-
6048
- // valid
6049
- data._valid = true;
6050
-
6051
-
6052
- // return
6053
- return data;
6054
-
6055
- },
6056
 
 
 
6057
 
6058
- /*
6059
- * render
6060
- *
6061
- * This function will render the UI
6062
- *
6063
- * @type function
6064
- * @date 12/04/2016
6065
- * @since 5.3.8
6066
- *
6067
- * @param attachment (obj)
6068
- * @return n/a
6069
- */
6070
 
6071
- render: function( data ){
6072
-
6073
- // prepare
6074
- data = this.prepare(data);
6075
-
6076
-
6077
- // update els
6078
- this.$el.find('img').attr({
6079
- src: data.icon,
6080
- alt: data.alt,
6081
- title: data.title
6082
- });
6083
- this.$el.find('[data-name="title"]').text( data.title );
6084
- this.$el.find('[data-name="filename"]').text( data.filename ).attr( 'href', data.url );
6085
- this.$el.find('[data-name="filesize"]').text( data.filesizeHumanReadable );
6086
-
6087
-
6088
- // vars
6089
- var val = '';
6090
-
6091
-
6092
- // WP attachment
6093
- if( data.id ) {
6094
-
6095
- val = data.id;
6096
-
6097
- }
6098
-
6099
-
6100
- // update val
6101
- acf.val( this.$input, val );
6102
-
6103
-
6104
- // update class
6105
- if( val ) {
6106
-
6107
- this.$el.addClass('has-value');
6108
-
6109
- } else {
6110
-
6111
- this.$el.removeClass('has-value');
6112
-
6113
- }
6114
-
6115
- },
6116
 
 
 
6117
 
6118
- /*
6119
- * add
6120
- *
6121
- * event listener
6122
- *
6123
- * @type function
6124
- * @date 12/04/2016
6125
- * @since 5.3.8
6126
- *
6127
- * @param e (event)
6128
- * @return n/a
6129
- */
6130
 
6131
- add: function() {
6132
-
6133
- // reference
6134
- var self = this,
6135
- $field = this.$field;
6136
-
6137
-
6138
- // get repeater
6139
- var $repeater = acf.get_closest_field( $field, 'repeater' );
6140
-
6141
-
6142
- // popup
6143
- var frame = acf.media.popup({
6144
-
6145
- title: acf._e('file', 'select'),
6146
- mode: 'select',
6147
- type: '',
6148
- field: $field.data('key'),
6149
- multiple: $repeater.exists(),
6150
- library: this.o.library,
6151
- mime_types: this.o.mime_types,
6152
-
6153
- select: function( attachment, i ) {
6154
-
6155
- // select / add another image field?
6156
- if( i > 0 ) {
6157
-
6158
- // vars
6159
- var key = $field.data('key'),
6160
- $tr = $field.closest('.acf-row');
6161
-
6162
-
6163
- // reset field
6164
- $field = false;
6165
-
6166
-
6167
- // find next image field
6168
- $tr.nextAll('.acf-row:visible').each(function(){
6169
-
6170
- // get next $field
6171
- $field = acf.get_field( key, $(this) );
6172
-
6173
-
6174
- // bail early if $next was not found
6175
- if( !$field ) return;
6176
-
6177
-
6178
- // bail early if next file uploader has value
6179
- if( $field.find('.acf-file-uploader.has-value').exists() ) {
6180
-
6181
- $field = false;
6182
- return;
6183
-
6184
- }
6185
-
6186
-
6187
- // end loop if $next is found
6188
- return false;
6189
-
6190
- });
6191
-
6192
-
6193
-
6194
- // add extra row if next is not found
6195
- if( !$field ) {
6196
-
6197
- $tr = acf.fields.repeater.doFocus( $repeater ).add();
6198
-
6199
-
6200
- // bail early if no $tr (maximum rows hit)
6201
- if( !$tr ) return false;
6202
-
6203
-
6204
- // get next $field
6205
- $field = acf.get_field( key, $tr );
6206
-
6207
- }
6208
-
6209
- }
6210
-
6211
-
6212
- // render
6213
- self.set('$field', $field).render( attachment );
6214
-
6215
- }
6216
- });
6217
-
6218
- },
6219
 
 
 
6220
 
6221
- /*
6222
- * edit
 
 
 
 
 
 
6223
  *
6224
- * event listener
6225
  *
6226
- * @type function
6227
- * @date 12/04/2016
6228
- * @since 5.3.8
6229
  *
6230
- * @param e (event)
6231
- * @return n/a
6232
  */
6233
 
6234
- edit: function() {
6235
-
6236
- // reference
6237
- var self = this,
6238
- $field = this.$field;
6239
-
6240
-
6241
- // vars
6242
- var val = this.$input.val();
6243
-
6244
-
6245
- // bail early if no val
6246
- if( !val ) return;
6247
-
6248
-
6249
- // popup
6250
- var frame = acf.media.popup({
6251
-
6252
- title: acf._e('file', 'edit'),
6253
- button: acf._e('file', 'update'),
6254
- mode: 'edit',
6255
- attachment: val,
6256
-
6257
- select: function( attachment, i ) {
6258
-
6259
- // render
6260
- self.set('$field', $field).render( attachment );
6261
-
6262
- }
6263
-
6264
- });
6265
-
6266
  },
6267
 
6268
-
6269
- /*
6270
- * remove
6271
  *
6272
- * event listener
6273
  *
6274
- * @type function
6275
- * @date 12/04/2016
6276
- * @since 5.3.8
6277
  *
6278
- * @param e (event)
6279
- * @return n/a
6280
  */
6281
 
6282
- remove: function() {
6283
-
6284
- // vars
6285
- var attachment = {};
6286
-
6287
-
6288
- // add file to field
6289
- this.render( attachment );
6290
-
6291
  },
6292
 
6293
-
6294
- /*
6295
- * get_file_info
6296
  *
6297
- * This function will find basic file info and store it in a hidden input
6298
  *
6299
- * @type function
6300
- * @date 18/1/17
6301
- * @since 5.5.0
6302
  *
6303
- * @param $file_input (jQuery)
6304
- * @param $hidden_input (jQuery)
6305
- * @return n/a
6306
  */
6307
 
6308
- get_file_info: function( $file_input, $hidden_input ){
6309
-
6310
- // vars
6311
- var val = $file_input.val(),
6312
- attachment = {};
6313
 
6314
-
6315
- // bail early if no value
6316
- if( !val ) {
6317
-
6318
- $hidden_input.val('');
6319
- return;
6320
-
6321
  }
6322
 
 
 
6323
 
6324
- // url
6325
- attachment.url = val;
6326
-
6327
-
6328
- // modern browsers
6329
- var files = $file_input[0].files;
6330
-
6331
- if( files.length ){
6332
-
6333
- // vars
6334
- var file = files[0];
6335
-
6336
-
6337
- // update
6338
- attachment.size = file.size;
6339
- attachment.type = file.type;
6340
-
6341
-
6342
- // image
6343
- if( file.type.indexOf('image') > -1 ) {
6344
-
6345
- // vars
6346
- var _url = window.URL || window.webkitURL;
6347
-
6348
-
6349
- // temp image
6350
- var img = new Image();
6351
-
6352
- img.onload = function () {
6353
-
6354
- // update
6355
- attachment.width = this.width;
6356
- attachment.height = this.height;
6357
-
6358
-
6359
- // set hidden input value
6360
- $hidden_input.val( jQuery.param(attachment) );
6361
-
6362
- };
6363
-
6364
- img.src = _url.createObjectURL(file);
6365
-
6366
- }
6367
-
6368
  }
6369
 
6370
-
6371
- // set hidden input value
6372
- $hidden_input.val( jQuery.param(attachment) );
6373
-
6374
  },
6375
 
6376
-
6377
- /*
6378
- * change
6379
  *
6380
- * This function will update the hidden input when selecting a basic file to add basic validation
6381
  *
6382
- * @type function
6383
- * @date 12/04/2016
6384
- * @since 5.3.8
6385
  *
6386
- * @param e (event)
6387
- * @return n/a
6388
  */
6389
 
6390
- change: function( e ){
6391
-
6392
- this.get_file_info( e.$el, this.$input );
6393
-
6394
- }
6395
-
6396
- });
6397
-
6398
-
6399
- })(jQuery);
6400
-
6401
- (function($){
6402
-
6403
- acf.fields.google_map = acf.field.extend({
6404
-
6405
- type: 'google_map',
6406
- url: '',
6407
- $el: null,
6408
- $search: null,
6409
-
6410
- timeout: null,
6411
- status : '', // '', 'loading', 'ready'
6412
- geocoder : false,
6413
- map : false,
6414
- maps : {},
6415
- $pending: $(),
6416
-
6417
- actions: {
6418
- // have considered changing to 'load', however, could cause issues with devs expecting the API to exist earlier
6419
- 'ready': 'initialize',
6420
- 'append': 'initialize',
6421
- 'show': 'show'
6422
- },
6423
-
6424
- events: {
6425
- 'click a[data-name="clear"]': '_clear',
6426
- 'click a[data-name="locate"]': '_locate',
6427
- 'click a[data-name="search"]': '_search',
6428
- 'keydown .search': '_keydown',
6429
- 'keyup .search': '_keyup',
6430
- 'focus .search': '_focus',
6431
- 'blur .search': '_blur',
6432
- //'paste .search': '_paste',
6433
- 'mousedown .acf-google-map': '_mousedown'
6434
- },
6435
-
6436
- focus: function(){
6437
 
6438
- // get elements
6439
- this.$el = this.$field.find('.acf-google-map');
6440
- this.$search = this.$el.find('.search');
6441
-
6442
-
6443
- // get options
6444
- this.o = acf.get_data( this.$el );
6445
- this.o.id = this.$el.attr('id');
6446
-
6447
-
6448
- // get map
6449
- if( this.maps[ this.o.id ] ) {
6450
-
6451
- this.map = this.maps[ this.o.id ];
6452
-
6453
  }
6454
 
 
 
 
 
 
6455
  },
6456
 
6457
-
6458
- /*
6459
- * is_ready
6460
  *
6461
- * This function will ensure google API is available and return a boolean for the current status
6462
  *
6463
- * @type function
6464
- * @date 19/11/2014
6465
- * @since 5.0.9
6466
  *
6467
- * @param n/a
6468
- * @return (boolean)
6469
  */
6470
 
6471
- is_ready: function(){
6472
-
6473
- // reference
6474
- var self = this;
6475
-
6476
-
6477
- // ready
6478
- if( this.status == 'ready' ) return true;
6479
-
6480
-
6481
- // loading
6482
- if( this.status == 'loading' ) return false;
6483
-
6484
-
6485
- // check exists (optimal)
6486
- if( acf.isset(window, 'google', 'maps', 'places') ) {
6487
-
6488
- this.status = 'ready';
6489
- return true;
6490
-
6491
- }
6492
-
6493
-
6494
- // check exists (ok)
6495
- if( acf.isset(window, 'google', 'maps') ) {
6496
-
6497
- this.status = 'ready';
6498
-
6499
- }
6500
-
6501
-
6502
- // attempt load google.maps.places
6503
- if( this.url ) {
6504
-
6505
- // set status
6506
- this.status = 'loading';
6507
-
6508
-
6509
- // enqueue
6510
- acf.enqueue_script(this.url, function(){
6511
-
6512
- // set status
6513
- self.status = 'ready';
6514
-
6515
-
6516
- // initialize pending
6517
- self.initialize_pending();
6518
-
6519
- });
6520
-
6521
- }
6522
-
6523
-
6524
- // ready
6525
- if( this.status == 'ready' ) return true;
6526
-
6527
-
6528
- // return
6529
- return false;
6530
-
6531
  },
6532
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6533
 
6534
- /*
6535
- * initialize_pending
6536
  *
6537
- * This function will initialize pending fields
6538
  *
6539
- * @type function
6540
- * @date 27/08/2016
6541
- * @since 5.4.0
6542
  *
6543
  * @param n/a
6544
  * @return n/a
6545
  */
6546
 
6547
- initialize_pending: function(){
6548
-
6549
- // reference
6550
- var self = this;
6551
-
6552
- this.$pending.each(function(){
6553
-
6554
- self.set('$field', $(this)).initialize();
6555
-
6556
- });
6557
-
6558
-
6559
- // reset
6560
- this.$pending = $();
6561
-
 
 
 
 
 
6562
  },
6563
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6564
 
6565
- /*
6566
- * actions
6567
  *
6568
- * these functions are fired for this fields actions
6569
  *
6570
- * @type function
6571
- * @date 17/09/2015
6572
- * @since 5.2.3
6573
  *
6574
- * @param (mixed)
6575
  * @return n/a
6576
  */
6577
 
6578
- initialize: function(){
6579
-
6580
- // add to pending
6581
- if( !this.is_ready() ) {
6582
-
6583
- this.$pending = this.$pending.add( this.$field );
6584
-
6585
- return false;
6586
-
6587
- }
6588
-
6589
-
6590
- // load geocode
6591
- if( !this.geocoder ) {
6592
-
6593
- this.geocoder = new google.maps.Geocoder();
6594
-
6595
- }
6596
-
6597
-
6598
- // reference
6599
- var self = this,
6600
- $field = this.$field,
6601
- $el = this.$el,
6602
- $search = this.$search;
6603
-
6604
-
6605
- // input value may be cached by browser, so update the search input to match
6606
- $search.val( this.$el.find('.input-address').val() );
6607
-
6608
-
6609
- // map
6610
- var map_args = acf.apply_filters('google_map_args', {
6611
-
6612
- scrollwheel: false,
6613
- zoom: parseInt(this.o.zoom),
6614
- center: new google.maps.LatLng(this.o.lat, this.o.lng),
6615
- mapTypeId: google.maps.MapTypeId.ROADMAP
6616
-
6617
- }, this.$field);
6618
-
6619
-
6620
- // create map
6621
- this.map = new google.maps.Map( this.$el.find('.canvas')[0], map_args);
6622
-
6623
-
6624
- // search
6625
- if( acf.isset(window, 'google', 'maps', 'places', 'Autocomplete') ) {
6626
-
6627
- // vars
6628
- var autocomplete = new google.maps.places.Autocomplete( this.$search[0] );
6629
-
6630
-
6631
- // bind
6632
- autocomplete.bindTo('bounds', this.map);
6633
-
6634
-
6635
- // event
6636
- google.maps.event.addListener(autocomplete, 'place_changed', function( e ) {
6637
-
6638
- // vars
6639
- var place = this.getPlace();
6640
-
6641
-
6642
- // search
6643
- self.search( place );
6644
-
6645
- });
6646
-
6647
-
6648
- // append
6649
- this.map.autocomplete = autocomplete;
6650
-
6651
- }
6652
-
6653
-
6654
- // marker
6655
- var marker_args = acf.apply_filters('google_map_marker_args', {
6656
-
6657
- draggable: true,
6658
- raiseOnDrag: true,
6659
- map: this.map
6660
-
6661
- }, this.$field);
6662
-
6663
-
6664
- // add marker
6665
- this.map.marker = new google.maps.Marker( marker_args );
6666
-
6667
-
6668
- // add references
6669
- this.map.$el = $el;
6670
- this.map.$field = $field;
6671
-
6672
-
6673
- // value exists?
6674
- var lat = $el.find('.input-lat').val(),
6675
- lng = $el.find('.input-lng').val();
6676
-
6677
- if( lat && lng ) {
6678
-
6679
- this.update(lat, lng).center();
6680
-
6681
- }
6682
-
6683
-
6684
- // events
6685
- google.maps.event.addListener( this.map.marker, 'dragend', function(){
6686
-
6687
- // vars
6688
- var position = this.map.marker.getPosition(),
6689
- lat = position.lat(),
6690
- lng = position.lng();
6691
-
6692
- self.update( lat, lng ).sync();
6693
-
6694
- });
6695
-
6696
-
6697
- google.maps.event.addListener( this.map, 'click', function( e ) {
6698
-
6699
- // vars
6700
- var lat = e.latLng.lat(),
6701
- lng = e.latLng.lng();
6702
-
6703
-
6704
- self.update( lat, lng ).sync();
6705
-
6706
- });
6707
-
6708
-
6709
- // action for 3rd party customization
6710
- acf.do_action('google_map_init', this.map, this.map.marker, this.$field);
6711
-
6712
-
6713
- // add to maps
6714
- this.maps[ this.o.id ] = this.map;
6715
-
6716
  },
6717
 
6718
- search: function( place ){
6719
-
6720
- // reference
6721
- var self = this;
6722
-
6723
-
6724
- // vars
6725
- var address = this.$search.val();
6726
-
6727
-
6728
- // bail ealry if no address
6729
- if( !address ) {
6730
-
6731
- return false;
6732
-
6733
- }
6734
-
6735
-
6736
- // update input
6737
- this.$el.find('.input-address').val( address );
6738
-
6739
-
6740
- // is lat lng?
6741
- var latLng = address.split(',');
6742
-
6743
- if( latLng.length == 2 ) {
6744
-
6745
- var lat = latLng[0],
6746
- lng = latLng[1];
6747
-
6748
-
6749
- if( $.isNumeric(lat) && $.isNumeric(lng) ) {
6750
-
6751
- // parse
6752
- lat = parseFloat(lat);
6753
- lng = parseFloat(lng);
6754
-
6755
- self.update( lat, lng ).center();
6756
-
6757
- return;
6758
-
6759
- }
6760
-
6761
- }
6762
-
6763
-
6764
- // if place exists
6765
- if( place && place.geometry ) {
6766
-
6767
- var lat = place.geometry.location.lat(),
6768
- lng = place.geometry.location.lng();
6769
-
6770
-
6771
- // update
6772
- self.update( lat, lng ).center();
6773
-
6774
-
6775
- // bail early
6776
- return;
6777
-
6778
- }
6779
-
6780
-
6781
- // add class
6782
- this.$el.addClass('-loading');
6783
-
6784
- self.geocoder.geocode({ 'address' : address }, function( results, status ){
6785
-
6786
- // remove class
6787
- self.$el.removeClass('-loading');
6788
-
6789
-
6790
- // validate
6791
- if( status != google.maps.GeocoderStatus.OK ) {
6792
-
6793
- console.log('Geocoder failed due to: ' + status);
6794
- return;
6795
-
6796
- } else if( !results[0] ) {
6797
-
6798
- console.log('No results found');
6799
- return;
6800
-
6801
- }
6802
-
6803
-
6804
- // get place
6805
- place = results[0];
6806
-
6807
- var lat = place.geometry.location.lat(),
6808
- lng = place.geometry.location.lng();
6809
-
6810
-
6811
- self.update( lat, lng ).center();
6812
-
6813
- });
6814
-
6815
  },
6816
 
6817
- update: function( lat, lng ){
6818
-
6819
- // vars
6820
- var latlng = new google.maps.LatLng( lat, lng );
6821
-
6822
-
6823
- // update inputs
6824
- acf.val( this.$el.find('.input-lat'), lat );
6825
- acf.val( this.$el.find('.input-lng'), lng );
6826
-
6827
-
6828
- // update marker
6829
- this.map.marker.setPosition( latlng );
6830
-
6831
-
6832
- // show marker
6833
- this.map.marker.setVisible( true );
6834
-
6835
-
6836
- // update class
6837
- this.$el.addClass('-value');
6838
-
6839
-
6840
- // validation
6841
- this.$field.removeClass('error');
6842
-
6843
-
6844
- // action
6845
- acf.do_action('google_map_change', latlng, this.map, this.$field);
6846
-
6847
-
6848
- // blur input
6849
- this.$search.blur();
6850
-
6851
-
6852
- // return for chaining
6853
- return this;
6854
-
6855
  },
6856
 
6857
- center: function(){
6858
-
6859
- // vars
6860
- var position = this.map.marker.getPosition(),
6861
- lat = this.o.lat,
6862
- lng = this.o.lng;
6863
-
6864
-
6865
- // if marker exists, center on the marker
6866
- if( position ) {
6867
-
6868
- lat = position.lat();
6869
- lng = position.lng();
6870
-
 
 
 
 
6871
  }
6872
-
6873
-
6874
- var latlng = new google.maps.LatLng( lat, lng );
6875
-
6876
-
6877
- // set center of map
6878
- this.map.setCenter( latlng );
6879
-
6880
  },
6881
 
6882
- sync: function(){
6883
-
6884
- // reference
6885
- var self = this;
6886
-
6887
-
6888
- // vars
6889
- var position = this.map.marker.getPosition(),
6890
- latlng = new google.maps.LatLng( position.lat(), position.lng() );
6891
-
6892
-
6893
- // add class
6894
- this.$el.addClass('-loading');
6895
-
6896
-
6897
- // load
6898
- this.geocoder.geocode({ 'latLng' : latlng }, function( results, status ){
6899
-
6900
- // remove class
6901
- self.$el.removeClass('-loading');
6902
-
6903
-
6904
- // validate
6905
- if( status != google.maps.GeocoderStatus.OK ) {
6906
-
6907
- console.log('Geocoder failed due to: ' + status);
6908
- return;
6909
-
6910
- } else if( !results[0] ) {
6911
-
6912
- console.log('No results found');
6913
  return;
6914
-
6915
  }
6916
 
 
 
 
 
6917
 
6918
- // get location
6919
- var location = results[0];
6920
-
6921
-
6922
- // update title
6923
- self.$search.val( location.formatted_address );
6924
-
6925
-
6926
- // update input
6927
- acf.val( self.$el.find('.input-address'), location.formatted_address );
6928
-
6929
  });
6930
-
6931
-
6932
- // return for chaining
6933
- return this;
6934
-
6935
  },
6936
 
6937
- refresh: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6938
 
6939
- // bail early if not ready
6940
- if( !this.is_ready() ) {
6941
-
6942
- return false;
6943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6944
  }
6945
 
 
 
6946
 
6947
- // trigger resize on map
6948
- google.maps.event.trigger(this.map, 'resize');
6949
-
 
6950
 
 
 
6951
 
6952
- // center map
6953
- this.center();
 
 
 
 
6954
 
 
 
6955
  },
6956
-
6957
- show: function(){
6958
-
6959
- // vars
6960
- var self = this,
6961
- $field = this.$field;
6962
-
6963
-
6964
- // center map when it is shown (by a tab / collapsed row)
6965
- // - use delay to avoid rendering issues with browsers (ensures div is visible)
6966
- setTimeout(function(){
6967
 
6968
- self.set('$field', $field).refresh();
6969
-
6970
- }, 10);
6971
-
6972
- },
6973
-
6974
-
6975
- /*
6976
- * events
6977
  *
6978
- * these functions are fired for this fields events
6979
  *
6980
- * @type function
6981
- * @date 17/09/2015
6982
- * @since 5.2.3
6983
  *
6984
- * @param e
 
6985
  * @return n/a
6986
  */
6987
 
6988
- _clear: function( e ){ // console.log('_clear');
6989
-
6990
- // remove Class
6991
- this.$el.removeClass('-value -loading -search');
6992
-
6993
-
6994
- // clear search
6995
- this.$search.val('');
6996
 
6997
-
6998
- // clear inputs
6999
- acf.val( this.$el.find('.input-address'), '' );
7000
- acf.val( this.$el.find('.input-lat'), '' );
7001
- acf.val( this.$el.find('.input-lng'), '' );
7002
 
7003
-
7004
- // hide marker
7005
- this.map.marker.setVisible( false );
7006
-
7007
- },
7008
-
7009
- _locate: function( e ){ // console.log('_locate');
7010
-
7011
- // reference
7012
- var self = this;
7013
-
7014
-
7015
- // Try HTML5 geolocation
7016
- if( !navigator.geolocation ) {
7017
 
7018
- alert( acf._e('google_map', 'browser_support') );
7019
- return this;
 
7020
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7021
  }
7022
 
 
 
7023
 
7024
- // add class
7025
- this.$el.addClass('-loading');
7026
-
7027
-
7028
- // load
7029
- navigator.geolocation.getCurrentPosition(function(position){
7030
-
7031
- // remove class
7032
- self.$el.removeClass('-loading');
7033
-
7034
-
7035
- // vars
7036
- var lat = position.coords.latitude,
7037
- lng = position.coords.longitude;
7038
-
7039
- self.update( lat, lng ).sync().center();
7040
-
7041
- });
7042
 
 
 
7043
  },
7044
 
7045
- _search: function( e ){ // console.log('_search');
7046
-
7047
- this.search();
7048
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7049
  },
7050
 
7051
- _focus: function( e ){ // console.log('_focus');
7052
-
7053
- // remove class
7054
- this.$el.removeClass('-value');
7055
-
7056
-
7057
- // toggle -search class
7058
- this._keyup();
7059
-
 
 
 
 
 
 
 
 
 
7060
  },
7061
 
7062
- _blur: function( e ){ // console.log('_blur');
7063
-
7064
- // reference
7065
- var self = this;
7066
-
7067
-
7068
- // vars
7069
- var val = this.$el.find('.input-address').val();
7070
-
7071
-
7072
- // bail early if no val
7073
- if( !val ) {
7074
-
7075
- return;
7076
-
7077
- }
7078
-
7079
-
7080
- // revert search to hidden input value
7081
- this.timeout = setTimeout(function(){
7082
-
7083
- self.$el.addClass('-value');
7084
- self.$search.val( val );
7085
-
7086
- }, 100);
7087
-
7088
  },
7089
 
7090
- /*
7091
- _paste: function( e ){ console.log('_paste');
7092
-
7093
- // reference
7094
- var $search = this.$search;
7095
-
7096
-
7097
- // blur search
7098
- $search.blur();
7099
-
 
 
 
 
 
 
 
7100
 
7101
- // clear timeout
7102
- this._mousedown(e);
 
 
7103
 
 
 
7104
 
7105
- // focus on input
7106
- setTimeout(function(){
7107
-
7108
- $search.focus();
7109
-
7110
- }, 1);
7111
  },
7112
- */
7113
 
7114
- _keydown: function( e ){ // console.log('_keydown');
7115
-
7116
- // prevent form from submitting
7117
- if( e.which == 13 ) {
7118
-
7119
- e.preventDefault();
7120
-
7121
- }
7122
-
 
 
 
 
 
 
7123
  },
7124
 
7125
- _keyup: function( e ){ // console.log('_keyup');
7126
-
7127
- // vars
7128
- var val = this.$search.val();
7129
-
7130
-
7131
- // toggle class
7132
- if( val ) {
7133
-
7134
- this.$el.addClass('-search');
7135
-
7136
- } else {
7137
-
7138
- this.$el.removeClass('-search');
7139
-
7140
- }
7141
-
 
7142
  },
7143
 
7144
- _mousedown: function( e ){ // console.log('_mousedown');
7145
-
7146
- // reference
7147
- var self = this;
 
 
 
 
 
 
 
 
 
 
7148
 
 
 
7149
 
7150
- // clear timeout in 1ms (_mousedown will run before _blur)
7151
- setTimeout(function(){
7152
-
7153
- clearTimeout( self.timeout );
7154
-
7155
- }, 1);
7156
 
 
 
7157
 
7158
- }
7159
-
7160
- });
7161
-
7162
-
7163
- })(jQuery);
7164
-
7165
- (function($){
7166
-
7167
- acf.fields.image = acf.field.extend({
7168
 
7169
- type: 'image',
7170
- $el: null,
7171
- $input: null,
7172
- $img: null,
 
 
 
 
 
 
 
7173
 
7174
- actions: {
7175
- 'ready': 'initialize',
7176
- 'append': 'initialize'
 
 
 
7177
  },
7178
 
7179
- events: {
7180
- 'click a[data-name="add"]': 'add',
7181
- 'click a[data-name="edit"]': 'edit',
7182
- 'click a[data-name="remove"]': 'remove',
7183
- 'change input[type="file"]': 'change'
 
 
 
 
 
 
 
 
 
 
7184
  },
7185
 
7186
-
7187
- /*
7188
- * focus
7189
  *
7190
- * This function will setup variables when focused on a field
7191
  *
7192
- * @type function
7193
- * @date 12/04/2016
7194
- * @since 5.3.8
7195
  *
7196
- * @param n/a
7197
- * @return n/a
7198
  */
7199
 
7200
- focus: function(){
7201
-
7202
- // vars
7203
- this.$el = this.$field.find('.acf-image-uploader');
7204
- this.$input = this.$el.find('input[type="hidden"]');
7205
- this.$img = this.$el.find('img');
7206
-
7207
-
7208
- // options
7209
- this.o = acf.get_data( this.$el );
7210
-
7211
  },
7212
 
7213
-
7214
- /*
7215
- * initialize
7216
  *
7217
- * This function is used to setup basic upload form attributes
7218
  *
7219
- * @type function
7220
- * @date 12/04/2016
7221
- * @since 5.3.8
7222
  *
7223
- * @param n/a
7224
- * @return n/a
7225
  */
7226
 
7227
- initialize: function(){
7228
-
7229
- // add attribute to form
7230
- if( this.o.uploader == 'basic' ) {
7231
-
7232
- this.$el.closest('form').attr('enctype', 'multipart/form-data');
7233
-
7234
- }
7235
-
7236
  },
7237
 
7238
-
7239
- /*
7240
- * prepare
7241
  *
7242
- * This function will prepare an object of attachment data
7243
- * selecting a library image vs embed an image via url return different data
7244
- * this function will keep the 2 consistent
7245
  *
7246
- * @type function
7247
- * @date 12/04/2016
7248
- * @since 5.3.8
7249
  *
7250
- * @param attachment (object)
7251
- * @return data (object)
7252
  */
7253
 
7254
- prepare: function( attachment ) {
7255
-
7256
- // defaults
7257
- attachment = attachment || {};
7258
-
7259
-
7260
- // bail ealry if already valid
7261
- if( attachment._valid ) return attachment;
7262
-
7263
-
7264
- // vars
7265
- var data = {
7266
- url: '',
7267
- alt: '',
7268
- title: '',
7269
- caption: '',
7270
- description: '',
7271
- width: 0,
7272
- height: 0
7273
- };
7274
-
7275
-
7276
- // wp image
7277
- if( attachment.id ) {
7278
-
7279
- // update data
7280
- data = attachment.attributes;
7281
-
7282
-
7283
- // maybe get preview size
7284
- data.url = acf.maybe_get(data, 'sizes.'+this.o.preview_size+'.url', data.url);
7285
-
7286
- }
7287
-
7288
-
7289
- // valid
7290
- data._valid = true;
7291
-
7292
-
7293
- // return
7294
- return data;
7295
-
7296
  },
7297
 
7298
-
7299
- /*
7300
- * render
7301
  *
7302
- * This function will render the UI
7303
  *
7304
- * @type function
7305
- * @date 12/04/2016
7306
- * @since 5.3.8
7307
  *
7308
- * @param attachment (obj)
7309
- * @return n/a
7310
  */
7311
 
7312
- render: function( data ){
7313
-
7314
- // prepare
7315
- data = this.prepare(data);
7316
-
7317
-
7318
- // update image
7319
- this.$img.attr({
7320
- src: data.url,
7321
- alt: data.alt,
7322
- title: data.title
7323
- });
7324
-
7325
-
7326
- // vars
7327
- var val = '';
7328
-
7329
-
7330
- // WP attachment
7331
- if( data.id ) {
7332
-
7333
- val = data.id;
7334
-
7335
- }
7336
-
7337
-
7338
- // update val
7339
- acf.val( this.$input, val );
7340
-
7341
-
7342
- // update class
7343
- if( val ) {
7344
-
7345
- this.$el.addClass('has-value');
7346
-
7347
- } else {
7348
-
7349
- this.$el.removeClass('has-value');
7350
-
7351
- }
7352
-
7353
  },
7354
 
7355
-
7356
- /*
7357
- * add
7358
  *
7359
- * event listener
7360
  *
7361
- * @type function
7362
- * @date 12/04/2016
7363
- * @since 5.3.8
7364
  *
7365
- * @param e (event)
7366
- * @return n/a
7367
  */
7368
 
7369
- add: function() {
7370
-
7371
- // reference
7372
- var self = this,
7373
- $field = this.$field;
7374
-
7375
-
7376
- // get repeater
7377
- var $repeater = acf.get_closest_field( this.$field, 'repeater' );
7378
-
7379
-
7380
- // popup
7381
- var frame = acf.media.popup({
7382
-
7383
- title: acf._e('image', 'select'),
7384
- mode: 'select',
7385
- type: 'image',
7386
- field: $field.data('key'),
7387
- multiple: $repeater.exists(),
7388
- library: this.o.library,
7389
- mime_types: this.o.mime_types,
7390
-
7391
- select: function( attachment, i ) {
7392
-
7393
- // select / add another image field?
7394
- if( i > 0 ) {
7395
-
7396
- // vars
7397
- var key = $field.data('key'),
7398
- $tr = $field.closest('.acf-row');
7399
-
7400
-
7401
- // reset field
7402
- $field = false;
7403
-
7404
-
7405
- // find next image field
7406
- $tr.nextAll('.acf-row:visible').each(function(){
7407
-
7408
- // get next $field
7409
- $field = acf.get_field( key, $(this) );
7410
-
7411
-
7412
- // bail early if $next was not found
7413
- if( !$field ) return;
7414
-
7415
-
7416
- // bail early if next file uploader has value
7417
- if( $field.find('.acf-image-uploader.has-value').exists() ) {
7418
-
7419
- $field = false;
7420
- return;
7421
-
7422
- }
7423
-
7424
-
7425
- // end loop if $next is found
7426
- return false;
7427
-
7428
- });
7429
-
7430
-
7431
- // add extra row if next is not found
7432
- if( !$field ) {
7433
-
7434
- $tr = acf.fields.repeater.doFocus( $repeater ).add();
7435
-
7436
-
7437
- // bail early if no $tr (maximum rows hit)
7438
- if( !$tr ) return false;
7439
-
7440
-
7441
- // get next $field
7442
- $field = acf.get_field( key, $tr );
7443
-
7444
- }
7445
-
7446
- }
7447
-
7448
-
7449
- // render
7450
- self.set('$field', $field).render( attachment );
7451
-
7452
- }
7453
-
7454
- });
7455
-
7456
  },
7457
 
7458
-
7459
- /*
7460
- * edit
7461
  *
7462
- * event listener
7463
  *
7464
- * @type function
7465
- * @date 12/04/2016
7466
- * @since 5.3.8
7467
  *
7468
- * @param e (event)
7469
- * @return n/a
7470
  */
7471
 
7472
- edit: function() {
7473
-
7474
- // reference
7475
- var self = this,
7476
- $field = this.$field;
7477
-
7478
-
7479
- // vars
7480
- var val = this.$input.val();
7481
-
7482
-
7483
- // bail early if no val
7484
- if( !val ) return;
7485
-
7486
-
7487
- // popup
7488
- var frame = acf.media.popup({
7489
-
7490
- title: acf._e('image', 'edit'),
7491
- button: acf._e('image', 'update'),
7492
- mode: 'edit',
7493
- attachment: val,
7494
-
7495
- select: function( attachment, i ) {
7496
-
7497
- // render
7498
- self.set('$field', $field).render( attachment );
7499
-
7500
- }
7501
-
7502
- });
7503
-
7504
  },
7505
 
7506
 
7507
- /*
7508
- * remove
7509
  *
7510
- * event listener
7511
  *
7512
- * @type function
7513
- * @date 12/04/2016
7514
- * @since 5.3.8
7515
  *
7516
- * @param e (event)
7517
- * @return n/a
7518
  */
7519
 
7520
- remove: function() {
7521
-
7522
- // vars
7523
- var attachment = {};
7524
-
7525
-
7526
- // add file to field
7527
- this.render( attachment );
7528
-
7529
  },
7530
 
7531
-
7532
- /*
7533
- * change
7534
  *
7535
- * This function will update the hidden input when selecting a basic file to add basic validation
7536
  *
7537
- * @type function
7538
- * @date 12/04/2016
7539
- * @since 5.3.8
7540
  *
7541
- * @param e (event)
7542
- * @return n/a
7543
  */
7544
 
7545
- change: function( e ){
7546
-
7547
- acf.fields.file.get_file_info( e.$el, this.$input );
7548
-
7549
  }
7550
 
 
7551
  });
7552
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7553
  })(jQuery);
7554
 
7555
- (function($){
7556
 
7557
- acf.fields.link = acf.field.extend({
7558
-
7559
- type: 'link',
7560
- active: false,
7561
- $el: null,
7562
- $node: null,
 
 
 
7563
 
7564
  events: {
7565
- 'click a[data-name="add"]': 'add',
7566
- 'click a[data-name="edit"]': 'edit',
7567
- 'click a[data-name="remove"]': 'remove',
7568
- 'change .link-node': 'change',
 
 
 
7569
  },
7570
 
 
 
 
 
7571
 
7572
- /*
7573
- * focus
7574
- *
7575
- * This function will setup variables when focused on a field
7576
- *
7577
- * @type function
7578
- * @date 12/04/2016
7579
- * @since 5.3.8
7580
- *
7581
- * @param n/a
7582
- * @return n/a
7583
- */
7584
 
7585
- focus: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7586
 
7587
- // get elements
7588
- this.$el = this.$field.find('.acf-link');
7589
- this.$node = this.$el.find('.link-node');
7590
 
 
 
 
 
 
 
 
 
7591
  },
7592
 
7593
- add: function( e ){
7594
-
7595
- acf.link.open( this.$node );
7596
-
7597
  },
7598
 
7599
- edit: function( e ){
7600
-
7601
- this.add();
7602
-
7603
  },
7604
 
7605
- remove: function( e ){
7606
-
7607
- this.val('');
7608
-
 
 
 
7609
  },
7610
 
7611
- change: function( e, value ){
7612
-
7613
- // vars
7614
- var val = {
7615
- 'title': this.$node.html(),
7616
- 'url': this.$node.attr('href'),
7617
- 'target': this.$node.attr('target')
7618
- };
7619
-
7620
-
7621
- // vars
7622
- this.val( val );
7623
-
7624
  },
7625
 
7626
- val: function( val ){
7627
-
7628
- // default
7629
- val = acf.parse_args(val, {
7630
- 'title': '',
7631
- 'url': '',
7632
- 'target': ''
7633
- });
7634
-
7635
-
7636
- // remove class
7637
- this.$el.removeClass('-value -external');
7638
-
7639
-
7640
- // add class
7641
- if( val.url ) this.$el.addClass('-value');
7642
- if( val.target === '_blank' ) this.$el.addClass('-external');
7643
-
7644
-
7645
- // update text
7646
- this.$el.find('.link-title').html( val.title );
7647
- this.$el.find('.link-url').attr('href', val.url).html( val.url );
7648
-
7649
-
7650
- // update inputs
7651
- this.$el.find('.input-title').val( val.title );
7652
- this.$el.find('.input-target').val( val.target );
7653
- this.$el.find('.input-url').val( val.url ).trigger('change');
7654
-
7655
-
7656
- // update node
7657
- this.$node.html(val.title);
7658
- this.$node.attr('href', val.url);
7659
- this.$node.attr('target', val.target);
7660
  }
7661
 
7662
  });
7663
 
7664
-
7665
- /*
7666
- * acf.link
7667
  *
7668
- * This model will handle adding tabs and groups
7669
  *
7670
- * @type function
7671
- * @date 25/11/2015
7672
- * @since 5.3.2
7673
  *
7674
- * @param $post_id (int)
7675
- * @return $post_id (int)
7676
  */
7677
 
7678
- acf.link = acf.model.extend({
 
 
 
 
 
 
 
 
7679
 
7680
- active: false,
7681
- $textarea: null,
7682
- $node: null,
 
 
 
 
 
7683
 
7684
  events: {
7685
- 'click #wp-link-submit': '_update',
7686
- //'river-select .query-results': '_select',
7687
- 'wplink-open': '_open',
7688
- 'wplink-close': '_close',
7689
  },
7690
 
7691
- atts: function( value ){
7692
-
7693
- // update
7694
- if( typeof value !== 'undefined' ) {
7695
-
7696
- this.$node.html( value.title );
7697
- this.$node.attr('href', value.url);
7698
- this.$node.attr('target', value.target);
7699
- this.$node.trigger('change', [value]);
7700
- return true;
7701
-
7702
- }
7703
-
7704
-
7705
- // get
7706
- return {
7707
- 'title': this.$node.html(),
7708
- 'url': this.$node.attr('href'),
7709
- 'target': this.$node.attr('target')
7710
- };
7711
-
7712
  },
7713
 
7714
- inputs: function( value ){
7715
 
7716
- // update
7717
- if( typeof value !== 'undefined' ) {
7718
-
7719
- $('#wp-link-text').val( value.title );
7720
- $('#wp-link-url').val( value.url );
7721
- $('#wp-link-target').prop('checked', value.target === '_blank' );
7722
- return true;
7723
-
7724
  }
7725
 
 
 
7726
 
7727
- // get
7728
- return {
7729
- 'title': $('#wp-link-text').val(),
7730
- 'url': $('#wp-link-url').val(),
7731
- 'target': $('#wp-link-target').prop('checked') ? '_blank' : ''
7732
- };
7733
 
7734
  },
7735
 
7736
- open: function( $node ){
7737
-
7738
- // create textarea
7739
- var $textarea = $('<textarea id="acf-link-textarea"></textarea>');
7740
-
7741
-
7742
- // append textarea
7743
- $node.before( $textarea );
7744
-
7745
-
7746
- // update vars
7747
- this.active = true;
7748
- this.$node = $node;
7749
- this.$textarea = $textarea;
7750
-
7751
-
7752
- // get atts
7753
- var atts = this.atts();
7754
-
7755
-
7756
- // open link
7757
- wpLink.open( 'acf-link-textarea', atts.url, atts.title, null );
7758
 
 
 
7759
 
7760
- // always show title (WP will hide title if empty)
7761
- $('#wp-link-wrap').addClass('has-text-field');
7762
 
7763
  },
7764
 
7765
- reset: function(){
7766
-
7767
- this.active = false;
7768
- this.$textarea.remove();
7769
- this.$textarea = null;
7770
- this.$node = null;
7771
-
 
 
 
 
 
 
 
7772
  },
7773
 
7774
- _select: function( e, $li ){
7775
-
7776
- // get inputs
7777
- var val = this.inputs();
7778
-
7779
-
7780
- // update title
7781
- if( !val.title ) {
7782
-
7783
- val.title = $li.find('.item-title').text();
7784
- this.inputs( val );
7785
-
7786
- console.log(val);
7787
- }
7788
-
7789
  },
7790
 
7791
- _open: function( e ){
7792
-
7793
- // bail early if not active
7794
- if( !this.active ) return;
7795
-
7796
-
7797
- // get atts
7798
- var val = this.atts();
7799
-
7800
-
7801
- // update WP inputs
7802
- this.inputs( val );
7803
-
7804
  },
7805
 
7806
- _close: function( e ){
7807
-
7808
- // bail early if not active
7809
- if( !this.active ) return;
7810
-
7811
-
7812
- // reset vars
7813
- // use timeout to allow _update() function to check vars
7814
- setTimeout(function(){
7815
-
7816
- acf.link.reset();
7817
-
7818
- }, 100);
7819
-
7820
  },
7821
 
7822
- _update: function( e ){
7823
-
7824
- // bail early if not active
7825
- if( !this.active ) return;
7826
-
7827
-
7828
- // get atts
7829
- var val = this.inputs();
7830
-
7831
-
7832
- // update node
7833
- this.atts( val );
7834
-
7835
  }
7836
-
7837
  });
7838
-
7839
-
7840
- // todo - listen to AJAX for wp-link-ajax and append post_id to value
7841
-
7842
-
7843
  })(jQuery);
7844
 
7845
- (function($){
7846
 
7847
- acf.media = acf.model.extend({
7848
-
7849
- frames: [],
7850
- mime_types: {},
7851
 
7852
- actions: {
7853
- 'ready': 'ready'
 
 
 
 
 
7854
  },
7855
 
7856
-
7857
- /*
7858
- * frame
7859
- *
7860
- * This function will return the current frame
7861
- *
7862
- * @type function
7863
- * @date 11/04/2016
7864
- * @since 5.3.2
7865
- *
7866
- * @param n/a
7867
- * @return frame (object)
7868
- */
7869
-
7870
- frame: function(){
7871
-
7872
- // vars
7873
- var i = this.frames.length - 1;
7874
-
7875
-
7876
- // bail early if no index
7877
- if( i < 0 ) return false;
7878
-
7879
-
7880
- // return
7881
- return this.frames[ i ];
7882
-
7883
  },
7884
 
 
 
 
7885
 
7886
- /*
7887
- * destroy
7888
- *
7889
- * this function will destroy a frame
7890
- *
7891
- * @type function
7892
- * @date 11/04/2016
7893
- * @since 5.3.8
7894
- *
7895
- * @return frame (object)
7896
- * @return n/a
7897
- */
7898
 
7899
- destroy: function( frame ) {
7900
-
7901
- // detach
7902
- frame.detach();
7903
- frame.dispose();
7904
-
7905
 
7906
- // remove frame
7907
- frame = null;
7908
- this.frames.pop();
7909
 
 
 
7910
  },
7911
 
7912
-
7913
- /*
7914
- * popup
7915
- *
7916
- * This function will create a wp media popup frame
7917
- *
7918
- * @type function
7919
- * @date 11/04/2016
7920
- * @since 5.3.8
7921
- *
7922
- * @param args (object)
7923
- * @return frame (object)
7924
- */
7925
-
7926
- popup: function( args ) {
7927
-
7928
- // vars
7929
- var post_id = acf.get('post_id'),
7930
- frame = false;
7931
-
7932
-
7933
- // validate post_id
7934
- if( !$.isNumeric(post_id) ) post_id = 0;
7935
-
7936
-
7937
- // settings
7938
- var settings = acf.parse_args( args, {
7939
- mode: 'select', // 'select', 'edit'
7940
- title: '', // 'Upload Image'
7941
- button: '', // 'Select Image'
7942
- type: '', // 'image', ''
7943
- field: '', // 'field_123'
7944
- mime_types: '', // 'pdf, etc'
7945
- library: 'all', // 'all', 'uploadedTo'
7946
- multiple: false, // false, true, 'add'
7947
- attachment: 0, // the attachment to edit
7948
- post_id: post_id, // the post being edited
7949
- select: function(){}
7950
- });
7951
-
7952
-
7953
- // id changed to attributes
7954
- if( settings.id ) settings.attachment = settings.id;
7955
-
7956
-
7957
- // create frame
7958
- var frame = this.new_media_frame( settings );
7959
-
7960
-
7961
- // append
7962
- this.frames.push( frame );
7963
 
 
 
7964
 
7965
- // open popup (allow frame customization before opening)
7966
- setTimeout(function(){
7967
-
7968
- frame.open();
7969
-
7970
- }, 1);
7971
 
 
 
 
 
 
7972
 
7973
- // return
7974
- return frame;
7975
-
 
 
7976
  },
7977
 
7978
-
7979
- /*
7980
- * _get_media_frame_settings
7981
- *
7982
- * This function will return an object containing frame settings
7983
- *
7984
- * @type function
7985
- * @date 11/04/2016
7986
- * @since 5.3.8
7987
- *
7988
- * @param frame (object)
7989
- * @param settings (object)
7990
- * @return frame (object)
7991
- */
7992
-
7993
- _get_media_frame_settings: function( frame, settings ){
7994
-
7995
- // select
7996
- if( settings.mode === 'select' ) {
7997
-
7998
- frame = this._get_select_frame_settings( frame, settings );
7999
-
8000
- // edit
8001
- } else if( settings.mode === 'edit' ) {
8002
-
8003
- frame = this._get_edit_frame_settings( frame, settings );
8004
-
8005
- }
8006
 
 
 
8007
 
8008
- // return
8009
- return frame;
8010
-
8011
  },
8012
 
8013
- _get_select_frame_settings: function( frame, settings ){
8014
-
8015
- // type
8016
- if( settings.type ) {
8017
-
8018
- frame.library.type = settings.type;
8019
-
8020
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
8021
 
8022
-
8023
- // library
8024
- if( settings.library === 'uploadedTo' ) {
8025
-
8026
- frame.library.uploadedTo = settings.post_id;
8027
-
8028
  }
8029
 
 
 
8030
 
8031
- // button
8032
- frame._button = acf._e('media', 'select');
8033
-
8034
-
8035
- // return
8036
- return frame;
8037
-
8038
  },
8039
 
8040
- _get_edit_frame_settings: function( frame, settings ){
8041
-
8042
- // post__in
8043
- frame.library.post__in = [ settings.attachment ];
8044
-
8045
-
8046
- // button
8047
- frame._button = acf._e('media', 'update');
8048
-
8049
-
8050
- // return
8051
- return frame;
8052
-
8053
  },
8054
 
 
 
 
8055
 
8056
- /*
8057
- * _add_media_frame_events
8058
- *
8059
- * This function will add events to the frame object
8060
- *
8061
- * @type function
8062
- * @date 11/04/2016
8063
- * @since 5.3.8
8064
- *
8065
- * @param $post_id (int)
8066
- * @return $post_id (int)
8067
- */
8068
 
8069
- _add_media_frame_events: function( frame, settings ){
8070
-
8071
- // log events
8072
- /*
8073
- frame.on('all', function( e ) {
8074
-
8075
- console.log( 'frame all: %o', e );
8076
-
8077
- });
8078
- */
8079
-
 
 
8080
 
8081
- // add class
8082
- frame.on('open',function() {
8083
-
8084
- // add class
8085
- this.$el.closest('.media-modal').addClass('acf-media-modal -' +settings.mode );
8086
-
8087
- }, frame);
8088
 
8089
-
8090
- // edit image view
8091
- // source: media-views.js:2410 editImageContent()
8092
- frame.on('content:render:edit-image', function(){
8093
-
8094
- var image = this.state().get('image'),
8095
- view = new wp.media.view.EditImage( { model: image, controller: this } ).render();
8096
 
8097
- this.content.set( view );
8098
 
8099
- // after creating the wrapper view, load the actual editor via an ajax call
8100
- view.loadEditor();
8101
-
8102
- }, frame);
8103
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8104
 
8105
- // update toolbar button
8106
- frame.on( 'toolbar:create:select', function( toolbar ) {
8107
-
8108
- toolbar.view = new wp.media.view.Toolbar.Select({
8109
- text: frame.options._button,
8110
- controller: this
8111
- });
8112
-
8113
- }, frame );
8114
 
 
 
 
8115
 
8116
- // select image
8117
- frame.on('select', function() {
8118
-
8119
- // get selected images
8120
- var state = frame.state(),
8121
- image = state.get('image'),
8122
- selection = state.get('selection');
8123
-
8124
-
8125
- // if editing image
8126
- if( image ) {
8127
-
8128
- settings.select.apply( frame, [image, 0] );
8129
-
8130
- return;
8131
-
8132
- }
8133
-
8134
-
8135
- // if selecting images
8136
- if( selection ) {
8137
-
8138
- // vars
8139
- var i = 0;
8140
-
8141
-
8142
- // loop
8143
- selection.each(function( attachment ){
8144
-
8145
- settings.select.apply( frame, [attachment, i] );
8146
-
8147
- i++;
8148
-
8149
- });
8150
-
8151
- return;
8152
-
8153
- }
8154
-
8155
- });
8156
 
 
 
 
 
 
8157
 
8158
- // close popup
8159
- frame.on('close',function(){
8160
 
8161
- setTimeout(function(){
8162
-
8163
- acf.media.destroy( frame );
8164
-
8165
- }, 500);
8166
 
8167
- });
8168
-
8169
-
8170
- // select
8171
- if( settings.mode === 'select' ) {
8172
-
8173
- frame = this._add_select_frame_events( frame, settings );
8174
 
8175
- // edit
8176
- } else if( settings.mode === 'edit' ) {
8177
-
8178
- frame = this._add_edit_frame_events( frame, settings );
8179
 
 
8180
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8181
 
 
 
 
8182
 
8183
- // return
8184
- return frame;
8185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8186
  },
8187
 
8188
- _add_select_frame_events: function( frame, settings ){
8189
-
8190
- // reference
8191
- var self = this;
 
 
 
 
 
 
8192
 
 
 
8193
 
8194
- // plupload
8195
- // adds _acfuploader param to validate uploads
8196
- if( acf.isset(_wpPluploadSettings, 'defaults', 'multipart_params') ) {
8197
-
8198
- // add _acfuploader so that Uploader will inherit
8199
- _wpPluploadSettings.defaults.multipart_params._acfuploader = settings.field;
8200
-
8201
-
8202
- // remove acf_field so future Uploaders won't inherit
8203
- frame.on('open', function(){
8204
-
8205
- delete _wpPluploadSettings.defaults.multipart_params._acfuploader;
8206
-
8207
- });
8208
-
8209
- }
8210
 
 
 
8211
 
8212
- // modify DOM
8213
- frame.on('content:activate:browse', function(){
8214
-
8215
- // populate above vars making sure to allow for failure
8216
- try {
8217
-
8218
- var toolbar = frame.content.get().toolbar,
8219
- filters = toolbar.get('filters'),
8220
- search = toolbar.get('search');
8221
-
8222
- } catch(e) {
8223
-
8224
- // one of the objects was 'undefined'... perhaps the frame open is Upload Files
8225
- // console.log( 'error %o', e );
8226
- return;
8227
-
8228
- }
8229
-
8230
-
8231
- // image
8232
- if( settings.type == 'image' ) {
8233
-
8234
- // update all
8235
- filters.filters.all.text = acf._e('image', 'all');
8236
-
8237
-
8238
- // remove some filters
8239
- delete filters.filters.audio;
8240
- delete filters.filters.video;
8241
-
8242
-
8243
- // update all filters to show images
8244
- $.each( filters.filters, function( k, filter ){
8245
-
8246
- if( filter.props.type === null ) {
8247
-
8248
- filter.props.type = 'image';
8249
-
8250
- }
8251
-
8252
- });
8253
-
8254
- }
8255
-
8256
-
8257
- // custom mime types
8258
- if( settings.mime_types ) {
8259
-
8260
- // explode
8261
- var extra_types = settings.mime_types.split(' ').join('').split('.').join('').split(',');
8262
-
8263
-
8264
- // loop through mime_types
8265
- $.each( extra_types, function( i, type ){
8266
-
8267
- // find mime
8268
- $.each( self.mime_types, function( t, mime ){
8269
-
8270
- // continue if key does not match
8271
- if( t.indexOf(type) === -1 ) {
8272
-
8273
- return;
8274
-
8275
- }
8276
-
8277
-
8278
- // create new filter
8279
- var filter = {
8280
- text: type,
8281
- props: {
8282
- status: null,
8283
- type: mime,
8284
- uploadedTo: null,
8285
- orderby: 'date',
8286
- order: 'DESC'
8287
- },
8288
- priority: 20
8289
- };
8290
-
8291
-
8292
- // append filter
8293
- filters.filters[ mime ] = filter;
8294
-
8295
- });
8296
-
8297
- });
8298
-
8299
- }
8300
-
8301
-
8302
- // uploaded to post
8303
- if( settings.library == 'uploadedTo' ) {
8304
-
8305
- // remove some filters
8306
- delete filters.filters.unattached;
8307
- delete filters.filters.uploaded;
8308
-
8309
-
8310
- // add 'uploadedTo' text
8311
- filters.$el.parent().append('<span class="acf-uploadedTo">' + acf._e('image', 'uploadedTo') + '</span>');
8312
-
8313
-
8314
- // add uploadedTo to filters
8315
- $.each( filters.filters, function( k, filter ){
8316
-
8317
- filter.props.uploadedTo = settings.post_id;
8318
-
8319
- });
8320
-
8321
- }
8322
-
8323
-
8324
- // add _acfuploader to filters
8325
- $.each( filters.filters, function( k, filter ){
8326
-
8327
- filter.props._acfuploader = settings.field;
8328
-
8329
- });
8330
-
8331
 
8332
- // add _acfuplaoder to search
8333
- search.model.attributes._acfuploader = settings.field;
 
 
 
 
8334
 
 
 
 
 
 
 
8335
 
8336
- // render
8337
- if( typeof filters.refresh === 'function' ) {
8338
-
8339
- filters.refresh();
8340
 
8341
- }
8342
 
8343
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8344
 
 
 
8345
 
8346
- // return
8347
- return frame;
 
 
 
 
 
 
 
8348
 
 
 
 
 
 
8349
  },
8350
 
8351
- _add_edit_frame_events: function( frame, settings ){
8352
 
8353
- // add class
8354
- frame.on('open',function() {
8355
-
8356
- // add class
8357
- this.$el.closest('.media-modal').addClass('acf-expanded');
8358
-
8359
-
8360
- // set to browse
8361
- if( this.content.mode() != 'browse' ) {
8362
-
8363
- this.content.mode('browse');
8364
-
8365
- }
8366
-
8367
-
8368
- // set selection
8369
- var state = this.state(),
8370
- selection = state.get('selection'),
8371
- attachment = wp.media.attachment( settings.attachment );
8372
-
8373
-
8374
- selection.add( attachment );
8375
-
8376
- }, frame);
8377
-
8378
 
8379
- // return
8380
- return frame;
 
8381
 
 
 
 
8382
  },
8383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8384
 
8385
- /*
8386
- * new_media_frame
8387
- *
8388
- * this function will create a new media frame
8389
- *
8390
- * @type function
8391
- * @date 11/04/2016
8392
- * @since 5.3.8
8393
- *
8394
- * @param settings (object)
8395
- * @return frame (object)
8396
- */
 
 
8397
 
8398
- new_media_frame: function( settings ){
8399
 
8400
- // vars
8401
- var attributes = {
8402
- title: settings.title,
8403
- multiple: settings.multiple,
8404
- library: {},
8405
- states: []
8406
- };
8407
 
 
 
 
 
8408
 
8409
- // get options
8410
- attributes = this._get_media_frame_settings( attributes, settings );
8411
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8412
 
8413
- // create query
8414
- var Query = wp.media.query( attributes.library );
 
 
 
 
 
 
 
8415
 
 
 
8416
 
8417
- // add _acfuploader
8418
- // this is super wack!
8419
- // if you add _acfuploader to the options.library args, new uploads will not be added to the library view.
8420
- // this has been traced back to the wp.media.model.Query initialize function (which can't be overriden)
8421
- // Adding any custom args will cause the Attahcments to not observe the uploader queue
8422
- // To bypass this security issue, we add in the args AFTER the Query has been initialized
8423
- // options.library._acfuploader = settings.field;
8424
- if( acf.isset(Query, 'mirroring', 'args') ) {
8425
-
8426
- Query.mirroring.args._acfuploader = settings.field;
8427
-
8428
  }
8429
 
 
 
8430
 
8431
- // add states
8432
- attributes.states = [
8433
-
8434
- // main state
8435
- new wp.media.controller.Library({
8436
- library: Query,
8437
- multiple: attributes.multiple,
8438
- title: attributes.title,
8439
- priority: 20,
8440
- filterable: 'all',
8441
- editable: true,
8442
-
8443
- // If the user isn't allowed to edit fields,
8444
- // can they still edit it locally?
8445
- allowLocalEdits: true
8446
- })
8447
-
8448
- ];
8449
-
8450
 
8451
- // edit image functionality (added in WP 3.9)
8452
- if( acf.isset(wp, 'media', 'controller', 'EditImage') ) {
8453
-
8454
- attributes.states.push( new wp.media.controller.EditImage() );
8455
-
 
8456
  }
8457
 
 
 
 
8458
 
8459
- // create frame
8460
- var frame = wp.media( attributes );
8461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8462
 
8463
- // add args reference
8464
- frame.acf = settings;
8465
 
 
 
8466
 
8467
- // add events
8468
- frame = this._add_media_frame_events( frame, settings );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8469
 
 
 
8470
 
8471
  // return
8472
- return frame;
8473
-
8474
  },
8475
 
8476
- ready: function(){
 
 
 
 
 
 
 
 
 
 
 
 
8477
 
8478
  // vars
8479
- var version = acf.get('wp_version'),
8480
- browser = acf.get('browser'),
8481
- post_id = acf.get('post_id');
8482
-
8483
-
8484
- // update wp.media
8485
- if( acf.isset(window,'wp','media','view','settings','post') && $.isNumeric(post_id) ) {
8486
-
8487
- wp.media.view.settings.post.id = post_id;
8488
-
8489
- }
8490
 
 
 
8491
 
8492
- // append browser
8493
- if( browser ) {
8494
-
8495
- $('body').addClass('browser-' + browser );
8496
-
8497
- }
8498
 
 
 
8499
 
8500
- // append version
8501
- if( version ) {
8502
-
8503
- // ensure is string
8504
- version = version + '';
8505
-
8506
-
8507
- // use only major version
8508
- major = version.substr(0,1);
8509
-
8510
-
8511
- // add body class
8512
- $('body').addClass('major-' + major);
8513
-
8514
  }
8515
 
 
 
 
 
 
8516
 
8517
- // customize wp.media views
8518
- if( acf.isset(window, 'wp', 'media', 'view') ) {
8519
-
8520
- //this.customize_Attachments();
8521
- //this.customize_Query();
8522
- //this.add_AcfEmbed();
8523
- this.customize_Attachment();
8524
- this.customize_AttachmentFiltersAll();
8525
- this.customize_AttachmentCompat();
8526
 
 
 
 
 
8527
  }
8528
 
 
 
8529
  },
8530
 
8531
-
8532
- /*
8533
- add_AcfEmbed: function(){
8534
-
8535
- //test urls
8536
- //(image) jpg: http://www.ml24.net/img/ml24_design_process_scion_frs_3d_rendering.jpg
8537
- //(image) svg: http://kompozer.net/images/svg/Mozilla_Firefox.svg
8538
- //(file) pdf: http://martinfowler.com/ieeeSoftware/whenType.pdf
8539
- //(video) mp4: https://videos.files.wordpress.com/kUJmAcSf/bbb_sunflower_1080p_30fps_normal_hd.mp4
8540
-
8541
 
 
 
8542
 
8543
- // add view
8544
- wp.media.view.AcfEmbed = wp.media.view.Embed.extend({
8545
-
8546
- initialize: function() {
8547
-
8548
- // set attachments
8549
- this.model.props.attributes = this.controller.acf.attachment || {};
8550
-
8551
-
8552
- // refresh
8553
- wp.media.view.Embed.prototype.initialize.apply( this, arguments );
8554
-
8555
- },
8556
-
8557
- refresh: function() {
8558
-
8559
- // vars
8560
- var attachment = acf.parse_args(this.model.props.attributes, {
8561
- url: '',
8562
- filename: '',
8563
- title: '',
8564
- caption: '',
8565
- alt: '',
8566
- description: '',
8567
- type: '',
8568
- ext: ''
8569
- });
8570
-
8571
-
8572
- // update attachment
8573
- if( attachment.url ) {
8574
-
8575
- // filename
8576
- attachment.filename = attachment.url.split('/').pop().split('?')[0];
8577
-
8578
-
8579
- // update
8580
- attachment.ext = attachment.filename.split('.').pop();
8581
- attachment.type = /(jpe?g|png|gif|svg)/i.test(attachment.ext) ? 'image': 'file';
8582
-
8583
- }
8584
-
8585
-
8586
- // auto generate title
8587
- if( attachment.filename && !attachment.title ) {
8588
-
8589
- // replace
8590
- attachment.title = attachment.filename.split('-').join(' ').split('_').join(' ');
8591
-
8592
-
8593
- // uppercase first word
8594
- attachment.title = attachment.title.charAt(0).toUpperCase() + attachment.title.slice(1);
8595
-
8596
-
8597
- // remove extension
8598
- attachment.title = attachment.title.replace('.'+attachment.ext, '');
8599
-
8600
-
8601
- // update model
8602
- this.model.props.attributes.title = attachment.title;
8603
-
8604
- }
8605
-
8606
-
8607
- // save somee extra data
8608
- this.model.props.attributes.filename = attachment.filename;
8609
- this.model.props.attributes.type = attachment.type;
8610
-
8611
-
8612
- // always show image view
8613
- // avoid this.model.set() to prevent listeners updating view
8614
- this.model.attributes.type = 'image';
8615
-
8616
-
8617
- // refresh
8618
- wp.media.view.Embed.prototype.refresh.apply( this, arguments );
8619
-
8620
-
8621
- // append title
8622
- this.$el.find('.setting.caption').before([
8623
- '<label class="setting title">',
8624
- '<span>Title</span>',
8625
- '<input type="text" data-setting="title" value="' + attachment.title + '">',
8626
- '</label>'
8627
- ].join(''));
8628
-
8629
-
8630
- // append description
8631
- this.$el.find('.setting.alt-text').after([
8632
- '<label class="setting description">',
8633
- '<span>Description</span>',
8634
- '<textarea type="text" data-setting="description">' + attachment.description + '</textarea>',
8635
- '</label>'
8636
- ].join(''));
8637
-
8638
-
8639
- // hide alt
8640
- if( attachment.type !== 'image' ) {
8641
-
8642
- this.$el.find('.setting.alt-text').hide();
8643
-
8644
- }
8645
-
8646
- }
8647
-
8648
- });
8649
 
 
 
8650
  },
8651
- */
8652
- /*
8653
 
8654
- customize_Attachments: function(){
8655
-
8656
- // vars
8657
- var Attachments = wp.media.model.Attachments;
8658
 
 
 
8659
 
8660
- wp.media.model.Attachments = Attachments.extend({
8661
-
8662
- initialize: function( models, options ){
8663
-
8664
- // console.log('My Attachments initialize: %o %o %o', this, models, options);
8665
-
8666
- // return
8667
- return Attachments.prototype.initialize.apply( this, arguments );
8668
-
8669
- },
8670
-
8671
- sync: function( method, model, options ) {
8672
-
8673
- // console.log('My Attachments sync: %o %o %o %o', this, method, model, options);
8674
-
8675
-
8676
- // return
8677
- return Attachments.prototype.sync.apply( this, arguments );
8678
-
8679
- }
8680
-
8681
- });
8682
 
 
 
8683
  },
8684
 
8685
- customize_Query: function(){
8686
-
8687
- // console.log('customize Query!');
8688
 
8689
- // vars
8690
- var Query = wp.media.model.Query;
8691
 
 
 
 
 
 
8692
 
8693
- wp.media.model.Query = {};
 
8694
 
 
 
8695
  },
8696
- */
8697
 
8698
- customize_Attachment: function(){
8699
 
8700
- // vars
8701
- var AttachmentLibrary = wp.media.view.Attachment.Library;
 
 
8702
 
 
 
 
 
8703
 
8704
- // extend
8705
- wp.media.view.Attachment.Library = AttachmentLibrary.extend({
8706
-
8707
- render: function() {
8708
-
8709
- // vars
8710
- var frame = acf.media.frame(),
8711
- errors = acf.maybe_get(this, 'model.attributes.acf_errors');
8712
-
8713
-
8714
- // add class
8715
- // also make sure frame exists to prevent this logic running on a WP popup (such as feature image)
8716
- if( frame && errors ) {
8717
-
8718
- this.$el.addClass('acf-disabled');
8719
-
8720
- }
8721
-
8722
-
8723
- // return
8724
- return AttachmentLibrary.prototype.render.apply( this, arguments );
8725
-
8726
- },
8727
-
8728
-
8729
- /*
8730
- * toggleSelection
8731
- *
8732
- * This function is called before an attachment is selected
8733
- * A good place to check for errors and prevent the 'select' function from being fired
8734
- *
8735
- * @type function
8736
- * @date 29/09/2016
8737
- * @since 5.4.0
8738
- *
8739
- * @param options (object)
8740
- * @return n/a
8741
- */
8742
-
8743
- toggleSelection: function( options ) {
8744
-
8745
- // vars
8746
- // source: wp-includes/js/media-views.js:2880
8747
- var collection = this.collection,
8748
- selection = this.options.selection,
8749
- model = this.model,
8750
- single = selection.single();
8751
-
8752
-
8753
- // vars
8754
- var frame = acf.media.frame(),
8755
- errors = acf.maybe_get(this, 'model.attributes.acf_errors'),
8756
- $sidebar = this.controller.$el.find('.media-frame-content .media-sidebar');
8757
-
8758
-
8759
- // remove previous error
8760
- $sidebar.children('.acf-selection-error').remove();
8761
-
8762
-
8763
- // show attachment details
8764
- $sidebar.children().removeClass('acf-hidden');
8765
-
8766
-
8767
- // add message
8768
- if( frame && errors ) {
8769
-
8770
- // vars
8771
- var filename = acf.maybe_get(this, 'model.attributes.filename', '');
8772
-
8773
-
8774
- // hide attachment details
8775
- // Gallery field continues to show previously selected attachment...
8776
- $sidebar.children().addClass('acf-hidden');
8777
-
8778
-
8779
- // append message
8780
- $sidebar.prepend([
8781
- '<div class="acf-selection-error">',
8782
- '<span class="selection-error-label">' + acf._e('restricted') +'</span>',
8783
- '<span class="selection-error-filename">' + filename + '</span>',
8784
- '<span class="selection-error-message">' + errors + '</span>',
8785
- '</div>'
8786
- ].join(''));
8787
-
8788
-
8789
- // reset selection (unselects all attachments)
8790
- selection.reset();
8791
-
8792
-
8793
- // set single (attachment displayed in sidebar)
8794
- selection.single( model );
8795
-
8796
-
8797
- // return and prevent 'select' form being fired
8798
- return;
8799
-
8800
- }
8801
-
8802
-
8803
- // return
8804
- AttachmentLibrary.prototype.toggleSelection.apply( this, arguments );
8805
-
8806
- }
8807
-
8808
- });
8809
 
 
 
8810
  },
8811
 
8812
- customize_AttachmentFiltersAll: function(){
8813
 
8814
- // add function refresh
8815
- wp.media.view.AttachmentFilters.All.prototype.refresh = function(){
8816
-
8817
- // Build `<option>` elements.
8818
- this.$el.html( _.chain( this.filters ).map( function( filter, value ) {
8819
- return {
8820
- el: $( '<option></option>' ).val( value ).html( filter.text )[0],
8821
- priority: filter.priority || 50
8822
- };
8823
- }, this ).sortBy('priority').pluck('el').value() );
8824
-
8825
- };
8826
 
 
 
 
 
 
8827
  },
8828
 
8829
- customize_AttachmentCompat: function(){
8830
 
8831
- // vars
8832
- var AttachmentCompat = wp.media.view.AttachmentCompat;
 
 
8833
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8834
 
8835
- // extend
8836
- wp.media.view.AttachmentCompat = AttachmentCompat.extend({
8837
-
8838
- add_acf_expand_button: function(){
8839
-
8840
- // vars
8841
- var $el = this.$el.closest('.media-modal');
8842
-
8843
-
8844
- // does button already exist?
8845
- if( $el.find('.media-frame-router .acf-expand-details').exists() ) return;
8846
-
8847
-
8848
- // create button
8849
- var $a = $([
8850
- '<a href="#" class="acf-expand-details">',
8851
- '<span class="is-closed"><span class="acf-icon -left small grey"></span>' + acf._e('expand_details') + '</span>',
8852
- '<span class="is-open"><span class="acf-icon -right small grey"></span>' + acf._e('collapse_details') + '</span>',
8853
- '</a>'
8854
- ].join(''));
8855
-
8856
-
8857
- // add events
8858
- $a.on('click', function( e ){
8859
-
8860
- e.preventDefault();
8861
-
8862
- if( $el.hasClass('acf-expanded') ) {
8863
-
8864
- $el.removeClass('acf-expanded');
8865
-
8866
- } else {
8867
-
8868
- $el.addClass('acf-expanded');
8869
-
8870
- }
8871
-
8872
- });
8873
-
8874
-
8875
- // append
8876
- $el.find('.media-frame-router').append( $a );
8877
-
8878
- },
8879
-
8880
- render: function() {
8881
-
8882
- // validate
8883
- if( this.ignore_render ) return this;
8884
-
8885
-
8886
- // reference
8887
- var self = this;
8888
-
8889
-
8890
- // add expand button
8891
- setTimeout(function(){
8892
-
8893
- self.add_acf_expand_button();
8894
-
8895
- }, 0);
8896
-
8897
-
8898
- // setup fields
8899
- // The clearTimout is needed to prevent many setup functions from running at the same time
8900
- clearTimeout( acf.media.render_timout );
8901
- acf.media.render_timout = setTimeout(function(){
8902
-
8903
- acf.do_action('append', self.$el);
8904
-
8905
- }, 50);
8906
-
8907
-
8908
- // return
8909
- return AttachmentCompat.prototype.render.apply( this, arguments );
8910
-
8911
- },
8912
-
8913
-
8914
- dispose: function() {
8915
-
8916
- // remove
8917
- acf.do_action('remove', this.$el);
8918
-
8919
-
8920
- // return
8921
- return AttachmentCompat.prototype.dispose.apply( this, arguments );
8922
-
8923
- },
8924
-
8925
-
8926
- save: function( e ) {
8927
-
8928
- if( e ) {
8929
-
8930
- e.preventDefault();
8931
 
8932
- }
8933
-
8934
-
8935
- // serialize form
8936
- var data = acf.serialize(this.$el);
8937
-
8938
-
8939
- // ignore render
8940
- this.ignore_render = true;
8941
-
8942
-
8943
- // save
8944
- this.model.saveCompat( data );
8945
-
8946
- }
8947
-
8948
-
8949
- });
8950
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8951
  }
8952
 
 
 
 
 
 
 
8953
 
8954
- });
8955
-
8956
- })(jQuery);
8957
-
8958
- (function($){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8959
 
8960
- acf.fields.oembed = acf.field.extend({
8961
 
8962
- type: 'oembed',
8963
- $el: null,
 
 
8964
 
8965
- events: {
8966
- 'click [data-name="search-button"]': '_search',
8967
- 'click [data-name="clear-button"]': '_clear',
8968
- 'click [data-name="value-title"]': '_edit',
8969
- 'keypress [data-name="search-input"]': '_keypress',
8970
- 'keyup [data-name="search-input"]': '_keyup',
8971
- 'blur [data-name="search-input"]': '_blur'
8972
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8973
 
 
 
 
8974
 
8975
- /*
8976
- * focus
8977
- *
8978
- * This function will setup variables when focused on a field
8979
- *
8980
- * @type function
8981
- * @date 12/04/2016
8982
- * @since 5.3.8
8983
- *
8984
- * @param n/a
8985
- * @return n/a
8986
- */
 
 
 
 
 
 
 
 
 
8987
 
8988
- focus: function(){
 
 
8989
 
8990
- // vars
8991
- this.$el = this.$field.find('.acf-oembed');
8992
- this.$search = this.$el.find('[data-name="search-input"]');
8993
- this.$input = this.$el.find('[data-name="value-input"]');
8994
- this.$title = this.$el.find('[data-name="value-title"]');
8995
- this.$embed = this.$el.find('[data-name="value-embed"]');
8996
 
 
 
 
 
 
 
 
 
 
 
 
8997
 
8998
- // options
8999
- this.o = acf.get_data( this.$el );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9000
 
 
 
9001
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9002
 
 
9003
 
9004
- /*
9005
- * maybe_search
9006
- *
9007
- * description
9008
- *
9009
- * @type function
9010
- * @date 14/10/16
9011
- * @since 5.4.0
9012
- *
9013
- * @param $post_id (int)
9014
- * @return $post_id (int)
9015
- */
9016
 
9017
- maybe_search: function(){
9018
-
9019
- // set url and focus
9020
- var old_url = this.$input.val(),
9021
- new_url = this.$search.val();
9022
-
9023
-
9024
- // bail early if no value
9025
- if( !new_url ) {
9026
-
9027
- this.clear();
9028
- return;
9029
-
9030
- }
9031
-
9032
-
9033
- // bail early if no change
9034
- if( new_url == old_url ) return;
9035
-
9036
-
9037
- // search
9038
- this.search();
9039
-
9040
  },
9041
 
9042
-
9043
- /*
9044
- * search
9045
- *
9046
- * This function will search for an oembed
9047
- *
9048
- * @type function
9049
- * @date 13/10/16
9050
- * @since 5.4.0
9051
- *
9052
- * @param n/a
9053
- * @return n/a
9054
- */
9055
-
9056
- search: function(){
9057
 
9058
  // vars
9059
- var s = this.$search.val();
 
 
 
 
9060
 
 
 
 
 
9061
 
9062
- // fix missing 'http://' - causes the oembed code to error and fail
9063
- if( s.substr(0, 4) != 'http' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9064
 
9065
- s = 'http://' + s;
9066
- this.$search.val( s );
 
 
9067
 
 
 
 
 
9068
  }
9069
 
 
 
 
 
 
 
 
9070
 
9071
- // show loading
9072
- this.$el.addClass('is-loading');
 
 
9073
 
 
 
 
 
 
9074
 
9075
- // AJAX data
9076
- var ajax_data = acf.prepare_for_ajax({
9077
- 'action' : 'acf/fields/oembed/search',
9078
- 's' : s,
9079
- 'field_key' : this.$field.data('key')
9080
- });
9081
 
 
 
9082
 
9083
- // abort XHR if this field is already loading AJAX data
9084
- if( this.$el.data('xhr') ) this.$el.data('xhr').abort();
 
 
 
9085
 
 
 
9086
 
9087
- // get HTML
9088
- var xhr = $.ajax({
9089
- url: acf.get('ajaxurl'),
9090
- data: ajax_data,
9091
- type: 'post',
9092
- dataType: 'json',
9093
- context: this,
9094
- success: this.search_success
9095
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9096
 
 
 
 
 
 
 
 
 
 
9097
 
9098
- // update el data
9099
- this.$el.data('xhr', xhr);
 
 
9100
 
 
 
9101
  },
9102
 
9103
- search_success: function( json ){
9104
-
9105
- // vars
9106
- var s = this.$search.val();
9107
 
 
 
9108
 
9109
- // remove loading
9110
- this.$el.removeClass('is-loading');
9111
 
 
 
 
9112
 
9113
- // error
9114
- if( !json || !json.html ) {
9115
-
9116
- this.$el.removeClass('has-value').addClass('has-error');
9117
  return;
9118
-
9119
  }
9120
 
 
 
 
 
 
9121
 
9122
- // add classes
9123
- this.$el.removeClass('has-error').addClass('has-value');
9124
-
9125
-
9126
- // update vars
9127
- this.$input.val( s );
9128
- this.$title.html( s );
9129
- this.$embed.html( json.html );
9130
-
9131
  },
9132
-
9133
- clear: function(){
9134
-
9135
- // update class
9136
- this.$el.removeClass('has-error has-value');
9137
-
9138
-
9139
- // clear search
9140
- this.$el.find('[data-name="search-input"]').val('');
9141
 
 
 
9142
 
9143
- // clear inputs
9144
- this.$input.val('');
9145
- this.$title.html('');
9146
- this.$embed.html('');
 
9147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9148
  },
9149
 
9150
- edit: function(){
9151
-
9152
- // add class
9153
- this.$el.addClass('is-editing');
9154
-
9155
-
9156
- // set url and focus
9157
- this.$search.val( this.$title.text() ).focus();
9158
-
9159
  },
9160
 
9161
- blur: function( $el ){
 
 
 
 
 
 
 
 
9162
 
9163
- // remove class
9164
- this.$el.removeClass('is-editing');
 
9165
 
 
 
 
 
 
9166
 
9167
- // maybe search
9168
- this.maybe_search();
9169
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9170
  },
9171
 
9172
- _search: function( e ){ // console.log('_search');
9173
-
9174
- this.search();
9175
-
9176
  },
9177
 
9178
- _clear: function( e ){ // console.log('_clear');
9179
-
9180
- this.clear();
9181
-
9182
  },
9183
 
9184
- _edit: function( e ){ // console.log('_clear');
9185
-
9186
- this.edit();
9187
-
9188
  },
9189
 
9190
- _keypress: function( e ){ // console.log('_keypress');
9191
-
9192
- // don't submit form
9193
- if( e.which == 13 ) e.preventDefault();
9194
-
9195
  },
9196
 
9197
- _keyup: function( e ){ //console.log('_keypress', e.which);
9198
-
9199
- // bail early if no value
9200
- if( !this.$search.val() ) return;
 
 
 
 
 
9201
 
 
 
 
9202
 
9203
- // maybe search
9204
- this.maybe_search();
 
 
 
 
9205
 
 
 
 
 
 
 
 
 
 
 
 
9206
  },
9207
 
9208
- _blur: function( e ){ // console.log('_blur');
9209
-
9210
- this.blur();
 
 
 
 
 
 
 
 
 
 
 
9211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9212
  }
9213
-
9214
  });
9215
-
 
 
9216
  })(jQuery);
9217
 
9218
- (function($){
9219
 
9220
- acf.fields.radio = acf.field.extend({
9221
 
9222
- type: 'radio',
9223
 
9224
- $ul: null,
9225
 
9226
- actions: {
9227
- 'ready': 'initialize',
9228
- 'append': 'initialize'
9229
  },
9230
 
9231
- events: {
9232
- 'click input[type="radio"]': 'click'
 
 
 
 
9233
  },
9234
 
9235
- focus: function(){
9236
 
9237
- // focus on $select
9238
- this.$ul = this.$field.find('.acf-radio-list');
 
9239
 
 
 
 
 
 
 
 
 
9240
 
9241
- // get options
9242
- this.o = acf.get_data( this.$ul );
 
 
 
 
 
 
9243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9244
  },
9245
 
 
 
 
9246
 
9247
- /*
9248
- * initialize
9249
- *
9250
- * This function will fix a bug found in Chrome.
9251
- * A radio input (for a given name) may only have 1 selected value. When used within a fc layout
9252
- * multiple times (clone field), the selected value (default value) will not be checked.
9253
- * This simply re-checks it.
9254
- *
9255
- * @type function
9256
- * @date 30/08/2016
9257
- * @since 5.4.0
9258
- *
9259
- * @param $post_id (int)
9260
- * @return $post_id (int)
9261
- */
9262
 
 
 
 
 
9263
  initialize: function(){
9264
 
9265
- // find selected input and check it
9266
- this.$ul.find('.selected input').prop('checked', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9267
 
9268
  },
9269
 
9270
- click: function(e){
9271
 
9272
  // vars
9273
- var $radio = e.$el,
9274
- $label = $radio.parent('label'),
9275
- selected = $label.hasClass('selected'),
9276
- val = $radio.val();
9277
-
9278
-
9279
- // remove previous selected
9280
- this.$ul.find('.selected').removeClass('selected');
9281
-
9282
 
9283
- // add active class
9284
- $label.addClass('selected');
 
 
 
 
 
 
 
 
 
 
 
 
9285
 
 
 
9286
 
9287
- // allow null
9288
- if( this.o.allow_null && selected ) {
9289
-
9290
- // unselect
9291
- e.$el.prop('checked', false);
9292
- $label.removeClass('selected');
9293
- val = false;
9294
-
9295
-
9296
- // trigger change
9297
- e.$el.trigger('change');
9298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9299
  }
 
 
 
 
 
 
 
 
 
 
 
9300
 
 
 
 
 
9301
 
9302
- // other
9303
- if( this.o.other_choice ) {
9304
-
9305
- // vars
9306
- var $other = this.$ul.find('input[type="text"]');
9307
-
9308
-
9309
- // show
9310
- if( val === 'other' ) {
9311
 
9312
- $other.prop('disabled', false).attr('name', $radio.attr('name'));
9313
-
9314
- // hide
9315
- } else {
9316
-
9317
- $other.prop('disabled', true).attr('name', '');
9318
-
9319
- }
9320
-
9321
  }
9322
 
 
 
 
 
 
 
9323
  }
 
 
 
 
9324
 
9325
- });
9326
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9327
  })(jQuery);
9328
 
9329
- (function($){
9330
 
9331
- acf.fields.range = acf.field.extend({
9332
 
9333
- type: 'range',
9334
- $el: null,
9335
- $range: null,
9336
- $input: null,
9337
 
9338
- events: {
9339
- 'input input': 'onInput',
9340
- 'change input': 'onChange'
9341
  },
9342
 
9343
- focus: function(){
9344
 
9345
- // get elements
9346
- this.$el = this.$field.find('.acf-range-wrap');
9347
- this.$range = this.$el.children('input[type="range"]');
9348
- this.$input = this.$el.children('input[type="number"]');
9349
 
9350
- },
9351
-
9352
- setValue: function( val ){
9353
- this.$input.val( val );
9354
- this.$range.val( val );
9355
- },
9356
-
9357
- onInput: function( e ){
9358
- this.setValue( e.$el.val() );
9359
- },
9360
-
9361
- onChange: function( e ){
9362
- this.setValue( e.$el.val() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9363
 
9364
- if( e.$el.attr('type') == 'number' ) {
9365
- this.$range.trigger('change');
 
9366
  }
 
 
 
 
 
 
 
9367
  }
9368
  });
9369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9370
  })(jQuery);
9371
 
9372
- (function($){
9373
 
9374
- acf.fields.relationship = acf.field.extend({
9375
 
9376
- type: 'relationship',
9377
 
9378
- $el: null,
9379
- $input: null,
9380
- $filters: null,
9381
- $choices: null,
9382
- $values: null,
9383
 
9384
- actions: {
9385
- 'ready': 'initialize',
9386
- 'append': 'initialize'
9387
- },
9388
 
9389
  events: {
9390
- 'keypress [data-filter]': 'submit_filter',
9391
- 'change [data-filter]': 'change_filter',
9392
- 'keyup [data-filter]': 'change_filter',
9393
- 'click .choices .acf-rel-item': 'add_item',
9394
- 'click [data-name="remove_item"]': 'remove_item'
 
 
 
9395
  },
9396
 
9397
- focus: function(){
9398
-
9399
- // get elements
9400
- this.$el = this.$field.find('.acf-relationship');
9401
- this.$input = this.$el.children('input[type="hidden"]');
9402
- this.$choices = this.$el.find('.choices'),
9403
- this.$values = this.$el.find('.values');
9404
-
9405
- // get options
9406
- this.o = acf.get_data( this.$el );
9407
-
9408
  },
9409
 
9410
- initialize: function(){
9411
-
9412
- // reference
9413
- var self = this,
9414
- $field = this.$field,
9415
- $el = this.$el,
9416
- $input = this.$input;
9417
-
9418
-
9419
- // right sortable
9420
- this.$values.children('.list').sortable({
9421
- items: 'li',
9422
- forceHelperSize: true,
9423
- forcePlaceholderSize: true,
9424
- scroll: true,
9425
- update: function(){
9426
-
9427
- $input.trigger('change');
9428
-
9429
- }
9430
- });
9431
-
9432
-
9433
- this.$choices.children('.list').scrollTop(0).on('scroll', function(e){
9434
-
9435
- // bail early if no more results
9436
- if( $el.hasClass('is-loading') || $el.hasClass('is-empty') ) {
9437
-
9438
- return;
9439
-
9440
- }
9441
-
9442
-
9443
- // Scrolled to bottom
9444
- if( Math.ceil( $(this).scrollTop() ) + $(this).innerHeight() >= $(this).get(0).scrollHeight ) {
9445
-
9446
- // get paged
9447
- var paged = $el.data('paged') || 1;
9448
-
9449
-
9450
- // update paged
9451
- $el.data('paged', (paged+1) );
9452
-
9453
-
9454
- // fetch
9455
- self.set('$field', $field).fetch();
9456
-
9457
- }
9458
-
9459
- });
9460
-
9461
 
9462
- /*
9463
- // scroll event
9464
- var maybe_fetch = function( e ){
9465
- console.log('scroll');
9466
- // remove listener
9467
- $(window).off('scroll', maybe_fetch);
9468
-
9469
-
9470
- // is field in view
9471
- if( acf.is_in_view($field) ) {
9472
-
9473
- // fetch
9474
- self.doFocus($field);
9475
- self.fetch();
9476
-
9477
-
9478
- // return
9479
- return;
9480
- }
9481
-
9482
-
9483
- // add listener
9484
- setTimeout(function(){
9485
-
9486
- $(window).on('scroll', maybe_fetch);
9487
-
9488
- }, 500);
9489
-
9490
  };
9491
- */
9492
 
 
 
 
 
9493
 
9494
- // fetch
9495
- this.fetch();
 
 
9496
 
 
 
9497
  },
9498
 
9499
- /*
9500
- show: function(){
9501
 
9502
- console.log('show field: %o', this.o.xhr);
 
 
 
 
 
9503
 
9504
- // bail ealry if already loaded
9505
- if( typeof this.o.xhr !== 'undefined' ) {
9506
-
9507
- return;
9508
-
9509
  }
9510
 
9511
-
9512
- // is field in view
9513
- if( acf.is_in_view(this.$field) ) {
9514
-
9515
- // fetch
9516
- this.fetch();
9517
-
9518
  }
9519
 
 
 
9520
  },
9521
- */
9522
 
9523
- maybe_fetch: function(){
9524
-
9525
- // reference
9526
- var self = this,
9527
- $field = this.$field;
9528
 
9529
-
9530
- // abort timeout
9531
- if( this.o.timeout ) {
9532
-
9533
- clearTimeout( this.o.timeout );
9534
-
9535
- }
9536
-
9537
-
9538
- // fetch
9539
- var timeout = setTimeout(function(){
9540
-
9541
- self.doFocus($field);
9542
- self.fetch();
9543
-
9544
- }, 300);
9545
-
9546
- this.$el.data('timeout', timeout);
9547
 
 
 
9548
  },
9549
 
9550
- fetch: function(){
9551
-
9552
- // reference
9553
- var self = this,
9554
- $field = this.$field;
9555
-
9556
-
9557
- // add class
9558
- this.$el.addClass('is-loading');
9559
-
9560
-
9561
- // abort XHR if this field is already loading AJAX data
9562
- if( this.o.xhr ) {
9563
-
9564
- this.o.xhr.abort();
9565
- this.o.xhr = false;
9566
-
9567
- }
9568
-
9569
-
9570
- // add to this.o
9571
- this.o.action = 'acf/fields/relationship/query';
9572
- this.o.field_key = $field.data('key');
9573
- this.o.post_id = acf.get('post_id');
9574
-
9575
-
9576
- // ready for ajax
9577
- var ajax_data = acf.prepare_for_ajax( this.o );
9578
-
9579
-
9580
- // clear html if is new query
9581
- if( ajax_data.paged == 1 ) {
9582
-
9583
- this.$choices.children('.list').html('')
9584
-
9585
- }
9586
 
 
 
9587
 
9588
- // add message
9589
- this.$choices.find('ul:last').append('<p><i class="acf-loading"></i> ' + acf._e('relationship', 'loading') + '</p>');
9590
-
9591
 
9592
- // get results
9593
- var xhr = $.ajax({
9594
- url: acf.get('ajaxurl'),
9595
- dataType: 'json',
9596
- type: 'post',
9597
- data: ajax_data,
9598
- success: function( json ){
9599
-
9600
- self.set('$field', $field).render( json );
9601
-
9602
- }
9603
- });
9604
 
 
 
9605
 
9606
- // update el data
9607
- this.$el.data('xhr', xhr);
9608
 
 
 
9609
  },
9610
 
9611
- render: function( json ){
9612
-
9613
- // remove loading class
9614
- this.$el.removeClass('is-loading is-empty');
9615
-
9616
-
9617
- // remove p tag
9618
- this.$choices.find('p').remove();
9619
-
9620
 
9621
- // no results?
9622
- if( !json || !json.results || !json.results.length ) {
 
 
9623
 
9624
- // add class
9625
- this.$el.addClass('is-empty');
 
 
 
9626
 
 
 
9627
 
9628
- // add message
9629
- if( this.o.paged == 1 ) {
9630
-
9631
- this.$choices.children('.list').append('<p>' + acf._e('relationship', 'empty') + '</p>');
 
 
 
 
 
 
 
 
 
9632
 
9633
- }
9634
-
9635
-
9636
- // return
9637
  return;
9638
-
9639
  }
9640
 
 
 
 
 
 
 
 
 
 
9641
 
9642
- // get new results
9643
- var $new = $( this.walker(json.results) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9644
 
 
 
 
 
 
 
9645
 
9646
- // apply .disabled to left li's
9647
- this.$values.find('.acf-rel-item').each(function(){
9648
 
9649
- $new.find('.acf-rel-item[data-id="' + $(this).data('id') + '"]').addClass('disabled');
 
 
 
 
 
 
 
9650
 
9651
- });
9652
-
9653
-
9654
- // underline search match
9655
- // consider removing due to bug where matched strings within HTML attributes caused incorrect results
9656
- // Looks like Select2 v4 has moved away from highlighting results, so perhaps we should too
9657
- /*
9658
- if( this.o.s ) {
9659
-
9660
  // vars
9661
- var s = this.o.s;
9662
-
9663
-
9664
- // allow special characters to be used within regex
9665
- s = acf.addslashes(s);
9666
 
9667
-
9668
- // loop
9669
- $new.find('.acf-rel-item').each(function(){
9670
-
9671
- // vars
9672
- var find = $(this).text(),
9673
- replace = find.replace( new RegExp('(' + s + ')', 'gi'), '<b>$1</b>');
9674
-
9675
- $(this).html( $(this).html().replace(find, replace) );
9676
-
9677
- });
9678
-
9679
- }
9680
- */
9681
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9682
 
9683
- // append
9684
- this.$choices.children('.list').append( $new );
 
9685
 
 
 
9686
 
9687
- // merge together groups
9688
- var label = '',
9689
- $list = null;
9690
-
9691
- this.$choices.find('.acf-rel-label').each(function(){
9692
-
9693
- if( $(this).text() == label ) {
9694
-
9695
- $list.append( $(this).siblings('ul').html() );
9696
-
9697
- $(this).parent().remove();
9698
-
9699
- return;
 
 
 
 
 
 
9700
  }
9701
 
 
 
 
 
 
 
9702
 
9703
- // update vars
9704
- label = $(this).text();
9705
- $list = $(this).siblings('ul');
9706
-
9707
- });
9708
-
9709
-
9710
  },
9711
 
9712
- walker: function( data ){
 
 
 
 
 
 
 
 
 
 
9713
 
9714
  // vars
9715
- var s = '';
 
 
9716
 
 
 
 
 
 
 
9717
 
9718
- // loop through data
9719
- if( $.isArray(data) ) {
 
 
 
9720
 
9721
- for( var k in data ) {
9722
-
9723
- s += this.walker( data[ k ] );
9724
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9725
  }
9726
 
9727
- } else if( $.isPlainObject(data) ) {
9728
-
9729
- // optgroup
9730
- if( data.children !== undefined ) {
9731
-
9732
- s += '<li><span class="acf-rel-label">' + data.text + '</span><ul class="acf-bl">';
9733
-
9734
- s += this.walker( data.children );
9735
-
9736
- s += '</ul></li>';
9737
-
9738
- } else {
9739
 
9740
- s += '<li><span class="acf-rel-item" data-id="' + data.id + '">' + data.text + '</span></li>';
9741
-
9742
- }
9743
 
 
 
 
 
 
 
 
 
 
 
 
9744
  }
9745
 
 
 
9746
 
9747
- // return
9748
- return s;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9749
 
 
 
 
 
 
 
 
9750
  },
9751
 
9752
- submit_filter: function( e ){
 
 
 
 
 
 
 
 
9753
 
9754
- // don't submit form
9755
  if( e.which == 13 ) {
9756
-
9757
  e.preventDefault();
9758
-
9759
  }
 
 
 
9760
 
 
 
 
 
 
 
9761
  },
9762
 
9763
- change_filter: function( e ){
9764
 
9765
- // vars
9766
- var val = e.$el.val(),
9767
- filter = e.$el.data('filter');
9768
-
 
9769
 
9770
- // Bail early if filter has not changed
9771
- if( this.$el.data(filter) == val ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9772
 
9773
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9774
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9775
  }
9776
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9777
 
9778
- // update attr
9779
- this.$el.data(filter, val);
9780
 
 
 
 
 
9781
 
9782
- // reset paged
9783
- this.$el.data('paged', 1);
 
 
 
 
 
 
 
 
9784
 
9785
-
9786
- // fetch
9787
- if( e.$el.is('select') ) {
9788
-
9789
- this.fetch();
9790
 
9791
- // search must go through timeout
9792
- } else {
9793
-
9794
- this.maybe_fetch();
9795
-
9796
- }
9797
-
9798
  },
9799
 
9800
- add_item: function( e ){
 
 
 
9801
 
9802
- // max posts
9803
- if( this.o.max > 0 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9804
 
9805
- if( this.$values.find('.acf-rel-item').length >= this.o.max ) {
 
9806
 
9807
- alert( acf._e('relationship', 'max').replace('{max}', this.o.max) );
9808
-
9809
- return;
9810
-
 
 
 
 
 
 
 
9811
  }
9812
-
 
 
9813
  }
9814
 
 
 
9815
 
9816
- // can be added?
9817
- if( e.$el.hasClass('disabled') ) {
9818
-
9819
- return false;
9820
-
9821
  }
 
 
 
 
 
 
 
 
9822
 
 
 
 
9823
 
9824
- // disable
9825
- e.$el.addClass('disabled');
9826
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9827
 
9828
- // template
9829
- var html = [
9830
- '<li>',
9831
- '<input type="hidden" name="' + this.$input.attr('name') + '[]" value="' + e.$el.data('id') + '" />',
9832
- '<span data-id="' + e.$el.data('id') + '" class="acf-rel-item">' + e.$el.html(),
9833
- '<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>',
9834
- '</span>',
9835
- '</li>'].join('');
9836
-
9837
 
9838
- // add new li
9839
- this.$values.children('.list').append( html )
9840
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9841
 
9842
- // trigger change on new_li
9843
- this.$input.trigger('change');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9844
 
 
 
9845
 
9846
- // validation
9847
- acf.validation.remove_error( this.$field );
 
 
9848
 
 
 
 
 
 
 
 
 
 
 
 
 
9849
  },
9850
 
9851
- remove_item : function( e ){
9852
 
9853
  // vars
9854
- var $span = e.$el.parent(),
9855
- id = $span.data('id');
9856
-
9857
 
9858
- // remove
9859
- $span.parent('li').remove();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9860
 
 
 
 
9861
 
9862
- // show
9863
- this.$choices.find('.acf-rel-item[data-id="' + id + '"]').removeClass('disabled');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9864
 
 
 
9865
 
9866
- // trigger change on new_li
9867
- this.$input.trigger('change');
 
 
9868
 
 
 
 
 
 
 
 
 
 
 
 
9869
  }
9870
-
9871
  });
9872
 
9873
-
 
9874
  })(jQuery);
9875
 
9876
- (function($){
9877
-
9878
- // globals
9879
- var _select2,
9880
- _select23,
9881
- _select24;
9882
-
9883
-
9884
- /*
9885
- * acf.select2
9886
- *
9887
- * all logic to create select2 instances
9888
- *
9889
- * @type function
9890
- * @date 16/12/2015
9891
- * @since 5.3.2
9892
- *
9893
- * @param n/a
9894
- * @return n/a
9895
- */
9896
 
9897
- _select2 = acf.select2 = acf.model.extend({
9898
 
9899
- // vars
9900
- version: 0,
9901
- version3: null,
9902
- version4: null,
9903
 
 
 
 
 
 
 
9904
 
9905
- // actions
9906
- actions: {
9907
- 'ready 1': 'ready'
9908
  },
9909
 
 
 
 
9910
 
9911
- /*
9912
- * ready
9913
- *
9914
- * This function will run on document ready
9915
- *
9916
- * @type function
9917
- * @date 21/06/2016
9918
- * @since 5.3.8
9919
- *
9920
- * @param n/a
9921
- * @return n/a
9922
- */
 
 
 
 
 
9923
 
9924
- ready: function(){
 
 
 
 
 
 
 
9925
 
9926
- // determine Select2 version
9927
- this.version = this.get_version();
 
 
 
 
 
 
 
 
9928
 
 
 
 
9929
 
9930
- // ready
9931
- this.do_function('ready');
 
 
9932
 
 
 
 
 
9933
  },
9934
 
 
 
 
9935
 
9936
- /*
9937
- * get_version
9938
- *
9939
- * This function will return the Select2 version
9940
- *
9941
- * @type function
9942
- * @date 29/4/17
9943
- * @since 5.5.13
9944
- *
9945
- * @param n/a
9946
- * @return n/a
9947
- */
9948
 
9949
- get_version: function(){
9950
 
9951
- if( acf.maybe_get(window, 'Select2') ) return 3;
9952
- if( acf.maybe_get(window, 'jQuery.fn.select2.amd') ) return 4;
9953
- return 0;
9954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9955
  },
9956
 
 
 
 
 
 
 
 
9957
 
9958
- /*
9959
- * do_function
9960
- *
9961
- * This function will call the v3 or v4 equivelant function
9962
- *
9963
- * @type function
9964
- * @date 28/4/17
9965
- * @since 5.5.13
9966
- *
9967
- * @param name (string)
9968
- * @param args (array)
9969
- * @return (mixed)
9970
- */
9971
 
9972
- do_function: function( name, args ){
 
 
 
 
9973
 
9974
- // defaults
9975
- args = args || [];
9976
 
 
 
 
9977
 
9978
  // vars
9979
- var model = 'version'+this.version;
9980
-
9981
-
9982
- // bail early if not set
9983
- if( typeof this[model] === 'undefined' ||
9984
- typeof this[model][name] === 'undefined' ) return false;
9985
 
 
 
9986
 
9987
- // run
9988
- return this[model][name].apply( this, args );
 
 
 
 
9989
 
 
 
 
9990
  },
9991
-
9992
 
9993
- /*
9994
- * get_data
9995
- *
9996
- * This function will look at a $select element and return an object choices
9997
- *
9998
- * @type function
9999
- * @date 24/12/2015
10000
- * @since 5.3.2
10001
- *
10002
- * @param $select (jQuery)
10003
- * @return (array)
10004
- */
10005
 
10006
- get_data: function( $select, data ){
10007
-
10008
- // reference
10009
- var self = this;
10010
 
 
 
 
 
 
10011
 
10012
- // defaults
10013
- data = data || [];
10014
-
10015
 
10016
- // loop over children
10017
- $select.children().each(function(){
10018
-
10019
- // vars
10020
- var $el = $(this);
10021
-
10022
-
10023
- // optgroup
10024
- if( $el.is('optgroup') ) {
10025
-
10026
- data.push({
10027
- 'text': $el.attr('label'),
10028
- 'children': self.get_data( $el )
10029
- });
10030
-
10031
- // option
10032
- } else {
10033
-
10034
- data.push({
10035
- 'id': $el.attr('value'),
10036
- 'text': $el.text()
10037
- });
10038
-
10039
- }
10040
-
10041
- });
10042
 
 
 
10043
 
10044
- // return
10045
- return data;
10046
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10047
  },
10048
 
10049
-
10050
- /*
10051
- * decode_data
10052
- *
10053
- * This function will take an array of choices and decode the text
10054
- * Changes '&amp;' to '&' which fixes a bug (in Select2 v3 )when searching for '&'
10055
- *
10056
- * @type function
10057
- * @date 24/12/2015
10058
- * @since 5.3.2
10059
- *
10060
- * @param $select (jQuery)
10061
- * @return (array)
10062
- */
 
10063
 
10064
- decode_data: function( data ) {
10065
-
10066
- // bail ealry if no data
10067
- if( !data ) return [];
10068
-
10069
-
10070
- //loop
10071
- $.each(data, function(k, v){
10072
-
10073
- // text
10074
- data[ k ].text = acf.decode( v.text );
10075
-
10076
-
10077
- // children
10078
- if( typeof v.children !== 'undefined' ) {
10079
-
10080
- data[ k ].children = _select2.decode_data(v.children);
10081
-
10082
- }
10083
-
10084
- });
10085
-
10086
 
10087
- // return
10088
- return data;
 
 
 
 
10089
 
 
10090
  },
10091
 
 
 
 
10092
 
10093
- /*
10094
- * count_data
10095
- *
10096
- * This function will take an array of choices and return the count
10097
- *
10098
- * @type function
10099
- * @date 24/12/2015
10100
- * @since 5.3.2
10101
- *
10102
- * @param data (array)
10103
- * @return (int)
10104
- */
10105
 
10106
- count_data: function( data ) {
10107
 
10108
  // vars
10109
- var i = 0;
 
10110
 
 
 
 
 
 
 
 
 
 
10111
 
10112
- // bail ealry if no data
10113
- if( !data ) return i;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10114
 
 
 
 
 
 
 
10115
 
10116
- //loop
10117
- $.each(data, function(k, v){
10118
-
10119
- // increase
10120
- i++;
10121
-
 
 
10122
 
10123
- // children
10124
- if( typeof v.children !== 'undefined' ) {
 
 
 
 
 
 
10125
 
10126
- i += v.children.length;
 
 
 
 
 
 
10127
 
 
 
 
 
 
 
10128
  }
10129
-
10130
  });
10131
 
10132
-
10133
- // return
10134
- return i;
10135
-
10136
  },
10137
 
 
 
 
 
 
10138
 
10139
- /*
10140
- * get_ajax_data
10141
- *
10142
- * This function will return an array of data to send via AJAX
10143
- *
10144
- * @type function
10145
- * @date 19/07/2016
10146
- * @since 5.4.0
10147
- *
10148
- * @param $post_id (int)
10149
- * @return $post_id (int)
10150
- */
10151
 
10152
- get_ajax_data: function( args, params, $el, $field ){
10153
-
10154
- // vars
10155
- var data = acf.prepare_for_ajax({
10156
- action: args.ajax_action,
10157
- field_key: args.key,
10158
- s: params.term || '',
10159
- paged: params.page || 1
10160
- });
10161
-
10162
-
10163
- // filter
10164
- data = acf.apply_filters( 'select2_ajax_data', data, args, $el, $field );
10165
-
10166
-
10167
- // return
10168
- return data;
10169
-
10170
  },
10171
 
 
 
 
 
 
10172
 
10173
- /*
10174
- * get_ajax_results
10175
- *
10176
- * This function will return a valid AJAX response
10177
- *
10178
- * @type function
10179
- * @date 19/07/2016
10180
- * @since 5.4.0
10181
- *
10182
- * @param $post_id (int)
10183
- * @return $post_id (int)
10184
- */
 
 
 
 
 
 
 
10185
 
10186
- get_ajax_results: function( data, params ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10187
 
10188
  // vars
10189
- var valid = {
10190
- results: []
10191
- };
10192
 
 
 
10193
 
10194
- // bail early if no data
10195
- if( !data ) {
10196
-
10197
- data = valid;
10198
-
10199
- }
10200
 
 
 
 
 
 
 
10201
 
10202
- // allow for an array of choices
10203
- if( typeof data.results == 'undefined' ) {
10204
-
10205
- valid.results = data;
10206
-
10207
- data = valid;
10208
 
 
 
 
 
 
 
 
 
10209
  }
10210
-
10211
-
10212
- // decode
10213
- data.results = this.decode_data(data.results);
10214
-
10215
-
10216
- // filter
10217
- data = acf.apply_filters( 'select2_ajax_results', data, params );
10218
-
10219
-
10220
- // return
10221
- return data;
10222
-
10223
- },
10224
 
 
10225
 
10226
- /*
10227
- * get_value
10228
- *
10229
- * This function will return the selected options in a Select2 format
10230
- *
10231
- * @type function
10232
- * @date 5/01/2016
10233
- * @since 5.3.2
10234
- *
10235
- * @param $post_id (int)
10236
- * @return $post_id (int)
10237
- */
10238
 
10239
- get_value: function( $select ){
 
 
10240
 
10241
- // vars
10242
- var val = [],
10243
- $selected = $select.find('option:selected');
10244
-
10245
-
10246
- // bail early if no selected
10247
- if( !$selected.exists() ) return val;
10248
-
10249
-
10250
- // sort
10251
- $selected = $selected.sort(function(a, b) {
10252
-
10253
- return +a.getAttribute('data-i') - +b.getAttribute('data-i');
10254
-
10255
- });
10256
-
10257
 
10258
- // loop
10259
- $selected.each(function(){
10260
-
10261
- // vars
10262
- var $el = $(this);
10263
-
10264
-
10265
- // append
10266
- val.push({
10267
- 'id': $el.attr('value'),
10268
- 'text': $el.text(),
10269
- '$el': $el
10270
- });
10271
-
10272
- });
10273
 
 
 
10274
 
10275
- // return
10276
- return val;
10277
 
 
10278
  },
10279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10280
 
10281
- /*
10282
- * get_input_value
10283
- *
10284
- * This function will return an array of values as per the hidden input
10285
- *
10286
- * @type function
10287
- * @date 29/4/17
10288
- * @since 5.5.13
10289
- *
10290
- * @param $input (jQuery)
10291
- * @return (array)
10292
- */
10293
 
10294
- get_input_value: function( $input ) {
10295
-
10296
- return $input.val().split('||');
10297
-
 
 
 
10298
  },
10299
 
 
 
 
10300
 
10301
- /*
10302
- * sync_input_value
10303
- *
10304
- * This function will save the current selected values into the hidden input
10305
- *
10306
- * @type function
10307
- * @date 29/4/17
10308
- * @since 5.5.13
10309
- *
10310
- * @param $input (jQuery)
10311
- * @param $select (jQuery)
10312
- * @return n/a
10313
- */
10314
 
10315
- sync_input_value: function( $input, $select ) {
10316
-
10317
- $input.val( $select.val().join('||') );
10318
-
10319
  },
10320
 
 
 
 
10321
 
10322
- /*
10323
- * add_option
10324
- *
10325
- * This function will add an <option> element to a select (if it doesn't already exist)
10326
- *
10327
- * @type function
10328
- * @date 29/4/17
10329
- * @since 5.5.13
10330
- *
10331
- * @param $select (jQuery)
10332
- * @param value (string)
10333
- * @param label (string)
10334
- * @return n/a
10335
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10336
 
10337
- add_option: function( $select, value, label ){
10338
 
10339
- if( !$select.find('option[value="'+value+'"]').length ) {
 
10340
 
10341
- $select.append('<option value="'+value+'">'+label+'</option>');
 
 
 
10342
 
10343
- }
10344
-
10345
- },
10346
-
10347
-
10348
- /*
10349
- * select_option
10350
- *
10351
- * This function will select an option
10352
- *
10353
- * @type function
10354
- * @date 29/4/17
10355
- * @since 5.5.13
10356
- *
10357
- * @param $select (jQuery)
10358
- * @param value (string)
10359
- * @return n/a
10360
- */
10361
-
10362
- select_option: function( $select, value ){
10363
 
10364
- $select.find('option[value="'+value+'"]').prop('selected', true);
10365
- $select.trigger('change');
10366
 
 
 
10367
  },
10368
 
10369
-
10370
- /*
10371
- * unselect_option
10372
- *
10373
- * This function will unselect an option
10374
- *
10375
- * @type function
10376
- * @date 29/4/17
10377
- * @since 5.5.13
10378
- *
10379
- * @param $select (jQuery)
10380
- * @param value (string)
10381
- * @return n/a
10382
- */
10383
-
10384
- unselect_option: function( $select, value ){
10385
 
10386
- $select.find('option[value="'+value+'"]').prop('selected', false);
10387
- $select.trigger('change');
10388
 
 
 
10389
  },
10390
 
10391
-
10392
- /*
10393
- * Select2 v3 or v4 functions
10394
- *
10395
- * description
10396
- *
10397
- * @type function
10398
- * @date 29/4/17
10399
- * @since 5.5.10
10400
- *
10401
- * @param $post_id (int)
10402
- * @return $post_id (int)
10403
- */
10404
-
10405
- init: function( $select, args, $field ){
10406
 
10407
- this.do_function( 'init', arguments );
10408
-
 
 
10409
  },
10410
 
10411
- destroy: function( $select ){
 
 
 
 
 
 
 
 
 
10412
 
10413
- this.do_function( 'destroy', arguments );
 
10414
 
10415
- },
10416
-
10417
- add_value: function( $select, value, label ){
10418
 
10419
- this.do_function( 'add_value', arguments );
 
 
10420
 
 
 
 
 
10421
  },
10422
 
10423
- remove_value: function( $select, value ){
10424
 
10425
- this.do_function( 'remove_value', arguments );
 
 
10426
 
10427
- }
10428
-
10429
- });
10430
-
10431
-
10432
- /*
10433
- * Select2 v3
10434
- *
10435
- * This model contains the Select2 v3 functions
10436
- *
10437
- * @type function
10438
- * @date 28/4/17
10439
- * @since 5.5.10
10440
- *
10441
- * @param n/a
10442
- * @return n/a
10443
- */
10444
-
10445
- _select23 = _select2.version3 = {
 
 
 
 
 
 
 
 
 
 
10446
 
10447
- ready: function(){
10448
 
10449
  // vars
10450
- var locale = acf.get('locale'),
10451
- rtl = acf.get('rtl')
10452
- l10n = acf._e('select');
10453
 
 
 
 
 
10454
 
10455
- // bail ealry if no l10n
10456
- if( !l10n ) return;
10457
 
 
 
 
 
 
10458
 
10459
  // vars
10460
- var l10n_functions = {
10461
- formatMatches: function( matches ) {
10462
-
10463
- if ( 1 === matches ) {
10464
- return l10n.matches_1;
10465
- }
10466
-
10467
- return l10n.matches_n.replace('%d', matches);
10468
- },
10469
- formatNoMatches: function() {
10470
- return l10n.matches_0;
10471
- },
10472
- formatAjaxError: function() {
10473
- return l10n.load_fail;
10474
- },
10475
- formatInputTooShort: function( input, min ) {
10476
- var number = min - input.length;
10477
-
10478
- if ( 1 === number ) {
10479
- return l10n.input_too_short_1;
10480
- }
10481
-
10482
- return l10n.input_too_short_n.replace( '%d', number );
10483
- },
10484
- formatInputTooLong: function( input, max ) {
10485
- var number = input.length - max;
10486
-
10487
- if ( 1 === number ) {
10488
- return l10n.input_too_long_1;
10489
- }
10490
-
10491
- return l10n.input_too_long_n.replace( '%d', number );
10492
- },
10493
- formatSelectionTooBig: function( limit ) {
10494
- if ( 1 === limit ) {
10495
- return l10n.selection_too_long_1;
10496
- }
10497
-
10498
- return l10n.selection_too_long_n.replace( '%d', limit );
10499
- },
10500
- formatLoadMore: function() {
10501
- return l10n.load_more;
10502
- },
10503
- formatSearching: function() {
10504
- return l10n.searching;
10505
- }
10506
- };
10507
 
 
 
 
 
10508
 
10509
- // ensure locales exists
10510
- // older versions of Select2 did not have a locale storage
10511
- $.fn.select2.locales = acf.maybe_get(window, 'jQuery.fn.select2.locales', {});
 
 
 
10512
 
 
 
 
 
 
10513
 
10514
- // append
10515
- $.fn.select2.locales[ locale ] = l10n_functions;
10516
- $.extend($.fn.select2.defaults, l10n_functions);
10517
 
 
 
10518
  },
10519
 
10520
- set_data: function( $select, data ){
10521
 
10522
- // v3
10523
- if( this.version == 3 ) {
10524
-
10525
- $select = $select.siblings('input');
10526
-
10527
  }
10528
 
 
 
 
 
 
 
 
 
10529
 
10530
- // set data
10531
- $select.select2('data', data);
 
 
10532
 
10533
- },
10534
-
10535
- append_data: function( $select, data ){
 
 
10536
 
10537
- // v3
10538
- if( this.version == 3 ) {
10539
 
10540
- $select = $select.siblings('input');
 
 
 
 
10541
 
10542
- }
10543
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10544
 
 
 
 
 
 
 
 
 
 
 
10545
 
10546
- // vars
10547
- var current = $select.select2('data') || [];
 
 
 
10548
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10549
 
10550
- // append
10551
- current.push( data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10552
 
 
 
10553
 
10554
- // set data
10555
- $select.select2('data', current);
10556
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10557
  },
10558
 
 
 
 
10559
 
10560
- /*
10561
- * init_v3
10562
- *
10563
- * This function will create a new Select2 for v3
10564
- *
10565
- * @type function
10566
- * @date 24/12/2015
10567
- * @since 5.3.2
10568
- *
10569
- * @param $select (jQuery)
10570
- * @return args (object)
10571
- */
10572
 
10573
- init: function( $select, args, $field ){
10574
-
10575
- // defaults
10576
- args = args || {};
10577
- $field = $field || null;
10578
-
10579
 
10580
- // merge
10581
- args = $.extend({
10582
- allow_null: false,
10583
- placeholder: '',
10584
- multiple: false,
10585
- ajax: false,
10586
- ajax_action: ''
10587
- }, args);
10588
 
10589
-
10590
  // vars
10591
- var $input = $select.siblings('input');
10592
-
 
 
 
 
 
10593
 
10594
- // bail early if no input
10595
- if( !$input.exists() ) return;
 
 
 
 
10596
 
 
 
 
 
 
 
 
 
 
10597
 
10598
- // select2 args
10599
- var select2_args = {
10600
- width: '100%',
10601
- containerCssClass: '-acf',
10602
- allowClear: args.allow_null,
10603
- placeholder: args.placeholder,
10604
- multiple: args.multiple,
10605
- separator: '||',
10606
- data: [],
10607
- escapeMarkup: function( m ){ return m; },
10608
- formatResult: function( result, container, query, escapeMarkup ){
10609
-
10610
- // run default formatResult
10611
- var text = $.fn.select2.defaults.formatResult( result, container, query, escapeMarkup );
10612
-
10613
-
10614
- // append description
10615
- if( result.description ) {
10616
-
10617
- text += ' <span class="select2-result-description">' + result.description + '</span>';
10618
-
10619
- }
10620
-
10621
-
10622
- // return
10623
- return text;
10624
-
10625
- }
10626
- };
10627
 
 
 
 
10628
 
10629
- // value
10630
- var value = this.get_value( $select );
 
 
 
10631
 
 
 
 
 
 
 
10632
 
10633
- // multiple
10634
- if( args.multiple ) {
10635
-
10636
- // vars
10637
- var name = $select.attr('name');
10638
-
10639
-
10640
- // add hidden input to each multiple selection
10641
- select2_args.formatSelection = function( object, $div ){
10642
-
10643
- // vars
10644
- var html = '<input type="hidden" class="select2-search-choice-hidden" name="' + name + '" value="' + object.id + '"' + ($input.prop('disabled') ? 'disabled="disabled"' : '') + ' />';
10645
-
10646
-
10647
- // append input
10648
- $div.parent().append(html);
10649
-
10650
-
10651
- // return
10652
- return object.text;
10653
-
10654
- }
10655
 
10656
- } else {
10657
-
10658
- // change array to single object
10659
- value = acf.maybe_get(value, 0, false);
10660
 
10661
-
10662
- // if no allow_null, this single select must contain a selection
10663
- if( !args.allow_null && value ) {
10664
-
10665
- $input.val( value.id );
10666
-
10667
- }
10668
  }
 
 
 
 
 
 
 
 
 
10669
 
10670
-
10671
- // remove the blank option as we have a clear all button!
10672
- if( args.allow_null ) {
10673
 
10674
- $select.find('option[value=""]').remove();
 
10675
 
 
 
 
 
10676
  }
10677
-
10678
-
10679
- // get data
10680
- select2_args.data = this.get_data( $select );
10681
-
10682
-
10683
- // initial selection
10684
- select2_args.initSelection = function( element, callback ) {
10685
-
10686
- callback( value );
10687
-
10688
- };
10689
-
10690
-
10691
- // ajax
10692
- if( args.ajax ) {
10693
-
10694
- select2_args.ajax = {
10695
- url: acf.get('ajaxurl'),
10696
- dataType: 'json',
10697
- type: 'post',
10698
- cache: false,
10699
- quietMillis: 250,
10700
- data: function( term, page ) {
10701
-
10702
- // vars
10703
- var params = { 'term': term, 'page': page };
10704
-
10705
-
10706
- // return
10707
- return _select2.get_ajax_data(args, params, $input, $field);
10708
-
10709
- },
10710
- results: function( data, page ){
10711
-
10712
- // vars
10713
- var params = { 'page': page };
10714
-
10715
-
10716
- // merge together groups
10717
- setTimeout(function(){
10718
-
10719
- _select23.merge_results();
10720
-
10721
- }, 1);
10722
-
10723
 
10724
- // return
10725
- return _select2.get_ajax_results(data, params);
10726
-
10727
- }
10728
- };
10729
-
10730
- }
10731
-
10732
-
10733
- // attachment z-index fix
10734
- select2_args.dropdownCss = {
10735
- 'z-index' : '999999999'
10736
- };
10737
-
10738
-
10739
- // append args
10740
- select2_args.acf = args;
10741
-
10742
-
10743
- // filter for 3rd party customization
10744
- select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args, $field );
10745
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10746
 
10747
- // add select2
10748
- $input.select2( select2_args );
10749
 
 
 
 
10750
 
10751
  // vars
10752
- var $container = $input.select2('container');
10753
-
10754
-
10755
- // reorder DOM
10756
- // - this order is very important so don't change it
10757
- // - $select goes first so the input can override it. Fixes issue where conditional logic will enable the select
10758
- // - $input goes second to reset the input data
10759
- // - container goes last to allow multiple hidden inputs to override $input
10760
- $container.before( $select );
10761
- $container.before( $input );
10762
 
 
 
 
 
10763
 
10764
- // multiple
10765
- if( args.multiple ) {
10766
-
10767
- // sortable
10768
- $container.find('ul.select2-choices').sortable({
10769
- start: function() {
10770
- $input.select2("onSortStart");
10771
- },
10772
- stop: function() {
10773
- $input.select2("onSortEnd");
10774
- }
10775
- });
10776
-
10777
  }
10778
 
 
 
10779
 
10780
- // disbale select
10781
- $select.prop('disabled', true).addClass('acf-disabled acf-hidden');
 
 
 
 
10782
 
 
 
10783
 
10784
- // update select value
10785
- // this fixes a bug where select2 appears blank after duplicating a post_object field (field settings).
10786
- // the $select is disabled, so setting the value won't cause any issues (this is what select2 v4 does anyway).
10787
- $input.on('change', function(e) {
10788
-
10789
- // add new data
10790
- if( e.added ) {
10791
-
10792
- // add item
10793
- _select2.add_option($select, e.added.id, e.added.text);
10794
-
10795
- }
10796
-
10797
-
10798
- // select
10799
- _select2.select_option($select, e.val);
10800
-
10801
- });
10802
 
 
 
 
10803
 
10804
- // action for 3rd party customization
10805
- acf.do_action('select2_init', $input, select2_args, args, $field);
 
 
 
 
10806
 
 
 
 
 
 
 
 
 
10807
  },
10808
 
 
 
 
10809
 
10810
- /*
10811
- * merge_results_v3
10812
- *
10813
- * description
10814
- *
10815
- * @type function
10816
- * @date 20/07/2016
10817
- * @since 5.4.0
10818
- *
10819
- * @param $post_id (int)
10820
- * @return $post_id (int)
10821
- */
10822
 
10823
- merge_results: function(){
10824
-
10825
- // vars
10826
- var label = '',
10827
- $list = null;
 
 
 
 
 
 
 
 
 
 
 
10828
 
 
 
10829
 
10830
- // loop
10831
- $('#select2-drop .select2-result-with-children').each(function(){
10832
-
10833
- // vars
10834
- var $label = $(this).children('.select2-result-label'),
10835
- $ul = $(this).children('.select2-result-sub');
10836
-
10837
-
10838
- // append group to previous
10839
- if( $label.text() == label ) {
10840
-
10841
- $list.append( $ul.children() );
10842
-
10843
- $(this).remove();
10844
-
10845
- return;
10846
-
10847
- }
10848
-
10849
-
10850
- // update vars
10851
- label = $label.text();
10852
- $list = $ul;
10853
-
10854
- });
10855
 
 
 
10856
  },
10857
 
 
 
 
 
 
 
 
 
10858
 
10859
- /*
10860
- * destroy
10861
- *
10862
- * This function will destroy a Select2
10863
- *
10864
- * @type function
10865
- * @date 24/12/2015
10866
- * @since 5.3.2
10867
- *
10868
- * @param $post_id (int)
10869
- * @return $post_id (int)
10870
- */
10871
 
10872
- destroy: function( $select ){
10873
 
10874
- // vars
10875
- var $input = $select.siblings('input');
 
 
 
 
10876
 
 
 
10877
 
10878
- // destroy via api
10879
- if( $input.data('select2') ) {
10880
- $input.select2('destroy');
10881
- }
 
 
10882
 
 
 
10883
 
10884
- // destory via HTML (duplicating HTML deos not contain data)
10885
- $select.siblings('.select2-container').remove();
10886
 
 
 
 
 
 
 
10887
 
10888
- // enable select
10889
- $select.prop('disabled', false).removeClass('acf-disabled acf-hidden');
10890
- $input.attr('style', ''); // fixes bug causing hidden select2 element
10891
 
 
 
10892
  },
10893
 
10894
- add_value: function( $select, value, label ){
10895
-
10896
- // add and select item
10897
- _select2.add_option($select, value, label);
10898
- _select2.select_option($select, value);
10899
-
10900
 
10901
- // vars
10902
- var $input = $select.siblings('input');
10903
 
 
 
 
 
 
10904
 
10905
- // new item
10906
- var item = {
10907
- 'id': value,
10908
- 'text': label
10909
- };
10910
 
 
 
10911
 
10912
- // single
10913
- if( !$select.data('multiple') ) {
10914
-
10915
- return $input.select2('data', item);
10916
-
10917
  }
10918
 
 
 
 
 
 
10919
 
10920
- // get existing value
10921
- var values = $input.select2('data') || [];
 
 
10922
 
 
 
 
 
10923
 
10924
- // append
10925
- values.push(item);
10926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10927
 
10928
- // set data
10929
- return $input.select2('data', values);
10930
 
 
 
10931
  },
10932
 
10933
- remove_value: function( $select, value ){
10934
-
10935
- // unselect option
10936
- _select2.unselect_option($select, value);
10937
 
 
 
10938
 
10939
- // vars
10940
- var $input = $select.siblings('input'),
10941
- current = $input.select2('data');
 
 
10942
 
 
 
10943
 
10944
- // single
10945
- if( !$select.data('multiple') ) {
10946
-
10947
- if( current && current.id == value ) {
10948
-
10949
- $input.select2('data', null);
10950
-
10951
- }
10952
 
10953
- // multiple
10954
- } else {
10955
-
10956
- // filter
10957
- current = $.grep(current, function( item ) {
10958
- return item.id != value;
10959
- });
10960
-
10961
-
10962
- // set data
10963
- $input.select2('data', current);
10964
-
10965
  }
10966
 
10967
- }
 
 
 
 
 
10968
 
 
10969
 
10970
- };
10971
-
10972
-
10973
- /*
10974
- * Select2 v4
10975
- *
10976
- * This model contains the Select2 v4 functions
10977
- *
10978
- * @type function
10979
- * @date 28/4/17
10980
- * @since 5.5.10
10981
- *
10982
- * @param n/a
10983
- * @return n/a
10984
- */
10985
-
10986
- _select24 = _select2.version4 = {
10987
 
10988
- init: function( $select, args, $field ){
10989
-
10990
- // defaults
10991
- args = args || {};
10992
- $field = $field || null;
 
 
 
 
 
 
 
 
 
 
 
 
10993
 
 
 
 
 
10994
 
10995
- // merge
10996
- args = $.extend({
10997
- allow_null: false,
10998
- placeholder: '',
10999
- multiple: false,
11000
- ajax: false,
11001
- ajax_action: ''
11002
- }, args);
11003
 
 
 
 
 
 
 
 
 
 
 
 
11004
 
11005
  // vars
11006
- var $input = $select.siblings('input');
11007
 
 
 
 
 
 
11008
 
11009
- // bail early if no input
11010
- if( !$input.exists() ) return;
 
 
11011
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11012
 
11013
- // select2 args
11014
- var select2_args = {
11015
- width: '100%',
11016
- allowClear: args.allow_null,
11017
- placeholder: args.placeholder,
11018
- multiple: args.multiple,
11019
- separator: '||',
11020
- data: [],
11021
- escapeMarkup: function( m ){ return m; }
11022
- };
11023
 
 
 
 
 
 
 
 
11024
 
11025
- // value
11026
- var value = this.get_value( $select );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11027
 
 
 
 
 
 
 
 
 
 
11028
 
11029
- // multiple
11030
- if( args.multiple ) {
11031
 
11032
- // reorder opts
11033
- $.each(value, function( k, item ){
11034
-
11035
- // detach and re-append to end
11036
- item.$el.detach().appendTo( $select );
11037
-
11038
  });
11039
 
11040
- } else {
11041
-
11042
- // change array to single object
11043
- value = acf.maybe_get(value, 0, '');
 
11044
 
11045
- }
11046
-
 
 
 
 
 
 
 
11047
 
11048
- /*
11049
- // removed - Select2 does not show this value by default!
11050
- // remove the blank option as we have a clear all button!
11051
- if( args.allow_null ) {
11052
 
11053
- $select.find('option[value=""]').remove();
 
 
11054
 
11055
- }
11056
- */
11057
-
11058
-
11059
- // remove conflicting atts
11060
- if( !args.ajax ) {
11061
 
11062
- $select.removeData('ajax');
11063
- $select.removeAttr('data-ajax');
11064
 
11065
- } else {
 
 
 
 
 
11066
 
11067
- select2_args.ajax = {
11068
- url: acf.get('ajaxurl'),
11069
- delay: 250,
11070
- dataType: 'json',
11071
- type: 'post',
11072
- cache: false,
11073
- data: function( params ) {
11074
-
11075
- // return
11076
- return _select2.get_ajax_data(args, params, $select, $field);
11077
-
11078
- },
11079
- processResults: function( data, params ){
11080
-
11081
- // vars
11082
- var results = _select2.get_ajax_results(data, params);
11083
-
11084
-
11085
- // change to more
11086
- if( results.more ) {
11087
-
11088
- results.pagination = { more: true };
11089
-
11090
- }
11091
-
11092
-
11093
- // merge together groups
11094
- setTimeout(function(){
11095
-
11096
- _select24.merge_results();
11097
-
11098
- }, 1);
11099
-
11100
-
11101
- // return
11102
- return results
11103
-
11104
- }
11105
-
11106
- };
11107
 
11108
- }
11109
-
11110
-
11111
- // filter for 3rd party customization
11112
- select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args, $field );
11113
-
11114
-
11115
- // add select2
11116
- $select.select2( select2_args );
11117
-
11118
-
11119
- // get container (Select2 v4 deos not return this from constructor)
11120
- var $container = $select.next('.select2-container');
11121
-
11122
-
11123
- // reorder DOM
11124
- // - no need to reorder, the select field is needed to $_POST values
11125
-
11126
-
11127
- // multiple
11128
- if( args.multiple ) {
11129
 
11130
- // vars
11131
- var $ul = $container.find('ul');
11132
 
 
 
 
 
 
 
 
11133
 
11134
- // sortable
11135
- $ul.sortable({
11136
-
11137
- stop: function( e ) {
11138
-
11139
- $ul.find('.select2-selection__choice').each(function() {
11140
-
11141
- // vars
11142
- var $option = $( $(this).data('data').element );
11143
-
11144
-
11145
- // detach and re-append to end
11146
- $option.detach().appendTo( $select );
11147
-
11148
-
11149
- // trigger change on input (JS error if trigger on select)
11150
- $input.trigger('change');
11151
- // update input
11152
- //_select2.sync_input_value( $input, $select );
11153
-
11154
- });
11155
-
11156
- }
11157
-
11158
  });
 
 
 
 
11159
 
 
 
11160
 
11161
- // on select, move to end
11162
- $select.on('select2:select', function( e ){
 
 
 
 
 
11163
 
11164
- // vars
11165
- var $option = $(e.params.data.element);
11166
 
 
 
11167
 
11168
- // detach and re-append to end
11169
- $option.detach().appendTo( $select );
 
 
 
 
 
 
11170
 
11171
-
11172
- // trigger change
11173
- //$select.trigger('change');
11174
 
11175
- });
 
 
 
 
 
 
 
 
11176
 
11177
- }
11178
-
 
11179
 
11180
- /*
11181
- // update input
11182
- $select.on('select2:select', function( e ){
11183
 
11184
- // update input
11185
- _select2.sync_input_value( $input, $select );
 
 
 
 
 
11186
 
11187
- });
11188
-
11189
- $select.on('select2:unselect', function( e ){
 
11190
 
11191
- // update input
11192
- _select2.sync_input_value( $input, $select );
 
 
 
11193
 
11194
- });
11195
- */
 
 
 
 
 
 
 
11196
 
 
 
 
 
 
 
 
 
11197
 
11198
- // clear value (allows null to be saved)
11199
- $input.val('');
 
 
11200
 
 
 
 
11201
 
11202
- // add class
11203
- $container.addClass('-acf');
 
11204
 
 
 
 
 
11205
 
11206
- // action for 3rd party customization
11207
- acf.do_action('select2_init', $select, select2_args, args, $field);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11208
 
 
 
11209
  },
11210
 
 
 
 
 
 
 
 
 
11211
 
11212
- /*
11213
- * merge_results_v4
11214
- *
11215
- * description
11216
- *
11217
- * @type function
11218
- * @date 20/07/2016
11219
- * @since 5.4.0
11220
- *
11221
- * @param $post_id (int)
11222
- * @return $post_id (int)
11223
- */
 
 
 
 
 
 
 
 
 
11224
 
11225
- merge_results: function(){
 
 
 
 
 
 
 
 
 
 
 
 
11226
 
11227
  // vars
11228
- var $prev_options = null,
11229
- $prev_group = null;
11230
 
 
 
 
 
 
 
 
 
 
 
 
 
11231
 
11232
- // loop
11233
- $('.select2-results__option[role="group"]').each(function(){
11234
 
11235
  // vars
11236
- var $options = $(this).children('ul'),
11237
- $group = $(this).children('strong');
11238
-
11239
-
11240
- // compare to previous
11241
- if( $prev_group !== null && $group.text() == $prev_group.text() ) {
11242
-
11243
- $prev_options.append( $options.children() );
11244
-
11245
- $(this).remove();
11246
-
11247
- return;
11248
-
11249
- }
11250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11251
 
11252
- // update vars
11253
- $prev_options = $options;
11254
- $prev_group = $group;
 
 
 
 
 
 
 
 
 
 
 
11255
 
11256
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11258
  },
11259
 
11260
- add_value: function( $select, value, label ){
11261
-
11262
- // add and select item
11263
- _select2.add_option($select, value, label);
11264
- _select2.select_option($select, value);
11265
 
 
 
 
 
11266
  },
11267
 
11268
- remove_value: function( $select, value ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11269
 
11270
- // unselect
11271
- _select2.unselect_option($select, value);
11272
 
 
 
11273
  },
11274
 
11275
- destroy: function( $select ){
11276
-
11277
- // destroy via api
11278
- if( $select.data('select2') ) {
11279
- $select.select2('destroy');
11280
- }
11281
 
 
 
11282
 
11283
- // destory via HTML (duplicating HTML deos not contain data)
11284
- $select.siblings('.select2-container').remove();
 
 
11285
 
11286
- }
 
 
11287
 
11288
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11289
 
 
 
11290
 
11291
- /*
11292
- * depreciated
11293
  *
11294
- * These functions have moved since v5.3.3
11295
  *
11296
- * @type function
11297
- * @date 11/12/2015
11298
- * @since 5.3.2
11299
  *
11300
- * @param n/a
11301
- * @return n/a
11302
  */
11303
 
11304
- acf.add_select2 = function( $select, args ) {
11305
 
11306
- _select2.init( $select, args );
11307
-
11308
- }
11309
-
11310
- acf.remove_select2 = function( $select ) {
11311
 
11312
- _select2.destroy( $select );
 
 
 
 
11313
 
11314
- }
11315
-
11316
- })(jQuery);
11317
-
11318
- (function($){
11319
-
11320
- // select
11321
- acf.fields.select = acf.field.extend({
11322
 
11323
- type: 'select',
 
 
11324
 
11325
- $select: null,
 
 
11326
 
11327
- actions: {
11328
- 'ready': 'render',
11329
- 'append': 'render',
11330
- 'remove': 'remove'
11331
  },
11332
-
11333
- focus: function(){
11334
-
11335
- // focus on $select
11336
- this.$select = this.$field.find('select');
11337
-
11338
-
11339
- // bail early if no select field
11340
- if( !this.$select.exists() ) return;
11341
-
11342
-
11343
- // get options
11344
- this.o = acf.get_data( this.$select );
11345
-
11346
-
11347
- // customize o
11348
- this.o = acf.parse_args(this.o, {
11349
- 'ajax_action': 'acf/fields/'+this.type+'/query',
11350
- 'key': this.$field.data('key')
11351
- });
11352
-
11353
  },
11354
 
11355
- render: function(){
11356
-
11357
- // validate ui
11358
- if( !this.$select.exists() || !this.o.ui ) {
11359
-
11360
- return false;
11361
-
11362
- }
11363
-
11364
-
11365
- acf.select2.init( this.$select, this.o, this.$field );
11366
-
11367
  },
11368
 
11369
- remove: function(){
11370
-
11371
- // validate ui
11372
- if( !this.$select.exists() || !this.o.ui ) {
11373
-
11374
- return false;
11375
-
11376
- }
11377
-
11378
-
11379
- // remove select2
11380
- acf.select2.destroy( this.$select );
11381
-
11382
  }
11383
-
11384
  });
11385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11386
 
11387
- // user
11388
- acf.fields.user = acf.fields.select.extend({
11389
 
11390
- type: 'user'
 
 
11391
 
11392
- });
11393
-
11394
-
11395
- // post_object
11396
- acf.fields.post_object = acf.fields.select.extend({
11397
 
11398
- type: 'post_object'
 
 
 
 
 
 
11399
 
11400
- });
11401
-
11402
-
11403
- // page_link
11404
- acf.fields.page_link = acf.fields.select.extend({
11405
 
11406
- type: 'page_link'
 
 
 
 
11407
 
11408
- });
11409
-
11410
-
11411
- })(jQuery);
 
 
 
 
 
11412
 
11413
- (function($, undefined){
 
 
 
 
 
 
 
 
 
 
11414
 
11415
- var i = 0;
11416
-
11417
- acf.fields.accordion = acf.field.extend({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11418
 
11419
- type: 'accordion',
11420
- $el: null,
11421
- $wrap: null,
 
11422
 
11423
- actions: {
11424
- 'prepare': 'initialize',
11425
- 'append': 'initialize',
11426
- },
11427
 
11428
- focus: function(){
11429
-
11430
-
11431
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11432
 
11433
- initialize: function(){
11434
-
11435
- // vars
11436
- var $field = this.$field;
11437
- var $label = $field.children('.acf-label');
11438
- var $input = $field.children('.acf-input');
11439
- var $wrap = $input.children('.acf-fields');
11440
- var settings = $wrap.data();
11441
-
11442
-
11443
- // bail early if is cell
11444
- if( $field.is('td') ) return;
11445
-
11446
-
11447
- // enpoint
11448
- if( settings.endpoint ) {
11449
- $field.remove();
11450
- return;
11451
- }
11452
-
11453
-
11454
- // force description into label
11455
- var $instructions = $input.children('.description')
11456
- if( $instructions.length ) {
11457
- $label.append( $instructions );
11458
- }
11459
-
11460
-
11461
- // table
11462
- if( $field.is('tr') ) {
11463
-
11464
- // vars
11465
- var $table = $field.closest('table');
11466
- var $newLabel = $('<div class="acf-accordion-title"/>');
11467
- var $newInput = $('<div class="acf-accordion-content"/>');
11468
- var $newTable = $('<table class="' + $table.attr('class') + '"/>');
11469
- var $newWrap = $('<tbody/>');
11470
-
11471
- // dom
11472
- $newLabel.append( $label.html() );
11473
- $newTable.append( $newWrap );
11474
- $newInput.append( $newTable );
11475
- $input.append( $newLabel );
11476
- $input.append( $newInput );
11477
-
11478
- // modify
11479
- $label.remove();
11480
- $wrap.remove();
11481
- $input.attr('colspan', 2);
11482
-
11483
- // update vars
11484
- $label = $newLabel;
11485
- $input = $newInput;
11486
- $wrap = $newWrap;
11487
-
11488
- }
11489
-
11490
-
11491
- // add classes
11492
- $field.addClass('acf-accordion');
11493
- $label.addClass('acf-accordion-title');
11494
- $input.addClass('acf-accordion-content');
11495
-
11496
-
11497
- // index
11498
- i++;
11499
-
11500
-
11501
- // multi-expand
11502
- if( settings.multi_expand ) {
11503
- $field.data('multi-expand', 1);
11504
- }
11505
-
11506
-
11507
- // open
11508
- var order = acf.getPreference('this.accordions') || [];
11509
- if( order[i-1] !== undefined ) {
11510
- settings.open = order[i-1];
11511
- }
11512
- if( settings.open ) {
11513
- $field.addClass('-open');
11514
- $input.css('display', 'block'); // needed for accordion to close smoothly
11515
- }
11516
-
11517
-
11518
- // add icon
11519
- $label.prepend('<i class="acf-accordion-icon dashicons dashicons-arrow-' + (settings.open ? 'down' : 'right') + '"></i>');
11520
 
 
 
 
 
11521
 
11522
- // classes
11523
- // - remove 'inside' which is a #poststuff WP class
11524
- var $parent = $field.parent();
11525
- $wrap.addClass( $parent.hasClass('-left') ? '-left' : '' );
11526
- $wrap.addClass( $parent.hasClass('-clear') ? '-clear' : '' );
11527
 
 
 
 
 
11528
 
11529
  // append
11530
- $wrap.append( $field.nextUntil('.acf-field-accordion', '.acf-field') );
11531
-
11532
-
11533
- // clean up
11534
- $wrap.removeAttr('data-open data-multi_expand data-endpoint');
11535
- }
11536
 
11537
- });
 
 
11538
 
 
 
 
11539
 
11540
- /*
11541
- * accordionManager
 
 
 
11542
  *
11543
- * This model will handle adding accordions
11544
  *
11545
- * @type function
11546
- * @date 25/11/2015
11547
- * @since 5.3.2
11548
  *
11549
- * @param $post_id (int)
11550
- * @return $post_id (int)
11551
  */
11552
 
11553
- var accordionManager = acf.model.extend({
11554
-
11555
- events: {
11556
- 'click .acf-accordion-title': '_click',
11557
- },
11558
 
11559
- _click: function( e ){
11560
-
11561
- // prevent Defailt
11562
- e.preventDefault();
11563
-
11564
- // open close
11565
- this.toggle( e.$el.closest('.acf-accordion') );
11566
-
11567
- },
11568
 
11569
- isOpen: function( $el ) {
11570
- return $el.hasClass('-open');
11571
- },
11572
 
11573
- toggle: function( $el ){
11574
-
11575
- // is open
11576
- if( this.isOpen($el) ) {
11577
- this.close( $el );
11578
- } else {
11579
- this.open( $el );
11580
- }
11581
-
11582
  },
11583
 
11584
- open: function( $el ){
11585
-
11586
- // open
11587
- $el.find('.acf-accordion-content:first').slideDown().css('display', 'block');
11588
- $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-right').addClass('dashicons-arrow-down');
11589
- $el.addClass('-open');
11590
-
11591
- // action
11592
- acf.do_action('show', $el);
11593
-
11594
- // close siblings
11595
- if( !$el.data('multi-expand') ) {
11596
- $el.siblings('.acf-accordion.-open').each(function(){
11597
- accordionManager.close( $(this) );
11598
- });
11599
  }
11600
-
11601
- // action
11602
- acf.do_action('refresh', $el);
11603
  },
11604
-
11605
- close: function( $el ){
11606
-
11607
- // close
11608
- $el.find('.acf-accordion-content:first').slideUp();
11609
- $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-down').addClass('dashicons-arrow-right');
11610
- $el.removeClass('-open');
11611
-
11612
- // action
11613
- acf.do_action('hide', $el);
11614
-
11615
- }
11616
-
11617
- });
11618
-
11619
- $(window).on('unload', function(){
11620
-
11621
- var order = [];
11622
- $('.acf-accordion').each(function(){
11623
- var open = $(this).hasClass('-open') ? 1 : 0;
11624
- order.push(open);
11625
- });
11626
- if( !order.length ) return;
11627
- acf.setPreference('this.accordions', order);
11628
-
11629
  });
11630
 
11631
-
11632
  /**
11633
- * accordionValidation
11634
  *
11635
- * This model will handle validation of fields within an accordion
11636
  *
11637
- * @date 20/11/17
11638
  * @since 5.6.5
11639
  *
11640
- * @param n/a
11641
- * @return n/a
11642
  */
11643
 
11644
- var accordionValidation = acf.model.extend({
 
 
 
 
 
 
 
11645
 
11646
- active: 1,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11647
 
11648
- events: {
11649
- 'invalidField .acf-accordion': 'invalidField'
11650
- },
11651
 
11652
- invalidField: function( e ){
11653
-
11654
- // bail early if already focused
11655
- if( !this.active ) return;
11656
-
11657
- // block
11658
- this.block();
11659
-
11660
- // open
11661
- accordionManager.open( e.$el );
11662
-
11663
- },
11664
 
11665
- block: function(){
11666
-
11667
- // reference
11668
- var self = this;
11669
-
11670
- // disable functionality for 1sec (allow next validation to work)
11671
- this.active = 0;
11672
 
11673
- // timeout
11674
- setTimeout(function(){
11675
- self.active = 1;
11676
- }, 1000);
11677
 
 
 
 
 
11678
  }
11679
 
11680
- });
11681
-
11682
- })(jQuery);
11683
-
11684
- (function($){
11685
-
11686
- // vars
11687
- var CLASS = 'hidden-by-conditional-logic';
11688
- var groupIndex = 0;
11689
- var tabIndex = 0;
11690
 
11691
 
11692
- /*
11693
- * tabs
11694
  *
11695
- * This model will handle adding tabs and groups
11696
  *
11697
- * @type function
11698
- * @date 25/11/2015
11699
- * @since 5.3.2
11700
  *
11701
- * @param n/a
11702
- * @return n/a
11703
  */
11704
 
11705
- var tabs = acf.model.extend({
11706
-
11707
- $fields: [],
11708
 
11709
- actions: {
11710
- 'prepare 15': 'initialize',
11711
- 'append 15': 'initialize',
11712
- 'refresh 15': 'refresh'
11713
- },
11714
 
11715
- events: {
11716
- 'click .acf-tab-button': '_click'
11717
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11718
 
11719
- _click: function( e ){
11720
-
11721
- // prevent Defailt
11722
- e.preventDefault();
11723
-
11724
- // toggle
11725
- this.toggle( e.$el );
11726
-
11727
- },
11728
 
11729
- isOpen: function( $el ) {
11730
- return $el.hasClass('-open');
 
 
11731
  },
11732
 
11733
- toggle: function( $a ){
11734
-
11735
- // vars
11736
- var key = $a.data('key');
11737
- var $li = $a.parent();
11738
- var $wrap = $a.closest('.acf-tab-wrap');
11739
- var $active = $wrap.find('.active a');
11740
- var $field = $wrap.siblings('.acf-field[data-key="' + key + '"]');
11741
 
 
 
11742
 
11743
- // bail early if already open
11744
- if( this.isOpen($field) ) return;
11745
-
11746
 
11747
- // close
11748
- if( $active.length ) {
11749
 
11750
- // vars
11751
- var activeKey = $active.data('key');
11752
- var $activeli = $active.parent();
11753
- var $activeField = $wrap.siblings('.acf-field[data-key="' + activeKey + '"]');
 
 
 
11754
 
11755
- // hide
11756
- $activeli.removeClass('active');
11757
- this.close( $activeField );
 
11758
 
 
 
 
11759
  }
 
 
 
11760
 
 
 
 
 
 
 
 
11761
 
11762
- // open
11763
- $li.addClass('active');
11764
- this.open( $field );
11765
-
11766
-
11767
- // action
11768
- // - allows acf.layout to fix floating field's min-height
11769
- acf.do_action('refresh', $wrap.parent() );
11770
-
11771
  },
11772
 
11773
- getFields: function( $field ){
11774
- return $field.nextUntil('.acf-field-tab', '.acf-field');
11775
  },
11776
 
11777
- getWrap: function( $field ){
11778
- return $field.prevAll('.acf-tab-wrap:first');
11779
  },
11780
 
11781
- getTab: function( $wrap, key ){
11782
- return $wrap.find('a[data-key="' + key + '"]');
11783
  },
11784
 
11785
- open: function( $field ){
11786
 
11787
- // show
11788
- this.getFields( $field ).each(function(){
 
 
 
 
 
 
11789
 
11790
- $(this).removeClass('hidden-by-tab');
11791
- acf.do_action('show_field', $(this), 'tab');
 
 
11792
 
 
 
 
 
11793
  });
11794
 
 
11795
  },
11796
 
11797
- close: function( $field ){
11798
-
11799
- // show
11800
- this.getFields( $field ).each(function(){
11801
-
11802
- $(this).addClass('hidden-by-tab');
11803
- acf.do_action('hide_field', $(this), 'tab');
11804
-
11805
- });
11806
-
11807
  },
11808
 
11809
- addTab: function( $field ){
11810
- this.$fields.push( $field );
11811
  },
11812
 
11813
- initialize: function(){
11814
-
11815
- // bail ealry if no fields
11816
- if( !this.$fields.length ) return;
11817
-
11818
- // loop
11819
- for( var i = 0; i < this.$fields.length; i++) {
11820
- this.createTab( this.$fields[ i ] );
11821
- }
11822
-
11823
- // reset
11824
- this.$fields = [];
11825
-
11826
  },
11827
-
11828
- createTab: function( $field ){
11829
-
11830
- // bail early if is cell
11831
- if( $field.is('td') ) return false;
11832
-
11833
-
11834
- // vars
11835
- var $label = $field.children('.acf-label');
11836
- var $input = $field.children('.acf-input');
11837
- var $wrap = this.getWrap( $field );
11838
- var $button = $field.find('.acf-tab-button');
11839
- var settings = $button.data();
11840
- var open = false;
11841
-
11842
-
11843
- // remove
11844
- $field.hide();
11845
- $label.remove();
11846
- $input.remove();
11847
-
11848
-
11849
- // create wrap
11850
- if( !$wrap.exists() || settings.endpoint ) {
11851
- $wrap = this.createTabWrap( $field, settings );
11852
- open = true;
11853
- }
11854
-
11855
-
11856
- // create tab
11857
- var $tab = $('<li></li>').append( $button );
11858
-
11859
-
11860
- // open
11861
- if( open ) {
11862
- $tab.addClass('active');
11863
- this.open( $field );
11864
- } else {
11865
- this.close( $field );
11866
- }
11867
-
11868
-
11869
- // hide li
11870
- if( $button.html() == '' ) $tab.hide();
11871
-
11872
-
11873
- // append
11874
- $wrap.find('ul').append( $tab );
11875
-
11876
-
11877
- // toggle active tab
11878
- // previous attempts to integrate with above 'open' variable were uncessefull
11879
- // this separate toggle logic ensures the tab exists
11880
- tabIndex++;
11881
- var order = acf.getPreference('this.tabs') || [];
11882
- var index = order[ groupIndex-1 ] || 0;
11883
- if( index == tabIndex-1 && !open ) {
11884
- this.toggle( $button );
11885
- }
11886
-
11887
-
11888
- // return
11889
- return $tab;
11890
  },
11891
 
11892
- createTabWrap: function( $field, settings ){
11893
 
11894
- // vars
11895
- var $parent = $field.parent();
11896
- var $wrap = false;
11897
-
11898
-
11899
- // add sidebar for left placement
11900
- if( $parent.hasClass('acf-fields') && settings.placement == 'left' ) {
11901
- $parent.addClass('-sidebar');
11902
- }
11903
 
 
 
11904
 
11905
- // create wrap
11906
- if( $field.is('tr') ) {
11907
- $wrap = $('<tr class="acf-tab-wrap"><td colspan="2"><ul class="acf-hl acf-tab-group"></ul></td></tr>');
11908
  } else {
11909
- $wrap = $('<div class="acf-tab-wrap -' + settings.placement + '"><ul class="acf-hl acf-tab-group"></ul></div>');
11910
  }
11911
 
 
 
11912
 
11913
- // append
11914
- $field.before( $wrap );
11915
-
 
11916
 
11917
- // index
11918
- groupIndex++;
11919
- tabIndex = 0;
 
 
11920
 
 
 
 
11921
 
11922
- // return
11923
- return $wrap;
 
11924
 
 
11925
  },
11926
 
11927
- refresh: function( $el ){
11928
-
11929
- // loop
11930
- $('.acf-tab-wrap', $el).each(function(){
11931
-
11932
- // vars
11933
- var $wrap = $(this);
11934
-
11935
-
11936
- // fix left aligned min-height
11937
- if( $wrap.hasClass('-left') ) {
11938
-
11939
- // vars
11940
- var $parent = $wrap.parent();
11941
- var attribute = $parent.is('td') ? 'height' : 'min-height';
11942
-
11943
- // find height (minus 1 for border-bottom)
11944
- var height = $wrap.position().top + $wrap.children('ul').outerHeight(true) - 1;
11945
-
11946
- // add css
11947
- $parent.css(attribute, height);
11948
-
11949
- }
11950
-
11951
- });
11952
 
11953
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11954
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11955
  });
11956
 
 
 
11957
 
11958
 
11959
  /**
11960
- * acf.fields.tab
11961
  *
11962
  * description
11963
  *
11964
- * @date 17/11/17
11965
  * @since 5.6.5
11966
  *
11967
- * @param n/a
11968
- * @return n/a
11969
  */
11970
 
11971
- acf.fields.tab = acf.field.extend({
11972
-
11973
- type: 'tab',
11974
- $el: null,
11975
- $wrap: null,
11976
-
11977
- actions: {
11978
- 'prepare': 'initialize',
11979
- 'append': 'initialize',
11980
- 'hide': 'hide',
11981
- 'show': 'show'
11982
  },
11983
-
11984
- focus: function(){
11985
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11986
  },
11987
-
11988
- initialize: function(){
11989
-
11990
- // add tab
11991
- tabs.addTab( this.$field );
11992
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11993
  },
11994
-
11995
- hide: function( $field, context ){
11996
-
11997
- // bail early if not conditional logic
11998
- if( context != 'conditional_logic' ) return;
11999
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12000
 
12001
  // vars
12002
- var key = $field.data('key');
12003
- var $wrap = tabs.getWrap( $field );
12004
- var $tab = tabs.getTab( $wrap, key );
12005
- var $li = $tab.parent();
12006
-
12007
- // bail early if $group does not exist (clone field)
12008
- if( !$wrap.exists() ) return;
12009
-
12010
 
12011
- // hide li
12012
- $li.addClass( CLASS );
 
 
 
 
 
12013
 
 
 
12014
 
12015
- // hide fields
12016
- tabs.getFields( $field ).each(function(){
12017
- acf.conditional_logic.hide_field( $(this), key );
 
 
 
 
 
 
 
 
12018
  });
12019
 
12020
-
12021
- // select other tab if active
12022
- if( $li.hasClass('active') ) {
12023
- $wrap.find('li:not(.'+CLASS+'):first a').trigger('click');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12024
  }
12025
-
12026
  },
12027
-
12028
- show: function( $field, context ){
12029
-
12030
- // bail early if not conditional logic
12031
- if( context != 'conditional_logic' ) return;
12032
-
12033
-
12034
- // vars
12035
- var key = $field.data('key');
12036
- var $wrap = tabs.getWrap( $field );
12037
- var $tab = tabs.getTab( $wrap, key );
12038
- var $li = $tab.parent();
12039
-
12040
-
12041
- // bail early if $group does not exist (clone field)
12042
- if( !$wrap.exists() ) return;
12043
-
12044
-
12045
- // show li
12046
- $li.removeClass( CLASS );
12047
-
12048
-
12049
- // hide fields
12050
- tabs.getFields( $field ).each(function(){
12051
- acf.conditional_logic.show_field( $(this), key );
12052
- });
12053
-
12054
-
12055
- // select tab if no other active
12056
- var $active = $li.siblings('.active');
12057
- if( !$active.exists() || $active.hasClass(CLASS) ) {
12058
- tabs.toggle( $tab );
12059
  }
12060
-
 
 
 
12061
  }
12062
-
12063
  });
12064
 
 
12065
 
12066
- $(window).on('unload', function(){
12067
-
12068
- var order = [];
12069
- $('.acf-tab-wrap').each(function(){
12070
- var active = $(this).find('.active').index() || 0;
12071
- order.push(active);
12072
- });
12073
- if( !order.length ) return;
12074
- acf.setPreference('this.tabs', order);
12075
-
 
 
 
 
 
 
12076
  });
12077
 
 
12078
 
12079
- /*
12080
- * tab_validation
12081
  *
12082
- * This model will handle validation of fields within a tab group
12083
  *
12084
- * @type function
12085
- * @date 25/11/2015
12086
- * @since 5.3.2
12087
  *
12088
- * @param $post_id (int)
12089
- * @return $post_id (int)
12090
  */
12091
 
12092
- var tab_validation = acf.model.extend({
12093
-
12094
- active: 1,
12095
-
12096
- actions: {
12097
- 'invalid_field': 'invalid_field',
12098
- },
12099
-
12100
- invalid_field: function( $field ){
12101
-
12102
- // bail early if already focused
12103
- if( !this.active ) {
12104
- return;
12105
- }
12106
-
12107
-
12108
- // bail early if not hidden by tab
12109
- if( !$field.hasClass('hidden-by-tab') ) {
12110
- return;
12111
- }
12112
-
12113
-
12114
- // reference
12115
- var self = this;
12116
-
12117
-
12118
- // vars
12119
- var $tab = $field.prevAll('.acf-field-tab:first'),
12120
- $group = $field.prevAll('.acf-tab-wrap:first');
12121
-
12122
-
12123
- // focus
12124
- $group.find('a[data-key="' + $tab.data('key') + '"]').trigger('click');
12125
-
12126
-
12127
- // disable functionality for 1sec (allow next validation to work)
12128
- this.active = 0;
12129
-
12130
- setTimeout(function(){
12131
-
12132
- self.active = 1;
12133
-
12134
- }, 1000);
12135
-
12136
- }
12137
-
12138
- });
12139
 
12140
-
12141
  })(jQuery);
12142
 
12143
- (function($){
 
 
 
 
 
 
 
 
 
 
 
 
12144
 
12145
- acf.fields.time_picker = acf.field.extend({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12146
 
12147
- type: 'time_picker',
12148
- $el: null,
12149
- $input: null,
12150
- $hidden: null,
 
 
12151
 
12152
- o: {},
 
 
 
 
 
12153
 
12154
- actions: {
12155
- 'ready': 'initialize',
12156
- 'append': 'initialize'
12157
- },
12158
 
12159
- events: {
12160
- 'blur input[type="text"]': 'blur'
12161
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12162
 
12163
- focus: function(){
12164
-
12165
- // get elements
12166
- this.$el = this.$field.find('.acf-time-picker');
12167
- this.$input = this.$el.find('input[type="text"]');
12168
- this.$hidden = this.$el.find('input[type="hidden"]');
12169
-
12170
-
12171
- // get options
12172
- this.o = acf.get_data( this.$el );
12173
-
12174
- },
12175
 
12176
- initialize: function(){
12177
-
12178
- // bail ealry if no timepicker library
12179
- if( typeof $.timepicker === 'undefined' ) return;
12180
-
12181
-
12182
- // create options
12183
- var args = {
12184
- timeFormat: this.o.time_format,
12185
- altField: this.$hidden,
12186
- altFieldTimeOnly: false,
12187
- altTimeFormat: 'HH:mm:ss',
12188
- showButtonPanel: true,
12189
- controlType: 'select',
12190
- oneLine: true,
12191
- closeText: acf._e('date_time_picker', 'selectText')
12192
- };
12193
-
12194
-
12195
- // add custom 'Close = Select' functionality
12196
- args.onClose = function( value, instance ){
12197
-
12198
- // vars
12199
- var $div = instance.dpDiv,
12200
- $close = $div.find('.ui-datepicker-close');
12201
-
12202
-
12203
- // if clicking close button
12204
- if( !value && $close.is(':hover') ) {
12205
-
12206
- // attempt to find new value
12207
- value = acf.maybe_get(instance, 'settings.timepicker.formattedTime');
12208
-
12209
-
12210
- // bail early if no value
12211
- if( !value ) return;
12212
-
12213
-
12214
- // update value
12215
- $.datepicker._setTime(instance);
12216
-
12217
- }
12218
-
12219
- };
12220
-
12221
-
12222
- // filter for 3rd party customization
12223
- args = acf.apply_filters('time_picker_args', args, this.$field);
12224
-
12225
-
12226
- // add date picker
12227
- this.$input.timepicker( args );
12228
-
12229
-
12230
- // wrap the datepicker (only if it hasn't already been wrapped)
12231
- if( $('body > #ui-datepicker-div').exists() ) {
12232
-
12233
- $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
12234
-
12235
- }
12236
-
12237
-
12238
- // action for 3rd party customization
12239
- acf.do_action('time_picker_init', this.$input, args, this.$field);
12240
-
12241
- },
12242
 
12243
- blur: function(){
12244
-
12245
- if( !this.$input.val() ) {
12246
-
12247
- this.$hidden.val('');
12248
-
12249
  }
12250
-
12251
  }
12252
 
12253
- });
 
 
12254
 
12255
- })(jQuery);
12256
-
12257
- (function($){
12258
 
12259
- acf.fields.true_false = acf.field.extend({
12260
-
12261
- type: 'true_false',
12262
- $switch: null,
12263
- $input: null,
12264
-
12265
- actions: {
12266
- 'prepare': 'render',
12267
- 'append': 'render',
12268
- 'show': 'render'
12269
- },
12270
-
12271
- events: {
12272
- 'change .acf-switch-input': '_change',
12273
- 'focus .acf-switch-input': '_focus',
12274
- 'blur .acf-switch-input': '_blur',
12275
- 'keypress .acf-switch-input': '_keypress'
12276
- },
12277
-
12278
 
12279
- /*
12280
- * focus
12281
- *
12282
- * This function will setup variables when focused on a field
12283
- *
12284
- * @type function
12285
- * @date 12/04/2016
12286
- * @since 5.3.8
12287
- *
12288
- * @param n/a
12289
- * @return n/a
12290
- */
12291
 
12292
- focus: function(){
12293
-
12294
- // vars
12295
- this.$input = this.$field.find('.acf-switch-input');
12296
- this.$switch = this.$field.find('.acf-switch');
12297
-
12298
  },
12299
 
12300
-
12301
- /*
12302
- * render
12303
- *
12304
- * This function is used to setup basic upload form attributes
12305
- *
12306
- * @type function
12307
- * @date 12/04/2016
12308
- * @since 5.3.8
12309
- *
12310
- * @param n/a
12311
- * @return n/a
12312
- */
12313
-
12314
- render: function(){
12315
-
12316
- // bail ealry if no $switch
12317
- if( !this.$switch.exists() ) return;
12318
-
12319
 
12320
  // vars
12321
- var $on = this.$switch.children('.acf-switch-on'),
12322
- $off = this.$switch.children('.acf-switch-off')
12323
- width = Math.max( $on.width(), $off.width() );
12324
-
12325
-
12326
- // bail ealry if no width
12327
- if( !width ) return;
12328
-
12329
-
12330
- // set widths
12331
- $on.css( 'min-width', width );
12332
- $off.css( 'min-width', width );
12333
-
12334
- },
12335
-
12336
-
12337
- /*
12338
- * on
12339
- *
12340
- * description
12341
- *
12342
- * @type function
12343
- * @date 10/1/17
12344
- * @since 5.5.0
12345
- *
12346
- * @param $post_id (int)
12347
- * @return $post_id (int)
12348
- */
12349
-
12350
- on: function() { //console.log('on');
12351
 
12352
- this.$input.prop('checked', true);
12353
- this.$switch.addClass('-on');
12354
 
12355
- },
12356
-
12357
-
12358
- /*
12359
- * off
12360
- *
12361
- * description
12362
- *
12363
- * @type function
12364
- * @date 10/1/17
12365
- * @since 5.5.0
12366
- *
12367
- * @param $post_id (int)
12368
- * @return $post_id (int)
12369
- */
12370
-
12371
- off: function() { //console.log('off');
12372
 
12373
- this.$input.prop('checked', false);
12374
- this.$switch.removeClass('-on');
12375
 
 
 
12376
  },
12377
 
 
 
 
12378
 
12379
- /*
12380
- * change
12381
- *
12382
- * description
12383
- *
12384
- * @type function
12385
- * @date 12/10/16
12386
- * @since 5.4.0
12387
- *
12388
- * @param $post_id (int)
12389
- * @return $post_id (int)
12390
- */
12391
 
12392
- _change: function( e ){
12393
 
12394
  // vars
12395
- var checked = e.$el.prop('checked');
 
 
 
 
 
12396
 
 
 
 
 
12397
 
12398
- // enable
12399
- if( checked ) {
12400
-
12401
- this.on();
12402
 
12403
- // disable
12404
- } else {
12405
-
12406
- this.off();
12407
 
 
 
 
 
 
12408
  }
12409
-
 
 
12410
  },
12411
 
12412
-
12413
- /*
12414
- * _focus
12415
- *
12416
- * description
12417
- *
12418
- * @type function
12419
- * @date 10/1/17
12420
- * @since 5.5.0
12421
- *
12422
- * @param $post_id (int)
12423
- * @return $post_id (int)
12424
- */
12425
-
12426
- _focus: function( e ){
12427
 
12428
- this.$switch.addClass('-focus');
 
12429
 
12430
- },
12431
-
12432
-
12433
- /*
12434
- * _blur
12435
- *
12436
- * description
12437
- *
12438
- * @type function
12439
- * @date 10/1/17
12440
- * @since 5.5.0
12441
- *
12442
- * @param $post_id (int)
12443
- * @return $post_id (int)
12444
- */
12445
-
12446
- _blur: function( e ){
12447
 
12448
- this.$switch.removeClass('-focus');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12449
 
 
 
 
 
12450
  },
12451
 
12452
-
12453
- /*
12454
- * _keypress
12455
- *
12456
- * description
12457
- *
12458
- * @type function
12459
- * @date 10/1/17
12460
- * @since 5.5.0
12461
- *
12462
- * @param $post_id (int)
12463
- * @return $post_id (int)
12464
- */
12465
-
12466
- _keypress: function( e ){
12467
 
12468
- // left
12469
- if( e.keyCode === 37 ) {
 
 
 
 
 
 
 
 
 
 
 
12470
 
12471
- return this.off();
 
 
 
 
 
12472
 
12473
- }
12474
-
12475
 
12476
- // right
12477
- if( e.keyCode === 39 ) {
 
12478
 
12479
- return this.on();
 
 
 
12480
 
12481
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12482
 
 
 
 
 
 
 
 
 
 
12483
  }
12484
-
12485
  });
12486
-
12487
- })(jQuery);
12488
-
12489
- (function($){
12490
 
12491
- // taxonomy
12492
- acf.fields.taxonomy = acf.field.extend({
12493
-
12494
- type: 'taxonomy',
12495
- $el: null,
12496
-
12497
- actions: {
12498
- 'ready': 'render',
12499
- 'append': 'render',
12500
- 'remove': 'remove'
12501
- },
12502
- events: {
12503
- 'click a[data-name="add"]': 'add_term'
 
 
 
 
 
 
 
 
 
 
 
12504
  },
12505
 
12506
- focus: function(){
12507
-
12508
- // $el
12509
- this.$el = this.$field.find('.acf-taxonomy-field');
12510
 
 
 
 
 
 
 
 
 
 
 
 
 
12511
 
12512
- // get options
12513
- this.o = acf.get_data(this.$el, {
12514
- save: '',
12515
- type: '',
12516
- taxonomy: ''
 
 
 
 
 
 
 
 
 
 
 
 
12517
  });
12518
 
12519
-
12520
- // extra
12521
- this.o.key = this.$field.data('key');
12522
 
12523
  },
12524
 
12525
- render: function(){
12526
 
12527
- // attempt select2
12528
- var $select = this.$field.find('select');
12529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12530
 
12531
- // bail early if no select field
12532
- if( !$select.exists() ) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12533
 
12534
 
12535
- // select2 options
12536
- var args = acf.get_data( $select );
12537
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12538
 
12539
- // customize args
12540
- args = acf.parse_args(args, {
12541
- 'pagination': true,
12542
- 'ajax_action': 'acf/fields/taxonomy/query',
12543
- 'key': this.o.key
12544
  });
12545
-
12546
 
12547
- // add select2
12548
- acf.select2.init( $select, args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12549
 
 
 
12550
  },
12551
 
12552
- remove: function(){
12553
-
12554
- // attempt select2
12555
- var $select = this.$field.find('select');
12556
-
12557
-
12558
- // validate ui
12559
- if( !$select.exists() ) return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12560
 
 
 
 
 
12561
 
12562
- // remove select2
12563
- acf.select2.destroy( $select );
 
 
 
12564
 
 
 
 
 
 
12565
  },
12566
 
12567
- add_term: function( e ){
12568
-
12569
- // reference
12570
- var self = this;
12571
-
12572
-
12573
- // open popup
12574
- acf.open_popup({
12575
- title: e.$el.attr('title') || e.$el.data('title'),
12576
- loading: true,
12577
- height: 220
12578
- });
12579
-
12580
-
12581
-
12582
- // AJAX data
12583
- var ajax_data = acf.prepare_for_ajax({
12584
- action: 'acf/fields/taxonomy/add_term',
12585
- field_key: this.o.key
12586
- });
12587
 
 
 
 
 
12588
 
 
 
12589
 
12590
- // get HTML
12591
- $.ajax({
12592
- url: acf.get('ajaxurl'),
12593
- data: ajax_data,
12594
- type: 'post',
12595
- dataType: 'html',
12596
- success: function(html){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12597
 
12598
- self.add_term_confirm( html );
 
 
 
12599
 
 
 
 
 
 
12600
  }
12601
- });
12602
-
12603
-
12604
  },
12605
 
12606
- add_term_confirm: function( html ){
12607
-
12608
- // reference
12609
- var self = this;
12610
 
 
 
 
 
12611
 
12612
- // update popup
12613
- acf.update_popup({
12614
- content : html
12615
- });
12616
-
12617
-
12618
- // focus
12619
- $('#acf-popup input[name="term_name"]').focus();
12620
-
12621
 
12622
- // events
12623
- $('#acf-popup form').on('submit', function( e ){
 
12624
 
12625
- // prevent default
12626
- e.preventDefault();
12627
-
12628
-
12629
- // submit
12630
- self.add_term_submit( $(this ));
 
12631
 
12632
- });
12633
-
12634
  },
12635
 
12636
- add_term_submit: function( $form ){
12637
-
12638
- // reference
12639
- var self = this;
12640
 
 
 
 
 
12641
 
12642
  // vars
12643
- var $submit = $form.find('.acf-submit'),
12644
- $name = $form.find('input[name="term_name"]'),
12645
- $parent = $form.find('select[name="term_parent"]');
12646
-
12647
 
12648
- // basic validation
12649
- if( $name.val() === '' ) {
12650
-
12651
- $name.focus();
12652
- return false;
12653
 
12654
- }
12655
-
12656
-
12657
- // show loading
12658
- $submit.find('button').attr('disabled', 'disabled');
12659
- $submit.find('.acf-spinner').addClass('is-active');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12660
 
 
 
 
 
12661
 
12662
  // vars
12663
- var ajax_data = acf.prepare_for_ajax({
12664
- action: 'acf/fields/taxonomy/add_term',
12665
- field_key: this.o.key,
12666
- term_name: $name.val(),
12667
- term_parent: $parent.exists() ? $parent.val() : 0
12668
- });
12669
-
12670
 
12671
- // save term
12672
- $.ajax({
12673
- url: acf.get('ajaxurl'),
12674
- data: ajax_data,
12675
- type: 'post',
12676
- dataType: 'json',
12677
- success: function( json ){
12678
 
12679
  // vars
12680
- var message = acf.get_ajax_message(json);
12681
-
12682
-
12683
- // success
12684
- if( acf.is_ajax_success(json) ) {
12685
-
12686
- // clear name
12687
- $name.val('');
12688
-
12689
-
12690
- // update term lists
12691
- self.append_new_term( json.data );
12692
-
12693
- }
12694
-
12695
 
12696
- // message
12697
- if( message.text ) {
12698
 
12699
- $submit.find('span').html( message.text );
 
 
 
12700
 
 
 
 
 
 
12701
  }
 
 
 
12702
 
12703
  },
12704
- complete: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12705
 
12706
- // reset button
12707
- $submit.find('button').removeAttr('disabled');
12708
 
 
 
 
 
12709
 
12710
- // hide loading
12711
- $submit.find('.acf-spinner').removeClass('is-active');
12712
 
 
 
12713
 
12714
- // remove message
12715
- $submit.find('span').delay(1500).fadeOut(250, function(){
12716
 
12717
- $(this).html('');
12718
- $(this).show();
12719
 
12720
- });
12721
-
12722
-
12723
- // focus
12724
- $name.focus();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12725
 
 
 
12726
  }
12727
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12728
 
 
 
 
 
 
 
 
 
 
 
12729
  },
12730
 
12731
- append_new_term: function( term ){
12732
 
12733
  // vars
12734
- var item = {
12735
- id: term.term_id,
12736
- text: term.term_label
12737
- };
12738
-
12739
 
12740
- // append to all taxonomy lists
12741
- $('.acf-taxonomy-field[data-taxonomy="' + this.o.taxonomy + '"]').each(function(){
12742
 
12743
  // vars
12744
- var type = $(this).data('type');
 
 
 
 
12745
 
12746
 
12747
- // bail early if not checkbox/radio
12748
- if( type == 'radio' || type == 'checkbox' ) {
12749
-
12750
- // allow
12751
-
12752
- } else {
12753
 
12754
  return;
12755
 
12756
  }
12757
 
12758
 
12759
- // vars
12760
- var $hidden = $(this).children('input[type="hidden"]'),
12761
- $ul = $(this).find('ul:first'),
12762
- name = $hidden.attr('name');
12763
-
12764
-
12765
- // allow multiple selection
12766
- if( type == 'checkbox' ) {
12767
 
12768
- name += '[]';
12769
-
12770
- }
12771
-
12772
 
12773
- // create new li
12774
- var $li = $([
12775
- '<li data-id="' + term.term_id + '">',
12776
- '<label>',
12777
- '<input type="' + type + '" value="' + term.term_id + '" name="' + name + '" /> ',
12778
- '<span>' + term.term_label + '</span>',
12779
- '</label>',
12780
- '</li>'
12781
- ].join(''));
12782
 
12783
 
12784
- // find parent
12785
- if( term.term_parent ) {
12786
 
12787
- // vars
12788
- var $parent = $ul.find('li[data-id="' + term.term_parent + '"]');
12789
-
 
 
12790
 
12791
- // update vars
12792
- $ul = $parent.children('ul');
12793
 
 
 
 
 
 
 
 
12794
 
12795
- // create ul
12796
- if( !$ul.exists() ) {
12797
 
12798
- $ul = $('<ul class="children acf-bl"></ul>');
12799
 
12800
- $parent.append( $ul );
 
 
 
 
12801
 
12802
- }
 
 
 
 
 
 
 
 
 
12803
 
12804
  }
12805
-
12806
-
12807
- // append
12808
- $ul.append( $li );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12809
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12810
  });
12811
 
 
 
12812
 
12813
- // append to select
12814
- $('#acf-popup #term_parent').each(function(){
12815
-
12816
- // vars
12817
- var $option = $('<option value="' + term.term_id + '">' + term.term_label + '</option>');
12818
-
12819
- if( term.term_parent ) {
12820
-
12821
- $(this).children('option[value="' + term.term_parent + '"]').after( $option );
12822
-
12823
- } else {
12824
-
12825
- $(this).append( $option );
12826
-
12827
- }
12828
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12829
  });
12830
 
 
 
12831
 
12832
- // set value
12833
- switch( this.o.type ) {
 
12834
 
12835
- // select
12836
- case 'select':
12837
-
12838
- //this.$el.children('input').select2('data', item);
12839
-
12840
-
12841
- // vars
12842
- var $select = this.$el.children('select');
12843
- acf.select2.add_value($select, term.term_id, term.term_label);
12844
-
12845
-
12846
- break;
12847
 
12848
- case 'multi_select':
12849
-
12850
- /*
12851
- // vars
12852
- var $input = this.$el.children('input'),
12853
- value = $input.select2('data') || [];
12854
-
12855
-
12856
- // append
12857
- value.push( item );
12858
-
12859
-
12860
- // update
12861
- $input.select2('data', value);
12862
-
12863
-
12864
- */
12865
- // vars
12866
- var $select = this.$el.children('select');
12867
- acf.select2.add_value($select, term.term_id, term.term_label);
12868
-
12869
-
12870
- break;
12871
 
12872
- case 'checkbox':
12873
- case 'radio':
12874
-
12875
- // scroll to view
12876
- var $holder = this.$el.find('.categorychecklist-holder'),
12877
- $li = $holder.find('li[data-id="' + term.term_id + '"]'),
12878
- offet = $holder.get(0).scrollTop + ( $li.offset().top - $holder.offset().top );
12879
-
12880
 
12881
- // check input
12882
- $li.find('input').prop('checked', true);
12883
 
 
 
 
 
 
 
 
12884
 
12885
- // scroll to bottom
12886
- $holder.animate({scrollTop: offet}, '250');
12887
- break;
 
 
 
 
 
 
12888
 
12889
- }
12890
-
 
12891
 
12892
- }
12893
-
12894
- });
12895
-
12896
- })(jQuery);
12897
-
12898
- (function($){
12899
-
12900
- acf.fields.url = acf.field.extend({
12901
-
12902
- type: 'url',
12903
- $input: null,
12904
 
12905
- actions: {
12906
- 'ready': 'render',
12907
- 'append': 'render'
 
 
 
 
 
 
 
 
 
 
12908
 
 
 
12909
  },
12910
 
12911
- events: {
12912
- 'keyup input[type="url"]': 'render'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12913
  },
12914
 
12915
- focus: function(){
 
 
 
 
 
 
 
 
 
 
 
12916
 
12917
- this.$input = this.$field.find('input[type="url"]');
 
 
 
 
 
 
 
12918
 
 
 
12919
  },
12920
 
12921
- is_valid: function(){
12922
 
12923
  // vars
12924
- var val = this.$input.val();
12925
 
12926
-
12927
- if( val.indexOf('://') !== -1 ) {
12928
-
12929
- // url
12930
-
12931
- } else if( val.indexOf('//') === 0 ) {
12932
-
12933
- // protocol relative url
12934
-
12935
- } else {
12936
-
12937
- return false;
12938
-
12939
  }
12940
 
 
 
12941
 
12942
  // return
12943
- return true;
12944
-
12945
  },
12946
 
12947
- render: function(){
12948
 
12949
- // add class
12950
- if( this.is_valid() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12951
 
12952
- this.$input.parent().addClass('-valid');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12953
 
12954
- // remove class
12955
- } else {
 
 
 
 
 
 
12956
 
12957
- this.$input.parent().removeClass('-valid');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12958
 
 
 
 
 
12959
  }
12960
 
 
 
12961
 
12962
- }
12963
-
12964
- });
12965
-
12966
- })(jQuery);
12967
-
12968
- (function($){
12969
-
12970
- acf.validation = acf.model.extend({
12971
-
12972
- actions: {
12973
- 'ready': 'ready',
12974
- 'append': 'ready'
12975
- },
12976
-
12977
- filters: {
12978
- 'validation_complete': 'validation_complete'
12979
  },
12980
 
12981
- events: {
12982
- 'click #save-post': 'click_ignore',
12983
- 'click [type="submit"]': 'click_publish',
12984
- 'submit form': 'submit_form',
12985
- 'click .acf-error-message a': 'click_message'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12986
  },
12987
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12988
 
12989
- // vars
12990
- active: 1,
12991
- ignore: 0,
12992
- busy: 0,
12993
- valid: true,
12994
- errors: [],
12995
-
12996
-
12997
- // classes
12998
- error_class: 'acf-error',
12999
- message_class: 'acf-error-message',
13000
-
13001
-
13002
- // el
13003
- $trigger: null,
13004
-
13005
-
13006
- /*
13007
- * ready
13008
- *
13009
- * This function will add 'non bubbling' events
13010
- *
13011
- * @type function
13012
- * @date 26/05/2015
13013
- * @since 5.2.3
13014
- *
13015
- * @param $post_id (int)
13016
- * @return $post_id (int)
13017
- */
13018
-
13019
- ready: function( $el ){
13020
 
13021
  // vars
13022
- var $inputs = $('.acf-field input, .acf-field textarea, .acf-field select');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13023
 
 
 
13024
 
13025
- // bail early if no inputs
13026
- if( !$inputs.length ) return;
13027
 
 
 
 
 
 
 
 
 
13028
 
13029
- // reference
13030
- var self = this;
 
 
 
13031
 
 
 
 
13032
 
13033
- // event
13034
- $inputs.on('invalid', function( e ){
13035
 
13036
  // vars
13037
- var $input = $(this);
13038
- var $field = acf.get_field_wrap( $input );
13039
 
 
 
 
 
 
 
13040
 
13041
- // event
13042
- $field.trigger('invalidField');
13043
-
13044
-
13045
- // action
13046
- acf.do_action('invalid', $input);
13047
- acf.do_action('invalid_field', $field);
13048
-
13049
-
13050
- // save draft (ignore validation)
13051
- if( acf.validation.ignore ) return;
13052
-
13053
-
13054
- // prevent default
13055
- // - prevents browser error message
13056
- // - also fixes chrome bug where 'hidden-by-tab' field throws focus error
13057
- e.preventDefault();
13058
-
13059
-
13060
- // append to errors
13061
- acf.validation.errors.push({
13062
- input: $input.attr('name'),
13063
- message: e.target.validationMessage
13064
- });
13065
-
13066
 
13067
- // invalid event has prevented the form from submitting
13068
- // trigger acf validation fetch (safe to call multiple times)
13069
- acf.validation.fetch( $input.closest('form') );
13070
-
13071
  });
13072
 
13073
  },
13074
 
13075
-
13076
- /*
13077
- * validation_complete
13078
- *
13079
- * This function will modify the JSON response and add local 'invalid' errors
13080
- *
13081
- * @type function
13082
- * @date 26/05/2015
13083
- * @since 5.2.3
13084
- *
13085
- * @param $post_id (int)
13086
- * @return $post_id (int)
13087
- */
13088
-
13089
- validation_complete: function( json, $form ) {
13090
 
13091
- // bail early if no local errors
13092
- if( !this.errors.length ) return json;
 
 
 
13093
 
 
 
 
 
 
 
 
 
 
 
 
 
13094
 
13095
- // set valid
13096
- json.valid = 0;
 
 
 
13097
 
 
 
 
 
13098
 
13099
- // require array
13100
- json.errors = json.errors || [];
 
 
13101
 
 
 
 
 
 
 
 
 
 
13102
 
13103
  // vars
13104
- var inputs = [];
 
13105
 
 
 
13106
 
13107
- // populate inputs
13108
- if( json.errors.length ) {
13109
-
13110
- for( i in json.errors ) {
13111
-
13112
- inputs.push( json.errors[ i ].input );
13113
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13114
  }
 
13115
 
13116
- }
13117
-
13118
-
13119
  // append
13120
- if( this.errors.length ) {
13121
-
13122
- for( i in this.errors ) {
13123
-
13124
- // vars
13125
- var error = this.errors[ i ];
13126
-
13127
-
13128
- // bail ealry if alreay exists
13129
- if( $.inArray(error.input, inputs) !== -1 ) continue;
13130
-
13131
-
13132
- // append
13133
- json.errors.push( error );
13134
-
13135
- }
13136
-
13137
- }
13138
-
13139
 
13140
- // reset
13141
- this.errors = [];
 
13142
 
 
 
13143
 
13144
- // return
13145
- return json;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13146
 
13147
- },
 
 
 
13148
 
 
 
 
 
 
 
 
13149
 
13150
  /*
13151
- * click_message
13152
  *
13153
- * This function will dismiss the validation message
13154
  *
13155
  * @type function
13156
- * @date 26/05/2015
13157
- * @since 5.2.3
13158
  *
13159
  * @param $post_id (int)
13160
  * @return $post_id (int)
13161
  */
13162
 
13163
- click_message: function( e ) {
13164
 
13165
- e.preventDefault();
 
13166
 
13167
- acf.remove_el( e.$el.parent() );
 
 
 
 
13168
 
 
 
13169
  },
13170
 
13171
 
13172
  /*
13173
- * click_ignore
13174
  *
13175
- * This event is trigered via submit butons which ignore validation
13176
  *
13177
  * @type function
13178
- * @date 4/05/2015
13179
- * @since 5.2.3
13180
  *
13181
  * @param $post_id (int)
13182
  * @return $post_id (int)
13183
  */
13184
 
13185
- click_ignore: function( e ) {
13186
-
13187
- // reference
13188
- var self = this;
13189
 
13190
-
13191
- // vars
13192
- this.ignore = 1;
13193
- this.$trigger = e.$el;
13194
- this.$form = e.$el.closest('form');
13195
-
13196
-
13197
- // remove error message
13198
- $('.'+this.message_class).each(function(){
13199
- acf.remove_el( $(this) );
13200
  });
13201
 
 
 
 
 
13202
 
13203
- // ignore required inputs
13204
- this.ignore_required_inputs();
13205
-
13206
-
13207
- // maybe show errors
13208
- setTimeout(function(){
13209
- self.ignore = 0;
13210
- }, 100);
13211
-
13212
- },
13213
-
13214
-
13215
- /**
13216
- * ignore_required_inputs
13217
- *
13218
- * This function will temporarily remove the 'required' attribute from all ACF inputs
13219
- *
13220
- * @date 23/10/17
13221
- * @since 5.6.3
13222
- *
13223
- * @param n/a
13224
- * @return n/a
13225
- */
13226
-
13227
- ignore_required_inputs: function(){
13228
-
13229
- // vars
13230
- var $inputs = $('.acf-field input[required], .acf-field textarea[required], .acf-field select[required]');
13231
-
13232
-
13233
- // bail early if no inputs
13234
- if( !$inputs.length ) return;
13235
-
13236
-
13237
- // remove required
13238
- $inputs.prop('required', false);
13239
-
13240
-
13241
- // timeout
13242
- setTimeout(function(){
13243
- $inputs.prop('required', true);
13244
- }, 100);
13245
-
13246
  },
13247
 
13248
 
13249
  /*
13250
- * click_publish
13251
  *
13252
- * This event is trigered via submit butons which trigger validation
13253
  *
13254
  * @type function
13255
- * @date 4/05/2015
13256
- * @since 5.2.3
13257
  *
13258
  * @param $post_id (int)
13259
  * @return $post_id (int)
13260
  */
13261
 
13262
- click_publish: function( e ) {
13263
 
13264
- this.$trigger = e.$el;
 
 
 
 
 
13265
 
13266
- },
13267
-
13268
-
13269
- /*
13270
- * submit_form
13271
- *
13272
- * description
13273
- *
13274
- * @type function
13275
- * @date 4/05/2015
13276
- * @since 5.2.3
13277
- *
13278
- * @param $post_id (int)
13279
- * @return $post_id (int)
13280
- */
13281
-
13282
- submit_form: function( e ){
13283
 
13284
- // bail early if not active
13285
- if( !this.active ) {
 
 
13286
 
13287
- return true;
 
 
 
 
 
 
 
13288
 
 
 
 
13289
  }
13290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13291
 
13292
- // ignore validation (only ignore once)
13293
- if( this.ignore ) {
13294
 
13295
- this.ignore = 0;
13296
- return true;
13297
-
13298
- }
13299
 
 
 
 
 
13300
 
13301
- // bail early if this form does not contain ACF data
13302
- if( !e.$el.find('#acf-form-data').exists() ) {
13303
 
13304
- return true;
 
13305
 
13306
- }
 
13307
 
13308
-
13309
- // bail early if is preview
13310
- var $preview = e.$el.find('#wp-preview');
13311
- if( $preview.exists() && $preview.val() ) {
13312
 
13313
- // WP will lock form, unlock it
13314
- this.toggle( e.$el, 'unlock' );
13315
- return true;
 
13316
 
 
 
 
 
 
13317
  }
13318
-
13319
-
13320
- // prevent default
13321
- e.preventDefault();
13322
-
13323
-
13324
- // run validation
13325
- this.fetch( e.$el );
13326
-
13327
  },
13328
 
13329
-
13330
  /*
13331
- * lock
13332
  *
13333
- * description
13334
  *
13335
  * @type function
13336
- * @date 7/05/2015
13337
- * @since 5.2.3
13338
  *
13339
  * @param $post_id (int)
13340
  * @return $post_id (int)
13341
  */
13342
 
13343
- toggle: function( $form, state ){
13344
-
13345
- // defaults
13346
- state = state || 'unlock';
13347
-
13348
-
13349
- // debug
13350
- //console.log('toggle %o, %o %o', this.$trigger, $form, state);
13351
 
13352
  // vars
13353
- var $submit = null,
13354
- $spinner = null,
13355
- $parent = $('#submitdiv');
13356
-
13357
-
13358
- // 3rd party publish box
13359
- if( !$parent.exists() ) {
13360
-
13361
- $parent = $('#submitpost');
13362
-
13363
- }
13364
 
 
 
 
13365
 
13366
- // term, user
13367
- if( !$parent.exists() ) {
13368
-
13369
- $parent = $form.find('p.submit').last();
13370
-
13371
- }
13372
 
 
 
 
 
13373
 
13374
- // front end form
13375
- if( !$parent.exists() ) {
13376
-
13377
- $parent = $form.find('.acf-form-submit');
13378
-
13379
- }
13380
 
 
 
13381
 
13382
- // default
13383
- if( !$parent.exists() ) {
13384
-
13385
- $parent = $form;
13386
-
13387
  }
13388
 
 
 
13389
 
13390
- // find elements
13391
- // note: media edit page does not use .button, this is why we need to look for generic input[type="submit"]
13392
- $submit = $parent.find('input[type="submit"], .button');
13393
- $spinner = $parent.find('.spinner, .acf-spinner');
13394
-
13395
-
13396
- // hide all spinners (hides the preview spinner)
13397
- this.hide_spinner( $spinner );
13398
-
13399
-
13400
- // unlock
13401
- if( state == 'unlock' ) {
13402
-
13403
- this.enable_submit( $submit );
13404
-
13405
- // lock
13406
- } else if( state == 'lock' ) {
13407
-
13408
- // show only last spinner (allow all spinners to be hidden - preview spinner + submit spinner)
13409
- this.disable_submit( $submit );
13410
- this.show_spinner( $spinner.last() );
13411
-
13412
- }
13413
-
13414
  },
13415
 
13416
 
13417
  /*
13418
- * fetch
13419
  *
13420
- * description
13421
  *
13422
  * @type function
13423
- * @date 4/05/2015
13424
- * @since 5.2.3
13425
  *
13426
  * @param $post_id (int)
13427
  * @return $post_id (int)
13428
  */
13429
 
13430
- fetch: function( $form ){
13431
-
13432
- // bail aelry if already busy
13433
- if( this.busy ) return false;
13434
 
 
 
13435
 
13436
- // reference
13437
- var self = this;
13438
-
 
 
 
 
13439
 
13440
- // action for 3rd party
13441
- acf.do_action('validation_begin');
13442
-
13443
-
13444
- // vars
13445
- var data = acf.serialize($form);
13446
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13447
 
13448
- // append AJAX action
13449
- data.action = 'acf/validate_save_post';
 
 
 
 
 
 
 
 
 
 
 
 
 
13450
 
 
 
13451
 
13452
- // prepare
13453
- data = acf.prepare_for_ajax(data);
13454
 
 
 
13455
 
13456
- // set busy
13457
- this.busy = 1;
13458
 
 
 
13459
 
13460
- // lock form
13461
- this.toggle( $form, 'lock' );
 
 
 
 
 
 
 
13462
 
 
 
13463
 
13464
- // ajax
13465
- $.ajax({
13466
- url: acf.get('ajaxurl'),
13467
- data: data,
13468
- type: 'post',
13469
- dataType: 'json',
13470
- success: function( json ){
13471
-
13472
- // bail early if not json success
13473
- if( !acf.is_ajax_success(json) ) {
13474
-
13475
- return;
13476
 
13477
- }
13478
-
13479
-
13480
- self.fetch_success( $form, json.data );
13481
-
13482
- },
13483
- complete: function(){
13484
-
13485
- self.fetch_complete( $form );
13486
-
13487
- }
13488
- });
13489
 
13490
- },
13491
-
 
 
 
 
13492
 
13493
- /*
13494
- * fetch_complete
13495
- *
13496
- * description
13497
- *
13498
- * @type function
13499
- * @date 4/05/2015
13500
- * @since 5.2.3
13501
- *
13502
- * @param $post_id (int)
13503
- * @return $post_id (int)
13504
- */
13505
 
13506
- fetch_complete: function( $form ){
13507
-
13508
- // set busy
13509
- this.busy = 0;
13510
-
13511
 
13512
- // unlock so WP can publish form
13513
- this.toggle( $form, 'unlock' );
13514
 
 
 
 
 
 
 
13515
 
13516
- // bail early if validationw as not valid
13517
- if( !this.valid ) return;
13518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13519
 
13520
- // update ignore (allow form submit to not run validation)
13521
- this.ignore = 1;
13522
-
13523
-
13524
- // remove previous error message
13525
- var $message = $form.children('.acf-error-message');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13526
 
13527
- if( $message.exists() ) {
13528
-
13529
- $message.addClass('-success');
13530
- $message.children('p').html( acf._e('validation_successful') );
13531
-
13532
-
13533
- // remove message
13534
- setTimeout(function(){
13535
-
13536
- acf.remove_el( $message );
13537
-
13538
- }, 2000);
13539
-
13540
  }
13541
-
13542
 
13543
- // remove hidden postboxes (this will stop them from being posted to save)
13544
- $form.find('.acf-postbox.acf-hidden').remove();
13545
-
13546
-
13547
- // action for 3rd party customization
13548
- acf.do_action('submit', $form);
13549
-
13550
-
13551
- // submit form again
13552
- if( this.$trigger ) {
13553
-
13554
- this.$trigger.click();
13555
-
13556
- } else {
13557
-
13558
- $form.submit();
13559
 
 
 
 
 
13560
  }
13561
 
 
 
13562
 
13563
- // lock form
13564
- this.toggle( $form, 'lock' );
13565
-
13566
  },
13567
 
 
 
 
13568
 
13569
- /*
13570
- * fetch_success
13571
- *
13572
- * description
13573
- *
13574
- * @type function
13575
- * @date 4/05/2015
13576
- * @since 5.2.3
13577
- *
13578
- * @param $post_id (int)
13579
- * @return $post_id (int)
13580
- */
 
 
 
 
 
 
 
 
13581
 
13582
- fetch_success: function( $form, json ){
 
 
 
 
 
 
 
 
 
 
 
 
13583
 
13584
- // filter for 3rd party customization
13585
- json = acf.apply_filters('validation_complete', json, $form);
13586
-
13587
 
13588
- // validate json
13589
- if( !json || json.valid || !json.errors ) {
13590
-
13591
- // set valid (allows fetch_complete to run)
13592
- this.valid = true;
13593
-
13594
 
13595
- // action for 3rd party
13596
- acf.do_action('validation_success');
13597
-
13598
 
13599
- // end function
13600
- return;
 
 
13601
 
13602
- }
13603
-
13604
- // set valid (prevents fetch_complete from runing)
13605
- this.valid = false;
13606
-
13607
-
13608
- // reset trigger
13609
- this.$trigger = null;
13610
-
13611
-
13612
- // display errors
13613
- this.display_errors( json.errors, $form );
13614
-
13615
-
13616
- // action
13617
- acf.do_action('validation_failure');
13618
 
 
 
13619
  },
13620
 
 
 
 
 
 
 
 
13621
 
13622
- /**
13623
- * display_errors
13624
- *
13625
- * This function will display errors
13626
- *
13627
- * @date 23/10/17
13628
- * @since 5.6.3
13629
- *
13630
- * @param array errors
13631
- * @return n/a
13632
- */
13633
-
13634
- display_errors: function( errors, $form ){
13635
 
13636
  // bail early if no errors
13637
- if( !errors || !errors.length ) return;
13638
-
 
13639
 
13640
  // vars
13641
- var $message = $form.children('.acf-error-message');
13642
- var message = acf._e('validation_failed');
13643
- var count = 0;
13644
- var $scrollTo = null;
13645
 
 
 
 
13646
 
13647
  // loop
13648
- for( i = 0; i < errors.length; i++ ) {
13649
-
13650
- // vars
13651
- var error = errors[ i ];
13652
-
13653
-
13654
- // general error
13655
- if( !error.input ) {
13656
- message += '. ' + error.message;
13657
- continue;
13658
- }
13659
-
13660
 
13661
  // get input
13662
  var $input = $form.find('[name="' + error.input + '"]').first();
13663
 
13664
-
13665
  // if $_POST value was an array, this $input may not exist
13666
  if( !$input.exists() ) {
13667
  $input = $form.find('[name^="' + error.input + '"]').first();
13668
  }
13669
 
13670
-
13671
  // bail early if input doesn't exist
13672
- if( !$input.exists() ) continue;
13673
-
 
13674
 
13675
  // increase
13676
- count++;
13677
 
 
 
13678
 
13679
- // now get field
13680
- var $field = acf.get_field_wrap( $input );
13681
-
13682
-
13683
- // add error
13684
- this.add_error( $field, error.message );
13685
-
13686
 
13687
  // set $scrollTo
13688
- if( $scrollTo === null ) {
13689
- $scrollTo = $field;
13690
  }
13691
-
13692
- }
13693
-
13694
 
13695
- // message
13696
- if( count == 1 ) {
13697
- message += '. ' + acf._e('validation_failed_1');
13698
- } else if( count > 1 ) {
13699
- message += '. ' + acf._e('validation_failed_2').replace('%d', count);
 
13700
  }
13701
 
13702
-
13703
- // maybe create $message
13704
- if( !$message.exists() ) {
13705
- $message = $('<div class="acf-error-message"><p></p><a href="#" class="acf-icon -cancel small"></a></div>');
13706
- $form.prepend( $message );
 
 
 
 
 
 
 
13707
  }
13708
 
13709
-
13710
- // update message
13711
- $message.children('p').html( message );
13712
-
13713
-
13714
  // if no $scrollTo, set to message
13715
- if( $scrollTo === null ) {
13716
- $scrollTo = $message;
13717
  }
13718
 
13719
-
13720
  // timeout
13721
  setTimeout(function(){
13722
  $("html, body").animate({ scrollTop: $scrollTo.offset().top - ( $(window).height() / 2 ) }, 500);
13723
  }, 10);
13724
-
13725
  },
13726
 
13727
-
13728
- /*
13729
- * add_error
13730
- *
13731
- * This function will add error markup to a field
13732
- *
13733
- * @type function
13734
- * @date 4/05/2015
13735
- * @since 5.2.3
13736
- *
13737
- * @param $field (jQuery)
13738
- * @param message (string)
13739
- * @return n/a
13740
- */
13741
-
13742
- add_error: function( $field, message ){
13743
-
13744
- // reference
13745
- var self = this;
13746
-
13747
-
13748
- // add class
13749
- $field.addClass(this.error_class);
13750
-
13751
-
13752
- // add message
13753
- if( message !== undefined ) {
13754
-
13755
- $field.children('.acf-input').children('.' + this.message_class).remove();
13756
- $field.children('.acf-input').prepend('<div class="' + this.message_class + '"><p>' + message + '</p></div>');
13757
 
 
 
 
13758
  }
13759
 
13760
-
13761
- // add event
13762
- var event = function(){
 
 
13763
 
13764
- // remove error
13765
- self.remove_error( $field );
13766
-
13767
 
13768
- // remove self
13769
- $field.off('focus change', 'input, textarea, select', event);
13770
 
13771
- }
13772
-
13773
- $field.on('focus change', 'input, textarea, select', event);
13774
-
13775
-
13776
- // event
13777
- $field.trigger('invalidField');
13778
 
 
 
13779
 
13780
- // hook for 3rd party customization
13781
- acf.do_action('add_field_error', $field);
13782
- acf.do_action('invalid_field', $field);
 
 
 
 
 
 
 
 
13783
 
13784
- },
13785
-
13786
-
13787
- /*
13788
- * remove_error
13789
- *
13790
- * This function will remove error markup from a field
13791
- *
13792
- * @type function
13793
- * @date 4/05/2015
13794
- * @since 5.2.3
13795
- *
13796
- * @param $field (jQuery)
13797
- * @return n/a
13798
- */
13799
-
13800
- remove_error: function( $field ){
13801
 
13802
- // var
13803
- var $message = $field.children('.acf-input').children('.' + this.message_class);
 
 
 
 
 
 
 
13804
 
 
 
 
 
 
 
13805
 
13806
- // remove class
13807
- $field.removeClass(this.error_class);
13808
 
 
 
13809
 
13810
- // remove message
13811
- setTimeout(function(){
13812
 
13813
- acf.remove_el( $message );
 
 
 
13814
 
13815
- }, 250);
13816
-
13817
-
13818
- // hook for 3rd party customization
13819
- acf.do_action('remove_field_error', $field);
13820
- acf.do_action('valid_field', $field);
13821
-
13822
- },
13823
-
13824
-
13825
- /*
13826
- * add_warning
13827
- *
13828
- * This functino will add and auto remove an error message to a field
13829
- *
13830
- * @type function
13831
- * @date 4/05/2015
13832
- * @since 5.2.3
13833
- *
13834
- * @param $field (jQuery)
13835
- * @param message (string)
13836
- * @return n/a
13837
- */
13838
-
13839
- add_warning: function( $field, message ){
13840
-
13841
- this.add_error( $field, message );
13842
 
13843
- setTimeout(function(){
 
13844
 
13845
- acf.validation.remove_error( $field )
 
13846
 
13847
- }, 1000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13848
 
 
 
 
 
 
 
 
 
 
 
13849
  },
13850
 
13851
-
13852
- /*
13853
- * show_spinner
13854
- *
13855
- * This function will show a spinner element. Logic changed in WP 4.2
13856
- *
13857
- * @type function
13858
- * @date 3/05/2015
13859
- * @since 5.2.3
13860
- *
13861
- * @param $spinner (jQuery)
13862
- * @return n/a
13863
- */
13864
-
13865
- show_spinner: function( $spinner ){
13866
 
13867
- // bail early if no spinner
13868
- if( !$spinner.exists() ) {
13869
-
13870
- return;
13871
-
13872
- }
13873
 
 
 
 
 
 
 
 
13874
 
13875
  // vars
13876
- var wp_version = acf.get('wp_version');
13877
 
 
 
 
 
 
13878
 
13879
- // show
13880
- if( parseFloat(wp_version) >= 4.2 ) {
13881
-
13882
- $spinner.addClass('is-active');
13883
 
13884
- } else {
13885
-
13886
- $spinner.css('display', 'inline-block');
 
 
 
13887
 
13888
- }
 
 
 
 
13889
 
 
 
13890
  },
13891
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13892
 
13893
- /*
13894
- * hide_spinner
13895
- *
13896
- * This function will hide a spinner element. Logic changed in WP 4.2
13897
- *
13898
- * @type function
13899
- * @date 3/05/2015
13900
- * @since 5.2.3
13901
- *
13902
- * @param $spinner (jQuery)
13903
- * @return n/a
13904
- */
 
 
 
 
 
13905
 
13906
- hide_spinner: function( $spinner ){
13907
 
13908
- // bail early if no spinner
13909
- if( !$spinner.exists() ) {
13910
-
13911
- return;
13912
-
13913
  }
13914
 
 
 
 
 
 
13915
 
13916
- // vars
13917
- var wp_version = acf.get('wp_version');
13918
-
13919
-
13920
- // hide
13921
- if( parseFloat(wp_version) >= 4.2 ) {
13922
-
13923
- $spinner.removeClass('is-active');
13924
-
13925
- } else {
13926
-
13927
- $spinner.css('display', 'none');
13928
 
 
 
 
 
13929
  }
13930
 
 
 
13931
  },
13932
 
13933
-
13934
- /*
13935
- * disable_submit
13936
- *
13937
- * This function will disable the $trigger is possible
13938
- *
13939
- * @type function
13940
- * @date 3/05/2015
13941
- * @since 5.2.3
13942
- *
13943
- * @param $spinner (jQuery)
13944
- * @return n/a
13945
- */
13946
-
13947
- disable_submit: function( $submit ){
13948
 
13949
- // bail early if no submit
13950
- if( !$submit.exists() ) {
13951
-
13952
- return;
13953
-
13954
- }
 
13955
 
 
 
 
 
 
 
13956
 
13957
- // add class
13958
- $submit.addClass('disabled button-disabled button-primary-disabled');
 
 
13959
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13960
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13961
 
 
 
 
 
 
13962
 
13963
- /*
13964
- * enable_submit
13965
- *
13966
- * This function will enable the $trigger is possible
13967
- *
13968
- * @type function
13969
- * @date 3/05/2015
13970
- * @since 5.2.3
13971
- *
13972
- * @param $spinner (jQuery)
13973
- * @return n/a
13974
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13975
 
13976
- enable_submit: function( $submit ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13977
 
13978
- // bail early if no submit
13979
- if( !$submit.exists() ) {
13980
 
13981
- return;
 
13982
 
 
 
 
 
 
 
 
 
 
 
13983
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13984
 
 
 
 
 
 
13985
 
13986
- // remove class
13987
- $submit.removeClass('disabled button-disabled button-primary-disabled');
13988
-
 
13989
  }
13990
-
13991
  });
13992
-
13993
- })(jQuery);
13994
-
13995
- (function($){
13996
 
13997
- acf.fields.wysiwyg = acf.field.extend({
 
 
 
 
 
 
 
 
 
 
 
 
13998
 
13999
- type: 'wysiwyg',
14000
- $el: null,
14001
- $textarea: null,
14002
- toolbars: {},
14003
 
14004
- events: {
14005
- 'mousedown .acf-editor-wrap.delay': 'mousedown'
14006
- },
14007
 
14008
  actions: {
14009
- 'load': 'initialize',
14010
- 'append': 'initialize',
14011
- 'remove': 'disable',
14012
- 'sortstart': 'disable',
14013
- 'sortstop': 'enable'
14014
  },
14015
 
14016
- focus: function(){
14017
-
14018
- // get elements
14019
- this.$el = this.$field.find('.wp-editor-wrap').last();
14020
- this.$textarea = this.$el.find('textarea');
14021
-
14022
 
14023
- // get options
14024
- this.o = acf.get_data(this.$el, {
14025
- toolbar: '',
14026
- active: this.$el.hasClass('tmce-active'),
14027
- id: this.$textarea.attr('id')
14028
  });
14029
-
14030
- },
14031
-
14032
- mousedown: function(e){
14033
-
14034
- // prevent default
14035
- e.preventDefault();
14036
-
14037
-
14038
- // remove delay class
14039
- this.$el.removeClass('delay');
14040
- this.$el.find('.acf-editor-toolbar').remove();
14041
-
14042
-
14043
- // initialize
14044
- this.initialize();
14045
-
14046
  },
14047
 
14048
- initialize: function(){
14049
-
14050
- // bail early if delay
14051
- if( this.$el.hasClass('delay') ) return;
14052
-
14053
 
14054
  // vars
14055
- var args = {
14056
- tinymce: true,
14057
- quicktags: true,
14058
- toolbar: this.o.toolbar,
14059
- mode: this.o.active ? 'visual' : 'text',
14060
- };
14061
-
14062
 
14063
- // generate new id
14064
- var old_id = this.o.id,
14065
- new_id = acf.get_uniqid('acf-editor-'),
14066
- html = this.$el.outerHTML();
14067
-
14068
-
14069
- // replace
14070
- html = acf.str_replace( old_id, new_id, html );
14071
 
14072
 
14073
- // swap
14074
- this.$el.replaceWith( html );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14075
 
14076
 
14077
- // update id
14078
- this.o.id = new_id;
14079
 
14080
-
14081
- // initialize
14082
- acf.tinymce.initialize( this.o.id, args, this.$field );
14083
 
14084
- },
14085
-
14086
- disable: function(){
14087
 
14088
- acf.tinymce.destroy( this.o.id );
 
 
 
 
 
 
14089
 
14090
- },
14091
-
14092
- enable: function(){
 
 
 
 
14093
 
14094
- if( this.o.active ) {
14095
- acf.tinymce.enable( this.o.id );
 
14096
  }
14097
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14098
  }
14099
-
14100
  });
14101
 
14102
 
14103
- /*
14104
- * acf.tinymce
14105
  *
14106
  * description
14107
  *
14108
- * @type function
14109
- * @date 18/8/17
14110
- * @since 5.6.0
14111
  *
14112
- * @param $post_id (int)
14113
- * @return $post_id (int)
14114
  */
14115
 
14116
- acf.tinymce = acf.model.extend({
14117
 
14118
- toolbars: {},
 
 
14119
 
14120
  actions: {
14121
- 'ready': 'ready'
14122
  },
14123
 
14124
-
14125
- /*
14126
- * ready
14127
- *
14128
- * This function will move the acf-hidden-wp-editor and fix the activeEditor
14129
- *
14130
- * @type function
14131
- * @date 18/8/17
14132
- * @since 5.6.0
14133
- *
14134
- * @param $post_id (int)
14135
- * @return $post_id (int)
14136
- */
14137
-
14138
- ready: function(){
14139
-
14140
- // vars
14141
- var $div = $('#acf-hidden-wp-editor');
14142
 
 
 
 
 
 
 
 
 
14143
 
14144
- // bail early if doesn't exist
14145
- if( !$div.exists() ) return;
14146
-
 
14147
 
14148
- // move to footer
14149
- $div.appendTo('body');
14150
 
 
 
 
 
14151
 
14152
- // bail early if no tinymce
14153
- if( !acf.isset(window,'tinymce','on') ) return;
 
 
 
 
14154
 
 
 
14155
 
14156
- // restore default activeEditor
14157
- tinymce.on('AddEditor', function( data ){
14158
 
14159
  // vars
14160
- var editor = data.editor;
 
 
 
14161
 
 
 
 
 
 
 
 
 
 
 
14162
 
14163
- // bail early if not 'acf'
14164
- if( editor.id.substr(0, 3) !== 'acf' ) return;
 
 
 
14165
 
 
 
 
 
 
 
14166
 
14167
- // override if 'content' exists
14168
- editor = tinymce.editors.content || editor;
 
14169
 
 
 
14170
 
14171
- // update vars
14172
- tinymce.activeEditor = editor;
14173
- wpActiveEditor = editor.id;
14174
 
 
 
14175
  });
14176
 
14177
- },
 
 
 
 
 
14178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14179
 
14180
- /*
14181
- * defaults
14182
- *
14183
- * This function will return default mce and qt settings
14184
- *
14185
- * @type function
14186
- * @date 18/8/17
14187
- * @since 5.6.0
14188
- *
14189
- * @param $post_id (int)
14190
- * @return $post_id (int)
14191
- */
14192
 
14193
- defaults: function(){
14194
-
14195
- // bail early if no tinyMCEPreInit
14196
- if( typeof tinyMCEPreInit === 'undefined' ) return false;
14197
-
14198
-
14199
- // vars
14200
- var defaults = {
14201
- tinymce: tinyMCEPreInit.mceInit.acf_content,
14202
- quicktags: tinyMCEPreInit.qtInit.acf_content
14203
- };
14204
-
14205
-
14206
- // return
14207
- return defaults;
14208
-
14209
- },
14210
 
 
 
14211
 
14212
- /*
14213
- * initialize
14214
- *
14215
- * This function will initialize the tinymce and quicktags instances
14216
- *
14217
- * @type function
14218
- * @date 18/8/17
14219
- * @since 5.6.0
14220
- *
14221
- * @param $post_id (int)
14222
- * @return $post_id (int)
14223
- */
14224
 
14225
- initialize: function( id, args, $field ){
14226
-
14227
- // defaults
14228
- args = args || {};
14229
- $field = $field || null;
14230
-
14231
-
14232
- // merge
14233
- args = acf.parse_args(args, {
14234
- tinymce: true,
14235
- quicktags: true,
14236
- toolbar: 'full',
14237
- mode: 'visual', // visual,text
14238
- });
14239
-
14240
-
14241
- // tinymce
14242
- if( args.tinymce ) {
14243
- this.initialize_tinymce( id, args, $field );
14244
- }
14245
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14246
 
14247
- // quicktags
14248
- if( args.quicktags ) {
14249
- this.initialize_quicktags( id, args, $field );
 
 
 
 
 
 
 
 
 
 
 
14250
  }
 
 
 
 
14251
 
14252
- },
 
14253
 
 
 
14254
 
14255
- /*
14256
- * initialize_tinymce
14257
- *
14258
- * This function will initialize the tinymce instance
14259
- *
14260
- * @type function
14261
- * @date 18/8/17
14262
- * @since 5.6.0
14263
- *
14264
- * @param $post_id (int)
14265
- * @return $post_id (int)
14266
- */
14267
 
14268
- initialize_tinymce: function( id, args, $field ){
14269
-
14270
- // vars
14271
- var $textarea = $('#'+id);
14272
- var defaults = this.defaults();
14273
- var toolbars = this.toolbars;
14274
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14275
 
14276
- // bail early
14277
- if( typeof tinymce === 'undefined' ) return false;
14278
- if( !defaults ) return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14279
 
 
 
 
14280
 
14281
- // check if exists
14282
- if( tinymce.get(id) ) {
14283
- return this.enable( id );
14284
  }
14285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14286
 
14287
- // settings
14288
- init = $.extend( {}, defaults.tinymce, args.tinymce );
14289
- init.id = id;
14290
- init.selector = '#' + id;
14291
-
14292
 
14293
- // toolbar
14294
- var toolbar = args.toolbar;
14295
- if( toolbar && typeof toolbars[toolbar] !== 'undefined' ) {
14296
-
14297
- for( var i = 1; i <= 4; i++ ) {
14298
- init[ 'toolbar' + i ] = toolbars[toolbar][i] || '';
14299
- }
14300
-
14301
- }
14302
 
 
 
 
 
14303
 
14304
- // event
14305
- init.setup = function( ed ){
14306
-
14307
- ed.on('focus', function(e) {
14308
- acf.validation.remove_error( $field );
14309
- });
14310
-
14311
- ed.on('change', function(e) {
14312
- ed.save(); // save to textarea
14313
- $textarea.trigger('change');
14314
- });
14315
-
14316
- $( ed.getWin() ).on('unload', function() {
14317
- acf.tinymce.remove( id );
14318
- });
14319
-
14320
- };
14321
 
 
 
 
 
 
14322
 
14323
- // disable wp_autoresize_on (no solution yet for fixed toolbar)
14324
- init.wp_autoresize_on = false;
 
14325
 
 
 
 
14326
 
14327
- // hook for 3rd party customization
14328
- init = acf.apply_filters('wysiwyg_tinymce_settings', init, id, $field);
14329
 
 
 
 
14330
 
14331
- // z-index fix (caused too many conflicts)
14332
- //if( acf.isset(tinymce,'ui','FloatPanel') ) {
14333
- // tinymce.ui.FloatPanel.zIndex = 900000;
14334
- //}
14335
 
 
 
 
14336
 
14337
- // store settings
14338
- tinyMCEPreInit.mceInit[ id ] = init;
 
 
 
14339
 
 
 
 
 
 
14340
 
14341
- // visual tab is active
14342
- if( args.mode == 'visual' ) {
14343
-
14344
- // init
14345
- tinymce.init( init );
14346
 
 
 
14347
 
14348
- // get editor
14349
- var ed = tinymce.get( id );
 
 
14350
 
 
 
 
 
14351
 
14352
- // action
14353
- acf.do_action('wysiwyg_tinymce_init', ed, ed.id, init, $field);
14354
 
14355
- }
14356
 
 
 
 
 
 
 
14357
  },
14358
 
14359
-
14360
- /*
14361
- * initialize_quicktags
14362
- *
14363
- * This function will initialize the quicktags instance
14364
- *
14365
- * @type function
14366
- * @date 18/8/17
14367
- * @since 5.6.0
14368
- *
14369
- * @param $post_id (int)
14370
- * @return $post_id (int)
14371
- */
14372
-
14373
- initialize_quicktags: function( id, args, $field ){
14374
-
14375
- // vars
14376
- var defaults = this.defaults();
14377
-
14378
-
14379
- // bail early
14380
- if( typeof quicktags === 'undefined' ) return false;
14381
- if( !defaults ) return false;
14382
-
14383
-
14384
- // settings
14385
- init = $.extend( {}, defaults.quicktags, args.quicktags );
14386
- init.id = id;
14387
-
14388
-
14389
- // filter
14390
- init = acf.apply_filters('wysiwyg_quicktags_settings', init, init.id, $field);
14391
-
14392
-
14393
- // store settings
14394
- tinyMCEPreInit.qtInit[ id ] = init;
14395
-
14396
-
14397
- // init
14398
- var ed = quicktags( init );
14399
-
14400
 
14401
- // generate HTML
14402
- this.build_quicktags( ed );
14403
 
 
 
 
 
14404
 
14405
- // action for 3rd party customization
14406
- acf.do_action('wysiwyg_quicktags_init', ed, ed.id, init, $field);
14407
-
14408
  },
14409
 
14410
-
14411
- /*
14412
- * build_quicktags
14413
- *
14414
- * This function will build the quicktags HTML
14415
- *
14416
- * @type function
14417
- * @date 18/8/17
14418
- * @since 5.6.0
14419
- *
14420
- * @param $post_id (int)
14421
- * @return $post_id (int)
14422
- */
14423
-
14424
- build_quicktags: function( ed ){
14425
-
14426
- var canvas, name, settings, theButtons, html, ed, id, i, use, instanceId,
14427
- defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
14428
-
14429
- canvas = ed.canvas;
14430
- name = ed.name;
14431
- settings = ed.settings;
14432
- html = '';
14433
- theButtons = {};
14434
- use = '';
14435
- instanceId = ed.id;
14436
 
14437
- // set buttons
14438
- if ( settings.buttons ) {
14439
- use = ','+settings.buttons+',';
14440
- }
14441
-
14442
- for ( i in edButtons ) {
14443
- if ( ! edButtons[i] ) {
14444
- continue;
14445
- }
14446
-
14447
- id = edButtons[i].id;
14448
- if ( use && defaults.indexOf( ',' + id + ',' ) !== -1 && use.indexOf( ',' + id + ',' ) === -1 ) {
14449
- continue;
14450
- }
14451
-
14452
- if ( ! edButtons[i].instance || edButtons[i].instance === instanceId ) {
14453
- theButtons[id] = edButtons[i];
14454
-
14455
- if ( edButtons[i].html ) {
14456
- html += edButtons[i].html( name + '_' );
14457
- }
14458
- }
14459
- }
14460
-
14461
- if ( use && use.indexOf(',dfw,') !== -1 ) {
14462
- theButtons.dfw = new QTags.DFWButton();
14463
- html += theButtons.dfw.html( name + '_' );
14464
- }
14465
-
14466
- if ( 'rtl' === document.getElementsByTagName( 'html' )[0].dir ) {
14467
- theButtons.textdirection = new QTags.TextDirectionButton();
14468
- html += theButtons.textdirection.html( name + '_' );
14469
- }
14470
-
14471
- ed.toolbar.innerHTML = html;
14472
- ed.theButtons = theButtons;
14473
-
14474
- if ( typeof jQuery !== 'undefined' ) {
14475
- jQuery( document ).triggerHandler( 'quicktags-init', [ ed ] );
14476
- }
14477
 
14478
- },
14479
-
14480
- disable: function( id ){
 
14481
 
14482
- this.destroy( id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14483
 
14484
- },
14485
-
14486
- destroy: function( id ){
14487
 
14488
- this.destroy_tinymce( id );
 
14489
 
 
 
 
 
 
 
 
 
 
14490
  },
14491
 
14492
- destroy_tinymce: function( id ){
14493
 
14494
- // bail early
14495
- if( typeof tinymce === 'undefined' ) return false;
14496
 
 
 
14497
 
14498
- // get editor
14499
- var ed = tinymce.get( id );
14500
 
 
 
 
 
 
 
 
 
 
14501
 
14502
- // bail early if no editor
14503
- if( !ed ) return false;
14504
-
14505
-
14506
- // save
14507
- ed.save();
14508
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14509
 
14510
- // destroy editor
14511
- ed.destroy();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14512
 
 
 
 
 
14513
 
14514
  // return
14515
- return true;
 
 
 
14516
 
 
 
 
 
 
14517
  },
14518
 
14519
- enable: function( id ){
14520
 
14521
- this.enable_tinymce( id );
 
 
 
 
 
 
 
 
 
 
 
 
 
14522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14523
  },
14524
 
14525
- enable_tinymce: function( id ){
14526
 
14527
- // bail early
14528
- if( typeof switchEditors === 'undefined' ) return false;
 
 
 
 
 
14529
 
 
 
14530
 
14531
- // bail ealry if not initialized
14532
- if( typeof tinyMCEPreInit.mceInit[ id ] === 'undefined' ) return false;
 
 
 
 
14533
 
14534
-
14535
- // toggle
14536
- switchEditors.go( id, 'tmce');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14537
 
 
 
 
 
 
 
 
 
 
 
14538
 
14539
  // return
14540
- return true;
14541
-
14542
  },
14543
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14544
  });
 
14545
 
14546
-
14547
  })(jQuery);
14548
 
14549
- // @codekit-prepend "../js/event-manager.js";
14550
  // @codekit-prepend "../js/acf.js";
14551
- // @codekit-prepend "../js/acf-ajax.js";
14552
- // @codekit-prepend "../js/acf-button-group.js";
14553
- // @codekit-prepend "../js/acf-checkbox.js";
14554
- // @codekit-prepend "../js/acf-color-picker.js";
14555
- // @codekit-prepend "../js/acf-conditional-logic.js";
14556
- // @codekit-prepend "../js/acf-date-picker.js";
14557
- // @codekit-prepend "../js/acf-date-time-picker.js";
14558
- // @codekit-prepend "../js/acf-file.js";
14559
- // @codekit-prepend "../js/acf-google-map.js";
14560
- // @codekit-prepend "../js/acf-image.js";
14561
- // @codekit-prepend "../js/acf-link.js";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14562
  // @codekit-prepend "../js/acf-media.js";
14563
- // @codekit-prepend "../js/acf-oembed.js";
14564
- // @codekit-prepend "../js/acf-radio.js";
14565
- // @codekit-prepend "../js/acf-range.js";
14566
- // @codekit-prepend "../js/acf-relationship.js";
14567
  // @codekit-prepend "../js/acf-select2.js";
14568
- // @codekit-prepend "../js/acf-select.js";
14569
- // @codekit-prepend "../js/acf-accordion.js";
14570
- // @codekit-prepend "../js/acf-tab.js";
14571
- // @codekit-prepend "../js/acf-time-picker.js";
14572
- // @codekit-prepend "../js/acf-true-false.js";
14573
- // @codekit-prepend "../js/acf-taxonomy.js";
14574
- // @codekit-prepend "../js/acf-url.js";
14575
  // @codekit-prepend "../js/acf-validation.js";
14576
- // @codekit-prepend "../js/acf-wysiwyg.js";
 
 
14577
 
1
+ (function($, undefined){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ /**
4
+ * acf
5
+ *
6
+ * description
7
+ *
8
+ * @date 14/12/17
9
+ * @since 5.6.5
10
+ *
11
+ * @param type $var Description. Default.
12
+ * @return type Description.
13
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ // The global acf object
16
+ var acf = {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ // Set as a browser global
19
+ window.acf = acf;
20
+
21
+ /** @var object Data sent from PHP */
22
+ acf.data = {};
23
+
24
+
25
+ /**
26
+ * get
27
+ *
28
+ * Gets a specific data value
29
+ *
30
+ * @date 14/12/17
31
+ * @since 5.6.5
32
+ *
33
+ * @param string name
34
+ * @return mixed
35
+ */
36
+
37
+ acf.get = function( name ){
38
+ return this.data[name] || null;
39
+ };
40
+
41
+
42
+ /**
43
+ * has
44
+ *
45
+ * Returns `true` if the data exists and is not null
46
+ *
47
+ * @date 14/12/17
48
+ * @since 5.6.5
49
+ *
50
+ * @param string name
51
+ * @return boolean
52
+ */
53
+
54
+ acf.has = function( name ){
55
+ return this.get(name) !== null;
56
+ };
57
+
58
+
59
+ /**
60
+ * set
61
+ *
62
+ * Sets a specific data value
63
+ *
64
+ * @date 14/12/17
65
+ * @since 5.6.5
66
+ *
67
+ * @param string name
68
+ * @param mixed value
69
+ * @return this
70
+ */
71
+
72
+ acf.set = function( name, value ){
73
+ this.data[ name ] = value;
74
+ return this;
75
+ };
76
+
77
+
78
+ /**
79
+ * uniqueId
80
+ *
81
+ * Returns a unique ID
82
+ *
83
+ * @date 9/11/17
84
+ * @since 5.6.3
85
+ *
86
+ * @param string prefix Optional prefix.
87
+ * @return string
88
+ */
89
+
90
+ var idCounter = 0;
91
+ acf.uniqueId = function(prefix){
92
+ var id = ++idCounter + '';
93
+ return prefix ? prefix + id : id;
94
+ };
95
+
96
+ /**
97
+ * acf.uniqueArray
98
+ *
99
+ * Returns a new array with only unique values
100
+ * Credit: https://stackoverflow.com/questions/1960473/get-all-unique-values-in-an-array-remove-duplicates
101
+ *
102
+ * @date 23/3/18
103
+ * @since 5.6.9
104
+ *
105
+ * @param type $var Description. Default.
106
+ * @return type Description.
107
+ */
108
+
109
+ acf.uniqueArray = function( array ){
110
+ function onlyUnique(value, index, self) {
111
+ return self.indexOf(value) === index;
112
+ }
113
+ return array.filter( onlyUnique );
114
+ };
115
+
116
+ /**
117
+ * uniqid
118
+ *
119
+ * Returns a unique ID (PHP version)
120
+ *
121
+ * @date 9/11/17
122
+ * @since 5.6.3
123
+ * @source http://locutus.io/php/misc/uniqid/
124
+ *
125
+ * @param string prefix Optional prefix.
126
+ * @return string
127
+ */
128
+
129
+ var uniqidSeed = '';
130
+ acf.uniqid = function(prefix, moreEntropy){
131
+ // discuss at: http://locutus.io/php/uniqid/
132
+ // original by: Kevin van Zonneveld (http://kvz.io)
133
+ // revised by: Kankrelune (http://www.webfaktory.info/)
134
+ // note 1: Uses an internal counter (in locutus global) to avoid collision
135
+ // example 1: var $id = uniqid()
136
+ // example 1: var $result = $id.length === 13
137
+ // returns 1: true
138
+ // example 2: var $id = uniqid('foo')
139
+ // example 2: var $result = $id.length === (13 + 'foo'.length)
140
+ // returns 2: true
141
+ // example 3: var $id = uniqid('bar', true)
142
+ // example 3: var $result = $id.length === (23 + 'bar'.length)
143
+ // returns 3: true
144
+ if (typeof prefix === 'undefined') {
145
+ prefix = '';
146
+ }
147
 
148
+ var retId;
149
+ var formatSeed = function(seed, reqWidth) {
150
+ seed = parseInt(seed, 10).toString(16); // to hex str
151
+ if (reqWidth < seed.length) { // so long we split
152
+ return seed.slice(seed.length - reqWidth);
 
 
 
 
 
 
153
  }
154
+ if (reqWidth > seed.length) { // so short we pad
155
+ return Array(1 + (reqWidth - seed.length)).join('0') + seed;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
+ return seed;
158
+ };
159
+
160
+ if (!uniqidSeed) { // init seed with big random int
161
+ uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
162
+ }
163
+ uniqidSeed++;
164
+
165
+ retId = prefix; // start with prefix, add current milliseconds hex string
166
+ retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
167
+ retId += formatSeed(uniqidSeed, 5); // add seed hex string
168
+ if (moreEntropy) {
169
+ // for more entropy we add a float lower to 10
170
+ retId += (Math.random() * 10).toFixed(8).toString();
171
  }
172
 
173
+ return retId;
174
+ };
175
 
 
 
 
176
 
177
+ /**
178
+ * strReplace
179
+ *
180
+ * Performs a string replace
181
+ *
182
+ * @date 14/12/17
183
+ * @since 5.6.5
184
+ *
185
+ * @param string search
186
+ * @param string replace
187
+ * @param string subject
188
+ * @return string
189
+ */
190
+
191
+ acf.strReplace = function( search, replace, subject ){
192
+ return subject.split(search).join(replace);
193
+ };
194
+
195
+
196
+ /**
197
+ * strCamelCase
198
+ *
199
+ * Converts a string into camelCase
200
+ * Thanks to https://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case
201
+ *
202
+ * @date 14/12/17
203
+ * @since 5.6.5
204
+ *
205
+ * @param string str
206
+ * @return string
207
+ */
208
+
209
+ acf.strCamelCase = function( str ){
210
 
211
+ // replace [_-] characters with space
212
+ str = str.replace(/[_-]/g, ' ');
 
 
 
 
 
 
 
 
 
 
213
 
214
+ // camelCase
215
+ str = str.replace(/(?:^\w|\b\w|\s+)/g, function(match, index) {
216
+ if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
217
+ return index == 0 ? match.toLowerCase() : match.toUpperCase();
218
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
 
220
+ // return
221
+ return str;
222
+ };
 
 
223
 
224
+ /**
225
+ * strPascalCase
226
+ *
227
+ * Converts a string into PascalCase
228
+ * Thanks to https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript
229
+ *
230
+ * @date 14/12/17
231
+ * @since 5.6.5
232
+ *
233
+ * @param string str
234
+ * @return string
235
+ */
236
+
237
+ acf.strPascalCase = function( str ){
238
+ var camel = acf.strCamelCase( str );
239
+ return camel.charAt(0).toUpperCase() + camel.slice(1);
240
+ };
241
+
242
+ /**
243
+ * acf.strSlugify
244
+ *
245
+ * Converts a string into a HTML class friendly slug
246
+ *
247
+ * @date 21/3/18
248
+ * @since 5.6.9
249
+ *
250
+ * @param string str
251
+ * @return string
252
+ */
253
+
254
+ acf.strSlugify = function( str ){
255
+ return acf.strReplace( '_', '-', str.toLowerCase() );
256
+ };
257
+
258
+
259
+ acf.strSanitize = function( str ){
260
+
261
+ // chars (https://jsperf.com/replace-foreign-characters)
262
+ var map = {
263
+ "À": "A",
264
+ "Á": "A",
265
+ "Â": "A",
266
+ "Ã": "A",
267
+ "Ä": "A",
268
+ "Å": "A",
269
+ "Æ": "AE",
270
+ "Ç": "C",
271
+ "È": "E",
272
+ "É": "E",
273
+ "Ê": "E",
274
+ "Ë": "E",
275
+ "Ì": "I",
276
+ "Í": "I",
277
+ "Î": "I",
278
+ "Ï": "I",
279
+ "Ð": "D",
280
+ "Ñ": "N",
281
+ "Ò": "O",
282
+ "Ó": "O",
283
+ "Ô": "O",
284
+ "Õ": "O",
285
+ "Ö": "O",
286
+ "Ø": "O",
287
+ "Ù": "U",
288
+ "Ú": "U",
289
+ "Û": "U",
290
+ "Ü": "U",
291
+ "Ý": "Y",
292
+ "ß": "s",
293
+ "à": "a",
294
+ "á": "a",
295
+ "â": "a",
296
+ "ã": "a",
297
+ "ä": "a",
298
+ "å": "a",
299
+ "æ": "ae",
300
+ "ç": "c",
301
+ "è": "e",
302
+ "é": "e",
303
+ "ê": "e",
304
+ "ë": "e",
305
+ "ì": "i",
306
+ "í": "i",
307
+ "î": "i",
308
+ "ï": "i",
309
+ "ñ": "n",
310
+ "ò": "o",
311
+ "ó": "o",
312
+ "ô": "o",
313
+ "õ": "o",
314
+ "ö": "o",
315
+ "ø": "o",
316
+ "ù": "u",
317
+ "ú": "u",
318
+ "û": "u",
319
+ "ü": "u",
320
+ "ý": "y",
321
+ "ÿ": "y",
322
+ "Ā": "A",
323
+ "ā": "a",
324
+ "Ă": "A",
325
+ "ă": "a",
326
+ "Ą": "A",
327
+ "ą": "a",
328
+ "Ć": "C",
329
+ "ć": "c",
330
+ "Ĉ": "C",
331
+ "ĉ": "c",
332
+ "Ċ": "C",
333
+ "ċ": "c",
334
+ "Č": "C",
335
+ "č": "c",
336
+ "Ď": "D",
337
+ "ď": "d",
338
+ "Đ": "D",
339
+ "đ": "d",
340
+ "Ē": "E",
341
+ "ē": "e",
342
+ "Ĕ": "E",
343
+ "ĕ": "e",
344
+ "Ė": "E",
345
+ "ė": "e",
346
+ "Ę": "E",
347
+ "ę": "e",
348
+ "Ě": "E",
349
+ "ě": "e",
350
+ "Ĝ": "G",
351
+ "ĝ": "g",
352
+ "Ğ": "G",
353
+ "ğ": "g",
354
+ "Ġ": "G",
355
+ "ġ": "g",
356
+ "Ģ": "G",
357
+ "ģ": "g",
358
+ "Ĥ": "H",
359
+ "ĥ": "h",
360
+ "Ħ": "H",
361
+ "ħ": "h",
362
+ "Ĩ": "I",
363
+ "ĩ": "i",
364
+ "Ī": "I",
365
+ "ī": "i",
366
+ "Ĭ": "I",
367
+ "ĭ": "i",
368
+ "Į": "I",
369
+ "į": "i",
370
+ "İ": "I",
371
+ "ı": "i",
372
+ "IJ": "IJ",
373
+ "ij": "ij",
374
+ "Ĵ": "J",
375
+ "ĵ": "j",
376
+ "Ķ": "K",
377
+ "ķ": "k",
378
+ "Ĺ": "L",
379
+ "ĺ": "l",
380
+ "Ļ": "L",
381
+ "ļ": "l",
382
+ "Ľ": "L",
383
+ "ľ": "l",
384
+ "Ŀ": "L",
385
+ "ŀ": "l",
386
+ "Ł": "l",
387
+ "ł": "l",
388
+ "Ń": "N",
389
+ "ń": "n",
390
+ "Ņ": "N",
391
+ "ņ": "n",
392
+ "Ň": "N",
393
+ "ň": "n",
394
+ "ʼn": "n",
395
+ "Ō": "O",
396
+ "ō": "o",
397
+ "Ŏ": "O",
398
+ "ŏ": "o",
399
+ "Ő": "O",
400
+ "ő": "o",
401
+ "Œ": "OE",
402
+ "œ": "oe",
403
+ "Ŕ": "R",
404
+ "ŕ": "r",
405
+ "Ŗ": "R",
406
+ "ŗ": "r",
407
+ "Ř": "R",
408
+ "ř": "r",
409
+ "Ś": "S",
410
+ "ś": "s",
411
+ "Ŝ": "S",
412
+ "ŝ": "s",
413
+ "Ş": "S",
414
+ "ş": "s",
415
+ "Š": "S",
416
+ "š": "s",
417
+ "Ţ": "T",
418
+ "ţ": "t",
419
+ "Ť": "T",
420
+ "ť": "t",
421
+ "Ŧ": "T",
422
+ "ŧ": "t",
423
+ "Ũ": "U",
424
+ "ũ": "u",
425
+ "Ū": "U",
426
+ "ū": "u",
427
+ "Ŭ": "U",
428
+ "ŭ": "u",
429
+ "Ů": "U",
430
+ "ů": "u",
431
+ "Ű": "U",
432
+ "ű": "u",
433
+ "Ų": "U",
434
+ "ų": "u",
435
+ "Ŵ": "W",
436
+ "ŵ": "w",
437
+ "Ŷ": "Y",
438
+ "ŷ": "y",
439
+ "Ÿ": "Y",
440
+ "Ź": "Z",
441
+ "ź": "z",
442
+ "Ż": "Z",
443
+ "ż": "z",
444
+ "Ž": "Z",
445
+ "ž": "z",
446
+ "ſ": "s",
447
+ "ƒ": "f",
448
+ "Ơ": "O",
449
+ "ơ": "o",
450
+ "Ư": "U",
451
+ "ư": "u",
452
+ "Ǎ": "A",
453
+ "ǎ": "a",
454
+ "Ǐ": "I",
455
+ "ǐ": "i",
456
+ "Ǒ": "O",
457
+ "ǒ": "o",
458
+ "Ǔ": "U",
459
+ "ǔ": "u",
460
+ "Ǖ": "U",
461
+ "ǖ": "u",
462
+ "Ǘ": "U",
463
+ "ǘ": "u",
464
+ "Ǚ": "U",
465
+ "ǚ": "u",
466
+ "Ǜ": "U",
467
+ "ǜ": "u",
468
+ "Ǻ": "A",
469
+ "ǻ": "a",
470
+ "Ǽ": "AE",
471
+ "ǽ": "ae",
472
+ "Ǿ": "O",
473
+ "ǿ": "o",
474
+
475
+ // extra
476
+ ' ': '_',
477
+ '\'': '',
478
+ '?': '',
479
+ '/': '',
480
+ '\\': '',
481
+ '.': '',
482
+ ',': '',
483
+ '`': '',
484
+ '>': '',
485
+ '<': '',
486
+ '"': '',
487
+ '[': '',
488
+ ']': '',
489
+ '|': '',
490
+ '{': '',
491
+ '}': '',
492
+ '(': '',
493
+ ')': ''
494
+ };
495
 
496
+ // vars
497
+ var nonWord = /\W/g;
498
+ var mapping = function (c) {
499
+ return map[c] || c;
500
+ };
501
+
502
+ // replace
503
+ str = str.replace(nonWord, mapping);
504
+
505
+ // lowercase
506
+ str = str.toLowerCase();
507
+
508
+ // return
509
+ return str;
510
+ };
511
+
512
+ /**
513
+ * acf.strMatch
514
+ *
515
+ * Returns the number of characters that match between two strings
516
+ *
517
+ * @date 1/2/18
518
+ * @since 5.6.5
519
+ *
520
+ * @param type $var Description. Default.
521
+ * @return type Description.
522
+ */
523
+
524
+ acf.strMatch = function( s1, s2 ){
525
 
526
+ // vars
527
+ var val = 0;
528
+ var min = Math.min( s1.length, s2.length );
529
 
530
+ // loop
531
+ for( var i = 0; i < min; i++ ) {
532
+ if( s1[i] !== s2[i] ) {
533
+ break;
534
+ }
535
+ val++;
536
+ }
 
 
 
 
 
537
 
538
+ // return
539
+ return val;
540
+ };
541
+
542
+ /**
543
+ * acf.decode
544
+ *
545
+ * description
546
+ *
547
+ * @date 13/1/18
548
+ * @since 5.6.5
549
+ *
550
+ * @param type $var Description. Default.
551
+ * @return type Description.
552
+ */
553
+
554
+ acf.decode = function( string ){
555
+ return $('<textarea/>').html( string ).text();
556
+ };
557
+
558
+ /**
559
+ * acf.strEscape
560
+ *
561
+ * description
562
+ *
563
+ * @date 3/2/18
564
+ * @since 5.6.5
565
+ *
566
+ * @param type $var Description. Default.
567
+ * @return type Description.
568
+ */
569
+
570
+ acf.strEscape = function( string ){
571
+
572
+ var entityMap = {
573
+ '&': '&amp;',
574
+ '<': '&lt;',
575
+ '>': '&gt;',
576
+ '"': '&quot;',
577
+ "'": '&#39;',
578
+ '/': '&#x2F;',
579
+ '`': '&#x60;',
580
+ '=': '&#x3D;'
581
+ };
582
 
583
+ return String(string).replace(/[&<>"'`=\/]/g, function (s) {
584
+ return entityMap[s];
585
+ });
586
+ };
587
+
588
+ /**
589
+ * parseArgs
590
+ *
591
+ * Merges together defaults and args much like the WP wp_parse_args function
592
+ *
593
+ * @date 14/12/17
594
+ * @since 5.6.5
595
+ *
596
+ * @param object args
597
+ * @param object defaults
598
+ * @return object
599
+ */
600
+
601
+ acf.parseArgs = function( args, defaults ){
602
+ if( typeof args !== 'object' ) args = {};
603
+ if( typeof defaults !== 'object' ) defaults = {};
604
+ return $.extend({}, defaults, args);
605
+ }
606
+
607
+ /**
608
+ * __
609
+ *
610
+ * Retrieve the translation of $text.
611
+ *
612
+ * @date 16/4/18
613
+ * @since 5.6.9
614
+ *
615
+ * @param string text Text to translate.
616
+ * @return string Translated text.
617
+ */
618
+
619
+ if( window.acfL10n == undefined ) {
620
+ acfL10n = {};
621
+ }
622
+
623
+ acf.__ = function( text ){
624
+ return acfL10n[ text ] || text;
625
+ };
626
+
627
+ /**
628
+ * _x
629
+ *
630
+ * Retrieve translated string with gettext context.
631
+ *
632
+ * @date 16/4/18
633
+ * @since 5.6.9
634
+ *
635
+ * @param string text Text to translate.
636
+ * @param string context Context information for the translators.
637
+ * @return string Translated text.
638
+ */
639
+
640
+ acf._x = function( text, context ){
641
+ return acfL10n[ text + '.' + context ] || acfL10n[ text ] || text;
642
+ };
643
+
644
+ /**
645
+ * _n
646
+ *
647
+ * Retrieve the plural or single form based on the amount.
648
+ *
649
+ * @date 16/4/18
650
+ * @since 5.6.9
651
+ *
652
+ * @param string single Single text to translate.
653
+ * @param string plural Plural text to translate.
654
+ * @param int number The number to compare against.
655
+ * @return string Translated text.
656
+ */
657
+
658
+ acf._n = function( single, plural, number ){
659
+ if( number == 1 ) {
660
+ return acf.__(single);
661
+ } else {
662
+ return acf.__(plural);
663
+ }
664
+ };
665
+
666
+ acf.isArray = function( a ){
667
+ return Array.isArray(a);
668
+ };
669
+
670
+ acf.isObject = function( a ){
671
+ return ( typeof a === 'object' );
672
+ }
673
+
674
+ /**
675
+ * serialize
676
+ *
677
+ * description
678
+ *
679
+ * @date 24/12/17
680
+ * @since 5.6.5
681
+ *
682
+ * @param type $var Description. Default.
683
+ * @return type Description.
684
+ */
685
+
686
+ var buildObject = function( obj, name, value ){
687
+ //console.log('buildObject', obj, name);
688
+ // replace [] with placeholder
689
+ name = name.replace('[]', '[%%index%%]');
690
 
691
+ // vars
692
+ var keys = name.match(/([^\[\]])+/g);
693
+ if( !keys ) return;
694
+ var length = keys.length;
695
+ var ref = obj;
 
 
 
 
 
 
 
 
 
696
 
697
+ // loop
698
+ for( var i = 0; i < length; i++ ) {
699
 
700
  // vars
701
+ var key = String( keys[i] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702
 
703
+ // value
704
+ if( i == length - 1 ) {
 
 
 
705
 
706
+ // %%index%%
707
+ if( key === '%%index%%' ) {
708
+ ref.push( value );
709
 
710
+ // default
711
+ } else {
712
+ ref[ key ] = value;
713
+ }
714
 
715
+ // path
716
+ } else {
717
 
718
+ // array
719
+ if( keys[i+1] === '%%index%%' ) {
720
+ if( !acf.isArray(ref[ key ]) ) {
721
+ ref[ key ] = [];
722
+ }
723
 
724
+ // object
725
+ } else {
726
+ if( !acf.isObject(ref[ key ]) ) {
727
+ ref[ key ] = {};
728
+ }
729
  }
 
 
 
 
 
 
 
730
 
731
+ // crawl
732
+ ref = ref[ key ];
733
  }
734
+ //console.log('ref:', ref);
735
+ }
736
+ };
737
+
738
+ acf.serialize = function( $el, prefix ){
739
+ //console.time('serialize');
740
+ // vars
741
+ var obj = {};
742
+ var inputs = $el.find('select, textarea, input').serializeArray();
743
+
744
+ // prefix
745
+ if( prefix !== undefined ) {
746
+
747
+ // filter and modify
748
+ inputs = inputs.filter(function( item ){
749
+ return item.name.indexOf(prefix) === 0;
750
+ }).map(function( item ){
751
+ item.name = item.name.slice(prefix.length);
752
+ return item;
753
+ });
754
+ }
755
+
756
+ // loop
757
+ for( var i = 0; i < inputs.length; i++ ) {
758
+ buildObject( obj, inputs[i].name, inputs[i].value );
759
+ }
760
+ //console.timeEnd('serialize');
761
+
762
+ // return
763
+ return obj;
764
+ };
765
+
766
+
767
+ /**
768
+ * addAction
769
+ *
770
+ * Wrapper for acf.hooks.addAction
771
+ *
772
+ * @date 14/12/17
773
+ * @since 5.6.5
774
+ *
775
+ * @param n/a
776
+ * @return this
777
+ */
778
+
779
+ /*
780
+ var prefixAction = function( action ){
781
+ return 'acf_' + action;
782
+ }
783
+ */
784
+
785
+ acf.addAction = function( action, callback, priority, context ){
786
+ //action = prefixAction(action);
787
+ acf.hooks.addAction.apply(this, arguments);
788
+ return this;
789
+ };
790
+
791
+
792
+ /**
793
+ * removeAction
794
+ *
795
+ * Wrapper for acf.hooks.removeAction
796
+ *
797
+ * @date 14/12/17
798
+ * @since 5.6.5
799
+ *
800
+ * @param n/a
801
+ * @return this
802
+ */
803
+
804
+ acf.removeAction = function( action, callback ){
805
+ //action = prefixAction(action);
806
+ acf.hooks.removeAction.apply(this, arguments);
807
+ return this;
808
+ };
809
+
810
+
811
+ /**
812
+ * doAction
813
+ *
814
+ * Wrapper for acf.hooks.doAction
815
+ *
816
+ * @date 14/12/17
817
+ * @since 5.6.5
818
+ *
819
+ * @param n/a
820
+ * @return this
821
+ */
822
+
823
+ var actionHistory = {};
824
+ //var currentAction = false;
825
+ acf.doAction = function( action ){
826
+ //action = prefixAction(action);
827
+ //currentAction = action;
828
+ actionHistory[ action ] = 1;
829
+ acf.hooks.doAction.apply(this, arguments);
830
+ actionHistory[ action ] = 0;
831
+ return this;
832
+ };
833
+
834
+
835
+ /**
836
+ * doingAction
837
+ *
838
+ * Return true if doing action
839
+ *
840
+ * @date 14/12/17
841
+ * @since 5.6.5
842
+ *
843
+ * @param n/a
844
+ * @return this
845
+ */
846
+
847
+ acf.doingAction = function( action ){
848
+ //action = prefixAction(action);
849
+ return (actionHistory[ action ] === 1);
850
+ };
851
+
852
+
853
+ /**
854
+ * didAction
855
+ *
856
+ * Wrapper for acf.hooks.doAction
857
+ *
858
+ * @date 14/12/17
859
+ * @since 5.6.5
860
+ *
861
+ * @param n/a
862
+ * @return this
863
+ */
864
+
865
+ acf.didAction = function( action ){
866
+ //action = prefixAction(action);
867
+ return (actionHistory[ action ] !== undefined);
868
+ };
869
+
870
+ /**
871
+ * currentAction
872
+ *
873
+ * Wrapper for acf.hooks.doAction
874
+ *
875
+ * @date 14/12/17
876
+ * @since 5.6.5
877
+ *
878
+ * @param n/a
879
+ * @return this
880
+ */
881
+
882
+ acf.currentAction = function(){
883
+ for( var k in actionHistory ) {
884
+ if( actionHistory[k] ) {
885
+ return k;
886
+ }
887
+ }
888
+ return false;
889
+ };
890
+
891
+ /**
892
+ * addFilter
893
+ *
894
+ * Wrapper for acf.hooks.addFilter
895
+ *
896
+ * @date 14/12/17
897
+ * @since 5.6.5
898
+ *
899
+ * @param n/a
900
+ * @return this
901
+ */
902
+
903
+ acf.addFilter = function( action ){
904
+ //action = prefixAction(action);
905
+ acf.hooks.addFilter.apply(this, arguments);
906
+ return this;
907
+ };
908
+
909
+
910
+ /**
911
+ * removeFilter
912
+ *
913
+ * Wrapper for acf.hooks.removeFilter
914
+ *
915
+ * @date 14/12/17
916
+ * @since 5.6.5
917
+ *
918
+ * @param n/a
919
+ * @return this
920
+ */
921
+
922
+ acf.removeFilter = function( action ){
923
+ //action = prefixAction(action);
924
+ acf.hooks.removeFilter.apply(this, arguments);
925
+ return this;
926
+ };
927
+
928
+
929
+ /**
930
+ * applyFilters
931
+ *
932
+ * Wrapper for acf.hooks.applyFilters
933
+ *
934
+ * @date 14/12/17
935
+ * @since 5.6.5
936
+ *
937
+ * @param n/a
938
+ * @return this
939
+ */
940
+
941
+ acf.applyFilters = function( action ){
942
+ //action = prefixAction(action);
943
+ return acf.hooks.applyFilters.apply(this, arguments);
944
+ };
945
+
946
+
947
+ /**
948
+ * getArgs
949
+ *
950
+ * description
951
+ *
952
+ * @date 15/12/17
953
+ * @since 5.6.5
954
+ *
955
+ * @param type $var Description. Default.
956
+ * @return type Description.
957
+ */
958
+
959
+ acf.arrayArgs = function( args ){
960
+ return Array.prototype.slice.call( args );
961
+ };
962
+
963
+
964
+ /**
965
+ * extendArgs
966
+ *
967
+ * description
968
+ *
969
+ * @date 15/12/17
970
+ * @since 5.6.5
971
+ *
972
+ * @param type $var Description. Default.
973
+ * @return type Description.
974
+ */
975
+
976
+ /*
977
+ acf.extendArgs = function( ){
978
+ var args = Array.prototype.slice.call( arguments );
979
+ var realArgs = args.shift();
980
 
981
+ Array.prototype.push.call(arguments, 'bar')
982
+ return Array.prototype.push.apply( args, arguments );
983
+ };
984
+ */
985
+
986
+
987
+ // Preferences
988
+ var preferences = localStorage.getItem('acf');
989
+ preferences = preferences ? JSON.parse(preferences) : {};
990
+
991
+
992
+ /**
993
+ * getPreferenceName
994
+ *
995
+ * Gets the true preference name.
996
+ * Converts "this.thing" to "thing-123" if editing post 123.
997
+ *
998
+ * @date 11/11/17
999
+ * @since 5.6.5
1000
+ *
1001
+ * @param string name
1002
+ * @return string
1003
+ */
1004
+
1005
+ var getPreferenceName = function( name ){
1006
+ if( name.substr(0, 5) === 'this.' ) {
1007
+ name = name.substr(5) + '-' + acf.get('post_id');
1008
+ }
1009
+ return name;
1010
+ };
1011
+
1012
+
1013
+ /**
1014
+ * acf.getPreference
1015
+ *
1016
+ * Gets a preference setting or null if not set.
1017
+ *
1018
+ * @date 11/11/17
1019
+ * @since 5.6.5
1020
+ *
1021
+ * @param string name
1022
+ * @return mixed
1023
+ */
1024
+
1025
+ acf.getPreference = function( name ){
1026
+ name = getPreferenceName( name );
1027
+ return preferences[ name ] || null;
1028
+ }
1029
+
1030
+
1031
+ /**
1032
+ * acf.setPreference
1033
+ *
1034
+ * Sets a preference setting.
1035
+ *
1036
+ * @date 11/11/17
1037
+ * @since 5.6.5
1038
+ *
1039
+ * @param string name
1040
+ * @param mixed value
1041
+ * @return n/a
1042
+ */
1043
+
1044
+ acf.setPreference = function( name, value ){
1045
+ name = getPreferenceName( name );
1046
+ if( value === null ) {
1047
+ delete preferences[ name ];
1048
+ } else {
1049
+ preferences[ name ] = value;
1050
+ }
1051
+ localStorage.setItem('acf', JSON.stringify(preferences));
1052
+ }
1053
+
1054
+
1055
+ /**
1056
+ * acf.removePreference
1057
+ *
1058
+ * Removes a preference setting.
1059
+ *
1060
+ * @date 11/11/17
1061
+ * @since 5.6.5
1062
+ *
1063
+ * @param string name
1064
+ * @return n/a
1065
+ */
1066
+
1067
+ acf.removePreference = function( name ){
1068
+ acf.setPreference(name, null);
1069
+ };
1070
+
1071
+
1072
+ /**
1073
+ * remove
1074
+ *
1075
+ * Removes an element with fade effect
1076
+ *
1077
+ * @date 1/1/18
1078
+ * @since 5.6.5
1079
+ *
1080
+ * @param type $var Description. Default.
1081
+ * @return type Description.
1082
+ */
1083
+
1084
+ acf.remove = function( props ){
1085
 
1086
+ // allow jQuery
1087
+ if( props instanceof jQuery ) {
1088
+ props = {
1089
+ target: props
1090
+ };
1091
  }
1092
 
1093
+ // defaults
1094
+ props = acf.parseArgs(props, {
1095
+ target: false,
1096
+ endHeight: 0,
1097
+ complete: function(){}
1098
+ });
1099
+
1100
+ // action
1101
+ acf.doAction('remove', props.target);
1102
+
1103
+ // tr
1104
+ if( props.target.is('tr') ) {
1105
+ removeTr( props );
1106
+
1107
+ // div
1108
+ } else {
1109
+ removeDiv( props );
1110
+ }
1111
+
1112
+ };
1113
 
1114
+ /**
1115
+ * removeDiv
1116
+ *
1117
+ * description
1118
+ *
1119
+ * @date 16/2/18
1120
+ * @since 5.6.9
1121
+ *
1122
+ * @param type $var Description. Default.
1123
+ * @return type Description.
1124
+ */
1125
 
1126
+ var removeDiv = function( props ){
1127
 
1128
+ // vars
1129
+ var $el = props.target;
1130
+ var height = $el.height();
1131
+ var width = $el.width();
1132
+ var margin = $el.css('margin');
1133
+ var outerHeight = $el.outerHeight(true);
1134
+ var style = $el.attr('style') + ''; // needed to copy
1135
+
1136
+ // wrap
1137
+ $el.wrap('<div class="acf-temp-remove" style="height:' + outerHeight + 'px"></div>');
1138
+ var $wrap = $el.parent();
1139
+
1140
+ // set pos
1141
+ $el.css({
1142
+ height: height,
1143
+ width: width,
1144
+ margin: margin,
1145
+ position: 'absolute'
1146
+ });
1147
 
1148
+ // fade wrap
1149
+ setTimeout(function(){
1150
 
1151
+ $wrap.css({
1152
+ opacity: 0,
1153
+ height: props.endHeight
1154
+ });
1155
 
1156
+ }, 50);
1157
 
1158
+ // remove
1159
+ setTimeout(function(){
 
 
 
 
1160
 
1161
+ $el.attr('style', style);
1162
+ $wrap.remove();
1163
+ props.complete();
1164
+
1165
+ }, 301);
1166
+ };
1167
+
1168
+ /**
1169
+ * removeTr
1170
+ *
1171
+ * description
1172
+ *
1173
+ * @date 16/2/18
1174
+ * @since 5.6.9
1175
+ *
1176
+ * @param type $var Description. Default.
1177
+ * @return type Description.
1178
+ */
1179
+
1180
+ var removeTr = function( props ){
1181
+
1182
+ // vars
1183
+ var $tr = props.target;
1184
+ var height = $tr.height();
1185
+ var children = $tr.children().length;
1186
+
1187
+ // create dummy td
1188
+ var $td = $('<td class="acf-temp-remove" style="padding:0; height:' + height + 'px" colspan="' + children + '"></td>');
1189
+
1190
+ // fade away tr
1191
+ $tr.addClass('acf-remove-element');
1192
+
1193
+ // update HTML after fade animation
1194
+ setTimeout(function(){
1195
+ $tr.html( $td );
1196
+ }, 251);
1197
+
1198
+ // allow .acf-temp-remove to exist before changing CSS
1199
+ setTimeout(function(){
1200
 
1201
+ // remove class
1202
+ $tr.removeClass('acf-remove-element');
1203
 
1204
+ // collapse
1205
+ $td.css({
1206
+ height: props.endHeight
1207
+ });
 
 
 
 
1208
 
1209
+ }, 300);
1210
+
1211
+ // remove
1212
+ setTimeout(function(){
 
 
 
 
 
1213
 
1214
+ $tr.remove();
1215
+ props.complete();
1216
 
1217
+ }, 451);
1218
+ };
 
 
 
1219
 
1220
+ /**
1221
+ * duplicate
1222
+ *
1223
+ * description
1224
+ *
1225
+ * @date 3/1/18
1226
+ * @since 5.6.5
1227
+ *
1228
+ * @param type $var Description. Default.
1229
+ * @return type Description.
1230
+ */
1231
 
1232
+ acf.duplicate = function( args ){
 
1233
 
1234
+ // allow jQuery
1235
+ if( args instanceof jQuery ) {
1236
+ args = {
1237
+ target: args
1238
+ };
1239
+ }
1240
 
1241
+ // vars
1242
+ var timeout = 0;
1243
+
1244
+ // defaults
1245
+ args = acf.parseArgs(args, {
1246
+ target: false,
1247
+ search: '',
1248
+ replace: '',
1249
+ before: function( $el ){},
1250
+ after: function( $el, $el2 ){},
1251
+ append: function( $el, $el2 ){
1252
+ $el.after( $el2 );
1253
+ timeout = 1;
1254
+ }
1255
+ });
1256
 
1257
+ // compatibility
1258
+ args.target = args.target || args.$el;
1259
+
1260
+ // vars
1261
+ var $el = args.target;
1262
+
1263
+ // search
1264
+ args.search = args.search || $el.attr('data-id');
1265
+ args.replace = args.replace || acf.uniqid();
1266
+
1267
+ // before
1268
+ // - allow acf to modify DOM
1269
+ // - fixes bug where select field option is not selected
1270
+ args.before( $el );
1271
+ acf.doAction('before_duplicate', $el);
1272
+
1273
+ // clone
1274
+ var $el2 = $el.clone();
1275
+
1276
+ // rename
1277
+ acf.rename({
1278
+ target: $el2,
1279
+ search: args.search,
1280
+ replace: args.replace,
1281
+ });
1282
 
1283
+ // remove classes
1284
+ $el2.removeClass('acf-clone');
1285
+ $el2.find('.ui-sortable').removeClass('ui-sortable');
 
 
 
1286
 
1287
+ // after
1288
+ // - allow acf to modify DOM
1289
+ args.after( $el, $el2 );
1290
+ acf.doAction('after_duplicate', $el, $el2 );
1291
 
1292
+ // append
1293
+ args.append( $el, $el2 );
 
 
 
 
 
 
 
 
 
 
 
1294
 
1295
+ // append
1296
+ // - allow element to be moved into a visible position before fire action
1297
+ //var callback = function(){
1298
+ acf.doAction('append', $el2);
1299
+ //};
1300
+ //if( timeout ) {
1301
+ // setTimeout(callback, timeout);
1302
+ //} else {
1303
+ // callback();
1304
+ //}
1305
+
1306
+ // return
1307
+ return $el2;
1308
+ };
1309
+
1310
+ /**
1311
+ * rename
1312
+ *
1313
+ * description
1314
+ *
1315
+ * @date 7/1/18
1316
+ * @since 5.6.5
1317
+ *
1318
+ * @param type $var Description. Default.
1319
+ * @return type Description.
1320
+ */
1321
+
1322
+ acf.rename = function( args ){
1323
+
1324
+ // allow jQuery
1325
+ if( args instanceof jQuery ) {
1326
+ args = {
1327
+ target: args
1328
+ };
1329
+ }
1330
+
1331
+ // defaults
1332
+ args = acf.parseArgs(args, {
1333
+ target: false,
1334
+ destructive: false,
1335
+ search: '',
1336
+ replace: '',
1337
+ });
1338
+
1339
+ // vars
1340
+ var $el = args.target;
1341
+ var search = args.search || $el.attr('data-id');
1342
+ var replace = args.replace || acf.uniqid('acf');
1343
+ var replaceAttr = function(i, value){
1344
+ return value.replace( search, replace );
1345
+ }
1346
+
1347
+ // replace (destructive)
1348
+ if( args.destructive ) {
1349
+ var html = $el.outerHTML();
1350
+ html = acf.strReplace( search, replace, html );
1351
+ $el.replaceWith( html );
1352
 
1353
+ // replace
1354
+ } else {
1355
+ $el.attr('data-id', replace);
1356
+ $el.find('[id*="' + search + '"]').attr('id', replaceAttr);
1357
+ $el.find('[for*="' + search + '"]').attr('for', replaceAttr);
1358
+ $el.find('[name*="' + search + '"]').attr('name', replaceAttr);
1359
+ }
1360
 
1361
+ // return
1362
+ return $el;
1363
+ };
1364
+
1365
+
1366
+ /**
1367
+ * acf.prepareForAjax
1368
+ *
1369
+ * description
1370
+ *
1371
+ * @date 4/1/18
1372
+ * @since 5.6.5
1373
+ *
1374
+ * @param type $var Description. Default.
1375
+ * @return type Description.
1376
+ */
1377
+
1378
+ acf.prepareForAjax = function( data ){
1379
 
1380
+ // required
1381
+ data.nonce = acf.get('nonce');
1382
+ data.post_id = acf.get('post_id');
 
 
 
 
 
 
 
 
1383
 
1384
+ // filter for 3rd party customization
1385
+ data = acf.applyFilters('prepare_for_ajax', data);
 
1386
 
1387
+ // return
1388
+ return data;
1389
+ };
1390
+
1391
+
1392
+ /**
1393
+ * acf.startButtonLoading
1394
+ *
1395
+ * description
1396
+ *
1397
+ * @date 5/1/18
1398
+ * @since 5.6.5
1399
+ *
1400
+ * @param type $var Description. Default.
1401
+ * @return type Description.
1402
+ */
1403
+
1404
+ acf.startButtonLoading = function( $el ){
1405
+ $el.prop('disabled', true);
1406
+ $el.after(' <i class="acf-loading"></i>');
1407
+ }
1408
+
1409
+ acf.stopButtonLoading = function( $el ){
1410
+ $el.prop('disabled', false);
1411
+ $el.next('.acf-loading').remove();
1412
+ }
1413
+
1414
+
1415
+ /**
1416
+ * acf.showLoading
1417
+ *
1418
+ * description
1419
+ *
1420
+ * @date 12/1/18
1421
+ * @since 5.6.5
1422
+ *
1423
+ * @param type $var Description. Default.
1424
+ * @return type Description.
1425
+ */
1426
+
1427
+ acf.showLoading = function( $el ){
1428
+ $el.append('<div class="acf-loading-overlay"><i class="acf-loading"></i></div>');
1429
+ };
1430
+
1431
+ acf.hideLoading = function( $el ){
1432
+ $el.children('.acf-loading-overlay').remove();
1433
+ };
1434
+
1435
+
1436
+ /**
1437
+ * acf.updateUserSetting
1438
+ *
1439
+ * description
1440
+ *
1441
+ * @date 5/1/18
1442
+ * @since 5.6.5
1443
+ *
1444
+ * @param type $var Description. Default.
1445
+ * @return type Description.
1446
+ */
1447
+
1448
+ acf.updateUserSetting = function( name, value ){
1449
 
1450
+ var ajaxData = {
1451
+ action: 'acf/update_user_setting',
1452
+ name: name,
1453
+ value: value
1454
+ };
 
 
 
 
 
 
1455
 
1456
+ $.ajax({
1457
+ url: acf.get('ajaxurl'),
1458
+ data: acf.prepareForAjax(ajaxData),
1459
+ type: 'post',
1460
+ dataType: 'html'
1461
+ });
1462
 
1463
+ };
1464
+
1465
+
1466
+ /**
1467
+ * acf.val
1468
+ *
1469
+ * description
1470
+ *
1471
+ * @date 8/1/18
1472
+ * @since 5.6.5
1473
+ *
1474
+ * @param type $var Description. Default.
1475
+ * @return type Description.
1476
+ */
1477
+
1478
+ acf.val = function( $input, value, silent ){
1479
 
1480
+ // vars
1481
+ var prevValue = $input.val();
 
 
 
 
 
 
 
 
 
1482
 
1483
+ // bail if no change
1484
+ if( value === prevValue ) {
1485
+ return false
1486
+ }
 
 
 
 
 
 
 
 
1487
 
1488
+ // update value
1489
+ $input.val( value );
1490
 
1491
+ // prevent select elements displaying blank value if option doesn't exist
1492
+ if( $input.is('select') && $input.val() === null ) {
1493
+ $input.val( prevValue );
1494
+ return false;
1495
+ }
 
 
 
 
 
 
1496
 
1497
+ // update with trigger
1498
+ if( silent !== true ) {
1499
+ $input.trigger('change');
1500
+ }
1501
 
1502
+ // return
1503
+ return true;
1504
+ };
1505
+
1506
+ /**
1507
+ * acf.show
1508
+ *
1509
+ * description
1510
+ *
1511
+ * @date 9/2/18
1512
+ * @since 5.6.5
1513
+ *
1514
+ * @param type $var Description. Default.
1515
+ * @return type Description.
1516
+ */
1517
+
1518
+ acf.show = function( $el, lockKey ){
1519
 
1520
+ // unlock
1521
+ if( lockKey ) {
1522
+ acf.unlock($el, 'hidden', lockKey);
1523
+ }
 
 
 
 
 
 
 
1524
 
1525
+ // bail early if $el is still locked
1526
+ if( acf.isLocked($el, 'hidden') ) {
1527
+ //console.log( 'still locked', getLocks( $el, 'hidden' ));
1528
+ return false;
1529
+ }
1530
 
1531
+ // $el is hidden, remove class and return true due to change in visibility
1532
+ if( $el.hasClass('acf-hidden') ) {
1533
+ $el.removeClass('acf-hidden');
1534
+ return true;
1535
 
1536
+ // $el is visible, return false due to no change in visibility
1537
+ } else {
1538
+ return false;
1539
+ }
1540
+ };
1541
+
1542
+
1543
+ /**
1544
+ * acf.hide
1545
+ *
1546
+ * description
1547
+ *
1548
+ * @date 9/2/18
1549
+ * @since 5.6.5
1550
+ *
1551
+ * @param type $var Description. Default.
1552
+ * @return type Description.
1553
+ */
1554
+
1555
+ acf.hide = function( $el, lockKey ){
1556
 
1557
+ // lock
1558
+ if( lockKey ) {
1559
+ acf.lock($el, 'hidden', lockKey);
1560
+ }
1561
 
1562
+ // $el is hidden, return false due to no change in visibility
1563
+ if( $el.hasClass('acf-hidden') ) {
1564
+ return false;
1565
 
1566
+ // $el is visible, add class and return true due to change in visibility
1567
+ } else {
1568
+ $el.addClass('acf-hidden');
1569
+ return true;
1570
+ }
1571
+ };
1572
+
1573
+
1574
+ /**
1575
+ * acf.isHidden
1576
+ *
1577
+ * description
1578
+ *
1579
+ * @date 9/2/18
1580
+ * @since 5.6.5
1581
+ *
1582
+ * @param type $var Description. Default.
1583
+ * @return type Description.
1584
+ */
1585
+
1586
+ acf.isHidden = function( $el ){
1587
+ return $el.hasClass('acf-hidden');
1588
+ };
1589
+
1590
+
1591
+ /**
1592
+ * acf.isVisible
1593
+ *
1594
+ * description
1595
+ *
1596
+ * @date 9/2/18
1597
+ * @since 5.6.5
1598
+ *
1599
+ * @param type $var Description. Default.
1600
+ * @return type Description.
1601
+ */
1602
+
1603
+ acf.isVisible = function( $el ){
1604
+ return !acf.isHidden( $el );
1605
+ };
1606
+
1607
+
1608
+ /**
1609
+ * enable
1610
+ *
1611
+ * description
1612
+ *
1613
+ * @date 12/3/18
1614
+ * @since 5.6.9
1615
+ *
1616
+ * @param type $var Description. Default.
1617
+ * @return type Description.
1618
+ */
1619
+
1620
+ var enable = function( $el, lockKey ){
1621
 
1622
+ // check class. Allow .acf-disabled to overrule all JS
1623
+ if( $el.hasClass('acf-disabled') ) {
1624
+ return false;
1625
+ }
 
 
 
 
 
 
 
 
 
 
 
1626
 
1627
+ // unlock
1628
+ if( lockKey ) {
1629
+ acf.unlock($el, 'disabled', lockKey);
1630
+ }
1631
 
1632
+ // bail early if $el is still locked
1633
+ if( acf.isLocked($el, 'disabled') ) {
1634
+ return false;
1635
+ }
 
 
 
 
 
 
 
1636
 
1637
+ // $el is disabled, remove prop and return true due to change
1638
+ if( $el.prop('disabled') ) {
1639
+ $el.prop('disabled', false);
1640
+ return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1641
 
1642
+ // $el is enabled, return false due to no change
1643
+ } else {
1644
+ return false;
1645
+ }
1646
+ };
1647
+
1648
+ /**
1649
+ * acf.enable
1650
+ *
1651
+ * description
1652
+ *
1653
+ * @date 9/2/18
1654
+ * @since 5.6.5
1655
+ *
1656
+ * @param type $var Description. Default.
1657
+ * @return type Description.
1658
+ */
1659
+
1660
+ acf.enable = function( $el, lockKey ){
1661
 
1662
+ // enable single input
1663
+ if( $el.attr('name') ) {
1664
+ return enable( $el, lockKey );
1665
+ }
 
 
 
 
 
 
 
 
1666
 
1667
+ // find and enable child inputs
1668
+ // return true if any inputs have changed
1669
+ var results = false;
1670
+ $el.find('[name]').each(function(){
1671
+ var result = enable( $(this), lockKey );
1672
+ if( result ) {
1673
+ results = true;
 
 
 
 
 
 
 
 
 
 
 
 
1674
  }
1675
+ });
1676
+ return results;
1677
+ };
1678
+
1679
+
1680
+ /**
1681
+ * disable
1682
+ *
1683
+ * description
1684
+ *
1685
+ * @date 12/3/18
1686
+ * @since 5.6.9
1687
+ *
1688
+ * @param type $var Description. Default.
1689
+ * @return type Description.
1690
+ */
1691
+
1692
+ var disable = function( $el, lockKey ){
1693
 
1694
+ // lock
1695
+ if( lockKey ) {
1696
+ acf.lock($el, 'disabled', lockKey);
1697
+ }
1698
 
1699
+ // $el is disabled, return false due to no change
1700
+ if( $el.prop('disabled') ) {
1701
+ return false;
1702
+
1703
+ // $el is enabled, add prop and return true due to change
1704
+ } else {
1705
+ $el.prop('disabled', true);
1706
+ return true;
1707
+ }
1708
+ };
1709
+
1710
+
1711
+ /**
1712
+ * acf.disable
1713
+ *
1714
+ * description
1715
+ *
1716
+ * @date 9/2/18
1717
+ * @since 5.6.5
1718
+ *
1719
+ * @param type $var Description. Default.
1720
+ * @return type Description.
1721
+ */
1722
+
1723
+ acf.disable = function( $el, lockKey ){
1724
 
1725
+ // disable single input
1726
+ if( $el.attr('name') ) {
1727
+ return disable( $el, lockKey );
1728
+ }
1729
 
1730
+ // find and enable child inputs
1731
+ // return true if any inputs have changed
1732
+ var results = false;
1733
+ $el.find('[name]').each(function(){
1734
+ var result = disable( $(this), lockKey );
1735
+ if( result ) {
1736
+ results = true;
1737
+ }
1738
+ });
1739
+ return results;
1740
+ };
1741
+
1742
+
1743
+ /**
1744
+ * acf.isset
1745
+ *
1746
+ * description
1747
+ *
1748
+ * @date 10/1/18
1749
+ * @since 5.6.5
1750
+ *
1751
+ * @param type $var Description. Default.
1752
+ * @return type Description.
1753
+ */
1754
+
1755
+ acf.isset = function( obj /*, level1, level2, ... */ ) {
1756
+ for( var i = 1; i < arguments.length; i++ ) {
1757
+ if( !obj.hasOwnProperty(arguments[i]) ) {
1758
+ return false;
1759
+ }
1760
+ obj = obj[ arguments[i] ];
1761
+ }
1762
+ return true;
1763
+ };
1764
+
1765
+ /**
1766
+ * acf.isget
1767
+ *
1768
+ * description
1769
+ *
1770
+ * @date 10/1/18
1771
+ * @since 5.6.5
1772
+ *
1773
+ * @param type $var Description. Default.
1774
+ * @return type Description.
1775
+ */
1776
+
1777
+ acf.isget = function( obj /*, level1, level2, ... */ ) {
1778
+ for( var i = 1; i < arguments.length; i++ ) {
1779
+ if( !obj.hasOwnProperty(arguments[i]) ) {
1780
+ return null;
1781
+ }
1782
+ obj = obj[ arguments[i] ];
1783
+ }
1784
+ return obj;
1785
+ };
1786
+
1787
+ /**
1788
+ * acf.getFileInputData
1789
+ *
1790
+ * description
1791
+ *
1792
+ * @date 10/1/18
1793
+ * @since 5.6.5
1794
+ *
1795
+ * @param type $var Description. Default.
1796
+ * @return type Description.
1797
+ */
1798
+
1799
+ acf.getFileInputData = function( $input, callback ){
1800
 
1801
+ // vars
1802
+ var value = $input.val();
1803
 
1804
+ // bail early if no value
1805
+ if( !value ) {
1806
+ return false;
1807
+ }
 
 
 
 
 
 
 
 
1808
 
1809
+ // data
1810
+ var data = {
1811
+ url: value
1812
+ };
1813
+
1814
+ // modern browsers
1815
+ var file = acf.isget( $input[0], 'files', 0);
1816
+ if( file ){
1817
 
1818
+ // update data
1819
+ data.size = file.size;
1820
+ data.type = file.type;
1821
 
1822
+ // image
1823
+ if( file.type.indexOf('image') > -1 ) {
1824
 
1825
  // vars
1826
+ var windowURL = window.URL || window.webkitURL;
1827
+ var img = new Image();
1828
 
1829
+ img.onload = function() {
 
 
 
 
1830
 
1831
+ // update
1832
+ data.width = this.width;
1833
+ data.height = this.height;
1834
 
1835
+ callback( data );
1836
+ };
1837
+ img.src = windowURL.createObjectURL( file );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1838
  } else {
1839
+ callback( data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1840
  }
1841
+ } else {
1842
+ callback( data );
1843
+ }
1844
+ };
1845
+
1846
+ /**
1847
+ * acf.isAjaxSuccess
1848
+ *
1849
+ * description
1850
+ *
1851
+ * @date 18/1/18
1852
+ * @since 5.6.5
1853
+ *
1854
+ * @param type $var Description. Default.
1855
+ * @return type Description.
1856
+ */
1857
+
1858
+ acf.isAjaxSuccess = function( json ){
1859
+ return ( json && json.success );
1860
+ };
1861
+
1862
+ /**
1863
+ * acf.getAjaxMessage
1864
+ *
1865
+ * description
1866
+ *
1867
+ * @date 18/1/18
1868
+ * @since 5.6.5
1869
+ *
1870
+ * @param type $var Description. Default.
1871
+ * @return type Description.
1872
+ */
1873
+
1874
+ acf.getAjaxMessage = function( json ){
1875
+ return acf.isget( json, 'data', 'message' );
1876
+ };
1877
+
1878
+ /**
1879
+ * acf.getAjaxError
1880
+ *
1881
+ * description
1882
+ *
1883
+ * @date 18/1/18
1884
+ * @since 5.6.5
1885
+ *
1886
+ * @param type $var Description. Default.
1887
+ * @return type Description.
1888
+ */
1889
+
1890
+ acf.getAjaxError = function( json ){
1891
+ return acf.isget( json, 'data', 'error' );
1892
+ };
1893
+
1894
+
1895
+ /**
1896
+ * acf.renderSelect
1897
+ *
1898
+ * Renders the innter html for a select field.
1899
+ *
1900
+ * @date 19/2/18
1901
+ * @since 5.6.9
1902
+ *
1903
+ * @param jQuery $select The select element.
1904
+ * @param array choices An array of choices.
1905
+ * @return void
1906
+ */
1907
+
1908
+ acf.renderSelect = function( $select, choices ){
1909
 
1910
+ // vars
1911
+ var value = $select.val();
1912
+ var values = [];
 
 
 
 
 
 
 
 
 
1913
 
1914
+ // callback
1915
+ var crawl = function( items ){
 
 
 
 
 
 
 
1916
 
1917
  // vars
1918
+ var itemsHtml = '';
 
1919
 
1920
+ // loop
1921
+ items.map(function( item ){
 
 
 
 
 
 
1922
 
1923
+ // vars
1924
+ var text = item.text || item.label || '';
1925
+ var id = item.id || item.value || '';
 
 
 
 
1926
 
1927
+ // append
1928
+ values.push(id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1929
 
1930
+ // optgroup
1931
+ if( item.children ) {
1932
+ itemsHtml += '<optgroup label="' + acf.strEscape(text) + '">' + crawl( item.children ) + '</optgroup>';
1933
 
1934
+ // option
1935
+ } else {
1936
+ itemsHtml += '<option value="' + id + '"' + (item.disabled ? ' disabled="disabled"' : '') + '>' + acf.strEscape(text) + '</option>';
1937
+ }
1938
+ });
1939
 
1940
  // return
1941
+ return itemsHtml;
1942
+ };
 
1943
 
1944
+ // update HTML
1945
+ $select.html( crawl(choices) );
1946
 
1947
+ // update value
1948
+ if( values.indexOf(value) > -1 ){
1949
+ $select.val( value );
1950
+ }
1951
+
1952
+ // return selected value
1953
+ return $select.val();
1954
+ };
1955
+
1956
+ /**
1957
+ * acf.lock
1958
+ *
1959
+ * Creates a "lock" on an element for a given type and key
1960
+ *
1961
+ * @date 22/2/18
1962
+ * @since 5.6.9
1963
+ *
1964
+ * @param jQuery $el The element to lock.
1965
+ * @param string type The type of lock such as "condition" or "visibility".
1966
+ * @param string key The key that will be used to unlock.
1967
+ * @return void
1968
+ */
1969
+
1970
+ var getLocks = function( $el, type ){
1971
+ return $el.data('acf-lock-'+type) || [];
1972
+ };
1973
+
1974
+ var setLocks = function( $el, type, locks ){
1975
+ $el.data('acf-lock-'+type, locks);
1976
+ }
1977
+
1978
+ acf.lock = function( $el, type, key ){
1979
+ var locks = getLocks( $el, type );
1980
+ var i = locks.indexOf(key);
1981
+ if( i < 0 ) {
1982
+ locks.push( key );
1983
+ setLocks( $el, type, locks );
1984
+ }
1985
+ };
1986
+
1987
+ /**
1988
+ * acf.unlock
1989
+ *
1990
+ * Unlocks a "lock" on an element for a given type and key
1991
+ *
1992
+ * @date 22/2/18
1993
+ * @since 5.6.9
1994
+ *
1995
+ * @param jQuery $el The element to lock.
1996
+ * @param string type The type of lock such as "condition" or "visibility".
1997
+ * @param string key The key that will be used to unlock.
1998
+ * @return void
1999
+ */
2000
+
2001
+ acf.unlock = function( $el, type, key ){
2002
+ var locks = getLocks( $el, type );
2003
+ var i = locks.indexOf(key);
2004
+ if( i > -1 ) {
2005
+ locks.splice(i, 1);
2006
+ setLocks( $el, type, locks );
2007
+ }
2008
+
2009
+ // return true if is unlocked (no locks)
2010
+ return (locks.length === 0);
2011
+ };
2012
+
2013
+ /**
2014
+ * acf.isLocked
2015
+ *
2016
+ * Returns true if a lock exists for a given type
2017
+ *
2018
+ * @date 22/2/18
2019
+ * @since 5.6.9
2020
+ *
2021
+ * @param jQuery $el The element to lock.
2022
+ * @param string type The type of lock such as "condition" or "visibility".
2023
+ * @return void
2024
+ */
2025
+
2026
+ acf.isLocked = function( $el, type ){
2027
+ return ( getLocks( $el, type ).length > 0 );
2028
+ };
2029
+
2030
+ /*
2031
+ * exists
2032
+ *
2033
+ * This function will return true if a jQuery selection exists
2034
+ *
2035
+ * @type function
2036
+ * @date 8/09/2014
2037
+ * @since 5.0.0
2038
+ *
2039
+ * @param n/a
2040
+ * @return (boolean)
2041
+ */
2042
+
2043
+ $.fn.exists = function() {
2044
+ return $(this).length>0;
2045
+ };
2046
+
2047
+
2048
+ /*
2049
+ * outerHTML
2050
+ *
2051
+ * This function will return a string containing the HTML of the selected element
2052
+ *
2053
+ * @type function
2054
+ * @date 19/11/2013
2055
+ * @since 5.0.0
2056
+ *
2057
+ * @param $.fn
2058
+ * @return (string)
2059
+ */
2060
+
2061
+ $.fn.outerHTML = function() {
2062
+ return $(this).get(0).outerHTML;
2063
+ };
2064
+
2065
+ /*
2066
+ * indexOf
2067
+ *
2068
+ * This function will provide compatibility for ie8
2069
+ *
2070
+ * @type function
2071
+ * @date 5/3/17
2072
+ * @since 5.5.10
2073
+ *
2074
+ * @param n/a
2075
+ * @return n/a
2076
+ */
2077
+
2078
+ if( !Array.prototype.indexOf ) {
2079
+
2080
+ Array.prototype.indexOf = function(val) {
2081
+ return $.inArray(val, this);
2082
+ };
2083
+
2084
+ }
2085
+
2086
+
2087
+ // Set up actions from events
2088
+ $(document).ready(function(){
2089
+ acf.doAction('ready');
2090
+ });
2091
+
2092
+ $(window).on('load', function(){
2093
+ acf.doAction('load');
2094
+ });
2095
+
2096
+ $(window).on('unload', function(){
2097
+ acf.doAction('unload');
2098
+ });
2099
+
2100
+ $(window).on('resize', function(){
2101
+ acf.doAction('resize');
2102
+ });
2103
+
2104
+ $(document).on('sortstart', function( event, ui ) {
2105
+ acf.doAction('sortstart', ui.item, ui.placeholder);
2106
+ });
2107
+
2108
+ $(document).on('sortstop', function( event, ui ) {
2109
+ acf.doAction('sortstop', ui.item, ui.placeholder);
2110
+ });
2111
+
2112
+ })(jQuery);
2113
+
2114
+ ( function( window, undefined ) {
2115
+ "use strict";
2116
+
2117
+ /**
2118
+ * Handles managing all events for whatever you plug it into. Priorities for hooks are based on lowest to highest in
2119
+ * that, lowest priority hooks are fired first.
2120
+ */
2121
+ var EventManager = function() {
2122
+ /**
2123
+ * Maintain a reference to the object scope so our public methods never get confusing.
2124
+ */
2125
+ var MethodsAvailable = {
2126
+ removeFilter : removeFilter,
2127
+ applyFilters : applyFilters,
2128
+ addFilter : addFilter,
2129
+ removeAction : removeAction,
2130
+ doAction : doAction,
2131
+ addAction : addAction,
2132
+ storage : getStorage
2133
+ };
2134
+
2135
+ /**
2136
+ * Contains the hooks that get registered with this EventManager. The array for storage utilizes a "flat"
2137
+ * object literal such that looking up the hook utilizes the native object literal hash.
2138
+ */
2139
+ var STORAGE = {
2140
+ actions : {},
2141
+ filters : {}
2142
+ };
2143
+
2144
+ function getStorage() {
2145
 
2146
+ return STORAGE;
2147
 
2148
+ };
2149
+
2150
+ /**
2151
+ * Adds an action to the event manager.
2152
+ *
2153
+ * @param action Must contain namespace.identifier
2154
+ * @param callback Must be a valid callback function before this action is added
2155
+ * @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
2156
+ * @param [context] Supply a value to be used for this
2157
+ */
2158
+ function addAction( action, callback, priority, context ) {
2159
+ if( typeof action === 'string' && typeof callback === 'function' ) {
2160
+ priority = parseInt( ( priority || 10 ), 10 );
2161
+ _addHook( 'actions', action, callback, priority, context );
2162
  }
2163
+
2164
+ return MethodsAvailable;
2165
+ }
2166
+
2167
+ /**
2168
+ * Performs an action if it exists. You can pass as many arguments as you want to this function; the only rule is
2169
+ * that the first argument must always be the action.
2170
+ */
2171
+ function doAction( /* action, arg1, arg2, ... */ ) {
2172
+ var args = Array.prototype.slice.call( arguments );
2173
+ var action = args.shift();
2174
+
2175
+ if( typeof action === 'string' ) {
2176
+ _runHook( 'actions', action, args );
2177
+ }
2178
+
2179
+ return MethodsAvailable;
2180
+ }
2181
+
2182
+ /**
2183
+ * Removes the specified action if it contains a namespace.identifier & exists.
2184
+ *
2185
+ * @param action The action to remove
2186
+ * @param [callback] Callback function to remove
2187
+ */
2188
+ function removeAction( action, callback ) {
2189
+ if( typeof action === 'string' ) {
2190
+ _removeHook( 'actions', action, callback );
2191
+ }
2192
+
2193
+ return MethodsAvailable;
2194
+ }
2195
+
2196
+ /**
2197
+ * Adds a filter to the event manager.
2198
+ *
2199
+ * @param filter Must contain namespace.identifier
2200
+ * @param callback Must be a valid callback function before this action is added
2201
+ * @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
2202
+ * @param [context] Supply a value to be used for this
2203
+ */
2204
+ function addFilter( filter, callback, priority, context ) {
2205
+ if( typeof filter === 'string' && typeof callback === 'function' ) {
2206
+ priority = parseInt( ( priority || 10 ), 10 );
2207
+ _addHook( 'filters', filter, callback, priority, context );
2208
  }
 
 
 
 
2209
 
2210
+ return MethodsAvailable;
 
 
 
2211
  }
 
 
 
 
 
 
 
 
2212
 
2213
+ /**
2214
+ * Performs a filter if it exists. You should only ever pass 1 argument to be filtered. The only rule is that
2215
+ * the first argument must always be the filter.
2216
+ */
2217
+ function applyFilters( /* filter, filtered arg, arg2, ... */ ) {
2218
+ var args = Array.prototype.slice.call( arguments );
2219
+ var filter = args.shift();
2220
 
2221
+ if( typeof filter === 'string' ) {
2222
+ return _runHook( 'filters', filter, args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2223
  }
2224
+
2225
+ return MethodsAvailable;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2226
  }
2227
+
2228
+ /**
2229
+ * Removes the specified filter if it contains a namespace.identifier & exists.
2230
+ *
2231
+ * @param filter The action to remove
2232
+ * @param [callback] Callback function to remove
2233
+ */
2234
+ function removeFilter( filter, callback ) {
2235
+ if( typeof filter === 'string') {
2236
+ _removeHook( 'filters', filter, callback );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2237
  }
2238
+
2239
+ return MethodsAvailable;
2240
+ }
2241
+
2242
+ /**
2243
+ * Removes the specified hook by resetting the value of it.
2244
+ *
2245
+ * @param type Type of hook, either 'actions' or 'filters'
2246
+ * @param hook The hook (namespace.identifier) to remove
2247
+ * @private
2248
+ */
2249
+ function _removeHook( type, hook, callback, context ) {
2250
+ if ( !STORAGE[ type ][ hook ] ) {
2251
+ return;
2252
+ }
2253
+ if ( !callback ) {
2254
+ STORAGE[ type ][ hook ] = [];
2255
+ } else {
2256
+ var handlers = STORAGE[ type ][ hook ];
2257
+ var i;
2258
+ if ( !context ) {
2259
+ for ( i = handlers.length; i--; ) {
2260
+ if ( handlers[i].callback === callback ) {
2261
+ handlers.splice( i, 1 );
2262
+ }
2263
+ }
2264
+ }
2265
+ else {
2266
+ for ( i = handlers.length; i--; ) {
2267
+ var handler = handlers[i];
2268
+ if ( handler.callback === callback && handler.context === context) {
2269
+ handlers.splice( i, 1 );
2270
+ }
2271
+ }
2272
+ }
2273
+ }
2274
+ }
2275
+
2276
+ /**
2277
+ * Adds the hook to the appropriate storage container
2278
+ *
2279
+ * @param type 'actions' or 'filters'
2280
+ * @param hook The hook (namespace.identifier) to add to our event manager
2281
+ * @param callback The function that will be called when the hook is executed.
2282
+ * @param priority The priority of this hook. Must be an integer.
2283
+ * @param [context] A value to be used for this
2284
+ * @private
2285
+ */
2286
+ function _addHook( type, hook, callback, priority, context ) {
2287
+ var hookObject = {
2288
+ callback : callback,
2289
+ priority : priority,
2290
+ context : context
2291
  };
2292
+
2293
+ // Utilize 'prop itself' : http://jsperf.com/hasownproperty-vs-in-vs-undefined/19
2294
+ var hooks = STORAGE[ type ][ hook ];
2295
+ if( hooks ) {
2296
+ hooks.push( hookObject );
2297
+ hooks = _hookInsertSort( hooks );
2298
+ }
2299
+ else {
2300
+ hooks = [ hookObject ];
2301
+ }
2302
+
2303
+ STORAGE[ type ][ hook ] = hooks;
2304
+ }
2305
+
2306
+ /**
2307
+ * Use an insert sort for keeping our hooks organized based on priority. This function is ridiculously faster
2308
+ * than bubble sort, etc: http://jsperf.com/javascript-sort
2309
+ *
2310
+ * @param hooks The custom array containing all of the appropriate hooks to perform an insert sort on.
2311
+ * @private
2312
+ */
2313
+ function _hookInsertSort( hooks ) {
2314
+ var tmpHook, j, prevHook;
2315
+ for( var i = 1, len = hooks.length; i < len; i++ ) {
2316
+ tmpHook = hooks[ i ];
2317
+ j = i;
2318
+ while( ( prevHook = hooks[ j - 1 ] ) && prevHook.priority > tmpHook.priority ) {
2319
+ hooks[ j ] = hooks[ j - 1 ];
2320
+ --j;
2321
+ }
2322
+ hooks[ j ] = tmpHook;
 
 
2323
  }
2324
+
2325
+ return hooks;
2326
+ }
2327
+
2328
+ /**
2329
+ * Runs the specified hook. If it is an action, the value is not modified but if it is a filter, it is.
2330
+ *
2331
+ * @param type 'actions' or 'filters'
2332
+ * @param hook The hook ( namespace.identifier ) to be ran.
2333
+ * @param args Arguments to pass to the action/filter. If it's a filter, args is actually a single parameter.
2334
+ * @private
2335
+ */
2336
+ function _runHook( type, hook, args ) {
2337
+ var handlers = STORAGE[ type ][ hook ];
2338
 
2339
+ if ( !handlers ) {
2340
+ return (type === 'filters') ? args[0] : false;
2341
+ }
2342
+
2343
+ var i = 0, len = handlers.length;
2344
+ if ( type === 'filters' ) {
2345
+ for ( ; i < len; i++ ) {
2346
+ args[ 0 ] = handlers[ i ].callback.apply( handlers[ i ].context, args );
2347
+ }
2348
+ } else {
2349
+ for ( ; i < len; i++ ) {
2350
+ handlers[ i ].callback.apply( handlers[ i ].context, args );
2351
+ }
2352
+ }
2353
+
2354
+ return ( type === 'filters' ) ? args[ 0 ] : true;
2355
  }
2356
+
2357
+ // return all of the publicly available methods
2358
+ return MethodsAvailable;
2359
+
2360
+ };
2361
 
2362
+ // instantiate
2363
+ acf.hooks = new EventManager();
2364
+
2365
+ } )( window );
2366
 
2367
+ (function($, undefined){
2368
 
2369
+ // Cached regex to split keys for `addEvent`.
2370
+ var delegateEventSplitter = /^(\S+)\s*(.*)$/;
2371
+
2372
+ /**
2373
+ * extend
2374
  *
2375
+ * Helper function to correctly set up the prototype chain for subclasses
2376
+ * Heavily inspired by backbone.js
2377
  *
2378
+ * @date 14/12/17
2379
+ * @since 5.6.5
 
2380
  *
2381
+ * @param object protoProps New properties for this object.
2382
+ * @return function.
2383
  */
2384
 
2385
+ var extend = function( protoProps ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2386
 
2387
+ // vars
2388
+ var Parent = this;
2389
+ var Child;
2390
+
2391
+ // The constructor function for the new subclass is either defined by you
2392
+ // (the "constructor" property in your `extend` definition), or defaulted
2393
+ // by us to simply call the parent constructor.
2394
+ if( protoProps && protoProps.hasOwnProperty('constructor') ) {
2395
+ Child = protoProps.constructor;
2396
+ } else {
2397
+ Child = function(){ return Parent.apply(this, arguments); };
2398
+ }
2399
+
2400
+ // Add static properties to the constructor function, if supplied.
2401
+ $.extend(Child, Parent);
2402
 
2403
+ // Set the prototype chain to inherit from `parent`, without calling
2404
+ // `parent`'s constructor function and add the prototype properties.
2405
+ Child.prototype = Object.create(Parent.prototype);
2406
+ $.extend(Child.prototype, protoProps);
2407
+ Child.prototype.constructor = Child;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2408
 
2409
+ // Set a convenience property in case the parent's prototype is needed later.
2410
+ //Child.prototype.__parent__ = Parent.prototype;
2411
+
2412
+ // return
2413
+ return Child;
 
 
 
 
2414
 
2415
+ };
2416
 
 
2417
 
2418
+ /**
2419
+ * Model
2420
+ *
2421
+ * Base class for all inheritence
2422
+ *
2423
+ * @date 14/12/17
2424
+ * @since 5.6.5
2425
+ *
2426
+ * @param object props
2427
+ * @return function.
2428
+ */
2429
 
2430
+ var Model = acf.Model = function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2431
 
2432
+ // generate uique client id
2433
+ this.cid = acf.uniqueId('acf');
 
 
 
 
 
 
 
 
 
2434
 
2435
+ // set vars to avoid modifying prototype
2436
+ this.data = $.extend(true, {}, this.data);
2437
 
2438
+ // pass props to setup function
2439
+ this.setup.apply(this, arguments);
 
 
 
 
 
 
 
 
 
 
2440
 
2441
+ // store on element (allow this.setup to create this.$el)
2442
+ if( this.$el && !this.$el.data('acf') ) {
2443
+ this.$el.data('acf', this);
2444
+ }
 
 
 
 
 
 
2445
 
2446
+ // initialize
2447
+ var initialize = function(){
2448
+ this.initialize();
2449
+ this.addEvents();
2450
+ this.addActions();
2451
+ this.addFilters();
2452
+ };
2453
 
2454
+ // initialize on action
2455
+ if( this.wait && !acf.didAction(this.wait) ) {
2456
+ this.addAction(this.wait, initialize);
 
 
 
 
 
 
 
 
 
 
 
2457
 
2458
+ // initialize now
2459
+ } else {
2460
+ initialize.apply(this);
2461
+ }
2462
+ };
2463
+
2464
+ // Attach all inheritable methods to the Model prototype.
2465
+ $.extend(Model.prototype, {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2466
 
2467
+ // Unique model id
2468
+ id: '',
2469
 
2470
+ // Unique client id
2471
+ cid: '',
 
 
 
 
 
 
 
 
 
 
2472
 
2473
+ // jQuery element
2474
+ $el: null,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2475
 
2476
+ // Data specific to this instance
2477
+ data: {},
2478
 
2479
+ // toggle used when changing data
2480
+ busy: false,
2481
+ changed: false,
 
 
 
 
 
 
 
 
 
2482
 
2483
+ // Setup events hooks
2484
+ events: {},
2485
+ actions: {},
2486
+ filters: {},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2487
 
2488
+ // class used to avoid nested event triggers
2489
+ eventScope: '',
2490
 
2491
+ // action to wait until initialize
2492
+ wait: false,
2493
+
2494
+ // action priority default
2495
+ priority: 10,
2496
+
2497
+ /**
2498
+ * get
2499
  *
2500
+ * Gets a specific data value
2501
  *
2502
+ * @date 14/12/17
2503
+ * @since 5.6.5
 
2504
  *
2505
+ * @param string name
2506
+ * @return mixed
2507
  */
2508
 
2509
+ get: function( name ) {
2510
+ return this.data[name];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2511
  },
2512
 
2513
+ /**
2514
+ * has
 
2515
  *
2516
+ * Returns `true` if the data exists and is not null
2517
  *
2518
+ * @date 14/12/17
2519
+ * @since 5.6.5
 
2520
  *
2521
+ * @param string name
2522
+ * @return boolean
2523
  */
2524
 
2525
+ has: function( name ) {
2526
+ return this.get(name) != null;
 
 
 
 
 
 
 
2527
  },
2528
 
2529
+ /**
2530
+ * set
 
2531
  *
2532
+ * Sets a specific data value
2533
  *
2534
+ * @date 14/12/17
2535
+ * @since 5.6.5
 
2536
  *
2537
+ * @param string name
2538
+ * @param mixed value
2539
+ * @return this
2540
  */
2541
 
2542
+ set: function( name, value, silent ) {
 
 
 
 
2543
 
2544
+ // bail if unchanged
2545
+ var prevValue = this.get(name);
2546
+ if( prevValue == value ) {
2547
+ return this;
 
 
 
2548
  }
2549
 
2550
+ // set data
2551
+ this.data[ name ] = value;
2552
 
2553
+ // trigger events
2554
+ if( !silent ) {
2555
+ this.changed = true;
2556
+ this.trigger('changed:' + name, [value]);
2557
+ this.trigger('changed', [name, value]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2558
  }
2559
 
2560
+ // return
2561
+ return this;
 
 
2562
  },
2563
 
2564
+ /**
2565
+ * inherit
 
2566
  *
2567
+ * Inherits the data from a jQuery element
2568
  *
2569
+ * @date 14/12/17
2570
+ * @since 5.6.5
 
2571
  *
2572
+ * @param jQuery $el
2573
+ * @return this
2574
  */
2575
 
2576
+ inherit: function( data ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2577
 
2578
+ // allow jQuery
2579
+ if( data instanceof jQuery ) {
2580
+ data = data.data();
 
 
 
 
 
 
 
 
 
 
 
 
2581
  }
2582
 
2583
+ // extend
2584
+ $.extend(this.data, data);
2585
+
2586
+ // return
2587
+ return this;
2588
  },
2589
 
2590
+ /**
2591
+ * prop
 
2592
  *
2593
+ * mimics the jQuery prop function
2594
  *
2595
+ * @date 4/6/18
2596
+ * @since 5.6.9
 
2597
  *
2598
+ * @param type $var Description. Default.
2599
+ * @return type Description.
2600
  */
2601
 
2602
+ prop: function(){
2603
+ return this.$el.prop.apply(this.$el, arguments);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2604
  },
2605
 
2606
+ /**
2607
+ * setup
2608
+ *
2609
+ * Run during constructor function
2610
+ *
2611
+ * @date 14/12/17
2612
+ * @since 5.6.5
2613
+ *
2614
+ * @param n/a
2615
+ * @return n/a
2616
+ */
2617
+
2618
+ setup: function( props ){
2619
+ $.extend(this, props);
2620
+ },
2621
 
2622
+ /**
2623
+ * initialize
2624
  *
2625
+ * Also run during constructor function
2626
  *
2627
+ * @date 14/12/17
2628
+ * @since 5.6.5
 
2629
  *
2630
  * @param n/a
2631
  * @return n/a
2632
  */
2633
 
2634
+ initialize: function(){},
2635
+
2636
+ /**
2637
+ * addElements
2638
+ *
2639
+ * Adds multiple jQuery elements to this object
2640
+ *
2641
+ * @date 9/5/18
2642
+ * @since 5.6.9
2643
+ *
2644
+ * @param type $var Description. Default.
2645
+ * @return type Description.
2646
+ */
2647
+
2648
+ addElements: function( elements ){
2649
+ elements = elements || this.elements || null;
2650
+ if( !elements || !Object.keys(elements).length ) return false;
2651
+ for( var i in elements ) {
2652
+ this.addElement( i, elements[i] );
2653
+ }
2654
  },
2655
 
2656
+ /**
2657
+ * addElement
2658
+ *
2659
+ * description
2660
+ *
2661
+ * @date 9/5/18
2662
+ * @since 5.6.9
2663
+ *
2664
+ * @param type $var Description. Default.
2665
+ * @return type Description.
2666
+ */
2667
+
2668
+ addElement: function( name, selector){
2669
+ this[ '$' + name ] = this.$( selector );
2670
+ },
2671
 
2672
+ /**
2673
+ * addEvents
2674
  *
2675
+ * Adds multiple event handlers
2676
  *
2677
+ * @date 14/12/17
2678
+ * @since 5.6.5
 
2679
  *
2680
+ * @param object events {event1 : callback, event2 : callback, etc }
2681
  * @return n/a
2682
  */
2683
 
2684
+ addEvents: function( events ){
2685
+ events = events || this.events || null;
2686
+ if( !events ) return false;
2687
+ for( var key in events ) {
2688
+ var match = key.match(delegateEventSplitter);
2689
+ this.on(match[1], match[2], events[key]);
2690
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2691
  },
2692
 
2693
+ /**
2694
+ * removeEvents
2695
+ *
2696
+ * Removes multiple event handlers
2697
+ *
2698
+ * @date 14/12/17
2699
+ * @since 5.6.5
2700
+ *
2701
+ * @param object events {event1 : callback, event2 : callback, etc }
2702
+ * @return n/a
2703
+ */
2704
+
2705
+ removeEvents: function( events ){
2706
+ events = events || this.events || null;
2707
+ if( !events ) return false;
2708
+ for( var key in events ) {
2709
+ var match = key.match(delegateEventSplitter);
2710
+ this.off(match[1], match[2], events[key]);
2711
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2712
  },
2713
 
2714
+ /**
2715
+ * getEventTarget
2716
+ *
2717
+ * Returns a jQUery element to tigger an event on
2718
+ *
2719
+ * @date 5/6/18
2720
+ * @since 5.6.9
2721
+ *
2722
+ * @param jQuery $el The default jQuery element. Optional.
2723
+ * @param string event The event name. Optional.
2724
+ * @return jQuery
2725
+ */
2726
+
2727
+ getEventTarget: function( $el, event ){
2728
+ return $el || this.$el || $(document);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2729
  },
2730
 
2731
+ /**
2732
+ * validateEvent
2733
+ *
2734
+ * Returns true if the event target's closest $el is the same as this.$el
2735
+ * Requires both this.el and this.$el to be defined
2736
+ *
2737
+ * @date 5/6/18
2738
+ * @since 5.6.9
2739
+ *
2740
+ * @param type $var Description. Default.
2741
+ * @return type Description.
2742
+ */
2743
+
2744
+ validateEvent: function( e ){
2745
+ if( this.eventScope ) {
2746
+ return $( e.target ).closest( this.eventScope ).is( this.$el );
2747
+ } else {
2748
+ return true;
2749
  }
 
 
 
 
 
 
 
 
2750
  },
2751
 
2752
+ /**
2753
+ * proxyEvent
2754
+ *
2755
+ * Returns a new event callback function scoped to this model
2756
+ *
2757
+ * @date 29/3/18
2758
+ * @since 5.6.9
2759
+ *
2760
+ * @param function callback
2761
+ * @return function
2762
+ */
2763
+
2764
+ proxyEvent: function( callback ){
2765
+ return this.proxy(function(e){
2766
+
2767
+ // validate
2768
+ if( !this.validateEvent(e) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2769
  return;
 
2770
  }
2771
 
2772
+ // construct args
2773
+ var args = acf.arrayArgs( arguments );
2774
+ var extraArgs = args.slice(1);
2775
+ var eventArgs = [ e, $(e.currentTarget) ].concat( extraArgs );
2776
 
2777
+ // callback
2778
+ callback.apply(this, eventArgs);
 
 
 
 
 
 
 
 
 
2779
  });
 
 
 
 
 
2780
  },
2781
 
2782
+ /**
2783
+ * on
2784
+ *
2785
+ * Adds an event handler similar to jQuery
2786
+ * Uses the instance 'cid' to namespace event
2787
+ *
2788
+ * @date 14/12/17
2789
+ * @since 5.6.5
2790
+ *
2791
+ * @param string name
2792
+ * @param string callback
2793
+ * @return n/a
2794
+ */
2795
+
2796
+ on: function( a1, a2, a3, a4 ){
2797
 
2798
+ // vars
2799
+ var $el, event, selector, callback, args;
 
 
2800
 
2801
+ // find args
2802
+ if( a1 instanceof jQuery ) {
2803
+
2804
+ // 1. args( $el, event, selector, callback )
2805
+ if( a4 ) {
2806
+ $el = a1; event = a2; selector = a3; callback = a4;
2807
+
2808
+ // 2. args( $el, event, callback )
2809
+ } else {
2810
+ $el = a1; event = a2; callback = a3;
2811
+ }
2812
+ } else {
2813
+
2814
+ // 3. args( event, selector, callback )
2815
+ if( a3 ) {
2816
+ event = a1; selector = a2; callback = a3;
2817
+
2818
+ // 4. args( event, callback )
2819
+ } else {
2820
+ event = a1; callback = a2;
2821
+ }
2822
  }
2823
 
2824
+ // element
2825
+ $el = this.getEventTarget( $el );
2826
 
2827
+ // modify callback
2828
+ if( typeof callback === 'string' ) {
2829
+ callback = this.proxyEvent( this[callback] );
2830
+ }
2831
 
2832
+ // modify event
2833
+ event = event + '.' + this.cid;
2834
 
2835
+ // args
2836
+ if( selector ) {
2837
+ args = [ event, selector, callback ];
2838
+ } else {
2839
+ args = [ event, callback ];
2840
+ }
2841
 
2842
+ // on()
2843
+ $el.on.apply($el, args);
2844
  },
 
 
 
 
 
 
 
 
 
 
 
2845
 
2846
+ /**
2847
+ * off
 
 
 
 
 
 
 
2848
  *
2849
+ * Removes an event handler similar to jQuery
2850
  *
2851
+ * @date 14/12/17
2852
+ * @since 5.6.5
 
2853
  *
2854
+ * @param string name
2855
+ * @param string callback
2856
  * @return n/a
2857
  */
2858
 
2859
+ off: function( a1, a2 ,a3 ){
 
 
 
 
 
 
 
2860
 
2861
+ // vars
2862
+ var $el, event, selector, args;
 
 
 
2863
 
2864
+ // find args
2865
+ if( a1 instanceof jQuery ) {
 
 
 
 
 
 
 
 
 
 
 
 
2866
 
2867
+ // 1. args( $el, event, selector )
2868
+ if( a3 ) {
2869
+ $el = a1; event = a2; selector = a3;
2870
 
2871
+ // 2. args( $el, event )
2872
+ } else {
2873
+ $el = a1; event = a2;
2874
+ }
2875
+ } else {
2876
+
2877
+ // 3. args( event, selector )
2878
+ if( a2 ) {
2879
+ event = a1; selector = a2;
2880
+
2881
+ // 4. args( event )
2882
+ } else {
2883
+ event = a1;
2884
+ }
2885
  }
2886
 
2887
+ // element
2888
+ $el = this.getEventTarget( $el );
2889
 
2890
+ // modify event
2891
+ event = event + '.' + this.cid;
2892
+
2893
+ // args
2894
+ if( selector ) {
2895
+ args = [ event, selector ];
2896
+ } else {
2897
+ args = [ event ];
2898
+ }
 
 
 
 
 
 
 
 
 
2899
 
2900
+ // off()
2901
+ $el.off.apply($el, args);
2902
  },
2903
 
2904
+ /**
2905
+ * trigger
2906
+ *
2907
+ * Triggers an event similar to jQuery
2908
+ *
2909
+ * @date 14/12/17
2910
+ * @since 5.6.5
2911
+ *
2912
+ * @param string name
2913
+ * @param string callback
2914
+ * @return n/a
2915
+ */
2916
+
2917
+ trigger: function( name, args, bubbles ){
2918
+ var $el = this.getEventTarget();
2919
+ if( bubbles ) {
2920
+ $el.trigger.apply( $el, arguments );
2921
+ } else {
2922
+ $el.triggerHandler.apply( $el, arguments );
2923
+ }
2924
+ return this;
2925
  },
2926
 
2927
+ /**
2928
+ * addActions
2929
+ *
2930
+ * Adds multiple action handlers
2931
+ *
2932
+ * @date 14/12/17
2933
+ * @since 5.6.5
2934
+ *
2935
+ * @param object actions {action1 : callback, action2 : callback, etc }
2936
+ * @return n/a
2937
+ */
2938
+
2939
+ addActions: function( actions ){
2940
+ actions = actions || this.actions || null;
2941
+ if( !actions ) return false;
2942
+ for( var i in actions ) {
2943
+ this.addAction( i, actions[i] );
2944
+ }
2945
  },
2946
 
2947
+ /**
2948
+ * removeActions
2949
+ *
2950
+ * Removes multiple action handlers
2951
+ *
2952
+ * @date 14/12/17
2953
+ * @since 5.6.5
2954
+ *
2955
+ * @param object actions {action1 : callback, action2 : callback, etc }
2956
+ * @return n/a
2957
+ */
2958
+
2959
+ removeActions: function( actions ){
2960
+ actions = actions || this.actions || null;
2961
+ if( !actions ) return false;
2962
+ for( var i in actions ) {
2963
+ this.removeAction( i, actions[i] );
2964
+ }
 
 
 
 
 
 
 
 
2965
  },
2966
 
2967
+ /**
2968
+ * addAction
2969
+ *
2970
+ * Adds an action using the wp.hooks library
2971
+ *
2972
+ * @date 14/12/17
2973
+ * @since 5.6.5
2974
+ *
2975
+ * @param string name
2976
+ * @param string callback
2977
+ * @return n/a
2978
+ */
2979
+
2980
+ addAction: function( name, callback, priority ){
2981
+ //console.log('addAction', name, priority);
2982
+ // defaults
2983
+ priority = priority || this.priority;
2984
 
2985
+ // modify callback
2986
+ if( typeof callback === 'string' ) {
2987
+ callback = this[ callback ];
2988
+ }
2989
 
2990
+ // add
2991
+ acf.addAction(name, callback, priority, this);
2992
 
 
 
 
 
 
 
2993
  },
 
2994
 
2995
+ /**
2996
+ * removeAction
2997
+ *
2998
+ * Remove an action using the wp.hooks library
2999
+ *
3000
+ * @date 14/12/17
3001
+ * @since 5.6.5
3002
+ *
3003
+ * @param string name
3004
+ * @param string callback
3005
+ * @return n/a
3006
+ */
3007
+
3008
+ removeAction: function( name, callback ){
3009
+ acf.removeAction(name, this[ callback ]);
3010
  },
3011
 
3012
+ /**
3013
+ * addFilters
3014
+ *
3015
+ * Adds multiple filter handlers
3016
+ *
3017
+ * @date 14/12/17
3018
+ * @since 5.6.5
3019
+ *
3020
+ * @param object filters {filter1 : callback, filter2 : callback, etc }
3021
+ * @return n/a
3022
+ */
3023
+
3024
+ addFilters: function( filters ){
3025
+ filters = filters || this.filters || null;
3026
+ if( !filters ) return false;
3027
+ for( var i in filters ) {
3028
+ this.addFilter( i, filters[i] );
3029
+ }
3030
  },
3031
 
3032
+ /**
3033
+ * addFilter
3034
+ *
3035
+ * Adds a filter using the wp.hooks library
3036
+ *
3037
+ * @date 14/12/17
3038
+ * @since 5.6.5
3039
+ *
3040
+ * @param string name
3041
+ * @param string callback
3042
+ * @return n/a
3043
+ */
3044
+
3045
+ addFilter: function( name, callback, priority ){
3046
 
3047
+ // defaults
3048
+ priority = priority || this.priority;
3049
 
3050
+ // modify callback
3051
+ if( typeof callback === 'string' ) {
3052
+ callback = this[ callback ];
3053
+ }
 
 
3054
 
3055
+ // add
3056
+ acf.addFilter(name, callback, priority, this);
3057
 
3058
+ },
 
 
 
 
 
 
 
 
 
3059
 
3060
+ /**
3061
+ * removeFilters
3062
+ *
3063
+ * Removes multiple filter handlers
3064
+ *
3065
+ * @date 14/12/17
3066
+ * @since 5.6.5
3067
+ *
3068
+ * @param object filters {filter1 : callback, filter2 : callback, etc }
3069
+ * @return n/a
3070
+ */
3071
 
3072
+ removeFilters: function( filters ){
3073
+ filters = filters || this.filters || null;
3074
+ if( !filters ) return false;
3075
+ for( var i in filters ) {
3076
+ this.removeFilter( i, filters[i] );
3077
+ }
3078
  },
3079
 
3080
+ /**
3081
+ * removeFilter
3082
+ *
3083
+ * Remove a filter using the wp.hooks library
3084
+ *
3085
+ * @date 14/12/17
3086
+ * @since 5.6.5
3087
+ *
3088
+ * @param string name
3089
+ * @param string callback
3090
+ * @return n/a
3091
+ */
3092
+
3093
+ removeFilter: function( name, callback ){
3094
+ acf.removeFilter(name, this[ callback ]);
3095
  },
3096
 
3097
+ /**
3098
+ * $
 
3099
  *
3100
+ * description
3101
  *
3102
+ * @date 16/12/17
3103
+ * @since 5.6.5
 
3104
  *
3105
+ * @param type $var Description. Default.
3106
+ * @return type Description.
3107
  */
3108
 
3109
+ $: function( selector ){
3110
+ return this.$el.find( selector );
 
 
 
 
 
 
 
 
 
3111
  },
3112
 
3113
+ /**
3114
+ * remove
 
3115
  *
3116
+ * Removes the element and listenters
3117
  *
3118
+ * @date 19/12/17
3119
+ * @since 5.6.5
 
3120
  *
3121
+ * @param type $var Description. Default.
3122
+ * @return type Description.
3123
  */
3124
 
3125
+ remove: function(){
3126
+ this.removeEvents();
3127
+ this.removeActions();
3128
+ this.removeFilters();
3129
+ this.$el.remove();
 
 
 
 
3130
  },
3131
 
3132
+ /**
3133
+ * setTimeout
 
3134
  *
3135
+ * description
 
 
3136
  *
3137
+ * @date 16/1/18
3138
+ * @since 5.6.5
 
3139
  *
3140
+ * @param type $var Description. Default.
3141
+ * @return type Description.
3142
  */
3143
 
3144
+ setTimeout: function( callback, milliseconds ){
3145
+ return setTimeout( this.proxy(callback), milliseconds );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3146
  },
3147
 
3148
+ /**
3149
+ * time
 
3150
  *
3151
+ * used for debugging
3152
  *
3153
+ * @date 7/3/18
3154
+ * @since 5.6.9
 
3155
  *
3156
+ * @param type $var Description. Default.
3157
+ * @return type Description.
3158
  */
3159
 
3160
+ time: function(){
3161
+ console.time( this.id || this.cid );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3162
  },
3163
 
3164
+ /**
3165
+ * timeEnd
 
3166
  *
3167
+ * used for debugging
3168
  *
3169
+ * @date 7/3/18
3170
+ * @since 5.6.9
 
3171
  *
3172
+ * @param type $var Description. Default.
3173
+ * @return type Description.
3174
  */
3175
 
3176
+ timeEnd: function(){
3177
+ console.timeEnd( this.id || this.cid );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3178
  },
3179
 
3180
+ /**
3181
+ * show
 
3182
  *
3183
+ * description
3184
  *
3185
+ * @date 15/3/18
3186
+ * @since 5.6.9
 
3187
  *
3188
+ * @param type $var Description. Default.
3189
+ * @return type Description.
3190
  */
3191
 
3192
+ show: function(){
3193
+ acf.show( this.$el );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3194
  },
3195
 
3196
 
3197
+ /**
3198
+ * hide
3199
  *
3200
+ * description
3201
  *
3202
+ * @date 15/3/18
3203
+ * @since 5.6.9
 
3204
  *
3205
+ * @param type $var Description. Default.
3206
+ * @return type Description.
3207
  */
3208
 
3209
+ hide: function(){
3210
+ acf.hide( this.$el );
 
 
 
 
 
 
 
3211
  },
3212
 
3213
+ /**
3214
+ * proxy
 
3215
  *
3216
+ * Returns a new function scoped to this model
3217
  *
3218
+ * @date 29/3/18
3219
+ * @since 5.6.9
 
3220
  *
3221
+ * @param function callback
3222
+ * @return function
3223
  */
3224
 
3225
+ proxy: function( callback ){
3226
+ return $.proxy( callback, this );
 
 
3227
  }
3228
 
3229
+
3230
  });
3231
+
3232
+ // Set up inheritance for the model
3233
+ Model.extend = extend;
3234
+
3235
+ // Global model storage
3236
+ acf.models = {};
3237
+
3238
+ /**
3239
+ * acf.getInstance
3240
+ *
3241
+ * This function will get an instance from an element
3242
+ *
3243
+ * @date 5/3/18
3244
+ * @since 5.6.9
3245
+ *
3246
+ * @param type $var Description. Default.
3247
+ * @return type Description.
3248
+ */
3249
+
3250
+ acf.getInstance = function( $el ){
3251
+ return $el.data('acf');
3252
+ };
3253
+
3254
+ /**
3255
+ * acf.getInstances
3256
+ *
3257
+ * This function will get an array of instances from multiple elements
3258
+ *
3259
+ * @date 5/3/18
3260
+ * @since 5.6.9
3261
+ *
3262
+ * @param type $var Description. Default.
3263
+ * @return type Description.
3264
+ */
3265
+
3266
+ acf.getInstances = function( $el ){
3267
+ var instances = [];
3268
+ $el.each(function(){
3269
+ instances.push( acf.getInstance( $(this) ) );
3270
+ });
3271
+ return instances;
3272
+ };
3273
+
3274
  })(jQuery);
3275
 
3276
+ (function($, undefined){
3277
 
3278
+ acf.models.Popup = acf.Model.extend({
3279
+
3280
+ data: {
3281
+ title: '',
3282
+ content: '',
3283
+ width: 0,
3284
+ height: 0,
3285
+ loading: false,
3286
+ },
3287
 
3288
  events: {
3289
+ 'click [data-event="close"]': 'onClickClose',
3290
+ 'click .acf-close-popup': 'onClickClose',
3291
+ },
3292
+
3293
+ setup: function( props ){
3294
+ $.extend(this.data, props);
3295
+ this.$el = $(this.tmpl());
3296
  },
3297
 
3298
+ initialize: function(){
3299
+ this.render();
3300
+ this.open();
3301
+ },
3302
 
3303
+ tmpl: function(){
3304
+ return [
3305
+ '<div id="acf-popup">',
3306
+ '<div class="acf-popup-box acf-box">',
3307
+ '<div class="title"><h3></h3><a href="#" class="acf-icon -cancel grey" data-event="close"></a></div>',
3308
+ '<div class="inner"></div>',
3309
+ '<div class="loading"><i class="acf-loading"></i></div>',
3310
+ '</div>',
3311
+ '<div class="bg" data-event="close"></div>',
3312
+ '</div>'
3313
+ ].join('');
3314
+ },
3315
 
3316
+ render: function(){
3317
+
3318
+ // vars
3319
+ var title = this.get('title');
3320
+ var content = this.get('content');
3321
+ var loading = this.get('loading');
3322
+ var width = this.get('width');
3323
+ var height = this.get('height');
3324
+
3325
+ // html
3326
+ this.title( title );
3327
+ this.content( content );
3328
+
3329
+ // width
3330
+ if( width ) {
3331
+ this.$('.acf-popup-box').css('width', width);
3332
+ }
3333
+
3334
+ // height
3335
+ if( height ) {
3336
+ this.$('.acf-popup-box').css('min-height', height);
3337
+ }
3338
 
3339
+ // loading
3340
+ this.loading( loading );
 
3341
 
3342
+ // action
3343
+ acf.doAction('append', this.$el);
3344
+
3345
+ },
3346
+
3347
+ update: function( props ){
3348
+ this.data = acf.parseArgs(props, this.data);
3349
+ this.render();
3350
  },
3351
 
3352
+ title: function( title ){
3353
+ this.$('.title:first h3').html( title );
 
 
3354
  },
3355
 
3356
+ content: function( content ){
3357
+ this.$('.inner:first').html( content );
 
 
3358
  },
3359
 
3360
+ loading: function( show ){
3361
+ var $loading = this.$('.loading:first');
3362
+ show ? $loading.show() : $loading.hide();
3363
+ },
3364
+
3365
+ open: function(){
3366
+ $('body').append( this.$el );
3367
  },
3368
 
3369
+ close: function(){
3370
+ this.remove();
 
 
 
 
 
 
 
 
 
 
 
3371
  },
3372
 
3373
+ onClickClose: function( e, $el ){
3374
+ e.preventDefault();
3375
+ this.close();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3376
  }
3377
 
3378
  });
3379
 
3380
+ /**
3381
+ * newPopup
 
3382
  *
3383
+ * Creates a new Popup with the supplied props
3384
  *
3385
+ * @date 17/12/17
3386
+ * @since 5.6.5
 
3387
  *
3388
+ * @param object props
3389
+ * @return object
3390
  */
3391
 
3392
+ acf.newPopup = function( props ){
3393
+ return new acf.models.Popup( props );
3394
+ };
3395
+
3396
+ })(jQuery);
3397
+
3398
+ (function($, undefined){
3399
+
3400
+ acf.unload = new acf.Model({
3401
 
3402
+ wait: 'load',
3403
+ active: true,
3404
+ changed: false,
3405
+
3406
+ actions: {
3407
+ 'change_field': 'startListening',
3408
+ 'validation_failure': 'startListening'
3409
+ },
3410
 
3411
  events: {
3412
+ 'submit form': 'stopListening'
 
 
 
3413
  },
3414
 
3415
+ reset: function(){
3416
+ this.stopListening();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3417
  },
3418
 
3419
+ startListening: function(){
3420
 
3421
+ // bail ealry if already changed, not active
3422
+ if( this.changed || !this.active ) {
3423
+ return;
 
 
 
 
 
3424
  }
3425
 
3426
+ // update
3427
+ this.changed = true;
3428
 
3429
+ // add event
3430
+ $(window).on('beforeunload', this.onUnload);
 
 
 
 
3431
 
3432
  },
3433
 
3434
+ stopListening: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3435
 
3436
+ // update
3437
+ this.changed = false;
3438
 
3439
+ // remove event
3440
+ $(window).off('beforeunload', this.onUnload);
3441
 
3442
  },
3443
 
3444
+ onUnload: function(){
3445
+ return acf.__('The changes you made will be lost if you navigate away from this page');
3446
+ }
3447
+
3448
+ });
3449
+
3450
+ })(jQuery);
3451
+
3452
+ (function($, undefined){
3453
+
3454
+ var panel = new acf.Model({
3455
+
3456
+ events: {
3457
+ 'click .acf-panel-title': 'onClick',
3458
  },
3459
 
3460
+ onClick: function( e, $el ){
3461
+ e.preventDefault();
3462
+ this.toggle( $el.parent() );
 
 
 
 
 
 
 
 
 
 
 
 
3463
  },
3464
 
3465
+ isOpen: function( $el ) {
3466
+ return $el.hasClass('-open');
 
 
 
 
 
 
 
 
 
 
 
3467
  },
3468
 
3469
+ toggle: function( $el ){
3470
+ this.isOpen($el) ? this.close( $el ) : this.open( $el );
 
 
 
 
 
 
 
 
 
 
 
 
3471
  },
3472
 
3473
+ open: function( $el ){
3474
+ $el.addClass('-open');
3475
+ $el.find('.acf-panel-title i').attr('class', 'dashicons dashicons-arrow-down');
3476
+ },
3477
+
3478
+ close: function( $el ){
3479
+ $el.removeClass('-open');
3480
+ $el.find('.acf-panel-title i').attr('class', 'dashicons dashicons-arrow-right');
 
 
 
 
 
3481
  }
3482
+
3483
  });
3484
+
 
 
 
 
3485
  })(jQuery);
3486
 
3487
+ (function($, undefined){
3488
 
3489
+ var Notice = acf.Model.extend({
 
 
 
3490
 
3491
+ data: {
3492
+ text: '',
3493
+ type: '',
3494
+ timeout: 0,
3495
+ dismiss: true,
3496
+ target: false,
3497
+ close: function(){}
3498
  },
3499
 
3500
+ events: {
3501
+ 'click .acf-notice-dismiss': 'onClickClose',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3502
  },
3503
 
3504
+ tmpl: function(){
3505
+ return '<div class="acf-notice"></div>';
3506
+ },
3507
 
3508
+ setup: function( props ){
3509
+ $.extend(this.data, props);
3510
+ this.$el = $(this.tmpl());
3511
+ },
 
 
 
 
 
 
 
 
3512
 
3513
+ initialize: function(){
 
 
 
 
 
3514
 
3515
+ // render
3516
+ this.render();
 
3517
 
3518
+ // show
3519
+ this.show();
3520
  },
3521
 
3522
+ render: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3523
 
3524
+ // class
3525
+ this.type( this.get('type') );
3526
 
3527
+ // text
3528
+ this.html( '<p>' + this.get('text') + '</p>' );
 
 
 
 
3529
 
3530
+ // close
3531
+ if( this.get('dismiss') ) {
3532
+ this.$el.append('<a href="#" class="acf-notice-dismiss acf-icon -cancel small"></a>');
3533
+ this.$el.addClass('-dismiss');
3534
+ }
3535
 
3536
+ // timeout
3537
+ var timeout = this.get('timeout');
3538
+ if( timeout ) {
3539
+ this.away( timeout );
3540
+ }
3541
  },
3542
 
3543
+ update: function( props ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3544
 
3545
+ // update
3546
+ $.extend(this.data, props);
3547
 
3548
+ // re-initialize
3549
+ this.initialize();
 
3550
  },
3551
 
3552
+ show: function(){
3553
+ var $target = this.get('target');
3554
+ if( $target ) {
3555
+ $target.prepend( this.$el );
 
 
 
3556
  }
3557
+ },
3558
+
3559
+ hide: function(){
3560
+ this.$el.remove();
3561
+ },
3562
+
3563
+ away: function( timeout ){
3564
+ this.setTimeout(function(){
3565
+ acf.remove( this.$el );
3566
+ }, timeout );
3567
+ },
3568
+
3569
+ type: function( type ){
3570
 
3571
+ // remove prev type
3572
+ var prevType = this.get('type');
3573
+ if( prevType ) {
3574
+ this.$el.removeClass('-' + prevType);
 
 
3575
  }
3576
 
3577
+ // add new type
3578
+ this.$el.addClass('-' + type);
3579
 
3580
+ // backwards compatibility
3581
+ if( type == 'error' ) {
3582
+ this.$el.addClass('acf-error-message');
3583
+ }
 
 
 
3584
  },
3585
 
3586
+ html: function( html ){
3587
+ this.$el.html( html );
 
 
 
 
 
 
 
 
 
 
 
3588
  },
3589
 
3590
+ text: function( text ){
3591
+ this.$('p').html( text );
3592
+ },
3593
 
3594
+ onClickClose: function( e, $el ){
3595
+ e.preventDefault();
3596
+ this.get('close').apply(this, arguments);
3597
+ this.remove();
3598
+ }
3599
+ });
3600
+
3601
+ acf.newNotice = function( props ){
 
 
 
 
3602
 
3603
+ // ensure object
3604
+ if( typeof props !== 'object' ) {
3605
+ props = { text: props };
3606
+ }
3607
+
3608
+ // instantiate
3609
+ return new Notice( props );
3610
+ };
3611
+
3612
+ var noticeManager = new acf.Model({
3613
+ wait: 'prepare',
3614
+ priority: 1,
3615
+ initialize: function(){
3616
 
3617
+ // vars
3618
+ var $notice = $('.acf-admin-notice');
 
 
 
 
 
3619
 
3620
+ // move to avoid WP flicker
3621
+ if( $notice.length ) {
3622
+ $('h1:first').after( $notice );
3623
+ }
3624
+ }
3625
+ });
 
3626
 
 
3627
 
3628
+ })(jQuery);
3629
+
3630
+ (function($, undefined){
3631
+
3632
+ acf.models.Postbox = acf.Model.extend({
3633
+
3634
+ data: {
3635
+ id: '',
3636
+ key: '',
3637
+ style: 'default',
3638
+ label: 'top',
3639
+ editLink: '',
3640
+ editTitle: '',
3641
+ visibility: true
3642
+ },
3643
+
3644
+ setup: function( props ){
3645
+ $.extend(this.data, props);
3646
+ },
3647
+
3648
+ initialize: function(){
3649
 
3650
+ // vars
3651
+ var id = this.get('id');
3652
+ var $postbox = $('#' + id);
3653
+ var $toggle = $('#' + id + '-hide');
3654
+ var $label = $toggle.parent();
 
 
 
 
3655
 
3656
+ // add class
3657
+ $postbox.addClass('acf-postbox');
3658
+ $label.addClass('acf-postbox-toggle');
3659
 
3660
+ // remove class
3661
+ $postbox.removeClass('hide-if-js');
3662
+ $label.removeClass('hide-if-js');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3663
 
3664
+ // field group style
3665
+ var style = this.get('style');
3666
+ if( style !== 'default' ) {
3667
+ $postbox.addClass( style );
3668
+ }
3669
 
3670
+ // .inside class
3671
+ $postbox.children('.inside').addClass('acf-fields').addClass('-' + this.get('label'));
3672
 
 
 
 
 
 
3673
 
3674
+ // visibility
3675
+ if( this.get('visibility') ) {
3676
+ $toggle.prop('checked', true);
3677
+ } else {
3678
+ $postbox.addClass('acf-hidden');
3679
+ $label.addClass('acf-hidden');
3680
+ }
3681
 
3682
+ // edit link
3683
+ var editLink = this.get('editLink');
3684
+ var editTitle = this.get('editTitle');
3685
+ if( editLink ) {
3686
 
3687
+ $postbox.children('.hndle').append('<a href="' + editLink + '" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="' + editTitle + '"></a>');
3688
  }
3689
+ }
3690
+ });
3691
+
3692
+ acf.newPostbox = function( props ){
3693
+ return new acf.models.Postbox( props );
3694
+ };
3695
+
3696
+ })(jQuery);
3697
+
3698
+ (function($, undefined){
3699
+
3700
+ acf.newTooltip = function( props ){
3701
+
3702
+ // ensure object
3703
+ if( typeof props !== 'object' ) {
3704
+ props = { text: props };
3705
+ }
3706
+
3707
+ // confirmRemove
3708
+ if( props.confirmRemove !== undefined ) {
3709
 
3710
+ props.textConfirm = acf.__('Remove');
3711
+ props.textCancel = acf.__('Cancel');
3712
+ return new TooltipConfirm( props );
3713
 
3714
+ // confirm
3715
+ } else if( props.confirm !== undefined ) {
3716
 
3717
+ return new TooltipConfirm( props );
3718
+
3719
+ // default
3720
+ } else {
3721
+ return new Tooltip( props );
3722
+ }
3723
+
3724
+ };
3725
+
3726
+ var Tooltip = acf.Model.extend({
3727
+
3728
+ data: {
3729
+ text: '',
3730
+ timeout: 0,
3731
+ target: null
3732
  },
3733
 
3734
+ tmpl: function(){
3735
+ return '<div class="acf-tooltip"></div>';
3736
+ },
3737
+
3738
+ setup: function( props ){
3739
+ $.extend(this.data, props);
3740
+ this.$el = $(this.tmpl());
3741
+ },
3742
+
3743
+ initialize: function(){
3744
 
3745
+ // render
3746
+ this.render();
3747
 
3748
+ // append
3749
+ this.show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3750
 
3751
+ // position
3752
+ this.position();
3753
 
3754
+ // timeout
3755
+ var timeout = this.get('timeout');
3756
+ if( timeout ) {
3757
+ setTimeout( $.proxy(this.fade, this), timeout );
3758
+ }
3759
+ },
3760
+
3761
+ update: function( props ){
3762
+ $.extend(this.data, props);
3763
+ this.initialize();
3764
+ },
3765
+
3766
+ render: function(){
3767
+ this.html( this.get('text') );
3768
+ },
3769
+
3770
+ show: function(){
3771
+ $('body').append( this.$el );
3772
+ },
3773
+
3774
+ hide: function(){
3775
+ this.$el.remove();
3776
+ },
3777
+
3778
+ fade: function(){
3779
+
3780
+ // add class
3781
+ this.$el.addClass('acf-fade-up');
3782
+
3783
+ // remove
3784
+ this.setTimeout(function(){
3785
+ this.remove();
3786
+ }, 250);
3787
+ },
3788
+
3789
+ html: function( html ){
3790
+ this.$el.html( html );
3791
+ },
3792
+
3793
+ position: function(){
3794
+
3795
+ // vars
3796
+ var $tooltip = this.$el;
3797
+ var $target = this.get('target');
3798
+ if( !$target ) return;
3799
+
3800
+ // reset class
3801
+ $tooltip.removeClass('right left bottom top');
3802
+
3803
+ // position
3804
+ var tolerance = 10;
3805
+ var target_w = $target.outerWidth();
3806
+ var target_h = $target.outerHeight();
3807
+ var target_t = $target.offset().top;
3808
+ var target_l = $target.offset().left;
3809
+ var tooltip_w = $tooltip.outerWidth();
3810
+ var tooltip_h = $tooltip.outerHeight();
3811
+
3812
+ // calculate top
3813
+ var top = target_t - tooltip_h;
3814
+ var left = target_l + (target_w / 2) - (tooltip_w / 2);
3815
+
3816
+ // too far left
3817
+ if( left < tolerance ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3818
 
3819
+ $tooltip.addClass('right');
3820
+ left = target_l + target_w;
3821
+ top = target_t + (target_h / 2) - (tooltip_h / 2);
3822
+
3823
+ // too far right
3824
+ } else if( (left + tooltip_w + tolerance) > $(window).width() ) {
3825
 
3826
+ $tooltip.addClass('left');
3827
+ left = target_l - tooltip_w;
3828
+ top = target_t + (target_h / 2) - (tooltip_h / 2);
3829
+
3830
+ // too far top
3831
+ } else if( top - $(window).scrollTop() < tolerance ) {
3832
 
3833
+ $tooltip.addClass('bottom');
3834
+ top = target_t + target_h;
3835
+
3836
+ } else {
3837
 
3838
+ $tooltip.addClass('top');
3839
 
3840
+ }
3841
+
3842
+ // update css
3843
+ $tooltip.css({ 'top': top, 'left': left });
3844
+ }
3845
+ });
3846
+
3847
+ var TooltipConfirm = Tooltip.extend({
3848
+
3849
+ data: {
3850
+ text: '',
3851
+ textConfirm: '',
3852
+ textCancel: '',
3853
+ target: null,
3854
+ targetConfirm: true,
3855
+ confirm: function(){},
3856
+ cancel: function(){},
3857
+ context: false
3858
+ },
3859
+
3860
+ events: {
3861
+ 'click [data-event="cancel"]': 'onCancel',
3862
+ 'click [data-event="confirm"]': 'onConfirm',
3863
+ },
3864
+
3865
+ addEvents: function(){
3866
 
3867
+ // add events
3868
+ acf.Model.prototype.addEvents.apply(this);
3869
 
3870
+ // vars
3871
+ var $document = $(document);
3872
+ var $target = this.get('target');
3873
+
3874
+ // add global 'cancel' click event
3875
+ // - use timeout to avoid the current 'click' event triggering the onCancel function
3876
+ this.setTimeout(function(){
3877
+ this.on( $document, 'click', 'onCancel' );
3878
+ });
3879
 
3880
+ // add target 'confirm' click event
3881
+ // - allow setting to control this feature
3882
+ if( this.get('targetConfirm') ) {
3883
+ this.on( $target, 'click', 'onConfirm' );
3884
+ }
3885
  },
3886
 
3887
+ removeEvents: function(){
3888
 
3889
+ // remove events
3890
+ acf.Model.prototype.removeEvents.apply(this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3891
 
3892
+ // vars
3893
+ var $document = $(document);
3894
+ var $target = this.get('target');
3895
 
3896
+ // remove custom events
3897
+ this.off( $document, 'click' );
3898
+ this.off( $target, 'click' );
3899
  },
3900
 
3901
+ render: function(){
3902
+
3903
+ // defaults
3904
+ var text = this.get('text') || acf.__('Are you sure?');
3905
+ var textConfirm = this.get('textConfirm') || acf.__('Yes');
3906
+ var textCancel = this.get('textCancel') || acf.__('No');
3907
+
3908
+ // html
3909
+ var html = [
3910
+ text,
3911
+ '<a href="#" data-event="confirm">' + textConfirm + '</a>',
3912
+ '<a href="#" data-event="cancel">' + textCancel + '</a>'
3913
+ ].join(' ');
3914
+
3915
+ // html
3916
+ this.html( html );
3917
+
3918
+ // class
3919
+ this.$el.addClass('-confirm');
3920
+ },
3921
 
3922
+ onCancel: function( e, $el ){
3923
+
3924
+ // prevent default
3925
+ e.preventDefault();
3926
+ e.stopImmediatePropagation();
3927
+
3928
+ // callback
3929
+ var callback = this.get('cancel');
3930
+ var context = this.get('context') || this;
3931
+ callback.apply( context, arguments );
3932
+
3933
+ //remove
3934
+ this.remove();
3935
+ },
3936
 
3937
+ onConfirm: function( e, $el ){
3938
 
3939
+ // prevent default
3940
+ e.preventDefault();
3941
+ e.stopImmediatePropagation();
 
 
 
 
3942
 
3943
+ // callback
3944
+ var callback = this.get('confirm');
3945
+ var context = this.get('context') || this;
3946
+ callback.apply( context, arguments );
3947
 
3948
+ //remove
3949
+ this.remove();
3950
+ }
3951
+ });
3952
+
3953
+ // storage
3954
+ acf.models.Tooltip = Tooltip;
3955
+ acf.models.TooltipConfirm = TooltipConfirm;
3956
+
3957
+
3958
+ /**
3959
+ * tooltipManager
3960
+ *
3961
+ * description
3962
+ *
3963
+ * @date 17/4/18
3964
+ * @since 5.6.9
3965
+ *
3966
+ * @param type $var Description. Default.
3967
+ * @return type Description.
3968
+ */
3969
+
3970
+ var tooltipHoverHelper = new acf.Model({
3971
 
3972
+ tooltip: false,
3973
+
3974
+ events: {
3975
+ 'mouseenter .acf-js-tooltip': 'showTitle',
3976
+ 'mouseup .acf-js-tooltip': 'hideTitle',
3977
+ 'mouseleave .acf-js-tooltip': 'hideTitle'
3978
+ },
3979
+
3980
+ showTitle: function( e, $el ){
3981
 
3982
+ // vars
3983
+ var title = $el.attr('title');
3984
 
3985
+ // bail ealry if no title
3986
+ if( !title ) {
3987
+ return;
 
 
 
 
 
 
 
 
3988
  }
3989
 
3990
+ // clear title to avoid default browser tooltip
3991
+ $el.attr('title', '');
3992
 
3993
+ // create
3994
+ if( !this.tooltip ) {
3995
+ this.tooltip = acf.newTooltip({
3996
+ text: title,
3997
+ target: $el
3998
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
3999
 
4000
+ // update
4001
+ } else {
4002
+ this.tooltip.update({
4003
+ text: title,
4004
+ target: $el
4005
+ });
4006
  }
4007
 
4008
+ },
4009
+
4010
+ hideTitle: function( e, $el ){
4011
 
4012
+ // hide tooltip
4013
+ this.tooltip.hide();
4014
 
4015
+ // restore title
4016
+ $el.attr('title', this.tooltip.get('text'));
4017
+ }
4018
+ });
4019
+
4020
+ })(jQuery);
4021
+
4022
+ (function($, undefined){
4023
+
4024
+ // vars
4025
+ var storage = [];
4026
+
4027
+ /**
4028
+ * acf.Field
4029
+ *
4030
+ * description
4031
+ *
4032
+ * @date 23/3/18
4033
+ * @since 5.6.9
4034
+ *
4035
+ * @param type $var Description. Default.
4036
+ * @return type Description.
4037
+ */
4038
+
4039
+ acf.Field = acf.Model.extend({
4040
+
4041
+ // field type
4042
+ type: '',
4043
+
4044
+ // class used to avoid nested event triggers
4045
+ eventScope: '.acf-field',
4046
+
4047
+ // initialize events on 'ready'
4048
+ wait: 'ready',
4049
+
4050
+ /**
4051
+ * setup
4052
+ *
4053
+ * Called during the constructor function to setup this field ready for initialization
4054
+ *
4055
+ * @date 8/5/18
4056
+ * @since 5.6.9
4057
+ *
4058
+ * @param jQuery $field The field element.
4059
+ * @return void
4060
+ */
4061
+
4062
+ setup: function( $field ){
4063
 
4064
+ // set $el
4065
+ this.$el = $field;
4066
 
4067
+ // inherit $field data
4068
+ this.inherit( $field );
4069
 
4070
+ // inherit controll data
4071
+ this.inherit( this.$control() );
4072
+ },
4073
+
4074
+ /**
4075
+ * val
4076
+ *
4077
+ * Sets or returns the field's value
4078
+ *
4079
+ * @date 8/5/18
4080
+ * @since 5.6.9
4081
+ *
4082
+ * @param mixed val Optional. The value to set
4083
+ * @return mixed
4084
+ */
4085
+
4086
+ val: function( val ){
4087
+ if( val !== undefined ) {
4088
+ return this.setValue( val );
4089
+ } else {
4090
+ return this.prop('disabled') ? null : this.getValue();
4091
+ }
4092
+ },
4093
+
4094
+ /**
4095
+ * getValue
4096
+ *
4097
+ * returns the field's value
4098
+ *
4099
+ * @date 8/5/18
4100
+ * @since 5.6.9
4101
+ *
4102
+ * @param void
4103
+ * @return mixed
4104
+ */
4105
+
4106
+ getValue: function(){
4107
+ return this.$input().val();
4108
+ },
4109
+
4110
+ /**
4111
+ * setValue
4112
+ *
4113
+ * sets the field's value and returns true if changed
4114
+ *
4115
+ * @date 8/5/18
4116
+ * @since 5.6.9
4117
+ *
4118
+ * @param mixed val
4119
+ * @return boolean. True if changed.
4120
+ */
4121
+
4122
+ setValue: function( val ){
4123
+ return acf.val( this.$input(), val );
4124
+ },
4125
+
4126
+ /**
4127
+ * __
4128
+ *
4129
+ * i18n helper to be removed
4130
+ *
4131
+ * @date 8/5/18
4132
+ * @since 5.6.9
4133
+ *
4134
+ * @param type $var Description. Default.
4135
+ * @return type Description.
4136
+ */
4137
+
4138
+ __: function( string ){
4139
+ return acf._e( this.type, string );
4140
+ },
4141
+
4142
+ /**
4143
+ * $control
4144
+ *
4145
+ * returns the control jQuery element used for inheriting data. Uses this.control setting.
4146
+ *
4147
+ * @date 8/5/18
4148
+ * @since 5.6.9
4149
+ *
4150
+ * @param void
4151
+ * @return jQuery
4152
+ */
4153
+
4154
+ $control: function(){
4155
+ return false;
4156
+ },
4157
+
4158
+ /**
4159
+ * $input
4160
+ *
4161
+ * returns the input jQuery element used for saving values. Uses this.input setting.
4162
+ *
4163
+ * @date 8/5/18
4164
+ * @since 5.6.9
4165
+ *
4166
+ * @param void
4167
+ * @return jQuery
4168
+ */
4169
+
4170
+ $input: function(){
4171
+ return this.$('[name]:first');
4172
+ },
4173
+
4174
+ /**
4175
+ * $inputWrap
4176
+ *
4177
+ * description
4178
+ *
4179
+ * @date 12/5/18
4180
+ * @since 5.6.9
4181
+ *
4182
+ * @param type $var Description. Default.
4183
+ * @return type Description.
4184
+ */
4185
+
4186
+ $inputWrap: function(){
4187
+ return this.$('.acf-input:first');
4188
+ },
4189
+
4190
+ /**
4191
+ * $inputWrap
4192
+ *
4193
+ * description
4194
+ *
4195
+ * @date 12/5/18
4196
+ * @since 5.6.9
4197
+ *
4198
+ * @param type $var Description. Default.
4199
+ * @return type Description.
4200
+ */
4201
+
4202
+ $labelWrap: function(){
4203
+ return this.$('.acf-label:first');
4204
+ },
4205
+
4206
+ /**
4207
+ * getInputName
4208
+ *
4209
+ * Returns the field's input name
4210
+ *
4211
+ * @date 8/5/18
4212
+ * @since 5.6.9
4213
+ *
4214
+ * @param void
4215
+ * @return string
4216
+ */
4217
+
4218
+ getInputName: function(){
4219
+ return this.$input().attr('name') || '';
4220
+ },
4221
+
4222
+ /**
4223
+ * parent
4224
+ *
4225
+ * returns the field's parent field or false on failure.
4226
+ *
4227
+ * @date 8/5/18
4228
+ * @since 5.6.9
4229
+ *
4230
+ * @param void
4231
+ * @return object|false
4232
+ */
4233
+
4234
+ parent: function() {
4235
 
4236
+ // vars
4237
+ var parents = this.parents();
4238
 
4239
  // return
4240
+ return parents.length ? parents[0] : false;
 
4241
  },
4242
 
4243
+ /**
4244
+ * parents
4245
+ *
4246
+ * description
4247
+ *
4248
+ * @date 9/7/18
4249
+ * @since 5.6.9
4250
+ *
4251
+ * @param type $var Description. Default.
4252
+ * @return type Description.
4253
+ */
4254
+
4255
+ parents: function(){
4256
 
4257
  // vars
4258
+ var $parents = this.$el.parents('.acf-field');
 
 
 
 
 
 
 
 
 
 
4259
 
4260
+ // convert
4261
+ var parents = acf.getFields( $parents );
4262
 
4263
+ // return
4264
+ return parents;
4265
+ },
4266
+
4267
+ show: function( lockKey, context ){
 
4268
 
4269
+ // show field and store result
4270
+ var changed = acf.show( this.$el, lockKey );
4271
 
4272
+ // do action if visibility has changed
4273
+ if( changed ) {
4274
+ this.prop('hidden', false);
4275
+ acf.doAction('show_field', this, context);
 
 
 
 
 
 
 
 
 
 
4276
  }
4277
 
4278
+ // return
4279
+ return changed;
4280
+ },
4281
+
4282
+ hide: function( lockKey, context ){
4283
 
4284
+ // hide field and store result
4285
+ var changed = acf.hide( this.$el, lockKey );
 
 
 
 
 
 
 
4286
 
4287
+ // do action if visibility has changed
4288
+ if( changed ) {
4289
+ this.prop('hidden', true);
4290
+ acf.doAction('hide_field', this, context);
4291
  }
4292
 
4293
+ // return
4294
+ return changed;
4295
  },
4296
 
4297
+ enable: function( lockKey, context ){
 
 
 
 
 
 
 
 
 
4298
 
4299
+ // enable field and store result
4300
+ var changed = acf.enable( this.$el, lockKey );
4301
 
4302
+ // do action if disabled has changed
4303
+ if( changed ) {
4304
+ this.prop('disabled', false);
4305
+ acf.doAction('enable_field', this, context);
4306
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4307
 
4308
+ // return
4309
+ return changed;
4310
  },
 
 
4311
 
4312
+ disable: function( lockKey, context ){
 
 
 
4313
 
4314
+ // disabled field and store result
4315
+ var changed = acf.disable( this.$el, lockKey );
4316
 
4317
+ // do action if disabled has changed
4318
+ if( changed ) {
4319
+ this.prop('disabled', true);
4320
+ acf.doAction('disable_field', this, context);
4321
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4322
 
4323
+ // return
4324
+ return changed;
4325
  },
4326
 
4327
+ showEnable: function( lockKey, context ){
 
 
4328
 
4329
+ // enable
4330
+ this.enable.apply(this, arguments);
4331
 
4332
+ // show and return true if changed
4333
+ return this.show.apply(this, arguments);
4334
+ },
4335
+
4336
+ hideDisable: function( lockKey, context ){
4337
 
4338
+ // disable
4339
+ this.disable.apply(this, arguments);
4340
 
4341
+ // hide and return true if changed
4342
+ return this.hide.apply(this, arguments);
4343
  },
 
4344
 
4345
+ showNotice: function( props ){
4346
 
4347
+ // ensure object
4348
+ if( typeof props !== 'object' ) {
4349
+ props = { text: props };
4350
+ }
4351
 
4352
+ // remove old notice
4353
+ if( this.notice ) {
4354
+ this.notice.remove();
4355
+ }
4356
 
4357
+ // create new notice
4358
+ props.target = this.$inputWrap();
4359
+ this.notice = acf.newNotice( props );
4360
+ },
4361
+
4362
+ removeNotice: function( timeout ){
4363
+ if( this.notice ) {
4364
+ this.notice.away( timeout || 0 );
4365
+ this.notice = false;
4366
+ }
4367
+ },
4368
+
4369
+ showError: function( message ){
4370
+
4371
+ // add class
4372
+ this.$el.addClass('acf-error');
4373
+
4374
+ // add message
4375
+ if( message !== undefined ) {
4376
+ this.showNotice({
4377
+ text: message,
4378
+ type: 'error',
4379
+ dismiss: false
4380
+ });
4381
+ }
4382
+
4383
+ // action
4384
+ acf.doAction('invalid_field', this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4385
 
4386
+ // add event
4387
+ this.$el.one('focus change', 'input, select, textarea', $.proxy( this.removeError, this ));
4388
  },
4389
 
4390
+ removeError: function(){
4391
 
4392
+ // remove class
4393
+ this.$el.removeClass('acf-error');
 
 
 
 
 
 
 
 
 
 
4394
 
4395
+ // remove notice
4396
+ this.removeNotice( 250 );
4397
+
4398
+ // action
4399
+ acf.doAction('valid_field', this);
4400
  },
4401
 
4402
+ trigger: function( name, args, bubbles ){
4403
 
4404
+ // allow some events to bubble
4405
+ if( name == 'invalidField' ) {
4406
+ bubbles = true;
4407
+ }
4408
 
4409
+ // return
4410
+ return acf.Model.prototype.trigger.apply(this, [name, args, bubbles]);
4411
+ },
4412
+ });
4413
+
4414
+ /**
4415
+ * newField
4416
+ *
4417
+ * description
4418
+ *
4419
+ * @date 14/12/17
4420
+ * @since 5.6.5
4421
+ *
4422
+ * @param type $var Description. Default.
4423
+ * @return type Description.
4424
+ */
4425
+
4426
+ acf.newField = function( $field ){
4427
+
4428
+ // vars
4429
+ var type = $field.data('type');
4430
+ var mid = modelId( type );
4431
+ var model = acf.models[ mid ] || acf.Field;
4432
+
4433
+ // instantiate
4434
+ var field = new model( $field );
4435
+
4436
+ // actions
4437
+ acf.doAction('new_field', field);
4438
+
4439
+ // return
4440
+ return field;
4441
+ };
4442
+
4443
+ /**
4444
+ * mid
4445
+ *
4446
+ * Calculates the model ID for a field type
4447
+ *
4448
+ * @date 15/12/17
4449
+ * @since 5.6.5
4450
+ *
4451
+ * @param string type
4452
+ * @return string
4453
+ */
4454
+
4455
+ var modelId = function( type ) {
4456
+ return acf.strPascalCase( type || '' ) + 'Field';
4457
+ };
4458
+
4459
+ /**
4460
+ * registerFieldType
4461
+ *
4462
+ * description
4463
+ *
4464
+ * @date 14/12/17
4465
+ * @since 5.6.5
4466
+ *
4467
+ * @param type $var Description. Default.
4468
+ * @return type Description.
4469
+ */
4470
+
4471
+ acf.registerFieldType = function( model ){
4472
+
4473
+ // vars
4474
+ var proto = model.prototype;
4475
+ var type = proto.type;
4476
+ var mid = modelId( type );
4477
+
4478
+ // store model
4479
+ acf.models[ mid ] = model;
4480
+
4481
+ // store reference
4482
+ storage.push( type );
4483
+ };
4484
+
4485
+ /**
4486
+ * acf.getFieldType
4487
+ *
4488
+ * description
4489
+ *
4490
+ * @date 1/2/18
4491
+ * @since 5.6.5
4492
+ *
4493
+ * @param type $var Description. Default.
4494
+ * @return type Description.
4495
+ */
4496
+
4497
+ acf.getFieldType = function( type ){
4498
+ var mid = modelId( type );
4499
+ return acf.models[ mid ] || false;
4500
+ }
4501
+
4502
+ /**
4503
+ * acf.getFieldTypes
4504
+ *
4505
+ * description
4506
+ *
4507
+ * @date 1/2/18
4508
+ * @since 5.6.5
4509
+ *
4510
+ * @param type $var Description. Default.
4511
+ * @return type Description.
4512
+ */
4513
+
4514
+ acf.getFieldTypes = function( args ){
4515
+
4516
+ // defaults
4517
+ args = acf.parseArgs(args, {
4518
+ category: '',
4519
+ // hasValue: true
4520
+ });
4521
+
4522
+ // clonse available types
4523
+ var types = [];
4524
+
4525
+ // loop
4526
+ storage.map(function( type ){
4527
 
4528
+ // vars
4529
+ var model = acf.getFieldType(type);
4530
+ var proto = model.prototype;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4531
 
4532
+ // check operator
4533
+ if( args.category && proto.category !== args.category ) {
4534
+ return;
4535
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4536
 
4537
+ // append
4538
+ types.push( model );
4539
+ });
4540
+
4541
+ // return
4542
+ return types;
4543
+ };
4544
+
4545
+ })(jQuery);
4546
+
4547
+ (function($, undefined){
4548
+
4549
+ /**
4550
+ * findFields
4551
+ *
4552
+ * Returns a jQuery selection object of acf fields.
4553
+ *
4554
+ * @date 14/12/17
4555
+ * @since 5.6.5
4556
+ *
4557
+ * @param object $args {
4558
+ * Optional. Arguments to find fields.
4559
+ *
4560
+ * @type string key The field's key (data-attribute).
4561
+ * @type string name The field's name (data-attribute).
4562
+ * @type string type The field's type (data-attribute).
4563
+ * @type string is jQuery selector to compare against.
4564
+ * @type jQuery parent jQuery element to search within.
4565
+ * @type jQuery sibling jQuery element to search alongside.
4566
+ * @type limit int The number of fields to find.
4567
+ * @type suppressFilters bool Whether to allow filters to add/remove results. Default behaviour will ignore clone fields.
4568
+ * }
4569
+ * @return jQuery
4570
+ */
4571
+
4572
+ acf.findFields = function( args ){
4573
+
4574
+ // vars
4575
+ var selector = '.acf-field';
4576
+ var $fields = false;
4577
+
4578
+ // args
4579
+ args = acf.parseArgs(args, {
4580
+ key: '',
4581
+ name: '',
4582
+ type: '',
4583
+ is: '',
4584
+ parent: false,
4585
+ sibling: false,
4586
+ limit: false,
4587
+ visible: false,
4588
+ suppressFilters: false,
4589
+ });
4590
+
4591
+ // filter args
4592
+ if( !args.suppressFilters ) {
4593
+ args = acf.applyFilters('find_fields_args', args);
4594
+ }
4595
+
4596
+ // key
4597
+ if( args.key ) {
4598
+ selector += '[data-key="' + args.key + '"]';
4599
+ }
4600
+
4601
+ // type
4602
+ if( args.type ) {
4603
+ selector += '[data-type="' + args.type + '"]';
4604
+ }
4605
+
4606
+ // name
4607
+ if( args.name ) {
4608
+ selector += '[data-name="' + args.name + '"]';
4609
+ }
4610
+
4611
+ // is
4612
+ if( args.is ) {
4613
+ selector += args.is;
4614
+ }
4615
+
4616
+ // visibility
4617
+ if( args.visible ) {
4618
+ selector += ':visible';
4619
+ }
4620
+
4621
+ // query
4622
+ if( args.parent ) {
4623
+ $fields = args.parent.find( selector );
4624
+ } else if( args.sibling ) {
4625
+ $fields = args.sibling.siblings( selector );
4626
+ } else {
4627
+ $fields = $( selector );
4628
+ }
4629
+
4630
+ // filter
4631
+ if( !args.suppressFilters ) {
4632
+ $fields = $fields.not('.acf-clone .acf-field');
4633
+ $fields = acf.applyFilters('find_fields', $fields);
4634
+ }
4635
+
4636
+ // limit
4637
+ if( args.limit ) {
4638
+ $fields = $fields.slice( 0, args.limit );
4639
+ }
4640
+
4641
+ // return
4642
+ return $fields;
4643
+
4644
+ };
4645
+
4646
+ /**
4647
+ * findField
4648
+ *
4649
+ * Finds a specific field with jQuery
4650
+ *
4651
+ * @date 14/12/17
4652
+ * @since 5.6.5
4653
+ *
4654
+ * @param string key The field's key.
4655
+ * @param jQuery $parent jQuery element to search within.
4656
+ * @return jQuery
4657
+ */
4658
+
4659
+ acf.findField = function( key, $parent ){
4660
+ return acf.findFields({
4661
+ key: key,
4662
+ limit: 1,
4663
+ parent: $parent,
4664
+ suppressFilters: true
4665
+ });
4666
+ };
4667
+
4668
+ /**
4669
+ * getField
4670
+ *
4671
+ * Returns a field instance
4672
+ *
4673
+ * @date 14/12/17
4674
+ * @since 5.6.5
4675
+ *
4676
+ * @param jQuery|string $field jQuery element or field key.
4677
+ * @return object
4678
+ */
4679
+
4680
+ acf.getField = function( $field ){
4681
+
4682
+ // allow jQuery
4683
+ if( $field instanceof jQuery ) {
4684
+
4685
+ // find fields
4686
+ } else {
4687
+ $field = acf.findField( $field );
4688
+ }
4689
+
4690
+ // instantiate
4691
+ var field = $field.data('acf');
4692
+ if( !field ) {
4693
+ field = acf.newField( $field );
4694
+ }
4695
+
4696
+ // return
4697
+ return field;
4698
+ };
4699
+
4700
+ /**
4701
+ * getFields
4702
+ *
4703
+ * Returns multiple field instances
4704
+ *
4705
+ * @date 14/12/17
4706
+ * @since 5.6.5
4707
+ *
4708
+ * @param jQuery|object $fields jQuery elements or query args.
4709
+ * @return array
4710
+ */
4711
+
4712
+ acf.getFields = function( $fields ){
4713
+
4714
+ // allow jQuery
4715
+ if( $fields instanceof jQuery ) {
4716
+
4717
+ // find fields
4718
+ } else {
4719
+ $fields = acf.findFields( $fields );
4720
  }
4721
 
4722
+ // loop
4723
+ var fields = [];
4724
+ $fields.each(function(){
4725
+ var field = acf.getField( $(this) );
4726
+ fields.push( field );
4727
+ });
4728
 
4729
+ // return
4730
+ return fields;
4731
+ };
4732
+
4733
+ /**
4734
+ * findClosestField
4735
+ *
4736
+ * Returns the closest jQuery field element
4737
+ *
4738
+ * @date 9/4/18
4739
+ * @since 5.6.9
4740
+ *
4741
+ * @param jQuery $el
4742
+ * @return jQuery
4743
+ */
4744
+
4745
+ acf.findClosestField = function( $el ){
4746
+ return $el.closest('.acf-field');
4747
+ };
4748
+
4749
+ /**
4750
+ * getClosestField
4751
+ *
4752
+ * Returns the closest field instance
4753
+ *
4754
+ * @date 22/1/18
4755
+ * @since 5.6.5
4756
+ *
4757
+ * @param jQuery $el
4758
+ * @return object
4759
+ */
4760
+
4761
+ acf.getClosestField = function( $el ){
4762
+ var $field = acf.findClosestField( $el );
4763
+ return this.getField( $field );
4764
+ };
4765
+
4766
+ /**
4767
+ * addGlobalFieldAction
4768
+ *
4769
+ * Sets up callback logic for global field actions
4770
+ *
4771
+ * @date 15/6/18
4772
+ * @since 5.6.9
4773
+ *
4774
+ * @param string action
4775
+ * @return void
4776
+ */
4777
 
4778
+ var addGlobalFieldAction = function( action ){
4779
 
4780
+ // vars
4781
+ var globalAction = action;
4782
+ var pluralAction = action + '_fields'; // ready_fields
4783
+ var singleAction = action + '_field'; // ready_field
4784
 
4785
+ // global action
4786
+ var globalCallback = function( $el /*, arg1, arg2, etc*/ ){
4787
+ //console.log( action, arguments );
4788
+
4789
+ // get args [$el, ...]
4790
+ var args = acf.arrayArgs( arguments );
4791
+ var extraArgs = args.slice(1);
4792
+
4793
+ // find fields
4794
+ var fields = acf.getFields({ parent: $el });
4795
+
4796
+ // check
4797
+ if( fields.length ) {
4798
+
4799
+ // pluralAction
4800
+ var pluralArgs = [ pluralAction, fields ].concat( extraArgs );
4801
+ acf.doAction.apply(null, pluralArgs);
4802
+ }
4803
+ };
4804
+
4805
+ // plural action
4806
+ var pluralCallback = function( fields /*, arg1, arg2, etc*/ ){
4807
+ //console.log( pluralAction, arguments );
4808
+
4809
+ // get args [fields, ...]
4810
+ var args = acf.arrayArgs( arguments );
4811
+ var extraArgs = args.slice(1);
4812
+
4813
+ // loop
4814
+ fields.map(function( field, i ){
4815
+ //setTimeout(function(){
4816
+ // singleAction
4817
+ var singleArgs = [ singleAction, field ].concat( extraArgs );
4818
+ acf.doAction.apply(null, singleArgs);
4819
+ //}, i * 100);
4820
+ });
4821
+ };
4822
 
4823
+ // add actions
4824
+ acf.addAction(globalAction, globalCallback);
4825
+ acf.addAction(pluralAction, pluralCallback);
4826
 
4827
+ // also add single action
4828
+ addSingleFieldAction( action );
4829
+ }
4830
+
4831
+ /**
4832
+ * addSingleFieldAction
4833
+ *
4834
+ * Sets up callback logic for single field actions
4835
+ *
4836
+ * @date 15/6/18
4837
+ * @since 5.6.9
4838
+ *
4839
+ * @param string action
4840
+ * @return void
4841
+ */
4842
+
4843
+ var addSingleFieldAction = function( action ){
4844
+
4845
+ // vars
4846
+ var singleAction = action + '_field'; // ready_field
4847
+ var singleEvent = action + 'Field'; // readyField
4848
 
4849
+ // single action
4850
+ var singleCallback = function( field /*, arg1, arg2, etc*/ ){
4851
+ //console.log( singleAction, arguments );
4852
 
4853
+ // get args [field, ...]
4854
+ var args = acf.arrayArgs( arguments );
4855
+ var extraArgs = args.slice(1);
 
 
 
4856
 
4857
+ // action variations (ready_field/type=image)
4858
+ var variations = ['type', 'name', 'key'];
4859
+ variations.map(function( variation ){
4860
+
4861
+ // vars
4862
+ var prefix = '/' + variation + '=' + field.get(variation);
4863
+
4864
+ // singleAction
4865
+ args = [ singleAction + prefix , field ].concat( extraArgs );
4866
+ acf.doAction.apply(null, args);
4867
+ });
4868
 
4869
+ // event
4870
+ if( singleFieldEvents.indexOf(action) > -1 ) {
4871
+ field.trigger(singleEvent, extraArgs);
4872
+ }
4873
+ };
4874
+
4875
+ // add actions
4876
+ acf.addAction(singleAction, singleCallback);
4877
+ }
4878
+
4879
+ // vars
4880
+ var globalFieldActions = [ 'prepare', 'ready', 'load', 'append', 'remove', 'sortstart', 'sortstop', 'show', 'hide', 'unload' ];
4881
+ var singleFieldActions = [ 'valid', 'invalid', 'enable', 'disable', 'new' ];
4882
+ var singleFieldEvents = [ 'remove', 'sortstart', 'sortstop', 'show', 'hide', 'unload', 'valid', 'invalid', 'enable', 'disable' ];
4883
+
4884
+ // add
4885
+ globalFieldActions.map( addGlobalFieldAction );
4886
+ singleFieldActions.map( addSingleFieldAction );
4887
+
4888
+ /**
4889
+ * fieldsEventManager
4890
+ *
4891
+ * Manages field actions and events
4892
+ *
4893
+ * @date 15/12/17
4894
+ * @since 5.6.5
4895
+ *
4896
+ * @param void
4897
+ * @param void
4898
+ */
4899
+
4900
+ var fieldsEventManager = new acf.Model({
4901
+ id: 'fieldsEventManager',
4902
+ events: {
4903
+ 'click .acf-field a[href="#"]': 'onClick',
4904
+ 'change .acf-field': 'onChange'
4905
+ },
4906
+ onClick: function( e ){
4907
 
4908
+ // prevent default of any link with an href of #
4909
+ e.preventDefault();
4910
  },
4911
+ onChange: function(){
4912
+
4913
+ // preview hack allows post to save with no title or content
4914
+ $('#_acf_changed').val(1);
4915
+ }
4916
+ });
4917
+
4918
+ })(jQuery);
4919
+
4920
+ (function($, undefined){
4921
+
4922
+ var i = 0;
4923
+
4924
+ var Field = acf.Field.extend({
4925
 
4926
+ type: 'accordion',
4927
 
4928
+ wait: '',
 
 
 
 
 
 
 
 
 
 
 
4929
 
4930
+ $control: function(){
4931
+ return this.$('.acf-fields:first');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4932
  },
4933
 
4934
+ initialize: function(){
4935
+
4936
+ // bail early if is cell
4937
+ if( this.$el.is('td') ) return;
4938
+
4939
+ // enpoint
4940
+ if( this.get('endpoint') ) {
4941
+ return this.remove();
4942
+ }
 
 
 
 
 
 
4943
 
4944
  // vars
4945
+ var $field = this.$el;
4946
+ var $label = this.$labelWrap()
4947
+ var $input = this.$inputWrap();
4948
+ var $wrap = this.$control();
4949
+ var $instructions = $input.children('.description');
4950
 
4951
+ // force description into label
4952
+ if( $instructions.length ) {
4953
+ $label.append( $instructions );
4954
+ }
4955
 
4956
+ // table
4957
+ if( this.$el.is('tr') ) {
4958
+
4959
+ // vars
4960
+ var $table = this.$el.closest('table');
4961
+ var $newLabel = $('<div class="acf-accordion-title"/>');
4962
+ var $newInput = $('<div class="acf-accordion-content"/>');
4963
+ var $newTable = $('<table class="' + $table.attr('class') + '"/>');
4964
+ var $newWrap = $('<tbody/>');
4965
+
4966
+ // dom
4967
+ $newLabel.append( $label.html() );
4968
+ $newTable.append( $newWrap );
4969
+ $newInput.append( $newTable );
4970
+ $input.append( $newLabel );
4971
+ $input.append( $newInput );
4972
 
4973
+ // modify
4974
+ $label.remove();
4975
+ $wrap.remove();
4976
+ $input.attr('colspan', 2);
4977
 
4978
+ // update vars
4979
+ $label = $newLabel;
4980
+ $input = $newInput;
4981
+ $wrap = $newWrap;
4982
  }
4983
 
4984
+ // add classes
4985
+ $field.addClass('acf-accordion');
4986
+ $label.addClass('acf-accordion-title');
4987
+ $input.addClass('acf-accordion-content');
4988
+
4989
+ // index
4990
+ i++;
4991
 
4992
+ // multi-expand
4993
+ if( this.get('multi_expand') ) {
4994
+ $field.attr('multi-expand', 1);
4995
+ }
4996
 
4997
+ // open
4998
+ var order = acf.getPreference('this.accordions') || [];
4999
+ if( order[i-1] !== undefined ) {
5000
+ this.set('open', order[i-1]);
5001
+ }
5002
 
5003
+ if( this.get('open') ) {
5004
+ $field.addClass('-open');
5005
+ $input.css('display', 'block'); // needed for accordion to close smoothly
5006
+ }
 
 
5007
 
5008
+ // add icon
5009
+ $label.prepend('<i class="acf-accordion-icon dashicons dashicons-arrow-' + (this.get('open') ? 'down' : 'right') + '"></i>');
5010
 
5011
+ // classes
5012
+ // - remove 'inside' which is a #poststuff WP class
5013
+ var $parent = $field.parent();
5014
+ $wrap.addClass( $parent.hasClass('-left') ? '-left' : '' );
5015
+ $wrap.addClass( $parent.hasClass('-clear') ? '-clear' : '' );
5016
 
5017
+ // append
5018
+ $wrap.append( $field.nextUntil('.acf-field-accordion', '.acf-field') );
5019
 
5020
+ // clean up
5021
+ $wrap.removeAttr('data-open data-multi_expand data-endpoint');
5022
+ },
5023
+
5024
+ });
5025
+
5026
+ acf.registerFieldType( Field );
5027
+
5028
+
5029
+ /**
5030
+ * accordionManager
5031
+ *
5032
+ * Events manager for the acf accordion
5033
+ *
5034
+ * @date 14/2/18
5035
+ * @since 5.6.9
5036
+ *
5037
+ * @param void
5038
+ * @return void
5039
+ */
5040
+
5041
+ var accordionManager = new acf.Model({
5042
+
5043
+ actions: {
5044
+ 'unload': 'onUnload'
5045
+ },
5046
+
5047
+ events: {
5048
+ 'click .acf-accordion-title': 'onClick',
5049
+ 'invalidField .acf-accordion': 'onInvalidField'
5050
+ },
5051
+
5052
+ isOpen: function( $el ) {
5053
+ return $el.hasClass('-open');
5054
+ },
5055
+
5056
+ toggle: function( $el ){
5057
+ if( this.isOpen($el) ) {
5058
+ this.close( $el );
5059
+ } else {
5060
+ this.open( $el );
5061
+ }
5062
+ },
5063
+
5064
+ open: function( $el ){
5065
+
5066
+ // open
5067
+ $el.find('.acf-accordion-content:first').slideDown().css('display', 'block');
5068
+ $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-right').addClass('dashicons-arrow-down');
5069
+ $el.addClass('-open');
5070
+
5071
+ // action
5072
+ acf.doAction('show', $el);
5073
 
5074
+ // close siblings
5075
+ if( !$el.attr('multi-expand') ) {
5076
+ $el.siblings('.acf-accordion.-open').each(function(){
5077
+ accordionManager.close( $(this) );
5078
+ });
5079
+ }
5080
+ },
5081
+
5082
+ close: function( $el ){
5083
 
5084
+ // close
5085
+ $el.find('.acf-accordion-content:first').slideUp();
5086
+ $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-down').addClass('dashicons-arrow-right');
5087
+ $el.removeClass('-open');
5088
 
5089
+ // action
5090
+ acf.doAction('hide', $el);
5091
  },
5092
 
5093
+ onClick: function( e, $el ){
 
 
 
5094
 
5095
+ // prevent Defailt
5096
+ e.preventDefault();
5097
 
5098
+ // open close
5099
+ this.toggle( $el.parent() );
5100
 
5101
+ },
5102
+
5103
+ onInvalidField: function( e, $el ){
5104
 
5105
+ // bail early if already focused
5106
+ if( this.busy ) {
 
 
5107
  return;
 
5108
  }
5109
 
5110
+ // disable functionality for 1sec (allow next validation to work)
5111
+ this.busy = true;
5112
+ this.setTimeout(function(){
5113
+ this.busy = false;
5114
+ }, 1000);
5115
 
5116
+ // open accordion
5117
+ this.open( $el );
 
 
 
 
 
 
 
5118
  },
5119
+
5120
+ onUnload: function( e ){
 
 
 
 
 
 
 
5121
 
5122
+ // vars
5123
+ var order = [];
5124
 
5125
+ // loop
5126
+ $('.acf-accordion').each(function(){
5127
+ var open = $(this).hasClass('-open') ? 1 : 0;
5128
+ order.push(open);
5129
+ });
5130
 
5131
+ // set
5132
+ if( order.length ) {
5133
+ acf.setPreference('this.accordions', order);
5134
+ }
5135
+ }
5136
+ });
5137
+
5138
+ })(jQuery);
5139
+
5140
+ (function($, undefined){
5141
+
5142
+ var Field = acf.Field.extend({
5143
+
5144
+ type: 'button_group',
5145
+
5146
+ events: {
5147
+ 'click input[type="radio"]': 'onClick'
5148
  },
5149
 
5150
+ $control: function(){
5151
+ return this.$('.acf-button-group');
 
 
 
 
 
 
 
5152
  },
5153
 
5154
+ $input: function(){
5155
+ return this.$('input:checked');
5156
+ },
5157
+
5158
+ setValue: function( val ){
5159
+ this.$('input[value="' + val + '"]').prop('checked', true).trigger('change');
5160
+ },
5161
+
5162
+ onClick: function( e, $el ){
5163
 
5164
+ // vars
5165
+ var $label = $el.parent('label');
5166
+ var selected = $label.hasClass('selected');
5167
 
5168
+ // remove previous selected
5169
+ this.$('.selected').removeClass('selected');
5170
+
5171
+ // add active class
5172
+ $label.addClass('selected');
5173
 
5174
+ // allow null
5175
+ if( this.get('allow_null') && selected ) {
5176
+ $label.removeClass('selected');
5177
+ $el.prop('checked', false).trigger('change');
5178
+ }
5179
+ }
5180
+ });
5181
+
5182
+ acf.registerFieldType( Field );
5183
+
5184
+ })(jQuery);
5185
+
5186
+ (function($, undefined){
5187
+
5188
+ var Field = acf.Field.extend({
5189
+
5190
+ type: 'checkbox',
5191
+
5192
+ events: {
5193
+ 'change input': 'onChange',
5194
+ 'click .acf-add-checkbox': 'onClickAdd',
5195
+ 'click .acf-checkbox-toggle': 'onClickToggle',
5196
+ 'click .acf-checkbox-custom': 'onClickCustom'
5197
  },
5198
 
5199
+ $control: function(){
5200
+ return this.$('.acf-checkbox-list');
 
 
5201
  },
5202
 
5203
+ $toggle: function(){
5204
+ return this.$('.acf-checkbox-toggle');
 
 
5205
  },
5206
 
5207
+ $input: function(){
5208
+ return this.$('input[type="hidden"]');
 
 
5209
  },
5210
 
5211
+ $inputs: function(){
5212
+ return this.$('input[type="checkbox"]').not('.acf-checkbox-toggle');
 
 
 
5213
  },
5214
 
5215
+ getValue: function(){
5216
+ var val = [];
5217
+ this.$(':checked').each(function(){
5218
+ val.push( $(this).val() );
5219
+ });
5220
+ return val.length ? val : false;
5221
+ },
5222
+
5223
+ onChange: function( e, $el ){
5224
 
5225
+ // vars
5226
+ var checked = $el.prop('checked');
5227
+ var $toggle = this.$toggle();
5228
 
5229
+ // selected
5230
+ if( checked ) {
5231
+ $el.parent().addClass('selected');
5232
+ } else {
5233
+ $el.parent().removeClass('selected');
5234
+ }
5235
 
5236
+ // determine if all inputs are checked
5237
+ if( $toggle.length ) {
5238
+ var $inputs = this.$inputs();
5239
+
5240
+ // all checked
5241
+ if( $inputs.not(':checked').length == 0 ) {
5242
+ $toggle.prop('checked', true);
5243
+ } else {
5244
+ $toggle.prop('checked', false);
5245
+ }
5246
+ }
5247
  },
5248
 
5249
+ onClickAdd: function( e, $el ){
5250
+ var html = '<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input type="text" name="' + this.getInputName() + '[]" /></li>';
5251
+ $el.parent('li').before( html );
5252
+ },
5253
+
5254
+ onClickToggle: function( e, $el ){
5255
+ var checked = $el.prop('checked');
5256
+ var $inputs = this.$inputs();
5257
+ $inputs.prop('checked', checked);
5258
+ },
5259
+
5260
+ onClickCustom: function( e, $el ){
5261
+ var checked = $el.prop('checked');
5262
+ var $text = $el.next('input[type="text"]');
5263
 
5264
+ // checked
5265
+ if( checked ) {
5266
+ $text.prop('disabled', false);
5267
+
5268
+ // not checked
5269
+ } else {
5270
+ $text.prop('disabled', true);
5271
+
5272
+ // remove
5273
+ if( $text.val() == '' ) {
5274
+ $el.parent('li').remove();
5275
+ }
5276
+ }
5277
  }
 
5278
  });
5279
+
5280
+ acf.registerFieldType( Field );
5281
+
5282
  })(jQuery);
5283
 
5284
+ (function($, undefined){
5285
 
5286
+ var Field = acf.Field.extend({
5287
 
5288
+ type: 'color_picker',
5289
 
5290
+ wait: 'load',
5291
 
5292
+ $control: function(){
5293
+ return this.$('.acf-color-picker');
 
5294
  },
5295
 
5296
+ $input: function(){
5297
+ return this.$('input[type="hidden"]');
5298
+ },
5299
+
5300
+ $inputText: function(){
5301
+ return this.$('input[type="text"]');
5302
  },
5303
 
5304
+ initialize: function(){
5305
 
5306
+ // vars
5307
+ var $input = this.$input();
5308
+ var $inputText = this.$inputText();
5309
 
5310
+ // event
5311
+ var onChange = function( e ){
5312
+
5313
+ // timeout is required to ensure the $input val is correct
5314
+ setTimeout(function(){
5315
+ acf.val( $input, $inputText.val() );
5316
+ }, 1);
5317
+ }
5318
 
5319
+ // args
5320
+ var args = {
5321
+ defaultColor: false,
5322
+ palettes: true,
5323
+ hide: true,
5324
+ change: onChange,
5325
+ clear: onChange
5326
+ };
5327
 
5328
+ // filter
5329
+ var args = acf.applyFilters('color_picker_args', args, this);
5330
+
5331
+ // initialize
5332
+ $inputText.wpColorPicker( args );
5333
+ }
5334
+ });
5335
+
5336
+ acf.registerFieldType( Field );
5337
+
5338
+ })(jQuery);
5339
+
5340
+ (function($, undefined){
5341
+
5342
+ var Field = acf.Field.extend({
5343
+
5344
+ type: 'date_picker',
5345
+
5346
+ events: {
5347
+ 'blur input[type="text"]': 'onBlur'
5348
  },
5349
 
5350
+ $control: function(){
5351
+ return this.$('.acf-date-picker');
5352
+ },
5353
 
5354
+ $input: function(){
5355
+ return this.$('input[type="hidden"]');
5356
+ },
 
 
 
 
 
 
 
 
 
 
 
 
5357
 
5358
+ $inputText: function(){
5359
+ return this.$('input[type="text"]');
5360
+ },
5361
+
5362
  initialize: function(){
5363
 
5364
+ // save_format: compatibility with ACF < 5.0.0
5365
+ if( this.has('save_format') ) {
5366
+ return this.initializeCompatibility();
5367
+ }
5368
+
5369
+ // vars
5370
+ var $input = this.$input();
5371
+ var $inputText = this.$inputText();
5372
+
5373
+ // args
5374
+ var args = {
5375
+ dateFormat: this.get('date_format'),
5376
+ altField: $input,
5377
+ altFormat: 'yymmdd',
5378
+ changeYear: true,
5379
+ yearRange: "-100:+100",
5380
+ changeMonth: true,
5381
+ showButtonPanel: true,
5382
+ firstDay: this.get('first_day')
5383
+ };
5384
+
5385
+ // filter
5386
+ args = acf.applyFilters('date_picker_args', args, this);
5387
+
5388
+ // add date picker
5389
+ acf.newDatePicker( $inputText, args );
5390
+
5391
+ // action
5392
+ acf.doAction('date_picker_init', $inputText, args, this);
5393
 
5394
  },
5395
 
5396
+ initializeCompatibility: function(){
5397
 
5398
  // vars
5399
+ var $input = this.$input();
5400
+ var $inputText = this.$inputText();
 
 
 
 
 
 
 
5401
 
5402
+ // get and set value from alt field
5403
+ $inputText.val( $input.val() );
5404
+
5405
+ // args
5406
+ var args = {
5407
+ dateFormat: this.get('date_format'),
5408
+ altField: $input,
5409
+ altFormat: this.get('save_format'),
5410
+ changeYear: true,
5411
+ yearRange: "-100:+100",
5412
+ changeMonth: true,
5413
+ showButtonPanel: true,
5414
+ firstDay: this.get('first_day')
5415
+ };
5416
 
5417
+ // filter for 3rd party customization
5418
+ args = acf.applyFilters('date_picker_args', args, this);
5419
 
5420
+ // backup
5421
+ var dateFormat = args.dateFormat;
5422
+
5423
+ // change args.dateFormat
5424
+ args.dateFormat = this.get('save_format');
 
 
 
 
 
 
5425
 
5426
+ // add date picker
5427
+ acf.newDatePicker( $inputText, args );
5428
+
5429
+ // now change the format back to how it should be.
5430
+ $inputText.datepicker( 'option', 'dateFormat', dateFormat );
5431
+
5432
+ // action for 3rd party customization
5433
+ acf.doAction('date_picker_init', $inputText, args, this);
5434
+ },
5435
+
5436
+ onBlur: function(){
5437
+ if( !this.$inputText().val() ) {
5438
+ acf.val( this.$input(), '' );
5439
  }
5440
+ }
5441
+ });
5442
+
5443
+ acf.registerFieldType( Field );
5444
+
5445
+
5446
+ // manager
5447
+ var datePickerManager = new acf.Model({
5448
+ priority: 5,
5449
+ wait: 'ready',
5450
+ initialize: function(){
5451
 
5452
+ // vars
5453
+ var locale = acf.get('locale');
5454
+ var rtl = acf.get('rtl');
5455
+ var l10n = acf.get('datePickerL10n');
5456
 
5457
+ // bail ealry if no l10n
5458
+ if( !l10n ) {
5459
+ return false;
5460
+ }
 
 
 
 
 
5461
 
5462
+ // bail ealry if no datepicker library
5463
+ if( typeof $.datepicker === 'undefined' ) {
5464
+ return false;
 
 
 
 
 
 
5465
  }
5466
 
5467
+ // rtl
5468
+ l10n.isRTL = rtl;
5469
+
5470
+ // append
5471
+ $.datepicker.regional[ locale ] = l10n;
5472
+ $.datepicker.setDefaults(l10n);
5473
  }
5474
+ });
5475
+
5476
+ // add
5477
+ acf.newDatePicker = function( $input, args ){
5478
 
5479
+ // bail ealry if no datepicker library
5480
+ if( typeof $.datepicker === 'undefined' ) {
5481
+ return false;
5482
+ }
5483
+
5484
+ // defaults
5485
+ args = args || {};
5486
+
5487
+ // initialize
5488
+ $input.datepicker( args );
5489
+
5490
+ // wrap the datepicker (only if it hasn't already been wrapped)
5491
+ if( $('body > #ui-datepicker-div').exists() ) {
5492
+ $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
5493
+ }
5494
+ };
5495
+
5496
  })(jQuery);
5497
 
5498
+ (function($, undefined){
5499
 
5500
+ var Field = acf.models.DatePickerField.extend({
5501
 
5502
+ type: 'date_time_picker',
 
 
 
5503
 
5504
+ $control: function(){
5505
+ return this.$('.acf-date-time-picker');
 
5506
  },
5507
 
5508
+ initialize: function(){
5509
 
5510
+ // vars
5511
+ var $input = this.$input();
5512
+ var $inputText = this.$inputText();
 
5513
 
5514
+ // args
5515
+ var args = {
5516
+ dateFormat: this.get('date_format'),
5517
+ timeFormat: this.get('time_format'),
5518
+ altField: $input,
5519
+ altFieldTimeOnly: false,
5520
+ altFormat: 'yy-mm-dd',
5521
+ altTimeFormat: 'HH:mm:ss',
5522
+ changeYear: true,
5523
+ yearRange: "-100:+100",
5524
+ changeMonth: true,
5525
+ showButtonPanel: true,
5526
+ firstDay: this.get('first_day'),
5527
+ controlType: 'select',
5528
+ oneLine: true
5529
+ };
5530
+
5531
+ // filter
5532
+ args = acf.applyFilters('date_time_picker_args', args, this);
5533
+
5534
+ // add date time picker
5535
+ acf.newDateTimePicker( $inputText, args );
5536
+
5537
+ // action
5538
+ acf.doAction('date_time_picker_init', $inputText, args, this);
5539
+ }
5540
+ });
5541
+
5542
+ acf.registerFieldType( Field );
5543
+
5544
+
5545
+ // manager
5546
+ var dateTimePickerManager = new acf.Model({
5547
+ priority: 5,
5548
+ wait: 'ready',
5549
+ initialize: function(){
5550
+
5551
+ // vars
5552
+ var locale = acf.get('locale');
5553
+ var rtl = acf.get('rtl');
5554
+ var l10n = acf.get('dateTimePickerL10n');
5555
+
5556
+ // bail ealry if no l10n
5557
+ if( !l10n ) {
5558
+ return false;
5559
+ }
5560
 
5561
+ // bail ealry if no datepicker library
5562
+ if( typeof $.timepicker === 'undefined' ) {
5563
+ return false;
5564
  }
5565
+
5566
+ // rtl
5567
+ l10n.isRTL = rtl;
5568
+
5569
+ // append
5570
+ $.timepicker.regional[ locale ] = l10n;
5571
+ $.timepicker.setDefaults(l10n);
5572
  }
5573
  });
5574
 
5575
+
5576
+ // add
5577
+ acf.newDateTimePicker = function( $input, args ){
5578
+
5579
+ // bail ealry if no datepicker library
5580
+ if( typeof $.timepicker === 'undefined' ) {
5581
+ return false;
5582
+ }
5583
+
5584
+ // defaults
5585
+ args = args || {};
5586
+
5587
+ // initialize
5588
+ $input.datetimepicker( args );
5589
+
5590
+ // wrap the datepicker (only if it hasn't already been wrapped)
5591
+ if( $('body > #ui-datepicker-div').exists() ) {
5592
+ $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
5593
+ }
5594
+ };
5595
+
5596
  })(jQuery);
5597
 
5598
+ (function($, undefined){
5599
 
5600
+ var Field = acf.Field.extend({
5601
 
5602
+ type: 'google_map',
5603
 
5604
+ map: false,
 
 
 
 
5605
 
5606
+ wait: 'load',
 
 
 
5607
 
5608
  events: {
5609
+ 'click a[data-name="clear"]': 'onClickClear',
5610
+ 'click a[data-name="locate"]': 'onClickLocate',
5611
+ 'click a[data-name="search"]': 'onClickSearch',
5612
+ 'keydown .search': 'onKeydownSearch',
5613
+ 'keyup .search': 'onKeyupSearch',
5614
+ 'focus .search': 'onFocusSearch',
5615
+ 'blur .search': 'onBlurSearch',
5616
+ 'showField': 'onShow'
5617
  },
5618
 
5619
+ $control: function(){
5620
+ return this.$('.acf-google-map');
 
 
 
 
 
 
 
 
 
5621
  },
5622
 
5623
+ $input: function( name ){
5624
+ return this.$('input[data-name="' + (name || 'address') + '"]');
5625
+ },
5626
+
5627
+ $search: function(){
5628
+ return this.$('.search');
5629
+ },
5630
+
5631
+ addClass: function( name ){
5632
+ this.$control().addClass( name );
5633
+ },
5634
+
5635
+ removeClass: function( name ){
5636
+ this.$control().removeClass( name );
5637
+ },
5638
+
5639
+ getValue: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5640
 
5641
+ // defaults
5642
+ var val = {
5643
+ lat: '',
5644
+ lng: '',
5645
+ address: ''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5646
  };
 
5647
 
5648
+ // loop
5649
+ this.$('input[type="hidden"]').each(function(){
5650
+ val[ $(this).data('name') ] = $(this).val();
5651
+ });
5652
 
5653
+ // return false if no address
5654
+ if( !val.address ) {
5655
+ val = false;
5656
+ }
5657
 
5658
+ // return
5659
+ return val;
5660
  },
5661
 
5662
+ setValue: function( val ){
 
5663
 
5664
+ // defaults
5665
+ val = acf.parseArgs(val, {
5666
+ lat: '',
5667
+ lng: '',
5668
+ address: ''
5669
+ });
5670
 
5671
+ // loop
5672
+ for( var name in val ) {
5673
+ acf.val( this.$input(name), val[name] );
 
 
5674
  }
5675
 
5676
+ // return false if no address
5677
+ if( !val.address ) {
5678
+ val = false;
 
 
 
 
5679
  }
5680
 
5681
+ // render
5682
+ this.renderVal( val );
5683
  },
 
5684
 
5685
+ renderVal: function( val ){
 
 
 
 
5686
 
5687
+ // has value
5688
+ if( val ) {
5689
+ this.addClass('-value');
5690
+ this.setPosition( val.lat, val.lng );
5691
+ this.map.marker.setVisible( true );
5692
+
5693
+ // no value
5694
+ } else {
5695
+ this.removeClass('-value');
5696
+ this.map.marker.setVisible( false );
5697
+ }
 
 
 
 
 
 
 
5698
 
5699
+ // search
5700
+ this.$search().val( val.address );
5701
  },
5702
 
5703
+ setPosition: function( lat, lng ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5704
 
5705
+ // vars
5706
+ var latLng = this.newLatLng( lat, lng );
5707
 
5708
+ // update marker
5709
+ this.map.marker.setPosition( latLng );
 
5710
 
5711
+ // show marker
5712
+ this.map.marker.setVisible( true );
 
 
 
 
 
 
 
 
 
 
5713
 
5714
+ // action
5715
+ acf.doAction('google_map_change', latLng, this.map, this);
5716
 
5717
+ // center
5718
+ this.center();
5719
 
5720
+ // return
5721
+ return this;
5722
  },
5723
 
5724
+ center: function(){
 
 
 
 
 
 
 
 
5725
 
5726
+ // vars
5727
+ var position = this.map.marker.getPosition();
5728
+ var lat = this.get('lat');
5729
+ var lng = this.get('lng');
5730
 
5731
+ // if marker exists, center on the marker
5732
+ if( position ) {
5733
+ lat = position.lat();
5734
+ lng = position.lng();
5735
+ }
5736
 
5737
+ // latlng
5738
+ var latLng = this.newLatLng( lat, lng );
5739
 
5740
+ // set center of map
5741
+ this.map.setCenter( latLng );
5742
+ },
5743
+
5744
+ getSearchVal: function(){
5745
+ return this.$search().val();
5746
+ },
5747
+
5748
+ getCanvas: function(){
5749
+ return this.$('.canvas');
5750
+ },
5751
+
5752
+ initialize: function(){
5753
 
5754
+ // bail early if too early
5755
+ if( !api.isReady() ) {
5756
+ api.ready( this.initializeMap, this );
 
5757
  return;
 
5758
  }
5759
 
5760
+ // initializeMap
5761
+ this.initializeMap();
5762
+ },
5763
+
5764
+ newLatLng: function( lat, lng ){
5765
+ return new google.maps.LatLng( parseFloat(lat), parseFloat(lng) );
5766
+ },
5767
+
5768
+ initializeMap: function(){
5769
 
5770
+ // vars
5771
+ var zoom = this.get('zoom');
5772
+ var lat = this.get('lat');
5773
+ var lng = this.get('lng');
5774
+
5775
+
5776
+ // map
5777
+ var mapArgs = {
5778
+ scrollwheel: false,
5779
+ zoom: parseInt( zoom ),
5780
+ center: this.newLatLng(lat, lng),
5781
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
5782
+ marker: {
5783
+ draggable: true,
5784
+ raiseOnDrag: true
5785
+ },
5786
+ autocomplete: {}
5787
+ };
5788
+ mapArgs = acf.applyFilters('google_map_args', mapArgs, this);
5789
+ var map = new google.maps.Map( this.getCanvas()[0], mapArgs );
5790
+ this.addMapEvents( map, this );
5791
+
5792
+
5793
+ // marker
5794
+ var markerArgs = acf.parseArgs(mapArgs.marker, {
5795
+ draggable: true,
5796
+ raiseOnDrag: true,
5797
+ map: map
5798
+ });
5799
+ markerArgs = acf.applyFilters('google_map_marker_args', markerArgs, this);
5800
+ var marker = new google.maps.Marker( markerArgs );
5801
+ this.addMarkerEvents( marker, this );
5802
+
5803
+
5804
+ // reference
5805
+ map.acf = this;
5806
+ map.marker = marker;
5807
+ this.map = map;
5808
+
5809
+ // action for 3rd party customization
5810
+ acf.doAction('google_map_init', map, marker, this);
5811
+
5812
+ // set position
5813
+ var val = this.getValue();
5814
+ this.renderVal( val );
5815
+ },
5816
+
5817
+ addMapEvents: function( map, field ){
5818
 
5819
+ // autocomplete
5820
+ if( acf.isset(window, 'google', 'maps', 'places', 'Autocomplete') ) {
5821
+
5822
+ // vars
5823
+ var autocompleteArgs = map.autocomplete || {};
5824
+ var autocomplete = new google.maps.places.Autocomplete( this.$search()[0], autocompleteArgs );
5825
 
5826
+ // bind
5827
+ autocomplete.bindTo('bounds', map);
5828
 
5829
+ // event
5830
+ google.maps.event.addListener(autocomplete, 'place_changed', function() {
5831
+ field.setPlace( this.getPlace() );
5832
+ });
5833
+ }
5834
+
5835
+ // click
5836
+ google.maps.event.addListener( map, 'click', function( e ) {
5837
 
 
 
 
 
 
 
 
 
 
5838
  // vars
5839
+ var lat = e.latLng.lat();
5840
+ var lng = e.latLng.lng();
 
 
 
5841
 
5842
+ // search
5843
+ field.searchPosition( lat, lng );
5844
+ });
5845
+ },
5846
+
5847
+ addMarkerEvents: function( marker, field ){
 
 
 
 
 
 
 
 
5848
 
5849
+ // dragend
5850
+ google.maps.event.addListener( marker, 'dragend', function(){
5851
+
5852
+ // vars
5853
+ var position = this.getPosition();
5854
+ var lat = position.lat();
5855
+ var lng = position.lng();
5856
+
5857
+ // search
5858
+ field.searchPosition( lat, lng );
5859
+ });
5860
+ },
5861
+
5862
+ searchPosition: function( lat, lng ){
5863
 
5864
+ // vars
5865
+ var latLng = this.newLatLng( lat, lng );
5866
+ var $wrap = this.$control();
5867
 
5868
+ // set position
5869
+ this.setPosition( lat, lng );
5870
 
5871
+ // add class
5872
+ $wrap.addClass('-loading');
5873
+
5874
+ // callback
5875
+ var callback = $.proxy(function( results, status ){
5876
+
5877
+ // remove class
5878
+ $wrap.removeClass('-loading');
5879
+
5880
+ // vars
5881
+ var address = '';
5882
+
5883
+ // validate
5884
+ if( status != google.maps.GeocoderStatus.OK ) {
5885
+ console.log('Geocoder failed due to: ' + status);
5886
+ } else if( !results[0] ) {
5887
+ console.log('No results found');
5888
+ } else {
5889
+ address = results[0].formatted_address;
5890
  }
5891
 
5892
+ // update val
5893
+ this.val({
5894
+ lat: lat,
5895
+ lng: lng,
5896
+ address: address
5897
+ });
5898
 
5899
+ }, this);
5900
+
5901
+ // query
5902
+ api.geocoder.geocode({ 'latLng' : latLng }, callback);
 
 
 
5903
  },
5904
 
5905
+ setPlace: function( place ){
5906
+
5907
+ // bail if no place
5908
+ if( !place ) return this;
5909
+
5910
+ // search name if no geometry
5911
+ // - possible when hitting enter in search address
5912
+ if( place.name && !place.geometry ) {
5913
+ this.searchAddress(place.name);
5914
+ return this;
5915
+ }
5916
 
5917
  // vars
5918
+ var lat = place.geometry.location.lat();
5919
+ var lng = place.geometry.location.lng();
5920
+ var address = place.formatted_address;
5921
 
5922
+ // update
5923
+ this.setValue({
5924
+ lat: lat,
5925
+ lng: lng,
5926
+ address: address
5927
+ });
5928
 
5929
+ // return
5930
+ return this;
5931
+ },
5932
+
5933
+ searchAddress: function( address ){
5934
 
5935
+ // is address latLng?
5936
+ var latLng = address.split(',');
5937
+ if( latLng.length == 2 ) {
5938
+
5939
+ // vars
5940
+ var lat = latLng[0];
5941
+ var lng = latLng[1];
5942
+
5943
+ // check
5944
+ if( $.isNumeric(lat) && $.isNumeric(lng) ) {
5945
+ return this.searchPosition( lat, lng );
5946
+ }
5947
+ }
5948
+
5949
+ // vars
5950
+ var $wrap = this.$control();
5951
+
5952
+ // add class
5953
+ $wrap.addClass('-loading');
5954
+
5955
+ // callback
5956
+ var callback = $.proxy(function( results, status ){
5957
+
5958
+ // remove class
5959
+ $wrap.removeClass('-loading');
5960
+
5961
+ // vars
5962
+ var lat = '';
5963
+ var lng = '';
5964
+
5965
+ // validate
5966
+ if( status != google.maps.GeocoderStatus.OK ) {
5967
+ console.log('Geocoder failed due to: ' + status);
5968
+ } else if( !results[0] ) {
5969
+ console.log('No results found');
5970
+ } else {
5971
+ lat = results[0].geometry.location.lat();
5972
+ lng = results[0].geometry.location.lng();
5973
+ address = results[0].formatted_address;
5974
  }
5975
 
5976
+ // update val
5977
+ this.val({
5978
+ lat: lat,
5979
+ lng: lng,
5980
+ address: address
5981
+ });
 
 
 
 
 
 
5982
 
5983
+ //acf.doAction('google_map_geocode_results', results, status, this.$el, this);
 
 
5984
 
5985
+ }, this);
5986
+
5987
+ // query
5988
+ api.geocoder.geocode({ 'address' : address }, callback);
5989
+ },
5990
+
5991
+ searchLocation: function(){
5992
+
5993
+ // Try HTML5 geolocation
5994
+ if( !navigator.geolocation ) {
5995
+ return alert( acf.__('Sorry, this browser does not support geolocation') );
5996
  }
5997
 
5998
+ // vars
5999
+ var $wrap = this.$control();
6000
 
6001
+ // add class
6002
+ $wrap.addClass('-loading');
6003
+
6004
+ // callback
6005
+ var onSuccess = $.proxy(function( results, status ){
6006
+
6007
+ // remove class
6008
+ $wrap.removeClass('-loading');
6009
+
6010
+ // vars
6011
+ var lat = results.coords.latitude;
6012
+ var lng = results.coords.longitude;
6013
+
6014
+ // search;
6015
+ this.searchPosition( lat, lng );
6016
+
6017
+ }, this);
6018
+
6019
+ var onFailure = function( error ){
6020
+ $wrap.removeClass('-loading');
6021
+ }
6022
+
6023
+ // try query
6024
+ navigator.geolocation.getCurrentPosition( onSuccess, onFailure );
6025
+ },
6026
+
6027
+ onClickClear: function( e, $el ){
6028
+ this.val( false );
6029
+ },
6030
+
6031
+ onClickLocate: function( e, $el ){
6032
+ this.searchLocation();
6033
+ },
6034
+
6035
+ onClickSearch: function( e, $el ){
6036
+ this.searchAddress( this.$search().val() );
6037
+ },
6038
+
6039
+ onFocusSearch: function( e, $el ){
6040
+ this.removeClass('-value');
6041
+ this.onKeyupSearch.apply(this, arguments);
6042
+ },
6043
+
6044
+ onBlurSearch: function( e, $el ){
6045
 
6046
+ // timeout to allow onClickLocate event
6047
+ this.setTimeout(function(){
6048
+ this.removeClass('-search');
6049
+ if( $el.val() ) {
6050
+ this.addClass('-value');
6051
+ }
6052
+ }, 100);
6053
  },
6054
 
6055
+ onKeyupSearch: function( e, $el ){
6056
+ if( $el.val() ) {
6057
+ this.addClass('-search');
6058
+ } else {
6059
+ this.removeClass('-search');
6060
+ }
6061
+ },
6062
+
6063
+ onKeydownSearch: function( e, $el ){
6064
 
6065
+ // prevent form from submitting
6066
  if( e.which == 13 ) {
 
6067
  e.preventDefault();
 
6068
  }
6069
+ },
6070
+
6071
+ onMousedown: function(){
6072
 
6073
+ /*
6074
+ // clear timeout in 1ms (onMousedown will run before onBlurSearch)
6075
+ this.setTimeout(function(){
6076
+ clearTimeout( this.get('timeout') );
6077
+ }, 1);
6078
+ */
6079
  },
6080
 
6081
+ onShow: function(){
6082
 
6083
+ // bail early if no map
6084
+ // - possible if JS API was not loaded
6085
+ if( !this.map ) {
6086
+ return false;
6087
+ }
6088
 
6089
+ // center map when it is shown (by a tab / collapsed row)
6090
+ // - use delay to avoid rendering issues with browsers (ensures div is visible)
6091
+ this.setTimeout( this.center, 10 );
6092
+ }
6093
+ });
6094
+
6095
+ acf.registerFieldType( Field );
6096
+
6097
+ var api = new acf.Model({
6098
+
6099
+ geocoder: false,
6100
+
6101
+ data: {
6102
+ status: false,
6103
+ },
6104
+
6105
+ getStatus: function(){
6106
+ return this.get('status');
6107
+ },
6108
+
6109
+ setStatus: function( status ){
6110
+ return this.set('status', status);
6111
+ },
6112
+
6113
+ isReady: function(){
6114
 
6115
+ // loaded
6116
+ if( this.getStatus() == 'ready' ) {
6117
+ return true;
6118
+ }
6119
+
6120
+ // loading
6121
+ if( this.getStatus() == 'loading' ) {
6122
+ return false;
6123
+ }
6124
+
6125
+ // check exists (optimal)
6126
+ if( acf.isset(window, 'google', 'maps', 'places') ) {
6127
+ this.setStatus('ready');
6128
+ return true;
6129
+ }
6130
+
6131
+ // load api
6132
+ var url = acf.get('google_map_api');
6133
+ if( url ) {
6134
+ this.setStatus('loading');
6135
 
6136
+ // enqueue
6137
+ $.ajax({
6138
+ url: url,
6139
+ dataType: 'script',
6140
+ cache: true,
6141
+ context: this,
6142
+ success: function(){
6143
+
6144
+ // ready
6145
+ this.setStatus('ready');
6146
+
6147
+ // geocoder
6148
+ this.geocoder = new google.maps.Geocoder();
6149
+
6150
+ // action
6151
+ acf.doAction('google_map_api_loaded');
6152
+ }
6153
+ });
6154
  }
6155
 
6156
+ // return
6157
+ return false;
6158
+ },
6159
+
6160
+ ready: function( callback, context ){
6161
+ acf.addAction('google_map_api_loaded', callback, 10, context);
6162
+ }
6163
+ });
6164
+
6165
+ })(jQuery);
6166
+
6167
+ (function($, undefined){
6168
+
6169
+ var Field = acf.Field.extend({
6170
+
6171
+ type: 'image',
6172
+
6173
+ $control: function(){
6174
+ return this.$('.acf-image-uploader');
6175
+ },
6176
+
6177
+ $input: function(){
6178
+ return this.$('input[type="hidden"]');
6179
+ },
6180
+
6181
+ events: {
6182
+ 'click a[data-name="add"]': 'onClickAdd',
6183
+ 'click a[data-name="edit"]': 'onClickEdit',
6184
+ 'click a[data-name="remove"]': 'onClickRemove',
6185
+ 'change input[type="file"]': 'onChange'
6186
+ },
6187
+
6188
+ initialize: function(){
6189
+
6190
+ // add attribute to form
6191
+ if( this.get('uploader') === 'basic' ) {
6192
+ this.$el.closest('form').attr('enctype', 'multipart/form-data');
6193
+ }
6194
+ },
6195
+
6196
+ validateAttachment: function( attachment ){
6197
 
6198
+ // defaults
6199
+ attachment = attachment || {};
6200
 
6201
+ // WP attachment
6202
+ if( attachment.id !== undefined ) {
6203
+ attachment = attachment.attributes;
6204
+ }
6205
 
6206
+ // args
6207
+ attachment = acf.parseArgs(attachment, {
6208
+ url: '',
6209
+ alt: '',
6210
+ title: '',
6211
+ caption: '',
6212
+ description: '',
6213
+ width: 0,
6214
+ height: 0
6215
+ });
6216
 
6217
+ // preview size
6218
+ var url = acf.isget(attachment, 'sizes', this.get('preview_size'), 'url');
6219
+ if( url !== null ) {
6220
+ attachment.url = url;
6221
+ }
6222
 
6223
+ // return
6224
+ return attachment;
 
 
 
 
 
6225
  },
6226
 
6227
+ render: function( attachment ){
6228
+
6229
+ // vars
6230
+ attachment = this.validateAttachment( attachment );
6231
 
6232
+ // update image
6233
+ this.$('img').attr({
6234
+ src: attachment.url,
6235
+ alt: attachment.alt,
6236
+ title: attachment.title
6237
+ });
6238
+
6239
+ // vars
6240
+ var val = attachment.id || '';
6241
+
6242
+ // update val
6243
+ this.val( val );
6244
+
6245
+ // update class
6246
+ if( val ) {
6247
+ this.$control().addClass('has-value');
6248
+ } else {
6249
+ this.$control().removeClass('has-value');
6250
+ }
6251
+ },
6252
+
6253
+ // create a new repeater row and render value
6254
+ append: function( attachment, parent ){
6255
 
6256
+ // create function to find next available field within parent
6257
+ var getNext = function( field, parent ){
6258
 
6259
+ // find existing file fields within parent
6260
+ var fields = acf.getFields({
6261
+ key: field.get('key'),
6262
+ parent: parent.$el
6263
+ });
6264
+
6265
+ // find the first field with no value
6266
+ for( var i = 0; i < fields.length; i++ ) {
6267
+ if( !fields[i].val() ) {
6268
+ return fields[i];
6269
+ }
6270
  }
6271
+
6272
+ // return
6273
+ return false;
6274
  }
6275
 
6276
+ // find existing file fields within parent
6277
+ var field = getNext( this, parent );
6278
 
6279
+ // add new row if no available field
6280
+ if( !field ) {
6281
+ parent.$('.acf-button:last').trigger('click');
6282
+ field = getNext( this, parent );
 
6283
  }
6284
+
6285
+ // render
6286
+ if( field ) {
6287
+ field.render( attachment );
6288
+ }
6289
+ },
6290
+
6291
+ selectAttachment: function(){
6292
 
6293
+ // vars
6294
+ var parent = this.parent();
6295
+ var multiple = (parent && parent.get('type') === 'repeater');
6296
 
6297
+ // new frame
6298
+ var frame = acf.newMediaPopup({
6299
+ mode: 'select',
6300
+ type: 'image',
6301
+ title: acf.__('Select Image'),
6302
+ field: this.get('key'),
6303
+ multiple: multiple,
6304
+ library: this.get('library'),
6305
+ allowedTypes: this.get('mime_types'),
6306
+ select: $.proxy(function( attachment, i ) {
6307
+ if( i > 0 ) {
6308
+ this.append( attachment, parent );
6309
+ } else {
6310
+ this.render( attachment );
6311
+ }
6312
+ }, this)
6313
+ });
6314
+ },
6315
+
6316
+ editAttachment: function(){
6317
 
6318
+ // vars
6319
+ var val = this.val();
 
 
 
 
 
 
 
6320
 
6321
+ // bail early if no val
6322
+ if( !val ) return;
6323
 
6324
+ // popup
6325
+ var frame = acf.newMediaPopup({
6326
+ mode: 'edit',
6327
+ title: acf.__('Edit Image'),
6328
+ button: acf.__('Update Image'),
6329
+ attachment: val,
6330
+ field: this.get('key'),
6331
+ select: $.proxy(function( attachment, i ) {
6332
+ this.render( attachment );
6333
+ }, this)
6334
+ });
6335
+ },
6336
+
6337
+ removeAttachment: function(){
6338
+ this.render( false );
6339
+ },
6340
+
6341
+ onClickAdd: function( e, $el ){
6342
+ this.selectAttachment();
6343
+ },
6344
+
6345
+ onClickEdit: function( e, $el ){
6346
+ this.editAttachment();
6347
+ },
6348
+
6349
+ onClickRemove: function( e, $el ){
6350
+ this.removeAttachment();
6351
+ },
6352
+
6353
+ onChange: function( e, $el ){
6354
+ var $hiddenInput = this.$input();
6355
 
6356
+ acf.getFileInputData($el, function( data ){
6357
+ $hiddenInput.val( $.param(data) );
6358
+ });
6359
+ }
6360
+ });
6361
+
6362
+ acf.registerFieldType( Field );
6363
+
6364
+ })(jQuery);
6365
+
6366
+ (function($, undefined){
6367
+
6368
+ var Field = acf.models.ImageField.extend({
6369
+
6370
+ type: 'file',
6371
+
6372
+ $control: function(){
6373
+ return this.$('.acf-file-uploader');
6374
+ },
6375
+
6376
+ $input: function(){
6377
+ return this.$('input[type="hidden"]');
6378
+ },
6379
+
6380
+ validateAttachment: function( attachment ){
6381
 
6382
+ // defaults
6383
+ attachment = attachment || {};
6384
 
6385
+ // WP attachment
6386
+ if( attachment.id !== undefined ) {
6387
+ attachment = attachment.attributes;
6388
+ }
6389
 
6390
+ // args
6391
+ attachment = acf.parseArgs(attachment, {
6392
+ url: '',
6393
+ alt: '',
6394
+ title: '',
6395
+ filename: '',
6396
+ filesizeHumanReadable: '',
6397
+ icon: '/wp-includes/images/media/default.png'
6398
+ });
6399
+
6400
+ // return
6401
+ return attachment;
6402
  },
6403
 
6404
+ render: function( attachment ){
6405
 
6406
  // vars
6407
+ attachment = this.validateAttachment( attachment );
 
 
6408
 
6409
+ // update image
6410
+ this.$('img').attr({
6411
+ src: attachment.icon,
6412
+ alt: attachment.alt,
6413
+ title: attachment.title
6414
+ });
6415
+
6416
+ // update elements
6417
+ this.$('[data-name="title"]').text( attachment.title );
6418
+ this.$('[data-name="filename"]').text( attachment.filename ).attr( 'href', attachment.url );
6419
+ this.$('[data-name="filesize"]').text( attachment.filesizeHumanReadable );
6420
+
6421
+ // vars
6422
+ var val = attachment.id || '';
6423
+
6424
+ // update val
6425
+ acf.val( this.$input(), val );
6426
+
6427
+ // update class
6428
+ if( val ) {
6429
+ this.$control().addClass('has-value');
6430
+ } else {
6431
+ this.$control().removeClass('has-value');
6432
+ }
6433
+ },
6434
+
6435
+ selectAttachment: function(){
6436
 
6437
+ // vars
6438
+ var parent = this.parent();
6439
+ var multiple = (parent && parent.get('type') === 'repeater');
6440
 
6441
+ // new frame
6442
+ var frame = acf.newMediaPopup({
6443
+ mode: 'select',
6444
+ title: acf.__('Select File'),
6445
+ field: this.get('key'),
6446
+ multiple: multiple,
6447
+ library: this.get('library'),
6448
+ allowedTypes: this.get('mime_types'),
6449
+ select: $.proxy(function( attachment, i ) {
6450
+ if( i > 0 ) {
6451
+ this.append( attachment, parent );
6452
+ } else {
6453
+ this.render( attachment );
6454
+ }
6455
+ }, this)
6456
+ });
6457
+ },
6458
+
6459
+ editAttachment: function(){
6460
 
6461
+ // vars
6462
+ var val = this.val();
6463
 
6464
+ // bail early if no val
6465
+ if( !val ) {
6466
+ return false;
6467
+ }
6468
 
6469
+ // popup
6470
+ var frame = acf.newMediaPopup({
6471
+ mode: 'edit',
6472
+ title: acf.__('Edit File'),
6473
+ button: acf.__('Update File'),
6474
+ attachment: val,
6475
+ field: this.get('key'),
6476
+ select: $.proxy(function( attachment, i ) {
6477
+ this.render( attachment );
6478
+ }, this)
6479
+ });
6480
  }
 
6481
  });
6482
 
6483
+ acf.registerFieldType( Field );
6484
+
6485
  })(jQuery);
6486
 
6487
+ (function($, undefined){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6488
 
6489
+ var Field = acf.Field.extend({
6490
 
6491
+ type: 'link',
 
 
 
6492
 
6493
+ events: {
6494
+ 'click a[data-name="add"]': 'onClickEdit',
6495
+ 'click a[data-name="edit"]': 'onClickEdit',
6496
+ 'click a[data-name="remove"]': 'onClickRemove',
6497
+ 'change .link-node': 'onChange',
6498
+ },
6499
 
6500
+ $control: function(){
6501
+ return this.$('.acf-link');
 
6502
  },
6503
 
6504
+ $node: function(){
6505
+ return this.$('.link-node');
6506
+ },
6507
 
6508
+ getValue: function(){
6509
+
6510
+ // vars
6511
+ var $node = this.$node();
6512
+
6513
+ // return false if empty
6514
+ if( !$node.attr('href') ) {
6515
+ return false;
6516
+ }
6517
+
6518
+ // return
6519
+ return {
6520
+ title: $node.html(),
6521
+ url: $node.attr('href'),
6522
+ target: $node.attr('target')
6523
+ };
6524
+ },
6525
 
6526
+ setValue: function( val ){
6527
+
6528
+ // default
6529
+ val = acf.parseArgs(val, {
6530
+ title: '',
6531
+ url: '',
6532
+ target: ''
6533
+ });
6534
 
6535
+ // vars
6536
+ var $div = this.$control();
6537
+ var $node = this.$node();
6538
+
6539
+ // remove class
6540
+ $div.removeClass('-value -external');
6541
+
6542
+ // add class
6543
+ if( val.url ) $div.addClass('-value');
6544
+ if( val.target === '_blank' ) $div.addClass('-external');
6545
 
6546
+ // update text
6547
+ this.$('.link-title').html( val.title );
6548
+ this.$('.link-url').attr('href', val.url).html( val.url );
6549
 
6550
+ // update node
6551
+ $node.html(val.title);
6552
+ $node.attr('href', val.url);
6553
+ $node.attr('target', val.target);
6554
 
6555
+ // update inputs
6556
+ this.$('.input-title').val( val.title );
6557
+ this.$('.input-target').val( val.target );
6558
+ this.$('.input-url').val( val.url ).trigger('change');
6559
  },
6560
 
6561
+ onClickEdit: function( e, $el ){
6562
+ acf.wpLink.open( this.$node() );
6563
+ },
6564
 
6565
+ onClickRemove: function( e, $el ){
6566
+ this.setValue( false );
6567
+ },
 
 
 
 
 
 
 
 
 
6568
 
6569
+ onChange: function( e, $el ){
6570
 
6571
+ // get the changed value
6572
+ var val = this.getValue();
 
6573
 
6574
+ // update inputs
6575
+ this.setValue(val);
6576
+ }
6577
+
6578
+ });
6579
+
6580
+ acf.registerFieldType( Field );
6581
+
6582
+
6583
+ // manager
6584
+ acf.wpLink = new acf.Model({
6585
+
6586
+ getNodeValue: function(){
6587
+ var $node = this.get('node');
6588
+ return {
6589
+ title: $node.html(),
6590
+ url: $node.attr('href'),
6591
+ target: $node.attr('target')
6592
+ };
6593
  },
6594
 
6595
+ setNodeValue: function( val ){
6596
+ var $node = this.get('node');
6597
+ $node.html( val.title );
6598
+ $node.attr('href', val.url);
6599
+ $node.attr('target', val.target);
6600
+ $node.trigger('change');
6601
+ },
6602
 
6603
+ getInputValue: function(){
6604
+ return {
6605
+ title: $('#wp-link-text').val(),
6606
+ url: $('#wp-link-url').val(),
6607
+ target: $('#wp-link-target').prop('checked') ? '_blank' : ''
6608
+ };
6609
+ },
6610
+
6611
+ setInputValue: function( val ){
6612
+ $('#wp-link-text').val( val.title );
6613
+ $('#wp-link-url').val( val.url );
6614
+ $('#wp-link-target').prop('checked', val.target === '_blank' );
6615
+ },
6616
 
6617
+ open: function( $node ){
6618
+
6619
+ // add events
6620
+ this.on('wplink-open', 'onOpen');
6621
+ this.on('wplink-close', 'onClose');
6622
 
6623
+ // set node
6624
+ this.set('node', $node);
6625
 
6626
+ // create textarea
6627
+ var $textarea = $('<textarea id="acf-link-textarea" style="display:none;"></textarea>');
6628
+ $('body').append( $textarea );
6629
 
6630
  // vars
6631
+ var val = this.getNodeValue();
 
 
 
 
 
6632
 
6633
+ // open popup
6634
+ wpLink.open( 'acf-link-textarea', val.url, val.title, null );
6635
 
6636
+ },
6637
+
6638
+ onOpen: function(){
6639
+
6640
+ // always show title (WP will hide title if empty)
6641
+ $('#wp-link-wrap').addClass('has-text-field');
6642
 
6643
+ // set inputs
6644
+ var val = this.getNodeValue();
6645
+ this.setInputValue( val );
6646
  },
 
6647
 
6648
+ close: function(){
6649
+ wpLink.close();
6650
+ },
 
 
 
 
 
 
 
 
 
6651
 
6652
+ onClose: function(){
 
 
 
6653
 
6654
+ // bail early if no node
6655
+ // needed due to WP triggering this event twice
6656
+ if( !this.has('node') ) {
6657
+ return false;
6658
+ }
6659
 
6660
+ // remove events
6661
+ this.off('wplink-open');
6662
+ this.off('wplink-close');
6663
 
6664
+ // set value
6665
+ var val = this.getInputValue();
6666
+ this.setNodeValue( val );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6667
 
6668
+ // remove textarea
6669
+ $('#acf-link-textarea').remove();
6670
 
6671
+ // reset
6672
+ this.set('node', null);
6673
 
6674
+ }
6675
+ });
6676
+
6677
+ })(jQuery);
6678
+
6679
+ (function($, undefined){
6680
+
6681
+ var Field = acf.Field.extend({
6682
+
6683
+ type: 'oembed',
6684
+
6685
+ events: {
6686
+ 'click [data-name="clear-button"]': 'onClickClear',
6687
+ 'keypress .input-search': 'onKeypressSearch',
6688
+ 'keyup .input-search': 'onKeyupSearch',
6689
+ 'change .input-search': 'onChangeSearch'
6690
  },
6691
 
6692
+ $control: function(){
6693
+ return this.$('.acf-oembed');
6694
+ },
6695
+
6696
+ $input: function(){
6697
+ return this.$('.input-value');
6698
+ },
6699
+
6700
+ $search: function(){
6701
+ return this.$('.input-search');
6702
+ },
6703
+
6704
+ getValue: function(){
6705
+ return this.$input().val();
6706
+ },
6707
 
6708
+ getSearchVal: function(){
6709
+ return this.$search().val();
6710
+ },
6711
+
6712
+ setValue: function( val ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6713
 
6714
+ // class
6715
+ if( val ) {
6716
+ this.$control().addClass('has-value');
6717
+ } else {
6718
+ this.$control().removeClass('has-value');
6719
+ }
6720
 
6721
+ acf.val( this.$input(), val );
6722
  },
6723
 
6724
+ showLoading: function( show ){
6725
+ acf.showLoading( this.$('.canvas') );
6726
+ },
6727
 
6728
+ hideLoading: function(){
6729
+ acf.hideLoading( this.$('.canvas') );
6730
+ },
 
 
 
 
 
 
 
 
 
6731
 
6732
+ maybeSearch: function(){
6733
 
6734
  // vars
6735
+ var prevUrl = this.val();
6736
+ var url = this.getSearchVal();
6737
 
6738
+ // no value
6739
+ if( !url ) {
6740
+ return this.clear();
6741
+ }
6742
+
6743
+ // fix missing 'http://' - causes the oembed code to error and fail
6744
+ if( url.substr(0, 4) != 'http' ) {
6745
+ url = 'http://' + url;
6746
+ }
6747
 
6748
+ // bail early if no change
6749
+ if( url === prevUrl ) return;
6750
+
6751
+ // clear existing timeout
6752
+ var timeout = this.get('timeout');
6753
+ if( timeout ) {
6754
+ clearTimeout( timeout );
6755
+ }
6756
+
6757
+ // set new timeout
6758
+ var callback = $.proxy(this.search, this, url);
6759
+ this.set('timeout', setTimeout(callback, 300));
6760
+
6761
+ },
6762
+
6763
+ search: function( url ){
6764
 
6765
+ // ajax
6766
+ var ajaxData = {
6767
+ action: 'acf/fields/oembed/search',
6768
+ s: url,
6769
+ field_key: this.get('key')
6770
+ };
6771
 
6772
+ // clear existing timeout
6773
+ var xhr = this.get('xhr');
6774
+ if( xhr ) {
6775
+ xhr.abort();
6776
+ }
6777
+
6778
+ // loading
6779
+ this.showLoading();
6780
 
6781
+ // query
6782
+ var xhr = $.ajax({
6783
+ url: acf.get('ajaxurl'),
6784
+ data: acf.prepareForAjax(ajaxData),
6785
+ type: 'post',
6786
+ dataType: 'json',
6787
+ context: this,
6788
+ success: function( json ){
6789
 
6790
+ // error
6791
+ if( !json || !json.html ) {
6792
+ json = {
6793
+ url: false,
6794
+ html: ''
6795
+ }
6796
+ }
6797
 
6798
+ // update vars
6799
+ this.val( json.url );
6800
+ this.$('.canvas-media').html( json.html );
6801
+ },
6802
+ complete: function(){
6803
+ this.hideLoading();
6804
  }
 
6805
  });
6806
 
6807
+ this.set('xhr', xhr);
 
 
 
6808
  },
6809
 
6810
+ clear: function(){
6811
+ this.val('');
6812
+ this.$search().val('');
6813
+ this.$('.canvas-media').html('');
6814
+ },
6815
 
6816
+ onClickClear: function( e, $el ){
6817
+ this.clear();
6818
+ },
 
 
 
 
 
 
 
 
 
6819
 
6820
+ onKeypressSearch: function( e, $el ){
6821
+ if( e.which == 13 ) {
6822
+ e.preventDefault();
6823
+ this.maybeSearch();
6824
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
6825
  },
6826
 
6827
+ onKeyupSearch: function( e, $el ){
6828
+ if( $el.val() ) {
6829
+ this.maybeSearch();
6830
+ }
6831
+ },
6832
 
6833
+ onChangeSearch: function( e, $el ){
6834
+ this.maybeSearch();
6835
+ }
6836
+
6837
+ });
6838
+
6839
+ acf.registerFieldType( Field );
6840
+
6841
+ })(jQuery);
6842
+
6843
+ (function($, undefined){
6844
+
6845
+ var Field = acf.Field.extend({
6846
+
6847
+ type: 'radio',
6848
+
6849
+ events: {
6850
+ 'click input[type="radio"]': 'onClick',
6851
+ },
6852
 
6853
+ $control: function(){
6854
+ return this.$('.acf-radio-list');
6855
+ },
6856
+
6857
+ $input: function(){
6858
+ return this.$('input:checked');
6859
+ },
6860
+
6861
+ $inputText: function(){
6862
+ return this.$('input[type="text"]');
6863
+ },
6864
+
6865
+ getValue: function(){
6866
+ var val = this.$input().val();
6867
+ if( val === 'other' ) {
6868
+ val = this.inputText().val();
6869
+ }
6870
+ return val;
6871
+ },
6872
+
6873
+ onClick: function( e, $el ){
6874
 
6875
  // vars
6876
+ var $label = $el.parent('label');
6877
+ var selected = $label.hasClass('selected');
6878
+ var val = $el.val();
6879
 
6880
+ // remove previous selected
6881
+ this.$('.selected').removeClass('selected');
6882
 
6883
+ // add active class
6884
+ $label.addClass('selected');
 
 
 
 
6885
 
6886
+ // allow null
6887
+ if( this.get('allow_null') && selected ) {
6888
+ $label.removeClass('selected');
6889
+ $el.prop('checked', false).trigger('change');
6890
+ val = false;
6891
+ }
6892
 
6893
+ // other
6894
+ if( this.get('other_choice') ) {
 
 
 
 
6895
 
6896
+ // enable
6897
+ if( val === 'other' ) {
6898
+ this.$inputText().prop('disabled', false);
6899
+
6900
+ // disable
6901
+ } else {
6902
+ this.$inputText().prop('disabled', true);
6903
+ }
6904
  }
6905
+ }
6906
+ });
6907
+
6908
+ acf.registerFieldType( Field );
6909
+
6910
+ })(jQuery);
6911
+
6912
+ (function($, undefined){
6913
+
6914
+ var Field = acf.Field.extend({
 
 
 
 
6915
 
6916
+ type: 'range',
6917
 
6918
+ events: {
6919
+ 'input input[type="range"]': 'onChange',
6920
+ 'change input': 'onChange'
6921
+ },
 
 
 
 
 
 
 
 
6922
 
6923
+ $input: function(){
6924
+ return this.$('input[type="range"]');
6925
+ },
6926
 
6927
+ $inputAlt: function(){
6928
+ return this.$('input[type="number"]');
6929
+ },
6930
+
6931
+ setValue: function( val ){
 
 
 
 
 
 
 
 
 
 
 
6932
 
6933
+ this.busy = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6934
 
6935
+ // update range input (with change)
6936
+ acf.val( this.$input(), val );
6937
 
6938
+ // update alt input (without change)
6939
+ acf.val( this.$inputAlt(), val, true );
6940
 
6941
+ this.busy = false;
6942
  },
6943
 
6944
+ onChange: function( e, $el ){
6945
+ if( !this.busy ) {
6946
+ this.setValue( $el.val() );
6947
+ }
6948
+ }
6949
+ });
6950
+
6951
+ acf.registerFieldType( Field );
6952
+
6953
+ })(jQuery);
6954
+
6955
+ (function($, undefined){
6956
+
6957
+ var Field = acf.Field.extend({
6958
 
6959
+ type: 'relationship',
 
 
 
 
 
 
 
 
 
 
 
6960
 
6961
+ events: {
6962
+ 'keypress [data-filter]': 'onKeypressFilter',
6963
+ 'change [data-filter]': 'onChangeFilter',
6964
+ 'keyup [data-filter]': 'onChangeFilter',
6965
+ 'click .choices-list .acf-rel-item': 'onClickAdd',
6966
+ 'click [data-name="remove_item"]': 'onClickRemove',
6967
+ 'mouseover': 'onHover'
6968
  },
6969
 
6970
+ $control: function(){
6971
+ return this.$('.acf-relationship');
6972
+ },
6973
 
6974
+ $list: function( list ) {
6975
+ return this.$('.' + list + '-list');
6976
+ },
 
 
 
 
 
 
 
 
 
 
6977
 
6978
+ $listItems: function( list ) {
6979
+ return this.$list( list ).find('.acf-rel-item');
 
 
6980
  },
6981
 
6982
+ $listItem: function( list, id ) {
6983
+ return this.$list( list ).find('.acf-rel-item[data-id="' + id + '"]');
6984
+ },
6985
 
6986
+ getValue: function(){
6987
+ var val = [];
6988
+ this.$listItems('values').each(function(){
6989
+ val.push( $(this).data('id') );
6990
+ });
6991
+ return val.length ? val : false;
6992
+ },
6993
+
6994
+ newChoice: function( props ){
6995
+ return [
6996
+ '<li>',
6997
+ '<span data-id="' + props.id + '" class="acf-rel-item">' + props.text + '</span>',
6998
+ '</li>'
6999
+ ].join('');
7000
+ },
7001
+
7002
+ newValue: function( props ){
7003
+ return [
7004
+ '<li>',
7005
+ '<input type="hidden" name="' + this.getInputName() + '[]" value="' + props.id + '" />',
7006
+ '<span data-id="' + props.id + '" class="acf-rel-item">' + props.text,
7007
+ '<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>',
7008
+ '</span>',
7009
+ '</li>'
7010
+ ].join('');
7011
+ },
7012
+
7013
+ addSortable: function( self ){
7014
+
7015
+ // sortable
7016
+ this.$list('values').sortable({
7017
+ items: 'li',
7018
+ forceHelperSize: true,
7019
+ forcePlaceholderSize: true,
7020
+ scroll: true,
7021
+ update: function(){
7022
+ self.$input().trigger('change');
7023
+ }
7024
+ });
7025
+ },
7026
 
7027
+ initialize: function(){
7028
 
7029
+ // scroll
7030
+ var onScroll = this.proxy(function(e){
7031
 
7032
+ // bail early if no more results
7033
+ if( this.get('loading') || !this.get('more') ) {
7034
+ return;
7035
+ }
7036
 
7037
+ // Scrolled to bottom
7038
+ var $list = this.$list('choices');
7039
+ var scrollTop = Math.ceil( $list.scrollTop() );
7040
+ var scrollHeight = Math.ceil( $list[0].scrollHeight );
7041
+ var innerHeight = Math.ceil( $list.innerHeight() );
7042
+ var paged = this.get('paged') || 1;
7043
+ if( (scrollTop + innerHeight) >= scrollHeight ) {
7044
+
7045
+ // update paged
7046
+ this.set('paged', (paged+1));
7047
+
7048
+ // fetch
7049
+ this.fetch();
7050
+ }
7051
+
7052
+ });
 
 
 
 
7053
 
7054
+ this.$list('choices').scrollTop(0).on('scroll', onScroll);
 
7055
 
7056
+ // fetch
7057
+ this.fetch();
7058
  },
7059
 
7060
+ onHover: function( e ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7061
 
7062
+ // only once
7063
+ $().off(e);
7064
 
7065
+ // add sortable
7066
+ this.addSortable( this );
7067
  },
7068
 
7069
+ onKeypressFilter: function( e, $el ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7070
 
7071
+ // don't submit form
7072
+ if( e.which == 13 ) {
7073
+ e.preventDefault();
7074
+ }
7075
  },
7076
 
7077
+ onChangeFilter: function( e, $el ){
7078
+
7079
+ // vars
7080
+ var val = $el.val();
7081
+ var filter = $el.data('filter');
7082
+
7083
+ // Bail early if filter has not changed
7084
+ if( this.get(filter) === val ) {
7085
+ return;
7086
+ }
7087
 
7088
+ // update attr
7089
+ this.set(filter, val);
7090
 
7091
+ // reset paged
7092
+ this.set('paged', 1);
 
7093
 
7094
+ // fetch
7095
+ if( $el.is('select') ) {
7096
+ this.fetch();
7097
 
7098
+ // search must go through timeout
7099
+ } else {
7100
+ this.maybeFetch();
7101
+ }
7102
  },
7103
 
7104
+ onClickAdd: function( e, $el ){
7105
 
7106
+ // vars
7107
+ var val = this.val();
7108
+ var max = parseInt( this.get('max') );
7109
 
7110
+ // can be added?
7111
+ if( $el.hasClass('disabled') ) {
7112
+ return false;
7113
+ }
7114
+
7115
+ // validate
7116
+ if( max > 0 && val && val.length >= max ) {
7117
+
7118
+ // add notice
7119
+ this.showNotice({
7120
+ text: acf.__('Maximum values reached ( {max} values )').replace('{max}', max),
7121
+ type: 'warning'
7122
+ });
7123
+ return false;
7124
+ }
7125
+
7126
+ // disable
7127
+ $el.addClass('disabled');
7128
+
7129
+ // add
7130
+ var html = this.newValue({
7131
+ id: $el.data('id'),
7132
+ text: $el.html()
7133
+ });
7134
+ this.$list('values').append( html )
7135
+
7136
+ // trigger change
7137
+ this.$input().trigger('change');
7138
+ },
7139
 
7140
+ onClickRemove: function( e, $el ){
7141
 
7142
  // vars
7143
+ var $span = $el.parent();
7144
+ var $li = $span.parent();
7145
+ var id = $span.data('id');
7146
 
7147
+ // remove value
7148
+ setTimeout(function(){
7149
+ $li.remove();
7150
+ }, 1);
7151
 
7152
+ // show choice
7153
+ this.$listItem('choices', id).removeClass('disabled');
7154
 
7155
+ // trigger change
7156
+ this.$input().trigger('change');
7157
+ },
7158
+
7159
+ maybeFetch: function(){
7160
 
7161
  // vars
7162
+ var timeout = this.get('timeout');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7163
 
7164
+ // abort timeout
7165
+ if( timeout ) {
7166
+ clearTimeout( timeout );
7167
+ }
7168
 
7169
+ // fetch
7170
+ timeout = this.setTimeout(this.fetch, 300);
7171
+ this.set('timeout', timeout);
7172
+ },
7173
+
7174
+ getAjaxData: function(){
7175
 
7176
+ // load data based on element attributes
7177
+ var ajaxData = this.$control().data();
7178
+ for( var name in ajaxData ) {
7179
+ ajaxData[ name ] = this.get( name );
7180
+ }
7181
 
7182
+ // extra
7183
+ ajaxData.action = 'acf/fields/relationship/query';
7184
+ ajaxData.field_key = this.get('key');
7185
 
7186
+ // return
7187
+ return ajaxData;
7188
  },
7189
 
7190
+ fetch: function(){
7191
 
7192
+ // abort XHR if this field is already loading AJAX data
7193
+ var xhr = this.get('xhr');
7194
+ if( xhr ) {
7195
+ xhr.abort();
 
7196
  }
7197
 
7198
+ // add to this.o
7199
+ var ajaxData = this.getAjaxData();
7200
+
7201
+ // clear html if is new query
7202
+ var $choiceslist = this.$list( 'choices' );
7203
+ if( ajaxData.paged == 1 ) {
7204
+ $choiceslist.html('');
7205
+ }
7206
 
7207
+ // loading
7208
+ var $loading = $('<li><i class="acf-loading"></i> ' + acf.__('Loading') + '</li>');
7209
+ $choiceslist.append($loading);
7210
+ this.set('loading', true);
7211
 
7212
+ // callback
7213
+ var onComplete = function(){
7214
+ this.set('loading', false);
7215
+ $loading.remove();
7216
+ };
7217
 
7218
+ var onSuccess = function( json ){
 
7219
 
7220
+ // no results
7221
+ if( !json || !json.results || !json.results.length ) {
7222
+
7223
+ // prevent pagination
7224
+ this.set('more', false);
7225
 
7226
+ // add message
7227
+ if( this.get('paged') == 1 ) {
7228
+ this.$list('choices').append('<li>' + acf.__('No matches found') + '</li>');
7229
+ }
7230
+
7231
+ // return
7232
+ return;
7233
+ }
7234
+
7235
+ // set more (allows pagination scroll)
7236
+ this.set('more', json.more );
7237
+
7238
+ // get new results
7239
+ var html = this.walkChoices(json.results);
7240
+ var $html = $( html );
7241
+
7242
+ // apply .disabled to left li's
7243
+ var val = this.val();
7244
+ if( val && val.length ) {
7245
+ val.map(function( id ){
7246
+ $html.find('.acf-rel-item[data-id="' + id + '"]').addClass('disabled');
7247
+ });
7248
+ }
7249
+
7250
+ // append
7251
+ $choiceslist.append( $html );
7252
+
7253
+ // merge together groups
7254
+ var $prevLabel = false;
7255
+ var $prevList = false;
7256
+
7257
+ $choiceslist.find('.acf-rel-label').each(function(){
7258
+
7259
+ var $label = $(this);
7260
+ var $list = $label.siblings('ul');
7261
+
7262
+ if( $prevLabel && $prevLabel.text() == $label.text() ) {
7263
+ $prevList.append( $list.children() );
7264
+ $(this).parent().remove();
7265
+ return;
7266
+ }
7267
+
7268
+ // update vars
7269
+ $prevLabel = $label;
7270
+ $prevList = $list;
7271
+ });
7272
+ };
7273
 
7274
+ // get results
7275
+ var xhr = $.ajax({
7276
+ url: acf.get('ajaxurl'),
7277
+ dataType: 'json',
7278
+ type: 'post',
7279
+ data: acf.prepareForAjax(ajaxData),
7280
+ context: this,
7281
+ success: onSuccess,
7282
+ complete: onComplete
7283
+ });
7284
 
7285
+ // set
7286
+ this.set('xhr', xhr);
7287
+ },
7288
+
7289
+ walkChoices: function( data ){
7290
 
7291
+ // walker
7292
+ var walk = function( data ){
7293
+
7294
+ // vars
7295
+ var html = '';
7296
+
7297
+ // is array
7298
+ if( $.isArray(data) ) {
7299
+ data.map(function(item){
7300
+ html += walk( item );
7301
+ });
7302
+
7303
+ // is item
7304
+ } else if( $.isPlainObject(data) ) {
7305
+
7306
+ // group
7307
+ if( data.children !== undefined ) {
7308
+
7309
+ html += '<li><span class="acf-rel-label">' + data.text + '</span><ul class="acf-bl">';
7310
+ html += walk( data.children );
7311
+ html += '</ul></li>';
7312
+
7313
+ // single
7314
+ } else {
7315
+ html += '<li><span class="acf-rel-item" data-id="' + data.id + '">' + data.text + '</span></li>';
7316
+ }
7317
+ }
7318
+
7319
+ // return
7320
+ return html;
7321
+ };
7322
 
7323
+ return walk( data );
7324
+ }
7325
+
7326
+ });
7327
+
7328
+ acf.registerFieldType( Field );
7329
+
7330
+ })(jQuery);
7331
+
7332
+ (function($, undefined){
7333
+
7334
+ var Field = acf.Field.extend({
7335
+
7336
+ type: 'select',
7337
+
7338
+ select2: false,
7339
+
7340
+ wait: 'load',
7341
+
7342
+ events: {
7343
+ 'removeField': 'onRemove'
7344
+ },
7345
+
7346
+ $input: function(){
7347
+ return this.$('select');
7348
+ },
7349
+
7350
+ initialize: function(){
7351
 
7352
+ // vars
7353
+ var $select = this.$input();
7354
 
7355
+ // inherit data
7356
+ this.inherit( $select );
7357
 
7358
+ // select2
7359
+ if( this.get('ui') ) {
7360
+
7361
+ // populate ajax_data (allowing custom attribute to already exist)
7362
+ var ajaxAction = this.get('ajax_action');
7363
+ if( !ajaxAction ) {
7364
+ ajaxAction = 'acf/fields/' + this.get('type') + '/query';
7365
+ }
7366
+
7367
+ // select2
7368
+ this.select2 = acf.newSelect2($select, {
7369
+ field: this,
7370
+ ajax: this.get('ajax'),
7371
+ multiple: this.get('multiple'),
7372
+ placeholder: this.get('placeholder'),
7373
+ allowNull: this.get('allow_null'),
7374
+ ajaxAction: ajaxAction,
7375
+ });
7376
+ }
7377
+ },
7378
+
7379
+ onRemove: function(){
7380
+ if( this.select2 ) {
7381
+ this.select2.destroy();
7382
+ }
7383
+ }
7384
+ });
7385
+
7386
+ acf.registerFieldType( Field );
7387
+
7388
+ })(jQuery);
7389
+
7390
+ (function($, undefined){
7391
+
7392
+ // vars
7393
+ var CONTEXT = 'tab';
7394
+
7395
+ var Field = acf.Field.extend({
7396
+
7397
+ type: 'tab',
7398
+
7399
+ wait: '',
7400
+
7401
+ tabs: false,
7402
+
7403
+ tab: false,
7404
+
7405
+ findFields: function(){
7406
+ return this.$el.nextUntil('.acf-field-tab', '.acf-field');
7407
  },
7408
 
7409
+ getFields: function(){
7410
+ return acf.getFields( this.findFields() );
7411
+ },
7412
 
7413
+ findTabs: function(){
7414
+ return this.$el.prevAll('.acf-tab-wrap:first');
7415
+ },
 
 
 
 
 
 
 
 
 
7416
 
7417
+ findTab: function(){
7418
+ return this.$('.acf-tab-button');
7419
+ },
7420
+
7421
+ initialize: function(){
 
7422
 
7423
+ // bail early if is td
7424
+ if( this.$el.is('td') ) {
7425
+ this.events = {};
7426
+ return false;
7427
+ }
 
 
 
7428
 
 
7429
  // vars
7430
+ var $tabs = this.findTabs();
7431
+ var $tab = this.findTab();
7432
+ var settings = acf.parseArgs($tab.data(), {
7433
+ endpoint: false,
7434
+ placement: '',
7435
+ before: this.$el
7436
+ });
7437
 
7438
+ // create wrap
7439
+ if( !$tabs.length || settings.endpoint ) {
7440
+ this.tabs = new Tabs( settings );
7441
+ } else {
7442
+ this.tabs = $tabs.data('acf');
7443
+ }
7444
 
7445
+ // add tab
7446
+ this.tab = this.tabs.addTab($tab, this);
7447
+ },
7448
+
7449
+ isActive: function(){
7450
+ return this.tab.isActive();
7451
+ },
7452
+
7453
+ showFields: function(){
7454
 
7455
+ // show fields
7456
+ this.getFields().map(function( field ){
7457
+ field.show( this.cid, CONTEXT );
7458
+ field.hiddenByTab = false;
7459
+ }, this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7460
 
7461
+ },
7462
+
7463
+ hideFields: function(){
7464
 
7465
+ // hide fields
7466
+ this.getFields().map(function( field ){
7467
+ field.hide( this.cid, CONTEXT );
7468
+ field.hiddenByTab = this.tab;
7469
+ }, this);
7470
 
7471
+ },
7472
+
7473
+ show: function( lockKey ){
7474
+
7475
+ // show field and store result
7476
+ var visible = acf.Field.prototype.show.apply(this, arguments);
7477
 
7478
+ // check if now visible
7479
+ if( visible ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7480
 
7481
+ // show tab
7482
+ this.tab.show();
 
 
7483
 
7484
+ // check active tabs
7485
+ this.tabs.refresh();
 
 
 
 
 
7486
  }
7487
+
7488
+ // return
7489
+ return visible;
7490
+ },
7491
+
7492
+ hide: function( lockKey ){
7493
+
7494
+ // hide field and store result
7495
+ var hidden = acf.Field.prototype.hide.apply(this, arguments);
7496
 
7497
+ // check if now hidden
7498
+ if( hidden ) {
 
7499
 
7500
+ // hide tab
7501
+ this.tab.hide();
7502
 
7503
+ // reset tabs if this was active
7504
+ if( this.isActive() ) {
7505
+ this.tabs.reset();
7506
+ }
7507
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7508
 
7509
+ // return
7510
+ return hidden;
7511
+ },
7512
+
7513
+ enable: function( lockKey ){
7514
+
7515
+ // enable fields
7516
+ this.getFields().map(function( field ){
7517
+ field.enable( CONTEXT );
7518
+ });
7519
+ },
7520
+
7521
+ disable: function( lockKey ){
 
 
 
 
 
 
 
 
7522
 
7523
+ // disable fields
7524
+ this.getFields().map(function( field ){
7525
+ field.disable( CONTEXT );
7526
+ });
7527
+ }
7528
+ });
7529
+
7530
+ acf.registerFieldType( Field );
7531
+
7532
+
7533
+ /**
7534
+ * tabs
7535
+ *
7536
+ * description
7537
+ *
7538
+ * @date 8/2/18
7539
+ * @since 5.6.5
7540
+ *
7541
+ * @param type $var Description. Default.
7542
+ * @return type Description.
7543
+ */
7544
+
7545
+ var i = 0;
7546
+ var Tabs = acf.Model.extend({
7547
+
7548
+ tabs: [],
7549
+
7550
+ active: false,
7551
+
7552
+ actions: {
7553
+ 'refresh': 'onRefresh'
7554
+ },
7555
+
7556
+ data: {
7557
+ before: false,
7558
+ placement: 'top',
7559
+ index: 0,
7560
+ initialized: false,
7561
+ },
7562
+
7563
+ setup: function( settings ){
7564
 
7565
+ // data
7566
+ $.extend(this.data, settings);
7567
 
7568
+ // define this prop to avoid scope issues
7569
+ this.tabs = [];
7570
+ this.active = false;
7571
 
7572
  // vars
7573
+ var placement = this.get('placement');
7574
+ var $before = this.get('before');
7575
+ var $parent = $before.parent();
 
 
 
 
 
 
 
7576
 
7577
+ // add sidebar for left placement
7578
+ if( placement == 'left' && $parent.hasClass('acf-fields') ) {
7579
+ $parent.addClass('-sidebar');
7580
+ }
7581
 
7582
+ // create wrap
7583
+ if( $before.is('tr') ) {
7584
+ this.$el = $('<tr class="acf-tab-wrap"><td colspan="2"><ul class="acf-hl acf-tab-group"></ul></td></tr>');
7585
+ } else {
7586
+ this.$el = $('<div class="acf-tab-wrap -' + placement + '"><ul class="acf-hl acf-tab-group"></ul></div>');
 
 
 
 
 
 
 
 
7587
  }
7588
 
7589
+ // append
7590
+ $before.before( this.$el );
7591
 
7592
+ // set index
7593
+ this.set('index', i, true);
7594
+ i++;
7595
+ },
7596
+
7597
+ initializeTabs: function(){
7598
 
7599
+ // find first visible tab
7600
+ var tab = this.getVisible().shift();
7601
 
7602
+ // remember previous tab state
7603
+ var order = acf.getPreference('this.tabs') || [];
7604
+ var groupIndex = this.get('index');
7605
+ var tabIndex = order[ groupIndex ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7606
 
7607
+ if( this.tabs[ tabIndex ] && this.tabs[ tabIndex ].isVisible() ) {
7608
+ tab = this.tabs[ tabIndex ];
7609
+ }
7610
 
7611
+ // select
7612
+ if( tab ) {
7613
+ this.selectTab( tab );
7614
+ } else {
7615
+ this.closeTabs();
7616
+ }
7617
 
7618
+ // set local variable used by tabsManager
7619
+ this.set('initialized', true);
7620
+ },
7621
+
7622
+ getVisible: function(){
7623
+ return this.tabs.filter(function( tab ){
7624
+ return tab.isVisible();
7625
+ });
7626
  },
7627
 
7628
+ getActive: function(){
7629
+ return this.active;
7630
+ },
7631
 
7632
+ setActive: function( tab ){
7633
+ return this.active = tab;
7634
+ },
 
 
 
 
 
 
 
 
 
7635
 
7636
+ hasActive: function(){
7637
+ return (this.active !== false);
7638
+ },
7639
+
7640
+ isActive: function( tab ){
7641
+ var active = this.getActive();
7642
+ return (active && active.cid === tab.cid);
7643
+ },
7644
+
7645
+ closeActive: function(){
7646
+ if( this.hasActive() ) {
7647
+ this.closeTab( this.getActive() );
7648
+ }
7649
+ },
7650
+
7651
+ openTab: function( tab ){
7652
 
7653
+ // close existing tab
7654
+ this.closeActive();
7655
 
7656
+ // open
7657
+ tab.open();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7658
 
7659
+ // set active
7660
+ this.setActive( tab );
7661
  },
7662
 
7663
+ closeTab: function( tab ){
7664
+
7665
+ // close
7666
+ tab.close();
7667
+
7668
+ // set active
7669
+ this.setActive( false );
7670
+ },
7671
 
7672
+ closeTabs: function(){
7673
+ this.tabs.map( this.closeTab, this );
7674
+ },
 
 
 
 
 
 
 
 
 
7675
 
7676
+ selectTab: function( tab ){
7677
 
7678
+ // close other tabs
7679
+ this.tabs.map(function( t ){
7680
+ if( tab.cid !== t.cid ) {
7681
+ this.closeTab( t );
7682
+ }
7683
+ }, this);
7684
 
7685
+ // open
7686
+ this.openTab( tab );
7687
 
7688
+ },
7689
+
7690
+ addTab: function( $a, field ){
7691
+
7692
+ // create <li>
7693
+ var $li = $('<li></li>');
7694
 
7695
+ // append <a>
7696
+ $li.append( $a );
7697
 
7698
+ // append
7699
+ this.$('ul').append( $li );
7700
 
7701
+ // initialize
7702
+ var tab = new Tab({
7703
+ $el: $li,
7704
+ field: field,
7705
+ group: this,
7706
+ });
7707
 
7708
+ // store
7709
+ this.tabs.push( tab );
 
7710
 
7711
+ // return
7712
+ return tab;
7713
  },
7714
 
7715
+ reset: function(){
 
 
 
 
 
7716
 
7717
+ // close existing tab
7718
+ this.closeActive();
7719
 
7720
+ // find and active a tab
7721
+ return this.refresh();
7722
+ },
7723
+
7724
+ refresh: function(){
7725
 
7726
+ // bail early if active already exists
7727
+ if( this.hasActive() ) {
7728
+ return false;
7729
+ }
 
7730
 
7731
+ // find next active tab
7732
+ var tab = this.getVisible().shift();
7733
 
7734
+ // open tab
7735
+ if( tab ) {
7736
+ this.openTab( tab );
 
 
7737
  }
7738
 
7739
+ // return
7740
+ return tab;
7741
+ },
7742
+
7743
+ onRefresh: function(){
7744
 
7745
+ // only for left placements
7746
+ if( this.get('placement') !== 'left' ) {
7747
+ return;
7748
+ }
7749
 
7750
+ // vars
7751
+ var $parent = this.$el.parent();
7752
+ var $list = this.$el.children('ul');
7753
+ var attribute = $parent.is('td') ? 'height' : 'min-height';
7754
 
7755
+ // find height (minus 1 for border-bottom)
7756
+ var height = $list.position().top + $list.outerHeight(true) - 1;
7757
 
7758
+ // add css
7759
+ $parent.css(attribute, height);
7760
+ }
7761
+ });
7762
+
7763
+ var Tab = acf.Model.extend({
7764
+
7765
+ group: false,
7766
+
7767
+ field: false,
7768
+
7769
+ events: {
7770
+ 'click a': 'onClick'
7771
+ },
7772
+
7773
+ index: function(){
7774
+ return this.$el.index();
7775
+ },
7776
+
7777
+ isVisible: function(){
7778
+ return acf.isVisible( this.$el );
7779
+ },
7780
+
7781
+ isActive: function(){
7782
+ return this.$el.hasClass('active');
7783
+ },
7784
+
7785
+ open: function(){
7786
 
7787
+ // add class
7788
+ this.$el.addClass('active');
7789
 
7790
+ // show field
7791
+ this.field.showFields();
7792
  },
7793
 
7794
+ close: function(){
 
 
 
7795
 
7796
+ // remove class
7797
+ this.$el.removeClass('active');
7798
 
7799
+ // hide field
7800
+ this.field.hideFields();
7801
+ },
7802
+
7803
+ onClick: function( e, $el ){
7804
 
7805
+ // prevent default
7806
+ e.preventDefault();
7807
 
7808
+ // toggle
7809
+ this.toggle();
7810
+ },
7811
+
7812
+ toggle: function(){
 
 
 
7813
 
7814
+ // bail early if already active
7815
+ if( this.isActive() ) {
7816
+ return;
 
 
 
 
 
 
 
 
 
7817
  }
7818
 
7819
+ // toggle this tab
7820
+ this.group.openTab( this );
7821
+ }
7822
+ });
7823
+
7824
+ var tabsManager = new acf.Model({
7825
 
7826
+ priority: 50,
7827
 
7828
+ actions: {
7829
+ 'prepare': 'render',
7830
+ 'append': 'render',
7831
+ 'unload': 'onUnload',
7832
+ 'invalid_field': 'onInvalidField'
7833
+ },
 
 
 
 
 
 
 
 
 
 
 
7834
 
7835
+ findTabs: function(){
7836
+ return $('.acf-tab-wrap');
7837
+ },
7838
+
7839
+ getTabs: function(){
7840
+ return acf.getInstances( this.findTabs() );
7841
+ },
7842
+
7843
+ render: function( $el ){
7844
+ this.getTabs().map(function( tabs ){
7845
+ if( !tabs.get('initialized') ) {
7846
+ tabs.initializeTabs();
7847
+ }
7848
+ });
7849
+ },
7850
+
7851
+ onInvalidField: function( field ){
7852
 
7853
+ // bail early if busy
7854
+ if( this.busy ) {
7855
+ return;
7856
+ }
7857
 
7858
+ // ignore if not hidden by tab
7859
+ if( !field.hiddenByTab ) {
7860
+ return;
7861
+ }
 
 
 
 
7862
 
7863
+ // toggle tab
7864
+ field.hiddenByTab.toggle();
7865
+
7866
+ // ignore other invalid fields
7867
+ this.busy = true;
7868
+ this.setTimeout(function(){
7869
+ this.busy = false;
7870
+ }, 100);
7871
+ },
7872
+
7873
+ onUnload: function(){
7874
 
7875
  // vars
7876
+ var order = [];
7877
 
7878
+ // loop
7879
+ this.getTabs().map(function( group ){
7880
+ var active = group.hasActive() ? group.getActive().index() : 0;
7881
+ order.push(active);
7882
+ });
7883
 
7884
+ // bail if no tabs
7885
+ if( !order.length ) {
7886
+ return;
7887
+ }
7888
 
7889
+ // update
7890
+ acf.setPreference('this.tabs', order);
7891
+ }
7892
+ });
7893
+
7894
+ })(jQuery);
7895
+
7896
+ (function($, undefined){
7897
+
7898
+ var Field = acf.models.SelectField.extend({
7899
+ type: 'post_object',
7900
+ });
7901
+
7902
+ acf.registerFieldType( Field );
7903
+
7904
+ })(jQuery);
7905
+
7906
+ (function($, undefined){
7907
+
7908
+ var Field = acf.models.SelectField.extend({
7909
+ type: 'page_link',
7910
+ });
7911
+
7912
+ acf.registerFieldType( Field );
7913
+
7914
+ })(jQuery);
7915
+
7916
+ (function($, undefined){
7917
+
7918
+ var Field = acf.models.SelectField.extend({
7919
+ type: 'user',
7920
+ });
7921
+
7922
+ acf.registerFieldType( Field );
7923
+
7924
+ })(jQuery);
7925
+
7926
+ (function($, undefined){
7927
+
7928
+ var Field = acf.Field.extend({
7929
+
7930
+ type: 'taxonomy',
7931
+
7932
+ data: {
7933
+ 'ftype': 'select'
7934
+ },
7935
+
7936
+ select2: false,
7937
+
7938
+ wait: 'load',
7939
+
7940
+ events: {
7941
+ 'click a[data-name="add"]': 'onClickAdd',
7942
+ 'click input[type="radio"]': 'onClickRadio',
7943
+ },
7944
+
7945
+ $control: function(){
7946
+ return this.$('.acf-taxonomy-field');
7947
+ },
7948
+
7949
+ $input: function(){
7950
+ return this.getRelatedPrototype().$input.apply(this, arguments);
7951
+ },
7952
+
7953
+ getRelatedType: function(){
7954
 
7955
+ // vars
7956
+ var fieldType = this.get('ftype');
 
 
 
 
 
 
 
 
7957
 
7958
+ // normalize
7959
+ if( fieldType == 'multi_select' ) {
7960
+ fieldType = 'select';
7961
+ }
7962
+
7963
+ // return
7964
+ return fieldType;
7965
 
7966
+ },
7967
+
7968
+ getRelatedPrototype: function(){
7969
+ return acf.getFieldType( this.getRelatedType() ).prototype;
7970
+ },
7971
+
7972
+ getValue: function(){
7973
+ return this.getRelatedPrototype().getValue.apply(this, arguments);
7974
+ },
7975
+
7976
+ setValue: function(){
7977
+ return this.getRelatedPrototype().setValue.apply(this, arguments);
7978
+ },
7979
+
7980
+ initialize: function(){
7981
+ this.getRelatedPrototype().initialize.apply(this, arguments);
7982
+ },
7983
+
7984
+ onRemove: function(){
7985
+ if( this.select2 ) {
7986
+ this.select2.destroy();
7987
+ }
7988
+ },
7989
+
7990
+ onClickAdd: function( e, $el ){
7991
 
7992
+ // vars
7993
+ var field = this;
7994
+ var popup = false;
7995
+ var $form = false;
7996
+ var $name = false;
7997
+ var $parent = false;
7998
+ var $button = false;
7999
+ var $message = false;
8000
+ var notice = false;
8001
 
8002
+ // step 1.
8003
+ var step1 = function(){
8004
 
8005
+ // popup
8006
+ popup = acf.newPopup({
8007
+ title: $el.attr('title'),
8008
+ loading: true,
8009
+ width: '300px'
 
8010
  });
8011
 
8012
+ // ajax
8013
+ var ajaxData = {
8014
+ action: 'acf/fields/taxonomy/add_term',
8015
+ field_key: field.get('key')
8016
+ };
8017
 
8018
+ // get HTML
8019
+ $.ajax({
8020
+ url: acf.get('ajaxurl'),
8021
+ data: acf.prepareForAjax(ajaxData),
8022
+ type: 'post',
8023
+ dataType: 'html',
8024
+ success: step2
8025
+ });
8026
+ };
8027
 
8028
+ // step 2.
8029
+ var step2 = function( html ){
 
 
8030
 
8031
+ // update popup
8032
+ popup.loading(false);
8033
+ popup.content(html);
8034
 
8035
+ // vars
8036
+ $form = popup.$('form');
8037
+ $name = popup.$('input[name="term_name"]');
8038
+ $parent = popup.$('select[name="term_parent"]');
8039
+ $button = popup.$('.acf-submit-button');
 
8040
 
8041
+ // focus
8042
+ $name.focus();
8043
 
8044
+ // submit form
8045
+ popup.on('submit', 'form', step3);
8046
+ };
8047
+
8048
+ // step 3.
8049
+ var step3 = function( e, $el ){
8050
 
8051
+ // prevent
8052
+ e.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8053
 
8054
+ // basic validation
8055
+ if( $name.val() === '' ) {
8056
+ $name.focus();
8057
+ return false;
8058
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8059
 
8060
+ // disable
8061
+ acf.startButtonLoading( $button );
8062
 
8063
+ // ajax
8064
+ var ajaxData = {
8065
+ action: 'acf/fields/taxonomy/add_term',
8066
+ field_key: field.get('key'),
8067
+ term_name: $name.val(),
8068
+ term_parent: $parent.length ? $parent.val() : 0
8069
+ };
8070
 
8071
+ $.ajax({
8072
+ url: acf.get('ajaxurl'),
8073
+ data: acf.prepareForAjax(ajaxData),
8074
+ type: 'post',
8075
+ dataType: 'json',
8076
+ success: step4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8077
  });
8078
+ };
8079
+
8080
+ // step 4.
8081
+ var step4 = function( json ){
8082
 
8083
+ // enable
8084
+ acf.stopButtonLoading( $button );
8085
 
8086
+ // remove prev notice
8087
+ if( notice ) {
8088
+ notice.remove();
8089
+ }
8090
+
8091
+ // success
8092
+ if( acf.isAjaxSuccess(json) ) {
8093
 
8094
+ // clear name
8095
+ $name.val('');
8096
 
8097
+ // update term lists
8098
+ step5( json.data );
8099
 
8100
+ // notice
8101
+ notice = acf.newNotice({
8102
+ type: 'success',
8103
+ text: acf.getAjaxMessage(json),
8104
+ target: $form,
8105
+ timeout: 2000,
8106
+ dismiss: false
8107
+ });
8108
 
8109
+ } else {
 
 
8110
 
8111
+ // notice
8112
+ notice = acf.newNotice({
8113
+ type: 'error',
8114
+ text: acf.getAjaxError(json),
8115
+ target: $form,
8116
+ timeout: 2000,
8117
+ dismiss: false
8118
+ });
8119
+ }
8120
 
8121
+ // focus
8122
+ $name.focus();
8123
+ };
8124
 
8125
+ // step 5.
8126
+ var step5 = function( term ){
 
8127
 
8128
+ // update parent dropdown
8129
+ var $option = $('<option value="' + term.term_id + '">' + term.term_label + '</option>');
8130
+ if( term.term_parent ) {
8131
+ $parent.children('option[value="' + term.term_parent + '"]').after( $option );
8132
+ } else {
8133
+ $parent.append( $option );
8134
+ }
8135
 
8136
+ // add this new term to all taxonomy field
8137
+ var fields = acf.getFields({
8138
+ type: 'taxonomy'
8139
+ });
8140
 
8141
+ fields.map(function( otherField ){
8142
+ if( otherField.get('taxonomy') == field.get('taxonomy') ) {
8143
+ otherField.appendTerm( term );
8144
+ }
8145
+ });
8146
 
8147
+ // select
8148
+ field.selectTerm( term.term_id );
8149
+ };
8150
+
8151
+ // run
8152
+ step1();
8153
+ },
8154
+
8155
+ appendTerm: function( term ){
8156
 
8157
+ if( this.getRelatedType() == 'select' ) {
8158
+ this.appendTermSelect( term );
8159
+ } else {
8160
+ this.appendTermCheckbox( term );
8161
+ }
8162
+ },
8163
+
8164
+ appendTermSelect: function( term ){
8165
 
8166
+ this.select2.addOption({
8167
+ id: term.term_id,
8168
+ text: term.term_label
8169
+ });
8170
 
8171
+ },
8172
+
8173
+ appendTermCheckbox: function( term ){
8174
 
8175
+ // vars
8176
+ var name = this.$('[name]:first').attr('name');
8177
+ var $ul = this.$('ul:first');
8178
 
8179
+ // allow multiple selection
8180
+ if( this.getRelatedType() == 'checkbox' ) {
8181
+ name += '[]';
8182
+ }
8183
 
8184
+ // create new li
8185
+ var $li = $([
8186
+ '<li data-id="' + term.term_id + '">',
8187
+ '<label>',
8188
+ '<input type="' + this.get('ftype') + '" value="' + term.term_id + '" name="' + name + '" /> ',
8189
+ '<span>' + term.term_name + '</span>',
8190
+ '</label>',
8191
+ '</li>'
8192
+ ].join(''));
8193
+
8194
+ // find parent
8195
+ if( term.term_parent ) {
8196
+
8197
+ // vars
8198
+ var $parent = $ul.find('li[data-id="' + term.term_parent + '"]');
8199
+
8200
+ // update vars
8201
+ $ul = $parent.children('ul');
8202
+
8203
+ // create ul
8204
+ if( !$ul.exists() ) {
8205
+ $ul = $('<ul class="children acf-bl"></ul>');
8206
+ $parent.append( $ul );
8207
+ }
8208
+ }
8209
 
8210
+ // append
8211
+ $ul.append( $li );
8212
  },
8213
 
8214
+ selectTerm: function( id ){
8215
+ if( this.getRelatedType() == 'select' ) {
8216
+ this.select2.selectOption( id );
8217
+ } else {
8218
+ var $input = this.$('input[value="' + id + '"]');
8219
+ $input.prop('checked', true).trigger('change');
8220
+ }
8221
+ },
8222
 
8223
+ onClickRadio: function( e, $el ){
8224
+
8225
+ // vars
8226
+ var $label = $el.parent('label');
8227
+ var selected = $label.hasClass('selected');
8228
+
8229
+ // remove previous selected
8230
+ this.$('.selected').removeClass('selected');
8231
+
8232
+ // add active class
8233
+ $label.addClass('selected');
8234
+
8235
+ // allow null
8236
+ if( this.get('allow_null') && selected ) {
8237
+ $label.removeClass('selected');
8238
+ $el.prop('checked', false).trigger('change');
8239
+ }
8240
+ }
8241
+ });
8242
+
8243
+ acf.registerFieldType( Field );
8244
 
8245
+ })(jQuery);
8246
+
8247
+ (function($, undefined){
8248
+
8249
+ var Field = acf.models.DatePickerField.extend({
8250
+
8251
+ type: 'time_picker',
8252
+
8253
+ $control: function(){
8254
+ return this.$('.acf-time-picker');
8255
+ },
8256
+
8257
+ initialize: function(){
8258
 
8259
  // vars
8260
+ var $input = this.$input();
8261
+ var $inputText = this.$inputText();
8262
 
8263
+ // args
8264
+ var args = {
8265
+ timeFormat: this.get('time_format'),
8266
+ altField: $input,
8267
+ altFieldTimeOnly: false,
8268
+ altTimeFormat: 'HH:mm:ss',
8269
+ showButtonPanel: true,
8270
+ controlType: 'select',
8271
+ oneLine: true,
8272
+ closeText: acf.get('dateTimePickerL10n').selectText,
8273
+ timeOnly: true,
8274
+ };
8275
 
8276
+ // add custom 'Close = Select' functionality
8277
+ args.onClose = function( value, dp_instance, t_instance ){
8278
 
8279
  // vars
8280
+ var $close = dp_instance.dpDiv.find('.ui-datepicker-close');
 
 
 
 
 
 
 
 
 
 
 
 
 
8281
 
8282
+ // if clicking close button
8283
+ if( !value && $close.is(':hover') ) {
8284
+ t_instance._updateDateTime();
8285
+ }
8286
+ };
8287
+
8288
+
8289
+ // filter
8290
+ args = acf.applyFilters('time_picker_args', args, this);
8291
+
8292
+ // add date time picker
8293
+ acf.newTimePicker( $inputText, args );
8294
+
8295
+ // action
8296
+ acf.doAction('time_picker_init', $inputText, args, this);
8297
+ }
8298
+ });
8299
+
8300
+ acf.registerFieldType( Field );
8301
+
8302
+
8303
+ // add
8304
+ acf.newTimePicker = function( $input, args ){
8305
+
8306
+ // bail ealry if no datepicker library
8307
+ if( typeof $.timepicker === 'undefined' ) {
8308
+ return false;
8309
+ }
8310
+
8311
+ // defaults
8312
+ args = args || {};
8313
+
8314
+ // initialize
8315
+ $input.timepicker( args );
8316
+
8317
+ // wrap the datepicker (only if it hasn't already been wrapped)
8318
+ if( $('body > #ui-datepicker-div').exists() ) {
8319
+ $('body > #ui-datepicker-div').wrap('<div class="acf-ui-datepicker" />');
8320
+ }
8321
+ };
8322
+
8323
+ })(jQuery);
8324
+
8325
+ (function($, undefined){
8326
+
8327
+ var Field = acf.Field.extend({
8328
+
8329
+ type: 'true_false',
8330
+
8331
+ events: {
8332
+ 'change .acf-switch-input': 'onChange',
8333
+ 'focus .acf-switch-input': 'onFocus',
8334
+ 'blur .acf-switch-input': 'onBlur',
8335
+ 'keypress .acf-switch-input': 'onKeypress'
8336
+ },
8337
+
8338
+ $input: function(){
8339
+ return this.$('input[type="checkbox"]');
8340
+ },
8341
+
8342
+ $switch: function(){
8343
+ return this.$('.acf-switch');
8344
+ },
8345
+
8346
+ getValue: function(){
8347
+ return this.$input().prop('checked') ? 1 : 0;
8348
+ },
8349
+
8350
+ initialize: function(){
8351
+ this.render();
8352
+ },
8353
+
8354
+ render: function(){
8355
+
8356
+ // vars
8357
+ var $switch = this.$switch();
8358
 
8359
+ // bail ealry if no $switch
8360
+ if( !$switch.length ) return;
8361
+
8362
+ // vars
8363
+ var $on = $switch.children('.acf-switch-on');
8364
+ var $off = $switch.children('.acf-switch-off');
8365
+ var width = Math.max( $on.width(), $off.width() );
8366
+
8367
+ // bail ealry if no width
8368
+ if( !width ) return;
8369
+
8370
+ // set widths
8371
+ $on.css( 'min-width', width );
8372
+ $off.css( 'min-width', width );
8373
 
8374
+ },
8375
+
8376
+ switchOn: function() {
8377
+ this.$input().prop('checked', true);
8378
+ this.$switch().addClass('-on');
8379
+ },
8380
+
8381
+ switchOff: function() {
8382
+ this.$input().prop('checked', false);
8383
+ this.$switch().removeClass('-on');
8384
+ },
8385
+
8386
+ onChange: function( e, $el ){
8387
+ if( $el.prop('checked') ) {
8388
+ this.switchOn();
8389
+ } else {
8390
+ this.switchOff();
8391
+ }
8392
+ },
8393
+
8394
+ onFocus: function( e, $el ){
8395
+ this.$switch().addClass('-focus');
8396
+ },
8397
+
8398
+ onBlur: function( e, $el ){
8399
+ this.$switch().removeClass('-focus');
8400
+ },
8401
+
8402
+ onKeypress: function( e, $el ){
8403
+
8404
+ // left
8405
+ if( e.keyCode === 37 ) {
8406
+ return this.switchOff();
8407
+ }
8408
+
8409
+ // right
8410
+ if( e.keyCode === 39 ) {
8411
+ return this.switchOn();
8412
+ }
8413
+
8414
+ }
8415
+ });
8416
+
8417
+ acf.registerFieldType( Field );
8418
+
8419
+ })(jQuery);
8420
+
8421
+ (function($, undefined){
8422
+
8423
+ var Field = acf.Field.extend({
8424
+
8425
+ type: 'url',
8426
+
8427
+ events: {
8428
+ 'keyup input[type="url"]': 'onkeyup'
8429
+ },
8430
+
8431
+ $control: function(){
8432
+ return this.$('.acf-input-wrap');
8433
+ },
8434
+
8435
+ $input: function(){
8436
+ return this.$('input[type="url"]');
8437
+ },
8438
+
8439
+ initialize: function(){
8440
+ this.render();
8441
+ },
8442
+
8443
+ isValid: function(){
8444
+
8445
+ // vars
8446
+ var val = this.val();
8447
+
8448
+ // bail early if no val
8449
+ if( !val ) {
8450
+ return false;
8451
+ }
8452
+
8453
+ // url
8454
+ if( val.indexOf('://') !== -1 ) {
8455
+ return true;
8456
+ }
8457
 
8458
+ // protocol relative url
8459
+ if( val.indexOf('//') === 0 ) {
8460
+ return true;
8461
+ }
8462
+
8463
+ // return
8464
+ return false;
8465
+ },
8466
+
8467
+ render: function(){
8468
+
8469
+ // add class
8470
+ if( this.isValid() ) {
8471
+ this.$control().addClass('-valid');
8472
+ } else {
8473
+ this.$control().removeClass('-valid');
8474
+ }
8475
+ },
8476
+
8477
+ onkeyup: function( e, $el ){
8478
+ this.render();
8479
+ }
8480
+ });
8481
+
8482
+ acf.registerFieldType( Field );
8483
+
8484
+ })(jQuery);
8485
+
8486
+ (function($, undefined){
8487
+
8488
+ var Field = acf.Field.extend({
8489
+
8490
+ type: 'wysiwyg',
8491
+
8492
+ wait: 'load',
8493
+
8494
+ events: {
8495
+ 'mousedown .acf-editor-wrap.delay': 'onMousedown',
8496
+ 'sortstartField': 'disableEditor',
8497
+ 'sortstopField': 'enableEditor',
8498
+ 'removeField': 'disableEditor'
8499
+ },
8500
+
8501
+ $control: function(){
8502
+ return this.$('.acf-editor-wrap');
8503
+ },
8504
+
8505
+ $input: function(){
8506
+ return this.$('textarea');
8507
+ },
8508
+
8509
+ getMode: function(){
8510
+ return this.$control().hasClass('tmce-active') ? 'visual' : 'text';
8511
  },
8512
 
8513
+ initialize: function(){
 
 
 
 
8514
 
8515
+ // initializeEditor if no delay
8516
+ if( !this.$control().hasClass('delay') ) {
8517
+ this.initializeEditor();
8518
+ }
8519
  },
8520
 
8521
+ initializeEditor: function(){
8522
+
8523
+ // vars
8524
+ var $wrap = this.$control();
8525
+ var $textarea = this.$input();
8526
+ var args = {
8527
+ tinymce: true,
8528
+ quicktags: true,
8529
+ toolbar: this.get('toolbar'),
8530
+ mode: this.getMode(),
8531
+ field: this
8532
+ };
8533
+
8534
+ // generate new id
8535
+ var oldId = $textarea.attr('id');
8536
+ var newId = acf.uniqueId('acf-editor-');
8537
+
8538
+ // rename
8539
+ acf.rename({
8540
+ target: $wrap,
8541
+ search: oldId,
8542
+ replace: newId,
8543
+ destructive: true
8544
+ });
8545
 
8546
+ // update id
8547
+ this.set('id', newId, true);
8548
 
8549
+ // initialize
8550
+ acf.tinymce.initialize( newId, args );
8551
  },
8552
 
8553
+ onMousedown: function( e ){
 
 
 
 
 
8554
 
8555
+ // prevent default
8556
+ e.preventDefault();
8557
 
8558
+ // remove delay class
8559
+ var $wrap = this.$control();
8560
+ $wrap.removeClass('delay');
8561
+ $wrap.find('.acf-editor-toolbar').remove();
8562
 
8563
+ // initialize
8564
+ this.initializeEditor();
8565
+ },
8566
 
8567
+ enableEditor: function(){
8568
+ if( this.getMode() == 'visual' ) {
8569
+ acf.tinymce.enable( this.get('id') );
8570
+ }
8571
+ },
8572
+
8573
+ disableEditor: function(){
8574
+ acf.tinymce.destroy( this.get('id') );
8575
+ }
8576
+ });
8577
+
8578
+ acf.registerFieldType( Field );
8579
+
8580
+ })(jQuery);
8581
+
8582
+ (function($, undefined){
8583
 
8584
+ // vars
8585
+ var storage = [];
8586
 
8587
+ /**
8588
+ * acf.Condition
8589
  *
8590
+ * description
8591
  *
8592
+ * @date 23/3/18
8593
+ * @since 5.6.9
 
8594
  *
8595
+ * @param type $var Description. Default.
8596
+ * @return type Description.
8597
  */
8598
 
8599
+ acf.Condition = acf.Model.extend({
8600
 
8601
+ type: '', // used for model name
8602
+ operator: '==', // rule operator
8603
+ label: '', // label shown when editing fields
8604
+ choiceType: 'input', // input, select
8605
+ fieldTypes: [], // auto connect this conditions with these field types
8606
 
8607
+ data: {
8608
+ conditions: false, // the parent instance
8609
+ field: false, // the field which we query against
8610
+ rule: {} // the rule [field, operator, value]
8611
+ },
8612
 
8613
+ events: {
8614
+ 'change': 'change',
8615
+ 'keyup': 'change',
8616
+ 'enableField': 'change',
8617
+ 'disableField': 'change'
8618
+ },
 
 
8619
 
8620
+ setup: function( props ){
8621
+ $.extend(this.data, props);
8622
+ },
8623
 
8624
+ getEventTarget: function( $el, event ){
8625
+ return $el || this.get('field').$el;
8626
+ },
8627
 
8628
+ change: function( e, $el ){
8629
+ this.get('conditions').change( e );
 
 
8630
  },
8631
+
8632
+ match: function( rule, field ){
8633
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8634
  },
8635
 
8636
+ calculate: function(){
8637
+ return this.match( this.get('rule'), this.get('field') );
 
 
 
 
 
 
 
 
 
 
8638
  },
8639
 
8640
+ choices: function( field ){
8641
+ return '<intput type="text" />';
 
 
 
 
 
 
 
 
 
 
 
8642
  }
 
8643
  });
8644
 
8645
+ /**
8646
+ * acf.newCondition
8647
+ *
8648
+ * description
8649
+ *
8650
+ * @date 1/2/18
8651
+ * @since 5.6.5
8652
+ *
8653
+ * @param type $var Description. Default.
8654
+ * @return type Description.
8655
+ */
8656
+
8657
+ acf.newCondition = function( rule, conditions ){
8658
 
8659
+ // currently setting up conditions for fieldX, this field is the 'target'
8660
+ var target = conditions.get('field');
8661
 
8662
+ // use the 'target' to find the 'trigger' field.
8663
+ // - this field is used to setup the conditional logic events
8664
+ var field = target.getField( rule.field );
8665
 
8666
+ // bail ealry if no target or no field (possible if field doesn't exist due to HTML error)
8667
+ if( !target || !field ) {
8668
+ return false;
8669
+ }
 
8670
 
8671
+ // vars
8672
+ var args = {
8673
+ rule: rule,
8674
+ target: target,
8675
+ conditions: conditions,
8676
+ field: field
8677
+ };
8678
 
8679
+ // vars
8680
+ var fieldType = field.get('type');
8681
+ var operator = rule.operator;
 
 
8682
 
8683
+ // get avaibale conditions
8684
+ var conditionTypes = acf.getConditionTypes({
8685
+ fieldType: fieldType,
8686
+ operator: operator,
8687
+ });
8688
 
8689
+ // instantiate
8690
+ var model = conditionTypes[0] || acf.Condition;
8691
+
8692
+ // instantiate
8693
+ var condition = new model( args );
8694
+
8695
+ // return
8696
+ return condition;
8697
+ };
8698
 
8699
+ /**
8700
+ * mid
8701
+ *
8702
+ * Calculates the model ID for a field type
8703
+ *
8704
+ * @date 15/12/17
8705
+ * @since 5.6.5
8706
+ *
8707
+ * @param string type
8708
+ * @return string
8709
+ */
8710
 
8711
+ var modelId = function( type ) {
8712
+ return acf.strPascalCase( type || '' ) + 'Condition';
8713
+ };
8714
+
8715
+ /**
8716
+ * acf.registerConditionType
8717
+ *
8718
+ * description
8719
+ *
8720
+ * @date 1/2/18
8721
+ * @since 5.6.5
8722
+ *
8723
+ * @param type $var Description. Default.
8724
+ * @return type Description.
8725
+ */
8726
+
8727
+ acf.registerConditionType = function( model ){
8728
 
8729
+ // vars
8730
+ var proto = model.prototype;
8731
+ var type = proto.type;
8732
+ var mid = modelId( type );
8733
 
8734
+ // store model
8735
+ acf.models[ mid ] = model;
 
 
8736
 
8737
+ // store reference
8738
+ storage.push( type );
8739
+ };
8740
+
8741
+ /**
8742
+ * acf.getConditionType
8743
+ *
8744
+ * description
8745
+ *
8746
+ * @date 1/2/18
8747
+ * @since 5.6.5
8748
+ *
8749
+ * @param type $var Description. Default.
8750
+ * @return type Description.
8751
+ */
8752
+
8753
+ acf.getConditionType = function( type ){
8754
+ var mid = modelId( type );
8755
+ return acf.models[ mid ] || false;
8756
+ }
8757
+
8758
+ /**
8759
+ * acf.registerConditionForFieldType
8760
+ *
8761
+ * description
8762
+ *
8763
+ * @date 1/2/18
8764
+ * @since 5.6.5
8765
+ *
8766
+ * @param type $var Description. Default.
8767
+ * @return type Description.
8768
+ */
8769
+
8770
+ acf.registerConditionForFieldType = function( conditionType, fieldType ){
8771
 
8772
+ // get model
8773
+ var model = acf.getConditionType( conditionType );
8774
+
8775
+ // append
8776
+ if( model ) {
8777
+ model.prototype.fieldTypes.push( fieldType );
8778
+ }
8779
+ };
8780
+
8781
+ /**
8782
+ * acf.getConditionTypes
8783
+ *
8784
+ * description
8785
+ *
8786
+ * @date 1/2/18
8787
+ * @since 5.6.5
8788
+ *
8789
+ * @param type $var Description. Default.
8790
+ * @return type Description.
8791
+ */
8792
+
8793
+ acf.getConditionTypes = function( args ){
8794
+
8795
+ // defaults
8796
+ args = acf.parseArgs(args, {
8797
+ fieldType: '',
8798
+ operator: ''
8799
+ });
8800
+
8801
+ // clonse available types
8802
+ var types = [];
8803
+
8804
+ // loop
8805
+ storage.map(function( type ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8806
 
8807
+ // vars
8808
+ var model = acf.getConditionType(type);
8809
+ var ProtoFieldTypes = model.prototype.fieldTypes;
8810
+ var ProtoOperator = model.prototype.operator;
8811
 
8812
+ // check fieldType
8813
+ if( args.fieldType && ProtoFieldTypes.indexOf( args.fieldType ) === -1 ) {
8814
+ return;
8815
+ }
 
8816
 
8817
+ // check operator
8818
+ if( args.operator && ProtoOperator !== args.operator ) {
8819
+ return;
8820
+ }
8821
 
8822
  // append
8823
+ types.push( model );
8824
+ });
 
 
 
 
8825
 
8826
+ // return
8827
+ return types;
8828
+ };
8829
 
8830
+ })(jQuery);
8831
+
8832
+ (function($, undefined){
8833
 
8834
+ // vars
8835
+ var CONTEXT = 'conditional_logic';
8836
+
8837
+ /**
8838
+ * conditionsManager
8839
  *
8840
+ * description
8841
  *
8842
+ * @date 1/2/18
8843
+ * @since 5.6.5
 
8844
  *
8845
+ * @param type $var Description. Default.
8846
+ * @return type Description.
8847
  */
8848
 
8849
+ var conditionsManager = new acf.Model({
 
 
 
 
8850
 
8851
+ id: 'conditionsManager',
 
 
 
 
 
 
 
 
8852
 
8853
+ priority: 20, // run actions later
 
 
8854
 
8855
+ actions: {
8856
+ 'new_field': 'onNewField',
 
 
 
 
 
 
 
8857
  },
8858
 
8859
+ onNewField: function( field ){
8860
+ if( field.has('conditions') ) {
8861
+ field.getConditions().render();
 
 
 
 
 
 
 
 
 
 
 
 
8862
  }
 
 
 
8863
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8864
  });
8865
 
 
8866
  /**
8867
+ * acf.Field.prototype.getField
8868
  *
8869
+ * Finds a field that is related to another field
8870
  *
8871
+ * @date 1/2/18
8872
  * @since 5.6.5
8873
  *
8874
+ * @param type $var Description. Default.
8875
+ * @return type Description.
8876
  */
8877
 
8878
+ var getSiblingField = function( field, key ){
8879
+
8880
+ // find sibling (very fast)
8881
+ var fields = acf.getFields({
8882
+ key: key,
8883
+ sibling: field.$el,
8884
+ suppressFilters: true,
8885
+ });
8886
 
8887
+ // find sibling-children (fast)
8888
+ // needed for group fields, accordions, etc
8889
+ if( !fields.length ) {
8890
+ fields = acf.getFields({
8891
+ key: key,
8892
+ parent: field.$el.parent(),
8893
+ suppressFilters: true,
8894
+ });
8895
+ }
8896
+
8897
+ // return
8898
+ if( fields.length ) {
8899
+ return fields[0];
8900
+ }
8901
+ return false;
8902
+ };
8903
+
8904
+ acf.Field.prototype.getField = function( key ){
8905
 
8906
+ // get sibling field
8907
+ var field = getSiblingField( this, key );
 
8908
 
8909
+ // return early
8910
+ if( field ) {
8911
+ return field;
8912
+ }
 
 
 
 
 
 
 
 
8913
 
8914
+ // move up through each parent and try again
8915
+ var parents = this.parents();
8916
+ for( var i = 0; i < parents.length; i++ ) {
 
 
 
 
8917
 
8918
+ // get sibling field
8919
+ field = getSiblingField( parents[i], key );
 
 
8920
 
8921
+ // return early
8922
+ if( field ) {
8923
+ return field;
8924
+ }
8925
  }
8926
 
8927
+ // return
8928
+ return false;
8929
+ };
 
 
 
 
 
 
 
8930
 
8931
 
8932
+ /**
8933
+ * acf.Field.prototype.getConditions
8934
  *
8935
+ * Returns the field's conditions instance
8936
  *
8937
+ * @date 1/2/18
8938
+ * @since 5.6.5
 
8939
  *
8940
+ * @param type $var Description. Default.
8941
+ * @return type Description.
8942
  */
8943
 
8944
+ acf.Field.prototype.getConditions = function(){
 
 
8945
 
8946
+ // instantiate
8947
+ if( !this.conditions ) {
8948
+ this.conditions = new Conditions( this );
8949
+ }
 
8950
 
8951
+ // return
8952
+ return this.conditions;
8953
+ };
8954
+
8955
+
8956
+ /**
8957
+ * Conditions
8958
+ *
8959
+ * description
8960
+ *
8961
+ * @date 1/2/18
8962
+ * @since 5.6.5
8963
+ *
8964
+ * @param type $var Description. Default.
8965
+ * @return type Description.
8966
+ */
8967
+ var timeout = false;
8968
+ var Conditions = acf.Model.extend({
8969
 
8970
+ id: 'Conditions',
 
 
 
 
 
 
 
 
8971
 
8972
+ data: {
8973
+ field: false, // The field with "data-conditions" (target).
8974
+ timeStamp: false, // Reference used during "change" event.
8975
+ groups: [], // The groups of condition instances.
8976
  },
8977
 
8978
+ setup: function( field ){
 
 
 
 
 
 
 
8979
 
8980
+ // data
8981
+ this.data.field = field;
8982
 
8983
+ // vars
8984
+ var conditions = field.get('conditions');
 
8985
 
8986
+ // detect groups
8987
+ if( conditions instanceof Array ) {
8988
 
8989
+ // detect groups
8990
+ if( conditions[0] instanceof Array ) {
8991
+
8992
+ // loop
8993
+ conditions.map(function(rules, i){
8994
+ this.addRules( rules, i );
8995
+ }, this);
8996
 
8997
+ // detect rules
8998
+ } else {
8999
+ this.addRules( conditions );
9000
+ }
9001
 
9002
+ // detect rule
9003
+ } else {
9004
+ this.addRule( conditions );
9005
  }
9006
+ },
9007
+
9008
+ change: function( e ){
9009
 
9010
+ // this function may be triggered multiple times per event due to multiple condition classes
9011
+ // compare timestamp to allow only 1 trigger per event
9012
+ if( this.get('timeStamp') === e.timeStamp ) {
9013
+ return false;
9014
+ } else {
9015
+ this.set('timeStamp', e.timeStamp, true);
9016
+ }
9017
 
9018
+ // render condition and store result
9019
+ var changed = this.render();
 
 
 
 
 
 
 
9020
  },
9021
 
9022
+ render: function(){
9023
+ return this.calculate() ? this.show() : this.hide();
9024
  },
9025
 
9026
+ show: function(){
9027
+ return this.get('field').showEnable(this.cid, CONTEXT);
9028
  },
9029
 
9030
+ hide: function(){
9031
+ return this.get('field').hideDisable(this.cid, CONTEXT);
9032
  },
9033
 
9034
+ calculate: function(){
9035
 
9036
+ // vars
9037
+ var pass = false;
9038
+
9039
+ // loop
9040
+ this.getGroups().map(function( group ){
9041
+
9042
+ // igrnore this group if another group passed
9043
+ if( pass ) return;
9044
 
9045
+ // find passed
9046
+ var passed = group.filter(function(condition){
9047
+ return condition.calculate();
9048
+ });
9049
 
9050
+ // if all conditions passed, update the global var
9051
+ if( passed.length == group.length ) {
9052
+ pass = true;
9053
+ }
9054
  });
9055
 
9056
+ return pass;
9057
  },
9058
 
9059
+ hasGroups: function(){
9060
+ return this.data.groups != null;
 
 
 
 
 
 
 
 
9061
  },
9062
 
9063
+ getGroups: function(){
9064
+ return this.data.groups;
9065
  },
9066
 
9067
+ addGroup: function(){
9068
+ var group = [];
9069
+ this.data.groups.push( group );
9070
+ return group;
 
 
 
 
 
 
 
 
 
9071
  },
9072
+
9073
+ hasGroup: function( i ){
9074
+ return this.data.groups[i] != null;
9075
+ },
9076
+
9077
+ getGroup: function( i ){
9078
+ return this.data.groups[i];
9079
+ },
9080
+
9081
+ removeGroup: function( i ){
9082
+ this.data.groups[i].delete;
9083
+ return this;
9084
+ },
9085
+
9086
+ addRules: function( rules, group ){
9087
+ rules.map(function( rule ){
9088
+ this.addRule( rule, group );
9089
+ }, this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9090
  },
9091
 
9092
+ addRule: function( rule, group ){
9093
 
9094
+ // defaults
9095
+ group = group || 0;
 
 
 
 
 
 
 
9096
 
9097
+ // vars
9098
+ var groupArray;
9099
 
9100
+ // get group
9101
+ if( this.hasGroup(group) ) {
9102
+ groupArray = this.getGroup(group);
9103
  } else {
9104
+ groupArray = this.addGroup();
9105
  }
9106
 
9107
+ // instantiate
9108
+ var condition = acf.newCondition( rule, this );
9109
 
9110
+ // bail ealry if condition failed (field did not exist)
9111
+ if( !condition ) {
9112
+ return false;
9113
+ }
9114
 
9115
+ // add rule
9116
+ groupArray.push(condition);
9117
+ },
9118
+
9119
+ hasRule: function(){
9120
 
9121
+ },
9122
+
9123
+ getRule: function( rule, group ){
9124
 
9125
+ // defaults
9126
+ rule = rule || 0;
9127
+ group = group || 0;
9128
 
9129
+ return this.data.groups[ group ][ rule ];
9130
  },
9131
 
9132
+ removeRule: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9133
 
9134
  }
9135
+ });
9136
+
9137
+ })(jQuery);
9138
+
9139
+ (function($, undefined){
9140
+
9141
+ var __ = acf.__;
9142
+
9143
+ var parseString = function( val ){
9144
+ return val ? '' + val : '';
9145
+ };
9146
+
9147
+ var isEqualTo = function( v1, v2 ){
9148
+ return ( parseString(v1).toLowerCase() === parseString(v2).toLowerCase() );
9149
+ };
9150
+
9151
+ var isEqualToNumber = function( v1, v2 ){
9152
+ return ( parseFloat(v1) === parseFloat(v2) );
9153
+ };
9154
+
9155
+ var isGreaterThan = function( v1, v2 ){
9156
+ return ( parseFloat(v1) > parseFloat(v2) );
9157
+ };
9158
+
9159
+ var isLessThan = function( v1, v2 ){
9160
+ return ( parseFloat(v1) < parseFloat(v2) );
9161
+ };
9162
+
9163
+ var inArray = function( v1, array ){
9164
 
9165
+ // cast all values as string
9166
+ array = array.map(function(v2){
9167
+ return parseString(v2);
9168
+ });
9169
+
9170
+ return (array.indexOf( v1 ) > -1);
9171
+ }
9172
+
9173
+ var containsString = function( haystack, needle ){
9174
+ return ( parseString(haystack).indexOf( parseString(needle) ) > -1 );
9175
+ };
9176
+
9177
+ var matchesPattern = function( v1, pattern ){
9178
+ var regexp = new RegExp(parseString(pattern), 'gi');
9179
+ return parseString(v1).match( regexp );
9180
+ };
9181
+
9182
+ /**
9183
+ * hasValue
9184
+ *
9185
+ * description
9186
+ *
9187
+ * @date 1/2/18
9188
+ * @since 5.6.5
9189
+ *
9190
+ * @param void
9191
+ * @return void
9192
+ */
9193
+
9194
+ var HasValue = acf.Condition.extend({
9195
+ type: 'hasValue',
9196
+ operator: '!=empty',
9197
+ label: __('Has any value'),
9198
+ fieldTypes: [ 'text', 'textarea', 'number', 'range', 'email', 'url', 'password', 'image', 'file', 'wysiwyg', 'oembed', 'select', 'checkbox', 'radio', 'button_group', 'link', 'post_object', 'page_link', 'relationship', 'taxonomy', 'user', 'google_map', 'date_picker', 'date_time_picker', 'time_picker', 'color_picker' ],
9199
+ match: function( rule, field ){
9200
+ return (field.val() ? true : false);
9201
+ },
9202
+ choices: function( fieldObject ){
9203
+ return '<input type="text" disabled="" />';
9204
+ }
9205
+ });
9206
+
9207
+ acf.registerConditionType( HasValue );
9208
+
9209
+ /**
9210
+ * hasValue
9211
+ *
9212
+ * description
9213
+ *
9214
+ * @date 1/2/18
9215
+ * @since 5.6.5
9216
+ *
9217
+ * @param void
9218
+ * @return void
9219
+ */
9220
+
9221
+ var HasNoValue = HasValue.extend({
9222
+ type: 'hasNoValue',
9223
+ operator: '==empty',
9224
+ label: __('Has no value'),
9225
+ match: function( rule, field ){
9226
+ return !HasValue.prototype.match.apply(this, arguments);
9227
+ }
9228
  });
9229
 
9230
+ acf.registerConditionType( HasNoValue );
9231
+
9232
 
9233
 
9234
  /**
9235
+ * EqualTo
9236
  *
9237
  * description
9238
  *
9239
+ * @date 1/2/18
9240
  * @since 5.6.5
9241
  *
9242
+ * @param void
9243
+ * @return void
9244
  */
9245
 
9246
+ var EqualTo = acf.Condition.extend({
9247
+ type: 'equalTo',
9248
+ operator: '==',
9249
+ label: __('Value is equal to'),
9250
+ fieldTypes: [ 'text', 'textarea', 'number', 'range', 'email', 'url', 'password' ],
9251
+ match: function( rule, field ){
9252
+ if( $.isNumeric(rule.value) ) {
9253
+ return isEqualToNumber( rule.value, field.val() );
9254
+ } else {
9255
+ return isEqualTo( rule.value, field.val() );
9256
+ }
9257
  },
9258
+ choices: function( fieldObject ){
9259
+ return '<input type="text" />';
9260
+ }
9261
+ });
9262
+
9263
+ acf.registerConditionType( EqualTo );
9264
+
9265
+ /**
9266
+ * NotEqualTo
9267
+ *
9268
+ * description
9269
+ *
9270
+ * @date 1/2/18
9271
+ * @since 5.6.5
9272
+ *
9273
+ * @param void
9274
+ * @return void
9275
+ */
9276
+
9277
+ var NotEqualTo = EqualTo.extend({
9278
+ type: 'notEqualTo',
9279
+ operator: '!=',
9280
+ label: __('Value is not equal to'),
9281
+ match: function( rule, field ){
9282
+ return !EqualTo.prototype.match.apply(this, arguments);
9283
+ }
9284
+ });
9285
+
9286
+ acf.registerConditionType( NotEqualTo );
9287
+
9288
+ /**
9289
+ * PatternMatch
9290
+ *
9291
+ * description
9292
+ *
9293
+ * @date 1/2/18
9294
+ * @since 5.6.5
9295
+ *
9296
+ * @param void
9297
+ * @return void
9298
+ */
9299
+
9300
+ var PatternMatch = acf.Condition.extend({
9301
+ type: 'patternMatch',
9302
+ operator: '==pattern',
9303
+ label: __('Value matches pattern'),
9304
+ fieldTypes: [ 'text', 'textarea', 'email', 'url', 'password', 'wysiwyg' ],
9305
+ match: function( rule, field ){
9306
+ return matchesPattern( field.val(), rule.value );
9307
  },
9308
+ choices: function( fieldObject ){
9309
+ return '<input type="text" placeholder="[a-z0-9]" />';
9310
+ }
9311
+ });
9312
+
9313
+ acf.registerConditionType( PatternMatch );
9314
+
9315
+ /**
9316
+ * Contains
9317
+ *
9318
+ * description
9319
+ *
9320
+ * @date 1/2/18
9321
+ * @since 5.6.5
9322
+ *
9323
+ * @param void
9324
+ * @return void
9325
+ */
9326
+
9327
+ var Contains = acf.Condition.extend({
9328
+ type: 'contains',
9329
+ operator: '==contains',
9330
+ label: __('Value contains'),
9331
+ fieldTypes: [ 'text', 'textarea', 'number', 'email', 'url', 'password', 'wysiwyg', 'oembed' ],
9332
+ match: function( rule, field ){
9333
+ return containsString( field.val(), rule.value );
9334
  },
9335
+ choices: function( fieldObject ){
9336
+ return '<input type="text" />';
9337
+ }
9338
+ });
9339
+
9340
+ acf.registerConditionType( Contains );
9341
+
9342
+ /**
9343
+ * TrueFalseEqualTo
9344
+ *
9345
+ * description
9346
+ *
9347
+ * @date 1/2/18
9348
+ * @since 5.6.5
9349
+ *
9350
+ * @param void
9351
+ * @return void
9352
+ */
9353
+
9354
+ var TrueFalseEqualTo = EqualTo.extend({
9355
+ type: 'trueFalseEqualTo',
9356
+ choiceType: 'select',
9357
+ fieldTypes: [ 'true_false' ],
9358
+ choices: function( field ){
9359
+ return [
9360
+ {
9361
+ id: 1,
9362
+ text: __('Checked')
9363
+ }
9364
+ ];
9365
+ },
9366
+ });
9367
+
9368
+ acf.registerConditionType( TrueFalseEqualTo );
9369
+
9370
+ /**
9371
+ * TrueFalseNotEqualTo
9372
+ *
9373
+ * description
9374
+ *
9375
+ * @date 1/2/18
9376
+ * @since 5.6.5
9377
+ *
9378
+ * @param void
9379
+ * @return void
9380
+ */
9381
+
9382
+ var TrueFalseNotEqualTo = NotEqualTo.extend({
9383
+ type: 'trueFalseNotEqualTo',
9384
+ choiceType: 'select',
9385
+ fieldTypes: [ 'true_false' ],
9386
+ choices: function( field ){
9387
+ return [
9388
+ {
9389
+ id: 1,
9390
+ text: __('Checked')
9391
+ }
9392
+ ];
9393
+ },
9394
+ });
9395
+
9396
+ acf.registerConditionType( TrueFalseNotEqualTo );
9397
+
9398
+ /**
9399
+ * SelectEqualTo
9400
+ *
9401
+ * description
9402
+ *
9403
+ * @date 1/2/18
9404
+ * @since 5.6.5
9405
+ *
9406
+ * @param void
9407
+ * @return void
9408
+ */
9409
+
9410
+ var SelectEqualTo = acf.Condition.extend({
9411
+ type: 'selectEqualTo',
9412
+ operator: '==',
9413
+ label: __('Value is equal to'),
9414
+ fieldTypes: [ 'select', 'checkbox', 'radio', 'button_group' ],
9415
+ match: function( rule, field ){
9416
+ var val = field.val();
9417
+ if( val instanceof Array ) {
9418
+ return inArray( rule.value, val );
9419
+ } else {
9420
+ return isEqualTo( rule.value, val );
9421
+ }
9422
+ },
9423
+ choices: function( fieldObject ){
9424
 
9425
  // vars
9426
+ var choices = [];
9427
+ var lines = fieldObject.$setting('choices textarea').val().split("\n");
 
 
 
 
 
 
9428
 
9429
+ // allow null
9430
+ if( fieldObject.$input('allow_null').prop('checked') ) {
9431
+ choices.push({
9432
+ id: '',
9433
+ text: __('Null')
9434
+ });
9435
+ }
9436
 
9437
+ // loop
9438
+ lines.map(function( line ){
9439
 
9440
+ // split
9441
+ line = line.split(':');
9442
+
9443
+ // default label to value
9444
+ line[1] = line[1] || line[0];
9445
+
9446
+ // append
9447
+ choices.push({
9448
+ id: $.trim( line[0] ),
9449
+ text: $.trim( line[1] )
9450
+ });
9451
  });
9452
 
9453
+ // return
9454
+ return choices;
9455
+ },
9456
+ });
9457
+
9458
+ acf.registerConditionType( SelectEqualTo );
9459
+
9460
+ /**
9461
+ * SelectNotEqualTo
9462
+ *
9463
+ * description
9464
+ *
9465
+ * @date 1/2/18
9466
+ * @since 5.6.5
9467
+ *
9468
+ * @param void
9469
+ * @return void
9470
+ */
9471
+
9472
+ var SelectNotEqualTo = SelectEqualTo.extend({
9473
+ type: 'selectNotEqualTo',
9474
+ operator: '!=',
9475
+ label: __('Value is not equal to'),
9476
+ match: function( rule, field ){
9477
+ return !SelectEqualTo.prototype.match.apply(this, arguments);
9478
+ }
9479
+ });
9480
+
9481
+ acf.registerConditionType( SelectNotEqualTo );
9482
+
9483
+ /**
9484
+ * GreaterThan
9485
+ *
9486
+ * description
9487
+ *
9488
+ * @date 1/2/18
9489
+ * @since 5.6.5
9490
+ *
9491
+ * @param void
9492
+ * @return void
9493
+ */
9494
+
9495
+ var GreaterThan = acf.Condition.extend({
9496
+ type: 'greaterThan',
9497
+ operator: '>',
9498
+ label: __('Value is greater than'),
9499
+ fieldTypes: [ 'number', 'range' ],
9500
+ match: function( rule, field ){
9501
+ var val = field.val();
9502
+ if( val instanceof Array ) {
9503
+ val = val.length;
9504
  }
9505
+ return isGreaterThan( val, rule.value );
9506
  },
9507
+ choices: function( fieldObject ){
9508
+ return '<input type="number" />';
9509
+ }
9510
+ });
9511
+
9512
+ acf.registerConditionType( GreaterThan );
9513
+
9514
+
9515
+ /**
9516
+ * LessThan
9517
+ *
9518
+ * description
9519
+ *
9520
+ * @date 1/2/18
9521
+ * @since 5.6.5
9522
+ *
9523
+ * @param void
9524
+ * @return void
9525
+ */
9526
+
9527
+ var LessThan = GreaterThan.extend({
9528
+ type: 'lessThan',
9529
+ operator: '<',
9530
+ label: __('Value is less than'),
9531
+ match: function( rule, field ){
9532
+ var val = field.val();
9533
+ if( val instanceof Array ) {
9534
+ val = val.length;
 
 
 
 
9535
  }
9536
+ return isLessThan( val, rule.value );
9537
+ },
9538
+ choices: function( fieldObject ){
9539
+ return '<input type="number" />';
9540
  }
 
9541
  });
9542
 
9543
+ acf.registerConditionType( LessThan );
9544
 
9545
+ /**
9546
+ * SelectedGreaterThan
9547
+ *
9548
+ * description
9549
+ *
9550
+ * @date 1/2/18
9551
+ * @since 5.6.5
9552
+ *
9553
+ * @param void
9554
+ * @return void
9555
+ */
9556
+
9557
+ var SelectionGreaterThan = GreaterThan.extend({
9558
+ type: 'selectionGreaterThan',
9559
+ label: __('Selection is greater than'),
9560
+ fieldTypes: [ 'checkbox', 'select', 'post_object', 'page_link', 'relationship', 'taxonomy', 'user' ],
9561
  });
9562
 
9563
+ acf.registerConditionType( SelectionGreaterThan );
9564
 
9565
+ /**
9566
+ * SelectedGreaterThan
9567
  *
9568
+ * description
9569
  *
9570
+ * @date 1/2/18
9571
+ * @since 5.6.5
 
9572
  *
9573
+ * @param void
9574
+ * @return void
9575
  */
9576
 
9577
+ var SelectionLessThan = LessThan.extend({
9578
+ type: 'selectionLessThan',
9579
+ label: __('Selection is less than'),
9580
+ fieldTypes: [ 'checkbox', 'select', 'post_object', 'page_link', 'relationship', 'taxonomy', 'user' ],
9581
+ });
9582
+
9583
+ acf.registerConditionType( SelectionLessThan );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9584
 
 
9585
  })(jQuery);
9586
 
9587
+ (function($, undefined){
9588
+
9589
+ /**
9590
+ * acf.newMediaPopup
9591
+ *
9592
+ * description
9593
+ *
9594
+ * @date 10/1/18
9595
+ * @since 5.6.5
9596
+ *
9597
+ * @param type $var Description. Default.
9598
+ * @return type Description.
9599
+ */
9600
 
9601
+ acf.newMediaPopup = function( args ){
9602
+
9603
+ // args
9604
+ var popup = null;
9605
+ var args = acf.parseArgs(args, {
9606
+ mode: 'select', // 'select', 'edit'
9607
+ title: '', // 'Upload Image'
9608
+ button: '', // 'Select Image'
9609
+ type: '', // 'image', ''
9610
+ field: false, // field instance
9611
+ allowedTypes: '', // '.jpg, .png, etc'
9612
+ library: 'all', // 'all', 'uploadedTo'
9613
+ multiple: false, // false, true, 'add'
9614
+ attachment: 0, // the attachment to edit
9615
+ autoOpen: true, // open the popup automatically
9616
+ open: function(){}, // callback after close
9617
+ select: function(){}, // callback after select
9618
+ close: function(){} // callback after close
9619
+ });
9620
 
9621
+ // initialize
9622
+ if( args.mode == 'edit' ) {
9623
+ popup = new acf.models.EditMediaPopup( args );
9624
+ } else {
9625
+ popup = new acf.models.SelectMediaPopup( args );
9626
+ }
9627
 
9628
+ // open popup (allow frame customization before opening)
9629
+ if( args.autoOpen ) {
9630
+ setTimeout(function(){
9631
+ popup.open();
9632
+ }, 1);
9633
+ }
9634
 
9635
+ // action
9636
+ acf.doAction('new_media_popup', popup);
 
 
9637
 
9638
+ // return
9639
+ return popup;
9640
+ };
9641
+
9642
+
9643
+ /**
9644
+ * getPostID
9645
+ *
9646
+ * description
9647
+ *
9648
+ * @date 10/1/18
9649
+ * @since 5.6.5
9650
+ *
9651
+ * @param type $var Description. Default.
9652
+ * @return type Description.
9653
+ */
9654
+
9655
+ var getPostID = function() {
9656
+ var postID = acf.get('post_id');
9657
+ return $.isNumeric(postID) ? postID : 0;
9658
+ }
9659
+
9660
+
9661
+ /**
9662
+ * acf.getMimeTypes
9663
+ *
9664
+ * description
9665
+ *
9666
+ * @date 11/1/18
9667
+ * @since 5.6.5
9668
+ *
9669
+ * @param type $var Description. Default.
9670
+ * @return type Description.
9671
+ */
9672
+
9673
+ acf.getMimeTypes = function(){
9674
+ return this.get('mimeTypes');
9675
+ };
9676
+
9677
+ acf.getMimeType = function( name ){
9678
 
9679
+ // vars
9680
+ var allTypes = acf.getMimeTypes();
 
 
 
 
 
 
 
 
 
 
9681
 
9682
+ // search
9683
+ if( allTypes[name] !== undefined ) {
9684
+ return allTypes[name];
9685
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9686
 
9687
+ // some types contain a mixed key such as "jpg|jpeg|jpe"
9688
+ for( var key in allTypes ) {
9689
+ if( key.indexOf(name) !== -1 ) {
9690
+ return allTypes[key];
 
 
9691
  }
 
9692
  }
9693
 
9694
+ // return
9695
+ return false;
9696
+ };
9697
 
 
 
 
9698
 
9699
+ /**
9700
+ * MediaPopup
9701
+ *
9702
+ * description
9703
+ *
9704
+ * @date 10/1/18
9705
+ * @since 5.6.5
9706
+ *
9707
+ * @param type $var Description. Default.
9708
+ * @return type Description.
9709
+ */
9710
+
9711
+ var MediaPopup = acf.Model.extend({
 
 
 
 
 
 
9712
 
9713
+ id: 'MediaPopup',
9714
+ data: {},
9715
+ defaults: {},
9716
+ frame: false,
 
 
 
 
 
 
 
 
9717
 
9718
+ setup: function( props ){
9719
+ $.extend(this.data, props);
 
 
 
 
9720
  },
9721
 
9722
+ initialize: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9723
 
9724
  // vars
9725
+ var options = this.getFrameOptions();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9726
 
9727
+ // add states
9728
+ this.addFrameStates( options );
9729
 
9730
+ // create frame
9731
+ var frame = wp.media( options );
9732
+
9733
+ // add args reference
9734
+ frame.acf = this;
 
 
 
 
 
 
 
 
 
 
 
 
9735
 
9736
+ // add events
9737
+ this.addFrameEvents( frame, options );
9738
 
9739
+ // strore frame
9740
+ this.frame = frame;
9741
  },
9742
 
9743
+ open: function(){
9744
+ this.frame.open();
9745
+ },
9746
 
9747
+ close: function(){
9748
+ this.frame.close();
9749
+ },
9750
+
9751
+ remove: function(){
9752
+ this.frame.detach();
9753
+ this.frame.remove();
9754
+ },
 
 
 
 
9755
 
9756
+ getFrameOptions: function(){
9757
 
9758
  // vars
9759
+ var options = {
9760
+ title: this.get('title'),
9761
+ multiple: this.get('multiple'),
9762
+ library: {},
9763
+ states: []
9764
+ };
9765
 
9766
+ // type
9767
+ if( this.get('type') ) {
9768
+ options.library.type = this.get('type');
9769
+ }
9770
 
9771
+ // type
9772
+ if( this.get('library') === 'uploadedTo' ) {
9773
+ options.library.uploadedTo = getPostID();
9774
+ }
9775
 
9776
+ // attachment
9777
+ if( this.get('attachment') ) {
9778
+ options.library.post__in = [ this.get('attachment') ];
9779
+ }
9780
 
9781
+ // button
9782
+ if( this.get('button') ) {
9783
+ options.button = {
9784
+ text: this.get('button')
9785
+ };
9786
  }
9787
+
9788
+ // return
9789
+ return options;
9790
  },
9791
 
9792
+ addFrameStates: function( options ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9793
 
9794
+ // create query
9795
+ var Query = wp.media.query( options.library );
9796
 
9797
+ // add _acfuploader
9798
+ // this is super wack!
9799
+ // if you add _acfuploader to the options.library args, new uploads will not be added to the library view.
9800
+ // this has been traced back to the wp.media.model.Query initialize function (which can't be overriden)
9801
+ // Adding any custom args will cause the Attahcments to not observe the uploader queue
9802
+ // To bypass this security issue, we add in the args AFTER the Query has been initialized
9803
+ // options.library._acfuploader = settings.field;
9804
+ if( this.get('field') && acf.isset(Query, 'mirroring', 'args') ) {
9805
+ Query.mirroring.args._acfuploader = this.get('field');
9806
+ }
 
 
 
 
 
 
 
9807
 
9808
+ // add states
9809
+ options.states.push(
9810
+
9811
+ // main state
9812
+ new wp.media.controller.Library({
9813
+ library: Query,
9814
+ multiple: this.get('multiple'),
9815
+ title: this.get('title'),
9816
+ priority: 20,
9817
+ filterable: 'all',
9818
+ editable: true,
9819
+ allowLocalEdits: true
9820
+ })
9821
+
9822
+ );
9823
 
9824
+ // edit image functionality (added in WP 3.9)
9825
+ if( acf.isset(wp, 'media', 'controller', 'EditImage') ) {
9826
+ options.states.push( new wp.media.controller.EditImage() );
9827
+ }
9828
  },
9829
 
9830
+ addFrameEvents: function( frame, options ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9831
 
9832
+ // log all events
9833
+ //frame.on('all', function( e ) {
9834
+ // console.log( 'frame all: %o', e );
9835
+ //});
9836
+
9837
+ // add class
9838
+ frame.on('open',function() {
9839
+ this.$el.closest('.media-modal').addClass('acf-media-modal -' + this.acf.get('mode') );
9840
+ }, frame);
9841
+
9842
+ // edit image view
9843
+ // source: media-views.js:2410 editImageContent()
9844
+ frame.on('content:render:edit-image', function(){
9845
 
9846
+ var image = this.state().get('image');
9847
+ var view = new wp.media.view.EditImage({ model: image, controller: this }).render();
9848
+ this.content.set( view );
9849
+
9850
+ // after creating the wrapper view, load the actual editor via an ajax call
9851
+ view.loadEditor();
9852
 
9853
+ }, frame);
 
9854
 
9855
+ // update toolbar button
9856
+ /*
9857
+ frame.on( 'toolbar:create:select', function( toolbar ) {
9858
 
9859
+ toolbar.view = new wp.media.view.Toolbar.Select({
9860
+ text: frame.options._button,
9861
+ controller: this
9862
+ });
9863
 
9864
+ }, frame );
9865
+ */
9866
+ // on select
9867
+ frame.on('select', function() {
9868
+
9869
+ // vars
9870
+ var selection = frame.state().get('selection');
9871
+
9872
+ // if selecting images
9873
+ if( selection ) {
9874
+
9875
+ // loop
9876
+ selection.each(function( attachment, i ){
9877
+ frame.acf.get('select').apply( frame.acf, [attachment, i] );
9878
+ });
9879
+ }
9880
+ });
9881
 
9882
+ // on close
9883
+ frame.on('close',function(){
9884
+
9885
+ // callback and remove
9886
+ setTimeout(function(){
9887
+ frame.acf.get('close').apply( frame.acf );
9888
+ frame.acf.remove();
9889
+ }, 1);
9890
+ });
9891
  }
 
9892
  });
 
 
 
 
9893
 
9894
+
9895
+ /**
9896
+ * acf.models.SelectMediaPopup
9897
+ *
9898
+ * description
9899
+ *
9900
+ * @date 10/1/18
9901
+ * @since 5.6.5
9902
+ *
9903
+ * @param type $var Description. Default.
9904
+ * @return type Description.
9905
+ */
9906
+
9907
+ acf.models.SelectMediaPopup = MediaPopup.extend({
9908
+ id: 'SelectMediaPopup',
9909
+ setup: function( props ){
9910
+
9911
+ // default button
9912
+ if( !props.button ) {
9913
+ props.button = acf._x('Select', 'verb');
9914
+ }
9915
+
9916
+ // parent
9917
+ MediaPopup.prototype.setup.apply(this, arguments);
9918
  },
9919
 
9920
+ addFrameEvents: function( frame, options ){
 
 
 
9921
 
9922
+ // plupload
9923
+ // adds _acfuploader param to validate uploads
9924
+ if( acf.isset(_wpPluploadSettings, 'defaults', 'multipart_params') ) {
9925
+
9926
+ // add _acfuploader so that Uploader will inherit
9927
+ _wpPluploadSettings.defaults.multipart_params._acfuploader = this.get('field');
9928
+
9929
+ // remove acf_field so future Uploaders won't inherit
9930
+ frame.on('open', function(){
9931
+ delete _wpPluploadSettings.defaults.multipart_params._acfuploader;
9932
+ });
9933
+ }
9934
 
9935
+ // browse
9936
+ frame.on('content:activate:browse', function(){
9937
+
9938
+ // vars
9939
+ var toolbar = false;
9940
+
9941
+ // populate above vars making sure to allow for failure
9942
+ // perhaps toolbar does not exist because the frame open is Upload Files
9943
+ try {
9944
+ toolbar = frame.content.get().toolbar;
9945
+ } catch(e) {
9946
+ console.log(e);
9947
+ return;
9948
+ }
9949
+
9950
+ // callback
9951
+ frame.acf.customizeFilters.apply(frame.acf, [toolbar]);
9952
  });
9953
 
9954
+ // parent
9955
+ MediaPopup.prototype.addFrameEvents.apply(this, arguments);
 
9956
 
9957
  },
9958
 
9959
+ customizeFilters: function( toolbar ){
9960
 
9961
+ // vars
9962
+ var filters = toolbar.get('filters');
9963
 
9964
+ // image
9965
+ if( this.get('type') == 'image' ) {
9966
+
9967
+ // update all
9968
+ filters.filters.all.text = acf.__('All images');
9969
+
9970
+ // remove some filters
9971
+ delete filters.filters.audio;
9972
+ delete filters.filters.video;
9973
+ delete filters.filters.image;
9974
+
9975
+ // update all filters to show images
9976
+ $.each(filters.filters, function( i, filter ){
9977
+ filter.props.type = filter.props.type || 'image';
9978
+ });
9979
+ }
9980
 
9981
+ // specific types
9982
+ if( this.get('allowedTypes') ) {
9983
+
9984
+ // convert ".jpg, .png" into ["jpg", "png"]
9985
+ var allowedTypes = this.get('allowedTypes').split(' ').join('').split('.').join('').split(',');
9986
+
9987
+ // loop
9988
+ allowedTypes.map(function( name ){
9989
+
9990
+ // get type
9991
+ var mimeType = acf.getMimeType( name );
9992
+
9993
+ // bail early if no type
9994
+ if( !mimeType ) return;
9995
+
9996
+ // create new filter
9997
+ var newFilter = {
9998
+ text: mimeType,
9999
+ props: {
10000
+ status: null,
10001
+ type: mimeType,
10002
+ uploadedTo: null,
10003
+ orderby: 'date',
10004
+ order: 'DESC'
10005
+ },
10006
+ priority: 20
10007
+ };
10008
+
10009
+ // append
10010
+ filters.filters[ mimeType ] = newFilter;
10011
+
10012
+ });
10013
+ }
10014
 
10015
 
 
 
10016
 
10017
+ // uploaded to post
10018
+ if( this.get('library') === 'uploadedTo' ) {
10019
+
10020
+ // vars
10021
+ var uploadedTo = this.frame.options.library.uploadedTo;
10022
+
10023
+ // remove some filters
10024
+ delete filters.filters.unattached;
10025
+ delete filters.filters.uploaded;
10026
+
10027
+ // add uploadedTo to filters
10028
+ $.each(filters.filters, function( i, filter ){
10029
+ filter.text += ' (' + acf.__('Uploaded to this post') + ')';
10030
+ filter.props.uploadedTo = uploadedTo;
10031
+ });
10032
+ }
10033
 
10034
+ // add _acfuploader to filters
10035
+ var field = this.get('field');
10036
+ $.each(filters.filters, function( k, filter ){
10037
+ filter.props._acfuploader = field;
 
10038
  });
 
10039
 
10040
+ // add _acfuplaoder to search
10041
+ var search = toolbar.get('search');
10042
+ search.model.attributes._acfuploader = field;
10043
+
10044
+ // render (custom function added to prototype)
10045
+ if( filters.renderFilters ) {
10046
+ filters.renderFilters();
10047
+ }
10048
+ }
10049
+ });
10050
+
10051
+
10052
+ /**
10053
+ * acf.models.EditMediaPopup
10054
+ *
10055
+ * description
10056
+ *
10057
+ * @date 10/1/18
10058
+ * @since 5.6.5
10059
+ *
10060
+ * @param type $var Description. Default.
10061
+ * @return type Description.
10062
+ */
10063
+
10064
+ acf.models.EditMediaPopup = MediaPopup.extend({
10065
+ id: 'SelectMediaPopup',
10066
+ setup: function( props ){
10067
+
10068
+ // default button
10069
+ if( !props.button ) {
10070
+ props.button = acf._x('Update', 'verb');
10071
+ }
10072
 
10073
+ // parent
10074
+ MediaPopup.prototype.setup.apply(this, arguments);
10075
  },
10076
 
10077
+ addFrameEvents: function( frame, options ){
10078
+
10079
+ // add class
10080
+ frame.on('open',function() {
10081
+
10082
+ // add class
10083
+ this.$el.closest('.media-modal').addClass('acf-expanded');
10084
+
10085
+ // set to browse
10086
+ if( this.content.mode() != 'browse' ) {
10087
+ this.content.mode('browse');
10088
+ }
10089
+
10090
+ // set selection
10091
+ var state = this.state();
10092
+ var selection = state.get('selection');
10093
+ var attachment = wp.media.attachment( frame.acf.get('attachment') );
10094
+ selection.add( attachment );
10095
+
10096
+ }, frame);
10097
+
10098
+ // parent
10099
+ MediaPopup.prototype.addFrameEvents.apply(this, arguments);
10100
+
10101
+ }
10102
+ });
10103
+
10104
+
10105
+ /**
10106
+ * customizePrototypes
10107
+ *
10108
+ * description
10109
+ *
10110
+ * @date 11/1/18
10111
+ * @since 5.6.5
10112
+ *
10113
+ * @param type $var Description. Default.
10114
+ * @return type Description.
10115
+ */
10116
+
10117
+ var customizePrototypes = new acf.Model({
10118
+ id: 'customizePrototypes',
10119
+ wait: 'ready',
10120
+
10121
+ initialize: function(){
10122
 
10123
+ // bail early if no media views
10124
+ if( !acf.isset(window, 'wp', 'media', 'view') ) {
10125
+ return;
10126
+ }
10127
 
10128
+ // fix bug where CPT without "editor" does not set post.id setting which then prevents uploadedTo from working
10129
+ var postID = getPostID();
10130
+ if( postID && acf.isset(wp, 'media', 'view', 'settings', 'post') ) {
10131
+ wp.media.view.settings.post.id = postID;
10132
+ }
10133
 
10134
+ // customize
10135
+ this.customizeAttachmentsRouter();
10136
+ this.customizeAttachmentFilters();
10137
+ this.customizeAttachmentCompat();
10138
+ this.customizeAttachmentLibrary();
10139
  },
10140
 
10141
+ customizeAttachmentsRouter: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10142
 
10143
+ // validate
10144
+ if( !acf.isset(wp, 'media', 'view', 'Router') ) {
10145
+ return;
10146
+ }
10147
 
10148
+ // vars
10149
+ var Parent = wp.media.view.Router;
10150
 
10151
+ // extend
10152
+ wp.media.view.Router = Parent.extend({
10153
+
10154
+ addExpand: function(){
10155
+
10156
+ // vars
10157
+ var $a = $([
10158
+ '<a href="#" class="acf-expand-details">',
10159
+ '<span class="is-closed"><span class="acf-icon -left small grey"></span>' + acf.__('Expand Details') + '</span>',
10160
+ '<span class="is-open"><span class="acf-icon -right small grey"></span>' + acf.__('Collapse Details') + '</span>',
10161
+ '</a>'
10162
+ ].join(''));
10163
+
10164
+ // add events
10165
+ $a.on('click', function( e ){
10166
+ e.preventDefault();
10167
+ var $div = $(this).closest('.media-modal');
10168
+ if( $div.hasClass('acf-expanded') ) {
10169
+ $div.removeClass('acf-expanded');
10170
+ } else {
10171
+ $div.addClass('acf-expanded');
10172
+ }
10173
+ });
10174
+
10175
+ // append
10176
+ this.$el.append( $a );
10177
+ },
10178
 
10179
+ initialize: function(){
10180
+
10181
+ // initialize
10182
+ Parent.prototype.initialize.apply( this, arguments );
10183
 
10184
+ // add buttons
10185
+ this.addExpand();
10186
+
10187
+ // return
10188
+ return this;
10189
  }
10190
+ });
 
 
10191
  },
10192
 
10193
+ customizeAttachmentFilters: function(){
 
 
 
10194
 
10195
+ // validate
10196
+ if( !acf.isset(wp, 'media', 'view', 'AttachmentFilters', 'All') ) {
10197
+ return;
10198
+ }
10199
 
10200
+ // vars
10201
+ var Parent = wp.media.view.AttachmentFilters.All;
 
 
 
 
 
 
 
10202
 
10203
+ // renderFilters
10204
+ // copied from media-views.js:6939
10205
+ Parent.prototype.renderFilters = function(){
10206
 
10207
+ // Build `<option>` elements.
10208
+ this.$el.html( _.chain( this.filters ).map( function( filter, value ) {
10209
+ return {
10210
+ el: $( '<option></option>' ).val( value ).html( filter.text )[0],
10211
+ priority: filter.priority || 50
10212
+ };
10213
+ }, this ).sortBy('priority').pluck('el').value() );
10214
 
10215
+ };
 
10216
  },
10217
 
10218
+ customizeAttachmentCompat: function(){
 
 
 
10219
 
10220
+ // validate
10221
+ if( !acf.isset(wp, 'media', 'view', 'AttachmentCompat') ) {
10222
+ return;
10223
+ }
10224
 
10225
  // vars
10226
+ var AttachmentCompat = wp.media.view.AttachmentCompat;
10227
+ var timeout = false;
 
 
10228
 
10229
+ // extend
10230
+ wp.media.view.AttachmentCompat = AttachmentCompat.extend({
 
 
 
10231
 
10232
+ render: function() {
10233
+
10234
+ // WP bug
10235
+ // When multiple media frames exist on the same page (WP content, WYSIWYG, image, file ),
10236
+ // WP creates multiple instances of this AttachmentCompat view.
10237
+ // Each instance will attempt to render when a new modal is created.
10238
+ // Use a property to avoid this and only render once per instance.
10239
+ if( this.rendered ) {
10240
+ return this;
10241
+ }
10242
+
10243
+ // render HTML
10244
+ AttachmentCompat.prototype.render.apply( this, arguments );
10245
+
10246
+ // when uploading, render is called twice.
10247
+ // ignore first render by checking for #acf-form-data element
10248
+ if( !this.$('#acf-form-data').length ) {
10249
+ return this;
10250
+ }
10251
+
10252
+ // clear timeout
10253
+ clearTimeout( timeout );
10254
+
10255
+ // setTimeout
10256
+ timeout = setTimeout($.proxy(function(){
10257
+ this.rendered = true;
10258
+ acf.doAction('append', this.$el);
10259
+ }, this), 50);
10260
+
10261
+ // return
10262
+ return this;
10263
+ }
10264
+ });
10265
+
10266
+ },
10267
+
10268
+ customizeAttachmentLibrary: function(){
10269
 
10270
+ // validate
10271
+ if( !acf.isset(wp, 'media', 'view', 'Attachment', 'Library') ) {
10272
+ return;
10273
+ }
10274
 
10275
  // vars
10276
+ var AttachmentLibrary = wp.media.view.Attachment.Library;
 
 
 
 
 
 
10277
 
10278
+ // extend
10279
+ wp.media.view.Attachment.Library = AttachmentLibrary.extend({
10280
+
10281
+ render: function() {
 
 
 
10282
 
10283
  // vars
10284
+ var popup = acf.isget(this, 'controller', 'acf');
10285
+ var attributes = acf.isget(this, 'model', 'attributes');
 
 
 
 
 
 
 
 
 
 
 
 
 
10286
 
10287
+ // check vars exist to avoid errors
10288
+ if( popup && attributes ) {
10289
 
10290
+ // show errors
10291
+ if( attributes.acf_errors ) {
10292
+ this.$el.addClass('acf-disabled');
10293
+ }
10294
 
10295
+ // disable selected
10296
+ var selected = popup.get('selected');
10297
+ if( selected && selected.indexOf(attributes.id) > -1 ) {
10298
+ this.$el.addClass('acf-selected');
10299
+ }
10300
  }
10301
+
10302
+ // render
10303
+ return AttachmentLibrary.prototype.render.apply( this, arguments );
10304
 
10305
  },
10306
+
10307
+
10308
+ /*
10309
+ * toggleSelection
10310
+ *
10311
+ * This function is called before an attachment is selected
10312
+ * A good place to check for errors and prevent the 'select' function from being fired
10313
+ *
10314
+ * @type function
10315
+ * @date 29/09/2016
10316
+ * @since 5.4.0
10317
+ *
10318
+ * @param options (object)
10319
+ * @return n/a
10320
+ */
10321
+
10322
+ toggleSelection: function( options ) {
10323
+
10324
+ // vars
10325
+ // source: wp-includes/js/media-views.js:2880
10326
+ var collection = this.collection,
10327
+ selection = this.options.selection,
10328
+ model = this.model,
10329
+ single = selection.single();
10330
 
 
 
10331
 
10332
+ // vars
10333
+ var frame = this.controller;
10334
+ var errors = acf.isget(this, 'model', 'attributes', 'acf_errors');
10335
+ var $sidebar = frame.$el.find('.media-frame-content .media-sidebar');
10336
 
10337
+ // remove previous error
10338
+ $sidebar.children('.acf-selection-error').remove();
10339
 
10340
+ // show attachment details
10341
+ $sidebar.children().removeClass('acf-hidden');
10342
 
10343
+ // add message
10344
+ if( frame && errors ) {
10345
 
10346
+ // vars
10347
+ var filename = acf.isget(this, 'model', 'attributes', 'filename');
10348
 
10349
+ // hide attachment details
10350
+ // Gallery field continues to show previously selected attachment...
10351
+ $sidebar.children().addClass('acf-hidden');
10352
+
10353
+ // append message
10354
+ $sidebar.prepend([
10355
+ '<div class="acf-selection-error">',
10356
+ '<span class="selection-error-label">' + acf.__('Restricted') +'</span>',
10357
+ '<span class="selection-error-filename">' + filename + '</span>',
10358
+ '<span class="selection-error-message">' + errors + '</span>',
10359
+ '</div>'
10360
+ ].join(''));
10361
+
10362
+ // reset selection (unselects all attachments)
10363
+ selection.reset();
10364
+
10365
+ // set single (attachment displayed in sidebar)
10366
+ selection.single( model );
10367
+
10368
+ // return and prevent 'select' form being fired
10369
+ return;
10370
+
10371
+ }
10372
 
10373
+ // return
10374
+ return AttachmentLibrary.prototype.toggleSelection.apply( this, arguments );
10375
  }
10376
  });
10377
+ }
10378
+ });
10379
+
10380
+ })(jQuery);
10381
+
10382
+ (function($, undefined){
10383
+
10384
+ acf.screen = new acf.Model({
10385
+
10386
+ active: true,
10387
+
10388
+ xhr: false,
10389
+
10390
+ wait: 'ready',
10391
+
10392
+ events: {
10393
+ 'change #page_template': 'onChangeTemplate',
10394
+ 'change #parent_id': 'onChangeParent',
10395
+ 'change #post-formats-select input': 'onChangeFormat',
10396
+ 'change .categorychecklist input': 'onChangeTerm',
10397
+ 'change .categorychecklist select': 'onChangeTerm',
10398
+ 'change .acf-taxonomy-field[data-save="1"] input': 'onChangeTerm',
10399
+ 'change .acf-taxonomy-field[data-save="1"] select': 'onChangeTerm'
10400
+ },
10401
+
10402
+ data: {
10403
+ //'post_id': 0,
10404
+ //'page_template': 0,
10405
+ //'page_parent': 0,
10406
+ //'page_type': 0,
10407
+ //'post_format': 0,
10408
+ //'post_taxonomy': 0
10409
+ },
10410
+
10411
+ fetch: function(){
10412
+
10413
+ // bail early if not active
10414
+ if( !this.active ) {
10415
+ return;
10416
+ }
10417
+
10418
+ // bail early if not for post
10419
+ if( acf.get('screen') !== 'post' ) {
10420
+ return;
10421
+ }
10422
+
10423
+ // abort XHR if is already loading AJAX data
10424
+ if( this.xhr ) {
10425
+ this.xhr.abort();
10426
+ }
10427
+
10428
+ // vars
10429
+ var ajaxData = acf.parseArgs(this.data, {
10430
+ post_id: acf.get('post_id')
10431
+ });
10432
+
10433
+ // add action url
10434
+ ajaxData.action = 'acf/post/get_field_groups';
10435
+
10436
+ // add ignore
10437
+ ajaxData.exists = [];
10438
+ $('.acf-postbox').not('.acf-hidden').each(function(){
10439
+ ajaxData.exists.push( $(this).attr('id').substr(4) );
10440
+ });
10441
+
10442
+ // success
10443
+ var onSuccess = function( json ){
10444
+
10445
+ // bail early if not success
10446
+ if( !acf.isAjaxSuccess(json) ) {
10447
+ return;
10448
+ }
10449
+
10450
+ // hide
10451
+ $('.acf-postbox').addClass('acf-hidden');
10452
+ $('.acf-postbox-toggle').addClass('acf-hidden');
10453
+
10454
+ // reset style
10455
+ $('#acf-style').html('');
10456
+
10457
+ // loop
10458
+ json.data.map(function( fieldGroup, i ){
10459
+
10460
+ // vars
10461
+ var $postbox = $('#acf-' + fieldGroup.key);
10462
+ var $toggle = $('#acf-' + fieldGroup.key + '-hide');
10463
+ var $label = $toggle.parent();
10464
+
10465
+ // show
10466
+ // use show() to force display when postbox has been hidden by 'Show on screen' toggle
10467
+ $postbox.removeClass('acf-hidden hide-if-js').show();
10468
+ $label.removeClass('acf-hidden hide-if-js').show();
10469
+ $toggle.prop('checked', true);
10470
+
10471
+ // replace HTML if needed
10472
+ var $replace = $postbox.find('.acf-replace-with-fields');
10473
+ if( $replace.exists() ) {
10474
+ $replace.replaceWith( fieldGroup.html );
10475
+ acf.doAction('append', $postbox);
10476
+ }
10477
+
10478
+ // update style if needed
10479
+ if( i === 0 ) {
10480
+ $('#acf-style').html( fieldGroup.style );
10481
+ }
10482
+
10483
+ // enable inputs
10484
+ acf.enable( $postbox, 'postbox' );
10485
+ });
10486
+ };
10487
+
10488
+ // complete
10489
+ var onComplete = function( json ){
10490
+
10491
+ // disable inputs
10492
+ $('.acf-postbox.acf-hidden').each(function(){
10493
+ acf.disable( $(this), 'postbox' );
10494
+ });
10495
+ };
10496
 
10497
+ // ajax
10498
+ this.xhr = $.ajax({
10499
+ url: acf.get('ajaxurl'),
10500
+ data: acf.prepareForAjax( ajaxData ),
10501
+ type: 'post',
10502
+ dataType: 'json',
10503
+ context: this,
10504
+ success: onSuccess,
10505
+ complete: onComplete
10506
+ });
10507
  },
10508
 
10509
+ syncTaxonomyTerms: function(){
10510
 
10511
  // vars
10512
+ var values = [''];
 
 
 
 
10513
 
10514
+ // loop over term lists
10515
+ $('.categorychecklist, .acf-taxonomy-field').each(function(){
10516
 
10517
  // vars
10518
+ var $el = $(this),
10519
+ $checkbox = $el.find('input[type="checkbox"]').not(':disabled'),
10520
+ $radio = $el.find('input[type="radio"]').not(':disabled'),
10521
+ $select = $el.find('select').not(':disabled'),
10522
+ $hidden = $el.find('input[type="hidden"]').not(':disabled');
10523
 
10524
 
10525
+ // bail early if not a field which saves taxonomy terms to post
10526
+ if( $el.is('.acf-taxonomy-field') && $el.attr('data-save') != '1' ) {
 
 
 
 
10527
 
10528
  return;
10529
 
10530
  }
10531
 
10532
 
10533
+ // bail early if in attachment
10534
+ if( $el.closest('.media-frame').exists() ) {
 
 
 
 
 
 
10535
 
10536
+ return;
 
 
 
10537
 
10538
+ }
 
 
 
 
 
 
 
 
10539
 
10540
 
10541
+ // checkbox
10542
+ if( $checkbox.exists() ) {
10543
 
10544
+ $checkbox.filter(':checked').each(function(){
10545
+
10546
+ values.push( $(this).val() );
10547
+
10548
+ });
10549
 
10550
+ } else if( $radio.exists() ) {
 
10551
 
10552
+ $radio.filter(':checked').each(function(){
10553
+
10554
+ values.push( $(this).val() );
10555
+
10556
+ });
10557
+
10558
+ } else if( $select.exists() ) {
10559
 
10560
+ $select.find('option:selected').each(function(){
 
10561
 
10562
+ values.push( $(this).val() );
10563
 
10564
+ });
10565
+
10566
+ } else if( $hidden.exists() ) {
10567
+
10568
+ $hidden.each(function(){
10569
 
10570
+ // ignor blank values
10571
+ if( ! $(this).val() ) {
10572
+
10573
+ return;
10574
+
10575
+ }
10576
+
10577
+ values.push( $(this).val() );
10578
+
10579
+ });
10580
 
10581
  }
10582
+
10583
+ });
10584
+
10585
+
10586
+ // filter duplicates
10587
+ values = values.filter(function(item, pos, self) {
10588
+ return self.indexOf(item) == pos;
10589
+ });
10590
+
10591
+
10592
+ // update screen
10593
+ this.set( 'post_taxonomy', values ).fetch();
10594
+ },
10595
+
10596
+ onChangeTemplate: function( e, $el ){
10597
+
10598
+ // update & fetch
10599
+ this.set('page_template', $el.val()).fetch();
10600
+ },
10601
+
10602
+ onChangeParent: function( e, $el ){
10603
+
10604
+ // vars
10605
+ var pageType = 'parent';
10606
+ var pageParent = 0;
10607
+
10608
+ // if is child
10609
+ if( $el.val() != "" ) {
10610
+ pageType = 'child';
10611
+ pageParent = $el.val();
10612
+ }
10613
+
10614
+ // update & fetch
10615
+ this.set('page_type', pageType).set('page_parent', pageParent).fetch();
10616
+ },
10617
+
10618
+ onChangeFormat: function( e, $el ){
10619
+
10620
+ // vars
10621
+ var postFormat = $el.val();
10622
+
10623
+ // default
10624
+ if( postFormat == '0' ) {
10625
+ postFormat = 'standard';
10626
+ }
10627
+
10628
+ // update & fetch
10629
+ this.set('post_format', postFormat).fetch();
10630
+ },
10631
+
10632
+ onChangeTerm: function( e, $el ){
10633
+
10634
+ // bail early if within media popup
10635
+ if( $el.closest('.media-frame').exists() ) {
10636
+ return;
10637
+ }
10638
+
10639
+ // set timeout to fix issue with chrome which does not register the change has yet happened
10640
+ this.setTimeout(this.syncTaxonomyTerms, 1);
10641
+ }
10642
+ });
10643
+
10644
+ })(jQuery);
10645
 
10646
+ (function($, undefined){
10647
+
10648
+ /**
10649
+ * acf.newSelect2
10650
+ *
10651
+ * description
10652
+ *
10653
+ * @date 13/1/18
10654
+ * @since 5.6.5
10655
+ *
10656
+ * @param type $var Description. Default.
10657
+ * @return type Description.
10658
+ */
10659
+
10660
+ acf.newSelect2 = function( $select, props ){
10661
+
10662
+ // defaults
10663
+ props = acf.parseArgs(props, {
10664
+ allowNull: false,
10665
+ placeholder: '',
10666
+ multiple: false,
10667
+ field: false,
10668
+ ajax: false,
10669
+ ajaxAction: '',
10670
+ ajaxData: function( data ){ return data; },
10671
+ ajaxResults: function( json ){ return json; },
10672
+ });
10673
+
10674
+ // initialize
10675
+ if( getVersion() == 4 ) {
10676
+ var select2 = new Select2_4( $select, props );
10677
+ } else {
10678
+ var select2 = new Select2_3( $select, props );
10679
+ }
10680
+
10681
+ // actions
10682
+ acf.doAction('new_select2', select2);
10683
+
10684
+ // return
10685
+ return select2;
10686
+ };
10687
+
10688
+ /**
10689
+ * getVersion
10690
+ *
10691
+ * description
10692
+ *
10693
+ * @date 13/1/18
10694
+ * @since 5.6.5
10695
+ *
10696
+ * @param type $var Description. Default.
10697
+ * @return type Description.
10698
+ */
10699
+
10700
+ function getVersion() {
10701
+
10702
+ // v4
10703
+ if( acf.isset(window, 'jQuery', 'fn', 'select2', 'amd') ) {
10704
+ return 4;
10705
+ }
10706
+
10707
+ // v3
10708
+ if( acf.isset(window, 'Select2') ) {
10709
+ return 3;
10710
+ }
10711
+
10712
+ // return
10713
+ return false;
10714
+ }
10715
+
10716
+ /**
10717
+ * Select2
10718
+ *
10719
+ * description
10720
+ *
10721
+ * @date 13/1/18
10722
+ * @since 5.6.5
10723
+ *
10724
+ * @param type $var Description. Default.
10725
+ * @return type Description.
10726
+ */
10727
+
10728
+ var Select2 = acf.Model.extend({
10729
+
10730
+ setup: function( $select, props ){
10731
+ $.extend(this.data, props);
10732
+ this.$el = $select;
10733
+ },
10734
+
10735
+ initialize: function(){
10736
+
10737
+ },
10738
+
10739
+ selectOption: function( value ){
10740
+ var $option = this.getOption( value );
10741
+ if( !$option.prop('selected') ) {
10742
+ $option.prop('selected', true).trigger('change');
10743
+ }
10744
+ },
10745
+
10746
+ unselectOption: function( value ){
10747
+ var $option = this.getOption( value );
10748
+ if( $option.prop('selected') ) {
10749
+ $option.prop('selected', false).trigger('change');
10750
+ }
10751
+ },
10752
+
10753
+ getOption: function( value ){
10754
+ return this.$('option[value="' + value + '"]');
10755
+ },
10756
+
10757
+ addOption: function( option ){
10758
+
10759
+ // defaults
10760
+ option = acf.parseArgs(option, {
10761
+ id: '',
10762
+ text: '',
10763
+ selected: false
10764
  });
10765
 
10766
+ // vars
10767
+ var $option = this.getOption( option.id );
10768
 
10769
+ // append
10770
+ if( !$option.length ) {
10771
+ $option = $('<option></option>');
10772
+ $option.html( option.text );
10773
+ $option.attr('value', option.id);
10774
+ $option.prop('selected', option.selected);
10775
+ this.$el.append($option);
10776
+ }
10777
+
10778
+ // chain
10779
+ return $option;
10780
+ },
10781
+
10782
+ getValue: function(){
10783
+
10784
+ // vars
10785
+ var val = [];
10786
+ var $options = this.$el.find('option:selected');
10787
+
10788
+ // bail early if no selected
10789
+ if( !$options.exists() ) {
10790
+ return val;
10791
+ }
10792
+
10793
+ // sort by attribute
10794
+ $options = $options.sort(function(a, b) {
10795
+ return +a.getAttribute('data-i') - +b.getAttribute('data-i');
10796
+ });
10797
+
10798
+ // loop
10799
+ $options.each(function(){
10800
+ var $el = $(this);
10801
+ val.push({
10802
+ $el: $el,
10803
+ id: $el.attr('value'),
10804
+ text: $el.text(),
10805
+ });
10806
  });
10807
 
10808
+ // return
10809
+ return val;
10810
 
10811
+ },
10812
+
10813
+ mergeOptions: function(){
10814
 
10815
+ },
10816
+
10817
+ getChoices: function(){
10818
+
10819
+ // callback
10820
+ var crawl = function( $parent ){
 
 
 
 
 
 
10821
 
10822
+ // vars
10823
+ var choices = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10824
 
10825
+ // loop
10826
+ $parent.children().each(function(){
 
 
 
 
 
 
10827
 
10828
+ // vars
10829
+ var $child = $(this);
10830
 
10831
+ // optgroup
10832
+ if( $child.is('optgroup') ) {
10833
+
10834
+ choices.push({
10835
+ text: $child.attr('label'),
10836
+ children: crawl( $child )
10837
+ });
10838
 
10839
+ // option
10840
+ } else {
10841
+
10842
+ choices.push({
10843
+ id: $child.attr('value'),
10844
+ text: $child.text()
10845
+ });
10846
+ }
10847
+ });
10848
 
10849
+ // return
10850
+ return choices;
10851
+ };
10852
 
10853
+ // crawl
10854
+ return crawl( this.$el );
10855
+ },
 
 
 
 
 
 
 
 
 
10856
 
10857
+ decodeChoices: function( choices ){
10858
+
10859
+ // callback
10860
+ var crawl = function( items ){
10861
+ items.map(function( item ){
10862
+ item.text = acf.decode( item.text );
10863
+ if( item.children ) {
10864
+ item.children = crawl( item.children );
10865
+ }
10866
+ return item;
10867
+ });
10868
+ return items;
10869
+ };
10870
 
10871
+ // crawl
10872
+ return crawl( choices );
10873
  },
10874
 
10875
+ getAjaxData: function( params ){
10876
+
10877
+ // vars
10878
+ var ajaxData = {
10879
+ action: this.get('ajaxAction'),
10880
+ s: params.term || '',
10881
+ paged: params.page || 1
10882
+ };
10883
+
10884
+ // field helper
10885
+ var field = this.get('field');
10886
+ if( field ) {
10887
+ ajaxData.field_key = field.get('key');
10888
+ }
10889
+
10890
+ // callback
10891
+ var callback = this.get('ajaxData');
10892
+ if( callback ) {
10893
+ ajaxData = callback.apply( this, [ajaxData, params] );
10894
+ }
10895
+
10896
+ // filter
10897
+ ajaxData = acf.applyFilters( 'select2_ajax_data', ajaxData, this.data, this.$el, (field || false), this );
10898
+
10899
+ // return
10900
+ return acf.prepareForAjax(ajaxData);
10901
  },
10902
 
10903
+ getAjaxResults: function( json, params ){
10904
+
10905
+ // defaults
10906
+ json = acf.parseArgs(json, {
10907
+ results: false,
10908
+ more: false,
10909
+ });
10910
+
10911
+ // decode
10912
+ if( json.results ) {
10913
+ json.results = this.decodeChoices(json.results);
10914
+ }
10915
 
10916
+ // callback
10917
+ var callback = this.get('ajaxResults');
10918
+ if( callback ) {
10919
+ json = callback.apply( this, [json, params] );
10920
+ }
10921
+
10922
+ // filter
10923
+ json = acf.applyFilters( 'select2_ajax_results', json, params, this );
10924
 
10925
+ // return
10926
+ return json;
10927
  },
10928
 
10929
+ processAjaxResults: function( json, params ){
10930
 
10931
  // vars
10932
+ var json = this.getAjaxResults( json, params );
10933
 
10934
+ // change more to pagination
10935
+ if( json.more ) {
10936
+ json.pagination = { more: true };
 
 
 
 
 
 
 
 
 
 
10937
  }
10938
 
10939
+ // merge together groups
10940
+ setTimeout($.proxy(this.mergeOptions, this), 1);
10941
 
10942
  // return
10943
+ return json;
 
10944
  },
10945
 
10946
+ destroy: function(){
10947
 
10948
+ // destroy via api
10949
+ if( this.$el.data('select2') ) {
10950
+ this.$el.select2('destroy');
10951
+ }
10952
+
10953
+ // destory via HTML (duplicating HTML does not contain data)
10954
+ this.$el.siblings('.select2-container').remove();
10955
+ }
10956
+
10957
+ });
10958
+
10959
+
10960
+ /**
10961
+ * Select2_4
10962
+ *
10963
+ * description
10964
+ *
10965
+ * @date 13/1/18
10966
+ * @since 5.6.5
10967
+ *
10968
+ * @param type $var Description. Default.
10969
+ * @return type Description.
10970
+ */
10971
+
10972
+ var Select2_4 = Select2.extend({
10973
+
10974
+ initialize: function(){
10975
+
10976
+ // vars
10977
+ var $select = this.$el;
10978
+ var options = {
10979
+ width: '100%',
10980
+ allowClear: this.get('allowNull'),
10981
+ placeholder: this.get('placeholder'),
10982
+ multiple: this.get('multiple'),
10983
+ data: [],
10984
+ escapeMarkup: function( m ){ return m; }
10985
+ };
10986
+
10987
+ // multiple
10988
+ if( options.multiple ) {
10989
+
10990
+ // reorder options
10991
+ this.getValue().map(function( item ){
10992
+ item.$el.detach().appendTo( $select );
10993
+ });
10994
+ }
10995
+
10996
+ // remove conflicting atts
10997
+ $select.removeData('ajax');
10998
+ $select.removeAttr('data-ajax');
10999
+
11000
+ // ajax
11001
+ if( this.get('ajax') ) {
11002
 
11003
+ options.ajax = {
11004
+ url: acf.get('ajaxurl'),
11005
+ delay: 250,
11006
+ dataType: 'json',
11007
+ type: 'post',
11008
+ cache: false,
11009
+ data: $.proxy(this.getAjaxData, this),
11010
+ processResults: $.proxy(this.processAjaxResults, this),
11011
+ };
11012
+ }
11013
+
11014
+ // filter for 3rd party customization
11015
+ //options = acf.applyFilters( 'select2_args', options, $select, this );
11016
+ var field = this.get('field');
11017
+ options = acf.applyFilters( 'select2_args', options, $select, this.data, (field || false), this );
11018
 
11019
+ // add select2
11020
+ $select.select2( options );
11021
+
11022
+ // get container (Select2 v4 does not return this from constructor)
11023
+ var $container = $select.next('.select2-container');
11024
+
11025
+ // multiple
11026
+ if( options.multiple ) {
11027
 
11028
+ // vars
11029
+ var $ul = $container.find('ul');
11030
+
11031
+ // sortable
11032
+ $ul.sortable({
11033
+ stop: function( e ) {
11034
+
11035
+ // loop
11036
+ $ul.find('.select2-selection__choice').each(function() {
11037
+
11038
+ // vars
11039
+ var $option = $( $(this).data('data').element );
11040
+
11041
+ // detach and re-append to end
11042
+ $option.detach().appendTo( $select );
11043
+ });
11044
+
11045
+ // trigger change on input (JS error if trigger on select)
11046
+ $select.trigger('change');
11047
+ }
11048
+ });
11049
 
11050
+ // on select, move to end
11051
+ $select.on('select2:select', this.proxy(function( e ){
11052
+ this.getOption( e.params.data.id ).detach().appendTo( this.$el );
11053
+ }));
11054
  }
11055
 
11056
+ // add class
11057
+ $container.addClass('-acf');
11058
 
11059
+ // action for 3rd party customization
11060
+ acf.doAction('select2_init', $select, options, this.data, (field || false), this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11061
  },
11062
 
11063
+ mergeOptions: function(){
11064
+
11065
+ // vars
11066
+ var $prevOptions = false;
11067
+ var $prevGroup = false;
11068
+
11069
+ // loop
11070
+ $('.select2-results__option[role="group"]').each(function(){
11071
+
11072
+ // vars
11073
+ var $options = $(this).children('ul');
11074
+ var $group = $(this).children('strong');
11075
+
11076
+ // compare to previous
11077
+ if( $prevGroup && $prevGroup.text() === $group.text() ) {
11078
+ $prevOptions.append( $options.children() );
11079
+ $(this).remove();
11080
+ return;
11081
+ }
11082
+
11083
+ // update vars
11084
+ $prevOptions = $options;
11085
+ $prevGroup = $group;
11086
+
11087
+ });
11088
  },
11089
 
11090
+ });
11091
+
11092
+ /**
11093
+ * Select2_3
11094
+ *
11095
+ * description
11096
+ *
11097
+ * @date 13/1/18
11098
+ * @since 5.6.5
11099
+ *
11100
+ * @param type $var Description. Default.
11101
+ * @return type Description.
11102
+ */
11103
+
11104
+ var Select2_3 = Select2.extend({
11105
 
11106
+ initialize: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11107
 
11108
  // vars
11109
+ var $select = this.$el;
11110
+ var value = this.getValue();
11111
+ var multiple = this.get('multiple');
11112
+ var options = {
11113
+ width: '100%',
11114
+ allowClear: this.get('allowNull'),
11115
+ placeholder: this.get('placeholder'),
11116
+ separator: '||',
11117
+ multiple: this.get('multiple'),
11118
+ data: this.getChoices(),
11119
+ escapeMarkup: function( m ){ return m; },
11120
+ dropdownCss: {
11121
+ 'z-index': '999999999'
11122
+ },
11123
+ initSelection: function( element, callback ) {
11124
+ if( multiple ) {
11125
+ callback( value );
11126
+ } else {
11127
+ callback( value.shift() );
11128
+ }
11129
+ }
11130
+ };
11131
+
11132
+ // get hidden input
11133
+ var $input = $select.siblings('input');
11134
+ if( !$input.length ) {
11135
+ $input = $('<input type="hidden" />');
11136
+ $select.before( $input );
11137
+ }
11138
+
11139
+ // set input value
11140
+ inputValue = value.map(function(item){ return item.id }).join('||');
11141
+ $input.val( inputValue );
11142
+
11143
+ // multiple
11144
+ if( options.multiple ) {
11145
+
11146
+ // reorder options
11147
+ value.map(function( item ){
11148
+ item.$el.detach().appendTo( $select );
11149
+ });
11150
+ }
11151
+
11152
+ // remove blank option as we have a clear all button
11153
+ if( options.allowClear ) {
11154
+ options.data = options.data.filter(function(item){
11155
+ return item.id !== '';
11156
+ });
11157
+ }
11158
+
11159
+ // remove conflicting atts
11160
+ $select.removeData('ajax');
11161
+ $select.removeAttr('data-ajax');
11162
+
11163
+ // ajax
11164
+ if( this.get('ajax') ) {
11165
+
11166
+ options.ajax = {
11167
+ url: acf.get('ajaxurl'),
11168
+ quietMillis: 250,
11169
+ dataType: 'json',
11170
+ type: 'post',
11171
+ cache: false,
11172
+ data: $.proxy(this.getAjaxData, this),
11173
+ results: $.proxy(this.processAjaxResults, this),
11174
+ };
11175
+ }
11176
+
11177
+ // filter for 3rd party customization
11178
+ var field = this.get('field');
11179
+ options = acf.applyFilters( 'select2_args', options, $select, this.data, (field || false), this );
11180
+
11181
+ // add select2
11182
+ $input.select2( options );
11183
+
11184
+ // get container
11185
+ var $container = $input.select2('container');
11186
+
11187
+ // helper to find this select's option
11188
+ var getOption = $.proxy(this.getOption, this);
11189
+
11190
+ // multiple
11191
+ if( options.multiple ) {
11192
+
11193
+ // vars
11194
+ var $ul = $container.find('ul');
11195
+
11196
+ // sortable
11197
+ $ul.sortable({
11198
+ stop: function() {
11199
+
11200
+ // loop
11201
+ $ul.find('.select2-search-choice').each(function() {
11202
+
11203
+ // vars
11204
+ var data = $(this).data('select2Data');
11205
+ var $option = getOption( data.id );
11206
+
11207
+ // detach and re-append to end
11208
+ $option.detach().appendTo( $select );
11209
+ });
11210
+
11211
+ // trigger change on input (JS error if trigger on select)
11212
+ $select.trigger('change');
11213
+ }
11214
+ });
11215
+ }
11216
+
11217
+ // on select, create option and move to end
11218
+ $input.on('select2-selecting', function( e ){
11219
+
11220
+ // vars
11221
+ var item = e.choice;
11222
+ var $option = getOption( item.id );
11223
+
11224
+ // create if doesn't exist
11225
+ if( !$option.length ) {
11226
+ $option = $('<option value="' + item.id + '">' + item.text + '</option>');
11227
+ }
11228
+
11229
+ // detach and re-append to end
11230
+ $option.detach().appendTo( $select );
11231
+ });
11232
 
11233
+ // add class
11234
+ $container.addClass('-acf');
11235
 
11236
+ // action for 3rd party customization
11237
+ acf.doAction('select2_init', $select, options, this.data, (field || false), this);
11238
 
11239
+ // change
11240
+ $input.on('change', function(){
11241
+ var val = $input.val();
11242
+ if( val.indexOf('||') ) {
11243
+ val = val.split('||');
11244
+ }
11245
+ $select.val( val ).trigger('change');
11246
+ });
11247
 
11248
+ // hide select
11249
+ $select.hide();
11250
+ },
11251
+
11252
+ mergeOptions: function(){
11253
 
11254
+ // vars
11255
+ var $prevOptions = false;
11256
+ var $prevGroup = false;
11257
 
11258
+ // loop
11259
+ $('#select2-drop .select2-result-with-children').each(function(){
11260
 
11261
  // vars
11262
+ var $options = $(this).children('ul');
11263
+ var $group = $(this).children('.select2-result-label');
11264
 
11265
+ // compare to previous
11266
+ if( $prevGroup && $prevGroup.text() === $group.text() ) {
11267
+ $prevGroup.append( $options.children() );
11268
+ $(this).remove();
11269
+ return;
11270
+ }
11271
 
11272
+ // update vars
11273
+ $prevOptions = $options;
11274
+ $prevGroup = $group;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11275
 
 
 
 
 
11276
  });
11277
 
11278
  },
11279
 
11280
+ getAjaxData: function( term, page ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11281
 
11282
+ // create Select2 v4 params
11283
+ var params = {
11284
+ term: term,
11285
+ page: page
11286
+ }
11287
 
11288
+ // return
11289
+ return Select2.prototype.getAjaxData.apply(this, [params]);
11290
+ },
11291
+
11292
+ });
11293
+
11294
+
11295
+ // manager
11296
+ var select2Manager = new acf.Model({
11297
+ priority: 5,
11298
+ wait: 'prepare',
11299
+ initialize: function(){
11300
 
11301
+ // vars
11302
+ var locale = acf.get('locale');
11303
+ var rtl = acf.get('rtl');
11304
+ var l10n = acf.get('select2L10n');
11305
+ var version = getVersion();
11306
 
11307
+ // bail ealry if no l10n
11308
+ if( !l10n ) {
11309
+ return false;
11310
+ }
11311
 
11312
+ // bail early if 'en'
11313
+ if( locale.indexOf('en') === 0 ) {
11314
+ return false;
11315
+ }
11316
 
11317
+ // initialize
11318
+ if( version == 4 ) {
11319
+ this.addTranslations4();
11320
+ } else if( version == 3 ) {
11321
+ this.addTranslations3();
11322
+ }
11323
+ },
11324
+
11325
+ addTranslations4: function(){
11326
 
11327
  // vars
11328
+ var l10n = acf.get('select2L10n');
11329
+ var locale = acf.get('locale');
11330
 
11331
+ // modify local to match html[lang] attribute (used by Select2)
11332
+ locale = locale.replace('_', '-');
11333
 
11334
+ // select2L10n
11335
+ var select2L10n = {
11336
+ errorLoading: function () {
11337
+ return l10n.load_fail;
11338
+ },
11339
+ inputTooLong: function (args) {
11340
+ var overChars = args.input.length - args.maximum;
11341
+ if( overChars > 1 ) {
11342
+ return l10n.input_too_long_n.replace( '%d', overChars );
11343
+ }
11344
+ return l10n.input_too_long_1;
11345
+ },
11346
+ inputTooShort: function( args ){
11347
+ var remainingChars = args.minimum - args.input.length;
11348
+ if( remainingChars > 1 ) {
11349
+ return l10n.input_too_short_n.replace( '%d', remainingChars );
11350
+ }
11351
+ return l10n.input_too_short_1;
11352
+ },
11353
+ loadingMore: function () {
11354
+ return l10n.load_more;
11355
+ },
11356
+ maximumSelected: function( args ) {
11357
+ var maximum = args.maximum;
11358
+ if( maximum > 1 ) {
11359
+ return l10n.selection_too_long_n.replace( '%d', maximum );
11360
+ }
11361
+ return l10n.selection_too_long_1;
11362
+ },
11363
+ noResults: function () {
11364
+ return l10n.matches_0;
11365
+ },
11366
+ searching: function () {
11367
+ return l10n.searching;
11368
  }
11369
+ };
11370
 
 
 
 
11371
  // append
11372
+ jQuery.fn.select2.amd.define('select2/i18n/' + locale, [], function(){
11373
+ return select2L10n;
11374
+ });
11375
+ },
11376
+
11377
+ addTranslations3: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
11378
 
11379
+ // vars
11380
+ var l10n = acf.get('select2L10n');
11381
+ var locale = acf.get('locale');
11382
 
11383
+ // modify local to match html[lang] attribute (used by Select2)
11384
+ locale = locale.replace('_', '-');
11385
 
11386
+ // select2L10n
11387
+ var select2L10n = {
11388
+ formatMatches: function( matches ) {
11389
+ if( matches > 1 ) {
11390
+ return l10n.matches_n.replace( '%d', matches );
11391
+ }
11392
+ return l10n.matches_1;
11393
+ },
11394
+ formatNoMatches: function() {
11395
+ return l10n.matches_0;
11396
+ },
11397
+ formatAjaxError: function() {
11398
+ return l10n.load_fail;
11399
+ },
11400
+ formatInputTooShort: function( input, min ) {
11401
+ var remainingChars = min - input.length;
11402
+ if( remainingChars > 1 ) {
11403
+ return l10n.input_too_short_n.replace( '%d', remainingChars );
11404
+ }
11405
+ return l10n.input_too_short_1;
11406
+ },
11407
+ formatInputTooLong: function( input, max ) {
11408
+ var overChars = input.length - max;
11409
+ if( overChars > 1 ) {
11410
+ return l10n.input_too_long_n.replace( '%d', overChars );
11411
+ }
11412
+ return l10n.input_too_long_1;
11413
+ },
11414
+ formatSelectionTooBig: function( maximum ) {
11415
+ if( maximum > 1 ) {
11416
+ return l10n.selection_too_long_n.replace( '%d', maximum );
11417
+ }
11418
+ return l10n.selection_too_long_1;
11419
+ },
11420
+ formatLoadMore: function() {
11421
+ return l10n.load_more;
11422
+ },
11423
+ formatSearching: function() {
11424
+ return l10n.searching;
11425
+ }
11426
+ };
11427
+
11428
+ // ensure locales exists
11429
+ $.fn.select2.locales = $.fn.select2.locales || {};
11430
 
11431
+ // append
11432
+ $.fn.select2.locales[ locale ] = select2L10n;
11433
+ $.extend($.fn.select2.defaults, select2L10n);
11434
+ }
11435
 
11436
+ });
11437
+
11438
+ })(jQuery);
11439
+
11440
+ (function($, undefined){
11441
+
11442
+ acf.tinymce = {
11443
 
11444
  /*
11445
+ * defaults
11446
  *
11447
+ * This function will return default mce and qt settings
11448
  *
11449
  * @type function
11450
+ * @date 18/8/17
11451
+ * @since 5.6.0
11452
  *
11453
  * @param $post_id (int)
11454
  * @return $post_id (int)
11455
  */
11456
 
11457
+ defaults: function(){
11458
 
11459
+ // bail early if no tinyMCEPreInit
11460
+ if( typeof tinyMCEPreInit === 'undefined' ) return false;
11461
 
11462
+ // vars
11463
+ var defaults = {
11464
+ tinymce: tinyMCEPreInit.mceInit.acf_content,
11465
+ quicktags: tinyMCEPreInit.qtInit.acf_content
11466
+ };
11467
 
11468
+ // return
11469
+ return defaults;
11470
  },
11471
 
11472
 
11473
  /*
11474
+ * initialize
11475
  *
11476
+ * This function will initialize the tinymce and quicktags instances
11477
  *
11478
  * @type function
11479
+ * @date 18/8/17
11480
+ * @since 5.6.0
11481
  *
11482
  * @param $post_id (int)
11483
  * @return $post_id (int)
11484
  */
11485
 
11486
+ initialize: function( id, args ){
 
 
 
11487
 
11488
+ // defaults
11489
+ args = acf.parseArgs(args, {
11490
+ tinymce: true,
11491
+ quicktags: true,
11492
+ toolbar: 'full',
11493
+ mode: 'visual', // visual,text
11494
+ field: false
 
 
 
11495
  });
11496
 
11497
+ // tinymce
11498
+ if( args.tinymce ) {
11499
+ this.initializeTinymce( id, args );
11500
+ }
11501
 
11502
+ // quicktags
11503
+ if( args.quicktags ) {
11504
+ this.initializeQuicktags( id, args );
11505
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11506
  },
11507
 
11508
 
11509
  /*
11510
+ * initializeTinymce
11511
  *
11512
+ * This function will initialize the tinymce instance
11513
  *
11514
  * @type function
11515
+ * @date 18/8/17
11516
+ * @since 5.6.0
11517
  *
11518
  * @param $post_id (int)
11519
  * @return $post_id (int)
11520
  */
11521
 
11522
+ initializeTinymce: function( id, args ){
11523
 
11524
+ // vars
11525
+ var $textarea = $('#'+id);
11526
+ var defaults = this.defaults();
11527
+ var toolbars = acf.get('toolbars');
11528
+ var field = args.field || false;
11529
+ var $field = field.$el || false;
11530
 
11531
+ // bail early
11532
+ if( typeof tinymce === 'undefined' ) return false;
11533
+ if( !defaults ) return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11534
 
11535
+ // check if exists
11536
+ if( tinymce.get(id) ) {
11537
+ return this.enable( id );
11538
+ }
11539
 
11540
+ // settings
11541
+ var init = $.extend( {}, defaults.tinymce, args.tinymce );
11542
+ init.id = id;
11543
+ init.selector = '#' + id;
11544
+
11545
+ // toolbar
11546
+ var toolbar = args.toolbar;
11547
+ if( toolbar && typeof toolbars[toolbar] !== 'undefined' ) {
11548
 
11549
+ for( var i = 1; i <= 4; i++ ) {
11550
+ init[ 'toolbar' + i ] = toolbars[toolbar][i] || '';
11551
+ }
11552
  }
11553
 
11554
+ // event
11555
+ init.setup = function( ed ){
11556
+
11557
+ ed.on('change', function(e) {
11558
+ ed.save(); // save to textarea
11559
+ $textarea.trigger('change');
11560
+ });
11561
+
11562
+ $( ed.getWin() ).on('unload', function() {
11563
+ acf.tinymce.remove( id );
11564
+ });
11565
+
11566
+ };
11567
 
11568
+ // disable wp_autoresize_on (no solution yet for fixed toolbar)
11569
+ init.wp_autoresize_on = false;
11570
 
11571
+ // hook for 3rd party customization
11572
+ init = acf.applyFilters('wysiwyg_tinymce_settings', init, id, field);
 
 
11573
 
11574
+ // z-index fix (caused too many conflicts)
11575
+ //if( acf.isset(tinymce,'ui','FloatPanel') ) {
11576
+ // tinymce.ui.FloatPanel.zIndex = 900000;
11577
+ //}
11578
 
11579
+ // store settings
11580
+ tinyMCEPreInit.mceInit[ id ] = init;
11581
 
11582
+ // visual tab is active
11583
+ if( args.mode == 'visual' ) {
11584
 
11585
+ // init
11586
+ var result = tinymce.init( init );
11587
 
11588
+ // get editor
11589
+ var ed = tinymce.get( id );
 
 
11590
 
11591
+ // validate
11592
+ if( !ed ) {
11593
+ return false;
11594
+ }
11595
 
11596
+ // add reference
11597
+ ed.acf = args.field;
11598
+
11599
+ // action
11600
+ acf.doAction('wysiwyg_tinymce_init', ed, ed.id, init, field);
11601
  }
 
 
 
 
 
 
 
 
 
11602
  },
11603
 
 
11604
  /*
11605
+ * initializeQuicktags
11606
  *
11607
+ * This function will initialize the quicktags instance
11608
  *
11609
  * @type function
11610
+ * @date 18/8/17
11611
+ * @since 5.6.0
11612
  *
11613
  * @param $post_id (int)
11614
  * @return $post_id (int)
11615
  */
11616
 
11617
+ initializeQuicktags: function( id, args ){
 
 
 
 
 
 
 
11618
 
11619
  // vars
11620
+ var defaults = this.defaults();
 
 
 
 
 
 
 
 
 
 
11621
 
11622
+ // bail early
11623
+ if( typeof quicktags === 'undefined' ) return false;
11624
+ if( !defaults ) return false;
11625
 
11626
+ // settings
11627
+ var init = $.extend( {}, defaults.quicktags, args.quicktags );
11628
+ init.id = id;
 
 
 
11629
 
11630
+ // filter
11631
+ var field = args.field || false;
11632
+ var $field = field.$el || false;
11633
+ init = acf.applyFilters('wysiwyg_quicktags_settings', init, init.id, field);
11634
 
11635
+ // store settings
11636
+ tinyMCEPreInit.qtInit[ id ] = init;
 
 
 
 
11637
 
11638
+ // init
11639
+ var ed = quicktags( init );
11640
 
11641
+ // validate
11642
+ if( !ed ) {
11643
+ return false;
 
 
11644
  }
11645
 
11646
+ // generate HTML
11647
+ this.buildQuicktags( ed );
11648
 
11649
+ // action for 3rd party customization
11650
+ acf.doAction('wysiwyg_quicktags_init', ed, ed.id, init, field);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11651
  },
11652
 
11653
 
11654
  /*
11655
+ * buildQuicktags
11656
  *
11657
+ * This function will build the quicktags HTML
11658
  *
11659
  * @type function
11660
+ * @date 18/8/17
11661
+ * @since 5.6.0
11662
  *
11663
  * @param $post_id (int)
11664
  * @return $post_id (int)
11665
  */
11666
 
11667
+ buildQuicktags: function( ed ){
 
 
 
11668
 
11669
+ var canvas, name, settings, theButtons, html, ed, id, i, use, instanceId,
11670
+ defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
11671
 
11672
+ canvas = ed.canvas;
11673
+ name = ed.name;
11674
+ settings = ed.settings;
11675
+ html = '';
11676
+ theButtons = {};
11677
+ use = '';
11678
+ instanceId = ed.id;
11679
 
11680
+ // set buttons
11681
+ if ( settings.buttons ) {
11682
+ use = ','+settings.buttons+',';
11683
+ }
11684
+
11685
+ for ( i in edButtons ) {
11686
+ if ( ! edButtons[i] ) {
11687
+ continue;
11688
+ }
11689
+
11690
+ id = edButtons[i].id;
11691
+ if ( use && defaults.indexOf( ',' + id + ',' ) !== -1 && use.indexOf( ',' + id + ',' ) === -1 ) {
11692
+ continue;
11693
+ }
11694
+
11695
+ if ( ! edButtons[i].instance || edButtons[i].instance === instanceId ) {
11696
+ theButtons[id] = edButtons[i];
11697
+
11698
+ if ( edButtons[i].html ) {
11699
+ html += edButtons[i].html( name + '_' );
11700
+ }
11701
+ }
11702
+ }
11703
+
11704
+ if ( use && use.indexOf(',dfw,') !== -1 ) {
11705
+ theButtons.dfw = new QTags.DFWButton();
11706
+ html += theButtons.dfw.html( name + '_' );
11707
+ }
11708
+
11709
+ if ( 'rtl' === document.getElementsByTagName( 'html' )[0].dir ) {
11710
+ theButtons.textdirection = new QTags.TextDirectionButton();
11711
+ html += theButtons.textdirection.html( name + '_' );
11712
+ }
11713
+
11714
+ ed.toolbar.innerHTML = html;
11715
+ ed.theButtons = theButtons;
11716
+
11717
+ if ( typeof jQuery !== 'undefined' ) {
11718
+ jQuery( document ).triggerHandler( 'quicktags-init', [ ed ] );
11719
+ }
11720
 
11721
+ },
11722
+
11723
+ disable: function( id ){
11724
+ this.destroyTinymce( id );
11725
+ },
11726
+
11727
+ remove: function( id ){
11728
+ this.destroyTinymce( id );
11729
+ },
11730
+
11731
+ destroy: function( id ){
11732
+ this.destroyTinymce( id );
11733
+ },
11734
+
11735
+ destroyTinymce: function( id ){
11736
 
11737
+ // bail early
11738
+ if( typeof tinymce === 'undefined' ) return false;
11739
 
11740
+ // get editor
11741
+ var ed = tinymce.get( id );
11742
 
11743
+ // bail early if no editor
11744
+ if( !ed ) return false;
11745
 
11746
+ // save
11747
+ ed.save();
11748
 
11749
+ // destroy editor
11750
+ ed.destroy();
11751
 
11752
+ // return
11753
+ return true;
11754
+ },
11755
+
11756
+ enable: function( id ){
11757
+ this.enableTinymce( id );
11758
+ },
11759
+
11760
+ enableTinymce: function( id ){
11761
 
11762
+ // bail early
11763
+ if( typeof switchEditors === 'undefined' ) return false;
11764
 
11765
+ // bail ealry if not initialized
11766
+ if( typeof tinyMCEPreInit.mceInit[ id ] === 'undefined' ) return false;
 
 
 
 
 
 
 
 
 
 
11767
 
11768
+ // toggle
11769
+ switchEditors.go( id, 'tmce');
 
 
 
 
 
 
 
 
 
 
11770
 
11771
+ // return
11772
+ return true;
11773
+ }
11774
+ };
11775
+
11776
+ var editorManager = new acf.Model({
11777
 
11778
+ // hook in before fieldsEventManager, conditions, etc
11779
+ priority: 5,
 
 
 
 
 
 
 
 
 
 
11780
 
11781
+ actions: {
11782
+ 'prepare': 'onPrepare',
11783
+ 'ready': 'onReady',
11784
+ },
11785
+ onPrepare: function(){
11786
 
11787
+ // find hidden editor which may exist within a field
11788
+ var $div = $('#acf-hidden-wp-editor');
11789
 
11790
+ // move to footer
11791
+ if( $div.exists() ) {
11792
+ $div.appendTo('body');
11793
+ }
11794
+ },
11795
+ onReady: function(){
11796
 
11797
+ // bail early if no tinymce
11798
+ if( !acf.isset(window,'tinymce','on') ) return;
11799
 
11800
+ // restore default activeEditor
11801
+ tinymce.on('AddEditor', function( data ){
11802
+
11803
+ // vars
11804
+ var editor = data.editor;
11805
+
11806
+ // bail early if not 'acf'
11807
+ if( editor.id.substr(0, 3) !== 'acf' ) return;
11808
+
11809
+ // override if 'content' exists
11810
+ editor = tinymce.editors.content || editor;
11811
+
11812
+ // update vars
11813
+ tinymce.activeEditor = editor;
11814
+ wpActiveEditor = editor.id;
11815
+ });
11816
+ }
11817
+ });
11818
+
11819
+ })(jQuery);
11820
+
11821
+ (function($, undefined){
11822
+
11823
+ /**
11824
+ * acf.validation
11825
+ *
11826
+ * Global validation logic
11827
+ *
11828
+ * @date 4/4/18
11829
+ * @since 5.6.9
11830
+ *
11831
+ * @param void
11832
+ * @return void
11833
+ */
11834
+
11835
+ acf.validation = new acf.Model({
11836
+
11837
+ // enable / disable validation logic
11838
+ active: true,
11839
 
11840
+ // temp ignore flag allowing bypass of validation
11841
+ ignore: false,
11842
+
11843
+ // errors
11844
+ errors: [],
11845
+
11846
+ // active form
11847
+ form: false,
11848
+
11849
+ // wait
11850
+ wait: 'prepare',
11851
+
11852
+ actions: {
11853
+ 'ready': 'addInputEvents',
11854
+ 'append': 'addInputEvents'
11855
+ },
11856
+
11857
+ events: {
11858
+ 'click input[type="submit"]': 'onClickSubmit',
11859
+ 'click button[type="submit"]': 'onClickSubmit',
11860
+ 'click #save-post': 'onClickSave',
11861
+ 'submit form': 'onSubmit',
11862
+ },
11863
+
11864
+ initialize: function(){
11865
 
11866
+ // load global setting
11867
+ if( !acf.get('validation') ) {
11868
+ this.disable();
11869
+ this.actions = {};
11870
+ this.events = {};
 
 
 
 
 
 
 
 
11871
  }
11872
+ },
11873
 
11874
+ getForm: function( $form ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11875
 
11876
+ // instantiate
11877
+ var form = $form.data('acf');
11878
+ if( !form ) {
11879
+ form = new Form( $form );
11880
  }
11881
 
11882
+ // store
11883
+ this.form = form;
11884
 
11885
+ // return
11886
+ return form;
 
11887
  },
11888
 
11889
+ enable: function(){
11890
+ this.active = true;
11891
+ },
11892
 
11893
+ disable: function(){
11894
+ this.active = false;
11895
+ },
11896
+
11897
+ pass: function(){
11898
+ this.ignore = true;
11899
+ this.setTimeout(function(){
11900
+ this.ignore = false;
11901
+ }, 100);
11902
+ },
11903
+
11904
+ reset: function(){
11905
+ this.ignore = false;
11906
+ this.errors = [];
11907
+ this.form = false;
11908
+ },
11909
+
11910
+ getErrors: function(){
11911
+ return this.errors;
11912
+ },
11913
 
11914
+ hasErrors: function(){
11915
+ return this.errors.length;
11916
+ },
11917
+
11918
+ addErrors: function( errors ){
11919
+ errors.map( this.addError, this );
11920
+ },
11921
+
11922
+ addError: function( error ){
11923
+ this.errors.push( error );
11924
+ },
11925
+
11926
+ getFieldErrors: function(){
11927
 
11928
+ // vars
11929
+ var errors = [];
11930
+ var inputs = [];
11931
 
11932
+ // loop
11933
+ this.getErrors().map(function(error){
 
 
 
 
11934
 
11935
+ // bail early if global
11936
+ if( !error.input ) return;
 
11937
 
11938
+ // update if exists
11939
+ var i = inputs.indexOf(error.input);
11940
+ if( i > -1 ) {
11941
+ errors[ i ] = error;
11942
 
11943
+ // update
11944
+ } else {
11945
+ errors.push( error );
11946
+ inputs.push( error.input );
11947
+ }
11948
+ });
 
 
 
 
 
 
 
 
 
 
11949
 
11950
+ // return
11951
+ return errors;
11952
  },
11953
 
11954
+ getGlobalErrors: function(){
11955
+
11956
+ // return array of errors that contain no input
11957
+ return this.getErrors().filter(function(error){
11958
+ return !error.input;
11959
+ });
11960
+ },
11961
 
11962
+ showErrors: function( $form ){
 
 
 
 
 
 
 
 
 
 
 
 
11963
 
11964
  // bail early if no errors
11965
+ if( !this.hasErrors() ) {
11966
+ return;
11967
+ }
11968
 
11969
  // vars
11970
+ var form = this.getForm( $form );
11971
+ var fieldErrors = this.getFieldErrors();
11972
+ var globalErrors = this.getGlobalErrors();
 
11973
 
11974
+ // vars
11975
+ var errorCount = 0;
11976
+ var $scrollTo = false;
11977
 
11978
  // loop
11979
+ fieldErrors.map(function( error ){
 
 
 
 
 
 
 
 
 
 
 
11980
 
11981
  // get input
11982
  var $input = $form.find('[name="' + error.input + '"]').first();
11983
 
 
11984
  // if $_POST value was an array, this $input may not exist
11985
  if( !$input.exists() ) {
11986
  $input = $form.find('[name^="' + error.input + '"]').first();
11987
  }
11988
 
 
11989
  // bail early if input doesn't exist
11990
+ if( !$input.exists() ) {
11991
+ return;
11992
+ }
11993
 
11994
  // increase
11995
+ errorCount++;
11996
 
11997
+ // get field
11998
+ var field = acf.getClosestField( $input );
11999
 
12000
+ // show error
12001
+ field.showError( error.message );
 
 
 
 
 
12002
 
12003
  // set $scrollTo
12004
+ if( !$scrollTo ) {
12005
+ $scrollTo = field.$el;
12006
  }
12007
+ }, this);
 
 
12008
 
12009
+ // errorMessage
12010
+ var errorMessage = acf.__('Validation failed');
12011
+ if( errorCount == 1 ) {
12012
+ errorMessage += '. ' + acf.__('1 field requires attention');
12013
+ } else if( errorCount > 1 ) {
12014
+ errorMessage += '. ' + acf.__('%d fields require attention').replace('%d', errorCount);
12015
  }
12016
 
12017
+ // notice
12018
+ if( form.notice ) {
12019
+ form.notice.update({
12020
+ type: 'error',
12021
+ text: errorMessage
12022
+ });
12023
+ } else {
12024
+ form.notice = acf.newNotice({
12025
+ type: 'error',
12026
+ text: errorMessage,
12027
+ target: $form
12028
+ });
12029
  }
12030
 
 
 
 
 
 
12031
  // if no $scrollTo, set to message
12032
+ if( !$scrollTo ) {
12033
+ $scrollTo = form.notice.$el;
12034
  }
12035
 
 
12036
  // timeout
12037
  setTimeout(function(){
12038
  $("html, body").animate({ scrollTop: $scrollTo.offset().top - ( $(window).height() / 2 ) }, 500);
12039
  }, 10);
 
12040
  },
12041
 
12042
+ fetch: function( args ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12043
 
12044
+ // bail early if busy
12045
+ if( this.busy ) {
12046
+ return;
12047
  }
12048
 
12049
+ // set busy
12050
+ this.busy = 1;
12051
+
12052
+ // vars
12053
+ args = acf.parseArgs(args, {
12054
 
12055
+ // form element
12056
+ form: false,
 
12057
 
12058
+ // trigger event
12059
+ event: false,
12060
 
12061
+ // lock form on success
12062
+ lock: true,
 
 
 
 
 
12063
 
12064
+ // loading callback
12065
+ loading: function(){},
12066
 
12067
+ // complete callback
12068
+ complete: function(){},
12069
+
12070
+ // failure callback
12071
+ failure: function(){},
12072
+
12073
+ // success callback
12074
+ success: function( $form ){
12075
+ $form.submit();
12076
+ }
12077
+ });
12078
 
12079
+ // vars
12080
+ var $form = args.form;
12081
+ var form = this.getForm( $form );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12082
 
12083
+ // create event specific success callback
12084
+ if( args.event ) {
12085
+
12086
+ // create new event to avoid conflicts with prevenDefault (as used in taxonomy form)
12087
+ var event = $.Event(null, args.event);
12088
+ args.success = function(){
12089
+ $(event.target).trigger( event );
12090
+ }
12091
+ }
12092
 
12093
+ // action for 3rd party
12094
+ acf.doAction('validation_begin', $form);
12095
+
12096
+ // data
12097
+ var data = acf.serialize( $form );
12098
+ data.action = 'acf/validate_save_post';
12099
 
12100
+ // lock form
12101
+ this.lockForm( $form );
12102
 
12103
+ // loading callback
12104
+ args.loading( $form );
12105
 
12106
+ // success
12107
+ var onSuccess = function( json ){
12108
 
12109
+ // validate
12110
+ if( !acf.isAjaxSuccess(json) ) {
12111
+ return;
12112
+ }
12113
 
12114
+ // filter
12115
+ data = acf.applyFilters('validation_complete', json.data, $form);
12116
+
12117
+ // add errors
12118
+ if( !data.valid ) {
12119
+ this.addErrors( data.errors );
12120
+ }
12121
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12122
 
12123
+ // complete
12124
+ var onComplete = function(){
12125
 
12126
+ // set busy
12127
+ this.busy = 0;
12128
 
12129
+ // unlock form
12130
+ this.unlockForm( $form );
12131
+
12132
+ // failure
12133
+ if( this.hasErrors() ) {
12134
+
12135
+ // action
12136
+ acf.doAction('validation_failure', $form);
12137
+
12138
+ // display errors
12139
+ this.showErrors( $form );
12140
+
12141
+ // failure callback
12142
+ args.failure( $form );
12143
+
12144
+ // success
12145
+ } else {
12146
+
12147
+ // allow for to pass
12148
+ this.pass();
12149
+
12150
+ // remove previous error message
12151
+ if( form.notice ) {
12152
+ form.notice.update({
12153
+ type: 'success',
12154
+ text: acf.__('Validation successful'),
12155
+ timeout: 1000
12156
+ });
12157
+ }
12158
+
12159
+ // action
12160
+ acf.doAction('validation_success', $form);
12161
+ acf.doAction('submit', $form);
12162
+
12163
+ // success callback (submit form)
12164
+ args.success( $form );
12165
+
12166
+ // lock form
12167
+ if( args.lock ) {
12168
+ this.lockForm( $form );
12169
+ }
12170
+ }
12171
+
12172
+ // reset
12173
+ this.reset();
12174
+
12175
+ // complete callback
12176
+ args.complete( $form );
12177
+ };
12178
 
12179
+ // ajax
12180
+ $.ajax({
12181
+ url: acf.get('ajaxurl'),
12182
+ data: acf.prepareForAjax(data),
12183
+ type: 'post',
12184
+ dataType: 'json',
12185
+ context: this,
12186
+ success: onSuccess,
12187
+ complete: onComplete
12188
+ });
12189
  },
12190
 
12191
+ addInputEvents: function( $el ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12192
 
12193
+ // vars
12194
+ var $inputs = $('.acf-field [name]', $el);
 
 
 
 
12195
 
12196
+ // check
12197
+ if( $inputs.length ) {
12198
+ this.on( $inputs, 'invalid', 'onInvalid' );
12199
+ }
12200
+ },
12201
+
12202
+ onInvalid: function( e, $el ){
12203
 
12204
  // vars
12205
+ var $form = $el.closest('form');
12206
 
12207
+ // add error
12208
+ this.addError({
12209
+ input: $el.attr('name'),
12210
+ message: e.target.validationMessage
12211
+ });
12212
 
12213
+ // prevent default
12214
+ // - prevents browser error message
12215
+ // - also fixes chrome bug where 'hidden-by-tab' field throws focus error
12216
+ e.preventDefault();
12217
 
12218
+ // trigger submit on $form
12219
+ // - allows for "save", "preview" and "publish" to work
12220
+ $form.submit();
12221
+ },
12222
+
12223
+ onClickSubmit: function( e, $el ){
12224
 
12225
+ // store the "click event" for later use in this.onSubmit()
12226
+ this.set('originalEvent', e);
12227
+ },
12228
+
12229
+ onClickSave: function( e, $el ) {
12230
 
12231
+ // ignore errors when saving
12232
+ this.pass();
12233
  },
12234
 
12235
+ onSubmit: function( e, $form ){
12236
+
12237
+ // validate
12238
+ var valid = acf.validateForm({
12239
+ form: $form,
12240
+ event: this.get('originalEvent')
12241
+ });
12242
+
12243
+ // if not valid, stop event and allow validation to continue
12244
+ if( !valid ) {
12245
+ e.preventDefault();
12246
+ }
12247
+ },
12248
 
12249
+ showSpinner: function( $spinner ){
12250
+ $spinner.addClass('is-active'); // add class (WP > 4.2)
12251
+ $spinner.css('display', 'inline-block'); // css (WP < 4.2)
12252
+ },
12253
+
12254
+ hideSpinner: function( $spinner ){
12255
+ $spinner.removeClass('is-active'); // add class (WP > 4.2)
12256
+ $spinner.css('display', 'none'); // css (WP < 4.2)
12257
+ },
12258
+
12259
+ disableSubmit: function( $submit ){
12260
+ $submit.prop('disabled', true).addClass('disabled');
12261
+ },
12262
+
12263
+ enableSubmit: function( $submit ){
12264
+ $submit.prop('disabled', false).removeClass('disabled');
12265
+ },
12266
 
12267
+ findSubmitWrap: function( $form ){
12268
 
12269
+ // default post submit div
12270
+ var $wrap = $('#submitdiv');
12271
+ if( $wrap.length ) {
12272
+ return $wrap;
 
12273
  }
12274
 
12275
+ // 3rd party publish box
12276
+ var $wrap = $('#submitpost');
12277
+ if( $wrap.length ) {
12278
+ return $wrap;
12279
+ }
12280
 
12281
+ // term, user
12282
+ var $wrap = $form.find('p.submit').last();
12283
+ if( $wrap.length ) {
12284
+ return $wrap;
12285
+ }
 
 
 
 
 
 
 
12286
 
12287
+ // front end form
12288
+ var $wrap = $form.find('.acf-form-submit');
12289
+ if( $wrap.length ) {
12290
+ return $wrap;
12291
  }
12292
 
12293
+ // default
12294
+ return $form;
12295
  },
12296
 
12297
+ lockForm: function( $form ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12298
 
12299
+ // vars
12300
+ var $wrap = this.findSubmitWrap( $form );
12301
+ var $submit = $wrap.find('.button, .acf-button');
12302
+ var $spinner = $wrap.find('.spinner, .acf-spinner');
12303
+
12304
+ // hide all spinners (hides the preview spinner)
12305
+ this.hideSpinner( $spinner );
12306
 
12307
+ // lock
12308
+ this.disableSubmit( $submit );
12309
+ this.showSpinner( $spinner.last() );
12310
+ },
12311
+
12312
+ unlockForm: function( $form ){
12313
 
12314
+ // vars
12315
+ var $wrap = this.findSubmitWrap( $form );
12316
+ var $submit = $wrap.find('.button, .acf-button');
12317
+ var $spinner = $wrap.find('.spinner, .acf-spinner');
12318
 
12319
+ // unlock
12320
+ this.enableSubmit( $submit );
12321
+ this.hideSpinner( $spinner );
12322
+ }
12323
+
12324
+ });
12325
+
12326
+ /**
12327
+ * Form
12328
+ *
12329
+ * description
12330
+ *
12331
+ * @date 5/4/18
12332
+ * @since 5.6.9
12333
+ *
12334
+ * @param type $var Description. Default.
12335
+ * @return type Description.
12336
+ */
12337
+
12338
+ var Form = acf.Model.extend({
12339
+ notice: false,
12340
+ setup: function( $form ){
12341
+ this.$el = $form;
12342
+ },
12343
+ lock: function(){
12344
+ acf.validation.lockForm( this.$el );
12345
  },
12346
+ unlock: function(){
12347
+ acf.validation.unlockForm( this.$el );
12348
+ }
12349
+ });
12350
+
12351
+ /**
12352
+ * acf.validateForm
12353
+ *
12354
+ * description
12355
+ *
12356
+ * @date 4/4/18
12357
+ * @since 5.6.9
12358
+ *
12359
+ * @param type $var Description. Default.
12360
+ * @return type Description.
12361
+ */
12362
+
12363
+ acf.validateForm = function( args ){
12364
 
12365
+ // bail early if no form
12366
+ // - return true allowing form submit
12367
+ if( !args.form ) {
12368
+ return true;
12369
+ }
12370
 
12371
+ // get form
12372
+ var form = acf.validation.getForm( args.form );
12373
+
12374
+ // bail early if not active
12375
+ // - return true allowing form submit
12376
+ if( !acf.validation.active ) {
12377
+ return true;
12378
+ }
12379
+
12380
+ // bail early if ignore
12381
+ // - return true allowing form submit
12382
+ if( acf.validation.ignore ) {
12383
+ return true;
12384
+ }
12385
+
12386
+ // bail early if is preview
12387
+ // - return true allowing form submit
12388
+ if( form.$('#wp-preview').val() ) {
12389
+ form.unlock();
12390
+ return true;
12391
+ }
12392
+
12393
+ // bail early if this form does not contain ACF data
12394
+ // - return true allowing form submit
12395
+ if( !form.$('#acf-form-data').length ) {
12396
+ return true;
12397
+ }
12398
 
12399
+ // validate
12400
+ acf.validation.fetch( args );
12401
+
12402
+ // return false preventing form submit
12403
+ return false;
12404
+ };
12405
+
12406
+ })(jQuery);
12407
+
12408
+ (function($, undefined){
12409
+
12410
+ /**
12411
+ * refreshHelper
12412
+ *
12413
+ * description
12414
+ *
12415
+ * @date 1/7/18
12416
+ * @since 5.6.9
12417
+ *
12418
+ * @param type $var Description. Default.
12419
+ * @return type Description.
12420
+ */
12421
+
12422
+ var refreshHelper = new acf.Model({
12423
+ priority: 90,
12424
+ timeout: 0,
12425
+ actions: {
12426
+ 'new_field': 'refresh',
12427
+ 'show_field': 'refresh',
12428
+ 'hide_field': 'refresh',
12429
+ 'remove_field': 'refresh'
12430
+ },
12431
+ refresh: function(){
12432
+ clearTimeout( this.timeout );
12433
+ this.timeout = setTimeout(function(){
12434
+ acf.doAction('refresh');
12435
+ }, 0);
12436
+ }
12437
+ });
12438
+
12439
+
12440
+ /**
12441
+ * sortableHelper
12442
+ *
12443
+ * Adds compatibility for sorting a <tr> element
12444
+ *
12445
+ * @date 6/3/18
12446
+ * @since 5.6.9
12447
+ *
12448
+ * @param void
12449
+ * @return void
12450
+ */
12451
+
12452
+ var sortableHelper = new acf.Model({
12453
+ actions: {
12454
+ 'sortstart': 'onSortstart'
12455
+ },
12456
+ onSortstart: function( $item, $placeholder ){
12457
 
12458
+ // if $item is a tr, apply some css to the elements
12459
+ if( $item.is('tr') ) {
12460
 
12461
+ // temp set as relative to find widths
12462
+ $item.css('position', 'relative');
12463
 
12464
+ // set widths for td children
12465
+ $item.children().each(function(){
12466
+ $(this).width($(this).width());
12467
+ });
12468
+
12469
+ // revert position css
12470
+ $item.css('position', 'absolute');
12471
+
12472
+ // add markup to the placeholder
12473
+ $placeholder.html('<td style="height:' + $item.height() + 'px; padding:0;" colspan="' + $item.children('td').length + '"></td>');
12474
  }
12475
+ }
12476
+ });
12477
+
12478
+ /**
12479
+ * duplicateHelper
12480
+ *
12481
+ * Fixes browser bugs when duplicating an element
12482
+ *
12483
+ * @date 6/3/18
12484
+ * @since 5.6.9
12485
+ *
12486
+ * @param void
12487
+ * @return void
12488
+ */
12489
+
12490
+ var duplicateHelper = new acf.Model({
12491
+ actions: {
12492
+ 'after_duplicate': 'onAfterDuplicate'
12493
+ },
12494
+ onAfterDuplicate: function( $el, $el2 ){
12495
 
12496
+ // get original values
12497
+ var vals = [];
12498
+ $el.find('select').each(function(i){
12499
+ vals.push( $(this).val() );
12500
+ });
12501
 
12502
+ // set duplicate values
12503
+ $el2.find('select').each(function(i){
12504
+ $(this).val( vals[i] );
12505
+ });
12506
  }
 
12507
  });
 
 
 
 
12508
 
12509
+ /**
12510
+ * tableHelper
12511
+ *
12512
+ * description
12513
+ *
12514
+ * @date 6/3/18
12515
+ * @since 5.6.9
12516
+ *
12517
+ * @param type $var Description. Default.
12518
+ * @return type Description.
12519
+ */
12520
+
12521
+ var tableHelper = new acf.Model({
12522
 
12523
+ id: 'tableHelper',
 
 
 
12524
 
12525
+ priority: 20,
 
 
12526
 
12527
  actions: {
12528
+ 'refresh': 'renderTables'
 
 
 
 
12529
  },
12530
 
12531
+ renderTables: function( $el ){
 
 
 
 
 
12532
 
12533
+ // loop
12534
+ var self = this;
12535
+ $('.acf-table:visible').each(function(){
12536
+ self.renderTable( $(this) );
 
12537
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12538
  },
12539
 
12540
+ renderTable: function( $table ){
 
 
 
 
12541
 
12542
  // vars
12543
+ var $ths = $table.find('> thead > tr:visible > th[data-key]');
12544
+ var $tds = $table.find('> tbody > tr:visible > td[data-key]');
 
 
 
 
 
12545
 
12546
+ // bail early if no thead
12547
+ if( !$ths.length || !$tds.length ) {
12548
+ return false;
12549
+ }
 
 
 
 
12550
 
12551
 
12552
+ // visiblity
12553
+ $ths.each(function( i ){
12554
+
12555
+ // vars
12556
+ var $th = $(this);
12557
+ var key = $th.data('key');
12558
+ var $cells = $tds.filter('[data-key="' + key + '"]');
12559
+ var $hidden = $cells.filter('.acf-hidden');
12560
+
12561
+ // always remove empty and allow cells to be hidden
12562
+ $cells.removeClass('acf-empty');
12563
+
12564
+ // hide $th if all cells are hidden
12565
+ if( $cells.length === $hidden.length ) {
12566
+ acf.hide( $th );
12567
+
12568
+ // force all hidden cells to appear empty
12569
+ } else {
12570
+ acf.show( $th );
12571
+ $hidden.addClass('acf-empty');
12572
+ }
12573
+ });
12574
 
12575
 
12576
+ // clear width
12577
+ $ths.css('width', 'auto');
12578
 
12579
+ // get visible
12580
+ $ths = $ths.not('.acf-hidden');
 
12581
 
12582
+ // vars
12583
+ var availableWidth = 100;
12584
+ var colspan = $ths.length;
12585
 
12586
+ // set custom widths first
12587
+ var $fixedWidths = $ths.filter('[data-width]');
12588
+ $fixedWidths.each(function(){
12589
+ var width = $(this).data('width');
12590
+ $(this).css('width', width + '%');
12591
+ availableWidth -= width;
12592
+ });
12593
 
12594
+ // set auto widths
12595
+ var $auoWidths = $ths.not('[data-width]');
12596
+ if( $auoWidths.length ) {
12597
+ var width = availableWidth / $auoWidths.length;
12598
+ $auoWidths.css('width', width + '%');
12599
+ availableWidth = 0;
12600
+ }
12601
 
12602
+ // avoid stretching issue
12603
+ if( availableWidth > 0 ) {
12604
+ $ths.last().css('width', 'auto');
12605
  }
12606
 
12607
+
12608
+ // update colspan on collapsed
12609
+ $tds.filter('.-collapsed-target').each(function(){
12610
+
12611
+ // vars
12612
+ var $td = $(this);
12613
+
12614
+ // check if collapsed
12615
+ if( $td.parent().hasClass('-collapsed') ) {
12616
+ $td.attr('colspan', $ths.length);
12617
+ } else {
12618
+ $td.removeAttr('colspan');
12619
+ }
12620
+ });
12621
  }
 
12622
  });
12623
 
12624
 
12625
+ /**
12626
+ * fieldsHelper
12627
  *
12628
  * description
12629
  *
12630
+ * @date 6/3/18
12631
+ * @since 5.6.9
 
12632
  *
12633
+ * @param type $var Description. Default.
12634
+ * @return type Description.
12635
  */
12636
 
12637
+ var fieldsHelper = new acf.Model({
12638
 
12639
+ id: 'fieldsHelper',
12640
+
12641
+ priority: 30,
12642
 
12643
  actions: {
12644
+ 'refresh': 'renderGroups'
12645
  },
12646
 
12647
+ renderGroups: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12648
 
12649
+ // loop
12650
+ var self = this;
12651
+ $('.acf-fields:visible').each(function(){
12652
+ self.renderGroup( $(this) );
12653
+ });
12654
+ },
12655
+
12656
+ renderGroup: function( $el ){
12657
 
12658
+ // vars
12659
+ var top = 0;
12660
+ var height = 0;
12661
+ var $row = $();
12662
 
12663
+ // get fields
12664
+ var $fields = $el.children('.acf-field[data-width]:visible');
12665
 
12666
+ // bail early if no fields
12667
+ if( !$fields.length ) {
12668
+ return false;
12669
+ }
12670
 
12671
+ // bail ealry if is .-left
12672
+ if( $el.hasClass('-left') ) {
12673
+ $fields.removeAttr('data-width');
12674
+ $fields.css('width', 'auto');
12675
+ return false;
12676
+ }
12677
 
12678
+ // reset fields
12679
+ $fields.removeClass('-r0 -c0').css({'min-height': 0});
12680
 
12681
+ // loop
12682
+ $fields.each(function( i ){
12683
 
12684
  // vars
12685
+ var $field = $(this);
12686
+ var position = $field.position();
12687
+ var thisTop = Math.ceil( position.top );
12688
+ var thisLeft = Math.ceil( position.left );
12689
 
12690
+ // detect change in row
12691
+ if( $row.length && thisTop > top ) {
12692
+
12693
+ // set previous heights
12694
+ $row.css({'min-height': height+'px'});
12695
+
12696
+ // update position due to change in row above
12697
+ position = $field.position();
12698
+ thisTop = Math.ceil( position.top );
12699
+ thisLeft = Math.ceil( position.left );
12700
 
12701
+ // reset vars
12702
+ top = 0;
12703
+ height = 0;
12704
+ $row = $();
12705
+ }
12706
 
12707
+ // add classes
12708
+ if( thisTop == 0 ) {
12709
+ $field.addClass('-r0');
12710
+ } else if( thisLeft == 0 ) {
12711
+ $field.addClass('-c0');
12712
+ }
12713
 
12714
+ // get height after class change
12715
+ // - add 1 for subpixel rendering
12716
+ var thisHeight = Math.ceil( $field.outerHeight() ) + 1;
12717
 
12718
+ // set height
12719
+ height = Math.max( height, thisHeight );
12720
 
12721
+ // set y
12722
+ top = Math.max( top, thisTop );
 
12723
 
12724
+ // append
12725
+ $row = $row.add( $field );
12726
  });
12727
 
12728
+ // clean up
12729
+ if( $row.length ) {
12730
+ $row.css({'min-height': height+'px'});
12731
+ }
12732
+ }
12733
+ });
12734
 
12735
+ })(jQuery);
12736
+
12737
+ (function($, undefined){
12738
+
12739
+ /**
12740
+ * acf.newCompatibility
12741
+ *
12742
+ * Inserts a new __proto__ object compatibility layer
12743
+ *
12744
+ * @date 15/2/18
12745
+ * @since 5.6.9
12746
+ *
12747
+ * @param object instance The object to modify.
12748
+ * @param object compatibilty Optional. The compatibilty layer.
12749
+ * @return object compatibilty
12750
+ */
12751
+
12752
+ acf.newCompatibility = function( instance, compatibilty ){
12753
 
12754
+ // defaults
12755
+ compatibilty = compatibilty || {};
 
 
 
 
 
 
 
 
 
 
12756
 
12757
+ // inherit __proto_-
12758
+ compatibilty.__proto__ = instance.__proto__;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12759
 
12760
+ // inject
12761
+ instance.__proto__ = compatibilty;
12762
 
12763
+ // reference
12764
+ instance.compatibility = compatibilty;
 
 
 
 
 
 
 
 
 
 
12765
 
12766
+ // return
12767
+ return compatibilty;
12768
+ };
12769
+
12770
+ /**
12771
+ * acf.getCompatibility
12772
+ *
12773
+ * Returns the compatibility layer for a given instance
12774
+ *
12775
+ * @date 13/3/18
12776
+ * @since 5.6.9
12777
+ *
12778
+ * @param object instance The object to look in.
12779
+ * @return object|null compatibility The compatibility object or null on failure.
12780
+ */
12781
+
12782
+ acf.getCompatibility = function( instance ) {
12783
+ return instance.compatibility || null;
12784
+ };
12785
+
12786
+ /**
12787
+ * acf (compatibility)
12788
+ *
12789
+ * Compatibility layer for the acf object
12790
+ *
12791
+ * @date 15/2/18
12792
+ * @since 5.6.9
12793
+ *
12794
+ * @param void
12795
+ * @return void
12796
+ */
12797
+
12798
+ var _acf = acf.newCompatibility(acf, {
12799
+
12800
+ // storage
12801
+ l10n: {},
12802
+ o: {},
12803
+ fields: {},
12804
+
12805
+ // changed function names
12806
+ update: acf.set,
12807
+ add_action: acf.addAction,
12808
+ remove_action: acf.removeAction,
12809
+ do_action: acf.doAction,
12810
+ add_filter: acf.addFilter,
12811
+ remove_filter: acf.removeFilter,
12812
+ apply_filters: acf.applyFilters,
12813
+ parse_args: acf.parseArgs,
12814
+ disable_el: acf.disable,
12815
+ disable_form: acf.disable,
12816
+ enable_el: acf.enable,
12817
+ enable_form: acf.enable,
12818
+ update_user_setting: acf.updateUserSetting,
12819
+ prepare_for_ajax: acf.prepareForAjax,
12820
+ is_ajax_success: acf.isAjaxSuccess,
12821
+ remove_el: acf.remove,
12822
+ remove_tr: acf.remove,
12823
+ str_replace: acf.strReplace,
12824
+ render_select: acf.renderSelect,
12825
+ get_uniqid: acf.uniqid,
12826
+ serialize_form: acf.serialize,
12827
+ esc_html: acf.strEscape,
12828
+ str_sanitize: acf.strSanitize,
12829
+
12830
+ });
12831
+
12832
+ _acf._e = function( k1, k2 ){
12833
+
12834
+ // defaults
12835
+ k1 = k1 || '';
12836
+ k2 = k2 || '';
12837
+
12838
+ // compability
12839
+ var compatKey = k2 ? k1 + '.' + k2 : k1;
12840
+ var compats = {
12841
+ 'image.select': 'Select Image',
12842
+ 'image.edit': 'Edit Image',
12843
+ 'image.update': 'Update Image'
12844
+ };
12845
+ if( compats[compatKey] ) {
12846
+ return acf.__(compats[compatKey]);
12847
+ }
12848
+
12849
+ // try k1
12850
+ var string = this.l10n[ k1 ] || '';
12851
+
12852
+ // try k2
12853
+ if( k2 ) {
12854
+ string = string[ k2 ] || '';
12855
+ }
12856
+
12857
+ // return
12858
+ return string;
12859
+ };
12860
+
12861
+ _acf.get_selector = function( s ) {
12862
 
12863
+ // vars
12864
+ var selector = '.acf-field';
12865
+
12866
+ // bail early if no search
12867
+ if( !s ) {
12868
+ return selector;
12869
+ }
12870
+
12871
+ // compatibility with object
12872
+ if( $.isPlainObject(s) ) {
12873
+ if( $.isEmptyObject(s) ) {
12874
+ return selector;
12875
+ } else {
12876
+ for( var k in s ) { s = s[k]; break; }
12877
  }
12878
+ }
12879
+
12880
+ // append
12881
+ selector += '-' + s;
12882
 
12883
+ // replace underscores (split/join replaces all and is faster than regex!)
12884
+ selector = acf.strReplace('_', '-', selector);
12885
 
12886
+ // remove potential double up
12887
+ selector = acf.strReplace('field-field-', 'field-', selector);
12888
 
12889
+ // return
12890
+ return selector;
12891
+ };
12892
+
12893
+ _acf.get_fields = function( s, $el, all ){
 
 
 
 
 
 
 
12894
 
12895
+ // args
12896
+ var args = {
12897
+ is: s || '',
12898
+ parent: $el || false,
12899
+ suppressFilters: all || false,
12900
+ };
12901
+
12902
+ // change 'field_123' to '.acf-field-123'
12903
+ if( args.is ) {
12904
+ args.is = this.get_selector( args.is );
12905
+ }
12906
+
12907
+ // return
12908
+ return acf.findFields(args);
12909
+ };
12910
+
12911
+ _acf.get_field = function( s, $el ){
12912
+
12913
+ // get fields
12914
+ var $fields = this.get_fields.apply(this, arguments);
12915
+
12916
+ // return
12917
+ if( $fields.length ) {
12918
+ return $fields.first();
12919
+ } else {
12920
+ return false;
12921
+ }
12922
+ };
12923
+
12924
+ _acf.get_closest_field = function( $el, s ){
12925
+ return $el.closest( this.get_selector(s) );
12926
+ };
12927
+
12928
+ _acf.get_field_wrap = function( $el ){
12929
+ return $el.closest( this.get_selector() );
12930
+ };
12931
+
12932
+ _acf.get_field_key = function( $field ){
12933
+ return $field.data('key');
12934
+ };
12935
+
12936
+ _acf.get_field_type = function( $field ){
12937
+ return $field.data('type');
12938
+ };
12939
+
12940
+ _acf.get_data = function( $el, defaults ){
12941
+ return acf.parseArgs( $el.data(), defaults );
12942
+ };
12943
+
12944
+ _acf.maybe_get = function( obj, key, value ){
12945
 
12946
+ // default
12947
+ if( value === undefined ) {
12948
+ value = null;
12949
+ }
12950
+
12951
+ // get keys
12952
+ keys = String(key).split('.');
12953
+
12954
+ // acf.isget
12955
+ for( var i = 0; i < keys.length; i++ ) {
12956
+ if( !obj.hasOwnProperty(keys[i]) ) {
12957
+ return value;
12958
+ }
12959
+ obj = obj[ keys[i] ];
12960
+ }
12961
+ return obj;
12962
+ };
12963
+
12964
+
12965
+ /**
12966
+ * hooks
12967
+ *
12968
+ * Modify add_action and add_filter functions to add compatibility with changed $field parameter
12969
+ * Using the acf.add_action() or acf.add_filter() functions will interpret new field parameters as jQuery $field
12970
+ *
12971
+ * @date 12/5/18
12972
+ * @since 5.6.9
12973
+ *
12974
+ * @param void
12975
+ * @return void
12976
+ */
12977
+
12978
+ var compatibleArgument = function( arg ){
12979
+ return ( arg instanceof acf.Field ) ? arg.$el : arg;
12980
+ };
12981
+
12982
+ var compatibleArguments = function( args ){
12983
+ return acf.arrayArgs( args ).map( compatibleArgument );
12984
+ }
12985
+
12986
+ var compatibleCallback = function( origCallback ){
12987
+ return function(){
12988
 
12989
+ // convert to compatible arguments
12990
+ if( arguments.length ) {
12991
+ var args = compatibleArguments(arguments);
12992
 
12993
+ // add default argument for 'ready', 'append' and 'load' events
12994
+ } else {
12995
+ var args = [ $(document) ];
12996
  }
12997
 
12998
+ // return
12999
+ return origCallback.apply(this, args);
13000
+ }
13001
+ }
13002
+
13003
+ _acf.add_action = function( action, callback, priority, context ){
13004
+
13005
+ // handle multiple actions
13006
+ var actions = action.split(' ');
13007
+ var length = actions.length;
13008
+ if( length > 1 ) {
13009
+ for( var i = 0; i < length; i++) {
13010
+ action = actions[i];
13011
+ _acf.add_action.apply(this, arguments);
13012
+ }
13013
+ return this;
13014
+ }
13015
+
13016
+ // single
13017
+ var callback = compatibleCallback(callback);
13018
+ return acf.addAction.apply(this, arguments);
13019
+ };
13020
+
13021
+ _acf.add_filter = function( action, callback, priority, context ){
13022
+ var callback = compatibleCallback(callback);
13023
+ return acf.addFilter.apply(this, arguments);
13024
+ };
13025
+
13026
+ /*
13027
+ * acf.model
13028
+ *
13029
+ * This model acts as a scafold for action.event driven modules
13030
+ *
13031
+ * @type object
13032
+ * @date 8/09/2014
13033
+ * @since 5.0.0
13034
+ *
13035
+ * @param (object)
13036
+ * @return (object)
13037
+ */
13038
+
13039
+ _acf.model = {
13040
+ actions: {},
13041
+ filters: {},
13042
+ events: {},
13043
+ extend: function( args ){
13044
 
13045
+ // extend
13046
+ var model = $.extend( {}, this, args );
 
 
 
13047
 
13048
+ // setup actions
13049
+ $.each(model.actions, function( name, callback ){
13050
+ model._add_action( name, callback );
13051
+ });
 
 
 
 
 
13052
 
13053
+ // setup filters
13054
+ $.each(model.filters, function( name, callback ){
13055
+ model._add_filter( name, callback );
13056
+ });
13057
 
13058
+ // setup events
13059
+ $.each(model.events, function( name, callback ){
13060
+ model._add_event( name, callback );
13061
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
13062
 
13063
+ // return
13064
+ return model;
13065
+ },
13066
+
13067
+ _add_action: function( name, callback ) {
13068
 
13069
+ // split
13070
+ var model = this,
13071
+ data = name.split(' ');
13072
 
13073
+ // add missing priority
13074
+ var name = data[0] || '',
13075
+ priority = data[1] || 10;
13076
 
13077
+ // add action
13078
+ acf.add_action(name, model[ callback ], priority, model);
13079
 
13080
+ },
13081
+
13082
+ _add_filter: function( name, callback ) {
13083
 
13084
+ // split
13085
+ var model = this,
13086
+ data = name.split(' ');
 
13087
 
13088
+ // add missing priority
13089
+ var name = data[0] || '',
13090
+ priority = data[1] || 10;
13091
 
13092
+ // add action
13093
+ acf.add_filter(name, model[ callback ], priority, model);
13094
+ },
13095
+
13096
+ _add_event: function( name, callback ) {
13097
 
13098
+ // vars
13099
+ var model = this,
13100
+ i = name.indexOf(' '),
13101
+ event = (i > 0) ? name.substr(0,i) : name,
13102
+ selector = (i > 0) ? name.substr(i+1) : '';
13103
 
13104
+ // event
13105
+ var fn = function( e ){
 
 
 
13106
 
13107
+ // append $el to event object
13108
+ e.$el = $(this);
13109
 
13110
+ // append $field to event object (used in field group)
13111
+ if( acf.field_group ) {
13112
+ e.$field = e.$el.closest('.acf-field-object');
13113
+ }
13114
 
13115
+ // event
13116
+ if( typeof model.event === 'function' ) {
13117
+ e = model.event( e );
13118
+ }
13119
 
13120
+ // callback
13121
+ model[ callback ].apply(model, arguments);
13122
 
13123
+ };
13124
 
13125
+ // add event
13126
+ if( selector ) {
13127
+ $(document).on(event, selector, fn);
13128
+ } else {
13129
+ $(document).on(event, fn);
13130
+ }
13131
  },
13132
 
13133
+ get: function( name, value ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13134
 
13135
+ // defaults
13136
+ value = value || null;
13137
 
13138
+ // get
13139
+ if( typeof this[ name ] !== 'undefined' ) {
13140
+ value = this[ name ];
13141
+ }
13142
 
13143
+ // return
13144
+ return value;
 
13145
  },
13146
 
13147
+ set: function( name, value ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13148
 
13149
+ // set
13150
+ this[ name ] = value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13151
 
13152
+ // function for 3rd party
13153
+ if( typeof this[ '_set_' + name ] === 'function' ) {
13154
+ this[ '_set_' + name ].apply(this);
13155
+ }
13156
 
13157
+ // return for chaining
13158
+ return this;
13159
+ }
13160
+ };
13161
+
13162
+ /*
13163
+ * field
13164
+ *
13165
+ * This model sets up many of the field's interactions
13166
+ *
13167
+ * @type function
13168
+ * @date 21/02/2014
13169
+ * @since 3.5.1
13170
+ *
13171
+ * @param n/a
13172
+ * @return n/a
13173
+ */
13174
+
13175
+ _acf.field = acf.model.extend({
13176
+ type: '',
13177
+ o: {},
13178
+ $field: null,
13179
+ _add_action: function( name, callback ) {
13180
 
13181
+ // vars
13182
+ var model = this;
 
13183
 
13184
+ // update name
13185
+ name = name + '_field/type=' + model.type;
13186
 
13187
+ // add action
13188
+ acf.add_action(name, function( $field ){
13189
+
13190
+ // focus
13191
+ model.set('$field', $field);
13192
+
13193
+ // callback
13194
+ model[ callback ].apply(model, arguments);
13195
+ });
13196
  },
13197
 
13198
+ _add_filter: function( name, callback ) {
13199
 
13200
+ // vars
13201
+ var model = this;
13202
 
13203
+ // update name
13204
+ name = name + '_field/type=' + model.type;
13205
 
13206
+ // add action
13207
+ acf.add_filter(name, function( $field ){
13208
 
13209
+ // focus
13210
+ model.set('$field', $field);
13211
+
13212
+ // callback
13213
+ model[ callback ].apply(model, arguments);
13214
+ });
13215
+ },
13216
+
13217
+ _add_event: function( name, callback ) {
13218
 
13219
+ // vars
13220
+ var model = this,
13221
+ event = name.substr(0,name.indexOf(' ')),
13222
+ selector = name.substr(name.indexOf(' ')+1),
13223
+ context = acf.get_selector(model.type);
 
13224
 
13225
+ // add event
13226
+ $(document).on(event, context + ' ' + selector, function( e ){
13227
+
13228
+ // vars
13229
+ var $el = $(this);
13230
+ var $field = acf.get_closest_field( $el, model.type );
13231
+
13232
+ // bail early if no field
13233
+ if( !$field.length ) return;
13234
+
13235
+ // focus
13236
+ if( !$field.is(model.$field) ) {
13237
+ model.set('$field', $field);
13238
+ }
13239
+
13240
+ // append to event
13241
+ e.$el = $el;
13242
+ e.$field = $field;
13243
+
13244
+ // callback
13245
+ model[ callback ].apply(model, [e]);
13246
+ });
13247
+ },
13248
+
13249
+ _set_$field: function(){
13250
 
13251
+ // callback
13252
+ if( typeof this.focus === 'function' ) {
13253
+ this.focus();
13254
+ }
13255
+ },
13256
+
13257
+ // depreciated
13258
+ doFocus: function( $field ){
13259
+ return this.set('$field', $field);
13260
+ }
13261
+ });
13262
+
13263
+
13264
+ /**
13265
+ * validation
13266
+ *
13267
+ * description
13268
+ *
13269
+ * @date 15/2/18
13270
+ * @since 5.6.9
13271
+ *
13272
+ * @param type $var Description. Default.
13273
+ * @return type Description.
13274
+ */
13275
+
13276
+ var _validation = acf.newCompatibility(acf.validation, {
13277
+ remove_error: function( $field ){
13278
+ acf.getField( $field ).removeError();
13279
+ },
13280
+ add_warning: function( $field, message ){
13281
+ acf.getField( $field ).showNotice({
13282
+ text: message,
13283
+ type: 'warning',
13284
+ timeout: 1000
13285
+ });
13286
+ }
13287
+ });
13288
+
13289
+
13290
+ /**
13291
+ * tooltip
13292
+ *
13293
+ * description
13294
+ *
13295
+ * @date 15/2/18
13296
+ * @since 5.6.9
13297
+ *
13298
+ * @param type $var Description. Default.
13299
+ * @return type Description.
13300
+ */
13301
+
13302
+ _acf.tooltip = {
13303
+
13304
+ tooltip: function( text, $el ){
13305
 
13306
+ var tooltip = acf.newTooltip({
13307
+ text: text,
13308
+ target: $el
13309
+ });
13310
 
13311
  // return
13312
+ return tooltip.$el;
13313
+ },
13314
+
13315
+ temp: function( text, $el ){
13316
 
13317
+ var tooltip = acf.newTooltip({
13318
+ text: text,
13319
+ target: $el,
13320
+ timeout: 250
13321
+ });
13322
  },
13323
 
13324
+ confirm: function( $el, callback, text, button_y, button_n ){
13325
 
13326
+ var tooltip = acf.newTooltip({
13327
+ confirm: true,
13328
+ text: text,
13329
+ target: $el,
13330
+ confirm: function(){
13331
+ callback(true);
13332
+ },
13333
+ cancel: function(){
13334
+ callback(false);
13335
+ }
13336
+ });
13337
+ },
13338
+
13339
+ confirm_remove: function( $el, callback ){
13340
 
13341
+ var tooltip = acf.newTooltip({
13342
+ confirmRemove: true,
13343
+ target: $el,
13344
+ confirm: function(){
13345
+ callback(true);
13346
+ },
13347
+ cancel: function(){
13348
+ callback(false);
13349
+ }
13350
+ });
13351
+ },
13352
+ };
13353
+
13354
+ /**
13355
+ * tooltip
13356
+ *
13357
+ * description
13358
+ *
13359
+ * @date 15/2/18
13360
+ * @since 5.6.9
13361
+ *
13362
+ * @param type $var Description. Default.
13363
+ * @return type Description.
13364
+ */
13365
+
13366
+ _acf.media = new acf.Model({
13367
+ activeFrame: false,
13368
+ actions: {
13369
+ 'new_media_popup': 'onNewMediaPopup'
13370
+ },
13371
+
13372
+ frame: function(){
13373
+ return this.activeFrame;
13374
+ },
13375
+
13376
+ onNewMediaPopup: function( popup ){
13377
+ this.activeFrame = popup.frame;
13378
  },
13379
 
13380
+ popup: function( props ){
13381
 
13382
+ // update props
13383
+ if( props.mime_types ) {
13384
+ props.allowedTypes = props.mime_types;
13385
+ }
13386
+ if( props.id ) {
13387
+ props.attachment = props.id;
13388
+ }
13389
 
13390
+ // new
13391
+ var popup = acf.newMediaPopup( props );
13392
 
13393
+ // append
13394
+ /*
13395
+ if( props.selected ) {
13396
+ popup.selected = props.selected;
13397
+ }
13398
+ */
13399
 
13400
+ // return
13401
+ return popup.frame;
13402
+ }
13403
+ });
13404
+
13405
+
13406
+ /**
13407
+ * Select2
13408
+ *
13409
+ * description
13410
+ *
13411
+ * @date 11/6/18
13412
+ * @since 5.6.9
13413
+ *
13414
+ * @param type $var Description. Default.
13415
+ * @return type Description.
13416
+ */
13417
+
13418
+ _acf.select2 = {
13419
+ init: function( $select, args, $field ){
13420
 
13421
+ // compatible args
13422
+ if( args.allow_null ) {
13423
+ args.allowNull = args.allow_null;
13424
+ }
13425
+ if( args.ajax_action ) {
13426
+ args.ajaxAction = args.ajax_action;
13427
+ }
13428
+ if( $field ) {
13429
+ args.field = acf.getField($field);
13430
+ }
13431
 
13432
  // return
13433
+ return acf.newSelect2( $select, args );
 
13434
  },
13435
 
13436
+ destroy: function( $select ){
13437
+ return acf.getInstance( $select ).destroy();
13438
+
13439
+ },
13440
+ };
13441
+
13442
+ /**
13443
+ * postbox
13444
+ *
13445
+ * description
13446
+ *
13447
+ * @date 11/6/18
13448
+ * @since 5.6.9
13449
+ *
13450
+ * @param type $var Description. Default.
13451
+ * @return type Description.
13452
+ */
13453
+
13454
+ _acf.postbox = {
13455
+ render: function( args ){
13456
+
13457
+ // compatible args
13458
+ if( args.edit_url ) {
13459
+ args.editLink = args.edit_url;
13460
+ }
13461
+ if( args.edit_title ) {
13462
+ args.editTitle = args.edit_title;
13463
+ }
13464
+
13465
+ // return
13466
+ return acf.newPostbox( args );
13467
+ }
13468
+ };
13469
+
13470
+ /**
13471
+ * acf.screen
13472
+ *
13473
+ * description
13474
+ *
13475
+ * @date 11/6/18
13476
+ * @since 5.6.9
13477
+ *
13478
+ * @param type $var Description. Default.
13479
+ * @return type Description.
13480
+ */
13481
+
13482
+ acf.newCompatibility(acf.screen, {
13483
+ update: function(){
13484
+ return this.set.apply(this, arguments);
13485
+ }
13486
  });
13487
+ _acf.ajax = acf.screen;
13488
 
 
13489
  })(jQuery);
13490
 
 
13491
  // @codekit-prepend "../js/acf.js";
13492
+ // @codekit-prepend "../js/acf-hooks.js";
13493
+ // @codekit-prepend "../js/acf-model.js";
13494
+ // @codekit-prepend "../js/acf-popup.js";
13495
+ // @codekit-prepend "../js/acf-unload.js";
13496
+ // @codekit-prepend "../js/acf-panel.js";
13497
+ // @codekit-prepend "../js/acf-notice.js";
13498
+ // @codekit-prepend "../js/acf-postbox.js";
13499
+ // @codekit-prepend "../js/acf-tooltip.js";
13500
+ // @codekit-prepend "../js/acf-field.js";
13501
+ // @codekit-prepend "../js/acf-fields.js";
13502
+ // @codekit-prepend "../js/acf-field-accordion.js";
13503
+ // @codekit-prepend "../js/acf-field-button-group.js";
13504
+ // @codekit-prepend "../js/acf-field-checkbox.js";
13505
+ // @codekit-prepend "../js/acf-field-color-picker.js";
13506
+ // @codekit-prepend "../js/acf-field-date-picker.js";
13507
+ // @codekit-prepend "../js/acf-field-date-time-picker.js";
13508
+ // @codekit-prepend "../js/acf-field-google-map.js";
13509
+ // @codekit-prepend "../js/acf-field-image.js";
13510
+ // @codekit-prepend "../js/acf-field-file.js";
13511
+ // @codekit-prepend "../js/acf-field-link.js";
13512
+ // @codekit-prepend "../js/acf-field-oembed.js";
13513
+ // @codekit-prepend "../js/acf-field-radio.js";
13514
+ // @codekit-prepend "../js/acf-field-range.js";
13515
+ // @codekit-prepend "../js/acf-field-relationship.js";
13516
+ // @codekit-prepend "../js/acf-field-select.js";
13517
+ // @codekit-prepend "../js/acf-field-tab.js";
13518
+ // @codekit-prepend "../js/acf-field-post-object.js";
13519
+ // @codekit-prepend "../js/acf-field-page-link.js";
13520
+ // @codekit-prepend "../js/acf-field-user.js";
13521
+ // @codekit-prepend "../js/acf-field-taxonomy.js";
13522
+ // @codekit-prepend "../js/acf-field-time-picker.js";
13523
+ // @codekit-prepend "../js/acf-field-true-false.js";
13524
+ // @codekit-prepend "../js/acf-field-url.js";
13525
+ // @codekit-prepend "../js/acf-field-wysiwyg.js";
13526
+ // @codekit-prepend "../js/acf-condition.js";
13527
+ // @codekit-prepend "../js/acf-conditions.js";
13528
+ // @codekit-prepend "../js/acf-condition-types.js";
13529
  // @codekit-prepend "../js/acf-media.js";
13530
+ // @codekit-prepend "../js/acf-screen.js";
 
 
 
13531
  // @codekit-prepend "../js/acf-select2.js";
13532
+ // @codekit-prepend "../js/acf-tinymce.js";
 
 
 
 
 
 
13533
  // @codekit-prepend "../js/acf-validation.js";
13534
+ // @codekit-prepend "../js/acf-helpers.js";
13535
+ // @codekit-prepend "../js/acf-compatibility";
13536
+
13537
 
assets/js/acf-input.min.js CHANGED
@@ -1,3 +1,4 @@
1
- !function(e,t){"use strict";var i=function(){function e(){return u}function t(e,t,i,a){return"string"==typeof e&&"function"==typeof t&&(i=parseInt(i||10,10),l("actions",e,t,i,a)),f}function i(){var e=Array.prototype.slice.call(arguments),t=e.shift();return"string"==typeof t&&d("actions",t,e),f}function a(e,t){return"string"==typeof e&&r("actions",e,t),f}function n(e,t,i,a){return"string"==typeof e&&"function"==typeof t&&(i=parseInt(i||10,10),l("filters",e,t,i,a)),f}function s(){var e=Array.prototype.slice.call(arguments),t=e.shift();return"string"==typeof t?d("filters",t,e):f}function o(e,t){return"string"==typeof e&&r("filters",e,t),f}function r(e,t,i,a){if(u[e][t])if(i){var n=u[e][t],s;if(a)for(s=n.length;s--;){var o=n[s];o.callback===i&&o.context===a&&n.splice(s,1)}else for(s=n.length;s--;)n[s].callback===i&&n.splice(s,1)}else u[e][t]=[]}function l(e,t,i,a,n){var s={callback:i,priority:a,context:n},o=u[e][t];o?(o.push(s),o=c(o)):o=[s],u[e][t]=o}function c(e){for(var t,i,a,n=1,s=e.length;n<s;n++){for(t=e[n],i=n;(a=e[i-1])&&a.priority>t.priority;)e[i]=e[i-1],--i;e[i]=t}return e}function d(e,t,i){var a=u[e][t];if(!a)return"filters"===e&&i[0];var n=0,s=a.length;if("filters"===e)for(;n<s;n++)i[0]=a[n].callback.apply(a[n].context,i);else for(;n<s;n++)a[n].callback.apply(a[n].context,i);return"filters"!==e||i[0]}var f={removeFilter:o,applyFilters:s,addFilter:n,removeAction:a,doAction:i,addAction:t,storage:e},u={actions:{},filters:{}};return f};e.wp=e.wp||{},e.wp.hooks=e.wp.hooks||new i}(window);var acf;!function($){$.fn.exists=function(){return $(this).length>0},$.fn.outerHTML=function(){return $(this).get(0).outerHTML},acf={l10n:{},o:{},update:function(e,t){this.o[e]=t},get:function(e){return void 0!==this.o[e]?this.o[e]:null},_e:function(e,t){t=t||!1;var i=this.l10n[e]||"";return t&&(i=i[t]||""),i},add_action:function(){for(var e=arguments[0].split(" "),t=e.length,i=0;i<t;i++)arguments[0]="acf/"+e[i],wp.hooks.addAction.apply(this,arguments);return this},remove_action:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.removeAction.apply(this,arguments),this},do_action:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.doAction.apply(this,arguments),this},add_filter:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.addFilter.apply(this,arguments),this},remove_filter:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.removeFilter.apply(this,arguments),this},apply_filters:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.applyFilters.apply(this,arguments)},get_selector:function(e){e=e||"";var t=".acf-field";if($.isPlainObject(e))if($.isEmptyObject(e))e="";else for(k in e){e=e[k];break}return e&&(t+="-"+e,t=t.split("_").join("-"),t=t.split("field-field-").join("field-")),t},get_fields:function(e,t,i){e=e||"",t=t||!1,i=i||!1;var a=this.get_selector(e),n=$(a,t);return!1!==t&&t.each(function(){$(this).is(a)&&(n=n.add($(this)))}),i||(n=n.not(".acf-clone .acf-field"),n=acf.apply_filters("get_fields",n)),n},get_field:function(e,t){e=e||"",t=t||!1;var i=this.get_fields(e,t,!0);return!!i.exists()&&i.first()},get_closest_field:function(e,t){return t=t||"",e.closest(this.get_selector(t))},get_field_wrap:function(e){return e.closest(this.get_selector())},get_field_key:function(e){return e.data("key")},get_field_type:function(e){return e.data("type")},get_data:function(e,t){var i=e.data();return"object"==typeof t&&(i=this.parse_args(i,t)),i},get_uniqid:function(e,t){void 0===e&&(e="");var i,a=function(e,t){return e=parseInt(e,10).toString(16),t<e.length?e.slice(e.length-t):t>e.length?Array(t-e.length+1).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,i=e,i+=a(parseInt((new Date).getTime()/1e3,10),8),i+=a(this.php_js.uniqidSeed,5),t&&(i+=(10*Math.random()).toFixed(8).toString()),i},serialize_form:function(){return this.serialize.apply(this,arguments)},serialize:function(e,t){t=t||"";var i={},a={},n=e.find("select, textarea, input").serializeArray();return $.each(n,function(e,n){var s=n.name,o=n.value;if(t){if(0!==s.indexOf(t))return;s=s.slice(t.length),"["==s.slice(0,1)&&(s=s.slice(1).replace("]",""))}"[]"===s.slice(-2)&&(s=s.slice(0,-2),void 0===a[s]&&(a[s]=-1),a[s]++,s+="["+a[s]+"]"),i[s]=o}),i},remove_tr:function(e,t){var i=e.height(),a=e.children().length;e.addClass("acf-remove-element"),setTimeout(function(){e.removeClass("acf-remove-element"),e.html('<td style="padding:0; height:'+i+'px" colspan="'+a+'"></td>'),e.children("td").animate({height:0},250,function(){e.remove(),"function"==typeof t&&t()})},250)},remove_el:function(e,t,i){i=i||0;var a=e.height(),n=e.width(),s=e.css("margin"),o=e.outerHeight(!0);acf.do_action("remove",e),e.wrap('<div class="acf-temp-remove" style="height:'+o+'px"></div>');var r=e.parent();e.css({height:a,width:n,margin:s,position:"absolute"}),setTimeout(function(){r.css({opacity:0,height:i})},50),setTimeout(function(){r.remove(),"function"==typeof t&&t.apply(this,arguments)},301)},isset:function(){var e=arguments,t=e.length,a=null,n;if(0===t)throw new Error("Empty isset");for(a=e[0],i=1;i<t;i++){if(e[i]===n||a[e[i]]===n)return!1;a=a[e[i]]}return!0},maybe_get:function(e,t,i){void 0===i&&(i=null),keys=String(t).split(".");for(var a in keys){var t=keys[a];if(void 0===e[t])return i;e=e[t]}return e},open_popup:function(e){if($popup=$("body > #acf-popup"),$popup.exists())return update_popup(e);var t=['<div id="acf-popup">','<div class="acf-popup-box acf-box">','<div class="title"><h3></h3><a href="#" class="acf-icon -cancel grey acf-close-popup"></a></div>','<div class="inner"></div>','<div class="loading"><i class="acf-loading"></i></div>',"</div>",'<div class="bg"></div>',"</div>"].join("");return $("body").append(t),$("#acf-popup").on("click",".bg, .acf-close-popup",function(e){e.preventDefault(),acf.close_popup()}),this.update_popup(e)},update_popup:function(e){return $popup=$("#acf-popup"),!!$popup.exists()&&(e=$.extend({},{title:"",content:"",width:0,height:0,loading:!1},e),e.title&&$popup.find(".title h3").html(e.title),e.content&&($inner=$popup.find(".inner:first"),$inner.html(e.content),acf.do_action("append",$inner),$inner.attr("style","position: relative;"),e.height=$inner.outerHeight(),$inner.removeAttr("style")),e.width&&$popup.find(".acf-popup-box").css({width:e.width,"margin-left":0-e.width/2}),e.height&&(e.height+=44,$popup.find(".acf-popup-box").css({height:e.height,"margin-top":0-e.height/2})),e.loading?$popup.find(".loading").show():$popup.find(".loading").hide(),$popup)},close_popup:function(){$popup=$("#acf-popup"),$popup.exists()&&$popup.remove()},update_user_setting:function(e,t){$.ajax({url:acf.get("ajaxurl"),dataType:"html",type:"post",data:acf.prepare_for_ajax({action:"acf/update_user_setting",name:e,value:t})})},prepare_for_ajax:function(e){var t={};return $.each(e,function(e,i){$.isPlainObject(i)&&!$.isEmptyObject(i)?$.each(i,function(i,a){i+="";var n=i.indexOf("[");i=0==n?e+i:n>0?e+"["+i.slice(0,n)+"]"+i.slice(n):e+"["+i+"]",t[i]=a}):t[e]=i}),t.nonce=acf.get("nonce"),t.post_id=acf.get("post_id"),t=acf.apply_filters("prepare_for_ajax",t)},is_ajax_success:function(e){return!(!e||!e.success)},get_ajax_message:function(e){var t={text:"",type:"error"};return e?(e.success&&(t.type="success"),e.data&&e.data.message&&(t.text=e.data.message),e.data&&e.data.error&&(t.text=e.data.error),t):t},is_in_view:function(e){var t=e.offset().top,i=t+e.height();if(t===i)return!1;var a=$(window).scrollTop();return i<=a+$(window).height()&&t>=a},val:function(e,t){var i=e.val();e.val(t),t!=i&&e.trigger("change")},str_replace:function(e,t,i){return i.split(e).join(t)},str_sanitize:function(e){var t={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","ß":"s","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","ĝ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o"," ":"_","'":"","?":"","/":"","\\":"",".":"",",":"","`":"",">":"","<":"",'"':"","[":"","]":"","|":"","{":"","}":"","(":"",")":""},i=/\W/g,a=function(e){return void 0!==t[e]?t[e]:e};return e=e.replace(i,a),e=e.toLowerCase()},addslashes:function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},esc_html:function(e){var t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};return String(e).replace(/[&<>"'`=\/]/g,function(e){return t[e]})},render_select:function(e,t){var i=e.val();e.html(""),t&&$.each(t,function(t,a){var n=e;a.group&&(n=e.find('optgroup[label="'+a.group+'"]'),n.exists()||(n=$('<optgroup label="'+a.group+'"></optgroup>'),e.append(n))),n.append('<option value="'+a.value+'">'+acf.esc_html(a.label)+"</option>"),i==a.value&&e.prop("selectedIndex",t)})},duplicate:function(e){void 0!==e.length&&(e={$el:e}),e=acf.parse_args(e,{$el:!1,search:"",replace:"",before:function(e){},after:function(e,t){},append:function(e,t){e.after(t)}});var t=e.$el,i;e.search||(e.search=t.attr("data-id")),e.replace||(e.replace=acf.get_uniqid()),e.before.apply(this,[t]),acf.do_action("before_duplicate",t);var i=t.clone();return i.removeClass("acf-clone"),acf.do_action("remove",i),e.search&&(i.attr("data-id",e.replace),i.find('[id*="'+e.search+'"]').each(function(){$(this).attr("id",$(this).attr("id").replace(e.search,e.replace))}),i.find('[name*="'+e.search+'"]').each(function(){$(this).attr("name",$(this).attr("name").replace(e.search,e.replace))}),i.find('label[for*="'+e.search+'"]').each(function(){$(this).attr("for",$(this).attr("for").replace(e.search,e.replace))})),i.find(".ui-sortable").removeClass("ui-sortable"),acf.do_action("after_duplicate",t,i),e.after.apply(this,[t,i]),e.append.apply(this,[t,i]),setTimeout(function(){acf.do_action("append",i)},1),i},decode:function(e){return $("<textarea/>").html(e).text()},parse_args:function(e,t){return"object"!=typeof e&&(e={}),"object"!=typeof t&&(t={}),$.extend({},t,e)},enqueue_script:function(e,t){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.async=!0,i.readyState?i.onreadystatechange=function(){"loaded"!=i.readyState&&"complete"!=i.readyState||(i.onreadystatechange=null,t())}:i.onload=function(){t()},document.body.appendChild(i)}},acf.model={actions:{},filters:{},events:{},extend:function(e){var t=$.extend({},this,e);return $.each(t.actions,function(e,i){t._add_action(e,i)}),$.each(t.filters,function(e,i){t._add_filter(e,i)}),$.each(t.events,function(e,i){t._add_event(e,i)}),t},_add_action:function(e,t){var i=this,a=e.split(" "),e=a[0]||"",n=a[1]||10;acf.add_action(e,i[t],n,i)},_add_filter:function(e,t){var i=this,a=e.split(" "),e=a[0]||"",n=a[1]||10;acf.add_filter(e,i[t],n,i)},_add_event:function(e,t){var i=this,a=e.indexOf(" "),n=a>0?e.substr(0,a):e,s=a>0?e.substr(a+1):"",o=function(e){e.$el=$(this),"function"==typeof i.event&&(e=i.event(e)),i[t].apply(i,arguments)};s?$(document).on(n,s,o):$(document).on(n,o)},get:function(e,t){return t=t||null,void 0!==this[e]&&(t=this[e]),t},set:function(e,t){return this[e]=t,"function"==typeof this["_set_"+e]&&this["_set_"+e].apply(this),this}},acf.field=acf.model.extend({type:"",o:{},$field:null,_add_action:function(e,t){var i=this;e=e+"_field/type="+i.type,acf.add_action(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_filter:function(e,t){var i=this;e=e+"_field/type="+i.type,acf.add_filter(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_event:function(e,t){var i=this,a=e.substr(0,e.indexOf(" ")),n=e.substr(e.indexOf(" ")+1),s=acf.get_selector(i.type);$(document).on(a,s+" "+n,function(e){var a=$(this),n=acf.get_closest_field(a,i.type);n.length&&(n.is(i.$field)||i.set("$field",n),e.$el=a,e.$field=n,i[t].apply(i,[e]))})},_set_$field:function(){"function"==typeof this.focus&&this.focus()},doFocus:function(e){return this.set("$field",e)}}),acf.fields=acf.model.extend({actions:{prepare:"_prepare",prepare_field:"_prepare_field",ready:"_ready",ready_field:"_ready_field",append:"_append",append_field:"_append_field",load:"_load",load_field:"_load_field",remove:"_remove",remove_field:"_remove_field",sortstart:"_sortstart",sortstart_field:"_sortstart_field",sortstop:"_sortstop",sortstop_field:"_sortstop_field",show:"_show",show_field:"_show_field",hide:"_hide",hide_field:"_hide_field"},_prepare:function(e){acf.get_fields("",e).each(function(){acf.do_action("prepare_field",$(this))})},_prepare_field:function(e){acf.do_action("prepare_field/type="+e.data("type"),e)},_ready:function(e){acf.get_fields("",e).each(function(){acf.do_action("ready_field",$(this))})},_ready_field:function(e){acf.do_action("ready_field/type="+e.data("type"),e)},_append:function(e){acf.get_fields("",e).each(function(){acf.do_action("append_field",$(this))})},_append_field:function(e){acf.do_action("append_field/type="+e.data("type"),e)},_load:function(e){acf.get_fields("",e).each(function(){acf.do_action("load_field",$(this))})},_load_field:function(e){acf.do_action("load_field/type="+e.data("type"),e)},_remove:function(e){acf.get_fields("",e).each(function(){acf.do_action("remove_field",$(this))})},_remove_field:function(e){acf.do_action("remove_field/type="+e.data("type"),e)},_sortstart:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("sortstart_field",$(this),t)})},_sortstart_field:function(e,t){acf.do_action("sortstart_field/type="+e.data("type"),e,t)},_sortstop:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("sortstop_field",$(this),t)})},_sortstop_field:function(e,t){acf.do_action("sortstop_field/type="+e.data("type"),e,t)},_hide:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("hide_field",$(this),t)})},_hide_field:function(e,t){acf.do_action("hide_field/type="+e.data("type"),e,t)},_show:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("show_field",$(this),t)})},_show_field:function(e,t){acf.do_action("show_field/type="+e.data("type"),e,t)}}),$(document).ready(function(){acf.do_action("ready",$("body"))}),$(window).on("load",function(){acf.do_action("load",$("body"))}),acf.layout=acf.model.extend({actions:{"refresh 99":"refresh"},refresh:function(e){e=e||$("body"),this.render_tables(e),this.render_groups(e)},render_tables:function(e){var t=this,i=e.find(".acf-table:visible");e.is("table")?i=i.add(e):e.is("tr")&&(i=i.add(e.closest("table"))),i.each(function(){t.render_table($(this))})},render_table:function(e){var t=e.find("> thead th.acf-th"),i=1,a=100;if(t.exists()){var n=e.find("> tbody > tr"),s=n.find("> td.acf-field");n.hasClass("acf-clone")&&n.length>1&&(s=n.not(".acf-clone").find("> td.acf-field")),t.each(function(){var e=$(this),t=e.attr("data-key"),i=s.filter('[data-key="'+t+'"]');i.removeClass("appear-empty"),e.removeClass("hidden-by-conditional-logic"),i.exists()&&(0==i.not(".hidden-by-conditional-logic").length?e.addClass("hidden-by-conditional-logic"):i.filter(".hidden-by-conditional-logic").addClass("appear-empty"))}),t.css("width","auto"),t=t.not(".hidden-by-conditional-logic"),i=t.length,t.filter("[data-width]").each(function(){var e=parseInt($(this).attr("data-width"));a-=e,$(this).css("width",e+"%")}),t=t.not("[data-width]"),t.each(function(){var e=a/t.length;$(this).css("width",e+"%")}),e.find(".acf-row .acf-field.-collapsed-target").removeAttr("colspan"),e.find(".acf-row.-collapsed .acf-field.-collapsed-target").attr("colspan",i)}},render_groups:function(e){var t=this,i=e.find(".acf-fields:visible");e&&e.is(".acf-fields")&&(i=i.add(e)),i.each(function(){t.render_group($(this))})},render_group:function(e){var t=$(),i=0,a=0,n=-1,s=e.children(".acf-field[data-width]:visible");if(s.exists()){if(e.hasClass("-left"))return s.removeAttr("data-width"),void s.css("width","auto");s.removeClass("-r0 -c0").css({"min-height":0}),s.each(function(e){var s=$(this),o=s.position().top;0==e&&(i=o),o!=i&&(t.css({"min-height":a+1+"px"}),t=$(),i=s.position().top,a=0,n=-1),n++,a=s.outerHeight()>a?s.outerHeight():a,t=t.add(s),0==o?s.addClass("-r0"):0==n&&s.addClass("-c0")}),t.exists()&&t.css({"min-height":a+1+"px"})}}}),$(document).on("change",".acf-field input, .acf-field textarea, .acf-field select",function(){var e=$("#_acf_changed");e.length&&e.val(1),acf.do_action("change",$(this))}),$(document).on("click",'.acf-field a[href="#"]',function(e){e.preventDefault()}),acf.unload=acf.model.extend({locked:1,active:1,changed:0,filters:{validation_complete:"validation_complete"},actions:{ready:"ready",change:"on",submit:"off"},ready:function(){setTimeout(function(){acf.unload.locked=0},1e3)},events:{"submit form":"off"},validation_complete:function(e,t){return e&&e.errors&&this.on(),e},on:function(){this.changed||!this.active||this.locked||(this.changed=1,$(window).on("beforeunload",this.unload))},off:function(){this.changed=0,$(window).off("beforeunload",this.unload)},unload:function(){return acf._e("unload")}}),acf.tooltip=acf.model.extend({events:{"mouseenter .acf-js-tooltip":"_on","mouseup .acf-js-tooltip":"_off","mouseleave .acf-js-tooltip":"_off"},tooltip:function(e,t){var i=$('<div class="acf-tooltip">'+e+"</div>");$("body").append(i);var a=10;target_w=t.outerWidth(),target_h=t.outerHeight(),target_t=t.offset().top,target_l=t.offset().left,tooltip_w=i.outerWidth(),tooltip_h=i.outerHeight();var n=target_t-tooltip_h,s=target_l+target_w/2-tooltip_w/2;return s<10?(i.addClass("right"),s=target_l+target_w,n=target_t+target_h/2-tooltip_h/2):s+tooltip_w+10>$(window).width()?(i.addClass("left"),s=target_l-tooltip_w,n=target_t+target_h/2-tooltip_h/2):n-$(window).scrollTop()<10?(i.addClass("bottom"),n=target_t+target_h):i.addClass("top"),i.css({top:n,left:s}),i},temp:function(e,t){var t=this.tooltip(e,t),i=0;i+=250,setTimeout(function(){t.addClass("acf-fade-up")},i),i+=250,setTimeout(function(){t.remove()},i)},confirm:function(e,t,i,a,n){i=i||acf._e("are_you_sure"),a=a||'<a href="#" class="acf-confirm-y">'+acf._e("yes")+"</a>",n=n||'<a href="#" class="acf-confirm-n">'+acf._e("No")+"</a>";var s=this.tooltip(i+" "+a+" "+n,e);s.addClass("-confirm");var o=function(i,a){i.preventDefault(),i.stopImmediatePropagation(),e.off("click",r),s.off("click",".acf-confirm-y",r),s.off("click",".acf-confirm-n",l),$("body").off("click",l),s.remove(),t.apply(null,[a])},r=function(e){o(e,!0)},l=function(e){o(e,!1)};s.on("click",".acf-confirm-y",r),s.on("click",".acf-confirm-n",l),e.on("click",r),$("body").on("click",l)},confirm_remove:function(e,t){text=!1,button_y='<a href="#" class="acf-confirm-y -red">'+acf._e("remove")+"</a>",button_n='<a href="#" class="acf-confirm-n">'+acf._e("cancel")+"</a>",this.confirm(e,t,!1,button_y,button_n)},_on:function(e){var t=e.$el.attr("title");if(t){var i=this.tooltip(t,e.$el);e.$el.data("acf-tooltip",{title:t,$el:i}),e.$el.attr("title","")}},_off:function(e){var t=e.$el.data("acf-tooltip");t&&(t.$el.remove(),e.$el.attr("title",t.title))}}),acf.postbox=acf.model.extend({events:{"mouseenter .acf-postbox .handlediv":"on","mouseleave .acf-postbox .handlediv":"off"},on:function(e){e.$el.siblings(".hndle").addClass("hover")},off:function(e){e.$el.siblings(".hndle").removeClass("hover")},render:function(e){e=$.extend({},{id:"",key:"",style:"default",label:"top",edit_url:"",edit_title:"",visibility:!0},e);var t=$("#"+e.id),i=$("#"+e.id+"-hide"),a=i.parent();t.addClass("acf-postbox"),a.addClass("acf-postbox-toggle"),t.removeClass("hide-if-js"),a.removeClass("hide-if-js"),"default"!==e.style&&t.addClass(e.style),t.children(".inside").addClass("acf-fields").addClass("-"+e.label),e.visibility?i.prop("checked",!0):(t.addClass("acf-hidden"),a.addClass("acf-hidden")),e.edit_url&&t.children(".hndle").append('<a href="'+e.edit_url+'" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="'+e.edit_title+'"></a>')}});var e=acf.model.extend({events:{"click .acf-panel-title":"_click"},_click:function(e){e.preventDefault(),this.toggle(e.$el.parent())},is_open:function(e){return e.hasClass("-open")},toggle:function(e){this.is_open(e)?this.close(e):this.open(e)},open:function(e){e.addClass("-open"),e.find(".acf-panel-title i").attr("class","dashicons dashicons-arrow-down")},close:function(e){e.removeClass("-open"),e.find(".acf-panel-title i").attr("class","dashicons dashicons-arrow-right")}});acf.notice=acf.model.extend({actions:{prepare:"prepare"},prepare:function(){var e=$(".acf-notice");e.length&&$("h1:first").after(e)},html:function(e,t){},success:function(e){},error:function(e){},warning:function(e){},information:function(e){}});var t=localStorage.getItem("acf");t=t?JSON.parse(t):{};var a=function(e){return"this."===e.substr(0,5)&&(e=e.substr(5)+"-"+acf.get("post_id")),e};acf.getPreference=function(e){return e=a(e),t[e]||null},acf.setPreference=function(e,i){e=a(e),null===i?delete t[e]:t[e]=i,localStorage.setItem("acf",JSON.stringify(t))},acf.removePreference=function(e){acf.setPreference(e,null)};var n=function(e,t){return e.data("acf-lock-"+t)||[]},s=function(e,t,i){e.data("acf-lock-"+t,i)};acf.lock=function(e,t,i){var a=n(e,t);a.indexOf(i)<0&&(a.push(i),s(e,t,a))},acf.unlock=function(e,t,i){var a=n(e,t),o=a.indexOf(i);return o>-1&&(a.splice(o,1),s(e,t,a)),0===a.length},acf.isLocked=function(e,t){return n(e,t).length>0},acf.show=function(e,t){return t&&acf.unlock(e,"hidden",t),!acf.isLocked(e,"hidden")&&(!!e.hasClass("acf-hidden")&&(e.removeClass("acf-hidden"),!0))};var o=function(e,t){return!e.hasClass("acf-disabled")&&(t&&acf.unlock(e,"disabled",t),!acf.isLocked(e,"disabled")&&(!!e.prop("disabled")&&(e.prop("disabled",!1),!0)))};acf.enable=function(e,t){if(e.attr("name"))return o(e,t);var i=!0;return e.find("[name]").each(function(){o($(this),t)||(i=!1)}),i};var r=function(e,t){return t&&acf.lock(e,"disabled",t),!e.prop("disabled")&&(e.prop("disabled",!0),!0)};acf.disable=function(e,t){if(e.attr("name"))return r(e,t);var i=!0;return e.find("[name]").each(function(){r($(this),t)||(i=!1)}),i},acf.enable_el=acf.enable,acf.enable_form=acf.enable,acf.disable_el=acf.disable,acf.disable_form=acf.disable,acf.hide=function(e,t){return t&&acf.lock(e,"hidden",t),!e.hasClass("acf-hidden")&&(e.addClass("acf-hidden"),!0)},acf.isHidden=function(e){return e.hasClass("acf-hidden")},acf.isVisible=function(e){return!acf.isHidden(e)},$(document).on("sortstart",function(e,t){acf.do_action("sortstart",t.item,t.placeholder)}),$(document).on("sortstop",function(e,t){acf.do_action("sortstop",t.item,t.placeholder)}),acf.add_action("sortstart",function(e,t){e.is("tr")&&(e.css("position","relative"),e.children().each(function(){$(this).width($(this).width())}),e.css("position","absolute"),t.html('<td style="height:'+e.height()+'px; padding:0;" colspan="'+e.children("td").length+'"></td>'))}),acf.add_action("before_duplicate",function(e){e.find("select option:selected").addClass("selected")}),acf.add_action("after_duplicate",function(e,t){t.find("select").each(function(){var e=$(this),t=[];e.find("option.selected").each(function(){t.push($(this).val())}),e.val(t)}),e.find("select option.selected").removeClass("selected"),t.find("select option.selected").removeClass("selected")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){return $.inArray(e,this)})}(jQuery),function($){acf.ajax=acf.model.extend({active:!1,actions:{ready:"ready"},events:{"change #page_template":"_change_template","change #parent_id":"_change_parent","change #post-formats-select input":"_change_format","change .categorychecklist input":"_change_term","change .categorychecklist select":"_change_term",'change .acf-taxonomy-field[data-save="1"] input':"_change_term",'change .acf-taxonomy-field[data-save="1"] select':"_change_term"},o:{},xhr:null,update:function(e,t){return this.o[e]=t,this},get:function(e){return this.o[e]||null},ready:function(){this.update("post_id",acf.get("post_id")),this.active=!0},fetch:function(){if(this.active&&"post"===acf.get("screen")&&acf.get("ajax")){this.xhr&&this.xhr.abort();var e=this,t=this.o;t.action="acf/post/get_field_groups",t.exists=[],$(".acf-postbox").not(".acf-hidden").each(function(){t.exists.push($(this).attr("id").substr(4))}),this.xhr=$.ajax({url:acf.get("ajaxurl"),data:acf.prepare_for_ajax(t),type:"post",dataType:"json",success:function(t){acf.is_ajax_success(t)&&e.render(t.data)}})}},render:function(e){$(".acf-postbox").addClass("acf-hidden"),$(".acf-postbox-toggle").addClass("acf-hidden"),$("#acf-style").html(""),$.each(e,function(e,t){var i=$("#acf-"+t.key),a=$("#acf-"+t.key+"-hide"),n=a.parent();i.removeClass("acf-hidden hide-if-js").show(),n.removeClass("acf-hidden hide-if-js").show(),a.prop("checked",!0);var s=i.find(".acf-replace-with-fields");s.exists()&&(s.replaceWith(t.html),acf.do_action("append",i)),0===e&&$("#acf-style").html(t.style),i.find(".acf-hidden-by-postbox").prop("disabled",!1)}),$(".acf-postbox.acf-hidden").find("select, textarea, input").not(":disabled").each(function(){$(this).addClass("acf-hidden-by-postbox").prop("disabled",!0)})},sync_taxonomy_terms:function(){var e=[""];$(".categorychecklist, .acf-taxonomy-field").each(function(){var t=$(this),i=t.find('input[type="checkbox"]').not(":disabled"),a=t.find('input[type="radio"]').not(":disabled"),n=t.find("select").not(":disabled"),s=t.find('input[type="hidden"]').not(":disabled");t.is(".acf-taxonomy-field")&&"1"!=t.attr("data-save")||t.closest(".media-frame").exists()||(i.exists()?i.filter(":checked").each(function(){e.push($(this).val())}):a.exists()?a.filter(":checked").each(function(){e.push($(this).val())}):n.exists()?n.find("option:selected").each(function(){e.push($(this).val())}):s.exists()&&s.each(function(){$(this).val()&&e.push($(this).val())}))}),e=e.filter(function(e,t,i){return i.indexOf(e)==t}),this.update("post_taxonomy",e).fetch()},_change_template:function(e){var t=e.$el.val();this.update("page_template",t).fetch()},_change_parent:function(e){var t="parent",i=0;""!=e.$el.val()&&(t="child",i=e.$el.val()),this.update("page_type",t).update("page_parent",i).fetch()},_change_format:function(e){var t=e.$el.val();"0"==t&&(t="standard"),this.update("post_format",t).fetch()},_change_term:function(e){var t=this;e.$el.closest(".media-frame").exists()||setTimeout(function(){t.sync_taxonomy_terms()},1)}})}(jQuery),function($){acf.fields.button_group=acf.field.extend({type:"button_group",$div:null,events:{'click input[type="radio"]':"click"},focus:function(){this.$div=this.$field.find(".acf-button-group"),this.o=acf.get_data(this.$div,{allow_null:0})},click:function(e){var t=e.$el,i=t.parent("label"),a=i.hasClass("selected");this.$div.find(".selected").removeClass("selected"),i.addClass("selected"),this.o.allow_null&&a&&(e.$el.prop("checked",!1),i.removeClass("selected"),e.$el.trigger("change"))}})}(jQuery),function($){acf.fields.checkbox=acf.field.extend({type:"checkbox",events:{"change input":"_change","click .acf-add-checkbox":"_add"},focus:function(){this.$ul=this.$field.find("ul"),this.$input=this.$field.find('input[type="hidden"]')},add:function(){var e=this.$input.attr("name")+"[]",t='<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input type="text" name="'+e+'" /></li>';this.$ul.find(".acf-add-checkbox").parent("li").before(t)},_change:function(e){var t=this.$ul,i=t.find('input[type="checkbox"]').not(".acf-checkbox-toggle"),a=e.$el.is(":checked");if(e.$el.hasClass("acf-checkbox-toggle"))return void i.prop("checked",a).trigger("change");if(e.$el.hasClass("acf-checkbox-custom")){var n=e.$el.next('input[type="text"]');e.$el.next('input[type="text"]').prop("disabled",!a),a||""!=n.val()||e.$el.parent("li").remove()}if(t.find(".acf-checkbox-toggle").exists()){var a=0==i.not(":checked").length;t.find(".acf-checkbox-toggle").prop("checked",a)}},_add:function(e){this.add()}})}(jQuery),function($){acf.fields.color_picker=acf.field.extend({type:"color_picker",$input:null,$hidden:null,actions:{ready:"initialize",append:"initialize"},focus:function(){this.$input=this.$field.find('input[type="text"]'),this.$hidden=this.$field.find('input[type="hidden"]')},initialize:function(){var e=this.$input,t=this.$hidden,i=function(){setTimeout(function(){acf.val(t,e.val())},1)},a={defaultColor:!1,palettes:!0,hide:!0,change:i,clear:i},a=acf.apply_filters("color_picker_args",a,this.$field);this.$input.wpColorPicker(a)}})}(jQuery),function($,e){var t="hidden-by-conditional-logic",i="conditional_logic",a=acf.conditional_logic=acf.model.extend({conditions:{},triggers:{},$parent:!1,actions:{"prepare 20":"render","append 20":"render",change:"change"},add:function(e,t){for(var i in t){var a=t[i];for(var n in a){var s=a[n];this.addTrigger(s.field,e)}}this.setCondition(e,t)},getTrigger:function(e){return this.triggers[e]||null},setTrigger:function(e,t){this.triggers[e]=t},addTrigger:function(e,t){var i=this.getTrigger(e)||{};i[t]=1,this.setTrigger(e,i)},getConditions:function(){return this.conditions},getCondition:function(e){return this.conditions[e]||null},setCondition:function(e,t){this.conditions[e]=t},render:function(e){e=e||!1;var t=acf.get_fields("",e,!0);this.renderFields(t),acf.do_action("refresh",e)},findTarget:function(e,t){var i=this;this.$parent=!1;var a=acf.get_selector(t),n=e.siblings(a);if(n.length)return this.$parent=e.parent(),n;var n=acf.get_fields(t,!1,!0);return n.length>1&&e.parents(".acf-row, .acf-table, .acf-fields").each(function(){var e=$(this),t=e.find(n);if(t.length)return n=t,i.$parent=e,!1}),n},change:function(e){var t=acf.get_field_wrap(e),i=t.data("key"),a=this.getTrigger(i);if(!a)return!1;for(var n in a){var s=this.findTarget(t,n);this.renderFields(s)}acf.do_action("refresh",this.$parent)},renderFields:function(e){var t=this;e.each(function(){t.renderField($(this))})},renderField:function(e){var t=!1,i=e.data("key"),a=this.getCondition(i);if(!a)return!1;for(var n=0;n<a.length;n++){for(var s=a[n],o=!0,r=0;r<s.length;r++){var l=s[r],c=this.findTarget(e,l.field);if(!this.calculate(l,c,e)){o=!1;break}}if(o){t=!0;break}}t?this.showField(e,i):this.hideField(e,i)},showField:function(e,a){acf.enable(e,a);var n=acf.show(e,a);return n&&e.removeClass(t),acf.do_action("show_field",e,i),n},hideField:function(e,a){acf.disable(e,a);var n=acf.hide(e,a);return n&&e.addClass(t),acf.do_action("hide_field",e,i),n},calculate:function(e,t,i){if(!t||!i)return!1;var a=!1,n=t.data("type");return"true_false"==n||"checkbox"==n||"radio"==n||"button_group"==n?a=this.calculate_checkbox(e,t):"select"==n&&(a=this.calculate_select(e,t)),"!="===e.operator&&(a=!a),a},calculate_checkbox:function(e,t){var i=t.find('input[value="'+e.value+'"]:checked').exists();return""!==e.value||t.find("input:checked").exists()||(i=!0),i},
2
- calculate_select:function(e,t){var i=t.find("select"),a=i.val();return a||$.isNumeric(a)||(a=""),$.isArray(a)||(a=[a]),match=$.inArray(e.value,a)>-1,match}});a.show_field=a.showField,a.hide_field=a.hideField}(jQuery),function($){acf.datepicker=acf.model.extend({actions:{"ready 1":"ready"},ready:function(){var e=acf.get("locale"),t=acf.get("rtl");l10n=acf._e("date_picker"),l10n&&void 0!==$.datepicker&&(l10n.isRTL=t,$.datepicker.regional[e]=l10n,$.datepicker.setDefaults(l10n))},init:function(e,t){void 0!==$.datepicker&&(t=t||{},e.datepicker(t),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />'))},destroy:function(e){}}),acf.fields.date_picker=acf.field.extend({type:"date_picker",$el:null,$input:null,$hidden:null,o:{},actions:{ready:"initialize",append:"initialize"},events:{'blur input[type="text"]':"blur"},focus:function(){this.$el=this.$field.find(".acf-date-picker"),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){if(this.o.save_format)return this.initialize2();var e={dateFormat:this.o.date_format,altField:this.$hidden,altFormat:"yymmdd",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day};e=acf.apply_filters("date_picker_args",e,this.$field),acf.datepicker.init(this.$input,e),acf.do_action("date_picker_init",this.$input,e,this.$field)},initialize2:function(){this.$input.val(this.$hidden.val());var e={dateFormat:this.o.date_format,altField:this.$hidden,altFormat:this.o.save_format,changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day};e=acf.apply_filters("date_picker_args",e,this.$field);var t=e.dateFormat;e.dateFormat=this.o.save_format,acf.datepicker.init(this.$input,e),this.$input.datepicker("option","dateFormat",t),acf.do_action("date_picker_init",this.$input,e,this.$field)},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.datetimepicker=acf.model.extend({actions:{"ready 1":"ready"},ready:function(){var e=acf.get("locale"),t=acf.get("rtl");l10n=acf._e("date_time_picker"),l10n&&void 0!==$.timepicker&&(l10n.isRTL=t,$.timepicker.regional[e]=l10n,$.timepicker.setDefaults(l10n))},init:function(e,t){void 0!==$.timepicker&&(t=t||{},e.datetimepicker(t),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />'))},destroy:function(e){}}),acf.fields.date_time_picker=acf.field.extend({type:"date_time_picker",$el:null,$input:null,$hidden:null,o:{},actions:{ready:"initialize",append:"initialize"},events:{'blur input[type="text"]':"blur"},focus:function(){this.$el=this.$field.find(".acf-date-time-picker"),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){var e={dateFormat:this.o.date_format,timeFormat:this.o.time_format,altField:this.$hidden,altFieldTimeOnly:!1,altFormat:"yy-mm-dd",altTimeFormat:"HH:mm:ss",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day,controlType:"select",oneLine:!0};e=acf.apply_filters("date_time_picker_args",e,this.$field),acf.datetimepicker.init(this.$input,e),acf.do_action("date_time_picker_init",this.$input,e,this.$field)},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.file=acf.field.extend({type:"file",$el:null,$input:null,actions:{ready:"initialize",append:"initialize"},events:{'click a[data-name="add"]':"add",'click a[data-name="edit"]':"edit",'click a[data-name="remove"]':"remove",'change input[type="file"]':"change"},focus:function(){this.$el=this.$field.find(".acf-file-uploader"),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},prepare:function(e){if(e=e||{},e._valid)return e;var t={url:"",alt:"",title:"",filename:"",filesizeHumanReadable:"",icon:"/wp-includes/images/media/default.png"};return e.id&&(t=e.attributes),t._valid=!0,t},render:function(e){e=this.prepare(e),this.$el.find("img").attr({src:e.icon,alt:e.alt,title:e.title}),this.$el.find('[data-name="title"]').text(e.title),this.$el.find('[data-name="filename"]').text(e.filename).attr("href",e.url),this.$el.find('[data-name="filesize"]').text(e.filesizeHumanReadable);var t="";e.id&&(t=e.id),acf.val(this.$input,t),t?this.$el.addClass("has-value"):this.$el.removeClass("has-value")},add:function(){var e=this,t=this.$field,i=acf.get_closest_field(t,"repeater"),a=acf.media.popup({title:acf._e("file","select"),mode:"select",type:"",field:t.data("key"),multiple:i.exists(),library:this.o.library,mime_types:this.o.mime_types,select:function(a,n){if(n>0){var s=t.data("key"),o=t.closest(".acf-row");if(t=!1,o.nextAll(".acf-row:visible").each(function(){if(t=acf.get_field(s,$(this)))return!!t.find(".acf-file-uploader.has-value").exists()&&void(t=!1)}),!t){if(!(o=acf.fields.repeater.doFocus(i).add()))return!1;t=acf.get_field(s,o)}}e.set("$field",t).render(a)}})},edit:function(){var e=this,t=this.$field,i=this.$input.val();if(i)var a=acf.media.popup({title:acf._e("file","edit"),button:acf._e("file","update"),mode:"edit",attachment:i,select:function(i,a){e.set("$field",t).render(i)}})},remove:function(){var e={};this.render(e)},get_file_info:function(e,t){var i=e.val(),a={};if(!i)return void t.val("");a.url=i;var n=e[0].files;if(n.length){var s=n[0];if(a.size=s.size,a.type=s.type,s.type.indexOf("image")>-1){var o=window.URL||window.webkitURL,r=new Image;r.onload=function(){a.width=this.width,a.height=this.height,t.val(jQuery.param(a))},r.src=o.createObjectURL(s)}}t.val(jQuery.param(a))},change:function(e){this.get_file_info(e.$el,this.$input)}})}(jQuery),function($){acf.fields.google_map=acf.field.extend({type:"google_map",url:"",$el:null,$search:null,timeout:null,status:"",geocoder:!1,map:!1,maps:{},$pending:$(),actions:{ready:"initialize",append:"initialize",show:"show"},events:{'click a[data-name="clear"]':"_clear",'click a[data-name="locate"]':"_locate",'click a[data-name="search"]':"_search","keydown .search":"_keydown","keyup .search":"_keyup","focus .search":"_focus","blur .search":"_blur","mousedown .acf-google-map":"_mousedown"},focus:function(){this.$el=this.$field.find(".acf-google-map"),this.$search=this.$el.find(".search"),this.o=acf.get_data(this.$el),this.o.id=this.$el.attr("id"),this.maps[this.o.id]&&(this.map=this.maps[this.o.id])},is_ready:function(){var e=this;return"ready"==this.status||"loading"!=this.status&&(acf.isset(window,"google","maps","places")?(this.status="ready",!0):(acf.isset(window,"google","maps")&&(this.status="ready"),this.url&&(this.status="loading",acf.enqueue_script(this.url,function(){e.status="ready",e.initialize_pending()})),"ready"==this.status))},initialize_pending:function(){var e=this;this.$pending.each(function(){e.set("$field",$(this)).initialize()}),this.$pending=$()},initialize:function(){if(!this.is_ready())return this.$pending=this.$pending.add(this.$field),!1;this.geocoder||(this.geocoder=new google.maps.Geocoder);var e=this,t=this.$field,i=this.$el;this.$search.val(this.$el.find(".input-address").val());var a=acf.apply_filters("google_map_args",{scrollwheel:!1,zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP},this.$field);if(this.map=new google.maps.Map(this.$el.find(".canvas")[0],a),acf.isset(window,"google","maps","places","Autocomplete")){var n=new google.maps.places.Autocomplete(this.$search[0]);n.bindTo("bounds",this.map),google.maps.event.addListener(n,"place_changed",function(t){var i=this.getPlace();e.search(i)}),this.map.autocomplete=n}var s=acf.apply_filters("google_map_marker_args",{draggable:!0,raiseOnDrag:!0,map:this.map},this.$field);this.map.marker=new google.maps.Marker(s),this.map.$el=i,this.map.$field=t;var o=i.find(".input-lat").val(),r=i.find(".input-lng").val();o&&r&&this.update(o,r).center(),google.maps.event.addListener(this.map.marker,"dragend",function(){var t=this.map.marker.getPosition(),i=t.lat(),a=t.lng();e.update(i,a).sync()}),google.maps.event.addListener(this.map,"click",function(t){var i=t.latLng.lat(),a=t.latLng.lng();e.update(i,a).sync()}),acf.do_action("google_map_init",this.map,this.map.marker,this.$field),this.maps[this.o.id]=this.map},search:function(e){var t=this,i=this.$search.val();if(!i)return!1;this.$el.find(".input-address").val(i);var a=i.split(",");if(2==a.length){var n=a[0],s=a[1];if($.isNumeric(n)&&$.isNumeric(s))return n=parseFloat(n),s=parseFloat(s),void t.update(n,s).center()}if(e&&e.geometry){var n=e.geometry.location.lat(),s=e.geometry.location.lng();return void t.update(n,s).center()}this.$el.addClass("-loading"),t.geocoder.geocode({address:i},function(i,a){if(t.$el.removeClass("-loading"),a!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+a);if(!i[0])return void console.log("No results found");e=i[0];var n=e.geometry.location.lat(),s=e.geometry.location.lng();t.update(n,s).center()})},update:function(e,t){var i=new google.maps.LatLng(e,t);return acf.val(this.$el.find(".input-lat"),e),acf.val(this.$el.find(".input-lng"),t),this.map.marker.setPosition(i),this.map.marker.setVisible(!0),this.$el.addClass("-value"),this.$field.removeClass("error"),acf.do_action("google_map_change",i,this.map,this.$field),this.$search.blur(),this},center:function(){var e=this.map.marker.getPosition(),t=this.o.lat,i=this.o.lng;e&&(t=e.lat(),i=e.lng());var a=new google.maps.LatLng(t,i);this.map.setCenter(a)},sync:function(){var e=this,t=this.map.marker.getPosition(),i=new google.maps.LatLng(t.lat(),t.lng());return this.$el.addClass("-loading"),this.geocoder.geocode({latLng:i},function(t,i){if(e.$el.removeClass("-loading"),i!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+i);if(!t[0])return void console.log("No results found");var a=t[0];e.$search.val(a.formatted_address),acf.val(e.$el.find(".input-address"),a.formatted_address)}),this},refresh:function(){if(!this.is_ready())return!1;google.maps.event.trigger(this.map,"resize"),this.center()},show:function(){var e=this,t=this.$field;setTimeout(function(){e.set("$field",t).refresh()},10)},_clear:function(e){this.$el.removeClass("-value -loading -search"),this.$search.val(""),acf.val(this.$el.find(".input-address"),""),acf.val(this.$el.find(".input-lat"),""),acf.val(this.$el.find(".input-lng"),""),this.map.marker.setVisible(!1)},_locate:function(e){var t=this;if(!navigator.geolocation)return alert(acf._e("google_map","browser_support")),this;this.$el.addClass("-loading"),navigator.geolocation.getCurrentPosition(function(e){t.$el.removeClass("-loading");var i=e.coords.latitude,a=e.coords.longitude;t.update(i,a).sync().center()})},_search:function(e){this.search()},_focus:function(e){this.$el.removeClass("-value"),this._keyup()},_blur:function(e){var t=this,i=this.$el.find(".input-address").val();i&&(this.timeout=setTimeout(function(){t.$el.addClass("-value"),t.$search.val(i)},100))},_keydown:function(e){13==e.which&&e.preventDefault()},_keyup:function(e){this.$search.val()?this.$el.addClass("-search"):this.$el.removeClass("-search")},_mousedown:function(e){var t=this;setTimeout(function(){clearTimeout(t.timeout)},1)}})}(jQuery),function($){acf.fields.image=acf.field.extend({type:"image",$el:null,$input:null,$img:null,actions:{ready:"initialize",append:"initialize"},events:{'click a[data-name="add"]':"add",'click a[data-name="edit"]':"edit",'click a[data-name="remove"]':"remove",'change input[type="file"]':"change"},focus:function(){this.$el=this.$field.find(".acf-image-uploader"),this.$input=this.$el.find('input[type="hidden"]'),this.$img=this.$el.find("img"),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},prepare:function(e){if(e=e||{},e._valid)return e;var t={url:"",alt:"",title:"",caption:"",description:"",width:0,height:0};return e.id&&(t=e.attributes,t.url=acf.maybe_get(t,"sizes."+this.o.preview_size+".url",t.url)),t._valid=!0,t},render:function(e){e=this.prepare(e),this.$img.attr({src:e.url,alt:e.alt,title:e.title});var t="";e.id&&(t=e.id),acf.val(this.$input,t),t?this.$el.addClass("has-value"):this.$el.removeClass("has-value")},add:function(){var e=this,t=this.$field,i=acf.get_closest_field(this.$field,"repeater"),a=acf.media.popup({title:acf._e("image","select"),mode:"select",type:"image",field:t.data("key"),multiple:i.exists(),library:this.o.library,mime_types:this.o.mime_types,select:function(a,n){if(n>0){var s=t.data("key"),o=t.closest(".acf-row");if(t=!1,o.nextAll(".acf-row:visible").each(function(){if(t=acf.get_field(s,$(this)))return!!t.find(".acf-image-uploader.has-value").exists()&&void(t=!1)}),!t){if(!(o=acf.fields.repeater.doFocus(i).add()))return!1;t=acf.get_field(s,o)}}e.set("$field",t).render(a)}})},edit:function(){var e=this,t=this.$field,i=this.$input.val();if(i)var a=acf.media.popup({title:acf._e("image","edit"),button:acf._e("image","update"),mode:"edit",attachment:i,select:function(i,a){e.set("$field",t).render(i)}})},remove:function(){var e={};this.render(e)},change:function(e){acf.fields.file.get_file_info(e.$el,this.$input)}})}(jQuery),function($){acf.fields.link=acf.field.extend({type:"link",active:!1,$el:null,$node:null,events:{'click a[data-name="add"]':"add",'click a[data-name="edit"]':"edit",'click a[data-name="remove"]':"remove","change .link-node":"change"},focus:function(){this.$el=this.$field.find(".acf-link"),this.$node=this.$el.find(".link-node")},add:function(e){acf.link.open(this.$node)},edit:function(e){this.add()},remove:function(e){this.val("")},change:function(e,t){var i={title:this.$node.html(),url:this.$node.attr("href"),target:this.$node.attr("target")};this.val(i)},val:function(e){e=acf.parse_args(e,{title:"",url:"",target:""}),this.$el.removeClass("-value -external"),e.url&&this.$el.addClass("-value"),"_blank"===e.target&&this.$el.addClass("-external"),this.$el.find(".link-title").html(e.title),this.$el.find(".link-url").attr("href",e.url).html(e.url),this.$el.find(".input-title").val(e.title),this.$el.find(".input-target").val(e.target),this.$el.find(".input-url").val(e.url).trigger("change"),this.$node.html(e.title),this.$node.attr("href",e.url),this.$node.attr("target",e.target)}}),acf.link=acf.model.extend({active:!1,$textarea:null,$node:null,events:{"click #wp-link-submit":"_update","wplink-open":"_open","wplink-close":"_close"},atts:function(e){return void 0!==e?(this.$node.html(e.title),this.$node.attr("href",e.url),this.$node.attr("target",e.target),this.$node.trigger("change",[e]),!0):{title:this.$node.html(),url:this.$node.attr("href"),target:this.$node.attr("target")}},inputs:function(e){return void 0!==e?($("#wp-link-text").val(e.title),$("#wp-link-url").val(e.url),$("#wp-link-target").prop("checked","_blank"===e.target),!0):{title:$("#wp-link-text").val(),url:$("#wp-link-url").val(),target:$("#wp-link-target").prop("checked")?"_blank":""}},open:function(e){var t=$('<textarea id="acf-link-textarea"></textarea>');e.before(t),this.active=!0,this.$node=e,this.$textarea=t;var i=this.atts();wpLink.open("acf-link-textarea",i.url,i.title,null),$("#wp-link-wrap").addClass("has-text-field")},reset:function(){this.active=!1,this.$textarea.remove(),this.$textarea=null,this.$node=null},_select:function(e,t){var i=this.inputs();i.title||(i.title=t.find(".item-title").text(),this.inputs(i),console.log(i))},_open:function(e){if(this.active){var t=this.atts();this.inputs(t)}},_close:function(e){this.active&&setTimeout(function(){acf.link.reset()},100)},_update:function(e){if(this.active){var t=this.inputs();this.atts(t)}}})}(jQuery),function($){acf.media=acf.model.extend({frames:[],mime_types:{},actions:{ready:"ready"},frame:function(){var e=this.frames.length-1;return!(e<0)&&this.frames[e]},destroy:function(e){e.detach(),e.dispose(),e=null,this.frames.pop()},popup:function(e){var t=acf.get("post_id"),i=!1;$.isNumeric(t)||(t=0);var a=acf.parse_args(e,{mode:"select",title:"",button:"",type:"",field:"",mime_types:"",library:"all",multiple:!1,attachment:0,post_id:t,select:function(){}});a.id&&(a.attachment=a.id);var i=this.new_media_frame(a);return this.frames.push(i),setTimeout(function(){i.open()},1),i},_get_media_frame_settings:function(e,t){return"select"===t.mode?e=this._get_select_frame_settings(e,t):"edit"===t.mode&&(e=this._get_edit_frame_settings(e,t)),e},_get_select_frame_settings:function(e,t){return t.type&&(e.library.type=t.type),"uploadedTo"===t.library&&(e.library.uploadedTo=t.post_id),e._button=acf._e("media","select"),e},_get_edit_frame_settings:function(e,t){return e.library.post__in=[t.attachment],e._button=acf._e("media","update"),e},_add_media_frame_events:function(e,t){return e.on("open",function(){this.$el.closest(".media-modal").addClass("acf-media-modal -"+t.mode)},e),e.on("content:render:edit-image",function(){var e=this.state().get("image"),t=new wp.media.view.EditImage({model:e,controller:this}).render();this.content.set(t),t.loadEditor()},e),e.on("toolbar:create:select",function(t){t.view=new wp.media.view.Toolbar.Select({text:e.options._button,controller:this})},e),e.on("select",function(){var i=e.state(),a=i.get("image"),n=i.get("selection");if(a)return void t.select.apply(e,[a,0]);if(n){var s=0;return void n.each(function(i){t.select.apply(e,[i,s]),s++})}}),e.on("close",function(){setTimeout(function(){acf.media.destroy(e)},500)}),"select"===t.mode?e=this._add_select_frame_events(e,t):"edit"===t.mode&&(e=this._add_edit_frame_events(e,t)),e},_add_select_frame_events:function(e,t){var i=this;return acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=t.field,e.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),e.on("content:activate:browse",function(){try{var a=e.content.get().toolbar,n=a.get("filters"),s=a.get("search")}catch(e){return}if("image"==t.type&&(n.filters.all.text=acf._e("image","all"),delete n.filters.audio,delete n.filters.video,$.each(n.filters,function(e,t){null===t.props.type&&(t.props.type="image")})),t.mime_types){var o=t.mime_types.split(" ").join("").split(".").join("").split(",");$.each(o,function(e,t){$.each(i.mime_types,function(e,i){if(-1!==e.indexOf(t)){var a={text:t,props:{status:null,type:i,uploadedTo:null,orderby:"date",order:"DESC"},priority:20};n.filters[i]=a}})})}"uploadedTo"==t.library&&(delete n.filters.unattached,delete n.filters.uploaded,n.$el.parent().append('<span class="acf-uploadedTo">'+acf._e("image","uploadedTo")+"</span>"),$.each(n.filters,function(e,i){i.props.uploadedTo=t.post_id})),$.each(n.filters,function(e,i){i.props._acfuploader=t.field}),s.model.attributes._acfuploader=t.field,"function"==typeof n.refresh&&n.refresh()}),e},_add_edit_frame_events:function(e,t){return e.on("open",function(){this.$el.closest(".media-modal").addClass("acf-expanded"),"browse"!=this.content.mode()&&this.content.mode("browse");var e=this.state(),i=e.get("selection"),a=wp.media.attachment(t.attachment);i.add(a)},e),e},new_media_frame:function(e){var t={title:e.title,multiple:e.multiple,library:{},states:[]};t=this._get_media_frame_settings(t,e);var i=wp.media.query(t.library);acf.isset(i,"mirroring","args")&&(i.mirroring.args._acfuploader=e.field),t.states=[new wp.media.controller.Library({library:i,multiple:t.multiple,title:t.title,priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})],acf.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage);var a=wp.media(t);return a.acf=e,a=this._add_media_frame_events(a,e)},ready:function(){var e=acf.get("wp_version"),t=acf.get("browser"),i=acf.get("post_id");acf.isset(window,"wp","media","view","settings","post")&&$.isNumeric(i)&&(wp.media.view.settings.post.id=i),t&&$("body").addClass("browser-"+t),e&&(e+="",major=e.substr(0,1),$("body").addClass("major-"+major)),acf.isset(window,"wp","media","view")&&(this.customize_Attachment(),this.customize_AttachmentFiltersAll(),this.customize_AttachmentCompat())},customize_Attachment:function(){var e=wp.media.view.Attachment.Library;wp.media.view.Attachment.Library=e.extend({render:function(){var t=acf.media.frame(),i=acf.maybe_get(this,"model.attributes.acf_errors");return t&&i&&this.$el.addClass("acf-disabled"),e.prototype.render.apply(this,arguments)},toggleSelection:function(t){var i=this.collection,a=this.options.selection,n=this.model,s=a.single(),o=acf.media.frame(),r=acf.maybe_get(this,"model.attributes.acf_errors"),l=this.controller.$el.find(".media-frame-content .media-sidebar");if(l.children(".acf-selection-error").remove(),l.children().removeClass("acf-hidden"),o&&r){var c=acf.maybe_get(this,"model.attributes.filename","");return l.children().addClass("acf-hidden"),l.prepend(['<div class="acf-selection-error">','<span class="selection-error-label">'+acf._e("restricted")+"</span>",'<span class="selection-error-filename">'+c+"</span>",'<span class="selection-error-message">'+r+"</span>","</div>"].join("")),a.reset(),void a.single(n)}e.prototype.toggleSelection.apply(this,arguments)}})},customize_AttachmentFiltersAll:function(){wp.media.view.AttachmentFilters.All.prototype.refresh=function(){this.$el.html(_.chain(this.filters).map(function(e,t){return{el:$("<option></option>").val(t).html(e.text)[0],priority:e.priority||50}},this).sortBy("priority").pluck("el").value())}},customize_AttachmentCompat:function(){var e=wp.media.view.AttachmentCompat;wp.media.view.AttachmentCompat=e.extend({add_acf_expand_button:function(){var e=this.$el.closest(".media-modal");if(!e.find(".media-frame-router .acf-expand-details").exists()){var t=$(['<a href="#" class="acf-expand-details">','<span class="is-closed"><span class="acf-icon -left small grey"></span>'+acf._e("expand_details")+"</span>",'<span class="is-open"><span class="acf-icon -right small grey"></span>'+acf._e("collapse_details")+"</span>","</a>"].join(""));t.on("click",function(t){t.preventDefault(),e.hasClass("acf-expanded")?e.removeClass("acf-expanded"):e.addClass("acf-expanded")}),e.find(".media-frame-router").append(t)}},render:function(){if(this.ignore_render)return this;var t=this;return setTimeout(function(){t.add_acf_expand_button()},0),clearTimeout(acf.media.render_timout),acf.media.render_timout=setTimeout(function(){acf.do_action("append",t.$el)},50),e.prototype.render.apply(this,arguments)},dispose:function(){return acf.do_action("remove",this.$el),e.prototype.dispose.apply(this,arguments)},save:function(e){e&&e.preventDefault();var t=acf.serialize(this.$el);this.ignore_render=!0,this.model.saveCompat(t)}})}})}(jQuery),function($){acf.fields.oembed=acf.field.extend({type:"oembed",$el:null,events:{'click [data-name="search-button"]':"_search",'click [data-name="clear-button"]':"_clear",'click [data-name="value-title"]':"_edit",'keypress [data-name="search-input"]':"_keypress",'keyup [data-name="search-input"]':"_keyup",'blur [data-name="search-input"]':"_blur"},focus:function(){this.$el=this.$field.find(".acf-oembed"),this.$search=this.$el.find('[data-name="search-input"]'),this.$input=this.$el.find('[data-name="value-input"]'),this.$title=this.$el.find('[data-name="value-title"]'),this.$embed=this.$el.find('[data-name="value-embed"]'),this.o=acf.get_data(this.$el)},maybe_search:function(){var e=this.$input.val(),t=this.$search.val();if(!t)return void this.clear();t!=e&&this.search()},search:function(){var e=this.$search.val();"http"!=e.substr(0,4)&&(e="http://"+e,this.$search.val(e)),this.$el.addClass("is-loading");var t=acf.prepare_for_ajax({action:"acf/fields/oembed/search",s:e,field_key:this.$field.data("key")});this.$el.data("xhr")&&this.$el.data("xhr").abort();var i=$.ajax({url:acf.get("ajaxurl"),data:t,type:"post",dataType:"json",context:this,success:this.search_success});this.$el.data("xhr",i)},search_success:function(e){var t=this.$search.val();if(this.$el.removeClass("is-loading"),!e||!e.html)return void this.$el.removeClass("has-value").addClass("has-error");this.$el.removeClass("has-error").addClass("has-value"),this.$input.val(t),this.$title.html(t),this.$embed.html(e.html)},clear:function(){this.$el.removeClass("has-error has-value"),this.$el.find('[data-name="search-input"]').val(""),this.$input.val(""),this.$title.html(""),this.$embed.html("")},edit:function(){this.$el.addClass("is-editing"),this.$search.val(this.$title.text()).focus()},blur:function(e){this.$el.removeClass("is-editing"),this.maybe_search()},_search:function(e){this.search()},_clear:function(e){this.clear()},_edit:function(e){this.edit()},_keypress:function(e){13==e.which&&e.preventDefault()},_keyup:function(e){this.$search.val()&&this.maybe_search()},_blur:function(e){this.blur()}})}(jQuery),function($){acf.fields.radio=acf.field.extend({type:"radio",$ul:null,actions:{ready:"initialize",append:"initialize"},events:{'click input[type="radio"]':"click"},focus:function(){this.$ul=this.$field.find(".acf-radio-list"),this.o=acf.get_data(this.$ul)},initialize:function(){this.$ul.find(".selected input").prop("checked",!0)},click:function(e){var t=e.$el,i=t.parent("label"),a=i.hasClass("selected"),n=t.val();if(this.$ul.find(".selected").removeClass("selected"),i.addClass("selected"),this.o.allow_null&&a&&(e.$el.prop("checked",!1),i.removeClass("selected"),n=!1,e.$el.trigger("change")),this.o.other_choice){var s=this.$ul.find('input[type="text"]');"other"===n?s.prop("disabled",!1).attr("name",t.attr("name")):s.prop("disabled",!0).attr("name","")}}})}(jQuery),function($){acf.fields.range=acf.field.extend({type:"range",$el:null,$range:null,$input:null,events:{"input input":"onInput","change input":"onChange"},focus:function(){this.$el=this.$field.find(".acf-range-wrap"),this.$range=this.$el.children('input[type="range"]'),this.$input=this.$el.children('input[type="number"]')},setValue:function(e){this.$input.val(e),this.$range.val(e)},onInput:function(e){this.setValue(e.$el.val())},onChange:function(e){this.setValue(e.$el.val()),"number"==e.$el.attr("type")&&this.$range.trigger("change")}})}(jQuery),function($){acf.fields.relationship=acf.field.extend({type:"relationship",$el:null,$input:null,$filters:null,$choices:null,$values:null,actions:{ready:"initialize",append:"initialize"},events:{"keypress [data-filter]":"submit_filter","change [data-filter]":"change_filter","keyup [data-filter]":"change_filter","click .choices .acf-rel-item":"add_item",'click [data-name="remove_item"]':"remove_item"},focus:function(){this.$el=this.$field.find(".acf-relationship"),this.$input=this.$el.children('input[type="hidden"]'),this.$choices=this.$el.find(".choices"),this.$values=this.$el.find(".values"),this.o=acf.get_data(this.$el)},initialize:function(){var e=this,t=this.$field,i=this.$el,a=this.$input;this.$values.children(".list").sortable({items:"li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){a.trigger("change")}}),this.$choices.children(".list").scrollTop(0).on("scroll",function(a){if(!i.hasClass("is-loading")&&!i.hasClass("is-empty")&&Math.ceil($(this).scrollTop())+$(this).innerHeight()>=$(this).get(0).scrollHeight){var n=i.data("paged")||1;i.data("paged",n+1),e.set("$field",t).fetch()}}),this.fetch()},maybe_fetch:function(){var e=this,t=this.$field;this.o.timeout&&clearTimeout(this.o.timeout);var i=setTimeout(function(){e.doFocus(t),e.fetch()},300);this.$el.data("timeout",i)},fetch:function(){var e=this,t=this.$field;this.$el.addClass("is-loading"),this.o.xhr&&(this.o.xhr.abort(),this.o.xhr=!1),this.o.action="acf/fields/relationship/query",this.o.field_key=t.data("key"),this.o.post_id=acf.get("post_id");var i=acf.prepare_for_ajax(this.o);1==i.paged&&this.$choices.children(".list").html(""),this.$choices.find("ul:last").append('<p><i class="acf-loading"></i> '+acf._e("relationship","loading")+"</p>");var a=$.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",data:i,success:function(i){e.set("$field",t).render(i)}});this.$el.data("xhr",a)},render:function(e){if(this.$el.removeClass("is-loading is-empty"),this.$choices.find("p").remove(),!e||!e.results||!e.results.length)return this.$el.addClass("is-empty"),void(1==this.o.paged&&this.$choices.children(".list").append("<p>"+acf._e("relationship","empty")+"</p>"));var t=$(this.walker(e.results));this.$values.find(".acf-rel-item").each(function(){t.find('.acf-rel-item[data-id="'+$(this).data("id")+'"]').addClass("disabled")}),this.$choices.children(".list").append(t);var i="",a=null;this.$choices.find(".acf-rel-label").each(function(){if($(this).text()==i)return a.append($(this).siblings("ul").html()),void $(this).parent().remove();i=$(this).text(),a=$(this).siblings("ul")})},walker:function(e){var t="";if($.isArray(e))for(var i in e)t+=this.walker(e[i]);else $.isPlainObject(e)&&(void 0!==e.children?(t+='<li><span class="acf-rel-label">'+e.text+'</span><ul class="acf-bl">',t+=this.walker(e.children),t+="</ul></li>"):t+='<li><span class="acf-rel-item" data-id="'+e.id+'">'+e.text+"</span></li>");return t},submit_filter:function(e){13==e.which&&e.preventDefault()},change_filter:function(e){var t=e.$el.val(),i=e.$el.data("filter");this.$el.data(i)!=t&&(this.$el.data(i,t),this.$el.data("paged",1),e.$el.is("select")?this.fetch():this.maybe_fetch())},add_item:function(e){if(this.o.max>0&&this.$values.find(".acf-rel-item").length>=this.o.max)return void alert(acf._e("relationship","max").replace("{max}",this.o.max));if(e.$el.hasClass("disabled"))return!1;e.$el.addClass("disabled");var t=["<li>",'<input type="hidden" name="'+this.$input.attr("name")+'[]" value="'+e.$el.data("id")+'" />','<span data-id="'+e.$el.data("id")+'" class="acf-rel-item">'+e.$el.html(),'<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>',"</span>","</li>"].join("");this.$values.children(".list").append(t),this.$input.trigger("change"),acf.validation.remove_error(this.$field)},remove_item:function(e){var t=e.$el.parent(),i=t.data("id");t.parent("li").remove(),this.$choices.find('.acf-rel-item[data-id="'+i+'"]').removeClass("disabled"),this.$input.trigger("change")}})}(jQuery),function($){var e,t,i;e=acf.select2=acf.model.extend({version:0,version3:null,version4:null,actions:{"ready 1":"ready"},ready:function(){this.version=this.get_version(),this.do_function("ready")},get_version:function(){return acf.maybe_get(window,"Select2")?3:acf.maybe_get(window,"jQuery.fn.select2.amd")?4:0},do_function:function(e,t){t=t||[];var i="version"+this.version;return void 0!==this[i]&&void 0!==this[i][e]&&this[i][e].apply(this,t)},get_data:function(e,t){var i=this;return t=t||[],e.children().each(function(){var e=$(this);e.is("optgroup")?t.push({text:e.attr("label"),children:i.get_data(e)}):t.push({id:e.attr("value"),text:e.text()})}),t},decode_data:function(t){return t?($.each(t,function(i,a){t[i].text=acf.decode(a.text),void 0!==a.children&&(t[i].children=e.decode_data(a.children))}),t):[]},count_data:function(e){var t=0;return e?($.each(e,function(e,i){t++,void 0!==i.children&&(t+=i.children.length)}),t):t},get_ajax_data:function(e,t,i,a){var n=acf.prepare_for_ajax({action:e.ajax_action,field_key:e.key,s:t.term||"",paged:t.page||1});return n=acf.apply_filters("select2_ajax_data",n,e,i,a)},get_ajax_results:function(e,t){var i={results:[]};return e||(e=i),void 0===e.results&&(i.results=e,e=i),e.results=this.decode_data(e.results),e=acf.apply_filters("select2_ajax_results",e,t)},get_value:function(e){var t=[],i=e.find("option:selected");return i.exists()?(i=i.sort(function(e,t){return+e.getAttribute("data-i")-+t.getAttribute("data-i")}),i.each(function(){var e=$(this);t.push({id:e.attr("value"),text:e.text(),$el:e})}),t):t},get_input_value:function(e){return e.val().split("||")},sync_input_value:function(e,t){e.val(t.val().join("||"))},add_option:function(e,t,i){
3
- e.find('option[value="'+t+'"]').length||e.append('<option value="'+t+'">'+i+"</option>")},select_option:function(e,t){e.find('option[value="'+t+'"]').prop("selected",!0),e.trigger("change")},unselect_option:function(e,t){e.find('option[value="'+t+'"]').prop("selected",!1),e.trigger("change")},init:function(e,t,i){this.do_function("init",arguments)},destroy:function(e){this.do_function("destroy",arguments)},add_value:function(e,t,i){this.do_function("add_value",arguments)},remove_value:function(e,t){this.do_function("remove_value",arguments)}}),t=e.version3={ready:function(){var e=acf.get("locale"),t=acf.get("rtl");if(l10n=acf._e("select"),l10n){var i={formatMatches:function(e){return 1===e?l10n.matches_1:l10n.matches_n.replace("%d",e)},formatNoMatches:function(){return l10n.matches_0},formatAjaxError:function(){return l10n.load_fail},formatInputTooShort:function(e,t){var i=t-e.length;return 1===i?l10n.input_too_short_1:l10n.input_too_short_n.replace("%d",i)},formatInputTooLong:function(e,t){var i=e.length-t;return 1===i?l10n.input_too_long_1:l10n.input_too_long_n.replace("%d",i)},formatSelectionTooBig:function(e){return 1===e?l10n.selection_too_long_1:l10n.selection_too_long_n.replace("%d",e)},formatLoadMore:function(){return l10n.load_more},formatSearching:function(){return l10n.searching}};$.fn.select2.locales=acf.maybe_get(window,"jQuery.fn.select2.locales",{}),$.fn.select2.locales[e]=i,$.extend($.fn.select2.defaults,i)}},set_data:function(e,t){3==this.version&&(e=e.siblings("input")),e.select2("data",t)},append_data:function(e,t){3==this.version&&(e=e.siblings("input"));var i=e.select2("data")||[];i.push(t),e.select2("data",i)},init:function(i,a,n){a=a||{},n=n||null,a=$.extend({allow_null:!1,placeholder:"",multiple:!1,ajax:!1,ajax_action:""},a);var s=i.siblings("input");if(s.exists()){var o={width:"100%",containerCssClass:"-acf",allowClear:a.allow_null,placeholder:a.placeholder,multiple:a.multiple,separator:"||",data:[],escapeMarkup:function(e){return e},formatResult:function(e,t,i,a){var n=$.fn.select2.defaults.formatResult(e,t,i,a);return e.description&&(n+=' <span class="select2-result-description">'+e.description+"</span>"),n}},r=this.get_value(i);if(a.multiple){var l=i.attr("name");o.formatSelection=function(e,t){var i='<input type="hidden" class="select2-search-choice-hidden" name="'+l+'" value="'+e.id+'"'+(s.prop("disabled")?'disabled="disabled"':"")+" />";return t.parent().append(i),e.text}}else r=acf.maybe_get(r,0,!1),!a.allow_null&&r&&s.val(r.id);a.allow_null&&i.find('option[value=""]').remove(),o.data=this.get_data(i),o.initSelection=function(e,t){t(r)},a.ajax&&(o.ajax={url:acf.get("ajaxurl"),dataType:"json",type:"post",cache:!1,quietMillis:250,data:function(t,i){var o={term:t,page:i};return e.get_ajax_data(a,o,s,n)},results:function(i,a){var n={page:a};return setTimeout(function(){t.merge_results()},1),e.get_ajax_results(i,n)}}),o.dropdownCss={"z-index":"999999999"},o.acf=a,o=acf.apply_filters("select2_args",o,i,a,n),s.select2(o);var c=s.select2("container");c.before(i),c.before(s),a.multiple&&c.find("ul.select2-choices").sortable({start:function(){s.select2("onSortStart")},stop:function(){s.select2("onSortEnd")}}),i.prop("disabled",!0).addClass("acf-disabled acf-hidden"),s.on("change",function(t){t.added&&e.add_option(i,t.added.id,t.added.text),e.select_option(i,t.val)}),acf.do_action("select2_init",s,o,a,n)}},merge_results:function(){var e="",t=null;$("#select2-drop .select2-result-with-children").each(function(){var i=$(this).children(".select2-result-label"),a=$(this).children(".select2-result-sub");if(i.text()==e)return t.append(a.children()),void $(this).remove();e=i.text(),t=a})},destroy:function(e){var t=e.siblings("input");t.data("select2")&&t.select2("destroy"),e.siblings(".select2-container").remove(),e.prop("disabled",!1).removeClass("acf-disabled acf-hidden"),t.attr("style","")},add_value:function(t,i,a){e.add_option(t,i,a),e.select_option(t,i);var n=t.siblings("input"),s={id:i,text:a};if(!t.data("multiple"))return n.select2("data",s);var o=n.select2("data")||[];return o.push(s),n.select2("data",o)},remove_value:function(t,i){e.unselect_option(t,i);var a=t.siblings("input"),n=a.select2("data");t.data("multiple")?(n=$.grep(n,function(e){return e.id!=i}),a.select2("data",n)):n&&n.id==i&&a.select2("data",null)}},i=e.version4={init:function(t,a,n){a=a||{},n=n||null,a=$.extend({allow_null:!1,placeholder:"",multiple:!1,ajax:!1,ajax_action:""},a);var s=t.siblings("input");if(s.exists()){var o={width:"100%",allowClear:a.allow_null,placeholder:a.placeholder,multiple:a.multiple,separator:"||",data:[],escapeMarkup:function(e){return e}},r=this.get_value(t);a.multiple?$.each(r,function(e,i){i.$el.detach().appendTo(t)}):r=acf.maybe_get(r,0,""),a.ajax?o.ajax={url:acf.get("ajaxurl"),delay:250,dataType:"json",type:"post",cache:!1,data:function(i){return e.get_ajax_data(a,i,t,n)},processResults:function(t,a){var n=e.get_ajax_results(t,a);return n.more&&(n.pagination={more:!0}),setTimeout(function(){i.merge_results()},1),n}}:(t.removeData("ajax"),t.removeAttr("data-ajax")),o=acf.apply_filters("select2_args",o,t,a,n),t.select2(o);var l=t.next(".select2-container");if(a.multiple){var c=l.find("ul");c.sortable({stop:function(e){c.find(".select2-selection__choice").each(function(){$($(this).data("data").element).detach().appendTo(t),s.trigger("change")})}}),t.on("select2:select",function(e){$(e.params.data.element).detach().appendTo(t)})}s.val(""),l.addClass("-acf"),acf.do_action("select2_init",t,o,a,n)}},merge_results:function(){var e=null,t=null;$('.select2-results__option[role="group"]').each(function(){var i=$(this).children("ul"),a=$(this).children("strong");if(null!==t&&a.text()==t.text())return e.append(i.children()),void $(this).remove();e=i,t=a})},add_value:function(t,i,a){e.add_option(t,i,a),e.select_option(t,i)},remove_value:function(t,i){e.unselect_option(t,i)},destroy:function(e){e.data("select2")&&e.select2("destroy"),e.siblings(".select2-container").remove()}},acf.add_select2=function(t,i){e.init(t,i)},acf.remove_select2=function(t){e.destroy(t)}}(jQuery),function($){acf.fields.select=acf.field.extend({type:"select",$select:null,actions:{ready:"render",append:"render",remove:"remove"},focus:function(){this.$select=this.$field.find("select"),this.$select.exists()&&(this.o=acf.get_data(this.$select),this.o=acf.parse_args(this.o,{ajax_action:"acf/fields/"+this.type+"/query",key:this.$field.data("key")}))},render:function(){if(!this.$select.exists()||!this.o.ui)return!1;acf.select2.init(this.$select,this.o,this.$field)},remove:function(){if(!this.$select.exists()||!this.o.ui)return!1;acf.select2.destroy(this.$select)}}),acf.fields.user=acf.fields.select.extend({type:"user"}),acf.fields.post_object=acf.fields.select.extend({type:"post_object"}),acf.fields.page_link=acf.fields.select.extend({type:"page_link"})}(jQuery),function($,e){var t=0;acf.fields.accordion=acf.field.extend({type:"accordion",$el:null,$wrap:null,actions:{prepare:"initialize",append:"initialize"},focus:function(){},initialize:function(){var e=this.$field,i=e.children(".acf-label"),a=e.children(".acf-input"),n=a.children(".acf-fields"),s=n.data();if(!e.is("td")){if(s.endpoint)return void e.remove();var o=a.children(".description");if(o.length&&i.append(o),e.is("tr")){var r=e.closest("table"),l=$('<div class="acf-accordion-title"/>'),c=$('<div class="acf-accordion-content"/>'),d=$('<table class="'+r.attr("class")+'"/>'),f=$("<tbody/>");l.append(i.html()),d.append(f),c.append(d),a.append(l),a.append(c),i.remove(),n.remove(),a.attr("colspan",2),i=l,a=c,n=f}e.addClass("acf-accordion"),i.addClass("acf-accordion-title"),a.addClass("acf-accordion-content"),t++,s.multi_expand&&e.data("multi-expand",1);var u=acf.getPreference("this.accordions")||[];void 0!==u[t-1]&&(s.open=u[t-1]),s.open&&(e.addClass("-open"),a.css("display","block")),i.prepend('<i class="acf-accordion-icon dashicons dashicons-arrow-'+(s.open?"down":"right")+'"></i>');var h=e.parent();n.addClass(h.hasClass("-left")?"-left":""),n.addClass(h.hasClass("-clear")?"-clear":""),n.append(e.nextUntil(".acf-field-accordion",".acf-field")),n.removeAttr("data-open data-multi_expand data-endpoint")}}});var i=acf.model.extend({events:{"click .acf-accordion-title":"_click"},_click:function(e){e.preventDefault(),this.toggle(e.$el.closest(".acf-accordion"))},isOpen:function(e){return e.hasClass("-open")},toggle:function(e){this.isOpen(e)?this.close(e):this.open(e)},open:function(e){e.find(".acf-accordion-content:first").slideDown().css("display","block"),e.find(".acf-accordion-icon:first").removeClass("dashicons-arrow-right").addClass("dashicons-arrow-down"),e.addClass("-open"),acf.do_action("show",e),e.data("multi-expand")||e.siblings(".acf-accordion.-open").each(function(){i.close($(this))}),acf.do_action("refresh",e)},close:function(e){e.find(".acf-accordion-content:first").slideUp(),e.find(".acf-accordion-icon:first").removeClass("dashicons-arrow-down").addClass("dashicons-arrow-right"),e.removeClass("-open"),acf.do_action("hide",e)}});$(window).on("unload",function(){var e=[];$(".acf-accordion").each(function(){var t=$(this).hasClass("-open")?1:0;e.push(t)}),e.length&&acf.setPreference("this.accordions",e)});var a=acf.model.extend({active:1,events:{"invalidField .acf-accordion":"invalidField"},invalidField:function(e){this.active&&(this.block(),i.open(e.$el))},block:function(){var e=this;this.active=0,setTimeout(function(){e.active=1},1e3)}})}(jQuery),function($){var e="hidden-by-conditional-logic",t=0,i=0,a=acf.model.extend({$fields:[],actions:{"prepare 15":"initialize","append 15":"initialize","refresh 15":"refresh"},events:{"click .acf-tab-button":"_click"},_click:function(e){e.preventDefault(),this.toggle(e.$el)},isOpen:function(e){return e.hasClass("-open")},toggle:function(e){var t=e.data("key"),i=e.parent(),a=e.closest(".acf-tab-wrap"),n=a.find(".active a"),s=a.siblings('.acf-field[data-key="'+t+'"]');if(!this.isOpen(s)){if(n.length){var o=n.data("key"),r=n.parent(),l=a.siblings('.acf-field[data-key="'+o+'"]');r.removeClass("active"),this.close(l)}i.addClass("active"),this.open(s),acf.do_action("refresh",a.parent())}},getFields:function(e){return e.nextUntil(".acf-field-tab",".acf-field")},getWrap:function(e){return e.prevAll(".acf-tab-wrap:first")},getTab:function(e,t){return e.find('a[data-key="'+t+'"]')},open:function(e){this.getFields(e).each(function(){$(this).removeClass("hidden-by-tab"),acf.do_action("show_field",$(this),"tab")})},close:function(e){this.getFields(e).each(function(){$(this).addClass("hidden-by-tab"),acf.do_action("hide_field",$(this),"tab")})},addTab:function(e){this.$fields.push(e)},initialize:function(){if(this.$fields.length){for(var e=0;e<this.$fields.length;e++)this.createTab(this.$fields[e]);this.$fields=[]}},createTab:function(e){if(e.is("td"))return!1;var a=e.children(".acf-label"),n=e.children(".acf-input"),s=this.getWrap(e),o=e.find(".acf-tab-button"),r=o.data(),l=!1;e.hide(),a.remove(),n.remove(),s.exists()&&!r.endpoint||(s=this.createTabWrap(e,r),l=!0);var c=$("<li></li>").append(o);return l?(c.addClass("active"),this.open(e)):this.close(e),""==o.html()&&c.hide(),s.find("ul").append(c),i++,((acf.getPreference("this.tabs")||[])[t-1]||0)!=i-1||l||this.toggle(o),c},createTabWrap:function(e,a){var n=e.parent(),s=!1;return n.hasClass("acf-fields")&&"left"==a.placement&&n.addClass("-sidebar"),s=$(e.is("tr")?'<tr class="acf-tab-wrap"><td colspan="2"><ul class="acf-hl acf-tab-group"></ul></td></tr>':'<div class="acf-tab-wrap -'+a.placement+'"><ul class="acf-hl acf-tab-group"></ul></div>'),e.before(s),t++,i=0,s},refresh:function(e){$(".acf-tab-wrap",e).each(function(){var e=$(this);if(e.hasClass("-left")){var t=e.parent(),i=t.is("td")?"height":"min-height",a=e.position().top+e.children("ul").outerHeight(!0)-1;t.css(i,a)}})}});acf.fields.tab=acf.field.extend({type:"tab",$el:null,$wrap:null,actions:{prepare:"initialize",append:"initialize",hide:"hide",show:"show"},focus:function(){},initialize:function(){a.addTab(this.$field)},hide:function(t,i){if("conditional_logic"==i){var n=t.data("key"),s=a.getWrap(t),o=a.getTab(s,n),r=o.parent();s.exists()&&(r.addClass(e),a.getFields(t).each(function(){acf.conditional_logic.hide_field($(this),n)}),r.hasClass("active")&&s.find("li:not(."+e+"):first a").trigger("click"))}},show:function(t,i){if("conditional_logic"==i){var n=t.data("key"),s=a.getWrap(t),o=a.getTab(s,n),r=o.parent();if(s.exists()){r.removeClass(e),a.getFields(t).each(function(){acf.conditional_logic.show_field($(this),n)});var l=r.siblings(".active");l.exists()&&!l.hasClass(e)||a.toggle(o)}}}}),$(window).on("unload",function(){var e=[];$(".acf-tab-wrap").each(function(){var t=$(this).find(".active").index()||0;e.push(t)}),e.length&&acf.setPreference("this.tabs",e)});var n=acf.model.extend({active:1,actions:{invalid_field:"invalid_field"},invalid_field:function(e){if(this.active&&e.hasClass("hidden-by-tab")){var t=this,i=e.prevAll(".acf-field-tab:first");e.prevAll(".acf-tab-wrap:first").find('a[data-key="'+i.data("key")+'"]').trigger("click"),this.active=0,setTimeout(function(){t.active=1},1e3)}}})}(jQuery),function($){acf.fields.time_picker=acf.field.extend({type:"time_picker",$el:null,$input:null,$hidden:null,o:{},actions:{ready:"initialize",append:"initialize"},events:{'blur input[type="text"]':"blur"},focus:function(){this.$el=this.$field.find(".acf-time-picker"),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){if(void 0!==$.timepicker){var e={timeFormat:this.o.time_format,altField:this.$hidden,altFieldTimeOnly:!1,altTimeFormat:"HH:mm:ss",showButtonPanel:!0,controlType:"select",oneLine:!0,closeText:acf._e("date_time_picker","selectText")};e.onClose=function(e,t){var i=t.dpDiv,a=i.find(".ui-datepicker-close");if(!e&&a.is(":hover")){if(!(e=acf.maybe_get(t,"settings.timepicker.formattedTime")))return;$.datepicker._setTime(t)}},e=acf.apply_filters("time_picker_args",e,this.$field),this.$input.timepicker(e),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />'),acf.do_action("time_picker_init",this.$input,e,this.$field)}},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.true_false=acf.field.extend({type:"true_false",$switch:null,$input:null,actions:{prepare:"render",append:"render",show:"render"},events:{"change .acf-switch-input":"_change","focus .acf-switch-input":"_focus","blur .acf-switch-input":"_blur","keypress .acf-switch-input":"_keypress"},focus:function(){this.$input=this.$field.find(".acf-switch-input"),this.$switch=this.$field.find(".acf-switch")},render:function(){if(this.$switch.exists()){var e=this.$switch.children(".acf-switch-on"),t=this.$switch.children(".acf-switch-off");width=Math.max(e.width(),t.width()),width&&(e.css("min-width",width),t.css("min-width",width))}},on:function(){this.$input.prop("checked",!0),this.$switch.addClass("-on")},off:function(){this.$input.prop("checked",!1),this.$switch.removeClass("-on")},_change:function(e){e.$el.prop("checked")?this.on():this.off()},_focus:function(e){this.$switch.addClass("-focus")},_blur:function(e){this.$switch.removeClass("-focus")},_keypress:function(e){return 37===e.keyCode?this.off():39===e.keyCode?this.on():void 0}})}(jQuery),function($){acf.fields.taxonomy=acf.field.extend({type:"taxonomy",$el:null,actions:{ready:"render",append:"render",remove:"remove"},events:{'click a[data-name="add"]':"add_term"},focus:function(){this.$el=this.$field.find(".acf-taxonomy-field"),this.o=acf.get_data(this.$el,{save:"",type:"",taxonomy:""}),this.o.key=this.$field.data("key")},render:function(){var e=this.$field.find("select");if(e.exists()){var t=acf.get_data(e);t=acf.parse_args(t,{pagination:!0,ajax_action:"acf/fields/taxonomy/query",key:this.o.key}),acf.select2.init(e,t)}},remove:function(){var e=this.$field.find("select");if(!e.exists())return!1;acf.select2.destroy(e)},add_term:function(e){var t=this;acf.open_popup({title:e.$el.attr("title")||e.$el.data("title"),loading:!0,height:220});var i=acf.prepare_for_ajax({action:"acf/fields/taxonomy/add_term",field_key:this.o.key});$.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"html",success:function(e){t.add_term_confirm(e)}})},add_term_confirm:function(e){var t=this;acf.update_popup({content:e}),$('#acf-popup input[name="term_name"]').focus(),$("#acf-popup form").on("submit",function(e){e.preventDefault(),t.add_term_submit($(this))})},add_term_submit:function(e){var t=this,i=e.find(".acf-submit"),a=e.find('input[name="term_name"]'),n=e.find('select[name="term_parent"]');if(""===a.val())return a.focus(),!1;i.find("button").attr("disabled","disabled"),i.find(".acf-spinner").addClass("is-active");var s=acf.prepare_for_ajax({action:"acf/fields/taxonomy/add_term",field_key:this.o.key,term_name:a.val(),term_parent:n.exists()?n.val():0});$.ajax({url:acf.get("ajaxurl"),data:s,type:"post",dataType:"json",success:function(e){var n=acf.get_ajax_message(e);acf.is_ajax_success(e)&&(a.val(""),t.append_new_term(e.data)),n.text&&i.find("span").html(n.text)},complete:function(){i.find("button").removeAttr("disabled"),i.find(".acf-spinner").removeClass("is-active"),i.find("span").delay(1500).fadeOut(250,function(){$(this).html(""),$(this).show()}),a.focus()}})},append_new_term:function(e){var t={id:e.term_id,text:e.term_label};switch($('.acf-taxonomy-field[data-taxonomy="'+this.o.taxonomy+'"]').each(function(){var t=$(this).data("type");if("radio"==t||"checkbox"==t){var i=$(this).children('input[type="hidden"]'),a=$(this).find("ul:first"),n=i.attr("name");"checkbox"==t&&(n+="[]");var s=$(['<li data-id="'+e.term_id+'">',"<label>",'<input type="'+t+'" value="'+e.term_id+'" name="'+n+'" /> ',"<span>"+e.term_label+"</span>","</label>","</li>"].join(""));if(e.term_parent){var o=a.find('li[data-id="'+e.term_parent+'"]');a=o.children("ul"),a.exists()||(a=$('<ul class="children acf-bl"></ul>'),o.append(a))}a.append(s)}}),$("#acf-popup #term_parent").each(function(){var t=$('<option value="'+e.term_id+'">'+e.term_label+"</option>");e.term_parent?$(this).children('option[value="'+e.term_parent+'"]').after(t):$(this).append(t)}),this.o.type){case"select":var i=this.$el.children("select");acf.select2.add_value(i,e.term_id,e.term_label);break;case"multi_select":var i=this.$el.children("select");acf.select2.add_value(i,e.term_id,e.term_label);break;case"checkbox":case"radio":var a=this.$el.find(".categorychecklist-holder"),n=a.find('li[data-id="'+e.term_id+'"]'),s=a.get(0).scrollTop+(n.offset().top-a.offset().top);n.find("input").prop("checked",!0),a.animate({scrollTop:s},"250");break}}})}(jQuery),function($){acf.fields.url=acf.field.extend({type:"url",$input:null,actions:{ready:"render",append:"render"},events:{'keyup input[type="url"]':"render"},focus:function(){this.$input=this.$field.find('input[type="url"]')},is_valid:function(){var e=this.$input.val();if(-1!==e.indexOf("://"));else if(0!==e.indexOf("//"))return!1;return!0},render:function(){this.is_valid()?this.$input.parent().addClass("-valid"):this.$input.parent().removeClass("-valid")}})}(jQuery),function($){acf.validation=acf.model.extend({actions:{ready:"ready",append:"ready"},filters:{validation_complete:"validation_complete"},events:{"click #save-post":"click_ignore",'click [type="submit"]':"click_publish","submit form":"submit_form","click .acf-error-message a":"click_message"},active:1,ignore:0,busy:0,valid:!0,errors:[],error_class:"acf-error",message_class:"acf-error-message",$trigger:null,ready:function(e){var t=$(".acf-field input, .acf-field textarea, .acf-field select");if(t.length){var i=this;t.on("invalid",function(e){var t=$(this),i=acf.get_field_wrap(t);i.trigger("invalidField"),acf.do_action("invalid",t),acf.do_action("invalid_field",i),acf.validation.ignore||(e.preventDefault(),acf.validation.errors.push({input:t.attr("name"),message:e.target.validationMessage}),acf.validation.fetch(t.closest("form")))})}},validation_complete:function(e,t){if(!this.errors.length)return e;e.valid=0,e.errors=e.errors||[];var a=[];if(e.errors.length)for(i in e.errors)a.push(e.errors[i].input);if(this.errors.length)for(i in this.errors){var n=this.errors[i];-1===$.inArray(n.input,a)&&e.errors.push(n)}return this.errors=[],e},click_message:function(e){e.preventDefault(),acf.remove_el(e.$el.parent())},click_ignore:function(e){var t=this;this.ignore=1,this.$trigger=e.$el,this.$form=e.$el.closest("form"),$("."+this.message_class).each(function(){acf.remove_el($(this))}),this.ignore_required_inputs(),setTimeout(function(){t.ignore=0},100)},ignore_required_inputs:function(){var e=$(".acf-field input[required], .acf-field textarea[required], .acf-field select[required]");e.length&&(e.prop("required",!1),setTimeout(function(){e.prop("required",!0)},100))},click_publish:function(e){this.$trigger=e.$el},submit_form:function(e){if(!this.active)return!0;if(this.ignore)return this.ignore=0,!0;if(!e.$el.find("#acf-form-data").exists())return!0;var t=e.$el.find("#wp-preview");if(t.exists()&&t.val())return this.toggle(e.$el,"unlock"),!0;e.preventDefault(),this.fetch(e.$el)},toggle:function(e,t){t=t||"unlock";var i=null,a=null,n=$("#submitdiv");n.exists()||(n=$("#submitpost")),n.exists()||(n=e.find("p.submit").last()),n.exists()||(n=e.find(".acf-form-submit")),n.exists()||(n=e),i=n.find('input[type="submit"], .button'),a=n.find(".spinner, .acf-spinner"),this.hide_spinner(a),"unlock"==t?this.enable_submit(i):"lock"==t&&(this.disable_submit(i),this.show_spinner(a.last()))},fetch:function(e){if(this.busy)return!1;var t=this;acf.do_action("validation_begin");var i=acf.serialize(e);i.action="acf/validate_save_post",i=acf.prepare_for_ajax(i),this.busy=1,this.toggle(e,"lock"),$.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"json",success:function(i){acf.is_ajax_success(i)&&t.fetch_success(e,i.data)},complete:function(){t.fetch_complete(e)}})},fetch_complete:function(e){if(this.busy=0,this.toggle(e,"unlock"),this.valid){this.ignore=1;var t=e.children(".acf-error-message");t.exists()&&(t.addClass("-success"),t.children("p").html(acf._e("validation_successful")),setTimeout(function(){acf.remove_el(t)},2e3)),e.find(".acf-postbox.acf-hidden").remove(),acf.do_action("submit",e),this.$trigger?this.$trigger.click():e.submit(),this.toggle(e,"lock")}},fetch_success:function(e,t){if(!(t=acf.apply_filters("validation_complete",t,e))||t.valid||!t.errors)return this.valid=!0,void acf.do_action("validation_success");this.valid=!1,this.$trigger=null,this.display_errors(t.errors,e),acf.do_action("validation_failure")},display_errors:function(e,t){if(e&&e.length){var a=t.children(".acf-error-message"),n=acf._e("validation_failed"),s=0,o=null;for(i=0;i<e.length;i++){var r=e[i];if(r.input){var l=t.find('[name="'+r.input+'"]').first();if(l.exists()||(l=t.find('[name^="'+r.input+'"]').first()),l.exists()){s++;var c=acf.get_field_wrap(l);this.add_error(c,r.message),null===o&&(o=c)}}else n+=". "+r.message}1==s?n+=". "+acf._e("validation_failed_1"):s>1&&(n+=". "+acf._e("validation_failed_2").replace("%d",s)),a.exists()||(a=$('<div class="acf-error-message"><p></p><a href="#" class="acf-icon -cancel small"></a></div>'),t.prepend(a)),a.children("p").html(n),null===o&&(o=a),setTimeout(function(){$("html, body").animate({scrollTop:o.offset().top-$(window).height()/2},500)},10)}},add_error:function(e,t){var i=this;e.addClass(this.error_class),void 0!==t&&(e.children(".acf-input").children("."+this.message_class).remove(),e.children(".acf-input").prepend('<div class="'+this.message_class+'"><p>'+t+"</p></div>"));var a=function(){i.remove_error(e),e.off("focus change","input, textarea, select",a)};e.on("focus change","input, textarea, select",a),e.trigger("invalidField"),acf.do_action("add_field_error",e),acf.do_action("invalid_field",e)},remove_error:function(e){var t=e.children(".acf-input").children("."+this.message_class);e.removeClass(this.error_class),setTimeout(function(){acf.remove_el(t)},250),acf.do_action("remove_field_error",e),acf.do_action("valid_field",e)},add_warning:function(e,t){this.add_error(e,t),setTimeout(function(){acf.validation.remove_error(e)},1e3)},show_spinner:function(e){if(e.exists()){var t=acf.get("wp_version");parseFloat(t)>=4.2?e.addClass("is-active"):e.css("display","inline-block")}},hide_spinner:function(e){if(e.exists()){var t=acf.get("wp_version");parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},disable_submit:function(e){e.exists()&&e.addClass("disabled button-disabled button-primary-disabled")},enable_submit:function(e){e.exists()&&e.removeClass("disabled button-disabled button-primary-disabled")}})}(jQuery),function($){acf.fields.wysiwyg=acf.field.extend({type:"wysiwyg",$el:null,$textarea:null,toolbars:{},events:{"mousedown .acf-editor-wrap.delay":"mousedown"},actions:{load:"initialize",append:"initialize",remove:"disable",sortstart:"disable",sortstop:"enable"},focus:function(){this.$el=this.$field.find(".wp-editor-wrap").last(),this.$textarea=this.$el.find("textarea"),this.o=acf.get_data(this.$el,{toolbar:"",active:this.$el.hasClass("tmce-active"),id:this.$textarea.attr("id")})},mousedown:function(e){e.preventDefault(),this.$el.removeClass("delay"),this.$el.find(".acf-editor-toolbar").remove(),this.initialize()},initialize:function(){if(!this.$el.hasClass("delay")){var e={tinymce:!0,quicktags:!0,toolbar:this.o.toolbar,mode:this.o.active?"visual":"text"},t=this.o.id,i=acf.get_uniqid("acf-editor-"),a=this.$el.outerHTML();a=acf.str_replace(t,i,a),this.$el.replaceWith(a),this.o.id=i,acf.tinymce.initialize(this.o.id,e,this.$field)}},disable:function(){acf.tinymce.destroy(this.o.id)},enable:function(){this.o.active&&acf.tinymce.enable(this.o.id)}}),acf.tinymce=acf.model.extend({toolbars:{},actions:{ready:"ready"},ready:function(){var e=$("#acf-hidden-wp-editor");e.exists()&&(e.appendTo("body"),acf.isset(window,"tinymce","on")&&tinymce.on("AddEditor",function(e){var t=e.editor;"acf"===t.id.substr(0,3)&&(t=tinymce.editors.content||t,tinymce.activeEditor=t,wpActiveEditor=t.id)}))},defaults:function(){return"undefined"!=typeof tinyMCEPreInit&&{tinymce:tinyMCEPreInit.mceInit.acf_content,quicktags:tinyMCEPreInit.qtInit.acf_content}},initialize:function(e,t,i){t=t||{},i=i||null,t=acf.parse_args(t,{tinymce:!0,quicktags:!0,toolbar:"full",mode:"visual"}),t.tinymce&&this.initialize_tinymce(e,t,i),t.quicktags&&this.initialize_quicktags(e,t,i)},initialize_tinymce:function(e,t,i){var a=$("#"+e),n=this.defaults(),s=this.toolbars;if("undefined"==typeof tinymce)return!1;if(!n)return!1;if(tinymce.get(e))return this.enable(e);init=$.extend({},n.tinymce,t.tinymce),init.id=e,init.selector="#"+e;var o=t.toolbar;if(o&&void 0!==s[o])for(var r=1;r<=4;r++)init["toolbar"+r]=s[o][r]||"";if(init.setup=function(t){t.on("focus",function(e){acf.validation.remove_error(i)}),t.on("change",function(e){t.save(),a.trigger("change")}),$(t.getWin()).on("unload",function(){acf.tinymce.remove(e)})},init.wp_autoresize_on=!1,init=acf.apply_filters("wysiwyg_tinymce_settings",init,e,i),tinyMCEPreInit.mceInit[e]=init,"visual"==t.mode){tinymce.init(init);var l=tinymce.get(e);acf.do_action("wysiwyg_tinymce_init",l,l.id,init,i)}},initialize_quicktags:function(e,t,i){var a=this.defaults();if("undefined"==typeof quicktags)return!1;if(!a)return!1;init=$.extend({},a.quicktags,t.quicktags),init.id=e,init=acf.apply_filters("wysiwyg_quicktags_settings",init,init.id,i),tinyMCEPreInit.qtInit[e]=init;var n=quicktags(init);this.build_quicktags(n),acf.do_action("wysiwyg_quicktags_init",n,n.id,init,i)},build_quicktags:function(e){var t,i,a,n,s,e,o,r,l,c,d=",strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,";t=e.canvas,i=e.name,a=e.settings,s="",n={},l="",c=e.id,a.buttons&&(l=","+a.buttons+",");for(r in edButtons)edButtons[r]&&(o=edButtons[r].id,l&&-1!==d.indexOf(","+o+",")&&-1===l.indexOf(","+o+",")||edButtons[r].instance&&edButtons[r].instance!==c||(n[o]=edButtons[r],edButtons[r].html&&(s+=edButtons[r].html(i+"_"))));l&&-1!==l.indexOf(",dfw,")&&(n.dfw=new QTags.DFWButton,s+=n.dfw.html(i+"_")),"rtl"===document.getElementsByTagName("html")[0].dir&&(n.textdirection=new QTags.TextDirectionButton,s+=n.textdirection.html(i+"_")),e.toolbar.innerHTML=s,e.theButtons=n,"undefined"!=typeof jQuery&&jQuery(document).triggerHandler("quicktags-init",[e])},disable:function(e){this.destroy(e)},destroy:function(e){this.destroy_tinymce(e)},destroy_tinymce:function(e){if("undefined"==typeof tinymce)return!1;var t=tinymce.get(e);return!!t&&(t.save(),t.destroy(),!0)},enable:function(e){this.enable_tinymce(e)},enable_tinymce:function(e){return"undefined"!=typeof switchEditors&&(void 0!==tinyMCEPreInit.mceInit[e]&&(switchEditors.go(e,"tmce"),!0))}})}(jQuery);
 
1
+ !function($,t){var e={};window.acf=e,e.data={},e.get=function(t){return this.data[t]||null},e.has=function(t){return null!==this.get(t)},e.set=function(t,e){return this.data[t]=e,this};var i=0;e.uniqueId=function(t){var e=++i+"";return t?t+e:e},e.uniqueArray=function(t){function e(t,e,i){return i.indexOf(t)===e}return t.filter(e)};var n="";e.uniqid=function(t,e){void 0===t&&(t="");var i,a=function(t,e){return t=parseInt(t,10).toString(16),e<t.length?t.slice(t.length-e):e>t.length?Array(e-t.length+1).join("0")+t:t};return n||(n=Math.floor(123456789*Math.random())),n++,i=t,i+=a(parseInt((new Date).getTime()/1e3,10),8),i+=a(n,5),e&&(i+=(10*Math.random()).toFixed(8).toString()),i},e.strReplace=function(t,e,i){return i.split(t).join(e)},e.strCamelCase=function(t){return t=t.replace(/[_-]/g," "),t=t.replace(/(?:^\w|\b\w|\s+)/g,function(t,e){return 0==+t?"":0==e?t.toLowerCase():t.toUpperCase()})},e.strPascalCase=function(t){var i=e.strCamelCase(t);return i.charAt(0).toUpperCase()+i.slice(1)},e.strSlugify=function(t){return e.strReplace("_","-",t.toLowerCase())},e.strSanitize=function(t){var e={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","ß":"s","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","ĝ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o"," ":"_","'":"","?":"","/":"","\\":"",".":"",",":"","`":"",">":"","<":"",'"':"","[":"","]":"","|":"","{":"","}":"","(":"",")":""},i=/\W/g,n=function(t){return e[t]||t};return t=t.replace(i,n),t=t.toLowerCase()},e.strMatch=function(t,e){for(var i=0,n=Math.min(t.length,e.length),a=0;a<n&&t[a]===e[a];a++)i++;return i},e.decode=function(t){return $("<textarea/>").html(t).text()},e.strEscape=function(t){var e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};return String(t).replace(/[&<>"'`=\/]/g,function(t){return e[t]})},e.parseArgs=function(t,e){return"object"!=typeof t&&(t={}),"object"!=typeof e&&(e={}),$.extend({},e,t)},void 0==window.acfL10n&&(acfL10n={}),e.__=function(t){return acfL10n[t]||t},e._x=function(t,e){return acfL10n[t+"."+e]||acfL10n[t]||t},e._n=function(t,i,n){return 1==n?e.__(t):e.__(i)},e.isArray=function(t){return Array.isArray(t)},e.isObject=function(t){return"object"==typeof t};var a=function(t,i,n){i=i.replace("[]","[%%index%%]");var a=i.match(/([^\[\]])+/g);if(a)for(var r=a.length,o=t,s=0;s<r;s++){var c=String(a[s]);s==r-1?"%%index%%"===c?o.push(n):o[c]=n:("%%index%%"===a[s+1]?e.isArray(o[c])||(o[c]=[]):e.isObject(o[c])||(o[c]={}),o=o[c])}};e.serialize=function(t,e){var i={},n=t.find("select, textarea, input").serializeArray();void 0!==e&&(n=n.filter(function(t){return 0===t.name.indexOf(e)}).map(function(t){return t.name=t.name.slice(e.length),t}));for(var r=0;r<n.length;r++)a(i,n[r].name,n[r].value);return i},e.addAction=function(t,i,n,a){return e.hooks.addAction.apply(this,arguments),this},e.removeAction=function(t,i){return e.hooks.removeAction.apply(this,arguments),this};var r={};e.doAction=function(t){return r[t]=1,e.hooks.doAction.apply(this,arguments),r[t]=0,this},e.doingAction=function(t){return 1===r[t]},e.didAction=function(t){return void 0!==r[t]},e.currentAction=function(){for(var t in r)if(r[t])return t;return!1},e.addFilter=function(t){return e.hooks.addFilter.apply(this,arguments),this},e.removeFilter=function(t){return e.hooks.removeFilter.apply(this,arguments),this},e.applyFilters=function(t){return e.hooks.applyFilters.apply(this,arguments)},e.arrayArgs=function(t){return Array.prototype.slice.call(t)};var o=localStorage.getItem("acf");o=o?JSON.parse(o):{};var s=function(t){return"this."===t.substr(0,5)&&(t=t.substr(5)+"-"+e.get("post_id")),t};e.getPreference=function(t){return t=s(t),o[t]||null},e.setPreference=function(t,e){t=s(t),null===e?delete o[t]:o[t]=e,localStorage.setItem("acf",JSON.stringify(o))},e.removePreference=function(t){e.setPreference(t,null)},e.remove=function(t){t instanceof jQuery&&(t={target:t}),t=e.parseArgs(t,{target:!1,endHeight:0,complete:function(){}}),e.doAction("remove",t.target),t.target.is("tr")?l(t):c(t)};var c=function(t){var e=t.target,i=e.height(),n=e.width(),a=e.css("margin"),r=e.outerHeight(!0),o=e.attr("style")+"";e.wrap('<div class="acf-temp-remove" style="height:'+r+'px"></div>');var s=e.parent();e.css({height:i,width:n,margin:a,position:"absolute"}),setTimeout(function(){s.css({opacity:0,height:t.endHeight})},50),setTimeout(function(){e.attr("style",o),s.remove(),t.complete()},301)},l=function(t){var e=t.target,i=e.height(),n=e.children().length,a=$('<td class="acf-temp-remove" style="padding:0; height:'+i+'px" colspan="'+n+'"></td>');e.addClass("acf-remove-element"),setTimeout(function(){e.html(a)},251),setTimeout(function(){e.removeClass("acf-remove-element"),a.css({height:t.endHeight})},300),setTimeout(function(){e.remove(),t.complete()},451)};e.duplicate=function(t){t instanceof jQuery&&(t={target:t});var i=0;t=e.parseArgs(t,{target:!1,search:"",replace:"",before:function(t){},after:function(t,e){},append:function(t,e){t.after(e),i=1}}),t.target=t.target||t.$el;var n=t.target;t.search=t.search||n.attr("data-id"),t.replace=t.replace||e.uniqid(),t.before(n),e.doAction("before_duplicate",n);var a=n.clone();return e.rename({target:a,search:t.search,replace:t.replace}),a.removeClass("acf-clone"),a.find(".ui-sortable").removeClass("ui-sortable"),t.after(n,a),e.doAction("after_duplicate",n,a),t.append(n,a),e.doAction("append",a),a},e.rename=function(t){t instanceof jQuery&&(t={target:t}),t=e.parseArgs(t,{target:!1,destructive:!1,search:"",replace:""});var i=t.target,n=t.search||i.attr("data-id"),a=t.replace||e.uniqid("acf"),r=function(t,e){return e.replace(n,a)};if(t.destructive){var o=i.outerHTML();o=e.strReplace(n,a,o),i.replaceWith(o)}else i.attr("data-id",a),i.find('[id*="'+n+'"]').attr("id",r),i.find('[for*="'+n+'"]').attr("for",r),i.find('[name*="'+n+'"]').attr("name",r);return i},e.prepareForAjax=function(t){return t.nonce=e.get("nonce"),t.post_id=e.get("post_id"),t=e.applyFilters("prepare_for_ajax",t)},e.startButtonLoading=function(t){t.prop("disabled",!0),t.after(' <i class="acf-loading"></i>')},e.stopButtonLoading=function(t){t.prop("disabled",!1),t.next(".acf-loading").remove()},e.showLoading=function(t){t.append('<div class="acf-loading-overlay"><i class="acf-loading"></i></div>')},e.hideLoading=function(t){t.children(".acf-loading-overlay").remove()},e.updateUserSetting=function(t,i){var n={action:"acf/update_user_setting",name:t,value:i};$.ajax({url:e.get("ajaxurl"),data:e.prepareForAjax(n),type:"post",dataType:"html"})},e.val=function(t,e,i){var n=t.val();return e!==n&&(t.val(e),t.is("select")&&null===t.val()?(t.val(n),!1):(!0!==i&&t.trigger("change"),!0))},e.show=function(t,i){return i&&e.unlock(t,"hidden",i),!e.isLocked(t,"hidden")&&(!!t.hasClass("acf-hidden")&&(t.removeClass("acf-hidden"),!0))},e.hide=function(t,i){return i&&e.lock(t,"hidden",i),!t.hasClass("acf-hidden")&&(t.addClass("acf-hidden"),!0)},e.isHidden=function(t){return t.hasClass("acf-hidden")},e.isVisible=function(t){return!e.isHidden(t)};var d=function(t,i){return!t.hasClass("acf-disabled")&&(i&&e.unlock(t,"disabled",i),!e.isLocked(t,"disabled")&&(!!t.prop("disabled")&&(t.prop("disabled",!1),!0)))};e.enable=function(t,e){if(t.attr("name"))return d(t,e);var i=!1;return t.find("[name]").each(function(){d($(this),e)&&(i=!0)}),i};var u=function(t,i){return i&&e.lock(t,"disabled",i),!t.prop("disabled")&&(t.prop("disabled",!0),!0)};e.disable=function(t,e){if(t.attr("name"))return u(t,e);var i=!1;return t.find("[name]").each(function(){u($(this),e)&&(i=!0)}),i},e.isset=function(t){for(var e=1;e<arguments.length;e++){if(!t.hasOwnProperty(arguments[e]))return!1;t=t[arguments[e]]}return!0},e.isget=function(t){for(var e=1;e<arguments.length;e++){if(!t.hasOwnProperty(arguments[e]))return null;t=t[arguments[e]]}return t},e.getFileInputData=function(t,i){var n=t.val();if(!n)return!1;var a={url:n},r=e.isget(t[0],"files",0);if(r)if(a.size=r.size,a.type=r.type,r.type.indexOf("image")>-1){var o=window.URL||window.webkitURL,s=new Image;s.onload=function(){a.width=this.width,a.height=this.height,i(a)},s.src=o.createObjectURL(r)}else i(a);else i(a)},e.isAjaxSuccess=function(t){return t&&t.success},e.getAjaxMessage=function(t){return e.isget(t,"data","message")},e.getAjaxError=function(t){return e.isget(t,"data","error")},e.renderSelect=function(t,i){var n=t.val(),a=[],r=function(t){var i="";return t.map(function(t){var n=t.text||t.label||"",o=t.id||t.value||"";a.push(o),t.children?i+='<optgroup label="'+e.strEscape(n)+'">'+r(t.children)+"</optgroup>":i+='<option value="'+o+'"'+(t.disabled?' disabled="disabled"':"")+">"+e.strEscape(n)+"</option>"}),i};return t.html(r(i)),a.indexOf(n)>-1&&t.val(n),t.val()};var f=function(t,e){return t.data("acf-lock-"+e)||[]},h=function(t,e,i){t.data("acf-lock-"+e,i)};e.lock=function(t,e,i){var n=f(t,e);n.indexOf(i)<0&&(n.push(i),h(t,e,n))},e.unlock=function(t,e,i){var n=f(t,e),a=n.indexOf(i);return a>-1&&(n.splice(a,1),h(t,e,n)),0===n.length},e.isLocked=function(t,e){return f(t,e).length>0},$.fn.exists=function(){return $(this).length>0},$.fn.outerHTML=function(){return $(this).get(0).outerHTML},Array.prototype.indexOf||(Array.prototype.indexOf=function(t){return $.inArray(t,this)}),$(document).ready(function(){e.doAction("ready")}),$(window).on("load",function(){e.doAction("load")}),$(window).on("unload",function(){e.doAction("unload")}),$(window).on("resize",function(){e.doAction("resize")}),$(document).on("sortstart",function(t,i){e.doAction("sortstart",i.item,i.placeholder)}),$(document).on("sortstop",function(t,i){e.doAction("sortstop",i.item,i.placeholder)})}(jQuery),function(t,e){"use strict";var i=function(){function t(){return f}function e(t,e,i,n){return"string"==typeof t&&"function"==typeof e&&(i=parseInt(i||10,10),c("actions",t,e,i,n)),u}function i(){var t=Array.prototype.slice.call(arguments),e=t.shift();return"string"==typeof e&&d("actions",e,t),u}function n(t,e){return"string"==typeof t&&s("actions",t,e),u}function a(t,e,i,n){return"string"==typeof t&&"function"==typeof e&&(i=parseInt(i||10,10),c("filters",t,e,i,n)),u}function r(){var t=Array.prototype.slice.call(arguments),e=t.shift();return"string"==typeof e?d("filters",e,t):u}function o(t,e){return"string"==typeof t&&s("filters",t,e),u}function s(t,e,i,n){if(f[t][e])if(i){var a=f[t][e],r;if(n)for(r=a.length;r--;){var o=a[r];o.callback===i&&o.context===n&&a.splice(r,1)}else for(r=a.length;r--;)a[r].callback===i&&a.splice(r,1)}else f[t][e]=[]}function c(t,e,i,n,a){var r={callback:i,priority:n,context:a},o=f[t][e];o?(o.push(r),o=l(o)):o=[r],f[t][e]=o}function l(t){for(var e,i,n,a=1,r=t.length;a<r;a++){for(e=t[a],i=a;(n=t[i-1])&&n.priority>e.priority;)t[i]=t[i-1],--i;t[i]=e}return t}function d(t,e,i){var n=f[t][e];if(!n)return"filters"===t&&i[0];var a=0,r=n.length;if("filters"===t)for(;a<r;a++)i[0]=n[a].callback.apply(n[a].context,i);else for(;a<r;a++)n[a].callback.apply(n[a].context,i);return"filters"!==t||i[0]}var u={removeFilter:o,applyFilters:r,addFilter:a,removeAction:n,doAction:i,addAction:e,storage:t},f={actions:{},filters:{}};return u};acf.hooks=new i}(window),function($,t){var e=/^(\S+)\s*(.*)$/,i=function(t){var e=this,i;return i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},$.extend(i,e),i.prototype=Object.create(e.prototype),$.extend(i.prototype,t),i.prototype.constructor=i,i},n=acf.Model=function(){this.cid=acf.uniqueId("acf"),this.data=$.extend(!0,{},this.data),this.setup.apply(this,arguments),this.$el&&!this.$el.data("acf")&&this.$el.data("acf",this);var t=function(){this.initialize(),this.addEvents(),this.addActions(),this.addFilters()};this.wait&&!acf.didAction(this.wait)?this.addAction(this.wait,t):t.apply(this)};$.extend(n.prototype,{id:"",cid:"",$el:null,data:{},busy:!1,changed:!1,events:{},actions:{},filters:{},eventScope:"",wait:!1,priority:10,get:function(t){return this.data[t]},has:function(t){return null!=this.get(t)},set:function(t,e,i){return this.get(t)==e?this:(this.data[t]=e,i||(this.changed=!0,this.trigger("changed:"+t,[e]),this.trigger("changed",[t,e])),this)},inherit:function(t){return t instanceof jQuery&&(t=t.data()),$.extend(this.data,t),this},prop:function(){return this.$el.prop.apply(this.$el,arguments)},setup:function(t){$.extend(this,t)},initialize:function(){},addElements:function(t){if(!(t=t||this.elements||null)||!Object.keys(t).length)return!1;for(var e in t)this.addElement(e,t[e])},addElement:function(t,e){this["$"+t]=this.$(e)},addEvents:function(t){if(!(t=t||this.events||null))return!1;for(var i in t){var n=i.match(e);this.on(n[1],n[2],t[i])}},removeEvents:function(t){if(!(t=t||this.events||null))return!1;for(var i in t){var n=i.match(e);this.off(n[1],n[2],t[i])}},getEventTarget:function(t,e){return t||this.$el||$(document)},validateEvent:function(t){return!this.eventScope||$(t.target).closest(this.eventScope).is(this.$el)},proxyEvent:function(t){return this.proxy(function(e){if(this.validateEvent(e)){var i=acf.arrayArgs(arguments),n=i.slice(1),a=[e,$(e.currentTarget)].concat(n);t.apply(this,a)}})},on:function(t,e,i,n){var a,r,o,s,c;t instanceof jQuery?n?(a=t,r=e,o=i,s=n):(a=t,r=e,s=i):i?(r=t,o=e,s=i):(r=t,s=e),a=this.getEventTarget(a),"string"==typeof s&&(s=this.proxyEvent(this[s])),r=r+"."+this.cid,c=o?[r,o,s]:[r,s],a.on.apply(a,c)},off:function(t,e,i){var n,a,r,o;t instanceof jQuery?i?(n=t,a=e,r=i):(n=t,a=e):e?(a=t,r=e):a=t,n=this.getEventTarget(n),a=a+"."+this.cid,o=r?[a,r]:[a],n.off.apply(n,o)},trigger:function(t,e,i){var n=this.getEventTarget();return i?n.trigger.apply(n,arguments):n.triggerHandler.apply(n,arguments),this},addActions:function(t){if(!(t=t||this.actions||null))return!1;for(var e in t)this.addAction(e,t[e])},removeActions:function(t){if(!(t=t||this.actions||null))return!1;for(var e in t)this.removeAction(e,t[e])},addAction:function(t,e,i){i=i||this.priority,"string"==typeof e&&(e=this[e]),acf.addAction(t,e,i,this)},removeAction:function(t,e){acf.removeAction(t,this[e])},addFilters:function(t){if(!(t=t||this.filters||null))return!1;for(var e in t)this.addFilter(e,t[e])},addFilter:function(t,e,i){i=i||this.priority,"string"==typeof e&&(e=this[e]),acf.addFilter(t,e,i,this)},removeFilters:function(t){if(!(t=t||this.filters||null))return!1;for(var e in t)this.removeFilter(e,t[e])},removeFilter:function(t,e){acf.removeFilter(t,this[e])},$:function(t){return this.$el.find(t)},remove:function(){this.removeEvents(),this.removeActions(),this.removeFilters(),this.$el.remove()},setTimeout:function(t,e){return setTimeout(this.proxy(t),e)},time:function(){console.time(this.id||this.cid)},timeEnd:function(){console.timeEnd(this.id||this.cid)},show:function(){acf.show(this.$el)},hide:function(){acf.hide(this.$el)},proxy:function(t){return $.proxy(t,this)}}),n.extend=i,acf.models={},acf.getInstance=function(t){return t.data("acf")},acf.getInstances=function(t){var e=[];return t.each(function(){e.push(acf.getInstance($(this)))}),e}}(jQuery),function($,t){acf.models.Popup=acf.Model.extend({data:{title:"",content:"",width:0,height:0,loading:!1},events:{'click [data-event="close"]':"onClickClose","click .acf-close-popup":"onClickClose"},setup:function(t){$.extend(this.data,t),this.$el=$(this.tmpl())},initialize:function(){this.render(),this.open()},tmpl:function(){return['<div id="acf-popup">','<div class="acf-popup-box acf-box">','<div class="title"><h3></h3><a href="#" class="acf-icon -cancel grey" data-event="close"></a></div>','<div class="inner"></div>','<div class="loading"><i class="acf-loading"></i></div>',"</div>",'<div class="bg" data-event="close"></div>',"</div>"].join("")},render:function(){var t=this.get("title"),e=this.get("content"),i=this.get("loading"),n=this.get("width"),a=this.get("height");this.title(t),this.content(e),n&&this.$(".acf-popup-box").css("width",n),a&&this.$(".acf-popup-box").css("min-height",a),this.loading(i),acf.doAction("append",this.$el)},update:function(t){this.data=acf.parseArgs(t,this.data),this.render()},title:function(t){this.$(".title:first h3").html(t)},content:function(t){this.$(".inner:first").html(t)},loading:function(t){var e=this.$(".loading:first");t?e.show():e.hide()},open:function(){$("body").append(this.$el)},close:function(){this.remove()},onClickClose:function(t,e){t.preventDefault(),this.close()}}),acf.newPopup=function(t){return new acf.models.Popup(t)}}(jQuery),function($,t){acf.unload=new acf.Model({wait:"load",active:!0,changed:!1,actions:{change_field:"startListening",validation_failure:"startListening"},events:{"submit form":"stopListening"},reset:function(){this.stopListening()},startListening:function(){!this.changed&&this.active&&(this.changed=!0,$(window).on("beforeunload",this.onUnload))},stopListening:function(){this.changed=!1,$(window).off("beforeunload",this.onUnload)},onUnload:function(){return acf.__("The changes you made will be lost if you navigate away from this page")}})}(jQuery),function($,t){var e=new acf.Model({events:{"click .acf-panel-title":"onClick"},onClick:function(t,e){t.preventDefault(),this.toggle(e.parent())},isOpen:function(t){return t.hasClass("-open")},toggle:function(t){this.isOpen(t)?this.close(t):this.open(t)},open:function(t){t.addClass("-open"),t.find(".acf-panel-title i").attr("class","dashicons dashicons-arrow-down")},close:function(t){t.removeClass("-open"),t.find(".acf-panel-title i").attr("class","dashicons dashicons-arrow-right")}})}(jQuery),function($,t){var e=acf.Model.extend({data:{text:"",type:"",timeout:0,dismiss:!0,target:!1,close:function(){}},events:{"click .acf-notice-dismiss":"onClickClose"},tmpl:function(){return'<div class="acf-notice"></div>'},setup:function(t){$.extend(this.data,t),this.$el=$(this.tmpl())},initialize:function(){this.render(),this.show()},render:function(){this.type(this.get("type")),this.html("<p>"+this.get("text")+"</p>"),this.get("dismiss")&&(this.$el.append('<a href="#" class="acf-notice-dismiss acf-icon -cancel small"></a>'),this.$el.addClass("-dismiss"));var t=this.get("timeout");t&&this.away(t)},update:function(t){$.extend(this.data,t),this.initialize()},show:function(){var t=this.get("target");t&&t.prepend(this.$el)},hide:function(){this.$el.remove()},away:function(t){this.setTimeout(function(){acf.remove(this.$el)},t)},type:function(t){var e=this.get("type");e&&this.$el.removeClass("-"+e),this.$el.addClass("-"+t),"error"==t&&this.$el.addClass("acf-error-message")},html:function(t){this.$el.html(t)},text:function(t){this.$("p").html(t)},onClickClose:function(t,e){t.preventDefault(),this.get("close").apply(this,arguments),this.remove()}});acf.newNotice=function(t){return"object"!=typeof t&&(t={text:t}),new e(t)};var i=new acf.Model({wait:"prepare",priority:1,initialize:function(){var t=$(".acf-admin-notice");t.length&&$("h1:first").after(t)}})}(jQuery),function($,t){acf.models.Postbox=acf.Model.extend({data:{id:"",key:"",style:"default",label:"top",editLink:"",editTitle:"",visibility:!0},setup:function(t){$.extend(this.data,t)},initialize:function(){var t=this.get("id"),e=$("#"+t),i=$("#"+t+"-hide"),n=i.parent();e.addClass("acf-postbox"),n.addClass("acf-postbox-toggle"),e.removeClass("hide-if-js"),n.removeClass("hide-if-js");var a=this.get("style");"default"!==a&&e.addClass(a),e.children(".inside").addClass("acf-fields").addClass("-"+this.get("label")),this.get("visibility")?i.prop("checked",!0):(e.addClass("acf-hidden"),n.addClass("acf-hidden"));var r=this.get("editLink"),o=this.get("editTitle");r&&e.children(".hndle").append('<a href="'+r+'" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="'+o+'"></a>')}}),acf.newPostbox=function(t){return new acf.models.Postbox(t)}}(jQuery),function($,t){acf.newTooltip=function(t){return"object"!=typeof t&&(t={text:t}),void 0!==t.confirmRemove?(t.textConfirm=acf.__("Remove"),t.textCancel=acf.__("Cancel"),new i(t)):void 0!==t.confirm?new i(t):new e(t)};var e=acf.Model.extend({data:{text:"",timeout:0,target:null},tmpl:function(){return'<div class="acf-tooltip"></div>'},setup:function(t){$.extend(this.data,t),this.$el=$(this.tmpl())},initialize:function(){this.render(),this.show(),this.position();var t=this.get("timeout");t&&setTimeout($.proxy(this.fade,this),t)},update:function(t){$.extend(this.data,t),this.initialize()},render:function(){this.html(this.get("text"))},show:function(){$("body").append(this.$el)},hide:function(){this.$el.remove()},fade:function(){this.$el.addClass("acf-fade-up"),this.setTimeout(function(){this.remove()},250)},html:function(t){this.$el.html(t)},position:function(){var t=this.$el,e=this.get("target");if(e){t.removeClass("right left bottom top");var i=10,n=e.outerWidth(),a=e.outerHeight(),r=e.offset().top,o=e.offset().left,s=t.outerWidth(),c=t.outerHeight(),l=r-c,d=o+n/2-s/2;d<10?(t.addClass("right"),d=o+n,l=r+a/2-c/2):d+s+10>$(window).width()?(t.addClass("left"),d=o-s,l=r+a/2-c/2):l-$(window).scrollTop()<10?(t.addClass("bottom"),l=r+a):t.addClass("top"),t.css({top:l,left:d})}}}),i=e.extend({data:{text:"",textConfirm:"",textCancel:"",target:null,targetConfirm:!0,confirm:function(){},cancel:function(){},context:!1},events:{'click [data-event="cancel"]':"onCancel",'click [data-event="confirm"]':"onConfirm"},addEvents:function(){acf.Model.prototype.addEvents.apply(this);var t=$(document),e=this.get("target");this.setTimeout(function(){this.on(t,"click","onCancel")}),this.get("targetConfirm")&&this.on(e,"click","onConfirm")},removeEvents:function(){acf.Model.prototype.removeEvents.apply(this);var t=$(document),e=this.get("target");this.off(t,"click"),this.off(e,"click")},render:function(){var t=this.get("text")||acf.__("Are you sure?"),e=this.get("textConfirm")||acf.__("Yes"),i=this.get("textCancel")||acf.__("No"),n=[t,'<a href="#" data-event="confirm">'+e+"</a>",'<a href="#" data-event="cancel">'+i+"</a>"].join(" ");this.html(n),this.$el.addClass("-confirm")},onCancel:function(t,e){t.preventDefault(),t.stopImmediatePropagation();var i=this.get("cancel"),n=this.get("context")||this;i.apply(n,arguments),this.remove()},onConfirm:function(t,e){t.preventDefault(),t.stopImmediatePropagation();var i=this.get("confirm"),n=this.get("context")||this;i.apply(n,arguments),this.remove()}});acf.models.Tooltip=e,acf.models.TooltipConfirm=i;var n=new acf.Model({tooltip:!1,events:{"mouseenter .acf-js-tooltip":"showTitle","mouseup .acf-js-tooltip":"hideTitle","mouseleave .acf-js-tooltip":"hideTitle"},showTitle:function(t,e){var i=e.attr("title");i&&(e.attr("title",""),this.tooltip?this.tooltip.update({text:i,target:e}):this.tooltip=acf.newTooltip({text:i,target:e}))},hideTitle:function(t,e){this.tooltip.hide(),e.attr("title",this.tooltip.get("text"))}})}(jQuery),function($,t){var e=[];acf.Field=acf.Model.extend({type:"",eventScope:".acf-field",wait:"ready",setup:function(t){this.$el=t,this.inherit(t),this.inherit(this.$control())},val:function(t){return void 0!==t?this.setValue(t):this.prop("disabled")?null:this.getValue()},getValue:function(){return this.$input().val()},setValue:function(t){return acf.val(this.$input(),t)},__:function(t){return acf._e(this.type,t)},$control:function(){return!1},$input:function(){return this.$("[name]:first")},$inputWrap:function(){return this.$(".acf-input:first")},$labelWrap:function(){return this.$(".acf-label:first")},getInputName:function(){return this.$input().attr("name")||""},parent:function(){var t=this.parents();return!!t.length&&t[0]},parents:function(){var t=this.$el.parents(".acf-field");return acf.getFields(t)},show:function(t,e){var i=acf.show(this.$el,t);return i&&(this.prop("hidden",!1),acf.doAction("show_field",this,e)),i},hide:function(t,e){var i=acf.hide(this.$el,t);return i&&(this.prop("hidden",!0),acf.doAction("hide_field",this,e)),i},enable:function(t,e){var i=acf.enable(this.$el,t);return i&&(this.prop("disabled",!1),acf.doAction("enable_field",this,e)),i},disable:function(t,e){var i=acf.disable(this.$el,t);return i&&(this.prop("disabled",!0),acf.doAction("disable_field",this,e)),i},showEnable:function(t,e){return this.enable.apply(this,arguments),this.show.apply(this,arguments)},hideDisable:function(t,e){return this.disable.apply(this,arguments),this.hide.apply(this,arguments)},showNotice:function(t){"object"!=typeof t&&(t={text:t}),this.notice&&this.notice.remove(),t.target=this.$inputWrap(),this.notice=acf.newNotice(t)},removeNotice:function(t){this.notice&&(this.notice.away(t||0),this.notice=!1)},showError:function(t){this.$el.addClass("acf-error"),void 0!==t&&this.showNotice({text:t,type:"error",dismiss:!1}),acf.doAction("invalid_field",this),this.$el.one("focus change","input, select, textarea",$.proxy(this.removeError,this))},removeError:function(){this.$el.removeClass("acf-error"),this.removeNotice(250),acf.doAction("valid_field",this)},trigger:function(t,e,i){return"invalidField"==t&&(i=!0),acf.Model.prototype.trigger.apply(this,[t,e,i])}}),acf.newField=function(t){var e=t.data("type"),n=i(e),a=acf.models[n]||acf.Field,r=new a(t);return acf.doAction("new_field",r),r};var i=function(t){return acf.strPascalCase(t||"")+"Field"};acf.registerFieldType=function(t){var n=t.prototype,a=n.type,r=i(a);acf.models[r]=t,e.push(a)},acf.getFieldType=function(t){var e=i(t);return acf.models[e]||!1},acf.getFieldTypes=function(t){t=acf.parseArgs(t,{category:""});var i=[];return e.map(function(e){var n=acf.getFieldType(e),a=n.prototype;t.category&&a.category!==t.category||i.push(n)}),i}}(jQuery),function($,t){acf.findFields=function(t){var e=".acf-field",i=!1;return t=acf.parseArgs(t,{key:"",name:"",type:"",is:"",parent:!1,sibling:!1,limit:!1,visible:!1,suppressFilters:!1}),t.suppressFilters||(t=acf.applyFilters("find_fields_args",t)),t.key&&(e+='[data-key="'+t.key+'"]'),t.type&&(e+='[data-type="'+t.type+'"]'),t.name&&(e+='[data-name="'+t.name+'"]'),t.is&&(e+=t.is),t.visible&&(e+=":visible"),i=t.parent?t.parent.find(e):t.sibling?t.sibling.siblings(e):$(e),t.suppressFilters||(i=i.not(".acf-clone .acf-field"),i=acf.applyFilters("find_fields",i)),t.limit&&(i=i.slice(0,t.limit)),i},acf.findField=function(t,e){return acf.findFields({key:t,limit:1,parent:e,suppressFilters:!0})},acf.getField=function(t){t instanceof jQuery||(t=acf.findField(t));var e=t.data("acf");return e||(e=acf.newField(t)),e},acf.getFields=function(t){t instanceof jQuery||(t=acf.findFields(t));var e=[];return t.each(function(){var t=acf.getField($(this));e.push(t)}),e},acf.findClosestField=function(t){return t.closest(".acf-field")},acf.getClosestField=function(t){var e=acf.findClosestField(t);return this.getField(e)};var e=function(t){var e=t,n=t+"_fields",a=t+"_field",r=function(t){var e=acf.arrayArgs(arguments),i=e.slice(1),a=acf.getFields({parent:t});if(a.length){var r=[n,a].concat(i);acf.doAction.apply(null,r)}},o=function(t){var e=acf.arrayArgs(arguments),i=e.slice(1);t.map(function(t,e){var n=[a,t].concat(i);acf.doAction.apply(null,n)})};acf.addAction(e,r),acf.addAction(n,o),i(t)},i=function(t){var e=t+"_field",i=t+"Field",n=function(n){var a=acf.arrayArgs(arguments),o=a.slice(1);["type","name","key"].map(function(t){var i="/"+t+"="+n.get(t);a=[e+i,n].concat(o),acf.doAction.apply(null,a)}),r.indexOf(t)>-1&&n.trigger(i,o)};acf.addAction(e,n)},n=["prepare","ready","load","append","remove","sortstart","sortstop","show","hide","unload"],a=["valid","invalid","enable","disable","new"],r=["remove","sortstart","sortstop","show","hide","unload","valid","invalid","enable","disable"];n.map(e),a.map(i);var o=new acf.Model({id:"fieldsEventManager",events:{'click .acf-field a[href="#"]':"onClick","change .acf-field":"onChange"},onClick:function(t){t.preventDefault()},onChange:function(){$("#_acf_changed").val(1)}})}(jQuery),function($,t){var e=0,i=acf.Field.extend({type:"accordion",wait:"",$control:function(){return this.$(".acf-fields:first")},initialize:function(){if(!this.$el.is("td")){if(this.get("endpoint"))return this.remove();var t=this.$el,i=this.$labelWrap(),n=this.$inputWrap(),a=this.$control(),r=n.children(".description");if(r.length&&i.append(r),this.$el.is("tr")){var o=this.$el.closest("table"),s=$('<div class="acf-accordion-title"/>'),c=$('<div class="acf-accordion-content"/>'),l=$('<table class="'+o.attr("class")+'"/>'),d=$("<tbody/>");s.append(i.html()),l.append(d),c.append(l),n.append(s),n.append(c),i.remove(),a.remove(),n.attr("colspan",2),i=s,n=c,a=d}t.addClass("acf-accordion"),i.addClass("acf-accordion-title"),n.addClass("acf-accordion-content"),e++,this.get("multi_expand")&&t.attr("multi-expand",1);var u=acf.getPreference("this.accordions")||[];void 0!==u[e-1]&&this.set("open",u[e-1]),this.get("open")&&(t.addClass("-open"),n.css("display","block")),i.prepend('<i class="acf-accordion-icon dashicons dashicons-arrow-'+(this.get("open")?"down":"right")+'"></i>');var f=t.parent();a.addClass(f.hasClass("-left")?"-left":""),a.addClass(f.hasClass("-clear")?"-clear":""),a.append(t.nextUntil(".acf-field-accordion",".acf-field")),a.removeAttr("data-open data-multi_expand data-endpoint")}}});acf.registerFieldType(i);var n=new acf.Model({actions:{unload:"onUnload"},events:{"click .acf-accordion-title":"onClick","invalidField .acf-accordion":"onInvalidField"},isOpen:function(t){return t.hasClass("-open")},toggle:function(t){this.isOpen(t)?this.close(t):this.open(t)},open:function(t){t.find(".acf-accordion-content:first").slideDown().css("display","block"),t.find(".acf-accordion-icon:first").removeClass("dashicons-arrow-right").addClass("dashicons-arrow-down"),t.addClass("-open"),acf.doAction("show",t),t.attr("multi-expand")||t.siblings(".acf-accordion.-open").each(function(){n.close($(this))})},close:function(t){t.find(".acf-accordion-content:first").slideUp(),t.find(".acf-accordion-icon:first").removeClass("dashicons-arrow-down").addClass("dashicons-arrow-right"),t.removeClass("-open"),acf.doAction("hide",t)},onClick:function(t,e){t.preventDefault(),this.toggle(e.parent())},onInvalidField:function(t,e){this.busy||(this.busy=!0,this.setTimeout(function(){this.busy=!1},1e3),this.open(e))},onUnload:function(t){var e=[];$(".acf-accordion").each(function(){var t=$(this).hasClass("-open")?1:0;e.push(t)}),e.length&&acf.setPreference("this.accordions",e)}})}(jQuery),function($,t){var e=acf.Field.extend({type:"button_group",events:{'click input[type="radio"]':"onClick"},$control:function(){return this.$(".acf-button-group")},$input:function(){return this.$("input:checked")},setValue:function(t){this.$('input[value="'+t+'"]').prop("checked",!0).trigger("change")},onClick:function(t,e){var i=e.parent("label"),n=i.hasClass("selected")
2
+ ;this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"))}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"checkbox",events:{"change input":"onChange","click .acf-add-checkbox":"onClickAdd","click .acf-checkbox-toggle":"onClickToggle","click .acf-checkbox-custom":"onClickCustom"},$control:function(){return this.$(".acf-checkbox-list")},$toggle:function(){return this.$(".acf-checkbox-toggle")},$input:function(){return this.$('input[type="hidden"]')},$inputs:function(){return this.$('input[type="checkbox"]').not(".acf-checkbox-toggle")},getValue:function(){var t=[];return this.$(":checked").each(function(){t.push($(this).val())}),!!t.length&&t},onChange:function(t,e){var i=e.prop("checked"),n=this.$toggle();if(i?e.parent().addClass("selected"):e.parent().removeClass("selected"),n.length){0==this.$inputs().not(":checked").length?n.prop("checked",!0):n.prop("checked",!1)}},onClickAdd:function(t,e){var i='<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input type="text" name="'+this.getInputName()+'[]" /></li>';e.parent("li").before(i)},onClickToggle:function(t,e){var i=e.prop("checked");this.$inputs().prop("checked",i)},onClickCustom:function(t,e){var i=e.prop("checked"),n=e.next('input[type="text"]');i?n.prop("disabled",!1):(n.prop("disabled",!0),""==n.val()&&e.parent("li").remove())}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"color_picker",wait:"load",$control:function(){return this.$(".acf-color-picker")},$input:function(){return this.$('input[type="hidden"]')},$inputText:function(){return this.$('input[type="text"]')},initialize:function(){var t=this.$input(),e=this.$inputText(),i=function(i){setTimeout(function(){acf.val(t,e.val())},1)},n={defaultColor:!1,palettes:!0,hide:!0,change:i,clear:i},n=acf.applyFilters("color_picker_args",n,this);e.wpColorPicker(n)}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"date_picker",events:{'blur input[type="text"]':"onBlur"},$control:function(){return this.$(".acf-date-picker")},$input:function(){return this.$('input[type="hidden"]')},$inputText:function(){return this.$('input[type="text"]')},initialize:function(){if(this.has("save_format"))return this.initializeCompatibility();var t=this.$input(),e=this.$inputText(),i={dateFormat:this.get("date_format"),altField:t,altFormat:"yymmdd",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day")};i=acf.applyFilters("date_picker_args",i,this),acf.newDatePicker(e,i),acf.doAction("date_picker_init",e,i,this)},initializeCompatibility:function(){var t=this.$input(),e=this.$inputText();e.val(t.val());var i={dateFormat:this.get("date_format"),altField:t,altFormat:this.get("save_format"),changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day")};i=acf.applyFilters("date_picker_args",i,this);var n=i.dateFormat;i.dateFormat=this.get("save_format"),acf.newDatePicker(e,i),e.datepicker("option","dateFormat",n),acf.doAction("date_picker_init",e,i,this)},onBlur:function(){this.$inputText().val()||acf.val(this.$input(),"")}});acf.registerFieldType(e);var i=new acf.Model({priority:5,wait:"ready",initialize:function(){var t=acf.get("locale"),e=acf.get("rtl"),i=acf.get("datePickerL10n");return!!i&&(void 0!==$.datepicker&&(i.isRTL=e,$.datepicker.regional[t]=i,void $.datepicker.setDefaults(i)))}});acf.newDatePicker=function(t,e){if(void 0===$.datepicker)return!1;e=e||{},t.datepicker(e),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function($,t){var e=acf.models.DatePickerField.extend({type:"date_time_picker",$control:function(){return this.$(".acf-date-time-picker")},initialize:function(){var t=this.$input(),e=this.$inputText(),i={dateFormat:this.get("date_format"),timeFormat:this.get("time_format"),altField:t,altFieldTimeOnly:!1,altFormat:"yy-mm-dd",altTimeFormat:"HH:mm:ss",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day"),controlType:"select",oneLine:!0};i=acf.applyFilters("date_time_picker_args",i,this),acf.newDateTimePicker(e,i),acf.doAction("date_time_picker_init",e,i,this)}});acf.registerFieldType(e);var i=new acf.Model({priority:5,wait:"ready",initialize:function(){var t=acf.get("locale"),e=acf.get("rtl"),i=acf.get("dateTimePickerL10n");return!!i&&(void 0!==$.timepicker&&(i.isRTL=e,$.timepicker.regional[t]=i,void $.timepicker.setDefaults(i)))}});acf.newDateTimePicker=function(t,e){if(void 0===$.timepicker)return!1;e=e||{},t.datetimepicker(e),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function($,t){var e=acf.Field.extend({type:"google_map",map:!1,wait:"load",events:{'click a[data-name="clear"]':"onClickClear",'click a[data-name="locate"]':"onClickLocate",'click a[data-name="search"]':"onClickSearch","keydown .search":"onKeydownSearch","keyup .search":"onKeyupSearch","focus .search":"onFocusSearch","blur .search":"onBlurSearch",showField:"onShow"},$control:function(){return this.$(".acf-google-map")},$input:function(t){return this.$('input[data-name="'+(t||"address")+'"]')},$search:function(){return this.$(".search")},addClass:function(t){this.$control().addClass(t)},removeClass:function(t){this.$control().removeClass(t)},getValue:function(){var t={lat:"",lng:"",address:""};return this.$('input[type="hidden"]').each(function(){t[$(this).data("name")]=$(this).val()}),t.address||(t=!1),t},setValue:function(t){t=acf.parseArgs(t,{lat:"",lng:"",address:""});for(var e in t)acf.val(this.$input(e),t[e]);t.address||(t=!1),this.renderVal(t)},renderVal:function(t){t?(this.addClass("-value"),this.setPosition(t.lat,t.lng),this.map.marker.setVisible(!0)):(this.removeClass("-value"),this.map.marker.setVisible(!1)),this.$search().val(t.address)},setPosition:function(t,e){var i=this.newLatLng(t,e);return this.map.marker.setPosition(i),this.map.marker.setVisible(!0),acf.doAction("google_map_change",i,this.map,this),this.center(),this},center:function(){var t=this.map.marker.getPosition(),e=this.get("lat"),i=this.get("lng");t&&(e=t.lat(),i=t.lng());var n=this.newLatLng(e,i);this.map.setCenter(n)},getSearchVal:function(){return this.$search().val()},getCanvas:function(){return this.$(".canvas")},initialize:function(){if(!i.isReady())return void i.ready(this.initializeMap,this);this.initializeMap()},newLatLng:function(t,e){return new google.maps.LatLng(parseFloat(t),parseFloat(e))},initializeMap:function(){var t=this.get("zoom"),e=this.get("lat"),i=this.get("lng"),n={scrollwheel:!1,zoom:parseInt(t),center:this.newLatLng(e,i),mapTypeId:google.maps.MapTypeId.ROADMAP,marker:{draggable:!0,raiseOnDrag:!0},autocomplete:{}};n=acf.applyFilters("google_map_args",n,this);var a=new google.maps.Map(this.getCanvas()[0],n);this.addMapEvents(a,this);var r=acf.parseArgs(n.marker,{draggable:!0,raiseOnDrag:!0,map:a});r=acf.applyFilters("google_map_marker_args",r,this);var o=new google.maps.Marker(r);this.addMarkerEvents(o,this),a.acf=this,a.marker=o,this.map=a,acf.doAction("google_map_init",a,o,this);var s=this.getValue();this.renderVal(s)},addMapEvents:function(t,e){if(acf.isset(window,"google","maps","places","Autocomplete")){var i=t.autocomplete||{},n=new google.maps.places.Autocomplete(this.$search()[0],i);n.bindTo("bounds",t),google.maps.event.addListener(n,"place_changed",function(){e.setPlace(this.getPlace())})}google.maps.event.addListener(t,"click",function(t){var i=t.latLng.lat(),n=t.latLng.lng();e.searchPosition(i,n)})},addMarkerEvents:function(t,e){google.maps.event.addListener(t,"dragend",function(){var t=this.getPosition(),i=t.lat(),n=t.lng();e.searchPosition(i,n)})},searchPosition:function(t,e){var n=this.newLatLng(t,e),a=this.$control();this.setPosition(t,e),a.addClass("-loading");var r=$.proxy(function(i,n){a.removeClass("-loading");var r="";n!=google.maps.GeocoderStatus.OK?console.log("Geocoder failed due to: "+n):i[0]?r=i[0].formatted_address:console.log("No results found"),this.val({lat:t,lng:e,address:r})},this);i.geocoder.geocode({latLng:n},r)},setPlace:function(t){if(!t)return this;if(t.name&&!t.geometry)return this.searchAddress(t.name),this;var e=t.geometry.location.lat(),i=t.geometry.location.lng(),n=t.formatted_address;return this.setValue({lat:e,lng:i,address:n}),this},searchAddress:function(t){var e=t.split(",");if(2==e.length){var n=e[0],a=e[1];if($.isNumeric(n)&&$.isNumeric(a))return this.searchPosition(n,a)}var r=this.$control();r.addClass("-loading");var o=$.proxy(function(e,i){r.removeClass("-loading");var n="",a="";i!=google.maps.GeocoderStatus.OK?console.log("Geocoder failed due to: "+i):e[0]?(n=e[0].geometry.location.lat(),a=e[0].geometry.location.lng(),t=e[0].formatted_address):console.log("No results found"),this.val({lat:n,lng:a,address:t})},this);i.geocoder.geocode({address:t},o)},searchLocation:function(){if(!navigator.geolocation)return alert(acf.__("Sorry, this browser does not support geolocation"));var t=this.$control();t.addClass("-loading");var e=$.proxy(function(e,i){t.removeClass("-loading");var n=e.coords.latitude,a=e.coords.longitude;this.searchPosition(n,a)},this),i=function(e){t.removeClass("-loading")};navigator.geolocation.getCurrentPosition(e,i)},onClickClear:function(t,e){this.val(!1)},onClickLocate:function(t,e){this.searchLocation()},onClickSearch:function(t,e){this.searchAddress(this.$search().val())},onFocusSearch:function(t,e){this.removeClass("-value"),this.onKeyupSearch.apply(this,arguments)},onBlurSearch:function(t,e){this.setTimeout(function(){this.removeClass("-search"),e.val()&&this.addClass("-value")},100)},onKeyupSearch:function(t,e){e.val()?this.addClass("-search"):this.removeClass("-search")},onKeydownSearch:function(t,e){13==t.which&&t.preventDefault()},onMousedown:function(){},onShow:function(){if(!this.map)return!1;this.setTimeout(this.center,10)}});acf.registerFieldType(e);var i=new acf.Model({geocoder:!1,data:{status:!1},getStatus:function(){return this.get("status")},setStatus:function(t){return this.set("status",t)},isReady:function(){if("ready"==this.getStatus())return!0;if("loading"==this.getStatus())return!1;if(acf.isset(window,"google","maps","places"))return this.setStatus("ready"),!0;var t=acf.get("google_map_api");return t&&(this.setStatus("loading"),$.ajax({url:t,dataType:"script",cache:!0,context:this,success:function(){this.setStatus("ready"),this.geocoder=new google.maps.Geocoder,acf.doAction("google_map_api_loaded")}})),!1},ready:function(t,e){acf.addAction("google_map_api_loaded",t,10,e)}})}(jQuery),function($,t){var e=acf.Field.extend({type:"image",$control:function(){return this.$(".acf-image-uploader")},$input:function(){return this.$('input[type="hidden"]')},events:{'click a[data-name="add"]':"onClickAdd",'click a[data-name="edit"]':"onClickEdit",'click a[data-name="remove"]':"onClickRemove",'change input[type="file"]':"onChange"},initialize:function(){"basic"===this.get("uploader")&&this.$el.closest("form").attr("enctype","multipart/form-data")},validateAttachment:function(t){t=t||{},void 0!==t.id&&(t=t.attributes),t=acf.parseArgs(t,{url:"",alt:"",title:"",caption:"",description:"",width:0,height:0});var e=acf.isget(t,"sizes",this.get("preview_size"),"url");return null!==e&&(t.url=e),t},render:function(t){t=this.validateAttachment(t),this.$("img").attr({src:t.url,alt:t.alt,title:t.title});var e=t.id||"";this.val(e),e?this.$control().addClass("has-value"):this.$control().removeClass("has-value")},append:function(t,e){var i=function(t,e){for(var i=acf.getFields({key:t.get("key"),parent:e.$el}),n=0;n<i.length;n++)if(!i[n].val())return i[n];return!1},n=i(this,e);n||(e.$(".acf-button:last").trigger("click"),n=i(this,e)),n&&n.render(t)},selectAttachment:function(){var t=this.parent(),e=t&&"repeater"===t.get("type"),i=acf.newMediaPopup({mode:"select",type:"image",title:acf.__("Select Image"),field:this.get("key"),multiple:e,library:this.get("library"),allowedTypes:this.get("mime_types"),select:$.proxy(function(e,i){i>0?this.append(e,t):this.render(e)},this)})},editAttachment:function(){var t=this.val();if(t)var e=acf.newMediaPopup({mode:"edit",title:acf.__("Edit Image"),button:acf.__("Update Image"),attachment:t,field:this.get("key"),select:$.proxy(function(t,e){this.render(t)},this)})},removeAttachment:function(){this.render(!1)},onClickAdd:function(t,e){this.selectAttachment()},onClickEdit:function(t,e){this.editAttachment()},onClickRemove:function(t,e){this.removeAttachment()},onChange:function(t,e){var i=this.$input();acf.getFileInputData(e,function(t){i.val($.param(t))})}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.models.ImageField.extend({type:"file",$control:function(){return this.$(".acf-file-uploader")},$input:function(){return this.$('input[type="hidden"]')},validateAttachment:function(t){return t=t||{},void 0!==t.id&&(t=t.attributes),t=acf.parseArgs(t,{url:"",alt:"",title:"",filename:"",filesizeHumanReadable:"",icon:"/wp-includes/images/media/default.png"})},render:function(t){t=this.validateAttachment(t),this.$("img").attr({src:t.icon,alt:t.alt,title:t.title}),this.$('[data-name="title"]').text(t.title),this.$('[data-name="filename"]').text(t.filename).attr("href",t.url),this.$('[data-name="filesize"]').text(t.filesizeHumanReadable);var e=t.id||"";acf.val(this.$input(),e),e?this.$control().addClass("has-value"):this.$control().removeClass("has-value")},selectAttachment:function(){var t=this.parent(),e=t&&"repeater"===t.get("type"),i=acf.newMediaPopup({mode:"select",title:acf.__("Select File"),field:this.get("key"),multiple:e,library:this.get("library"),allowedTypes:this.get("mime_types"),select:$.proxy(function(e,i){i>0?this.append(e,t):this.render(e)},this)})},editAttachment:function(){var t=this.val();if(!t)return!1;var e=acf.newMediaPopup({mode:"edit",title:acf.__("Edit File"),button:acf.__("Update File"),attachment:t,field:this.get("key"),select:$.proxy(function(t,e){this.render(t)},this)})}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"link",events:{'click a[data-name="add"]':"onClickEdit",'click a[data-name="edit"]':"onClickEdit",'click a[data-name="remove"]':"onClickRemove","change .link-node":"onChange"},$control:function(){return this.$(".acf-link")},$node:function(){return this.$(".link-node")},getValue:function(){var t=this.$node();return!!t.attr("href")&&{title:t.html(),url:t.attr("href"),target:t.attr("target")}},setValue:function(t){t=acf.parseArgs(t,{title:"",url:"",target:""});var e=this.$control(),i=this.$node();e.removeClass("-value -external"),t.url&&e.addClass("-value"),"_blank"===t.target&&e.addClass("-external"),this.$(".link-title").html(t.title),this.$(".link-url").attr("href",t.url).html(t.url),i.html(t.title),i.attr("href",t.url),i.attr("target",t.target),this.$(".input-title").val(t.title),this.$(".input-target").val(t.target),this.$(".input-url").val(t.url).trigger("change")},onClickEdit:function(t,e){acf.wpLink.open(this.$node())},onClickRemove:function(t,e){this.setValue(!1)},onChange:function(t,e){var i=this.getValue();this.setValue(i)}});acf.registerFieldType(e),acf.wpLink=new acf.Model({getNodeValue:function(){var t=this.get("node");return{title:t.html(),url:t.attr("href"),target:t.attr("target")}},setNodeValue:function(t){var e=this.get("node");e.html(t.title),e.attr("href",t.url),e.attr("target",t.target),e.trigger("change")},getInputValue:function(){return{title:$("#wp-link-text").val(),url:$("#wp-link-url").val(),target:$("#wp-link-target").prop("checked")?"_blank":""}},setInputValue:function(t){$("#wp-link-text").val(t.title),$("#wp-link-url").val(t.url),$("#wp-link-target").prop("checked","_blank"===t.target)},open:function(t){this.on("wplink-open","onOpen"),this.on("wplink-close","onClose"),this.set("node",t);var e=$('<textarea id="acf-link-textarea" style="display:none;"></textarea>');$("body").append(e);var i=this.getNodeValue();wpLink.open("acf-link-textarea",i.url,i.title,null)},onOpen:function(){$("#wp-link-wrap").addClass("has-text-field");var t=this.getNodeValue();this.setInputValue(t)},close:function(){wpLink.close()},onClose:function(){if(!this.has("node"))return!1;this.off("wplink-open"),this.off("wplink-close");var t=this.getInputValue();this.setNodeValue(t),$("#acf-link-textarea").remove(),this.set("node",null)}})}(jQuery),function($,t){var e=acf.Field.extend({type:"oembed",events:{'click [data-name="clear-button"]':"onClickClear","keypress .input-search":"onKeypressSearch","keyup .input-search":"onKeyupSearch","change .input-search":"onChangeSearch"},$control:function(){return this.$(".acf-oembed")},$input:function(){return this.$(".input-value")},$search:function(){return this.$(".input-search")},getValue:function(){return this.$input().val()},getSearchVal:function(){return this.$search().val()},setValue:function(t){t?this.$control().addClass("has-value"):this.$control().removeClass("has-value"),acf.val(this.$input(),t)},showLoading:function(t){acf.showLoading(this.$(".canvas"))},hideLoading:function(){acf.hideLoading(this.$(".canvas"))},maybeSearch:function(){var t=this.val(),e=this.getSearchVal();if(!e)return this.clear();if("http"!=e.substr(0,4)&&(e="http://"+e),e!==t){var i=this.get("timeout");i&&clearTimeout(i);var n=$.proxy(this.search,this,e);this.set("timeout",setTimeout(n,300))}},search:function(t){var e={action:"acf/fields/oembed/search",s:t,field_key:this.get("key")},i=this.get("xhr");i&&i.abort(),this.showLoading();var i=$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"json",context:this,success:function(t){t&&t.html||(t={url:!1,html:""}),this.val(t.url),this.$(".canvas-media").html(t.html)},complete:function(){this.hideLoading()}});this.set("xhr",i)},clear:function(){this.val(""),this.$search().val(""),this.$(".canvas-media").html("")},onClickClear:function(t,e){this.clear()},onKeypressSearch:function(t,e){13==t.which&&(t.preventDefault(),this.maybeSearch())},onKeyupSearch:function(t,e){e.val()&&this.maybeSearch()},onChangeSearch:function(t,e){this.maybeSearch()}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"radio",events:{'click input[type="radio"]':"onClick"},$control:function(){return this.$(".acf-radio-list")},$input:function(){return this.$("input:checked")},$inputText:function(){return this.$('input[type="text"]')},getValue:function(){var t=this.$input().val();return"other"===t&&(t=this.inputText().val()),t},onClick:function(t,e){var i=e.parent("label"),n=i.hasClass("selected"),a=e.val();this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"),a=!1),this.get("other_choice")&&("other"===a?this.$inputText().prop("disabled",!1):this.$inputText().prop("disabled",!0))}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"range",events:{'input input[type="range"]':"onChange","change input":"onChange"},$input:function(){return this.$('input[type="range"]')},$inputAlt:function(){return this.$('input[type="number"]')},setValue:function(t){this.busy=!0,acf.val(this.$input(),t),acf.val(this.$inputAlt(),t,!0),this.busy=!1},onChange:function(t,e){this.busy||this.setValue(e.val())}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"relationship",events:{"keypress [data-filter]":"onKeypressFilter","change [data-filter]":"onChangeFilter","keyup [data-filter]":"onChangeFilter","click .choices-list .acf-rel-item":"onClickAdd",'click [data-name="remove_item"]':"onClickRemove",mouseover:"onHover"},$control:function(){return this.$(".acf-relationship")},$list:function(t){return this.$("."+t+"-list")},$listItems:function(t){return this.$list(t).find(".acf-rel-item")},$listItem:function(t,e){return this.$list(t).find('.acf-rel-item[data-id="'+e+'"]')},getValue:function(){var t=[];return this.$listItems("values").each(function(){t.push($(this).data("id"))}),!!t.length&&t},newChoice:function(t){return["<li>",'<span data-id="'+t.id+'" class="acf-rel-item">'+t.text+"</span>","</li>"].join("")},newValue:function(t){return["<li>",'<input type="hidden" name="'+this.getInputName()+'[]" value="'+t.id+'" />','<span data-id="'+t.id+'" class="acf-rel-item">'+t.text,'<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>',"</span>","</li>"].join("")},addSortable:function(t){this.$list("values").sortable({items:"li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){t.$input().trigger("change")}})},initialize:function(){var t=this.proxy(function(t){if(!this.get("loading")&&this.get("more")){var e=this.$list("choices"),i=Math.ceil(e.scrollTop()),n=Math.ceil(e[0].scrollHeight),a=Math.ceil(e.innerHeight()),r=this.get("paged")||1;i+a>=n&&(this.set("paged",r+1),this.fetch())}});this.$list("choices").scrollTop(0).on("scroll",t),this.fetch()},onHover:function(t){$().off(t),this.addSortable(this)},onKeypressFilter:function(t,e){13==t.which&&t.preventDefault()},onChangeFilter:function(t,e){var i=e.val(),n=e.data("filter");this.get(n)!==i&&(this.set(n,i),this.set("paged",1),e.is("select")?this.fetch():this.maybeFetch())},onClickAdd:function(t,e){var i=this.val(),n=parseInt(this.get("max"));if(e.hasClass("disabled"))return!1;if(n>0&&i&&i.length>=n)return this.showNotice({text:acf.__("Maximum values reached ( {max} values )").replace("{max}",n),type:"warning"}),!1;e.addClass("disabled");var a=this.newValue({id:e.data("id"),text:e.html()});this.$list("values").append(a),this.$input().trigger("change")},onClickRemove:function(t,e){var i=e.parent(),n=i.parent(),a=i.data("id");setTimeout(function(){n.remove()},1),this.$listItem("choices",a).removeClass("disabled"),this.$input().trigger("change")},maybeFetch:function(){var t=this.get("timeout");t&&clearTimeout(t),t=this.setTimeout(this.fetch,300),this.set("timeout",t)},getAjaxData:function(){var t=this.$control().data();for(var e in t)t[e]=this.get(e);return t.action="acf/fields/relationship/query",t.field_key=this.get("key"),t},fetch:function(){var t=this.get("xhr");t&&t.abort();var e=this.getAjaxData(),i=this.$list("choices");1==e.paged&&i.html("");var n=$('<li><i class="acf-loading"></i> '+acf.__("Loading")+"</li>");i.append(n),this.set("loading",!0);var a=function(){this.set("loading",!1),n.remove()},r=function(t){if(!t||!t.results||!t.results.length)return this.set("more",!1),void(1==this.get("paged")&&this.$list("choices").append("<li>"+acf.__("No matches found")+"</li>"));this.set("more",t.more);var e=this.walkChoices(t.results),n=$(e),a=this.val();a&&a.length&&a.map(function(t){n.find('.acf-rel-item[data-id="'+t+'"]').addClass("disabled")}),i.append(n);var r=!1,o=!1;i.find(".acf-rel-label").each(function(){var t=$(this),e=t.siblings("ul");if(r&&r.text()==t.text())return o.append(e.children()),void $(this).parent().remove();r=t,o=e})},t=$.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",data:acf.prepareForAjax(e),context:this,success:r,complete:a});this.set("xhr",t)},walkChoices:function(t){var e=function(t){var i="";return $.isArray(t)?t.map(function(t){i+=e(t)}):$.isPlainObject(t)&&(void 0!==t.children?(i+='<li><span class="acf-rel-label">'+t.text+'</span><ul class="acf-bl">',i+=e(t.children),i+="</ul></li>"):i+='<li><span class="acf-rel-item" data-id="'+t.id+'">'+t.text+"</span></li>"),i};return e(t)}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"select",select2:!1,wait:"load",events:{removeField:"onRemove"},$input:function(){return this.$("select")},initialize:function(){var t=this.$input();if(this.inherit(t),this.get("ui")){var e=this.get("ajax_action");e||(e="acf/fields/"+this.get("type")+"/query"),this.select2=acf.newSelect2(t,{field:this,ajax:this.get("ajax"),multiple:this.get("multiple"),placeholder:this.get("placeholder"),allowNull:this.get("allow_null"),ajaxAction:e})}},onRemove:function(){this.select2&&this.select2.destroy()}});acf.registerFieldType(e)}(jQuery),function($,t){var e="tab",i=acf.Field.extend({type:"tab",wait:"",tabs:!1,tab:!1,findFields:function(){return this.$el.nextUntil(".acf-field-tab",".acf-field")},getFields:function(){return acf.getFields(this.findFields())},findTabs:function(){return this.$el.prevAll(".acf-tab-wrap:first")},findTab:function(){return this.$(".acf-tab-button")},initialize:function(){if(this.$el.is("td"))return this.events={},!1;var t=this.findTabs(),e=this.findTab(),i=acf.parseArgs(e.data(),{endpoint:!1,placement:"",before:this.$el});!t.length||i.endpoint?this.tabs=new a(i):this.tabs=t.data("acf"),this.tab=this.tabs.addTab(e,this)},isActive:function(){return this.tab.isActive()},showFields:function(){this.getFields().map(function(t){t.show(this.cid,"tab"),t.hiddenByTab=!1},this)},hideFields:function(){this.getFields().map(function(t){t.hide(this.cid,"tab"),t.hiddenByTab=this.tab},this)},show:function(t){var e=acf.Field.prototype.show.apply(this,arguments);return e&&(this.tab.show(),this.tabs.refresh()),e},hide:function(t){var e=acf.Field.prototype.hide.apply(this,arguments);return e&&(this.tab.hide(),this.isActive()&&this.tabs.reset()),e},enable:function(t){this.getFields().map(function(t){t.enable("tab")})},disable:function(t){this.getFields().map(function(t){t.disable("tab")})}});acf.registerFieldType(i);var n=0,a=acf.Model.extend({tabs:[],active:!1,actions:{refresh:"onRefresh"},data:{before:!1,placement:"top",index:0,initialized:!1},setup:function(t){$.extend(this.data,t),this.tabs=[],this.active=!1;var e=this.get("placement"),i=this.get("before"),a=i.parent();"left"==e&&a.hasClass("acf-fields")&&a.addClass("-sidebar"),i.is("tr")?this.$el=$('<tr class="acf-tab-wrap"><td colspan="2"><ul class="acf-hl acf-tab-group"></ul></td></tr>'):this.$el=$('<div class="acf-tab-wrap -'+e+'"><ul class="acf-hl acf-tab-group"></ul></div>'),i.before(this.$el),this.set("index",n,!0),n++},initializeTabs:function(){var t=this.getVisible().shift(),e=acf.getPreference("this.tabs")||[],i=this.get("index"),n=e[i];this.tabs[n]&&this.tabs[n].isVisible()&&(t=this.tabs[n]),t?this.selectTab(t):this.closeTabs(),this.set("initialized",!0)},getVisible:function(){return this.tabs.filter(function(t){return t.isVisible()})},getActive:function(){return this.active},setActive:function(t){return this.active=t},hasActive:function(){return!1!==this.active},isActive:function(t){var e=this.getActive();return e&&e.cid===t.cid},closeActive:function(){this.hasActive()&&this.closeTab(this.getActive())},openTab:function(t){this.closeActive(),t.open(),this.setActive(t)},closeTab:function(t){t.close(),this.setActive(!1)},closeTabs:function(){this.tabs.map(this.closeTab,this)},selectTab:function(t){this.tabs.map(function(e){t.cid!==e.cid&&this.closeTab(e)},this),this.openTab(t)},addTab:function(t,e){var i=$("<li></li>");i.append(t),this.$("ul").append(i);var n=new r({$el:i,field:e,group:this});return this.tabs.push(n),n},reset:function(){return this.closeActive(),this.refresh()},refresh:function(){if(this.hasActive())return!1;var t=this.getVisible().shift();return t&&this.openTab(t),t},onRefresh:function(){if("left"===this.get("placement")){var t=this.$el.parent(),e=this.$el.children("ul"),i=t.is("td")?"height":"min-height",n=e.position().top+e.outerHeight(!0)-1;t.css(i,n)}}}),r=acf.Model.extend({group:!1,field:!1,events:{"click a":"onClick"},index:function(){return this.$el.index()},isVisible:function(){return acf.isVisible(this.$el)},isActive:function(){return this.$el.hasClass("active")},open:function(){this.$el.addClass("active"),this.field.showFields()},close:function(){this.$el.removeClass("active"),this.field.hideFields()},onClick:function(t,e){t.preventDefault(),this.toggle()},toggle:function(){this.isActive()||this.group.openTab(this)}}),o=new acf.Model({priority:50,actions:{prepare:"render",append:"render",unload:"onUnload",invalid_field:"onInvalidField"},findTabs:function(){return $(".acf-tab-wrap")},getTabs:function(){return acf.getInstances(this.findTabs())},render:function(t){this.getTabs().map(function(t){t.get("initialized")||t.initializeTabs()})},onInvalidField:function(t){this.busy||t.hiddenByTab&&(t.hiddenByTab.toggle(),this.busy=!0,this.setTimeout(function(){this.busy=!1},100))},onUnload:function(){var t=[];this.getTabs().map(function(e){var i=e.hasActive()?e.getActive().index():0;t.push(i)}),t.length&&acf.setPreference("this.tabs",t)}})}(jQuery),function($,t){var e=acf.models.SelectField.extend({type:"post_object"});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.models.SelectField.extend({type:"page_link"});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.models.SelectField.extend({type:"user"});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"taxonomy",data:{ftype:"select"},select2:!1,wait:"load",events:{'click a[data-name="add"]':"onClickAdd",'click input[type="radio"]':"onClickRadio"},$control:function(){return this.$(".acf-taxonomy-field")},$input:function(){return this.getRelatedPrototype().$input.apply(this,arguments)},getRelatedType:function(){var t=this.get("ftype");return"multi_select"==t&&(t="select"),t},getRelatedPrototype:function(){return acf.getFieldType(this.getRelatedType()).prototype},getValue:function(){return this.getRelatedPrototype().getValue.apply(this,arguments)},setValue:function(){return this.getRelatedPrototype().setValue.apply(this,arguments)},initialize:function(){this.getRelatedPrototype().initialize.apply(this,arguments)},onRemove:function(){this.select2&&this.select2.destroy()},onClickAdd:function(t,e){var i=this,n=!1,a=!1,r=!1,o=!1,s=!1,c=!1,l=!1,d=function(t){n.loading(!1),n.content(t),a=n.$("form"),r=n.$('input[name="term_name"]'),o=n.$('select[name="term_parent"]'),s=n.$(".acf-submit-button"),r.focus(),n.on("submit","form",u)},u=function(t,e){if(t.preventDefault(),""===r.val())return r.focus(),!1;acf.startButtonLoading(s);var n={action:"acf/fields/taxonomy/add_term",field_key:i.get("key"),term_name:r.val(),term_parent:o.length?o.val():0};$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(n),type:"post",dataType:"json",success:f})},f=function(t){acf.stopButtonLoading(s),l&&l.remove(),acf.isAjaxSuccess(t)?(r.val(""),h(t.data),l=acf.newNotice({type:"success",text:acf.getAjaxMessage(t),target:a,timeout:2e3,dismiss:!1})):l=acf.newNotice({type:"error",text:acf.getAjaxError(t),target:a,timeout:2e3,dismiss:!1}),r.focus()},h=function(t){var e=$('<option value="'+t.term_id+'">'+t.term_label+"</option>");t.term_parent?o.children('option[value="'+t.term_parent+'"]').after(e):o.append(e),acf.getFields({type:"taxonomy"}).map(function(e){e.get("taxonomy")==i.get("taxonomy")&&e.appendTerm(t)}),i.selectTerm(t.term_id)};!function(){n=acf.newPopup({title:e.attr("title"),loading:!0,width:"300px"});var t={action:"acf/fields/taxonomy/add_term",field_key:i.get("key")};$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(t),type:"post",dataType:"html",success:d})}()},appendTerm:function(t){"select"==this.getRelatedType()?this.appendTermSelect(t):this.appendTermCheckbox(t)},appendTermSelect:function(t){this.select2.addOption({id:t.term_id,text:t.term_label})},appendTermCheckbox:function(t){var e=this.$("[name]:first").attr("name"),i=this.$("ul:first");"checkbox"==this.getRelatedType()&&(e+="[]");var n=$(['<li data-id="'+t.term_id+'">',"<label>",'<input type="'+this.get("ftype")+'" value="'+t.term_id+'" name="'+e+'" /> ',"<span>"+t.term_name+"</span>","</label>","</li>"].join(""));if(t.term_parent){var a=i.find('li[data-id="'+t.term_parent+'"]');i=a.children("ul"),i.exists()||(i=$('<ul class="children acf-bl"></ul>'),a.append(i))}i.append(n)},selectTerm:function(t){if("select"==this.getRelatedType())this.select2.selectOption(t);else{this.$('input[value="'+t+'"]').prop("checked",!0).trigger("change")}},onClickRadio:function(t,e){var i=e.parent("label"),n=i.hasClass("selected");this.$(".selected").removeClass("selected"),
3
+ i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"))}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.models.DatePickerField.extend({type:"time_picker",$control:function(){return this.$(".acf-time-picker")},initialize:function(){var t=this.$input(),e=this.$inputText(),i={timeFormat:this.get("time_format"),altField:t,altFieldTimeOnly:!1,altTimeFormat:"HH:mm:ss",showButtonPanel:!0,controlType:"select",oneLine:!0,closeText:acf.get("dateTimePickerL10n").selectText,timeOnly:!0};i.onClose=function(t,e,i){var n=e.dpDiv.find(".ui-datepicker-close");!t&&n.is(":hover")&&i._updateDateTime()},i=acf.applyFilters("time_picker_args",i,this),acf.newTimePicker(e,i),acf.doAction("time_picker_init",e,i,this)}});acf.registerFieldType(e),acf.newTimePicker=function(t,e){if(void 0===$.timepicker)return!1;e=e||{},t.timepicker(e),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function($,t){var e=acf.Field.extend({type:"true_false",events:{"change .acf-switch-input":"onChange","focus .acf-switch-input":"onFocus","blur .acf-switch-input":"onBlur","keypress .acf-switch-input":"onKeypress"},$input:function(){return this.$('input[type="checkbox"]')},$switch:function(){return this.$(".acf-switch")},getValue:function(){return this.$input().prop("checked")?1:0},initialize:function(){this.render()},render:function(){var t=this.$switch();if(t.length){var e=t.children(".acf-switch-on"),i=t.children(".acf-switch-off"),n=Math.max(e.width(),i.width());n&&(e.css("min-width",n),i.css("min-width",n))}},switchOn:function(){this.$input().prop("checked",!0),this.$switch().addClass("-on")},switchOff:function(){this.$input().prop("checked",!1),this.$switch().removeClass("-on")},onChange:function(t,e){e.prop("checked")?this.switchOn():this.switchOff()},onFocus:function(t,e){this.$switch().addClass("-focus")},onBlur:function(t,e){this.$switch().removeClass("-focus")},onKeypress:function(t,e){return 37===t.keyCode?this.switchOff():39===t.keyCode?this.switchOn():void 0}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"url",events:{'keyup input[type="url"]':"onkeyup"},$control:function(){return this.$(".acf-input-wrap")},$input:function(){return this.$('input[type="url"]')},initialize:function(){this.render()},isValid:function(){var t=this.val();return!!t&&(-1!==t.indexOf("://")||0===t.indexOf("//"))},render:function(){this.isValid()?this.$control().addClass("-valid"):this.$control().removeClass("-valid")},onkeyup:function(t,e){this.render()}});acf.registerFieldType(e)}(jQuery),function($,t){var e=acf.Field.extend({type:"wysiwyg",wait:"load",events:{"mousedown .acf-editor-wrap.delay":"onMousedown",sortstartField:"disableEditor",sortstopField:"enableEditor",removeField:"disableEditor"},$control:function(){return this.$(".acf-editor-wrap")},$input:function(){return this.$("textarea")},getMode:function(){return this.$control().hasClass("tmce-active")?"visual":"text"},initialize:function(){this.$control().hasClass("delay")||this.initializeEditor()},initializeEditor:function(){var t=this.$control(),e=this.$input(),i={tinymce:!0,quicktags:!0,toolbar:this.get("toolbar"),mode:this.getMode(),field:this},n=e.attr("id"),a=acf.uniqueId("acf-editor-");acf.rename({target:t,search:n,replace:a,destructive:!0}),this.set("id",a,!0),acf.tinymce.initialize(a,i)},onMousedown:function(t){t.preventDefault();var e=this.$control();e.removeClass("delay"),e.find(".acf-editor-toolbar").remove(),this.initializeEditor()},enableEditor:function(){"visual"==this.getMode()&&acf.tinymce.enable(this.get("id"))},disableEditor:function(){acf.tinymce.destroy(this.get("id"))}});acf.registerFieldType(e)}(jQuery),function($,t){var e=[];acf.Condition=acf.Model.extend({type:"",operator:"==",label:"",choiceType:"input",fieldTypes:[],data:{conditions:!1,field:!1,rule:{}},events:{change:"change",keyup:"change",enableField:"change",disableField:"change"},setup:function(t){$.extend(this.data,t)},getEventTarget:function(t,e){return t||this.get("field").$el},change:function(t,e){this.get("conditions").change(t)},match:function(t,e){return!1},calculate:function(){return this.match(this.get("rule"),this.get("field"))},choices:function(t){return'<intput type="text" />'}}),acf.newCondition=function(t,e){var i=e.get("field"),n=i.getField(t.field);if(!i||!n)return!1;var a={rule:t,target:i,conditions:e,field:n},r=n.get("type"),o=t.operator;return new(acf.getConditionTypes({fieldType:r,operator:o})[0]||acf.Condition)(a)};var i=function(t){return acf.strPascalCase(t||"")+"Condition"};acf.registerConditionType=function(t){var n=t.prototype,a=n.type,r=i(a);acf.models[r]=t,e.push(a)},acf.getConditionType=function(t){var e=i(t);return acf.models[e]||!1},acf.registerConditionForFieldType=function(t,e){var i=acf.getConditionType(t);i&&i.prototype.fieldTypes.push(e)},acf.getConditionTypes=function(t){t=acf.parseArgs(t,{fieldType:"",operator:""});var i=[];return e.map(function(e){var n=acf.getConditionType(e),a=n.prototype.fieldTypes,r=n.prototype.operator;t.fieldType&&-1===a.indexOf(t.fieldType)||t.operator&&r!==t.operator||i.push(n)}),i}}(jQuery),function($,t){var e="conditional_logic",i=new acf.Model({id:"conditionsManager",priority:20,actions:{new_field:"onNewField"},onNewField:function(t){t.has("conditions")&&t.getConditions().render()}}),n=function(t,e){var i=acf.getFields({key:e,sibling:t.$el,suppressFilters:!0});return i.length||(i=acf.getFields({key:e,parent:t.$el.parent(),suppressFilters:!0})),!!i.length&&i[0]};acf.Field.prototype.getField=function(t){var e=n(this,t);if(e)return e;for(var i=this.parents(),a=0;a<i.length;a++)if(e=n(i[a],t))return e;return!1},acf.Field.prototype.getConditions=function(){return this.conditions||(this.conditions=new r(this)),this.conditions};var a=!1,r=acf.Model.extend({id:"Conditions",data:{field:!1,timeStamp:!1,groups:[]},setup:function(t){this.data.field=t;var e=t.get("conditions");e instanceof Array?e[0]instanceof Array?e.map(function(t,e){this.addRules(t,e)},this):this.addRules(e):this.addRule(e)},change:function(t){if(this.get("timeStamp")===t.timeStamp)return!1;this.set("timeStamp",t.timeStamp,!0);var e=this.render()},render:function(){return this.calculate()?this.show():this.hide()},show:function(){return this.get("field").showEnable(this.cid,e)},hide:function(){return this.get("field").hideDisable(this.cid,e)},calculate:function(){var t=!1;return this.getGroups().map(function(e){if(!t){e.filter(function(t){return t.calculate()}).length==e.length&&(t=!0)}}),t},hasGroups:function(){return null!=this.data.groups},getGroups:function(){return this.data.groups},addGroup:function(){var t=[];return this.data.groups.push(t),t},hasGroup:function(t){return null!=this.data.groups[t]},getGroup:function(t){return this.data.groups[t]},removeGroup:function(t){return this.data.groups[t].delete,this},addRules:function(t,e){t.map(function(t){this.addRule(t,e)},this)},addRule:function(t,e){e=e||0;var i;i=this.hasGroup(e)?this.getGroup(e):this.addGroup();var n=acf.newCondition(t,this);if(!n)return!1;i.push(n)},hasRule:function(){},getRule:function(t,e){return t=t||0,e=e||0,this.data.groups[e][t]},removeRule:function(){}})}(jQuery),function($,t){var e=acf.__,i=function(t){return t?""+t:""},n=function(t,e){return i(t).toLowerCase()===i(e).toLowerCase()},a=function(t,e){return parseFloat(t)===parseFloat(e)},r=function(t,e){return parseFloat(t)>parseFloat(e)},o=function(t,e){return parseFloat(t)<parseFloat(e)},s=function(t,e){return e=e.map(function(t){return i(t)}),e.indexOf(t)>-1},c=function(t,e){return i(t).indexOf(i(e))>-1},l=function(t,e){var n=new RegExp(i(e),"gi");return i(t).match(n)},d=acf.Condition.extend({type:"hasValue",operator:"!=empty",label:e("Has any value"),fieldTypes:["text","textarea","number","range","email","url","password","image","file","wysiwyg","oembed","select","checkbox","radio","button_group","link","post_object","page_link","relationship","taxonomy","user","google_map","date_picker","date_time_picker","time_picker","color_picker"],match:function(t,e){return!!e.val()},choices:function(t){return'<input type="text" disabled="" />'}});acf.registerConditionType(d);var u=d.extend({type:"hasNoValue",operator:"==empty",label:e("Has no value"),match:function(t,e){return!d.prototype.match.apply(this,arguments)}});acf.registerConditionType(u);var f=acf.Condition.extend({type:"equalTo",operator:"==",label:e("Value is equal to"),fieldTypes:["text","textarea","number","range","email","url","password"],match:function(t,e){return $.isNumeric(t.value)?a(t.value,e.val()):n(t.value,e.val())},choices:function(t){return'<input type="text" />'}});acf.registerConditionType(f);var h=f.extend({type:"notEqualTo",operator:"!=",label:e("Value is not equal to"),match:function(t,e){return!f.prototype.match.apply(this,arguments)}});acf.registerConditionType(h);var p=acf.Condition.extend({type:"patternMatch",operator:"==pattern",label:e("Value matches pattern"),fieldTypes:["text","textarea","email","url","password","wysiwyg"],match:function(t,e){return l(e.val(),t.value)},choices:function(t){return'<input type="text" placeholder="[a-z0-9]" />'}});acf.registerConditionType(p);var g=acf.Condition.extend({type:"contains",operator:"==contains",label:e("Value contains"),fieldTypes:["text","textarea","number","email","url","password","wysiwyg","oembed"],match:function(t,e){return c(e.val(),t.value)},choices:function(t){return'<input type="text" />'}});acf.registerConditionType(g);var m=f.extend({type:"trueFalseEqualTo",choiceType:"select",fieldTypes:["true_false"],choices:function(t){return[{id:1,text:e("Checked")}]}});acf.registerConditionType(m);var v=h.extend({type:"trueFalseNotEqualTo",choiceType:"select",fieldTypes:["true_false"],choices:function(t){return[{id:1,text:e("Checked")}]}});acf.registerConditionType(v);var y=acf.Condition.extend({type:"selectEqualTo",operator:"==",label:e("Value is equal to"),fieldTypes:["select","checkbox","radio","button_group"],match:function(t,e){var i=e.val();return i instanceof Array?s(t.value,i):n(t.value,i)},choices:function(t){var i=[],n=t.$setting("choices textarea").val().split("\n");return t.$input("allow_null").prop("checked")&&i.push({id:"",text:e("Null")}),n.map(function(t){t=t.split(":"),t[1]=t[1]||t[0],i.push({id:$.trim(t[0]),text:$.trim(t[1])})}),i}});acf.registerConditionType(y);var b=y.extend({type:"selectNotEqualTo",operator:"!=",label:e("Value is not equal to"),match:function(t,e){return!y.prototype.match.apply(this,arguments)}});acf.registerConditionType(b);var x=acf.Condition.extend({type:"greaterThan",operator:">",label:e("Value is greater than"),fieldTypes:["number","range"],match:function(t,e){var i=e.val();return i instanceof Array&&(i=i.length),r(i,t.value)},choices:function(t){return'<input type="number" />'}});acf.registerConditionType(x);var w=x.extend({type:"lessThan",operator:"<",label:e("Value is less than"),match:function(t,e){var i=e.val();return i instanceof Array&&(i=i.length),o(i,t.value)},choices:function(t){return'<input type="number" />'}});acf.registerConditionType(w);var _=x.extend({type:"selectionGreaterThan",label:e("Selection is greater than"),fieldTypes:["checkbox","select","post_object","page_link","relationship","taxonomy","user"]});acf.registerConditionType(_);var k=w.extend({type:"selectionLessThan",label:e("Selection is less than"),fieldTypes:["checkbox","select","post_object","page_link","relationship","taxonomy","user"]});acf.registerConditionType(k)}(jQuery),function($,t){acf.newMediaPopup=function(t){var e=null,t=acf.parseArgs(t,{mode:"select",title:"",button:"",type:"",field:!1,allowedTypes:"",library:"all",multiple:!1,attachment:0,autoOpen:!0,open:function(){},select:function(){},close:function(){}});return e="edit"==t.mode?new acf.models.EditMediaPopup(t):new acf.models.SelectMediaPopup(t),t.autoOpen&&setTimeout(function(){e.open()},1),acf.doAction("new_media_popup",e),e};var e=function(){var t=acf.get("post_id");return $.isNumeric(t)?t:0};acf.getMimeTypes=function(){return this.get("mimeTypes")},acf.getMimeType=function(t){var e=acf.getMimeTypes();if(void 0!==e[t])return e[t];for(var i in e)if(-1!==i.indexOf(t))return e[i];return!1};var i=acf.Model.extend({id:"MediaPopup",data:{},defaults:{},frame:!1,setup:function(t){$.extend(this.data,t)},initialize:function(){var t=this.getFrameOptions();this.addFrameStates(t);var e=wp.media(t);e.acf=this,this.addFrameEvents(e,t),this.frame=e},open:function(){this.frame.open()},close:function(){this.frame.close()},remove:function(){this.frame.detach(),this.frame.remove()},getFrameOptions:function(){var t={title:this.get("title"),multiple:this.get("multiple"),library:{},states:[]};return this.get("type")&&(t.library.type=this.get("type")),"uploadedTo"===this.get("library")&&(t.library.uploadedTo=e()),this.get("attachment")&&(t.library.post__in=[this.get("attachment")]),this.get("button")&&(t.button={text:this.get("button")}),t},addFrameStates:function(t){var e=wp.media.query(t.library);this.get("field")&&acf.isset(e,"mirroring","args")&&(e.mirroring.args._acfuploader=this.get("field")),t.states.push(new wp.media.controller.Library({library:e,multiple:this.get("multiple"),title:this.get("title"),priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})),acf.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage)},addFrameEvents:function(t,e){t.on("open",function(){this.$el.closest(".media-modal").addClass("acf-media-modal -"+this.acf.get("mode"))},t),t.on("content:render:edit-image",function(){var t=this.state().get("image"),e=new wp.media.view.EditImage({model:t,controller:this}).render();this.content.set(e),e.loadEditor()},t),t.on("select",function(){var e=t.state().get("selection");e&&e.each(function(e,i){t.acf.get("select").apply(t.acf,[e,i])})}),t.on("close",function(){setTimeout(function(){t.acf.get("close").apply(t.acf),t.acf.remove()},1)})}});acf.models.SelectMediaPopup=i.extend({id:"SelectMediaPopup",setup:function(t){t.button||(t.button=acf._x("Select","verb")),i.prototype.setup.apply(this,arguments)},addFrameEvents:function(t,e){acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=this.get("field"),t.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),t.on("content:activate:browse",function(){var e=!1;try{e=t.content.get().toolbar}catch(t){return void console.log(t)}t.acf.customizeFilters.apply(t.acf,[e])}),i.prototype.addFrameEvents.apply(this,arguments)},customizeFilters:function(t){var e=t.get("filters");if("image"==this.get("type")&&(e.filters.all.text=acf.__("All images"),delete e.filters.audio,delete e.filters.video,delete e.filters.image,$.each(e.filters,function(t,e){e.props.type=e.props.type||"image"})),this.get("allowedTypes")){this.get("allowedTypes").split(" ").join("").split(".").join("").split(",").map(function(t){var i=acf.getMimeType(t);if(i){var n={text:i,props:{status:null,type:i,uploadedTo:null,orderby:"date",order:"DESC"},priority:20};e.filters[i]=n}})}if("uploadedTo"===this.get("library")){var i=this.frame.options.library.uploadedTo;delete e.filters.unattached,delete e.filters.uploaded,$.each(e.filters,function(t,e){e.text+=" ("+acf.__("Uploaded to this post")+")",e.props.uploadedTo=i})}var n=this.get("field");$.each(e.filters,function(t,e){e.props._acfuploader=n}),t.get("search").model.attributes._acfuploader=n,e.renderFilters&&e.renderFilters()}}),acf.models.EditMediaPopup=i.extend({id:"SelectMediaPopup",setup:function(t){t.button||(t.button=acf._x("Update","verb")),i.prototype.setup.apply(this,arguments)},addFrameEvents:function(t,e){t.on("open",function(){this.$el.closest(".media-modal").addClass("acf-expanded"),"browse"!=this.content.mode()&&this.content.mode("browse");var e=this.state(),i=e.get("selection"),n=wp.media.attachment(t.acf.get("attachment"));i.add(n)},t),i.prototype.addFrameEvents.apply(this,arguments)}});var n=new acf.Model({id:"customizePrototypes",wait:"ready",initialize:function(){if(acf.isset(window,"wp","media","view")){var t=e();t&&acf.isset(wp,"media","view","settings","post")&&(wp.media.view.settings.post.id=t),this.customizeAttachmentsRouter(),this.customizeAttachmentFilters(),this.customizeAttachmentCompat(),this.customizeAttachmentLibrary()}},customizeAttachmentsRouter:function(){if(acf.isset(wp,"media","view","Router")){var t=wp.media.view.Router;wp.media.view.Router=t.extend({addExpand:function(){var t=$(['<a href="#" class="acf-expand-details">','<span class="is-closed"><span class="acf-icon -left small grey"></span>'+acf.__("Expand Details")+"</span>",'<span class="is-open"><span class="acf-icon -right small grey"></span>'+acf.__("Collapse Details")+"</span>","</a>"].join(""));t.on("click",function(t){t.preventDefault();var e=$(this).closest(".media-modal");e.hasClass("acf-expanded")?e.removeClass("acf-expanded"):e.addClass("acf-expanded")}),this.$el.append(t)},initialize:function(){return t.prototype.initialize.apply(this,arguments),this.addExpand(),this}})}},customizeAttachmentFilters:function(){if(acf.isset(wp,"media","view","AttachmentFilters","All")){wp.media.view.AttachmentFilters.All.prototype.renderFilters=function(){this.$el.html(_.chain(this.filters).map(function(t,e){return{el:$("<option></option>").val(e).html(t.text)[0],priority:t.priority||50}},this).sortBy("priority").pluck("el").value())}}},customizeAttachmentCompat:function(){if(acf.isset(wp,"media","view","AttachmentCompat")){var t=wp.media.view.AttachmentCompat,e=!1;wp.media.view.AttachmentCompat=t.extend({render:function(){return this.rendered?this:(t.prototype.render.apply(this,arguments),this.$("#acf-form-data").length?(clearTimeout(e),e=setTimeout($.proxy(function(){this.rendered=!0,acf.doAction("append",this.$el)},this),50),this):this)}})}},customizeAttachmentLibrary:function(){if(acf.isset(wp,"media","view","Attachment","Library")){var t=wp.media.view.Attachment.Library;wp.media.view.Attachment.Library=t.extend({render:function(){var e=acf.isget(this,"controller","acf"),i=acf.isget(this,"model","attributes");if(e&&i){i.acf_errors&&this.$el.addClass("acf-disabled");var n=e.get("selected");n&&n.indexOf(i.id)>-1&&this.$el.addClass("acf-selected")}return t.prototype.render.apply(this,arguments)},toggleSelection:function(e){var i=this.collection,n=this.options.selection,a=this.model,r=n.single(),o=this.controller,s=acf.isget(this,"model","attributes","acf_errors"),c=o.$el.find(".media-frame-content .media-sidebar");if(c.children(".acf-selection-error").remove(),c.children().removeClass("acf-hidden"),o&&s){var l=acf.isget(this,"model","attributes","filename");return c.children().addClass("acf-hidden"),c.prepend(['<div class="acf-selection-error">','<span class="selection-error-label">'+acf.__("Restricted")+"</span>",'<span class="selection-error-filename">'+l+"</span>",'<span class="selection-error-message">'+s+"</span>","</div>"].join("")),n.reset(),void n.single(a)}return t.prototype.toggleSelection.apply(this,arguments)}})}}})}(jQuery),function($,t){acf.screen=new acf.Model({active:!0,xhr:!1,wait:"ready",events:{"change #page_template":"onChangeTemplate","change #parent_id":"onChangeParent","change #post-formats-select input":"onChangeFormat","change .categorychecklist input":"onChangeTerm","change .categorychecklist select":"onChangeTerm",'change .acf-taxonomy-field[data-save="1"] input':"onChangeTerm",'change .acf-taxonomy-field[data-save="1"] select':"onChangeTerm"},data:{},fetch:function(){if(this.active&&"post"===acf.get("screen")){this.xhr&&this.xhr.abort();var t=acf.parseArgs(this.data,{post_id:acf.get("post_id")});t.action="acf/post/get_field_groups",t.exists=[],$(".acf-postbox").not(".acf-hidden").each(function(){t.exists.push($(this).attr("id").substr(4))});var e=function(t){acf.isAjaxSuccess(t)&&($(".acf-postbox").addClass("acf-hidden"),$(".acf-postbox-toggle").addClass("acf-hidden"),$("#acf-style").html(""),t.data.map(function(t,e){var i=$("#acf-"+t.key),n=$("#acf-"+t.key+"-hide"),a=n.parent();i.removeClass("acf-hidden hide-if-js").show(),a.removeClass("acf-hidden hide-if-js").show(),n.prop("checked",!0);var r=i.find(".acf-replace-with-fields");r.exists()&&(r.replaceWith(t.html),acf.doAction("append",i)),0===e&&$("#acf-style").html(t.style),acf.enable(i,"postbox")}))},i=function(t){$(".acf-postbox.acf-hidden").each(function(){acf.disable($(this),"postbox")})};this.xhr=$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(t),type:"post",dataType:"json",context:this,success:e,complete:i})}},syncTaxonomyTerms:function(){var t=[""];$(".categorychecklist, .acf-taxonomy-field").each(function(){var e=$(this),i=e.find('input[type="checkbox"]').not(":disabled"),n=e.find('input[type="radio"]').not(":disabled"),a=e.find("select").not(":disabled"),r=e.find('input[type="hidden"]').not(":disabled");e.is(".acf-taxonomy-field")&&"1"!=e.attr("data-save")||e.closest(".media-frame").exists()||(i.exists()?i.filter(":checked").each(function(){t.push($(this).val())}):n.exists()?n.filter(":checked").each(function(){t.push($(this).val())}):a.exists()?a.find("option:selected").each(function(){t.push($(this).val())}):r.exists()&&r.each(function(){$(this).val()&&t.push($(this).val())}))}),t=t.filter(function(t,e,i){return i.indexOf(t)==e}),this.set("post_taxonomy",t).fetch()},onChangeTemplate:function(t,e){this.set("page_template",e.val()).fetch()},onChangeParent:function(t,e){var i="parent",n=0;""!=e.val()&&(i="child",n=e.val()),this.set("page_type",i).set("page_parent",n).fetch()},onChangeFormat:function(t,e){var i=e.val();"0"==i&&(i="standard"),this.set("post_format",i).fetch()},onChangeTerm:function(t,e){e.closest(".media-frame").exists()||this.setTimeout(this.syncTaxonomyTerms,1)}})}(jQuery),function($,t){function e(){return acf.isset(window,"jQuery","fn","select2","amd")?4:!!acf.isset(window,"Select2")&&3}acf.newSelect2=function(t,i){if(i=acf.parseArgs(i,{allowNull:!1,placeholder:"",multiple:!1,field:!1,ajax:!1,ajaxAction:"",ajaxData:function(t){return t},ajaxResults:function(t){return t}}),4==e())var r=new n(t,i);else var r=new a(t,i);return acf.doAction("new_select2",r),r};var i=acf.Model.extend({setup:function(t,e){$.extend(this.data,e),this.$el=t},initialize:function(){},selectOption:function(t){var e=this.getOption(t);e.prop("selected")||e.prop("selected",!0).trigger("change")},unselectOption:function(t){var e=this.getOption(t);e.prop("selected")&&e.prop("selected",!1).trigger("change")},getOption:function(t){return this.$('option[value="'+t+'"]')},addOption:function(t){t=acf.parseArgs(t,{id:"",text:"",selected:!1});var e=this.getOption(t.id);return e.length||(e=$("<option></option>"),e.html(t.text),e.attr("value",t.id),e.prop("selected",t.selected),this.$el.append(e)),e},getValue:function(){var t=[],e=this.$el.find("option:selected");return e.exists()?(e=e.sort(function(t,e){return+t.getAttribute("data-i")-+e.getAttribute("data-i")}),e.each(function(){var e=$(this);t.push({$el:e,id:e.attr("value"),text:e.text()})}),t):t},mergeOptions:function(){},getChoices:function(){var t=function(e){var i=[];return e.children().each(function(){var e=$(this);e.is("optgroup")?i.push({text:e.attr("label"),children:t(e)}):i.push({id:e.attr("value"),text:e.text()})}),i};return t(this.$el)},decodeChoices:function(t){var e=function(t){return t.map(function(t){return t.text=acf.decode(t.text),t.children&&(t.children=e(t.children)),t}),t};return e(t)},getAjaxData:function(t){var e={action:this.get("ajaxAction"),s:t.term||"",paged:t.page||1},i=this.get("field");i&&(e.field_key=i.get("key"));var n=this.get("ajaxData");return n&&(e=n.apply(this,[e,t])),e=acf.applyFilters("select2_ajax_data",e,this.data,this.$el,i||!1,this),acf.prepareForAjax(e)},getAjaxResults:function(t,e){t=acf.parseArgs(t,{results:!1,more:!1}),t.results&&(t.results=this.decodeChoices(t.results));var i=this.get("ajaxResults");return i&&(t=i.apply(this,[t,e])),t=acf.applyFilters("select2_ajax_results",t,e,this)},processAjaxResults:function(t,e){var t=this.getAjaxResults(t,e);return t.more&&(t.pagination={more:!0}),setTimeout($.proxy(this.mergeOptions,this),1),t},destroy:function(){this.$el.data("select2")&&this.$el.select2("destroy"),this.$el.siblings(".select2-container").remove()}}),n=i.extend({initialize:function(){var t=this.$el,e={width:"100%",allowClear:this.get("allowNull"),placeholder:this.get("placeholder"),multiple:this.get("multiple"),data:[],escapeMarkup:function(t){return t}};e.multiple&&this.getValue().map(function(e){e.$el.detach().appendTo(t)}),t.removeData("ajax"),t.removeAttr("data-ajax"),this.get("ajax")&&(e.ajax={url:acf.get("ajaxurl"),delay:250,dataType:"json",type:"post",cache:!1,data:$.proxy(this.getAjaxData,this),processResults:$.proxy(this.processAjaxResults,this)});var i=this.get("field");e=acf.applyFilters("select2_args",e,t,this.data,i||!1,this),t.select2(e);var n=t.next(".select2-container");if(e.multiple){var a=n.find("ul");a.sortable({stop:function(e){a.find(".select2-selection__choice").each(function(){$($(this).data("data").element).detach().appendTo(t)}),t.trigger("change")}}),t.on("select2:select",this.proxy(function(t){this.getOption(t.params.data.id).detach().appendTo(this.$el)}))}n.addClass("-acf"),acf.doAction("select2_init",t,e,this.data,i||!1,this)},mergeOptions:function(){var t=!1,e=!1;$('.select2-results__option[role="group"]').each(function(){var i=$(this).children("ul"),n=$(this).children("strong");if(e&&e.text()===n.text())return t.append(i.children()),void $(this).remove();t=i,e=n})}}),a=i.extend({initialize:function(){var t=this.$el,e=this.getValue(),i=this.get("multiple"),n={width:"100%",allowClear:this.get("allowNull"),placeholder:this.get("placeholder"),separator:"||",multiple:this.get("multiple"),data:this.getChoices(),escapeMarkup:function(t){return t},dropdownCss:{"z-index":"999999999"},initSelection:function(t,n){n(i?e:e.shift())}},a=t.siblings("input");a.length||(a=$('<input type="hidden" />'),t.before(a)),inputValue=e.map(function(t){return t.id}).join("||"),a.val(inputValue),n.multiple&&e.map(function(e){e.$el.detach().appendTo(t)}),n.allowClear&&(n.data=n.data.filter(function(t){return""!==t.id})),t.removeData("ajax"),t.removeAttr("data-ajax"),this.get("ajax")&&(n.ajax={url:acf.get("ajaxurl"),quietMillis:250,dataType:"json",type:"post",cache:!1,data:$.proxy(this.getAjaxData,this),results:$.proxy(this.processAjaxResults,this)});var r=this.get("field");n=acf.applyFilters("select2_args",n,t,this.data,r||!1,this),a.select2(n);var o=a.select2("container"),s=$.proxy(this.getOption,this);if(n.multiple){var c=o.find("ul");c.sortable({stop:function(){c.find(".select2-search-choice").each(function(){var e=$(this).data("select2Data");s(e.id).detach().appendTo(t)}),t.trigger("change")}})}a.on("select2-selecting",function(e){var i=e.choice,n=s(i.id);n.length||(n=$('<option value="'+i.id+'">'+i.text+"</option>")),n.detach().appendTo(t)}),o.addClass("-acf"),acf.doAction("select2_init",t,n,this.data,r||!1,this),a.on("change",function(){var e=a.val();e.indexOf("||")&&(e=e.split("||")),t.val(e).trigger("change")}),t.hide()},mergeOptions:function(){var t=!1,e=!1;$("#select2-drop .select2-result-with-children").each(function(){var i=$(this).children("ul"),n=$(this).children(".select2-result-label");if(e&&e.text()===n.text())return e.append(i.children()),void $(this).remove();t=i,e=n})},getAjaxData:function(t,e){var n={term:t,page:e};return i.prototype.getAjaxData.apply(this,[n])}}),r=new acf.Model({priority:5,wait:"prepare",initialize:function(){var t=acf.get("locale"),i=acf.get("rtl"),n=acf.get("select2L10n"),a=e();return!!n&&(0!==t.indexOf("en")&&void(4==a?this.addTranslations4():3==a&&this.addTranslations3()))},addTranslations4:function(){var t=acf.get("select2L10n"),e=acf.get("locale");e=e.replace("_","-");var i={errorLoading:function(){return t.load_fail},inputTooLong:function(e){var i=e.input.length-e.maximum;return i>1?t.input_too_long_n.replace("%d",i):t.input_too_long_1},inputTooShort:function(e){var i=e.minimum-e.input.length;return i>1?t.input_too_short_n.replace("%d",i):t.input_too_short_1},loadingMore:function(){return t.load_more},maximumSelected:function(e){var i=e.maximum;return i>1?t.selection_too_long_n.replace("%d",i):t.selection_too_long_1},noResults:function(){return t.matches_0},searching:function(){return t.searching}};jQuery.fn.select2.amd.define("select2/i18n/"+e,[],function(){return i})},addTranslations3:function(){var t=acf.get("select2L10n"),e=acf.get("locale");e=e.replace("_","-");var i={formatMatches:function(e){return e>1?t.matches_n.replace("%d",e):t.matches_1},formatNoMatches:function(){return t.matches_0},formatAjaxError:function(){return t.load_fail},formatInputTooShort:function(e,i){var n=i-e.length;return n>1?t.input_too_short_n.replace("%d",n):t.input_too_short_1},formatInputTooLong:function(e,i){var n=e.length-i;return n>1?t.input_too_long_n.replace("%d",n):t.input_too_long_1},formatSelectionTooBig:function(e){return e>1?t.selection_too_long_n.replace("%d",e):t.selection_too_long_1},formatLoadMore:function(){return t.load_more},formatSearching:function(){return t.searching}};$.fn.select2.locales=$.fn.select2.locales||{},$.fn.select2.locales[e]=i,$.extend($.fn.select2.defaults,i)}})}(jQuery),function($,t){acf.tinymce={defaults:function(){return"undefined"!=typeof tinyMCEPreInit&&{tinymce:tinyMCEPreInit.mceInit.acf_content,quicktags:tinyMCEPreInit.qtInit.acf_content}},initialize:function(t,e){e=acf.parseArgs(e,{tinymce:!0,quicktags:!0,toolbar:"full",mode:"visual",field:!1}),e.tinymce&&this.initializeTinymce(t,e),e.quicktags&&this.initializeQuicktags(t,e)},initializeTinymce:function(t,e){var i=$("#"+t),n=this.defaults(),a=acf.get("toolbars"),r=e.field||!1,o=r.$el||!1;if("undefined"==typeof tinymce)return!1;if(!n)return!1;if(tinymce.get(t))return this.enable(t);var s=$.extend({},n.tinymce,e.tinymce);s.id=t,s.selector="#"+t;var c=e.toolbar;if(c&&void 0!==a[c])for(var l=1;l<=4;l++)s["toolbar"+l]=a[c][l]||"";if(s.setup=function(e){e.on("change",function(t){e.save(),i.trigger("change")}),$(e.getWin()).on("unload",function(){acf.tinymce.remove(t)})},s.wp_autoresize_on=!1,s=acf.applyFilters("wysiwyg_tinymce_settings",s,t,r),tinyMCEPreInit.mceInit[t]=s,"visual"==e.mode){var d=tinymce.init(s),u=tinymce.get(t);if(!u)return!1;u.acf=e.field,acf.doAction("wysiwyg_tinymce_init",u,u.id,s,r)}},initializeQuicktags:function(t,e){var i=this.defaults();if("undefined"==typeof quicktags)return!1;if(!i)return!1;var n=$.extend({},i.quicktags,e.quicktags);n.id=t;var a=e.field||!1,r=a.$el||!1;n=acf.applyFilters("wysiwyg_quicktags_settings",n,n.id,a),tinyMCEPreInit.qtInit[t]=n;var o=quicktags(n);if(!o)return!1;this.buildQuicktags(o),acf.doAction("wysiwyg_quicktags_init",o,o.id,n,a)},buildQuicktags:function(t){var e,i,n,a,r,t,o,s,c,l,d=",strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,";e=t.canvas,i=t.name,n=t.settings,r="",a={},c="",l=t.id,n.buttons&&(c=","+n.buttons+",");for(s in edButtons)edButtons[s]&&(o=edButtons[s].id,c&&-1!==d.indexOf(","+o+",")&&-1===c.indexOf(","+o+",")||edButtons[s].instance&&edButtons[s].instance!==l||(a[o]=edButtons[s],edButtons[s].html&&(r+=edButtons[s].html(i+"_"))));c&&-1!==c.indexOf(",dfw,")&&(a.dfw=new QTags.DFWButton,r+=a.dfw.html(i+"_")),"rtl"===document.getElementsByTagName("html")[0].dir&&(a.textdirection=new QTags.TextDirectionButton,r+=a.textdirection.html(i+"_")),t.toolbar.innerHTML=r,t.theButtons=a,"undefined"!=typeof jQuery&&jQuery(document).triggerHandler("quicktags-init",[t])},disable:function(t){this.destroyTinymce(t)},remove:function(t){this.destroyTinymce(t)},destroy:function(t){this.destroyTinymce(t)},destroyTinymce:function(t){if("undefined"==typeof tinymce)return!1;var e=tinymce.get(t);return!!e&&(e.save(),e.destroy(),!0)},enable:function(t){this.enableTinymce(t)},enableTinymce:function(t){return"undefined"!=typeof switchEditors&&(void 0!==tinyMCEPreInit.mceInit[t]&&(switchEditors.go(t,"tmce"),!0))}};var e=new acf.Model({priority:5,actions:{
4
+ prepare:"onPrepare",ready:"onReady"},onPrepare:function(){var t=$("#acf-hidden-wp-editor");t.exists()&&t.appendTo("body")},onReady:function(){acf.isset(window,"tinymce","on")&&tinymce.on("AddEditor",function(t){var e=t.editor;"acf"===e.id.substr(0,3)&&(e=tinymce.editors.content||e,tinymce.activeEditor=e,wpActiveEditor=e.id)})}})}(jQuery),function($,t){acf.validation=new acf.Model({active:!0,ignore:!1,errors:[],form:!1,wait:"prepare",actions:{ready:"addInputEvents",append:"addInputEvents"},events:{'click input[type="submit"]':"onClickSubmit",'click button[type="submit"]':"onClickSubmit","click #save-post":"onClickSave","submit form":"onSubmit"},initialize:function(){acf.get("validation")||(this.disable(),this.actions={},this.events={})},getForm:function(t){var i=t.data("acf");return i||(i=new e(t)),this.form=i,i},enable:function(){this.active=!0},disable:function(){this.active=!1},pass:function(){this.ignore=!0,this.setTimeout(function(){this.ignore=!1},100)},reset:function(){this.ignore=!1,this.errors=[],this.form=!1},getErrors:function(){return this.errors},hasErrors:function(){return this.errors.length},addErrors:function(t){t.map(this.addError,this)},addError:function(t){this.errors.push(t)},getFieldErrors:function(){var t=[],e=[];return this.getErrors().map(function(i){if(i.input){var n=e.indexOf(i.input);n>-1?t[n]=i:(t.push(i),e.push(i.input))}}),t},getGlobalErrors:function(){return this.getErrors().filter(function(t){return!t.input})},showErrors:function(t){if(this.hasErrors()){var e=this.getForm(t),i=this.getFieldErrors(),n=this.getGlobalErrors(),a=0,r=!1;i.map(function(e){var i=t.find('[name="'+e.input+'"]').first();if(i.exists()||(i=t.find('[name^="'+e.input+'"]').first()),i.exists()){a++;var n=acf.getClosestField(i);n.showError(e.message),r||(r=n.$el)}},this);var o=acf.__("Validation failed");1==a?o+=". "+acf.__("1 field requires attention"):a>1&&(o+=". "+acf.__("%d fields require attention").replace("%d",a)),e.notice?e.notice.update({type:"error",text:o}):e.notice=acf.newNotice({type:"error",text:o,target:t}),r||(r=e.notice.$el),setTimeout(function(){$("html, body").animate({scrollTop:r.offset().top-$(window).height()/2},500)},10)}},fetch:function(t){if(!this.busy){this.busy=1,t=acf.parseArgs(t,{form:!1,event:!1,lock:!0,loading:function(){},complete:function(){},failure:function(){},success:function(t){t.submit()}});var e=t.form,i=this.getForm(e);if(t.event){var n=$.Event(null,t.event);t.success=function(){$(n.target).trigger(n)}}acf.doAction("validation_begin",e);var a=acf.serialize(e);a.action="acf/validate_save_post",this.lockForm(e),t.loading(e);var r=function(t){acf.isAjaxSuccess(t)&&(a=acf.applyFilters("validation_complete",t.data,e),a.valid||this.addErrors(a.errors))},o=function(){this.busy=0,this.unlockForm(e),this.hasErrors()?(acf.doAction("validation_failure",e),this.showErrors(e),t.failure(e)):(this.pass(),i.notice&&i.notice.update({type:"success",text:acf.__("Validation successful"),timeout:1e3}),acf.doAction("validation_success",e),acf.doAction("submit",e),t.success(e),t.lock&&this.lockForm(e)),this.reset(),t.complete(e)};$.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(a),type:"post",dataType:"json",context:this,success:r,complete:o})}},addInputEvents:function(t){var e=$(".acf-field [name]",t);e.length&&this.on(e,"invalid","onInvalid")},onInvalid:function(t,e){var i=e.closest("form");this.addError({input:e.attr("name"),message:t.target.validationMessage}),t.preventDefault(),i.submit()},onClickSubmit:function(t,e){this.set("originalEvent",t)},onClickSave:function(t,e){this.pass()},onSubmit:function(t,e){acf.validateForm({form:e,event:this.get("originalEvent")})||t.preventDefault()},showSpinner:function(t){t.addClass("is-active"),t.css("display","inline-block")},hideSpinner:function(t){t.removeClass("is-active"),t.css("display","none")},disableSubmit:function(t){t.prop("disabled",!0).addClass("disabled")},enableSubmit:function(t){t.prop("disabled",!1).removeClass("disabled")},findSubmitWrap:function(t){var e=$("#submitdiv");if(e.length)return e;var e=$("#submitpost");if(e.length)return e;var e=t.find("p.submit").last();if(e.length)return e;var e=t.find(".acf-form-submit");return e.length?e:t},lockForm:function(t){var e=this.findSubmitWrap(t),i=e.find(".button, .acf-button"),n=e.find(".spinner, .acf-spinner");this.hideSpinner(n),this.disableSubmit(i),this.showSpinner(n.last())},unlockForm:function(t){var e=this.findSubmitWrap(t),i=e.find(".button, .acf-button"),n=e.find(".spinner, .acf-spinner");this.enableSubmit(i),this.hideSpinner(n)}});var e=acf.Model.extend({notice:!1,setup:function(t){this.$el=t},lock:function(){acf.validation.lockForm(this.$el)},unlock:function(){acf.validation.unlockForm(this.$el)}});acf.validateForm=function(t){if(!t.form)return!0;var e=acf.validation.getForm(t.form);return!acf.validation.active||(!!acf.validation.ignore||(e.$("#wp-preview").val()?(e.unlock(),!0):!e.$("#acf-form-data").length||(acf.validation.fetch(t),!1)))}}(jQuery),function($,t){var e=new acf.Model({priority:90,timeout:0,actions:{new_field:"refresh",show_field:"refresh",hide_field:"refresh",remove_field:"refresh"},refresh:function(){clearTimeout(this.timeout),this.timeout=setTimeout(function(){acf.doAction("refresh")},0)}}),i=new acf.Model({actions:{sortstart:"onSortstart"},onSortstart:function(t,e){t.is("tr")&&(t.css("position","relative"),t.children().each(function(){$(this).width($(this).width())}),t.css("position","absolute"),e.html('<td style="height:'+t.height()+'px; padding:0;" colspan="'+t.children("td").length+'"></td>'))}}),n=new acf.Model({actions:{after_duplicate:"onAfterDuplicate"},onAfterDuplicate:function(t,e){var i=[];t.find("select").each(function(t){i.push($(this).val())}),e.find("select").each(function(t){$(this).val(i[t])})}}),a=new acf.Model({id:"tableHelper",priority:20,actions:{refresh:"renderTables"},renderTables:function(t){var e=this;$(".acf-table:visible").each(function(){e.renderTable($(this))})},renderTable:function(t){var e=t.find("> thead > tr:visible > th[data-key]"),i=t.find("> tbody > tr:visible > td[data-key]");if(!e.length||!i.length)return!1;e.each(function(t){var e=$(this),n=e.data("key"),a=i.filter('[data-key="'+n+'"]'),r=a.filter(".acf-hidden");a.removeClass("acf-empty"),a.length===r.length?acf.hide(e):(acf.show(e),r.addClass("acf-empty"))}),e.css("width","auto"),e=e.not(".acf-hidden");var n=100,a=e.length;e.filter("[data-width]").each(function(){var t=$(this).data("width");$(this).css("width",t+"%"),n-=t});var r=e.not("[data-width]");if(r.length){var o=n/r.length;r.css("width",o+"%"),n=0}n>0&&e.last().css("width","auto"),i.filter(".-collapsed-target").each(function(){var t=$(this);t.parent().hasClass("-collapsed")?t.attr("colspan",e.length):t.removeAttr("colspan")})}}),r=new acf.Model({id:"fieldsHelper",priority:30,actions:{refresh:"renderGroups"},renderGroups:function(){var t=this;$(".acf-fields:visible").each(function(){t.renderGroup($(this))})},renderGroup:function(t){var e=0,i=0,n=$(),a=t.children(".acf-field[data-width]:visible");return!!a.length&&(t.hasClass("-left")?(a.removeAttr("data-width"),a.css("width","auto"),!1):(a.removeClass("-r0 -c0").css({"min-height":0}),a.each(function(t){var a=$(this),r=a.position(),o=Math.ceil(r.top),s=Math.ceil(r.left);n.length&&o>e&&(n.css({"min-height":i+"px"}),r=a.position(),o=Math.ceil(r.top),s=Math.ceil(r.left),e=0,i=0,n=$()),0==o?a.addClass("-r0"):0==s&&a.addClass("-c0");var c=Math.ceil(a.outerHeight())+1;i=Math.max(i,c),e=Math.max(e,o),n=n.add(a)}),void(n.length&&n.css({"min-height":i+"px"}))))}})}(jQuery),function($,t){acf.newCompatibility=function(t,e){return e=e||{},e.__proto__=t.__proto__,t.__proto__=e,t.compatibility=e,e},acf.getCompatibility=function(t){return t.compatibility||null};var e=acf.newCompatibility(acf,{l10n:{},o:{},fields:{},update:acf.set,add_action:acf.addAction,remove_action:acf.removeAction,do_action:acf.doAction,add_filter:acf.addFilter,remove_filter:acf.removeFilter,apply_filters:acf.applyFilters,parse_args:acf.parseArgs,disable_el:acf.disable,disable_form:acf.disable,enable_el:acf.enable,enable_form:acf.enable,update_user_setting:acf.updateUserSetting,prepare_for_ajax:acf.prepareForAjax,is_ajax_success:acf.isAjaxSuccess,remove_el:acf.remove,remove_tr:acf.remove,str_replace:acf.strReplace,render_select:acf.renderSelect,get_uniqid:acf.uniqid,serialize_form:acf.serialize,esc_html:acf.strEscape,str_sanitize:acf.strSanitize});e._e=function(t,e){t=t||"",e=e||"";var i=e?t+"."+e:t,n={"image.select":"Select Image","image.edit":"Edit Image","image.update":"Update Image"};if(n[i])return acf.__(n[i]);var a=this.l10n[t]||"";return e&&(a=a[e]||""),a},e.get_selector=function(t){var e=".acf-field";if(!t)return e;if($.isPlainObject(t)){if($.isEmptyObject(t))return e;for(var i in t){t=t[i];break}}return e+="-"+t,e=acf.strReplace("_","-",e),e=acf.strReplace("field-field-","field-",e)},e.get_fields=function(t,e,i){var n={is:t||"",parent:e||!1,suppressFilters:i||!1};return n.is&&(n.is=this.get_selector(n.is)),acf.findFields(n)},e.get_field=function(t,e){var i=this.get_fields.apply(this,arguments);return!!i.length&&i.first()},e.get_closest_field=function(t,e){return t.closest(this.get_selector(e))},e.get_field_wrap=function(t){return t.closest(this.get_selector())},e.get_field_key=function(t){return t.data("key")},e.get_field_type=function(t){return t.data("type")},e.get_data=function(t,e){return acf.parseArgs(t.data(),e)},e.maybe_get=function(t,e,i){void 0===i&&(i=null),keys=String(e).split(".");for(var n=0;n<keys.length;n++){if(!t.hasOwnProperty(keys[n]))return i;t=t[keys[n]]}return t};var i=function(t){return t instanceof acf.Field?t.$el:t},n=function(t){return acf.arrayArgs(t).map(i)},a=function(t){return function(){if(arguments.length)var e=n(arguments);else var e=[$(document)];return t.apply(this,e)}};e.add_action=function(t,i,n,r){var o=t.split(" "),s=o.length;if(s>1){for(var c=0;c<s;c++)t=o[c],e.add_action.apply(this,arguments);return this}var i=a(i);return acf.addAction.apply(this,arguments)},e.add_filter=function(t,e,i,n){var e=a(e);return acf.addFilter.apply(this,arguments)},e.model={actions:{},filters:{},events:{},extend:function(t){var e=$.extend({},this,t);return $.each(e.actions,function(t,i){e._add_action(t,i)}),$.each(e.filters,function(t,i){e._add_filter(t,i)}),$.each(e.events,function(t,i){e._add_event(t,i)}),e},_add_action:function(t,e){var i=this,n=t.split(" "),t=n[0]||"",a=n[1]||10;acf.add_action(t,i[e],a,i)},_add_filter:function(t,e){var i=this,n=t.split(" "),t=n[0]||"",a=n[1]||10;acf.add_filter(t,i[e],a,i)},_add_event:function(t,e){var i=this,n=t.indexOf(" "),a=n>0?t.substr(0,n):t,r=n>0?t.substr(n+1):"",o=function(t){t.$el=$(this),acf.field_group&&(t.$field=t.$el.closest(".acf-field-object")),"function"==typeof i.event&&(t=i.event(t)),i[e].apply(i,arguments)};r?$(document).on(a,r,o):$(document).on(a,o)},get:function(t,e){return e=e||null,void 0!==this[t]&&(e=this[t]),e},set:function(t,e){return this[t]=e,"function"==typeof this["_set_"+t]&&this["_set_"+t].apply(this),this}},e.field=acf.model.extend({type:"",o:{},$field:null,_add_action:function(t,e){var i=this;t=t+"_field/type="+i.type,acf.add_action(t,function(t){i.set("$field",t),i[e].apply(i,arguments)})},_add_filter:function(t,e){var i=this;t=t+"_field/type="+i.type,acf.add_filter(t,function(t){i.set("$field",t),i[e].apply(i,arguments)})},_add_event:function(t,e){var i=this,n=t.substr(0,t.indexOf(" ")),a=t.substr(t.indexOf(" ")+1),r=acf.get_selector(i.type);$(document).on(n,r+" "+a,function(t){var n=$(this),a=acf.get_closest_field(n,i.type);a.length&&(a.is(i.$field)||i.set("$field",a),t.$el=n,t.$field=a,i[e].apply(i,[t]))})},_set_$field:function(){"function"==typeof this.focus&&this.focus()},doFocus:function(t){return this.set("$field",t)}});var r=acf.newCompatibility(acf.validation,{remove_error:function(t){acf.getField(t).removeError()},add_warning:function(t,e){acf.getField(t).showNotice({text:e,type:"warning",timeout:1e3})}});e.tooltip={tooltip:function(t,e){return acf.newTooltip({text:t,target:e}).$el},temp:function(t,e){var i=acf.newTooltip({text:t,target:e,timeout:250})},confirm:function(t,e,i,n,a){var r=acf.newTooltip({confirm:!0,text:i,target:t,confirm:function(){e(!0)},cancel:function(){e(!1)}})},confirm_remove:function(t,e){var i=acf.newTooltip({confirmRemove:!0,target:t,confirm:function(){e(!0)},cancel:function(){e(!1)}})}},e.media=new acf.Model({activeFrame:!1,actions:{new_media_popup:"onNewMediaPopup"},frame:function(){return this.activeFrame},onNewMediaPopup:function(t){this.activeFrame=t.frame},popup:function(t){return t.mime_types&&(t.allowedTypes=t.mime_types),t.id&&(t.attachment=t.id),acf.newMediaPopup(t).frame}}),e.select2={init:function(t,e,i){return e.allow_null&&(e.allowNull=e.allow_null),e.ajax_action&&(e.ajaxAction=e.ajax_action),i&&(e.field=acf.getField(i)),acf.newSelect2(t,e)},destroy:function(t){return acf.getInstance(t).destroy()}},e.postbox={render:function(t){return t.edit_url&&(t.editLink=t.edit_url),t.edit_title&&(t.editTitle=t.edit_title),acf.newPostbox(t)}},acf.newCompatibility(acf.screen,{update:function(){return this.set.apply(this,arguments)}}),e.ajax=acf.screen}(jQuery);
includes/admin/admin-field-group.php CHANGED
@@ -120,7 +120,6 @@ class acf_admin_field_group {
120
 
121
  // filters
122
  add_filter('acf/input/admin_l10n', array($this, 'admin_l10n'));
123
-
124
  }
125
 
126
 
@@ -149,6 +148,27 @@ class acf_admin_field_group {
149
  wp_enqueue_script('acf-field-group');
150
 
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  // 3rd party hook
153
  do_action('acf/field_group/admin_enqueue_scripts');
154
 
@@ -221,7 +241,8 @@ class acf_admin_field_group {
221
  acf_form_data(array(
222
  'screen' => 'field_group',
223
  'post_id' => $post->ID,
224
- 'delete_fields' => 0
 
225
  ));
226
 
227
  }
@@ -262,33 +283,7 @@ class acf_admin_field_group {
262
  */
263
 
264
  function admin_l10n( $l10n ) {
265
-
266
- // merge in new strings
267
- $l10n = array_merge($l10n, array(
268
- 'move_to_trash' => __("Move to trash. Are you sure?",'acf'),
269
- 'checked' => __("checked",'acf'),
270
- 'no_fields' => __("No toggle fields available",'acf'),
271
- 'title_is_required' => __("Field group title is required",'acf'),
272
- 'copy' => __("copy",'acf'),
273
- 'or' => __("or",'acf'),
274
- 'fields' => __("Fields",'acf'),
275
- 'parent_fields' => __("Parent fields",'acf'),
276
- 'sibling_fields' => __("Sibling fields",'acf'),
277
- 'move_field' => __("Move Custom Field",'acf'),
278
- 'move_field_warning' => __("This field cannot be moved until its changes have been saved",'acf'),
279
- 'null' => __("Null",'acf'),
280
- 'unload' => __('The changes you made will be lost if you navigate away from this page','acf'),
281
- 'field_name_start' => __('The string "field_" may not be used at the start of a field name','acf'),
282
- ));
283
-
284
-
285
- // 3rd party hook
286
- $l10n = apply_filters('acf/field_group/admin_l10n', $l10n);
287
-
288
-
289
- // return
290
- return $l10n;
291
-
292
  }
293
 
294
 
@@ -427,43 +422,31 @@ class acf_admin_field_group {
427
 
428
  // do not save if this is an auto save routine
429
  if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
430
-
431
  return $post_id;
432
-
433
  }
434
 
435
-
436
  // bail early if not acf-field-group
437
  if( $post->post_type !== 'acf-field-group' ) {
438
-
439
  return $post_id;
440
-
441
  }
442
 
443
-
444
  // only save once! WordPress save's a revision as well.
445
  if( wp_is_post_revision($post_id) ) {
446
-
447
  return $post_id;
448
-
449
  }
450
 
451
-
452
  // verify nonce
453
  if( !acf_verify_nonce('field_group') ) {
454
-
455
  return $post_id;
456
-
457
  }
458
 
459
-
460
  // disable filters to ensure ACF loads raw data from DB
461
  acf_disable_filters();
462
 
463
-
464
  // save fields
465
- if( !empty($_POST['acf_fields']) ) {
466
 
 
467
  foreach( $_POST['acf_fields'] as $field ) {
468
 
469
  // vars
@@ -473,28 +456,21 @@ class acf_admin_field_group {
473
 
474
  // only saved field if has changed
475
  if( $save == 'meta' ) {
476
-
477
  $specific = array(
478
  'menu_order',
479
  'post_parent',
480
  );
481
-
482
  }
483
 
484
-
485
- // set field parent
486
- if( empty($field['parent']) ) {
487
-
488
  $field['parent'] = $post_id;
489
-
490
  }
491
 
492
-
493
  // save field
494
  acf_update_field( $field, $specific );
495
 
496
  }
497
-
498
  }
499
 
500
 
@@ -695,51 +671,25 @@ class acf_admin_field_group {
695
 
696
  function ajax_render_field_settings() {
697
 
698
- // vars
699
- $options = array(
700
- 'nonce' => '',
701
- 'parent' => 0,
702
- 'field_group' => 0,
703
- 'prefix' => '',
704
- 'type' => '',
705
- );
706
-
707
-
708
- // load post options
709
- $options = wp_parse_args($_POST, $options);
710
-
711
-
712
- // verify nonce
713
- if( !wp_verify_nonce($options['nonce'], 'acf_nonce') ) {
714
-
715
- die(0);
716
-
717
- }
718
-
719
 
720
- // required
721
- if( !$options['type'] ) {
722
 
723
- die(0);
724
-
725
- }
726
 
727
-
728
- // render options
729
- $field = acf_get_valid_field(array(
730
- 'type' => $options['type'],
731
- 'name' => 'temp',
732
- 'prefix' => $options['prefix'],
733
- 'parent' => $options['parent'],
734
- 'field_group' => $options['field_group'],
735
- ));
736
 
 
 
737
 
738
  // render
739
  do_action("acf/render_field_settings/type={$field['type']}", $field);
740
 
741
-
742
- // die
743
  die();
744
 
745
  }
120
 
121
  // filters
122
  add_filter('acf/input/admin_l10n', array($this, 'admin_l10n'));
 
123
  }
124
 
125
 
148
  wp_enqueue_script('acf-field-group');
149
 
150
 
151
+ // localize text
152
+ acf_localize_text(array(
153
+ 'The string "field_" may not be used at the start of a field name' => __('The string "field_" may not be used at the start of a field name', 'acf'),
154
+ 'This field cannot be moved until its changes have been saved' => __('This field cannot be moved until its changes have been saved', 'acf'),
155
+ 'Field group title is required' => __('Field group title is required', 'acf'),
156
+ 'Move to trash. Are you sure?' => __('Move to trash. Are you sure?', 'acf'),
157
+ 'No toggle fields available' => __('No toggle fields available', 'acf'),
158
+ 'Move Custom Field' => __('Move Custom Field', 'acf'),
159
+ 'Checked' => __('Checked', 'acf'),
160
+ '(no label)' => __('(no label)', 'acf'),
161
+ '(this field)' => __('(this field)', 'acf'),
162
+ 'copy' => __('copy', 'acf'),
163
+ 'or' => __('or', 'acf'),
164
+ 'Null' => __('Null', 'acf'),
165
+ ));
166
+
167
+ // localize data
168
+ acf_localize_data(array(
169
+ 'fieldTypes' => acf_get_field_types_info()
170
+ ));
171
+
172
  // 3rd party hook
173
  do_action('acf/field_group/admin_enqueue_scripts');
174
 
241
  acf_form_data(array(
242
  'screen' => 'field_group',
243
  'post_id' => $post->ID,
244
+ 'delete_fields' => 0,
245
+ 'validation' => 0
246
  ));
247
 
248
  }
283
  */
284
 
285
  function admin_l10n( $l10n ) {
286
+ return apply_filters('acf/field_group/admin_l10n', $l10n);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  }
288
 
289
 
422
 
423
  // do not save if this is an auto save routine
424
  if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
 
425
  return $post_id;
 
426
  }
427
 
 
428
  // bail early if not acf-field-group
429
  if( $post->post_type !== 'acf-field-group' ) {
 
430
  return $post_id;
 
431
  }
432
 
 
433
  // only save once! WordPress save's a revision as well.
434
  if( wp_is_post_revision($post_id) ) {
 
435
  return $post_id;
 
436
  }
437
 
 
438
  // verify nonce
439
  if( !acf_verify_nonce('field_group') ) {
 
440
  return $post_id;
 
441
  }
442
 
 
443
  // disable filters to ensure ACF loads raw data from DB
444
  acf_disable_filters();
445
 
 
446
  // save fields
447
+ if( !empty($_POST['acf_fields']) ) {
448
 
449
+ // loop
450
  foreach( $_POST['acf_fields'] as $field ) {
451
 
452
  // vars
456
 
457
  // only saved field if has changed
458
  if( $save == 'meta' ) {
 
459
  $specific = array(
460
  'menu_order',
461
  'post_parent',
462
  );
 
463
  }
464
 
465
+ // set parent
466
+ if( !$field['parent'] ) {
 
 
467
  $field['parent'] = $post_id;
 
468
  }
469
 
 
470
  // save field
471
  acf_update_field( $field, $specific );
472
 
473
  }
 
474
  }
475
 
476
 
671
 
672
  function ajax_render_field_settings() {
673
 
674
+ // validate
675
+ if( !acf_verify_ajax() ) die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
676
 
677
+ // vars
678
+ $field = acf_maybe_get_POST('field');
679
 
680
+ // check
681
+ if( !$field ) die();
 
682
 
683
+ // set prefix
684
+ $field['prefix'] = acf_maybe_get_POST('prefix');
 
 
 
 
 
 
 
685
 
686
+ // validate
687
+ $field = acf_get_valid_field( $field );
688
 
689
  // render
690
  do_action("acf/render_field_settings/type={$field['type']}", $field);
691
 
692
+ // return
 
693
  die();
694
 
695
  }
includes/admin/admin.php CHANGED
@@ -177,7 +177,7 @@ class acf_admin {
177
  }
178
 
179
  ?>
180
- <div class="notice is-dismissible <?php echo esc_attr($notice['class']); ?> acf-notice"><?php echo $open . $notice['text'] . $close; ?></div>
181
  <?php
182
 
183
  }
177
  }
178
 
179
  ?>
180
+ <div class="acf-admin-notice notice is-dismissible <?php echo esc_attr($notice['class']); ?>"><?php echo $open . $notice['text'] . $close; ?></div>
181
  <?php
182
 
183
  }
includes/admin/tools/class-acf-admin-tool-export.php CHANGED
@@ -479,7 +479,11 @@ class ACF_Admin_Tool_Export extends ACF_Admin_Tool {
479
 
480
 
481
  // tooltip
482
- acf.tooltip.temp('Copied', $a);
 
 
 
 
483
 
484
  } catch (err) {
485
 
479
 
480
 
481
  // tooltip
482
+ acf.newTooltip({
483
+ text: "<?php _e('Copied', 'acf' ); ?>",
484
+ timeout: 250,
485
+ target: $(this),
486
+ });
487
 
488
  } catch (err) {
489
 
includes/admin/views/field-group-field-conditional-logic.php CHANGED
@@ -15,15 +15,12 @@ if( empty($field['conditional_logic']) ) {
15
 
16
  // rule 0
17
  array()
18
-
19
  )
20
-
21
  );
22
-
23
  }
24
 
25
  ?>
26
- <tr class="acf-field acf-field-true-false acf-field-setting-conditional_logic" data_type="true_false" data-name="conditional_logic">
27
  <td class="acf-label">
28
  <label><?php _e("Conditional Logic",'acf'); ?></label>
29
  </td>
@@ -36,7 +33,7 @@ if( empty($field['conditional_logic']) ) {
36
  'prefix' => $field['prefix'],
37
  'value' => $disabled ? 0 : 1,
38
  'ui' => 1,
39
- 'class' => 'conditional-toggle',
40
  ));
41
 
42
  ?>
@@ -65,7 +62,7 @@ if( empty($field['conditional_logic']) ) {
65
  // valid rule
66
  $rule = wp_parse_args( $rule, array(
67
  'field' => '',
68
- 'operator' => '==',
69
  'value' => '',
70
  ));
71
 
@@ -75,23 +72,29 @@ if( empty($field['conditional_logic']) ) {
75
  $rule_id = "rule_{$rule_id}";
76
  $prefix = "{$field['prefix']}[conditional_logic][{$group_id}][{$rule_id}]";
77
 
 
 
 
 
 
 
 
 
78
  ?>
79
- <tr class="rule" data-id="<?php echo $rule_id; ?>">
80
  <td class="param">
81
  <?php
82
-
83
- $choices = array();
84
- $choices[ $rule['field'] ] = $rule['field'];
85
-
86
- // create field
87
  acf_render_field(array(
88
  'type' => 'select',
89
  'prefix' => $prefix,
90
  'name' => 'field',
91
- 'value' => $rule['field'],
92
- 'choices' => $choices,
93
- 'class' => 'conditional-rule-param',
94
  'disabled' => $disabled,
 
 
 
 
95
  ));
96
 
97
  ?>
@@ -99,40 +102,34 @@ if( empty($field['conditional_logic']) ) {
99
  <td class="operator">
100
  <?php
101
 
102
- $choices = array(
103
- '==' => __("is equal to",'acf'),
104
- '!=' => __("is not equal to",'acf'),
105
- );
106
-
107
-
108
- // create field
109
  acf_render_field(array(
110
  'type' => 'select',
111
  'prefix' => $prefix,
112
  'name' => 'operator',
113
- 'value' => $rule['operator'],
114
- 'choices' => $choices,
115
- 'class' => 'conditional-rule-operator',
116
  'disabled' => $disabled,
 
 
 
 
117
  ));
118
 
119
  ?>
120
  </td>
121
  <td class="value">
122
  <?php
123
-
124
- $choices = array();
125
- $choices[ $rule['value'] ] = $rule['value'];
126
-
127
  // create field
128
  acf_render_field(array(
129
  'type' => 'select',
130
  'prefix' => $prefix,
131
  'name' => 'value',
132
- 'value' => $rule['value'],
133
- 'choices' => $choices,
134
- 'class' => 'conditional-rule-value',
135
  'disabled' => $disabled,
 
 
 
 
136
  ));
137
 
138
  ?>
15
 
16
  // rule 0
17
  array()
 
18
  )
 
19
  );
 
20
  }
21
 
22
  ?>
23
+ <tr class="acf-field acf-field-true-false acf-field-setting-conditional_logic" data-type="true_false" data-name="conditional_logic">
24
  <td class="acf-label">
25
  <label><?php _e("Conditional Logic",'acf'); ?></label>
26
  </td>
33
  'prefix' => $field['prefix'],
34
  'value' => $disabled ? 0 : 1,
35
  'ui' => 1,
36
+ 'class' => 'conditions-toggle',
37
  ));
38
 
39
  ?>
62
  // valid rule
63
  $rule = wp_parse_args( $rule, array(
64
  'field' => '',
65
+ 'operator' => '',
66
  'value' => '',
67
  ));
68
 
72
  $rule_id = "rule_{$rule_id}";
73
  $prefix = "{$field['prefix']}[conditional_logic][{$group_id}][{$rule_id}]";
74
 
75
+ // data attributes
76
+ $attributes = array(
77
+ 'data-id' => $rule_id,
78
+ 'data-field' => $rule['field'],
79
+ 'data-operator' => $rule['operator'],
80
+ 'data-value' => $rule['value']
81
+ );
82
+
83
  ?>
84
+ <tr class="rule" <?php acf_esc_attr_e($attributes); ?>>
85
  <td class="param">
86
  <?php
87
+
 
 
 
 
88
  acf_render_field(array(
89
  'type' => 'select',
90
  'prefix' => $prefix,
91
  'name' => 'field',
92
+ 'class' => 'condition-rule-field',
 
 
93
  'disabled' => $disabled,
94
+ 'value' => $rule['field'],
95
+ 'choices' => array(
96
+ $rule['field'] => $rule['field']
97
+ )
98
  ));
99
 
100
  ?>
102
  <td class="operator">
103
  <?php
104
 
 
 
 
 
 
 
 
105
  acf_render_field(array(
106
  'type' => 'select',
107
  'prefix' => $prefix,
108
  'name' => 'operator',
109
+ 'class' => 'condition-rule-operator',
 
 
110
  'disabled' => $disabled,
111
+ 'value' => $rule['operator'],
112
+ 'choices' => array(
113
+ $rule['operator'] => $rule['operator']
114
+ )
115
  ));
116
 
117
  ?>
118
  </td>
119
  <td class="value">
120
  <?php
121
+
 
 
 
122
  // create field
123
  acf_render_field(array(
124
  'type' => 'select',
125
  'prefix' => $prefix,
126
  'name' => 'value',
127
+ 'class' => 'condition-rule-value',
 
 
128
  'disabled' => $disabled,
129
+ 'value' => $rule['value'],
130
+ 'choices' => array(
131
+ $rule['value'] => $rule['value']
132
+ )
133
  ));
134
 
135
  ?>
includes/admin/views/field-group-field.php CHANGED
@@ -1,12 +1,15 @@
1
  <?php
2
 
3
- // add prefix
4
- $field['prefix'] = "acf_fields[{$field['ID']}]";
 
5
 
 
 
6
 
7
- // vars
8
- $atts = array(
9
- 'class' => "acf-field-object acf-field-object-{$field['type']}",
10
  'data-id' => $field['ID'],
11
  'data-key' => $field['key'],
12
  'data-type' => $field['type'],
@@ -16,22 +19,16 @@ $meta = array(
16
  'ID' => $field['ID'],
17
  'key' => $field['key'],
18
  'parent' => $field['parent'],
19
- 'menu_order' => $field['menu_order'],
20
- 'save' => '',
21
  );
22
 
23
-
24
- // class
25
- $atts['class'] = str_replace('_', '-', $atts['class']);
26
-
27
  ?>
28
- <div <?php echo acf_esc_attr( $atts ); ?>>
29
 
30
  <div class="meta">
31
  <?php foreach( $meta as $k => $v ):
32
-
33
- acf_hidden_input(array( 'class' => "input-{$k}", 'name' => "{$field['prefix']}[{$k}]", 'value' => $v ));
34
-
35
  endforeach; ?>
36
  </div>
37
 
@@ -42,7 +39,7 @@ $atts['class'] = str_replace('_', '-', $atts['class']);
42
  </li>
43
  <li class="li-field-label">
44
  <strong>
45
- <a class="edit-field" title="<?php _e("Edit field",'acf'); ?>" href="#"><?php echo acf_get_field_label($field); ?></a>
46
  </strong>
47
  <div class="row-options">
48
  <a class="edit-field" title="<?php _e("Edit field",'acf'); ?>" href="#"><?php _e("Edit",'acf'); ?></a>
@@ -60,7 +57,7 @@ $atts['class'] = str_replace('_', '-', $atts['class']);
60
 
61
  <div class="settings">
62
  <table class="acf-table">
63
- <tbody>
64
  <?php
65
 
66
  // label
@@ -89,7 +86,7 @@ $atts['class'] = str_replace('_', '-', $atts['class']);
89
  'instructions' => '',
90
  'type' => 'select',
91
  'name' => 'type',
92
- 'choices' => acf_get_field_types(),
93
  'class' => 'field-type'
94
  ), true);
95
 
1
  <?php
2
 
3
+ // vars
4
+ $prefix = 'acf_fields[' . $field['ID'] . ']';
5
+ $id = acf_idify( $prefix );
6
 
7
+ // add prefix
8
+ $field['prefix'] = $prefix;
9
 
10
+ // div
11
+ $div = array(
12
+ 'class' => 'acf-field-object acf-field-object-' . acf_slugify($field['type']),
13
  'data-id' => $field['ID'],
14
  'data-key' => $field['key'],
15
  'data-type' => $field['type'],
19
  'ID' => $field['ID'],
20
  'key' => $field['key'],
21
  'parent' => $field['parent'],
22
+ 'menu_order' => $i,
23
+ 'save' => ''
24
  );
25
 
 
 
 
 
26
  ?>
27
+ <div <?php echo acf_esc_attr( $div ); ?>>
28
 
29
  <div class="meta">
30
  <?php foreach( $meta as $k => $v ):
31
+ acf_hidden_input(array( 'name' => $prefix . '[' . $k . ']', 'value' => $v, 'id' => $id . '-' . $k ));
 
 
32
  endforeach; ?>
33
  </div>
34
 
39
  </li>
40
  <li class="li-field-label">
41
  <strong>
42
+ <a class="edit-field" title="<?php _e("Edit field",'acf'); ?>" href="#"><?php echo acf_get_field_label($field, 'admin'); ?></a>
43
  </strong>
44
  <div class="row-options">
45
  <a class="edit-field" title="<?php _e("Edit field",'acf'); ?>" href="#"><?php _e("Edit",'acf'); ?></a>
57
 
58
  <div class="settings">
59
  <table class="acf-table">
60
+ <tbody class="acf-field-settings">
61
  <?php
62
 
63
  // label
86
  'instructions' => '',
87
  'type' => 'select',
88
  'name' => 'type',
89
+ 'choices' => acf_get_grouped_field_types(),
90
  'class' => 'field-type'
91
  ), true);
92
 
includes/admin/views/field-group-fields.php CHANGED
@@ -8,9 +8,9 @@
8
  <li class="li-field-type"><?php _e('Type','acf'); ?></li>
9
  </ul>
10
 
11
- <div class="acf-field-list">
12
 
13
- <div class="no-fields-message" <?php if( $fields ){ echo 'style="display:none;"'; } ?>>
14
  <?php _e("No fields. Click the <strong>+ Add Field</strong> button to create your first field.",'acf'); ?>
15
  </div>
16
 
8
  <li class="li-field-type"><?php _e('Type','acf'); ?></li>
9
  </ul>
10
 
11
+ <div class="acf-field-list<?php if( !$fields ){ echo ' -empty'; } ?>">
12
 
13
+ <div class="no-fields-message">
14
  <?php _e("No fields. Click the <strong>+ Add Field</strong> button to create your first field.",'acf'); ?>
15
  </div>
16
 
includes/admin/views/field-group-locations.php CHANGED
@@ -36,7 +36,7 @@ global $field_group;
36
  <script type="text/javascript">
37
  if( typeof acf !== 'undefined' ) {
38
 
39
- acf.postbox.render({
40
  'id': 'acf-field-group-locations',
41
  'label': 'left'
42
  });
36
  <script type="text/javascript">
37
  if( typeof acf !== 'undefined' ) {
38
 
39
+ acf.newPostbox({
40
  'id': 'acf-field-group-locations',
41
  'label': 'left'
42
  });
includes/admin/views/field-group-options.php CHANGED
@@ -103,6 +103,27 @@ acf_render_field_wrap(array(
103
 
104
 
105
  // hide on screen
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  acf_render_field_wrap(array(
107
  'label' => __('Hide on screen','acf'),
108
  'instructions' => __('<b>Select</b> items to <b>hide</b> them from the edit screen.','acf') . '<br /><br />' . __("If multiple field groups appear on an edit screen, the first field group's options will be used (the one with the lowest order number)",'acf'),
@@ -111,23 +132,7 @@ acf_render_field_wrap(array(
111
  'prefix' => 'acf_field_group',
112
  'value' => $field_group['hide_on_screen'],
113
  'toggle' => true,
114
- 'choices' => array(
115
- 'permalink' => __("Permalink", 'acf'),
116
- 'the_content' => __("Content Editor",'acf'),
117
- 'excerpt' => __("Excerpt", 'acf'),
118
- 'custom_fields' => __("Custom Fields", 'acf'),
119
- 'discussion' => __("Discussion", 'acf'),
120
- 'comments' => __("Comments", 'acf'),
121
- 'revisions' => __("Revisions", 'acf'),
122
- 'slug' => __("Slug", 'acf'),
123
- 'author' => __("Author", 'acf'),
124
- 'format' => __("Format", 'acf'),
125
- 'page_attributes' => __("Page Attributes", 'acf'),
126
- 'featured_image' => __("Featured Image", 'acf'),
127
- 'categories' => __("Categories", 'acf'),
128
- 'tags' => __("Tags", 'acf'),
129
- 'send-trackbacks' => __("Send Trackbacks", 'acf'),
130
- )
131
  ));
132
 
133
 
@@ -141,7 +146,7 @@ do_action('acf/render_field_group_settings', $field_group);
141
  <script type="text/javascript">
142
  if( typeof acf !== 'undefined' ) {
143
 
144
- acf.postbox.render({
145
  'id': 'acf-field-group-options',
146
  'label': 'left'
147
  });
103
 
104
 
105
  // hide on screen
106
+ $choices = array(
107
+ 'permalink' => __("Permalink", 'acf'),
108
+ 'the_content' => __("Content Editor",'acf'),
109
+ 'excerpt' => __("Excerpt", 'acf'),
110
+ 'custom_fields' => __("Custom Fields", 'acf'),
111
+ 'discussion' => __("Discussion", 'acf'),
112
+ 'comments' => __("Comments", 'acf'),
113
+ 'revisions' => __("Revisions", 'acf'),
114
+ 'slug' => __("Slug", 'acf'),
115
+ 'author' => __("Author", 'acf'),
116
+ 'format' => __("Format", 'acf'),
117
+ 'page_attributes' => __("Page Attributes", 'acf'),
118
+ 'featured_image' => __("Featured Image", 'acf'),
119
+ 'categories' => __("Categories", 'acf'),
120
+ 'tags' => __("Tags", 'acf'),
121
+ 'send-trackbacks' => __("Send Trackbacks", 'acf'),
122
+ );
123
+ if( acf_get_setting('remove_wp_meta_box') ) {
124
+ unset( $choices['custom_fields'] );
125
+ }
126
+
127
  acf_render_field_wrap(array(
128
  'label' => __('Hide on screen','acf'),
129
  'instructions' => __('<b>Select</b> items to <b>hide</b> them from the edit screen.','acf') . '<br /><br />' . __("If multiple field groups appear on an edit screen, the first field group's options will be used (the one with the lowest order number)",'acf'),
132
  'prefix' => 'acf_field_group',
133
  'value' => $field_group['hide_on_screen'],
134
  'toggle' => true,
135
+ 'choices' => $choices
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  ));
137
 
138
 
146
  <script type="text/javascript">
147
  if( typeof acf !== 'undefined' ) {
148
 
149
+ acf.newPostbox({
150
  'id': 'acf-field-group-options',
151
  'label': 'left'
152
  });
includes/admin/views/install-network.php CHANGED
@@ -178,22 +178,20 @@ $button = __('Upgrade Sites');
178
  $input.prop('checked', false);
179
  $input.remove();
180
 
181
-
182
  // vars
183
- var message = acf.get_ajax_message(json);
184
-
185
 
186
- // bail early if no message text
187
- if( !message.text ) {
188
-
189
- return;
190
-
191
  }
192
 
193
-
194
  // update text
195
- text = '<pre>' + message.text + '</pre>';
196
-
 
197
  },
198
  complete: function(){
199
 
178
  $input.prop('checked', false);
179
  $input.remove();
180
 
 
181
  // vars
182
+ var response = '';
 
183
 
184
+ // success
185
+ if( acf.isAjaxSuccess(json) ) {
186
+ response = acf.getAjaxMessage(json);
187
+ } else {
188
+ response = acf.getAjaxError(json);
189
  }
190
 
 
191
  // update text
192
+ if( response ) {
193
+ text = '<pre>' + response + '</pre>';
194
+ }
195
  },
196
  complete: function(){
197
 
includes/admin/views/install.php CHANGED
@@ -65,20 +65,19 @@
65
  success: function( json ){
66
 
67
  // vars
68
- var message = acf.get_ajax_message(json);
69
 
 
 
 
 
 
 
70
 
71
  // bail early if no message text
72
- if( !message.text ) {
73
-
74
- return;
75
-
76
  }
77
-
78
-
79
- // show message
80
- $('.show-on-ajax').html( message.text );
81
-
82
  },
83
  complete: function( json ){
84
 
65
  success: function( json ){
66
 
67
  // vars
68
+ var response = '';
69
 
70
+ // success
71
+ if( acf.isAjaxSuccess(json) ) {
72
+ response = acf.getAjaxMessage(json);
73
+ } else {
74
+ response = acf.getAjaxError(json);
75
+ }
76
 
77
  // bail early if no message text
78
+ if( response ) {
79
+ $('.show-on-ajax').html( response );
 
 
80
  }
 
 
 
 
 
81
  },
82
  complete: function( json ){
83
 
includes/api/api-field.php CHANGED
@@ -227,7 +227,7 @@ function acf_prepare_field( $field ) {
227
 
228
 
229
  // id attr is generated from name
230
- $field['id'] = str_replace(array('][', '[', ']'), array('-', '-', ''), $field['name']);
231
 
232
 
233
  // return
@@ -278,12 +278,18 @@ function acf_is_sub_field( $field ) {
278
  * @return $label (string)
279
  */
280
 
281
- function acf_get_field_label( $field ) {
282
 
283
  // vars
284
  $label = $field['label'];
285
 
286
 
 
 
 
 
 
 
287
  // required
288
  if( $field['required'] ) {
289
  $label .= ' <span class="acf-required">*</span>';
@@ -512,6 +518,17 @@ function acf_render_field_wrap( $field, $el = 'div', $instruction = 'label' ) {
512
  $wrapper = array_filter($wrapper);
513
 
514
 
 
 
 
 
 
 
 
 
 
 
 
515
  // html
516
  ?>
517
  <<?php echo $el; ?> <?php acf_esc_attr_e($wrapper); ?>>
@@ -527,13 +544,6 @@ function acf_render_field_wrap( $field, $el = 'div', $instruction = 'label' ) {
527
  <<?php echo $el2; ?> class="acf-input">
528
  <?php acf_render_field( $field ); ?>
529
  <?php if( $instruction == 'field' ) acf_render_field_instructions( $field ); ?>
530
- <?php if( !empty($field['conditional_logic']) ): ?>
531
- <script type="text/javascript">
532
- if( typeof acf !== 'undefined' ) {
533
- acf.conditional_logic.add( '<?php echo esc_js($field['key']); ?>', <?php echo wp_json_encode( $field['conditional_logic'] ); ?> );
534
- }
535
- </script>
536
- <?php endif; ?>
537
  </<?php echo $el2; ?>>
538
  </<?php echo $el; ?>>
539
  <?php
@@ -624,52 +634,38 @@ function acf_render_field_setting( $field, $setting, $global = false ) {
624
  // validate
625
  $setting = acf_get_valid_field( $setting );
626
 
 
 
 
627
 
628
- // specific
629
  if( !$global ) {
630
-
631
  $setting['wrapper']['data-setting'] = $field['type'];
632
-
633
  }
634
 
635
-
636
- // class
637
- $setting['wrapper']['class'] .= ' acf-field-setting-' . $setting['name'];
638
-
639
-
640
  // copy across prefix
641
  $setting['prefix'] = $field['prefix'];
642
 
643
-
644
  // attempt find value
645
  if( $setting['value'] === null ) {
646
 
647
  // name
648
  if( isset($field[ $setting['name'] ]) ) {
649
-
650
  $setting['value'] = $field[ $setting['name'] ];
651
 
652
  // default
653
  } elseif( isset($setting['default_value']) ) {
654
-
655
  $setting['value'] = $setting['default_value'];
656
-
657
  }
658
-
659
  }
660
 
661
-
662
  // append (used by JS to join settings)
663
  if( isset($setting['_append']) ) {
664
-
665
  $setting['wrapper']['data-append'] = $setting['_append'];
666
-
667
  }
668
 
669
-
670
  // render
671
  acf_render_field_wrap( $setting, 'tr', 'label' );
672
-
673
  }
674
 
675
 
227
 
228
 
229
  // id attr is generated from name
230
+ $field['id'] = acf_idify( $field['name'] );
231
 
232
 
233
  // return
278
  * @return $label (string)
279
  */
280
 
281
+ function acf_get_field_label( $field, $context = '' ) {
282
 
283
  // vars
284
  $label = $field['label'];
285
 
286
 
287
+ // show (no label) when editing field
288
+ if( $context == 'admin' && $label === '' ) {
289
+ $label = __('(no label)', 'acf');
290
+ }
291
+
292
+
293
  // required
294
  if( $field['required'] ) {
295
  $label .= ' <span class="acf-required">*</span>';
518
  $wrapper = array_filter($wrapper);
519
 
520
 
521
+ // conditional logic
522
+ if( !empty($field['conditional_logic']) ) {
523
+ $field['conditions'] = $field['conditional_logic'];
524
+ }
525
+
526
+ // conditions
527
+ if( !empty($field['conditions']) ) {
528
+ $wrapper['data-conditions'] = $field['conditions'];
529
+ }
530
+
531
+
532
  // html
533
  ?>
534
  <<?php echo $el; ?> <?php acf_esc_attr_e($wrapper); ?>>
544
  <<?php echo $el2; ?> class="acf-input">
545
  <?php acf_render_field( $field ); ?>
546
  <?php if( $instruction == 'field' ) acf_render_field_instructions( $field ); ?>
 
 
 
 
 
 
 
547
  </<?php echo $el2; ?>>
548
  </<?php echo $el; ?>>
549
  <?php
634
  // validate
635
  $setting = acf_get_valid_field( $setting );
636
 
637
+ // custom key and class
638
+ $setting['wrapper']['data-key'] = $setting['name'];
639
+ $setting['wrapper']['class'] .= ' acf-field-setting-' . $setting['name'];
640
 
641
+ // context
642
  if( !$global ) {
 
643
  $setting['wrapper']['data-setting'] = $field['type'];
 
644
  }
645
 
 
 
 
 
 
646
  // copy across prefix
647
  $setting['prefix'] = $field['prefix'];
648
 
 
649
  // attempt find value
650
  if( $setting['value'] === null ) {
651
 
652
  // name
653
  if( isset($field[ $setting['name'] ]) ) {
 
654
  $setting['value'] = $field[ $setting['name'] ];
655
 
656
  // default
657
  } elseif( isset($setting['default_value']) ) {
 
658
  $setting['value'] = $setting['default_value'];
 
659
  }
 
660
  }
661
 
 
662
  // append (used by JS to join settings)
663
  if( isset($setting['_append']) ) {
 
664
  $setting['wrapper']['data-append'] = $setting['_append'];
 
665
  }
666
 
 
667
  // render
668
  acf_render_field_wrap( $setting, 'tr', 'label' );
 
669
  }
670
 
671
 
includes/api/api-helpers.php CHANGED
@@ -39,6 +39,37 @@ function acf_is_empty( $value ) {
39
 
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  /**
44
  * acf_has_setting
@@ -3160,6 +3191,9 @@ function acf_get_post_id_info( $post_id = 0 ) {
3160
  //acf_set_cache($cache_key, $info);
3161
 
3162
 
 
 
 
3163
  // return
3164
  return $info;
3165
 
@@ -3386,8 +3420,7 @@ function acf_upload_file( $uploaded_file ) {
3386
  $object = array(
3387
  'post_title' => $filename,
3388
  'post_mime_type' => $type,
3389
- 'guid' => $url,
3390
- 'context' => 'acf-upload'
3391
  );
3392
 
3393
  // Save the data
@@ -3466,20 +3499,25 @@ function acf_update_nested_array( &$array, $ancestors, $value ) {
3466
  function acf_is_screen( $id = '' ) {
3467
 
3468
  // bail early if not defined
3469
- if( !function_exists('get_current_screen') ) return false;
3470
-
 
3471
 
3472
  // vars
3473
  $current_screen = get_current_screen();
3474
 
 
 
 
3475
 
3476
- // bail early if no screen
3477
- if( !$current_screen ) return false;
3478
-
3479
-
3480
- // return
3481
- return ($id === $current_screen->id);
3482
 
 
 
 
 
3483
  }
3484
 
3485
 
39
 
40
  }
41
 
42
+ /**
43
+ * acf_idify
44
+ *
45
+ * Returns an id friendly string
46
+ *
47
+ * @date 24/12/17
48
+ * @since 5.6.5
49
+ *
50
+ * @param type $var Description. Default.
51
+ * @return type Description.
52
+ */
53
+
54
+ function acf_idify( $str = '' ) {
55
+ return str_replace(array('][', '[', ']'), array('-', '-', ''), strtolower($str));
56
+ }
57
+
58
+ /**
59
+ * acf_slugify
60
+ *
61
+ * Returns a slug friendly string
62
+ *
63
+ * @date 24/12/17
64
+ * @since 5.6.5
65
+ *
66
+ * @param type $var Description. Default.
67
+ * @return type Description.
68
+ */
69
+
70
+ function acf_slugify( $str = '' ) {
71
+ return str_replace('_', '-', strtolower($str));
72
+ }
73
 
74
  /**
75
  * acf_has_setting
3191
  //acf_set_cache($cache_key, $info);
3192
 
3193
 
3194
+ // filter
3195
+ $info = apply_filters("acf/get_post_id_info", $info, $post_id);
3196
+
3197
  // return
3198
  return $info;
3199
 
3420
  $object = array(
3421
  'post_title' => $filename,
3422
  'post_mime_type' => $type,
3423
+ 'guid' => $url
 
3424
  );
3425
 
3426
  // Save the data
3499
  function acf_is_screen( $id = '' ) {
3500
 
3501
  // bail early if not defined
3502
+ if( !function_exists('get_current_screen') ) {
3503
+ return false;
3504
+ }
3505
 
3506
  // vars
3507
  $current_screen = get_current_screen();
3508
 
3509
+ // no screen
3510
+ if( !$current_screen ) {
3511
+ return false;
3512
 
3513
+ // array
3514
+ } elseif( is_array($id) ) {
3515
+ return in_array($current_screen->id, $id);
 
 
 
3516
 
3517
+ // string
3518
+ } else {
3519
+ return ($id === $current_screen->id);
3520
+ }
3521
  }
3522
 
3523
 
includes/api/api-input.php CHANGED
@@ -401,7 +401,7 @@ function acf_get_select_input( $atts = array() ) {
401
 
402
  // html
403
  $html = '';
404
- $html .= '<select ' . acf_esc_atts( $atts ) . '>' . "\n";
405
  $html .= acf_walk_select_input( $choices, $value );
406
  $html .= '</select>' . "\n";
407
 
@@ -447,7 +447,7 @@ function acf_walk_select_input( $choices = array(), $values = array(), $depth =
447
  // optgroup
448
  if( is_array($label) ){
449
 
450
- $html .= '<optgroup label="' . esc_attr($value) . '">' . "\n";
451
  $html .= acf_walk_select_input( $label, $values, $depth+1 );
452
  $html .= '</optgroup>';
453
 
@@ -467,7 +467,7 @@ function acf_walk_select_input( $choices = array(), $values = array(), $depth =
467
 
468
 
469
  // append
470
- $html .= '<option ' . acf_esc_attr($atts) . '>' . esc_html($label) . '</option>' . "\n";
471
 
472
  }
473
 
401
 
402
  // html
403
  $html = '';
404
+ $html .= '<select ' . acf_esc_atts( $atts ) . '>';
405
  $html .= acf_walk_select_input( $choices, $value );
406
  $html .= '</select>' . "\n";
407
 
447
  // optgroup
448
  if( is_array($label) ){
449
 
450
+ $html .= '<optgroup label="' . esc_attr($value) . '">';
451
  $html .= acf_walk_select_input( $label, $values, $depth+1 );
452
  $html .= '</optgroup>';
453
 
467
 
468
 
469
  // append
470
+ $html .= '<option ' . acf_esc_attr($atts) . '>' . esc_html($label) . '</option>';
471
 
472
  }
473
 
includes/assets.php ADDED
@@ -0,0 +1,477 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+ if( ! class_exists('ACF_Assets') ) :
6
+
7
+ class ACF_Assets {
8
+
9
+ /** @var array Storage for translations */
10
+ var $text = array();
11
+
12
+ /** @var array Storage for data */
13
+ var $data = array();
14
+
15
+
16
+ /**
17
+ * __construct
18
+ *
19
+ * description
20
+ *
21
+ * @date 10/4/18
22
+ * @since 5.6.9
23
+ *
24
+ * @param void
25
+ * @return void
26
+ */
27
+
28
+ function __construct() {
29
+
30
+ // actions
31
+ add_action('init', array($this, 'register_scripts'));
32
+ }
33
+
34
+
35
+ /**
36
+ * add_text
37
+ *
38
+ * description
39
+ *
40
+ * @date 13/4/18
41
+ * @since 5.6.9
42
+ *
43
+ * @param type $var Description. Default.
44
+ * @return type Description.
45
+ */
46
+
47
+ function add_text( $text ) {
48
+ foreach( (array) $text as $k => $v ) {
49
+ $this->text[ $k ] = $v;
50
+ }
51
+ }
52
+
53
+
54
+ /**
55
+ * add_data
56
+ *
57
+ * description
58
+ *
59
+ * @date 13/4/18
60
+ * @since 5.6.9
61
+ *
62
+ * @param type $var Description. Default.
63
+ * @return type Description.
64
+ */
65
+
66
+ function add_data( $data ) {
67
+ foreach( (array) $data as $k => $v ) {
68
+ $this->data[ $k ] = $v;
69
+ }
70
+ }
71
+
72
+
73
+ /**
74
+ * register_scripts
75
+ *
76
+ * description
77
+ *
78
+ * @date 13/4/18
79
+ * @since 5.6.9
80
+ *
81
+ * @param type $var Description. Default.
82
+ * @return type Description.
83
+ */
84
+
85
+ function register_scripts() {
86
+
87
+ // vars
88
+ $version = acf_get_setting('version');
89
+ $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
90
+
91
+ // scripts
92
+ wp_register_script('acf-input', acf_get_url("assets/js/acf-input{$min}.js"), array('jquery', 'jquery-ui-sortable', 'jquery-ui-resizable'), $version );
93
+ wp_register_script('acf-field-group', acf_get_url("assets/js/acf-field-group{$min}.js"), array('acf-input'), $version );
94
+
95
+ // styles
96
+ wp_register_style('acf-global', acf_get_url('assets/css/acf-global.css'), array(), $version );
97
+ wp_register_style('acf-input', acf_get_url('assets/css/acf-input.css'), array('acf-global'), $version );
98
+ wp_register_style('acf-field-group', acf_get_url('assets/css/acf-field-group.css'), array('acf-input'), $version );
99
+
100
+ // action
101
+ do_action('acf/register_scripts', $version, $min);
102
+ }
103
+
104
+
105
+ /**
106
+ * enqueue_scripts
107
+ *
108
+ * Enqueue scripts for input
109
+ *
110
+ * @date 13/4/18
111
+ * @since 5.6.9
112
+ *
113
+ * @param type $var Description. Default.
114
+ * @return type Description.
115
+ */
116
+
117
+ function enqueue_scripts( $args = array() ) {
118
+
119
+ // run only once
120
+ if( acf_has_done('enqueue_scripts') ) {
121
+ return;
122
+ }
123
+
124
+ // defaults
125
+ $args = wp_parse_args($args, array(
126
+
127
+ // force tinymce editor to be enqueued
128
+ 'uploader' => false,
129
+
130
+ // priority used for action callbacks, defaults to 20 which runs after defaults
131
+ 'priority' => 20,
132
+
133
+ // action prefix
134
+ 'context' => is_admin() ? 'admin' : 'wp'
135
+ ));
136
+
137
+ // define actions
138
+ $actions = array(
139
+ 'admin_enqueue_scripts' => $args['context'] . '_enqueue_scripts',
140
+ 'admin_print_scripts' => $args['context'] . '_print_scripts',
141
+ 'admin_head' => $args['context'] . '_head',
142
+ 'admin_footer' => $args['context'] . '_footer',
143
+ 'admin_print_footer_scripts' => $args['context'] . '_print_footer_scripts',
144
+ );
145
+
146
+ // fix customizer actions where head and footer are not available
147
+ if( $args['context'] == 'customize_controls' ) {
148
+ $actions['admin_head'] = $actions['admin_print_scripts'];
149
+ $actions['admin_footer'] = $actions['admin_print_footer_scripts'];
150
+ }
151
+
152
+ // add actions
153
+ foreach( $actions as $function => $action ) {
154
+ acf_maybe_add_action( $action, array($this, $function), $args['priority'] );
155
+ }
156
+
157
+ // enqueue uploader
158
+ // WP requires a lot of JS + inline scripes to create the media modal and should be avoioded when possible.
159
+ // - priority must be less than 10 to allow WP to enqueue
160
+ if( $args['uploader'] ) {
161
+ add_action($actions['admin_footer'], 'acf_enqueue_uploader', 5);
162
+ }
163
+
164
+ // enqueue
165
+ wp_enqueue_script('acf-input');
166
+ wp_enqueue_style('acf-input');
167
+
168
+ // localize text
169
+ acf_localize_text(array(
170
+
171
+ // unload
172
+ 'The changes you made will be lost if you navigate away from this page' => __('The changes you made will be lost if you navigate away from this page', 'acf'),
173
+
174
+ // media
175
+ 'Select.verb' => _x('Select', 'verb', 'acf'),
176
+ 'Edit.verb' => _x('Edit', 'verb', 'acf'),
177
+ 'Update.verb' => _x('Update', 'verb', 'acf'),
178
+ 'Uploaded to this post' => __('Uploaded to this post', 'acf'),
179
+ 'Expand Details' => __('Expand Details', 'acf'),
180
+ 'Collapse Details' => __('Collapse Details', 'acf'),
181
+ 'Restricted' => __('Restricted', 'acf'),
182
+ 'All images' => __('All images', 'acf'),
183
+
184
+ // validation
185
+ 'Validation successful' => __('Validation successful', 'acf'),
186
+ 'Validation failed' => __('Validation failed', 'acf'),
187
+ '1 field requires attention' => __('1 field requires attention', 'acf'),
188
+ '%d fields require attention' => __('%d fields require attention', 'acf'),
189
+
190
+ // tooltip
191
+ 'Are you sure?' => __('Are you sure?','acf'),
192
+ 'Yes' => __('Yes','acf'),
193
+ 'No' => __('No','acf'),
194
+ 'Remove' => __('Remove','acf'),
195
+ 'Cancel' => __('Cancel','acf'),
196
+
197
+ // conditions
198
+ 'Has any value' => __('Has any value', 'acf'),
199
+ 'Has no value' => __('Has no value', 'acf'),
200
+ 'Value is equal to' => __('Value is equal to', 'acf'),
201
+ 'Value is not equal to' => __('Value is not equal to', 'acf'),
202
+ 'Value matches pattern' => __('Value matches pattern', 'acf'),
203
+ 'Value contains' => __('Value contains', 'acf'),
204
+ 'Value is greater than' => __('Value is greater than', 'acf'),
205
+ 'Value is less than' => __('Value is less than', 'acf'),
206
+ 'Selection is greater than' => __('Selection is greater than', 'acf'),
207
+ 'Selection is less than' => __('Selection is less than', 'acf'),
208
+ ));
209
+
210
+ // action
211
+ do_action('acf/enqueue_scripts');
212
+ }
213
+
214
+
215
+ /**
216
+ * admin_enqueue_scripts
217
+ *
218
+ * description
219
+ *
220
+ * @date 16/4/18
221
+ * @since 5.6.9
222
+ *
223
+ * @param type $var Description. Default.
224
+ * @return type Description.
225
+ */
226
+
227
+ function admin_enqueue_scripts() {
228
+
229
+ // vars
230
+ $text = array();
231
+
232
+ // actions
233
+ do_action('acf/admin_enqueue_scripts');
234
+ do_action('acf/input/admin_enqueue_scripts');
235
+
236
+ // only include translated strings
237
+ foreach( $this->text as $k => $v ) {
238
+ if( str_replace('.verb', '', $k) !== $v ) {
239
+ $text[ $k ] = $v;
240
+ }
241
+ }
242
+
243
+ // localize text
244
+ if( $text ) {
245
+ wp_localize_script( 'acf-input', 'acfL10n', $text );
246
+ }
247
+ }
248
+
249
+
250
+ /**
251
+ * admin_print_scripts
252
+ *
253
+ * description
254
+ *
255
+ * @date 18/4/18
256
+ * @since 5.6.9
257
+ *
258
+ * @param type $var Description. Default.
259
+ * @return type Description.
260
+ */
261
+
262
+ function admin_print_scripts() {
263
+ do_action('acf/admin_print_scripts');
264
+ }
265
+
266
+
267
+ /**
268
+ * admin_head
269
+ *
270
+ * description
271
+ *
272
+ * @date 16/4/18
273
+ * @since 5.6.9
274
+ *
275
+ * @param type $var Description. Default.
276
+ * @return type Description.
277
+ */
278
+
279
+ function admin_head() {
280
+
281
+ // actions
282
+ do_action('acf/admin_head');
283
+ do_action('acf/input/admin_head');
284
+ }
285
+
286
+
287
+ /**
288
+ * admin_footer
289
+ *
290
+ * description
291
+ *
292
+ * @date 16/4/18
293
+ * @since 5.6.9
294
+ *
295
+ * @param type $var Description. Default.
296
+ * @return type Description.
297
+ */
298
+
299
+ function admin_footer() {
300
+
301
+ // global
302
+ global $wp_version;
303
+
304
+ // get data
305
+ $data = wp_parse_args($this->data, array(
306
+ 'screen' => acf_get_form_data('screen'),
307
+ 'post_id' => acf_get_form_data('post_id'),
308
+ 'nonce' => wp_create_nonce( 'acf_nonce' ),
309
+ 'admin_url' => admin_url(),
310
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
311
+ 'validation' => acf_get_form_data('validation'),
312
+ 'wp_version' => $wp_version,
313
+ 'acf_version' => acf_get_setting('version'),
314
+ 'browser' => acf_get_browser(),
315
+ 'locale' => acf_get_locale(),
316
+ 'rtl' => is_rtl()
317
+ ));
318
+
319
+ // get l10n (old)
320
+ $l10n = apply_filters( 'acf/input/admin_l10n', array() );
321
+
322
+ // todo: force 'acf-input' script enqueue if not yet included
323
+ // - fixes potential timing issue if acf_enqueue_assest() was called during body
324
+
325
+ // localize data
326
+ ?>
327
+ <script type="text/javascript">
328
+ acf.data = <?php echo wp_json_encode($data); ?>;
329
+ acf.l10n = <?php echo wp_json_encode($l10n); ?>;
330
+ </script>
331
+ <?php
332
+
333
+ // actions
334
+ do_action('acf/admin_footer');
335
+ do_action('acf/input/admin_footer');
336
+
337
+ // trigger prepare
338
+ ?>
339
+ <script type="text/javascript">
340
+ acf.doAction('prepare');
341
+ </script>
342
+ <?php
343
+
344
+ }
345
+
346
+
347
+ /**
348
+ * admin_print_footer_scripts
349
+ *
350
+ * description
351
+ *
352
+ * @date 18/4/18
353
+ * @since 5.6.9
354
+ *
355
+ * @param type $var Description. Default.
356
+ * @return type Description.
357
+ */
358
+
359
+ function admin_print_footer_scripts() {
360
+ do_action('acf/admin_print_footer_scripts');
361
+ }
362
+
363
+ /*
364
+ * enqueue_uploader
365
+ *
366
+ * This function will render a WP WYSIWYG and enqueue media
367
+ *
368
+ * @type function
369
+ * @date 27/10/2014
370
+ * @since 5.0.9
371
+ *
372
+ * @param n/a
373
+ * @return n/a
374
+ */
375
+
376
+ function enqueue_uploader() {
377
+
378
+ // run only once
379
+ if( acf_has_done('enqueue_uploader') ) {
380
+ return;
381
+ }
382
+
383
+ // bail early if doing ajax
384
+ if( acf_is_ajax() ) {
385
+ return;
386
+ }
387
+
388
+ // enqueue media if user can upload
389
+ if( current_user_can('upload_files') ) {
390
+ wp_enqueue_media();
391
+ }
392
+
393
+ // create dummy editor
394
+ ?>
395
+ <div id="acf-hidden-wp-editor" class="acf-hidden">
396
+ <?php wp_editor( '', 'acf_content' ); ?>
397
+ </div>
398
+ <?php
399
+ }
400
+ }
401
+
402
+ // instantiate
403
+ acf_new_instance('ACF_Assets');
404
+
405
+ endif; // class_exists check
406
+
407
+
408
+ /**
409
+ * acf_localize_text
410
+ *
411
+ * description
412
+ *
413
+ * @date 13/4/18
414
+ * @since 5.6.9
415
+ *
416
+ * @param type $var Description. Default.
417
+ * @return type Description.
418
+ */
419
+
420
+ function acf_localize_text( $text ) {
421
+ return acf_get_instance('ACF_Assets')->add_text( $text );
422
+ }
423
+
424
+
425
+ /**
426
+ * acf_localize_data
427
+ *
428
+ * description
429
+ *
430
+ * @date 13/4/18
431
+ * @since 5.6.9
432
+ *
433
+ * @param type $var Description. Default.
434
+ * @return type Description.
435
+ */
436
+
437
+ function acf_localize_data( $data ) {
438
+ return acf_get_instance('ACF_Assets')->add_data( $data );
439
+ }
440
+
441
+
442
+ /*
443
+ * acf_enqueue_scripts
444
+ *
445
+ *
446
+ *
447
+ * @type function
448
+ * @date 6/10/13
449
+ * @since 5.0.0
450
+ *
451
+ * @param n/a
452
+ * @return n/a
453
+ */
454
+
455
+ function acf_enqueue_scripts( $args = array() ) {
456
+ return acf_get_instance('ACF_Assets')->enqueue_scripts( $args );
457
+ }
458
+
459
+
460
+ /*
461
+ * acf_enqueue_uploader
462
+ *
463
+ * This function will render a WP WYSIWYG and enqueue media
464
+ *
465
+ * @type function
466
+ * @date 27/10/2014
467
+ * @since 5.0.9
468
+ *
469
+ * @param n/a
470
+ * @return n/a
471
+ */
472
+
473
+ function acf_enqueue_uploader() {
474
+ return acf_get_instance('ACF_Assets')->enqueue_uploader();
475
+ }
476
+
477
+ ?>
includes/compatibility.php CHANGED
@@ -279,23 +279,18 @@ class acf_compatibility {
279
  if( !empty($field['date_format']) ) {
280
 
281
  // extract vars
282
- $date_format = acf_extract_var( $field, 'date_format' );
283
- $display_format = acf_extract_var( $field, 'display_format' );
284
-
285
 
286
  // convert from js to php
287
- //$date_format = acf_convert_date_to_php( $date_format );
288
  $display_format = acf_convert_date_to_php( $display_format );
289
 
290
-
291
- // bail early if already matches 'Ymd'
292
- if( $date_format === 'yymmdd' ) return $field;
293
-
294
-
295
  // append settings
296
  $field['display_format'] = $display_format;
297
  $field['save_format'] = $date_format;
298
 
 
 
299
  }
300
 
301
 
279
  if( !empty($field['date_format']) ) {
280
 
281
  // extract vars
282
+ $date_format = $field['date_format'];
283
+ $display_format = $field['display_format'];
 
284
 
285
  // convert from js to php
 
286
  $display_format = acf_convert_date_to_php( $display_format );
287
 
 
 
 
 
 
288
  // append settings
289
  $field['display_format'] = $display_format;
290
  $field['save_format'] = $date_format;
291
 
292
+ // clean up
293
+ unset($field['date_format']);
294
  }
295
 
296
 
includes/fields.php CHANGED
@@ -6,7 +6,6 @@ if( ! class_exists('acf_fields') ) :
6
 
7
  class acf_fields {
8
 
9
-
10
  /** @var array Contains an array of field type instances */
11
  var $types = array();
12
 
@@ -25,16 +24,14 @@ class acf_fields {
25
  */
26
 
27
  function __construct() {
28
-
29
  /* do nothing */
30
-
31
  }
32
 
33
 
34
  /*
35
  * register_field_type
36
  *
37
- * This function will store a field type class
38
  *
39
  * @type function
40
  * @date 6/07/2016
@@ -46,24 +43,22 @@ class acf_fields {
46
 
47
  function register_field_type( $class ) {
48
 
 
49
  if( $class instanceOf acf_field ) {
50
-
51
  $this->types[ $class->name ] = $class;
52
-
 
53
  } else {
54
-
55
  $instance = new $class();
56
  $this->types[ $instance->name ] = $instance;
57
-
58
  }
59
-
60
  }
61
 
62
 
63
  /*
64
  * get_field_type
65
  *
66
- * This function will return a field type class
67
  *
68
  * @type function
69
  * @date 6/07/2016
@@ -74,9 +69,7 @@ class acf_fields {
74
  */
75
 
76
  function get_field_type( $name ) {
77
-
78
  return isset( $this->types[$name] ) ? $this->types[$name] : null;
79
-
80
  }
81
 
82
 
@@ -94,9 +87,7 @@ class acf_fields {
94
  */
95
 
96
  function is_field_type( $name ) {
97
-
98
  return isset( $this->types[$name] );
99
-
100
  }
101
 
102
 
@@ -104,7 +95,7 @@ class acf_fields {
104
  * register_field_type_info
105
  *
106
  * This function will store a basic array of info about the field type
107
- * to later be overriden by the avbove register_field_type function
108
  *
109
  * @type function
110
  * @date 29/5/17
@@ -119,14 +110,13 @@ class acf_fields {
119
  // convert to object
120
  $instance = (object) $info;
121
  $this->types[ $instance->name ] = $instance;
122
-
123
- }
124
 
125
 
126
  /*
127
  * get_field_types
128
  *
129
- * This function will return an array of all field type infos
130
  *
131
  * @type function
132
  * @date 6/07/2016
@@ -137,46 +127,8 @@ class acf_fields {
137
  */
138
 
139
  function get_field_types() {
140
-
141
- // vars
142
- $groups = array();
143
- $l10n = array(
144
- 'basic' => __('Basic', 'acf'),
145
- 'content' => __('Content', 'acf'),
146
- 'choice' => __('Choice', 'acf'),
147
- 'relational' => __('Relational', 'acf'),
148
- 'jquery' => __('jQuery', 'acf'),
149
- 'layout' => __('Layout', 'acf'),
150
- );
151
-
152
-
153
- // loop
154
- foreach( $this->types as $type ) {
155
-
156
- // bail ealry if not public
157
- if( !$type->public ) continue;
158
-
159
-
160
- // translate
161
- $cat = $type->category;
162
- $cat = isset( $l10n[$cat] ) ? $l10n[$cat] : $cat;
163
-
164
-
165
- // append
166
- $groups[ $cat ][ $type->name ] = $type->label;
167
-
168
- }
169
-
170
-
171
- // filter
172
- $groups = apply_filters('acf/get_field_types', $groups);
173
-
174
-
175
- // return
176
- return $groups;
177
-
178
  }
179
-
180
  }
181
 
182
 
@@ -200,16 +152,14 @@ endif; // class_exists check
200
  */
201
 
202
  function acf_register_field_type( $class ) {
203
-
204
  return acf()->fields->register_field_type( $class );
205
-
206
  }
207
 
208
 
209
  /*
210
- * acf_get_field_type
211
  *
212
- * alias of acf()->fields->get_field_type()
213
  *
214
  * @type function
215
  * @date 31/5/17
@@ -219,17 +169,15 @@ function acf_register_field_type( $class ) {
219
  * @return n/a
220
  */
221
 
222
- function acf_get_field_type( $name ) {
223
-
224
- return acf()->fields->get_field_type( $name );
225
-
226
  }
227
 
228
 
229
  /*
230
- * acf_register_field_type_info
231
  *
232
- * alias of acf()->fields->register_field_type_info()
233
  *
234
  * @type function
235
  * @date 31/5/17
@@ -239,10 +187,8 @@ function acf_get_field_type( $name ) {
239
  * @return n/a
240
  */
241
 
242
- function acf_register_field_type_info( $info ) {
243
-
244
- return acf()->fields->register_field_type_info( $info );
245
-
246
  }
247
 
248
 
@@ -259,10 +205,51 @@ function acf_register_field_type_info( $info ) {
259
  * @return n/a
260
  */
261
 
262
- function acf_get_field_types() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
 
264
- return acf()->fields->get_field_types();
 
 
265
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
 
268
 
@@ -280,9 +267,7 @@ function acf_get_field_types() {
280
  */
281
 
282
  function acf_is_field_type( $name = '' ) {
283
-
284
  return acf()->fields->is_field_type( $name );
285
-
286
  }
287
 
288
 
@@ -300,10 +285,8 @@ function acf_is_field_type( $name = '' ) {
300
  */
301
 
302
  function acf_get_field_type_prop( $name = '', $prop = '' ) {
303
-
304
  $type = acf_get_field_type( $name );
305
  return ($type && isset($type->$prop)) ? $type->$prop : null;
306
-
307
  }
308
 
309
 
@@ -321,10 +304,8 @@ function acf_get_field_type_prop( $name = '', $prop = '' ) {
321
  */
322
 
323
  function acf_get_field_type_label( $name = '' ) {
324
-
325
- $type = acf_get_field_type( $name );
326
- return $type ? $type->label : '<span class="acf-tooltip-js" title="'.__('Field type does not exist', 'acf').'">'.__('Unknown', 'acf').'</span>';
327
-
328
  }
329
 
330
 
@@ -347,9 +328,9 @@ function acf_field_type_exists( $type = '' ) {
347
 
348
 
349
  /*
350
- * acf_get_grouped_field_types (deprecated)
351
  *
352
- * deprecated in favour of acf_get_field_types()
353
  *
354
  * @type function
355
  * @date 1/10/13
@@ -360,7 +341,38 @@ function acf_field_type_exists( $type = '' ) {
360
  */
361
 
362
  function acf_get_grouped_field_types() {
363
- return acf_get_field_types();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  }
365
 
366
  ?>
6
 
7
  class acf_fields {
8
 
 
9
  /** @var array Contains an array of field type instances */
10
  var $types = array();
11
 
24
  */
25
 
26
  function __construct() {
 
27
  /* do nothing */
 
28
  }
29
 
30
 
31
  /*
32
  * register_field_type
33
  *
34
+ * This function will register a field type instance
35
  *
36
  * @type function
37
  * @date 6/07/2016
43
 
44
  function register_field_type( $class ) {
45
 
46
+ // allow instance
47
  if( $class instanceOf acf_field ) {
 
48
  $this->types[ $class->name ] = $class;
49
+
50
+ // allow class name
51
  } else {
 
52
  $instance = new $class();
53
  $this->types[ $instance->name ] = $instance;
 
54
  }
 
55
  }
56
 
57
 
58
  /*
59
  * get_field_type
60
  *
61
+ * This function will return a field type instance
62
  *
63
  * @type function
64
  * @date 6/07/2016
69
  */
70
 
71
  function get_field_type( $name ) {
 
72
  return isset( $this->types[$name] ) ? $this->types[$name] : null;
 
73
  }
74
 
75
 
87
  */
88
 
89
  function is_field_type( $name ) {
 
90
  return isset( $this->types[$name] );
 
91
  }
92
 
93
 
95
  * register_field_type_info
96
  *
97
  * This function will store a basic array of info about the field type
98
+ * to later be overriden by the above register_field_type function
99
  *
100
  * @type function
101
  * @date 29/5/17
110
  // convert to object
111
  $instance = (object) $info;
112
  $this->types[ $instance->name ] = $instance;
113
+ }
 
114
 
115
 
116
  /*
117
  * get_field_types
118
  *
119
+ * This function will return an array of all field types
120
  *
121
  * @type function
122
  * @date 6/07/2016
127
  */
128
 
129
  function get_field_types() {
130
+ return $this->types;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  }
 
132
  }
133
 
134
 
152
  */
153
 
154
  function acf_register_field_type( $class ) {
 
155
  return acf()->fields->register_field_type( $class );
 
156
  }
157
 
158
 
159
  /*
160
+ * acf_register_field_type_info
161
  *
162
+ * alias of acf()->fields->register_field_type_info()
163
  *
164
  * @type function
165
  * @date 31/5/17
169
  * @return n/a
170
  */
171
 
172
+ function acf_register_field_type_info( $info ) {
173
+ return acf()->fields->register_field_type_info( $info );
 
 
174
  }
175
 
176
 
177
  /*
178
+ * acf_get_field_type
179
  *
180
+ * alias of acf()->fields->get_field_type()
181
  *
182
  * @type function
183
  * @date 31/5/17
187
  * @return n/a
188
  */
189
 
190
+ function acf_get_field_type( $name ) {
191
+ return acf()->fields->get_field_type( $name );
 
 
192
  }
193
 
194
 
205
  * @return n/a
206
  */
207
 
208
+ function acf_get_field_types( $args = array() ) {
209
+
210
+ // default
211
+ $args = wp_parse_args($args, array(
212
+ 'public' => true, // true, false
213
+ ));
214
+
215
+ // get field types
216
+ $field_types = acf()->fields->get_field_types();
217
+
218
+ // filter
219
+ return wp_filter_object_list( $field_types, $args );
220
+ }
221
+
222
+
223
+ /**
224
+ * acf_get_field_types_info
225
+ *
226
+ * Returns an array containing information about each field type
227
+ *
228
+ * @date 18/6/18
229
+ * @since 5.6.9
230
+ *
231
+ * @param type $var Description. Default.
232
+ * @return type Description.
233
+ */
234
+
235
+ function acf_get_field_types_info( $args = array() ) {
236
 
237
+ // vars
238
+ $data = array();
239
+ $field_types = acf_get_field_types();
240
 
241
+ // loop
242
+ foreach( $field_types as $type ) {
243
+ $data[ $type->name ] = array(
244
+ 'label' => $type->label,
245
+ 'name' => $type->name,
246
+ 'category' => $type->category,
247
+ 'public' => $type->public
248
+ );
249
+ }
250
+
251
+ // return
252
+ return $data;
253
  }
254
 
255
 
267
  */
268
 
269
  function acf_is_field_type( $name = '' ) {
 
270
  return acf()->fields->is_field_type( $name );
 
271
  }
272
 
273
 
285
  */
286
 
287
  function acf_get_field_type_prop( $name = '', $prop = '' ) {
 
288
  $type = acf_get_field_type( $name );
289
  return ($type && isset($type->$prop)) ? $type->$prop : null;
 
290
  }
291
 
292
 
304
  */
305
 
306
  function acf_get_field_type_label( $name = '' ) {
307
+ $label = acf_get_field_type_prop( $name, 'label' );
308
+ return $label ? $label : '<span class="acf-tooltip-js" title="'.__('Field type does not exist', 'acf').'">'.__('Unknown', 'acf').'</span>';
 
 
309
  }
310
 
311
 
328
 
329
 
330
  /*
331
+ * acf_get_grouped_field_types
332
  *
333
+ * Returns an multi-dimentional array of field types "name => label" grouped by category
334
  *
335
  * @type function
336
  * @date 1/10/13
341
  */
342
 
343
  function acf_get_grouped_field_types() {
344
+
345
+ // vars
346
+ $types = acf_get_field_types();
347
+ $groups = array();
348
+ $l10n = array(
349
+ 'basic' => __('Basic', 'acf'),
350
+ 'content' => __('Content', 'acf'),
351
+ 'choice' => __('Choice', 'acf'),
352
+ 'relational' => __('Relational', 'acf'),
353
+ 'jquery' => __('jQuery', 'acf'),
354
+ 'layout' => __('Layout', 'acf'),
355
+ );
356
+
357
+
358
+ // loop
359
+ foreach( $types as $type ) {
360
+
361
+ // translate
362
+ $cat = $type->category;
363
+ $cat = isset( $l10n[$cat] ) ? $l10n[$cat] : $cat;
364
+
365
+ // append
366
+ $groups[ $cat ][ $type->name ] = $type->label;
367
+ }
368
+
369
+
370
+ // filter
371
+ $groups = apply_filters('acf/get_field_types', $groups);
372
+
373
+
374
+ // return
375
+ return $groups;
376
  }
377
 
378
  ?>
includes/fields/class-acf-field-checkbox.php CHANGED
@@ -366,7 +366,12 @@ class acf_field_checkbox extends acf_field {
366
  'name' => 'save_custom',
367
  'type' => 'true_false',
368
  'ui' => 1,
369
- 'message' => __("Save 'custom' values to the field's choices", 'acf')
 
 
 
 
 
370
  ));
371
 
372
 
366
  'name' => 'save_custom',
367
  'type' => 'true_false',
368
  'ui' => 1,
369
+ 'message' => __("Save 'custom' values to the field's choices", 'acf'),
370
+ 'conditions' => array(
371
+ 'field' => 'allow_custom',
372
+ 'operator' => '==',
373
+ 'value' => 1
374
+ )
375
  ));
376
 
377
 
includes/fields/class-acf-field-date_picker.php CHANGED
@@ -29,49 +29,6 @@ class acf_field_date_picker extends acf_field {
29
  'return_format' => 'd/m/Y',
30
  'first_day' => 1
31
  );
32
- $this->l10n = array(
33
- 'closeText' => _x('Done', 'Date Picker JS closeText', 'acf'),
34
- 'currentText' => _x('Today', 'Date Picker JS currentText', 'acf'),
35
- 'nextText' => _x('Next', 'Date Picker JS nextText', 'acf'),
36
- 'prevText' => _x('Prev', 'Date Picker JS prevText', 'acf'),
37
- 'weekHeader' => _x('Wk', 'Date Picker JS weekHeader', 'acf'),
38
- );
39
-
40
-
41
- // actions
42
- add_action('init', array($this, 'init'));
43
-
44
- }
45
-
46
-
47
- /*
48
- * init
49
- *
50
- * This function is run on the 'init' action to set the field's $l10n data. Before the init action,
51
- * access to the $wp_locale variable is not possible.
52
- *
53
- * @type action (init)
54
- * @date 3/09/13
55
- *
56
- * @param n/a
57
- * @return n/a
58
- */
59
-
60
- function init() {
61
-
62
- // globals
63
- global $wp_locale;
64
-
65
-
66
- // append
67
- $this->l10n = array_merge($this->l10n, array(
68
- 'monthNames' => array_values( $wp_locale->month ),
69
- 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
70
- 'dayNames' => array_values( $wp_locale->weekday ),
71
- 'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
72
- 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev )
73
- ));
74
-
75
  }
76
 
77
 
@@ -91,16 +48,32 @@ class acf_field_date_picker extends acf_field {
91
  function input_admin_enqueue_scripts() {
92
 
93
  // bail ealry if no enqueue
94
- if( !acf_get_setting('enqueue_datepicker') ) return;
 
 
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  // script
98
  wp_enqueue_script('jquery-ui-datepicker');
99
 
100
-
101
  // style
102
- wp_enqueue_style('acf-datepicker', acf_get_url('assets/inc/datepicker/jquery-ui.min.css'), '', '1.11.4' );
103
-
104
  }
105
 
106
 
29
  'return_format' => 'd/m/Y',
30
  'first_day' => 1
31
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
 
48
  function input_admin_enqueue_scripts() {
49
 
50
  // bail ealry if no enqueue
51
+ if( !acf_get_setting('enqueue_datepicker') ) {
52
+ return;
53
+ }
54
 
55
+ // localize
56
+ global $wp_locale;
57
+ acf_localize_data(array(
58
+ 'datePickerL10n' => array(
59
+ 'closeText' => _x('Done', 'Date Picker JS closeText', 'acf'),
60
+ 'currentText' => _x('Today', 'Date Picker JS currentText', 'acf'),
61
+ 'nextText' => _x('Next', 'Date Picker JS nextText', 'acf'),
62
+ 'prevText' => _x('Prev', 'Date Picker JS prevText', 'acf'),
63
+ 'weekHeader' => _x('Wk', 'Date Picker JS weekHeader', 'acf'),
64
+ 'monthNames' => array_values( $wp_locale->month ),
65
+ 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
66
+ 'dayNames' => array_values( $wp_locale->weekday ),
67
+ 'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
68
+ 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev )
69
+ )
70
+ ));
71
 
72
  // script
73
  wp_enqueue_script('jquery-ui-datepicker');
74
 
 
75
  // style
76
+ wp_enqueue_style('acf-datepicker', acf_get_url('assets/inc/datepicker/jquery-ui.min.css'), array(), '1.11.4' );
 
77
  }
78
 
79
 
includes/fields/class-acf-field-date_time_picker.php CHANGED
@@ -29,28 +29,6 @@ class acf_field_date_and_time_picker extends acf_field {
29
  'return_format' => 'd/m/Y g:i a',
30
  'first_day' => 1
31
  );
32
- $this->l10n = array(
33
- 'timeOnlyTitle' => _x('Choose Time', 'Date Time Picker JS timeOnlyTitle', 'acf'),
34
- 'timeText' => _x('Time', 'Date Time Picker JS timeText', 'acf'),
35
- 'hourText' => _x('Hour', 'Date Time Picker JS hourText', 'acf'),
36
- 'minuteText' => _x('Minute', 'Date Time Picker JS minuteText', 'acf'),
37
- 'secondText' => _x('Second', 'Date Time Picker JS secondText', 'acf'),
38
- 'millisecText' => _x('Millisecond', 'Date Time Picker JS millisecText', 'acf'),
39
- 'microsecText' => _x('Microsecond', 'Date Time Picker JS microsecText', 'acf'),
40
- 'timezoneText' => _x('Time Zone', 'Date Time Picker JS timezoneText', 'acf'),
41
- 'currentText' => _x('Now', 'Date Time Picker JS currentText', 'acf'),
42
- 'closeText' => _x('Done', 'Date Time Picker JS closeText', 'acf'),
43
- 'selectText' => _x('Select', 'Date Time Picker JS selectText', 'acf'),
44
- 'amNames' => array(
45
- _x('AM', 'Date Time Picker JS amText', 'acf'),
46
- _x('A', 'Date Time Picker JS amTextShort', 'acf'),
47
- ),
48
- 'pmNames' => array(
49
- _x('PM', 'Date Time Picker JS pmText', 'acf'),
50
- _x('P', 'Date Time Picker JS pmTextShort', 'acf'),
51
- )
52
- );
53
-
54
  }
55
 
56
 
@@ -84,6 +62,30 @@ class acf_field_date_and_time_picker extends acf_field {
84
  // style
85
  wp_enqueue_style('acf-timepicker', acf_get_url('assets/inc/timepicker/jquery-ui-timepicker-addon.min.css'), '', $version);
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
 
29
  'return_format' => 'd/m/Y g:i a',
30
  'first_day' => 1
31
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
 
62
  // style
63
  wp_enqueue_style('acf-timepicker', acf_get_url('assets/inc/timepicker/jquery-ui-timepicker-addon.min.css'), '', $version);
64
 
65
+ // localize
66
+ acf_localize_data(array(
67
+ 'dateTimePickerL10n' => array(
68
+ 'timeOnlyTitle' => _x('Choose Time', 'Date Time Picker JS timeOnlyTitle', 'acf'),
69
+ 'timeText' => _x('Time', 'Date Time Picker JS timeText', 'acf'),
70
+ 'hourText' => _x('Hour', 'Date Time Picker JS hourText', 'acf'),
71
+ 'minuteText' => _x('Minute', 'Date Time Picker JS minuteText', 'acf'),
72
+ 'secondText' => _x('Second', 'Date Time Picker JS secondText', 'acf'),
73
+ 'millisecText' => _x('Millisecond', 'Date Time Picker JS millisecText', 'acf'),
74
+ 'microsecText' => _x('Microsecond', 'Date Time Picker JS microsecText', 'acf'),
75
+ 'timezoneText' => _x('Time Zone', 'Date Time Picker JS timezoneText', 'acf'),
76
+ 'currentText' => _x('Now', 'Date Time Picker JS currentText', 'acf'),
77
+ 'closeText' => _x('Done', 'Date Time Picker JS closeText', 'acf'),
78
+ 'selectText' => _x('Select', 'Date Time Picker JS selectText', 'acf'),
79
+ 'amNames' => array(
80
+ _x('AM', 'Date Time Picker JS amText', 'acf'),
81
+ _x('A', 'Date Time Picker JS amTextShort', 'acf'),
82
+ ),
83
+ 'pmNames' => array(
84
+ _x('PM', 'Date Time Picker JS pmText', 'acf'),
85
+ _x('P', 'Date Time Picker JS pmTextShort', 'acf'),
86
+ )
87
+ )
88
+ ));
89
  }
90
 
91
 
includes/fields/class-acf-field-file.php CHANGED
@@ -31,17 +31,33 @@ class acf_field_file extends acf_field {
31
  'max_size' => 0,
32
  'mime_types' => ''
33
  );
34
- $this->l10n = array(
35
- 'select' => __("Select File",'acf'),
36
- 'edit' => __("Edit File",'acf'),
37
- 'update' => __("Update File",'acf'),
38
- 'uploadedTo' => __("Uploaded to this post",'acf'),
39
- );
40
-
41
 
42
  // filters
43
- add_filter('get_media_item_args', array($this, 'get_media_item_args'));
44
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
 
31
  'max_size' => 0,
32
  'mime_types' => ''
33
  );
 
 
 
 
 
 
 
34
 
35
  // filters
36
+ add_filter('get_media_item_args', array($this, 'get_media_item_args'));
37
+ }
38
+
39
+
40
+ /*
41
+ * input_admin_enqueue_scripts
42
+ *
43
+ * description
44
+ *
45
+ * @type function
46
+ * @date 16/12/2015
47
+ * @since 5.3.2
48
+ *
49
+ * @param $post_id (int)
50
+ * @return $post_id (int)
51
+ */
52
+
53
+ function input_admin_enqueue_scripts() {
54
+
55
+ // localize
56
+ acf_localize_text(array(
57
+ 'Select File' => __('Select File', 'acf'),
58
+ 'Edit File' => __('Edit File', 'acf'),
59
+ 'Update File' => __('Update File', 'acf'),
60
+ ));
61
  }
62
 
63
 
includes/fields/class-acf-field-google-map.php CHANGED
@@ -36,11 +36,63 @@ class acf_field_google_map extends acf_field {
36
  'center_lng' => '144.96328',
37
  'zoom' => '14'
38
  );
39
- $this->l10n = array(
40
- 'locating' => __("Locating",'acf'),
41
- 'browser_support' => __("Sorry, this browser does not support geolocation",'acf'),
42
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
 
46
 
@@ -102,7 +154,7 @@ class acf_field_google_map extends acf_field {
102
 
103
  <div class="acf-hidden">
104
  <?php foreach( $field['value'] as $k => $v ):
105
- acf_hidden_input(array( 'name' => $field['name'].'['.$k.']', 'value' => $v, 'class' => 'input-'.$k ));
106
  endforeach; ?>
107
  </div>
108
 
@@ -252,56 +304,6 @@ class acf_field_google_map extends acf_field {
252
  // return
253
  return $value;
254
  }
255
-
256
-
257
- /*
258
- * input_admin_footer
259
- *
260
- * description
261
- *
262
- * @type function
263
- * @date 6/03/2014
264
- * @since 5.0.0
265
- *
266
- * @param $post_id (int)
267
- * @return $post_id (int)
268
- */
269
-
270
- function input_admin_footer() {
271
-
272
- // bail ealry if no qneueu
273
- if( !acf_get_setting('enqueue_google_maps') ) return;
274
-
275
-
276
- // vars
277
- $api = array(
278
- 'key' => acf_get_setting('google_api_key'),
279
- 'client' => acf_get_setting('google_api_client'),
280
- 'libraries' => 'places',
281
- 'ver' => 3,
282
- 'callback' => ''
283
- );
284
-
285
-
286
- // filter
287
- $api = apply_filters('acf/fields/google_map/api', $api);
288
-
289
-
290
- // remove empty
291
- if( empty($api['key']) ) unset($api['key']);
292
- if( empty($api['client']) ) unset($api['client']);
293
-
294
-
295
- // construct url
296
- $url = add_query_arg($api, 'https://maps.googleapis.com/maps/api/js');
297
-
298
- ?>
299
- <script type="text/javascript">
300
- if( acf ) acf.fields.google_map.url = '<?php echo $url; ?>';
301
- </script>
302
- <?php
303
-
304
- }
305
 
306
  }
307
 
36
  'center_lng' => '144.96328',
37
  'zoom' => '14'
38
  );
39
+ }
40
+
41
+
42
+ /*
43
+ * input_admin_enqueue_scripts
44
+ *
45
+ * description
46
+ *
47
+ * @type function
48
+ * @date 16/12/2015
49
+ * @since 5.3.2
50
+ *
51
+ * @param $post_id (int)
52
+ * @return $post_id (int)
53
+ */
54
+
55
+ function input_admin_enqueue_scripts() {
56
 
57
+ // localize
58
+ acf_localize_text(array(
59
+ 'Sorry, this browser does not support geolocation' => __('Sorry, this browser does not support geolocation', 'acf'),
60
+ ));
61
+
62
+
63
+ // bail ealry if no enqueue
64
+ if( !acf_get_setting('enqueue_google_maps') ) {
65
+ return;
66
+ }
67
+
68
+
69
+ // vars
70
+ $api = array(
71
+ 'key' => acf_get_setting('google_api_key'),
72
+ 'client' => acf_get_setting('google_api_client'),
73
+ 'libraries' => 'places',
74
+ 'ver' => 3,
75
+ 'callback' => ''
76
+ );
77
+
78
+
79
+ // filter
80
+ $api = apply_filters('acf/fields/google_map/api', $api);
81
+
82
+
83
+ // remove empty
84
+ if( empty($api['key']) ) unset($api['key']);
85
+ if( empty($api['client']) ) unset($api['client']);
86
+
87
+
88
+ // construct url
89
+ $url = add_query_arg($api, 'https://maps.googleapis.com/maps/api/js');
90
+
91
+
92
+ // localize
93
+ acf_localize_data(array(
94
+ 'google_map_api' => $url
95
+ ));
96
  }
97
 
98
 
154
 
155
  <div class="acf-hidden">
156
  <?php foreach( $field['value'] as $k => $v ):
157
+ acf_hidden_input(array( 'name' => $field['name'].'['.$k.']', 'value' => $v, 'data-name' => $k ));
158
  endforeach; ?>
159
  </div>
160
 
304
  // return
305
  return $value;
306
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
 
308
  }
309
 
includes/fields/class-acf-field-image.php CHANGED
@@ -36,14 +36,6 @@ class acf_field_image extends acf_field {
36
  'max_size' => 0,
37
  'mime_types' => ''
38
  );
39
- $this->l10n = array(
40
- 'select' => __("Select Image",'acf'),
41
- 'edit' => __("Edit Image",'acf'),
42
- 'update' => __("Update Image",'acf'),
43
- 'uploadedTo' => __("Uploaded to this post",'acf'),
44
- 'all' => __("All images",'acf'),
45
- );
46
-
47
 
48
  // filters
49
  add_filter('get_media_item_args', array($this, 'get_media_item_args'));
@@ -51,6 +43,31 @@ class acf_field_image extends acf_field {
51
 
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  /*
56
  * render_field()
36
  'max_size' => 0,
37
  'mime_types' => ''
38
  );
 
 
 
 
 
 
 
 
39
 
40
  // filters
41
  add_filter('get_media_item_args', array($this, 'get_media_item_args'));
43
 
44
  }
45
 
46
+
47
+ /*
48
+ * input_admin_enqueue_scripts
49
+ *
50
+ * description
51
+ *
52
+ * @type function
53
+ * @date 16/12/2015
54
+ * @since 5.3.2
55
+ *
56
+ * @param $post_id (int)
57
+ * @return $post_id (int)
58
+ */
59
+
60
+ function input_admin_enqueue_scripts() {
61
+
62
+ // localize
63
+ acf_localize_text(array(
64
+ 'Select Image' => __('Select Image', 'acf'),
65
+ 'Edit Image' => __('Edit Image', 'acf'),
66
+ 'Update Image' => __('Update Image', 'acf'),
67
+ 'All images' => __('All images', 'acf'),
68
+ ));
69
+ }
70
+
71
 
72
  /*
73
  * render_field()
includes/fields/class-acf-field-oembed.php CHANGED
@@ -202,45 +202,32 @@ class acf_field_oembed extends acf_field {
202
  'class' => 'acf-oembed',
203
  );
204
 
 
205
 
206
  // value
207
  if( $field['value'] ) $atts['class'] .= ' has-value';
208
 
209
  ?>
210
  <div <?php acf_esc_attr_e($atts) ?>>
211
- <?php acf_hidden_input(array( 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'value-input' )); ?>
 
 
212
  <div class="title">
213
-
214
- <div class="title-value">
215
- <h4 data-name="value-title"><?php echo esc_html( $field['value'] ); ?></h4>
216
- </div>
217
-
218
- <div class="title-search">
219
- <input data-name="search-input" type="text" placeholder="<?php _e("Enter URL", 'acf'); ?>" autocomplete="off" />
220
- </div>
221
-
222
  <div class="acf-actions -hover">
223
  <a data-name="clear-button" href="#" class="acf-icon -cancel grey"></a>
224
  </div>
225
-
226
  </div>
 
227
  <div class="canvas">
228
-
229
- <div class="canvas-loading">
230
- <i class="acf-loading"></i>
231
- </div>
232
-
233
- <div class="canvas-error">
234
- <p><strong><?php _e("Error.", 'acf'); ?></strong> <?php _e("No embed found for the given URL.", 'acf'); ?></p>
235
- </div>
236
-
237
- <div class="canvas-media" data-name="value-embed">
238
- <?php if( $field['value'] ) echo $this->wp_oembed_get($field['value'], $field['width'], $field['height']); ?>
239
  </div>
240
-
241
  <i class="acf-icon -picture hide-if-value"></i>
242
-
243
  </div>
 
244
  </div>
245
  <?php
246
 
202
  'class' => 'acf-oembed',
203
  );
204
 
205
+ // <strong><?php _e("Error.", 'acf'); </strong> _e("No embed found for the given URL.", 'acf');
206
 
207
  // value
208
  if( $field['value'] ) $atts['class'] .= ' has-value';
209
 
210
  ?>
211
  <div <?php acf_esc_attr_e($atts) ?>>
212
+
213
+ <?php acf_hidden_input(array( 'class' => 'input-value', 'name' => $field['name'], 'value' => $field['value'] )); ?>
214
+
215
  <div class="title">
216
+ <?php acf_text_input(array( 'class' => 'input-search', 'value' => $field['value'], 'placeholder' => __("Enter URL", 'acf'), 'autocomplete' => 'off' )); ?>
 
 
 
 
 
 
 
 
217
  <div class="acf-actions -hover">
218
  <a data-name="clear-button" href="#" class="acf-icon -cancel grey"></a>
219
  </div>
 
220
  </div>
221
+
222
  <div class="canvas">
223
+ <div class="canvas-media">
224
+ <?php if( $field['value'] ) {
225
+ echo $this->wp_oembed_get($field['value'], $field['width'], $field['height']);
226
+ } ?>
 
 
 
 
 
 
 
227
  </div>
 
228
  <i class="acf-icon -picture hide-if-value"></i>
 
229
  </div>
230
+
231
  </div>
232
  <?php
233
 
includes/fields/class-acf-field-radio.php CHANGED
@@ -267,7 +267,12 @@ class acf_field_radio extends acf_field {
267
  'name' => 'save_other_choice',
268
  'type' => 'true_false',
269
  'ui' => 1,
270
- 'message' => __("Save 'other' values to the field's choices", 'acf')
 
 
 
 
 
271
  ));
272
 
273
 
267
  'name' => 'save_other_choice',
268
  'type' => 'true_false',
269
  'ui' => 1,
270
+ 'message' => __("Save 'other' values to the field's choices", 'acf'),
271
+ 'conditions' => array(
272
+ 'field' => 'other_choice',
273
+ 'operator' => '==',
274
+ 'value' => 1
275
+ )
276
  ));
277
 
278
 
includes/fields/class-acf-field-relationship.php CHANGED
@@ -33,13 +33,6 @@ class acf_field_relationship extends acf_field {
33
  'elements' => array(),
34
  'return_format' => 'object'
35
  );
36
- $this->l10n = array(
37
- 'min' => __("Minimum values reached ( {min} values )",'acf'),
38
- 'max' => __("Maximum values reached ( {max} values )",'acf'),
39
- 'loading' => __('Loading','acf'),
40
- 'empty' => __('No matches found','acf'),
41
- );
42
-
43
 
44
  // extra
45
  add_action('wp_ajax_acf/fields/relationship/query', array($this, 'ajax_query'));
@@ -48,6 +41,31 @@ class acf_field_relationship extends acf_field {
48
  }
49
 
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /*
52
  * ajax_query
53
  *
@@ -565,10 +583,10 @@ class acf_field_relationship extends acf_field {
565
 
566
  <div class="selection">
567
  <div class="choices">
568
- <ul class="acf-bl list"></ul>
569
  </div>
570
  <div class="values">
571
- <ul class="acf-bl list">
572
  <?php if( !empty($field['value']) ):
573
 
574
  // get posts
33
  'elements' => array(),
34
  'return_format' => 'object'
35
  );
 
 
 
 
 
 
 
36
 
37
  // extra
38
  add_action('wp_ajax_acf/fields/relationship/query', array($this, 'ajax_query'));
41
  }
42
 
43
 
44
+ /*
45
+ * input_admin_enqueue_scripts
46
+ *
47
+ * description
48
+ *
49
+ * @type function
50
+ * @date 16/12/2015
51
+ * @since 5.3.2
52
+ *
53
+ * @param $post_id (int)
54
+ * @return $post_id (int)
55
+ */
56
+
57
+ function input_admin_enqueue_scripts() {
58
+
59
+ // localize
60
+ acf_localize_text(array(
61
+ //'Minimum values reached ( {min} values )' => __('Minimum values reached ( {min} values )', 'acf'),
62
+ 'Maximum values reached ( {max} values )' => __('Maximum values reached ( {max} values )', 'acf'),
63
+ 'Loading' => __('Loading', 'acf'),
64
+ 'No matches found' => __('No matches found', 'acf'),
65
+ ));
66
+ }
67
+
68
+
69
  /*
70
  * ajax_query
71
  *
583
 
584
  <div class="selection">
585
  <div class="choices">
586
+ <ul class="acf-bl list choices-list"></ul>
587
  </div>
588
  <div class="values">
589
+ <ul class="acf-bl list values-list">
590
  <?php if( !empty($field['value']) ):
591
 
592
  // get posts
includes/fields/class-acf-field-select.php CHANGED
@@ -34,20 +34,6 @@ class acf_field_select extends acf_field {
34
  'placeholder' => '',
35
  'return_format' => 'value'
36
  );
37
- $this->l10n = array(
38
- 'matches_1' => _x('One result is available, press enter to select it.', 'Select2 JS matches_1', 'acf'),
39
- 'matches_n' => _x('%d results are available, use up and down arrow keys to navigate.', 'Select2 JS matches_n', 'acf'),
40
- 'matches_0' => _x('No matches found', 'Select2 JS matches_0', 'acf'),
41
- 'input_too_short_1' => _x('Please enter 1 or more characters', 'Select2 JS input_too_short_1', 'acf' ),
42
- 'input_too_short_n' => _x('Please enter %d or more characters', 'Select2 JS input_too_short_n', 'acf' ),
43
- 'input_too_long_1' => _x('Please delete 1 character', 'Select2 JS input_too_long_1', 'acf' ),
44
- 'input_too_long_n' => _x('Please delete %d characters', 'Select2 JS input_too_long_n', 'acf' ),
45
- 'selection_too_long_1' => _x('You can only select 1 item', 'Select2 JS selection_too_long_1', 'acf' ),
46
- 'selection_too_long_n' => _x('You can only select %d items', 'Select2 JS selection_too_long_n', 'acf' ),
47
- 'load_more' => _x('Loading more results&hellip;', 'Select2 JS load_more', 'acf' ),
48
- 'searching' => _x('Searching&hellip;', 'Select2 JS searching', 'acf' ),
49
- 'load_fail' => _x('Loading failed', 'Select2 JS load_fail', 'acf' ),
50
- );
51
 
52
 
53
  // ajax
@@ -118,6 +104,24 @@ class acf_field_select extends acf_field {
118
  wp_enqueue_script('select2', $script, array('jquery'), $version );
119
  wp_enqueue_style('select2', $style, '', $version );
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
 
123
 
@@ -262,13 +266,34 @@ class acf_field_select extends acf_field {
262
  }
263
 
264
 
 
 
 
 
 
 
 
 
 
 
 
265
  // allow null
266
  // - have tried array_merge but this causes keys to re-index if is numeric (post ID's)
267
- if( $field['allow_null'] && !$field['multiple'] ) {
268
-
269
- $prepend = array('' => '- ' . $field['placeholder'] . ' -');
270
- $choices = $prepend + $choices;
271
-
 
 
 
 
 
 
 
 
 
 
272
  }
273
 
274
 
@@ -287,11 +312,10 @@ class acf_field_select extends acf_field {
287
 
288
  // multiple
289
  if( $field['multiple'] ) {
290
-
291
  $select['multiple'] = 'multiple';
292
  $select['size'] = 5;
293
  $select['name'] .= '[]';
294
-
295
  }
296
 
297
 
@@ -301,34 +325,12 @@ class acf_field_select extends acf_field {
301
  if( !empty($field['ajax_action']) ) $select['data-ajax_action'] = $field['ajax_action'];
302
 
303
 
304
- // hidden input
305
- if( $field['ui'] ) {
306
-
307
- $v = $value;
308
-
309
- if( $field['multiple'] ) {
310
-
311
- $v = implode('||', $v);
312
-
313
- } else {
314
-
315
- $v = acf_maybe_get($v, 0, '');
316
-
317
- }
318
-
319
- acf_hidden_input(array(
320
- 'id' => $field['id'] . '-input',
321
- 'name' => $field['name'],
322
- 'value' => $v
323
- ));
324
-
325
- } elseif( $field['multiple'] ) {
326
-
327
  acf_hidden_input(array(
328
  'id' => $field['id'] . '-input',
329
  'name' => $field['name']
330
  ));
331
-
332
  }
333
 
334
 
@@ -418,6 +420,11 @@ class acf_field_select extends acf_field {
418
  'name' => 'ajax',
419
  'type' => 'true_false',
420
  'ui' => 1,
 
 
 
 
 
421
  ));
422
 
423
 
34
  'placeholder' => '',
35
  'return_format' => 'value'
36
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
 
39
  // ajax
104
  wp_enqueue_script('select2', $script, array('jquery'), $version );
105
  wp_enqueue_style('select2', $style, '', $version );
106
 
107
+
108
+ // localize
109
+ acf_localize_data(array(
110
+ 'select2L10n' => array(
111
+ 'matches_1' => _x('One result is available, press enter to select it.', 'Select2 JS matches_1', 'acf'),
112
+ 'matches_n' => _x('%d results are available, use up and down arrow keys to navigate.', 'Select2 JS matches_n', 'acf'),
113
+ 'matches_0' => _x('No matches found', 'Select2 JS matches_0', 'acf'),
114
+ 'input_too_short_1' => _x('Please enter 1 or more characters', 'Select2 JS input_too_short_1', 'acf' ),
115
+ 'input_too_short_n' => _x('Please enter %d or more characters', 'Select2 JS input_too_short_n', 'acf' ),
116
+ 'input_too_long_1' => _x('Please delete 1 character', 'Select2 JS input_too_long_1', 'acf' ),
117
+ 'input_too_long_n' => _x('Please delete %d characters', 'Select2 JS input_too_long_n', 'acf' ),
118
+ 'selection_too_long_1' => _x('You can only select 1 item', 'Select2 JS selection_too_long_1', 'acf' ),
119
+ 'selection_too_long_n' => _x('You can only select %d items', 'Select2 JS selection_too_long_n', 'acf' ),
120
+ 'load_more' => _x('Loading more results&hellip;', 'Select2 JS load_more', 'acf' ),
121
+ 'searching' => _x('Searching&hellip;', 'Select2 JS searching', 'acf' ),
122
+ 'load_fail' => _x('Loading failed', 'Select2 JS load_fail', 'acf' ),
123
+ )
124
+ ));
125
  }
126
 
127
 
266
  }
267
 
268
 
269
+ // prepend empty choice for single inputs
270
+ $prepend = false;
271
+
272
+ if( !$field['multiple'] ) {
273
+
274
+ // allow null or ajax
275
+ if( $field['allow_null'] || $field['ajax'] ) {
276
+ $prepend = true;
277
+ }
278
+ }
279
+
280
  // allow null
281
  // - have tried array_merge but this causes keys to re-index if is numeric (post ID's)
282
+ if( $prepend ) {
283
+ $placeholder = '- ' . $field['placeholder'] . ' -';
284
+ $choices = array( '' => $placeholder ) + $choices;
285
+ }
286
+
287
+
288
+ // clean up choices if using ajax
289
+ if( $field['ajax'] ) {
290
+ $minimal = array();
291
+ foreach( $value as $key ) {
292
+ if( isset($choices[ $key ]) ) {
293
+ $minimal[ $key ] = $choices[ $key ];
294
+ }
295
+ }
296
+ $choices = $minimal;
297
  }
298
 
299
 
312
 
313
  // multiple
314
  if( $field['multiple'] ) {
315
+
316
  $select['multiple'] = 'multiple';
317
  $select['size'] = 5;
318
  $select['name'] .= '[]';
 
319
  }
320
 
321
 
325
  if( !empty($field['ajax_action']) ) $select['data-ajax_action'] = $field['ajax_action'];
326
 
327
 
328
+ // hidden input is needed to allow validation to see <select> element with no selected value
329
+ if( $field['multiple'] || $field['ui'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  acf_hidden_input(array(
331
  'id' => $field['id'] . '-input',
332
  'name' => $field['name']
333
  ));
 
334
  }
335
 
336
 
420
  'name' => 'ajax',
421
  'type' => 'true_false',
422
  'ui' => 1,
423
+ 'conditions' => array(
424
+ 'field' => 'ui',
425
+ 'operator' => '==',
426
+ 'value' => 1
427
+ )
428
  ));
429
 
430
 
includes/fields/class-acf-field-taxonomy.php CHANGED
@@ -568,8 +568,9 @@ class acf_field_taxonomy extends acf_field {
568
  $div = array(
569
  'class' => 'acf-taxonomy-field',
570
  'data-save' => $field['save_terms'],
571
- 'data-type' => $field['field_type'],
572
- 'data-taxonomy' => $field['taxonomy']
 
573
  );
574
 
575
 
@@ -722,23 +723,13 @@ class acf_field_taxonomy extends acf_field {
722
  $args = apply_filters('acf/fields/taxonomy/wp_list_categories/name=' . $field['_name'], $args, $field);
723
  $args = apply_filters('acf/fields/taxonomy/wp_list_categories/key=' . $field['key'], $args, $field);
724
 
725
- ?><div class="categorychecklist-holder">
726
-
727
- <ul class="acf-checkbox-list acf-bl">
728
-
729
- <?php if( $field['field_type'] == 'radio' && $field['allow_null'] ): ?>
730
- <li>
731
- <label class="selectit">
732
- <input type="radio" name="<?php echo esc_attr($field['name']); ?>" value="" /> <?php _e("None", 'acf'); ?>
733
- </label>
734
- </li>
735
- <?php endif; ?>
736
-
737
- <?php wp_list_categories( $args ); ?>
738
-
739
- </ul>
740
-
741
- </div><?php
742
 
743
  }
744
 
@@ -795,6 +786,11 @@ class acf_field_taxonomy extends acf_field {
795
  'name' => 'allow_null',
796
  'type' => 'true_false',
797
  'ui' => 1,
 
 
 
 
 
798
  ));
799
 
800
 
@@ -860,100 +856,79 @@ class acf_field_taxonomy extends acf_field {
860
  function ajax_add_term() {
861
 
862
  // vars
863
- $args = acf_parse_args($_POST, array(
864
  'nonce' => '',
865
  'field_key' => '',
866
  'term_name' => '',
867
  'term_parent' => ''
868
  ));
869
 
870
-
871
  // verify nonce
872
- if( ! wp_verify_nonce($args['nonce'], 'acf_nonce') ) {
873
-
874
  die();
875
-
876
- }
877
-
878
 
879
  // load field
880
  $field = acf_get_field( $args['field_key'] );
881
-
882
  if( !$field ) {
883
-
884
  die();
885
-
886
  }
887
 
888
-
889
  // vars
890
  $taxonomy_obj = get_taxonomy($field['taxonomy']);
891
  $taxonomy_label = $taxonomy_obj->labels->singular_name;
892
 
893
-
894
  // validate cap
895
  // note: this situation should never occur due to condition of the add new button
896
  if( !current_user_can( $taxonomy_obj->cap->manage_terms) ) {
897
-
898
- echo '<p><strong>' . __("Error.", 'acf') . '</strong> ' . sprintf( __('User unable to add new %s', 'acf'), $taxonomy_label ) . '</p>';
899
- die;
900
-
901
  }
902
-
903
 
904
  // save?
905
  if( $args['term_name'] ) {
906
 
907
  // exists
908
  if( term_exists($args['term_name'], $field['taxonomy']) ) {
909
-
910
  wp_send_json_error(array(
911
  'error' => sprintf( __('%s already exists', 'acf'), $taxonomy_label )
912
  ));
913
-
914
  }
915
 
916
-
917
- // insert
918
  $extra = array();
919
-
920
  if( $args['term_parent'] ) {
921
-
922
- $extra['parent'] = $args['term_parent'];
923
-
924
  }
925
 
 
926
  $data = wp_insert_term( $args['term_name'], $field['taxonomy'], $extra );
927
 
928
-
929
- // error?
930
  if( is_wp_error($data) ) {
931
-
932
  wp_send_json_error(array(
933
  'error' => $data->get_error_message()
934
  ));
935
-
936
  }
937
 
 
 
938
 
939
- // ancestors
940
  $prefix = '';
941
- $ancestors = get_ancestors( $data['term_id'], $field['taxonomy'] );
942
-
943
  if( !empty($ancestors) ) {
944
-
945
  $prefix = str_repeat('- ', count($ancestors));
946
-
947
  }
948
 
949
-
950
  // success
951
  wp_send_json_success(array(
952
  'message' => sprintf( __('%s added', 'acf'), $taxonomy_label ),
953
- 'term_id' => $data['term_id'],
954
- 'term_name' => $args['term_name'],
955
- 'term_label' => $prefix . $args['term_name'],
956
- 'term_parent' => $args['term_parent']
957
  ));
958
 
959
  }
@@ -994,7 +969,10 @@ class acf_field_taxonomy extends acf_field {
994
  }
995
 
996
 
997
- ?><p class="acf-submit"><button class="acf-button button button-primary" type="submit"><?php _e("Add", 'acf'); ?></button><i class="acf-spinner"></i><span></span></p></form><?php
 
 
 
998
 
999
 
1000
  // die
568
  $div = array(
569
  'class' => 'acf-taxonomy-field',
570
  'data-save' => $field['save_terms'],
571
+ 'data-ftype' => $field['field_type'],
572
+ 'data-taxonomy' => $field['taxonomy'],
573
+ 'data-allow_null' => $field['allow_null']
574
  );
575
 
576
 
723
  $args = apply_filters('acf/fields/taxonomy/wp_list_categories/name=' . $field['_name'], $args, $field);
724
  $args = apply_filters('acf/fields/taxonomy/wp_list_categories/key=' . $field['key'], $args, $field);
725
 
726
+ ?>
727
+ <div class="categorychecklist-holder">
728
+ <ul class="acf-checkbox-list acf-bl">
729
+ <?php wp_list_categories( $args ); ?>
730
+ </ul>
731
+ </div>
732
+ <?php
 
 
 
 
 
 
 
 
 
 
733
 
734
  }
735
 
786
  'name' => 'allow_null',
787
  'type' => 'true_false',
788
  'ui' => 1,
789
+ 'conditions' => array(
790
+ 'field' => 'field_type',
791
+ 'operator' => '!=',
792
+ 'value' => 'checkbox'
793
+ )
794
  ));
795
 
796
 
856
  function ajax_add_term() {
857
 
858
  // vars
859
+ $args = wp_parse_args($_POST, array(
860
  'nonce' => '',
861
  'field_key' => '',
862
  'term_name' => '',
863
  'term_parent' => ''
864
  ));
865
 
 
866
  // verify nonce
867
+ if( !acf_verify_ajax() ) {
 
868
  die();
869
+ }
 
 
870
 
871
  // load field
872
  $field = acf_get_field( $args['field_key'] );
 
873
  if( !$field ) {
 
874
  die();
 
875
  }
876
 
 
877
  // vars
878
  $taxonomy_obj = get_taxonomy($field['taxonomy']);
879
  $taxonomy_label = $taxonomy_obj->labels->singular_name;
880
 
 
881
  // validate cap
882
  // note: this situation should never occur due to condition of the add new button
883
  if( !current_user_can( $taxonomy_obj->cap->manage_terms) ) {
884
+ wp_send_json_error(array(
885
+ 'error' => sprintf( __('User unable to add new %s', 'acf'), $taxonomy_label )
886
+ ));
 
887
  }
 
888
 
889
  // save?
890
  if( $args['term_name'] ) {
891
 
892
  // exists
893
  if( term_exists($args['term_name'], $field['taxonomy']) ) {
 
894
  wp_send_json_error(array(
895
  'error' => sprintf( __('%s already exists', 'acf'), $taxonomy_label )
896
  ));
 
897
  }
898
 
899
+ // vars
 
900
  $extra = array();
 
901
  if( $args['term_parent'] ) {
902
+ $extra['parent'] = (int) $args['term_parent'];
 
 
903
  }
904
 
905
+ // insert
906
  $data = wp_insert_term( $args['term_name'], $field['taxonomy'], $extra );
907
 
908
+ // error
 
909
  if( is_wp_error($data) ) {
 
910
  wp_send_json_error(array(
911
  'error' => $data->get_error_message()
912
  ));
 
913
  }
914
 
915
+ // load term
916
+ $term = get_term($data['term_id']);
917
 
918
+ // prepend ancenstors count to term name
919
  $prefix = '';
920
+ $ancestors = get_ancestors( $term->term_id, $term->taxonomy );
 
921
  if( !empty($ancestors) ) {
 
922
  $prefix = str_repeat('- ', count($ancestors));
 
923
  }
924
 
 
925
  // success
926
  wp_send_json_success(array(
927
  'message' => sprintf( __('%s added', 'acf'), $taxonomy_label ),
928
+ 'term_id' => $term->term_id,
929
+ 'term_name' => $term->name,
930
+ 'term_label' => $prefix . $term->name,
931
+ 'term_parent' => $term->parent
932
  ));
933
 
934
  }
969
  }
970
 
971
 
972
+ ?><p class="acf-submit">
973
+ <button class="acf-submit-button button button-primary" type="submit"><?php _e("Add", 'acf'); ?></button>
974
+ </p>
975
+ </form><?php
976
 
977
 
978
  // die
includes/fields/class-acf-field-true_false.php CHANGED
@@ -156,7 +156,12 @@ class acf_field_true_false extends acf_field {
156
  'instructions' => __('Text shown when active','acf'),
157
  'type' => 'text',
158
  'name' => 'ui_on_text',
159
- 'placeholder' => __('Yes', 'acf')
 
 
 
 
 
160
  ));
161
 
162
 
@@ -166,7 +171,12 @@ class acf_field_true_false extends acf_field {
166
  'instructions' => __('Text shown when inactive','acf'),
167
  'type' => 'text',
168
  'name' => 'ui_off_text',
169
- 'placeholder' => __('No', 'acf')
 
 
 
 
 
170
  ));
171
 
172
  }
156
  'instructions' => __('Text shown when active','acf'),
157
  'type' => 'text',
158
  'name' => 'ui_on_text',
159
+ 'placeholder' => __('Yes', 'acf'),
160
+ 'conditions' => array(
161
+ 'field' => 'ui',
162
+ 'operator' => '==',
163
+ 'value' => 1
164
+ )
165
  ));
166
 
167
 
171
  'instructions' => __('Text shown when inactive','acf'),
172
  'type' => 'text',
173
  'name' => 'ui_off_text',
174
+ 'placeholder' => __('No', 'acf'),
175
+ 'conditions' => array(
176
+ 'field' => 'ui',
177
+ 'operator' => '==',
178
+ 'value' => 1
179
+ )
180
  ));
181
 
182
  }
includes/fields/class-acf-field-wysiwyg.php CHANGED
@@ -35,7 +35,6 @@ class acf_field_wysiwyg extends acf_field {
35
 
36
  // add acf_the_content filters
37
  $this->add_filters();
38
-
39
  }
40
 
41
 
@@ -166,67 +165,55 @@ class acf_field_wysiwyg extends acf_field {
166
 
167
 
168
  /*
169
- * input_admin_footer
170
- *
171
- * description
172
- *
173
- * @type function
174
- * @date 6/03/2014
175
- * @since 5.0.0
176
- *
177
- * @param $post_id (int)
178
- * @return $post_id (int)
179
- */
180
-
181
- function input_admin_footer() {
182
-
183
- // vars
184
- $json = array();
185
  $toolbars = $this->get_toolbars();
186
-
187
 
188
  // bail ealry if no toolbars
189
  if( empty($toolbars) ) {
190
-
191
  return;
192
-
193
  }
194
 
195
-
196
- // loop through toolbars
197
  foreach( $toolbars as $label => $rows ) {
198
 
199
  // vars
200
- $label = sanitize_title( $label );
201
- $label = str_replace('-', '_', $label);
 
202
 
203
 
204
- // append to $json
205
- $json[ $label ] = array();
206
 
207
-
208
- // convert to strings
209
- if( !empty($rows) ) {
210
-
211
  foreach( $rows as $i => $row ) {
212
-
213
- $json[ $label ][ $i ] = implode(',', $row);
214
-
215
  }
216
-
217
  }
218
-
219
  }
220
 
221
-
222
- ?>
223
- <script type="text/javascript">
224
- if( acf ) acf.tinymce.toolbars = <?php echo wp_json_encode($json); ?>;
225
- </script>
226
- <?php
227
-
228
- }
229
-
230
 
231
  /*
232
  * render_field()
@@ -434,7 +421,12 @@ class acf_field_wysiwyg extends acf_field {
434
  'instructions' => '',
435
  'type' => 'select',
436
  'name' => 'toolbar',
437
- 'choices' => $choices
 
 
 
 
 
438
  ));
439
 
440
 
@@ -455,6 +447,11 @@ class acf_field_wysiwyg extends acf_field {
455
  'name' => 'delay',
456
  'type' => 'true_false',
457
  'ui' => 1,
 
 
 
 
 
458
  ));
459
 
460
  }
35
 
36
  // add acf_the_content filters
37
  $this->add_filters();
 
38
  }
39
 
40
 
165
 
166
 
167
  /*
168
+ * input_admin_enqueue_scripts
169
+ *
170
+ * description
171
+ *
172
+ * @type function
173
+ * @date 16/12/2015
174
+ * @since 5.3.2
175
+ *
176
+ * @param $post_id (int)
177
+ * @return $post_id (int)
178
+ */
179
+
180
+ function input_admin_enqueue_scripts() {
181
+
182
+ // vars
183
+ $data = array();
184
  $toolbars = $this->get_toolbars();
185
+
186
 
187
  // bail ealry if no toolbars
188
  if( empty($toolbars) ) {
 
189
  return;
 
190
  }
191
 
192
+
193
+ // loop
194
  foreach( $toolbars as $label => $rows ) {
195
 
196
  // vars
197
+ $key = $label;
198
+ $key = sanitize_title( $key );
199
+ $key = str_replace('-', '_', $key);
200
 
201
 
202
+ // append
203
+ $data[ $key ] = array();
204
 
205
+ if( $rows ) {
 
 
 
206
  foreach( $rows as $i => $row ) {
207
+ $data[ $key ][ $i ] = implode(',', $row);
 
 
208
  }
 
209
  }
 
210
  }
211
 
212
+ // localize
213
+ acf_localize_data(array(
214
+ 'toolbars' => $data
215
+ ));
216
+ }
 
 
 
 
217
 
218
  /*
219
  * render_field()
421
  'instructions' => '',
422
  'type' => 'select',
423
  'name' => 'toolbar',
424
+ 'choices' => $choices,
425
+ 'conditions' => array(
426
+ 'field' => 'tabs',
427
+ 'operator' => '!=',
428
+ 'value' => 'text'
429
+ )
430
  ));
431
 
432
 
447
  'name' => 'delay',
448
  'type' => 'true_false',
449
  'ui' => 1,
450
+ 'conditions' => array(
451
+ 'field' => 'tabs',
452
+ 'operator' => '!=',
453
+ 'value' => 'text'
454
+ )
455
  ));
456
 
457
  }
includes/form.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+ if( ! class_exists('ACF_Form') ) :
6
+
7
+ class ACF_Form {
8
+
9
+ /** @var array Storage for data */
10
+ var $data = array();
11
+
12
+
13
+ /*
14
+ * __construct
15
+ *
16
+ * This function will setup the class functionality.
17
+ *
18
+ * @type function
19
+ * @date 5/03/2014
20
+ * @since 5.0.0
21
+ *
22
+ * @param void
23
+ * @return void
24
+ */
25
+
26
+ function __construct() {
27
+
28
+ // actions
29
+ add_action('acf/save_post', array($this, '_save_post'), 10, 1);
30
+ }
31
+
32
+
33
+ /*
34
+ * set_data
35
+ *
36
+ * Sets data.
37
+ *
38
+ * @type function
39
+ * @date 4/03/2016
40
+ * @since 5.3.2
41
+ *
42
+ * @param array $data An array of data.
43
+ * @return array
44
+ */
45
+
46
+ function set_data( $data = array() ) {
47
+
48
+ // defaults
49
+ $data = wp_parse_args($data, array(
50
+ 'screen' => 'post', // Current screen loaded (post, user, taxonomy, etc)
51
+ 'post_id' => 0, // ID of current post being edited
52
+ 'nonce' => '', // nonce used for $_POST validation (defaults to screen)
53
+ 'validation' => 1, // enables form validation
54
+ 'changed' => 0, // used by revisions and unload to detect change
55
+ ));
56
+
57
+ // crete nonce
58
+ $data['nonce'] = wp_create_nonce($data['screen']);
59
+
60
+ // update
61
+ $this->data = $data;
62
+
63
+ // return
64
+ return $data;
65
+ }
66
+
67
+
68
+ /*
69
+ * get_data
70
+ *
71
+ * Returns data.
72
+ *
73
+ * @type function
74
+ * @date 4/03/2016
75
+ * @since 5.3.2
76
+ *
77
+ * @param string $name The data anme.
78
+ * @return mixed The data.
79
+ */
80
+
81
+ function get_data( $name = false ) {
82
+ return isset($this->data[ $name ]) ? $this->data[ $name ] : null;
83
+ }
84
+
85
+ /**
86
+ * render_data
87
+ *
88
+ * Renders the <div id="acf-form-data"> element with hidden "form data" inputs
89
+ *
90
+ * @date 17/4/18
91
+ * @since 5.6.9
92
+ *
93
+ * @param array $data An array of data.
94
+ * @return void
95
+ */
96
+
97
+ function render_data( $data = array() ) {
98
+
99
+ // set form data
100
+ $data = $this->set_data( $data );
101
+
102
+ ?>
103
+ <div id="acf-form-data" class="acf-hidden">
104
+ <?php
105
+
106
+ // loop
107
+ foreach( $data as $name => $value ) {
108
+
109
+ // input
110
+ acf_hidden_input(array(
111
+ 'id' => '_acf_' . $name,
112
+ 'name' => '_acf_' . $name,
113
+ 'value' => $value
114
+ ));
115
+ }
116
+
117
+ // actions
118
+ do_action('acf/form_data', $data);
119
+ do_action('acf/input/form_data', $data);
120
+
121
+ ?>
122
+ </div>
123
+ <?php
124
+ }
125
+
126
+
127
+ /**
128
+ * save_post
129
+ *
130
+ * Calls the 'acf/save_post' action allowing $_POST data to be saved
131
+ *
132
+ * @date 17/4/18
133
+ * @since 5.6.9
134
+ *
135
+ * @param mixed $post_id The $post_id used to save data to the DB
136
+ * @param array $values Optional. An optional array of data to be saved (modifies $_POST['acf'])
137
+ * @return boolean Returns true on success.
138
+ */
139
+
140
+
141
+ function save_post( $post_id = 0, $values = null ) {
142
+
143
+ // override $_POST
144
+ if( $values !== null ) {
145
+ $_POST['acf'] = $values;
146
+ }
147
+
148
+ // bail early if no values
149
+ if( empty($_POST['acf']) ) {
150
+ return false;
151
+ }
152
+
153
+ // set form data
154
+ $this->set_data(array(
155
+ 'post_id' => $post_id
156
+ ));
157
+
158
+ // action
159
+ do_action('acf/save_post', $post_id);
160
+
161
+ // return
162
+ return true;
163
+ }
164
+
165
+
166
+ /**
167
+ * _save_post
168
+ *
169
+ * Saves the actual $_POST['acf'] data.
170
+ * Performing this logic within an action allows developers to hook in before and after data is saved.
171
+ *
172
+ * @date 24/10/2014
173
+ * @since 5.0.9
174
+ *
175
+ * @param mixed $post_id The $post_id used to save data to the DB
176
+ * @return void.
177
+ */
178
+
179
+ function _save_post( $post_id ) {
180
+
181
+ // bail early if empty
182
+ // - post data may have be modified
183
+ if( empty($_POST['acf']) ) {
184
+ return;
185
+ }
186
+
187
+ // loop
188
+ foreach( $_POST['acf'] as $key => $value ) {
189
+
190
+ // get field
191
+ $field = acf_get_field( $key );
192
+
193
+ // update
194
+ if( $field ) {
195
+ acf_update_value( $value, $post_id, $field );
196
+ }
197
+ }
198
+ }
199
+ }
200
+
201
+ // instantiate
202
+ acf_new_instance('ACF_Form');
203
+
204
+ endif; // class_exists check
205
+
206
+
207
+ /*
208
+ * acf_get_form_data
209
+ *
210
+ * alias of acf()->form->get_data()
211
+ *
212
+ * @type function
213
+ * @date 6/10/13
214
+ * @since 5.0.0
215
+ *
216
+ * @param n/a
217
+ * @return n/a
218
+ */
219
+
220
+ function acf_get_form_data( $name = '' ) {
221
+ return acf_get_instance('ACF_Form')->get_data( $name );
222
+ }
223
+
224
+
225
+ /*
226
+ * acf_set_form_data
227
+ *
228
+ * alias of acf()->form->set_data()
229
+ *
230
+ * @type function
231
+ * @date 6/10/13
232
+ * @since 5.0.0
233
+ *
234
+ * @param n/a
235
+ * @return n/a
236
+ */
237
+
238
+ function acf_set_form_data( $data = array() ) {
239
+ return acf_get_instance('ACF_Form')->set_data( $data );
240
+ }
241
+
242
+
243
+ /*
244
+ * acf_form_data
245
+ *
246
+ * description
247
+ *
248
+ * @type function
249
+ * @date 15/10/13
250
+ * @since 5.0.0
251
+ *
252
+ * @param $post_id (int)
253
+ * @return $post_id (int)
254
+ */
255
+
256
+ function acf_form_data( $data = array() ) {
257
+ return acf_get_instance('ACF_Form')->render_data( $data );
258
+ }
259
+
260
+ /*
261
+ * acf_save_post
262
+ *
263
+ * description
264
+ *
265
+ * @type function
266
+ * @date 15/10/13
267
+ * @since 5.0.0
268
+ *
269
+ * @param $post_id (int)
270
+ * @return $post_id (int)
271
+ */
272
+
273
+ function acf_save_post( $post_id = 0, $values = null ) {
274
+ return acf_get_instance('ACF_Form')->save_post( $post_id, $values );
275
+ }
276
+
277
+ ?>
includes/forms/form-attachment.php CHANGED
@@ -14,7 +14,6 @@ if( ! class_exists('acf_form_attachment') ) :
14
 
15
  class acf_form_attachment {
16
 
17
-
18
  /*
19
  * __construct
20
  *
@@ -44,48 +43,6 @@ class acf_form_attachment {
44
  }
45
 
46
 
47
- /*
48
- * validate_page
49
- *
50
- * This function will check if the current page is for a post/page edit form
51
- *
52
- * @type function
53
- * @date 23/06/12
54
- * @since 3.1.8
55
- *
56
- * @param n/a
57
- * @return (boolean)
58
- */
59
-
60
- function validate_page() {
61
-
62
- // global
63
- global $pagenow, $typenow, $wp_version;
64
-
65
-
66
- // validate page
67
- if( $pagenow === 'post.php' && $typenow === 'attachment' ) {
68
-
69
- return true;
70
-
71
- }
72
-
73
-
74
- // validate page
75
- if( $pagenow === 'upload.php' && version_compare($wp_version, '4.0', '>=') ) {
76
-
77
- add_action('admin_footer', array($this, 'admin_footer'), 0);
78
-
79
- return true;
80
-
81
- }
82
-
83
-
84
- // return
85
- return false;
86
- }
87
-
88
-
89
  /*
90
  * admin_enqueue_scripts
91
  *
@@ -102,17 +59,20 @@ class acf_form_attachment {
102
 
103
  function admin_enqueue_scripts() {
104
 
105
- // bail early if not valid page
106
- if( !$this->validate_page() ) {
107
-
108
  return;
109
-
110
  }
111
-
112
-
113
- // load acf scripts
114
- acf_enqueue_scripts();
115
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
118
 
@@ -135,7 +95,6 @@ class acf_form_attachment {
135
  acf_form_data(array(
136
  'screen' => 'attachment',
137
  'post_id' => 0,
138
- 'ajax' => 1
139
  ));
140
 
141
  ?>
@@ -166,7 +125,7 @@ acf.unload.active = 0;
166
  function edit_attachment( $form_fields, $post ) {
167
 
168
  // vars
169
- $is_page = $this->validate_page();
170
  $post_id = $post->ID;
171
  $el = 'tr';
172
  $args = array(
@@ -257,24 +216,21 @@ acf.unload.active = 0;
257
  function save_attachment( $post, $attachment ) {
258
 
259
  // bail early if not valid nonce
260
- if( ! acf_verify_nonce('attachment') ) {
261
-
262
  return $post;
263
-
264
  }
265
 
266
-
267
- // validate and save
268
- if( acf_validate_save_post(true) ) {
269
-
270
  acf_save_post( $post['ID'] );
271
-
272
- }
273
 
 
 
 
 
274
 
275
  // return
276
- return $post;
277
-
278
  }
279
 
280
 
14
 
15
  class acf_form_attachment {
16
 
 
17
  /*
18
  * __construct
19
  *
43
  }
44
 
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  /*
47
  * admin_enqueue_scripts
48
  *
59
 
60
  function admin_enqueue_scripts() {
61
 
62
+ // bail early if not valid screen
63
+ if( !acf_is_screen(array('attachment', 'upload')) ) {
 
64
  return;
 
65
  }
 
 
 
 
66
 
67
+ // load acf scripts
68
+ acf_enqueue_scripts(array(
69
+ 'uploader' => true,
70
+ ));
71
+
72
+ // actions
73
+ if( acf_is_screen('upload') ) {
74
+ add_action('admin_footer', array($this, 'admin_footer'), 0);
75
+ }
76
  }
77
 
78
 
95
  acf_form_data(array(
96
  'screen' => 'attachment',
97
  'post_id' => 0,
 
98
  ));
99
 
100
  ?>
125
  function edit_attachment( $form_fields, $post ) {
126
 
127
  // vars
128
+ $is_page = acf_is_screen('attachment');
129
  $post_id = $post->ID;
130
  $el = 'tr';
131
  $args = array(
216
  function save_attachment( $post, $attachment ) {
217
 
218
  // bail early if not valid nonce
219
+ if( !acf_verify_nonce('attachment') ) {
 
220
  return $post;
 
221
  }
222
 
223
+ // bypass validation for ajax
224
+ if( acf_is_ajax('save-attachment-compat') ) {
 
 
225
  acf_save_post( $post['ID'] );
 
 
226
 
227
+ // validate and save
228
+ } elseif( acf_validate_save_post(true) ) {
229
+ acf_save_post( $post['ID'] );
230
+ }
231
 
232
  // return
233
+ return $post;
 
234
  }
235
 
236
 
includes/forms/form-comment.php CHANGED
@@ -183,7 +183,7 @@ class acf_form_comment {
183
  <script type="text/javascript">
184
  if( typeof acf !== 'undefined' ) {
185
 
186
- acf.postbox.render(<?php echo json_encode($o); ?>);
187
 
188
  }
189
  </script>
@@ -231,6 +231,10 @@ class acf_form_comment {
231
  if( !$field_groups ) return $html;
232
 
233
 
 
 
 
 
234
  // ob
235
  ob_start();
236
 
183
  <script type="text/javascript">
184
  if( typeof acf !== 'undefined' ) {
185
 
186
+ acf.newPostbox(<?php echo json_encode($o); ?>);
187
 
188
  }
189
  </script>
231
  if( !$field_groups ) return $html;
232
 
233
 
234
+ // enqueue scripts
235
+ acf_enqueue_scripts();
236
+
237
+
238
  // ob
239
  ob_start();
240
 
includes/forms/form-customizer.php CHANGED
@@ -29,7 +29,7 @@ class acf_form_customizer {
29
 
30
 
31
  // actions
32
- add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
33
  add_action('customize_preview_init', array($this, 'customize_preview_init'), 1, 1);
34
  add_action('customize_save', array($this, 'customize_save'), 1, 1);
35
 
@@ -54,14 +54,12 @@ class acf_form_customizer {
54
  * @return N/A
55
  */
56
 
57
- function admin_enqueue_scripts() {
58
-
59
- // validate screen
60
- if( !acf_is_screen('customize') ) return;
61
-
62
 
63
  // load acf scripts
64
- acf_enqueue_scripts();
 
 
65
 
66
 
67
  // actions
29
 
30
 
31
  // actions
32
+ add_action('customize_controls_init', array($this, 'customize_controls_init'));
33
  add_action('customize_preview_init', array($this, 'customize_preview_init'), 1, 1);
34
  add_action('customize_save', array($this, 'customize_save'), 1, 1);
35
 
54
  * @return N/A
55
  */
56
 
57
+ function customize_controls_init() {
 
 
 
 
58
 
59
  // load acf scripts
60
+ acf_enqueue_scripts(array(
61
+ 'context' => 'customize_controls'
62
+ ));
63
 
64
 
65
  // actions
includes/forms/form-post.php CHANGED
@@ -83,7 +83,7 @@ class ACF_Form_Post {
83
  // update vars
84
  if( !empty($post) ) {
85
 
86
- $this->post_id = $post->ID;
87
  $this->typenow = $typenow;
88
 
89
  }
@@ -134,7 +134,9 @@ class ACF_Form_Post {
134
 
135
 
136
  // load acf scripts
137
- acf_enqueue_scripts();
 
 
138
 
139
 
140
  // actions
@@ -299,8 +301,8 @@ class ACF_Form_Post {
299
  'key' => $field_group['key'],
300
  'style' => $field_group['style'],
301
  'label' => $field_group['label_placement'],
302
- 'edit_url' => '',
303
- 'edit_title' => __('Edit field group', 'acf'),
304
  'visibility' => $visibility
305
  );
306
 
@@ -308,7 +310,7 @@ class ACF_Form_Post {
308
  // edit_url
309
  if( $field_group['ID'] && acf_current_user_can_admin() ) {
310
 
311
- $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
312
 
313
  }
314
 
@@ -334,7 +336,7 @@ class ACF_Form_Post {
334
  <script type="text/javascript">
335
  if( typeof acf !== 'undefined' ) {
336
 
337
- acf.postbox.render(<?php echo json_encode($o); ?>);
338
 
339
  }
340
  </script>
83
  // update vars
84
  if( !empty($post) ) {
85
 
86
+ $this->post_id = (int) $post->ID;
87
  $this->typenow = $typenow;
88
 
89
  }
134
 
135
 
136
  // load acf scripts
137
+ acf_enqueue_scripts(array(
138
+ 'uploader' => true,
139
+ ));
140
 
141
 
142
  // actions
301
  'key' => $field_group['key'],
302
  'style' => $field_group['style'],
303
  'label' => $field_group['label_placement'],
304
+ 'editLink' => '',
305
+ 'editTitle' => __('Edit field group', 'acf'),
306
  'visibility' => $visibility
307
  );
308
 
310
  // edit_url
311
  if( $field_group['ID'] && acf_current_user_can_admin() ) {
312
 
313
+ $o['editLink'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
314
 
315
  }
316
 
336
  <script type="text/javascript">
337
  if( typeof acf !== 'undefined' ) {
338
 
339
+ acf.newPostbox(<?php echo json_encode($o); ?>);
340
 
341
  }
342
  </script>
includes/forms/form-taxonomy.php CHANGED
@@ -14,7 +14,7 @@ if( ! class_exists('acf_form_taxonomy') ) :
14
 
15
  class acf_form_taxonomy {
16
 
17
- var $form = '#addtag';
18
 
19
 
20
  /*
@@ -140,7 +140,7 @@ class acf_form_taxonomy {
140
 
141
 
142
  // update vars
143
- $this->form = '#addtag';
144
 
145
 
146
  // get field groups
@@ -195,7 +195,7 @@ class acf_form_taxonomy {
195
 
196
 
197
  // update vars
198
- $this->form = '#edittag';
199
 
200
 
201
  // get field groups
@@ -252,66 +252,42 @@ class acf_form_taxonomy {
252
  (function($) {
253
 
254
  // vars
255
- var $spinner = $('<?php echo $this->form; ?> p.submit .spinner');
256
 
257
-
258
- // create spinner if not exists (may exist in future WP versions)
259
- if( !$spinner.exists() ) {
260
-
261
- // create spinner
262
- $spinner = $('<span class="spinner"></span>');
263
-
264
-
265
- // append
266
- $('<?php echo $this->form; ?> p.submit').append( $spinner );
267
-
268
  }
269
 
 
270
 
271
- // update acf validation class
272
- acf.validation.error_class = 'form-invalid';
273
-
274
-
275
- <?php if( $this->form == '#addtag' ): ?>
276
-
277
- // store origional HTML
278
- var $el = $('#acf-term-fields');
279
- var html = $el.html();
280
 
281
- // events
282
- $('#submit').on('click', function( e ){
283
-
284
- // bail early if not active
285
- if( !acf.validation.active ) {
286
- return true;
287
- }
288
-
289
- // ignore validation (only ignore once)
290
- if( acf.validation.ignore ) {
291
- acf.validation.ignore = 0;
292
- return true;
293
- }
294
-
295
- // bail early if this form does not contain ACF data
296
- if( !$('#acf-form-data').exists() ) {
297
- return true;
 
 
298
  }
299
-
300
- // stop WP JS validation
301
- e.stopImmediatePropagation();
302
-
303
- // store submit trigger so it will be clicked if validation is passed
304
- acf.validation.$trigger = $(this);
305
-
306
- // run validation
307
- acf.validation.fetch( $('#addtag') );
308
-
309
- // stop all other click events on this input
310
- return false;
311
-
312
  });
313
 
314
-
315
  $(document).ajaxComplete(function(event, xhr, settings) {
316
 
317
  // bail early if is other ajax call
@@ -319,26 +295,22 @@ class acf_form_taxonomy {
319
  return;
320
  }
321
 
322
- // unlock form
323
- acf.validation.toggle( $('#addtag'), 'unlock' );
324
-
325
  // bail early if response contains error
326
  if( xhr.responseText.indexOf('wp_error') !== -1 ) {
327
  return;
328
  }
329
 
330
  // action for 3rd party customization
331
- acf.do_action('remove', $el);
332
 
333
- // restore html
334
- $el.html( html );
335
-
336
- // reset unload
337
- acf.unload.off();
338
 
339
  // action for 3rd party customization
340
- acf.do_action('append', $el);
341
 
 
 
342
  });
343
 
344
  <?php endif; ?>
@@ -433,4 +405,4 @@ new acf_form_taxonomy();
433
  endif;
434
 
435
 
436
- ?>
14
 
15
  class acf_form_taxonomy {
16
 
17
+ var $view = 'add';
18
 
19
 
20
  /*
140
 
141
 
142
  // update vars
143
+ $this->view = 'add';
144
 
145
 
146
  // get field groups
195
 
196
 
197
  // update vars
198
+ $this->view = 'edit';
199
 
200
 
201
  // get field groups
252
  (function($) {
253
 
254
  // vars
255
+ var view = '<?php echo $this->view; ?>';
256
 
257
+ // add missing spinners
258
+ var $submit = $('input.button-primary');
259
+ if( !$submit.next('.spinner').length ) {
260
+ $submit.after('<span class="spinner"></span>');
 
 
 
 
 
 
 
261
  }
262
 
263
+ <?php
264
 
265
+ // add view
266
+ if( $this->view == 'add' ): ?>
 
 
 
 
 
 
 
267
 
268
+ // vars
269
+ var $form = $('#addtag');
270
+ var $fields = $('#acf-term-fields');
271
+ var html = $fields.html();
272
+
273
+ // WP triggers click as primary action
274
+ $submit.on('click', function( e ){
275
+
276
+ // validate
277
+ var valid = acf.validateForm({
278
+ form: $form,
279
+ event: e,
280
+ lock: false
281
+ });
282
+
283
+ // if not valid, stop event and allow validation to continue
284
+ if( !valid ) {
285
+ e.preventDefault();
286
+ e.stopImmediatePropagation();
287
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  });
289
 
290
+ // listen to AJAX add-tag complete
291
  $(document).ajaxComplete(function(event, xhr, settings) {
292
 
293
  // bail early if is other ajax call
295
  return;
296
  }
297
 
 
 
 
298
  // bail early if response contains error
299
  if( xhr.responseText.indexOf('wp_error') !== -1 ) {
300
  return;
301
  }
302
 
303
  // action for 3rd party customization
304
+ acf.doAction('remove', $fields);
305
 
306
+ // reset HTML
307
+ $fields.html( html );
 
 
 
308
 
309
  // action for 3rd party customization
310
+ acf.doAction('append', $fields);
311
 
312
+ // reset unload
313
+ acf.unload.reset();
314
  });
315
 
316
  <?php endif; ?>
405
  endif;
406
 
407
 
408
+ ?>
includes/forms/form-user.php CHANGED
@@ -1,20 +1,13 @@
1
- <?php
2
 
3
- /*
4
- * ACF User Form Class
5
- *
6
- * All the logic for adding fields to users
7
- *
8
- * @class acf_form_user
9
- * @package ACF
10
- * @subpackage Forms
11
- */
12
 
13
- if( ! class_exists('acf_form_user') ) :
14
 
15
- class acf_form_user {
16
 
17
- var $form = '#createuser';
 
18
 
19
 
20
  /*
@@ -32,138 +25,117 @@ class acf_form_user {
32
 
33
  function __construct() {
34
 
35
- // actions
36
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
37
- add_action('login_form_register', array($this, 'admin_enqueue_scripts'));
38
 
39
  // render
40
- add_action('show_user_profile', array($this, 'edit_user'));
41
- add_action('edit_user_profile', array($this, 'edit_user'));
42
- add_action('user_new_form', array($this, 'user_new_form'));
43
- add_action('register_form', array($this, 'register_user'));
44
 
45
  // save
46
- //add_action('edit_user_profile_update', array($this, 'save_user'));
47
- //add_action('personal_options_update', array($this, 'save_user'));
48
  add_action('user_register', array($this, 'save_user'));
49
  add_action('profile_update', array($this, 'save_user'));
50
-
51
  }
52
 
53
 
54
- /*
55
- * validate_page
56
  *
57
- * This function will check if the current page is for a post/page edit form
58
  *
59
- * @type function
60
- * @date 23/06/12
61
- * @since 3.1.8
62
  *
63
- * @param N/A
64
- * @return (boolean)
65
  */
66
 
67
- function validate_page() {
68
-
69
- // global
70
- global $pagenow;
71
-
72
-
73
- // validate page
74
- if( in_array( $pagenow, array('profile.php', 'user-edit.php', 'user-new.php', 'wp-login.php') ) ) {
75
-
76
- return true;
77
 
 
 
 
78
  }
79
 
80
-
81
- // return
82
- return false;
83
  }
84
 
85
 
86
- /*
87
- * admin_enqueue_scripts
88
  *
89
- * This action is run after post query but before any admin script / head actions.
90
- * It is a good place to register all actions.
91
  *
92
- * @type action (admin_enqueue_scripts)
93
- * @date 26/01/13
94
- * @since 3.6.0
95
  *
96
- * @param N/A
97
- * @return N/A
98
  */
99
 
100
- function admin_enqueue_scripts() {
101
-
102
- // validate page
103
- if( ! $this->validate_page() ) {
104
-
105
- return;
106
-
107
- }
108
-
109
-
110
- // load acf scripts
111
- acf_enqueue_scripts();
112
-
113
-
114
- // actions
115
- add_action('acf/input/admin_footer', array($this, 'admin_footer'), 10, 1);
116
 
 
 
 
 
117
  }
118
 
119
 
120
  /*
121
  * register_user
122
  *
123
- * description
124
  *
125
  * @type function
126
  * @date 8/10/13
127
  * @since 5.0.0
128
  *
129
- * @param $post_id (int)
130
- * @return $post_id (int)
131
  */
132
 
133
- function register_user() {
134
-
135
- // update vars
136
- $this->form = '#registerform';
137
-
138
 
139
  // render
140
- $this->render( 0, 'register', 'div' );
141
-
 
 
 
142
  }
143
 
144
 
145
  /*
146
- * edit_user
147
  *
148
- * description
149
  *
150
  * @type function
151
  * @date 8/10/13
152
  * @since 5.0.0
153
  *
154
- * @param $post_id (int)
155
- * @return $post_id (int)
156
  */
157
 
158
- function edit_user( $user ) {
159
-
160
- // update vars
161
- $this->form = '#your-profile';
162
 
 
 
 
 
163
 
164
  // render
165
- $this->render( $user->ID, 'edit', 'tr' );
166
-
 
 
 
167
  }
168
 
169
 
@@ -180,15 +152,14 @@ class acf_form_user {
180
  * @return $post_id (int)
181
  */
182
 
183
- function user_new_form() {
184
-
185
- // update vars
186
- $this->form = '#createuser';
187
-
188
 
189
  // render
190
- $this->render( 0, 'add', 'tr' );
191
-
 
 
 
192
  }
193
 
194
 
@@ -207,36 +178,44 @@ class acf_form_user {
207
  * @return n/a
208
  */
209
 
210
- function render( $user_id, $user_form, $el = 'tr' ) {
211
-
212
- // vars
213
- $post_id = "user_{$user_id}";
214
- $show_title = true;
215
 
 
 
 
 
 
 
216
 
217
- // args
218
- $args = array(
219
- 'user_id' => 'new',
220
- 'user_form' => $user_form
221
- );
222
-
223
- if( $user_id ) $args['user_id'] = $user_id;
224
-
225
 
226
  // get field groups
227
- $field_groups = acf_get_field_groups( $args );
228
-
 
 
229
 
230
  // bail early if no field groups
231
- if( empty($field_groups) ) return;
232
-
 
233
 
234
  // form data
235
  acf_form_data(array(
236
- 'screen' => 'user',
237
- 'post_id' => $post_id,
 
238
  ));
239
 
 
 
 
 
 
 
 
 
240
 
241
  // loop
242
  foreach( $field_groups as $field_group ) {
@@ -244,35 +223,19 @@ class acf_form_user {
244
  // vars
245
  $fields = acf_get_fields( $field_group );
246
 
247
-
248
  // title
249
- if( $show_title && $field_group['style'] === 'default' ) {
250
  echo '<h2>' . $field_group['title'] . '</h2>';
251
  }
252
 
253
-
254
- // table start
255
- if( $el == 'tr' ) {
256
- echo '<table class="form-table"><tbody>';
257
- } else {
258
- echo '<div class="acf-user-register-fields acf-fields -clear">';
259
- }
260
-
261
-
262
- // render fields
263
- acf_render_fields( $fields, $post_id, $el, $field_group['instruction_placement'] );
264
-
265
-
266
- // table end
267
- if( $el == 'tr' ) {
268
- echo '</tbody></table>';
269
- } else {
270
- echo '</div>';
271
- }
272
-
273
  }
274
-
275
-
 
276
  }
277
 
278
 
@@ -290,79 +253,19 @@ class acf_form_user {
290
  */
291
 
292
  function admin_footer() {
293
-
294
- ?>
295
- <style type="text/css">
296
-
297
- <?php if( is_admin() ): ?>
298
-
299
- /* override for user css */
300
- .acf-field input[type="text"],
301
- .acf-field input[type="password"],
302
- .acf-field input[type="number"],
303
- .acf-field input[type="search"],
304
- .acf-field input[type="email"],
305
- .acf-field input[type="url"],
306
- .acf-field select {
307
- max-width: 25em;
308
- }
309
-
310
- .acf-field textarea {
311
- max-width: 500px;
312
- }
313
-
314
-
315
- /* allow sub fields to display correctly */
316
- .acf-field .acf-field input[type="text"],
317
- .acf-field .acf-field input[type="password"],
318
- .acf-field .acf-field input[type="number"],
319
- .acf-field .acf-field input[type="search"],
320
- .acf-field .acf-field input[type="email"],
321
- .acf-field .acf-field input[type="url"],
322
- .acf-field .acf-field textarea,
323
- .acf-field .acf-field select {
324
- max-width: none;
325
- }
326
-
327
- <?php else: ?>
328
-
329
- #registerform h2 {
330
- margin: 1em 0;
331
- }
332
-
333
- #registerform .acf-field .acf-label {
334
- margin-bottom: 0;
335
- }
336
-
337
- #registerform .acf-field .acf-label label {
338
- font-weight: normal;
339
- font-size: 14px;
340
- }
341
-
342
- #registerform p.submit {
343
- text-align: right;
344
- }
345
-
346
- <?php endif; ?>
347
-
348
- </style>
349
  <script type="text/javascript">
350
  (function($) {
351
 
352
  // vars
353
- var $spinner = $('<?php echo $this->form; ?> p.submit .spinner');
354
 
355
-
356
- // create spinner if not exists (may exist in future WP versions)
357
- if( !$spinner.exists() ) {
358
-
359
- // create spinner (use .acf-spinner becuase .spinner CSS not included on register page)
360
- $spinner = $('<span class="acf-spinner"></span>');
361
-
362
-
363
- // append
364
- $('<?php echo $this->form; ?> p.submit').append( $spinner );
365
-
366
  }
367
 
368
  })(jQuery);
@@ -387,27 +290,21 @@ class acf_form_user {
387
 
388
  function save_user( $user_id ) {
389
 
390
- // verify and remove nonce
391
- if( ! acf_verify_nonce('user') ) {
392
-
393
  return $user_id;
394
-
395
  }
396
 
397
-
398
- // save data
399
  if( acf_validate_save_post(true) ) {
400
-
401
- acf_save_post( "user_{$user_id}" );
402
-
403
  }
404
-
405
- }
406
-
407
  }
408
 
409
- new acf_form_user();
 
410
 
411
- endif;
412
 
413
  ?>
1
+ <?php
2
 
3
+ if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
 
 
 
 
 
 
4
 
5
+ if( ! class_exists('ACF_Form_User') ) :
6
 
7
+ class ACF_Form_User {
8
 
9
+ /** @var string The current view (new, edit, register) */
10
+ var $view = '';
11
 
12
 
13
  /*
25
 
26
  function __construct() {
27
 
28
+ // enqueue
29
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
30
+ add_action('login_form_register', array($this, 'login_form_register'));
31
 
32
  // render
33
+ add_action('show_user_profile', array($this, 'render_edit'));
34
+ add_action('edit_user_profile', array($this, 'render_edit'));
35
+ add_action('user_new_form', array($this, 'render_new'));
36
+ add_action('register_form', array($this, 'render_register'));
37
 
38
  // save
 
 
39
  add_action('user_register', array($this, 'save_user'));
40
  add_action('profile_update', array($this, 'save_user'));
 
41
  }
42
 
43
 
44
+ /**
45
+ * admin_enqueue_scripts
46
  *
47
+ * Checks current screen and enqueues scripts
48
  *
49
+ * @date 17/4/18
50
+ * @since 5.6.9
 
51
  *
52
+ * @param void
53
+ * @return void
54
  */
55
 
56
+ function admin_enqueue_scripts() {
 
 
 
 
 
 
 
 
 
57
 
58
+ // bail early if not valid screen
59
+ if( !acf_is_screen(array('profile', 'user', 'user-edit')) ) {
60
+ return;
61
  }
62
 
63
+ // enqueue
64
+ acf_enqueue_scripts();
 
65
  }
66
 
67
 
68
+ /**
69
+ * login_form_register
70
  *
71
+ * Customizes and enqueues scripts
 
72
  *
73
+ * @date 17/4/18
74
+ * @since 5.6.9
 
75
  *
76
+ * @param void
77
+ * @return void
78
  */
79
 
80
+ function login_form_register() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
+ // customize action prefix so that "admin_head" = "login_head"
83
+ acf_enqueue_scripts(array(
84
+ 'context' => 'login'
85
+ ));
86
  }
87
 
88
 
89
  /*
90
  * register_user
91
  *
92
+ * Called during the user register form
93
  *
94
  * @type function
95
  * @date 8/10/13
96
  * @since 5.0.0
97
  *
98
+ * @param void
99
+ * @return void
100
  */
101
 
102
+ function render_register() {
 
 
 
 
103
 
104
  // render
105
+ $this->render(array(
106
+ 'user_id' => 0,
107
+ 'view' => 'register',
108
+ 'el' => 'div'
109
+ ));
110
  }
111
 
112
 
113
  /*
114
+ * render_edit
115
  *
116
+ * Called during the user edit form
117
  *
118
  * @type function
119
  * @date 8/10/13
120
  * @since 5.0.0
121
  *
122
+ * @param void
123
+ * @return void
124
  */
125
 
126
+ function render_edit( $user ) {
 
 
 
127
 
128
+ // add compatibility with front-end user profile edit forms such as bbPress
129
+ if( !is_admin() ) {
130
+ acf_enqueue_scripts();
131
+ }
132
 
133
  // render
134
+ $this->render(array(
135
+ 'user_id' => $user->ID,
136
+ 'view' => 'edit',
137
+ 'el' => 'tr'
138
+ ));
139
  }
140
 
141
 
152
  * @return $post_id (int)
153
  */
154
 
155
+ function render_new() {
 
 
 
 
156
 
157
  // render
158
+ $this->render(array(
159
+ 'user_id' => 0,
160
+ 'view' => 'add',
161
+ 'el' => 'tr'
162
+ ));
163
  }
164
 
165
 
178
  * @return n/a
179
  */
180
 
181
+ function render( $args = array() ) {
 
 
 
 
182
 
183
+ // defaults
184
+ $args = wp_parse_args($args, array(
185
+ 'user_id' => 0,
186
+ 'view' => 'edit',
187
+ 'el' => 'tr',
188
+ ));
189
 
190
+ // vars
191
+ $post_id = 'user_' . $args['user_id'];
 
 
 
 
 
 
192
 
193
  // get field groups
194
+ $field_groups = acf_get_field_groups(array(
195
+ 'user_id' => $args['user_id'] ? $args['user_id'] : 'new',
196
+ 'user_form' => $args['view']
197
+ ));
198
 
199
  // bail early if no field groups
200
+ if( empty($field_groups) ) {
201
+ return;
202
+ }
203
 
204
  // form data
205
  acf_form_data(array(
206
+ 'screen' => 'user',
207
+ 'post_id' => $post_id,
208
+ 'validation' => ($args['view'] == 'register') ? 0 : 1
209
  ));
210
 
211
+ // elements
212
+ $before = '<table class="form-table"><tbody>';
213
+ $after = '</tbody></table>';
214
+
215
+ if( $args['el'] == 'div') {
216
+ $before = '<div class="acf-user-' . $args['view'] . '-fields acf-fields -clear">';
217
+ $after = '</div>';
218
+ }
219
 
220
  // loop
221
  foreach( $field_groups as $field_group ) {
223
  // vars
224
  $fields = acf_get_fields( $field_group );
225
 
 
226
  // title
227
+ if( $field_group['style'] === 'default' ) {
228
  echo '<h2>' . $field_group['title'] . '</h2>';
229
  }
230
 
231
+ // render
232
+ echo $before;
233
+ acf_render_fields( $fields, $post_id, $args['el'], $field_group['instruction_placement'] );
234
+ echo $after;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
236
+
237
+ // actions
238
+ add_action('acf/input/admin_footer', array($this, 'admin_footer'), 10, 1);
239
  }
240
 
241
 
253
  */
254
 
255
  function admin_footer() {
256
+
257
+ // script
258
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  <script type="text/javascript">
260
  (function($) {
261
 
262
  // vars
263
+ var view = '<?php echo $this->view; ?>';
264
 
265
+ // add missing spinners
266
+ var $submit = $('input.button-primary');
267
+ if( !$submit.next('.spinner').length ) {
268
+ $submit.after('<span class="spinner"></span>');
 
 
 
 
 
 
 
269
  }
270
 
271
  })(jQuery);
290
 
291
  function save_user( $user_id ) {
292
 
293
+ // verify nonce
294
+ if( !acf_verify_nonce('user') ) {
 
295
  return $user_id;
 
296
  }
297
 
298
+ // save
 
299
  if( acf_validate_save_post(true) ) {
300
+ acf_save_post( "user_$user_id" );
 
 
301
  }
302
+ }
 
 
303
  }
304
 
305
+ // instantiate
306
+ acf_new_instance('ACF_Form_User');
307
 
308
+ endif; // class_exists check
309
 
310
  ?>
includes/forms/form-widget.php CHANGED
@@ -199,7 +199,7 @@ class acf_form_widget {
199
  <script type="text/javascript">
200
  (function($) {
201
 
202
- acf.do_action('append', $('[id^="widget"][id$="<?php echo $widget->id; ?>"]') );
203
 
204
  })(jQuery);
205
  </script>
@@ -262,119 +262,68 @@ class acf_form_widget {
262
  (function($) {
263
 
264
  // vars
265
- acf.update('post_id', 'widgets');
266
-
267
 
268
  // restrict get fields
269
- acf.add_filter('get_fields', function( $fields ){
270
-
271
- // widgets
272
- $fields = $fields.not('#available-widgets .acf-field');
273
-
274
-
275
- // customizer
276
- $fields = $fields.not('.widget-tpl .acf-field');
277
 
 
 
 
 
278
 
279
  // return
280
- return $fields;
281
-
282
  });
283
 
284
-
285
  $('#widgets-right').on('click', '.widget-control-save', function( e ){
286
 
287
  // vars
288
- var $form = $(this).closest('form');
289
-
290
-
291
- // bail early if not active
292
- if( !acf.validation.active ) {
293
-
294
- return true;
295
-
296
- }
297
-
298
-
299
- // ignore validation (only ignore once)
300
- if( acf.validation.ignore ) {
301
-
302
- acf.validation.ignore = 0;
303
- return true;
304
-
305
- }
306
-
307
-
308
- // bail early if this form does not contain ACF data
309
- if( !$form.find('#acf-form-data').exists() ) {
310
-
311
- return true;
312
 
 
 
 
 
 
 
 
 
 
 
 
313
  }
314
-
315
-
316
- // stop WP JS validation
317
- e.stopImmediatePropagation();
318
-
319
-
320
- // store submit trigger so it will be clicked if validation is passed
321
- acf.validation.$trigger = $(this);
322
-
323
-
324
- // run validation
325
- acf.validation.fetch( $form );
326
-
327
-
328
- // stop all other click events on this input
329
- return false;
330
-
331
  });
332
 
333
-
334
- $(document).on('click', '.widget-top', function(){
335
-
336
- var $el = $(this).parent().children('.widget-inside');
337
-
338
- setTimeout(function(){
339
-
340
- acf.get_fields('', $el).each(function(){
341
-
342
- acf.do_action('show_field', $(this));
343
-
344
- });
345
-
346
- }, 250);
347
-
348
  });
349
 
350
  $(document).on('widget-added', function( e, $widget ){
351
 
352
  // - use delay to avoid rendering issues with customizer (ensures div is visible)
353
  setTimeout(function(){
354
-
355
- acf.do_action('append', $widget );
356
-
357
  }, 100);
358
-
359
  });
360
 
361
- $(document).on('widget-saved widget-updated', function( e, $widget ){
362
-
363
- // unlock form
364
- acf.validation.toggle( $widget, 'unlock' );
365
-
366
- });
367
-
368
  })(jQuery);
369
  </script>
370
  <?php
371
 
372
  }
373
-
374
  }
375
 
376
  new acf_form_widget();
377
 
378
  endif;
379
 
380
- ?>
199
  <script type="text/javascript">
200
  (function($) {
201
 
202
+ acf.doAction('append', $('[id^="widget"][id$="<?php echo $widget->id; ?>"]') );
203
 
204
  })(jQuery);
205
  </script>
262
  (function($) {
263
 
264
  // vars
265
+ acf.set('post_id', 'widgets');
 
266
 
267
  // restrict get fields
268
+ acf.addFilter('find_fields_args', function( args ){
 
 
 
 
 
 
 
269
 
270
+ // add parent
271
+ if( !args.parent ) {
272
+ args.parent = $('#widgets-right');
273
+ }
274
 
275
  // return
276
+ return args;
 
277
  });
278
 
279
+ // on publish
280
  $('#widgets-right').on('click', '.widget-control-save', function( e ){
281
 
282
  // vars
283
+ var $button = $(this);
284
+ var $form = $button.closest('form');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
 
286
+ // validate
287
+ var valid = acf.validateForm({
288
+ form: $form,
289
+ event: e,
290
+ lock: false
291
+ });
292
+
293
+ // if not valid, stop event and allow validation to continue
294
+ if( !valid ) {
295
+ e.preventDefault();
296
+ e.stopImmediatePropagation();
297
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  });
299
 
300
+ // show
301
+ $('#widgets-right').on('click', '.widget-top', function(){
302
+ var $widget = $(this).parent();
303
+ if( $widget.hasClass('open') ) {
304
+ acf.doAction('hide', $widget);
305
+ } else {
306
+ acf.doAction('show', $widget);
307
+ }
 
 
 
 
 
 
 
308
  });
309
 
310
  $(document).on('widget-added', function( e, $widget ){
311
 
312
  // - use delay to avoid rendering issues with customizer (ensures div is visible)
313
  setTimeout(function(){
314
+ acf.doAction('append', $widget );
 
 
315
  }, 100);
 
316
  });
317
 
 
 
 
 
 
 
 
318
  })(jQuery);
319
  </script>
320
  <?php
321
 
322
  }
 
323
  }
324
 
325
  new acf_form_widget();
326
 
327
  endif;
328
 
329
+ ?>
includes/input.php DELETED
@@ -1,522 +0,0 @@
1
- <?php
2
-
3
- if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
-
5
- if( ! class_exists('acf_input') ) :
6
-
7
- class acf_input {
8
-
9
-
10
- /*
11
- * __construct
12
- *
13
- * This function will setup the class functionality
14
- *
15
- * @type function
16
- * @date 5/03/2014
17
- * @since 5.0.0
18
- *
19
- * @param n/a
20
- * @return n/a
21
- */
22
-
23
- function __construct() {
24
-
25
- // vars
26
- $this->admin_enqueue_scripts = 'admin_enqueue_scripts';
27
- $this->admin_head = 'admin_head';
28
- $this->admin_footer = 'admin_footer';
29
- $this->enqueued = false;
30
- $this->data = array();
31
-
32
-
33
- // actions
34
- add_action('acf/save_post', array($this, 'save_post'), 10, 1);
35
-
36
- }
37
-
38
-
39
- /*
40
- * get_data
41
- *
42
- * This function will return form data
43
- *
44
- * @type function
45
- * @date 4/03/2016
46
- * @since 5.3.2
47
- *
48
- * @param $key (mixed)
49
- * @return (mixed)
50
- */
51
-
52
- function get_data( $key = false ) {
53
-
54
- // vars
55
- $data = $this->data;
56
-
57
-
58
- // key
59
- if( $key && isset($data[ $key ]) ) {
60
-
61
- $data = $data[ $key ];
62
-
63
- }
64
-
65
-
66
- // return
67
- return $data;
68
-
69
- }
70
-
71
-
72
- /*
73
- * set_data
74
- *
75
- * This function will se the form data
76
- *
77
- * @type function
78
- * @date 4/03/2016
79
- * @since 5.3.2
80
- *
81
- * @param $data (array)
82
- * @return (array)
83
- */
84
-
85
- function set_data( $data ) {
86
-
87
- // defaults
88
- $data = acf_parse_args($data, array(
89
- 'screen' => 'post', // Current screen loaded (post, user, taxonomy, etc)
90
- 'post_id' => 0, // ID of current post being edited
91
- 'nonce' => '', // nonce used for $_POST validation (defaults to screen)
92
- 'validation' => 1, // runs AJAX validation
93
- 'ajax' => 0, // if screen uses ajax to append new HTML (enqueue all assets)
94
- 'changed' => 0, // used to detect change and prompt unload
95
- ));
96
-
97
- // nonce
98
- if( !$data['nonce'] ) {
99
- $data['nonce'] = $data['screen'];
100
- }
101
-
102
- // enqueue uploader if page allows AJAX fields to appear
103
- // priority must be less than 10 to allow WP to enqueue
104
- if( $data['ajax'] ) {
105
- add_action($this->admin_footer, 'acf_enqueue_uploader', 5);
106
- }
107
-
108
- // update
109
- $this->data = $data;
110
-
111
- // return
112
- return $data;
113
- }
114
-
115
-
116
- /*
117
- * enqueue
118
- *
119
- * This function will determin the actions to use for different pages
120
- *
121
- * @type function
122
- * @date 13/01/2016
123
- * @since 5.3.2
124
- *
125
- * @param n/a
126
- * @return n/a
127
- */
128
-
129
- function enqueue() {
130
-
131
- // bail ealry if already enqueued
132
- if( $this->enqueued ) return;
133
-
134
-
135
- // update setting
136
- $this->enqueued = true;
137
-
138
-
139
- // global
140
- global $pagenow;
141
-
142
-
143
- // determine action hooks
144
- if( $pagenow == 'customize.php' ) {
145
-
146
- $this->admin_head = 'customize_controls_print_scripts';
147
- $this->admin_footer = 'customize_controls_print_footer_scripts';
148
-
149
- } elseif( $pagenow == 'wp-login.php' ) {
150
-
151
- $this->admin_enqueue_scripts = 'login_enqueue_scripts';
152
- $this->admin_head = 'login_head';
153
- $this->admin_footer = 'login_footer';
154
-
155
- } elseif( !is_admin() ) {
156
-
157
- $this->admin_enqueue_scripts = 'wp_enqueue_scripts';
158
- $this->admin_head = 'wp_head';
159
- $this->admin_footer = 'wp_footer';
160
-
161
- }
162
-
163
-
164
- // actions
165
- acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'admin_enqueue_scripts'), 20 );
166
- acf_maybe_add_action($this->admin_head, array($this, 'admin_head'), 20 );
167
- acf_maybe_add_action($this->admin_footer, array($this, 'admin_footer'), 20 );
168
-
169
- }
170
-
171
-
172
- /*
173
- * admin_enqueue_scripts
174
- *
175
- * The acf input screen admin_enqueue_scripts
176
- *
177
- * @type function
178
- * @date 4/03/2016
179
- * @since 5.3.2
180
- *
181
- * @param n/a
182
- * @return n/a
183
- */
184
-
185
- function admin_enqueue_scripts() {
186
-
187
- // scripts
188
- wp_enqueue_script('acf-input');
189
-
190
-
191
- // styles
192
- wp_enqueue_style('acf-input');
193
-
194
-
195
- // do action
196
- do_action('acf/input/admin_enqueue_scripts');
197
-
198
- }
199
-
200
-
201
- /*
202
- * admin_head
203
- *
204
- * The acf input screen admin_head
205
- *
206
- * @type function
207
- * @date 4/03/2016
208
- * @since 5.3.2
209
- *
210
- * @param n/a
211
- * @return n/a
212
- */
213
-
214
- function admin_head() {
215
-
216
- // do action
217
- do_action('acf/input/admin_head');
218
-
219
- }
220
-
221
-
222
- /*
223
- * admin_footer
224
- *
225
- * The acf input screen admin_footer
226
- *
227
- * @type function
228
- * @date 4/03/2016
229
- * @since 5.3.2
230
- *
231
- * @param n/a
232
- * @return n/a
233
- */
234
-
235
- function admin_footer() {
236
-
237
- // global
238
- global $wp_version;
239
-
240
-
241
- // options
242
- $o = array(
243
- 'screen' => acf_get_form_data('screen'),
244
- 'post_id' => acf_get_form_data('post_id'),
245
- 'nonce' => wp_create_nonce( 'acf_nonce' ),
246
- 'admin_url' => admin_url(),
247
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
248
- 'ajax' => acf_get_form_data('ajax'),
249
- 'validation' => acf_get_form_data('validation'),
250
- 'wp_version' => $wp_version,
251
- 'acf_version' => acf_get_setting('version'),
252
- 'browser' => acf_get_browser(),
253
- 'locale' => get_locale(),
254
- 'rtl' => is_rtl()
255
- );
256
-
257
-
258
- // l10n
259
- $l10n = apply_filters( 'acf/input/admin_l10n', array(
260
- 'unload' => __('The changes you made will be lost if you navigate away from this page','acf'),
261
- 'expand_details' => __('Expand Details','acf'),
262
- 'collapse_details' => __('Collapse Details','acf'),
263
- 'validation_successful' => __('Validation successful', 'acf'),
264
- 'validation_failed' => __('Validation failed', 'acf'),
265
- 'validation_failed_1' => __('1 field requires attention', 'acf'),
266
- 'validation_failed_2' => __('%d fields require attention', 'acf'),
267
- 'restricted' => __('Restricted','acf'),
268
- 'are_you_sure' => __('Are you sure?','acf'),
269
- 'yes' => __('Yes','acf'),
270
- 'no' => __('No','acf'),
271
- 'remove' => __('Remove','acf'),
272
- 'cancel' => __('Cancel','acf')
273
- ));
274
-
275
-
276
- ?>
277
- <script type="text/javascript">
278
- var acf = acf || null;
279
- if( acf ) {
280
-
281
- acf.o = <?php echo json_encode($o); ?>;
282
- acf.l10n = <?php echo json_encode($l10n); ?>;
283
- <?php do_action('acf/input/admin_footer_js'); ?>
284
-
285
- }
286
- </script>
287
- <?php
288
-
289
- do_action('acf/input/admin_footer');
290
-
291
- ?>
292
- <script type="text/javascript">
293
- if( acf ) acf.do_action('prepare');
294
- </script>
295
- <?php
296
-
297
- }
298
-
299
-
300
- /*
301
- * save_post
302
- *
303
- * This function will save the $_POST data
304
- *
305
- * @type function
306
- * @date 24/10/2014
307
- * @since 5.0.9
308
- *
309
- * @param $post_id (int)
310
- * @return n/a
311
- */
312
-
313
- function save_post( $post_id ) {
314
-
315
- // bail early if empty
316
- // - post data may have be modified
317
- if( empty($_POST['acf']) ) return;
318
-
319
-
320
- // loop
321
- foreach( $_POST['acf'] as $k => $v ) {
322
-
323
- // get field
324
- $field = acf_get_field( $k );
325
-
326
-
327
- // continue if no field
328
- if( !$field ) continue;
329
-
330
-
331
- // update
332
- acf_update_value( $v, $post_id, $field );
333
-
334
- }
335
-
336
- }
337
-
338
- }
339
-
340
- // initialize
341
- acf()->input = new acf_input();
342
-
343
- endif; // class_exists check
344
-
345
-
346
-
347
- /*
348
- * acf_enqueue_scripts
349
- *
350
- * alias of acf()->form->enqueue()
351
- *
352
- * @type function
353
- * @date 6/10/13
354
- * @since 5.0.0
355
- *
356
- * @param n/a
357
- * @return n/a
358
- */
359
-
360
- function acf_enqueue_scripts() {
361
-
362
- return acf()->input->enqueue();
363
-
364
- }
365
-
366
-
367
- /*
368
- * acf_get_form_data
369
- *
370
- * alias of acf()->form->get_data()
371
- *
372
- * @type function
373
- * @date 6/10/13
374
- * @since 5.0.0
375
- *
376
- * @param n/a
377
- * @return n/a
378
- */
379
-
380
- function acf_get_form_data( $key = false ) {
381
-
382
- return acf()->input->get_data( $key );
383
-
384
- }
385
-
386
-
387
- /*
388
- * acf_set_form_data
389
- *
390
- * alias of acf()->form->set_data()
391
- *
392
- * @type function
393
- * @date 6/10/13
394
- * @since 5.0.0
395
- *
396
- * @param n/a
397
- * @return n/a
398
- */
399
-
400
- function acf_set_form_data( $data = array() ) {
401
-
402
- return acf()->input->set_data( $data );
403
-
404
- }
405
-
406
-
407
- /*
408
- * acf_enqueue_uploader
409
- *
410
- * This function will render a WP WYSIWYG and enqueue media
411
- *
412
- * @type function
413
- * @date 27/10/2014
414
- * @since 5.0.9
415
- *
416
- * @param n/a
417
- * @return n/a
418
- */
419
-
420
- function acf_enqueue_uploader() {
421
-
422
- // bail early if doing ajax
423
- if( acf_is_ajax() ) return;
424
-
425
-
426
- // bail ealry if already run
427
- if( acf_has_done('enqueue_uploader') ) return;
428
-
429
-
430
- // enqueue media if user can upload
431
- if( current_user_can('upload_files') ) {
432
-
433
- wp_enqueue_media();
434
-
435
- }
436
-
437
-
438
- // create dummy editor
439
- ?><div id="acf-hidden-wp-editor" class="acf-hidden"><?php wp_editor( '', 'acf_content' ); ?></div><?php
440
-
441
- }
442
-
443
-
444
- /*
445
- * acf_form_data
446
- *
447
- * description
448
- *
449
- * @type function
450
- * @date 15/10/13
451
- * @since 5.0.0
452
- *
453
- * @param $post_id (int)
454
- * @return $post_id (int)
455
- */
456
-
457
- function acf_form_data( $args = array() ) {
458
-
459
- // make sure scripts and styles have been included
460
- // case: front end bbPress edit user
461
- acf_enqueue_scripts();
462
-
463
-
464
- // set form data
465
- $args = acf_set_form_data( $args );
466
-
467
-
468
- // hidden inputs
469
- $inputs = $args;
470
- $inputs['nonce'] = wp_create_nonce($inputs['nonce']);
471
-
472
- ?>
473
- <div id="acf-form-data" class="acf-hidden">
474
- <?php foreach( $inputs as $k => $v ): ?>
475
- <input type="hidden" id="_acf_<?php echo esc_attr($k); ?>" name="_acf_<?php echo esc_attr($k); ?>" value="<?php echo esc_attr($v); ?>" />
476
- <?php endforeach; ?>
477
- <?php do_action('acf/input/form_data', $args); ?>
478
- </div>
479
- <?php
480
-
481
- }
482
-
483
-
484
- /*
485
- * acf_save_post
486
- *
487
- * description
488
- *
489
- * @type function
490
- * @date 8/10/13
491
- * @since 5.0.0
492
- *
493
- * @param $post_id (int)
494
- * @return $post_id (int)
495
- */
496
-
497
- function acf_save_post( $post_id = 0, $values = null ) {
498
-
499
- // override $_POST
500
- if( $values !== null ) {
501
- $_POST['acf'] = $values;
502
- }
503
-
504
-
505
- // bail early if no values
506
- if( empty($_POST['acf']) ) return false;
507
-
508
-
509
- // set form data
510
- acf_set_form_data(array(
511
- 'post_id' => $post_id
512
- ));
513
-
514
-
515
- // hook for 3rd party customization
516
- do_action('acf/save_post', $post_id);
517
-
518
-
519
- // return
520
- return true;
521
-
522
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/media.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
 
3
- class acf_media {
 
 
 
 
4
 
5
 
6
  /*
@@ -19,51 +23,40 @@ class acf_media {
19
  function __construct() {
20
 
21
  // actions
 
22
  add_action('acf/save_post', array($this, 'save_files'), 5, 1);
23
- add_action('acf/input/admin_footer', array($this, 'admin_footer'));
24
 
25
 
26
  // filters
27
  add_filter('wp_handle_upload_prefilter', array($this, 'handle_upload_prefilter'), 10, 1);
28
- add_filter('acf/input/admin_l10n', array($this, 'acf_input_admin_l10n'), 10, 1);
29
 
30
 
31
  // ajax
32
- add_action( 'wp_ajax_query-attachments', array($this, 'wp_ajax_query_attachments'), -1);
33
-
34
  }
35
 
36
 
37
- /*
38
- * acf_input_admin_l10n
39
  *
40
- * This function will append l10n strings for JS use
41
  *
42
- * @type function
43
- * @date 11/04/2016
44
- * @since 5.3.8
45
  *
46
- * @param $post_id (int)
47
- * @return $post_id (int)
48
  */
49
 
50
- function acf_input_admin_l10n( $l10n ) {
51
-
52
- // append
53
- $l10n['media'] = array(
54
- 'select' => _x('Select', 'verb', 'acf'),
55
- 'edit' => _x('Edit', 'verb', 'acf'),
56
- 'update' => _x('Update', 'verb', 'acf'),
57
- 'uploadedTo' => __("Uploaded to this post",'acf'),
58
- 'default_icon' => wp_mime_type_icon()
59
- );
60
-
61
-
62
- // return
63
- return $l10n;
64
 
 
 
 
 
 
65
  }
66
-
67
 
68
  /*
69
  * handle_upload_prefilter
@@ -82,19 +75,14 @@ class acf_media {
82
 
83
  // bail early if no acf field
84
  if( empty($_POST['_acfuploader']) ) {
85
-
86
  return $file;
87
-
88
  }
89
 
90
 
91
  // load field
92
  $field = acf_get_field( $_POST['_acfuploader'] );
93
-
94
  if( !$field ) {
95
-
96
  return $file;
97
-
98
  }
99
 
100
 
@@ -111,15 +99,12 @@ class acf_media {
111
 
112
  // append error
113
  if( !empty($errors) ) {
114
-
115
  $file['error'] = implode("\n", $errors);
116
-
117
  }
118
 
119
 
120
  // return
121
  return $file;
122
-
123
  }
124
 
125
 
@@ -140,39 +125,12 @@ class acf_media {
140
 
141
  // bail early if no $_FILES data
142
  if( empty($_FILES['acf']['name']) ) {
143
-
144
  return;
145
-
146
  }
147
 
148
 
149
  // upload files
150
  acf_upload_files();
151
-
152
- }
153
-
154
-
155
- /*
156
- * admin_footer
157
- *
158
- * description
159
- *
160
- * @type function
161
- * @date 19/02/2015
162
- * @since 5.1.5
163
- *
164
- * @param $post_id (int)
165
- * @return $post_id (int)
166
- */
167
-
168
- function admin_footer() {
169
-
170
- ?>
171
- <script type="text/javascript">
172
- if( acf ) acf.media.mime_types = <?php echo json_encode( get_allowed_mime_types() ); ?>;
173
- </script>
174
- <?php
175
-
176
  }
177
 
178
 
@@ -203,19 +161,14 @@ class acf_media {
203
 
204
  // bail early if no acf field
205
  if( empty($_POST['query']['_acfuploader']) ) {
206
-
207
  return $response;
208
-
209
  }
210
 
211
 
212
  // load field
213
  $field = acf_get_field( $_POST['query']['_acfuploader'] );
214
-
215
  if( !$field ) {
216
-
217
  return $response;
218
-
219
  }
220
 
221
 
@@ -225,21 +178,18 @@ class acf_media {
225
 
226
  // append errors
227
  if( !empty($errors) ) {
228
-
229
  $response['acf_errors'] = implode('<br />', $errors);
230
-
231
  }
232
 
233
 
234
  // return
235
  return $response;
236
-
237
  }
238
-
239
  }
240
 
 
 
241
 
242
- // initialize
243
- new acf_media();
244
 
245
  ?>
1
  <?php
2
 
3
+ if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+ if( ! class_exists('ACF_Media') ) :
6
+
7
+ class ACF_Media {
8
 
9
 
10
  /*
23
  function __construct() {
24
 
25
  // actions
26
+ add_action('acf/enqueue_scripts', array($this, 'enqueue_scripts'));
27
  add_action('acf/save_post', array($this, 'save_files'), 5, 1);
 
28
 
29
 
30
  // filters
31
  add_filter('wp_handle_upload_prefilter', array($this, 'handle_upload_prefilter'), 10, 1);
 
32
 
33
 
34
  // ajax
35
+ add_action('wp_ajax_query-attachments', array($this, 'wp_ajax_query_attachments'), -1);
 
36
  }
37
 
38
 
39
+ /**
40
+ * enqueue_scripts
41
  *
42
+ * Localizes data
43
  *
44
+ * @date 27/4/18
45
+ * @since 5.6.9
 
46
  *
47
+ * @param void
48
+ * @return void
49
  */
50
 
51
+ function enqueue_scripts(){
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
+ // localize
54
+ acf_localize_data(array(
55
+ 'mimeTypeIcon' => wp_mime_type_icon(),
56
+ 'mimeTypes' => get_allowed_mime_types()
57
+ ));
58
  }
59
+
60
 
61
  /*
62
  * handle_upload_prefilter
75
 
76
  // bail early if no acf field
77
  if( empty($_POST['_acfuploader']) ) {
 
78
  return $file;
 
79
  }
80
 
81
 
82
  // load field
83
  $field = acf_get_field( $_POST['_acfuploader'] );
 
84
  if( !$field ) {
 
85
  return $file;
 
86
  }
87
 
88
 
99
 
100
  // append error
101
  if( !empty($errors) ) {
 
102
  $file['error'] = implode("\n", $errors);
 
103
  }
104
 
105
 
106
  // return
107
  return $file;
 
108
  }
109
 
110
 
125
 
126
  // bail early if no $_FILES data
127
  if( empty($_FILES['acf']['name']) ) {
 
128
  return;
 
129
  }
130
 
131
 
132
  // upload files
133
  acf_upload_files();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
 
136
 
161
 
162
  // bail early if no acf field
163
  if( empty($_POST['query']['_acfuploader']) ) {
 
164
  return $response;
 
165
  }
166
 
167
 
168
  // load field
169
  $field = acf_get_field( $_POST['query']['_acfuploader'] );
 
170
  if( !$field ) {
 
171
  return $response;
 
172
  }
173
 
174
 
178
 
179
  // append errors
180
  if( !empty($errors) ) {
 
181
  $response['acf_errors'] = implode('<br />', $errors);
 
182
  }
183
 
184
 
185
  // return
186
  return $response;
 
187
  }
 
188
  }
189
 
190
+ // instantiate
191
+ acf_new_instance('ACF_Media');
192
 
193
+ endif; // class_exists check
 
194
 
195
  ?>
includes/updates.php CHANGED
@@ -7,9 +7,9 @@ if( ! class_exists('acf_updates') ) :
7
  class acf_updates {
8
 
9
  // vars
10
- var $version = '2.2',
11
  $plugins = array(),
12
- $updates = false,
13
  $dev = 0;
14
 
15
 
@@ -28,13 +28,16 @@ class acf_updates {
28
 
29
  function __construct() {
30
 
 
 
 
 
31
  // append update information to transient
32
  add_filter('pre_set_site_transient_update_plugins', array($this, 'modify_plugins_transient'), 10, 1);
33
 
34
 
35
  // modify plugin data visible in the 'View details' popup
36
  add_filter('plugins_api', array($this, 'modify_plugin_details'), 10, 3);
37
-
38
  }
39
 
40
 
@@ -62,32 +65,16 @@ class acf_updates {
62
  'version' => '',
63
  ));
64
 
65
-
66
  // Check if is_plugin_active() function exists. This is required on the front end of the
67
  // site, since it is in a file that is normally only loaded in the admin.
68
  if( !function_exists( 'is_plugin_active' ) ) {
69
-
70
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
71
-
72
  }
73
 
74
-
75
- // bail early if not active plugin (included in theme)
76
- if( !is_plugin_active($plugin['basename']) ) return;
77
-
78
-
79
- // add custom message in plugin update row
80
- // removed: decided this message will have a negative impact on user
81
- // if( is_admin() ) {
82
- //
83
- // add_action('in_plugin_update_message-' . $plugin['basename'], array($this, 'modify_plugin_update_message'), 10, 2 );
84
- //
85
- // }
86
-
87
-
88
- // append
89
- $this->plugins[ $plugin['basename'] ] = $plugin;
90
-
91
  }
92
 
93
 
@@ -110,14 +97,11 @@ class acf_updates {
110
  // vars
111
  $url = 'https://connect.advancedcustomfields.com/' . $query;
112
 
113
-
114
- // test
115
- if( $this->dev ) $url = 'http://connect/' . $query;
116
-
117
-
118
- // log
119
- //acf_log('acf connect: '. $url, $body);
120
-
121
 
122
  // post
123
  $raw_response = wp_remote_post( $url, array(
@@ -125,35 +109,25 @@ class acf_updates {
125
  'body' => $body
126
  ));
127
 
128
-
129
  // wp error
130
  if( is_wp_error($raw_response) ) {
131
-
132
  return $raw_response;
133
 
134
  // http error
135
  } elseif( wp_remote_retrieve_response_code($raw_response) != 200 ) {
136
-
137
  return new WP_Error( 'server_error', wp_remote_retrieve_response_message($raw_response) );
138
-
139
  }
140
 
141
-
142
  // decode response
143
  $json = json_decode( wp_remote_retrieve_body($raw_response), true );
144
 
145
-
146
  // allow non json value
147
  if( $json === null ) {
148
-
149
  return wp_remote_retrieve_body($raw_response);
150
-
151
  }
152
 
153
-
154
  // return
155
  return $json;
156
-
157
  }
158
 
159
 
@@ -173,41 +147,130 @@ class acf_updates {
173
  function get_plugin_info( $id = '' ) {
174
 
175
  // var
176
- $transient_name = 'acf_plugin_info_'.$id;
177
-
178
 
179
- // delete transient (force-check is used to refresh)
180
- if( !empty($_GET['force-check']) ) {
181
-
182
- delete_transient($transient_name);
183
 
 
 
 
 
184
  }
185
-
186
-
187
- // try transient
188
- $transient = get_transient($transient_name);
189
- if( $transient !== false ) return $transient;
190
-
191
 
192
  // connect
193
  $response = $this->request('v2/plugins/get-info?p='.$id);
194
 
195
-
196
- // ensure response is expected JSON array (not string)
197
  if( is_string($response) ) {
198
  $response = new WP_Error( 'server_error', esc_html($response) );
199
  }
200
 
 
 
201
 
202
  // update transient
203
- set_transient($transient_name, $response, HOUR_IN_SECONDS );
204
-
205
 
206
  // return
207
  return $response;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
 
 
 
 
 
209
  }
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
  /*
213
  * refresh_plugins_transient
@@ -227,14 +290,12 @@ class acf_updates {
227
  // vars
228
  $transient = get_site_transient('update_plugins');
229
 
230
-
231
  // bail early if no transient
232
  if( empty($transient) ) return;
233
 
234
-
235
  // update (will trigger modify function)
 
236
  set_site_transient( 'update_plugins', $transient );
237
-
238
  }
239
 
240
 
@@ -254,50 +315,22 @@ class acf_updates {
254
  function modify_plugins_transient( $transient ) {
255
 
256
  // bail early if no response (error)
257
- if( !isset($transient->response) ) return $transient;
258
-
259
-
260
- // fetch updates once (this filter is called multiple times during a single page load)
261
- if( !$this->updates ) {
262
-
263
- // vars
264
- $post = array(
265
- 'plugins' => wp_json_encode($this->plugins),
266
- 'wp' => wp_json_encode(array(
267
- 'wp_name' => get_bloginfo('name'),
268
- 'wp_url' => home_url(),
269
- 'wp_version' => get_bloginfo('version'),
270
- 'wp_language' => get_bloginfo('language'),
271
- 'wp_timezone' => get_option('timezone_string'),
272
- )),
273
- 'acf' => wp_json_encode(array(
274
- 'acf_version' => get_option('acf_version'),
275
- 'acf_pro' => (defined('ACF_PRO') && ACF_PRO),
276
- )),
277
- );
278
-
279
-
280
- // connect
281
- $this->updates = $this->request('v2/plugins/update-check', $post);
282
-
283
  }
284
 
 
 
285
 
286
  // append
287
- if( is_array($this->updates) ) {
288
-
289
- foreach( $this->updates['plugins'] as $basename => $update ) {
290
-
291
  $transient->response[ $basename ] = (object) $update;
292
-
293
  }
294
-
295
  }
296
 
297
-
298
  // return
299
  return $transient;
300
-
301
  }
302
 
303
 
@@ -375,35 +408,6 @@ class acf_updates {
375
  return $response;
376
 
377
  }
378
-
379
-
380
- /*
381
- * modify_plugin_update_message
382
- *
383
- * Displays an update message for plugin list screens.
384
- * Shows only the version updates from the current until the newest version
385
- *
386
- * @type function
387
- * @date 14/06/2016
388
- * @since 5.3.8
389
- *
390
- * @param $plugin_data (array)
391
- * @param $r (object)
392
- * @return n/a
393
- */
394
-
395
- /*
396
- function modify_plugin_update_message( $plugin_data, $response ) {
397
-
398
- // show notice if exists in transient data
399
- if( isset($response->notice) ) {
400
-
401
- echo '<div class="acf-plugin-upgrade-notice">' . $response->notice . '</div>';
402
-
403
- }
404
-
405
- }
406
- */
407
 
408
  }
409
 
7
  class acf_updates {
8
 
9
  // vars
10
+ var $version = '2.3',
11
  $plugins = array(),
12
+ $force_check = false,
13
  $dev = 0;
14
 
15
 
28
 
29
  function __construct() {
30
 
31
+ // vars
32
+ $this->force_check = !empty($_GET['force-check']);
33
+
34
+
35
  // append update information to transient
36
  add_filter('pre_set_site_transient_update_plugins', array($this, 'modify_plugins_transient'), 10, 1);
37
 
38
 
39
  // modify plugin data visible in the 'View details' popup
40
  add_filter('plugins_api', array($this, 'modify_plugin_details'), 10, 3);
 
41
  }
42
 
43
 
65
  'version' => '',
66
  ));
67
 
 
68
  // Check if is_plugin_active() function exists. This is required on the front end of the
69
  // site, since it is in a file that is normally only loaded in the admin.
70
  if( !function_exists( 'is_plugin_active' ) ) {
 
71
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
 
72
  }
73
 
74
+ // add if is active plugin (not included in theme)
75
+ if( is_plugin_active($plugin['basename']) ) {
76
+ $this->plugins[ $plugin['basename'] ] = $plugin;
77
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
 
80
 
97
  // vars
98
  $url = 'https://connect.advancedcustomfields.com/' . $query;
99
 
100
+ // development mode
101
+ if( $this->dev ) {
102
+ $url = 'http://connect/' . $query;
103
+ acf_log('acf connect: '. $url, $body);
104
+ }
 
 
 
105
 
106
  // post
107
  $raw_response = wp_remote_post( $url, array(
109
  'body' => $body
110
  ));
111
 
 
112
  // wp error
113
  if( is_wp_error($raw_response) ) {
 
114
  return $raw_response;
115
 
116
  // http error
117
  } elseif( wp_remote_retrieve_response_code($raw_response) != 200 ) {
 
118
  return new WP_Error( 'server_error', wp_remote_retrieve_response_message($raw_response) );
 
119
  }
120
 
 
121
  // decode response
122
  $json = json_decode( wp_remote_retrieve_body($raw_response), true );
123
 
 
124
  // allow non json value
125
  if( $json === null ) {
 
126
  return wp_remote_retrieve_body($raw_response);
 
127
  }
128
 
 
129
  // return
130
  return $json;
 
131
  }
132
 
133
 
147
  function get_plugin_info( $id = '' ) {
148
 
149
  // var
150
+ $transient_name = 'acf_plugin_info_' . $id;
 
151
 
152
+ // ignore cache (only once)
153
+ if( $this->force_check ) {
154
+ $this->force_check = false;
 
155
 
156
+ // check cache
157
+ } else {
158
+ $transient = get_transient($transient_name);
159
+ if( $transient !== false ) return $transient;
160
  }
 
 
 
 
 
 
161
 
162
  // connect
163
  $response = $this->request('v2/plugins/get-info?p='.$id);
164
 
165
+ // convert string (misc error) to WP_Error object
 
166
  if( is_string($response) ) {
167
  $response = new WP_Error( 'server_error', esc_html($response) );
168
  }
169
 
170
+ // allow json to include expiration but force minimum and max for safety
171
+ $expiration = $this->get_expiration($response, DAY_IN_SECONDS, MONTH_IN_SECONDS);
172
 
173
  // update transient
174
+ set_transient($transient_name, $response, $expiration );
 
175
 
176
  // return
177
  return $response;
178
+ }
179
+
180
+
181
+ /**
182
+ * get_plugin_updates
183
+ *
184
+ * description
185
+ *
186
+ * @date 8/7/18
187
+ * @since 5.6.9
188
+ *
189
+ * @param type $var Description. Default.
190
+ * @return type Description.
191
+ */
192
+
193
+ function get_plugin_updates() {
194
+
195
+ // var
196
+ $transient_name = 'acf_plugin_updates';
197
+
198
+ // ignore cache (only once)
199
+ if( $this->force_check ) {
200
+ $this->force_check = false;
201
+
202
+ // check cache
203
+ } else {
204
+ $transient = get_transient($transient_name);
205
+ if( $transient !== false ) return $transient;
206
+ }
207
+
208
+ // vars
209
+ $post = array(
210
+ 'plugins' => wp_json_encode($this->plugins),
211
+ 'wp' => wp_json_encode(array(
212
+ 'wp_name' => get_bloginfo('name'),
213
+ 'wp_url' => home_url(),
214
+ 'wp_version' => get_bloginfo('version'),
215
+ 'wp_language' => get_bloginfo('language'),
216
+ 'wp_timezone' => get_option('timezone_string'),
217
+ )),
218
+ 'acf' => wp_json_encode(array(
219
+ 'acf_version' => get_option('acf_version'),
220
+ 'acf_pro' => (defined('ACF_PRO') && ACF_PRO),
221
+ )),
222
+ );
223
+
224
+ // request
225
+ $response = $this->request('v2/plugins/update-check', $post);
226
+
227
+ // allow json to include expiration but force minimum and max for safety
228
+ $expiration = $this->get_expiration($response, DAY_IN_SECONDS, MONTH_IN_SECONDS);
229
 
230
+ // update transient
231
+ set_transient($transient_name, $response, $expiration );
232
+
233
+ // return
234
+ return $response;
235
  }
236
 
237
+ /**
238
+ * get_expiration
239
+ *
240
+ * This function safely gets the expiration value from a response
241
+ *
242
+ * @date 8/7/18
243
+ * @since 5.6.9
244
+ *
245
+ * @param mixed $response The response from the server. Default false.
246
+ * @param int $min The minimum expiration limit. Default 0.
247
+ * @param int $max The maximum expiration limit. Default 0.
248
+ * @return int
249
+ */
250
+
251
+ function get_expiration( $response = false, $min = 0, $max = 0 ) {
252
+
253
+ // vars
254
+ $expiration = 0;
255
+
256
+ // check
257
+ if( is_array($response) && isset($response['expiration']) ) {
258
+ $expiration = (int) $response['expiration'];
259
+ }
260
+
261
+ // min
262
+ if( $expiration < $min ) {
263
+ return $min;
264
+ }
265
+
266
+ // max
267
+ if( $expiration > $max ) {
268
+ return $max;
269
+ }
270
+
271
+ // return
272
+ return $expiration;
273
+ }
274
 
275
  /*
276
  * refresh_plugins_transient
290
  // vars
291
  $transient = get_site_transient('update_plugins');
292
 
 
293
  // bail early if no transient
294
  if( empty($transient) ) return;
295
 
 
296
  // update (will trigger modify function)
297
+ $this->force_check = true;
298
  set_site_transient( 'update_plugins', $transient );
 
299
  }
300
 
301
 
315
  function modify_plugins_transient( $transient ) {
316
 
317
  // bail early if no response (error)
318
+ if( !isset($transient->response) ) {
319
+ return $transient;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  }
321
 
322
+ // fetch updates (this filter is called multiple times during a single page load)
323
+ $updates = $this->get_plugin_updates();
324
 
325
  // append
326
+ if( is_array($updates) ) {
327
+ foreach( $updates['plugins'] as $basename => $update ) {
 
 
328
  $transient->response[ $basename ] = (object) $update;
 
329
  }
 
330
  }
331
 
 
332
  // return
333
  return $transient;
 
334
  }
335
 
336
 
408
  return $response;
409
 
410
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
 
412
  }
413
 
includes/walkers/class-acf-walker-nav-menu-edit.php CHANGED
@@ -126,7 +126,7 @@ class ACF_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
126
  if( acf_is_ajax('add-menu-item') ): ?>
127
  <script type="text/javascript">
128
  (function($) {
129
- acf.do_action('append', jQuery('#menu-item-settings-<?php echo $post_id; ?>') );
130
  })(jQuery);
131
  </script>
132
  <?php endif;
126
  if( acf_is_ajax('add-menu-item') ): ?>
127
  <script type="text/javascript">
128
  (function($) {
129
+ acf.doAction('append', jQuery('#menu-item-settings-<?php echo $post_id; ?>') );
130
  })(jQuery);
131
  </script>
132
  <?php endif;
includes/walkers/class-acf-walker-taxonomy-field.php CHANGED
@@ -23,7 +23,7 @@ class ACF_Taxonomy_Field_Walker extends Walker {
23
 
24
 
25
  // append
26
- $output .= '<li data-id="' . $term->term_id . '"><label><input type="' . $this->field['field_type'] . '" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checked"' : '') . ' /> <span>' . $term->name . '</span></label>';
27
 
28
  }
29
 
23
 
24
 
25
  // append
26
+ $output .= '<li data-id="' . $term->term_id . '"><label' . ($selected ? ' class="selected"' : '') . '><input type="' . $this->field['field_type'] . '" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checked"' : '') . ' /> <span>' . $term->name . '</span></label>';
27
 
28
  }
29
 
lang/acf-ar.mo CHANGED
Binary file
lang/acf-ar.po CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Advanced Custom Fields Pro\n"
4
  "POT-Creation-Date: 2017-06-27 15:37+1000\n"
5
- "PO-Revision-Date: 2018-02-06 10:05+1000\n"
6
  "Last-Translator: Elliot Condon <e@elliotcondon.com>\n"
7
  "Language-Team: Adil el hallaoui <servicewb11@gmail.com>\n"
8
  "Language: ar\n"
@@ -12,12 +12,9 @@ msgstr ""
12
  "X-Generator: Poedit 1.8.1\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-WPHeader: acf.php\n"
15
- "Plural-Forms: nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
16
- "&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5);\n"
2
  msgstr ""
3
  "Project-Id-Version: Advanced Custom Fields Pro\n"
4
  "POT-Creation-Date: 2017-06-27 15:37+1000\n"
5
+ "PO-Revision-Date: 2018-07-12 13:37+1000\n"
6
  "Last-Translator: Elliot Condon <e@elliotcondon.com>\n"
7
  "Language-Team: Adil el hallaoui <servicewb11@gmail.com>\n"
8
  "Language: ar\n"
12
  "X-Generator: Poedit 1.8.1\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-WPHeader: acf.php\n"
15
+ "Plural-Forms: nplurals=6; plural=(n==0