diff --git a/acf.php b/acf.php
index 2869e0e..b17d3b3 100644
--- a/acf.php
+++ b/acf.php
@@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields PRO
Plugin URI: https://www.advancedcustomfields.com/
Description: Customise WordPress with powerful, professional and intuitive fields.
-Version: 5.6.10
+Version: 5.7.0
Author: Elliot Condon
Author URI: http://www.elliotcondon.com/
Copyright: Elliot Condon
@@ -18,7 +18,7 @@ if( ! class_exists('ACF') ) :
class ACF {
/** @var string The plugin version number */
- var $version = '5.6.10';
+ var $version = '5.7.0';
/** @var array The plugin settings array */
var $settings = array();
@@ -140,11 +140,12 @@ class ACF {
// core
+ acf_include('includes/assets.php');
acf_include('includes/ajax.php');
acf_include('includes/cache.php');
acf_include('includes/compatibility.php');
acf_include('includes/deprecated.php');
- acf_include('includes/input.php');
+ acf_include('includes/form.php');
acf_include('includes/json.php');
acf_include('includes/local.php');
acf_include('includes/loop.php');
@@ -194,7 +195,6 @@ class ACF {
add_action('init', array($this, 'init'), 5);
add_action('init', array($this, 'register_post_types'), 5);
add_action('init', array($this, 'register_post_status'), 5);
- add_action('init', array($this, 'register_assets'), 5);
// filters
@@ -475,39 +475,6 @@ class ACF {
}
- /*
- * register_assets
- *
- * This function will register scripts and styles
- *
- * @type function
- * @date 22/10/2015
- * @since 5.3.2
- *
- * @param n/a
- * @return n/a
- */
-
- function register_assets() {
-
- // vars
- $version = acf_get_setting('version');
- $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
-
-
- // scripts
- 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 );
- wp_register_script('acf-field-group', acf_get_url("assets/js/acf-field-group{$min}.js"), array('acf-input'), $version );
-
-
- // styles
- wp_register_style('acf-global', acf_get_url('assets/css/acf-global.css'), array(), $version );
- wp_register_style('acf-input', acf_get_url('assets/css/acf-input.css'), array('acf-global'), $version );
- wp_register_style('acf-field-group', acf_get_url('assets/css/acf-field-group.css'), array('acf-input'), $version );
-
- }
-
-
/*
* posts_where
*
@@ -737,4 +704,4 @@ acf();
endif; // class_exists check
-?>
\ No newline at end of file
+?>
diff --git a/assets/css/acf-field-group.css b/assets/css/acf-field-group.css
index 8b9c9da..8773e84 100644
--- a/assets/css/acf-field-group.css
+++ b/assets/css/acf-field-group.css
@@ -58,7 +58,6 @@
box-shadow: none;
/* metabox */
/* links */
- /* no fields */
/* table header */
/* show keys */
/* fields */
@@ -75,10 +74,6 @@
outline: none;
box-shadow: none;
}
-#acf-field-group-fields .no-fields-message {
- padding: 15px 15px;
- background: #fff;
-}
#acf-field-group-fields .li-field-order {
width: 20%;
}
@@ -109,6 +104,16 @@
#acf-field-group-fields .acf-field-list {
background: #F9F9F9;
margin-top: -1px;
+ /* no fields */
+ /* empty */
+}
+#acf-field-group-fields .acf-field-list .no-fields-message {
+ padding: 15px 15px;
+ background: #fff;
+ display: none;
+}
+#acf-field-group-fields .acf-field-list.-empty .no-fields-message {
+ display: block;
}
/* field object */
.acf-field-object {
@@ -118,6 +123,20 @@
/* meta */
/* handle */
/* open */
+ /*
+ // debug
+ &[data-save="meta"] {
+ > .handle {
+ border-left: #ffb700 solid 5px !important;
+ }
+ }
+
+ &[data-save="settings"] {
+ > .handle {
+ border-left: #0ec563 solid 5px !important;
+ }
+ }
+*/
/* hover */
/* settings */
/* conditional logic */
@@ -207,7 +226,8 @@
.acf-field-object.open > .handle .acf-required {
color: #fff;
}
-.acf-field-object:hover > .handle .row-options {
+.acf-field-object:hover > .handle .row-options,
+.acf-field-object.-hover > .handle .row-options {
visibility: visible;
}
.acf-field-object > .settings {
@@ -230,6 +250,7 @@
}
.rule-groups .rule-group {
margin: 0 0 5px;
+ /* Don't allow user to delete the first field group */
}
.rule-groups .rule-group h4 {
margin: 0 0 3px;
@@ -246,15 +267,19 @@
.rule-groups .rule-group td.remove {
width: 28px;
vertical-align: middle;
+}
+.rule-groups .rule-group td.remove a {
visibility: hidden;
}
-.rule-groups .rule-group tr:hover td.remove {
+.rule-groups .rule-group tr:hover td.remove a {
visibility: visible;
}
-/* Don't allow user to delete the first field group */
-.rule-groups .rule-group:first-child tr:first-child td.remove {
+.rule-groups .rule-group:first-child tr:first-child td.remove a {
visibility: hidden !important;
}
+.rule-groups .rule-group select:empty {
+ background: #f8f8f8;
+}
/*---------------------------------------------------------------------------------------------
*
* Options
diff --git a/assets/css/acf-global.css b/assets/css/acf-global.css
index 492e079..05b5160 100644
--- a/assets/css/acf-global.css
+++ b/assets/css/acf-global.css
@@ -16,14 +16,6 @@
* General
*
*--------------------------------------------------------------------------------------------*/
-/* box-sizing */
-/*
-[class^="acf-"] {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-*/
/* Horizontal List */
.acf-hl {
padding: 0;
@@ -71,18 +63,15 @@
padding: 0;
float: none;
}
-/* Full width */
-img.acf-fw {
- width: 100%;
-}
-/* Browser */
-.acf-visible {
- display: block;
- visibility: visible;
-}
+/* Visibility */
.acf-hidden {
- display: none;
- visibility: visible;
+ display: none !important;
+}
+.acf-empty {
+ display: table-cell !important;
+}
+.acf-empty * {
+ display: none !important;
}
/* Float */
.acf-fl {
@@ -178,6 +167,7 @@ img.acf-fw {
padding: 5px 10px;
position: absolute;
font-size: 12px;
+ line-height: 1.4em;
z-index: 900000;
/* tip */
/* positions */
@@ -229,6 +219,9 @@ img.acf-fw {
border-left-color: #2F353E;
border-right-width: 0;
}
+.acf-tooltip .acf-overlay {
+ z-index: -1;
+}
/* confirm */
.acf-tooltip.-confirm {
z-index: 900001;
@@ -240,9 +233,42 @@ img.acf-fw {
.acf-tooltip.-confirm a:hover {
text-decoration: underline;
}
-.acf-tooltip.-confirm a.-red {
+.acf-tooltip.-confirm a[data-event="confirm"] {
color: #F55E4F;
}
+.acf-overlay {
+ position: fixed;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ cursor: default;
+}
+.acf-tooltip-target {
+ position: relative;
+ z-index: 900002;
+}
+/*---------------------------------------------------------------------------------------------
+*
+* loading
+*
+*---------------------------------------------------------------------------------------------*/
+.acf-loading-overlay {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ cursor: default;
+ z-index: 99;
+ background: rgba(249, 249, 249, 0.5);
+}
+.acf-loading-overlay i {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+}
/*---------------------------------------------------------------------------------------------
*
* callout
@@ -614,48 +640,52 @@ a.acf-icon.-cancel.grey:hover {
.acf-box .footer p {
margin: 0;
}
-/* error */
-.acf-error-message {
+/*--------------------------------------------------------------------------------------------
+*
+* acf-notice
+*
+*--------------------------------------------------------------------------------------------*/
+.acf-notice {
position: relative;
display: block;
- background: #F55E4F;
+ color: #fff;
margin: 5px 0 15px;
- padding: 1px 12px;
- min-height: 0px;
- border-left: #dd4232 solid 4px;
+ padding: 3px 12px;
+ background: #2a9bd9;
+ border-left: #2183b9 solid 4px;
}
-.acf-error-message p {
- font-size: 13px !important;
+.acf-notice p {
+ font-size: 13px;
line-height: 1.5;
margin: 0.5em 0;
- padding: 2px;
text-shadow: none;
- color: #fff;
+ color: inherit;
}
-.acf-error-message .acf-icon {
+.acf-notice a.acf-notice-dismiss {
position: absolute;
+ border-color: transparent;
top: 9px;
right: 12px;
- background-color: #dd4232;
- border-color: transparent;
color: #fff;
+ background: rgba(0, 0, 0, 0.1);
}
-/* important to include .-cancel to override .acf-icon.-cancel class */
-.acf-error-message .acf-icon.-cancel:hover {
- background-color: #191e23;
- color: #F55E4F;
+.acf-notice a.acf-notice-dismiss:hover {
+ background: rgba(0, 0, 0, 0.2);
}
-/* success */
-.acf-error-message.-success {
- background-color: #46b450;
- border-color: #32973b;
+.acf-notice.-dismiss {
+ padding-right: 40px;
}
-.acf-error-message.-success .acf-icon {
- background-color: #32973b;
+.acf-notice.-error {
+ background: #F55E4F;
+ border-color: #f33b28;
}
-.acf-error-message.-success .acf-icon.-cancel:hover {
- background-color: #191e23;
- color: #46b450;
+.acf-notice.-success {
+ background: #46b450;
+ border-color: #3b9743;
+}
+.acf-notice.-warning {
+ background: #fd8d3b;
+ border-color: #fd7613;
}
/*--------------------------------------------------------------------------------------------
*
@@ -955,6 +985,7 @@ html[dir="rtl"] .acf-columns-2 .acf-column-2 {
left: 0;
right: 0;
bottom: 0;
+ text-align: center;
}
#acf-popup .bg {
position: absolute;
@@ -965,59 +996,69 @@ html[dir="rtl"] .acf-columns-2 .acf-column-2 {
z-index: 0;
background: rgba(0, 0, 0, 0.25);
}
-#acf-popup .acf-popup-box {
- position: absolute;
- z-index: 1;
- width: 300px;
- height: 300px;
- left: 50%;
- top: 50%;
- margin: -150px 0 0 -150px;
- border-color: #aaaaaa;
+#acf-popup:before {
+ content: '';
+ display: inline-block;
+ height: 100%;
+ vertical-align: middle;
}
-#acf-popup .title .acf-icon {
+#acf-popup .acf-popup-box {
+ display: inline-block;
+ vertical-align: middle;
+ z-index: 1;
+ min-width: 300px;
+ min-height: 160px;
+ border-color: #aaaaaa;
+ box-shadow: 0 5px 30px -5px rgba(0, 0, 0, 0.25);
+ text-align: left;
+}
+html[dir="rtl"] #acf-popup .acf-popup-box {
+ text-align: right;
+}
+#acf-popup .acf-popup-box .title {
+ min-height: 15px;
+ line-height: 15px;
+}
+#acf-popup .acf-popup-box .title .acf-icon {
position: absolute;
top: 10px;
right: 10px;
}
-html[dir="rtl"] #acf-popup .title .acf-icon {
+html[dir="rtl"] #acf-popup .acf-popup-box .title .acf-icon {
right: auto;
left: 10px;
}
-#acf-popup .acf-popup-box .inner,
+#acf-popup .acf-popup-box .inner {
+ min-height: 50px;
+ padding: 0;
+ margin: 15px;
+}
#acf-popup .acf-popup-box .loading {
position: absolute;
- top: 44px;
+ top: 45px;
left: 0;
right: 0;
bottom: 0;
- z-index: 1;
-}
-#acf-popup .acf-popup-box .loading {
- background: rgba(0, 0, 0, 0.1);
z-index: 2;
- border-top: #DDDDDD solid 1px;
+ background: rgba(0, 0, 0, 0.1);
display: none;
}
-#acf-popup .acf-popup-box .loading .acf-loading {
+#acf-popup .acf-popup-box .loading i {
position: absolute;
top: 50%;
left: 50%;
- margin: -10px 0 0 -10px;
+ transform: translate(-50%, -50%);
}
-#acf-popup .inner > *:first-child {
- margin-top: 0;
-}
-/* submit p */
.acf-submit {
margin-bottom: 0;
+ line-height: 28px;
}
.acf-submit span {
float: right;
color: #999;
}
-.acf-submit .acf-loading {
- display: none;
+.acf-submit span.-error {
+ color: #dd4232;
}
.acf-submit .button {
margin-right: 5px;
@@ -1129,7 +1170,7 @@ html[dir="rtl"] #acf-popup .title .acf-icon {
width: 25%;
}
/* mobile */
-@media screen and (max-width: 782px) {
+@media screen and (max-width: 640px) {
.acf-hl[data-cols] {
margin-left: 0;
margin-right: 0;
diff --git a/assets/css/acf-input.css b/assets/css/acf-input.css
index 292b163..c25ffba 100644
--- a/assets/css/acf-input.css
+++ b/assets/css/acf-input.css
@@ -52,24 +52,33 @@
.acf-field .acf-input > p.description {
margin-top: 5px;
}
-.acf-field .acf-error-message {
- background: #F55E4F;
- color: #fff;
- margin: 0 0 10px;
- display: inline-block;
- border-radius: 3px;
- border-left: none;
+.acf-field .acf-notice {
+ margin: 0 0 15px;
+ background: #edf2ff;
+ color: #2183b9;
+ border: none;
}
-.acf-field .acf-error-message:after {
- content: "";
- display: block;
- width: 0;
- height: 0;
- border: transparent 5px solid;
- border-top-color: #F55E4F;
- position: absolute;
- bottom: -10px;
- left: 10px;
+.acf-field .acf-notice .acf-notice-dismiss {
+ background: transparent;
+ color: inherit;
+}
+.acf-field .acf-notice .acf-notice-dismiss:hover {
+ background: #fff;
+}
+.acf-field .acf-notice.-dismiss {
+ padding-right: 40px;
+}
+.acf-field .acf-notice.-error {
+ background: #ffe6e6;
+ color: #d12626;
+}
+.acf-field .acf-notice.-success {
+ background: #eefbe8;
+ color: #32a23b;
+}
+.acf-field .acf-notice.-warning {
+ background: #fff3e6;
+ color: #d16226;
}
.acf-fieldtd,
.acf-fieldtr {
@@ -216,7 +225,7 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-label {
html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
float: right;
}
-@media screen and (max-width: 782px) {
+@media screen and (max-width: 640px) {
.acf-fields.-left > .acf-field:before {
display: none;
}
@@ -265,9 +274,6 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
*--------------------------------------------------------------------------------------------*/
.acf-postbox {
position: relative;
- /* position high */
- /* inside */
- /* hndle */
}
#acf_after_title-sortables .acf-postbox {
margin: 20px 0 0;
@@ -293,8 +299,7 @@ html[dir="rtl"] .acf-fields.-left > .acf-field > .acf-input {
.acf-postbox > .hndle .acf-hndle-cog:hover {
color: #777777;
}
-.acf-postbox > .hndle:hover .acf-hndle-cog,
-.acf-postbox > .hndle.hover .acf-hndle-cog {
+.acf-postbox:hover > .hndle .acf-hndle-cog {
display: block;
}
.acf-postbox .acf-replace-with-fields {
@@ -777,7 +782,7 @@ html[dir="rtl"] ul.acf-checkbox-list input[type="radio"] {
background: #48a8f4;
}
.acf-button-group input {
- display: none;
+ display: none !important;
}
.acf-button-group label {
margin: 0 0 0 -1px;
@@ -1291,6 +1296,9 @@ html[dir="rtl"] .acf-relationship .selection .values .acf-icon {
outline: none;
box-shadow: none;
}
+.acf-tab-group li a:empty {
+ display: none;
+}
html[dir="rtl"] .acf-tab-group li {
margin: 0 0 0 0.5em;
}
@@ -1329,7 +1337,7 @@ html[dir="rtl"] .acf-tab-group li {
/* mobile */
/* rtl */
}
-@media screen and (max-width: 782px) {
+@media screen and (max-width: 640px) {
.acf-fields.-left > .acf-tab-wrap .acf-tab-group {
padding-left: 10px;
}
@@ -1571,8 +1579,7 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
border-bottom: #DFDFDF solid 1px;
padding: 5px 10px;
}
-.acf-oembed .title h4,
-.acf-oembed .title input[type="text"] {
+.acf-oembed .title .input-search {
margin: 0;
font-size: 14px;
line-height: 30px;
@@ -1584,16 +1591,9 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
font-family: inherit;
cursor: text;
}
-.acf-oembed .title .search {
- height: auto;
- border: 0 none;
-}
.acf-oembed .title .acf-actions {
padding: 6px;
}
-.acf-oembed .title:hover .acf-actions {
- display: block;
-}
.acf-oembed .canvas {
position: relative;
min-height: 250px;
@@ -1613,28 +1613,15 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
position: absolute;
top: 50%;
left: 50%;
- margin: -21px 0 0 -21px;
+ transform: translate(-50%, -50%);
z-index: 0;
height: 42px;
width: 42px;
font-size: 42px;
color: #999;
}
-.acf-oembed .canvas .canvas-loading {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
+.acf-oembed .canvas .acf-loading-overlay {
background: rgba(255, 255, 255, 0.9);
- display: none;
- z-index: 2;
-}
-.acf-oembed .canvas .canvas-loading i {
- position: absolute;
- top: 50%;
- left: 50%;
- margin: -10px 0 0 -10px;
}
.acf-oembed .canvas .canvas-error {
position: absolute;
@@ -1651,42 +1638,14 @@ html[dir="rtl"] .form-table > tbody > tr.acf-tab-wrap .acf-tab-group {
display: inline;
}
.acf-oembed.has-value .canvas {
- min-height: 0;
+ min-height: 50;
}
-/* states */
-.acf-oembed .title-value {
- display: none;
+.acf-oembed.has-value .input-search {
+ font-weight: bold;
}
-.acf-oembed .title-search {
+.acf-oembed.has-value .title:hover .acf-actions {
display: block;
}
-.acf-oembed.has-value .title-value {
- display: block;
-}
-.acf-oembed.has-value .title-search {
- display: none;
-}
-.acf-oembed.has-value .canvas .acf-icon {
- display: none;
-}
-.acf-oembed.is-editing .title-value {
- display: none;
-}
-.acf-oembed.is-editing .title-search {
- display: block;
-}
-.acf-oembed.is-loading .canvas-loading {
- display: block;
-}
-.acf-oembed.is-loading .title .acf-icon {
- display: none;
-}
-.acf-oembed.has-error .canvas-error {
- display: block;
-}
-.acf-oembed.has-error .canvas .acf-icon {
- display: none;
-}
/*--------------------------------------------------------------------------------------------
*
* Image
@@ -1871,7 +1830,7 @@ html[dir="rtl"] .acf-file-uploader .file-info {
.acf-taxonomy-field:hover .acf-actions {
display: block;
}
-.acf-taxonomy-field[data-type="select"] .acf-actions {
+.acf-taxonomy-field[data-ftype="select"] .acf-actions {
padding: 0;
margin: -9px;
}
@@ -2193,7 +2152,6 @@ tr.acf-accordion + tr.acf-accordion {
/* misc */
.media-modal {
/* compat-item */
- /* fix % margin which causes .acf-uploadedTo to drop down below select */
/* allow line breaks in upload error */
/* fix required span */
/* sidebar */
@@ -2203,18 +2161,6 @@ tr.acf-accordion + tr.acf-accordion {
.media-modal .compat-field-acf-blank {
display: none !important;
}
-.media-modal select.attachment-filters {
- margin-right: 6px !important;
- vertical-align: middle;
-}
-.media-modal .acf-uploadedTo {
- line-height: 28px;
- height: 28px;
- display: inline-block;
- position: relative;
- margin: 11px 6px 0 0;
- vertical-align: middle;
-}
.media-modal .upload-error-message {
white-space: pre-wrap;
}
@@ -2262,6 +2208,7 @@ tr.acf-accordion + tr.acf-accordion {
line-height: 18px;
color: #AAAAAA;
font-size: 12px;
+ /* mobile sm */
}
.media-modal .acf-expand-details:focus,
.media-modal .acf-expand-details:active {
@@ -2288,6 +2235,11 @@ tr.acf-accordion + tr.acf-accordion {
.media-modal .acf-expand-details .is-closed {
display: block;
}
+@media (max-width: 640px) {
+ .media-modal .acf-expand-details {
+ display: none;
+ }
+}
/* expanded */
.media-modal.acf-expanded {
/* toggle */
@@ -2371,6 +2323,18 @@ tr.acf-accordion + tr.acf-accordion {
.acf-media-modal .media-embed .setting.link-to {
display: none;
}
+@media screen and (min-width: 1024px) {
+ .acf-media-modal .media-modal-content .media-frame .media-toolbar-secondary {
+ max-width: none;
+ }
+ .acf-media-modal .media-modal-content .media-frame .media-toolbar-secondary select.attachment-filters {
+ width: auto;
+ min-width: 150px;
+ max-width: none;
+ margin: 11px 6px 0 0;
+ vertical-align: middle;
+ }
+}
/*---------------------------------------------------------------------------------------------
*
* ACF Media Model (Select Mode)
@@ -2390,7 +2354,6 @@ tr.acf-accordion + tr.acf-accordion {
/* hide elements */
/* full width */
/* tidy up incorrect distance */
- /* WP4 */
/* title box shadow (to match media grid) */
/* sidebar */
/* mobile md */
@@ -2411,9 +2374,6 @@ tr.acf-accordion + tr.acf-accordion {
right: 0;
}
.acf-media-modal.-edit .media-frame-content {
- top: 56px;
-}
-body.major-4 .acf-media-modal.-edit .media-frame-content {
top: 50px;
}
.acf-media-modal.-edit .media-frame-title {
@@ -2499,7 +2459,7 @@ body.major-4 .acf-media-modal.-edit .media-frame-content {
}
.form-table > tbody > .acf-field > .acf-label {
padding: 20px 10px 20px 0;
- width: 200px;
+ width: 210px;
/* rtl */
}
html[dir="rtl"] .form-table > tbody > .acf-field > .acf-label {
@@ -2526,6 +2486,62 @@ html[dir="rtl"] .form-table > tbody > .acf-tab-wrap td {
.form-table > tbody .form-table th.acf-th {
width: auto;
}
+#your-profile,
+#createuser {
+ /* override for user css */
+ /* allow sub fields to display correctly */
+}
+#your-profile .acf-field input[type="text"],
+#createuser .acf-field input[type="text"],
+#your-profile .acf-field input[type="password"],
+#createuser .acf-field input[type="password"],
+#your-profile .acf-field input[type="number"],
+#createuser .acf-field input[type="number"],
+#your-profile .acf-field input[type="search"],
+#createuser .acf-field input[type="search"],
+#your-profile .acf-field input[type="email"],
+#createuser .acf-field input[type="email"],
+#your-profile .acf-field input[type="url"],
+#createuser .acf-field input[type="url"],
+#your-profile .acf-field select,
+#createuser .acf-field select {
+ max-width: 25em;
+}
+#your-profile .acf-field textarea,
+#createuser .acf-field textarea {
+ max-width: 500px;
+}
+#your-profile .acf-field .acf-field input[type="text"],
+#createuser .acf-field .acf-field input[type="text"],
+#your-profile .acf-field .acf-field input[type="password"],
+#createuser .acf-field .acf-field input[type="password"],
+#your-profile .acf-field .acf-field input[type="number"],
+#createuser .acf-field .acf-field input[type="number"],
+#your-profile .acf-field .acf-field input[type="search"],
+#createuser .acf-field .acf-field input[type="search"],
+#your-profile .acf-field .acf-field input[type="email"],
+#createuser .acf-field .acf-field input[type="email"],
+#your-profile .acf-field .acf-field input[type="url"],
+#createuser .acf-field .acf-field input[type="url"],
+#your-profile .acf-field .acf-field textarea,
+#createuser .acf-field .acf-field textarea,
+#your-profile .acf-field .acf-field select,
+#createuser .acf-field .acf-field select {
+ max-width: none;
+}
+#registerform h2 {
+ margin: 1em 0;
+}
+#registerform .acf-field .acf-label {
+ margin-bottom: 0;
+}
+#registerform .acf-field .acf-label label {
+ font-weight: normal;
+ font-size: 14px;
+}
+#registerform p.submit {
+ text-align: right;
+}
/*--------------------------------------------------------------------------------------------
*
* Term
@@ -2592,9 +2608,6 @@ p.submit .acf-spinner {
font-weight: normal;
margin: 0;
}
-.widget form > .acf-error-message {
- margin-top: 15px;
-}
/*--------------------------------------------------------------------------------------------
*
* Nav Menu
diff --git a/assets/js/acf-field-group.js b/assets/js/acf-field-group.js
index ffbaf3c..f9820d1 100644
--- a/assets/js/acf-field-group.js
+++ b/assets/js/acf-field-group.js
@@ -1,2185 +1,2267 @@
-(function($){
+(function($, undefined){
- acf.field_group = acf.model.extend({
+ /**
+ * fieldGroupManager
+ *
+ * Generic field group functionality
+ *
+ * @date 15/12/17
+ * @since 5.7.0
+ *
+ * @param void
+ * @return void
+ */
+
+ var fieldGroupManager = new acf.Model({
- // vars
- $fields: null,
- $locations: null,
- $options: null,
-
- actions: {
- 'ready': 'init'
- },
+ id: 'fieldGroupManager',
events: {
- 'submit #post': 'submit',
- 'click a[href="#"]': 'preventDefault',
- 'click .submitdelete': 'trash',
- 'mouseenter .acf-field-list': 'sortable'
+ 'submit #post': 'onSubmit',
+ 'click a[href="#"]': 'onClick',
+ 'click .submitdelete': 'onClickTrash',
},
-
- /*
- * init
- *
- * This function will run on document ready and initialize the module
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- init: function(){
-
- // $el
- this.$fields = $('#acf-field-group-fields');
- this.$locations = $('#acf-field-group-locations');
- this.$options = $('#acf-field-group-options');
-
-
- // disable validation
- acf.validation.active = 0;
-
+ filters: {
+ 'find_fields_args': 'filterFindFieldArgs'
},
-
- /*
- * sortable
- *
- * This function will add sortable to the feild group list
- * sortable is added on mouseover to speed up page load
- *
- * @type function
- * @date 28/10/2015
- * @since 5.3.2
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- sortable: function( e ){
-
- // bail early if already sortable
- if( e.$el.hasClass('ui-sortable') ) {
-
- return;
-
- }
-
-
- // vars
- var self = this;
-
-
- // sortable
- e.$el.sortable({
- handle: '.acf-sortable-handle',
- connectWith: '.acf-field-list',
- start: function(e, ui){
- ui.placeholder.height( ui.item.height() );
- },
- update: function(event, ui){
-
- // vars
- var $el = ui.item;
-
-
- // render
- self.render_fields();
-
-
- // actions
- acf.do_action('sortstop', $el);
-
- }
- });
-
- },
-
-
- /*
- * preventDefault
- *
- * This helper will preventDefault on all events for empty links
- *
- * @type function
- * @date 18/08/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- preventDefault: function( e ){
-
- e.preventDefault();
-
- },
-
-
- /*
- * get_selector
- *
- * This function will return a valid selector for finding a field object
- *
- * @type function
- * @date 15/01/2015
- * @since 5.1.5
- *
- * @param s (string)
- * @return (string)
- */
-
- get_selector: function( s ) {
-
- // defaults
- s = s || '';
-
-
- // vars
- var selector = '.acf-field-object';
-
-
- // search
- if( s ) {
-
- // append
- selector += '-' + s;
-
-
- // replace underscores (split/join replaces all and is faster than regex!)
- selector = selector.split('_').join('-');
-
- }
-
-
- // return
- return selector;
-
- },
-
-
- /*
- * render_fields
- *
- * This function is triggered by a change in field order, and will update the field icon number
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- render_fields: function(){
-
- // reference
- var self = this;
-
-
- // update order numbers
- $('.acf-field-list').each(function(){
-
- // vars
- var $fields = $(this).children('.acf-field-object');
-
-
- // loop over fields
- $fields.each(function( i ){
-
- // update meta
- self.update_field_meta( $(this), 'menu_order', i );
-
-
- // update icon number
- $(this).children('.handle').find('.acf-icon').html( i+1 );
-
- });
-
-
- // show no fields message
- if( !$fields.exists() ){
-
- $(this).children('.no-fields-message').show();
-
- } else {
-
- $(this).children('.no-fields-message').hide();
-
- }
-
- });
-
- },
-
-
- /*
- * get_field_meta
- *
- * This function will return an input value for a field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @param name
- * @return (string)
- */
-
- get_field_meta: function( $el, name ){
-
- //console.log( 'get_field_meta(%o, %o)', $el, name );
-
- // vars
- var $input = $el.find('> .meta > .input-' + name);
-
-
- // bail early if no input
- if( !$input.exists() ) {
-
- //console.log( '- aborted due to no input' );
- return false;
-
- }
-
-
- // return
- return $input.val();
-
- },
-
-
- /*
- * update_field_meta
- *
- * This function will update an input value for a field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @param name
- * @param value
- * @return n/a
- */
-
- update_field_meta: function( $el, name, value ){
-
- //console.log( 'update_field_meta(%o, %o, %o)', $el, name, value );
-
- // vars
- var $input = $el.find('> .meta > .input-' + name);
-
-
- // create hidden input if doesn't exist
- if( !$input.exists() ) {
-
- // vars
- var html = $el.find('> .meta > .input-ID').outerHTML();
-
-
- // replcae
- html = acf.str_replace('ID', name, html);
-
-
- // update $input
- $input = $(html);
-
-
- // reset value
- $input.val( value );
-
-
- // append
- $el.children('.meta').append( $input );
-
- //console.log( '- created new input' );
-
- }
-
-
- // bail early if no change
- if( $input.val() == value ) {
-
- //console.log( '- aborted due to no change in input value' );
- return;
- }
-
-
- // update value
- $input.val( value );
-
-
- // bail early if updating save
- if( name == 'save' ) {
-
- //console.log( '- aborted due to name == save' );
- return;
-
- }
-
-
- // meta has changed, update save
- this.save_field( $el, 'meta' );
-
- },
-
-
- /*
- * delete_field_meta
- *
- * This function will return an input value for a field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @param name
- * @return (string)
- */
-
- delete_field_meta: function( $el, name ){
-
- //console.log( 'delete_field_meta(%o, %o, %o)', $el, name );
-
- // vars
- var $input = $el.find('> .meta > .input-' + name);
-
-
- // bail early if not exists
- if( !$input.exists() ) {
-
- //console.log( '- aborted due to no input' );
- return;
-
- }
-
-
- // remove
- $input.remove();
-
-
- // meta has changed, update save
- this.save_field( $el, 'meta' );
-
- },
-
-
- /*
- * save_field
- *
- * This function will update the changed input for a given field making sure it is saved on submit
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- save_field: function( $el, type ){
-
- //console.log('save_field(%o %o)', $el, type);
-
- // defaults
- type = type || 'settings';
-
-
- // vars
- var value = this.get_field_meta( $el, 'save' );
-
-
- // bail early if already 'settings'
- if( value == 'settings' ) {
-
- return;
-
- }
-
-
- // bail early if no change
- if( value == type ) {
-
- return;
-
- }
-
-
- // update meta
- this.update_field_meta( $el, 'save', type );
-
-
- // action for 3rd party customization
- acf.do_action('save_field', $el, type);
-
- },
-
-
- /*
- * submit
- *
- * This function is triggered when submitting the form and provides validation prior to posting the data
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param n/a
- * @return (boolean)
- */
-
- submit: function( e ){
-
- // reference
- var self = this;
-
+ onSubmit: function( e, $el ){
// vars
var $title = $('#titlewrap #title');
-
- // title empty
+ // empty
if( !$title.val() ) {
// prevent default
e.preventDefault();
-
// unlock form
- acf.validation.toggle( e.$el, 'unlock' );
-
+ acf.validation.unlockForm( $el );
// alert
- alert( acf._e('title_is_required') );
-
+ alert( acf.__('Field group title is required') );
// focus
$title.focus();
-
}
-
-
- // close / delete fields
- $('.acf-field-object').each(function(){
-
- // vars
- var save = self.get_field_meta( $(this), 'save'),
- ID = self.get_field_meta( $(this), 'ID'),
- open = $(this).hasClass('open');
-
-
- // close
- if( open ) {
-
- self.close_field( $(this) );
-
- }
-
-
- // remove unnecessary inputs
- if( save == 'settings' ) {
-
- // allow all settings to save (new field, changed field)
-
- } else if( save == 'meta' ) {
-
- $(this).children('.settings').find('[name^="acf_fields[' + ID + ']"]').remove();
-
- } else {
-
- $(this).find('[name^="acf_fields[' + ID + ']"]').remove();
-
- }
-
- });
-
},
+ onClick: function( e ){
+ e.preventDefault();
+ },
- /*
- * trash
- *
- * This function is triggered when moving the field group to trash
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param n/a
- * @return (boolean)
- */
-
- trash: function( e ){
-
- var result = confirm( acf._e('move_to_trash') );
-
+ onClickTrash: function( e ){
+ var result = confirm( acf.__('Move to trash. Are you sure?') );
if( !result ) {
-
e.preventDefault();
-
}
-
},
+ filterFindFieldArgs: function( args ){
+ args.visible = true;
+ return args;
+ }
+ });
+
+
+ /**
+ * screenOptionsManager
+ *
+ * Screen options functionality
+ *
+ * @date 15/12/17
+ * @since 5.7.0
+ *
+ * @param void
+ * @return void
+ */
- /*
- * render_field
- *
- * This function will update the field's info
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
+ var screenOptionsManager = new acf.Model({
- render_field: function( $el ){
+ id: 'screenOptionsManager',
+ wait: 'prepare',
+
+ events: {
+ 'change': 'onChange'
+ },
+
+ initialize: function(){
// vars
- var label = $el.find('.field-label:first').val(),
- name = $el.find('.field-name:first').val(),
- type = $el.find('.field-type:first option:selected').text(),
- required = $el.find('.field-required:first').prop('checked'),
- $handle = $el.children('.handle');
+ var $div = $('#adv-settings');
+ var $append = $('#acf-append-show-on-screen');
+ // append
+ $div.find('.metabox-prefs').append( $append.html() );
+ $div.find('.metabox-prefs br').remove();
+
+ // clean up
+ $append.remove();
+
+ // initialize
+ this.$el = $('#acf-field-key-hide');
+ this.addEvents();
+
+ // render
+ this.render();
+ },
+
+ isChecked: function(){
+ return this.$el.prop('checked');
+ },
+
+ onChange: function( e, $el ) {
+ var val = this.isChecked() ? 1 : 0;
+ acf.updateUserSetting('show_field_keys', val);
+ this.render();
+ },
+
+ render: function(){
+ if( this.isChecked() ) {
+ $('#acf-field-group-fields').addClass('show-field-keys');
+ } else {
+ $('#acf-field-group-fields').removeClass('show-field-keys');
+ }
+ }
+
+ });
+
+
+ /**
+ * appendFieldManager
+ *
+ * Appends fields together
+ *
+ * @date 15/12/17
+ * @since 5.7.0
+ *
+ * @param void
+ * @return void
+ */
+
+ var appendFieldManager = new acf.Model({
+
+ actions: {
+ 'new_field' : 'onNewField'
+ },
+
+ onNewField: function( field ){
+
+ // bail ealry if not append
+ if( !field.has('append') ) return;
+
+ // vars
+ var append = field.get('append');
+ var $sibling = field.$el.siblings('[data-name="' + append + '"]').first();
+
+ // bail early if no sibling
+ if( !$sibling.length ) return;
+
+ // ul
+ var $div = $sibling.children('.acf-input');
+ var $ul = $div.children('ul');
+
+ // create ul
+ if( !$ul.length ) {
+ $div.wrapInner('
');
+ $ul = $div.children('ul');
+ }
+
+ // li
+ var html = field.$('.acf-input').html();
+ var $li = $('' + html + ' ');
+ $ul.append( $li );
+ $ul.attr('data-cols', $ul.children().length );
+
+ // clean up
+ field.remove();
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ acf.FieldObject = acf.Model.extend({
+
+ // class used to avoid nested event triggers
+ eventScope: '.acf-field-object',
+
+ // events
+ 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
+ data: {
+
+ // Similar to ID, but used for HTML puposes.
+ // It is possbile for a new field to have an ID of 0, but an id of 'field_123' */
+ id: 0,
+
+ // The field key ('field_123')
+ key: '',
+
+ // The field type (text, image, etc)
+ type: '',
+
+ // The $post->ID of this field
+ //ID: 0,
+
+ // The field's parent
+ //parent: 0,
+
+ // The menu order
+ //menu_order: 0
+ },
+
+ setup: function( $field ){
+
+ // set $el
+ this.$el = $field;
+
+ // inherit $field data (id, key, type)
+ this.inherit( $field );
+
+ // load additional props
+ // - this won't trigger 'changed'
+ this.prop('ID');
+ this.prop('parent');
+ this.prop('menu_order');
+ },
+
+ $input: function( name ){
+ return $('#' + this.getInputId() + '-' + name);
+ },
+
+ $settings: function(){
+ return this.$('.acf-field-settings:first > .acf-field');
+ },
+
+ $setting: function( name ){
+ return this.$('.acf-field-settings:first > .acf-field-setting-' + name);
+ },
+
+ 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( name, value ){
+
+ // vars
+ var inputId = this.getInputId();
+ var inputName = this.getInputName();
+
+ // append name
+ if( name ) {
+ inputId += '-'+name;
+ inputName += '['+name+']';
+ }
+
+ // create input (avoid HTML + JSON value issues)
+ var $input = $(' ').attr({
+ id: inputId,
+ name: inputName,
+ value: value
+ });
+ this.$('> .meta').append( $input );
+
+ // return
+ return $input;
+ },
+
+ getProp: function( name ){
+
+ // check data
+ if( this.has(name) ) {
+ return this.get(name);
+ }
+
+ // get input value
+ var $input = this.$input( name );
+ //console.log($input );
+ var value = $input.length ? $input.val() : null;
+
+ // set data silently (cache)
+ this.set(name, value, true);
+
+ // return
+ return value;
+ },
+
+ setProp: function( name, value ) {
+
+ // get input
+ var $input = this.$input( name );
+ var prevVal = $input.val();
+
+ // create if new
+ if( !$input.length ) {
+ $input = this.newInput( name, value );
+ }
+
+ // remove
+ if( value === null ) {
+ $input.remove();
+
+ // update
+ } else {
+ $input.val( value );
+ }
+
+ //console.log('setProp', name, value, this);
+
+ // set data silently (cache)
+ if( !this.has(name) ) {
+ //console.log('setting silently');
+ this.set(name, value, true);
+
+ // set data allowing 'change' event to fire
+ } else {
+ //console.log('setting loudly!');
+ this.set(name, value);
+ }
+
+ // return
+ return this;
+
+ },
+
+ prop: function( name, value ){
+ if( value !== undefined ) {
+ return this.setProp( name, value );
+ } else {
+ return this.getProp( name );
+ }
+ },
+
+ props: function( props ){
+ Object.keys( props ).map(function( key ){
+ this.setProp( key, props[key] );
+ }, this);
+ },
+
+ getLabel: function(){
+
+ // get label with empty default
+ var label = this.prop('label');
+ if( label === '' ) {
+ label = acf.__('(no label)')
+ }
+
+ // return
+ return label;
+ },
+
+ getName: function(){
+ return this.prop('name');
+ },
+
+ getType: function(){
+ return this.prop('type');
+ },
+
+ getTypeLabel: function(){
+ var type = this.prop('type');
+ var types = acf.get('fieldTypes');
+ return ( types[type] ) ? types[type].label : type;
+ },
+
+ getKey: function(){
+ return this.prop('key');
+ },
+
+ initialize: function(){
+ // do nothing
+ },
+
+ render: function(){
+
+ // vars
+ var $handle = this.$('.handle:first');
+ var menu_order = this.prop('menu_order');
+ var label = this.getLabel();
+ var name = this.prop('name');
+ var type = this.getTypeLabel();
+ var key = this.prop('key');
+ var required = this.$input('required').prop('checked');
+
+ // update menu order
+ $handle.find('.acf-icon').html( parseInt(menu_order) + 1 );
+
+ // update required
+ if( required ) {
+ label += ' * ';
+ }
// update label
$handle.find('.li-field-label strong a').html( label );
-
-
- // update required
- $handle.find('.li-field-label .acf-required').remove();
-
- if( required ) {
-
- $handle.find('.li-field-label strong').append('* ');
-
- }
-
-
+
// update name
$handle.find('.li-field-name').text( name );
-
// update type
$handle.find('.li-field-type').text( type );
+ // update key
+ $handle.find('.li-field-key').text( key );
// action for 3rd party customization
- acf.do_action('render_field_handle', $el, $handle);
-
+ acf.doAction('render_field_object', this);
},
+ refresh: function(){
+ acf.doAction('refresh_field_object', this);
+ },
- /*
- * edit_field
- *
- * This function is triggered when clicking on a field. It will open / close a fields settings
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
+ isOpen: function() {
+ return this.$el.hasClass('open');
+ },
- edit_field: function( $field ){
+ onClickEdit: function( e ){
+ this.isOpen() ? this.close() : this.open();
+ },
+
+ open: function(){
- // toggle
- if( $field.hasClass('open') ) {
+ // vars
+ var $settings = this.$el.children('.settings');
- this.close_field( $field );
+ // open
+ $settings.slideDown();
+ this.$el.addClass('open');
+
+ // action (open)
+ acf.doAction('open_field_object', this);
+ this.trigger('openFieldObject');
+
+ // action (show)
+ acf.doAction('show', $settings);
+ },
+
+ close: function(){
+
+ // vars
+ var $settings = this.$el.children('.settings');
+
+ // close
+ $settings.slideUp();
+ this.$el.removeClass('open');
+
+ // action (close)
+ acf.doAction('close_field_object', this);
+ this.trigger('closeFieldObject');
+
+ // action (hide)
+ acf.doAction('hide', $settings);
+ },
+
+ serialize: function(){
+ return acf.serialize( this.$el, this.getInputName() );
+ },
+
+ save: function( type ){
+
+ // defaults
+ type = type || 'settings'; // meta, settings
+
+ // vars
+ var save = this.getProp('save');
+
+ // bail if already saving settings
+ if( save === 'settings' ) {
+ return;
+ }
+
+ // prop
+ this.setProp('save', type);
+
+ // debug
+ this.$el.attr('data-save', type);
+
+ // action
+ acf.doAction('save_field_object', this, type);
+ },
+
+ submit: function(){
+
+ // vars
+ var inputName = this.getInputName();
+ var save = this.get('save');
+
+ // close
+ if( this.isOpen() ) {
+ this.close();
+ }
+
+ // allow all inputs to save
+ if( save == 'settings' ) {
+ // do nothing
+
+ // allow only meta inputs to save
+ } else if( save == 'meta' ) {
+ this.$('> .settings [name^="' + inputName + '"]').remove();
+ // prevent all inputs from saving
} else {
-
- this.open_field( $field );
-
+ this.$('[name^="' + inputName + '"]').remove();
}
+ // action
+ acf.doAction('submit_field_object', this);
},
-
- /*
- * open_field
- *
- * This function will open a fields settings
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- open_field: function( $el ){
+ onChange: function(){
+ //console.log('onChange');
+ this.save();
- // bail early if already open
- if( $el.hasClass('open') ) {
+ // action for 3rd party customization
+ acf.doAction('change_field_object', this);
+ },
+
+ onChanged: function( e, name, value ){
- return false;
-
+ // ignore 'save'
+ if( name == 'save' ) {
+ return;
}
+ // save meta
+ if( ['menu_order', 'parent'].indexOf(name) > -1 ) {
+ this.save('meta');
+
+ // save field
+ } else {
+ this.save();
+ }
+
+ // render
+ if( ['menu_order', 'label', 'required', 'name', 'type', 'key'].indexOf(name) > -1 ) {
+ this.render();
+ }
+
+ // action for 3rd party customization
+ acf.doAction('change_field_object_' + name, this, value);
+ },
+
+ onChangeLabel: function( e, $el ){
+
+ // set
+ var label = $el.val();
+ this.set('label', label);
+
+ // render name
+ if( this.prop('name') == '' ) {
+ var name = acf.applyFilters('generate_field_object_name', acf.strSanitize(label), this);
+ this.prop('name', name);
+ }
+ },
+
+ onChangeName: function( e, $el){
+
+ // set
+ var name = $el.val();
+ this.set('name', name);
+
+ // error
+ if( name.substr(0, 6) === 'field_' ) {
+ alert( acf.__('The string "field_" may not be used at the start of a field name') );
+ }
+ },
+
+ onChangeRequired: function( e, $el ){
+
+ // set
+ var required = $el.prop('checked') ? 1 : 0;
+ this.set('required', required);
+ },
+
+ delete: function( args ){
+
+ // defaults
+ args = acf.parseArgs(args, {
+ animate: true
+ });
+
+ // add to remove list
+ var id = this.prop('ID');
+
+ if( id ) {
+ var $input = $('#_acf_delete_fields');
+ var newVal = $input.val() + '|' + id;
+ $input.val( newVal );
+ }
+
+ // action
+ acf.doAction('delete_field_object', this);
+
+ // animate
+ if( args.animate ) {
+ this.removeAnimate();
+ } else {
+ this.remove();
+ }
+ },
+
+ onClickDelete: function( e, $el ){
// add class
- $el.addClass('open');
-
-
- // action for 3rd party customization
- acf.do_action('open_field', $el);
-
-
- // animate toggle
- $el.children('.settings').animate({ 'height' : 'toggle' }, 250 );
+ this.$el.addClass('-hover');
+ // add tooltip
+ var self = this;
+ var tooltip = acf.newTooltip({
+ confirmRemove: true,
+ target: $el,
+ confirm: function(){
+ self.delete( true );
+ },
+ cancel: function(){
+ self.$el.removeClass('-hover');
+ }
+ });
},
-
- /*
- * close_field
- *
- * This function will open a fields settings
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- close_field: function( $el ){
-
- // bail early if already closed
- if( !$el.hasClass('open') ) {
-
- return false;
-
- }
-
-
- // remove class
- $el.removeClass('open');
-
-
- // action for 3rd party customization
- acf.do_action('close_field', $el);
-
-
- // animate toggle
- $el.children('.settings').animate({ 'height' : 'toggle' }, 250 );
-
- },
-
-
- /*
- * wipe_field
- *
- * This function will prepare a new field by updating the input names
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- wipe_field: function( $el ){
+ removeAnimate: function(){
// vars
- var id = $el.attr('data-id'),
- key = $el.attr('data-key'),
- new_id = acf.get_uniqid(),
- new_key = 'field_' + new_id;
-
-
- // update attr
- $el.attr('data-id', new_id);
- $el.attr('data-key', new_key);
- $el.attr('data-orig', key);
-
-
- // update hidden inputs
- this.update_field_meta( $el, 'ID', '' );
- this.update_field_meta( $el, 'key', new_key );
-
-
- // update attributes
- $el.find('[id*="' + id + '"]').each(function(){
-
- $(this).attr('id', $(this).attr('id').replace(id, new_id) );
-
+ var field = this;
+ var $list = this.$el.parent();
+ var $fields = acf.findFieldObjects({
+ sibling: this.$el
});
- $el.find('[name*="' + id + '"]').each(function(){
-
- $(this).attr('name', $(this).attr('name').replace(id, new_id) );
-
+ // remove
+ acf.remove({
+ target: this.$el,
+ endHeight: $fields.length ? 0 : 50,
+ complete: function(){
+ field.remove();
+ acf.doAction('removed_field_object', field, $list);
+ }
});
-
- // update key
- $el.find('> .handle .pre-field-key').text( new_key );
-
-
- // remove sortable classes
- $el.find('.ui-sortable').removeClass('ui-sortable');
-
-
- // action for 3rd party customization
- acf.do_action('wipe_field', $el);
-
+ // action
+ acf.doAction('remove_field_object', field, $list);
},
-
- /*
- * add_field
- *
- * This function will add a new field to a field list
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $fields
- * @return n/a
- */
-
- add_field: function( $fields ){
-
- // clone tr
- var $el = $( $('#tmpl-acf-field').html() ),
- $label = $el.find('.field-label:first'),
- $name = $el.find('.field-name:first');
-
-
- // update names
- this.wipe_field( $el );
-
-
- // append to table
- $fields.append( $el );
-
-
- // clear name
- $label.val('');
- $name.val('');
-
-
- // focus after form has dropped down
- setTimeout(function(){
-
- $label.focus();
-
- }, 251);
-
-
- // update order numbers
- this.render_fields();
-
-
- // trigger append
- acf.do_action('append', $el);
-
-
- // open up form
- this.edit_field( $el );
-
-
- // action for 3rd party customization
- acf.do_action('add_field', $el);
-
- },
-
-
- /*
- * duplicate_field
- *
- * This function will duplicate a field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return $el2
- */
-
- duplicate_field: function( $el ){
-
- // allow acf to modify DOM
- acf.do_action('before_duplicate', $el);
-
+ duplicate: function(){
// vars
- var $el2 = $el.clone(),
- $label = $el2.find('.field-label:first'),
- $name = $el2.find('.field-name:first');
+ var newKey = acf.uniqid('field_');
+ // duplicate
+ var $newField = acf.duplicate({
+ target: this.$el,
+ search: this.get('id'),
+ replace: newKey,
+ });
- // remove JS functionality
- acf.do_action('remove', $el2);
+ // set new key
+ $newField.attr('data-key', newKey);
+ // get instance
+ var newField = acf.getFieldObject( $newField );
- // update names
- this.wipe_field( $el2 );
-
-
- // allow acf to modify DOM
- acf.do_action('after_duplicate', $el, $el2);
-
-
- // append to table
- $el.after( $el2 );
-
-
- // trigger append
- acf.do_action('append', $el2);
-
-
- // focus after form has dropped down
- setTimeout(function(){
-
- $label.focus();
-
- }, 251);
-
-
- // update order numbers
- this.render_fields();
-
-
- // open up form
- if( $el.hasClass('open') ) {
-
- this.close_field( $el );
-
+ // open / close
+ if( this.isOpen() ) {
+ this.close();
} else {
-
- this.open_field( $el2 );
-
+ newField.open();
}
+ // focus label
+ var $label = newField.$setting('label input');
+ setTimeout(function(){
+ $label.focus();
+ }, 251);
- // update new_field label / name
- var label = $label.val(),
- name = $name.val(),
- end = name.split('_').pop(),
- copy = acf._e('copy');
+ // update newField label / name
+ var label = newField.prop('label');
+ var name = newField.prop('name');
+ var end = name.split('_').pop();
+ var copy = acf.__('copy');
+ // increase suffix "1"
+ if( $.isNumeric(end) ) {
+ var i = (end*1) + 1;
+ label = label.replace( end, i );
+ name = name.replace( end, i );
- // look at last word
- if( end.indexOf(copy) === 0 ) {
-
+ // increase suffix "(copy1)"
+ } else if( end.indexOf(copy) === 0 ) {
var i = end.replace(copy, '') * 1;
- i = i ? i+1 : 2;
+ i = i ? i+1 : 2;
// replace
label = label.replace( end, copy + i );
name = name.replace( end, copy + i );
-
+
+ // add default "(copy)"
} else {
-
label += ' (' + copy + ')';
name += '_' + copy;
-
}
+ newField.prop('ID', 0);
+ newField.prop('label', label);
+ newField.prop('name', name);
+ newField.prop('key', newKey);
- $label.val( label );
- $name.val( name );
-
-
- // save field
- this.save_field( $el2 );
-
-
- // render field
- this.render_field( $el2 );
-
-
- // action for 3rd party customization
- acf.do_action('duplicate_field', $el2);
-
-
- // return
- return $el2;
-
+ // action
+ acf.doAction('duplicate_field_object', this, newField);
+ acf.doAction('append_field_object', newField);
},
-
- /*
- * move_field
- *
- * This function will launch a popup to move a field to another field group
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $field
- * @return n/a
- */
-
- move_field: function( $field ){
-
- // reference
- var self = this;
-
-
- // AJAX data
- var ajax_data = acf.prepare_for_ajax({
- action: 'acf/field_group/move_field',
- field_id: this.get_field_meta( $field, 'ID' )
- });
-
+ wipe: function(){
// vars
- var warning = false;
+ var prevId = this.get('id');
+ var prevKey = this.get('key');
+ var newKey = acf.uniqid('field_');
-
- // validate
- if( !ajax_data.field_id ) {
-
- // Case: field not saved to DB
- warning = true;
-
- } else if( this.get_field_meta( $field, 'save' ) == 'settings' ) {
-
- // Case: field's settings have changed
- warning = true;
-
- } else {
-
- // Case: sub field's settings have changed
- $field.find('.acf-field-object').each(function(){
-
- if( !self.get_field_meta( $(this), 'ID' ) ) {
-
- // Case: field not saved to DB
- warning = true;
- return false;
-
- } else if( self.get_field_meta( $(this), 'save' ) == 'settings' ) {
-
- // Case: field's settings have changed
- warning = true;
-
- }
-
- });
-
- }
-
-
- // bail early if can't move
- if( warning ) {
-
- alert( acf._e('move_field_warning') );
- return;
-
- }
-
-
- // open popup
- acf.open_popup({
- title : acf._e('move_field'),
- loading : true,
- height : 145
+ // rename
+ acf.rename({
+ target: this.$el,
+ search: prevId,
+ replace: newKey,
});
+ // data
+ this.set('id', newKey);
+ this.set('prevId', prevId);
+ this.set('prevKey', prevKey);
- // get HTML
- $.ajax({
- url: acf.get('ajaxurl'),
- data: ajax_data,
- type: 'post',
- dataType: 'html',
- success: function(html){
-
- self.move_field_confirm( $field, html );
-
- }
- });
+ // props
+ this.prop('key', newKey);
+ this.prop('ID', 0);
+ // attr
+ this.$el.attr('data-key', newKey);
+ this.$el.attr('data-id', newKey);
+
+ // action
+ acf.doAction('wipe_field_object', this);
},
-
- /*
- * move_field_confirm
- *
- * This function will move a field to another field group
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- move_field_confirm: function( $field, html ){
+ move: function(){
- // reference
- var self = this;
+ // helper
+ var hasChanged = function( field ){
+ return (field.get('save') == 'settings');
+ };
+ // vars
+ var changed = hasChanged(this);
- // update popup
- acf.update_popup({
- content : html
- });
+ // has sub fields changed
+ if( !changed ) {
+ acf.getFieldObjects({
+ parent: this.$el
+ }).map(function( field ){
+ changed = hasChanged(field) || field.changed;
+ });
+ }
+ // bail early if changed
+ if( changed ) {
+ alert( acf.__('This field cannot be moved until its changes have been saved') );
+ return;
+ }
- // AJAX data
- var ajax_data = acf.prepare_for_ajax({
- 'action' : 'acf/field_group/move_field',
- 'field_id' : this.get_field_meta($field, 'ID'),
- 'field_group_id' : 0
- });
-
-
- // submit form
- $('#acf-move-field-form').on('submit', function(){
-
- ajax_data.field_group_id = $(this).find('select').val();
+ // step 1.
+ var id = this.prop('ID');
+ var field = this;
+ var popup = false;
+ var step1 = function(){
+ // popup
+ popup = acf.newPopup({
+ title: acf.__('Move Custom Field'),
+ loading: true,
+ width: '300px'
+ });
+
+ // ajax
+ var ajaxData = {
+ action: 'acf/field_group/move_field',
+ field_id: id
+ };
// get HTML
$.ajax({
url: acf.get('ajaxurl'),
- data: ajax_data,
+ data: acf.prepareForAjax(ajaxData),
type: 'post',
dataType: 'html',
- success: function(html){
-
- acf.update_popup({
- content : html
- });
-
-
- // remove the field without actually deleting it
- self.remove_field( $field );
-
- }
+ success: step2
});
+ };
+
+ var step2 = function( html ){
- return false;
+ // update popup
+ popup.loading(false);
+ popup.content(html);
- });
+ // submit form
+ popup.on('submit', 'form', step3);
+ };
+
+ var step3 = function( e, $el ){
+
+ // prevent
+ e.preventDefault();
+
+ // disable
+ acf.startButtonLoading( popup.$('.button') );
+
+ // ajax
+ var ajaxData = {
+ action: 'acf/field_group/move_field',
+ field_id: id,
+ field_group_id: popup.$('select').val()
+ };
+
+ // get HTML
+ $.ajax({
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax(ajaxData),
+ type: 'post',
+ dataType: 'html',
+ success: step4
+ });
+ };
+
+ var step4 = function( html ){
+
+ // update popup
+ popup.content(html);
+
+ // remove element
+ field.removeAnimate();
+ };
+
+ // start
+ step1();
},
-
- /*
- * delete_field
- *
- * This function will delete a field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @param animation
- * @return n/a
- */
-
- delete_field: function( $el, animation ){
+ onChangeType: function( e, $el ){
- // defaults
- animation = animation || true;
-
-
- // vars
- var id = this.get_field_meta($el, 'ID');
-
-
- // add to remove list
- if( id ) {
-
- var $input = $('#_acf_delete_fields');
- $input.val( $input.val() + '|' + id );
-
+ // clea previous timout
+ if( this.changeTimeout ) {
+ clearTimeout(this.changeTimeout);
}
-
- // action for 3rd party customization
- acf.do_action('delete_field', $el);
-
-
- // bail early if no animation
- if( animation ) {
-
- this.remove_field( $el );
-
- }
-
+ // set new timeout
+ // - prevents changing type multiple times whilst user types in newType
+ this.changeTimeout = this.setTimeout(function(){
+ this.changeType( $el.val() );
+ }, 300);
},
-
- /*
- * remove_field
- *
- * This function will visualy remove a field
- *
- * @type function
- * @date 24/10/2014
- * @since 5.0.9
- *
- * @param $el
- * @param animation
- * @return n/a
- */
-
- remove_field: function( $el ){
-
- // reference
- var self = this;
-
+ changeType: function( newType ){
// vars
- var $field_list = $el.closest('.acf-field-list');
-
-
- // set layout
- $el.css({
- height : $el.height(),
- width : $el.width(),
- position : 'absolute'
- });
-
-
- // wrap field
- $el.wrap( '
' );
-
-
- // fade $el
- $el.animate({ opacity : 0 }, 250);
-
-
- // close field
- var end_height = 0,
- $show = false;
-
-
- if( !$field_list.children('.acf-field-object').length ) {
-
- $show = $field_list.children('.no-fields-message');
- end_height = $show.outerHeight();
-
- }
-
- $el.parent('.temp-field-wrap').animate({ height : end_height }, 250, function(){
-
- // show another element
- if( $show ) {
-
- $show.show();
-
- }
-
-
- // action for 3rd party customization
- acf.do_action('remove', $(this));
-
-
- // remove $el
- $(this).remove();
-
-
- // render fields becuase they have changed
- self.render_fields();
-
- });
-
- },
-
-
- /*
- * change_field_type
- *
- * This function will update the field's settings based on the new field type
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $select
- * @return n/a
- */
-
- change_field_type: function( $select ){
-
- // vars
- var $tbody = $select.closest('tbody'),
- $el = $tbody.closest('.acf-field-object'),
- $parent = $el.parent().closest('.acf-field-object'),
-
- key = $el.attr('data-key'),
- old_type = $el.attr('data-type'),
- new_type = $select.val();
-
-
- // update class
- $el.removeClass( 'acf-field-object-' + acf.str_replace('_', '-', old_type) );
- $el.addClass( 'acf-field-object-' + acf.str_replace('_', '-', new_type) );
-
-
- // update atts
- $el.attr('data-type', new_type);
- $el.data('type', new_type);
+ var prevType = this.prop('type');
+ var prevClass = acf.strSlugify( 'acf-field-object-' + prevType );
+ var newClass = acf.strSlugify( 'acf-field-object-' + newType );
+ // update props
+ this.$el.removeClass(prevClass).addClass(newClass);
+ this.$el.attr('data-type', newType);
+ this.$el.data('type', newType);
// abort XHR if this field is already loading AJAX data
- if( $el.data('xhr') ) {
-
- $el.data('xhr').abort();
-
+ if( this.has('xhr') ) {
+ this.get('xhr').abort();
}
-
- // get settings
- var $settings = $tbody.children('.acf-field[data-setting="' + old_type + '"]');
-
- // save field settings html
- acf.update( key + '_settings_' + old_type, $settings );
-
- // remove settings
+ // store settings
+ var $tbody = this.$('> .settings > table > tbody');
+ var $settings = $tbody.children('[data-setting="' + prevType + '"]');
+ this.set( 'settings-' + prevType, $settings );
$settings.detach();
-
- // render field
- this.render_field( $el );
-
-
- // show field options if they already exist
- $newettings = acf.get( key + '_settings_' + new_type );
-
- if( $newettings ) {
-
- // append settings
- $tbody.children('.acf-field[data-name="conditional_logic"]').before( $newettings );
-
-
- // remove field settings html
- acf.update( key + '_settings_' + new_type, false );
-
-
- // trigger event
- acf.do_action('change_field_type', $el);
-
-
- // return
+
+ // show settings
+ if( this.has('settings-' + newType) ) {
+ var $newSettings = this.get('settings-' + newType);
+ this.$setting('conditional_logic').before( $newSettings );
+ this.set('type', newType);
+ //this.refresh();
return;
}
+ // load settings
+ var $loading = $('
');
+ this.$setting('conditional_logic').before( $loading );
- // add loading
- var $tr = $('
');
-
-
- // add $tr
- $tbody.children('.acf-field[data-name="conditional_logic"]').before( $tr );
-
-
- var ajax_data = {
- action : 'acf/field_group/render_field_settings',
- nonce : acf.o.nonce,
- parent : acf.o.post_id,
- field_group : acf.o.post_id,
- prefix : $select.attr('name').replace('[type]', ''),
- type : new_type
- };
-
-
- // parent
- if( $parent.exists() ) {
-
- ajax_data.parent = this.get_field_meta( $parent, 'ID' );
-
- }
-
+ // ajax
+ var ajaxData = {
+ action: 'acf/field_group/render_field_settings',
+ field: this.serialize(),
+ prefix: this.getInputName()
+ };
// ajax
var xhr = $.ajax({
- url: acf.o.ajaxurl,
- data: ajax_data,
- type: 'post',
- dataType: 'html',
- success: function( html ){
-
- // bail early if no html
- if( !html ) {
-
- return;
-
- }
-
-
- // vars
- var $new_tr = $(html);
-
-
- // replace
- $tr.after( $new_tr );
-
-
- // trigger event
- acf.do_action('append', $new_tr);
- acf.do_action('change_field_type', $el);
-
-
- },
- complete : function(){
-
- // this function will also be triggered by $el.data('xhr').abort();
- $tr.remove();
-
- }
- });
-
-
- // update el data
- $el.data('xhr', xhr);
-
- },
-
- /*
- * change_field_label
- *
- * This function is triggered when changing the field's label
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- change_field_label: function( $el ) {
-
- // vars
- var $label = $el.find('.field-label:first'),
- $name = $el.find('.field-name:first'),
- type = $el.attr('data-type');
-
-
- // render name
- if( $name.val() == '' ) {
-
- // vars
- var s = $label.val();
-
-
- // sanitize
- s = acf.str_sanitize(s);
-
-
- // update name
- $name.val( s ).trigger('change');
-
- }
-
-
- // render field
- this.render_field( $el );
-
-
- // action for 3rd party customization
- acf.do_action('change_field_label', $el);
-
- },
-
- /*
- * change_field_name
- *
- * This function is triggered when changing the field's name
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- change_field_name: function( $el ) {
-
- // vars
- var $name = $el.find('.field-name:first');
-
- if( $name.val().substr(0, 6) === 'field_' ) {
-
- alert( acf._e('field_name_start') );
-
- setTimeout(function(){
-
- $name.focus();
-
- }, 1);
-
- }
-
-
- // action for 3rd party customization
- acf.do_action('change_field_name', $el);
-
- }
-
- });
-
-
- /*
- * field
- *
- * This model will handle field events
- *
- * @type function
- * @date 19/08/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- 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 ){
-
- // append $field
- e.$field = e.$el.closest('.acf-field-object');
-
-
- // return
- return e;
-
- },
-
-
- /*
- * events
- *
- * description
- *
- * @type function
- * @date 19/08/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- 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 $list = e.$el.closest('.acf-field-list-wrap').children('.acf-field-list');
-
- acf.field_group.add_field( $list );
-
- },
-
- 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 );
-
- }
-
- });
-
-
- /*
- * conditions
- *
- * This model will handle conditional logic events
- *
- * @type function
- * @date 19/08/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- 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
- *
- * description
- *
- * @type function
- * @date 19/08/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- render_fields: function(){
-
- var self = this;
-
- $('.acf-field-object.open').each(function(){
-
- self.render_field( $(this) );
-
- });
-
- },
-
-
- /*
- * render_field
- *
- * This function will render the conditional logic fields for a given field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $field
- * @return n/a
- */
-
- render_field: function( $field ){
-
- // reference
- var self = this;
-
-
- // vars
- var key = $field.attr('data-key');
- var $lists = $field.parents('.acf-field-list');
- var $tr = $field.find('.acf-field-setting-conditional_logic:last');
-
-
- // choices
- var choices = [];
-
-
- // loop over ancestor lists
- $.each( $lists, function( i ){
-
- // vars
- var group = (i == 0) ? acf._e('sibling_fields') : acf._e('parent_fields');
-
-
- // loop over fields
- $(this).children('.acf-field-object').each(function(){
-
- // vars
- var $this_field = $(this),
- this_key = $this_field.attr('data-key'),
- this_type = $this_field.attr('data-type'),
- this_label = $this_field.find('.field-label:first').val();
-
-
- // validate
- if( $.inArray(this_type, ['select', 'checkbox', 'true_false', 'radio', 'button_group']) === -1 ) {
-
- return;
-
- } else if( this_key == key ) {
-
- return;
-
- }
-
-
- // add this field to available triggers
- choices.push({
- value: this_key,
- label: this_label,
- group: group
- });
-
- });
-
- });
-
-
- // empty?
- if( !choices.length ) {
-
- choices.push({
- value: '',
- label: acf._e('no_fields')
- });
-
- }
-
-
- // create select fields
- $tr.find('.rule').each(function(){
-
- self.render_rule( $(this), choices );
-
- });
-
- },
-
-
- /*
- * populate_triggers
- *
- * description
- *
- * @type function
- * @date 22/08/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- render_rule: function( $tr, triggers ) {
-
- // vars
- var $trigger = $tr.find('.conditional-rule-param'),
- $value = $tr.find('.conditional-rule-value');
-
-
- // populate triggers
- if( triggers ) {
-
- acf.render_select( $trigger, triggers );
-
- }
-
-
- // vars
- var $field = $('.acf-field-object[data-key="' + $trigger.val() + '"]'),
- field_type = $field.attr('data-type'),
- choices = [];
-
-
- // populate choices
- if( field_type == "true_false" ) {
-
- choices.push({
- 'value': 1,
- 'label': acf._e('checked')
- });
-
- // select
- } else if( field_type == "select" || field_type == "checkbox" || field_type == "radio" || field_type == "button_group" ) {
-
- // vars
- var lines = $field.find('.acf-field[data-name="choices"] textarea').val().split("\n");
-
- $.each(lines, function(i, line){
-
- // explode
- line = line.split(':');
-
-
- // default label to value
- line[1] = line[1] || line[0];
-
-
- // append
- choices.push({
- 'value': $.trim( line[0] ),
- 'label': $.trim( line[1] )
- });
-
- });
-
-
- // allow null
- var $allow_null = $field.find('.acf-field[data-name="allow_null"]');
-
- if( $allow_null.exists() ) {
-
- if( $allow_null.find('input:checked').val() == '1' ) {
-
- choices.unshift({
- 'value': '',
- 'label': acf._e('null')
- });
-
- }
-
- }
-
- }
-
-
- // update select
- acf.render_select( $value, choices );
-
- },
-
-
- /*
- * change_toggle
- *
- * This function is triggered by changing the 'Conditional Logic' radio button
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $input
- * @return n/a
- */
-
- change_toggle: function( e ){
-
- // vars
- var $input = e.$el,
- checked = e.$el.prop('checked'),
- $td = $input.closest('.acf-input');
-
-
- if( checked ) {
-
- $td.find('.rule-groups').show();
- $td.find('.rule-groups').find('[name]').prop('disabled', false);
-
- } else {
-
- $td.find('.rule-groups').hide();
- $td.find('.rule-groups').find('[name]').prop('disabled', true);
-
- }
-
- },
-
-
- /*
- * change_trigger
- *
- * This function is triggered by changing a 'Conditional Logic' trigger
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $select
- * @return n/a
- */
-
- change_param: function( e ){
-
- // vars
- var $rule = e.$el.closest('.rule');
-
-
- // render
- this.render_rule( $rule );
-
- },
-
-
- /*
- * add_rule
- *
- * This function will add a new rule below the specified $tr
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $tr
- * @return n/a
- */
-
- add_rule: function( e ){
-
- // vars
- var $tr = e.$el.closest('tr');
-
-
- // duplicate
- $tr2 = acf.duplicate( $tr );
-
-
- // save field
- $tr2.find('select:first').trigger('change');
-
- },
-
-
- /*
- * remove_rule
- *
- * This function will remove the $tr and potentially the group
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $tr
- * @return n/a
- */
-
- remove_rule: function( e ){
-
- // vars
- var $tr = e.$el.closest('tr');
-
-
- // save field
- $tr.find('select:first').trigger('change');
-
-
- if( $tr.siblings('tr').length == 0 ) {
-
- // remove group
- $tr.closest('.rule-group').remove();
-
- }
-
-
- // remove tr
- $tr.remove();
-
-
- },
-
-
- /*
- * add_group
- *
- * This function will add a new rule group to the given $groups container
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $tr
- * @return n/a
- */
-
- add_group: function( e ){
-
- // vars
- var $groups = e.$el.closest('.rule-groups'),
- $group = $groups.find('.rule-group:last');
-
-
- // duplicate
- $group2 = acf.duplicate( $group );
-
-
- // update h4
- $group2.find('h4').text( acf._e('or') );
-
-
- // remove all tr's except the first one
- $group2.find('tr:not(:first)').remove();
-
-
- // save field
- $group2.find('select:first').trigger('change');
-
- }
-
- });
-
-
- /*
- * locations
- *
- * This model will handle location rule events
- *
- * @type function
- * @date 19/08/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- 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
- *
- * This function will add a new rule below the specified $tr
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $tr
- * @return n/a
- */
-
- add_rule: function( e ){
-
- // vars
- var $tr = e.$el.closest('tr');
-
-
- // duplicate
- $tr2 = acf.duplicate( $tr );
-
-
- // action
- //acf.do_action('add_location_rule', $tr2);
-
- },
-
-
- /*
- * remove_rule
- *
- * This function will remove the $tr and potentially the group
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $tr
- * @return n/a
- */
-
- remove_rule: function( e ){
-
- // vars
- var $tr = e.$el.closest('tr');
-
-
- // action
- //acf.do_action('remove_location_rule', $tr);
-
-
- // remove
- if( $tr.siblings('tr').length == 0 ) {
-
- // remove group
- $tr.closest('.rule-group').remove();
-
- } else {
-
- // remove tr
- $tr.remove();
-
- }
-
- },
-
-
- /*
- * add_group
- *
- * This function will add a new rule group to the given $groups container
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $tr
- * @return n/a
- */
-
- add_group: function( e ){
-
- // vars
- var $groups = e.$el.closest('.rule-groups'),
- $group = $groups.find('.rule-group:last');
-
-
- // duplicate
- $group2 = acf.duplicate( $group );
-
-
- // update h4
- $group2.find('h4').text( acf._e('or') );
-
-
- // remove all tr's except the first one
- $group2.find('tr:not(:first)').remove();
-
-
- // vars
- //var $tr = $group2.find('tr');
-
-
- // action
- //acf.do_action('add_location_rule', $tr);
-
- },
-
-
- /*
- * change_rule
- *
- * This function is triggered when changing a location rule trigger
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $select
- * @return n/a
- */
-
- change_rule: function( e ){
-
- // vars
- var $rule = e.$el.closest('tr');
- var $group = $rule.closest('.rule-group');
- var prefix = $rule.find('td.param select').attr('name').replace('[param]', '');
-
-
- // ajax data
- var ajaxdata = {
- action: 'acf/field_group/render_location_rule',
- rule: acf.serialize( $rule, prefix ),
- };
-
-
- // append to data
- ajaxdata.rule.id = $rule.attr('data-id');
- ajaxdata.rule.group = $group.attr('data-id');
-
-
- // ajax
- $.ajax({
url: acf.get('ajaxurl'),
- data: acf.prepare_for_ajax(ajaxdata),
+ data: acf.prepareForAjax(ajaxData),
type: 'post',
dataType: 'html',
+ context: this,
success: function( html ){
- // bail early if no html
+ // bail early if no settings
if( !html ) return;
+ // append settings
+ $loading.after( html );
- // update
- $rule.replaceWith( html );
-
-
- // action
- //acf.do_action('change_location_rule', $rule);
-
+ // events
+ acf.doAction('append', $tbody);
+ },
+ complete: function(){
+ // also triggered by xhr.abort();
+ $loading.remove();
+ this.set('type', newType);
+ //this.refresh();
}
});
+ // set
+ this.set('xhr', xhr);
+
+ },
+
+ updateParent: function(){
+
+ // vars
+ var ID = acf.get('post_id');
+
+ // check parent
+ var parent = this.getParent();
+ if( parent ) {
+ ID = parent.prop('ID') || parent.prop('key');
+ }
+
+ // update
+ this.prop('parent', ID);
+ }
+
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * mid
+ *
+ * Calculates the model ID for a field type
+ *
+ * @date 15/12/17
+ * @since 5.6.5
+ *
+ * @param string type
+ * @return string
+ */
+
+ var modelId = function( type ) {
+ return acf.strPascalCase( type || '' ) + 'FieldSetting';
+ };
+
+ /**
+ * registerFieldType
+ *
+ * description
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.registerFieldSetting = function( model ){
+ var proto = model.prototype;
+ var mid = modelId(proto.type + ' ' + proto.name);
+ this.models[ mid ] = model;
+ };
+
+ /**
+ * newField
+ *
+ * description
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.newFieldSetting = function( field ){
+
+ // vars
+ var type = field.get('setting') || '';
+ var name = field.get('name') || '';
+ var mid = modelId( type + ' ' + name );
+ var model = acf.models[ mid ] || null;
+
+ // bail ealry if no setting
+ if( model === null ) return false;
+
+ // instantiate
+ var setting = new model( field );
+
+ // return
+ return setting;
+ };
+
+ /**
+ * acf.getFieldSetting
+ *
+ * description
+ *
+ * @date 19/4/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getFieldSetting = function( field ) {
+
+ // allow jQuery
+ if( field instanceof jQuery ) {
+ field = acf.getField(field);
+ }
+
+ // return
+ return field.setting;
+ };
+
+ /**
+ * settingsManager
+ *
+ * description
+ *
+ * @date 6/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var settingsManager = new acf.Model({
+ actions: {
+ 'new_field': 'onNewField'
+ },
+ onNewField: function( field ){
+ field.setting = acf.newFieldSetting( field );
}
});
+ /**
+ * acf.FieldSetting
+ *
+ * description
+ *
+ * @date 6/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.FieldSetting = acf.Model.extend({
+
+ field: false,
+ type: '',
+ name: '',
+ wait: 'ready',
+ eventScope: '.acf-field',
+
+ events: {
+ 'change': 'render'
+ },
+
+ setup: function( field ){
+
+ // vars
+ var $field = field.$el;
+
+ // set props
+ this.$el = $field;
+ this.field = field;
+ this.$fieldObject = $field.closest('.acf-field-object');
+ this.fieldObject = acf.getFieldObject( this.$fieldObject );
+
+ // inherit data
+ $.extend(this.data, field.data);
+ },
+
+ initialize: function(){
+ this.render();
+ },
+
+ render: function(){
+ // do nothing
+ }
+ });
/*
- * field
+ * Date Picker
*
- * This model sets up many of the field's interactions
+ * This field type requires some extra logic for its settings
*
* @type function
- * @date 21/02/2014
- * @since 3.5.1
+ * @date 24/10/13
+ * @since 5.0.0
*
* @param n/a
* @return n/a
*/
- acf.field_group.field_object = acf.model.extend({
+ var DisplayFormatFieldSetting = acf.FieldSetting.extend({
+ type: '',
+ name: '',
+ render: function(){
+ var $input = this.$('input[type="radio"]:checked');
+ if( $input.val() != 'other' ) {
+ this.$('input[type="text"]').val( $input.val() );
+ }
+ }
+ });
+
+ var DatePickerDisplayFormatFieldSetting = DisplayFormatFieldSetting.extend({
+ type: 'date_picker',
+ name: 'display_format'
+ });
+
+ var DatePickerReturnFormatFieldSetting = DisplayFormatFieldSetting.extend({
+ type: 'date_picker',
+ name: 'return_format'
+ });
+
+ acf.registerFieldSetting( DatePickerDisplayFormatFieldSetting );
+ acf.registerFieldSetting( DatePickerReturnFormatFieldSetting );
+
+ /*
+ * Date Time Picker
+ *
+ * This field type requires some extra logic for its settings
+ *
+ * @type function
+ * @date 24/10/13
+ * @since 5.0.0
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ var DateTimePickerDisplayFormatFieldSetting = DisplayFormatFieldSetting.extend({
+ type: 'date_time_picker',
+ name: 'display_format'
+ });
+
+ var DateTimePickerReturnFormatFieldSetting = DisplayFormatFieldSetting.extend({
+ type: 'date_time_picker',
+ name: 'return_format'
+ });
+
+ acf.registerFieldSetting( DateTimePickerDisplayFormatFieldSetting );
+ acf.registerFieldSetting( DateTimePickerReturnFormatFieldSetting );
+
+ /*
+ * Time Picker
+ *
+ * This field type requires some extra logic for its settings
+ *
+ * @type function
+ * @date 24/10/13
+ * @since 5.0.0
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ var TimePickerDisplayFormatFieldSetting = DisplayFormatFieldSetting.extend({
+ type: 'time_picker',
+ name: 'display_format'
+ });
+
+ var TimePickerReturnFormatFieldSetting = DisplayFormatFieldSetting.extend({
+ name: 'time_picker',
+ name: 'return_format'
+ });
+
+ acf.registerFieldSetting( TimePickerDisplayFormatFieldSetting );
+ acf.registerFieldSetting( TimePickerReturnFormatFieldSetting );
+
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * ConditionalLogicFieldSetting
+ *
+ * description
+ *
+ * @date 3/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var ConditionalLogicFieldSetting = 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: false,
+
+ scope: function( $rule ){
+ this.$rule = $rule;
+ return this;
+ },
+
+ ruleData: function( name, value ){
+ return this.$rule.data.apply( this.$rule, arguments );
+ },
+
+ $input: function( name ){
+ return this.$rule.find('.condition-rule-' + name);
+ },
+
+ $td: function( name ){
+ return this.$rule.find('td.' + name);
+ },
+
+ $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 $div = this.$control();
+ $div.show();
+ acf.enable( $div );
+ },
+
+ close: function(){
+ var $div = this.$control();
+ $div.hide();
+ acf.disable( $div );
+ },
+
+ render: function(){
+
+ // show
+ if( this.$toggle().prop('checked') ) {
+ this.renderRules();
+ this.open();
+
+ // hide
+ } else {
+ this.close();
+ }
+ },
+
+ renderRules: function(){
+
+ // vars
+ var self = this;
+
+ // loop
+ this.$rules().each(function(){
+ self.renderRule( $(this) );
+ });
+ },
+
+ renderRule: function( $rule ){
+ this.scope( $rule );
+ this.renderField();
+ this.renderOperator();
+ this.renderValue();
+ },
+
+ renderField: function(){
+
+ // vars
+ var choices = [];
+ var validFieldTypes = [];
+ var cid = this.fieldObject.cid;
+ var $select = this.$input('field');
+
+ // loop
+ acf.getFieldObjects().map(function( fieldObject ){
+
+ // vars
+ var choice = {
+ id: fieldObject.getKey(),
+ text: fieldObject.getLabel()
+ };
+
+ // bail early if is self
+ if( fieldObject.cid === cid ) {
+ choice.text += acf.__('(this field)');
+ choice.disabled = true;
+ }
+
+ // get selected field conditions
+ var conditionTypes = acf.getConditionTypes({
+ fieldType: fieldObject.getType()
+ });
+
+ // bail early if no types
+ if( !conditionTypes.length ) {
+ choice.disabled = true;
+ }
+
+ // calulate indents
+ var indents = fieldObject.getParents().length;
+ choice.text = '- '.repeat(indents) + choice.text;
+
+ // append
+ choices.push(choice);
+ });
+
+ // allow for scenario where only one field exists
+ if( !choices.length ) {
+ choices.push({
+ id: '',
+ text: acf.__('No toggle fields available'),
+ });
+ }
+
+ // render
+ acf.renderSelect( $select, choices );
+
+ // set
+ this.ruleData('field', $select.val());
+ },
+
+ renderOperator: function(){
+
+ // bail early if no field selected
+ if( !this.ruleData('field') ) {
+ return;
+ }
+
+ // vars
+ var $select = this.$input('operator');
+ var val = $select.val();
+ var choices = [];
+
+ // set saved value on first render
+ // - this allows the 2nd render to correctly select an option
+ if( $select.val() === null ) {
+ acf.renderSelect($select, [{
+ id: this.ruleData('operator'),
+ text: ''
+ }]);
+ }
+
+ // get selected field
+ var $field = acf.findFieldObject( this.ruleData('field') );
+ var field = acf.getFieldObject( $field );
+
+ // get selected field conditions
+ var conditionTypes = acf.getConditionTypes({
+ fieldType: field.getType()
+ });
+
+ // html
+ conditionTypes.map(function( model ){
+ choices.push({
+ id: model.prototype.operator,
+ text: acf.strEscape(model.prototype.label)
+ });
+ });
+
+ // render
+ acf.renderSelect( $select, choices );
+
+ // set
+ this.ruleData('operator', $select.val());
+ },
+
+ renderValue: function(){
+
+ // bail early if no field selected
+ if( !this.ruleData('field') || !this.ruleData('operator') ) {
+ return;
+ }
+
+ // vars
+ var $select = this.$input('value');
+ var $td = this.$td('value');
+ var val = $select.val();
+
+ // get selected field
+ var $field = acf.findFieldObject( this.ruleData('field') );
+ var field = acf.getFieldObject( $field );
+
+ // get selected field conditions
+ var conditionTypes = acf.getConditionTypes({
+ fieldType: field.getType(),
+ operator: this.ruleData('operator')
+ });
+
+ // html
+ var conditionType = conditionTypes[0].prototype;
+ var choices = conditionType.choices( field );
+
+ // create html: array
+ if( choices instanceof Array ) {
+ var $newSelect = $(' ');
+ acf.renderSelect( $newSelect, choices );
+
+ // create html: string ( )
+ } else {
+ var $newSelect = $(choices);
+ }
+
+ // append
+ $select.detach();
+ $td.html( $newSelect );
+
+ // copy attrs
+ // timeout needed to avoid browser bug where "disabled" attribute is not applied
+ setTimeout(function(){
+ ['class', 'name', 'id'].map(function( attr ){
+ $newSelect.attr( attr, $select.attr(attr));
+ });
+ }, 0);
+
+ // select existing value (if not a disabled input)
+ if( !$newSelect.prop('disabled') ) {
+ acf.val( $newSelect, val, true );
+ }
+
+ // set
+ this.ruleData('value', $newSelect.val());
+ },
+
+ onChangeToggle: function(){
+ this.render();
+ },
+
+ onClickAddGroup: function( e, $el ){
+ this.addGroup();
+ },
+
+ addGroup: function(){
+
+ // vars
+ var $group = this.$('.rule-group:last');
+
+ // duplicate
+ var $group2 = acf.duplicate( $group );
+
+ // update h4
+ $group2.find('h4').text( acf.__('or') );
+
+ // remove all tr's except the first one
+ $group2.find('tr').not(':first').remove();
+
+ // save field
+ this.fieldObject.save();
+ },
+
+ onFocusField: function( e, $el ){
+ this.renderField();
+ },
+
+ onChangeField: function( e, $el ){
+
+ // scope
+ this.scope( $el.closest('.rule') );
+
+ // set data
+ this.ruleData('field', $el.val());
+
+ // render
+ this.renderOperator();
+ this.renderValue();
+ },
+
+ onChangeOperator: function( e, $el ){
+
+ // scope
+ this.scope( $el.closest('.rule') );
+
+ // set data
+ this.ruleData('operator', $el.val());
+
+ // render
+ this.renderValue();
+ },
+
+ onClickAdd: function( e, $el ){
+
+ // duplciate
+ var $rule = acf.duplicate( $el.closest('.rule') );
+
+ // render
+ this.renderRule( $rule );
+ },
+
+ onClickRemove: function( e, $el ){
+
+ // vars
+ var $rule = $el.closest('.rule');
+
+ // save field
+ this.fieldObject.save();
+
+ // remove group
+ if( $rule.siblings('.rule').length == 0 ) {
+ $rule.closest('.rule-group').remove();
+ }
+
+ // remove
+ $rule.remove();
+ }
+ });
+
+ acf.registerFieldSetting( ConditionalLogicFieldSetting );
+
+
+ /**
+ * conditionalLogicHelper
+ *
+ * description
+ *
+ * @date 20/4/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var conditionalLogicHelper = new acf.Model({
+ actions: {
+ 'duplicate_field_objects': 'onDuplicateFieldObjects',
+ },
+
+ onDuplicateFieldObjects: function( children, newField, prevField ){
+
+ // vars
+ var data = {};
+ var $selects = $();
+
+ // reference change in key
+ children.map(function( child ){
+
+ // store reference of changed key
+ data[ child.get('prevKey') ] = child.get('key');
+
+ // append condition select
+ $selects = $selects.add( child.$('.condition-rule-field') );
+ });
+
+ // loop
+ $selects.each(function(){
+
+ // vars
+ var $select = $(this);
+ var val = $select.val();
+
+ // bail early if val is not a ref key
+ if( !val || !data[val] ) {
+ return;
+ }
+
+ // modify selected option
+ $select.find('option:selected').attr('value', data[val]);
+
+ // set new val
+ $select.val( data[val] );
+
+ });
+ },
+ });
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * acf.findFieldObject
+ *
+ * Returns a single fieldObject $el for a given field key
+ *
+ * @date 1/2/18
+ * @since 5.7.0
+ *
+ * @param string key The field key
+ * @return jQuery
+ */
+
+ acf.findFieldObject = function( key ){
+ return acf.findFieldObjects({
+ key: key,
+ limit: 1
+ });
+ };
+
+ /**
+ * acf.findFieldObjects
+ *
+ * Returns an array of fieldObject $el for the given args
+ *
+ * @date 1/2/18
+ * @since 5.7.0
+ *
+ * @param object args
+ * @return jQuery
+ */
+
+ acf.findFieldObjects = function( args ){
+
+ // vars
+ args = args || {};
+ var selector = '.acf-field-object';
+ var $fields = false;
+
+ // args
+ args = acf.parseArgs(args, {
+ id: '',
+ key: '',
+ type: '',
+ limit: false,
+ list: null,
+ parent: false,
+ sibling: false,
+ child: false,
+ });
+
+ // id
+ if( args.id ) {
+ selector += '[data-id="' + args.id + '"]';
+ }
+
+ // key
+ if( args.key ) {
+ selector += '[data-key="' + args.key + '"]';
+ }
+
+ // type
+ if( args.type ) {
+ selector += '[data-type="' + args.type + '"]';
+ }
+
+ // query
+ if( args.list ) {
+ $fields = args.list.children( selector );
+ } else if( args.parent ) {
+ $fields = args.parent.find( selector );
+ } else if( args.sibling ) {
+ $fields = args.sibling.siblings( selector );
+ } else if( args.child ) {
+ $fields = args.child.parents( selector );
+ } else {
+ $fields = $( selector );
+ }
+
+ // limit
+ if( args.limit ) {
+ $fields = $fields.slice( 0, args.limit );
+ }
+
+ // return
+ return $fields;
+ };
+
+ /**
+ * acf.getFieldObject
+ *
+ * Returns a single fieldObject instance for a given $el|key
+ *
+ * @date 1/2/18
+ * @since 5.7.0
+ *
+ * @param string|jQuery $field The field $el or key
+ * @return jQuery
+ */
+
+ acf.getFieldObject = function( $field ){
+
+ // allow key
+ if( typeof $field === 'string' ) {
+ $field = acf.findFieldObject( $field );
+ }
+
+ // instantiate
+ var field = $field.data('acf');
+ if( !field ) {
+ field = acf.newFieldObject( $field );
+ }
+
+ // return
+ return field;
+ };
+
+ /**
+ * acf.getFieldObjects
+ *
+ * Returns an array of fieldObject instances for the given args
+ *
+ * @date 1/2/18
+ * @since 5.7.0
+ *
+ * @param object args
+ * @return array
+ */
+
+ acf.getFieldObjects = function( args ){
+
+ // query
+ var $fields = acf.findFieldObjects( args );
+
+ // loop
+ var fields = [];
+ $fields.each(function(){
+ var field = acf.getFieldObject( $(this) );
+ fields.push( field );
+ });
+
+ // return
+ return fields;
+ };
+
+ /**
+ * acf.newFieldObject
+ *
+ * Initializes and returns a new FieldObject instance
+ *
+ * @date 1/2/18
+ * @since 5.7.0
+ *
+ * @param jQuery $field The field $el
+ * @return object
+ */
+
+ acf.newFieldObject = function( $field ){
+
+ // instantiate
+ var field = new acf.FieldObject( $field );
+
+ // action
+ acf.doAction('new_field_object', field);
+
+ // return
+ return field;
+ };
+
+ /**
+ * actionManager
+ *
+ * description
+ *
+ * @date 15/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var eventManager = new acf.Model({
+
+ priority: 5,
+
+ initialize: function(){
+
+ // actions
+ var actions = [
+ 'prepare',
+ 'ready',
+ 'append',
+ 'remove'
+ ];
+
+ // loop
+ actions.map(function( action ){
+ this.addFieldActions( action );
+ }, this);
+ },
+
+ addFieldActions: function( action ){
+
+ // vars
+ var pluralAction = action + '_field_objects'; // ready_field_objects
+ var singleAction = action + '_field_object'; // ready_field_object
+ var singleEvent = action + 'FieldObject'; // readyFieldObject
+
+ // global action
+ var callback = function( $el /*, arg1, arg2, etc*/ ){
+
+ // vars
+ var fieldObjects = acf.getFieldObjects({ parent: $el });
+
+ // call plural
+ if( fieldObjects.length ) {
+
+ /// get args [$el, arg1]
+ var args = acf.arrayArgs( arguments );
+
+ // modify args [pluralAction, fields, arg1]
+ args.splice(0, 1, pluralAction, fieldObjects);
+ acf.doAction.apply(null, args);
+ }
+ };
+
+ // plural action
+ var pluralCallback = function( fieldObjects /*, arg1, arg2, etc*/ ){
+
+ /// get args [fields, arg1]
+ var args = acf.arrayArgs( arguments );
+
+ // modify args [singleAction, fields, arg1]
+ args.unshift(singleAction);
+
+ // loop
+ fieldObjects.map(function( fieldObject ){
+
+ // modify args [singleAction, field, arg1]
+ args[1] = fieldObject;
+ acf.doAction.apply(null, args);
+ });
+ };
+
+ // single action
+ var singleCallback = function( fieldObject /*, arg1, arg2, etc*/ ){
+
+ /// get args [$field, arg1]
+ var args = acf.arrayArgs( arguments );
+
+ // modify args [singleAction, $field, arg1]
+ args.unshift(singleAction);
+
+ // action variations (ready_field/type=image)
+ var variations = ['type', 'name', 'key'];
+ variations.map(function( variation ){
+ args[0] = singleAction + '/' + variation + '=' + fieldObject.get(variation);
+ acf.doAction.apply(null, args);
+ });
+
+ // modify args [arg1]
+ args.splice(0, 2);
+
+ // event
+ fieldObject.trigger(singleEvent, args);
+ };
+
+ // add actions
+ acf.addAction(action, callback, 5);
+ acf.addAction(pluralAction, pluralCallback, 5);
+ acf.addAction(singleAction, singleCallback, 5);
+
+ }
+ });
+
+ /**
+ * fieldManager
+ *
+ * description
+ *
+ * @date 4/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var fieldManager = 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, $el ){
+
+ // vars
+ var fields = acf.getFieldObjects();
+
+ // loop
+ fields.map(function( field ){
+ field.submit();
+ });
+ },
+
+ setFieldMenuOrder: function( field ){
+ this.renderFields( field.$el.parent() );
+ },
+
+ onHoverSortable: function( e, $el ){
+
+ // bail early if already sortable
+ if( $el.hasClass('ui-sortable') ) return;
+
+ // sortable
+ $el.sortable({
+ handle: '.acf-sortable-handle',
+ connectWith: '.acf-field-list',
+ start: function(e, ui){
+ var field = acf.getFieldObject( ui.item );
+ ui.placeholder.height( ui.item.height() );
+ acf.doAction('sortstart_field_object', field, $el);
+ },
+ update: function( e, ui ){
+ var field = acf.getFieldObject( ui.item );
+ acf.doAction('sortstop_field_object', field, $el);
+ }
+ });
+ },
+
+ onRemovedField: function( field, $list ){
+ this.renderFields( $list );
+ },
+
+ onReorderField: function( field, $list ){
+ field.updateParent();
+ this.renderFields( $list );
+ },
+
+ onDeleteField: function( field ){
+
+ // delete children
+ field.getFields().map(function( child ){
+ child.delete({ animate: false });
+ });
+ },
+
+ onChangeFieldType: function( field ){
+ // this caused sub fields to disapear if changing type back...
+ //this.onDeleteField( field );
+ },
+
+ onDuplicateField: function( field, newField ){
+
+ // check for children
+ var children = newField.getFields();
+ if( children.length ) {
+
+ // loop
+ children.map(function( child ){
+
+ // wipe field
+ child.wipe();
+
+ // update parent
+ child.updateParent();
+ });
+
+ // action
+ acf.doAction('duplicate_field_objects', children, newField, field);
+ }
+
+ // set menu order
+ this.setFieldMenuOrder( newField );
+ },
+
+ renderFields: function( $list ){
+
+ // vars
+ var fields = acf.getFieldObjects({
+ list: $list
+ });
+
+ // no fields
+ if( !fields.length ) {
+ $list.addClass('-empty');
+ return;
+ }
+
+ // has fields
+ $list.removeClass('-empty');
+
+ // prop
+ fields.map(function( field, i ){
+ field.prop('menu_order', i);
+ });
+ },
+
+ onClickAdd: function( e, $el ){
+ var $list = $el.closest('.acf-tfoot').siblings('.acf-field-list');
+ this.addField( $list );
+ },
+
+ addField: function( $list ){
+
+ // vars
+ var html = $('#tmpl-acf-field').html();
+ var $el = $(html);
+ var prevId = $el.data('id');
+ var newKey = acf.uniqid('field_');
+
+ // duplicate
+ var $newField = acf.duplicate({
+ target: $el,
+ search: prevId,
+ replace: newKey,
+ append: function( $el, $el2 ){
+ $list.append( $el2 );
+ }
+ });
+
+ // get instance
+ var newField = acf.getFieldObject( $newField );
+
+ // props
+ newField.prop('key', newKey);
+ newField.prop('ID', 0);
+ newField.prop('label', '');
+ newField.prop('name', '');
+
+ // attr
+ $newField.attr('data-key', newKey);
+ $newField.attr('data-id', newKey);
+
+ // update parent prop
+ newField.updateParent();
+
+ // focus label
+ var $label = newField.$input('label');
+ setTimeout(function(){
+ $label.focus();
+ }, 251);
+
+ // open
+ newField.open();
+
+ // set menu order
+ this.renderFields( $list );
+
+ // action
+ acf.doAction('add_field_object', newField);
+ acf.doAction('append_field_object', newField);
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * locationManager
+ *
+ * Field group location rules functionality
+ *
+ * @date 15/12/17
+ * @since 5.7.0
+ *
+ * @param void
+ * @return void
+ */
+
+ var locationManager = 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, $el ){
+ this.addRule( $el.closest('tr') );
+ },
+
+ onClickRemoveRule: function( e, $el ){
+ this.removeRule( $el.closest('tr') );
+ },
+
+ onChangeRemoveRule: function( e, $el ){
+ this.changeRule( $el.closest('tr') );
+ },
+
+ onClickAddGroup: function( e, $el ){
+ this.addGroup();
+ },
+
+ addRule: function( $tr ){
+ acf.duplicate( $tr );
+ },
+
+ removeRule: function( $tr ){
+ if( $tr.siblings('tr').length == 0 ) {
+ $tr.closest('.rule-group').remove();
+ } else {
+ $tr.remove();
+ }
+ },
+
+ changeRule: function( $rule ){
+
+ // vars
+ var $group = $rule.closest('.rule-group');
+ var prefix = $rule.find('td.param select').attr('name').replace('[param]', '');
+
+ // ajaxdata
+ var ajaxdata = {};
+ ajaxdata.action = 'acf/field_group/render_location_rule';
+ ajaxdata.rule = acf.serialize( $rule, prefix );
+ ajaxdata.rule.id = $rule.data('id');
+ ajaxdata.rule.group = $group.data('id');
+
+ // temp disable
+ acf.disable( $rule.find('td.value') );
+
+ // ajax
+ $.ajax({
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax(ajaxdata),
+ type: 'post',
+ dataType: 'html',
+ success: function( html ){
+ if( !html ) return;
+ $rule.replaceWith( html );
+ }
+ });
+ },
+
+ addGroup: function(){
+
+ // vars
+ var $group = this.$('.rule-group:last');
+
+ // duplicate
+ $group2 = acf.duplicate( $group );
+
+ // update h4
+ $group2.find('h4').text( acf.__('or') );
+
+ // remove all tr's except the first one
+ $group2.find('tr').not(':first').remove();
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ var _acf = acf.getCompatibility( acf );
+
+ /**
+ * fieldGroupCompatibility
+ *
+ * Compatibility layer for extinct acf.field_group
+ *
+ * @date 15/12/17
+ * @since 5.7.0
+ *
+ * @param void
+ * @return void
+ */
+
+ _acf.field_group = {
+
+ save_field: function( $field, type ){
+ type = (type !== undefined) ? type : 'settings';
+ acf.getFieldObject( $field ).save( type );
+ },
+
+ delete_field: function( $field, animate ){
+ animate = (animate !== undefined) ? animate : true;
+ acf.getFieldObject( $field ).delete({
+ animate: animate
+ });
+ },
+
+ update_field_meta: function( $field, name, value ){
+ acf.getFieldObject( $field ).prop( name, value );
+ },
+
+ delete_field_meta: function( $field, name ){
+ acf.getFieldObject( $field ).prop( name, null );
+ }
+ };
+
+ /**
+ * fieldGroupCompatibility.field_object
+ *
+ * Compatibility layer for extinct acf.field_group.field_object
+ *
+ * @date 15/12/17
+ * @since 5.7.0
+ *
+ * @param void
+ * @return void
+ */
+
+ _acf.field_group.field_object = acf.model.extend({
// vars
type: '',
@@ -2342,830 +2424,79 @@
* @return n/a
*/
- acf.field_group.field_objects = acf.model.extend({
+ var actionManager = new acf.Model({
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'
+ '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'
},
- _save_field: function( $el ){
-
- acf.do_action('save_field/type=' + $el.data('type'), $el);
+ onOpenFieldObject: function( field ){
+ acf.doAction('open_field', field.$el);
+ acf.doAction('open_field/type=' + field.get('type'), field.$el);
+ acf.doAction('render_field_settings', field.$el);
+ acf.doAction('render_field_settings/type=' + field.get('type'), field.$el);
},
- _open_field: function( $el ){
-
- acf.do_action('open_field/type=' + $el.data('type'), $el);
- acf.do_action('render_field_settings', $el);
-
+ onCloseFieldObject: function( field ){
+ acf.doAction('close_field', field.$el);
+ acf.doAction('close_field/type=' + field.get('type'), field.$el);
},
- _close_field: function( $el ){
-
- acf.do_action('close_field/type=' + $el.data('type'), $el);
-
+ onAddFieldObject: function( field ){
+ acf.doAction('add_field', field.$el);
+ acf.doAction('add_field/type=' + field.get('type'), field.$el);
},
- _wipe_field: function( $el ){
-
- acf.do_action('wipe_field/type=' + $el.data('type'), $el);
-
+ onDuplicateFieldObject: function( field ){
+ acf.doAction('duplicate_field', field.$el);
+ acf.doAction('duplicate_field/type=' + field.get('type'), field.$el);
},
- _add_field: function( $el ){
-
- acf.do_action('add_field/type=' + $el.data('type'), $el);
-
+ onDeleteFieldObject: function( field ){
+ acf.doAction('delete_field', field.$el);
+ acf.doAction('delete_field/type=' + field.get('type'), field.$el);
},
- _duplicate_field: function( $el ){
-
- acf.do_action('duplicate_field/type=' + $el.data('type'), $el);
+ onChangeFieldObjectType: function( field ){
+ acf.doAction('change_field_type', field.$el);
+ acf.doAction('change_field_type/type=' + field.get('type'), field.$el);
+ acf.doAction('render_field_settings', field.$el);
+ acf.doAction('render_field_settings/type=' + field.get('type'), field.$el);
},
- _delete_field: function( $el ){
-
- acf.do_action('delete_field/type=' + $el.data('type'), $el);
-
+ onChangeFieldObjectLabel: function( field ){
+ acf.doAction('change_field_label', field.$el);
+ acf.doAction('change_field_label/type=' + field.get('type'), field.$el);
},
- _change_field_type: function( $el ){
-
- acf.do_action('change_field_type/type=' + $el.data('type'), $el);
- acf.do_action('render_field_settings', $el);
+ onChangeFieldObjectName: function( field ){
+ acf.doAction('change_field_name', field.$el);
+ acf.doAction('change_field_name/type=' + field.get('type'), field.$el);
},
- _change_field_label: function( $el ){
-
- acf.do_action('change_field_label/type=' + $el.data('type'), $el);
-
- },
-
- _change_field_name: function( $el ){
-
- acf.do_action('change_field_name/type=' + $el.data('type'), $el);
-
- },
-
- _render_field_settings: function( $el ){
-
- acf.do_action('render_field_settings/type=' + $el.data('type'), $el);
-
+ onChangeFieldObjectParent: function( field ){
+ acf.doAction('update_field_parent', field.$el);
}
-
- });
-
-
-
- /*
- * Append
- *
- * This model handles all logic to append fields together
- *
- * @type function
- * @date 12/02/2015
- * @since 5.5.0
- *
- * @param n/a
- * @return n/a
- */
-
- acf.field_group.append = acf.model.extend({
-
- actions: {
- 'render_field_settings' : '_render_field_settings'
- },
-
- render: function( $el ){
-
- // vars
- var append = $el.data('append');
-
-
- // find sibling
- $sibling = $el.siblings('[data-name="' + append + '"]');
-
-
- // bail early if no sibling
- if( !$sibling.exists() ) return;
-
-
- // vars
- var $wrap = $sibling.children('.acf-input'),
- $ul = $wrap.children('.acf-hl');
-
-
- // append ul if doesn't exist
- if( !$ul.exists() ) {
-
- $wrap.wrapInner('');
-
- $ul = $wrap.children('.acf-hl');
-
- }
-
-
- // create $li
- var $li = $(' ').append( $el.children('.acf-input').children() );
-
-
- // append $li
- $ul.append( $li );
-
-
- // update cols
- $ul.attr('data-cols', $ul.children().length );
-
-
- // remove
- $el.remove();
-
- },
-
- _render_field_settings: function( $el ){
-
- // reference
- var self = this;
-
-
- // loop
- $el.find('.acf-field[data-append]').each(function(){
-
- self.render( $(this) );
-
- });
-
- }
-
- });
-
-
-
- /*
- * Select
- *
- * This field type requires some extra logic for its settings
- *
- * @type function
- * @date 24/10/13
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_settings_select = acf.field_group.field_object.extend({
-
- type: 'select',
-
- actions: {
- 'render_settings': 'render'
- },
-
- events: {
- 'change .acf-field-setting-ui input': 'render'
- },
-
- render: function( $el ){
-
- // ui checked
- if( this.setting('ui input[type="checkbox"]').prop('checked') ) {
-
- this.setting('ajax').show();
-
- // ui not checked
- } else {
-
- this.setting('ajax').hide();
- this.setting('ajax input[type="checkbox"]').prop('checked', false).trigger('change');
-
- }
-
- }
-
- });
-
-
- /*
- * Radio
- *
- * This field type requires some extra logic for its settings
- *
- * @type function
- * @date 24/10/13
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_settings_radio = acf.field_group.field_object.extend({
-
- type: 'radio',
-
- actions: {
- 'render_settings': 'render'
- },
-
- events: {
- 'change .acf-field-setting-other_choice input': 'render'
- },
-
- render: function( $el ){
-
- // other_choice checked
- if( this.setting('other_choice input[type="checkbox"]').prop('checked') ) {
-
- this.setting('save_other_choice').show();
-
- // other_choice not checked
- } else {
-
- this.setting('save_other_choice').hide();
- this.setting('save_other_choice input[type="checkbox"]').prop('checked', false).trigger('change');
-
- }
-
- }
-
- });
-
-
- /*
- * Radio
- *
- * This field type requires some extra logic for its settings
- *
- * @type function
- * @date 24/10/13
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_settings_checkbox = acf.field_group.field_object.extend({
-
- type: 'checkbox',
-
- actions: {
- 'render_settings': 'render'
- },
-
- events: {
- 'change .acf-field-setting-allow_custom input': 'render'
- },
-
- render: function( $el ){
-
- // other_choice checked
- if( this.setting('allow_custom input[type="checkbox"]').prop('checked') ) {
-
- this.setting('save_custom').show();
-
- // other_choice not checked
- } else {
-
- this.setting('save_custom').hide();
- this.setting('save_custom input[type="checkbox"]').prop('checked', false).trigger('change');
-
- }
-
- }
-
- });
-
-
- /*
- * True false
- *
- * This field type requires some extra logic for its settings
- *
- * @type function
- * @date 24/10/13
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_settings_true_false = acf.field_group.field_object.extend({
-
- type: 'true_false',
-
- actions: {
- 'render_settings': 'render'
- },
-
- events: {
- 'change .acf-field-setting-ui input': 'render'
- },
-
- render: function( $el ){
-
- // ui checked
- if( this.setting('ui input[type="checkbox"]').prop('checked') ) {
-
- this.setting('ui_on_text').show();
- this.setting('ui_off_text').show();
-
- // ui not checked
- } else {
-
- this.setting('ui_on_text').hide();
- this.setting('ui_off_text').hide();
-
- }
-
- }
-
- });
-
-
- /*
- * Date Picker
- *
- * This field type requires some extra logic for its settings
- *
- * @type function
- * @date 24/10/13
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_settings_date_picker = 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( $el ){
-
- this.render_list( this.setting('display_format') );
- this.render_list( this.setting('return_format') );
-
- },
-
- render_list: function( $setting ){
-
- // vars
- var $ul = $setting.find('ul'),
- $radio = $ul.find('input[type="radio"]:checked'),
- $other = $ul.find('input[type="text"]');
-
-
- // display val
- if( $radio.val() != 'other' ) {
-
- $other.val( $radio.val() );
-
- }
-
- }
-
- });
-
-
- /*
- * Date Time Picker
- *
- * This field type requires some extra logic for its settings
- *
- * @type function
- * @date 24/10/13
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_settings_date_time_picker = acf_settings_date_picker.extend({
-
- type: 'date_time_picker'
-
- });
-
-
- /*
- * Time Picker
- *
- * This field type requires some extra logic for its settings
- *
- * @type function
- * @date 24/10/13
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_settings_date_time_picker = acf_settings_date_picker.extend({
-
- type: 'time_picker'
-
- });
-
-
- /*
- * tab
- *
- * description
- *
- * @type function
- * @date 12/02/2015
- * @since 5.1.5
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- var acf_settings_tab = acf.field_group.field_object.extend({
-
- type: 'tab',
-
- actions: {
- 'render_settings': 'render'
- },
-
- render: function( $el ){
-
- // clear name
- this.setting('name input').val('').trigger('change');
-
-
- // clear required
- this.setting('required input[type="checkbox"]').prop('checked', false).trigger('change');
-
- }
-
- });
-
-
- /*
- * message
- *
- * description
- *
- * @type function
- * @date 12/02/2015
- * @since 5.1.5
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- var acf_settings_message = acf_settings_tab.extend({
-
- type: 'message'
-
- });
-
-
- /*
- * screen
- *
- * description
- *
- * @type function
- * @date 23/07/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- acf.field_group.screen = acf.model.extend({
-
- actions: {
- 'ready': 'ready'
- },
-
- events: {
- 'click #acf-field-key-hide': 'toggle'
- },
-
- ready: function(){
-
- // vars
- var $el = $('#adv-settings'),
- $append = $el.find('#acf-append-show-on-screen');
-
-
- // append
- $el.find('.metabox-prefs').append( $append.html() );
-
-
- // move br
- $el.find('.metabox-prefs br').remove();
-
-
- // remove
- $append.remove();
-
-
- // render
- this.render();
-
- },
-
- toggle: function( e ){
-
- // vars
- var val = e.$el.prop('checked') ? 1 : 0;
-
-
- // update user setting
- acf.update_user_setting('show_field_keys', val);
-
-
- // render $fields
- this.render();
-
- },
-
- render: function(){
-
- // vars
- var options = acf.serialize( $('#adv-settings') );
-
-
- // toggle class
- var $fields = acf.field_group.$fields;
-
-
- // show field keys
- if( options.show_field_keys ) {
-
- $fields.addClass('show-field-keys');
-
- } else {
-
- $fields.removeClass('show-field-keys');
-
- }
-
- }
-
- });
-
-
- /*
- * sub fields
- *
- * description
- *
- * @type function
- * @date 31/1/17
- * @since 5.5.6
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- 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
- *
- * This function will update sub field conditional logic rules after duplication
- *
- * @type function
- * @date 10/06/2014
- * @since 5.0.0
- *
- * @param $fields (jquery selection)
- * @return n/a
- */
-
- fix_conditional_logic : function( $fields ){
-
- // build refernce
- var ref = {};
-
- $fields.each(function(){
-
- ref[ $(this).attr('data-orig') ] = $(this).attr('data-key');
-
- });
-
-
- $fields.find('.conditional-rule-param').each(function(){
-
- // vars
- var key = $(this).val();
-
-
- // bail early if val is not a ref key
- if( !(key in ref) ) {
-
- return;
-
- }
-
-
- // add option if doesn't yet exist
- if( ! $(this).find('option[value="' + ref[key] + '"]').exists() ) {
-
- $(this).append('' + ref[key] + ' ');
-
- }
-
-
- // set new val
- $(this).val( ref[key] );
-
- });
-
- },
-
-
- /*
- * update_field_parent
- *
- * This function will update field meta such as parent
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- update_field_parent: function( $el ){
-
- // bail early if not div.field (flexible content tr)
- if( !$el.hasClass('acf-field-object') ) return;
-
-
- // vars
- var $parent = $el.parent().closest('.acf-field-object'),
- val = acf.get('post_id');
-
-
- // find parent
- if( $parent.exists() ) {
-
- // set as parent ID
- val = acf.field_group.get_field_meta( $parent, 'ID' );
-
-
- // if parent is new, no ID exists
- if( !val ) {
-
- val = acf.field_group.get_field_meta( $parent, 'key' );
-
- }
-
- }
-
-
- // update parent
- acf.field_group.update_field_meta( $el, 'parent', val );
-
-
- // action for 3rd party customization
- acf.do_action('update_field_parent', $el, $parent);
-
- },
-
-
- /*
- * duplicate_field
- *
- * This function is triggered when duplicating a field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- duplicate_field: function( $el ) {
-
- // vars
- var $fields = $el.find('.acf-field-object');
-
-
- // bail early if $fields are empty
- if( !$fields.exists() ) {
-
- return;
-
- }
-
-
- // loop over sub fields
- $fields.each(function(){
-
- // vars
- var $parent = $(this).parent().closest('.acf-field-object'),
- key = acf.field_group.get_field_meta( $parent, 'key');
-
-
- // wipe field
- acf.field_group.wipe_field( $(this) );
-
-
- // update parent
- acf.field_group.update_field_meta( $(this), 'parent', key );
-
-
- // save field
- acf.field_group.save_field( $(this) );
-
-
- });
-
-
- // fix conditional logic rules
- this.fix_conditional_logic( $fields );
-
- },
-
-
- /*
- * delete_field
- *
- * This function is triggered when deleting a field
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $el
- * @return n/a
- */
-
- delete_field : function( $el ){
-
- $el.find('.acf-field-object').each(function(){
-
- acf.field_group.delete_field( $(this), false );
-
- });
-
- },
-
-
- /*
- * change_field_type
- *
- * This function is triggered when changing a field type
- *
- * @type function
- * @date 7/06/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- change_field_type : function( $el ) {
-
- $el.find('.acf-field-object').each(function(){
-
- acf.field_group.delete_field( $(this), false );
-
- });
-
- }
-
});
})(jQuery);
// @codekit-prepend "../js/field-group.js";
+// @codekit-prepend "../js/field-group-field.js";
+// @codekit-prepend "../js/field-group-settings.js";
+// @codekit-prepend "../js/field-group-conditions.js";
+// @codekit-prepend "../js/field-group-fields.js";
+// @codekit-prepend "../js/field-group-locations.js";
+// @codekit-prepend "../js/field-group-compatibility.js";
diff --git a/assets/js/acf-field-group.min.js b/assets/js/acf-field-group.min.js
index f712a72..e10d1fa 100644
--- a/assets/js/acf-field-group.min.js
+++ b/assets/js/acf-field-group.min.js
@@ -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('* '),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('
'),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=$('
');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(''),a=i.children(".acf-hl"));var n=$(" ").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(''+t[e]+" "),$(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);
\ No newline at end of file
+!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(''),a=n.children("ul"));var c=e.$(".acf-input").html(),l=$(""+c+" ");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=$(" ").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+=' * '),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(){this.save(),acf.doAction("change_field_object",this)},onChanged:function(e,t,i){"save"!=t&&(["menu_order","parent"].indexOf(t)>-1?this.save("meta"):this.save(),["menu_order","label","required","name","type","key"].indexOf(t)>-1&&this.render(),acf.doAction("change_field_object_"+t,this,i))},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=$('
');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=$(" ");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);
\ No newline at end of file
diff --git a/assets/js/acf-input.js b/assets/js/acf-input.js
index 84b2dfe..1861a52 100644
--- a/assets/js/acf-input.js
+++ b/assets/js/acf-input.js
@@ -1,3 +1,2115 @@
+(function($, undefined){
+
+ /**
+ * acf
+ *
+ * description
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ // The global acf object
+ var acf = {};
+
+ // Set as a browser global
+ window.acf = acf;
+
+ /** @var object Data sent from PHP */
+ acf.data = {};
+
+
+ /**
+ * get
+ *
+ * Gets a specific data value
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @return mixed
+ */
+
+ acf.get = function( name ){
+ return this.data[name] || null;
+ };
+
+
+ /**
+ * has
+ *
+ * Returns `true` if the data exists and is not null
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @return boolean
+ */
+
+ acf.has = function( name ){
+ return this.get(data) !== null;
+ };
+
+
+ /**
+ * set
+ *
+ * Sets a specific data value
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param mixed value
+ * @return this
+ */
+
+ acf.set = function( name, value ){
+ this.data[ name ] = value;
+ return this;
+ };
+
+
+ /**
+ * uniqueId
+ *
+ * Returns a unique ID
+ *
+ * @date 9/11/17
+ * @since 5.6.3
+ *
+ * @param string prefix Optional prefix.
+ * @return string
+ */
+
+ var idCounter = 0;
+ acf.uniqueId = function(prefix){
+ var id = ++idCounter + '';
+ return prefix ? prefix + id : id;
+ };
+
+ /**
+ * acf.uniqueArray
+ *
+ * Returns a new array with only unique values
+ * Credit: https://stackoverflow.com/questions/1960473/get-all-unique-values-in-an-array-remove-duplicates
+ *
+ * @date 23/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.uniqueArray = function( array ){
+ function onlyUnique(value, index, self) {
+ return self.indexOf(value) === index;
+ }
+ return array.filter( onlyUnique );
+ };
+
+ /**
+ * uniqid
+ *
+ * Returns a unique ID (PHP version)
+ *
+ * @date 9/11/17
+ * @since 5.6.3
+ * @source http://locutus.io/php/misc/uniqid/
+ *
+ * @param string prefix Optional prefix.
+ * @return string
+ */
+
+ var uniqidSeed = '';
+ acf.uniqid = function(prefix, moreEntropy){
+ // discuss at: http://locutus.io/php/uniqid/
+ // original by: Kevin van Zonneveld (http://kvz.io)
+ // revised by: Kankrelune (http://www.webfaktory.info/)
+ // note 1: Uses an internal counter (in locutus global) to avoid collision
+ // example 1: var $id = uniqid()
+ // example 1: var $result = $id.length === 13
+ // returns 1: true
+ // example 2: var $id = uniqid('foo')
+ // example 2: var $result = $id.length === (13 + 'foo'.length)
+ // returns 2: true
+ // example 3: var $id = uniqid('bar', true)
+ // example 3: var $result = $id.length === (23 + 'bar'.length)
+ // returns 3: true
+ if (typeof prefix === 'undefined') {
+ prefix = '';
+ }
+
+ var retId;
+ var formatSeed = function(seed, reqWidth) {
+ seed = parseInt(seed, 10).toString(16); // to hex str
+ if (reqWidth < seed.length) { // so long we split
+ return seed.slice(seed.length - reqWidth);
+ }
+ if (reqWidth > seed.length) { // so short we pad
+ return Array(1 + (reqWidth - seed.length)).join('0') + seed;
+ }
+ return seed;
+ };
+
+ if (!uniqidSeed) { // init seed with big random int
+ uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
+ }
+ uniqidSeed++;
+
+ retId = prefix; // start with prefix, add current milliseconds hex string
+ retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
+ retId += formatSeed(uniqidSeed, 5); // add seed hex string
+ if (moreEntropy) {
+ // for more entropy we add a float lower to 10
+ retId += (Math.random() * 10).toFixed(8).toString();
+ }
+
+ return retId;
+ };
+
+
+ /**
+ * strReplace
+ *
+ * Performs a string replace
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string search
+ * @param string replace
+ * @param string subject
+ * @return string
+ */
+
+ acf.strReplace = function( search, replace, subject ){
+ return subject.split(search).join(replace);
+ };
+
+
+ /**
+ * strCamelCase
+ *
+ * Converts a string into camelCase
+ * Thanks to https://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string str
+ * @return string
+ */
+
+ acf.strCamelCase = function( str ){
+
+ // replace [_-] characters with space
+ str = str.replace(/[_-]/g, ' ');
+
+ // camelCase
+ str = str.replace(/(?:^\w|\b\w|\s+)/g, function(match, index) {
+ if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
+ return index == 0 ? match.toLowerCase() : match.toUpperCase();
+ });
+
+ // return
+ return str;
+ };
+
+ /**
+ * strPascalCase
+ *
+ * Converts a string into PascalCase
+ * Thanks to https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string str
+ * @return string
+ */
+
+ acf.strPascalCase = function( str ){
+ var camel = acf.strCamelCase( str );
+ return camel.charAt(0).toUpperCase() + camel.slice(1);
+ };
+
+ /**
+ * acf.strSlugify
+ *
+ * Converts a string into a HTML class friendly slug
+ *
+ * @date 21/3/18
+ * @since 5.6.9
+ *
+ * @param string str
+ * @return string
+ */
+
+ acf.strSlugify = function( str ){
+ return acf.strReplace( '_', '-', str.toLowerCase() );
+ };
+
+
+ acf.strSanitize = function( str ){
+
+ // chars (https://jsperf.com/replace-foreign-characters)
+ var map = {
+ "À": "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",
+
+ // extra
+ ' ': '_',
+ '\'': '',
+ '?': '',
+ '/': '',
+ '\\': '',
+ '.': '',
+ ',': '',
+ '`': '',
+ '>': '',
+ '<': '',
+ '"': '',
+ '[': '',
+ ']': '',
+ '|': '',
+ '{': '',
+ '}': '',
+ '(': '',
+ ')': ''
+ };
+
+ // vars
+ var nonWord = /\W/g;
+ var mapping = function (c) {
+ return map[c] || c;
+ };
+
+ // replace
+ str = str.replace(nonWord, mapping);
+
+ // lowercase
+ str = str.toLowerCase();
+
+ // return
+ return str;
+ };
+
+ /**
+ * acf.strMatch
+ *
+ * Returns the number of characters that match between two strings
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.strMatch = function( s1, s2 ){
+
+ // vars
+ var val = 0;
+ var min = Math.min( s1.length, s2.length );
+
+ // loop
+ for( var i = 0; i < min; i++ ) {
+ if( s1[i] !== s2[i] ) {
+ break;
+ }
+ val++;
+ }
+
+ // return
+ return val;
+ };
+
+ /**
+ * acf.decode
+ *
+ * description
+ *
+ * @date 13/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.decode = function( string ){
+ return $('').html( string ).text();
+ };
+
+ /**
+ * acf.strEscape
+ *
+ * description
+ *
+ * @date 3/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.strEscape = function( string ){
+
+ var entityMap = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": ''',
+ '/': '/',
+ '`': '`',
+ '=': '='
+ };
+
+ return String(string).replace(/[&<>"'`=\/]/g, function (s) {
+ return entityMap[s];
+ });
+ };
+
+ /**
+ * parseArgs
+ *
+ * Merges together defaults and args much like the WP wp_parse_args function
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object args
+ * @param object defaults
+ * @return object
+ */
+
+ acf.parseArgs = function( args, defaults ){
+ if( typeof args !== 'object' ) args = {};
+ if( typeof defaults !== 'object' ) defaults = {};
+ return $.extend({}, defaults, args);
+ }
+
+ /**
+ * __
+ *
+ * Retrieve the translation of $text.
+ *
+ * @date 16/4/18
+ * @since 5.6.9
+ *
+ * @param string text Text to translate.
+ * @return string Translated text.
+ */
+
+ if( window.acfL10n == undefined ) {
+ acfL10n = {};
+ }
+
+ acf.__ = function( text ){
+ return acfL10n[ text ] || text;
+ };
+
+ /**
+ * _x
+ *
+ * Retrieve translated string with gettext context.
+ *
+ * @date 16/4/18
+ * @since 5.6.9
+ *
+ * @param string text Text to translate.
+ * @param string context Context information for the translators.
+ * @return string Translated text.
+ */
+
+ acf._x = function( text, context ){
+ return acfL10n[ text + '.' + context ] || acfL10n[ text ] || text;
+ };
+
+ /**
+ * _n
+ *
+ * Retrieve the plural or single form based on the amount.
+ *
+ * @date 16/4/18
+ * @since 5.6.9
+ *
+ * @param string single Single text to translate.
+ * @param string plural Plural text to translate.
+ * @param int number The number to compare against.
+ * @return string Translated text.
+ */
+
+ acf._n = function( single, plural, number ){
+ if( number == 1 ) {
+ return acf.__(single);
+ } else {
+ return acf.__(plural);
+ }
+ };
+
+ acf.isArray = function( a ){
+ return Array.isArray(a);
+ };
+
+ acf.isObject = function( a ){
+ return ( typeof a === 'object' );
+ }
+
+ /**
+ * serialize
+ *
+ * description
+ *
+ * @date 24/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var buildObject = function( obj, name, value ){
+ //console.log('buildObject', obj, name);
+ // replace [] with placeholder
+ name = name.replace('[]', '[%%index%%]');
+
+ // vars
+ var keys = name.match(/([^\[\]])+/g);
+ if( !keys ) return;
+ var length = keys.length;
+ var ref = obj;
+
+ // loop
+ for( var i = 0; i < length; i++ ) {
+
+ // vars
+ var key = String( keys[i] );
+
+ // value
+ if( i == length - 1 ) {
+
+ // %%index%%
+ if( key === '%%index%%' ) {
+ ref.push( value );
+
+ // default
+ } else {
+ ref[ key ] = value;
+ }
+
+ // path
+ } else {
+
+ // array
+ if( keys[i+1] === '%%index%%' ) {
+ if( !acf.isArray(ref[ key ]) ) {
+ ref[ key ] = [];
+ }
+
+ // object
+ } else {
+ if( !acf.isObject(ref[ key ]) ) {
+ ref[ key ] = {};
+ }
+ }
+
+ // crawl
+ ref = ref[ key ];
+ }
+ //console.log('ref:', ref);
+ }
+ };
+
+ acf.serialize = function( $el, prefix ){
+ //console.time('serialize');
+ // vars
+ var obj = {};
+ var inputs = $el.find('select, textarea, input').serializeArray();
+
+ // prefix
+ if( prefix !== undefined ) {
+
+ // filter and modify
+ inputs = inputs.filter(function( item ){
+ return item.name.indexOf(prefix) === 0;
+ }).map(function( item ){
+ item.name = item.name.slice(prefix.length);
+ return item;
+ });
+ }
+
+ // loop
+ for( var i = 0; i < inputs.length; i++ ) {
+ buildObject( obj, inputs[i].name, inputs[i].value );
+ }
+ //console.timeEnd('serialize');
+
+ // return
+ return obj;
+ };
+
+
+ /**
+ * addAction
+ *
+ * Wrapper for acf.hooks.addAction
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+/*
+ var prefixAction = function( action ){
+ return 'acf_' + action;
+ }
+*/
+
+ acf.addAction = function( action, callback, priority, context ){
+ //action = prefixAction(action);
+ acf.hooks.addAction.apply(this, arguments);
+ return this;
+ };
+
+
+ /**
+ * removeAction
+ *
+ * Wrapper for acf.hooks.removeAction
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ acf.removeAction = function( action, callback ){
+ //action = prefixAction(action);
+ acf.hooks.removeAction.apply(this, arguments);
+ return this;
+ };
+
+
+ /**
+ * doAction
+ *
+ * Wrapper for acf.hooks.doAction
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ var actionHistory = {};
+ //var currentAction = false;
+ acf.doAction = function( action ){
+ //action = prefixAction(action);
+ //currentAction = action;
+ actionHistory[ action ] = 1;
+ acf.hooks.doAction.apply(this, arguments);
+ actionHistory[ action ] = 0;
+ return this;
+ };
+
+
+ /**
+ * doingAction
+ *
+ * Return true if doing action
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ acf.doingAction = function( action ){
+ //action = prefixAction(action);
+ return (actionHistory[ action ] === 1);
+ };
+
+
+ /**
+ * didAction
+ *
+ * Wrapper for acf.hooks.doAction
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ acf.didAction = function( action ){
+ //action = prefixAction(action);
+ return (actionHistory[ action ] !== undefined);
+ };
+
+ /**
+ * currentAction
+ *
+ * Wrapper for acf.hooks.doAction
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ acf.currentAction = function(){
+ for( var k in actionHistory ) {
+ if( actionHistory[k] ) {
+ return k;
+ }
+ }
+ return false;
+ };
+
+ /**
+ * addFilter
+ *
+ * Wrapper for acf.hooks.addFilter
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ acf.addFilter = function( action ){
+ //action = prefixAction(action);
+ acf.hooks.addFilter.apply(this, arguments);
+ return this;
+ };
+
+
+ /**
+ * removeFilter
+ *
+ * Wrapper for acf.hooks.removeFilter
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ acf.removeFilter = function( action ){
+ //action = prefixAction(action);
+ acf.hooks.removeFilter.apply(this, arguments);
+ return this;
+ };
+
+
+ /**
+ * applyFilters
+ *
+ * Wrapper for acf.hooks.applyFilters
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param n/a
+ * @return this
+ */
+
+ acf.applyFilters = function( action ){
+ //action = prefixAction(action);
+ return acf.hooks.applyFilters.apply(this, arguments);
+ };
+
+
+ /**
+ * getArgs
+ *
+ * description
+ *
+ * @date 15/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.arrayArgs = function( args ){
+ return Array.prototype.slice.call( args );
+ };
+
+
+ /**
+ * extendArgs
+ *
+ * description
+ *
+ * @date 15/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+/*
+ acf.extendArgs = function( ){
+ var args = Array.prototype.slice.call( arguments );
+ var realArgs = args.shift();
+
+ Array.prototype.push.call(arguments, 'bar')
+ return Array.prototype.push.apply( args, arguments );
+ };
+*/
+
+
+ // Preferences
+ var preferences = localStorage.getItem('acf');
+ preferences = preferences ? JSON.parse(preferences) : {};
+
+
+ /**
+ * getPreferenceName
+ *
+ * Gets the true preference name.
+ * Converts "this.thing" to "thing-123" if editing post 123.
+ *
+ * @date 11/11/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @return string
+ */
+
+ var getPreferenceName = function( name ){
+ if( name.substr(0, 5) === 'this.' ) {
+ name = name.substr(5) + '-' + acf.get('post_id');
+ }
+ return name;
+ };
+
+
+ /**
+ * acf.getPreference
+ *
+ * Gets a preference setting or null if not set.
+ *
+ * @date 11/11/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @return mixed
+ */
+
+ acf.getPreference = function( name ){
+ name = getPreferenceName( name );
+ return preferences[ name ] || null;
+ }
+
+
+ /**
+ * acf.setPreference
+ *
+ * Sets a preference setting.
+ *
+ * @date 11/11/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param mixed value
+ * @return n/a
+ */
+
+ acf.setPreference = function( name, value ){
+ name = getPreferenceName( name );
+ if( value === null ) {
+ delete preferences[ name ];
+ } else {
+ preferences[ name ] = value;
+ }
+ localStorage.setItem('acf', JSON.stringify(preferences));
+ }
+
+
+ /**
+ * acf.removePreference
+ *
+ * Removes a preference setting.
+ *
+ * @date 11/11/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @return n/a
+ */
+
+ acf.removePreference = function( name ){
+ acf.setPreference(name, null);
+ };
+
+
+ /**
+ * remove
+ *
+ * Removes an element with fade effect
+ *
+ * @date 1/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.remove = function( props ){
+
+ // allow jQuery
+ if( props instanceof jQuery ) {
+ props = {
+ target: props
+ };
+ }
+
+ // defaults
+ props = acf.parseArgs(props, {
+ target: false,
+ endHeight: 0,
+ complete: function(){}
+ });
+
+ // action
+ acf.doAction('remove', props.target);
+
+ // tr
+ if( props.target.is('tr') ) {
+ removeTr( props );
+
+ // div
+ } else {
+ removeDiv( props );
+ }
+
+ };
+
+ /**
+ * removeDiv
+ *
+ * description
+ *
+ * @date 16/2/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var removeDiv = function( props ){
+
+ // vars
+ var $el = props.target;
+ var height = $el.height();
+ var width = $el.width();
+ var margin = $el.css('margin');
+ var outerHeight = $el.outerHeight(true);
+ var style = $el.attr('style') + ''; // needed to copy
+
+ // wrap
+ $el.wrap('
');
+ var $wrap = $el.parent();
+
+ // set pos
+ $el.css({
+ height: height,
+ width: width,
+ margin: margin,
+ position: 'absolute'
+ });
+
+ // fade wrap
+ setTimeout(function(){
+
+ $wrap.css({
+ opacity: 0,
+ height: props.endHeight
+ });
+
+ }, 50);
+
+ // remove
+ setTimeout(function(){
+
+ $el.attr('style', style);
+ $wrap.remove();
+ props.complete();
+
+ }, 301);
+ };
+
+ /**
+ * removeTr
+ *
+ * description
+ *
+ * @date 16/2/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var removeTr = function( props ){
+
+ // vars
+ var $tr = props.target;
+ var height = $tr.height();
+ var children = $tr.children().length;
+
+ // create dummy td
+ var $td = $(' ');
+
+ // fade away tr
+ $tr.addClass('acf-remove-element');
+
+ // update HTML after fade animation
+ setTimeout(function(){
+ $tr.html( $td );
+ }, 251);
+
+ // allow .acf-temp-remove to exist before changing CSS
+ setTimeout(function(){
+
+ // remove class
+ $tr.removeClass('acf-remove-element');
+
+ // collapse
+ $td.css({
+ height: props.endHeight
+ });
+
+ }, 300);
+
+ // remove
+ setTimeout(function(){
+
+ $tr.remove();
+ props.complete();
+
+ }, 451);
+ };
+
+ /**
+ * duplicate
+ *
+ * description
+ *
+ * @date 3/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.duplicate = function( args ){
+
+ // allow jQuery
+ if( args instanceof jQuery ) {
+ args = {
+ target: args
+ };
+ }
+
+ // vars
+ var timeout = 0;
+
+ // defaults
+ args = acf.parseArgs(args, {
+ target: false,
+ search: '',
+ replace: '',
+ before: function( $el ){},
+ after: function( $el, $el2 ){},
+ append: function( $el, $el2 ){
+ $el.after( $el2 );
+ timeout = 1;
+ }
+ });
+
+ // compatibility
+ args.target = args.target || args.$el;
+
+ // vars
+ var $el = args.target;
+
+ // search
+ args.search = args.search || $el.attr('data-id');
+ args.replace = args.replace || acf.uniqid();
+
+ // before
+ // - allow acf to modify DOM
+ // - fixes bug where select field option is not selected
+ args.before( $el );
+ acf.doAction('before_duplicate', $el);
+
+ // clone
+ var $el2 = $el.clone();
+
+ // rename
+ acf.rename({
+ target: $el2,
+ search: args.search,
+ replace: args.replace,
+ });
+
+ // remove classes
+ $el2.removeClass('acf-clone');
+ $el2.find('.ui-sortable').removeClass('ui-sortable');
+
+ // after
+ // - allow acf to modify DOM
+ args.after( $el, $el2 );
+ acf.doAction('after_duplicate', $el, $el2 );
+
+ // append
+ args.append( $el, $el2 );
+
+ // append
+ // - allow element to be moved into a visible position before fire action
+ //var callback = function(){
+ acf.doAction('append', $el2);
+ //};
+ //if( timeout ) {
+ // setTimeout(callback, timeout);
+ //} else {
+ // callback();
+ //}
+
+ // return
+ return $el2;
+ };
+
+ /**
+ * rename
+ *
+ * description
+ *
+ * @date 7/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.rename = function( args ){
+
+ // allow jQuery
+ if( args instanceof jQuery ) {
+ args = {
+ target: args
+ };
+ }
+
+ // defaults
+ args = acf.parseArgs(args, {
+ target: false,
+ destructive: false,
+ search: '',
+ replace: '',
+ });
+
+ // vars
+ var $el = args.target;
+ var search = args.search || $el.attr('data-id');
+ var replace = args.replace || acf.uniqid('acf');
+ var replaceAttr = function(i, value){
+ return value.replace( search, replace );
+ }
+
+ // replace (destructive)
+ if( args.destructive ) {
+ var html = $el.outerHTML();
+ html = acf.strReplace( search, replace, html );
+ $el.replaceWith( html );
+
+ // replace
+ } else {
+ $el.attr('data-id', replace);
+ $el.find('[id*="' + search + '"]').attr('id', replaceAttr);
+ $el.find('[for*="' + search + '"]').attr('for', replaceAttr);
+ $el.find('[name*="' + search + '"]').attr('name', replaceAttr);
+ }
+
+ // return
+ return $el;
+ };
+
+
+ /**
+ * acf.prepareForAjax
+ *
+ * description
+ *
+ * @date 4/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.prepareForAjax = function( data ){
+
+ // required
+ data.nonce = acf.get('nonce');
+ data.post_id = acf.get('post_id');
+
+ // filter for 3rd party customization
+ data = acf.applyFilters('prepare_for_ajax', data);
+
+ // return
+ return data;
+ };
+
+
+ /**
+ * acf.startButtonLoading
+ *
+ * description
+ *
+ * @date 5/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.startButtonLoading = function( $el ){
+ $el.prop('disabled', true);
+ $el.after(' ');
+ }
+
+ acf.stopButtonLoading = function( $el ){
+ $el.prop('disabled', false);
+ $el.next('.acf-loading').remove();
+ }
+
+
+ /**
+ * acf.showLoading
+ *
+ * description
+ *
+ * @date 12/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.showLoading = function( $el ){
+ $el.append('
');
+ };
+
+ acf.hideLoading = function( $el ){
+ $el.children('.acf-loading-overlay').remove();
+ };
+
+
+ /**
+ * acf.updateUserSetting
+ *
+ * description
+ *
+ * @date 5/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.updateUserSetting = function( name, value ){
+
+ var ajaxData = {
+ action: 'acf/update_user_setting',
+ name: name,
+ value: value
+ };
+
+ $.ajax({
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax(ajaxData),
+ type: 'post',
+ dataType: 'html'
+ });
+
+ };
+
+
+ /**
+ * acf.val
+ *
+ * description
+ *
+ * @date 8/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.val = function( $input, value, silent ){
+
+ // vars
+ var prevValue = $input.val();
+
+ // bail if no change
+ if( value === prevValue ) {
+ return false
+ }
+
+ // bail if select option does not exist
+ if( $input.is('select') && !$input.find('option[value="'+value+'"]').length ) {
+ return false;
+ }
+
+ // update value
+ $input.val( value );
+
+ // update with trigger
+ if( silent !== true ) {
+ $input.trigger('change');
+ }
+
+ // return
+ return true;
+ };
+
+ /**
+ * acf.show
+ *
+ * description
+ *
+ * @date 9/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.show = function( $el, lockKey ){
+
+ // unlock
+ if( lockKey ) {
+ acf.unlock($el, 'hidden', lockKey);
+ }
+
+ // bail early if $el is still locked
+ if( acf.isLocked($el, 'hidden') ) {
+ //console.log( 'still locked', getLocks( $el, 'hidden' ));
+ return false;
+ }
+
+ // $el is hidden, remove class and return true due to change in visibility
+ if( $el.hasClass('acf-hidden') ) {
+ $el.removeClass('acf-hidden');
+ return true;
+
+ // $el is visible, return false due to no change in visibility
+ } else {
+ return false;
+ }
+ };
+
+
+ /**
+ * acf.hide
+ *
+ * description
+ *
+ * @date 9/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.hide = function( $el, lockKey ){
+
+ // lock
+ if( lockKey ) {
+ acf.lock($el, 'hidden', lockKey);
+ }
+
+ // $el is hidden, return false due to no change in visibility
+ if( $el.hasClass('acf-hidden') ) {
+ return false;
+
+ // $el is visible, add class and return true due to change in visibility
+ } else {
+ $el.addClass('acf-hidden');
+ return true;
+ }
+ };
+
+
+ /**
+ * acf.isHidden
+ *
+ * description
+ *
+ * @date 9/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.isHidden = function( $el ){
+ return $el.hasClass('acf-hidden');
+ };
+
+
+ /**
+ * acf.isVisible
+ *
+ * description
+ *
+ * @date 9/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.isVisible = function( $el ){
+ return !acf.isHidden( $el );
+ };
+
+
+ /**
+ * enable
+ *
+ * description
+ *
+ * @date 12/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var enable = function( $el, lockKey ){
+
+ // check class. Allow .acf-disabled to overrule all JS
+ if( $el.hasClass('acf-disabled') ) {
+ return false;
+ }
+
+ // unlock
+ if( lockKey ) {
+ acf.unlock($el, 'disabled', lockKey);
+ }
+
+ // bail early if $el is still locked
+ if( acf.isLocked($el, 'disabled') ) {
+ return false;
+ }
+
+ // $el is disabled, remove prop and return true due to change
+ if( $el.prop('disabled') ) {
+ $el.prop('disabled', false);
+ return true;
+
+ // $el is enabled, return false due to no change
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * acf.enable
+ *
+ * description
+ *
+ * @date 9/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.enable = function( $el, lockKey ){
+
+ // enable single input
+ if( $el.attr('name') ) {
+ return enable( $el, lockKey );
+ }
+
+ // find and enable child inputs
+ // return true if any inputs have changed
+ var results = false;
+ $el.find('[name]').each(function(){
+ var result = enable( $(this), lockKey );
+ if( result ) {
+ results = true;
+ }
+ });
+ return results;
+ };
+
+
+ /**
+ * disable
+ *
+ * description
+ *
+ * @date 12/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var disable = function( $el, lockKey ){
+
+ // lock
+ if( lockKey ) {
+ acf.lock($el, 'disabled', lockKey);
+ }
+
+ // $el is disabled, return false due to no change
+ if( $el.prop('disabled') ) {
+ return false;
+
+ // $el is enabled, add prop and return true due to change
+ } else {
+ $el.prop('disabled', true);
+ return true;
+ }
+ };
+
+
+ /**
+ * acf.disable
+ *
+ * description
+ *
+ * @date 9/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.disable = function( $el, lockKey ){
+
+ // disable single input
+ if( $el.attr('name') ) {
+ return disable( $el, lockKey );
+ }
+
+ // find and enable child inputs
+ // return true if any inputs have changed
+ var results = false;
+ $el.find('[name]').each(function(){
+ var result = disable( $(this), lockKey );
+ if( result ) {
+ results = true;
+ }
+ });
+ return results;
+ };
+
+
+ /**
+ * acf.isset
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.isset = function( obj /*, level1, level2, ... */ ) {
+ for( var i = 1; i < arguments.length; i++ ) {
+ if( !obj.hasOwnProperty(arguments[i]) ) {
+ return false;
+ }
+ obj = obj[ arguments[i] ];
+ }
+ return true;
+ };
+
+ /**
+ * acf.isget
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.isget = function( obj /*, level1, level2, ... */ ) {
+ for( var i = 1; i < arguments.length; i++ ) {
+ if( !obj.hasOwnProperty(arguments[i]) ) {
+ return null;
+ }
+ obj = obj[ arguments[i] ];
+ }
+ return obj;
+ };
+
+ /**
+ * acf.getFileInputData
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getFileInputData = function( $input, callback ){
+
+ // vars
+ var value = $input.val();
+
+ // bail early if no value
+ if( !value ) {
+ return false;
+ }
+
+ // data
+ var data = {
+ url: value
+ };
+
+ // modern browsers
+ var file = acf.isget( $input[0], 'files', 0);
+ if( file ){
+
+ // update data
+ data.size = file.size;
+ data.type = file.type;
+
+ // image
+ if( file.type.indexOf('image') > -1 ) {
+
+ // vars
+ var windowURL = window.URL || window.webkitURL;
+ var img = new Image();
+
+ img.onload = function() {
+
+ // update
+ data.width = this.width;
+ data.height = this.height;
+
+ callback( data );
+ };
+ img.src = windowURL.createObjectURL( file );
+ } else {
+ callback( data );
+ }
+ } else {
+ callback( data );
+ }
+ };
+
+ /**
+ * acf.isAjaxSuccess
+ *
+ * description
+ *
+ * @date 18/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.isAjaxSuccess = function( json ){
+ return ( json && json.success );
+ };
+
+ /**
+ * acf.getAjaxMessage
+ *
+ * description
+ *
+ * @date 18/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getAjaxMessage = function( json ){
+ return acf.isget( json, 'data', 'message' );
+ };
+
+ /**
+ * acf.getAjaxError
+ *
+ * description
+ *
+ * @date 18/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getAjaxError = function( json ){
+ return acf.isget( json, 'data', 'error' );
+ };
+
+
+ /**
+ * acf.renderSelect
+ *
+ * Renders the innter html for a select field.
+ *
+ * @date 19/2/18
+ * @since 5.6.9
+ *
+ * @param jQuery $select The select element.
+ * @param array choices An array of choices.
+ * @return void
+ */
+
+ acf.renderSelect = function( $select, choices ){
+
+ // vars
+ var value = $select.val();
+ var values = [];
+
+ // callback
+ var crawl = function( items ){
+
+ // vars
+ var itemsHtml = '';
+
+ // loop
+ items.map(function( item ){
+
+ // vars
+ var text = item.text || item.label || '';
+ var id = item.id || item.value || '';
+
+ // append
+ values.push(id);
+
+ // optgroup
+ if( item.children ) {
+ itemsHtml += '' + crawl( item.children ) + ' ';
+
+ // option
+ } else {
+ itemsHtml += '' + acf.strEscape(text) + ' ';
+ }
+ });
+
+ // return
+ return itemsHtml;
+ };
+
+ // update HTML
+ $select.html( crawl(choices) );
+
+ // update value
+ if( values.indexOf(value) > -1 ){
+ $select.val( value );
+ }
+
+ // return selected value
+ return $select.val();
+ };
+
+ /**
+ * acf.lock
+ *
+ * Creates a "lock" on an element for a given type and key
+ *
+ * @date 22/2/18
+ * @since 5.6.9
+ *
+ * @param jQuery $el The element to lock.
+ * @param string type The type of lock such as "condition" or "visibility".
+ * @param string key The key that will be used to unlock.
+ * @return void
+ */
+
+ var getLocks = function( $el, type ){
+ return $el.data('acf-lock-'+type) || [];
+ };
+
+ var setLocks = function( $el, type, locks ){
+ $el.data('acf-lock-'+type, locks);
+ }
+
+ acf.lock = function( $el, type, key ){
+ var locks = getLocks( $el, type );
+ var i = locks.indexOf(key);
+ if( i < 0 ) {
+ locks.push( key );
+ setLocks( $el, type, locks );
+ }
+ };
+
+ /**
+ * acf.unlock
+ *
+ * Unlocks a "lock" on an element for a given type and key
+ *
+ * @date 22/2/18
+ * @since 5.6.9
+ *
+ * @param jQuery $el The element to lock.
+ * @param string type The type of lock such as "condition" or "visibility".
+ * @param string key The key that will be used to unlock.
+ * @return void
+ */
+
+ acf.unlock = function( $el, type, key ){
+ var locks = getLocks( $el, type );
+ var i = locks.indexOf(key);
+ if( i > -1 ) {
+ locks.splice(i, 1);
+ setLocks( $el, type, locks );
+ }
+
+ // return true if is unlocked (no locks)
+ return (locks.length === 0);
+ };
+
+ /**
+ * acf.isLocked
+ *
+ * Returns true if a lock exists for a given type
+ *
+ * @date 22/2/18
+ * @since 5.6.9
+ *
+ * @param jQuery $el The element to lock.
+ * @param string type The type of lock such as "condition" or "visibility".
+ * @return void
+ */
+
+ acf.isLocked = function( $el, type ){
+ return ( getLocks( $el, type ).length > 0 );
+ };
+
+ /*
+ * exists
+ *
+ * This function will return true if a jQuery selection exists
+ *
+ * @type function
+ * @date 8/09/2014
+ * @since 5.0.0
+ *
+ * @param n/a
+ * @return (boolean)
+ */
+
+ $.fn.exists = function() {
+ return $(this).length>0;
+ };
+
+
+ /*
+ * outerHTML
+ *
+ * This function will return a string containing the HTML of the selected element
+ *
+ * @type function
+ * @date 19/11/2013
+ * @since 5.0.0
+ *
+ * @param $.fn
+ * @return (string)
+ */
+
+ $.fn.outerHTML = function() {
+ return $(this).get(0).outerHTML;
+ };
+
+ /*
+ * indexOf
+ *
+ * This function will provide compatibility for ie8
+ *
+ * @type function
+ * @date 5/3/17
+ * @since 5.5.10
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ if( !Array.prototype.indexOf ) {
+
+ Array.prototype.indexOf = function(val) {
+ return $.inArray(val, this);
+ };
+
+ }
+
+
+ // Set up actions from events
+ $(document).ready(function(){
+ acf.doAction('ready');
+ });
+
+ $(window).on('load', function(){
+ acf.doAction('load');
+ });
+
+ $(window).on('unload', function(){
+ acf.doAction('unload');
+ });
+
+ $(window).on('resize', function(){
+ acf.doAction('resize');
+ });
+
+ $(document).on('sortstart', function( event, ui ) {
+ acf.doAction('sortstart', ui.item, ui.placeholder);
+ });
+
+ $(document).on('sortstop', function( event, ui ) {
+ acf.doAction('sortstop', ui.item, ui.placeholder);
+ });
+
+})(jQuery);
+
( function( window, undefined ) {
"use strict";
@@ -246,3432 +2358,1108 @@
};
- window.wp = window.wp || {};
- window.wp.hooks = window.wp.hooks || new EventManager();
+ // instantiate
+ acf.hooks = new EventManager();
} )( window );
-
-var acf;
-
-(function($){
+(function($, undefined){
-
- /*
- * exists
+ // Cached regex to split keys for `addEvent`.
+ var delegateEventSplitter = /^(\S+)\s*(.*)$/;
+
+ /**
+ * extend
*
- * This function will return true if a jQuery selection exists
+ * Helper function to correctly set up the prototype chain for subclasses
+ * Heavily inspired by backbone.js
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 14/12/17
+ * @since 5.6.5
*
- * @param n/a
- * @return (boolean)
+ * @param object protoProps New properties for this object.
+ * @return function.
*/
- $.fn.exists = function() {
-
- return $(this).length>0;
-
- };
-
-
- /*
- * outerHTML
- *
- * This function will return a string containing the HTML of the selected element
- *
- * @type function
- * @date 19/11/2013
- * @since 5.0.0
- *
- * @param $.fn
- * @return (string)
- */
-
- $.fn.outerHTML = function() {
-
- return $(this).get(0).outerHTML;
-
- };
-
-
- acf = {
+ var extend = function( protoProps ) {
// vars
- l10n: {},
- o: {},
+ var Parent = this;
+ var Child;
+ // The constructor function for the new subclass is either defined by you
+ // (the "constructor" property in your `extend` definition), or defaulted
+ // by us to simply call the parent constructor.
+ if( protoProps && protoProps.hasOwnProperty('constructor') ) {
+ Child = protoProps.constructor;
+ } else {
+ Child = function(){ return Parent.apply(this, arguments); };
+ }
+
+ // Add static properties to the constructor function, if supplied.
+ $.extend(Child, Parent);
- /*
- * update
- *
- * This function will update a value found in acf.o
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param k (string) the key
- * @param v (mixed) the value
- * @return n/a
- */
+ // Set the prototype chain to inherit from `parent`, without calling
+ // `parent`'s constructor function and add the prototype properties.
+ Child.prototype = Object.create(Parent.prototype);
+ $.extend(Child.prototype, protoProps);
+ Child.prototype.constructor = Child;
- update: function( k, v ){
-
- this.o[ k ] = v;
-
- },
+ // Set a convenience property in case the parent's prototype is needed later.
+ //Child.prototype.__parent__ = Parent.prototype;
+
+ // return
+ return Child;
+ };
+
+
+ /**
+ * Model
+ *
+ * Base class for all inheritence
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object props
+ * @return function.
+ */
+
+ var Model = acf.Model = function(){
- /*
+ // generate uique client id
+ this.cid = acf.uniqueId('acf');
+
+ // set vars to avoid modifying prototype
+ this.data = $.extend(true, {}, this.data);
+
+ // pass props to setup function
+ this.setup.apply(this, arguments);
+
+ // store on element (allow this.setup to create this.$el)
+ if( this.$el && !this.$el.data('acf') ) {
+ this.$el.data('acf', this);
+ }
+
+ // initialize
+ var initialize = function(){
+ this.initialize();
+ this.addEvents();
+ this.addActions();
+ this.addFilters();
+ };
+
+ // initialize on action
+ if( this.wait && !acf.didAction(this.wait) ) {
+ this.addAction(this.wait, initialize);
+
+ // initialize now
+ } else {
+ initialize.apply(this);
+ }
+ };
+
+ // Attach all inheritable methods to the Model prototype.
+ $.extend(Model.prototype, {
+
+ // Unique model id
+ id: '',
+
+ // Unique client id
+ cid: '',
+
+ // jQuery element
+ $el: null,
+
+ // Data specific to this instance
+ data: {},
+
+ // toggle used when changing data
+ busy: false,
+ changed: false,
+
+ // Setup events hooks
+ events: {},
+ actions: {},
+ filters: {},
+
+ // class used to avoid nested event triggers
+ eventScope: '',
+
+ // action to wait until initialize
+ wait: false,
+
+ // action priority default
+ priority: 10,
+
+ /**
* get
*
- * This function will return a value found in acf.o
+ * Gets a specific data value
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 14/12/17
+ * @since 5.6.5
*
- * @param k (string) the key
- * @return v (mixed) the value
+ * @param string name
+ * @return mixed
*/
- get: function( k ){
-
- if( typeof this.o[ k ] !== 'undefined' ) {
-
- return this.o[ k ];
-
- }
-
- return null;
-
+ get: function( name ) {
+ return this.data[name];
},
-
- /*
- * _e
+ /**
+ * has
*
- * This functiln will return a string found in acf.l10n
+ * Returns `true` if the data exists and is not null
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 14/12/17
+ * @since 5.6.5
*
- * @param k1 (string) the first key to look for
- * @param k2 (string) the second key to look for
- * @return string (string)
+ * @param string name
+ * @return boolean
*/
- _e: function( k1, k2 ){
-
- // defaults
- k2 = k2 || false;
-
-
- // get context
- var string = this.l10n[ k1 ] || '';
-
-
- // get string
- if( k2 ) {
-
- string = string[ k2 ] || '';
-
- }
-
-
- // return
- return string;
-
+ has: function( name ) {
+ return this.get(name) != null;
},
-
- /*
- * add_action
+ /**
+ * set
*
- * This function uses wp.hooks to mimics WP add_action
+ * Sets a specific data value
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 14/12/17
+ * @since 5.6.5
*
- * @param
- * @return
+ * @param string name
+ * @param mixed value
+ * @return this
*/
- add_action: function() {
+ set: function( name, value, silent ) {
- // vars
- var a = arguments[0].split(' '),
- l = a.length;
-
-
- // loop
- for( var i = 0; i < l; i++) {
-
-/*
- // allow for special actions
- if( a[i].indexOf('initialize') !== -1 ) {
-
- a.push( a[i].replace('initialize', 'ready') );
- a.push( a[i].replace('initialize', 'append') );
- l = a.length;
-
- continue;
- }
-*/
-
-
- // prefix action
- arguments[0] = 'acf/' + a[i];
-
-
- // add
- wp.hooks.addAction.apply(this, arguments);
-
+ // bail if unchanged
+ var prevValue = this.get(name);
+ if( prevValue == value ) {
+ return this;
}
+ // set data
+ this.data[ name ] = value;
+
+ // trigger events
+ if( !silent ) {
+ this.changed = true;
+ this.trigger('changed:' + name, [value]);
+ this.trigger('changed', [name, value]);
+ }
// return
return this;
-
},
-
- /*
- * remove_action
+ /**
+ * inherit
*
- * This function uses wp.hooks to mimics WP remove_action
+ * Inherits the data from a jQuery element
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 14/12/17
+ * @since 5.6.5
*
- * @param
- * @return
+ * @param jQuery $el
+ * @return this
*/
- remove_action: function() {
+ inherit: function( data ){
- // prefix action
- arguments[0] = 'acf/' + arguments[0];
+ // allow jQuery
+ if( data instanceof jQuery ) {
+ data = data.data();
+ }
- wp.hooks.removeAction.apply(this, arguments);
+ // extend
+ $.extend(this.data, data);
+ // return
return this;
-
},
-
- /*
- * do_action
+ /**
+ * prop
*
- * This function uses wp.hooks to mimics WP do_action
+ * mimics the jQuery prop function
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 4/6/18
+ * @since 5.6.9
*
- * @param
- * @return
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- do_action: function() { //console.log('acf.do_action(%o)', arguments);
-
- // prefix action
- arguments[0] = 'acf/' + arguments[0];
-
- wp.hooks.doAction.apply(this, arguments);
-
- return this;
-
+ prop: function(){
+ return this.$el.prop.apply(this.$el, arguments);
},
-
- /*
- * add_filter
+ /**
+ * setup
*
- * This function uses wp.hooks to mimics WP add_filter
+ * Run during constructor function
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param
- * @return
- */
-
- add_filter: function() {
-
- // prefix action
- arguments[0] = 'acf/' + arguments[0];
-
- wp.hooks.addFilter.apply(this, arguments);
-
- return this;
-
- },
-
-
- /*
- * remove_filter
- *
- * This function uses wp.hooks to mimics WP remove_filter
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param
- * @return
- */
-
- remove_filter: function() {
-
- // prefix action
- arguments[0] = 'acf/' + arguments[0];
-
- wp.hooks.removeFilter.apply(this, arguments);
-
- return this;
-
- },
-
-
- /*
- * apply_filters
- *
- * This function uses wp.hooks to mimics WP apply_filters
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param
- * @return
- */
-
- apply_filters: function() { //console.log('acf.apply_filters(%o)', arguments);
-
- // prefix action
- arguments[0] = 'acf/' + arguments[0];
-
- return wp.hooks.applyFilters.apply(this, arguments);
-
- },
-
-
- /*
- * get_selector
- *
- * This function will return a valid selector for finding a field object
- *
- * @type function
- * @date 15/01/2015
- * @since 5.1.5
- *
- * @param s (string)
- * @return (string)
- */
-
- get_selector: function( s ) {
-
- // defaults
- s = s || '';
-
-
- // vars
- var selector = '.acf-field';
-
-
- // compatibility with object
- if( $.isPlainObject(s) ) {
-
- if( $.isEmptyObject(s) ) {
-
- s = '';
-
- } else {
-
- for( k in s ) { s = s[k]; break; }
-
- }
-
- }
-
-
- // search
- if( s ) {
-
- // append
- selector += '-' + s;
-
-
- // replace underscores (split/join replaces all and is faster than regex!)
- selector = selector.split('_').join('-');
-
-
- // remove potential double up
- selector = selector.split('field-field-').join('field-');
-
- }
-
-
- // return
- return selector;
-
- },
-
-
- /*
- * get_fields
- *
- * This function will return a jQuery selection of fields
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param args (object)
- * @param $el (jQuery) element to look within
- * @param all (boolean) return all fields or allow filtering (for repeater)
- * @return $fields (jQuery)
- */
-
- get_fields: function( s, $el, all ){
-
- // debug
- //console.log( 'acf.get_fields(%o, %o, %o)', args, $el, all );
- //console.time("acf.get_fields");
-
-
- // defaults
- s = s || '';
- $el = $el || false;
- all = all || false;
-
-
- // vars
- var selector = this.get_selector(s);
-
-
- // get child fields
- var $fields = $( selector, $el );
-
-
- // append context to fields if also matches selector.
- // * Required for field group 'change_filed_type' append $tr to work
- if( $el !== false ) {
-
- $el.each(function(){
-
- if( $(this).is(selector) ) {
-
- $fields = $fields.add( $(this) );
-
- }
-
- });
-
- }
-
-
- // filter out fields
- if( !all ) {
-
- // remove clone fields
- $fields = $fields.not('.acf-clone .acf-field');
-
-
- // filter
- $fields = acf.apply_filters('get_fields', $fields);
-
- }
-
-
- //console.log('get_fields(%o, %o, %o) %o', s, $el, all, $fields);
- //console.log('acf.get_fields(%o):', this.get_selector(s) );
- //console.timeEnd("acf.get_fields");
-
-
- // return
- return $fields;
-
- },
-
-
- /*
- * get_field
- *
- * This function will return a jQuery selection based on a field key
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param field_key (string)
- * @param $el (jQuery) element to look within
- * @return $field (jQuery)
- */
-
- get_field: function( s, $el ){
-
- // defaults
- s = s || '';
- $el = $el || false;
-
-
- // get fields
- var $fields = this.get_fields(s, $el, true);
-
-
- // check if exists
- if( $fields.exists() ) {
-
- return $fields.first();
-
- }
-
-
- // return
- return false;
-
- },
-
-
- /*
- * get_closest_field
- *
- * This function will return the closest parent field
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $el (jQuery) element to start from
- * @param args (object)
- * @return $field (jQuery)
- */
-
- get_closest_field : function( $el, s ){
-
- // defaults
- s = s || '';
-
-
- // return
- return $el.closest( this.get_selector(s) );
-
- },
-
-
- /*
- * get_field_wrap
- *
- * This function will return the closest parent field
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $el (jQuery) element to start from
- * @return $field (jQuery)
- */
-
- get_field_wrap: function( $el ){
-
- return $el.closest( this.get_selector() );
-
- },
-
-
- /*
- * get_field_key
- *
- * This function will return the field's key
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $field (jQuery)
- * @return (string)
- */
-
- get_field_key: function( $field ){
-
- return $field.data('key');
-
- },
-
-
- /*
- * get_field_type
- *
- * This function will return the field's type
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $field (jQuery)
- * @return (string)
- */
-
- get_field_type: function( $field ){
-
- return $field.data('type');
-
- },
-
-
- /*
- * get_data
- *
- * This function will return attribute data for a given elemnt
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $el (jQuery)
- * @param name (mixed)
- * @return (mixed)
- */
-
- get_data: function( $el, defaults ){
-
- // get data
- var data = $el.data();
-
-
- // defaults
- if( typeof defaults === 'object' ) {
-
- data = this.parse_args( data, defaults );
-
- }
-
-
- // return
- return data;
-
- },
-
-
- /*
- * get_uniqid
- *
- * This function will return a unique string ID
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param prefix (string)
- * @param more_entropy (boolean)
- * @return (string)
- */
-
- get_uniqid : function( prefix, more_entropy ){
-
- // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + revised by: Kankrelune (http://www.webfaktory.info/)
- // % note 1: Uses an internal counter (in php_js global) to avoid collision
- // * example 1: uniqid();
- // * returns 1: 'a30285b160c14'
- // * example 2: uniqid('foo');
- // * returns 2: 'fooa30285b1cd361'
- // * example 3: uniqid('bar', true);
- // * returns 3: 'bara20285b23dfd1.31879087'
- if (typeof prefix === 'undefined') {
- prefix = "";
- }
-
- var retId;
- var formatSeed = function (seed, reqWidth) {
- seed = parseInt(seed, 10).toString(16); // to hex str
- if (reqWidth < seed.length) { // so long we split
- return seed.slice(seed.length - reqWidth);
- }
- if (reqWidth > seed.length) { // so short we pad
- return Array(1 + (reqWidth - seed.length)).join('0') + seed;
- }
- return seed;
- };
-
- // BEGIN REDUNDANT
- if (!this.php_js) {
- this.php_js = {};
- }
- // END REDUNDANT
- if (!this.php_js.uniqidSeed) { // init seed with big random int
- this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
- }
- this.php_js.uniqidSeed++;
-
- retId = prefix; // start with prefix, add current milliseconds hex string
- retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
- retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
- if (more_entropy) {
- // for more entropy we add a float lower to 10
- retId += (Math.random() * 10).toFixed(8).toString();
- }
-
- return retId;
-
- },
-
-
- /*
- * serialize_form
- *
- * This function will create an object of data containing all form inputs within an element
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $el (jQuery selection)
- * @return $post_id (int)
- */
-
- serialize_form: function(){
-
- return this.serialize.apply( this, arguments );
-
- },
-
- serialize: function( $el, prefix ){
-
- // defaults
- prefix = prefix || '';
-
-
- // vars
- var data = {};
- var names = {};
- var values = $el.find('select, textarea, input').serializeArray();
-
-
- // populate data
- $.each( values, function( i, pair ) {
-
- // vars
- var name = pair.name;
- var value = pair.value;
-
-
- // prefix
- if( prefix ) {
-
- // bail early if does not contain
- if( name.indexOf(prefix) !== 0 ) return;
-
-
- // remove prefix
- name = name.slice(prefix.length);
-
-
- // name must not start as array piece
- if( name.slice(0, 1) == '[' ) {
-
- name = name.slice(1).replace(']', '');
-
- }
-
- }
-
-
- // initiate name
- if( name.slice(-2) === '[]' ) {
-
- // remove []
- name = name.slice(0, -2);
-
-
- // initiate counter
- if( typeof names[ name ] === 'undefined'){
-
- names[ name ] = -1;
-
- }
-
-
- // increase counter
- names[ name ]++;
-
-
- // add key
- name += '[' + names[ name ] +']';
- }
-
-
- // append to data
- data[ name ] = value;
-
- });
-
-
- //console.log('serialize', data);
-
-
- // return
- return data;
-
- },
-
-
- /*
- * remove_tr
- *
- * This function will remove a tr element with animation
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $tr (jQuery selection)
- * @param callback (function) runs on complete
- * @return n/a
- */
-
- remove_tr : function( $tr, callback ){
-
- // vars
- var height = $tr.height(),
- children = $tr.children().length;
-
-
- // add class
- $tr.addClass('acf-remove-element');
-
-
- // after animation
- setTimeout(function(){
-
- // remove class
- $tr.removeClass('acf-remove-element');
-
-
- // vars
- $tr.html(' ');
-
-
- $tr.children('td').animate({ height : 0}, 250, function(){
-
- $tr.remove();
-
- if( typeof(callback) == 'function' ) {
-
- callback();
-
- }
-
-
- });
-
-
- }, 250);
-
- },
-
-
- /*
- * remove_el
- *
- * This function will remove an element with animation
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $el (jQuery selection)
- * @param callback (function) runs on complete
- * @param end_height (int)
- * @return n/a
- */
-
- remove_el : function( $el, callback, end_height ){
-
- // defaults
- end_height = end_height || 0;
-
-
- // vars
- var height = $el.height(),
- width = $el.width(),
- margin = $el.css('margin'),
- outer_height = $el.outerHeight(true);
-
-
- // action
- acf.do_action('remove', $el);
-
-
- // create wrap
- $el.wrap('
');
- var $wrap = $el.parent();
-
-
- // set pos
- $el.css({
- height: height,
- width: width,
- margin: margin,
- position: 'absolute'
- });
-
-
- // fade
- setTimeout(function(){
-
- // aniamte
- $wrap.css({
- opacity: 0,
- height: end_height
- });
-
- }, 50);
-
-
- // animate complete
- setTimeout(function(){
-
- // remove wrap
- $wrap.remove();
-
-
- // callback
- if( typeof(callback) == 'function' ) {
- callback.apply(this, arguments);
- }
-
- }, 301);
-
- },
-
-
- /*
- * isset
- *
- * This function will return true if an object key exists
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param (object)
- * @param key1 (string)
- * @param key2 (string)
- * @param ...
- * @return (boolean)
- */
-
- isset : function(){
-
- var a = arguments,
- l = a.length,
- c = null,
- undef;
-
- if (l === 0) {
- throw new Error('Empty isset');
- }
-
- c = a[0];
-
- for (i = 1; i < l; i++) {
-
- if (a[i] === undef || c[ a[i] ] === undef) {
- return false;
- }
-
- c = c[ a[i] ];
-
- }
-
- return true;
-
- },
-
-
- /*
- * maybe_get
- *
- * This function will attempt to return a value and return null if not possible
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param obj (object) the array to look within
- * @param key (key) the array key to look for. Nested values may be found using '/'
- * @param value (mixed) the value returned if not found
- * @return (mixed)
- */
-
- maybe_get: function( obj, key, value ){
-
- // default
- if( typeof value == 'undefined' ) value = null;
-
-
- // convert type to string and split
- keys = String(key).split('.');
-
-
- // loop through keys
- for( var i in keys ) {
-
- // vars
- var key = keys[i];
-
-
- // bail ealry if not set
- if( typeof obj[ key ] === 'undefined' ) {
-
- return value;
-
- }
-
-
- // update obj
- obj = obj[ key ];
-
- }
-
-
- // return
- return obj;
-
- },
-
-
- /*
- * open_popup
- *
- * This function will create and open a popup modal
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param args (object)
- * @return n/a
- */
-
- open_popup : function( args ){
-
- // vars
- $popup = $('body > #acf-popup');
-
-
- // already exists?
- if( $popup.exists() ) {
-
- return update_popup(args);
-
- }
-
-
- // template
- var tmpl = [
- ''
- ].join('');
-
-
- // append
- $('body').append( tmpl );
-
-
- $('#acf-popup').on('click', '.bg, .acf-close-popup', function( e ){
-
- e.preventDefault();
-
- acf.close_popup();
-
- });
-
-
- // update
- return this.update_popup(args);
-
- },
-
-
- /*
- * update_popup
- *
- * This function will update the content within a popup modal
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param args (object)
- * @return n/a
- */
-
- update_popup : function( args ){
-
- // vars
- $popup = $('#acf-popup');
-
-
- // validate
- if( !$popup.exists() )
- {
- return false
- }
-
-
- // defaults
- args = $.extend({}, {
- title : '',
- content : '',
- width : 0,
- height : 0,
- loading : false
- }, args);
-
-
- if( args.title ) {
-
- $popup.find('.title h3').html( args.title );
-
- }
-
- if( args.content ) {
-
- $inner = $popup.find('.inner:first');
-
- $inner.html( args.content );
-
- acf.do_action('append', $inner);
-
- // update height
- $inner.attr('style', 'position: relative;');
- args.height = $inner.outerHeight();
- $inner.removeAttr('style');
-
- }
-
- if( args.width ) {
-
- $popup.find('.acf-popup-box').css({
- 'width' : args.width,
- 'margin-left' : 0 - (args.width / 2)
- });
-
- }
-
- if( args.height ) {
-
- // add h3 height (44)
- args.height += 44;
-
- $popup.find('.acf-popup-box').css({
- 'height' : args.height,
- 'margin-top' : 0 - (args.height / 2)
- });
-
- }
-
-
- if( args.loading ) {
-
- $popup.find('.loading').show();
-
- } else {
-
- $popup.find('.loading').hide();
-
- }
-
- return $popup;
- },
-
-
- /*
- * close_popup
- *
- * This function will close and remove a popup modal
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 14/12/17
+ * @since 5.6.5
*
* @param n/a
* @return n/a
*/
- close_popup : function(){
-
- // vars
- $popup = $('#acf-popup');
-
-
- // already exists?
- if( $popup.exists() )
- {
- $popup.remove();
- }
-
+ setup: function( props ){
+ $.extend(this, props);
},
-
- /*
- * update_user_setting
+ /**
+ * initialize
*
- * This function will send an AJAX request to update a user setting
+ * Also run during constructor function
*
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
+ * @date 14/12/17
+ * @since 5.6.5
*
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- update_user_setting : function( name, value ) {
-
- // ajax
- $.ajax({
- url : acf.get('ajaxurl'),
- dataType : 'html',
- type : 'post',
- data : acf.prepare_for_ajax({
- 'action' : 'acf/update_user_setting',
- 'name' : name,
- 'value' : value
- })
- });
-
- },
-
-
- /*
- * prepare_for_ajax
- *
- * This function will prepare data for an AJAX request
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param args (object)
- * @return args
- */
-
- prepare_for_ajax : function( args ) {
-
- // vars
- var data = {};
-
-
- // $.ajax() expects all args to be 'non-nested'
- $.each(args, function(k,v){
-
- // object
- if( $.isPlainObject(v) && !$.isEmptyObject(v) ) {
-
- // loop
- $.each(v, function(k2,v2){
-
- // convert string
- k2 = k2 + '';
-
-
- // vars
- var i = k2.indexOf('[');
-
-
- // starts with [
- if( i == 0 ) {
-
- k2 = k + k2;
-
- // contains [
- } else if( i > 0 ) {
-
- k2 = k + '[' + k2.slice(0, i) + ']' + k2.slice(i);
-
- // no [
- } else {
-
- k2 = k + '[' + k2 + ']';
-
- }
-
-
- // append
- data[k2] = v2;
-
- });
-
- // else
- } else {
-
- data[k] = v;
-
- }
-
- });
-
-
- // required
- data.nonce = acf.get('nonce');
- data.post_id = acf.get('post_id');
-
-
- // filter for 3rd party customization
- data = acf.apply_filters('prepare_for_ajax', data);
-
-
- // return
- return data;
-
- },
-
-
- /*
- * is_ajax_success
- *
- * This function will return true for a successful WP AJAX response
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param json (object)
- * @return (boolean)
- */
-
- is_ajax_success : function( json ) {
-
- if( json && json.success ) {
-
- return true;
-
- }
-
- return false;
-
- },
-
-
- /*
- * get_ajax_message
- *
- * This function will return an object containing error/message information
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param json (object)
- * @return (boolean)
- */
-
- get_ajax_message: function( json ) {
-
- // vars
- var message = {
- text: '',
- type: 'error'
- };
-
-
- // bail early if no json
- if( !json ) {
-
- return message;
-
- }
-
-
- // PHP error (too may themes will have warnings / errors. Don't show these in ACF taxonomy popup)
-/*
- if( typeof json === 'string' ) {
-
- message.text = json;
- return message;
-
- }
-*/
-
-
- // success
- if( json.success ) {
-
- message.type = 'success';
-
- }
-
-
- // message
- if( json.data && json.data.message ) {
-
- message.text = json.data.message;
-
- }
-
-
- // error
- if( json.data && json.data.error ) {
-
- message.text = json.data.error;
-
- }
-
-
- // return
- return message;
-
- },
-
-
- /*
- * is_in_view
- *
- * This function will return true if a jQuery element is visible in browser
- *
- * @type function
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param $el (jQuery)
- * @return (boolean)
- */
-
- is_in_view: function( $el ) {
-
- // vars
- var elemTop = $el.offset().top,
- elemBottom = elemTop + $el.height();
-
-
- // bail early if hidden
- if( elemTop === elemBottom ) {
-
- return false;
-
- }
-
-
- // more vars
- var docViewTop = $(window).scrollTop(),
- docViewBottom = docViewTop + $(window).height();
-
-
- // return
- return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
-
- },
-
-
- /*
- * val
- *
- * This function will update an elements value and trigger the change event if different
- *
- * @type function
- * @date 16/10/2014
- * @since 5.0.9
- *
- * @param $el (jQuery)
- * @param val (mixed)
+ * @param n/a
* @return n/a
*/
- val: function( $el, val ){
-
- // vars
- var orig = $el.val();
-
-
- // update value
- $el.val( val );
-
-
- // trigger change
- if( val != orig ) {
-
- $el.trigger('change');
-
- }
-
- },
+ initialize: function(){},
-
- /*
- * str_replace
+ /**
+ * addElements
*
- * This function will perform a str replace similar to php function str_replace
+ * Adds multiple jQuery elements to this object
*
- * @type function
- * @date 1/05/2015
- * @since 5.2.3
+ * @date 9/5/18
+ * @since 5.6.9
*
- * @param $search (string)
- * @param $replace (string)
- * @param $subject (string)
- * @return (string)
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- str_replace: function( search, replace, subject ) {
-
- return subject.split(search).join(replace);
-
+ addElements: function( elements ){
+ elements = elements || this.elements || null;
+ if( !elements || !Object.keys(elements).length ) return false;
+ for( var i in elements ) {
+ this.addElement( i, elements[i] );
+ }
},
-
- /*
- * str_sanitize
+ /**
+ * addElement
*
* description
*
- * @type function
- * @date 4/06/2015
- * @since 5.2.3
+ * @date 9/5/18
+ * @since 5.6.9
*
- * @param $post_id (int)
- * @return $post_id (int)
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- str_sanitize: function( string ) {
-
- // chars (https://jsperf.com/replace-foreign-characters)
- var map = {
- "À": "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",
-
- // extra
- ' ': '_',
- '\'': '',
- '?': '',
- '/': '',
- '\\': '',
- '.': '',
- ',': '',
- '`': '',
- '>': '',
- '<': '',
- '"': '',
- '[': '',
- ']': '',
- '|': '',
- '{': '',
- '}': '',
- '(': '',
- ')': ''
- };
-
-
- // vars
- var regexp = /\W/g,
- mapping = function (c) { return (typeof map[c] !== 'undefined') ? map[c] : c; };
-
-
- // replace
- string = string.replace(regexp, mapping);
-
-
- // lower case
- string = string.toLowerCase();
-
-
- // return
- return string;
-
+ addElement: function( name, selector){
+ this[ '$' + name ] = this.$( selector );
},
-
- /*
- * addslashes
+ /**
+ * addEvents
*
- * This function mimics the PHP addslashes function.
- * Returns a string with backslashes before characters that need to be escaped.
+ * Adds multiple event handlers
*
- * @type function
- * @date 9/1/17
- * @since 5.5.0
+ * @date 14/12/17
+ * @since 5.6.5
*
- * @param text (string)
- * @return (string)
+ * @param object events {event1 : callback, event2 : callback, etc }
+ * @return n/a
*/
- addslashes: function(text){
+ addEvents: function( events ){
+ events = events || this.events || null;
+ if( !events ) return false;
+ for( var key in events ) {
+ var match = key.match(delegateEventSplitter);
+ this.on(match[1], match[2], events[key]);
+ }
+ },
+
+ /**
+ * removeEvents
+ *
+ * Removes multiple event handlers
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object events {event1 : callback, event2 : callback, etc }
+ * @return n/a
+ */
+
+ removeEvents: function( events ){
+ events = events || this.events || null;
+ if( !events ) return false;
+ for( var key in events ) {
+ var match = key.match(delegateEventSplitter);
+ this.off(match[1], match[2], events[key]);
+ }
+ },
+
+ /**
+ * getEventTarget
+ *
+ * Returns a jQUery element to tigger an event on
+ *
+ * @date 5/6/18
+ * @since 5.6.9
+ *
+ * @param jQuery $el The default jQuery element. Optional.
+ * @param string event The event name. Optional.
+ * @return jQuery
+ */
+
+ getEventTarget: function( $el, event ){
+ return $el || this.$el || $(document);
+ },
+
+ /**
+ * validateEvent
+ *
+ * Returns true if the event target's closest $el is the same as this.$el
+ * Requires both this.el and this.$el to be defined
+ *
+ * @date 5/6/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ validateEvent: function( e ){
+ if( this.eventScope ) {
+ return $( e.target ).closest( this.eventScope ).is( this.$el );
+ } else {
+ return true;
+ }
+ },
+
+ /**
+ * proxyEvent
+ *
+ * Returns a new event callback function scoped to this model
+ *
+ * @date 29/3/18
+ * @since 5.6.9
+ *
+ * @param function callback
+ * @return function
+ */
+
+ proxyEvent: function( callback ){
+ return this.proxy(function(e){
+ if( !this.validateEvent(e) ) {
+ return;
+ }
+ var args = acf.arrayArgs(arguments);
+ args.push( $(e.currentTarget) );
+ callback.apply(this, args);
+ });
+ },
+
+ /**
+ * on
+ *
+ * Adds an event handler similar to jQuery
+ * Uses the instance 'cid' to namespace event
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param string callback
+ * @return n/a
+ */
+
+ on: function( a1, a2, a3, a4 ){
- return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ // vars
+ var $el, event, selector, callback, args;
+ // find args
+ if( a1 instanceof jQuery ) {
+
+ // 1. args( $el, event, selector, callback )
+ if( a4 ) {
+ $el = a1; event = a2; selector = a3; callback = a4;
+
+ // 2. args( $el, event, callback )
+ } else {
+ $el = a1; event = a2; callback = a3;
+ }
+ } else {
+
+ // 3. args( event, selector, callback )
+ if( a3 ) {
+ event = a1; selector = a2; callback = a3;
+
+ // 4. args( event, callback )
+ } else {
+ event = a1; callback = a2;
+ }
+ }
+
+ // element
+ $el = this.getEventTarget( $el );
+
+ // modify callback
+ if( typeof callback === 'string' ) {
+ callback = this.proxyEvent( this[callback] );
+ }
+
+ // modify event
+ event = event + '.' + this.cid;
+
+ // args
+ if( selector ) {
+ args = [ event, selector, callback ];
+ } else {
+ args = [ event, callback ];
+ }
+
+ // on()
+ $el.on.apply($el, args);
+ },
+
+ /**
+ * off
+ *
+ * Removes an event handler similar to jQuery
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param string callback
+ * @return n/a
+ */
+
+ off: function( a1, a2 ,a3 ){
+
+ // vars
+ var $el, event, selector, args;
+
+ // find args
+ if( a1 instanceof jQuery ) {
+
+ // 1. args( $el, event, selector )
+ if( a3 ) {
+ $el = a1; event = a2; selector = a3;
+
+ // 2. args( $el, event )
+ } else {
+ $el = a1; event = a2;
+ }
+ } else {
+
+ // 3. args( event, selector )
+ if( a2 ) {
+ event = a1; selector = a2;
+
+ // 4. args( event )
+ } else {
+ event = a1;
+ }
+ }
+
+ // element
+ $el = this.getEventTarget( $el );
+
+ // modify event
+ event = event + '.' + this.cid;
+
+ // args
+ if( selector ) {
+ args = [ event, selector ];
+ } else {
+ args = [ event ];
+ }
+
+ // off()
+ $el.off.apply($el, args);
+ },
+
+ /**
+ * trigger
+ *
+ * Triggers an event similar to jQuery
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param string callback
+ * @return n/a
+ */
+
+ trigger: function( name, args, bubbles ){
+ var $el = this.getEventTarget();
+ if( bubbles ) {
+ $el.trigger.apply( $el, arguments );
+ } else {
+ $el.triggerHandler.apply( $el, arguments );
+ }
+ return this;
+ },
+
+ /**
+ * addActions
+ *
+ * Adds multiple action handlers
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object actions {action1 : callback, action2 : callback, etc }
+ * @return n/a
+ */
+
+ addActions: function( actions ){
+ actions = actions || this.actions || null;
+ if( !actions ) return false;
+ for( var i in actions ) {
+ this.addAction( i, actions[i] );
+ }
+ },
+
+ /**
+ * removeActions
+ *
+ * Removes multiple action handlers
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object actions {action1 : callback, action2 : callback, etc }
+ * @return n/a
+ */
+
+ removeActions: function( actions ){
+ actions = actions || this.actions || null;
+ if( !actions ) return false;
+ for( var i in actions ) {
+ this.removeAction( i, actions[i] );
+ }
+ },
+
+ /**
+ * addAction
+ *
+ * Adds an action using the wp.hooks library
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param string callback
+ * @return n/a
+ */
+
+ addAction: function( name, callback, priority ){
+ //console.log('addAction', name, priority);
+ // defaults
+ priority = priority || this.priority;
+
+ // modify callback
+ if( typeof callback === 'string' ) {
+ callback = this[ callback ];
+ }
+
+ // add
+ acf.addAction(name, callback, priority, this);
+
+ },
+
+ /**
+ * removeAction
+ *
+ * Remove an action using the wp.hooks library
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param string callback
+ * @return n/a
+ */
+
+ removeAction: function( name, callback ){
+ acf.removeAction(name, this[ callback ]);
+ },
+
+ /**
+ * addFilters
+ *
+ * Adds multiple filter handlers
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object filters {filter1 : callback, filter2 : callback, etc }
+ * @return n/a
+ */
+
+ addFilters: function( filters ){
+ filters = filters || this.filters || null;
+ if( !filters ) return false;
+ for( var i in filters ) {
+ this.addFilter( i, filters[i] );
+ }
+ },
+
+ /**
+ * addFilter
+ *
+ * Adds a filter using the wp.hooks library
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param string callback
+ * @return n/a
+ */
+
+ addFilter: function( name, callback, priority ){
+
+ // defaults
+ priority = priority || this.priority;
+
+ // modify callback
+ if( typeof callback === 'string' ) {
+ callback = this[ callback ];
+ }
+
+ // add
+ acf.addFilter(name, callback, priority, this);
+
+ },
+
+ /**
+ * removeFilters
+ *
+ * Removes multiple filter handlers
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object filters {filter1 : callback, filter2 : callback, etc }
+ * @return n/a
+ */
+
+ removeFilters: function( filters ){
+ filters = filters || this.filters || null;
+ if( !filters ) return false;
+ for( var i in filters ) {
+ this.removeFilter( i, filters[i] );
+ }
+ },
+
+ /**
+ * removeFilter
+ *
+ * Remove a filter using the wp.hooks library
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string name
+ * @param string callback
+ * @return n/a
+ */
+
+ removeFilter: function( name, callback ){
+ acf.removeFilter(name, this[ callback ]);
+ },
+
+ /**
+ * $
+ *
+ * description
+ *
+ * @date 16/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ $: function( selector ){
+ return this.$el.find( selector );
+ },
+
+ /**
+ * remove
+ *
+ * Removes the element and listenters
+ *
+ * @date 19/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ remove: function(){
+ this.removeEvents();
+ this.removeActions();
+ this.removeFilters();
+ this.$el.remove();
+ },
+
+ /**
+ * setTimeout
+ *
+ * description
+ *
+ * @date 16/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ setTimeout: function( callback, milliseconds ){
+ return setTimeout( this.proxy(callback), milliseconds );
+ },
+
+ /**
+ * time
+ *
+ * used for debugging
+ *
+ * @date 7/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ time: function(){
+ console.time( this.id || this.cid );
+ },
+
+ /**
+ * timeEnd
+ *
+ * used for debugging
+ *
+ * @date 7/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ timeEnd: function(){
+ console.timeEnd( this.id || this.cid );
+ },
+
+ /**
+ * show
+ *
+ * description
+ *
+ * @date 15/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ show: function(){
+ acf.show( this.$el );
},
/**
- * esc_html
+ * hide
*
- * This function will escape HTML characters for safe use
+ * description
*
- * @source https://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
- * @date 20/9/17
- * @since 5.6.3
+ * @date 15/3/18
+ * @since 5.6.9
*
- * @param n/a
- * @return n/a
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- esc_html: function( string ){
-
- var entityMap = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": ''',
- '/': '/',
- '`': '`',
- '=': '='
- };
-
- return String(string).replace(/[&<>"'`=\/]/g, function (s) {
- return entityMap[s];
- });
+ hide: function(){
+ acf.hide( this.$el );
+ },
+
+ /**
+ * proxy
+ *
+ * Returns a new function scoped to this model
+ *
+ * @date 29/3/18
+ * @since 5.6.9
+ *
+ * @param function callback
+ * @return function
+ */
+
+ proxy: function( callback ){
+ return $.proxy( callback, this );
+ }
+
+
+ });
+
+ // Set up inheritance for the model
+ Model.extend = extend;
+
+ // Global model storage
+ acf.models = {};
+
+ /**
+ * acf.getInstance
+ *
+ * This function will get an instance from an element
+ *
+ * @date 5/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getInstance = function( $el ){
+ return $el.data('acf');
+ };
+
+ /**
+ * acf.getInstances
+ *
+ * This function will get an array of instances from multiple elements
+ *
+ * @date 5/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getInstances = function( $el ){
+ var instances = [];
+ $el.each(function(){
+ instances.push( acf.getInstance( $(this) ) );
+ });
+ return instances;
+ };
+
+})(jQuery);
- },
-
-
- /*
- * render_select
- *
- * This function will update a select field with new choices
- *
- * @type function
- * @date 8/04/2014
- * @since 5.0.0
- *
- * @param $select
- * @param choices
- * @return n/a
- */
-
- render_select: function( $select, choices ){
-
- // vars
- var value = $select.val();
-
-
- // clear choices
- $select.html('');
-
-
- // bail early if no choices
- if( !choices ) {
-
- return;
-
- }
-
-
- // populate choices
- $.each(choices, function( i, item ){
-
- // vars
- var $optgroup = $select;
-
-
- // add group
- if( item.group ) {
-
- $optgroup = $select.find('optgroup[label="' + item.group + '"]');
-
- if( !$optgroup.exists() ) {
-
- $optgroup = $(' ');
-
- $select.append( $optgroup );
-
- }
-
- }
-
-
- // append select
- $optgroup.append( '' + acf.esc_html(item.label) + ' ' );
-
-
- // selectedIndex
- if( value == item.value ) {
-
- $select.prop('selectedIndex', i);
-
- }
-
- });
-
- },
-
-
- /*
- * duplicate
- *
- * This function will duplicate and return an element
- *
- * @type function
- * @date 22/08/2015
- * @since 5.2.3
- *
- * @param $el (jQuery) object to be duplicated
- * @param attr (string) attrbute name where $el id can be found
- * @return $el2 (jQuery)
- */
-
- duplicate: function( args ){
-
- //console.time('duplicate');
-
-
- // backwards compatibility
- // - array of settings added in v5.4.6
- if( typeof args.length !== 'undefined' ) args = { $el: args };
-
-
- // defaults
- args = acf.parse_args(args, {
- $el: false,
- search: '',
- replace: '',
- before: function( $el ){},
- after: function( $el, $el2 ){},
- append: function( $el, $el2 ){ $el.after( $el2 ); }
- });
-
-
- // vars
- var $el = args.$el,
- $el2;
-
-
- // search
- if( !args.search ) args.search = $el.attr('data-id');
-
-
- // replace
- if( !args.replace ) args.replace = acf.get_uniqid();
-
-
- // before
- // - allow acf to modify DOM
- // - fixes bug where select field option is not selected
- args.before.apply( this, [$el] );
- acf.do_action('before_duplicate', $el);
-
-
- // clone
- var $el2 = $el.clone();
-
-
- // remove acf-clone (may be a clone)
- $el2.removeClass('acf-clone');
-
-
- // remove JS functionality
- acf.do_action('remove', $el2);
-
-
- // find / replace
- if( args.search ) {
-
- // replace data
- $el2.attr('data-id', args.replace);
-
-
- // replace ids
- $el2.find('[id*="' + args.search + '"]').each(function(){
-
- $(this).attr('id', $(this).attr('id').replace(args.search, args.replace) );
-
- });
-
-
- // replace names
- $el2.find('[name*="' + args.search + '"]').each(function(){
-
- $(this).attr('name', $(this).attr('name').replace(args.search, args.replace) );
-
- });
-
-
- // replace label for
- $el2.find('label[for*="' + args.search + '"]').each(function(){
-
- $(this).attr('for', $(this).attr('for').replace(args.search, args.replace) );
-
- });
-
- }
-
-
- // remove ui-sortable
- $el2.find('.ui-sortable').removeClass('ui-sortable');
-
-
- // after
- // - allow acf to modify DOM
- acf.do_action('after_duplicate', $el, $el2 );
- args.after.apply( this, [$el, $el2] );
-
-
- // append
- args.append.apply( this, [$el, $el2] );
-
-
- // add JS functionality
- // - allow element to be moved into a visible position before fire action
- setTimeout(function(){
-
- acf.do_action('append', $el2);
-
- }, 1);
-
-
- //console.timeEnd('duplicate');
-
-
- // return
- return $el2;
-
- },
-
- decode: function( string ){
-
- return $('').html( string ).text();
-
- },
-
-
- /*
- * parse_args
- *
- * This function will merge together defaults and args much like the WP wp_parse_args function
- *
- * @type function
- * @date 11/04/2016
- * @since 5.3.8
- *
- * @param args (object)
- * @param defaults (object)
- * @return args
- */
-
- parse_args: function( args, defaults ) {
-
- // defaults
- if( typeof args !== 'object' ) args = {};
- if( typeof defaults !== 'object' ) defaults = {};
-
-
- // return
- return $.extend({}, defaults, args);
-
- },
-
-
- /*
- * enqueue_script
- *
- * This function will append a script to the page
- *
- * @source https://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/
- * @type function
- * @date 27/08/2016
- * @since 5.4.0
- *
- * @param url (string)
- * @param callback (function)
- * @return na
- */
-
- enqueue_script: function( url, callback ) {
-
- // vars
- var script = document.createElement('script');
-
-
- // atts
- script.type = "text/javascript";
- script.src = url;
- script.async = true;
-
-
- // ie
- if( script.readyState ) {
-
- script.onreadystatechange = function(){
-
- if( script.readyState == 'loaded' || script.readyState == 'complete' ){
-
- script.onreadystatechange = null;
- callback();
-
- }
-
- };
-
- // normal browsers
- } else {
-
- script.onload = function(){
- callback();
- };
-
- }
-
-
- // append
- document.body.appendChild(script);
-
- }
-
- };
+(function($, undefined){
-
- /*
- * acf.model
- *
- * This model acts as a scafold for action.event driven modules
- *
- * @type object
- * @date 8/09/2014
- * @since 5.0.0
- *
- * @param (object)
- * @return (object)
- */
-
- acf.model = {
-
- // vars
- actions: {},
- filters: {},
- events: {},
-
- extend: function( args ){
-
- // extend
- var model = $.extend( {}, this, args );
-
-
- // setup actions
- $.each(model.actions, function( name, callback ){
-
- model._add_action( name, callback );
-
- });
-
-
- // setup filters
- $.each(model.filters, function( name, callback ){
-
- model._add_filter( name, callback );
-
- });
-
-
- // setup events
- $.each(model.events, function( name, callback ){
-
- model._add_event( name, callback );
-
- });
-
-
- // return
- return model;
-
- },
-
- _add_action: function( name, callback ) {
-
- // split
- var model = this,
- data = name.split(' ');
-
-
- // add missing priority
- var name = data[0] || '',
- priority = data[1] || 10;
-
-
- // add action
- acf.add_action(name, model[ callback ], priority, model);
-
- },
-
- _add_filter: function( name, callback ) {
-
- // split
- var model = this,
- data = name.split(' ');
-
-
- // add missing priority
- var name = data[0] || '',
- priority = data[1] || 10;
-
-
- // add action
- acf.add_filter(name, model[ callback ], priority, model);
-
- },
-
- _add_event: function( name, callback ) {
-
- // vars
- var model = this,
- i = name.indexOf(' '),
- event = (i > 0) ? name.substr(0,i) : name,
- selector = (i > 0) ? name.substr(i+1) : '';
-
-
- // event
- var fn = function( e ){
-
- // append $el to event object
- e.$el = $(this);
-
-
- // event
- if( typeof model.event === 'function' ) {
- e = model.event( e );
- }
-
-
- // callback
- model[ callback ].apply(model, arguments);
-
- };
-
-
- // add event
- if( selector ) {
- $(document).on(event, selector, fn);
- } else {
- $(document).on(event, fn);
- }
-
- },
-
- get: function( name, value ){
-
- // defaults
- value = value || null;
-
-
- // get
- if( typeof this[ name ] !== 'undefined' ) {
-
- value = this[ name ];
-
- }
-
-
- // return
- return value;
-
- },
-
-
- set: function( name, value ){
-
- // set
- this[ name ] = value;
-
-
- // function for 3rd party
- if( typeof this[ '_set_' + name ] === 'function' ) {
-
- this[ '_set_' + name ].apply(this);
-
- }
-
-
- // return for chaining
- return this;
-
- }
-
- };
-
-
- /*
- * field
- *
- * This model sets up many of the field's interactions
- *
- * @type function
- * @date 21/02/2014
- * @since 3.5.1
- *
- * @param n/a
- * @return n/a
- */
-
- acf.field = acf.model.extend({
-
- // vars
- type: '',
- o: {},
- $field: null,
-
- _add_action: function( name, callback ) {
-
- // vars
- var model = this;
-
-
- // update name
- name = name + '_field/type=' + model.type;
-
-
- // add action
- acf.add_action(name, function( $field ){
-
- // focus
- model.set('$field', $field);
-
-
- // callback
- model[ callback ].apply(model, arguments);
-
- });
-
- },
-
- _add_filter: function( name, callback ) {
-
- // vars
- var model = this;
-
-
- // update name
- name = name + '_field/type=' + model.type;
-
-
- // add action
- acf.add_filter(name, function( $field ){
-
- // focus
- model.set('$field', $field);
-
-
- // callback
- model[ callback ].apply(model, arguments);
-
- });
-
- },
-
- _add_event: function( name, callback ) {
-
- // vars
- var model = this,
- event = name.substr(0,name.indexOf(' ')),
- selector = name.substr(name.indexOf(' ')+1),
- context = acf.get_selector(model.type);
-
-
- // add event
- $(document).on(event, context + ' ' + selector, function( e ){
-
- // vars
- var $el = $(this);
- var $field = acf.get_closest_field( $el, model.type );
-
-
- // bail early if no field
- if( !$field.length ) return;
-
-
- // focus
- if( !$field.is(model.$field) ) {
- model.set('$field', $field);
- }
-
-
- // append to event
- e.$el = $el;
- e.$field = $field;
-
-
- // callback
- model[ callback ].apply(model, [e]);
-
- });
-
- },
-
- _set_$field: function(){
-
- // callback
- if( typeof this.focus === 'function' ) {
- this.focus();
- }
-
- },
-
- // depreciated
- doFocus: function( $field ){
-
- return this.set('$field', $field);
-
- }
-
- });
-
-
- /*
- * field
- *
- * This model fires actions and filters for registered fields
- *
- * @type function
- * @date 21/02/2014
- * @since 3.5.1
- *
- * @param n/a
- * @return n/a
- */
-
- 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
- _prepare: function( $el ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('prepare_field', $(this));
-
- });
-
- },
-
- _prepare_field: function( $el ){
-
- acf.do_action('prepare_field/type=' + $el.data('type'), $el);
-
- },
-
- // ready
- _ready: function( $el ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('ready_field', $(this));
-
- });
-
- },
-
- _ready_field: function( $el ){
-
- acf.do_action('ready_field/type=' + $el.data('type'), $el);
-
- },
-
- // append
- _append: function( $el ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('append_field', $(this));
-
- });
-
- },
-
- _append_field: function( $el ){
-
- acf.do_action('append_field/type=' + $el.data('type'), $el);
-
- },
-
- // load
- _load: function( $el ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('load_field', $(this));
-
- });
-
- },
-
- _load_field: function( $el ){
-
- acf.do_action('load_field/type=' + $el.data('type'), $el);
-
- },
-
- // remove
- _remove: function( $el ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('remove_field', $(this));
-
- });
-
- },
-
- _remove_field: function( $el ){
-
- acf.do_action('remove_field/type=' + $el.data('type'), $el);
-
- },
-
- // sortstart
- _sortstart: function( $el, $placeholder ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('sortstart_field', $(this), $placeholder);
-
- });
-
- },
-
- _sortstart_field: function( $el, $placeholder ){
-
- acf.do_action('sortstart_field/type=' + $el.data('type'), $el, $placeholder);
-
- },
-
- // sortstop
- _sortstop: function( $el, $placeholder ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('sortstop_field', $(this), $placeholder);
-
- });
-
- },
-
- _sortstop_field: function( $el, $placeholder ){
-
- acf.do_action('sortstop_field/type=' + $el.data('type'), $el, $placeholder);
-
- },
-
-
- // hide
- _hide: function( $el, context ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('hide_field', $(this), context);
-
- });
-
- },
-
- _hide_field: function( $el, context ){
-
- acf.do_action('hide_field/type=' + $el.data('type'), $el, context);
-
- },
-
- // show
- _show: function( $el, context ){
-
- acf.get_fields('', $el).each(function(){
-
- acf.do_action('show_field', $(this), context);
-
- });
-
- },
-
- _show_field: function( $el, context ){
-
- acf.do_action('show_field/type=' + $el.data('type'), $el, context);
-
- }
-
- });
-
-
- /*
- * ready
- *
- * description
- *
- * @type function
- * @date 19/02/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- $(document).ready(function(){
-
- // action for 3rd party customization
- acf.do_action('ready', $('body'));
-
- });
-
-
- /*
- * load
- *
- * description
- *
- * @type function
- * @date 19/02/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- $(window).on('load', function(){
-
- // action for 3rd party customization
- acf.do_action('load', $('body'));
-
- });
-
-
- /*
- * layout
- *
- * This model handles the width layout for fields
- *
- * @type function
- * @date 21/02/2014
- * @since 3.5.1
- *
- * @param n/a
- * @return n/a
- */
-
- acf.layout = acf.model.extend({
-
- actions: {
- 'refresh 99': 'refresh'
- },
-
- refresh: function( $el ){
-
- // defaults
- $el = $el || $('body');
-
-
- // render
- this.render_tables( $el );
- this.render_groups( $el );
-
- },
-
- render_tables: function( $el ){
-
- // reference
- var self = this;
-
-
- // vars
- var $tables = $el.find('.acf-table:visible');
-
-
- // appent self
- if( $el.is('table') ) {
- $tables = $tables.add( $el );
- } else if( $el.is('tr') ) {
- $tables = $tables.add( $el.closest('table') );
- }
-
-
- // loop
- $tables.each(function(){
-
- self.render_table( $(this) );
-
- });
-
- },
-
- render_table: function( $table ){
-
- // vars
- var $ths = $table.find('> thead th.acf-th'),
- colspan = 1,
- available_width = 100;
-
-
- // bail early if no $ths
- if( !$ths.exists() ) return;
-
-
- // vars
- var $trs = $table.find('> tbody > tr'),
- $tds = $trs.find('> td.acf-field');
-
-
- // remove clones if has visible rows
- if( $trs.hasClass('acf-clone') && $trs.length > 1 ) {
-
- $tds = $trs.not('.acf-clone').find('> td.acf-field');
-
- }
-
-
- // render th/td visibility
- $ths.each(function(){
-
- // vars
- var $th = $(this),
- key = $th.attr('data-key'),
- $td = $tds.filter('[data-key="'+key+'"]');
-
- // clear class
- $td.removeClass('appear-empty');
- $th.removeClass('hidden-by-conditional-logic');
-
-
- // no td
- if( !$td.exists() ) {
-
- // do nothing
-
- // if all td are hidden
- } else if( $td.not('.hidden-by-conditional-logic').length == 0 ) {
-
- $th.addClass('hidden-by-conditional-logic');
-
- // if 1 or more td are visible
- } else {
-
- $td.filter('.hidden-by-conditional-logic').addClass('appear-empty');
-
- }
-
- });
-
-
-
- // clear widths
- $ths.css('width', 'auto');
-
-
- // update $ths
- $ths = $ths.not('.hidden-by-conditional-logic');
-
-
- // set colspan
- colspan = $ths.length;
-
-
- // set custom widths first
- $ths.filter('[data-width]').each(function(){
-
- // vars
- var width = parseInt( $(this).attr('data-width') );
-
-
- // remove from available
- available_width -= width;
-
-
- // set width
- $(this).css('width', width + '%');
-
- });
-
-
- // update $ths
- $ths = $ths.not('[data-width]');
-
-
- // set custom widths first
- $ths.each(function(){
-
- // cal width
- var width = available_width / $ths.length;
-
-
- // set width
- $(this).css('width', width + '%');
-
- });
-
-
- // update colspan
- $table.find('.acf-row .acf-field.-collapsed-target').removeAttr('colspan');
- $table.find('.acf-row.-collapsed .acf-field.-collapsed-target').attr('colspan', colspan);
-
- },
-
- render_groups: function( $el ){
-
- // reference
- var self = this;
-
-
- // vars
- var $groups = $el.find('.acf-fields:visible');
-
-
- // appent self if is '.acf-fields'
- if( $el && $el.is('.acf-fields') ) {
-
- $groups = $groups.add( $el );
-
- }
-
-
- // loop
- $groups.each(function(){
-
- self.render_group( $(this) );
-
- });
-
- },
-
- render_group: function( $el ){
-
- // vars
- var $els = $(),
- top = 0,
- height = 0,
- cell = -1;
-
-
- // get fields
- var $fields = $el.children('.acf-field[data-width]:visible');
-
-
- // bail early if no fields
- if( !$fields.exists() ) return;
-
-
- // bail ealry if is .-left
- if( $el.hasClass('-left') ) {
-
- $fields.removeAttr('data-width');
- $fields.css('width', 'auto');
- return;
-
- }
-
-
- // reset fields
- $fields.removeClass('-r0 -c0').css({'min-height': 0});
-
-
- // loop
- $fields.each(function( i ){
-
- // vars
- var $el = $(this),
- this_top = $el.position().top;
-
-
- // set top
- if( i == 0 ) top = this_top;
-
-
- // detect new row
- if( this_top != top ) {
-
- // set previous heights
- $els.css({'min-height': (height+1)+'px'});
-
- // reset
- $els = $();
- top = $el.position().top; // don't use variable as this value may have changed due to min-height css
- height = 0;
- cell = -1;
-
- }
-
-
- // increase
- cell++;
-
-
- // set height
- height = ($el.outerHeight() > height) ? $el.outerHeight() : height;
-
-
- // append
- $els = $els.add( $el );
-
-
- // add classes
- if( this_top == 0 ) {
-
- $el.addClass('-r0');
-
- } else if( cell == 0 ) {
-
- $el.addClass('-c0');
-
- }
-
- });
-
-
- // clean up
- if( $els.exists() ) {
-
- $els.css({'min-height': (height+1)+'px'});
-
- }
-
- }
-
- });
-
-
- /*
- * Force revisions
- *
- * description
- *
- * @type function
- * @date 19/02/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- $(document).on('change', '.acf-field input, .acf-field textarea, .acf-field select', function(){
-
- // preview hack
- var $input = $('#_acf_changed');
- if( $input.length ) $input.val(1);
-
-
- // action for 3rd party customization
- acf.do_action('change', $(this));
-
- });
-
-
- /*
- * preventDefault helper
- *
- * This function will prevent default of any link with an href of #
- *
- * @type function
- * @date 24/07/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- $(document).on('click', '.acf-field a[href="#"]', function( e ){
-
- e.preventDefault();
-
- });
-
-
- /*
- * unload
- *
- * This model handles the unload prompt
- *
- * @type function
- * @date 21/02/2014
- * @since 3.5.1
- *
- * @param n/a
- * @return n/a
- */
-
- 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(){
-
- // unlock in 1s to avoid JS 'trigger change' bugs
- setTimeout(function(){
-
- acf.unload.locked = 0;
-
- }, 1000);
-
+ acf.models.Popup = acf.Model.extend({
+
+ data: {
+ title: '',
+ content: '',
+ width: 0,
+ height: 0,
+ loading: false,
},
events: {
- 'submit form': 'off'
+ 'click [data-event="close"]': 'onClickClose',
+ 'click .acf-close-popup': 'onClickClose',
},
- validation_complete: function( json, $form ){
+ setup: function( props ){
+ $.extend(this.data, props);
+ this.$el = $(this.tmpl());
+ },
+
+ initialize: function(){
+ this.render();
+ this.open();
+ },
+
+ tmpl: function(){
+ return [
+ ''
+ ].join('');
+ },
+
+ render: function(){
- if( json && json.errors ) {
-
- this.on();
-
+ // vars
+ var title = this.get('title');
+ var content = this.get('content');
+ var loading = this.get('loading');
+ var width = this.get('width');
+ var height = this.get('height');
+
+ // html
+ this.title( title );
+ this.content( content );
+
+ // width
+ if( width ) {
+ this.$('.acf-popup-box').css('width', width);
}
- // return
- return json;
+ // height
+ if( height ) {
+ this.$('.acf-popup-box').css('min-height', height);
+ }
+ // loading
+ this.loading( loading );
+
+ // action
+ acf.doAction('append', this.$el);
+
},
- on: function(){
-
- // bail ealry if already changed, not active, or still locked
- if( this.changed || !this.active || this.locked ) {
+ update: function( props ){
+ this.data = acf.parseArgs(props, this.data);
+ this.render();
+ },
+
+ title: function( title ){
+ this.$('.title:first h3').html( title );
+ },
+
+ content: function( content ){
+ this.$('.inner:first').html( content );
+ },
+
+ loading: function( show ){
+ var $loading = this.$('.loading:first');
+ show ? $loading.show() : $loading.hide();
+ },
+
+ open: function(){
+ $('body').append( this.$el );
+ },
+
+ close: function(){
+ this.remove();
+ },
+
+ onClickClose: function( e, $el ){
+ e.preventDefault();
+ this.close();
+ }
+
+ });
+
+ /**
+ * newPopup
+ *
+ * Creates a new Popup with the supplied props
+ *
+ * @date 17/12/17
+ * @since 5.6.5
+ *
+ * @param object props
+ * @return object
+ */
+
+ acf.newPopup = function( props ){
+ return new acf.models.Popup( props );
+ };
+
+})(jQuery);
+
+(function($, undefined){
+
+ acf.unload = new acf.Model({
+
+ wait: 'load',
+ active: true,
+ changed: false,
+
+ actions: {
+ 'change_field': 'startListening',
+ 'validation_failure': 'startListening'
+ },
+
+ events: {
+ 'submit form': 'stopListening'
+ },
+ reset: function(){
+ this.stopListening();
+ },
+
+ startListening: function(){
+
+ // bail ealry if already changed, not active
+ if( this.changed || !this.active ) {
return;
-
}
-
// update
- this.changed = 1;
-
+ this.changed = true;
// add event
- $(window).on('beforeunload', this.unload);
+ $(window).on('beforeunload', this.onUnload);
},
- off: function(){
+ stopListening: function(){
// update
- this.changed = 0;
-
+ this.changed = false;
// remove event
- $(window).off('beforeunload', this.unload);
+ $(window).off('beforeunload', this.onUnload);
},
- unload: function(){
-
- // alert string
- return acf._e('unload');
-
+ onUnload: function(){
+ return acf.__('The changes you made will be lost if you navigate away from this page');
}
});
+})(jQuery);
+
+(function($, undefined){
- acf.tooltip = acf.model.extend({
+ var panel = new acf.Model({
events: {
- 'mouseenter .acf-js-tooltip': '_on',
- 'mouseup .acf-js-tooltip': '_off',
- 'mouseleave .acf-js-tooltip': '_off'
+ 'click .acf-panel-title': 'onClick',
},
- tooltip: function( text, $el ){
-
- // vars
- var $tooltip = $('' + text + '
');
-
-
- // append
- $('body').append( $tooltip );
-
-
- // position
- var tolerance = 10;
- target_w = $el.outerWidth(),
- target_h = $el.outerHeight(),
- target_t = $el.offset().top,
- target_l = $el.offset().left,
- tooltip_w = $tooltip.outerWidth(),
- tooltip_h = $tooltip.outerHeight();
-
-
- // calculate top
- var top = target_t - tooltip_h,
- left = target_l + (target_w / 2) - (tooltip_w / 2);
-
-
- // too far left
- if( left < tolerance ) {
-
- $tooltip.addClass('right');
-
- left = target_l + target_w;
- top = target_t + (target_h / 2) - (tooltip_h / 2);
-
-
- // too far right
- } else if( (left + tooltip_w + tolerance) > $(window).width() ) {
-
- $tooltip.addClass('left');
-
- left = target_l - tooltip_w;
- top = target_t + (target_h / 2) - (tooltip_h / 2);
-
-
- // too far top
- } else if( top - $(window).scrollTop() < tolerance ) {
-
- $tooltip.addClass('bottom');
-
- top = target_t + target_h;
-
- } else {
-
- $tooltip.addClass('top');
-
- }
-
-
- // update css
- $tooltip.css({ 'top': top, 'left': left });
-
-
- // return
- return $tooltip;
-
- },
-
- temp: function( text, $el ){
-
- // tooltip
- var $el = this.tooltip( text, $el );
- var time = 0;
-
-
- // wait 250
- time += 250;
-
-
- // add class
- setTimeout(function(){
-
- $el.addClass('acf-fade-up');
-
- }, time);
-
-
- // wait 250
- time += 250;
-
-
- // remove
- setTimeout(function(){
-
- $el.remove();
-
- }, time);
-
- },
-
- confirm: function( $el, callback, text, button_y, button_n ){
-
- // defaults
- text = text || acf._e('are_you_sure');
- button_y = button_y || ''+acf._e('yes')+' ';
- button_n = button_n || ''+acf._e('No')+' ';
-
-
- // vars
- var $tooltip = this.tooltip( text + ' ' + button_y + ' ' + button_n , $el);
-
-
- // add class
- $tooltip.addClass('-confirm');
-
-
- // events
- var event = function( e, result ){
-
- // prevent all listeners
- e.preventDefault();
- e.stopImmediatePropagation();
-
-
- // remove events
- $el.off('click', event_y);
- $tooltip.off('click', '.acf-confirm-y', event_y);
- $tooltip.off('click', '.acf-confirm-n', event_n);
- $('body').off('click', event_n);
-
-
- // remove tooltip
- $tooltip.remove();
-
-
- // callback
- callback.apply(null, [result]);
-
- };
-
- var event_y = function( e ){
- event( e, true );
- };
-
- var event_n = function( e ){
- event( e, false );
- };
-
-
- // add events
- $tooltip.on('click', '.acf-confirm-y', event_y);
- $tooltip.on('click', '.acf-confirm-n', event_n);
- $el.on('click', event_y);
- $('body').on('click', event_n);
-
- },
-
- confirm_remove: function( $el, callback ){
-
- // vars
- text = false; // default
- button_y = ''+acf._e('remove')+' ';
- button_n = ''+acf._e('cancel')+' ';
-
-
- // confirm
- this.confirm( $el, callback, false, button_y, button_n );
-
- },
-
- _on: function( e ){
-
- // vars
- var title = e.$el.attr('title');
-
-
- // bail ealry if no title
- if( !title ) return;
-
-
- // create tooltip
- var $tooltip = this.tooltip( title, e.$el );
-
-
- // store as data
- e.$el.data('acf-tooltip', {
- 'title': title,
- '$el': $tooltip
- });
-
-
- // clear title to avoid default browser tooltip
- e.$el.attr('title', '');
-
- },
-
- _off: function( e ){
-
- // vars
- var tooltip = e.$el.data('acf-tooltip');
-
-
- // bail early if no data
- if( !tooltip ) return;
-
-
- // remove tooltip
- tooltip.$el.remove();
-
-
- // restore title
- e.$el.attr('title', tooltip.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( args ){
-
- // defaults
- args = $.extend({}, {
- id: '',
- key: '',
- style: 'default',
- label: 'top',
- edit_url: '',
- edit_title: '',
- visibility: true
- }, args);
-
-
- // vars
- var $postbox = $('#' + args.id),
- $toggle = $('#' + args.id + '-hide'),
- $label = $toggle.parent();
-
-
-
- // add class
- $postbox.addClass('acf-postbox');
- $label.addClass('acf-postbox-toggle');
-
-
- // remove class
- $postbox.removeClass('hide-if-js');
- $label.removeClass('hide-if-js');
-
-
- // field group style
- if( args.style !== 'default' ) {
-
- $postbox.addClass( args.style );
-
- }
-
-
- // .inside class
- $postbox.children('.inside').addClass('acf-fields').addClass('-' + args.label);
-
-
- // visibility
- if( args.visibility ) {
-
- $toggle.prop('checked', true);
-
- } else {
-
- $postbox.addClass('acf-hidden');
- $label.addClass('acf-hidden');
-
- }
-
-
- // edit_url
- if( args.edit_url ) {
-
- $postbox.children('.hndle').append(' ');
-
- }
-
- }
-
- });
-
-
- /**
- * panel
- *
- * This model handles .acf-panel JS
- *
- * @date 21/10/17
- * @since 5.6.3
- *
- * @param n/a
- * @return n/a
- */
-
- var acf_panel = acf.model.extend({
-
- events: {
- 'click .acf-panel-title': '_click',
- },
-
- _click: function( e ){
-
- // prevent Defailt
+ onClick: function( e, $el ){
e.preventDefault();
-
-
- // open close
- this.toggle( e.$el.parent() );
-
+ this.toggle( $el.parent() );
},
- is_open: function( $el ) {
+ isOpen: function( $el ) {
return $el.hasClass('-open');
},
toggle: function( $el ){
-
- // is open
- if( this.is_open($el) ) {
- this.close( $el );
- } else {
- this.open( $el );
- }
-
+ this.isOpen($el) ? this.close( $el ) : this.open( $el );
},
open: function( $el ){
@@ -3685,653 +3473,6927 @@ var acf;
}
});
-
-
- /**
- * acf_h2_notice
- *
- * This model will move the .acf-notice element quickly without the WP flicker
- *
- * @date 21/10/17
- * @since 5.6.3
- *
- * @param n/a
- * @return n/a
- */
-
- acf.notice = acf.model.extend({
- actions: {
- 'prepare': 'prepare',
+})(jQuery);
+
+(function($, undefined){
+
+ var Notice = acf.Model.extend({
+
+ data: {
+ text: '',
+ type: '',
+ timeout: 0,
+ dismiss: true,
+ target: false,
+ close: function(){}
},
- prepare: function(){
+ events: {
+ 'click .acf-notice-dismiss': 'onClickClose',
+ },
+
+ tmpl: function(){
+ return '
';
+ },
+
+ setup: function( props ){
+ $.extend(this.data, props);
+ this.$el = $(this.tmpl());
+ },
+
+ initialize: function(){
+
+ // render
+ this.render();
+
+ // show
+ this.show();
+ },
+
+ render: function(){
+
+ // class
+ this.type( this.get('type') );
+
+ // text
+ this.html( '' + this.get('text') + '
' );
+
+ // close
+ if( this.get('dismiss') ) {
+ this.$el.append(' ');
+ this.$el.addClass('-dismiss');
+ }
+
+ // timeout
+ var timeout = this.get('timeout');
+ if( timeout ) {
+ this.away( timeout );
+ }
+ },
+
+ update: function( props ){
+
+ // update
+ $.extend(this.data, props);
+
+ // re-initialize
+ this.initialize();
+ },
+
+ show: function(){
+ var $target = this.get('target');
+ if( $target ) {
+ $target.prepend( this.$el );
+ }
+ },
+
+ hide: function(){
+ this.$el.remove();
+ },
+
+ away: function( timeout ){
+ this.setTimeout(function(){
+ acf.remove( this.$el );
+ }, timeout );
+ },
+
+ type: function( type ){
+
+ // remove prev type
+ var prevType = this.get('type');
+ if( prevType ) {
+ this.$el.removeClass('-' + prevType);
+ }
+
+ // add new type
+ this.$el.addClass('-' + type);
+
+ // backwards compatibility
+ if( type == 'error' ) {
+ this.$el.addClass('acf-error-message');
+ }
+ },
+
+ html: function( html ){
+ this.$el.html( html );
+ },
+
+ text: function( text ){
+ this.$('p').html( text );
+ },
+
+ onClickClose: function( e, $el ){
+ e.preventDefault();
+ this.get('close').apply(this, arguments);
+ this.remove();
+ }
+ });
+
+ acf.newNotice = function( props ){
+
+ // ensure object
+ if( typeof props !== 'object' ) {
+ props = { text: props };
+ }
+
+ // instantiate
+ return new Notice( props );
+ };
+
+ var noticeManager = new acf.Model({
+ wait: 'prepare',
+ priority: 1,
+ initialize: function(){
// vars
- var $notice = $('.acf-notice');
+ var $notice = $('.acf-admin-notice');
-
- // move
+ // move to avoid WP flicker
if( $notice.length ) {
$('h1:first').after( $notice );
}
-
- },
-
- html: function( text, type ){
-
- },
-
- success: function( text ){
-
-
- },
-
- error: function( text ){
-
- },
-
- warning: function( text ){
-
- },
-
- information: function( text ){
-
- }
-
+ }
});
- // Preferences
- var preferences = localStorage.getItem('acf');
- preferences = preferences ? JSON.parse(preferences) : {};
-
-
- /**
- * getPreferenceName
- *
- * Gets the true preference name.
- * Converts "this.thing" to "thing-123" if editing post 123.
- *
- * @date 11/11/17
- * @since 5.6.5
- *
- * @param string name
- * @return string
- */
-
- var getPreferenceName = function( name ){
- if( name.substr(0, 5) === 'this.' ) {
- name = name.substr(5) + '-' + acf.get('post_id');
- }
- return name;
- };
-
-
- /**
- * acf.getPreference
- *
- * Gets a preference setting or null if not set.
- *
- * @date 11/11/17
- * @since 5.6.5
- *
- * @param string name
- * @return mixed
- */
-
- acf.getPreference = function( name ){
- name = getPreferenceName( name );
- return preferences[ name ] || null;
- }
-
-
- /**
- * acf.setPreference
- *
- * Sets a preference setting.
- *
- * @date 11/11/17
- * @since 5.6.5
- *
- * @param string name
- * @param mixed value
- * @return n/a
- */
-
- acf.setPreference = function( name, value ){
- name = getPreferenceName( name );
- if( value === null ) {
- delete preferences[ name ];
- } else {
- preferences[ name ] = value;
- }
- localStorage.setItem('acf', JSON.stringify(preferences));
- }
-
-
- /**
- * acf.removePreference
- *
- * Removes a preference setting.
- *
- * @date 11/11/17
- * @since 5.6.5
- *
- * @param string name
- * @return n/a
- */
-
- acf.removePreference = function( name ){
- acf.setPreference(name, null);
- };
-
-
- /**
- * acf.lock
- *
- * Creates a "lock" on an element for a given type and key
- *
- * @date 22/2/18
- * @since 5.6.9
- *
- * @param jQuery $el The element to lock.
- * @param string type The type of lock such as "condition" or "visibility".
- * @param string key The key that will be used to unlock.
- * @return void
- */
-
- var getLocks = function( $el, type ){
- return $el.data('acf-lock-'+type) || [];
- };
-
- var setLocks = function( $el, type, locks ){
- $el.data('acf-lock-'+type, locks);
- }
-
- acf.lock = function( $el, type, key ){
- var locks = getLocks( $el, type );
- var i = locks.indexOf(key);
- if( i < 0 ) {
- locks.push( key );
- setLocks( $el, type, locks );
- }
- };
-
- /**
- * acf.unlock
- *
- * Unlocks a "lock" on an element for a given type and key
- *
- * @date 22/2/18
- * @since 5.6.9
- *
- * @param jQuery $el The element to lock.
- * @param string type The type of lock such as "condition" or "visibility".
- * @param string key The key that will be used to unlock.
- * @return void
- */
-
- acf.unlock = function( $el, type, key ){
- var locks = getLocks( $el, type );
- var i = locks.indexOf(key);
- if( i > -1 ) {
- locks.splice(i, 1);
- setLocks( $el, type, locks );
- }
-
- // return true if is unlocked (no locks)
- return (locks.length === 0);
- };
-
- /**
- * acf.isLocked
- *
- * Returns true if a lock exists for a given type
- *
- * @date 22/2/18
- * @since 5.6.9
- *
- * @param jQuery $el The element to lock.
- * @param string type The type of lock such as "condition" or "visibility".
- * @return void
- */
-
- acf.isLocked = function( $el, type ){
- return ( getLocks( $el, type ).length > 0 );
- };
-
- /**
- * acf.show
- *
- * description
- *
- * @date 9/2/18
- * @since 5.6.5
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- acf.show = function( $el, lockKey ){
-
- // unlock
- if( lockKey ) {
- acf.unlock($el, 'hidden', lockKey);
- }
-
- // bail early if $el is still locked
- if( acf.isLocked($el, 'hidden') ) {
- //console.log( 'still locked', getLocks( $el, 'hidden' ));
- return false;
- }
-
- // $el is hidden, remove class and return true due to change in visibility
- if( $el.hasClass('acf-hidden') ) {
- $el.removeClass('acf-hidden');
- return true;
-
- // $el is visible, return false due to no change in visibility
- } else {
- return false;
- }
- };
-
- /**
- * enable
- *
- * description
- *
- * @date 12/3/18
- * @since 5.6.9
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- var enable = function( $el, lockKey ){
-
- // check class. Allow .acf-disabled to overrule all JS
- if( $el.hasClass('acf-disabled') ) {
- return false;
- }
-
- // unlock
- if( lockKey ) {
- acf.unlock($el, 'disabled', lockKey);
- }
-
- // bail early if $el is still locked
- if( acf.isLocked($el, 'disabled') ) {
- return false;
- }
-
- // $el is disabled, remove prop and return true due to change
- if( $el.prop('disabled') ) {
- $el.prop('disabled', false);
- return true;
-
- // $el is enabled, return false due to no change
- } else {
- return false;
- }
- };
-
- /**
- * acf.enable
- *
- * description
- *
- * @date 9/2/18
- * @since 5.6.5
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- acf.enable = function( $el, lockKey ){
-
- // enable single input
- if( $el.attr('name') ) {
- return enable( $el, lockKey );
- }
-
- // find and enable child inputs
- // return false if 'any' inputs are still disabled
- var results = true;
- $el.find('[name]').each(function(){
- var result = enable( $(this), lockKey );
- if( !result ) {
- results = false;
- }
- });
- return results;
- };
-
-
- /**
- * disable
- *
- * description
- *
- * @date 12/3/18
- * @since 5.6.9
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- var disable = function( $el, lockKey ){
-
- // lock
- if( lockKey ) {
- acf.lock($el, 'disabled', lockKey);
- }
-
- // $el is disabled, return false due to no change
- if( $el.prop('disabled') ) {
- return false;
-
- // $el is enabled, add prop and return true due to change
- } else {
- $el.prop('disabled', true);
- return true;
- }
- };
-
-
- /**
- * acf.disable
- *
- * description
- *
- * @date 9/2/18
- * @since 5.6.5
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- acf.disable = function( $el, lockKey ){
-
- // disable single input
- if( $el.attr('name') ) {
- return disable( $el, lockKey );
- }
-
- // find and enable child inputs
- // return false if 'any' inputs did not change
- var results = true;
- $el.find('[name]').each(function(){
- var result = disable( $(this), lockKey );
- if( !result ) {
- results = false;
- }
- });
- return results;
- };
-
- // compatibility
- acf.enable_el = acf.enable;
- acf.enable_form = acf.enable;
-
- acf.disable_el = acf.disable;
- acf.disable_form = acf.disable;
-
-
- /**
- * acf.hide
- *
- * description
- *
- * @date 9/2/18
- * @since 5.6.5
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- acf.hide = function( $el, lockKey ){
-
- // lock
- if( lockKey ) {
- acf.lock($el, 'hidden', lockKey);
- }
-
- // $el is hidden, return false due to no change in visibility
- if( $el.hasClass('acf-hidden') ) {
- return false;
-
- // $el is visible, add class and return true due to change in visibility
- } else {
- $el.addClass('acf-hidden');
- return true;
- }
- };
-
-
- /**
- * acf.isHidden
- *
- * description
- *
- * @date 9/2/18
- * @since 5.6.5
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- acf.isHidden = function( $el ){
- return $el.hasClass('acf-hidden');
- };
-
-
- /**
- * acf.isVisible
- *
- * description
- *
- * @date 9/2/18
- * @since 5.6.5
- *
- * @param type $var Description. Default.
- * @return type Description.
- */
-
- acf.isVisible = function( $el ){
- return !acf.isHidden( $el );
- };
-
- /*
- * Sortable
- *
- * These functions will hook into the start and stop of a jQuery sortable event and modify the item and placeholder
- *
- * @type function
- * @date 12/11/2013
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- $(document).on('sortstart', function( event, ui ) {
- acf.do_action('sortstart', ui.item, ui.placeholder);
- });
-
- $(document).on('sortstop', function( event, ui ) {
- acf.do_action('sortstop', ui.item, ui.placeholder);
- });
-
- acf.add_action('sortstart', function( $item, $placeholder ){
-
- // if $item is a tr, apply some css to the elements
- if( $item.is('tr') ) {
-
- // temp set as relative to find widths
- $item.css('position', 'relative');
-
-
- // set widths for td children
- $item.children().each(function(){
-
- $(this).width($(this).width());
-
- });
-
-
- // revert position css
- $item.css('position', 'absolute');
-
-
- // add markup to the placeholder
- $placeholder.html(' ');
-
- }
-
- });
-
-
-
- /*
- * before & after duplicate
- *
- * This function will modify the DOM before it is cloned. Primarily fixes a cloning issue with select elements
- *
- * @type function
- * @date 16/05/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- acf.add_action('before_duplicate', function( $orig ){
-
- // add 'selected' class
- $orig.find('select option:selected').addClass('selected');
-
- });
-
- acf.add_action('after_duplicate', function( $orig, $duplicate ){
-
- // set select values
- $duplicate.find('select').each(function(){
-
- // vars
- var $select = $(this);
-
-
- // bail early if is 'Stylized UI'
- //if( $select.data('ui') ) return;
-
-
- // vars
- var val = [];
-
-
- // loop
- $select.find('option.selected').each(function(){
-
- val.push( $(this).val() );
-
- });
-
-
- // set val
- $select.val( val );
-
- });
-
-
- // remove 'selected' class
- $orig.find('select option.selected').removeClass('selected');
- $duplicate.find('select option.selected').removeClass('selected');
-
- });
-
-
-
-/*
- acf.test_rtl = acf.model.extend({
-
- actions: {
- 'ready': 'ready',
- },
-
- ready: function(){
-
- $('html').attr('dir', 'rtl');
-
- }
-
- });
-*/
-
-
-
-/*
-
-
- console.time("acf_test_ready");
- console.time("acf_test_load");
-
- acf.add_action('ready', function(){
-
- console.timeEnd("acf_test_ready");
-
- }, 999);
-
- acf.add_action('load', function(){
-
- console.timeEnd("acf_test_load");
-
- }, 999);
-*/
-
-
- /*
- * indexOf
- *
- * This function will provide compatibility for ie8
- *
- * @type function
- * @date 5/3/17
- * @since 5.5.10
- *
- * @param n/a
- * @return n/a
- */
-
- if( !Array.prototype.indexOf ) {
-
- Array.prototype.indexOf = function(val) {
- return $.inArray(val, this);
- };
-
- }
-
})(jQuery);
-(function($){
+(function($, undefined){
- acf.ajax = acf.model.extend({
+ acf.models.Postbox = acf.Model.extend({
+
+ data: {
+ id: '',
+ key: '',
+ style: 'default',
+ label: 'top',
+ editLink: '',
+ editTitle: '',
+ visibility: true
+ },
+
+ setup: function( props ){
+ $.extend(this.data, props);
+ },
+
+ initialize: function(){
+
+ // vars
+ var id = this.get('id');
+ var $postbox = $('#' + id);
+ var $toggle = $('#' + id + '-hide');
+ var $label = $toggle.parent();
+
+ // add class
+ $postbox.addClass('acf-postbox');
+ $label.addClass('acf-postbox-toggle');
+
+ // remove class
+ $postbox.removeClass('hide-if-js');
+ $label.removeClass('hide-if-js');
+
+ // field group style
+ var style = this.get('style');
+ if( style !== 'default' ) {
+ $postbox.addClass( style );
+ }
+
+ // .inside class
+ $postbox.children('.inside').addClass('acf-fields').addClass('-' + this.get('label'));
+
+
+ // visibility
+ if( this.get('visibility') ) {
+ $toggle.prop('checked', true);
+ } else {
+ $postbox.addClass('acf-hidden');
+ $label.addClass('acf-hidden');
+ }
+
+ // edit link
+ var editLink = this.get('editLink');
+ var editTitle = this.get('editTitle');
+ if( editLink ) {
+
+ $postbox.children('.hndle').append(' ');
+ }
+ }
+ });
+
+ acf.newPostbox = function( props ){
+ return new acf.models.Postbox( props );
+ };
+
+})(jQuery);
+
+(function($, undefined){
+
+ acf.newTooltip = function( props ){
+
+ // ensure object
+ if( typeof props !== 'object' ) {
+ props = { text: props };
+ }
+
+ // confirmRemove
+ if( props.confirmRemove !== undefined ) {
+
+ props.textConfirm = acf.__('Remove');
+ props.textCancel = acf.__('Cancel');
+ return new TooltipConfirm( props );
+
+ // confirm
+ } else if( props.confirm !== undefined ) {
+
+ return new TooltipConfirm( props );
+
+ // default
+ } else {
+ return new Tooltip( props );
+ }
+
+ };
+
+ var Tooltip = acf.Model.extend({
+
+ data: {
+ text: '',
+ timeout: 0,
+ target: null
+ },
+
+ tmpl: function(){
+ return '
';
+ },
+
+ setup: function( props ){
+ $.extend(this.data, props);
+ this.$el = $(this.tmpl());
+ },
+
+ initialize: function(){
+
+ // render
+ this.render();
+
+ // append
+ this.show();
+
+ // position
+ this.position();
+
+ // timeout
+ var timeout = this.get('timeout');
+ if( timeout ) {
+ setTimeout( $.proxy(this.fade, this), timeout );
+ }
+ },
+
+ update: function( props ){
+ $.extend(this.data, props);
+ this.initialize();
+ },
+
+ render: function(){
+ this.html( this.get('text') );
+ },
+
+ show: function(){
+ $('body').append( this.$el );
+ },
+
+ hide: function(){
+ this.$el.remove();
+ },
+
+ fade: function(){
+
+ // add class
+ this.$el.addClass('acf-fade-up');
+
+ // remove
+ this.setTimeout(function(){
+ this.remove();
+ }, 250);
+ },
+
+ html: function( html ){
+ this.$el.html( html );
+ },
+
+ position: function(){
+
+ // vars
+ var $tooltip = this.$el;
+ var $target = this.get('target');
+ if( !$target ) return;
+
+ // reset class
+ $tooltip.removeClass('right left bottom top');
+
+ // position
+ var tolerance = 10;
+ var target_w = $target.outerWidth();
+ var target_h = $target.outerHeight();
+ var target_t = $target.offset().top;
+ var target_l = $target.offset().left;
+ var tooltip_w = $tooltip.outerWidth();
+ var tooltip_h = $tooltip.outerHeight();
+
+ // calculate top
+ var top = target_t - tooltip_h;
+ var left = target_l + (target_w / 2) - (tooltip_w / 2);
+
+ // too far left
+ if( left < tolerance ) {
+
+ $tooltip.addClass('right');
+ left = target_l + target_w;
+ top = target_t + (target_h / 2) - (tooltip_h / 2);
+
+ // too far right
+ } else if( (left + tooltip_w + tolerance) > $(window).width() ) {
+
+ $tooltip.addClass('left');
+ left = target_l - tooltip_w;
+ top = target_t + (target_h / 2) - (tooltip_h / 2);
+
+ // too far top
+ } else if( top - $(window).scrollTop() < tolerance ) {
+
+ $tooltip.addClass('bottom');
+ top = target_t + target_h;
+
+ } else {
+
+ $tooltip.addClass('top');
+
+ }
+
+ // update css
+ $tooltip.css({ 'top': top, 'left': left });
+ }
+ });
+
+ var TooltipConfirm = Tooltip.extend({
+
+ data: {
+ text: '',
+ textConfirm: '',
+ textCancel: '',
+ target: null,
+ targetConfirm: true,
+ confirm: function(){},
+ cancel: function(){},
+ context: false
+ },
+
+ events: {
+ 'click [data-event="cancel"]': 'onCancel',
+ 'click [data-event="confirm"]': 'onConfirm',
+ },
+
+ addEvents: function(){
+
+ // add events
+ acf.Model.prototype.addEvents.apply(this);
+
+ // vars
+ var $document = $(document);
+ var $target = this.get('target');
+
+ // add global 'cancel' click event
+ // - use timeout to avoid the current 'click' event triggering the onCancel function
+ this.setTimeout(function(){
+ this.on( $document, 'click', 'onCancel' );
+ });
+
+ // add target 'confirm' click event
+ // - allow setting to control this feature
+ if( this.get('targetConfirm') ) {
+ this.on( $target, 'click', 'onConfirm' );
+ }
+ },
+
+ removeEvents: function(){
+
+ // remove events
+ acf.Model.prototype.removeEvents.apply(this);
+
+ // vars
+ var $document = $(document);
+ var $target = this.get('target');
+
+ // remove custom events
+ this.off( $document, 'click' );
+ this.off( $target, 'click' );
+ },
+
+ render: function(){
+
+ // defaults
+ var text = this.get('text') || acf.__('Are you sure?');
+ var textConfirm = this.get('textConfirm') || acf.__('Yes');
+ var textCancel = this.get('textCancel') || acf.__('No');
+
+ // html
+ var html = [
+ text,
+ '' + textConfirm + ' ',
+ '' + textCancel + ' '
+ ].join(' ');
+
+ // html
+ this.html( html );
+
+ // class
+ this.$el.addClass('-confirm');
+ },
+
+ onCancel: function( e, $el ){
+
+ // prevent default
+ e.preventDefault();
+ e.stopImmediatePropagation();
+
+ // callback
+ var callback = this.get('cancel');
+ var context = this.get('context') || this;
+ callback.apply( context, arguments );
+
+ //remove
+ this.remove();
+ },
+
+ onConfirm: function( e, $el ){
+
+ // prevent default
+ e.preventDefault();
+ e.stopImmediatePropagation();
+
+ // callback
+ var callback = this.get('confirm');
+ var context = this.get('context') || this;
+ callback.apply( context, arguments );
+
+ //remove
+ this.remove();
+ }
+ });
+
+ // storage
+ acf.models.Tooltip = Tooltip;
+ acf.models.TooltipConfirm = TooltipConfirm;
+
+
+ /**
+ * tooltipManager
+ *
+ * description
+ *
+ * @date 17/4/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var tooltipHoverHelper = new acf.Model({
+
+ tooltip: false,
+
+ events: {
+ 'mouseenter .acf-js-tooltip': 'showTitle',
+ 'mouseup .acf-js-tooltip': 'hideTitle',
+ 'mouseleave .acf-js-tooltip': 'hideTitle'
+ },
+
+ showTitle: function( e, $el ){
+
+ // vars
+ var title = $el.attr('title');
+
+ // bail ealry if no title
+ if( !title ) {
+ return;
+ }
+
+ // clear title to avoid default browser tooltip
+ $el.attr('title', '');
+
+ // create
+ if( !this.tooltip ) {
+ this.tooltip = acf.newTooltip({
+ text: title,
+ target: $el
+ });
+
+ // update
+ } else {
+ this.tooltip.update({
+ text: title,
+ target: $el
+ });
+ }
+
+ },
+
+ hideTitle: function( e, $el ){
+
+ // hide tooltip
+ this.tooltip.hide();
+
+ // restore title
+ $el.attr('title', this.tooltip.get('text'));
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ // vars
+ var storage = [];
+
+ /**
+ * acf.Field
+ *
+ * description
+ *
+ * @date 23/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.Field = acf.Model.extend({
+
+ // field type
+ type: '',
+
+ // class used to avoid nested event triggers
+ eventScope: '.acf-field',
+
+ // initialize events on 'ready'
+ wait: 'ready',
+
+ /**
+ * setup
+ *
+ * Called during the constructor function to setup this field ready for initialization
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param jQuery $field The field element.
+ * @return void
+ */
+
+ setup: function( $field ){
+
+ // set $el
+ this.$el = $field;
+
+ // inherit $field data
+ this.inherit( $field );
+
+ // inherit controll data
+ this.inherit( this.$control() );
+ },
+
+ /**
+ * val
+ *
+ * Sets or returns the field's value
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param mixed val Optional. The value to set
+ * @return mixed
+ */
+
+ val: function( val ){
+ if( val !== undefined ) {
+ return this.setValue( val );
+ } else {
+ return this.prop('disabled') ? null : this.getValue();
+ }
+ },
+
+ /**
+ * getValue
+ *
+ * returns the field's value
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return mixed
+ */
+
+ getValue: function(){
+ return this.$input().val();
+ },
+
+ /**
+ * setValue
+ *
+ * sets the field's value and returns true if changed
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param mixed val
+ * @return boolean. True if changed.
+ */
+
+ setValue: function( val ){
+ return acf.val( this.$input(), val );
+ },
+
+ /**
+ * __
+ *
+ * i18n helper to be removed
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ __: function( string ){
+ return acf._e( this.type, string );
+ },
+
+ /**
+ * $control
+ *
+ * returns the control jQuery element used for inheriting data. Uses this.control setting.
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return jQuery
+ */
+
+ $control: function(){
+ return false;
+ },
+
+ /**
+ * $input
+ *
+ * returns the input jQuery element used for saving values. Uses this.input setting.
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return jQuery
+ */
+
+ $input: function(){
+ return this.$('[name]:first');
+ },
+
+ /**
+ * $inputWrap
+ *
+ * description
+ *
+ * @date 12/5/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ $inputWrap: function(){
+ return this.$('.acf-input:first');
+ },
+
+ /**
+ * $inputWrap
+ *
+ * description
+ *
+ * @date 12/5/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ $labelWrap: function(){
+ return this.$('.acf-label:first');
+ },
+
+ /**
+ * getInputName
+ *
+ * Returns the field's input name
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return string
+ */
+
+ getInputName: function(){
+ return this.$input().attr('name') || '';
+ },
+
+ /**
+ * parent
+ *
+ * returns the field's parent field or false on failure.
+ *
+ * @date 8/5/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return object|false
+ */
+
+ parent: function() {
+
+ // vars
+ var parents = this.parents();
+
+ // return
+ return parents.length ? parents[0] : false;
+ },
+
+ /**
+ * parents
+ *
+ * description
+ *
+ * @date 9/7/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ parents: function(){
+
+ // vars
+ var $parents = this.$el.parents('.acf-field');
+
+ // convert
+ var parents = acf.getFields( $parents );
+
+ // return
+ return parents;
+ },
+
+ show: function( lockKey, context ){
+
+ // show field and store result
+ var changed = acf.show( this.$el, lockKey );
+
+ // do action if visibility has changed
+ if( changed ) {
+ this.prop('hidden', false);
+ acf.doAction('show_field', this, context);
+ }
+
+ // return
+ return changed;
+ },
+
+ hide: function( lockKey, context ){
+
+ // hide field and store result
+ var changed = acf.hide( this.$el, lockKey );
+
+ // do action if visibility has changed
+ if( changed ) {
+ this.prop('hidden', true);
+ acf.doAction('hide_field', this, context);
+ }
+
+ // return
+ return changed;
+ },
+
+ enable: function( lockKey, context ){
+
+ // enable field and store result
+ var changed = acf.enable( this.$el, lockKey );
+
+ // do action if disabled has changed
+ if( changed ) {
+ this.prop('disabled', false);
+ acf.doAction('enable_field', this, context);
+ }
+
+ // return
+ return changed;
+ },
+
+ disable: function( lockKey, context ){
+
+ // disabled field and store result
+ var changed = acf.disable( this.$el, lockKey );
+
+ // do action if disabled has changed
+ if( changed ) {
+ this.prop('disabled', true);
+ acf.doAction('disable_field', this, context);
+ }
+
+ // return
+ return changed;
+ },
+
+ showEnable: function( lockKey, context ){
+
+ // enable
+ this.enable.apply(this, arguments);
+
+ // show and return true if changed
+ return this.show.apply(this, arguments);
+ },
+
+ hideDisable: function( lockKey, context ){
+
+ // disable
+ this.disable.apply(this, arguments);
+
+ // hide and return true if changed
+ return this.hide.apply(this, arguments);
+ },
+
+ showNotice: function( props ){
+
+ // ensure object
+ if( typeof props !== 'object' ) {
+ props = { text: props };
+ }
+
+ // remove old notice
+ if( this.notice ) {
+ this.notice.remove();
+ }
+
+ // create new notice
+ props.target = this.$inputWrap();
+ this.notice = acf.newNotice( props );
+ },
+
+ removeNotice: function( timeout ){
+ if( this.notice ) {
+ this.notice.away( timeout || 0 );
+ this.notice = false;
+ }
+ },
+
+ showError: function( message ){
+
+ // add class
+ this.$el.addClass('acf-error');
+
+ // add message
+ if( message !== undefined ) {
+ this.showNotice({
+ text: message,
+ type: 'error',
+ dismiss: false
+ });
+ }
+
+ // action
+ acf.doAction('invalid_field', this);
+
+ // add event
+ this.$el.one('focus change', 'input, select, textarea', $.proxy( this.removeError, this ));
+ },
+
+ removeError: function(){
+
+ // remove class
+ this.$el.removeClass('acf-error');
+
+ // remove notice
+ this.removeNotice( 250 );
+
+ // action
+ acf.doAction('valid_field', this);
+ },
+
+ trigger: function( name, args, bubbles ){
+
+ // allow some events to bubble
+ if( name == 'invalidField' ) {
+ bubbles = true;
+ }
+
+ // return
+ return acf.Model.prototype.trigger.apply(this, [name, args, bubbles]);
+ },
+ });
+
+ /**
+ * newField
+ *
+ * description
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.newField = function( $field ){
+
+ // vars
+ var type = $field.data('type');
+ var mid = modelId( type );
+ var model = acf.models[ mid ] || acf.Field;
+
+ // instantiate
+ var field = new model( $field );
+
+ // actions
+ acf.doAction('new_field', field);
+
+ // return
+ return field;
+ };
+
+ /**
+ * mid
+ *
+ * Calculates the model ID for a field type
+ *
+ * @date 15/12/17
+ * @since 5.6.5
+ *
+ * @param string type
+ * @return string
+ */
+
+ var modelId = function( type ) {
+ return acf.strPascalCase( type || '' ) + 'Field';
+ };
+
+ /**
+ * registerFieldType
+ *
+ * description
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.registerFieldType = function( model ){
+
+ // vars
+ var proto = model.prototype;
+ var type = proto.type;
+ var mid = modelId( type );
+
+ // store model
+ acf.models[ mid ] = model;
+
+ // store reference
+ storage.push( type );
+ };
+
+ /**
+ * acf.getFieldType
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getFieldType = function( type ){
+ var mid = modelId( type );
+ return acf.models[ mid ] || false;
+ }
+
+ /**
+ * acf.getFieldTypes
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getFieldTypes = function( args ){
+
+ // defaults
+ args = acf.parseArgs(args, {
+ category: '',
+ // hasValue: true
+ });
+
+ // clonse available types
+ var types = [];
+
+ // loop
+ storage.map(function( type ){
+
+ // vars
+ var model = acf.getFieldType(type);
+ var proto = model.prototype;
+
+ // check operator
+ if( args.category && proto.category !== args.category ) {
+ return;
+ }
+
+ // append
+ types.push( model );
+ });
+
+ // return
+ return types;
+ };
+
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * findFields
+ *
+ * Returns a jQuery selection object of acf fields.
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param object $args {
+ * Optional. Arguments to find fields.
+ *
+ * @type string key The field's key (data-attribute).
+ * @type string name The field's name (data-attribute).
+ * @type string type The field's type (data-attribute).
+ * @type string is jQuery selector to compare against.
+ * @type jQuery parent jQuery element to search within.
+ * @type jQuery sibling jQuery element to search alongside.
+ * @type limit int The number of fields to find.
+ * @type suppressFilters bool Whether to allow filters to add/remove results. Default behaviour will ignore clone fields.
+ * }
+ * @return jQuery
+ */
+
+ acf.findFields = function( args ){
+
+ // vars
+ var selector = '.acf-field';
+ var $fields = false;
+
+ // args
+ args = acf.parseArgs(args, {
+ key: '',
+ name: '',
+ type: '',
+ is: '',
+ parent: false,
+ sibling: false,
+ limit: false,
+ visible: false,
+ suppressFilters: false,
+ });
+
+ // filter args
+ if( !args.suppressFilters ) {
+ args = acf.applyFilters('find_fields_args', args);
+ }
+
+ // key
+ if( args.key ) {
+ selector += '[data-key="' + args.key + '"]';
+ }
+
+ // type
+ if( args.type ) {
+ selector += '[data-type="' + args.type + '"]';
+ }
+
+ // name
+ if( args.name ) {
+ selector += '[data-name="' + args.name + '"]';
+ }
+
+ // is
+ if( args.is ) {
+ selector += args.is;
+ }
+
+ // visibility
+ if( args.visible ) {
+ selector += ':visible';
+ }
+
+ // query
+ if( args.parent ) {
+ $fields = args.parent.find( selector );
+ } else if( args.sibling ) {
+ $fields = args.sibling.siblings( selector );
+ } else {
+ $fields = $( selector );
+ }
+
+ // filter
+ if( !args.suppressFilters ) {
+ $fields = $fields.not('.acf-clone .acf-field');
+ $fields = acf.applyFilters('find_fields', $fields);
+ }
+
+ // limit
+ if( args.limit ) {
+ $fields = $fields.slice( 0, args.limit );
+ }
+
+ // return
+ return $fields;
+
+ };
+
+ /**
+ * findField
+ *
+ * Finds a specific field with jQuery
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param string key The field's key.
+ * @param jQuery $parent jQuery element to search within.
+ * @return jQuery
+ */
+
+ acf.findField = function( key, $parent ){
+ return acf.findFields({
+ key: key,
+ limit: 1,
+ parent: $parent,
+ suppressFilters: true
+ });
+ };
+
+ /**
+ * getField
+ *
+ * Returns a field instance
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param jQuery|string $field jQuery element or field key.
+ * @return object
+ */
+
+ acf.getField = function( $field ){
+
+ // allow jQuery
+ if( $field instanceof jQuery ) {
+
+ // find fields
+ } else {
+ $field = acf.findField( $field );
+ }
+
+ // instantiate
+ var field = $field.data('acf');
+ if( !field ) {
+ field = acf.newField( $field );
+ }
+
+ // return
+ return field;
+ };
+
+ /**
+ * getFields
+ *
+ * Returns multiple field instances
+ *
+ * @date 14/12/17
+ * @since 5.6.5
+ *
+ * @param jQuery|object $fields jQuery elements or query args.
+ * @return array
+ */
+
+ acf.getFields = function( $fields ){
+
+ // allow jQuery
+ if( $fields instanceof jQuery ) {
+
+ // find fields
+ } else {
+ $fields = acf.findFields( $fields );
+ }
+
+ // loop
+ var fields = [];
+ $fields.each(function(){
+ var field = acf.getField( $(this) );
+ fields.push( field );
+ });
+
+ // return
+ return fields;
+ };
+
+ /**
+ * findClosestField
+ *
+ * Returns the closest jQuery field element
+ *
+ * @date 9/4/18
+ * @since 5.6.9
+ *
+ * @param jQuery $el
+ * @return jQuery
+ */
+
+ acf.findClosestField = function( $el ){
+ return $el.closest('.acf-field');
+ };
+
+ /**
+ * getClosestField
+ *
+ * Returns the closest field instance
+ *
+ * @date 22/1/18
+ * @since 5.6.5
+ *
+ * @param jQuery $el
+ * @return object
+ */
+
+ acf.getClosestField = function( $el ){
+ var $field = acf.findClosestField( $el );
+ return this.getField( $field );
+ };
+
+ /**
+ * addGlobalFieldAction
+ *
+ * Sets up callback logic for global field actions
+ *
+ * @date 15/6/18
+ * @since 5.6.9
+ *
+ * @param string action
+ * @return void
+ */
+
+ var addGlobalFieldAction = function( action ){
+
+ // vars
+ var globalAction = action;
+ var pluralAction = action + '_fields'; // ready_fields
+ var singleAction = action + '_field'; // ready_field
+
+ // global action
+ var globalCallback = function( $el /*, arg1, arg2, etc*/ ){
+ //console.log( action, arguments );
+
+ // get args [$el, ...]
+ var args = acf.arrayArgs( arguments );
+ var extraArgs = args.slice(1);
+
+ // find fields
+ var fields = acf.getFields({ parent: $el });
+
+ // check
+ if( fields.length ) {
+
+ // pluralAction
+ var pluralArgs = [ pluralAction, fields ].concat( extraArgs );
+ acf.doAction.apply(null, pluralArgs);
+ }
+ };
+
+ // plural action
+ var pluralCallback = function( fields /*, arg1, arg2, etc*/ ){
+ //console.log( pluralAction, arguments );
+
+ // get args [fields, ...]
+ var args = acf.arrayArgs( arguments );
+ var extraArgs = args.slice(1);
+
+ // loop
+ fields.map(function( field, i ){
+ //setTimeout(function(){
+ // singleAction
+ var singleArgs = [ singleAction, field ].concat( extraArgs );
+ acf.doAction.apply(null, singleArgs);
+ //}, i * 100);
+ });
+ };
+
+ // add actions
+ acf.addAction(globalAction, globalCallback);
+ acf.addAction(pluralAction, pluralCallback);
+
+ // also add single action
+ addSingleFieldAction( action );
+ }
+
+ /**
+ * addSingleFieldAction
+ *
+ * Sets up callback logic for single field actions
+ *
+ * @date 15/6/18
+ * @since 5.6.9
+ *
+ * @param string action
+ * @return void
+ */
+
+ var addSingleFieldAction = function( action ){
+
+ // vars
+ var singleAction = action + '_field'; // ready_field
+ var singleEvent = action + 'Field'; // readyField
+
+ // single action
+ var singleCallback = function( field /*, arg1, arg2, etc*/ ){
+ //console.log( singleAction, arguments );
+
+ // get args [field, ...]
+ var args = acf.arrayArgs( arguments );
+ var extraArgs = args.slice(1);
+
+ // action variations (ready_field/type=image)
+ var variations = ['type', 'name', 'key'];
+ variations.map(function( variation ){
+
+ // vars
+ var prefix = '/' + variation + '=' + field.get(variation);
+
+ // singleAction
+ args = [ singleAction + prefix , field ].concat( extraArgs );
+ acf.doAction.apply(null, args);
+ });
+
+ // event
+ if( singleFieldEvents.indexOf(action) > -1 ) {
+ field.trigger(singleEvent, extraArgs);
+ }
+ };
+
+ // add actions
+ acf.addAction(singleAction, singleCallback);
+ }
+
+ // vars
+ var globalFieldActions = [ 'prepare', 'ready', 'load', 'append', 'remove', 'sortstart', 'sortstop', 'show', 'hide', 'unload' ];
+ var singleFieldActions = [ 'valid', 'invalid', 'enable', 'disable', 'new' ];
+ var singleFieldEvents = [ 'remove', 'sortstart', 'sortstop', 'show', 'hide', 'unload', 'valid', 'invalid', 'enable', 'disable' ];
+
+ // add
+ globalFieldActions.map( addGlobalFieldAction );
+ singleFieldActions.map( addSingleFieldAction );
+
+ /**
+ * fieldsEventManager
+ *
+ * Manages field actions and events
+ *
+ * @date 15/12/17
+ * @since 5.6.5
+ *
+ * @param void
+ * @param void
+ */
+
+ var fieldsEventManager = new acf.Model({
+ id: 'fieldsEventManager',
+ events: {
+ 'click .acf-field a[href="#"]': 'onClick'
+ },
+ onClick: function( e ){
+ e.preventDefault();
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ var i = 0;
+
+ var Field = acf.Field.extend({
+
+ type: 'accordion',
+
+ wait: '',
+
+ $control: function(){
+ return this.$('.acf-fields:first');
+ },
+
+ initialize: function(){
+
+ // bail early if is cell
+ if( this.$el.is('td') ) return;
+
+ // enpoint
+ if( this.get('endpoint') ) {
+ return this.remove();
+ }
+
+ // vars
+ var $field = this.$el;
+ var $label = this.$labelWrap()
+ var $input = this.$inputWrap();
+ var $wrap = this.$control();
+ var $instructions = $input.children('.description');
+
+ // force description into label
+ if( $instructions.length ) {
+ $label.append( $instructions );
+ }
+
+ // table
+ if( this.$el.is('tr') ) {
+
+ // vars
+ var $table = this.$el.closest('table');
+ var $newLabel = $('
');
+ var $newInput = $('
');
+ var $newTable = $('');
+ var $newWrap = $(' ');
+
+ // dom
+ $newLabel.append( $label.html() );
+ $newTable.append( $newWrap );
+ $newInput.append( $newTable );
+ $input.append( $newLabel );
+ $input.append( $newInput );
+
+ // modify
+ $label.remove();
+ $wrap.remove();
+ $input.attr('colspan', 2);
+
+ // update vars
+ $label = $newLabel;
+ $input = $newInput;
+ $wrap = $newWrap;
+ }
+
+ // add classes
+ $field.addClass('acf-accordion');
+ $label.addClass('acf-accordion-title');
+ $input.addClass('acf-accordion-content');
+
+ // index
+ i++;
+
+ // multi-expand
+ if( this.get('multi_expand') ) {
+ $field.attr('multi-expand', 1);
+ }
+
+ // open
+ var order = acf.getPreference('this.accordions') || [];
+ if( order[i-1] !== undefined ) {
+ this.set('open', order[i-1]);
+ }
+
+ if( this.get('open') ) {
+ $field.addClass('-open');
+ $input.css('display', 'block'); // needed for accordion to close smoothly
+ }
+
+ // add icon
+ $label.prepend(' ');
+
+ // classes
+ // - remove 'inside' which is a #poststuff WP class
+ var $parent = $field.parent();
+ $wrap.addClass( $parent.hasClass('-left') ? '-left' : '' );
+ $wrap.addClass( $parent.hasClass('-clear') ? '-clear' : '' );
+
+ // append
+ $wrap.append( $field.nextUntil('.acf-field-accordion', '.acf-field') );
+
+ // clean up
+ $wrap.removeAttr('data-open data-multi_expand data-endpoint');
+ },
+
+ });
+
+ acf.registerFieldType( Field );
+
+
+ /**
+ * accordionManager
+ *
+ * Events manager for the acf accordion
+ *
+ * @date 14/2/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return void
+ */
+
+ var accordionManager = new acf.Model({
+
+ actions: {
+ 'unload': 'onUnload'
+ },
+
+ events: {
+ 'click .acf-accordion-title': 'onClick',
+ 'invalidField .acf-accordion': 'onInvalidField'
+ },
+
+ isOpen: function( $el ) {
+ return $el.hasClass('-open');
+ },
+
+ toggle: function( $el ){
+ if( this.isOpen($el) ) {
+ this.close( $el );
+ } else {
+ this.open( $el );
+ }
+ },
+
+ open: function( $el ){
+
+ // open
+ $el.find('.acf-accordion-content:first').slideDown().css('display', 'block');
+ $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-right').addClass('dashicons-arrow-down');
+ $el.addClass('-open');
+
+ // action
+ acf.doAction('show', $el);
+
+ // close siblings
+ if( !$el.attr('multi-expand') ) {
+ $el.siblings('.acf-accordion.-open').each(function(){
+ accordionManager.close( $(this) );
+ });
+ }
+ },
+
+ close: function( $el ){
+
+ // close
+ $el.find('.acf-accordion-content:first').slideUp();
+ $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-down').addClass('dashicons-arrow-right');
+ $el.removeClass('-open');
+
+ // action
+ acf.doAction('hide', $el);
+ },
+
+ onClick: function( e, $el ){
+
+ // prevent Defailt
+ e.preventDefault();
+
+ // open close
+ this.toggle( $el.parent() );
+
+ },
+
+ onInvalidField: function( e, $el ){
+
+ // bail early if already focused
+ if( this.busy ) {
+ return;
+ }
+
+ // disable functionality for 1sec (allow next validation to work)
+ this.busy = true;
+ this.setTimeout(function(){
+ this.busy = false;
+ }, 1000);
+
+ // open accordion
+ this.open( $el );
+ },
+
+ onUnload: function( e ){
+
+ // vars
+ var order = [];
+
+ // loop
+ $('.acf-accordion').each(function(){
+ var open = $(this).hasClass('-open') ? 1 : 0;
+ order.push(open);
+ });
+
+ // set
+ if( order.length ) {
+ acf.setPreference('this.accordions', order);
+ }
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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( val ){
+ this.$('input[value="' + val + '"]').prop('checked', true).trigger('change');
+ },
+
+ onClick: function( e, $el ){
+
+ // vars
+ var $label = $el.parent('label');
+ var selected = $label.hasClass('selected');
+
+ // remove previous selected
+ this.$('.selected').removeClass('selected');
+
+ // add active class
+ $label.addClass('selected');
+
+ // allow null
+ if( this.get('allow_null') && selected ) {
+ $label.removeClass('selected');
+ $el.prop('checked', false).trigger('change');
+ }
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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 val = [];
+ this.$(':checked').each(function(){
+ val.push( $(this).val() );
+ });
+ return val.length ? val : false;
+ },
+
+ onChange: function( e, $el ){
+
+ // vars
+ var checked = $el.prop('checked');
+ var $toggle = this.$toggle();
+
+ // selected
+ if( checked ) {
+ $el.parent().addClass('selected');
+ } else {
+ $el.parent().removeClass('selected');
+ }
+
+ // determine if all inputs are checked
+ if( $toggle.length ) {
+ var $inputs = this.$inputs();
+
+ // all checked
+ if( $inputs.not(':checked').length == 0 ) {
+ $toggle.prop('checked', true);
+ } else {
+ $toggle.prop('checked', false);
+ }
+ }
+ },
+
+ onClickAdd: function( e, $el ){
+ var html = ' ';
+ $el.parent('li').before( html );
+ },
+
+ onClickToggle: function( e, $el ){
+ var checked = $el.prop('checked');
+ var $inputs = this.$inputs();
+ $inputs.prop('checked', checked);
+ },
+
+ onClickCustom: function( e, $el ){
+ var checked = $el.prop('checked');
+ var $text = $el.next('input[type="text"]');
+
+ // checked
+ if( checked ) {
+ $text.prop('disabled', false);
+
+ // not checked
+ } else {
+ $text.prop('disabled', true);
+
+ // remove
+ if( $text.val() == '' ) {
+ $el.parent('li').remove();
+ }
+ }
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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(){
+
+ // vars
+ var $input = this.$input();
+ var $inputText = this.$inputText();
+
+ // event
+ var onChange = function( e ){
+
+ // timeout is required to ensure the $input val is correct
+ setTimeout(function(){
+ acf.val( $input, $inputText.val() );
+ }, 1);
+ }
+
+ // args
+ var args = {
+ defaultColor: false,
+ palettes: true,
+ hide: true,
+ change: onChange,
+ clear: onChange
+ };
+
+ // filter
+ var args = acf.applyFilters('color_picker_args', args, this);
+
+ // initialize
+ $inputText.wpColorPicker( args );
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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(){
+
+ // save_format: compatibility with ACF < 5.0.0
+ if( this.has('save_format') ) {
+ return this.initializeCompatibility();
+ }
+
+ // vars
+ var $input = this.$input();
+ var $inputText = this.$inputText();
+
+ // args
+ var args = {
+ dateFormat: this.get('date_format'),
+ altField: $input,
+ altFormat: 'yymmdd',
+ changeYear: true,
+ yearRange: "-100:+100",
+ changeMonth: true,
+ showButtonPanel: true,
+ firstDay: this.get('first_day')
+ };
+
+ // filter
+ args = acf.applyFilters('date_picker_args', args, this);
+
+ // add date picker
+ acf.newDatePicker( $inputText, args );
+
+ // action
+ acf.doAction('date_picker_init', $inputText, args, this);
+
+ },
+
+ initializeCompatibility: function(){
+
+ // vars
+ var $input = this.$input();
+ var $inputText = this.$inputText();
+
+ // get and set value from alt field
+ $inputText.val( $input.val() );
+
+ // args
+ var args = {
+ dateFormat: this.get('date_format'),
+ altField: $input,
+ altFormat: this.get('save_format'),
+ changeYear: true,
+ yearRange: "-100:+100",
+ changeMonth: true,
+ showButtonPanel: true,
+ firstDay: this.get('first_day')
+ };
+
+ // filter for 3rd party customization
+ args = acf.applyFilters('date_picker_args', args, this);
+
+ // backup
+ var dateFormat = args.dateFormat;
+
+ // change args.dateFormat
+ args.dateFormat = this.get('save_format');
+
+ // add date picker
+ acf.newDatePicker( $inputText, args );
+
+ // now change the format back to how it should be.
+ $inputText.datepicker( 'option', 'dateFormat', dateFormat );
+
+ // action for 3rd party customization
+ acf.doAction('date_picker_init', $inputText, args, this);
+ },
+
+ onBlur: function(){
+ if( !this.$inputText().val() ) {
+ acf.val( this.$input(), '' );
+ }
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+
+ // manager
+ var datePickerManager = new acf.Model({
+ priority: 5,
+ wait: 'ready',
+ initialize: function(){
+
+ // vars
+ var locale = acf.get('locale');
+ var rtl = acf.get('rtl');
+ var l10n = acf.get('datePickerL10n');
+
+ // bail ealry if no l10n
+ if( !l10n ) {
+ return false;
+ }
+
+ // bail ealry if no datepicker library
+ if( typeof $.datepicker === 'undefined' ) {
+ return false;
+ }
+
+ // rtl
+ l10n.isRTL = rtl;
+
+ // append
+ $.datepicker.regional[ locale ] = l10n;
+ $.datepicker.setDefaults(l10n);
+ }
+ });
+
+ // add
+ acf.newDatePicker = function( $input, args ){
+
+ // bail ealry if no datepicker library
+ if( typeof $.datepicker === 'undefined' ) {
+ return false;
+ }
+
+ // defaults
+ args = args || {};
+
+ // initialize
+ $input.datepicker( args );
+
+ // wrap the datepicker (only if it hasn't already been wrapped)
+ if( $('body > #ui-datepicker-div').exists() ) {
+ $('body > #ui-datepicker-div').wrap('
');
+ }
+ };
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.models.DatePickerField.extend({
+
+ type: 'date_time_picker',
+
+ $control: function(){
+ return this.$('.acf-date-time-picker');
+ },
+
+ initialize: function(){
+
+ // vars
+ var $input = this.$input();
+ var $inputText = this.$inputText();
+
+ // args
+ var args = {
+ dateFormat: this.get('date_format'),
+ timeFormat: this.get('time_format'),
+ altField: $input,
+ altFieldTimeOnly: false,
+ altFormat: 'yy-mm-dd',
+ altTimeFormat: 'HH:mm:ss',
+ changeYear: true,
+ yearRange: "-100:+100",
+ changeMonth: true,
+ showButtonPanel: true,
+ firstDay: this.get('first_day'),
+ controlType: 'select',
+ oneLine: true
+ };
+
+ // filter
+ args = acf.applyFilters('date_time_picker_args', args, this);
+
+ // add date time picker
+ acf.newDateTimePicker( $inputText, args );
+
+ // action
+ acf.doAction('date_time_picker_init', $inputText, args, this);
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+
+ // manager
+ var dateTimePickerManager = new acf.Model({
+ priority: 5,
+ wait: 'ready',
+ initialize: function(){
+
+ // vars
+ var locale = acf.get('locale');
+ var rtl = acf.get('rtl');
+ var l10n = acf.get('dateTimePickerL10n');
+
+ // bail ealry if no l10n
+ if( !l10n ) {
+ return false;
+ }
+
+ // bail ealry if no datepicker library
+ if( typeof $.timepicker === 'undefined' ) {
+ return false;
+ }
+
+ // rtl
+ l10n.isRTL = rtl;
+
+ // append
+ $.timepicker.regional[ locale ] = l10n;
+ $.timepicker.setDefaults(l10n);
+ }
+ });
+
+
+ // add
+ acf.newDateTimePicker = function( $input, args ){
+
+ // bail ealry if no datepicker library
+ if( typeof $.timepicker === 'undefined' ) {
+ return false;
+ }
+
+ // defaults
+ args = args || {};
+
+ // initialize
+ $input.datetimepicker( args );
+
+ // wrap the datepicker (only if it hasn't already been wrapped)
+ if( $('body > #ui-datepicker-div').exists() ) {
+ $('body > #ui-datepicker-div').wrap('
');
+ }
+ };
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.Field.extend({
+
+ type: 'google_map',
+
+ map: false,
+
+ 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( name ){
+ return this.$('input[data-name="' + (name || 'address') + '"]');
+ },
+
+ $search: function(){
+ return this.$('.search');
+ },
+
+ addClass: function( name ){
+ this.$control().addClass( name );
+ },
+
+ removeClass: function( name ){
+ this.$control().removeClass( name );
+ },
+
+ getValue: function(){
+
+ // defaults
+ var val = {
+ lat: '',
+ lng: '',
+ address: ''
+ };
+
+ // loop
+ this.$('input[type="hidden"]').each(function(){
+ val[ $(this).data('name') ] = $(this).val();
+ });
+
+ // return false if no address
+ if( !val.address ) {
+ val = false;
+ }
+
+ // return
+ return val;
+ },
+
+ setValue: function( val ){
+
+ // defaults
+ val = acf.parseArgs(val, {
+ lat: '',
+ lng: '',
+ address: ''
+ });
+
+ // loop
+ for( var name in val ) {
+ acf.val( this.$input(name), val[name] );
+ }
+
+ // return false if no address
+ if( !val.address ) {
+ val = false;
+ }
+
+ // render
+ this.renderVal( val );
+ },
+
+ renderVal: function( val ){
+
+ // has value
+ if( val ) {
+ this.addClass('-value');
+ this.setPosition( val.lat, val.lng );
+ this.map.marker.setVisible( true );
+
+ // no value
+ } else {
+ this.removeClass('-value');
+ this.map.marker.setVisible( false );
+ }
+
+ // search
+ this.$search().val( val.address );
+ },
+
+ setPosition: function( lat, lng ){
+
+ // vars
+ var latLng = this.newLatLng( lat, lng );
+
+ // update marker
+ this.map.marker.setPosition( latLng );
+
+ // show marker
+ this.map.marker.setVisible( true );
+
+ // action
+ acf.doAction('google_map_change', latLng, this.map, this);
+
+ // center
+ this.center();
+
+ // return
+ return this;
+ },
+
+ center: function(){
+
+ // vars
+ var position = this.map.marker.getPosition();
+ var lat = this.get('lat');
+ var lng = this.get('lng');
+
+ // if marker exists, center on the marker
+ if( position ) {
+ lat = position.lat();
+ lng = position.lng();
+ }
+
+ // latlng
+ var latLng = this.newLatLng( lat, lng );
+
+ // set center of map
+ this.map.setCenter( latLng );
+ },
+
+ getSearchVal: function(){
+ return this.$search().val();
+ },
+
+ getCanvas: function(){
+ return this.$('.canvas');
+ },
+
+ initialize: function(){
+
+ // bail early if too early
+ if( !api.isReady() ) {
+ api.ready( this.initializeMap, this );
+ return;
+ }
+
+ // initializeMap
+ this.initializeMap();
+ },
+
+ newLatLng: function( lat, lng ){
+ return new google.maps.LatLng( parseFloat(lat), parseFloat(lng) );
+ },
+
+ initializeMap: function(){
+
+ // vars
+ var zoom = this.get('zoom');
+ var lat = this.get('lat');
+ var lng = this.get('lng');
+
+
+ // map
+ var mapArgs = {
+ scrollwheel: false,
+ zoom: parseInt( zoom ),
+ center: this.newLatLng(lat, lng),
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
+ marker: {
+ draggable: true,
+ raiseOnDrag: true
+ },
+ autocomplete: {}
+ };
+ mapArgs = acf.applyFilters('google_map_args', mapArgs, this);
+ var map = new google.maps.Map( this.getCanvas()[0], mapArgs );
+ this.addMapEvents( map, this );
+
+
+ // marker
+ var markerArgs = acf.parseArgs(mapArgs.marker, {
+ draggable: true,
+ raiseOnDrag: true,
+ map: map
+ });
+ markerArgs = acf.applyFilters('google_map_marker_args', markerArgs, this);
+ var marker = new google.maps.Marker( markerArgs );
+ this.addMarkerEvents( marker, this );
+
+
+ // reference
+ map.acf = this;
+ map.marker = marker;
+ this.map = map;
+
+ // action for 3rd party customization
+ acf.doAction('google_map_init', map, marker, this);
+
+ // set position
+ var val = this.getValue();
+ this.renderVal( val );
+ },
+
+ addMapEvents: function( map, field ){
+
+ // autocomplete
+ if( acf.isset(window, 'google', 'maps', 'places', 'Autocomplete') ) {
+
+ // vars
+ var autocompleteArgs = map.autocomplete || {};
+ var autocomplete = new google.maps.places.Autocomplete( this.$search()[0], autocompleteArgs );
+
+ // bind
+ autocomplete.bindTo('bounds', map);
+
+ // event
+ google.maps.event.addListener(autocomplete, 'place_changed', function() {
+ field.setPlace( this.getPlace() );
+ });
+ }
+
+ // click
+ google.maps.event.addListener( map, 'click', function( e ) {
+
+ // vars
+ var lat = e.latLng.lat();
+ var lng = e.latLng.lng();
+
+ // search
+ field.searchPosition( lat, lng );
+ });
+ },
+
+ addMarkerEvents: function( marker, field ){
+
+ // dragend
+ google.maps.event.addListener( marker, 'dragend', function(){
+
+ // vars
+ var position = this.getPosition();
+ var lat = position.lat();
+ var lng = position.lng();
+
+ // search
+ field.searchPosition( lat, lng );
+ });
+ },
+
+ searchPosition: function( lat, lng ){
+
+ // vars
+ var latLng = this.newLatLng( lat, lng );
+ var $wrap = this.$control();
+
+ // set position
+ this.setPosition( lat, lng );
+
+ // add class
+ $wrap.addClass('-loading');
+
+ // callback
+ var callback = $.proxy(function( results, status ){
+
+ // remove class
+ $wrap.removeClass('-loading');
+
+ // vars
+ var address = '';
+
+ // validate
+ if( status != google.maps.GeocoderStatus.OK ) {
+ console.log('Geocoder failed due to: ' + status);
+ } else if( !results[0] ) {
+ console.log('No results found');
+ } else {
+ address = results[0].formatted_address;
+ }
+
+ // update val
+ this.val({
+ lat: lat,
+ lng: lng,
+ address: address
+ });
+
+ }, this);
+
+ // query
+ api.geocoder.geocode({ 'latLng' : latLng }, callback);
+ },
+
+ setPlace: function( place ){
+
+ // bail if no place
+ if( !place ) return this;
+
+ // search name if no geometry
+ // - possible when hitting enter in search address
+ if( place.name && !place.geometry ) {
+ this.searchAddress(place.name);
+ return this;
+ }
+
+ // vars
+ var lat = place.geometry.location.lat();
+ var lng = place.geometry.location.lng();
+ var address = place.formatted_address;
+
+ // update
+ this.setValue({
+ lat: lat,
+ lng: lng,
+ address: address
+ });
+
+ // return
+ return this;
+ },
+
+ searchAddress: function( address ){
+
+ // is address latLng?
+ var latLng = address.split(',');
+ if( latLng.length == 2 ) {
+
+ // vars
+ var lat = latLng[0];
+ var lng = latLng[1];
+
+ // check
+ if( $.isNumeric(lat) && $.isNumeric(lng) ) {
+ return this.searchPosition( lat, lng );
+ }
+ }
+
+ // vars
+ var $wrap = this.$control();
+
+ // add class
+ $wrap.addClass('-loading');
+
+ // callback
+ var callback = $.proxy(function( results, status ){
+
+ // remove class
+ $wrap.removeClass('-loading');
+
+ // vars
+ var lat = '';
+ var lng = '';
+
+ // validate
+ if( status != google.maps.GeocoderStatus.OK ) {
+ console.log('Geocoder failed due to: ' + status);
+ } else if( !results[0] ) {
+ console.log('No results found');
+ } else {
+ lat = results[0].geometry.location.lat();
+ lng = results[0].geometry.location.lng();
+ address = results[0].formatted_address;
+ }
+
+ // update val
+ this.val({
+ lat: lat,
+ lng: lng,
+ address: address
+ });
+
+ //acf.doAction('google_map_geocode_results', results, status, this.$el, this);
+
+ }, this);
+
+ // query
+ api.geocoder.geocode({ 'address' : address }, callback);
+ },
+
+ searchLocation: function(){
+
+ // Try HTML5 geolocation
+ if( !navigator.geolocation ) {
+ return alert( acf.__('Sorry, this browser does not support geolocation') );
+ }
+
+ // vars
+ var $wrap = this.$control();
+
+ // add class
+ $wrap.addClass('-loading');
+
+ // callback
+ var onSuccess = $.proxy(function( results, status ){
+
+ // remove class
+ $wrap.removeClass('-loading');
+
+ // vars
+ var lat = results.coords.latitude;
+ var lng = results.coords.longitude;
+
+ // search;
+ this.searchPosition( lat, lng );
+
+ }, this);
+
+ var onFailure = function( error ){
+ $wrap.removeClass('-loading');
+ }
+
+ // try query
+ navigator.geolocation.getCurrentPosition( onSuccess, onFailure );
+ },
+
+ onClickClear: function( e, $el ){
+ this.val( false );
+ },
+
+ onClickLocate: function( e, $el ){
+ this.searchLocation();
+ },
+
+ onClickSearch: function( e, $el ){
+ this.searchAddress( this.$search().val() );
+ },
+
+ onFocusSearch: function( e, $el ){
+ this.removeClass('-value');
+ this.onKeyupSearch.apply(this, arguments);
+ },
+
+ onBlurSearch: function( e, $el ){
+
+ // timeout to allow onClickLocate event
+ this.setTimeout(function(){
+ this.removeClass('-search');
+ if( $el.val() ) {
+ this.addClass('-value');
+ }
+ }, 100);
+ },
+
+ onKeyupSearch: function( e, $el ){
+ if( $el.val() ) {
+ this.addClass('-search');
+ } else {
+ this.removeClass('-search');
+ }
+ },
+
+ onKeydownSearch: function( e, $el ){
+
+ // prevent form from submitting
+ if( e.which == 13 ) {
+ e.preventDefault();
+ }
+ },
+
+ onMousedown: function(){
+
+/*
+ // clear timeout in 1ms (onMousedown will run before onBlurSearch)
+ this.setTimeout(function(){
+ clearTimeout( this.get('timeout') );
+ }, 1);
+*/
+ },
+
+ onShow: function(){
+
+ // bail early if no map
+ // - possible if JS API was not loaded
+ if( !this.map ) {
+ return false;
+ }
+
+ // center map when it is shown (by a tab / collapsed row)
+ // - use delay to avoid rendering issues with browsers (ensures div is visible)
+ this.setTimeout( this.center, 10 );
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+ var api = new acf.Model({
+
+ geocoder: false,
+
+ data: {
+ status: false,
+ },
+
+ getStatus: function(){
+ return this.get('status');
+ },
+
+ setStatus: function( status ){
+ return this.set('status', status);
+ },
+
+ isReady: function(){
+
+ // loaded
+ if( this.getStatus() == 'ready' ) {
+ return true;
+ }
+
+ // loading
+ if( this.getStatus() == 'loading' ) {
+ return false;
+ }
+
+ // check exists (optimal)
+ if( acf.isset(window, 'google', 'maps', 'places') ) {
+ this.setStatus('ready');
+ return true;
+ }
+
+ // load api
+ var url = acf.get('google_map_api');
+ if( url ) {
+ this.setStatus('loading');
+
+ // enqueue
+ $.ajax({
+ url: url,
+ dataType: 'script',
+ cache: true,
+ context: this,
+ success: function(){
+
+ // ready
+ this.setStatus('ready');
+
+ // geocoder
+ this.geocoder = new google.maps.Geocoder();
+
+ // action
+ acf.doAction('google_map_api_loaded');
+ }
+ });
+ }
+
+ // return
+ return false;
+ },
+
+ ready: function( callback, context ){
+ acf.addAction('google_map_api_loaded', callback, 10, context);
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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(){
+
+ // add attribute to form
+ if( this.get('uploader') === 'basic' ) {
+ this.$el.closest('form').attr('enctype', 'multipart/form-data');
+ }
+ },
+
+ validateAttachment: function( attachment ){
+
+ // defaults
+ attachment = attachment || {};
+
+ // WP attachment
+ if( attachment.id !== undefined ) {
+ attachment = attachment.attributes;
+ }
+
+ // args
+ attachment = acf.parseArgs(attachment, {
+ url: '',
+ alt: '',
+ title: '',
+ caption: '',
+ description: '',
+ width: 0,
+ height: 0
+ });
+
+ // preview size
+ var url = acf.isget(attachment, 'sizes', this.get('preview_size'), 'url');
+ if( url !== null ) {
+ attachment.url = url;
+ }
+
+ // return
+ return attachment;
+ },
+
+ render: function( attachment ){
+
+ // vars
+ attachment = this.validateAttachment( attachment );
+
+ // update image
+ this.$('img').attr({
+ src: attachment.url,
+ alt: attachment.alt,
+ title: attachment.title
+ });
+
+ // vars
+ var val = attachment.id || '';
+
+ // update val
+ this.val( val );
+
+ // update class
+ if( val ) {
+ this.$control().addClass('has-value');
+ } else {
+ this.$control().removeClass('has-value');
+ }
+ },
+
+ // create a new repeater row and render value
+ append: function( attachment, parent ){
+
+ // create function to find next available field within parent
+ var getNext = function( field, parent ){
+
+ // find existing file fields within parent
+ var fields = acf.getFields({
+ key: field.get('key'),
+ parent: parent.$el
+ });
+
+ // find the first field with no value
+ for( var i = 0; i < fields.length; i++ ) {
+ if( !fields[i].val() ) {
+ return fields[i];
+ }
+ }
+
+ // return
+ return false;
+ }
+
+ // find existing file fields within parent
+ var field = getNext( this, parent );
+
+ // add new row if no available field
+ if( !field ) {
+ parent.$('.acf-button:last').trigger('click');
+ field = getNext( this, parent );
+ }
+
+ // render
+ if( field ) {
+ field.render( attachment );
+ }
+ },
+
+ selectAttachment: function(){
+
+ // vars
+ var parent = this.parent();
+ var multiple = (parent && parent.get('type') === 'repeater');
+
+ // new frame
+ var frame = acf.newMediaPopup({
+ mode: 'select',
+ type: 'image',
+ title: acf.__('Select Image'),
+ field: this.get('key'),
+ multiple: multiple,
+ library: this.get('library'),
+ allowedTypes: this.get('mime_types'),
+ select: $.proxy(function( attachment, i ) {
+ if( i > 0 ) {
+ this.append( attachment, parent );
+ } else {
+ this.render( attachment );
+ }
+ }, this)
+ });
+ },
+
+ editAttachment: function(){
+
+ // vars
+ var val = this.val();
+
+ // bail early if no val
+ if( !val ) return;
+
+ // popup
+ var frame = acf.newMediaPopup({
+ mode: 'edit',
+ title: acf.__('Edit Image'),
+ button: acf.__('Update Image'),
+ attachment: val,
+ field: this.get('key'),
+ select: $.proxy(function( attachment, i ) {
+ this.render( attachment );
+ }, this)
+ });
+ },
+
+ removeAttachment: function(){
+ this.render( false );
+ },
+
+ onClickAdd: function( e, $el ){
+ this.selectAttachment();
+ },
+
+ onClickEdit: function( e, $el ){
+ this.editAttachment();
+ },
+
+ onClickRemove: function( e, $el ){
+ this.removeAttachment();
+ },
+
+ onChange: function( e, $el ){
+ var $hiddenInput = this.$input();
+
+ acf.getFileInputData($el, function( data ){
+ $hiddenInput.val( $.param(data) );
+ });
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.models.ImageField.extend({
+
+ type: 'file',
+
+ $control: function(){
+ return this.$('.acf-file-uploader');
+ },
+
+ $input: function(){
+ return this.$('input[type="hidden"]');
+ },
+
+ validateAttachment: function( attachment ){
+
+ // defaults
+ attachment = attachment || {};
+
+ // WP attachment
+ if( attachment.id !== undefined ) {
+ attachment = attachment.attributes;
+ }
+
+ // args
+ attachment = acf.parseArgs(attachment, {
+ url: '',
+ alt: '',
+ title: '',
+ filename: '',
+ filesizeHumanReadable: '',
+ icon: '/wp-includes/images/media/default.png'
+ });
+
+ // return
+ return attachment;
+ },
+
+ render: function( attachment ){
+
+ // vars
+ attachment = this.validateAttachment( attachment );
+
+ // update image
+ this.$('img').attr({
+ src: attachment.icon,
+ alt: attachment.alt,
+ title: attachment.title
+ });
+
+ // update elements
+ this.$('[data-name="title"]').text( attachment.title );
+ this.$('[data-name="filename"]').text( attachment.filename ).attr( 'href', attachment.url );
+ this.$('[data-name="filesize"]').text( attachment.filesizeHumanReadable );
+
+ // vars
+ var val = attachment.id || '';
+
+ // update val
+ acf.val( this.$input(), val );
+
+ // update class
+ if( val ) {
+ this.$control().addClass('has-value');
+ } else {
+ this.$control().removeClass('has-value');
+ }
+ },
+
+ selectAttachment: function(){
+
+ // vars
+ var parent = this.parent();
+ var multiple = (parent && parent.get('type') === 'repeater');
+
+ // new frame
+ var frame = acf.newMediaPopup({
+ mode: 'select',
+ title: acf.__('Select File'),
+ field: this.get('key'),
+ multiple: multiple,
+ library: this.get('library'),
+ allowedTypes: this.get('mime_types'),
+ select: $.proxy(function( attachment, i ) {
+ if( i > 0 ) {
+ this.append( attachment, parent );
+ } else {
+ this.render( attachment );
+ }
+ }, this)
+ });
+ },
+
+ editAttachment: function(){
+
+ // vars
+ var val = this.val();
+
+ // bail early if no val
+ if( !val ) {
+ return false;
+ }
+
+ // popup
+ var frame = acf.newMediaPopup({
+ mode: 'edit',
+ title: acf.__('Edit File'),
+ button: acf.__('Update File'),
+ attachment: val,
+ field: this.get('key'),
+ select: $.proxy(function( attachment, i ) {
+ this.render( attachment );
+ }, this)
+ });
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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(){
+
+ // vars
+ var $node = this.$node();
+
+ // return false if empty
+ if( !$node.attr('href') ) {
+ return false;
+ }
+
+ // return
+ return {
+ title: $node.html(),
+ url: $node.attr('href'),
+ target: $node.attr('target')
+ };
+ },
+
+ setValue: function( val ){
+
+ // default
+ val = acf.parseArgs(val, {
+ title: '',
+ url: '',
+ target: ''
+ });
+
+ // vars
+ var $div = this.$control();
+ var $node = this.$node();
+
+ // remove class
+ $div.removeClass('-value -external');
+
+ // add class
+ if( val.url ) $div.addClass('-value');
+ if( val.target === '_blank' ) $div.addClass('-external');
+
+ // update text
+ this.$('.link-title').html( val.title );
+ this.$('.link-url').attr('href', val.url).html( val.url );
+
+ // update node
+ $node.html(val.title);
+ $node.attr('href', val.url);
+ $node.attr('target', val.target);
+
+ // update inputs
+ this.$('.input-title').val( val.title );
+ this.$('.input-target').val( val.target );
+ this.$('.input-url').val( val.url ).trigger('change');
+ },
+
+ onClickEdit: function( e, $el ){
+ acf.wpLink.open( this.$node() );
+ },
+
+ onClickRemove: function( e, $el ){
+ this.setValue( false );
+ },
+
+ onChange: function( e, $el ){
+
+ // get the changed value
+ var val = this.getValue();
+
+ // update inputs
+ this.setValue(val);
+ }
+
+ });
+
+ acf.registerFieldType( Field );
+
+
+ // manager
+ acf.wpLink = new acf.Model({
+
+ getNodeValue: function(){
+ var $node = this.get('node');
+ return {
+ title: $node.html(),
+ url: $node.attr('href'),
+ target: $node.attr('target')
+ };
+ },
+
+ setNodeValue: function( val ){
+ var $node = this.get('node');
+ $node.html( val.title );
+ $node.attr('href', val.url);
+ $node.attr('target', val.target);
+ $node.trigger('change');
+ },
+
+ getInputValue: function(){
+ return {
+ title: $('#wp-link-text').val(),
+ url: $('#wp-link-url').val(),
+ target: $('#wp-link-target').prop('checked') ? '_blank' : ''
+ };
+ },
+
+ setInputValue: function( val ){
+ $('#wp-link-text').val( val.title );
+ $('#wp-link-url').val( val.url );
+ $('#wp-link-target').prop('checked', val.target === '_blank' );
+ },
+
+ open: function( $node ){
+
+ // add events
+ this.on('wplink-open', 'onOpen');
+ this.on('wplink-close', 'onClose');
+
+ // set node
+ this.set('node', $node);
+
+ // create textarea
+ var $textarea = $('');
+ $('body').append( $textarea );
+
+ // vars
+ var val = this.getNodeValue();
+
+ // open popup
+ wpLink.open( 'acf-link-textarea', val.url, val.title, null );
+
+ },
+
+ onOpen: function(){
+
+ // always show title (WP will hide title if empty)
+ $('#wp-link-wrap').addClass('has-text-field');
+
+ // set inputs
+ var val = this.getNodeValue();
+ this.setInputValue( val );
+ },
+
+ close: function(){
+ wpLink.close();
+ },
+
+ onClose: function(){
+
+ // bail early if no node
+ // needed due to WP triggering this event twice
+ if( !this.has('node') ) {
+ return false;
+ }
+
+ // remove events
+ this.off('wplink-open');
+ this.off('wplink-close');
+
+ // set value
+ var val = this.getInputValue();
+ this.setNodeValue( val );
+
+ // remove textarea
+ $('#acf-link-textarea').remove();
+
+ // reset
+ this.set('node', null);
+
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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( val ){
+
+ // class
+ if( val ) {
+ this.$control().addClass('has-value');
+ } else {
+ this.$control().removeClass('has-value');
+ }
+
+ acf.val( this.$input(), val );
+ },
+
+ showLoading: function( show ){
+ acf.showLoading( this.$('.canvas') );
+ },
+
+ hideLoading: function(){
+ acf.hideLoading( this.$('.canvas') );
+ },
+
+ maybeSearch: function(){
+
+ // vars
+ var prevUrl = this.val();
+ var url = this.getSearchVal();
+
+ // no value
+ if( !url ) {
+ return this.clear();
+ }
+
+ // fix missing 'http://' - causes the oembed code to error and fail
+ if( url.substr(0, 4) != 'http' ) {
+ url = 'http://' + url;
+ }
+
+ // bail early if no change
+ if( url === prevUrl ) return;
+
+ // clear existing timeout
+ var timeout = this.get('timeout');
+ if( timeout ) {
+ clearTimeout( timeout );
+ }
+
+ // set new timeout
+ var callback = $.proxy(this.search, this, url);
+ this.set('timeout', setTimeout(callback, 300));
+
+ },
+
+ search: function( url ){
+
+ // ajax
+ var ajaxData = {
+ action: 'acf/fields/oembed/search',
+ s: url,
+ field_key: this.get('key')
+ };
+
+ // clear existing timeout
+ var xhr = this.get('xhr');
+ if( xhr ) {
+ xhr.abort();
+ }
+
+ // loading
+ this.showLoading();
+
+ // query
+ var xhr = $.ajax({
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax(ajaxData),
+ type: 'post',
+ dataType: 'json',
+ context: this,
+ success: function( json ){
+
+ // error
+ if( !json || !json.html ) {
+ json = {
+ url: false,
+ html: ''
+ }
+ }
+
+ // update vars
+ this.val( json.url );
+ this.$('.canvas-media').html( json.html );
+ },
+ complete: function(){
+ this.hideLoading();
+ }
+ });
+
+ this.set('xhr', xhr);
+ },
+
+ clear: function(){
+ this.val('');
+ this.$search().val('');
+ this.$('.canvas-media').html('');
+ },
+
+ onClickClear: function( e, $el ){
+ this.clear();
+ },
+
+ onKeypressSearch: function( e, $el ){
+ if( e.which == 13 ) {
+ e.preventDefault();
+ this.maybeSearch();
+ }
+ },
+
+ onKeyupSearch: function( e, $el ){
+ if( $el.val() ) {
+ this.maybeSearch();
+ }
+ },
+
+ onChangeSearch: function( e, $el ){
+ this.maybeSearch();
+ }
+
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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 val = this.$input().val();
+ if( val === 'other' ) {
+ val = this.inputText().val();
+ }
+ return val;
+ },
+
+ onClick: function( e, $el ){
+
+ // vars
+ var $label = $el.parent('label');
+ var selected = $label.hasClass('selected');
+ var val = $el.val();
+
+ // remove previous selected
+ this.$('.selected').removeClass('selected');
+
+ // add active class
+ $label.addClass('selected');
+
+ // allow null
+ if( this.get('allow_null') && selected ) {
+ $label.removeClass('selected');
+ $el.prop('checked', false).trigger('change');
+ val = false;
+ }
+
+ // other
+ if( this.get('other_choice') ) {
+
+ // enable
+ if( val === 'other' ) {
+ this.$inputText().prop('disabled', false);
+
+ // disable
+ } else {
+ this.$inputText().prop('disabled', true);
+ }
+ }
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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( val ){
+
+ this.busy = true;
+
+ // update range input (with change)
+ acf.val( this.$input(), val );
+
+ // update alt input (without change)
+ acf.val( this.$inputAlt(), val, true );
+
+ this.busy = false;
+ },
+
+ onChange: function( e, $el ){
+ if( !this.busy ) {
+ this.setValue( $el.val() );
+ }
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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( list ) {
+ return this.$('.' + list + '-list');
+ },
+
+ $listItems: function( list ) {
+ return this.$list( list ).find('.acf-rel-item');
+ },
+
+ $listItem: function( list, id ) {
+ return this.$list( list ).find('.acf-rel-item[data-id="' + id + '"]');
+ },
+
+ getValue: function(){
+ var val = [];
+ this.$listItems('values').each(function(){
+ val.push( $(this).data('id') );
+ });
+ return val.length ? val : false;
+ },
+
+ newChoice: function( props ){
+ return [
+ '',
+ '' + props.text + ' ',
+ ' '
+ ].join('');
+ },
+
+ newValue: function( props ){
+ return [
+ '',
+ ' ',
+ '' + props.text,
+ ' ',
+ ' ',
+ ' '
+ ].join('');
+ },
+
+ addSortable: function( self ){
+
+ // sortable
+ this.$list('values').sortable({
+ items: 'li',
+ forceHelperSize: true,
+ forcePlaceholderSize: true,
+ scroll: true,
+ update: function(){
+ self.$input().trigger('change');
+ }
+ });
+ },
+
+ initialize: function(){
+
+ // scroll
+ var onScroll = this.proxy(function(e){
+
+ // bail early if no more results
+ if( this.get('loading') || !this.get('more') ) {
+ return;
+ }
+
+ // Scrolled to bottom
+ var $list = this.$list('choices');
+ var scrollTop = Math.ceil( $list.scrollTop() );
+ var scrollHeight = Math.ceil( $list[0].scrollHeight );
+ var innerHeight = Math.ceil( $list.innerHeight() );
+ var paged = this.get('paged') || 1;
+ if( (scrollTop + innerHeight) >= scrollHeight ) {
+
+ // update paged
+ this.set('paged', (paged+1));
+
+ // fetch
+ this.fetch();
+ }
+
+ });
+
+ this.$list('choices').scrollTop(0).on('scroll', onScroll);
+
+ // fetch
+ this.fetch();
+ },
+
+ onHover: function( e ){
+
+ // only once
+ $().off(e);
+
+ // add sortable
+ this.addSortable( this );
+ },
+
+ onKeypressFilter: function( e, $el ){
+
+ // don't submit form
+ if( e.which == 13 ) {
+ e.preventDefault();
+ }
+ },
+
+ onChangeFilter: function( e, $el ){
+
+ // vars
+ var val = $el.val();
+ var filter = $el.data('filter');
+
+ // Bail early if filter has not changed
+ if( this.get(filter) === val ) {
+ return;
+ }
+
+ // update attr
+ this.set(filter, val);
+
+ // reset paged
+ this.set('paged', 1);
+
+ // fetch
+ if( $el.is('select') ) {
+ this.fetch();
+
+ // search must go through timeout
+ } else {
+ this.maybeFetch();
+ }
+ },
+
+ onClickAdd: function( e, $el ){
+
+ // vars
+ var val = this.val();
+ var max = parseInt( this.get('max') );
+
+ // can be added?
+ if( $el.hasClass('disabled') ) {
+ return false;
+ }
+
+ // validate
+ if( max > 0 && val && val.length >= max ) {
+
+ // add notice
+ this.showNotice({
+ text: acf.__('Maximum values reached ( {max} values )').replace('{max}', max),
+ type: 'warning'
+ });
+ return false;
+ }
+
+ // disable
+ $el.addClass('disabled');
+
+ // add
+ var html = this.newValue({
+ id: $el.data('id'),
+ text: $el.html()
+ });
+ this.$list('values').append( html )
+
+ // trigger change
+ this.$input().trigger('change');
+ },
+
+ onClickRemove: function( e, $el ){
+
+ // vars
+ var $span = $el.parent();
+ var $li = $span.parent();
+ var id = $span.data('id');
+
+ // remove value
+ setTimeout(function(){
+ $li.remove();
+ }, 1);
+
+ // show choice
+ this.$listItem('choices', id).removeClass('disabled');
+
+ // trigger change
+ this.$input().trigger('change');
+ },
+
+ maybeFetch: function(){
+
+ // vars
+ var timeout = this.get('timeout');
+
+ // abort timeout
+ if( timeout ) {
+ clearTimeout( timeout );
+ }
+
+ // fetch
+ timeout = this.setTimeout(this.fetch, 300);
+ this.set('timeout', timeout);
+ },
+
+ getAjaxData: function(){
+
+ // load data based on element attributes
+ var ajaxData = this.$control().data();
+ for( var name in ajaxData ) {
+ ajaxData[ name ] = this.get( name );
+ }
+
+ // extra
+ ajaxData.action = 'acf/fields/relationship/query';
+ ajaxData.field_key = this.get('key');
+
+ // return
+ return ajaxData;
+ },
+
+ fetch: function(){
+
+ // abort XHR if this field is already loading AJAX data
+ var xhr = this.get('xhr');
+ if( xhr ) {
+ xhr.abort();
+ }
+
+ // add to this.o
+ var ajaxData = this.getAjaxData();
+
+ // clear html if is new query
+ var $choiceslist = this.$list( 'choices' );
+ if( ajaxData.paged == 1 ) {
+ $choiceslist.html('');
+ }
+
+ // loading
+ var $loading = $(' ' + acf.__('Loading') + ' ');
+ $choiceslist.append($loading);
+ this.set('loading', true);
+
+ // callback
+ var onComplete = function(){
+ this.set('loading', false);
+ $loading.remove();
+ };
+
+ var onSuccess = function( json ){
+
+ // no results
+ if( !json || !json.results || !json.results.length ) {
+
+ // prevent pagination
+ this.set('more', false);
+
+ // add message
+ if( this.get('paged') == 1 ) {
+ this.$list('choices').append('' + acf.__('No matches found') + ' ');
+ }
+
+ // return
+ return;
+ }
+
+ // set more (allows pagination scroll)
+ this.set('more', json.more );
+
+ // get new results
+ var html = this.walkChoices(json.results);
+ var $html = $( html );
+
+ // apply .disabled to left li's
+ var val = this.val();
+ if( val && val.length ) {
+ val.map(function( id ){
+ $html.find('.acf-rel-item[data-id="' + id + '"]').addClass('disabled');
+ });
+ }
+
+ // append
+ $choiceslist.append( $html );
+
+ // merge together groups
+ var $prevLabel = false;
+ var $prevList = false;
+
+ $choiceslist.find('.acf-rel-label').each(function(){
+
+ var $label = $(this);
+ var $list = $label.siblings('ul');
+
+ if( $prevLabel && $prevLabel.text() == $label.text() ) {
+ $prevList.append( $list.children() );
+ $(this).parent().remove();
+ return;
+ }
+
+ // update vars
+ $prevLabel = $label;
+ $prevList = $list;
+ });
+ };
+
+ // get results
+ var xhr = $.ajax({
+ url: acf.get('ajaxurl'),
+ dataType: 'json',
+ type: 'post',
+ data: acf.prepareForAjax(ajaxData),
+ context: this,
+ success: onSuccess,
+ complete: onComplete
+ });
+
+ // set
+ this.set('xhr', xhr);
+ },
+
+ walkChoices: function( data ){
+
+ // walker
+ var walk = function( data ){
+
+ // vars
+ var html = '';
+
+ // is array
+ if( $.isArray(data) ) {
+ data.map(function(item){
+ html += walk( item );
+ });
+
+ // is item
+ } else if( $.isPlainObject(data) ) {
+
+ // group
+ if( data.children !== undefined ) {
+
+ html += '' + data.text + ' ';
+ html += walk( data.children );
+ html += ' ';
+
+ // single
+ } else {
+ html += '' + data.text + ' ';
+ }
+ }
+
+ // return
+ return html;
+ };
+
+ return walk( data );
+ }
+
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.Field.extend({
+
+ type: 'select',
+
+ select2: false,
+
+ wait: 'load',
+
+ events: {
+ 'removeField': 'onRemove'
+ },
+
+ $input: function(){
+ return this.$('select');
+ },
+
+ initialize: function(){
+
+ // vars
+ var $select = this.$input();
+
+ // inherit data
+ this.inherit( $select );
+
+ // select2
+ if( this.get('ui') ) {
+
+ // populate ajax_data (allowing custom attribute to already exist)
+ var ajaxAction = this.get('ajax_action');
+ if( !ajaxAction ) {
+ ajaxAction = 'acf/fields/' + this.get('type') + '/query';
+ }
+
+ // select2
+ this.select2 = acf.newSelect2($select, {
+ field: this,
+ ajax: this.get('ajax'),
+ multiple: this.get('multiple'),
+ placeholder: this.get('placeholder'),
+ allowNull: this.get('allow_null'),
+ ajaxAction: ajaxAction,
+ });
+ }
+ },
+
+ onRemove: function(){
+ if( this.select2 ) {
+ this.select2.destroy();
+ }
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ // vars
+ var CONTEXT = 'tab';
+
+ var Field = acf.Field.extend({
+
+ type: 'tab',
+
+ wait: '',
+
+ tabs: false,
+
+ tab: false,
+
+ 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(){
+
+ // bail early if is td
+ if( this.$el.is('td') ) {
+ this.events = {};
+ return false;
+ }
+
+ // vars
+ var $tabs = this.findTabs();
+ var $tab = this.findTab();
+ var settings = acf.parseArgs($tab.data(), {
+ endpoint: false,
+ placement: '',
+ before: this.$el
+ });
+
+ // create wrap
+ if( !$tabs.length || settings.endpoint ) {
+ this.tabs = new Tabs( settings );
+ } else {
+ this.tabs = $tabs.data('acf');
+ }
+
+ // add tab
+ this.tab = this.tabs.addTab($tab, this);
+ },
+
+ isActive: function(){
+ return this.tab.isActive();
+ },
+
+ showFields: function(){
+
+ // show fields
+ this.getFields().map(function( field ){
+ field.show( this.cid, CONTEXT );
+ field.hiddenByTab = false;
+ }, this);
+
+ },
+
+ hideFields: function(){
+
+ // hide fields
+ this.getFields().map(function( field ){
+ field.hide( this.cid, CONTEXT );
+ field.hiddenByTab = this.tab;
+ }, this);
+
+ },
+
+ show: function( lockKey ){
+
+ // show field and store result
+ var visible = acf.Field.prototype.show.apply(this, arguments);
+
+ // check if now visible
+ if( visible ) {
+
+ // show tab
+ this.tab.show();
+
+ // check active tabs
+ this.tabs.refresh();
+ }
+
+ // return
+ return visible;
+ },
+
+ hide: function( lockKey ){
+
+ // hide field and store result
+ var hidden = acf.Field.prototype.hide.apply(this, arguments);
+
+ // check if now hidden
+ if( hidden ) {
+
+ // hide tab
+ this.tab.hide();
+
+ // reset tabs if this was active
+ if( this.isActive() ) {
+ this.tabs.reset();
+ }
+ }
+
+ // return
+ return hidden;
+ },
+
+ enable: function( lockKey ){
+
+ // enable fields
+ this.getFields().map(function( field ){
+ field.enable( CONTEXT );
+ });
+ },
+
+ disable: function( lockKey ){
+
+ // disable fields
+ this.getFields().map(function( field ){
+ field.disable( CONTEXT );
+ });
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+
+ /**
+ * tabs
+ *
+ * description
+ *
+ * @date 8/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var i = 0;
+ var Tabs = acf.Model.extend({
+
+ tabs: [],
active: false,
+
actions: {
- 'ready': 'ready'
+ 'refresh': 'onRefresh'
},
+
+ data: {
+ before: false,
+ placement: 'top',
+ index: 0,
+ initialized: false,
+ },
+
+ setup: function( settings ){
+
+ // data
+ $.extend(this.data, settings);
+
+ // define this prop to avoid scope issues
+ this.tabs = [];
+ this.active = false;
+
+ // vars
+ var placement = this.get('placement');
+ var $before = this.get('before');
+ var $parent = $before.parent();
+
+ // add sidebar for left placement
+ if( placement == 'left' && $parent.hasClass('acf-fields') ) {
+ $parent.addClass('-sidebar');
+ }
+
+ // create wrap
+ if( $before.is('tr') ) {
+ this.$el = $(' ');
+ } else {
+ this.$el = $('');
+ }
+
+ // append
+ $before.before( this.$el );
+
+ // set index
+ this.set('index', i, true);
+ i++;
+ },
+
+ initializeTabs: function(){
+
+ // find first visible tab
+ var tab = this.getVisible().shift();
+
+ // remember previous tab state
+ var order = acf.getPreference('this.tabs') || [];
+ var groupIndex = this.get('index');
+ var tabIndex = order[ groupIndex ];
+
+ if( this.tabs[ tabIndex ] && this.tabs[ tabIndex ].isVisible() ) {
+ tab = this.tabs[ tabIndex ];
+ }
+
+ // select
+ if( tab ) {
+ this.selectTab( tab );
+ } else {
+ this.closeTabs();
+ }
+
+ // set local variable used by tabsManager
+ this.set('initialized', true);
+ },
+
+ getVisible: function(){
+ return this.tabs.filter(function( tab ){
+ return tab.isVisible();
+ });
+ },
+
+ getActive: function(){
+ return this.active;
+ },
+
+ setActive: function( tab ){
+ return this.active = tab;
+ },
+
+ hasActive: function(){
+ return (this.active !== false);
+ },
+
+ isActive: function( tab ){
+ var active = this.getActive();
+ return (active && active.cid === tab.cid);
+ },
+
+ closeActive: function(){
+ if( this.hasActive() ) {
+ this.closeTab( this.getActive() );
+ }
+ },
+
+ openTab: function( tab ){
+
+ // close existing tab
+ this.closeActive();
+
+ // open
+ tab.open();
+
+ // set active
+ this.setActive( tab );
+ },
+
+ closeTab: function( tab ){
+
+ // close
+ tab.close();
+
+ // set active
+ this.setActive( false );
+ },
+
+ closeTabs: function(){
+ this.tabs.map( this.closeTab, this );
+ },
+
+ selectTab: function( tab ){
+
+ // close other tabs
+ this.tabs.map(function( t ){
+ if( tab.cid !== t.cid ) {
+ this.closeTab( t );
+ }
+ }, this);
+
+ // open
+ this.openTab( tab );
+
+ },
+
+ addTab: function( $a, field ){
+
+ // create
+ var $li = $(' ');
+
+ // append
+ $li.append( $a );
+
+ // append
+ this.$('ul').append( $li );
+
+ // initialize
+ var tab = new Tab({
+ $el: $li,
+ field: field,
+ group: this,
+ });
+
+ // store
+ this.tabs.push( tab );
+
+ // return
+ return tab;
+ },
+
+ reset: function(){
+
+ // close existing tab
+ this.closeActive();
+
+ // find and active a tab
+ return this.refresh();
+ },
+
+ refresh: function(){
+
+ // bail early if active already exists
+ if( this.hasActive() ) {
+ return false;
+ }
+
+ // find next active tab
+ var tab = this.getVisible().shift();
+
+ // open tab
+ if( tab ) {
+ this.openTab( tab );
+ }
+
+ // return
+ return tab;
+ },
+
+ onRefresh: function(){
+
+ // only for left placements
+ if( this.get('placement') !== 'left' ) {
+ return;
+ }
+
+ // vars
+ var $parent = this.$el.parent();
+ var $list = this.$el.children('ul');
+ var attribute = $parent.is('td') ? 'height' : 'min-height';
+
+ // find height (minus 1 for border-bottom)
+ var height = $list.position().top + $list.outerHeight(true) - 1;
+
+ // add css
+ $parent.css(attribute, height);
+ }
+ });
+
+ var Tab = acf.Model.extend({
+
+ group: false,
+
+ field: false,
+
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'
+ 'click a': 'onClick'
},
- o: {
+
+ index: function(){
+ return this.$el.index();
+ },
+
+ isVisible: function(){
+ return acf.isVisible( this.$el );
+ },
+
+ isActive: function(){
+ return this.$el.hasClass('active');
+ },
+
+ open: function(){
+
+ // add class
+ this.$el.addClass('active');
+
+ // show field
+ this.field.showFields();
+ },
+
+ close: function(){
+
+ // remove class
+ this.$el.removeClass('active');
+
+ // hide field
+ this.field.hideFields();
+ },
+
+ onClick: function( e, $el ){
+
+ // prevent default
+ e.preventDefault();
+
+ // toggle
+ this.toggle();
+ },
+
+ toggle: function(){
+
+ // bail early if already active
+ if( this.isActive() ) {
+ return;
+ }
+
+ // toggle this tab
+ this.group.openTab( this );
+ }
+ });
+
+ var tabsManager = 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( $el ){
+ this.getTabs().map(function( tabs ){
+ if( !tabs.get('initialized') ) {
+ tabs.initializeTabs();
+ }
+ });
+ },
+
+ onInvalidField: function( field ){
+
+ // bail early if busy
+ if( this.busy ) {
+ return;
+ }
+
+ // ignore if not hidden by tab
+ if( !field.hiddenByTab ) {
+ return;
+ }
+
+ // toggle tab
+ field.hiddenByTab.toggle();
+
+ // ignore other invalid fields
+ this.busy = true;
+ this.setTimeout(function(){
+ this.busy = false;
+ }, 100);
+ },
+
+ onUnload: function(){
+
+ // vars
+ var order = [];
+
+ // loop
+ this.getTabs().map(function( group ){
+ var active = group.hasActive() ? group.getActive().index() : 0;
+ order.push(active);
+ });
+
+ // bail if no tabs
+ if( !order.length ) {
+ return;
+ }
+
+ // update
+ acf.setPreference('this.tabs', order);
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.models.SelectField.extend({
+ type: 'post_object',
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.models.SelectField.extend({
+ type: 'page_link',
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.models.SelectField.extend({
+ type: 'user',
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.Field.extend({
+
+ type: 'taxonomy',
+
+ data: {
+ 'ftype': 'select'
+ },
+
+ select2: false,
+
+ 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(){
+
+ // vars
+ var fieldType = this.get('ftype');
+
+ // normalize
+ if( fieldType == 'multi_select' ) {
+ fieldType = 'select';
+ }
+
+ // return
+ return fieldType;
+
+ },
+
+ 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(){
+ if( this.select2 ) {
+ this.select2.destroy();
+ }
+ },
+
+ onClickAdd: function( e, $el ){
+
+ // vars
+ var field = this;
+ var popup = false;
+ var $form = false;
+ var $name = false;
+ var $parent = false;
+ var $button = false;
+ var $message = false;
+ var notice = false;
+
+ // step 1.
+ var step1 = function(){
+
+ // popup
+ popup = acf.newPopup({
+ title: $el.attr('title'),
+ loading: true,
+ width: '300px'
+ });
+
+ // ajax
+ var ajaxData = {
+ action: 'acf/fields/taxonomy/add_term',
+ field_key: field.get('key')
+ };
+
+ // get HTML
+ $.ajax({
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax(ajaxData),
+ type: 'post',
+ dataType: 'html',
+ success: step2
+ });
+ };
+
+ // step 2.
+ var step2 = function( html ){
+
+ // update popup
+ popup.loading(false);
+ popup.content(html);
+
+ // vars
+ $form = popup.$('form');
+ $name = popup.$('input[name="term_name"]');
+ $parent = popup.$('select[name="term_parent"]');
+ $button = popup.$('.acf-submit-button');
+
+ // focus
+ $name.focus();
+
+ // submit form
+ popup.on('submit', 'form', step3);
+ };
+
+ // step 3.
+ var step3 = function( e, $el ){
+
+ // prevent
+ e.preventDefault();
+
+ // basic validation
+ if( $name.val() === '' ) {
+ $name.focus();
+ return false;
+ }
+
+ // disable
+ acf.startButtonLoading( $button );
+
+ // ajax
+ var ajaxData = {
+ action: 'acf/fields/taxonomy/add_term',
+ field_key: field.get('key'),
+ term_name: $name.val(),
+ term_parent: $parent.length ? $parent.val() : 0
+ };
+
+ $.ajax({
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax(ajaxData),
+ type: 'post',
+ dataType: 'json',
+ success: step4
+ });
+ };
+
+ // step 4.
+ var step4 = function( json ){
+
+ // enable
+ acf.stopButtonLoading( $button );
+
+ // remove prev notice
+ if( notice ) {
+ notice.remove();
+ }
+
+ // success
+ if( acf.isAjaxSuccess(json) ) {
+
+ // clear name
+ $name.val('');
+
+ // update term lists
+ step5( json.data );
+
+ // notice
+ notice = acf.newNotice({
+ type: 'success',
+ text: acf.getAjaxMessage(json),
+ target: $form,
+ timeout: 2000,
+ dismiss: false
+ });
+
+ } else {
+
+ // notice
+ notice = acf.newNotice({
+ type: 'error',
+ text: acf.getAjaxError(json),
+ target: $form,
+ timeout: 2000,
+ dismiss: false
+ });
+ }
+
+ // focus
+ $name.focus();
+ };
+
+ // step 5.
+ var step5 = function( term ){
+
+ // update parent dropdown
+ var $option = $('' + term.term_label + ' ');
+ if( term.term_parent ) {
+ $parent.children('option[value="' + term.term_parent + '"]').after( $option );
+ } else {
+ $parent.append( $option );
+ }
+
+ // add this new term to all taxonomy field
+ var fields = acf.getFields({
+ type: 'taxonomy'
+ });
+
+ fields.map(function( otherField ){
+ if( otherField.get('taxonomy') == field.get('taxonomy') ) {
+ otherField.appendTerm( term );
+ }
+ });
+
+ // select
+ field.selectTerm( term.term_id );
+ };
+
+ // run
+ step1();
+ },
+
+ appendTerm: function( term ){
+
+ if( this.getRelatedType() == 'select' ) {
+ this.appendTermSelect( term );
+ } else {
+ this.appendTermCheckbox( term );
+ }
+ },
+
+ appendTermSelect: function( term ){
+
+ this.select2.addOption({
+ id: term.term_id,
+ text: term.term_label
+ });
+
+ },
+
+ appendTermCheckbox: function( term ){
+
+ // vars
+ var name = this.$('[name]:first').attr('name');
+ var $ul = this.$('ul:first');
+
+ // allow multiple selection
+ if( this.getRelatedType() == 'checkbox' ) {
+ name += '[]';
+ }
+
+ // create new li
+ var $li = $([
+ '',
+ '',
+ ' ',
+ '' + term.term_name + ' ',
+ ' ',
+ ' '
+ ].join(''));
+
+ // find parent
+ if( term.term_parent ) {
+
+ // vars
+ var $parent = $ul.find('li[data-id="' + term.term_parent + '"]');
+
+ // update vars
+ $ul = $parent.children('ul');
+
+ // create ul
+ if( !$ul.exists() ) {
+ $ul = $('');
+ $parent.append( $ul );
+ }
+ }
+
+ // append
+ $ul.append( $li );
+ },
+
+ selectTerm: function( id ){
+ if( this.getRelatedType() == 'select' ) {
+ this.select2.selectOption( id );
+ } else {
+ var $input = this.$('input[value="' + id + '"]');
+ $input.prop('checked', true).trigger('change');
+ }
+ },
+
+ onClickRadio: function( e, $el ){
+
+ // vars
+ var $label = $el.parent('label');
+ var selected = $label.hasClass('selected');
+
+ // remove previous selected
+ this.$('.selected').removeClass('selected');
+
+ // add active class
+ $label.addClass('selected');
+
+ // allow null
+ if( this.get('allow_null') && selected ) {
+ $label.removeClass('selected');
+ $el.prop('checked', false).trigger('change');
+ }
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = acf.models.DatePickerField.extend({
+
+ type: 'time_picker',
+
+ $control: function(){
+ return this.$('.acf-time-picker');
+ },
+
+ initialize: function(){
+
+ // vars
+ var $input = this.$input();
+ var $inputText = this.$inputText();
+
+ // args
+ var args = {
+ timeFormat: this.get('time_format'),
+ altField: $input,
+ altFieldTimeOnly: false,
+ altTimeFormat: 'HH:mm:ss',
+ showButtonPanel: true,
+ controlType: 'select',
+ oneLine: true,
+ closeText: acf.get('dateTimePickerL10n').selectText,
+ timeOnly: true,
+ };
+
+ // add custom 'Close = Select' functionality
+ args.onClose = function( value, dp_instance, t_instance ){
+
+ // vars
+ var $close = dp_instance.dpDiv.find('.ui-datepicker-close');
+
+ // if clicking close button
+ if( !value && $close.is(':hover') ) {
+ t_instance._updateDateTime();
+ }
+ };
+
+
+ // filter
+ args = acf.applyFilters('time_picker_args', args, this);
+
+ // add date time picker
+ acf.newTimePicker( $inputText, args );
+
+ // action
+ acf.doAction('time_picker_init', $inputText, args, this);
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+
+ // add
+ acf.newTimePicker = function( $input, args ){
+
+ // bail ealry if no datepicker library
+ if( typeof $.timepicker === 'undefined' ) {
+ return false;
+ }
+
+ // defaults
+ args = args || {};
+
+ // initialize
+ $input.timepicker( args );
+
+ // wrap the datepicker (only if it hasn't already been wrapped)
+ if( $('body > #ui-datepicker-div').exists() ) {
+ $('body > #ui-datepicker-div').wrap('
');
+ }
+ };
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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(){
+
+ // vars
+ var $switch = this.$switch();
+
+ // bail ealry if no $switch
+ if( !$switch.length ) return;
+
+ // vars
+ var $on = $switch.children('.acf-switch-on');
+ var $off = $switch.children('.acf-switch-off');
+ var width = Math.max( $on.width(), $off.width() );
+
+ // bail ealry if no width
+ if( !width ) return;
+
+ // set widths
+ $on.css( 'min-width', width );
+ $off.css( 'min-width', width );
+
+ },
+
+ switchOn: function() {
+ this.$input().prop('checked', true);
+ this.$switch().addClass('-on');
+ },
+
+ switchOff: function() {
+ this.$input().prop('checked', false);
+ this.$switch().removeClass('-on');
+ },
+
+ onChange: function( e, $el ){
+ if( $el.prop('checked') ) {
+ this.switchOn();
+ } else {
+ this.switchOff();
+ }
+ },
+
+ onFocus: function( e, $el ){
+ this.$switch().addClass('-focus');
+ },
+
+ onBlur: function( e, $el ){
+ this.$switch().removeClass('-focus');
+ },
+
+ onKeypress: function( e, $el ){
+
+ // left
+ if( e.keyCode === 37 ) {
+ return this.switchOff();
+ }
+
+ // right
+ if( e.keyCode === 39 ) {
+ return this.switchOn();
+ }
+
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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(){
+
+ // vars
+ var val = this.val();
+
+ // bail early if no val
+ if( !val ) {
+ return false;
+ }
+
+ // url
+ if( val.indexOf('://') !== -1 ) {
+ return true;
+ }
+
+ // protocol relative url
+ if( val.indexOf('//') === 0 ) {
+ return true;
+ }
+
+ // return
+ return false;
+ },
+
+ render: function(){
+
+ // add class
+ if( this.isValid() ) {
+ this.$control().addClass('-valid');
+ } else {
+ this.$control().removeClass('-valid');
+ }
+ },
+
+ onkeyup: function( e, $el ){
+ this.render();
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ var Field = 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(){
+
+ // initializeEditor if no delay
+ if( !this.$control().hasClass('delay') ) {
+ this.initializeEditor();
+ }
+ },
+
+ initializeEditor: function(){
+
+ // vars
+ var $wrap = this.$control();
+ var $textarea = this.$input();
+ var args = {
+ tinymce: true,
+ quicktags: true,
+ toolbar: this.get('toolbar'),
+ mode: this.getMode(),
+ field: this
+ };
+
+ // generate new id
+ var oldId = $textarea.attr('id');
+ var newId = acf.uniqueId('acf-editor-');
+
+ // rename
+ acf.rename({
+ target: $wrap,
+ search: oldId,
+ replace: newId,
+ destructive: true
+ });
+
+ // update id
+ this.set('id', newId, true);
+
+ // initialize
+ acf.tinymce.initialize( newId, args );
+ },
+
+ onMousedown: function( e ){
+
+ // prevent default
+ e.preventDefault();
+
+ // remove delay class
+ var $wrap = this.$control();
+ $wrap.removeClass('delay');
+ $wrap.find('.acf-editor-toolbar').remove();
+
+ // initialize
+ this.initializeEditor();
+ },
+
+ enableEditor: function(){
+ if( this.getMode() == 'visual' ) {
+ acf.tinymce.enable( this.get('id') );
+ }
+ },
+
+ disableEditor: function(){
+ acf.tinymce.destroy( this.get('id') );
+ }
+ });
+
+ acf.registerFieldType( Field );
+
+})(jQuery);
+
+(function($, undefined){
+
+ // vars
+ var storage = [];
+
+ /**
+ * acf.Condition
+ *
+ * description
+ *
+ * @date 23/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.Condition = acf.Model.extend({
+
+ type: '', // used for model name
+ operator: '==', // rule operator
+ label: '', // label shown when editing fields
+ choiceType: 'input', // input, select
+ fieldTypes: [], // auto connect this conditions with these field types
+
+ data: {
+ conditions: false, // the parent instance
+ field: false, // the field which we query against
+ rule: {} // the rule [field, operator, value]
+ },
+
+ events: {
+ 'change': 'change',
+ 'keyup': 'change',
+ 'enableField': 'change',
+ 'disableField': 'change'
+ },
+
+ setup: function( props ){
+ $.extend(this.data, props);
+ },
+
+ getEventTarget: function( $el, event ){
+ return $el || this.get('field').$el;
+ },
+
+ change: function( e, $el ){
+ this.get('conditions').change( e );
+ },
+
+ match: function( rule, field ){
+ return false;
+ },
+
+ calculate: function(){
+ return this.match( this.get('rule'), this.get('field') );
+ },
+
+ choices: function( field ){
+ return ' ';
+ }
+ });
+
+ /**
+ * acf.newCondition
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.newCondition = function( rule, conditions ){
+
+ // currently setting up conditions for fieldX, this field is the 'target'
+ var target = conditions.get('field');
+
+ // use the 'target' to find the 'trigger' field.
+ // - this field is used to setup the conditional logic events
+ var field = target.getField( rule.field );
+
+ // bail ealry if no target or no field (possible if field doesn't exist due to HTML error)
+ if( !target || !field ) {
+ return false;
+ }
+
+ // vars
+ var args = {
+ rule: rule,
+ target: target,
+ conditions: conditions,
+ field: field
+ };
+
+ // vars
+ var fieldType = field.get('type');
+ var operator = rule.operator;
+
+ // get avaibale conditions
+ var conditionTypes = acf.getConditionTypes({
+ fieldType: fieldType,
+ operator: operator,
+ });
+
+ // instantiate
+ var model = conditionTypes[0] || acf.Condition;
+
+ // instantiate
+ var condition = new model( args );
+
+ // return
+ return condition;
+ };
+
+ /**
+ * mid
+ *
+ * Calculates the model ID for a field type
+ *
+ * @date 15/12/17
+ * @since 5.6.5
+ *
+ * @param string type
+ * @return string
+ */
+
+ var modelId = function( type ) {
+ return acf.strPascalCase( type || '' ) + 'Condition';
+ };
+
+ /**
+ * acf.registerConditionType
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.registerConditionType = function( model ){
+
+ // vars
+ var proto = model.prototype;
+ var type = proto.type;
+ var mid = modelId( type );
+
+ // store model
+ acf.models[ mid ] = model;
+
+ // store reference
+ storage.push( type );
+ };
+
+ /**
+ * acf.getConditionType
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getConditionType = function( type ){
+ var mid = modelId( type );
+ return acf.models[ mid ] || false;
+ }
+
+ /**
+ * acf.registerConditionForFieldType
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.registerConditionForFieldType = function( conditionType, fieldType ){
+
+ // get model
+ var model = acf.getConditionType( conditionType );
+
+ // append
+ if( model ) {
+ model.prototype.fieldTypes.push( fieldType );
+ }
+ };
+
+ /**
+ * acf.getConditionTypes
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getConditionTypes = function( args ){
+
+ // defaults
+ args = acf.parseArgs(args, {
+ fieldType: '',
+ operator: ''
+ });
+
+ // clonse available types
+ var types = [];
+
+ // loop
+ storage.map(function( type ){
+
+ // vars
+ var model = acf.getConditionType(type);
+ var ProtoFieldTypes = model.prototype.fieldTypes;
+ var ProtoOperator = model.prototype.operator;
+
+ // check fieldType
+ if( args.fieldType && ProtoFieldTypes.indexOf( args.fieldType ) === -1 ) {
+ return;
+ }
+
+ // check operator
+ if( args.operator && ProtoOperator !== args.operator ) {
+ return;
+ }
+
+ // append
+ types.push( model );
+ });
+
+ // return
+ return types;
+ };
+
+})(jQuery);
+
+(function($, undefined){
+
+ // vars
+ var CONTEXT = 'conditional_logic';
+
+ /**
+ * conditionsManager
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var conditionsManager = new acf.Model({
+
+ id: 'conditionsManager',
+
+ priority: 20, // run actions later
+
+ actions: {
+ 'new_field': 'onNewField',
+ },
+
+ onNewField: function( field ){
+ if( field.has('conditions') ) {
+ field.getConditions().render();
+ }
+ },
+ });
+
+ /**
+ * acf.Field.prototype.getField
+ *
+ * Finds a field that is related to another field
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var getSiblingField = function( field, key ){
+
+ // find sibling (very fast)
+ var fields = acf.getFields({
+ key: key,
+ sibling: field.$el,
+ suppressFilters: true,
+ });
+
+ // find sibling-children (fast)
+ // needed for group fields, accordions, etc
+ if( !fields.length ) {
+ fields = acf.getFields({
+ key: key,
+ parent: field.$el.parent(),
+ suppressFilters: true,
+ });
+ }
+
+ // return
+ if( fields.length ) {
+ return fields[0];
+ }
+ return false;
+ };
+
+ acf.Field.prototype.getField = function( key ){
+
+ // get sibling field
+ var field = getSiblingField( this, key );
+
+ // return early
+ if( field ) {
+ return field;
+ }
+
+ // move up through each parent and try again
+ var parents = this.parents();
+ for( var i = 0; i < parents.length; i++ ) {
+
+ // get sibling field
+ field = getSiblingField( parents[i], key );
+
+ // return early
+ if( field ) {
+ return field;
+ }
+ }
+
+ // return
+ return false;
+ };
+
+
+ /**
+ * acf.Field.prototype.getConditions
+ *
+ * Returns the field's conditions instance
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.Field.prototype.getConditions = function(){
+
+ // instantiate
+ if( !this.conditions ) {
+ this.conditions = new Conditions( this );
+ }
+
+ // return
+ return this.conditions;
+ };
+
+
+ /**
+ * Conditions
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+ var timeout = false;
+ var Conditions = acf.Model.extend({
+
+ id: 'Conditions',
+
+ data: {
+ field: false, // The field with "data-conditions" (target).
+ timeStamp: false, // Reference used during "change" event.
+ groups: [], // The groups of condition instances.
+ },
+
+ setup: function( field ){
+
+ // data
+ this.data.field = field;
+
+ // vars
+ var conditions = field.get('conditions');
+
+ // detect groups
+ if( conditions instanceof Array ) {
+
+ // detect groups
+ if( conditions[0] instanceof Array ) {
+
+ // loop
+ conditions.map(function(rules, i){
+ this.addRules( rules, i );
+ }, this);
+
+ // detect rules
+ } else {
+ this.addRules( conditions );
+ }
+
+ // detect rule
+ } else {
+ this.addRule( conditions );
+ }
+ },
+
+ change: function( e ){
+
+ // this function may be triggered multiple times per event due to multiple condition classes
+ // compare timestamp to allow only 1 trigger per event
+ if( this.get('timeStamp') === e.timeStamp ) {
+ return false;
+ } else {
+ this.set('timeStamp', e.timeStamp, true);
+ }
+
+ // render condition and store result
+ var changed = this.render();
+ },
+
+ render: function(){
+ return this.calculate() ? this.show() : this.hide();
+ },
+
+ show: function(){
+ return this.get('field').showEnable(this.cid, CONTEXT);
+ },
+
+ hide: function(){
+ return this.get('field').hideDisable(this.cid, CONTEXT);
+ },
+
+ calculate: function(){
+
+ // vars
+ var pass = false;
+
+ // loop
+ this.getGroups().map(function( group ){
+
+ // igrnore this group if another group passed
+ if( pass ) return;
+
+ // find passed
+ var passed = group.filter(function(condition){
+ return condition.calculate();
+ });
+
+ // if all conditions passed, update the global var
+ if( passed.length == group.length ) {
+ pass = true;
+ }
+ });
+
+ return pass;
+ },
+
+ hasGroups: function(){
+ return this.data.groups != null;
+ },
+
+ getGroups: function(){
+ return this.data.groups;
+ },
+
+ addGroup: function(){
+ var group = [];
+ this.data.groups.push( group );
+ return group;
+ },
+
+ hasGroup: function( i ){
+ return this.data.groups[i] != null;
+ },
+
+ getGroup: function( i ){
+ return this.data.groups[i];
+ },
+
+ removeGroup: function( i ){
+ this.data.groups[i].delete;
+ return this;
+ },
+
+ addRules: function( rules, group ){
+ rules.map(function( rule ){
+ this.addRule( rule, group );
+ }, this);
+ },
+
+ addRule: function( rule, group ){
+
+ // defaults
+ group = group || 0;
+
+ // vars
+ var groupArray;
+
+ // get group
+ if( this.hasGroup(group) ) {
+ groupArray = this.getGroup(group);
+ } else {
+ groupArray = this.addGroup();
+ }
+
+ // instantiate
+ var condition = acf.newCondition( rule, this );
+
+ // bail ealry if condition failed (field did not exist)
+ if( !condition ) {
+ return false;
+ }
+
+ // add rule
+ groupArray.push(condition);
+ },
+
+ hasRule: function(){
+
+ },
+
+ getRule: function( rule, group ){
+
+ // defaults
+ rule = rule || 0;
+ group = group || 0;
+
+ return this.data.groups[ group ][ rule ];
+ },
+
+ removeRule: function(){
+
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ var __ = acf.__;
+
+ var parseString = function( val ){
+ return val ? '' + val : '';
+ };
+
+ var isEqualTo = function( v1, v2 ){
+ return ( parseString(v1).toLowerCase() === parseString(v2).toLowerCase() );
+ };
+
+ var isEqualToNumber = function( v1, v2 ){
+ return ( parseFloat(v1) === parseFloat(v2) );
+ };
+
+ var isGreaterThan = function( v1, v2 ){
+ return ( parseFloat(v1) > parseFloat(v2) );
+ };
+
+ var isLessThan = function( v1, v2 ){
+ return ( parseFloat(v1) < parseFloat(v2) );
+ };
+
+ var inArray = function( v1, array ){
+
+ // cast all values as string
+ array = array.map(function(v2){
+ return parseString(v2);
+ });
+
+ return (array.indexOf( v1 ) > -1);
+ }
+
+ var containsString = function( haystack, needle ){
+ return ( parseString(haystack).indexOf( parseString(needle) ) > -1 );
+ };
+
+ var matchesPattern = function( v1, pattern ){
+ var regexp = new RegExp(parseString(pattern), 'gi');
+ return parseString(v1).match( regexp );
+ };
+
+ /**
+ * hasValue
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var HasValue = acf.Condition.extend({
+ type: 'hasValue',
+ operator: '!=empty',
+ label: __('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( rule, field ){
+ return (field.val() ? true : false);
+ },
+ choices: function( fieldObject ){
+ return ' ';
+ }
+ });
+
+ acf.registerConditionType( HasValue );
+
+ /**
+ * hasValue
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var HasNoValue = HasValue.extend({
+ type: 'hasNoValue',
+ operator: '==empty',
+ label: __('Has no value'),
+ match: function( rule, field ){
+ return !HasValue.prototype.match.apply(this, arguments);
+ }
+ });
+
+ acf.registerConditionType( HasNoValue );
+
+
+
+ /**
+ * EqualTo
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var EqualTo = acf.Condition.extend({
+ type: 'equalTo',
+ operator: '==',
+ label: __('Value is equal to'),
+ fieldTypes: [ 'text', 'textarea', 'number', 'range', 'email', 'url', 'password' ],
+ match: function( rule, field ){
+ if( $.isNumeric(rule.value) ) {
+ return isEqualToNumber( rule.value, field.val() );
+ } else {
+ return isEqualTo( rule.value, field.val() );
+ }
+ },
+ choices: function( fieldObject ){
+ return ' ';
+ }
+ });
+
+ acf.registerConditionType( EqualTo );
+
+ /**
+ * NotEqualTo
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var NotEqualTo = EqualTo.extend({
+ type: 'notEqualTo',
+ operator: '!=',
+ label: __('Value is not equal to'),
+ match: function( rule, field ){
+ return !EqualTo.prototype.match.apply(this, arguments);
+ }
+ });
+
+ acf.registerConditionType( NotEqualTo );
+
+ /**
+ * PatternMatch
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var PatternMatch = acf.Condition.extend({
+ type: 'patternMatch',
+ operator: '==pattern',
+ label: __('Value matches pattern'),
+ fieldTypes: [ 'text', 'textarea', 'email', 'url', 'password', 'wysiwyg' ],
+ match: function( rule, field ){
+ return matchesPattern( field.val(), rule.value );
+ },
+ choices: function( fieldObject ){
+ return ' ';
+ }
+ });
+
+ acf.registerConditionType( PatternMatch );
+
+ /**
+ * Contains
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var Contains = acf.Condition.extend({
+ type: 'contains',
+ operator: '==contains',
+ label: __('Value contains'),
+ fieldTypes: [ 'text', 'textarea', 'number', 'email', 'url', 'password', 'wysiwyg', 'oembed' ],
+ match: function( rule, field ){
+ return containsString( field.val(), rule.value );
+ },
+ choices: function( fieldObject ){
+ return ' ';
+ }
+ });
+
+ acf.registerConditionType( Contains );
+
+ /**
+ * TrueFalseEqualTo
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var TrueFalseEqualTo = EqualTo.extend({
+ type: 'trueFalseEqualTo',
+ choiceType: 'select',
+ fieldTypes: [ 'true_false' ],
+ choices: function( field ){
+ return [
+ {
+ id: 1,
+ text: __('Checked')
+ }
+ ];
+ },
+ });
+
+ acf.registerConditionType( TrueFalseEqualTo );
+
+ /**
+ * TrueFalseNotEqualTo
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var TrueFalseNotEqualTo = NotEqualTo.extend({
+ type: 'trueFalseNotEqualTo',
+ choiceType: 'select',
+ fieldTypes: [ 'true_false' ],
+ choices: function( field ){
+ return [
+ {
+ id: 1,
+ text: __('Checked')
+ }
+ ];
+ },
+ });
+
+ acf.registerConditionType( TrueFalseNotEqualTo );
+
+ /**
+ * SelectEqualTo
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var SelectEqualTo = acf.Condition.extend({
+ type: 'selectEqualTo',
+ operator: '==',
+ label: __('Value is equal to'),
+ fieldTypes: [ 'select', 'checkbox', 'radio', 'button_group' ],
+ match: function( rule, field ){
+ var val = field.val();
+ if( val instanceof Array ) {
+ return inArray( rule.value, val );
+ } else {
+ return isEqualTo( rule.value, val );
+ }
+ },
+ choices: function( fieldObject ){
+
+ // vars
+ var choices = [];
+ var lines = fieldObject.$setting('choices textarea').val().split("\n");
+
+ // allow null
+ if( fieldObject.$input('allow_null').prop('checked') ) {
+ choices.push({
+ id: '',
+ text: __('Null')
+ });
+ }
+
+ // loop
+ lines.map(function( line ){
+
+ // split
+ line = line.split(':');
+
+ // default label to value
+ line[1] = line[1] || line[0];
+
+ // append
+ choices.push({
+ id: $.trim( line[0] ),
+ text: $.trim( line[1] )
+ });
+ });
+
+ // return
+ return choices;
+ },
+ });
+
+ acf.registerConditionType( SelectEqualTo );
+
+ /**
+ * SelectNotEqualTo
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var SelectNotEqualTo = SelectEqualTo.extend({
+ type: 'selectNotEqualTo',
+ operator: '!=',
+ label: __('Value is not equal to'),
+ match: function( rule, field ){
+ return !SelectEqualTo.prototype.match.apply(this, arguments);
+ }
+ });
+
+ acf.registerConditionType( SelectNotEqualTo );
+
+ /**
+ * GreaterThan
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var GreaterThan = acf.Condition.extend({
+ type: 'greaterThan',
+ operator: '>',
+ label: __('Value is greater than'),
+ fieldTypes: [ 'number', 'range' ],
+ match: function( rule, field ){
+ var val = field.val();
+ if( val instanceof Array ) {
+ val = val.length;
+ }
+ return isGreaterThan( val, rule.value );
+ },
+ choices: function( fieldObject ){
+ return ' ';
+ }
+ });
+
+ acf.registerConditionType( GreaterThan );
+
+
+ /**
+ * LessThan
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var LessThan = GreaterThan.extend({
+ type: 'lessThan',
+ operator: '<',
+ label: __('Value is less than'),
+ match: function( rule, field ){
+ var val = field.val();
+ if( val instanceof Array ) {
+ val = val.length;
+ }
+ return isLessThan( val, rule.value );
+ },
+ choices: function( fieldObject ){
+ return ' ';
+ }
+ });
+
+ acf.registerConditionType( LessThan );
+
+ /**
+ * SelectedGreaterThan
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var SelectionGreaterThan = GreaterThan.extend({
+ type: 'selectionGreaterThan',
+ label: __('Selection is greater than'),
+ fieldTypes: [ 'checkbox', 'select', 'post_object', 'page_link', 'relationship', 'taxonomy', 'user' ],
+ });
+
+ acf.registerConditionType( SelectionGreaterThan );
+
+ /**
+ * SelectedGreaterThan
+ *
+ * description
+ *
+ * @date 1/2/18
+ * @since 5.6.5
+ *
+ * @param void
+ * @return void
+ */
+
+ var SelectionLessThan = LessThan.extend({
+ type: 'selectionLessThan',
+ label: __('Selection is less than'),
+ fieldTypes: [ 'checkbox', 'select', 'post_object', 'page_link', 'relationship', 'taxonomy', 'user' ],
+ });
+
+ acf.registerConditionType( SelectionLessThan );
+
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * acf.newMediaPopup
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.newMediaPopup = function( args ){
+
+ // args
+ var popup = null;
+ var args = acf.parseArgs(args, {
+ mode: 'select', // 'select', 'edit'
+ title: '', // 'Upload Image'
+ button: '', // 'Select Image'
+ type: '', // 'image', ''
+ field: false, // field instance
+ allowedTypes: '', // '.jpg, .png, etc'
+ library: 'all', // 'all', 'uploadedTo'
+ multiple: false, // false, true, 'add'
+ attachment: 0, // the attachment to edit
+ autoOpen: true, // open the popup automatically
+ open: function(){}, // callback after close
+ select: function(){}, // callback after select
+ close: function(){} // callback after close
+ });
+
+ // initialize
+ if( args.mode == 'edit' ) {
+ popup = new acf.models.EditMediaPopup( args );
+ } else {
+ popup = new acf.models.SelectMediaPopup( args );
+ }
+
+ // open popup (allow frame customization before opening)
+ if( args.autoOpen ) {
+ setTimeout(function(){
+ popup.open();
+ }, 1);
+ }
+
+ // action
+ acf.doAction('new_media_popup', popup);
+
+ // return
+ return popup;
+ };
+
+
+ /**
+ * getPostID
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var getPostID = function() {
+ var postID = acf.get('post_id');
+ return $.isNumeric(postID) ? postID : 0;
+ }
+
+
+ /**
+ * acf.getMimeTypes
+ *
+ * description
+ *
+ * @date 11/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.getMimeTypes = function(){
+ return this.get('mimeTypes');
+ };
+
+ acf.getMimeType = function( name ){
+
+ // vars
+ var allTypes = acf.getMimeTypes();
+
+ // search
+ if( allTypes[name] !== undefined ) {
+ return allTypes[name];
+ }
+
+ // some types contain a mixed key such as "jpg|jpeg|jpe"
+ for( var key in allTypes ) {
+ if( key.indexOf(name) !== -1 ) {
+ return allTypes[key];
+ }
+ }
+
+ // return
+ return false;
+ };
+
+
+ /**
+ * MediaPopup
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var MediaPopup = acf.Model.extend({
+
+ id: 'MediaPopup',
+ data: {},
+ defaults: {},
+ frame: false,
+
+ setup: function( props ){
+ $.extend(this.data, props);
+ },
+
+ initialize: function(){
+
+ // vars
+ var options = this.getFrameOptions();
+
+ // add states
+ this.addFrameStates( options );
+
+ // create frame
+ var frame = wp.media( options );
+
+ // add args reference
+ frame.acf = this;
+
+ // add events
+ this.addFrameEvents( frame, options );
+
+ // strore frame
+ this.frame = frame;
+ },
+
+ open: function(){
+ this.frame.open();
+ },
+
+ close: function(){
+ this.frame.close();
+ },
+
+ remove: function(){
+ this.frame.detach();
+ this.frame.dispose();
+ },
+
+ getFrameOptions: function(){
+
+ // vars
+ var options = {
+ title: this.get('title'),
+ multiple: this.get('multiple'),
+ library: {},
+ states: []
+ };
+
+ // type
+ if( this.get('type') ) {
+ options.library.type = this.get('type');
+ }
+
+ // type
+ if( this.get('library') === 'uploadedTo' ) {
+ options.library.uploadedTo = getPostID();
+ }
+
+ // attachment
+ if( this.get('attachment') ) {
+ options.library.post__in = [ this.get('attachment') ];
+ }
+
+ // button
+ if( this.get('button') ) {
+ options.button = {
+ text: this.get('button')
+ };
+ }
+
+ // return
+ return options;
+ },
+
+ addFrameStates: function( options ){
+
+ // create query
+ var Query = wp.media.query( options.library );
+
+ // add _acfuploader
+ // this is super wack!
+ // if you add _acfuploader to the options.library args, new uploads will not be added to the library view.
+ // this has been traced back to the wp.media.model.Query initialize function (which can't be overriden)
+ // Adding any custom args will cause the Attahcments to not observe the uploader queue
+ // To bypass this security issue, we add in the args AFTER the Query has been initialized
+ // options.library._acfuploader = settings.field;
+ if( this.get('field') && acf.isset(Query, 'mirroring', 'args') ) {
+ Query.mirroring.args._acfuploader = this.get('field');
+ }
+
+ // add states
+ options.states.push(
+
+ // main state
+ new wp.media.controller.Library({
+ library: Query,
+ multiple: this.get('multiple'),
+ title: this.get('title'),
+ priority: 20,
+ filterable: 'all',
+ editable: true,
+ allowLocalEdits: true
+ })
+
+ );
+
+ // edit image functionality (added in WP 3.9)
+ if( acf.isset(wp, 'media', 'controller', 'EditImage') ) {
+ options.states.push( new wp.media.controller.EditImage() );
+ }
+ },
+
+ addFrameEvents: function( frame, options ){
+
+ // log all events
+ //frame.on('all', function( e ) {
+ // console.log( 'frame all: %o', e );
+ //});
+
+ // add class
+ frame.on('open',function() {
+ this.$el.closest('.media-modal').addClass('acf-media-modal -' + this.acf.get('mode') );
+ }, frame);
+
+ // edit image view
+ // source: media-views.js:2410 editImageContent()
+ frame.on('content:render:edit-image', function(){
+
+ var image = this.state().get('image');
+ var view = new wp.media.view.EditImage({ model: image, controller: this }).render();
+ this.content.set( view );
+
+ // after creating the wrapper view, load the actual editor via an ajax call
+ view.loadEditor();
+
+ }, frame);
+
+ // update toolbar button
+/*
+ frame.on( 'toolbar:create:select', function( toolbar ) {
+
+ toolbar.view = new wp.media.view.Toolbar.Select({
+ text: frame.options._button,
+ controller: this
+ });
+
+ }, frame );
+*/
+ // on select
+ frame.on('select', function() {
+
+ // vars
+ var selection = frame.state().get('selection');
+
+ // if selecting images
+ if( selection ) {
+
+ // loop
+ selection.each(function( attachment, i ){
+ frame.acf.get('select').apply( frame.acf, [attachment, i] );
+ });
+ }
+ });
+
+ // on close
+ frame.on('close',function(){
+
+ // callback and remove
+ setTimeout(function(){
+ frame.acf.get('close').apply( frame.acf );
+ frame.acf.remove();
+ }, 1);
+ });
+ }
+ });
+
+
+ /**
+ * acf.models.SelectMediaPopup
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.models.SelectMediaPopup = MediaPopup.extend({
+ id: 'SelectMediaPopup',
+ setup: function( props ){
+
+ // default button
+ if( !props.button ) {
+ props.button = acf._x('Select', 'verb');
+ }
+
+ // parent
+ MediaPopup.prototype.setup.apply(this, arguments);
+ },
+
+ addFrameEvents: function( frame, options ){
+
+ // plupload
+ // adds _acfuploader param to validate uploads
+ if( acf.isset(_wpPluploadSettings, 'defaults', 'multipart_params') ) {
+
+ // add _acfuploader so that Uploader will inherit
+ _wpPluploadSettings.defaults.multipart_params._acfuploader = this.get('field');
+
+ // remove acf_field so future Uploaders won't inherit
+ frame.on('open', function(){
+ delete _wpPluploadSettings.defaults.multipart_params._acfuploader;
+ });
+ }
+
+ // browse
+ frame.on('content:activate:browse', function(){
+
+ // vars
+ var toolbar = false;
+
+ // populate above vars making sure to allow for failure
+ // perhaps toolbar does not exist because the frame open is Upload Files
+ try {
+ toolbar = frame.content.get().toolbar;
+ } catch(e) {
+ console.log(e);
+ return;
+ }
+
+ // callback
+ frame.acf.customizeFilters.apply(frame.acf, [toolbar]);
+ });
+
+ // parent
+ MediaPopup.prototype.addFrameEvents.apply(this, arguments);
+
+ },
+
+ customizeFilters: function( toolbar ){
+
+ // vars
+ var filters = toolbar.get('filters');
+
+ // image
+ if( this.get('type') == 'image' ) {
+
+ // update all
+ filters.filters.all.text = acf.__('All images');
+
+ // remove some filters
+ delete filters.filters.audio;
+ delete filters.filters.video;
+ delete filters.filters.image;
+
+ // update all filters to show images
+ $.each(filters.filters, function( i, filter ){
+ filter.props.type = filter.props.type || 'image';
+ });
+ }
+
+ // specific types
+ if( this.get('allowedTypes') ) {
+
+ // convert ".jpg, .png" into ["jpg", "png"]
+ var allowedTypes = this.get('allowedTypes').split(' ').join('').split('.').join('').split(',');
+
+ // loop
+ allowedTypes.map(function( name ){
+
+ // get type
+ var mimeType = acf.getMimeType( name );
+
+ // bail early if no type
+ if( !mimeType ) return;
+
+ // create new filter
+ var newFilter = {
+ text: mimeType,
+ props: {
+ status: null,
+ type: mimeType,
+ uploadedTo: null,
+ orderby: 'date',
+ order: 'DESC'
+ },
+ priority: 20
+ };
+
+ // append
+ filters.filters[ mimeType ] = newFilter;
+
+ });
+ }
+
+
+
+ // uploaded to post
+ if( this.get('library') === 'uploadedTo' ) {
+
+ // vars
+ var uploadedTo = this.frame.options.library.uploadedTo;
+
+ // remove some filters
+ delete filters.filters.unattached;
+ delete filters.filters.uploaded;
+
+ // add uploadedTo to filters
+ $.each(filters.filters, function( i, filter ){
+ filter.text += ' (' + acf.__('Uploaded to this post') + ')';
+ filter.props.uploadedTo = uploadedTo;
+ });
+ }
+
+ // add _acfuploader to filters
+ var field = this.get('field');
+ $.each(filters.filters, function( k, filter ){
+ filter.props._acfuploader = field;
+ });
+
+ // add _acfuplaoder to search
+ var search = toolbar.get('search');
+ search.model.attributes._acfuploader = field;
+
+ // render (custom function added to prototype)
+ if( filters.renderFilters ) {
+ filters.renderFilters();
+ }
+ }
+ });
+
+
+ /**
+ * acf.models.EditMediaPopup
+ *
+ * description
+ *
+ * @date 10/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.models.EditMediaPopup = MediaPopup.extend({
+ id: 'SelectMediaPopup',
+ setup: function( props ){
+
+ // default button
+ if( !props.button ) {
+ props.button = acf._x('Update', 'verb');
+ }
+
+ // parent
+ MediaPopup.prototype.setup.apply(this, arguments);
+ },
+
+ addFrameEvents: function( frame, options ){
+
+ // add class
+ frame.on('open',function() {
+
+ // add class
+ this.$el.closest('.media-modal').addClass('acf-expanded');
+
+ // set to browse
+ if( this.content.mode() != 'browse' ) {
+ this.content.mode('browse');
+ }
+
+ // set selection
+ var state = this.state();
+ var selection = state.get('selection');
+ var attachment = wp.media.attachment( frame.acf.get('attachment') );
+ selection.add( attachment );
+
+ }, frame);
+
+ // parent
+ MediaPopup.prototype.addFrameEvents.apply(this, arguments);
+
+ }
+ });
+
+
+ /**
+ * customizePrototypes
+ *
+ * description
+ *
+ * @date 11/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var customizePrototypes = new acf.Model({
+ id: 'customizePrototypes',
+ wait: 'ready',
+
+ initialize: function(){
+
+ // bail early if no media views
+ if( !acf.isset(wp, 'media', 'view') ) {
+ return;
+ }
+
+ // customize
+ this.customizeAttachmentsRouter();
+ this.customizeAttachmentFilters();
+ this.customizeAttachmentCompat();
+ this.customizeAttachmentLibrary();
+ },
+
+ customizeAttachmentsRouter: function(){
+
+ // validate
+ if( !acf.isset(wp, 'media', 'view', 'Router') ) {
+ return;
+ }
+
+ // vars
+ var Parent = wp.media.view.Router;
+
+ // extend
+ wp.media.view.Router = Parent.extend({
+
+ addExpand: function(){
+
+ // vars
+ var $a = $([
+ ' ',
+ ' ' + acf.__('Expand Details') + ' ',
+ ' ' + acf.__('Collapse Details') + ' ',
+ ' '
+ ].join(''));
+
+ // add events
+ $a.on('click', function( e ){
+ e.preventDefault();
+ var $div = $(this).closest('.media-modal');
+ if( $div.hasClass('acf-expanded') ) {
+ $div.removeClass('acf-expanded');
+ } else {
+ $div.addClass('acf-expanded');
+ }
+ });
+
+ // append
+ this.$el.append( $a );
+ },
+
+ initialize: function(){
+
+ // initialize
+ Parent.prototype.initialize.apply( this, arguments );
+
+ // add buttons
+ this.addExpand();
+
+ // return
+ return this;
+ }
+ });
+ },
+
+ customizeAttachmentFilters: function(){
+
+ // validate
+ if( !acf.isset(wp, 'media', 'view', 'AttachmentFilters', 'All') ) {
+ return;
+ }
+
+ // vars
+ var Parent = wp.media.view.AttachmentFilters.All;
+
+ // renderFilters
+ // copied from media-views.js:6939
+ Parent.prototype.renderFilters = function(){
+
+ // Build `` elements.
+ this.$el.html( _.chain( this.filters ).map( function( filter, value ) {
+ return {
+ el: $( ' ' ).val( value ).html( filter.text )[0],
+ priority: filter.priority || 50
+ };
+ }, this ).sortBy('priority').pluck('el').value() );
+
+ };
+ },
+
+ customizeAttachmentCompat: function(){
+
+ // validate
+ if( !acf.isset(wp, 'media', 'view', 'AttachmentCompat') ) {
+ return;
+ }
+
+ // vars
+ var AttachmentCompat = wp.media.view.AttachmentCompat;
+ var timeout = false;
+
+ // extend
+ wp.media.view.AttachmentCompat = AttachmentCompat.extend({
+
+ render: function() {
+
+ // WP bug
+ // When multiple media frames exist on the same page (WP content, WYSIWYG, image, file ),
+ // WP creates multiple instances of this AttachmentCompat view.
+ // Each instance will attempt to render when a new modal is created.
+ // Use a property to avoid this and only render once per instance.
+ if( this.rendered ) {
+ //console.log('ignore render', this.cid);
+ return this;
+ }
+ this.rendered = true;
+
+ // render
+ //console.log('render', this.cid);
+ AttachmentCompat.prototype.render.apply( this, arguments );
+
+ // clear timeout
+ clearTimeout( timeout );
+
+ // setTimeout
+ timeout = setTimeout($.proxy(function(){
+
+ // check if element is visible to avoid logic on previous instances (which are hidden)
+ if( this.$el.is(':visible') ) {
+ //console.log('append', this.cid);
+ acf.doAction('append', this.$el);
+ }
+
+ }, this), 50);
+
+ // return
+ return this;
+ },
+
+ // commented out function causing JS errors when navigating through media grid
+ // dispose (and remove) are called after the element has been detached, so this only causes extra JS initialization
+ dispose: function(){
+
+ // remove
+ if( this.$el.is(':visible') ) {
+ //acf.doAction('remove', this.$el);
+ console.log('removed visible');
+ }
+ // dispose
+ return AttachmentCompat.prototype.dispose.apply( this, arguments );
+ }
+
+ });
+
+ },
+
+ customizeAttachmentLibrary: function(){
+
+ // validate
+ if( !acf.isset(wp, 'media', 'view', 'Attachment', 'Library') ) {
+ return;
+ }
+
+ // vars
+ var AttachmentLibrary = wp.media.view.Attachment.Library;
+
+ // extend
+ wp.media.view.Attachment.Library = AttachmentLibrary.extend({
+
+ render: function() {
+
+ // vars
+ var popup = acf.isget(this, 'controller', 'acf');
+ var attributes = acf.isget(this, 'model', 'attributes');
+
+ // check vars exist to avoid errors
+ if( popup && attributes ) {
+
+ // show errors
+ if( attributes.acf_errors ) {
+ this.$el.addClass('acf-disabled');
+ }
+
+ // disable selected
+ var selected = popup.get('selected');
+ if( selected && selected.indexOf(attributes.id) > -1 ) {
+ this.$el.addClass('acf-selected');
+ }
+ }
+
+ // render
+ return AttachmentLibrary.prototype.render.apply( this, arguments );
+
+ },
+
+
+ /*
+ * toggleSelection
+ *
+ * This function is called before an attachment is selected
+ * A good place to check for errors and prevent the 'select' function from being fired
+ *
+ * @type function
+ * @date 29/09/2016
+ * @since 5.4.0
+ *
+ * @param options (object)
+ * @return n/a
+ */
+
+ toggleSelection: function( options ) {
+
+ // vars
+ // source: wp-includes/js/media-views.js:2880
+ var collection = this.collection,
+ selection = this.options.selection,
+ model = this.model,
+ single = selection.single();
+
+
+ // vars
+ var frame = this.controller;
+ var errors = acf.isget(this, 'model', 'attributes', 'acf_errors');
+ var $sidebar = frame.$el.find('.media-frame-content .media-sidebar');
+
+ // remove previous error
+ $sidebar.children('.acf-selection-error').remove();
+
+ // show attachment details
+ $sidebar.children().removeClass('acf-hidden');
+
+ // add message
+ if( frame && errors ) {
+
+ // vars
+ var filename = acf.isget(this, 'model', 'attributes', 'filename');
+
+ // hide attachment details
+ // Gallery field continues to show previously selected attachment...
+ $sidebar.children().addClass('acf-hidden');
+
+ // append message
+ $sidebar.prepend([
+ '',
+ '' + acf.__('Restricted') +' ',
+ '' + filename + ' ',
+ '' + errors + ' ',
+ '
'
+ ].join(''));
+
+ // reset selection (unselects all attachments)
+ selection.reset();
+
+ // set single (attachment displayed in sidebar)
+ selection.single( model );
+
+ // return and prevent 'select' form being fired
+ return;
+
+ }
+
+ // return
+ return AttachmentLibrary.prototype.toggleSelection.apply( this, arguments );
+ }
+ });
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ acf.screen = new acf.Model({
+
+ active: true,
+
+ xhr: false,
+
+ 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: {
//'post_id': 0,
//'page_template': 0,
//'page_parent': 0,
@@ -4339,186 +10401,110 @@ var acf;
//'post_format': 0,
//'post_taxonomy': 0
},
- xhr: null,
-
- update: function( k, v ){
- this.o[ k ] = v;
-
- return this;
-
- },
-
- get: function( k ){
-
- return this.o[ k ] || null;
-
- },
-
- ready: function(){
-
- // update post_id
- this.update('post_id', acf.get('post_id'));
-
-
- // active
- this.active = true;
-
- },
-
-/*
- timeout: null,
- maybe_fetch: function(){
-
- // reference
- var self = this;
-
-
- // abort timeout
- if( this.timeout ) {
-
- clearTimeout( this.timeout );
-
- }
-
-
- // fetch
- this.timeout = setTimeout(function(){
-
- self.fetch();
-
- }, 100);
-
- },
-*/
-
fetch: function(){
// bail early if not active
- if( !this.active ) return;
+ if( !this.active ) {
+ return;
+ }
// bail early if not for post
- if( acf.get('screen') !== 'post' ) return;
-
- // bail early if no ajax
- if( !acf.get('ajax') ) return;
-
+ if( acf.get('screen') !== 'post' ) {
+ return;
+ }
// abort XHR if is already loading AJAX data
if( this.xhr ) {
-
this.xhr.abort();
-
}
-
// vars
- var self = this,
- data = this.o;
-
-
- // add action url
- data.action = 'acf/post/get_field_groups';
-
-
- // add ignore
- data.exists = [];
-
- $('.acf-postbox').not('.acf-hidden').each(function(){
-
- data.exists.push( $(this).attr('id').substr(4) );
-
+ var ajaxData = acf.parseArgs(this.data, {
+ post_id: acf.get('post_id')
});
+ // add action url
+ ajaxData.action = 'acf/post/get_field_groups';
+
+ // add ignore
+ ajaxData.exists = [];
+ $('.acf-postbox').not('.acf-hidden').each(function(){
+ ajaxData.exists.push( $(this).attr('id').substr(4) );
+ });
+
+ // success
+ var onSuccess = function( json ){
+
+ // bail early if not success
+ if( !acf.isAjaxSuccess(json) ) {
+ return;
+ }
+
+ // hide
+ $('.acf-postbox').addClass('acf-hidden');
+ $('.acf-postbox-toggle').addClass('acf-hidden');
+
+ // reset style
+ $('#acf-style').html('');
+
+ // loop
+ json.data.map(function( fieldGroup, i ){
+
+ // vars
+ var $postbox = $('#acf-' + fieldGroup.key);
+ var $toggle = $('#acf-' + fieldGroup.key + '-hide');
+ var $label = $toggle.parent();
+
+ // show
+ // use show() to force display when postbox has been hidden by 'Show on screen' toggle
+ $postbox.removeClass('acf-hidden hide-if-js').show();
+ $label.removeClass('acf-hidden hide-if-js').show();
+ $toggle.prop('checked', true);
+
+ // replace HTML if needed
+ var $replace = $postbox.find('.acf-replace-with-fields');
+ if( $replace.exists() ) {
+ $replace.replaceWith( fieldGroup.html );
+ acf.doAction('append', $postbox);
+ }
+
+ // update style if needed
+ if( i === 0 ) {
+ $('#acf-style').html( fieldGroup.style );
+ }
+
+ // enable inputs
+ acf.enable( $postbox, 'postbox' );
+ });
+ };
+
+ // complete
+ var onComplete = function( json ){
+
+ // disable inputs
+ $('.acf-postbox.acf-hidden').each(function(){
+ acf.disable( $(this), 'postbox' );
+ });
+ };
// ajax
this.xhr = $.ajax({
- url: acf.get('ajaxurl'),
- data: acf.prepare_for_ajax( data ),
- type: 'post',
- dataType: 'json',
-
- success: function( json ){
-
- if( acf.is_ajax_success( json ) ) {
-
- self.render( json.data );
-
- }
-
- }
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax( ajaxData ),
+ type: 'post',
+ dataType: 'json',
+ context: this,
+ success: onSuccess,
+ complete: onComplete
});
-
},
- render: function( json ){
-
- // hide
- $('.acf-postbox').addClass('acf-hidden');
- $('.acf-postbox-toggle').addClass('acf-hidden');
-
-
- // reset style
- $('#acf-style').html('');
-
-
- // show the new postboxes
- $.each(json, function( k, field_group ){
-
- // vars
- var $postbox = $('#acf-' + field_group.key),
- $toggle = $('#acf-' + field_group.key + '-hide'),
- $label = $toggle.parent();
-
-
- // show
- // use show() to force display when postbox has been hidden by 'Show on screen' toggle
- $postbox.removeClass('acf-hidden hide-if-js').show();
- $label.removeClass('acf-hidden hide-if-js').show();
- $toggle.prop('checked', true);
-
-
- // replace HTML if needed
- var $replace = $postbox.find('.acf-replace-with-fields');
-
- if( $replace.exists() ) {
-
- $replace.replaceWith( field_group.html );
-
- acf.do_action('append', $postbox);
-
- }
-
-
- // update style if needed
- if( k === 0 ) {
-
- $('#acf-style').html( field_group.style );
-
- }
-
-
- // enable inputs
- $postbox.find('.acf-hidden-by-postbox').prop('disabled', false);
-
- });
-
-
- // disable inputs
- $('.acf-postbox.acf-hidden').find('select, textarea, input').not(':disabled').each(function(){
-
- $(this).addClass('acf-hidden-by-postbox').prop('disabled', true);
-
- });
-
- },
-
- sync_taxonomy_terms: function(){
+ syncTaxonomyTerms: function(){
// vars
var values = [''];
-
// loop over term lists
$('.categorychecklist, .acf-taxonomy-field').each(function(){
@@ -4592,5879 +10578,811 @@ var acf;
// filter duplicates
- values = values.filter (function (v, i, a) { return a.indexOf (v) == i });
+ values = values.filter(function(item, pos, self) {
+ return self.indexOf(item) == pos;
+ });
// update screen
- this.update( 'post_taxonomy', values ).fetch();
-
+ this.set( 'post_taxonomy', values ).fetch();
},
-
- /*
- * events
- *
- * description
- *
- * @type function
- * @date 29/09/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- _change_template: function( e ){
-
- // vars
- var page_template = e.$el.val();
-
+ onChangeTemplate: function( e, $el ){
// update & fetch
- this.update('page_template', page_template).fetch();
-
+ this.set('page_template', $el.val()).fetch();
},
- _change_parent: function( e ){
+ onChangeParent: function( e, $el ){
// vars
- var page_type = 'parent',
- page_parent = 0;
-
+ var pageType = 'parent';
+ var pageParent = 0;
// if is child
- if( e.$el.val() != "" ) {
-
- page_type = 'child';
- page_parent = e.$el.val();
-
+ if( $el.val() != "" ) {
+ pageType = 'child';
+ pageParent = $el.val();
}
// update & fetch
- this.update('page_type', page_type).update('page_parent', page_parent).fetch();
-
+ this.set('page_type', pageType).set('page_parent', pageParent).fetch();
},
- _change_format: function( e ){
+ onChangeFormat: function( e, $el ){
// vars
- var post_format = e.$el.val();
-
+ var postFormat = $el.val();
// default
- if( post_format == '0' ) {
-
- post_format = 'standard';
-
+ if( postFormat == '0' ) {
+ postFormat = 'standard';
}
-
// update & fetch
- this.update('post_format', post_format).fetch();
-
+ this.set('post_format', postFormat).fetch();
},
- _change_term: function( e ){
-
- // reference
- var self = this;
-
+ onChangeTerm: function( e, $el ){
// bail early if within media popup
- if( e.$el.closest('.media-frame').exists() ) {
-
+ if( $el.closest('.media-frame').exists() ) {
return;
-
}
-
// set timeout to fix issue with chrome which does not register the change has yet happened
- setTimeout(function(){
-
- self.sync_taxonomy_terms();
-
- }, 1);
-
-
+ this.setTimeout(this.syncTaxonomyTerms, 1);
}
-
- });
-
-
-})(jQuery);
-
-(function($){
-
- acf.fields.button_group = acf.field.extend({
-
- type: 'button_group',
- $div: null,
-
- events: {
- 'click input[type="radio"]': 'click'
- },
-
- focus: function(){
-
- // focus on $select
- this.$div = this.$field.find('.acf-button-group');
-
-
- // get options
- this.o = acf.get_data(this.$div, {
- allow_null: 0
- });
-
- },
-
- click: function( e ){
-
- // vars
- var $radio = e.$el;
- var $label = $radio.parent('label');
- var selected = $label.hasClass('selected');
-
-
- // remove previous selected
- this.$div.find('.selected').removeClass('selected');
-
-
- // add active class
- $label.addClass('selected');
-
-
- // allow null
- if( this.o.allow_null && selected ) {
-
- // unselect
- e.$el.prop('checked', false);
- $label.removeClass('selected');
-
-
- // trigger change
- e.$el.trigger('change');
-
- }
-
- }
-
- });
-
-})(jQuery);
-
-(function($){
-
- acf.fields.checkbox = acf.field.extend({
-
- type: 'checkbox',
-
- events: {
- 'change input': '_change',
- 'click .acf-add-checkbox': '_add'
- },
-
-
- /*
- * focus
- *
- * This function will setup variables when focused on a field
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- focus: function(){
-
- // get elements
- this.$ul = this.$field.find('ul');
- this.$input = this.$field.find('input[type="hidden"]');
-
- },
-
-
- add: function(){
-
- // vars
- var name = this.$input.attr('name') + '[]';
-
-
- // vars
- var html = ' ';
-
-
- // append
- this.$ul.find('.acf-add-checkbox').parent('li').before( html );
-
- },
-
- _change: function( e ){
-
- // vars
- var $ul = this.$ul,
- $inputs = $ul.find('input[type="checkbox"]').not('.acf-checkbox-toggle'),
- checked = e.$el.is(':checked');
-
-
- // is toggle?
- if( e.$el.hasClass('acf-checkbox-toggle') ) {
-
- // toggle all
- $inputs.prop('checked', checked).trigger('change');
-
-
- // return
- return;
-
- }
-
-
- // is custom
- if( e.$el.hasClass('acf-checkbox-custom') ) {
-
- // vars
- var $text = e.$el.next('input[type="text"]');
-
-
- // toggle disabled
- e.$el.next('input[type="text"]').prop('disabled', !checked);
-
-
- // remove complelety if no value
- if( !checked && $text.val() == '' ) {
-
- e.$el.parent('li').remove();
-
- }
- }
-
-
- // bail early if no toggle
- if( !$ul.find('.acf-checkbox-toggle').exists() ) {
-
- return;
-
- }
-
-
- // determine if all inputs are checked
- var checked = ( $inputs.not(':checked').length == 0 );
-
-
- // update toggle
- $ul.find('.acf-checkbox-toggle').prop('checked', checked);
-
- },
-
- _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(){
-
- // reference
- var $input = this.$input,
- $hidden = this.$hidden;
-
-
- // trigger change function
- var change_hidden = function(){
-
- // timeout is required to ensure the $input val is correct
- setTimeout(function(){
-
- acf.val( $hidden, $input.val() );
-
- }, 1);
-
- }
-
-
- // args
- var args = {
-
- defaultColor: false,
- palettes: true,
- hide: true,
- change: change_hidden,
- clear: change_hidden
-
- }
-
-
- // filter
- var args = acf.apply_filters('color_picker_args', args, this.$field);
-
-
- // iris
- this.$input.wpColorPicker(args);
-
- }
-
});
})(jQuery);
(function($, undefined){
- // constants
- var CLASS = 'hidden-by-conditional-logic';
- var CONTEXT = 'conditional_logic';
-
- // model
- var conditionalLogic = acf.conditional_logic = acf.model.extend({
-
- // storage of fields that have conditions
- conditions: {},
-
- // storage of fields that trigger a condition
- triggers: {},
-
- // reference to parent element of both the trigger and target
- $parent: false,
-
- // actions
- actions: {
- 'prepare 20': 'render',
- 'append 20': 'render',
- 'change': 'change'
- },
-
-
- /*
- * add
- *
- * This function will add a set of conditional logic rules
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param string target field key
- * @param array conditions array of conditional logic groups
- * @return $post_id (int)
- */
-
- add: function( target, conditions ){
-
- // add triggers
- for( var i in conditions ) {
- var group = conditions[i];
-
- for( var k in group ) {
- var rule = group[k];
-
- this.addTrigger( rule.field, target );
- }
- }
-
-
- // add condition
- this.setCondition( target, conditions );
-
- },
-
-
- /**
- * getTrigger
- *
- * This function will return the fields that are triggered by this key.
- *
- * @date 15/11/17
- * @since 5.6.5
- *
- * @param string key The trigger's key.
- * @return mixed
- */
-
- getTrigger: function( key ){
- return this.triggers[ key ] || null;
- },
-
-
- /**
- * setTrigger
- *
- * This function will set the fields that are triggered by this key.
- *
- * @date 15/11/17
- * @since 5.6.5
- *
- * @param string key The trigger's key.
- * @return mixed
- */
-
- setTrigger: function( key, value ){
- this.triggers[ key ] = value;
- },
-
-
- /**
- * addTrigger
- *
- * This function will add a reference for a field that triggers another field's visibility
- *
- * @date 15/11/17
- * @since 5.6.5
- *
- * @param n/a
- * @return n/a
- */
-
- addTrigger: function( trigger, target ){
-
- // vars
- var triggers = this.getTrigger( trigger ) || {};
-
- // append
- triggers[ target ] = 1;
-
- // set
- this.setTrigger(trigger, triggers);
-
- },
-
-
- /**
- * getConditions
- *
- * This function will return the conditions for all targets.
- *
- * @date 15/11/17
- * @since 5.6.5
- *
- * @param string key The trigger's key.
- * @return mixed
- */
-
- getConditions: function(){
- return this.conditions;
- },
-
-
- /**
- * getCondition
- *
- * This function will return the conditions for a target.
- *
- * @date 15/11/17
- * @since 5.6.5
- *
- * @param string key The trigger's key.
- * @return mixed
- */
-
- getCondition: function( key ){
- return this.conditions[ key ] || null;
- },
-
-
- /**
- * setCondition
- *
- * This function will set the conditions for a target.
- *
- * @date 15/11/17
- * @since 5.6.5
- *
- * @param string key The trigger's key.
- * @return mixed
- */
-
- setCondition: function( key, value ){
- this.conditions[ key ] = value;
- },
-
-
- /*
- * render
- *
- * This function will render all fields
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- render: function( $el ){
-
- // vars
- $el = $el || false;
-
- // get targets
- var $targets = acf.get_fields( '', $el, true );
-
- // render fields
- this.renderFields( $targets );
-
- // action for 3rd party customization
- acf.do_action('refresh', $el);
-
- },
-
-
- /**
- * findParent
- *
- * This function will find a parent that contains both the trigger and target
- *
- * @date 15/11/17
- * @since 5.6.5
- *
- * @param n/a
- * @return n/a
- */
-
- findTarget: function( $trigger, target ){
-
- // vars
- var self = this;
-
- // reset scope
- this.$parent = false;
-
-
- // find siblings
- var selector = acf.get_selector( target );
- var $targets = $trigger.siblings( selector );
-
- // return if found
- if( $targets.length ) {
- this.$parent = $trigger.parent();
- return $targets;
- }
-
-
- // find all targets
- var $targets = acf.get_fields(target, false, true);
-
- // refine scope if more than 1 found
- if( $targets.length > 1 ) {
-
- // loop
- $trigger.parents('.acf-row, .acf-table, .acf-fields').each(function(){
-
- // vars
- var $parent = $(this);
- var $child = $parent.find( $targets );
-
- // found
- if( $child.length ) {
- $targets = $child;
- self.$parent = $parent;
- return false;
- }
-
- });
-
- }
-
- // return
- return $targets;
-
- },
-
-
- /*
- * change
- *
- * This function is called when an input is changed and will render any fields which are considered targets of this trigger
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- change: function( $input ){
-
- // vars
- var $trigger = acf.get_field_wrap($input);
- var key = $trigger.data('key');
- var trigger = this.getTrigger(key);
-
- // bail early if this field is not a trigger
- if( !trigger ) return false;
-
- // loop
- for( var target in trigger ) {
-
- // get target(s)
- var $targets = this.findTarget( $trigger, target );
-
- // render
- this.renderFields( $targets );
-
- }
-
- // action for 3rd party customization
- acf.do_action('refresh', this.$parent);
-
- },
-
-
- /*
- * renderFields
- *
- * This function will render a selection of fields
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- renderFields: function( $targets ) {
-
- // reference
- var self = this;
-
- // loop
- $targets.each(function(){
- self.renderField( $(this) );
- });
-
- },
-
-
- /*
- * render_field
- *
- * This function will render a field
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- renderField : function( $target ){
-
- // vars
- var visibility = false;
- var key = $target.data('key');
- var condition = this.getCondition( key );
-
- // bail early if this field does not contain any conditional logic
- if( !condition ) return false;
-
- // loop
- for( var i = 0; i < condition.length; i++ ) {
-
- // vars
- var group = condition[i],
- match_group = true;
-
- // loop
- for( var k = 0; k < group.length; k++ ) {
-
- // vars
- var rule = group[k];
-
- // get trigger for rule
- var $trigger = this.findTarget( $target, rule.field );
-
- // break if rule did not validate
- if( !this.calculate(rule, $trigger, $target) ) {
- match_group = false;
- break;
- }
- }
-
- // set visibility if rule group did validate
- if( match_group ) {
- visibility = true;
- break;
- }
- }
-
- // hide / show
- if( visibility ) {
- this.showField( $target, key );
- } else {
- this.hideField( $target, key );
- }
-
- },
-
-
- /*
- * show_field
- *
- * This function will show a field
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- showField: function( $field, lockKey ){
-
- // enable
- acf.enable( $field, lockKey );
-
- // show field and store result
- var changed = acf.show( $field, lockKey );
-
- // use changed to set cl class
- if( changed ) {
- $field.removeClass( CLASS );
- }
-
- // always do action to avoid tab field bugs (fixed in 5.7)
- acf.do_action('show_field', $field, CONTEXT);
-
- // return
- return changed;
- },
-
-
- /*
- * hide_field
- *
- * This function will hide a field
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- hideField: function( $field, lockKey ){
-
- // disable
- acf.disable( $field, lockKey );
-
- // hide field and store result
- var changed = acf.hide( $field, lockKey );
-
- // use changed to set cl class
- if( changed ) {
- $field.addClass( CLASS );
- }
-
- // always do action to avoid tab field bugs (fixed in 5.7)
- acf.do_action('hide_field', $field, CONTEXT);
-
- // return
- return changed;
- },
-
-
- /*
- * calculate
- *
- * This function will calculate if a rule matches based on the $trigger
- *
- * @type function
- * @date 22/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- calculate: function( rule, $trigger, $target ){
-
- // bail early if $trigger could not be found
- if( !$trigger || !$target ) return false;
-
-
- // debug
- //console.log( 'calculate(%o, %o, %o)', rule, $trigger, $target);
-
-
- // vars
- var match = false,
- type = $trigger.data('type');
-
-
- // input with :checked
- if( type == 'true_false' || type == 'checkbox' || type == 'radio' || type == 'button_group' ) {
-
- match = this.calculate_checkbox( rule, $trigger );
-
-
- } else if( type == 'select' ) {
-
- match = this.calculate_select( rule, $trigger );
-
- }
-
-
- // reverse if 'not equal to'
- if( rule.operator === "!=" ) {
-
- match = !match;
-
- }
-
-
- // return
- return match;
-
- },
-
- calculate_checkbox: function( rule, $trigger ){
-
- // look for selected input
- var match = $trigger.find('input[value="' + rule.value + '"]:checked').exists();
-
-
- // override for "allow null"
- if( rule.value === '' && !$trigger.find('input:checked').exists() ) {
-
- match = true;
-
- }
-
-
- // return
- return match;
-
- },
-
-
- calculate_select: function( rule, $trigger ){
-
- // vars
- var $select = $trigger.find('select'),
- val = $select.val();
-
-
- // check for no value
- if( !val && !$.isNumeric(val) ) {
-
- val = '';
-
- }
-
-
- // convert to array
- if( !$.isArray(val) ) {
-
- val = [ val ];
-
- }
-
-
- // calc
- match = ($.inArray(rule.value, val) > -1);
-
-
- // return
- return match;
-
- }
-
- });
-
-
- // compatibility
- conditionalLogic.show_field = conditionalLogic.showField;
- conditionalLogic.hide_field = conditionalLogic.hideField;
-
-
-})(jQuery);
-
-(function($){
-
- /*
- * acf.datepicker
+ /**
+ * acf.newSelect2
*
* description
*
- * @type function
- * @date 16/12/2015
- * @since 5.3.2
+ * @date 13/1/18
+ * @since 5.6.5
*
- * @param $post_id (int)
- * @return $post_id (int)
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- acf.datepicker = acf.model.extend({
+ acf.newSelect2 = function( $select, props ){
- actions: {
- 'ready 1': 'ready'
- },
+ // defaults
+ props = acf.parseArgs(props, {
+ allowNull: false,
+ placeholder: '',
+ multiple: false,
+ field: false,
+ ajax: false,
+ ajaxAction: '',
+ ajaxData: function( data ){ return data; },
+ ajaxResults: function( json ){ return json; },
+ });
- ready: function(){
-
- // vars
- var locale = acf.get('locale'),
- rtl = acf.get('rtl')
- l10n = acf._e('date_picker');
-
-
- // bail ealry if no l10n (fiedl groups admin page)
- if( !l10n ) return;
-
-
- // bail ealry if no datepicker library
- if( typeof $.datepicker === 'undefined' ) return;
-
-
- // rtl
- l10n.isRTL = rtl;
-
-
- // append
- $.datepicker.regional[ locale ] = l10n;
- $.datepicker.setDefaults(l10n);
-
- },
-
-
- /*
- * init
- *
- * This function will initialize JS
- *
- * @type function
- * @date 2/06/2016
- * @since 5.3.8
- *
- * @param $input (jQuery selector)
- * @param args (object)
- * @return n/a
- */
-
- init: function( $input, args ){
-
- // bail ealry if no datepicker library
- if( typeof $.datepicker === 'undefined' ) return;
-
-
- // defaults
- args = args || {};
-
-
- // add date picker
- $input.datepicker( args );
-
-
- // wrap the datepicker (only if it hasn't already been wrapped)
- if( $('body > #ui-datepicker-div').exists() ) {
-
- $('body > #ui-datepicker-div').wrap('
');
-
- }
-
- },
-
-
- /*
- * init
- *
- * This function will remove JS
- *
- * @type function
- * @date 2/06/2016
- * @since 5.3.8
- *
- * @param $input (jQuery selector)
- * @return n/a
- */
-
- destroy: function( $input ){
-
- // do nothing
-
+ // initialize
+ if( getVersion() == 4 ) {
+ var select2 = new Select2_4( $select, props );
+ } else {
+ var select2 = new Select2_3( $select, props );
}
- });
+ // actions
+ acf.doAction('new_select2', select2);
- 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(){
-
- // get elements
- this.$el = this.$field.find('.acf-date-picker');
- this.$input = this.$el.find('input[type="text"]');
- this.$hidden = this.$el.find('input[type="hidden"]');
-
-
- // get options
- this.o = acf.get_data( this.$el );
-
- },
-
- initialize: function(){
-
- // save_format - compatibility with ACF < 5.0.0
- if( this.o.save_format ) {
-
- return this.initialize2();
-
- }
-
-
- // create options
- var args = {
- dateFormat: this.o.date_format,
- altField: this.$hidden,
- altFormat: 'yymmdd',
- changeYear: true,
- yearRange: "-100:+100",
- changeMonth: true,
- showButtonPanel: true,
- firstDay: this.o.first_day
- };
-
-
- // filter for 3rd party customization
- args = acf.apply_filters('date_picker_args', args, this.$field);
-
-
- // add date picker
- acf.datepicker.init( this.$input, args );
-
-
- // action for 3rd party customization
- acf.do_action('date_picker_init', this.$input, args, this.$field);
-
- },
-
- initialize2: function(){
-
- // get and set value from alt field
- this.$input.val( this.$hidden.val() );
-
-
- // create options
- var args = {
- dateFormat: this.o.date_format,
- altField: this.$hidden,
- altFormat: this.o.save_format,
- changeYear: true,
- yearRange: "-100:+100",
- changeMonth: true,
- showButtonPanel: true,
- firstDay: this.o.first_day
- };
-
-
- // filter for 3rd party customization
- args = acf.apply_filters('date_picker_args', args, this.$field);
-
-
- // backup
- var dateFormat = args.dateFormat;
-
-
- // change args.dateFormat
- args.dateFormat = this.o.save_format;
-
-
- // add date picker
- acf.datepicker.init( this.$input, args );
-
-
- // now change the format back to how it should be.
- this.$input.datepicker( 'option', 'dateFormat', dateFormat );
-
-
- // action for 3rd party customization
- acf.do_action('date_picker_init', this.$input, args, this.$field);
-
- },
-
- blur: function(){
-
- if( !this.$input.val() ) {
-
- this.$hidden.val('');
-
- }
-
- }
-
- });
+ // return
+ return select2;
+ };
-})(jQuery);
-
-(function($){
-
- /*
- * acf.datepicker
+ /**
+ * getVersion
*
* description
*
- * @type function
- * @date 16/12/2015
- * @since 5.3.2
+ * @date 13/1/18
+ * @since 5.6.5
*
- * @param $post_id (int)
- * @return $post_id (int)
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- acf.datetimepicker = acf.model.extend({
+ function getVersion() {
- actions: {
- 'ready 1': 'ready'
- },
-
- ready: function(){
-
- // vars
- var locale = acf.get('locale'),
- rtl = acf.get('rtl')
- l10n = acf._e('date_time_picker');
-
-
- // bail ealry if no l10n (fiedl groups admin page)
- if( !l10n ) return;
-
-
- // bail ealry if no timepicker library
- if( typeof $.timepicker === 'undefined' ) return;
-
-
- // rtl
- l10n.isRTL = rtl;
-
-
- // append
- $.timepicker.regional[ locale ] = l10n;
- $.timepicker.setDefaults(l10n);
-
- },
-
-
- /*
- * init
- *
- * This function will initialize JS
- *
- * @type function
- * @date 2/06/2016
- * @since 5.3.8
- *
- * @param $input (jQuery selector)
- * @param args (object)
- * @return n/a
- */
-
- init: function( $input, args ){
-
- // bail ealry if no timepicker library
- if( typeof $.timepicker === 'undefined' ) return;
-
-
- // defaults
- args = args || {};
-
-
- // add date picker
- $input.datetimepicker( args );
-
-
- // wrap the datepicker (only if it hasn't already been wrapped)
- if( $('body > #ui-datepicker-div').exists() ) {
-
- $('body > #ui-datepicker-div').wrap('
');
-
- }
-
- },
-
-
- /*
- * init
- *
- * This function will remove JS
- *
- * @type function
- * @date 2/06/2016
- * @since 5.3.8
- *
- * @param $input (jQuery selector)
- * @return n/a
- */
-
- destroy: function( $input ){
-
- // do nothing
-
+ // v4
+ if( acf.isset(window, 'jQuery', 'fn', 'select2', 'amd') ) {
+ return 4;
}
- });
-
-
- 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(){
-
- // get elements
- 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"]');
-
-
- // get options
- this.o = acf.get_data( this.$el );
-
- },
-
- initialize: function(){
-
- // create options
- var args = {
- dateFormat: this.o.date_format,
- timeFormat: this.o.time_format,
- altField: this.$hidden,
- altFieldTimeOnly: false,
- altFormat: 'yy-mm-dd',
- altTimeFormat: 'HH:mm:ss',
- changeYear: true,
- yearRange: "-100:+100",
- changeMonth: true,
- showButtonPanel: true,
- firstDay: this.o.first_day,
- controlType: 'select',
- oneLine: true
- };
-
-
- // filter for 3rd party customization
- args = acf.apply_filters('date_time_picker_args', args, this.$field);
-
-
- // add date time picker
- acf.datetimepicker.init( this.$input, args );
-
-
- // action for 3rd party customization
- acf.do_action('date_time_picker_init', this.$input, args, this.$field);
-
- },
-
- blur: function(){
-
- if( !this.$input.val() ) {
-
- this.$hidden.val('');
-
- }
-
+ // v3
+ if( acf.isset(window, 'Select2') ) {
+ return 3;
}
- });
+ // return
+ return false;
+ }
-})(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
- *
- * This function will setup variables when focused on a field
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- focus: function(){
-
- // get elements
- this.$el = this.$field.find('.acf-file-uploader');
- this.$input = this.$el.find('input[type="hidden"]');
-
-
- // get options
- this.o = acf.get_data( this.$el );
-
- },
-
-
- /*
- * initialize
- *
- * This function is used to setup basic upload form attributes
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- initialize: function(){
-
- // add attribute to form
- if( this.o.uploader == 'basic' ) {
-
- this.$el.closest('form').attr('enctype', 'multipart/form-data');
-
- }
-
- },
-
-
- /*
- * prepare
- *
- * This function will prepare an object of attachment data
- * selecting a library image vs embed an image via url return different data
- * this function will keep the 2 consistent
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param attachment (object)
- * @return data (object)
- */
-
- prepare: function( attachment ) {
-
- // defaults
- attachment = attachment || {};
-
-
- // bail ealry if already valid
- if( attachment._valid ) return attachment;
-
-
- // vars
- var data = {
- url: '',
- alt: '',
- title: '',
- filename: '',
- filesizeHumanReadable: '',
- icon: '/wp-includes/images/media/default.png'
- };
-
-
- // wp image
- if( attachment.id ) {
-
- // update data
- data = attachment.attributes;
-
- }
-
-
- // valid
- data._valid = true;
-
-
- // return
- return data;
-
- },
-
-
- /*
- * render
- *
- * This function will render the UI
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param attachment (obj)
- * @return n/a
- */
-
- render: function( data ){
-
- // prepare
- data = this.prepare(data);
-
-
- // update els
- this.$el.find('img').attr({
- src: data.icon,
- alt: data.alt,
- title: data.title
- });
- this.$el.find('[data-name="title"]').text( data.title );
- this.$el.find('[data-name="filename"]').text( data.filename ).attr( 'href', data.url );
- this.$el.find('[data-name="filesize"]').text( data.filesizeHumanReadable );
-
-
- // vars
- var val = '';
-
-
- // WP attachment
- if( data.id ) {
-
- val = data.id;
-
- }
-
-
- // update val
- acf.val( this.$input, val );
-
-
- // update class
- if( val ) {
-
- this.$el.addClass('has-value');
-
- } else {
-
- this.$el.removeClass('has-value');
-
- }
-
- },
-
-
- /*
- * add
- *
- * event listener
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/a
- */
-
- add: function() {
-
- // reference
- var self = this,
- $field = this.$field;
-
-
- // get repeater
- var $repeater = acf.get_closest_field( $field, 'repeater' );
-
-
- // popup
- var frame = acf.media.popup({
-
- title: acf._e('file', 'select'),
- mode: 'select',
- type: '',
- field: $field.data('key'),
- multiple: $repeater.exists(),
- library: this.o.library,
- mime_types: this.o.mime_types,
-
- select: function( attachment, i ) {
-
- // select / add another image field?
- if( i > 0 ) {
-
- // vars
- var key = $field.data('key'),
- $tr = $field.closest('.acf-row');
-
-
- // reset field
- $field = false;
-
-
- // find next image field
- $tr.nextAll('.acf-row:visible').each(function(){
-
- // get next $field
- $field = acf.get_field( key, $(this) );
-
-
- // bail early if $next was not found
- if( !$field ) return;
-
-
- // bail early if next file uploader has value
- if( $field.find('.acf-file-uploader.has-value').exists() ) {
-
- $field = false;
- return;
-
- }
-
-
- // end loop if $next is found
- return false;
-
- });
-
-
-
- // add extra row if next is not found
- if( !$field ) {
-
- $tr = acf.fields.repeater.doFocus( $repeater ).add();
-
-
- // bail early if no $tr (maximum rows hit)
- if( !$tr ) return false;
-
-
- // get next $field
- $field = acf.get_field( key, $tr );
-
- }
-
- }
-
-
- // render
- self.set('$field', $field).render( attachment );
-
- }
- });
-
- },
-
-
- /*
- * edit
- *
- * event listener
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/a
- */
-
- edit: function() {
-
- // reference
- var self = this,
- $field = this.$field;
-
-
- // vars
- var val = this.$input.val();
-
-
- // bail early if no val
- if( !val ) return;
-
-
- // popup
- var frame = acf.media.popup({
-
- title: acf._e('file', 'edit'),
- button: acf._e('file', 'update'),
- mode: 'edit',
- attachment: val,
-
- select: function( attachment, i ) {
-
- // render
- self.set('$field', $field).render( attachment );
-
- }
-
- });
-
- },
-
-
- /*
- * remove
- *
- * event listener
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/a
- */
-
- remove: function() {
-
- // vars
- var attachment = {};
-
-
- // add file to field
- this.render( attachment );
-
- },
-
-
- /*
- * get_file_info
- *
- * This function will find basic file info and store it in a hidden input
- *
- * @type function
- * @date 18/1/17
- * @since 5.5.0
- *
- * @param $file_input (jQuery)
- * @param $hidden_input (jQuery)
- * @return n/a
- */
-
- get_file_info: function( $file_input, $hidden_input ){
-
- // vars
- var val = $file_input.val(),
- attachment = {};
-
-
- // bail early if no value
- if( !val ) {
-
- $hidden_input.val('');
- return;
-
- }
-
-
- // url
- attachment.url = val;
-
-
- // modern browsers
- var files = $file_input[0].files;
-
- if( files.length ){
-
- // vars
- var file = files[0];
-
-
- // update
- attachment.size = file.size;
- attachment.type = file.type;
-
-
- // image
- if( file.type.indexOf('image') > -1 ) {
-
- // vars
- var _url = window.URL || window.webkitURL;
-
-
- // temp image
- var img = new Image();
-
- img.onload = function () {
-
- // update
- attachment.width = this.width;
- attachment.height = this.height;
-
-
- // set hidden input value
- $hidden_input.val( jQuery.param(attachment) );
-
- };
-
- img.src = _url.createObjectURL(file);
-
- }
-
- }
-
-
- // set hidden input value
- $hidden_input.val( jQuery.param(attachment) );
-
- },
-
-
- /*
- * change
- *
- * This function will update the hidden input when selecting a basic file to add basic validation
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/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 : '', // '', 'loading', 'ready'
- geocoder : false,
- map : false,
- maps : {},
- $pending: $(),
-
- actions: {
- // have considered changing to 'load', however, could cause issues with devs expecting the API to exist earlier
- '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',
- //'paste .search': '_paste',
- 'mousedown .acf-google-map': '_mousedown'
- },
-
- focus: function(){
-
- // get elements
- this.$el = this.$field.find('.acf-google-map');
- this.$search = this.$el.find('.search');
-
-
- // get options
- this.o = acf.get_data( this.$el );
- this.o.id = this.$el.attr('id');
-
-
- // get map
- if( this.maps[ this.o.id ] ) {
-
- this.map = this.maps[ this.o.id ];
-
- }
-
- },
-
-
- /*
- * is_ready
- *
- * This function will ensure google API is available and return a boolean for the current status
- *
- * @type function
- * @date 19/11/2014
- * @since 5.0.9
- *
- * @param n/a
- * @return (boolean)
- */
-
- is_ready: function(){
-
- // reference
- var self = this;
-
-
- // ready
- if( this.status == 'ready' ) return true;
-
-
- // loading
- if( this.status == 'loading' ) return false;
-
-
- // check exists (optimal)
- if( acf.isset(window, 'google', 'maps', 'places') ) {
-
- this.status = 'ready';
- return true;
-
- }
-
-
- // check exists (ok)
- if( acf.isset(window, 'google', 'maps') ) {
-
- this.status = 'ready';
-
- }
-
-
- // attempt load google.maps.places
- if( this.url ) {
-
- // set status
- this.status = 'loading';
-
-
- // enqueue
- acf.enqueue_script(this.url, function(){
-
- // set status
- self.status = 'ready';
-
-
- // initialize pending
- self.initialize_pending();
-
- });
-
- }
-
-
- // ready
- if( this.status == 'ready' ) return true;
-
-
- // return
- return false;
-
- },
-
-
- /*
- * initialize_pending
- *
- * This function will initialize pending fields
- *
- * @type function
- * @date 27/08/2016
- * @since 5.4.0
- *
- * @param n/a
- * @return n/a
- */
-
- initialize_pending: function(){
-
- // reference
- var self = this;
-
- this.$pending.each(function(){
-
- self.set('$field', $(this)).initialize();
-
- });
-
-
- // reset
- this.$pending = $();
-
- },
-
-
- /*
- * actions
- *
- * these functions are fired for this fields actions
- *
- * @type function
- * @date 17/09/2015
- * @since 5.2.3
- *
- * @param (mixed)
- * @return n/a
- */
-
- initialize: function(){
-
- // add to pending
- if( !this.is_ready() ) {
-
- this.$pending = this.$pending.add( this.$field );
-
- return false;
-
- }
-
-
- // load geocode
- if( !this.geocoder ) {
-
- this.geocoder = new google.maps.Geocoder();
-
- }
-
-
- // reference
- var self = this,
- $field = this.$field,
- $el = this.$el,
- $search = this.$search;
-
-
- // input value may be cached by browser, so update the search input to match
- $search.val( this.$el.find('.input-address').val() );
-
-
- // map
- var map_args = acf.apply_filters('google_map_args', {
-
- scrollwheel: false,
- zoom: parseInt(this.o.zoom),
- center: new google.maps.LatLng(this.o.lat, this.o.lng),
- mapTypeId: google.maps.MapTypeId.ROADMAP
-
- }, this.$field);
-
-
- // create map
- this.map = new google.maps.Map( this.$el.find('.canvas')[0], map_args);
-
-
- // search
- if( acf.isset(window, 'google', 'maps', 'places', 'Autocomplete') ) {
-
- // vars
- var autocomplete = new google.maps.places.Autocomplete( this.$search[0] );
-
-
- // bind
- autocomplete.bindTo('bounds', this.map);
-
-
- // event
- google.maps.event.addListener(autocomplete, 'place_changed', function( e ) {
-
- // vars
- var place = this.getPlace();
-
-
- // search
- self.search( place );
-
- });
-
-
- // append
- this.map.autocomplete = autocomplete;
-
- }
-
-
- // marker
- var marker_args = acf.apply_filters('google_map_marker_args', {
-
- draggable: true,
- raiseOnDrag: true,
- map: this.map
-
- }, this.$field);
-
-
- // add marker
- this.map.marker = new google.maps.Marker( marker_args );
-
-
- // add references
- this.map.$el = $el;
- this.map.$field = $field;
-
-
- // value exists?
- var lat = $el.find('.input-lat').val(),
- lng = $el.find('.input-lng').val();
-
- if( lat && lng ) {
-
- this.update(lat, lng).center();
-
- }
-
-
- // events
- google.maps.event.addListener( this.map.marker, 'dragend', function(){
-
- // vars
- var position = this.map.marker.getPosition(),
- lat = position.lat(),
- lng = position.lng();
-
- self.update( lat, lng ).sync();
-
- });
-
-
- google.maps.event.addListener( this.map, 'click', function( e ) {
-
- // vars
- var lat = e.latLng.lat(),
- lng = e.latLng.lng();
-
-
- self.update( lat, lng ).sync();
-
- });
-
-
- // action for 3rd party customization
- acf.do_action('google_map_init', this.map, this.map.marker, this.$field);
-
-
- // add to maps
- this.maps[ this.o.id ] = this.map;
-
- },
-
- search: function( place ){
-
- // reference
- var self = this;
-
-
- // vars
- var address = this.$search.val();
-
-
- // bail ealry if no address
- if( !address ) {
-
- return false;
-
- }
-
-
- // update input
- this.$el.find('.input-address').val( address );
-
-
- // is lat lng?
- var latLng = address.split(',');
-
- if( latLng.length == 2 ) {
-
- var lat = latLng[0],
- lng = latLng[1];
-
-
- if( $.isNumeric(lat) && $.isNumeric(lng) ) {
-
- // parse
- lat = parseFloat(lat);
- lng = parseFloat(lng);
-
- self.update( lat, lng ).center();
-
- return;
-
- }
-
- }
-
-
- // if place exists
- if( place && place.geometry ) {
-
- var lat = place.geometry.location.lat(),
- lng = place.geometry.location.lng();
-
-
- // update
- self.update( lat, lng ).center();
-
-
- // bail early
- return;
-
- }
-
-
- // add class
- this.$el.addClass('-loading');
-
- self.geocoder.geocode({ 'address' : address }, function( results, status ){
-
- // remove class
- self.$el.removeClass('-loading');
-
-
- // validate
- if( status != google.maps.GeocoderStatus.OK ) {
-
- console.log('Geocoder failed due to: ' + status);
- return;
-
- } else if( !results[0] ) {
-
- console.log('No results found');
- return;
-
- }
-
-
- // get place
- place = results[0];
-
- var lat = place.geometry.location.lat(),
- lng = place.geometry.location.lng();
-
-
- self.update( lat, lng ).center();
-
- });
-
- },
-
- update: function( lat, lng ){
-
- // vars
- var latlng = new google.maps.LatLng( lat, lng );
-
-
- // update inputs
- acf.val( this.$el.find('.input-lat'), lat );
- acf.val( this.$el.find('.input-lng'), lng );
-
-
- // update marker
- this.map.marker.setPosition( latlng );
-
-
- // show marker
- this.map.marker.setVisible( true );
-
-
- // update class
- this.$el.addClass('-value');
-
-
- // validation
- this.$field.removeClass('error');
-
-
- // action
- acf.do_action('google_map_change', latlng, this.map, this.$field);
-
-
- // blur input
- this.$search.blur();
-
-
- // return for chaining
- return this;
-
- },
-
- center: function(){
-
- // vars
- var position = this.map.marker.getPosition(),
- lat = this.o.lat,
- lng = this.o.lng;
-
-
- // if marker exists, center on the marker
- if( position ) {
-
- lat = position.lat();
- lng = position.lng();
-
- }
-
-
- var latlng = new google.maps.LatLng( lat, lng );
-
-
- // set center of map
- this.map.setCenter( latlng );
-
- },
-
- sync: function(){
-
- // reference
- var self = this;
-
-
- // vars
- var position = this.map.marker.getPosition(),
- latlng = new google.maps.LatLng( position.lat(), position.lng() );
-
-
- // add class
- this.$el.addClass('-loading');
-
-
- // load
- this.geocoder.geocode({ 'latLng' : latlng }, function( results, status ){
-
- // remove class
- self.$el.removeClass('-loading');
-
-
- // validate
- if( status != google.maps.GeocoderStatus.OK ) {
-
- console.log('Geocoder failed due to: ' + status);
- return;
-
- } else if( !results[0] ) {
-
- console.log('No results found');
- return;
-
- }
-
-
- // get location
- var location = results[0];
-
-
- // update title
- self.$search.val( location.formatted_address );
-
-
- // update input
- acf.val( self.$el.find('.input-address'), location.formatted_address );
-
- });
-
-
- // return for chaining
- return this;
-
- },
-
- refresh: function(){
-
- // bail early if not ready
- if( !this.is_ready() ) {
-
- return false;
-
- }
-
-
- // trigger resize on map
- google.maps.event.trigger(this.map, 'resize');
-
-
-
- // center map
- this.center();
-
- },
-
- show: function(){
-
- // vars
- var self = this,
- $field = this.$field;
-
-
- // center map when it is shown (by a tab / collapsed row)
- // - use delay to avoid rendering issues with browsers (ensures div is visible)
- setTimeout(function(){
-
- self.set('$field', $field).refresh();
-
- }, 10);
-
- },
-
-
- /*
- * events
- *
- * these functions are fired for this fields events
- *
- * @type function
- * @date 17/09/2015
- * @since 5.2.3
- *
- * @param e
- * @return n/a
- */
-
- _clear: function( e ){ // console.log('_clear');
-
- // remove Class
- this.$el.removeClass('-value -loading -search');
-
-
- // clear search
- this.$search.val('');
-
-
- // clear inputs
- acf.val( this.$el.find('.input-address'), '' );
- acf.val( this.$el.find('.input-lat'), '' );
- acf.val( this.$el.find('.input-lng'), '' );
-
-
- // hide marker
- this.map.marker.setVisible( false );
-
- },
-
- _locate: function( e ){ // console.log('_locate');
-
- // reference
- var self = this;
-
-
- // Try HTML5 geolocation
- if( !navigator.geolocation ) {
-
- alert( acf._e('google_map', 'browser_support') );
- return this;
-
- }
-
-
- // add class
- this.$el.addClass('-loading');
-
-
- // load
- navigator.geolocation.getCurrentPosition(function(position){
-
- // remove class
- self.$el.removeClass('-loading');
-
-
- // vars
- var lat = position.coords.latitude,
- lng = position.coords.longitude;
-
- self.update( lat, lng ).sync().center();
-
- });
-
- },
-
- _search: function( e ){ // console.log('_search');
-
- this.search();
-
- },
-
- _focus: function( e ){ // console.log('_focus');
-
- // remove class
- this.$el.removeClass('-value');
-
-
- // toggle -search class
- this._keyup();
-
- },
-
- _blur: function( e ){ // console.log('_blur');
-
- // reference
- var self = this;
-
-
- // vars
- var val = this.$el.find('.input-address').val();
-
-
- // bail early if no val
- if( !val ) {
-
- return;
-
- }
-
-
- // revert search to hidden input value
- this.timeout = setTimeout(function(){
-
- self.$el.addClass('-value');
- self.$search.val( val );
-
- }, 100);
-
- },
-
-/*
- _paste: function( e ){ console.log('_paste');
-
- // reference
- var $search = this.$search;
-
-
- // blur search
- $search.blur();
-
-
- // clear timeout
- this._mousedown(e);
-
-
- // focus on input
- setTimeout(function(){
-
- $search.focus();
-
- }, 1);
- },
-*/
-
- _keydown: function( e ){ // console.log('_keydown');
-
- // prevent form from submitting
- if( e.which == 13 ) {
-
- e.preventDefault();
-
- }
-
- },
-
- _keyup: function( e ){ // console.log('_keyup');
-
- // vars
- var val = this.$search.val();
-
-
- // toggle class
- if( val ) {
-
- this.$el.addClass('-search');
-
- } else {
-
- this.$el.removeClass('-search');
-
- }
-
- },
-
- _mousedown: function( e ){ // console.log('_mousedown');
-
- // reference
- var self = this;
-
-
- // clear timeout in 1ms (_mousedown will run before _blur)
- setTimeout(function(){
-
- clearTimeout( self.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
- *
- * This function will setup variables when focused on a field
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- focus: function(){
-
- // vars
- this.$el = this.$field.find('.acf-image-uploader');
- this.$input = this.$el.find('input[type="hidden"]');
- this.$img = this.$el.find('img');
-
-
- // options
- this.o = acf.get_data( this.$el );
-
- },
-
-
- /*
- * initialize
- *
- * This function is used to setup basic upload form attributes
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- initialize: function(){
-
- // add attribute to form
- if( this.o.uploader == 'basic' ) {
-
- this.$el.closest('form').attr('enctype', 'multipart/form-data');
-
- }
-
- },
-
-
- /*
- * prepare
- *
- * This function will prepare an object of attachment data
- * selecting a library image vs embed an image via url return different data
- * this function will keep the 2 consistent
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param attachment (object)
- * @return data (object)
- */
-
- prepare: function( attachment ) {
-
- // defaults
- attachment = attachment || {};
-
-
- // bail ealry if already valid
- if( attachment._valid ) return attachment;
-
-
- // vars
- var data = {
- url: '',
- alt: '',
- title: '',
- caption: '',
- description: '',
- width: 0,
- height: 0
- };
-
-
- // wp image
- if( attachment.id ) {
-
- // update data
- data = attachment.attributes;
-
-
- // maybe get preview size
- data.url = acf.maybe_get(data, 'sizes.'+this.o.preview_size+'.url', data.url);
-
- }
-
-
- // valid
- data._valid = true;
-
-
- // return
- return data;
-
- },
-
-
- /*
- * render
- *
- * This function will render the UI
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param attachment (obj)
- * @return n/a
- */
-
- render: function( data ){
-
- // prepare
- data = this.prepare(data);
-
-
- // update image
- this.$img.attr({
- src: data.url,
- alt: data.alt,
- title: data.title
- });
-
-
- // vars
- var val = '';
-
-
- // WP attachment
- if( data.id ) {
-
- val = data.id;
-
- }
-
-
- // update val
- acf.val( this.$input, val );
-
-
- // update class
- if( val ) {
-
- this.$el.addClass('has-value');
-
- } else {
-
- this.$el.removeClass('has-value');
-
- }
-
- },
-
-
- /*
- * add
- *
- * event listener
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/a
- */
-
- add: function() {
-
- // reference
- var self = this,
- $field = this.$field;
-
-
- // get repeater
- var $repeater = acf.get_closest_field( this.$field, 'repeater' );
-
-
- // popup
- var frame = acf.media.popup({
-
- title: acf._e('image', 'select'),
- mode: 'select',
- type: 'image',
- field: $field.data('key'),
- multiple: $repeater.exists(),
- library: this.o.library,
- mime_types: this.o.mime_types,
-
- select: function( attachment, i ) {
-
- // select / add another image field?
- if( i > 0 ) {
-
- // vars
- var key = $field.data('key'),
- $tr = $field.closest('.acf-row');
-
-
- // reset field
- $field = false;
-
-
- // find next image field
- $tr.nextAll('.acf-row:visible').each(function(){
-
- // get next $field
- $field = acf.get_field( key, $(this) );
-
-
- // bail early if $next was not found
- if( !$field ) return;
-
-
- // bail early if next file uploader has value
- if( $field.find('.acf-image-uploader.has-value').exists() ) {
-
- $field = false;
- return;
-
- }
-
-
- // end loop if $next is found
- return false;
-
- });
-
-
- // add extra row if next is not found
- if( !$field ) {
-
- $tr = acf.fields.repeater.doFocus( $repeater ).add();
-
-
- // bail early if no $tr (maximum rows hit)
- if( !$tr ) return false;
-
-
- // get next $field
- $field = acf.get_field( key, $tr );
-
- }
-
- }
-
-
- // render
- self.set('$field', $field).render( attachment );
-
- }
-
- });
-
- },
-
-
- /*
- * edit
- *
- * event listener
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/a
- */
-
- edit: function() {
-
- // reference
- var self = this,
- $field = this.$field;
-
-
- // vars
- var val = this.$input.val();
-
-
- // bail early if no val
- if( !val ) return;
-
-
- // popup
- var frame = acf.media.popup({
-
- title: acf._e('image', 'edit'),
- button: acf._e('image', 'update'),
- mode: 'edit',
- attachment: val,
-
- select: function( attachment, i ) {
-
- // render
- self.set('$field', $field).render( attachment );
-
- }
-
- });
-
- },
-
-
- /*
- * remove
- *
- * event listener
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/a
- */
-
- remove: function() {
-
- // vars
- var attachment = {};
-
-
- // add file to field
- this.render( attachment );
-
- },
-
-
- /*
- * change
- *
- * This function will update the hidden input when selecting a basic file to add basic validation
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param e (event)
- * @return n/a
- */
-
- change: function( e ){
-
- acf.fields.file.get_file_info( e.$el, this.$input );
-
- }
-
- });
-
-})(jQuery);
-
-(function($){
-
- acf.fields.link = acf.field.extend({
-
- type: 'link',
- active: false,
- $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
- *
- * This function will setup variables when focused on a field
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- focus: function(){
-
- // get elements
- 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, value ){
-
- // vars
- var val = {
- 'title': this.$node.html(),
- 'url': this.$node.attr('href'),
- 'target': this.$node.attr('target')
- };
-
-
- // vars
- this.val( val );
-
- },
-
- val: function( val ){
-
- // default
- val = acf.parse_args(val, {
- 'title': '',
- 'url': '',
- 'target': ''
- });
-
-
- // remove class
- this.$el.removeClass('-value -external');
-
-
- // add class
- if( val.url ) this.$el.addClass('-value');
- if( val.target === '_blank' ) this.$el.addClass('-external');
-
-
- // update text
- this.$el.find('.link-title').html( val.title );
- this.$el.find('.link-url').attr('href', val.url).html( val.url );
-
-
- // update inputs
- this.$el.find('.input-title').val( val.title );
- this.$el.find('.input-target').val( val.target );
- this.$el.find('.input-url').val( val.url ).trigger('change');
-
-
- // update node
- this.$node.html(val.title);
- this.$node.attr('href', val.url);
- this.$node.attr('target', val.target);
- }
-
- });
-
-
- /*
- * acf.link
+ /**
+ * Select2
*
- * This model will handle adding tabs and groups
+ * description
*
- * @type function
- * @date 25/11/2015
- * @since 5.3.2
+ * @date 13/1/18
+ * @since 5.6.5
*
- * @param $post_id (int)
- * @return $post_id (int)
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- acf.link = acf.model.extend({
+ var Select2 = acf.Model.extend({
- active: false,
- $textarea: null,
- $node: null,
-
- events: {
- 'click #wp-link-submit': '_update',
- //'river-select .query-results': '_select',
- 'wplink-open': '_open',
- 'wplink-close': '_close',
- },
-
- atts: function( value ){
-
- // update
- if( typeof value !== 'undefined' ) {
-
- this.$node.html( value.title );
- this.$node.attr('href', value.url);
- this.$node.attr('target', value.target);
- this.$node.trigger('change', [value]);
- return true;
-
- }
-
-
- // get
- return {
- 'title': this.$node.html(),
- 'url': this.$node.attr('href'),
- 'target': this.$node.attr('target')
- };
-
- },
-
- inputs: function( value ){
-
- // update
- if( typeof value !== 'undefined' ) {
-
- $('#wp-link-text').val( value.title );
- $('#wp-link-url').val( value.url );
- $('#wp-link-target').prop('checked', value.target === '_blank' );
- return true;
-
- }
-
-
- // get
- return {
- 'title': $('#wp-link-text').val(),
- 'url': $('#wp-link-url').val(),
- 'target': $('#wp-link-target').prop('checked') ? '_blank' : ''
- };
-
- },
-
- open: function( $node ){
-
- // create textarea
- var $textarea = $('');
-
-
- // append textarea
- $node.before( $textarea );
-
-
- // update vars
- this.active = true;
- this.$node = $node;
- this.$textarea = $textarea;
-
-
- // get atts
- var atts = this.atts();
-
-
- // open link
- wpLink.open( 'acf-link-textarea', atts.url, atts.title, null );
-
-
- // always show title (WP will hide title if empty)
- $('#wp-link-wrap').addClass('has-text-field');
-
- },
-
- reset: function(){
-
- this.active = false;
- this.$textarea.remove();
- this.$textarea = null;
- this.$node = null;
-
- },
-
- _select: function( e, $li ){
-
- // get inputs
- var val = this.inputs();
-
-
- // update title
- if( !val.title ) {
-
- val.title = $li.find('.item-title').text();
- this.inputs( val );
-
- console.log(val);
- }
-
- },
-
- _open: function( e ){
-
- // bail early if not active
- if( !this.active ) return;
-
-
- // get atts
- var val = this.atts();
-
-
- // update WP inputs
- this.inputs( val );
-
- },
-
- _close: function( e ){
-
- // bail early if not active
- if( !this.active ) return;
-
-
- // reset vars
- // use timeout to allow _update() function to check vars
- setTimeout(function(){
-
- acf.link.reset();
-
- }, 100);
-
- },
-
- _update: function( e ){
-
- // bail early if not active
- if( !this.active ) return;
-
-
- // get atts
- var val = this.inputs();
-
-
- // update node
- this.atts( val );
-
- }
-
- });
-
-
- // todo - listen to AJAX for wp-link-ajax and append post_id to value
-
-
-})(jQuery);
-
-(function($){
-
- acf.media = acf.model.extend({
-
- frames: [],
- mime_types: {},
-
- actions: {
- 'ready': 'ready'
- },
-
-
- /*
- * frame
- *
- * This function will return the current frame
- *
- * @type function
- * @date 11/04/2016
- * @since 5.3.2
- *
- * @param n/a
- * @return frame (object)
- */
-
- frame: function(){
-
- // vars
- var i = this.frames.length - 1;
-
-
- // bail early if no index
- if( i < 0 ) return false;
-
-
- // return
- return this.frames[ i ];
-
- },
-
-
- /*
- * destroy
- *
- * this function will destroy a frame
- *
- * @type function
- * @date 11/04/2016
- * @since 5.3.8
- *
- * @return frame (object)
- * @return n/a
- */
-
- destroy: function( frame ) {
-
- // detach
- frame.detach();
- frame.dispose();
-
-
- // remove frame
- frame = null;
- this.frames.pop();
-
- },
-
-
- /*
- * popup
- *
- * This function will create a wp media popup frame
- *
- * @type function
- * @date 11/04/2016
- * @since 5.3.8
- *
- * @param args (object)
- * @return frame (object)
- */
-
- popup: function( args ) {
-
- // vars
- var post_id = acf.get('post_id'),
- frame = false;
-
-
- // validate post_id
- if( !$.isNumeric(post_id) ) post_id = 0;
-
-
- // settings
- var settings = acf.parse_args( args, {
- mode: 'select', // 'select', 'edit'
- title: '', // 'Upload Image'
- button: '', // 'Select Image'
- type: '', // 'image', ''
- field: '', // 'field_123'
- mime_types: '', // 'pdf, etc'
- library: 'all', // 'all', 'uploadedTo'
- multiple: false, // false, true, 'add'
- attachment: 0, // the attachment to edit
- post_id: post_id, // the post being edited
- select: function(){}
- });
-
-
- // id changed to attributes
- if( settings.id ) settings.attachment = settings.id;
-
-
- // create frame
- var frame = this.new_media_frame( settings );
-
-
- // append
- this.frames.push( frame );
-
-
- // open popup (allow frame customization before opening)
- setTimeout(function(){
-
- frame.open();
-
- }, 1);
-
-
- // return
- return frame;
-
- },
-
-
- /*
- * _get_media_frame_settings
- *
- * This function will return an object containing frame settings
- *
- * @type function
- * @date 11/04/2016
- * @since 5.3.8
- *
- * @param frame (object)
- * @param settings (object)
- * @return frame (object)
- */
-
- _get_media_frame_settings: function( frame, settings ){
-
- // select
- if( settings.mode === 'select' ) {
-
- frame = this._get_select_frame_settings( frame, settings );
-
- // edit
- } else if( settings.mode === 'edit' ) {
-
- frame = this._get_edit_frame_settings( frame, settings );
-
- }
-
-
- // return
- return frame;
-
- },
-
- _get_select_frame_settings: function( frame, settings ){
-
- // type
- if( settings.type ) {
-
- frame.library.type = settings.type;
-
- }
-
-
- // library
- if( settings.library === 'uploadedTo' ) {
-
- frame.library.uploadedTo = settings.post_id;
-
- }
-
-
- // button
- frame._button = acf._e('media', 'select');
-
-
- // return
- return frame;
-
- },
-
- _get_edit_frame_settings: function( frame, settings ){
-
- // post__in
- frame.library.post__in = [ settings.attachment ];
-
-
- // button
- frame._button = acf._e('media', 'update');
-
-
- // return
- return frame;
-
- },
-
-
- /*
- * _add_media_frame_events
- *
- * This function will add events to the frame object
- *
- * @type function
- * @date 11/04/2016
- * @since 5.3.8
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- _add_media_frame_events: function( frame, settings ){
-
- // log events
-/*
- frame.on('all', function( e ) {
-
- console.log( 'frame all: %o', e );
-
- });
-*/
-
-
- // add class
- frame.on('open',function() {
-
- // add class
- this.$el.closest('.media-modal').addClass('acf-media-modal -' +settings.mode );
-
- }, frame);
-
-
- // edit image view
- // source: media-views.js:2410 editImageContent()
- frame.on('content:render:edit-image', function(){
-
- var image = this.state().get('image'),
- view = new wp.media.view.EditImage( { model: image, controller: this } ).render();
-
- this.content.set( view );
-
- // after creating the wrapper view, load the actual editor via an ajax call
- view.loadEditor();
-
- }, frame);
-
-
- // update toolbar button
- frame.on( 'toolbar:create:select', function( toolbar ) {
-
- toolbar.view = new wp.media.view.Toolbar.Select({
- text: frame.options._button,
- controller: this
- });
-
- }, frame );
-
-
- // select image
- frame.on('select', function() {
-
- // get selected images
- var state = frame.state(),
- image = state.get('image'),
- selection = state.get('selection');
-
-
- // if editing image
- if( image ) {
-
- settings.select.apply( frame, [image, 0] );
-
- return;
-
- }
-
-
- // if selecting images
- if( selection ) {
-
- // vars
- var i = 0;
-
-
- // loop
- selection.each(function( attachment ){
-
- settings.select.apply( frame, [attachment, i] );
-
- i++;
-
- });
-
- return;
-
- }
-
- });
-
-
- // close popup
- frame.on('close',function(){
-
- setTimeout(function(){
-
- acf.media.destroy( frame );
-
- }, 500);
-
- });
-
-
- // select
- if( settings.mode === 'select' ) {
-
- frame = this._add_select_frame_events( frame, settings );
-
- // edit
- } else if( settings.mode === 'edit' ) {
-
- frame = this._add_edit_frame_events( frame, settings );
-
- }
-
-
- // return
- return frame;
-
- },
-
- _add_select_frame_events: function( frame, settings ){
-
- // reference
- var self = this;
-
-
- // plupload
- // adds _acfuploader param to validate uploads
- if( acf.isset(_wpPluploadSettings, 'defaults', 'multipart_params') ) {
-
- // add _acfuploader so that Uploader will inherit
- _wpPluploadSettings.defaults.multipart_params._acfuploader = settings.field;
-
-
- // remove acf_field so future Uploaders won't inherit
- frame.on('open', function(){
-
- delete _wpPluploadSettings.defaults.multipart_params._acfuploader;
-
- });
-
- }
-
-
- // modify DOM
- frame.on('content:activate:browse', function(){
-
- // populate above vars making sure to allow for failure
- try {
-
- var toolbar = frame.content.get().toolbar,
- filters = toolbar.get('filters'),
- search = toolbar.get('search');
-
- } catch(e) {
-
- // one of the objects was 'undefined'... perhaps the frame open is Upload Files
- // console.log( 'error %o', e );
- return;
-
- }
-
-
- // image
- if( settings.type == 'image' ) {
-
- // update all
- filters.filters.all.text = acf._e('image', 'all');
-
-
- // remove some filters
- delete filters.filters.audio;
- delete filters.filters.video;
-
-
- // update all filters to show images
- $.each( filters.filters, function( k, filter ){
-
- if( filter.props.type === null ) {
-
- filter.props.type = 'image';
-
- }
-
- });
-
- }
-
-
- // custom mime types
- if( settings.mime_types ) {
-
- // explode
- var extra_types = settings.mime_types.split(' ').join('').split('.').join('').split(',');
-
-
- // loop through mime_types
- $.each( extra_types, function( i, type ){
-
- // find mime
- $.each( self.mime_types, function( t, mime ){
-
- // continue if key does not match
- if( t.indexOf(type) === -1 ) {
-
- return;
-
- }
-
-
- // create new filter
- var filter = {
- text: type,
- props: {
- status: null,
- type: mime,
- uploadedTo: null,
- orderby: 'date',
- order: 'DESC'
- },
- priority: 20
- };
-
-
- // append filter
- filters.filters[ mime ] = filter;
-
- });
-
- });
-
- }
-
-
- // uploaded to post
- if( settings.library == 'uploadedTo' ) {
-
- // remove some filters
- delete filters.filters.unattached;
- delete filters.filters.uploaded;
-
-
- // add 'uploadedTo' text
- filters.$el.parent().append('' + acf._e('image', 'uploadedTo') + ' ');
-
-
- // add uploadedTo to filters
- $.each( filters.filters, function( k, filter ){
-
- filter.props.uploadedTo = settings.post_id;
-
- });
-
- }
-
-
- // add _acfuploader to filters
- $.each( filters.filters, function( k, filter ){
-
- filter.props._acfuploader = settings.field;
-
- });
-
-
- // add _acfuplaoder to search
- search.model.attributes._acfuploader = settings.field;
-
-
- // render
- if( typeof filters.refresh === 'function' ) {
-
- filters.refresh();
-
- }
-
- });
-
-
- // return
- return frame;
-
- },
-
- _add_edit_frame_events: function( frame, settings ){
-
- // add class
- frame.on('open',function() {
-
- // add class
- this.$el.closest('.media-modal').addClass('acf-expanded');
-
-
- // set to browse
- if( this.content.mode() != 'browse' ) {
-
- this.content.mode('browse');
-
- }
-
-
- // set selection
- var state = this.state(),
- selection = state.get('selection'),
- attachment = wp.media.attachment( settings.attachment );
-
-
- selection.add( attachment );
-
- }, frame);
-
-
- // return
- return frame;
-
- },
-
-
- /*
- * new_media_frame
- *
- * this function will create a new media frame
- *
- * @type function
- * @date 11/04/2016
- * @since 5.3.8
- *
- * @param settings (object)
- * @return frame (object)
- */
-
- new_media_frame: function( settings ){
-
- // vars
- var attributes = {
- title: settings.title,
- multiple: settings.multiple,
- library: {},
- states: []
- };
-
-
- // get options
- attributes = this._get_media_frame_settings( attributes, settings );
-
-
- // create query
- var Query = wp.media.query( attributes.library );
-
-
- // add _acfuploader
- // this is super wack!
- // if you add _acfuploader to the options.library args, new uploads will not be added to the library view.
- // this has been traced back to the wp.media.model.Query initialize function (which can't be overriden)
- // Adding any custom args will cause the Attahcments to not observe the uploader queue
- // To bypass this security issue, we add in the args AFTER the Query has been initialized
- // options.library._acfuploader = settings.field;
- if( acf.isset(Query, 'mirroring', 'args') ) {
-
- Query.mirroring.args._acfuploader = settings.field;
-
- }
-
-
- // add states
- attributes.states = [
-
- // main state
- new wp.media.controller.Library({
- library: Query,
- multiple: attributes.multiple,
- title: attributes.title,
- priority: 20,
- filterable: 'all',
- editable: true,
-
- // If the user isn't allowed to edit fields,
- // can they still edit it locally?
- allowLocalEdits: true
- })
-
- ];
-
-
- // edit image functionality (added in WP 3.9)
- if( acf.isset(wp, 'media', 'controller', 'EditImage') ) {
-
- attributes.states.push( new wp.media.controller.EditImage() );
-
- }
-
-
- // create frame
- var frame = wp.media( attributes );
-
-
- // add args reference
- frame.acf = settings;
-
-
- // add events
- frame = this._add_media_frame_events( frame, settings );
-
-
- // return
- return frame;
-
- },
-
- ready: function(){
-
- // vars
- var version = acf.get('wp_version'),
- browser = acf.get('browser'),
- post_id = acf.get('post_id');
-
-
- // update wp.media
- if( acf.isset(window,'wp','media','view','settings','post') && $.isNumeric(post_id) ) {
-
- wp.media.view.settings.post.id = post_id;
-
- }
-
-
- // append browser
- if( browser ) {
-
- $('body').addClass('browser-' + browser );
-
- }
-
-
- // append version
- if( version ) {
-
- // ensure is string
- version = version + '';
-
-
- // use only major version
- major = version.substr(0,1);
-
-
- // add body class
- $('body').addClass('major-' + major);
-
- }
-
-
- // customize wp.media views
- if( acf.isset(window, 'wp', 'media', 'view') ) {
-
- //this.customize_Attachments();
- //this.customize_Query();
- //this.add_AcfEmbed();
- this.customize_Attachment();
- this.customize_AttachmentFiltersAll();
- this.customize_AttachmentCompat();
-
- }
-
- },
-
-
-/*
- add_AcfEmbed: function(){
-
- //test urls
- //(image) jpg: http://www.ml24.net/img/ml24_design_process_scion_frs_3d_rendering.jpg
- //(image) svg: http://kompozer.net/images/svg/Mozilla_Firefox.svg
- //(file) pdf: http://martinfowler.com/ieeeSoftware/whenType.pdf
- //(video) mp4: https://videos.files.wordpress.com/kUJmAcSf/bbb_sunflower_1080p_30fps_normal_hd.mp4
-
-
-
- // add view
- wp.media.view.AcfEmbed = wp.media.view.Embed.extend({
-
- initialize: function() {
-
- // set attachments
- this.model.props.attributes = this.controller.acf.attachment || {};
-
-
- // refresh
- wp.media.view.Embed.prototype.initialize.apply( this, arguments );
-
- },
-
- refresh: function() {
-
- // vars
- var attachment = acf.parse_args(this.model.props.attributes, {
- url: '',
- filename: '',
- title: '',
- caption: '',
- alt: '',
- description: '',
- type: '',
- ext: ''
- });
-
-
- // update attachment
- if( attachment.url ) {
-
- // filename
- attachment.filename = attachment.url.split('/').pop().split('?')[0];
-
-
- // update
- attachment.ext = attachment.filename.split('.').pop();
- attachment.type = /(jpe?g|png|gif|svg)/i.test(attachment.ext) ? 'image': 'file';
-
- }
-
-
- // auto generate title
- if( attachment.filename && !attachment.title ) {
-
- // replace
- attachment.title = attachment.filename.split('-').join(' ').split('_').join(' ');
-
-
- // uppercase first word
- attachment.title = attachment.title.charAt(0).toUpperCase() + attachment.title.slice(1);
-
-
- // remove extension
- attachment.title = attachment.title.replace('.'+attachment.ext, '');
-
-
- // update model
- this.model.props.attributes.title = attachment.title;
-
- }
-
-
- // save somee extra data
- this.model.props.attributes.filename = attachment.filename;
- this.model.props.attributes.type = attachment.type;
-
-
- // always show image view
- // avoid this.model.set() to prevent listeners updating view
- this.model.attributes.type = 'image';
-
-
- // refresh
- wp.media.view.Embed.prototype.refresh.apply( this, arguments );
-
-
- // append title
- this.$el.find('.setting.caption').before([
- '',
- 'Title ',
- ' ',
- ' '
- ].join(''));
-
-
- // append description
- this.$el.find('.setting.alt-text').after([
- '',
- 'Description ',
- '',
- ' '
- ].join(''));
-
-
- // hide alt
- if( attachment.type !== 'image' ) {
-
- this.$el.find('.setting.alt-text').hide();
-
- }
-
- }
-
- });
-
- },
-*/
-/*
-
- customize_Attachments: function(){
-
- // vars
- var Attachments = wp.media.model.Attachments;
-
-
- wp.media.model.Attachments = Attachments.extend({
-
- initialize: function( models, options ){
-
- // console.log('My Attachments initialize: %o %o %o', this, models, options);
-
- // return
- return Attachments.prototype.initialize.apply( this, arguments );
-
- },
-
- sync: function( method, model, options ) {
-
- // console.log('My Attachments sync: %o %o %o %o', this, method, model, options);
-
-
- // return
- return Attachments.prototype.sync.apply( this, arguments );
-
- }
-
- });
-
- },
-
- customize_Query: function(){
-
- // console.log('customize Query!');
-
- // vars
- var Query = wp.media.model.Query;
-
-
- wp.media.model.Query = {};
-
- },
-*/
-
- customize_Attachment: function(){
-
- // vars
- var AttachmentLibrary = wp.media.view.Attachment.Library;
-
-
- // extend
- wp.media.view.Attachment.Library = AttachmentLibrary.extend({
-
- render: function() {
-
- // vars
- var frame = acf.media.frame(),
- errors = acf.maybe_get(this, 'model.attributes.acf_errors');
-
-
- // add class
- // also make sure frame exists to prevent this logic running on a WP popup (such as feature image)
- if( frame && errors ) {
-
- this.$el.addClass('acf-disabled');
-
- }
-
-
- // return
- return AttachmentLibrary.prototype.render.apply( this, arguments );
-
- },
-
-
- /*
- * toggleSelection
- *
- * This function is called before an attachment is selected
- * A good place to check for errors and prevent the 'select' function from being fired
- *
- * @type function
- * @date 29/09/2016
- * @since 5.4.0
- *
- * @param options (object)
- * @return n/a
- */
-
- toggleSelection: function( options ) {
-
- // vars
- // source: wp-includes/js/media-views.js:2880
- var collection = this.collection,
- selection = this.options.selection,
- model = this.model,
- single = selection.single();
-
-
- // vars
- var frame = acf.media.frame(),
- errors = acf.maybe_get(this, 'model.attributes.acf_errors'),
- $sidebar = this.controller.$el.find('.media-frame-content .media-sidebar');
-
-
- // remove previous error
- $sidebar.children('.acf-selection-error').remove();
-
-
- // show attachment details
- $sidebar.children().removeClass('acf-hidden');
-
-
- // add message
- if( frame && errors ) {
-
- // vars
- var filename = acf.maybe_get(this, 'model.attributes.filename', '');
-
-
- // hide attachment details
- // Gallery field continues to show previously selected attachment...
- $sidebar.children().addClass('acf-hidden');
-
-
- // append message
- $sidebar.prepend([
- '',
- '' + acf._e('restricted') +' ',
- '' + filename + ' ',
- '' + errors + ' ',
- '
'
- ].join(''));
-
-
- // reset selection (unselects all attachments)
- selection.reset();
-
-
- // set single (attachment displayed in sidebar)
- selection.single( model );
-
-
- // return and prevent 'select' form being fired
- return;
-
- }
-
-
- // return
- AttachmentLibrary.prototype.toggleSelection.apply( this, arguments );
-
- }
-
- });
-
- },
-
- customize_AttachmentFiltersAll: function(){
-
- // add function refresh
- wp.media.view.AttachmentFilters.All.prototype.refresh = function(){
-
- // Build `` elements.
- this.$el.html( _.chain( this.filters ).map( function( filter, value ) {
- return {
- el: $( ' ' ).val( value ).html( filter.text )[0],
- priority: filter.priority || 50
- };
- }, this ).sortBy('priority').pluck('el').value() );
-
- };
-
- },
-
- customize_AttachmentCompat: function(){
-
- // vars
- var AttachmentCompat = wp.media.view.AttachmentCompat;
-
-
- // extend
- wp.media.view.AttachmentCompat = AttachmentCompat.extend({
-
- add_acf_expand_button: function(){
-
- // vars
- var $el = this.$el.closest('.media-modal');
-
-
- // does button already exist?
- if( $el.find('.media-frame-router .acf-expand-details').exists() ) return;
-
-
- // create button
- var $a = $([
- '',
- ' ' + acf._e('expand_details') + ' ',
- ' ' + acf._e('collapse_details') + ' ',
- ' '
- ].join(''));
-
-
- // add events
- $a.on('click', function( e ){
-
- e.preventDefault();
-
- if( $el.hasClass('acf-expanded') ) {
-
- $el.removeClass('acf-expanded');
-
- } else {
-
- $el.addClass('acf-expanded');
-
- }
-
- });
-
-
- // append
- $el.find('.media-frame-router').append( $a );
-
- },
-
- render: function() {
-
- // validate
- if( this.ignore_render ) return this;
-
-
- // reference
- var self = this;
-
-
- // add expand button
- setTimeout(function(){
-
- self.add_acf_expand_button();
-
- }, 0);
-
-
- // setup fields
- // The clearTimout is needed to prevent many setup functions from running at the same time
- clearTimeout( acf.media.render_timout );
- acf.media.render_timout = setTimeout(function(){
-
- acf.do_action('append', self.$el);
-
- }, 50);
-
-
- // return
- return AttachmentCompat.prototype.render.apply( this, arguments );
-
- },
-
-
- dispose: function() {
-
- // remove
- acf.do_action('remove', this.$el);
-
-
- // return
- return AttachmentCompat.prototype.dispose.apply( this, arguments );
-
- },
-
-
- save: function( e ) {
-
- if( e ) {
-
- e.preventDefault();
-
- }
-
-
- // serialize form
- var data = acf.serialize(this.$el);
-
-
- // ignore render
- this.ignore_render = true;
-
-
- // save
- this.model.saveCompat( data );
-
- }
-
-
- });
-
- }
-
-
- });
-
-})(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
- *
- * This function will setup variables when focused on a field
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- focus: function(){
-
- // vars
- 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"]');
-
-
- // options
- this.o = acf.get_data( this.$el );
-
- },
-
-
- /*
- * maybe_search
- *
- * description
- *
- * @type function
- * @date 14/10/16
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- maybe_search: function(){
-
- // set url and focus
- var old_url = this.$input.val(),
- new_url = this.$search.val();
-
-
- // bail early if no value
- if( !new_url ) {
-
- this.clear();
- return;
-
- }
-
-
- // bail early if no change
- if( new_url == old_url ) return;
-
-
- // search
- this.search();
-
- },
-
-
- /*
- * search
- *
- * This function will search for an oembed
- *
- * @type function
- * @date 13/10/16
- * @since 5.4.0
- *
- * @param n/a
- * @return n/a
- */
-
- search: function(){
-
- // vars
- var s = this.$search.val();
-
-
- // fix missing 'http://' - causes the oembed code to error and fail
- if( s.substr(0, 4) != 'http' ) {
-
- s = 'http://' + s;
- this.$search.val( s );
-
- }
-
-
- // show loading
- this.$el.addClass('is-loading');
-
-
- // AJAX data
- var ajax_data = acf.prepare_for_ajax({
- 'action' : 'acf/fields/oembed/search',
- 's' : s,
- 'field_key' : this.$field.data('key')
- });
-
-
- // abort XHR if this field is already loading AJAX data
- if( this.$el.data('xhr') ) this.$el.data('xhr').abort();
-
-
- // get HTML
- var xhr = $.ajax({
- url: acf.get('ajaxurl'),
- data: ajax_data,
- type: 'post',
- dataType: 'json',
- context: this,
- success: this.search_success
- });
-
-
- // update el data
- this.$el.data('xhr', xhr);
-
- },
-
- search_success: function( json ){
-
- // vars
- var s = this.$search.val();
-
-
- // remove loading
- this.$el.removeClass('is-loading');
-
-
- // error
- if( !json || !json.html ) {
-
- this.$el.removeClass('has-value').addClass('has-error');
- return;
-
- }
-
-
- // add classes
- this.$el.removeClass('has-error').addClass('has-value');
-
-
- // update vars
- this.$input.val( s );
- this.$title.html( s );
- this.$embed.html( json.html );
-
- },
-
- clear: function(){
-
- // update class
- this.$el.removeClass('has-error has-value');
-
-
- // clear search
- this.$el.find('[data-name="search-input"]').val('');
-
-
- // clear inputs
- this.$input.val('');
- this.$title.html('');
- this.$embed.html('');
-
- },
-
- edit: function(){
-
- // add class
- this.$el.addClass('is-editing');
-
-
- // set url and focus
- this.$search.val( this.$title.text() ).focus();
-
- },
-
- blur: function( $el ){
-
- // remove class
- this.$el.removeClass('is-editing');
-
-
- // maybe search
- this.maybe_search();
-
- },
-
- _search: function( e ){ // console.log('_search');
-
- this.search();
-
- },
-
- _clear: function( e ){ // console.log('_clear');
-
- this.clear();
-
- },
-
- _edit: function( e ){ // console.log('_clear');
-
- this.edit();
-
- },
-
- _keypress: function( e ){ // console.log('_keypress');
-
- // don't submit form
- if( e.which == 13 ) e.preventDefault();
-
- },
-
- _keyup: function( e ){ //console.log('_keypress', e.which);
-
- // bail early if no value
- if( !this.$search.val() ) return;
-
-
- // maybe search
- this.maybe_search();
-
- },
-
- _blur: function( e ){ // console.log('_blur');
-
- 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(){
-
- // focus on $select
- this.$ul = this.$field.find('.acf-radio-list');
-
-
- // get options
- this.o = acf.get_data( this.$ul );
-
- },
-
-
- /*
- * initialize
- *
- * This function will fix a bug found in Chrome.
- * A radio input (for a given name) may only have 1 selected value. When used within a fc layout
- * multiple times (clone field), the selected value (default value) will not be checked.
- * This simply re-checks it.
- *
- * @type function
- * @date 30/08/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- initialize: function(){
-
- // find selected input and check it
- this.$ul.find('.selected input').prop('checked', true);
-
- },
-
- click: function(e){
-
- // vars
- var $radio = e.$el,
- $label = $radio.parent('label'),
- selected = $label.hasClass('selected'),
- val = $radio.val();
-
-
- // remove previous selected
- this.$ul.find('.selected').removeClass('selected');
-
-
- // add active class
- $label.addClass('selected');
-
-
- // allow null
- if( this.o.allow_null && selected ) {
-
- // unselect
- e.$el.prop('checked', false);
- $label.removeClass('selected');
- val = false;
-
-
- // trigger change
- e.$el.trigger('change');
-
- }
-
-
- // other
- if( this.o.other_choice ) {
-
- // vars
- var $other = this.$ul.find('input[type="text"]');
-
-
- // show
- if( val === 'other' ) {
-
- $other.prop('disabled', false).attr('name', $radio.attr('name'));
-
- // hide
- } else {
-
- $other.prop('disabled', true).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(){
-
- // get elements
- 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( val ){
- this.$input.val( val );
- this.$range.val( val );
- },
-
- onInput: function( e ){
- this.setValue( e.$el.val() );
- },
-
- onChange: function( e ){
- this.setValue( e.$el.val() );
-
- if( e.$el.attr('type') == 'number' ) {
- 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(){
-
- // get elements
- 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');
-
- // get options
- this.o = acf.get_data( this.$el );
-
+ setup: function( $select, props ){
+ $.extend(this.data, props);
+ this.$el = $select;
},
initialize: function(){
- // reference
- var self = this,
- $field = this.$field,
- $el = this.$el,
- $input = this.$input;
-
-
- // right sortable
- this.$values.children('.list').sortable({
- items: 'li',
- forceHelperSize: true,
- forcePlaceholderSize: true,
- scroll: true,
- update: function(){
-
- $input.trigger('change');
-
- }
- });
-
-
- this.$choices.children('.list').scrollTop(0).on('scroll', function(e){
-
- // bail early if no more results
- if( $el.hasClass('is-loading') || $el.hasClass('is-empty') ) {
-
- return;
-
- }
-
-
- // Scrolled to bottom
- if( Math.ceil( $(this).scrollTop() ) + $(this).innerHeight() >= $(this).get(0).scrollHeight ) {
-
- // get paged
- var paged = $el.data('paged') || 1;
-
-
- // update paged
- $el.data('paged', (paged+1) );
-
-
- // fetch
- self.set('$field', $field).fetch();
-
- }
-
- });
-
-
-/*
- // scroll event
- var maybe_fetch = function( e ){
- console.log('scroll');
- // remove listener
- $(window).off('scroll', maybe_fetch);
-
-
- // is field in view
- if( acf.is_in_view($field) ) {
-
- // fetch
- self.doFocus($field);
- self.fetch();
-
-
- // return
- return;
- }
-
-
- // add listener
- setTimeout(function(){
-
- $(window).on('scroll', maybe_fetch);
-
- }, 500);
-
- };
-*/
-
-
- // fetch
- this.fetch();
-
},
-/*
- show: function(){
-
- console.log('show field: %o', this.o.xhr);
-
- // bail ealry if already loaded
- if( typeof this.o.xhr !== 'undefined' ) {
-
- return;
-
+ selectOption: function( value ){
+ var $option = this.getOption( value );
+ if( !$option.prop('selected') ) {
+ $option.prop('selected', true).trigger('change');
}
-
-
- // is field in view
- if( acf.is_in_view(this.$field) ) {
-
- // fetch
- this.fetch();
-
- }
-
- },
-*/
-
- maybe_fetch: function(){
-
- // reference
- var self = this,
- $field = this.$field;
-
-
- // abort timeout
- if( this.o.timeout ) {
-
- clearTimeout( this.o.timeout );
-
- }
-
-
- // fetch
- var timeout = setTimeout(function(){
-
- self.doFocus($field);
- self.fetch();
-
- }, 300);
-
- this.$el.data('timeout', timeout);
-
},
- fetch: function(){
-
- // reference
- var self = this,
- $field = this.$field;
-
-
- // add class
- this.$el.addClass('is-loading');
-
-
- // abort XHR if this field is already loading AJAX data
- if( this.o.xhr ) {
-
- this.o.xhr.abort();
- this.o.xhr = false;
-
+ unselectOption: function( value ){
+ var $option = this.getOption( value );
+ if( $option.prop('selected') ) {
+ $option.prop('selected', false).trigger('change');
}
+ },
+
+ getOption: function( value ){
+ return this.$('option[value="' + value + '"]');
+ },
+
+ addOption: function( option ){
-
- // add to this.o
- this.o.action = 'acf/fields/relationship/query';
- this.o.field_key = $field.data('key');
- this.o.post_id = acf.get('post_id');
-
-
- // ready for ajax
- var ajax_data = acf.prepare_for_ajax( this.o );
-
-
- // clear html if is new query
- if( ajax_data.paged == 1 ) {
-
- this.$choices.children('.list').html('')
-
- }
-
-
- // add message
- this.$choices.find('ul:last').append(' ' + acf._e('relationship', 'loading') + '
');
-
-
- // get results
- var xhr = $.ajax({
- url: acf.get('ajaxurl'),
- dataType: 'json',
- type: 'post',
- data: ajax_data,
- success: function( json ){
-
- self.set('$field', $field).render( json );
-
- }
+ // defaults
+ option = acf.parseArgs(option, {
+ id: '',
+ text: '',
+ selected: false
});
-
- // update el data
- this.$el.data('xhr', xhr);
-
- },
-
- render: function( json ){
-
- // remove loading class
- this.$el.removeClass('is-loading is-empty');
-
-
- // remove p tag
- this.$choices.find('p').remove();
-
-
- // no results?
- if( !json || !json.results || !json.results.length ) {
-
- // add class
- this.$el.addClass('is-empty');
-
-
- // add message
- if( this.o.paged == 1 ) {
-
- this.$choices.children('.list').append('' + acf._e('relationship', 'empty') + '
');
-
- }
-
-
- // return
- return;
-
- }
-
-
- // get new results
- var $new = $( this.walker(json.results) );
-
-
- // apply .disabled to left li's
- this.$values.find('.acf-rel-item').each(function(){
-
- $new.find('.acf-rel-item[data-id="' + $(this).data('id') + '"]').addClass('disabled');
-
- });
-
-
- // underline search match
- // consider removing due to bug where matched strings within HTML attributes caused incorrect results
- // Looks like Select2 v4 has moved away from highlighting results, so perhaps we should too
-/*
- if( this.o.s ) {
-
- // vars
- var s = this.o.s;
-
-
- // allow special characters to be used within regex
- s = acf.addslashes(s);
-
-
- // loop
- $new.find('.acf-rel-item').each(function(){
-
- // vars
- var find = $(this).text(),
- replace = find.replace( new RegExp('(' + s + ')', 'gi'), '$1 ');
-
- $(this).html( $(this).html().replace(find, replace) );
-
- });
-
- }
-*/
-
+ // vars
+ var $option = this.getOption( option.id );
// append
- this.$choices.children('.list').append( $new );
-
-
- // merge together groups
- var label = '',
- $list = null;
-
- this.$choices.find('.acf-rel-label').each(function(){
-
- if( $(this).text() == label ) {
-
- $list.append( $(this).siblings('ul').html() );
-
- $(this).parent().remove();
-
- return;
- }
-
-
- // update vars
- label = $(this).text();
- $list = $(this).siblings('ul');
-
- });
-
-
- },
-
- walker: function( data ){
-
- // vars
- var s = '';
-
-
- // loop through data
- if( $.isArray(data) ) {
-
- for( var k in data ) {
-
- s += this.walker( data[ k ] );
-
- }
-
- } else if( $.isPlainObject(data) ) {
-
- // optgroup
- if( data.children !== undefined ) {
-
- s += '' + data.text + ' ';
-
- s += this.walker( data.children );
-
- s += ' ';
-
- } else {
-
- s += '' + data.text + ' ';
-
- }
-
+ if( !$option.length ) {
+ $option = $(' ');
+ $option.html( option.text );
+ $option.attr('value', option.id);
+ $option.prop('selected', option.selected);
+ this.$el.append($option);
}
-
-
- // return
- return s;
-
- },
-
- submit_filter: function( e ){
-
- // don't submit form
- if( e.which == 13 ) {
-
- e.preventDefault();
-
- }
-
- },
-
- change_filter: function( e ){
-
- // vars
- var val = e.$el.val(),
- filter = e.$el.data('filter');
-
-
- // Bail early if filter has not changed
- if( this.$el.data(filter) == val ) {
-
- return;
-
- }
-
-
- // update attr
- this.$el.data(filter, val);
-
-
- // reset paged
- this.$el.data('paged', 1);
-
-
- // fetch
- if( e.$el.is('select') ) {
-
- this.fetch();
-
- // search must go through timeout
- } else {
-
- this.maybe_fetch();
-
- }
-
- },
-
- add_item: function( e ){
-
- // max posts
- if( this.o.max > 0 ) {
-
- if( this.$values.find('.acf-rel-item').length >= this.o.max ) {
-
- alert( acf._e('relationship', 'max').replace('{max}', this.o.max) );
-
- return;
-
- }
-
- }
-
-
- // can be added?
- if( e.$el.hasClass('disabled') ) {
-
- return false;
-
- }
-
-
- // disable
- e.$el.addClass('disabled');
-
-
- // template
- var html = [
- '',
- ' ',
- '' + e.$el.html(),
- ' ',
- ' ',
- ' '].join('');
-
- // add new li
- this.$values.children('.list').append( html )
-
-
- // trigger change on new_li
- this.$input.trigger('change');
-
-
- // validation
- acf.validation.remove_error( this.$field );
-
+ // chain
+ return $option;
},
- remove_item : function( e ){
+ getValue: function(){
// vars
- var $span = e.$el.parent(),
- id = $span.data('id');
-
-
- // remove
- $span.parent('li').remove();
-
-
- // show
- this.$choices.find('.acf-rel-item[data-id="' + id + '"]').removeClass('disabled');
-
-
- // trigger change on new_li
- this.$input.trigger('change');
-
- }
-
- });
-
-
-})(jQuery);
-
-(function($){
-
- // globals
- var _select2,
- _select23,
- _select24;
-
-
- /*
- * acf.select2
- *
- * all logic to create select2 instances
- *
- * @type function
- * @date 16/12/2015
- * @since 5.3.2
- *
- * @param n/a
- * @return n/a
- */
-
- _select2 = acf.select2 = acf.model.extend({
-
- // vars
- version: 0,
- version3: null,
- version4: null,
-
-
- // actions
- actions: {
- 'ready 1': 'ready'
- },
-
-
- /*
- * ready
- *
- * This function will run on document ready
- *
- * @type function
- * @date 21/06/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- ready: function(){
-
- // determine Select2 version
- this.version = this.get_version();
-
-
- // ready
- this.do_function('ready');
-
- },
-
-
- /*
- * get_version
- *
- * This function will return the Select2 version
- *
- * @type function
- * @date 29/4/17
- * @since 5.5.13
- *
- * @param n/a
- * @return n/a
- */
-
- get_version: function(){
-
- if( acf.maybe_get(window, 'Select2') ) return 3;
- if( acf.maybe_get(window, 'jQuery.fn.select2.amd') ) return 4;
- return 0;
-
- },
-
-
- /*
- * do_function
- *
- * This function will call the v3 or v4 equivelant function
- *
- * @type function
- * @date 28/4/17
- * @since 5.5.13
- *
- * @param name (string)
- * @param args (array)
- * @return (mixed)
- */
-
- do_function: function( name, args ){
-
- // defaults
- args = args || [];
-
-
- // vars
- var model = 'version'+this.version;
-
-
- // bail early if not set
- if( typeof this[model] === 'undefined' ||
- typeof this[model][name] === 'undefined' ) return false;
-
-
- // run
- return this[model][name].apply( this, args );
-
- },
-
-
- /*
- * get_data
- *
- * This function will look at a $select element and return an object choices
- *
- * @type function
- * @date 24/12/2015
- * @since 5.3.2
- *
- * @param $select (jQuery)
- * @return (array)
- */
-
- get_data: function( $select, data ){
-
- // reference
- var self = this;
-
-
- // defaults
- data = data || [];
-
-
- // loop over children
- $select.children().each(function(){
-
- // vars
- var $el = $(this);
-
-
- // optgroup
- if( $el.is('optgroup') ) {
-
- data.push({
- 'text': $el.attr('label'),
- 'children': self.get_data( $el )
- });
-
- // option
- } else {
-
- data.push({
- 'id': $el.attr('value'),
- 'text': $el.text()
- });
-
- }
-
- });
-
-
- // return
- return data;
-
- },
-
-
- /*
- * decode_data
- *
- * This function will take an array of choices and decode the text
- * Changes '&' to '&' which fixes a bug (in Select2 v3 )when searching for '&'
- *
- * @type function
- * @date 24/12/2015
- * @since 5.3.2
- *
- * @param $select (jQuery)
- * @return (array)
- */
-
- decode_data: function( data ) {
-
- // bail ealry if no data
- if( !data ) return [];
-
-
- //loop
- $.each(data, function(k, v){
-
- // text
- data[ k ].text = acf.decode( v.text );
-
-
- // children
- if( typeof v.children !== 'undefined' ) {
-
- data[ k ].children = _select2.decode_data(v.children);
-
- }
-
- });
-
-
- // return
- return data;
-
- },
-
-
- /*
- * count_data
- *
- * This function will take an array of choices and return the count
- *
- * @type function
- * @date 24/12/2015
- * @since 5.3.2
- *
- * @param data (array)
- * @return (int)
- */
-
- count_data: function( data ) {
-
- // vars
- var i = 0;
-
-
- // bail ealry if no data
- if( !data ) return i;
-
-
- //loop
- $.each(data, function(k, v){
-
- // increase
- i++;
-
-
- // children
- if( typeof v.children !== 'undefined' ) {
-
- i += v.children.length;
-
- }
-
- });
-
-
- // return
- return i;
-
- },
-
-
- /*
- * get_ajax_data
- *
- * This function will return an array of data to send via AJAX
- *
- * @type function
- * @date 19/07/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- get_ajax_data: function( args, params, $el, $field ){
-
- // vars
- var data = acf.prepare_for_ajax({
- action: args.ajax_action,
- field_key: args.key,
- s: params.term || '',
- paged: params.page || 1
- });
-
-
- // filter
- data = acf.apply_filters( 'select2_ajax_data', data, args, $el, $field );
-
-
- // return
- return data;
-
- },
-
-
- /*
- * get_ajax_results
- *
- * This function will return a valid AJAX response
- *
- * @type function
- * @date 19/07/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- get_ajax_results: function( data, params ){
-
- // vars
- var valid = {
- results: []
- };
-
-
- // bail early if no data
- if( !data ) {
-
- data = valid;
-
- }
-
-
- // allow for an array of choices
- if( typeof data.results == 'undefined' ) {
-
- valid.results = data;
-
- data = valid;
-
- }
-
-
- // decode
- data.results = this.decode_data(data.results);
-
-
- // filter
- data = acf.apply_filters( 'select2_ajax_results', data, params );
-
-
- // return
- return data;
-
- },
-
-
- /*
- * get_value
- *
- * This function will return the selected options in a Select2 format
- *
- * @type function
- * @date 5/01/2016
- * @since 5.3.2
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- get_value: function( $select ){
-
- // vars
- var val = [],
- $selected = $select.find('option:selected');
-
+ var val = [];
+ var $options = this.$el.find('option:selected');
// bail early if no selected
- if( !$selected.exists() ) return val;
+ if( !$options.exists() ) {
+ return val;
+ }
-
- // sort
- $selected = $selected.sort(function(a, b) {
-
+ // sort by attribute
+ $options = $options.sort(function(a, b) {
return +a.getAttribute('data-i') - +b.getAttribute('data-i');
-
});
-
// loop
- $selected.each(function(){
-
- // vars
+ $options.each(function(){
var $el = $(this);
-
-
- // append
val.push({
- 'id': $el.attr('value'),
- 'text': $el.text(),
- '$el': $el
+ $el: $el,
+ id: $el.attr('value'),
+ text: $el.text(),
});
-
});
-
// return
return val;
},
-
- /*
- * get_input_value
- *
- * This function will return an array of values as per the hidden input
- *
- * @type function
- * @date 29/4/17
- * @since 5.5.13
- *
- * @param $input (jQuery)
- * @return (array)
- */
-
- get_input_value: function( $input ) {
-
- return $input.val().split('||');
-
+ mergeOptions: function(){
+
},
-
- /*
- * sync_input_value
- *
- * This function will save the current selected values into the hidden input
- *
- * @type function
- * @date 29/4/17
- * @since 5.5.13
- *
- * @param $input (jQuery)
- * @param $select (jQuery)
- * @return n/a
- */
-
- sync_input_value: function( $input, $select ) {
+ getChoices: function(){
- $input.val( $select.val().join('||') );
+ // callback
+ var crawl = function( $parent ){
+
+ // vars
+ var choices = [];
+
+ // loop
+ $parent.children().each(function(){
+
+ // vars
+ var $child = $(this);
+
+ // optgroup
+ if( $child.is('optgroup') ) {
+
+ choices.push({
+ text: $child.attr('label'),
+ children: crawl( $child )
+ });
+
+ // option
+ } else {
+
+ choices.push({
+ id: $child.attr('value'),
+ text: $child.text()
+ });
+ }
+ });
+
+ // return
+ return choices;
+ };
+ // crawl
+ return crawl( this.$el );
},
-
- /*
- * add_option
- *
- * This function will add an element to a select (if it doesn't already exist)
- *
- * @type function
- * @date 29/4/17
- * @since 5.5.13
- *
- * @param $select (jQuery)
- * @param value (string)
- * @param label (string)
- * @return n/a
- */
-
- add_option: function( $select, value, label ){
+ decodeChoices: function( choices ){
- if( !$select.find('option[value="'+value+'"]').length ) {
-
- $select.append(' '+label+' ');
-
+ // callback
+ var crawl = function( items ){
+ items.map(function( item ){
+ item.text = acf.decode( item.text );
+ if( item.children ) {
+ item.children = crawl( item.children );
+ }
+ return item;
+ });
+ return items;
+ };
+
+ // crawl
+ return crawl( choices );
+ },
+
+ getAjaxData: function( params ){
+
+ // vars
+ var ajaxData = {
+ action: this.get('ajaxAction'),
+ s: params.term || '',
+ paged: params.page || 1
+ };
+
+ // field helper
+ var field = this.get('field');
+ if( field ) {
+ ajaxData.field_key = field.get('key');
}
+ // callback
+ var callback = this.get('ajaxData');
+ if( callback ) {
+ ajaxData = callback.apply( this, [ajaxData, params] );
+ }
+
+ // filter
+ ajaxData = acf.applyFilters( 'select2_ajax_data', ajaxData, this.data, this.$el, (field || false), this );
+
+ // return
+ return acf.prepareForAjax(ajaxData);
},
-
- /*
- * select_option
- *
- * This function will select an option
- *
- * @type function
- * @date 29/4/17
- * @since 5.5.13
- *
- * @param $select (jQuery)
- * @param value (string)
- * @return n/a
- */
-
- select_option: function( $select, value ){
+ getAjaxResults: function( json, params ){
- $select.find('option[value="'+value+'"]').prop('selected', true);
- $select.trigger('change');
+ // defaults
+ json = acf.parseArgs(json, {
+ results: false,
+ more: false,
+ });
+ // decode
+ if( json.results ) {
+ json.results = this.decodeChoices(json.results);
+ }
+
+ // callback
+ var callback = this.get('ajaxResults');
+ if( callback ) {
+ json = callback.apply( this, [json, params] );
+ }
+
+ // filter
+ json = acf.applyFilters( 'select2_ajax_results', json, params, this );
+
+ // return
+ return json;
},
-
- /*
- * unselect_option
- *
- * This function will unselect an option
- *
- * @type function
- * @date 29/4/17
- * @since 5.5.13
- *
- * @param $select (jQuery)
- * @param value (string)
- * @return n/a
- */
-
- unselect_option: function( $select, value ){
+ processAjaxResults: function( json, params ){
- $select.find('option[value="'+value+'"]').prop('selected', false);
- $select.trigger('change');
+ // vars
+ var json = this.getAjaxResults( json, params );
+ // change more to pagination
+ if( json.more ) {
+ json.pagination = { more: true };
+ }
+
+ // merge together groups
+ setTimeout($.proxy(this.mergeOptions, this), 1);
+
+ // return
+ return json;
},
-
- /*
- * Select2 v3 or v4 functions
- *
- * description
- *
- * @type function
- * @date 29/4/17
- * @since 5.5.10
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- init: function( $select, args, $field ){
+ destroy: function(){
- this.do_function( 'init', arguments );
-
- },
-
- destroy: function( $select ){
-
- this.do_function( 'destroy', arguments );
-
- },
-
- add_value: function( $select, value, label ){
-
- this.do_function( 'add_value', arguments );
-
- },
-
- remove_value: function( $select, value ){
-
- this.do_function( 'remove_value', arguments );
+ // destroy via api
+ if( this.$el.data('select2') ) {
+ this.$el.select2('destroy');
+ }
+ // destory via HTML (duplicating HTML does not contain data)
+ this.$el.siblings('.select2-container').remove();
}
});
- /*
- * Select2 v3
+ /**
+ * Select2_4
*
- * This model contains the Select2 v3 functions
+ * description
*
- * @type function
- * @date 28/4/17
- * @since 5.5.10
+ * @date 13/1/18
+ * @since 5.6.5
*
- * @param n/a
- * @return n/a
+ * @param type $var Description. Default.
+ * @return type Description.
*/
- _select23 = _select2.version3 = {
+ var Select2_4 = Select2.extend({
- ready: function(){
+ initialize: function(){
// vars
- var locale = acf.get('locale'),
- rtl = acf.get('rtl')
- l10n = acf._e('select');
+ var $select = this.$el;
+ var options = {
+ width: '100%',
+ allowClear: this.get('allowNull'),
+ placeholder: this.get('placeholder'),
+ multiple: this.get('multiple'),
+ data: [],
+ escapeMarkup: function( m ){ return m; }
+ };
+ // multiple
+ if( options.multiple ) {
+
+ // reorder options
+ this.getValue().map(function( item ){
+ item.$el.detach().appendTo( $select );
+ });
+ }
+
+ // remove conflicting atts
+ $select.removeData('ajax');
+ $select.removeAttr('data-ajax');
+
+ // ajax
+ if( this.get('ajax') ) {
+
+ options.ajax = {
+ url: acf.get('ajaxurl'),
+ delay: 250,
+ dataType: 'json',
+ type: 'post',
+ cache: false,
+ data: $.proxy(this.getAjaxData, this),
+ processResults: $.proxy(this.processAjaxResults, this),
+ };
+ }
+
+ // filter for 3rd party customization
+ //options = acf.applyFilters( 'select2_args', options, $select, this );
+ var field = this.get('field');
+ options = acf.applyFilters( 'select2_args', options, $select, this.data, (field || false), this );
+
+ // add select2
+ $select.select2( options );
+
+ // get container (Select2 v4 does not return this from constructor)
+ var $container = $select.next('.select2-container');
+
+ // multiple
+ if( options.multiple ) {
+
+ // vars
+ var $ul = $container.find('ul');
+
+ // sortable
+ $ul.sortable({
+ stop: function( e ) {
+
+ // loop
+ $ul.find('.select2-selection__choice').each(function() {
+
+ // vars
+ var $option = $( $(this).data('data').element );
+
+ // detach and re-append to end
+ $option.detach().appendTo( $select );
+ });
+
+ // trigger change on input (JS error if trigger on select)
+ $select.trigger('change');
+ }
+ });
+
+ // on select, move to end
+ $select.on('select2:select', this.proxy(function( e ){
+ this.getOption( e.params.data.id ).detach().appendTo( this.$el );
+ }));
+ }
+
+ // add class
+ $container.addClass('-acf');
+
+ // action for 3rd party customization
+ acf.doAction('select2_init', $select, options, this.data, (field || false), this);
+ },
+
+ mergeOptions: function(){
+
+ // vars
+ var $prevOptions = false;
+ var $prevGroup = false;
+
+ // loop
+ $('.select2-results__option[role="group"]').each(function(){
+
+ // vars
+ var $options = $(this).children('ul');
+ var $group = $(this).children('strong');
+
+ // compare to previous
+ if( $prevGroup && $prevGroup.text() === $group.text() ) {
+ $prevOptions.append( $options.children() );
+ $(this).remove();
+ return;
+ }
+
+ // update vars
+ $prevOptions = $options;
+ $prevGroup = $group;
+
+ });
+ },
+
+ });
+
+ /**
+ * Select2_3
+ *
+ * description
+ *
+ * @date 13/1/18
+ * @since 5.6.5
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var Select2_3 = Select2.extend({
+
+ initialize: function(){
+
+ // vars
+ var $select = this.$el;
+ var value = this.getValue();
+ var multiple = this.get('multiple');
+ var options = {
+ width: '100%',
+ allowClear: this.get('allowNull'),
+ placeholder: this.get('placeholder'),
+ separator: '||',
+ multiple: this.get('multiple'),
+ data: this.getChoices(),
+ escapeMarkup: function( m ){ return m; },
+ dropdownCss: {
+ 'z-index': '999999999'
+ },
+ initSelection: function( element, callback ) {
+ if( multiple ) {
+ callback( value );
+ } else {
+ callback( value.shift() );
+ }
+ }
+ };
+
+ // get hidden input
+ var $input = $select.siblings('input');
+ if( !$input.length ) {
+ $input = $(' ');
+ $select.before( $input );
+ }
+
+ // set input value
+ inputValue = value.map(function(item){ return item.id }).join('||');
+ $input.val( inputValue );
+
+ // multiple
+ if( options.multiple ) {
+
+ // reorder options
+ value.map(function( item ){
+ item.$el.detach().appendTo( $select );
+ });
+ }
+
+ // remove blank option as we have a clear all button
+ if( options.allowClear ) {
+ options.data = options.data.filter(function(item){
+ return item.id !== '';
+ });
+ }
+
+ // remove conflicting atts
+ $select.removeData('ajax');
+ $select.removeAttr('data-ajax');
+
+ // ajax
+ if( this.get('ajax') ) {
+
+ options.ajax = {
+ url: acf.get('ajaxurl'),
+ quietMillis: 250,
+ dataType: 'json',
+ type: 'post',
+ cache: false,
+ data: $.proxy(this.getAjaxData, this),
+ results: $.proxy(this.processAjaxResults, this),
+ };
+ }
+
+ // filter for 3rd party customization
+ var field = this.get('field');
+ options = acf.applyFilters( 'select2_args', options, $select, this.data, (field || false), this );
+
+ // add select2
+ $input.select2( options );
+
+ // get container
+ var $container = $input.select2('container');
+
+ // helper to find this select's option
+ var getOption = $.proxy(this.getOption, this);
+
+ // multiple
+ if( options.multiple ) {
+
+ // vars
+ var $ul = $container.find('ul');
+
+ // sortable
+ $ul.sortable({
+ stop: function() {
+
+ // loop
+ $ul.find('.select2-search-choice').each(function() {
+
+ // vars
+ var data = $(this).data('select2Data');
+ var $option = getOption( data.id );
+
+ // detach and re-append to end
+ $option.detach().appendTo( $select );
+ });
+
+ // trigger change on input (JS error if trigger on select)
+ $select.trigger('change');
+ }
+ });
+ }
+
+ // on select, create option and move to end
+ $input.on('select2-selecting', function( e ){
+
+ // vars
+ var item = e.choice;
+ var $option = getOption( item.id );
+
+ // create if doesn't exist
+ if( !$option.length ) {
+ $option = $('' + item.text + ' ');
+ }
+
+ // detach and re-append to end
+ $option.detach().appendTo( $select );
+ });
+
+ // add class
+ $container.addClass('-acf');
+
+ // action for 3rd party customization
+ acf.doAction('select2_init', $select, options, this.data, (field || false), this);
+
+ // change
+ $input.on('change', function(){
+ var val = $input.val();
+ if( val.indexOf('||') ) {
+ val = val.split('||');
+ }
+ $select.val( val ).trigger('change');
+ });
+
+ // hide select
+ $select.hide();
+ },
+
+ mergeOptions: function(){
+
+ // vars
+ var $prevOptions = false;
+ var $prevGroup = false;
+
+ // loop
+ $('#select2-drop .select2-result-with-children').each(function(){
+
+ // vars
+ var $options = $(this).children('ul');
+ var $group = $(this).children('.select2-result-label');
+
+ // compare to previous
+ if( $prevGroup && $prevGroup.text() === $group.text() ) {
+ $prevGroup.append( $options.children() );
+ $(this).remove();
+ return;
+ }
+
+ // update vars
+ $prevOptions = $options;
+ $prevGroup = $group;
+
+ });
+
+ },
+
+ getAjaxData: function( term, page ){
+
+ // create Select2 v4 params
+ var params = {
+ term: term,
+ page: page
+ }
+
+ // return
+ return Select2.prototype.getAjaxData.apply(this, [params]);
+ },
+
+ });
+
+
+ // manager
+ var select2Manager = new acf.Model({
+ priority: 5,
+ wait: 'prepare',
+ initialize: function(){
+
+ // vars
+ var locale = acf.get('locale');
+ var rtl = acf.get('rtl');
+ var l10n = acf.get('select2L10n');
// bail ealry if no l10n
- if( !l10n ) return;
+ if( !l10n ) {
+ return false;
+ }
+ // bail early if 'en'
+ if( locale.indexOf('en') === 0 ) {
+ return false;
+ }
+
+ // initialize
+ if( getVersion() == 4 ) {
+ this.addTranslations4();
+ } else {
+ this.addTranslations3();
+ }
+ },
+
+ addTranslations4: function(){
// vars
- var l10n_functions = {
- formatMatches: function( matches ) {
-
- if ( 1 === matches ) {
- return l10n.matches_1;
+ var l10n = acf.get('select2L10n');
+ var locale = acf.get('locale');
+
+ // modify local to match html[lang] attribute (used by Select2)
+ locale = locale.replace('_', '-');
+
+ // select2L10n
+ var select2L10n = {
+ errorLoading: function () {
+ return l10n.load_fail;
+ },
+ inputTooLong: function (args) {
+ var overChars = args.input.length - args.maximum;
+ if( overChars > 1 ) {
+ return l10n.input_too_long_n.replace( '%d', overChars );
}
-
- return l10n.matches_n.replace('%d', matches);
+ return l10n.input_too_long_1;
+ },
+ inputTooShort: function( args ){
+ var remainingChars = args.minimum - args.input.length;
+ if( remainingChars > 1 ) {
+ return l10n.input_too_short_n.replace( '%d', remainingChars );
+ }
+ return l10n.input_too_short_1;
+ },
+ loadingMore: function () {
+ return l10n.load_more;
+ },
+ maximumSelected: function( args ) {
+ var maximum = args.maximum;
+ if( maximum > 1 ) {
+ return l10n.selection_too_long_n.replace( '%d', maximum );
+ }
+ return l10n.selection_too_long_1;
+ },
+ noResults: function () {
+ return l10n.matches_0;
+ },
+ searching: function () {
+ return l10n.searching;
+ }
+ };
+
+ // append
+ jQuery.fn.select2.amd.define('select2/i18n/' + locale, [], function(){
+ return select2L10n;
+ });
+ },
+
+ addTranslations3: function(){
+
+ // vars
+ var l10n = acf.get('select2L10n');
+ var locale = acf.get('locale');
+
+ // modify local to match html[lang] attribute (used by Select2)
+ locale = locale.replace('_', '-');
+
+ // select2L10n
+ var select2L10n = {
+ formatMatches: function( matches ) {
+ if( matches > 1 ) {
+ return l10n.matches_n.replace( '%d', matches );
+ }
+ return l10n.matches_1;
},
formatNoMatches: function() {
return l10n.matches_0;
@@ -10473,29 +11391,24 @@ var acf;
return l10n.load_fail;
},
formatInputTooShort: function( input, min ) {
- var number = min - input.length;
-
- if ( 1 === number ) {
- return l10n.input_too_short_1;
+ var remainingChars = min - input.length;
+ if( remainingChars > 1 ) {
+ return l10n.input_too_short_n.replace( '%d', remainingChars );
}
-
- return l10n.input_too_short_n.replace( '%d', number );
+ return l10n.input_too_short_1;
},
formatInputTooLong: function( input, max ) {
- var number = input.length - max;
-
- if ( 1 === number ) {
- return l10n.input_too_long_1;
+ var overChars = input.length - max;
+ if( overChars > 1 ) {
+ return l10n.input_too_long_n.replace( '%d', overChars );
}
-
- return l10n.input_too_long_n.replace( '%d', number );
+ return l10n.input_too_long_1;
},
- formatSelectionTooBig: function( limit ) {
- if ( 1 === limit ) {
- return l10n.selection_too_long_1;
+ formatSelectionTooBig: function( maximum ) {
+ if( maximum > 1 ) {
+ return l10n.selection_too_long_n.replace( '%d', maximum );
}
-
- return l10n.selection_too_long_n.replace( '%d', limit );
+ return l10n.selection_too_long_1;
},
formatLoadMore: function() {
return l10n.load_more;
@@ -10504,3678 +11417,22 @@ var acf;
return l10n.searching;
}
};
-
-
- // ensure locales exists
- // older versions of Select2 did not have a locale storage
- $.fn.select2.locales = acf.maybe_get(window, 'jQuery.fn.select2.locales', {});
-
+
+ // ensure locales exists
+ $.fn.select2.locales = $.fn.select2.locales || {};
// append
- $.fn.select2.locales[ locale ] = l10n_functions;
- $.extend($.fn.select2.defaults, l10n_functions);
-
- },
-
- set_data: function( $select, data ){
-
- // v3
- if( this.version == 3 ) {
-
- $select = $select.siblings('input');
-
- }
-
-
- // set data
- $select.select2('data', data);
-
- },
-
- append_data: function( $select, data ){
-
- // v3
- if( this.version == 3 ) {
-
- $select = $select.siblings('input');
-
- }
-
-
-
- // vars
- var current = $select.select2('data') || [];
-
-
- // append
- current.push( data );
-
-
- // set data
- $select.select2('data', current);
-
- },
-
-
- /*
- * init_v3
- *
- * This function will create a new Select2 for v3
- *
- * @type function
- * @date 24/12/2015
- * @since 5.3.2
- *
- * @param $select (jQuery)
- * @return args (object)
- */
-
- init: function( $select, args, $field ){
-
- // defaults
- args = args || {};
- $field = $field || null;
-
-
- // merge
- args = $.extend({
- allow_null: false,
- placeholder: '',
- multiple: false,
- ajax: false,
- ajax_action: ''
- }, args);
-
-
- // vars
- var $input = $select.siblings('input');
-
-
- // bail early if no input
- if( !$input.exists() ) return;
-
-
- // select2 args
- var select2_args = {
- width: '100%',
- containerCssClass: '-acf',
- allowClear: args.allow_null,
- placeholder: args.placeholder,
- multiple: args.multiple,
- separator: '||',
- data: [],
- escapeMarkup: function( m ){ return m; },
- formatResult: function( result, container, query, escapeMarkup ){
-
- // run default formatResult
- var text = $.fn.select2.defaults.formatResult( result, container, query, escapeMarkup );
-
-
- // append description
- if( result.description ) {
-
- text += ' ' + result.description + ' ';
-
- }
-
-
- // return
- return text;
-
- }
- };
-
-
- // value
- var value = this.get_value( $select );
-
-
- // multiple
- if( args.multiple ) {
-
- // vars
- var name = $select.attr('name');
-
-
- // add hidden input to each multiple selection
- select2_args.formatSelection = function( object, $div ){
-
- // vars
- var html = ' ';
-
-
- // append input
- $div.parent().append(html);
-
-
- // return
- return object.text;
-
- }
-
- } else {
-
- // change array to single object
- value = acf.maybe_get(value, 0, false);
-
-
- // if no allow_null, this single select must contain a selection
- if( !args.allow_null && value ) {
-
- $input.val( value.id );
-
- }
- }
-
-
- // remove the blank option as we have a clear all button!
- if( args.allow_null ) {
-
- $select.find('option[value=""]').remove();
-
- }
-
-
- // get data
- select2_args.data = this.get_data( $select );
-
-
- // initial selection
- select2_args.initSelection = function( element, callback ) {
-
- callback( value );
-
- };
-
-
- // ajax
- if( args.ajax ) {
-
- select2_args.ajax = {
- url: acf.get('ajaxurl'),
- dataType: 'json',
- type: 'post',
- cache: false,
- quietMillis: 250,
- data: function( term, page ) {
-
- // vars
- var params = { 'term': term, 'page': page };
-
-
- // return
- return _select2.get_ajax_data(args, params, $input, $field);
-
- },
- results: function( data, page ){
-
- // vars
- var params = { 'page': page };
-
-
- // merge together groups
- setTimeout(function(){
-
- _select23.merge_results();
-
- }, 1);
-
-
- // return
- return _select2.get_ajax_results(data, params);
-
- }
- };
-
- }
-
-
- // attachment z-index fix
- select2_args.dropdownCss = {
- 'z-index' : '999999999'
- };
-
-
- // append args
- select2_args.acf = args;
-
-
- // filter for 3rd party customization
- select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args, $field );
-
-
- // add select2
- $input.select2( select2_args );
-
-
- // vars
- var $container = $input.select2('container');
-
-
- // reorder DOM
- // - this order is very important so don't change it
- // - $select goes first so the input can override it. Fixes issue where conditional logic will enable the select
- // - $input goes second to reset the input data
- // - container goes last to allow multiple hidden inputs to override $input
- $container.before( $select );
- $container.before( $input );
-
-
- // multiple
- if( args.multiple ) {
-
- // sortable
- $container.find('ul.select2-choices').sortable({
- start: function() {
- $input.select2("onSortStart");
- },
- stop: function() {
- $input.select2("onSortEnd");
- }
- });
-
- }
-
-
- // disbale select
- $select.prop('disabled', true).addClass('acf-disabled acf-hidden');
-
-
- // update select value
- // this fixes a bug where select2 appears blank after duplicating a post_object field (field settings).
- // the $select is disabled, so setting the value won't cause any issues (this is what select2 v4 does anyway).
- $input.on('change', function(e) {
-
- // add new data
- if( e.added ) {
-
- // add item
- _select2.add_option($select, e.added.id, e.added.text);
-
- }
-
-
- // select
- _select2.select_option($select, e.val);
-
- });
-
-
- // action for 3rd party customization
- acf.do_action('select2_init', $input, select2_args, args, $field);
-
- },
-
-
- /*
- * merge_results_v3
- *
- * description
- *
- * @type function
- * @date 20/07/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- merge_results: function(){
-
- // vars
- var label = '',
- $list = null;
-
-
- // loop
- $('#select2-drop .select2-result-with-children').each(function(){
-
- // vars
- var $label = $(this).children('.select2-result-label'),
- $ul = $(this).children('.select2-result-sub');
-
-
- // append group to previous
- if( $label.text() == label ) {
-
- $list.append( $ul.children() );
-
- $(this).remove();
-
- return;
-
- }
-
-
- // update vars
- label = $label.text();
- $list = $ul;
-
- });
-
- },
-
-
- /*
- * destroy
- *
- * This function will destroy a Select2
- *
- * @type function
- * @date 24/12/2015
- * @since 5.3.2
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- destroy: function( $select ){
-
- // vars
- var $input = $select.siblings('input');
-
-
- // destroy via api
- if( $input.data('select2') ) {
- $input.select2('destroy');
- }
-
-
- // destory via HTML (duplicating HTML deos not contain data)
- $select.siblings('.select2-container').remove();
-
-
- // enable select
- $select.prop('disabled', false).removeClass('acf-disabled acf-hidden');
- $input.attr('style', ''); // fixes bug causing hidden select2 element
-
- },
-
- add_value: function( $select, value, label ){
-
- // add and select item
- _select2.add_option($select, value, label);
- _select2.select_option($select, value);
-
-
- // vars
- var $input = $select.siblings('input');
-
-
- // new item
- var item = {
- 'id': value,
- 'text': label
- };
-
-
- // single
- if( !$select.data('multiple') ) {
-
- return $input.select2('data', item);
-
- }
-
-
- // get existing value
- var values = $input.select2('data') || [];
-
-
- // append
- values.push(item);
-
-
- // set data
- return $input.select2('data', values);
-
- },
-
- remove_value: function( $select, value ){
-
- // unselect option
- _select2.unselect_option($select, value);
-
-
- // vars
- var $input = $select.siblings('input'),
- current = $input.select2('data');
-
-
- // single
- if( !$select.data('multiple') ) {
-
- if( current && current.id == value ) {
-
- $input.select2('data', null);
-
- }
-
- // multiple
- } else {
-
- // filter
- current = $.grep(current, function( item ) {
- return item.id != value;
- });
-
-
- // set data
- $input.select2('data', current);
-
- }
-
+ $.fn.select2.locales[ locale ] = select2L10n;
+ $.extend($.fn.select2.defaults, select2L10n);
}
-
- };
-
-
- /*
- * Select2 v4
- *
- * This model contains the Select2 v4 functions
- *
- * @type function
- * @date 28/4/17
- * @since 5.5.10
- *
- * @param n/a
- * @return n/a
- */
-
- _select24 = _select2.version4 = {
-
- init: function( $select, args, $field ){
-
- // defaults
- args = args || {};
- $field = $field || null;
-
-
- // merge
- args = $.extend({
- allow_null: false,
- placeholder: '',
- multiple: false,
- ajax: false,
- ajax_action: ''
- }, args);
-
-
- // vars
- var $input = $select.siblings('input');
-
-
- // bail early if no input
- if( !$input.exists() ) return;
-
-
- // select2 args
- var select2_args = {
- width: '100%',
- allowClear: args.allow_null,
- placeholder: args.placeholder,
- multiple: args.multiple,
- separator: '||',
- data: [],
- escapeMarkup: function( m ){ return m; }
- };
-
-
- // value
- var value = this.get_value( $select );
-
-
- // multiple
- if( args.multiple ) {
-
- // reorder opts
- $.each(value, function( k, item ){
-
- // detach and re-append to end
- item.$el.detach().appendTo( $select );
-
- });
-
- } else {
-
- // change array to single object
- value = acf.maybe_get(value, 0, '');
-
- }
-
-
-/*
- // removed - Select2 does not show this value by default!
- // remove the blank option as we have a clear all button!
- if( args.allow_null ) {
-
- $select.find('option[value=""]').remove();
-
- }
-*/
-
-
- // remove conflicting atts
- if( !args.ajax ) {
-
- $select.removeData('ajax');
- $select.removeAttr('data-ajax');
-
- } else {
-
- select2_args.ajax = {
- url: acf.get('ajaxurl'),
- delay: 250,
- dataType: 'json',
- type: 'post',
- cache: false,
- data: function( params ) {
-
- // return
- return _select2.get_ajax_data(args, params, $select, $field);
-
- },
- processResults: function( data, params ){
-
- // vars
- var results = _select2.get_ajax_results(data, params);
-
-
- // change to more
- if( results.more ) {
-
- results.pagination = { more: true };
-
- }
-
-
- // merge together groups
- setTimeout(function(){
-
- _select24.merge_results();
-
- }, 1);
-
-
- // return
- return results
-
- }
-
- };
-
- }
-
-
- // filter for 3rd party customization
- select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args, $field );
-
-
- // add select2
- $select.select2( select2_args );
-
-
- // get container (Select2 v4 deos not return this from constructor)
- var $container = $select.next('.select2-container');
-
-
- // reorder DOM
- // - no need to reorder, the select field is needed to $_POST values
-
-
- // multiple
- if( args.multiple ) {
-
- // vars
- var $ul = $container.find('ul');
-
-
- // sortable
- $ul.sortable({
-
- stop: function( e ) {
-
- $ul.find('.select2-selection__choice').each(function() {
-
- // vars
- var $option = $( $(this).data('data').element );
-
-
- // detach and re-append to end
- $option.detach().appendTo( $select );
-
-
- // trigger change on input (JS error if trigger on select)
- $input.trigger('change');
- // update input
- //_select2.sync_input_value( $input, $select );
-
- });
-
- }
-
- });
-
-
- // on select, move to end
- $select.on('select2:select', function( e ){
-
- // vars
- var $option = $(e.params.data.element);
-
-
- // detach and re-append to end
- $option.detach().appendTo( $select );
-
-
- // trigger change
- //$select.trigger('change');
-
- });
-
- }
-
-
-/*
- // update input
- $select.on('select2:select', function( e ){
-
- // update input
- _select2.sync_input_value( $input, $select );
-
- });
-
- $select.on('select2:unselect', function( e ){
-
- // update input
- _select2.sync_input_value( $input, $select );
-
- });
-*/
-
-
- // clear value (allows null to be saved)
- $input.val('');
-
-
- // add class
- $container.addClass('-acf');
-
-
- // action for 3rd party customization
- acf.do_action('select2_init', $select, select2_args, args, $field);
-
- },
-
-
- /*
- * merge_results_v4
- *
- * description
- *
- * @type function
- * @date 20/07/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- merge_results: function(){
-
- // vars
- var $prev_options = null,
- $prev_group = null;
-
-
- // loop
- $('.select2-results__option[role="group"]').each(function(){
-
- // vars
- var $options = $(this).children('ul'),
- $group = $(this).children('strong');
-
-
- // compare to previous
- if( $prev_group !== null && $group.text() == $prev_group.text() ) {
-
- $prev_options.append( $options.children() );
-
- $(this).remove();
-
- return;
-
- }
-
-
- // update vars
- $prev_options = $options;
- $prev_group = $group;
-
- });
-
- },
-
- add_value: function( $select, value, label ){
-
- // add and select item
- _select2.add_option($select, value, label);
- _select2.select_option($select, value);
-
- },
-
- remove_value: function( $select, value ){
-
- // unselect
- _select2.unselect_option($select, value);
-
- },
-
- destroy: function( $select ){
-
- // destroy via api
- if( $select.data('select2') ) {
- $select.select2('destroy');
- }
-
-
- // destory via HTML (duplicating HTML deos not contain data)
- $select.siblings('.select2-container').remove();
-
- }
-
- };
-
-
- /*
- * depreciated
- *
- * These functions have moved since v5.3.3
- *
- * @type function
- * @date 11/12/2015
- * @since 5.3.2
- *
- * @param n/a
- * @return n/a
- */
-
- acf.add_select2 = function( $select, args ) {
-
- _select2.init( $select, args );
-
- }
-
- acf.remove_select2 = function( $select ) {
-
- _select2.destroy( $select );
-
- }
-
-})(jQuery);
-
-(function($){
-
- // select
- acf.fields.select = acf.field.extend({
-
- type: 'select',
-
- $select: null,
-
- actions: {
- 'ready': 'render',
- 'append': 'render',
- 'remove': 'remove'
- },
-
- focus: function(){
-
- // focus on $select
- this.$select = this.$field.find('select');
-
-
- // bail early if no select field
- if( !this.$select.exists() ) return;
-
-
- // get options
- this.o = acf.get_data( this.$select );
-
-
- // customize o
- this.o = acf.parse_args(this.o, {
- 'ajax_action': 'acf/fields/'+this.type+'/query',
- 'key': this.$field.data('key')
- });
-
- },
-
- render: function(){
-
- // validate ui
- if( !this.$select.exists() || !this.o.ui ) {
-
- return false;
-
- }
-
-
- acf.select2.init( this.$select, this.o, this.$field );
-
- },
-
- remove: function(){
-
- // validate ui
- if( !this.$select.exists() || !this.o.ui ) {
-
- return false;
-
- }
-
-
- // remove select2
- acf.select2.destroy( this.$select );
-
- }
-
- });
-
-
- // user
- acf.fields.user = acf.fields.select.extend({
-
- type: 'user'
-
- });
-
-
- // post_object
- acf.fields.post_object = acf.fields.select.extend({
-
- type: 'post_object'
-
});
-
- // page_link
- acf.fields.page_link = acf.fields.select.extend({
-
- type: 'page_link'
-
- });
-
-
})(jQuery);
(function($, undefined){
- var i = 0;
-
- acf.fields.accordion = acf.field.extend({
-
- type: 'accordion',
- $el: null,
- $wrap: null,
-
- actions: {
- 'prepare': 'initialize',
- 'append': 'initialize',
- },
-
- focus: function(){
-
-
- },
-
- initialize: function(){
-
- // vars
- var $field = this.$field;
- var $label = $field.children('.acf-label');
- var $input = $field.children('.acf-input');
- var $wrap = $input.children('.acf-fields');
- var settings = $wrap.data();
-
-
- // bail early if is cell
- if( $field.is('td') ) return;
-
-
- // enpoint
- if( settings.endpoint ) {
- $field.remove();
- return;
- }
-
-
- // force description into label
- var $instructions = $input.children('.description')
- if( $instructions.length ) {
- $label.append( $instructions );
- }
-
-
- // table
- if( $field.is('tr') ) {
-
- // vars
- var $table = $field.closest('table');
- var $newLabel = $('
');
- var $newInput = $('
');
- var $newTable = $('');
- var $newWrap = $(' ');
-
- // dom
- $newLabel.append( $label.html() );
- $newTable.append( $newWrap );
- $newInput.append( $newTable );
- $input.append( $newLabel );
- $input.append( $newInput );
-
- // modify
- $label.remove();
- $wrap.remove();
- $input.attr('colspan', 2);
-
- // update vars
- $label = $newLabel;
- $input = $newInput;
- $wrap = $newWrap;
-
- }
-
-
- // add classes
- $field.addClass('acf-accordion');
- $label.addClass('acf-accordion-title');
- $input.addClass('acf-accordion-content');
-
-
- // index
- i++;
-
-
- // multi-expand
- if( settings.multi_expand ) {
- $field.data('multi-expand', 1);
- }
-
-
- // open
- var order = acf.getPreference('this.accordions') || [];
- if( order[i-1] !== undefined ) {
- settings.open = order[i-1];
- }
- if( settings.open ) {
- $field.addClass('-open');
- $input.css('display', 'block'); // needed for accordion to close smoothly
- }
-
-
- // add icon
- $label.prepend(' ');
-
-
- // classes
- // - remove 'inside' which is a #poststuff WP class
- var $parent = $field.parent();
- $wrap.addClass( $parent.hasClass('-left') ? '-left' : '' );
- $wrap.addClass( $parent.hasClass('-clear') ? '-clear' : '' );
-
-
- // append
- $wrap.append( $field.nextUntil('.acf-field-accordion', '.acf-field') );
-
-
- // clean up
- $wrap.removeAttr('data-open data-multi_expand data-endpoint');
- }
-
- });
-
-
- /*
- * accordionManager
- *
- * This model will handle adding accordions
- *
- * @type function
- * @date 25/11/2015
- * @since 5.3.2
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- var accordionManager = acf.model.extend({
-
- events: {
- 'click .acf-accordion-title': '_click',
- },
-
- _click: function( e ){
-
- // prevent Defailt
- e.preventDefault();
-
- // open close
- this.toggle( e.$el.closest('.acf-accordion') );
-
- },
-
- isOpen: function( $el ) {
- return $el.hasClass('-open');
- },
-
- toggle: function( $el ){
-
- // is open
- if( this.isOpen($el) ) {
- this.close( $el );
- } else {
- this.open( $el );
- }
-
- },
-
- open: function( $el ){
-
- // open
- $el.find('.acf-accordion-content:first').slideDown().css('display', 'block');
- $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-right').addClass('dashicons-arrow-down');
- $el.addClass('-open');
-
- // action
- acf.do_action('show', $el);
-
- // close siblings
- if( !$el.data('multi-expand') ) {
- $el.siblings('.acf-accordion.-open').each(function(){
- accordionManager.close( $(this) );
- });
- }
-
- // action
- acf.do_action('refresh', $el);
- },
-
- close: function( $el ){
-
- // close
- $el.find('.acf-accordion-content:first').slideUp();
- $el.find('.acf-accordion-icon:first').removeClass('dashicons-arrow-down').addClass('dashicons-arrow-right');
- $el.removeClass('-open');
-
- // action
- acf.do_action('hide', $el);
-
- }
-
- });
-
- $(window).on('unload', function(){
-
- var order = [];
- $('.acf-accordion').each(function(){
- var open = $(this).hasClass('-open') ? 1 : 0;
- order.push(open);
- });
- if( !order.length ) return;
- acf.setPreference('this.accordions', order);
-
- });
-
-
- /**
- * accordionValidation
- *
- * This model will handle validation of fields within an accordion
- *
- * @date 20/11/17
- * @since 5.6.5
- *
- * @param n/a
- * @return n/a
- */
-
- var accordionValidation = acf.model.extend({
-
- active: 1,
-
- events: {
- 'invalidField .acf-accordion': 'invalidField'
- },
-
- invalidField: function( e ){
-
- // bail early if already focused
- if( !this.active ) return;
-
- // block
- this.block();
-
- // open
- accordionManager.open( e.$el );
-
- },
-
- block: function(){
-
- // reference
- var self = this;
-
- // disable functionality for 1sec (allow next validation to work)
- this.active = 0;
-
- // timeout
- setTimeout(function(){
- self.active = 1;
- }, 1000);
-
- }
-
- });
-
-})(jQuery);
-
-(function($){
-
- // vars
- var CLASS = 'hidden-by-conditional-logic';
- var groupIndex = 0;
- var tabIndex = 0;
-
-
- /*
- * tabs
- *
- * This model will handle adding tabs and groups
- *
- * @type function
- * @date 25/11/2015
- * @since 5.3.2
- *
- * @param n/a
- * @return n/a
- */
-
- var tabs = acf.model.extend({
-
- $fields: [],
-
- actions: {
- 'prepare 15': 'initialize',
- 'append 15': 'initialize',
- 'refresh 15': 'refresh'
- },
-
- events: {
- 'click .acf-tab-button': '_click'
- },
-
- _click: function( e ){
-
- // prevent Defailt
- e.preventDefault();
-
- // toggle
- this.toggle( e.$el );
-
- },
-
- isOpen: function( $el ) {
- return $el.hasClass('-open');
- },
-
- toggle: function( $a ){
-
- // vars
- var key = $a.data('key');
- var $li = $a.parent();
- var $wrap = $a.closest('.acf-tab-wrap');
- var $active = $wrap.find('.active a');
- var $field = $wrap.siblings('.acf-field[data-key="' + key + '"]');
-
-
- // bail early if already open
- if( this.isOpen($field) ) return;
-
-
- // close
- if( $active.length ) {
-
- // vars
- var activeKey = $active.data('key');
- var $activeli = $active.parent();
- var $activeField = $wrap.siblings('.acf-field[data-key="' + activeKey + '"]');
-
- // hide
- $activeli.removeClass('active');
- this.close( $activeField );
-
- }
-
-
- // open
- $li.addClass('active');
- this.open( $field );
-
-
- // action
- // - allows acf.layout to fix floating field's min-height
- acf.do_action('refresh', $wrap.parent() );
-
- },
-
- getFields: function( $field ){
- return $field.nextUntil('.acf-field-tab', '.acf-field');
- },
-
- getWrap: function( $field ){
- return $field.prevAll('.acf-tab-wrap:first');
- },
-
- getTab: function( $wrap, key ){
- return $wrap.find('a[data-key="' + key + '"]');
- },
-
- open: function( $field ){
-
- // show
- this.getFields( $field ).each(function(){
-
- $(this).removeClass('hidden-by-tab');
- acf.do_action('show_field', $(this), 'tab');
-
- });
-
- },
-
- close: function( $field ){
-
- // show
- this.getFields( $field ).each(function(){
-
- $(this).addClass('hidden-by-tab');
- acf.do_action('hide_field', $(this), 'tab');
-
- });
-
- },
-
- addTab: function( $field ){
- this.$fields.push( $field );
- },
-
- initialize: function(){
-
- // bail ealry if no fields
- if( !this.$fields.length ) return;
-
- // loop
- for( var i = 0; i < this.$fields.length; i++) {
- this.createTab( this.$fields[ i ] );
- }
-
- // reset
- this.$fields = [];
-
- },
-
- createTab: function( $field ){
-
- // bail early if is cell
- if( $field.is('td') ) return false;
-
-
- // vars
- var $label = $field.children('.acf-label');
- var $input = $field.children('.acf-input');
- var $wrap = this.getWrap( $field );
- var $button = $field.find('.acf-tab-button');
- var settings = $button.data();
- var open = false;
-
-
- // remove
- $field.hide();
- $label.remove();
- $input.remove();
-
-
- // create wrap
- if( !$wrap.exists() || settings.endpoint ) {
- $wrap = this.createTabWrap( $field, settings );
- open = true;
- }
-
-
- // create tab
- var $tab = $(' ').append( $button );
-
-
- // open
- if( open ) {
- $tab.addClass('active');
- this.open( $field );
- } else {
- this.close( $field );
- }
-
-
- // hide li
- if( $button.html() == '' ) $tab.hide();
-
-
- // append
- $wrap.find('ul').append( $tab );
-
-
- // toggle active tab
- // previous attempts to integrate with above 'open' variable were uncessefull
- // this separate toggle logic ensures the tab exists
- tabIndex++;
- var order = acf.getPreference('this.tabs') || [];
- var index = order[ groupIndex-1 ] || 0;
- if( index == tabIndex-1 && !open ) {
- this.toggle( $button );
- }
-
-
- // return
- return $tab;
- },
-
- createTabWrap: function( $field, settings ){
-
- // vars
- var $parent = $field.parent();
- var $wrap = false;
-
-
- // add sidebar for left placement
- if( $parent.hasClass('acf-fields') && settings.placement == 'left' ) {
- $parent.addClass('-sidebar');
- }
-
-
- // create wrap
- if( $field.is('tr') ) {
- $wrap = $(' ');
- } else {
- $wrap = $('');
- }
-
-
- // append
- $field.before( $wrap );
-
-
- // index
- groupIndex++;
- tabIndex = 0;
-
-
- // return
- return $wrap;
-
- },
-
- refresh: function( $el ){
-
- // loop
- $('.acf-tab-wrap', $el).each(function(){
-
- // vars
- var $wrap = $(this);
-
-
- // fix left aligned min-height
- if( $wrap.hasClass('-left') ) {
-
- // vars
- var $parent = $wrap.parent();
- var attribute = $parent.is('td') ? 'height' : 'min-height';
-
- // find height (minus 1 for border-bottom)
- var height = $wrap.position().top + $wrap.children('ul').outerHeight(true) - 1;
-
- // add css
- $parent.css(attribute, height);
-
- }
-
- });
-
- }
-
- });
-
-
-
- /**
- * acf.fields.tab
- *
- * description
- *
- * @date 17/11/17
- * @since 5.6.5
- *
- * @param n/a
- * @return n/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(){
-
- // add tab
- tabs.addTab( this.$field );
-
- },
-
- hide: function( $field, context ){
-
- // bail early if not conditional logic
- if( context != 'conditional_logic' ) return;
-
-
- // vars
- var key = $field.data('key');
- var $wrap = tabs.getWrap( $field );
- var $tab = tabs.getTab( $wrap, key );
- var $li = $tab.parent();
-
- // bail early if $group does not exist (clone field)
- if( !$wrap.exists() ) return;
-
-
- // hide li
- $li.addClass( CLASS );
-
-
- // hide fields
- tabs.getFields( $field ).each(function(){
- acf.conditional_logic.hide_field( $(this), key );
- });
-
-
- // select other tab if active
- if( $li.hasClass('active') ) {
- $wrap.find('li:not(.'+CLASS+'):first a').trigger('click');
- }
-
- },
-
- show: function( $field, context ){
-
- // bail early if not conditional logic
- if( context != 'conditional_logic' ) return;
-
-
- // vars
- var key = $field.data('key');
- var $wrap = tabs.getWrap( $field );
- var $tab = tabs.getTab( $wrap, key );
- var $li = $tab.parent();
-
-
- // bail early if $group does not exist (clone field)
- if( !$wrap.exists() ) return;
-
-
- // show li
- $li.removeClass( CLASS );
-
-
- // hide fields
- tabs.getFields( $field ).each(function(){
- acf.conditional_logic.show_field( $(this), key );
- });
-
-
- // select tab if no other active
- var $active = $li.siblings('.active');
- if( !$active.exists() || $active.hasClass(CLASS) ) {
- tabs.toggle( $tab );
- }
-
- }
-
- });
-
-
- $(window).on('unload', function(){
-
- var order = [];
- $('.acf-tab-wrap').each(function(){
- var active = $(this).find('.active').index() || 0;
- order.push(active);
- });
- if( !order.length ) return;
- acf.setPreference('this.tabs', order);
-
- });
-
-
- /*
- * tab_validation
- *
- * This model will handle validation of fields within a tab group
- *
- * @type function
- * @date 25/11/2015
- * @since 5.3.2
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- var tab_validation = acf.model.extend({
-
- active: 1,
-
- actions: {
- 'invalid_field': 'invalid_field',
- },
-
- invalid_field: function( $field ){
-
- // bail early if already focused
- if( !this.active ) {
- return;
- }
-
-
- // bail early if not hidden by tab
- if( !$field.hasClass('hidden-by-tab') ) {
- return;
- }
-
-
- // reference
- var self = this;
-
-
- // vars
- var $tab = $field.prevAll('.acf-field-tab:first'),
- $group = $field.prevAll('.acf-tab-wrap:first');
-
-
- // focus
- $group.find('a[data-key="' + $tab.data('key') + '"]').trigger('click');
-
-
- // disable functionality for 1sec (allow next validation to work)
- this.active = 0;
-
- setTimeout(function(){
-
- self.active = 1;
-
- }, 1000);
-
- }
-
- });
-
-
-})(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(){
-
- // get elements
- this.$el = this.$field.find('.acf-time-picker');
- this.$input = this.$el.find('input[type="text"]');
- this.$hidden = this.$el.find('input[type="hidden"]');
-
-
- // get options
- this.o = acf.get_data( this.$el );
-
- },
-
- initialize: function(){
-
- // bail ealry if no timepicker library
- if( typeof $.timepicker === 'undefined' ) return;
-
-
- // create options
- var args = {
- timeFormat: this.o.time_format,
- altField: this.$hidden,
- altFieldTimeOnly: false,
- altTimeFormat: 'HH:mm:ss',
- showButtonPanel: true,
- controlType: 'select',
- oneLine: true,
- closeText: acf._e('date_time_picker', 'selectText')
- };
-
-
- // add custom 'Close = Select' functionality
- args.onClose = function( value, instance ){
-
- // vars
- var $div = instance.dpDiv,
- $close = $div.find('.ui-datepicker-close');
-
-
- // if clicking close button
- if( !value && $close.is(':hover') ) {
-
- // attempt to find new value
- value = acf.maybe_get(instance, 'settings.timepicker.formattedTime');
-
-
- // bail early if no value
- if( !value ) return;
-
-
- // update value
- $.datepicker._setTime(instance);
-
- }
-
- };
-
-
- // filter for 3rd party customization
- args = acf.apply_filters('time_picker_args', args, this.$field);
-
-
- // add date picker
- this.$input.timepicker( args );
-
-
- // wrap the datepicker (only if it hasn't already been wrapped)
- if( $('body > #ui-datepicker-div').exists() ) {
-
- $('body > #ui-datepicker-div').wrap('
');
-
- }
-
-
- // action for 3rd party customization
- acf.do_action('time_picker_init', this.$input, args, this.$field);
-
- },
-
- blur: function(){
-
- if( !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
- *
- * This function will setup variables when focused on a field
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- focus: function(){
-
- // vars
- this.$input = this.$field.find('.acf-switch-input');
- this.$switch = this.$field.find('.acf-switch');
-
- },
-
-
- /*
- * render
- *
- * This function is used to setup basic upload form attributes
- *
- * @type function
- * @date 12/04/2016
- * @since 5.3.8
- *
- * @param n/a
- * @return n/a
- */
-
- render: function(){
-
- // bail ealry if no $switch
- if( !this.$switch.exists() ) return;
-
-
- // vars
- var $on = this.$switch.children('.acf-switch-on'),
- $off = this.$switch.children('.acf-switch-off')
- width = Math.max( $on.width(), $off.width() );
-
-
- // bail ealry if no width
- if( !width ) return;
-
-
- // set widths
- $on.css( 'min-width', width );
- $off.css( 'min-width', width );
-
- },
-
-
- /*
- * on
- *
- * description
- *
- * @type function
- * @date 10/1/17
- * @since 5.5.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- on: function() { //console.log('on');
-
- this.$input.prop('checked', true);
- this.$switch.addClass('-on');
-
- },
-
-
- /*
- * off
- *
- * description
- *
- * @type function
- * @date 10/1/17
- * @since 5.5.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- off: function() { //console.log('off');
-
- this.$input.prop('checked', false);
- this.$switch.removeClass('-on');
-
- },
-
-
- /*
- * change
- *
- * description
- *
- * @type function
- * @date 12/10/16
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- _change: function( e ){
-
- // vars
- var checked = e.$el.prop('checked');
-
-
- // enable
- if( checked ) {
-
- this.on();
-
- // disable
- } else {
-
- this.off();
-
- }
-
- },
-
-
- /*
- * _focus
- *
- * description
- *
- * @type function
- * @date 10/1/17
- * @since 5.5.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- _focus: function( e ){
-
- this.$switch.addClass('-focus');
-
- },
-
-
- /*
- * _blur
- *
- * description
- *
- * @type function
- * @date 10/1/17
- * @since 5.5.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- _blur: function( e ){
-
- this.$switch.removeClass('-focus');
-
- },
-
-
- /*
- * _keypress
- *
- * description
- *
- * @type function
- * @date 10/1/17
- * @since 5.5.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- _keypress: function( e ){
-
- // left
- if( e.keyCode === 37 ) {
-
- return this.off();
-
- }
-
-
- // right
- if( e.keyCode === 39 ) {
-
- return this.on();
-
- }
-
- }
-
- });
-
-})(jQuery);
-
-(function($){
-
- // taxonomy
- 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(){
-
- // $el
- this.$el = this.$field.find('.acf-taxonomy-field');
-
-
- // get options
- this.o = acf.get_data(this.$el, {
- save: '',
- type: '',
- taxonomy: ''
- });
-
-
- // extra
- this.o.key = this.$field.data('key');
-
- },
-
- render: function(){
-
- // attempt select2
- var $select = this.$field.find('select');
-
-
- // bail early if no select field
- if( !$select.exists() ) return;
-
-
- // select2 options
- var args = acf.get_data( $select );
-
-
- // customize args
- args = acf.parse_args(args, {
- 'pagination': true,
- 'ajax_action': 'acf/fields/taxonomy/query',
- 'key': this.o.key
- });
-
-
- // add select2
- acf.select2.init( $select, args );
-
- },
-
- remove: function(){
-
- // attempt select2
- var $select = this.$field.find('select');
-
-
- // validate ui
- if( !$select.exists() ) return false;
-
-
- // remove select2
- acf.select2.destroy( $select );
-
- },
-
- add_term: function( e ){
-
- // reference
- var self = this;
-
-
- // open popup
- acf.open_popup({
- title: e.$el.attr('title') || e.$el.data('title'),
- loading: true,
- height: 220
- });
-
-
-
- // AJAX data
- var ajax_data = acf.prepare_for_ajax({
- action: 'acf/fields/taxonomy/add_term',
- field_key: this.o.key
- });
-
-
-
- // get HTML
- $.ajax({
- url: acf.get('ajaxurl'),
- data: ajax_data,
- type: 'post',
- dataType: 'html',
- success: function(html){
-
- self.add_term_confirm( html );
-
- }
- });
-
-
- },
-
- add_term_confirm: function( html ){
-
- // reference
- var self = this;
-
-
- // update popup
- acf.update_popup({
- content : html
- });
-
-
- // focus
- $('#acf-popup input[name="term_name"]').focus();
-
-
- // events
- $('#acf-popup form').on('submit', function( e ){
-
- // prevent default
- e.preventDefault();
-
-
- // submit
- self.add_term_submit( $(this ));
-
- });
-
- },
-
- add_term_submit: function( $form ){
-
- // reference
- var self = this;
-
-
- // vars
- var $submit = $form.find('.acf-submit'),
- $name = $form.find('input[name="term_name"]'),
- $parent = $form.find('select[name="term_parent"]');
-
-
- // basic validation
- if( $name.val() === '' ) {
-
- $name.focus();
- return false;
-
- }
-
-
- // show loading
- $submit.find('button').attr('disabled', 'disabled');
- $submit.find('.acf-spinner').addClass('is-active');
-
-
- // vars
- var ajax_data = acf.prepare_for_ajax({
- action: 'acf/fields/taxonomy/add_term',
- field_key: this.o.key,
- term_name: $name.val(),
- term_parent: $parent.exists() ? $parent.val() : 0
- });
-
-
- // save term
- $.ajax({
- url: acf.get('ajaxurl'),
- data: ajax_data,
- type: 'post',
- dataType: 'json',
- success: function( json ){
-
- // vars
- var message = acf.get_ajax_message(json);
-
-
- // success
- if( acf.is_ajax_success(json) ) {
-
- // clear name
- $name.val('');
-
-
- // update term lists
- self.append_new_term( json.data );
-
- }
-
-
- // message
- if( message.text ) {
-
- $submit.find('span').html( message.text );
-
- }
-
- },
- complete: function(){
-
- // reset button
- $submit.find('button').removeAttr('disabled');
-
-
- // hide loading
- $submit.find('.acf-spinner').removeClass('is-active');
-
-
- // remove message
- $submit.find('span').delay(1500).fadeOut(250, function(){
-
- $(this).html('');
- $(this).show();
-
- });
-
-
- // focus
- $name.focus();
-
- }
- });
-
- },
-
- append_new_term: function( term ){
-
- // vars
- var item = {
- id: term.term_id,
- text: term.term_label
- };
-
-
- // append to all taxonomy lists
- $('.acf-taxonomy-field[data-taxonomy="' + this.o.taxonomy + '"]').each(function(){
-
- // vars
- var type = $(this).data('type');
-
-
- // bail early if not checkbox/radio
- if( type == 'radio' || type == 'checkbox' ) {
-
- // allow
-
- } else {
-
- return;
-
- }
-
-
- // vars
- var $hidden = $(this).children('input[type="hidden"]'),
- $ul = $(this).find('ul:first'),
- name = $hidden.attr('name');
-
-
- // allow multiple selection
- if( type == 'checkbox' ) {
-
- name += '[]';
-
- }
-
-
- // create new li
- var $li = $([
- '',
- '',
- ' ',
- '' + term.term_label + ' ',
- ' ',
- ' '
- ].join(''));
-
-
- // find parent
- if( term.term_parent ) {
-
- // vars
- var $parent = $ul.find('li[data-id="' + term.term_parent + '"]');
-
-
- // update vars
- $ul = $parent.children('ul');
-
-
- // create ul
- if( !$ul.exists() ) {
-
- $ul = $('');
-
- $parent.append( $ul );
-
- }
-
- }
-
-
- // append
- $ul.append( $li );
-
- });
-
-
- // append to select
- $('#acf-popup #term_parent').each(function(){
-
- // vars
- var $option = $('' + term.term_label + ' ');
-
- if( term.term_parent ) {
-
- $(this).children('option[value="' + term.term_parent + '"]').after( $option );
-
- } else {
-
- $(this).append( $option );
-
- }
-
- });
-
-
- // set value
- switch( this.o.type ) {
-
- // select
- case 'select':
-
- //this.$el.children('input').select2('data', item);
-
-
- // vars
- var $select = this.$el.children('select');
- acf.select2.add_value($select, term.term_id, term.term_label);
-
-
- break;
-
- case 'multi_select':
-
-/*
- // vars
- var $input = this.$el.children('input'),
- value = $input.select2('data') || [];
-
-
- // append
- value.push( item );
-
-
- // update
- $input.select2('data', value);
-
-
-*/
- // vars
- var $select = this.$el.children('select');
- acf.select2.add_value($select, term.term_id, term.term_label);
-
-
- break;
-
- case 'checkbox':
- case 'radio':
-
- // scroll to view
- var $holder = this.$el.find('.categorychecklist-holder'),
- $li = $holder.find('li[data-id="' + term.term_id + '"]'),
- offet = $holder.get(0).scrollTop + ( $li.offset().top - $holder.offset().top );
-
-
- // check input
- $li.find('input').prop('checked', true);
-
-
- // scroll to bottom
- $holder.animate({scrollTop: offet}, '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(){
-
- // vars
- var val = this.$input.val();
-
-
- if( val.indexOf('://') !== -1 ) {
-
- // url
-
- } else if( val.indexOf('//') === 0 ) {
-
- // protocol relative url
-
- } else {
-
- return false;
-
- }
-
-
- // return
- return true;
-
- },
-
- render: function(){
-
- // add class
- if( this.is_valid() ) {
-
- this.$input.parent().addClass('-valid');
-
- // remove class
- } else {
-
- 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'
- },
-
-
- // vars
- active: 1,
- ignore: 0,
- busy: 0,
- valid: true,
- errors: [],
-
-
- // classes
- error_class: 'acf-error',
- message_class: 'acf-error-message',
-
-
- // el
- $trigger: null,
-
-
- /*
- * ready
- *
- * This function will add 'non bubbling' events
- *
- * @type function
- * @date 26/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- ready: function( $el ){
-
- // vars
- var $inputs = $('.acf-field input, .acf-field textarea, .acf-field select');
-
-
- // bail early if no inputs
- if( !$inputs.length ) return;
-
-
- // reference
- var self = this;
-
-
- // event
- $inputs.on('invalid', function( e ){
-
- // vars
- var $input = $(this);
- var $field = acf.get_field_wrap( $input );
-
-
- // event
- $field.trigger('invalidField');
-
-
- // action
- acf.do_action('invalid', $input);
- acf.do_action('invalid_field', $field);
-
-
- // save draft (ignore validation)
- if( acf.validation.ignore ) return;
-
-
- // prevent default
- // - prevents browser error message
- // - also fixes chrome bug where 'hidden-by-tab' field throws focus error
- e.preventDefault();
-
-
- // append to errors
- acf.validation.errors.push({
- input: $input.attr('name'),
- message: e.target.validationMessage
- });
-
-
- // invalid event has prevented the form from submitting
- // trigger acf validation fetch (safe to call multiple times)
- acf.validation.fetch( $input.closest('form') );
-
- });
-
- },
-
-
- /*
- * validation_complete
- *
- * This function will modify the JSON response and add local 'invalid' errors
- *
- * @type function
- * @date 26/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- validation_complete: function( json, $form ) {
-
- // bail early if no local errors
- if( !this.errors.length ) return json;
-
-
- // set valid
- json.valid = 0;
-
-
- // require array
- json.errors = json.errors || [];
-
-
- // vars
- var inputs = [];
-
-
- // populate inputs
- if( json.errors.length ) {
-
- for( i in json.errors ) {
-
- inputs.push( json.errors[ i ].input );
-
- }
-
- }
-
-
- // append
- if( this.errors.length ) {
-
- for( i in this.errors ) {
-
- // vars
- var error = this.errors[ i ];
-
-
- // bail ealry if alreay exists
- if( $.inArray(error.input, inputs) !== -1 ) continue;
-
-
- // append
- json.errors.push( error );
-
- }
-
- }
-
-
- // reset
- this.errors = [];
-
-
- // return
- return json;
-
- },
-
-
- /*
- * click_message
- *
- * This function will dismiss the validation message
- *
- * @type function
- * @date 26/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- click_message: function( e ) {
-
- e.preventDefault();
-
- acf.remove_el( e.$el.parent() );
-
- },
-
-
- /*
- * click_ignore
- *
- * This event is trigered via submit butons which ignore validation
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- click_ignore: function( e ) {
-
- // reference
- var self = this;
-
-
- // vars
- this.ignore = 1;
- this.$trigger = e.$el;
- this.$form = e.$el.closest('form');
-
-
- // remove error message
- $('.'+this.message_class).each(function(){
- acf.remove_el( $(this) );
- });
-
-
- // ignore required inputs
- this.ignore_required_inputs();
-
-
- // maybe show errors
- setTimeout(function(){
- self.ignore = 0;
- }, 100);
-
- },
-
-
- /**
- * ignore_required_inputs
- *
- * This function will temporarily remove the 'required' attribute from all ACF inputs
- *
- * @date 23/10/17
- * @since 5.6.3
- *
- * @param n/a
- * @return n/a
- */
-
- ignore_required_inputs: function(){
-
- // vars
- var $inputs = $('.acf-field input[required], .acf-field textarea[required], .acf-field select[required]');
-
-
- // bail early if no inputs
- if( !$inputs.length ) return;
-
-
- // remove required
- $inputs.prop('required', false);
-
-
- // timeout
- setTimeout(function(){
- $inputs.prop('required', true);
- }, 100);
-
- },
-
-
- /*
- * click_publish
- *
- * This event is trigered via submit butons which trigger validation
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- click_publish: function( e ) {
-
- this.$trigger = e.$el;
-
- },
-
-
- /*
- * submit_form
- *
- * description
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- submit_form: function( e ){
-
- // bail early if not active
- if( !this.active ) {
-
- return true;
-
- }
-
-
- // ignore validation (only ignore once)
- if( this.ignore ) {
-
- this.ignore = 0;
- return true;
-
- }
-
-
- // bail early if this form does not contain ACF data
- if( !e.$el.find('#acf-form-data').exists() ) {
-
- return true;
-
- }
-
-
- // bail early if is preview
- var $preview = e.$el.find('#wp-preview');
- if( $preview.exists() && $preview.val() ) {
-
- // WP will lock form, unlock it
- this.toggle( e.$el, 'unlock' );
- return true;
-
- }
-
-
- // prevent default
- e.preventDefault();
-
-
- // run validation
- this.fetch( e.$el );
-
- },
-
-
- /*
- * lock
- *
- * description
- *
- * @type function
- * @date 7/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- toggle: function( $form, state ){
-
- // defaults
- state = state || 'unlock';
-
-
- // debug
- //console.log('toggle %o, %o %o', this.$trigger, $form, state);
-
- // vars
- var $submit = null,
- $spinner = null,
- $parent = $('#submitdiv');
-
-
- // 3rd party publish box
- if( !$parent.exists() ) {
-
- $parent = $('#submitpost');
-
- }
-
-
- // term, user
- if( !$parent.exists() ) {
-
- $parent = $form.find('p.submit').last();
-
- }
-
-
- // front end form
- if( !$parent.exists() ) {
-
- $parent = $form.find('.acf-form-submit');
-
- }
-
-
- // default
- if( !$parent.exists() ) {
-
- $parent = $form;
-
- }
-
-
- // find elements
- // note: media edit page does not use .button, this is why we need to look for generic input[type="submit"]
- $submit = $parent.find('input[type="submit"], .button');
- $spinner = $parent.find('.spinner, .acf-spinner');
-
-
- // hide all spinners (hides the preview spinner)
- this.hide_spinner( $spinner );
-
-
- // unlock
- if( state == 'unlock' ) {
-
- this.enable_submit( $submit );
-
- // lock
- } else if( state == 'lock' ) {
-
- // show only last spinner (allow all spinners to be hidden - preview spinner + submit spinner)
- this.disable_submit( $submit );
- this.show_spinner( $spinner.last() );
-
- }
-
- },
-
-
- /*
- * fetch
- *
- * description
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- fetch: function( $form ){
-
- // bail aelry if already busy
- if( this.busy ) return false;
-
-
- // reference
- var self = this;
-
-
- // action for 3rd party
- acf.do_action('validation_begin');
-
-
- // vars
- var data = acf.serialize($form);
-
-
- // append AJAX action
- data.action = 'acf/validate_save_post';
-
-
- // prepare
- data = acf.prepare_for_ajax(data);
-
-
- // set busy
- this.busy = 1;
-
-
- // lock form
- this.toggle( $form, 'lock' );
-
-
- // ajax
- $.ajax({
- url: acf.get('ajaxurl'),
- data: data,
- type: 'post',
- dataType: 'json',
- success: function( json ){
-
- // bail early if not json success
- if( !acf.is_ajax_success(json) ) {
-
- return;
-
- }
-
-
- self.fetch_success( $form, json.data );
-
- },
- complete: function(){
-
- self.fetch_complete( $form );
-
- }
- });
-
- },
-
-
- /*
- * fetch_complete
- *
- * description
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- fetch_complete: function( $form ){
-
- // set busy
- this.busy = 0;
-
-
- // unlock so WP can publish form
- this.toggle( $form, 'unlock' );
-
-
- // bail early if validationw as not valid
- if( !this.valid ) return;
-
-
- // update ignore (allow form submit to not run validation)
- this.ignore = 1;
-
-
- // remove previous error message
- var $message = $form.children('.acf-error-message');
-
- if( $message.exists() ) {
-
- $message.addClass('-success');
- $message.children('p').html( acf._e('validation_successful') );
-
-
- // remove message
- setTimeout(function(){
-
- acf.remove_el( $message );
-
- }, 2000);
-
- }
-
-
- // remove hidden postboxes (this will stop them from being posted to save)
- $form.find('.acf-postbox.acf-hidden').remove();
-
-
- // action for 3rd party customization
- acf.do_action('submit', $form);
-
-
- // submit form again
- if( this.$trigger ) {
-
- this.$trigger.click();
-
- } else {
-
- $form.submit();
-
- }
-
-
- // lock form
- this.toggle( $form, 'lock' );
-
- },
-
-
- /*
- * fetch_success
- *
- * description
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- fetch_success: function( $form, json ){
-
- // filter for 3rd party customization
- json = acf.apply_filters('validation_complete', json, $form);
-
-
- // validate json
- if( !json || json.valid || !json.errors ) {
-
- // set valid (allows fetch_complete to run)
- this.valid = true;
-
-
- // action for 3rd party
- acf.do_action('validation_success');
-
-
- // end function
- return;
-
- }
-
- // set valid (prevents fetch_complete from runing)
- this.valid = false;
-
-
- // reset trigger
- this.$trigger = null;
-
-
- // display errors
- this.display_errors( json.errors, $form );
-
-
- // action
- acf.do_action('validation_failure');
-
- },
-
-
- /**
- * display_errors
- *
- * This function will display errors
- *
- * @date 23/10/17
- * @since 5.6.3
- *
- * @param array errors
- * @return n/a
- */
-
- display_errors: function( errors, $form ){
-
- // bail early if no errors
- if( !errors || !errors.length ) return;
-
-
- // vars
- var $message = $form.children('.acf-error-message');
- var message = acf._e('validation_failed');
- var count = 0;
- var $scrollTo = null;
-
-
- // loop
- for( i = 0; i < errors.length; i++ ) {
-
- // vars
- var error = errors[ i ];
-
-
- // general error
- if( !error.input ) {
- message += '. ' + error.message;
- continue;
- }
-
-
- // get input
- var $input = $form.find('[name="' + error.input + '"]').first();
-
-
- // if $_POST value was an array, this $input may not exist
- if( !$input.exists() ) {
- $input = $form.find('[name^="' + error.input + '"]').first();
- }
-
-
- // bail early if input doesn't exist
- if( !$input.exists() ) continue;
-
-
- // increase
- count++;
-
-
- // now get field
- var $field = acf.get_field_wrap( $input );
-
-
- // add error
- this.add_error( $field, error.message );
-
-
- // set $scrollTo
- if( $scrollTo === null ) {
- $scrollTo = $field;
- }
-
- }
-
-
- // message
- if( count == 1 ) {
- message += '. ' + acf._e('validation_failed_1');
- } else if( count > 1 ) {
- message += '. ' + acf._e('validation_failed_2').replace('%d', count);
- }
-
-
- // maybe create $message
- if( !$message.exists() ) {
- $message = $('');
- $form.prepend( $message );
- }
-
-
- // update message
- $message.children('p').html( message );
-
-
- // if no $scrollTo, set to message
- if( $scrollTo === null ) {
- $scrollTo = $message;
- }
-
-
- // timeout
- setTimeout(function(){
- $("html, body").animate({ scrollTop: $scrollTo.offset().top - ( $(window).height() / 2 ) }, 500);
- }, 10);
-
- },
-
-
- /*
- * add_error
- *
- * This function will add error markup to a field
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $field (jQuery)
- * @param message (string)
- * @return n/a
- */
-
- add_error: function( $field, message ){
-
- // reference
- var self = this;
-
-
- // add class
- $field.addClass(this.error_class);
-
-
- // add message
- if( message !== undefined ) {
-
- $field.children('.acf-input').children('.' + this.message_class).remove();
- $field.children('.acf-input').prepend('');
-
- }
-
-
- // add event
- var event = function(){
-
- // remove error
- self.remove_error( $field );
-
-
- // remove self
- $field.off('focus change', 'input, textarea, select', event);
-
- }
-
- $field.on('focus change', 'input, textarea, select', event);
-
-
- // event
- $field.trigger('invalidField');
-
-
- // hook for 3rd party customization
- acf.do_action('add_field_error', $field);
- acf.do_action('invalid_field', $field);
-
- },
-
-
- /*
- * remove_error
- *
- * This function will remove error markup from a field
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $field (jQuery)
- * @return n/a
- */
-
- remove_error: function( $field ){
-
- // var
- var $message = $field.children('.acf-input').children('.' + this.message_class);
-
-
- // remove class
- $field.removeClass(this.error_class);
-
-
- // remove message
- setTimeout(function(){
-
- acf.remove_el( $message );
-
- }, 250);
-
-
- // hook for 3rd party customization
- acf.do_action('remove_field_error', $field);
- acf.do_action('valid_field', $field);
-
- },
-
-
- /*
- * add_warning
- *
- * This functino will add and auto remove an error message to a field
- *
- * @type function
- * @date 4/05/2015
- * @since 5.2.3
- *
- * @param $field (jQuery)
- * @param message (string)
- * @return n/a
- */
-
- add_warning: function( $field, message ){
-
- this.add_error( $field, message );
-
- setTimeout(function(){
-
- acf.validation.remove_error( $field )
-
- }, 1000);
-
- },
-
-
- /*
- * show_spinner
- *
- * This function will show a spinner element. Logic changed in WP 4.2
- *
- * @type function
- * @date 3/05/2015
- * @since 5.2.3
- *
- * @param $spinner (jQuery)
- * @return n/a
- */
-
- show_spinner: function( $spinner ){
-
- // bail early if no spinner
- if( !$spinner.exists() ) {
-
- return;
-
- }
-
-
- // vars
- var wp_version = acf.get('wp_version');
-
-
- // show
- if( parseFloat(wp_version) >= 4.2 ) {
-
- $spinner.addClass('is-active');
-
- } else {
-
- $spinner.css('display', 'inline-block');
-
- }
-
- },
-
-
- /*
- * hide_spinner
- *
- * This function will hide a spinner element. Logic changed in WP 4.2
- *
- * @type function
- * @date 3/05/2015
- * @since 5.2.3
- *
- * @param $spinner (jQuery)
- * @return n/a
- */
-
- hide_spinner: function( $spinner ){
-
- // bail early if no spinner
- if( !$spinner.exists() ) {
-
- return;
-
- }
-
-
- // vars
- var wp_version = acf.get('wp_version');
-
-
- // hide
- if( parseFloat(wp_version) >= 4.2 ) {
-
- $spinner.removeClass('is-active');
-
- } else {
-
- $spinner.css('display', 'none');
-
- }
-
- },
-
-
- /*
- * disable_submit
- *
- * This function will disable the $trigger is possible
- *
- * @type function
- * @date 3/05/2015
- * @since 5.2.3
- *
- * @param $spinner (jQuery)
- * @return n/a
- */
-
- disable_submit: function( $submit ){
-
- // bail early if no submit
- if( !$submit.exists() ) {
-
- return;
-
- }
-
-
- // add class
- $submit.addClass('disabled button-disabled button-primary-disabled');
-
- },
-
-
- /*
- * enable_submit
- *
- * This function will enable the $trigger is possible
- *
- * @type function
- * @date 3/05/2015
- * @since 5.2.3
- *
- * @param $spinner (jQuery)
- * @return n/a
- */
-
- enable_submit: function( $submit ){
-
- // bail early if no submit
- if( !$submit.exists() ) {
-
- return;
-
- }
-
-
- // remove class
- $submit.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(){
-
- // get elements
- this.$el = this.$field.find('.wp-editor-wrap').last();
- this.$textarea = this.$el.find('textarea');
-
-
- // get options
- this.o = acf.get_data(this.$el, {
- toolbar: '',
- active: this.$el.hasClass('tmce-active'),
- id: this.$textarea.attr('id')
- });
-
- },
-
- mousedown: function(e){
-
- // prevent default
- e.preventDefault();
-
-
- // remove delay class
- this.$el.removeClass('delay');
- this.$el.find('.acf-editor-toolbar').remove();
-
-
- // initialize
- this.initialize();
-
- },
-
- initialize: function(){
-
- // bail early if delay
- if( this.$el.hasClass('delay') ) return;
-
-
- // vars
- var args = {
- tinymce: true,
- quicktags: true,
- toolbar: this.o.toolbar,
- mode: this.o.active ? 'visual' : 'text',
- };
-
-
- // generate new id
- var old_id = this.o.id,
- new_id = acf.get_uniqid('acf-editor-'),
- html = this.$el.outerHTML();
-
-
- // replace
- html = acf.str_replace( old_id, new_id, html );
-
-
- // swap
- this.$el.replaceWith( html );
-
-
- // update id
- this.o.id = new_id;
-
-
- // initialize
- acf.tinymce.initialize( this.o.id, args, this.$field );
-
- },
-
- disable: function(){
-
- acf.tinymce.destroy( this.o.id );
-
- },
-
- enable: function(){
-
- if( this.o.active ) {
- acf.tinymce.enable( this.o.id );
- }
-
- }
-
- });
-
-
- /*
- * acf.tinymce
- *
- * description
- *
- * @type function
- * @date 18/8/17
- * @since 5.6.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- acf.tinymce = acf.model.extend({
-
- toolbars: {},
-
- actions: {
- 'ready': 'ready'
- },
-
-
- /*
- * ready
- *
- * This function will move the acf-hidden-wp-editor and fix the activeEditor
- *
- * @type function
- * @date 18/8/17
- * @since 5.6.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- ready: function(){
-
- // vars
- var $div = $('#acf-hidden-wp-editor');
-
-
- // bail early if doesn't exist
- if( !$div.exists() ) return;
-
-
- // move to footer
- $div.appendTo('body');
-
-
- // bail early if no tinymce
- if( !acf.isset(window,'tinymce','on') ) return;
-
-
- // restore default activeEditor
- tinymce.on('AddEditor', function( data ){
-
- // vars
- var editor = data.editor;
-
-
- // bail early if not 'acf'
- if( editor.id.substr(0, 3) !== 'acf' ) return;
-
-
- // override if 'content' exists
- editor = tinymce.editors.content || editor;
-
-
- // update vars
- tinymce.activeEditor = editor;
- wpActiveEditor = editor.id;
-
- });
-
- },
-
+ acf.tinymce = {
/*
* defaults
@@ -14195,17 +11452,14 @@ var acf;
// bail early if no tinyMCEPreInit
if( typeof tinyMCEPreInit === 'undefined' ) return false;
-
// vars
var defaults = {
tinymce: tinyMCEPreInit.mceInit.acf_content,
quicktags: tinyMCEPreInit.qtInit.acf_content
};
-
// return
return defaults;
-
},
@@ -14222,38 +11476,31 @@ var acf;
* @return $post_id (int)
*/
- initialize: function( id, args, $field ){
+ initialize: function( id, args ){
// defaults
- args = args || {};
- $field = $field || null;
-
-
- // merge
- args = acf.parse_args(args, {
+ args = acf.parseArgs(args, {
tinymce: true,
quicktags: true,
toolbar: 'full',
mode: 'visual', // visual,text
+ field: false
});
-
// tinymce
if( args.tinymce ) {
- this.initialize_tinymce( id, args, $field );
+ this.initializeTinymce( id, args );
}
-
// quicktags
if( args.quicktags ) {
- this.initialize_quicktags( id, args, $field );
+ this.initializeQuicktags( id, args );
}
-
},
/*
- * initialize_tinymce
+ * initializeTinymce
*
* This function will initialize the tinymce instance
*
@@ -14265,31 +11512,29 @@ var acf;
* @return $post_id (int)
*/
- initialize_tinymce: function( id, args, $field ){
+ initializeTinymce: function( id, args ){
// vars
var $textarea = $('#'+id);
var defaults = this.defaults();
- var toolbars = this.toolbars;
-
+ var toolbars = acf.get('toolbars');
+ var field = args.field || false;
+ var $field = field.$el || false;
// bail early
if( typeof tinymce === 'undefined' ) return false;
if( !defaults ) return false;
-
// check if exists
if( tinymce.get(id) ) {
return this.enable( id );
}
-
// settings
- init = $.extend( {}, defaults.tinymce, args.tinymce );
+ var init = $.extend( {}, defaults.tinymce, args.tinymce );
init.id = id;
init.selector = '#' + id;
-
// toolbar
var toolbar = args.toolbar;
if( toolbar && typeof toolbars[toolbar] !== 'undefined' ) {
@@ -14297,17 +11542,11 @@ var acf;
for( var i = 1; i <= 4; i++ ) {
init[ 'toolbar' + i ] = toolbars[toolbar][i] || '';
}
-
}
-
// event
init.setup = function( ed ){
- ed.on('focus', function(e) {
- acf.validation.remove_error( $field );
- });
-
ed.on('change', function(e) {
ed.save(); // save to textarea
$textarea.trigger('change');
@@ -14319,46 +11558,44 @@ var acf;
};
-
// disable wp_autoresize_on (no solution yet for fixed toolbar)
init.wp_autoresize_on = false;
-
// hook for 3rd party customization
- init = acf.apply_filters('wysiwyg_tinymce_settings', init, id, $field);
-
+ init = acf.applyFilters('wysiwyg_tinymce_settings', init, id, field);
// z-index fix (caused too many conflicts)
//if( acf.isset(tinymce,'ui','FloatPanel') ) {
// tinymce.ui.FloatPanel.zIndex = 900000;
//}
-
// store settings
tinyMCEPreInit.mceInit[ id ] = init;
-
// visual tab is active
if( args.mode == 'visual' ) {
// init
- tinymce.init( init );
-
+ var result = tinymce.init( init );
// get editor
var ed = tinymce.get( id );
+ // validate
+ if( !ed ) {
+ return false;
+ }
+
+ // add reference
+ ed.acf = args.field;
// action
- acf.do_action('wysiwyg_tinymce_init', ed, ed.id, init, $field);
-
+ acf.doAction('wysiwyg_tinymce_init', ed, ed.id, init, field);
}
-
},
-
/*
- * initialize_quicktags
+ * initializeQuicktags
*
* This function will initialize the quicktags instance
*
@@ -14370,46 +11607,45 @@ var acf;
* @return $post_id (int)
*/
- initialize_quicktags: function( id, args, $field ){
+ initializeQuicktags: function( id, args ){
// vars
var defaults = this.defaults();
-
// bail early
if( typeof quicktags === 'undefined' ) return false;
if( !defaults ) return false;
-
// settings
- init = $.extend( {}, defaults.quicktags, args.quicktags );
+ var init = $.extend( {}, defaults.quicktags, args.quicktags );
init.id = id;
-
// filter
- init = acf.apply_filters('wysiwyg_quicktags_settings', init, init.id, $field);
-
+ var field = args.field || false;
+ var $field = field.$el || false;
+ init = acf.applyFilters('wysiwyg_quicktags_settings', init, init.id, field);
// store settings
tinyMCEPreInit.qtInit[ id ] = init;
-
// init
var ed = quicktags( init );
+ // validate
+ if( !ed ) {
+ return false;
+ }
// generate HTML
- this.build_quicktags( ed );
-
+ this.buildQuicktags( ed );
// action for 3rd party customization
- acf.do_action('wysiwyg_quicktags_init', ed, ed.id, init, $field);
-
+ acf.doAction('wysiwyg_quicktags_init', ed, ed.id, init, field);
},
/*
- * build_quicktags
+ * buildQuicktags
*
* This function will build the quicktags HTML
*
@@ -14421,7 +11657,7 @@ var acf;
* @return $post_id (int)
*/
- build_quicktags: function( ed ){
+ buildQuicktags: function( ed ){
var canvas, name, settings, theButtons, html, ed, id, i, use, instanceId,
defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,';
@@ -14478,100 +11714,1819 @@ var acf;
},
disable: function( id ){
-
- this.destroy( id );
-
+ this.destroyTinymce( id );
+ },
+
+ remove: function( id ){
+ this.destroyTinymce( id );
},
destroy: function( id ){
-
- this.destroy_tinymce( id );
-
+ this.destroyTinymce( id );
},
- destroy_tinymce: function( id ){
+ destroyTinymce: function( id ){
// bail early
if( typeof tinymce === 'undefined' ) return false;
-
// get editor
var ed = tinymce.get( id );
-
// bail early if no editor
if( !ed ) return false;
-
// save
ed.save();
-
// destroy editor
ed.destroy();
-
// return
return true;
-
},
enable: function( id ){
-
- this.enable_tinymce( id );
-
+ this.enableTinymce( id );
},
- enable_tinymce: function( id ){
+ enableTinymce: function( id ){
// bail early
if( typeof switchEditors === 'undefined' ) return false;
-
// bail ealry if not initialized
if( typeof tinyMCEPreInit.mceInit[ id ] === 'undefined' ) return false;
-
// toggle
switchEditors.go( id, 'tmce');
-
// return
return true;
-
+ }
+ };
+
+ var editorManager = new acf.Model({
+
+ // hook in before fieldsEventManager, conditions, etc
+ priority: 5,
+
+ actions: {
+ 'prepare': 'onPrepare',
+ 'ready': 'onReady',
},
+ onPrepare: function(){
+
+ // find hidden editor which may exist within a field
+ var $div = $('#acf-hidden-wp-editor');
+
+ // move to footer
+ if( $div.exists() ) {
+ $div.appendTo('body');
+ }
+ },
+ onReady: function(){
+
+ // bail early if no tinymce
+ if( !acf.isset(window,'tinymce','on') ) return;
+
+ // restore default activeEditor
+ tinymce.on('AddEditor', function( data ){
+
+ // vars
+ var editor = data.editor;
+
+ // bail early if not 'acf'
+ if( editor.id.substr(0, 3) !== 'acf' ) return;
+
+ // override if 'content' exists
+ editor = tinymce.editors.content || editor;
+
+ // update vars
+ tinymce.activeEditor = editor;
+ wpActiveEditor = editor.id;
+ });
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * acf.validation
+ *
+ * Global validation logic
+ *
+ * @date 4/4/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return void
+ */
+
+ acf.validation = new acf.Model({
+
+ // enable / disable validation logic
+ active: true,
+
+ // temp ignore flag allowing bypass of validation
+ ignore: false,
+
+ // errors
+ errors: [],
+
+ // active form
+ form: false,
+
+ // wait
+ wait: 'prepare',
+
+ actions: {
+ 'ready': 'addInputEvents',
+ 'append': 'addInputEvents'
+ },
+
+ events: {
+ 'click #publish': 'onClickPublish',
+ 'click #submit': 'onClickPublish',
+ 'click #save-post': 'onClickSave',
+ 'submit form': 'onSubmit',
+ },
+
+ initialize: function(){
+
+ // load global setting
+ if( !acf.get('validation') ) {
+ this.disable();
+ this.actions = {};
+ this.events = {};
+ }
+ },
+
+ getForm: function( $form ){
+
+ // instantiate
+ var form = $form.data('acf');
+ if( !form ) {
+ form = new Form( $form );
+ }
+
+ // store
+ this.form = form;
+
+ // return
+ return form;
+ },
+
+ enable: function(){
+ this.active = true;
+ },
+
+ disable: function(){
+ this.active = false;
+ },
+
+ pass: function(){
+ this.ignore = true;
+ this.setTimeout(function(){
+ this.ignore = false;
+ }, 100);
+ },
+
+ reset: function(){
+ this.ignore = false;
+ this.errors = [];
+ this.form = false;
+ },
+
+ getErrors: function(){
+ return this.errors;
+ },
+
+ hasErrors: function(){
+ return this.errors.length;
+ },
+
+ addErrors: function( errors ){
+ errors.map( this.addError, this );
+ },
+
+ addError: function( error ){
+ this.errors.push( error );
+ },
+
+ getFieldErrors: function(){
+
+ // vars
+ var errors = [];
+ var inputs = [];
+
+ // loop
+ this.getErrors().map(function(error){
+
+ // bail early if global
+ if( !error.input ) return;
+
+ // update if exists
+ var i = inputs.indexOf(error.input);
+ if( i > -1 ) {
+ errors[ i ] = error;
+
+ // update
+ } else {
+ errors.push( error );
+ inputs.push( error.input );
+ }
+ });
+
+ // return
+ return errors;
+ },
+
+ getGlobalErrors: function(){
+
+ // return array of errors that contain no input
+ return this.getErrors().filter(function(error){
+ return !error.input;
+ });
+ },
+
+ showErrors: function( $form ){
+
+ // bail early if no errors
+ if( !this.hasErrors() ) {
+ return;
+ }
+
+ // vars
+ var form = this.getForm( $form );
+ var fieldErrors = this.getFieldErrors();
+ var globalErrors = this.getGlobalErrors();
+
+ // vars
+ var errorCount = 0;
+ var $scrollTo = false;
+
+ // loop
+ fieldErrors.map(function( error ){
+
+ // get input
+ var $input = $form.find('[name="' + error.input + '"]').first();
+
+ // if $_POST value was an array, this $input may not exist
+ if( !$input.exists() ) {
+ $input = $form.find('[name^="' + error.input + '"]').first();
+ }
+
+ // bail early if input doesn't exist
+ if( !$input.exists() ) {
+ return;
+ }
+
+ // increase
+ errorCount++;
+
+ // get field
+ var field = acf.getClosestField( $input );
+
+ // show error
+ field.showError( error.message );
+
+ // set $scrollTo
+ if( !$scrollTo ) {
+ $scrollTo = field.$el;
+ }
+ }, this);
+
+ // errorMessage
+ var errorMessage = acf.__('Validation failed');
+ if( errorCount == 1 ) {
+ errorMessage += '. ' + acf.__('1 field requires attention');
+ } else if( errorCount > 1 ) {
+ errorMessage += '. ' + acf.__('%d fields require attention').replace('%d', errorCount);
+ }
+
+ // notice
+ if( form.notice ) {
+ form.notice.update({
+ type: 'error',
+ text: errorMessage
+ });
+ } else {
+ form.notice = acf.newNotice({
+ type: 'error',
+ text: errorMessage,
+ target: $form
+ });
+ }
+
+ // if no $scrollTo, set to message
+ if( !$scrollTo ) {
+ $scrollTo = form.notice.$el;
+ }
+
+ // timeout
+ setTimeout(function(){
+ $("html, body").animate({ scrollTop: $scrollTo.offset().top - ( $(window).height() / 2 ) }, 500);
+ }, 10);
+ },
+
+ fetch: function( args ){
+
+ // bail early if busy
+ if( this.busy ) {
+ return;
+ }
+
+ // set busy
+ this.busy = 1;
+
+ // vars
+ args = acf.parseArgs(args, {
+
+ // form element
+ form: false,
+
+ // trigger event
+ event: false,
+
+ // lock form on success
+ lock: true,
+
+ // loading callback
+ loading: function(){},
+
+ // complete callback
+ complete: function(){},
+
+ // failure callback
+ failure: function(){},
+
+ // success callback
+ success: function( $form ){
+ $form.submit();
+ }
+ });
+
+ // vars
+ var $form = args.form;
+ var form = this.getForm( $form );
+
+ // create event specific success callback
+ if( args.event ) {
+ var event = $.Event(null, args.event);
+ args.success = function(){
+ $(event.target).trigger( event );
+ }
+ }
+
+ // action for 3rd party
+ acf.doAction('validation_begin', $form);
+
+ // data
+ var data = acf.serialize( $form );
+ data.action = 'acf/validate_save_post';
+
+ // lock form
+ this.lockForm( $form );
+
+ // loading callback
+ args.loading( $form );
+
+ // success
+ var onSuccess = function( json ){
+
+ // validate
+ if( !acf.isAjaxSuccess(json) ) {
+ return;
+ }
+
+ // filter
+ data = acf.applyFilters('validation_complete', json.data, $form);
+
+ // add errors
+ if( !data.valid ) {
+ this.addErrors( data.errors );
+ }
+ };
+
+ // complete
+ var onComplete = function(){
+
+ // set busy
+ this.busy = 0;
+
+ // unlock form
+ this.unlockForm( $form );
+
+ // failure
+ if( this.hasErrors() ) {
+
+ // action
+ acf.doAction('validation_failure', $form);
+
+ // display errors
+ this.showErrors( $form );
+
+ // failure callback
+ args.failure( $form );
+
+ // success
+ } else {
+
+ // allow for to pass
+ this.pass();
+
+ // remove previous error message
+ if( form.notice ) {
+ form.notice.update({
+ type: 'success',
+ text: acf.__('Validation successful'),
+ timeout: 1000
+ });
+ }
+
+ // action
+ acf.doAction('validation_success', $form);
+ acf.doAction('submit', $form);
+
+ // success callback (submit form)
+ args.success( $form );
+
+ // lock form
+ if( args.lock ) {
+ this.lockForm( $form );
+ }
+ }
+
+ // reset
+ this.reset();
+
+ // complete callback
+ args.complete( $form );
+ };
+
+ // ajax
+ $.ajax({
+ url: acf.get('ajaxurl'),
+ data: acf.prepareForAjax(data),
+ type: 'post',
+ dataType: 'json',
+ context: this,
+ success: onSuccess,
+ complete: onComplete
+ });
+ },
+
+ addInputEvents: function( $el ){
+
+ // vars
+ var $inputs = $('.acf-field [name]');
+
+ // check
+ if( $inputs.length ) {
+ this.on( $inputs, 'invalid', 'onInvalid' );
+ }
+ },
+
+ onInvalid: function( e, $el ){
+
+ // vars
+ var $form = $el.closest('form');
+
+ // add error
+ this.addError({
+ input: $el.attr('name'),
+ message: e.target.validationMessage
+ });
+
+ // prevent default
+ // - prevents browser error message
+ // - also fixes chrome bug where 'hidden-by-tab' field throws focus error
+ e.preventDefault();
+
+ // trigger submit on $form
+ // - allows for "save", "preview" and "publish" to work
+ $form.submit();
+ },
+
+ // fixes bug on User Profile edit form
+ // - WP prevents $form.submit() events for unknown reason
+ // - temp store 'click event' and use later in onSubmit
+ onClickPublish: function( e, $el ){
+ this.set('originalEvent', e);
+ this.setTimeout(function(){
+ this.set('originalEvent', null);
+ }, 100);
+ },
+
+ onClickSave: function( e, $el ) {
+
+ // ignore errors
+ this.pass();
+ },
+
+ onSubmit: function( e, $form ){
+
+ // validate
+ var valid = acf.validateForm({
+ form: $form,
+ event: this.get('originalEvent') || e
+ });
+
+ // if not valid, stop event and allow validation to continue
+ if( !valid ) {
+ e.preventDefault();
+ }
+ },
+
+ showSpinner: function( $spinner ){
+ $spinner.addClass('is-active'); // add class (WP > 4.2)
+ $spinner.css('display', 'inline-block'); // css (WP < 4.2)
+ },
+
+ hideSpinner: function( $spinner ){
+ $spinner.removeClass('is-active'); // add class (WP > 4.2)
+ $spinner.css('display', 'none'); // css (WP < 4.2)
+ },
+
+ disableSubmit: function( $submit ){
+ $submit.prop('disabled', true).addClass('disabled');
+ },
+
+ enableSubmit: function( $submit ){
+ $submit.prop('disabled', false).removeClass('disabled');
+ },
+
+ findSubmitWrap: function( $form ){
+
+ // default post submit div
+ var $wrap = $('#submitdiv');
+ if( $wrap.length ) {
+ return $wrap;
+ }
+
+ // 3rd party publish box
+ var $wrap = $('#submitpost');
+ if( $wrap.length ) {
+ return $wrap;
+ }
+
+ // term, user
+ var $wrap = $form.find('p.submit').last();
+ if( $wrap.length ) {
+ return $wrap;
+ }
+
+ // front end form
+ var $wrap = $form.find('.acf-form-submit');
+ if( $wrap.length ) {
+ return $wrap;
+ }
+
+ // default
+ return $form;
+ },
+
+ lockForm: function( $form ){
+
+ // vars
+ var $wrap = this.findSubmitWrap( $form );
+ var $submit = $wrap.find('.button, .acf-button');
+ var $spinner = $wrap.find('.spinner, .acf-spinner');
+
+ // hide all spinners (hides the preview spinner)
+ this.hideSpinner( $spinner );
+
+ // lock
+ this.disableSubmit( $submit );
+ this.showSpinner( $spinner.last() );
+ },
+
+ unlockForm: function( $form ){
+
+ // vars
+ var $wrap = this.findSubmitWrap( $form );
+ var $submit = $wrap.find('.button, .acf-button');
+ var $spinner = $wrap.find('.spinner, .acf-spinner');
+
+ // unlock
+ this.enableSubmit( $submit );
+ this.hideSpinner( $spinner );
+ }
});
-
+ /**
+ * Form
+ *
+ * description
+ *
+ * @date 5/4/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var Form = acf.Model.extend({
+ notice: false,
+ setup: function( $form ){
+ this.$el = $form;
+ },
+ lock: function(){
+ acf.validation.lockForm( this.$el );
+ },
+ unlock: function(){
+ acf.validation.unlockForm( this.$el );
+ }
+ });
+
+ /**
+ * acf.validateForm
+ *
+ * description
+ *
+ * @date 4/4/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.validateForm = function( args ){
+
+ // bail early if no form
+ // - return true allowing form submit
+ if( !args.form ) {
+ return true;
+ }
+
+ // get form
+ var form = acf.validation.getForm( args.form );
+
+ // bail early if not active
+ // - return true allowing form submit
+ if( !acf.validation.active ) {
+ return true;
+ }
+
+ // bail early if ignore
+ // - return true allowing form submit
+ if( acf.validation.ignore ) {
+ return true;
+ }
+
+ // bail early if is preview
+ // - return true allowing form submit
+ if( form.$('#wp-preview').val() ) {
+ form.unlock();
+ return true;
+ }
+
+ // bail early if this form does not contain ACF data
+ // - return true allowing form submit
+ if( !form.$('#acf-form-data').length ) {
+ return true;
+ }
+
+ // validate
+ acf.validation.fetch( args );
+
+ // return false preventing form submit
+ return false;
+ };
+
})(jQuery);
-// @codekit-prepend "../js/event-manager.js";
-// @codekit-prepend "../js/acf.js";
-// @codekit-prepend "../js/acf-ajax.js";
-// @codekit-prepend "../js/acf-button-group.js";
-// @codekit-prepend "../js/acf-checkbox.js";
-// @codekit-prepend "../js/acf-color-picker.js";
-// @codekit-prepend "../js/acf-conditional-logic.js";
-// @codekit-prepend "../js/acf-date-picker.js";
-// @codekit-prepend "../js/acf-date-time-picker.js";
-// @codekit-prepend "../js/acf-file.js";
-// @codekit-prepend "../js/acf-google-map.js";
-// @codekit-prepend "../js/acf-image.js";
-// @codekit-prepend "../js/acf-link.js";
-// @codekit-prepend "../js/acf-media.js";
-// @codekit-prepend "../js/acf-oembed.js";
-// @codekit-prepend "../js/acf-radio.js";
-// @codekit-prepend "../js/acf-range.js";
-// @codekit-prepend "../js/acf-relationship.js";
-// @codekit-prepend "../js/acf-select2.js";
-// @codekit-prepend "../js/acf-select.js";
-// @codekit-prepend "../js/acf-accordion.js";
-// @codekit-prepend "../js/acf-tab.js";
-// @codekit-prepend "../js/acf-time-picker.js";
-// @codekit-prepend "../js/acf-true-false.js";
-// @codekit-prepend "../js/acf-taxonomy.js";
-// @codekit-prepend "../js/acf-url.js";
-// @codekit-prepend "../js/acf-validation.js";
-// @codekit-prepend "../js/acf-wysiwyg.js";
+(function($, undefined){
+
+ /**
+ * refreshHelper
+ *
+ * description
+ *
+ * @date 1/7/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var refreshHelper = 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);
+ }
+ });
+
+
+ /**
+ * sortableHelper
+ *
+ * Adds compatibility for sorting a element
+ *
+ * @date 6/3/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return void
+ */
+
+ var sortableHelper = new acf.Model({
+ actions: {
+ 'sortstart': 'onSortstart'
+ },
+ onSortstart: function( $item, $placeholder ){
+
+ // if $item is a tr, apply some css to the elements
+ if( $item.is('tr') ) {
+
+ // temp set as relative to find widths
+ $item.css('position', 'relative');
+
+ // set widths for td children
+ $item.children().each(function(){
+ $(this).width($(this).width());
+ });
+
+ // revert position css
+ $item.css('position', 'absolute');
+
+ // add markup to the placeholder
+ $placeholder.html(' ');
+ }
+ }
+ });
+
+ /**
+ * duplicateHelper
+ *
+ * Fixes browser bugs when duplicating an element
+ *
+ * @date 6/3/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return void
+ */
+
+ var duplicateHelper = new acf.Model({
+ actions: {
+ 'after_duplicate': 'onAfterDuplicate'
+ },
+ onAfterDuplicate: function( $el, $el2 ){
+
+ // get original values
+ var vals = [];
+ $el.find('select').each(function(i){
+ vals.push( $(this).val() );
+ });
+
+ // set duplicate values
+ $el2.find('select').each(function(i){
+ $(this).val( vals[i] );
+ });
+ }
+ });
+
+ /**
+ * tableHelper
+ *
+ * description
+ *
+ * @date 6/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var tableHelper = new acf.Model({
+
+ id: 'tableHelper',
+
+ priority: 20,
+
+ actions: {
+ 'refresh': 'renderTables'
+ },
+
+ renderTables: function( $el ){
+
+ // loop
+ var self = this;
+ $('.acf-table:visible').each(function(){
+ self.renderTable( $(this) );
+ });
+ },
+
+ renderTable: function( $table ){
+
+ // vars
+ var $ths = $table.find('> thead > tr:visible > th[data-key]');
+ var $tds = $table.find('> tbody > tr:visible > td[data-key]');
+
+ // bail early if no thead
+ if( !$ths.length || !$tds.length ) {
+ return false;
+ }
+
+
+ // visiblity
+ $ths.each(function( i ){
+
+ // vars
+ var $th = $(this);
+ var key = $th.data('key');
+ var $cells = $tds.filter('[data-key="' + key + '"]');
+ var $hidden = $cells.filter('.acf-hidden');
+
+ // always remove empty and allow cells to be hidden
+ $cells.removeClass('acf-empty');
+
+ // hide $th if all cells are hidden
+ if( $cells.length === $hidden.length ) {
+ acf.hide( $th );
+
+ // force all hidden cells to appear empty
+ } else {
+ acf.show( $th );
+ $hidden.addClass('acf-empty');
+ }
+ });
+
+
+ // clear width
+ $ths.css('width', 'auto');
+
+ // get visible
+ $ths = $ths.not('.acf-hidden');
+
+ // vars
+ var availableWidth = 100;
+ var colspan = $ths.length;
+
+ // set custom widths first
+ var $fixedWidths = $ths.filter('[data-width]');
+ $fixedWidths.each(function(){
+ var width = $(this).data('width');
+ $(this).css('width', width + '%');
+ availableWidth -= width;
+ });
+
+ // set auto widths
+ var $auoWidths = $ths.not('[data-width]');
+ if( $auoWidths.length ) {
+ var width = availableWidth / $auoWidths.length;
+ $auoWidths.css('width', width + '%');
+ availableWidth = 0;
+ }
+
+ // avoid stretching issue
+ if( availableWidth > 0 ) {
+ $ths.last().css('width', 'auto');
+ }
+
+
+ // update colspan on collapsed
+ $tds.filter('.-collapsed-target').each(function(){
+
+ // vars
+ var $td = $(this);
+
+ // check if collapsed
+ if( $td.parent().hasClass('-collapsed') ) {
+ $td.attr('colspan', $ths.length);
+ } else {
+ $td.removeAttr('colspan');
+ }
+ });
+ }
+ });
+
+
+ /**
+ * fieldsHelper
+ *
+ * description
+ *
+ * @date 6/3/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var fieldsHelper = new acf.Model({
+
+ id: 'fieldsHelper',
+
+ priority: 30,
+
+ actions: {
+ 'refresh': 'renderGroups'
+ },
+
+ renderGroups: function(){
+
+ // loop
+ var self = this;
+ $('.acf-fields:visible').each(function(){
+ self.renderGroup( $(this) );
+ });
+ },
+
+ renderGroup: function( $el ){
+
+ // vars
+ var top = 0;
+ var height = 0;
+ var $row = $();
+
+ // get fields
+ var $fields = $el.children('.acf-field[data-width]:visible');
+
+ // bail early if no fields
+ if( !$fields.length ) {
+ return false;
+ }
+
+ // bail ealry if is .-left
+ if( $el.hasClass('-left') ) {
+ $fields.removeAttr('data-width');
+ $fields.css('width', 'auto');
+ return false;
+ }
+
+ // reset fields
+ $fields.removeClass('-r0 -c0').css({'min-height': 0});
+
+ // loop
+ $fields.each(function( i ){
+
+ // vars
+ var $field = $(this);
+ var position = $field.position();
+ var thisTop = Math.ceil( position.top );
+ var thisLeft = Math.ceil( position.left );
+
+ // detect change in row
+ if( $row.length && thisTop > top ) {
+
+ // set previous heights
+ $row.css({'min-height': height+'px'});
+
+ // update position due to change in row above
+ position = $field.position();
+ thisTop = Math.ceil( position.top );
+ thisLeft = Math.ceil( position.left );
+
+ // reset vars
+ top = 0;
+ height = 0;
+ $row = $();
+ }
+
+ // add classes
+ if( thisTop == 0 ) {
+ $field.addClass('-r0');
+ } else if( thisLeft == 0 ) {
+ $field.addClass('-c0');
+ }
+
+ // get height after class change
+ // - add 1 for subpixel rendering
+ var thisHeight = Math.ceil( $field.outerHeight() ) + 1;
+
+ // set height
+ height = Math.max( height, thisHeight );
+
+ // set y
+ top = Math.max( top, thisTop );
+
+ // append
+ $row = $row.add( $field );
+ });
+
+ // clean up
+ if( $row.length ) {
+ $row.css({'min-height': height+'px'});
+ }
+ }
+ });
+
+})(jQuery);
+
+(function($, undefined){
+
+ /**
+ * acf.newCompatibility
+ *
+ * Inserts a new __proto__ object compatibility layer
+ *
+ * @date 15/2/18
+ * @since 5.6.9
+ *
+ * @param object instance The object to modify.
+ * @param object compatibilty Optional. The compatibilty layer.
+ * @return object compatibilty
+ */
+
+ acf.newCompatibility = function( instance, compatibilty ){
+
+ // defaults
+ compatibilty = compatibilty || {};
+
+ // inherit __proto_-
+ compatibilty.__proto__ = instance.__proto__;
+
+ // inject
+ instance.__proto__ = compatibilty;
+
+ // reference
+ instance.compatibility = compatibilty;
+
+ // return
+ return compatibilty;
+ };
+
+ /**
+ * acf.getCompatibility
+ *
+ * Returns the compatibility layer for a given instance
+ *
+ * @date 13/3/18
+ * @since 5.6.9
+ *
+ * @param object instance The object to look in.
+ * @return object|null compatibility The compatibility object or null on failure.
+ */
+
+ acf.getCompatibility = function( instance ) {
+ return instance.compatibility || null;
+ };
+
+ /**
+ * acf (compatibility)
+ *
+ * Compatibility layer for the acf object
+ *
+ * @date 15/2/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return void
+ */
+
+ var _acf = acf.newCompatibility(acf, {
+
+ // storage
+ l10n: {},
+ o: {},
+ fields: {},
+
+ // changed function names
+ 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,
+
+ });
+
+ _acf._e = function( k1, k2 ){
+
+ // defaults
+ k1 = k1 || '';
+ k2 = k2 || '';
+
+ // compability
+ var compatKey = k2 ? k1 + '.' + k2 : k1;
+ var compats = {
+ 'image.select': 'Select Image',
+ 'image.edit': 'Edit Image',
+ 'image.update': 'Update Image'
+ };
+ if( compats[compatKey] ) {
+ return acf.__(compats[compatKey]);
+ }
+
+ // try k1
+ var string = this.l10n[ k1 ] || '';
+
+ // try k2
+ if( k2 ) {
+ string = string[ k2 ] || '';
+ }
+
+ // return
+ return string;
+ };
+
+ _acf.get_selector = function( s ) {
+
+ // vars
+ var selector = '.acf-field';
+
+ // bail early if no search
+ if( !s ) {
+ return selector;
+ }
+
+ // compatibility with object
+ if( $.isPlainObject(s) ) {
+ if( $.isEmptyObject(s) ) {
+ return selector;
+ } else {
+ for( var k in s ) { s = s[k]; break; }
+ }
+ }
+
+ // append
+ selector += '-' + s;
+
+ // replace underscores (split/join replaces all and is faster than regex!)
+ selector = acf.strReplace('_', '-', selector);
+
+ // remove potential double up
+ selector = acf.strReplace('field-field-', 'field-', selector);
+
+ // return
+ return selector;
+ };
+
+ _acf.get_fields = function( s, $el, all ){
+
+ // args
+ var args = {
+ is: s || '',
+ parent: $el || false,
+ suppressFilters: all || false,
+ };
+
+ // change 'field_123' to '.acf-field-123'
+ if( args.is ) {
+ args.is = this.get_selector( args.is );
+ }
+
+ // return
+ return acf.findFields(args);
+ };
+
+ _acf.get_field = function( s, $el ){
+
+ // get fields
+ var $fields = this.get_fields.apply(this, arguments);
+
+ // return
+ if( $fields.length ) {
+ return $fields.first();
+ } else {
+ return false;
+ }
+ };
+
+ _acf.get_closest_field = function( $el, s ){
+ return $el.closest( this.get_selector(s) );
+ };
+
+ _acf.get_field_wrap = function( $el ){
+ return $el.closest( this.get_selector() );
+ };
+
+ _acf.get_field_key = function( $field ){
+ return $field.data('key');
+ };
+
+ _acf.get_field_type = function( $field ){
+ return $field.data('type');
+ };
+
+ _acf.get_data = function( $el, defaults ){
+ return acf.parseArgs( $el.data(), defaults );
+ };
+
+ _acf.maybe_get = function( obj, key, value ){
+
+ // default
+ if( value === undefined ) {
+ value = null;
+ }
+
+ // get keys
+ keys = String(key).split('.');
+
+ // acf.isget
+ for( var i = 0; i < keys.length; i++ ) {
+ if( !obj.hasOwnProperty(keys[i]) ) {
+ return value;
+ }
+ obj = obj[ keys[i] ];
+ }
+ return obj;
+ };
+
+
+ /**
+ * hooks
+ *
+ * Modify add_action and add_filter functions to add compatibility with changed $field parameter
+ * Using the acf.add_action() or acf.add_filter() functions will interpret new field parameters as jQuery $field
+ *
+ * @date 12/5/18
+ * @since 5.6.9
+ *
+ * @param void
+ * @return void
+ */
+
+ var compatibleArgument = function( arg ){
+ return ( arg instanceof acf.Field ) ? arg.$el : arg;
+ };
+
+ var compatibleArguments = function( args ){
+ return acf.arrayArgs( args ).map( compatibleArgument );
+ }
+
+ var compatibleCallback = function( origCallback ){
+ return function(){
+
+ // convert to compatible arguments
+ if( arguments.length ) {
+ var args = compatibleArguments(arguments);
+
+ // add default argument for 'ready', 'append' and 'load' events
+ } else {
+ var args = [ $(document) ];
+ }
+
+ // return
+ return origCallback.apply(this, args);
+ }
+ }
+
+ _acf.add_action = function( action, callback, priority, context ){
+
+ // handle multiple actions
+ var actions = action.split(' ');
+ var length = actions.length;
+ if( length > 1 ) {
+ for( var i = 0; i < length; i++) {
+ action = actions[i];
+ _acf.add_action.apply(this, arguments);
+ }
+ return this;
+ }
+
+ // single
+ var callback = compatibleCallback(callback);
+ return acf.addAction.apply(this, arguments);
+ };
+
+ _acf.add_filter = function( action, callback, priority, context ){
+ var callback = compatibleCallback(callback);
+ return acf.addFilter.apply(this, arguments);
+ };
+
+ /*
+ * acf.model
+ *
+ * This model acts as a scafold for action.event driven modules
+ *
+ * @type object
+ * @date 8/09/2014
+ * @since 5.0.0
+ *
+ * @param (object)
+ * @return (object)
+ */
+
+ _acf.model = {
+ actions: {},
+ filters: {},
+ events: {},
+ extend: function( args ){
+
+ // extend
+ var model = $.extend( {}, this, args );
+
+ // setup actions
+ $.each(model.actions, function( name, callback ){
+ model._add_action( name, callback );
+ });
+
+ // setup filters
+ $.each(model.filters, function( name, callback ){
+ model._add_filter( name, callback );
+ });
+
+ // setup events
+ $.each(model.events, function( name, callback ){
+ model._add_event( name, callback );
+ });
+
+ // return
+ return model;
+ },
+
+ _add_action: function( name, callback ) {
+
+ // split
+ var model = this,
+ data = name.split(' ');
+
+ // add missing priority
+ var name = data[0] || '',
+ priority = data[1] || 10;
+
+ // add action
+ acf.add_action(name, model[ callback ], priority, model);
+
+ },
+
+ _add_filter: function( name, callback ) {
+
+ // split
+ var model = this,
+ data = name.split(' ');
+
+ // add missing priority
+ var name = data[0] || '',
+ priority = data[1] || 10;
+
+ // add action
+ acf.add_filter(name, model[ callback ], priority, model);
+ },
+
+ _add_event: function( name, callback ) {
+
+ // vars
+ var model = this,
+ i = name.indexOf(' '),
+ event = (i > 0) ? name.substr(0,i) : name,
+ selector = (i > 0) ? name.substr(i+1) : '';
+
+ // event
+ var fn = function( e ){
+
+ // append $el to event object
+ e.$el = $(this);
+
+ // append $field to event object (used in field group)
+ if( acf.field_group ) {
+ e.$field = e.$el.closest('.acf-field-object');
+ }
+
+ // event
+ if( typeof model.event === 'function' ) {
+ e = model.event( e );
+ }
+
+ // callback
+ model[ callback ].apply(model, arguments);
+
+ };
+
+ // add event
+ if( selector ) {
+ $(document).on(event, selector, fn);
+ } else {
+ $(document).on(event, fn);
+ }
+ },
+
+ get: function( name, value ){
+
+ // defaults
+ value = value || null;
+
+ // get
+ if( typeof this[ name ] !== 'undefined' ) {
+ value = this[ name ];
+ }
+
+ // return
+ return value;
+ },
+
+ set: function( name, value ){
+
+ // set
+ this[ name ] = value;
+
+ // function for 3rd party
+ if( typeof this[ '_set_' + name ] === 'function' ) {
+ this[ '_set_' + name ].apply(this);
+ }
+
+ // return for chaining
+ return this;
+ }
+ };
+
+ /*
+ * field
+ *
+ * This model sets up many of the field's interactions
+ *
+ * @type function
+ * @date 21/02/2014
+ * @since 3.5.1
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ _acf.field = acf.model.extend({
+ type: '',
+ o: {},
+ $field: null,
+ _add_action: function( name, callback ) {
+
+ // vars
+ var model = this;
+
+ // update name
+ name = name + '_field/type=' + model.type;
+
+ // add action
+ acf.add_action(name, function( $field ){
+
+ // focus
+ model.set('$field', $field);
+
+ // callback
+ model[ callback ].apply(model, arguments);
+ });
+ },
+
+ _add_filter: function( name, callback ) {
+
+ // vars
+ var model = this;
+
+ // update name
+ name = name + '_field/type=' + model.type;
+
+ // add action
+ acf.add_filter(name, function( $field ){
+
+ // focus
+ model.set('$field', $field);
+
+ // callback
+ model[ callback ].apply(model, arguments);
+ });
+ },
+
+ _add_event: function( name, callback ) {
+
+ // vars
+ var model = this,
+ event = name.substr(0,name.indexOf(' ')),
+ selector = name.substr(name.indexOf(' ')+1),
+ context = acf.get_selector(model.type);
+
+ // add event
+ $(document).on(event, context + ' ' + selector, function( e ){
+
+ // vars
+ var $el = $(this);
+ var $field = acf.get_closest_field( $el, model.type );
+
+ // bail early if no field
+ if( !$field.length ) return;
+
+ // focus
+ if( !$field.is(model.$field) ) {
+ model.set('$field', $field);
+ }
+
+ // append to event
+ e.$el = $el;
+ e.$field = $field;
+
+ // callback
+ model[ callback ].apply(model, [e]);
+ });
+ },
+
+ _set_$field: function(){
+
+ // callback
+ if( typeof this.focus === 'function' ) {
+ this.focus();
+ }
+ },
+
+ // depreciated
+ doFocus: function( $field ){
+ return this.set('$field', $field);
+ }
+ });
+
+
+ /**
+ * validation
+ *
+ * description
+ *
+ * @date 15/2/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ var _validation = acf.newCompatibility(acf.validation, {
+ remove_error: function( $field ){
+ acf.getField( $field ).removeError();
+ },
+ add_warning: function( $field, message ){
+ acf.getField( $field ).showNotice({
+ text: message,
+ type: 'warning',
+ timeout: 1000
+ });
+ }
+ });
+
+
+ /**
+ * tooltip
+ *
+ * description
+ *
+ * @date 15/2/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ _acf.tooltip = {
+
+ tooltip: function( text, $el ){
+
+ var tooltip = acf.newTooltip({
+ text: text,
+ target: $el
+ });
+
+ // return
+ return tooltip.$el;
+ },
+
+ temp: function( text, $el ){
+
+ var tooltip = acf.newTooltip({
+ text: text,
+ target: $el,
+ timeout: 250
+ });
+ },
+
+ confirm: function( $el, callback, text, button_y, button_n ){
+
+ var tooltip = acf.newTooltip({
+ confirm: true,
+ text: text,
+ target: $el,
+ confirm: function(){
+ callback(true);
+ },
+ cancel: function(){
+ callback(false);
+ }
+ });
+ },
+
+ confirm_remove: function( $el, callback ){
+
+ var tooltip = acf.newTooltip({
+ confirmRemove: true,
+ target: $el,
+ confirm: function(){
+ callback(true);
+ },
+ cancel: function(){
+ callback(false);
+ }
+ });
+ },
+ };
+
+ /**
+ * tooltip
+ *
+ * description
+ *
+ * @date 15/2/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ _acf.media = new acf.Model({
+ activeFrame: false,
+ actions: {
+ 'new_media_popup': 'onNewMediaPopup'
+ },
+
+ frame: function(){
+ return this.activeFrame;
+ },
+
+ onNewMediaPopup: function( popup ){
+ this.activeFrame = popup.frame;
+ },
+
+ popup: function( props ){
+
+ // update props
+ if( props.mime_types ) {
+ props.allowedTypes = props.mime_types;
+ }
+ if( props.id ) {
+ props.attachment = props.id;
+ }
+
+ // new
+ var popup = acf.newMediaPopup( props );
+
+ // append
+/*
+ if( props.selected ) {
+ popup.selected = props.selected;
+ }
+*/
+
+ // return
+ return popup.frame;
+ }
+ });
+
+
+ /**
+ * Select2
+ *
+ * description
+ *
+ * @date 11/6/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ _acf.select2 = {
+ init: function( $select, args, $field ){
+
+ // compatible args
+ if( args.allow_null ) {
+ args.allowNull = args.allow_null;
+ }
+ if( args.ajax_action ) {
+ args.ajaxAction = args.ajax_action;
+ }
+ if( $field ) {
+ args.field = acf.getField($field);
+ }
+
+ // return
+ return acf.newSelect2( $select, args );
+ },
+
+ destroy: function( $select ){
+ return acf.getInstance( $select ).destroy();
+
+ },
+ };
+
+ /**
+ * postbox
+ *
+ * description
+ *
+ * @date 11/6/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ _acf.postbox = {
+ render: function( args ){
+
+ // compatible args
+ if( args.edit_url ) {
+ args.editLink = args.edit_url;
+ }
+ if( args.edit_title ) {
+ args.editTitle = args.edit_title;
+ }
+
+ // return
+ return acf.newPostbox( args );
+ }
+ };
+
+ /**
+ * acf.screen
+ *
+ * description
+ *
+ * @date 11/6/18
+ * @since 5.6.9
+ *
+ * @param type $var Description. Default.
+ * @return type Description.
+ */
+
+ acf.newCompatibility(acf.screen, {
+ update: function(){
+ return this.set.apply(this, arguments);
+ }
+ });
+ _acf.ajax = acf.screen;
+
+})(jQuery);
+
+// @codekit-prepend "../js/acf.js";
+// @codekit-prepend "../js/acf-hooks.js";
+// @codekit-prepend "../js/acf-model.js";
+// @codekit-prepend "../js/acf-popup.js";
+// @codekit-prepend "../js/acf-unload.js";
+// @codekit-prepend "../js/acf-panel.js";
+// @codekit-prepend "../js/acf-notice.js";
+// @codekit-prepend "../js/acf-postbox.js";
+// @codekit-prepend "../js/acf-tooltip.js";
+// @codekit-prepend "../js/acf-field.js";
+// @codekit-prepend "../js/acf-fields.js";
+// @codekit-prepend "../js/acf-field-accordion.js";
+// @codekit-prepend "../js/acf-field-button-group.js";
+// @codekit-prepend "../js/acf-field-checkbox.js";
+// @codekit-prepend "../js/acf-field-color-picker.js";
+// @codekit-prepend "../js/acf-field-date-picker.js";
+// @codekit-prepend "../js/acf-field-date-time-picker.js";
+// @codekit-prepend "../js/acf-field-google-map.js";
+// @codekit-prepend "../js/acf-field-image.js";
+// @codekit-prepend "../js/acf-field-file.js";
+// @codekit-prepend "../js/acf-field-link.js";
+// @codekit-prepend "../js/acf-field-oembed.js";
+// @codekit-prepend "../js/acf-field-radio.js";
+// @codekit-prepend "../js/acf-field-range.js";
+// @codekit-prepend "../js/acf-field-relationship.js";
+// @codekit-prepend "../js/acf-field-select.js";
+// @codekit-prepend "../js/acf-field-tab.js";
+// @codekit-prepend "../js/acf-field-post-object.js";
+// @codekit-prepend "../js/acf-field-page-link.js";
+// @codekit-prepend "../js/acf-field-user.js";
+// @codekit-prepend "../js/acf-field-taxonomy.js";
+// @codekit-prepend "../js/acf-field-time-picker.js";
+// @codekit-prepend "../js/acf-field-true-false.js";
+// @codekit-prepend "../js/acf-field-url.js";
+// @codekit-prepend "../js/acf-field-wysiwyg.js";
+// @codekit-prepend "../js/acf-condition.js";
+// @codekit-prepend "../js/acf-conditions.js";
+// @codekit-prepend "../js/acf-condition-types.js";
+// @codekit-prepend "../js/acf-media.js";
+// @codekit-prepend "../js/acf-screen.js";
+// @codekit-prepend "../js/acf-select2.js";
+// @codekit-prepend "../js/acf-tinymce.js";
+// @codekit-prepend "../js/acf-validation.js";
+// @codekit-prepend "../js/acf-helpers.js";
+// @codekit-prepend "../js/acf-compatibility";
+
diff --git a/assets/js/acf-input.min.js b/assets/js/acf-input.min.js
index 837534e..ba3800f 100644
--- a/assets/js/acf-input.min.js
+++ b/assets/js/acf-input.min.js
@@ -1,3 +1,4 @@
-!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;nt.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(;n0},$.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;ie.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(' '),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('
');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 #acf-popup"),$popup.exists())return update_popup(e);var t=['"].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={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};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=$(' '),e.append(n))),n.append(''+acf.esc_html(a.label)+" "),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 $("").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=$(''+e+"
");$("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||''+acf._e("yes")+" ",n=n||''+acf._e("No")+" ";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=''+acf._e("remove")+" ",button_n=''+acf._e("cancel")+" ",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(' ')}});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(' '))}),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=' ';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-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('
'))},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('
'))},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=$('');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(''+acf._e("image","uploadedTo")+" "),$.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(['',''+acf._e("restricted")+" ",''+c+" ",''+r+" ","
"].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:$(" ").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=$(['',' '+acf._e("expand_details")+" ",' '+acf._e("collapse_details")+" "," "].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(' '+acf._e("relationship","loading")+"
");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(""+acf._e("relationship","empty")+"
"));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+=''+e.text+' ',t+=this.walker(e.children),t+=" "):t+=''+e.text+" ");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=["",' ',''+e.$el.html(),' '," "," "].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){
-e.find('option[value="'+t+'"]').length||e.append(''+i+" ")},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+=' '+e.description+" "),n}},r=this.get_value(i);if(a.multiple){var l=i.attr("name");o.formatSelection=function(e,t){var i=' ";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=$('
'),c=$('
'),d=$(''),f=$(" ");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(' ');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").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")?' ':''),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('
'),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=$(['',"",' ',""+e.term_label+" "," "," "].join(""));if(e.term_parent){var o=a.find('li[data-id="'+e.term_parent+'"]');a=o.children("ul"),a.exists()||(a=$(''),o.append(a))}a.append(s)}}),$("#acf-popup #term_parent").each(function(){var t=$(''+e.term_label+" ");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;i1&&(n+=". "+acf._e("validation_failed_2").replace("%d",s)),a.exists()||(a=$(''),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('"));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);
\ No newline at end of file
+!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(data)},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),et.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 ").html(t).text()},e.strEscape=function(t){var e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};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');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=$(' ');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(' ')},e.stopButtonLoading=function(t){t.prop("disabled",!1),t.next(".acf-loading").remove()},e.showLoading=function(t){t.append('
')},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){return e!==t.val()&&(!(t.is("select")&&!t.find('option[value="'+e+'"]').length)&&(t.val(e),!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-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+=''+r(t.children)+" ":i+='"+e.strEscape(n)+" "}),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;ae.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