Version Description
Release Date - 25 August 2021
- View Release Post
- Enhancement - Improved security by running all user-generated content through
wp_kses()
by default - Enhancement - New ACF Blocks features
- Switched to v2 of the Blocks API for WordPress 5.6+
- Block preloading now enabled by default
- Block preloading now supports blocks set to "Edit" mode
- Add support for full height alignment setting
- Enhancement - Added setting to color picker field to enable an opacity slider
- Enhancement - Allow deletion of first field group location rule if multiple rules have been added thanks to Arthur Shlain
- Fix - Fixed vulnerability with
acf_shortcode()
where users with subscriber role could view arbitrary ACF data, thanks to Keitaro Yamazaki - Fix - Fixed vulnerability where users with subscriber role could move fields and view field groups, thanks to Keitaro Yamazaki
- Fix - Fixed issue where fields in legacy widgets weren't saving in new widget block editor
- Fix - Fixed issue with custom field validation in scheduled posts
- Fix - Fixed warnings thrown by clone field if the cloned field group is empty
- Fix - Fixed issue where Select2 search input wouldn't have focus in WordPress 5.8+
- Fix - Fixed issue with Select2 value sorting when Yoast SEO is installed
- Fix - Fixed deprecation warnings in block editor in WordPress 5.6+
- i18n - Updated Swedish translation thanks to Erik Betshammar
Download this release
Release Info
Developer | deliciousbrains |
Plugin | Advanced Custom Fields |
Version | 5.10 |
Comparing to | |
See all releases |
Code changes from version 5.9.9 to 5.10
- acf.php +627 -617
- assets/build/css/acf-field-group.css +4 -4
- assets/build/css/acf-field-group.min.css +1 -1
- assets/build/js/acf-field-group.js +57 -1
- assets/build/js/acf-field-group.min.js +1 -1
- assets/build/js/acf-input.js +11 -6
- assets/build/js/acf-input.min.js +1 -1
- assets/inc/color-picker-alpha/wp-color-picker-alpha.js +635 -0
- assets/inc/color-picker-alpha/wp-color-picker-alpha.min.js +11 -0
- assets/inc/select2/4/select2.css +8 -11
- assets/inc/select2/4/select2.full.js +668 -292
- assets/inc/select2/4/select2.full.min.js +1 -3
- assets/inc/select2/4/select2.js +663 -280
- assets/inc/select2/4/select2.min.css +1 -1
- assets/inc/select2/4/select2.min.js +2 -3
- includes/acf-field-functions.php +654 -644
- includes/acf-field-group-functions.php +444 -437
- includes/acf-form-functions.php +69 -64
- includes/acf-helper-functions.php +161 -161
- includes/acf-hook-functions.php +104 -94
- includes/acf-input-functions.php +200 -220
- includes/acf-meta-functions.php +159 -156
- includes/acf-post-functions.php +15 -15
- includes/acf-user-functions.php +45 -45
- includes/acf-utility-functions.php +51 -51
- includes/acf-value-functions.php +145 -145
- includes/acf-wp-functions.php +86 -86
- includes/admin/admin-field-group.php +783 -785
- includes/admin/admin-field-groups.php +775 -777
acf.php
CHANGED
@@ -3,655 +3,665 @@
|
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: https://www.advancedcustomfields.com
|
5 |
Description: Customize WordPress with powerful, professional and intuitive fields.
|
6 |
-
Version: 5.
|
7 |
Author: Delicious Brains
|
8 |
Author URI: https://www.advancedcustomfields.com
|
9 |
Text Domain: acf
|
10 |
Domain Path: /lang
|
11 |
*/
|
12 |
|
13 |
-
if( ! defined( 'ABSPATH' ) )
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* initialize
|
48 |
-
*
|
49 |
-
* Sets up the ACF plugin.
|
50 |
-
*
|
51 |
-
* @date 28/09/13
|
52 |
-
* @since 5.0.0
|
53 |
-
*
|
54 |
-
* @param void
|
55 |
-
* @return void
|
56 |
-
*/
|
57 |
-
function initialize() {
|
58 |
-
|
59 |
-
// Define constants.
|
60 |
-
$this->define( 'ACF', true );
|
61 |
-
$this->define( 'ACF_PATH', plugin_dir_path( __FILE__ ) );
|
62 |
-
$this->define( 'ACF_BASENAME', plugin_basename( __FILE__ ) );
|
63 |
-
$this->define( 'ACF_VERSION', $this->version );
|
64 |
-
$this->define( 'ACF_MAJOR_VERSION', 5 );
|
65 |
-
|
66 |
-
// Define settings.
|
67 |
-
$this->settings = array(
|
68 |
-
'name' => __('Advanced Custom Fields', 'acf'),
|
69 |
-
'slug' => dirname( ACF_BASENAME ),
|
70 |
-
'version' => ACF_VERSION,
|
71 |
-
'basename' => ACF_BASENAME,
|
72 |
-
'path' => ACF_PATH,
|
73 |
-
'file' => __FILE__,
|
74 |
-
'url' => plugin_dir_url( __FILE__ ),
|
75 |
-
'show_admin' => true,
|
76 |
-
'show_updates' => true,
|
77 |
-
'stripslashes' => false,
|
78 |
-
'local' => true,
|
79 |
-
'json' => true,
|
80 |
-
'save_json' => '',
|
81 |
-
'load_json' => array(),
|
82 |
-
'default_language' => '',
|
83 |
-
'current_language' => '',
|
84 |
-
'capability' => 'manage_options',
|
85 |
-
'uploader' => 'wp',
|
86 |
-
'autoload' => false,
|
87 |
-
'l10n' => true,
|
88 |
-
'l10n_textdomain' => '',
|
89 |
-
'google_api_key' => '',
|
90 |
-
'google_api_client' => '',
|
91 |
-
'enqueue_google_maps' => true,
|
92 |
-
'enqueue_select2' => true,
|
93 |
-
'enqueue_datepicker' => true,
|
94 |
-
'enqueue_datetimepicker' => true,
|
95 |
-
'select2_version' => 4,
|
96 |
-
'row_index_offset' => 1,
|
97 |
-
'remove_wp_meta_box' => true
|
98 |
-
);
|
99 |
-
|
100 |
-
// Include utility functions.
|
101 |
-
include_once( ACF_PATH . 'includes/acf-utility-functions.php');
|
102 |
-
|
103 |
-
// Include previous API functions.
|
104 |
-
acf_include('includes/api/api-helpers.php');
|
105 |
-
acf_include('includes/api/api-template.php');
|
106 |
-
acf_include('includes/api/api-term.php');
|
107 |
-
|
108 |
-
// Include classes.
|
109 |
-
acf_include('includes/class-acf-data.php');
|
110 |
-
acf_include('includes/fields/class-acf-field.php');
|
111 |
-
acf_include('includes/locations/abstract-acf-legacy-location.php');
|
112 |
-
acf_include('includes/locations/abstract-acf-location.php');
|
113 |
-
|
114 |
-
// Include functions.
|
115 |
-
acf_include('includes/acf-helper-functions.php');
|
116 |
-
acf_include('includes/acf-hook-functions.php');
|
117 |
-
acf_include('includes/acf-field-functions.php');
|
118 |
-
acf_include('includes/acf-field-group-functions.php');
|
119 |
-
acf_include('includes/acf-form-functions.php');
|
120 |
-
acf_include('includes/acf-meta-functions.php');
|
121 |
-
acf_include('includes/acf-post-functions.php');
|
122 |
-
acf_include('includes/acf-user-functions.php');
|
123 |
-
acf_include('includes/acf-value-functions.php');
|
124 |
-
acf_include('includes/acf-input-functions.php');
|
125 |
-
acf_include('includes/acf-wp-functions.php');
|
126 |
-
|
127 |
-
// Include core.
|
128 |
-
acf_include('includes/fields.php');
|
129 |
-
acf_include('includes/locations.php');
|
130 |
-
acf_include('includes/assets.php');
|
131 |
-
acf_include('includes/compatibility.php');
|
132 |
-
acf_include('includes/deprecated.php');
|
133 |
-
acf_include('includes/l10n.php');
|
134 |
-
acf_include('includes/local-fields.php');
|
135 |
-
acf_include('includes/local-meta.php');
|
136 |
-
acf_include('includes/local-json.php');
|
137 |
-
acf_include('includes/loop.php');
|
138 |
-
acf_include('includes/media.php');
|
139 |
-
acf_include('includes/revisions.php');
|
140 |
-
acf_include('includes/updates.php');
|
141 |
-
acf_include('includes/upgrades.php');
|
142 |
-
acf_include('includes/validation.php');
|
143 |
-
|
144 |
-
// Include ajax.
|
145 |
-
acf_include('includes/ajax/class-acf-ajax.php');
|
146 |
-
acf_include('includes/ajax/class-acf-ajax-check-screen.php');
|
147 |
-
acf_include('includes/ajax/class-acf-ajax-user-setting.php');
|
148 |
-
acf_include('includes/ajax/class-acf-ajax-upgrade.php');
|
149 |
-
acf_include('includes/ajax/class-acf-ajax-query.php');
|
150 |
-
acf_include('includes/ajax/class-acf-ajax-query-users.php');
|
151 |
-
acf_include('includes/ajax/class-acf-ajax-local-json-diff.php');
|
152 |
-
|
153 |
-
// Include forms.
|
154 |
-
acf_include('includes/forms/form-attachment.php');
|
155 |
-
acf_include('includes/forms/form-comment.php');
|
156 |
-
acf_include('includes/forms/form-customizer.php');
|
157 |
-
acf_include('includes/forms/form-front.php');
|
158 |
-
acf_include('includes/forms/form-nav-menu.php');
|
159 |
-
acf_include('includes/forms/form-post.php');
|
160 |
-
acf_include('includes/forms/form-gutenberg.php');
|
161 |
-
acf_include('includes/forms/form-taxonomy.php');
|
162 |
-
acf_include('includes/forms/form-user.php');
|
163 |
-
acf_include('includes/forms/form-widget.php');
|
164 |
-
|
165 |
-
// Include admin.
|
166 |
-
if( is_admin() ) {
|
167 |
-
acf_include('includes/admin/admin.php');
|
168 |
-
acf_include('includes/admin/admin-field-group.php');
|
169 |
-
acf_include('includes/admin/admin-field-groups.php');
|
170 |
-
acf_include('includes/admin/admin-notices.php');
|
171 |
-
acf_include('includes/admin/admin-tools.php');
|
172 |
-
acf_include('includes/admin/admin-upgrade.php');
|
173 |
}
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
}
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
-
|
232 |
-
// Include fields.
|
233 |
-
acf_include('includes/fields/class-acf-field-text.php');
|
234 |
-
acf_include('includes/fields/class-acf-field-textarea.php');
|
235 |
-
acf_include('includes/fields/class-acf-field-number.php');
|
236 |
-
acf_include('includes/fields/class-acf-field-range.php');
|
237 |
-
acf_include('includes/fields/class-acf-field-email.php');
|
238 |
-
acf_include('includes/fields/class-acf-field-url.php');
|
239 |
-
acf_include('includes/fields/class-acf-field-password.php');
|
240 |
-
acf_include('includes/fields/class-acf-field-image.php');
|
241 |
-
acf_include('includes/fields/class-acf-field-file.php');
|
242 |
-
acf_include('includes/fields/class-acf-field-wysiwyg.php');
|
243 |
-
acf_include('includes/fields/class-acf-field-oembed.php');
|
244 |
-
acf_include('includes/fields/class-acf-field-select.php');
|
245 |
-
acf_include('includes/fields/class-acf-field-checkbox.php');
|
246 |
-
acf_include('includes/fields/class-acf-field-radio.php');
|
247 |
-
acf_include('includes/fields/class-acf-field-button-group.php');
|
248 |
-
acf_include('includes/fields/class-acf-field-true_false.php');
|
249 |
-
acf_include('includes/fields/class-acf-field-link.php');
|
250 |
-
acf_include('includes/fields/class-acf-field-post_object.php');
|
251 |
-
acf_include('includes/fields/class-acf-field-page_link.php');
|
252 |
-
acf_include('includes/fields/class-acf-field-relationship.php');
|
253 |
-
acf_include('includes/fields/class-acf-field-taxonomy.php');
|
254 |
-
acf_include('includes/fields/class-acf-field-user.php');
|
255 |
-
acf_include('includes/fields/class-acf-field-google-map.php');
|
256 |
-
acf_include('includes/fields/class-acf-field-date_picker.php');
|
257 |
-
acf_include('includes/fields/class-acf-field-date_time_picker.php');
|
258 |
-
acf_include('includes/fields/class-acf-field-time_picker.php');
|
259 |
-
acf_include('includes/fields/class-acf-field-color_picker.php');
|
260 |
-
acf_include('includes/fields/class-acf-field-message.php');
|
261 |
-
acf_include('includes/fields/class-acf-field-accordion.php');
|
262 |
-
acf_include('includes/fields/class-acf-field-tab.php');
|
263 |
-
acf_include('includes/fields/class-acf-field-group.php');
|
264 |
-
|
265 |
/**
|
266 |
-
*
|
267 |
*
|
268 |
-
*
|
269 |
-
* @since 5.0.0
|
270 |
*
|
271 |
-
* @
|
|
|
|
|
|
|
|
|
272 |
*/
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
acf_include('includes/locations/class-acf-location-nav-menu.php');
|
296 |
-
acf_include('includes/locations/class-acf-location-nav-menu-item.php');
|
297 |
-
|
298 |
/**
|
299 |
-
*
|
300 |
*
|
301 |
-
*
|
302 |
-
* @since 5.0.0
|
303 |
*
|
304 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
305 |
*/
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
|
|
308 |
/**
|
309 |
-
*
|
|
|
|
|
310 |
*
|
311 |
-
* @date
|
312 |
-
* @since
|
313 |
*
|
314 |
-
* @param
|
|
|
315 |
*/
|
316 |
-
|
317 |
-
|
|
|
|
|
318 |
/**
|
319 |
-
*
|
|
|
|
|
320 |
*
|
321 |
-
* @date
|
322 |
-
* @since
|
323 |
*
|
324 |
-
* @param
|
|
|
325 |
*/
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
/**
|
330 |
-
* register_post_types
|
331 |
-
*
|
332 |
-
* Registers the ACF post types.
|
333 |
-
*
|
334 |
-
* @date 22/10/2015
|
335 |
-
* @since 5.3.2
|
336 |
-
*
|
337 |
-
* @param void
|
338 |
-
* @return void
|
339 |
-
*/
|
340 |
-
function register_post_types() {
|
341 |
-
|
342 |
-
// Vars.
|
343 |
-
$cap = acf_get_setting('capability');
|
344 |
-
|
345 |
-
// Register the Field Group post type.
|
346 |
-
register_post_type('acf-field-group', array(
|
347 |
-
'labels' => array(
|
348 |
-
'name' => __( 'Field Groups', 'acf' ),
|
349 |
-
'singular_name' => __( 'Field Group', 'acf' ),
|
350 |
-
'add_new' => __( 'Add New' , 'acf' ),
|
351 |
-
'add_new_item' => __( 'Add New Field Group' , 'acf' ),
|
352 |
-
'edit_item' => __( 'Edit Field Group' , 'acf' ),
|
353 |
-
'new_item' => __( 'New Field Group' , 'acf' ),
|
354 |
-
'view_item' => __( 'View Field Group', 'acf' ),
|
355 |
-
'search_items' => __( 'Search Field Groups', 'acf' ),
|
356 |
-
'not_found' => __( 'No Field Groups found', 'acf' ),
|
357 |
-
'not_found_in_trash' => __( 'No Field Groups found in Trash', 'acf' ),
|
358 |
-
),
|
359 |
-
'public' => false,
|
360 |
-
'hierarchical' => true,
|
361 |
-
'show_ui' => true,
|
362 |
-
'show_in_menu' => false,
|
363 |
-
'_builtin' => false,
|
364 |
-
'capability_type' => 'post',
|
365 |
-
'capabilities' => array(
|
366 |
-
'edit_post' => $cap,
|
367 |
-
'delete_post' => $cap,
|
368 |
-
'edit_posts' => $cap,
|
369 |
-
'delete_posts' => $cap,
|
370 |
-
),
|
371 |
-
'supports' => array('title'),
|
372 |
-
'rewrite' => false,
|
373 |
-
'query_var' => false,
|
374 |
-
));
|
375 |
-
|
376 |
-
|
377 |
-
// Register the Field post type.
|
378 |
-
register_post_type('acf-field', array(
|
379 |
-
'labels' => array(
|
380 |
-
'name' => __( 'Fields', 'acf' ),
|
381 |
-
'singular_name' => __( 'Field', 'acf' ),
|
382 |
-
'add_new' => __( 'Add New' , 'acf' ),
|
383 |
-
'add_new_item' => __( 'Add New Field' , 'acf' ),
|
384 |
-
'edit_item' => __( 'Edit Field' , 'acf' ),
|
385 |
-
'new_item' => __( 'New Field' , 'acf' ),
|
386 |
-
'view_item' => __( 'View Field', 'acf' ),
|
387 |
-
'search_items' => __( 'Search Fields', 'acf' ),
|
388 |
-
'not_found' => __( 'No Fields found', 'acf' ),
|
389 |
-
'not_found_in_trash' => __( 'No Fields found in Trash', 'acf' ),
|
390 |
-
),
|
391 |
-
'public' => false,
|
392 |
-
'hierarchical' => true,
|
393 |
-
'show_ui' => false,
|
394 |
-
'show_in_menu' => false,
|
395 |
-
'_builtin' => false,
|
396 |
-
'capability_type' => 'post',
|
397 |
-
'capabilities' => array(
|
398 |
-
'edit_post' => $cap,
|
399 |
-
'delete_post' => $cap,
|
400 |
-
'edit_posts' => $cap,
|
401 |
-
'delete_posts' => $cap,
|
402 |
-
),
|
403 |
-
'supports' => array('title'),
|
404 |
-
'rewrite' => false,
|
405 |
-
'query_var' => false,
|
406 |
-
));
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* register_post_status
|
411 |
-
*
|
412 |
-
* Registers the ACF post statuses.
|
413 |
-
*
|
414 |
-
* @date 22/10/2015
|
415 |
-
* @since 5.3.2
|
416 |
-
*
|
417 |
-
* @param void
|
418 |
-
* @return void
|
419 |
-
*/
|
420 |
-
function register_post_status() {
|
421 |
-
|
422 |
-
// Register the Disabled post status.
|
423 |
-
register_post_status('acf-disabled', array(
|
424 |
-
'label' => _x( 'Disabled', 'post status', 'acf' ),
|
425 |
-
'public' => true,
|
426 |
-
'exclude_from_search' => false,
|
427 |
-
'show_in_admin_all_list' => true,
|
428 |
-
'show_in_admin_status_list' => true,
|
429 |
-
'label_count' => _n_noop( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', 'acf' ),
|
430 |
-
));
|
431 |
-
}
|
432 |
-
|
433 |
-
/**
|
434 |
-
* posts_where
|
435 |
-
*
|
436 |
-
* Filters the $where clause allowing for custom WP_Query args.
|
437 |
-
*
|
438 |
-
* @date 31/8/19
|
439 |
-
* @since 5.8.1
|
440 |
-
*
|
441 |
-
* @param string $where The WHERE clause.
|
442 |
-
* @return WP_Query $wp_query The query object.
|
443 |
-
*/
|
444 |
-
function posts_where( $where, $wp_query ) {
|
445 |
-
global $wpdb;
|
446 |
-
|
447 |
-
// Add custom "acf_field_key" arg.
|
448 |
-
if( $field_key = $wp_query->get('acf_field_key') ) {
|
449 |
-
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_name = %s", $field_key );
|
450 |
-
}
|
451 |
-
|
452 |
-
// Add custom "acf_field_name" arg.
|
453 |
-
if( $field_name = $wp_query->get('acf_field_name') ) {
|
454 |
-
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_excerpt = %s", $field_name );
|
455 |
-
}
|
456 |
-
|
457 |
-
// Add custom "acf_group_key" arg.
|
458 |
-
if( $group_key = $wp_query->get('acf_group_key') ) {
|
459 |
-
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_name = %s", $group_key );
|
460 |
-
}
|
461 |
-
|
462 |
-
// Return.
|
463 |
-
return $where;
|
464 |
-
}
|
465 |
-
|
466 |
-
/**
|
467 |
-
* define
|
468 |
-
*
|
469 |
-
* Defines a constant if doesnt already exist.
|
470 |
-
*
|
471 |
-
* @date 3/5/17
|
472 |
-
* @since 5.5.13
|
473 |
-
*
|
474 |
-
* @param string $name The constant name.
|
475 |
-
* @param mixed $value The constant value.
|
476 |
-
* @return void
|
477 |
-
*/
|
478 |
-
function define( $name, $value = true ) {
|
479 |
-
if( !defined($name) ) {
|
480 |
-
define( $name, $value );
|
481 |
}
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Magic __isset method for backwards compatibility.
|
598 |
-
*
|
599 |
-
* @date 24/4/20
|
600 |
-
* @since 5.9.0
|
601 |
-
*
|
602 |
-
* @param string $key Key name.
|
603 |
-
* @return bool
|
604 |
-
*/
|
605 |
-
public function __isset( $key ) {
|
606 |
-
return in_array( $key, array( 'locations', 'json' ) );
|
607 |
-
}
|
608 |
-
|
609 |
-
/**
|
610 |
-
* Magic __get method for backwards compatibility.
|
611 |
-
*
|
612 |
-
* @date 24/4/20
|
613 |
-
* @since 5.9.0
|
614 |
-
*
|
615 |
-
* @param string $key Key name.
|
616 |
-
* @return mixed
|
617 |
-
*/
|
618 |
-
public function __get( $key ) {
|
619 |
-
switch ( $key ) {
|
620 |
-
case 'locations':
|
621 |
-
return acf_get_instance( 'ACF_Legacy_Locations' );
|
622 |
-
case 'json':
|
623 |
-
return acf_get_instance( 'ACF_Local_JSON' );
|
624 |
}
|
625 |
-
return null;
|
626 |
}
|
627 |
-
}
|
628 |
|
629 |
-
/*
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
function acf() {
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
|
|
|
|
650 |
}
|
651 |
-
return $acf;
|
652 |
-
}
|
653 |
|
654 |
-
// Instantiate.
|
655 |
-
acf();
|
656 |
|
657 |
endif; // class_exists check
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: https://www.advancedcustomfields.com
|
5 |
Description: Customize WordPress with powerful, professional and intuitive fields.
|
6 |
+
Version: 5.10
|
7 |
Author: Delicious Brains
|
8 |
Author URI: https://www.advancedcustomfields.com
|
9 |
Text Domain: acf
|
10 |
Domain Path: /lang
|
11 |
*/
|
12 |
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit; // Exit if accessed directly
|
15 |
+
}
|
16 |
+
|
17 |
+
if ( ! class_exists( 'ACF' ) ) :
|
18 |
+
|
19 |
+
class ACF {
|
20 |
+
|
21 |
+
/** @var string The plugin version number. */
|
22 |
+
var $version = '5.10';
|
23 |
+
|
24 |
+
/** @var array The plugin settings array. */
|
25 |
+
var $settings = array();
|
26 |
+
|
27 |
+
/** @var array The plugin data array. */
|
28 |
+
var $data = array();
|
29 |
+
|
30 |
+
/** @var array Storage for class instances. */
|
31 |
+
var $instances = array();
|
32 |
+
|
33 |
+
/**
|
34 |
+
* __construct
|
35 |
+
*
|
36 |
+
* A dummy constructor to ensure ACF is only setup once.
|
37 |
+
*
|
38 |
+
* @date 23/06/12
|
39 |
+
* @since 5.0.0
|
40 |
+
*
|
41 |
+
* @param void
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
function __construct() {
|
45 |
+
// Do nothing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* initialize
|
50 |
+
*
|
51 |
+
* Sets up the ACF plugin.
|
52 |
+
*
|
53 |
+
* @date 28/09/13
|
54 |
+
* @since 5.0.0
|
55 |
+
*
|
56 |
+
* @param void
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
function initialize() {
|
60 |
+
|
61 |
+
// Define constants.
|
62 |
+
$this->define( 'ACF', true );
|
63 |
+
$this->define( 'ACF_PATH', plugin_dir_path( __FILE__ ) );
|
64 |
+
$this->define( 'ACF_BASENAME', plugin_basename( __FILE__ ) );
|
65 |
+
$this->define( 'ACF_VERSION', $this->version );
|
66 |
+
$this->define( 'ACF_MAJOR_VERSION', 5 );
|
67 |
+
|
68 |
+
// Define settings.
|
69 |
+
$this->settings = array(
|
70 |
+
'name' => __( 'Advanced Custom Fields', 'acf' ),
|
71 |
+
'slug' => dirname( ACF_BASENAME ),
|
72 |
+
'version' => ACF_VERSION,
|
73 |
+
'basename' => ACF_BASENAME,
|
74 |
+
'path' => ACF_PATH,
|
75 |
+
'file' => __FILE__,
|
76 |
+
'url' => plugin_dir_url( __FILE__ ),
|
77 |
+
'show_admin' => true,
|
78 |
+
'show_updates' => true,
|
79 |
+
'stripslashes' => false,
|
80 |
+
'local' => true,
|
81 |
+
'json' => true,
|
82 |
+
'save_json' => '',
|
83 |
+
'load_json' => array(),
|
84 |
+
'default_language' => '',
|
85 |
+
'current_language' => '',
|
86 |
+
'capability' => 'manage_options',
|
87 |
+
'uploader' => 'wp',
|
88 |
+
'autoload' => false,
|
89 |
+
'l10n' => true,
|
90 |
+
'l10n_textdomain' => '',
|
91 |
+
'google_api_key' => '',
|
92 |
+
'google_api_client' => '',
|
93 |
+
'enqueue_google_maps' => true,
|
94 |
+
'enqueue_select2' => true,
|
95 |
+
'enqueue_datepicker' => true,
|
96 |
+
'enqueue_datetimepicker' => true,
|
97 |
+
'select2_version' => 4,
|
98 |
+
'row_index_offset' => 1,
|
99 |
+
'remove_wp_meta_box' => true,
|
100 |
+
);
|
101 |
+
|
102 |
+
// Include utility functions.
|
103 |
+
include_once ACF_PATH . 'includes/acf-utility-functions.php';
|
104 |
+
|
105 |
+
// Include previous API functions.
|
106 |
+
acf_include( 'includes/api/api-helpers.php' );
|
107 |
+
acf_include( 'includes/api/api-template.php' );
|
108 |
+
acf_include( 'includes/api/api-term.php' );
|
109 |
+
|
110 |
+
// Include classes.
|
111 |
+
acf_include( 'includes/class-acf-data.php' );
|
112 |
+
acf_include( 'includes/fields/class-acf-field.php' );
|
113 |
+
acf_include( 'includes/locations/abstract-acf-legacy-location.php' );
|
114 |
+
acf_include( 'includes/locations/abstract-acf-location.php' );
|
115 |
+
|
116 |
+
// Include functions.
|
117 |
+
acf_include( 'includes/acf-helper-functions.php' );
|
118 |
+
acf_include( 'includes/acf-hook-functions.php' );
|
119 |
+
acf_include( 'includes/acf-field-functions.php' );
|
120 |
+
acf_include( 'includes/acf-field-group-functions.php' );
|
121 |
+
acf_include( 'includes/acf-form-functions.php' );
|
122 |
+
acf_include( 'includes/acf-meta-functions.php' );
|
123 |
+
acf_include( 'includes/acf-post-functions.php' );
|
124 |
+
acf_include( 'includes/acf-user-functions.php' );
|
125 |
+
acf_include( 'includes/acf-value-functions.php' );
|
126 |
+
acf_include( 'includes/acf-input-functions.php' );
|
127 |
+
acf_include( 'includes/acf-wp-functions.php' );
|
128 |
+
|
129 |
+
// Include core.
|
130 |
+
acf_include( 'includes/fields.php' );
|
131 |
+
acf_include( 'includes/locations.php' );
|
132 |
+
acf_include( 'includes/assets.php' );
|
133 |
+
acf_include( 'includes/compatibility.php' );
|
134 |
+
acf_include( 'includes/deprecated.php' );
|
135 |
+
acf_include( 'includes/l10n.php' );
|
136 |
+
acf_include( 'includes/local-fields.php' );
|
137 |
+
acf_include( 'includes/local-meta.php' );
|
138 |
+
acf_include( 'includes/local-json.php' );
|
139 |
+
acf_include( 'includes/loop.php' );
|
140 |
+
acf_include( 'includes/media.php' );
|
141 |
+
acf_include( 'includes/revisions.php' );
|
142 |
+
acf_include( 'includes/updates.php' );
|
143 |
+
acf_include( 'includes/upgrades.php' );
|
144 |
+
acf_include( 'includes/validation.php' );
|
145 |
+
|
146 |
+
// Include ajax.
|
147 |
+
acf_include( 'includes/ajax/class-acf-ajax.php' );
|
148 |
+
acf_include( 'includes/ajax/class-acf-ajax-check-screen.php' );
|
149 |
+
acf_include( 'includes/ajax/class-acf-ajax-user-setting.php' );
|
150 |
+
acf_include( 'includes/ajax/class-acf-ajax-upgrade.php' );
|
151 |
+
acf_include( 'includes/ajax/class-acf-ajax-query.php' );
|
152 |
+
acf_include( 'includes/ajax/class-acf-ajax-query-users.php' );
|
153 |
+
acf_include( 'includes/ajax/class-acf-ajax-local-json-diff.php' );
|
154 |
+
|
155 |
+
// Include forms.
|
156 |
+
acf_include( 'includes/forms/form-attachment.php' );
|
157 |
+
acf_include( 'includes/forms/form-comment.php' );
|
158 |
+
acf_include( 'includes/forms/form-customizer.php' );
|
159 |
+
acf_include( 'includes/forms/form-front.php' );
|
160 |
+
acf_include( 'includes/forms/form-nav-menu.php' );
|
161 |
+
acf_include( 'includes/forms/form-post.php' );
|
162 |
+
acf_include( 'includes/forms/form-gutenberg.php' );
|
163 |
+
acf_include( 'includes/forms/form-taxonomy.php' );
|
164 |
+
acf_include( 'includes/forms/form-user.php' );
|
165 |
+
acf_include( 'includes/forms/form-widget.php' );
|
166 |
+
|
167 |
+
// Include admin.
|
168 |
+
if ( is_admin() ) {
|
169 |
+
acf_include( 'includes/admin/admin.php' );
|
170 |
+
acf_include( 'includes/admin/admin-field-group.php' );
|
171 |
+
acf_include( 'includes/admin/admin-field-groups.php' );
|
172 |
+
acf_include( 'includes/admin/admin-notices.php' );
|
173 |
+
acf_include( 'includes/admin/admin-tools.php' );
|
174 |
+
acf_include( 'includes/admin/admin-upgrade.php' );
|
175 |
+
}
|
176 |
+
|
177 |
+
// Include legacy.
|
178 |
+
acf_include( 'includes/legacy/legacy-locations.php' );
|
179 |
+
|
180 |
+
// Include PRO.
|
181 |
+
acf_include( 'pro/acf-pro.php' );
|
182 |
+
|
183 |
+
// Include tests.
|
184 |
+
if ( defined( 'ACF_DEV' ) && ACF_DEV ) {
|
185 |
+
acf_include( 'tests/tests.php' );
|
186 |
+
}
|
187 |
+
|
188 |
+
// Add actions.
|
189 |
+
add_action( 'init', array( $this, 'init' ), 5 );
|
190 |
+
add_action( 'init', array( $this, 'register_post_types' ), 5 );
|
191 |
+
add_action( 'init', array( $this, 'register_post_status' ), 5 );
|
192 |
+
|
193 |
+
// Add filters.
|
194 |
+
add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 );
|
195 |
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* init
|
199 |
+
*
|
200 |
+
* Completes the setup process on "init" of earlier.
|
201 |
+
*
|
202 |
+
* @date 28/09/13
|
203 |
+
* @since 5.0.0
|
204 |
+
*
|
205 |
+
* @param void
|
206 |
+
* @return void
|
207 |
+
*/
|
208 |
+
function init() {
|
209 |
+
|
210 |
+
// Bail early if called directly from functions.php or plugin file.
|
211 |
+
if ( ! did_action( 'plugins_loaded' ) ) {
|
212 |
+
return;
|
213 |
+
}
|
214 |
+
|
215 |
+
// This function may be called directly from template functions. Bail early if already did this.
|
216 |
+
if ( acf_did( 'init' ) ) {
|
217 |
+
return;
|
218 |
+
}
|
219 |
+
|
220 |
+
// Update url setting. Allows other plugins to modify the URL (force SSL).
|
221 |
+
acf_update_setting( 'url', plugin_dir_url( __FILE__ ) );
|
222 |
+
|
223 |
+
// Load textdomain file.
|
224 |
+
acf_load_textdomain();
|
225 |
+
|
226 |
+
// Include 3rd party compatiblity.
|
227 |
+
acf_include( 'includes/third-party.php' );
|
228 |
+
|
229 |
+
// Include wpml support.
|
230 |
+
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
231 |
+
acf_include( 'includes/wpml.php' );
|
232 |
+
}
|
233 |
+
|
234 |
+
// Include fields.
|
235 |
+
acf_include( 'includes/fields/class-acf-field-text.php' );
|
236 |
+
acf_include( 'includes/fields/class-acf-field-textarea.php' );
|
237 |
+
acf_include( 'includes/fields/class-acf-field-number.php' );
|
238 |
+
acf_include( 'includes/fields/class-acf-field-range.php' );
|
239 |
+
acf_include( 'includes/fields/class-acf-field-email.php' );
|
240 |
+
acf_include( 'includes/fields/class-acf-field-url.php' );
|
241 |
+
acf_include( 'includes/fields/class-acf-field-password.php' );
|
242 |
+
acf_include( 'includes/fields/class-acf-field-image.php' );
|
243 |
+
acf_include( 'includes/fields/class-acf-field-file.php' );
|
244 |
+
acf_include( 'includes/fields/class-acf-field-wysiwyg.php' );
|
245 |
+
acf_include( 'includes/fields/class-acf-field-oembed.php' );
|
246 |
+
acf_include( 'includes/fields/class-acf-field-select.php' );
|
247 |
+
acf_include( 'includes/fields/class-acf-field-checkbox.php' );
|
248 |
+
acf_include( 'includes/fields/class-acf-field-radio.php' );
|
249 |
+
acf_include( 'includes/fields/class-acf-field-button-group.php' );
|
250 |
+
acf_include( 'includes/fields/class-acf-field-true_false.php' );
|
251 |
+
acf_include( 'includes/fields/class-acf-field-link.php' );
|
252 |
+
acf_include( 'includes/fields/class-acf-field-post_object.php' );
|
253 |
+
acf_include( 'includes/fields/class-acf-field-page_link.php' );
|
254 |
+
acf_include( 'includes/fields/class-acf-field-relationship.php' );
|
255 |
+
acf_include( 'includes/fields/class-acf-field-taxonomy.php' );
|
256 |
+
acf_include( 'includes/fields/class-acf-field-user.php' );
|
257 |
+
acf_include( 'includes/fields/class-acf-field-google-map.php' );
|
258 |
+
acf_include( 'includes/fields/class-acf-field-date_picker.php' );
|
259 |
+
acf_include( 'includes/fields/class-acf-field-date_time_picker.php' );
|
260 |
+
acf_include( 'includes/fields/class-acf-field-time_picker.php' );
|
261 |
+
acf_include( 'includes/fields/class-acf-field-color_picker.php' );
|
262 |
+
acf_include( 'includes/fields/class-acf-field-message.php' );
|
263 |
+
acf_include( 'includes/fields/class-acf-field-accordion.php' );
|
264 |
+
acf_include( 'includes/fields/class-acf-field-tab.php' );
|
265 |
+
acf_include( 'includes/fields/class-acf-field-group.php' );
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Fires after field types have been included.
|
269 |
+
*
|
270 |
+
* @date 28/09/13
|
271 |
+
* @since 5.0.0
|
272 |
+
*
|
273 |
+
* @param int $major_version The major version of ACF.
|
274 |
+
*/
|
275 |
+
do_action( 'acf/include_field_types', ACF_MAJOR_VERSION );
|
276 |
+
|
277 |
+
// Include locations.
|
278 |
+
acf_include( 'includes/locations/class-acf-location-post-type.php' );
|
279 |
+
acf_include( 'includes/locations/class-acf-location-post-template.php' );
|
280 |
+
acf_include( 'includes/locations/class-acf-location-post-status.php' );
|
281 |
+
acf_include( 'includes/locations/class-acf-location-post-format.php' );
|
282 |
+
acf_include( 'includes/locations/class-acf-location-post-category.php' );
|
283 |
+
acf_include( 'includes/locations/class-acf-location-post-taxonomy.php' );
|
284 |
+
acf_include( 'includes/locations/class-acf-location-post.php' );
|
285 |
+
acf_include( 'includes/locations/class-acf-location-page-template.php' );
|
286 |
+
acf_include( 'includes/locations/class-acf-location-page-type.php' );
|
287 |
+
acf_include( 'includes/locations/class-acf-location-page-parent.php' );
|
288 |
+
acf_include( 'includes/locations/class-acf-location-page.php' );
|
289 |
+
acf_include( 'includes/locations/class-acf-location-current-user.php' );
|
290 |
+
acf_include( 'includes/locations/class-acf-location-current-user-role.php' );
|
291 |
+
acf_include( 'includes/locations/class-acf-location-user-form.php' );
|
292 |
+
acf_include( 'includes/locations/class-acf-location-user-role.php' );
|
293 |
+
acf_include( 'includes/locations/class-acf-location-taxonomy.php' );
|
294 |
+
acf_include( 'includes/locations/class-acf-location-attachment.php' );
|
295 |
+
acf_include( 'includes/locations/class-acf-location-comment.php' );
|
296 |
+
acf_include( 'includes/locations/class-acf-location-widget.php' );
|
297 |
+
acf_include( 'includes/locations/class-acf-location-nav-menu.php' );
|
298 |
+
acf_include( 'includes/locations/class-acf-location-nav-menu-item.php' );
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Fires after location types have been included.
|
302 |
+
*
|
303 |
+
* @date 28/09/13
|
304 |
+
* @since 5.0.0
|
305 |
+
*
|
306 |
+
* @param int $major_version The major version of ACF.
|
307 |
+
*/
|
308 |
+
do_action( 'acf/include_location_rules', ACF_MAJOR_VERSION );
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Fires during initialization. Used to add local fields.
|
312 |
+
*
|
313 |
+
* @date 28/09/13
|
314 |
+
* @since 5.0.0
|
315 |
+
*
|
316 |
+
* @param int $major_version The major version of ACF.
|
317 |
+
*/
|
318 |
+
do_action( 'acf/include_fields', ACF_MAJOR_VERSION );
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Fires after ACF is completely "initialized".
|
322 |
+
*
|
323 |
+
* @date 28/09/13
|
324 |
+
* @since 5.0.0
|
325 |
+
*
|
326 |
+
* @param int $major_version The major version of ACF.
|
327 |
+
*/
|
328 |
+
do_action( 'acf/init', ACF_MAJOR_VERSION );
|
329 |
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* register_post_types
|
333 |
+
*
|
334 |
+
* Registers the ACF post types.
|
335 |
+
*
|
336 |
+
* @date 22/10/2015
|
337 |
+
* @since 5.3.2
|
338 |
+
*
|
339 |
+
* @param void
|
340 |
+
* @return void
|
341 |
+
*/
|
342 |
+
function register_post_types() {
|
343 |
+
|
344 |
+
// Vars.
|
345 |
+
$cap = acf_get_setting( 'capability' );
|
346 |
+
|
347 |
+
// Register the Field Group post type.
|
348 |
+
register_post_type(
|
349 |
+
'acf-field-group',
|
350 |
+
array(
|
351 |
+
'labels' => array(
|
352 |
+
'name' => __( 'Field Groups', 'acf' ),
|
353 |
+
'singular_name' => __( 'Field Group', 'acf' ),
|
354 |
+
'add_new' => __( 'Add New', 'acf' ),
|
355 |
+
'add_new_item' => __( 'Add New Field Group', 'acf' ),
|
356 |
+
'edit_item' => __( 'Edit Field Group', 'acf' ),
|
357 |
+
'new_item' => __( 'New Field Group', 'acf' ),
|
358 |
+
'view_item' => __( 'View Field Group', 'acf' ),
|
359 |
+
'search_items' => __( 'Search Field Groups', 'acf' ),
|
360 |
+
'not_found' => __( 'No Field Groups found', 'acf' ),
|
361 |
+
'not_found_in_trash' => __( 'No Field Groups found in Trash', 'acf' ),
|
362 |
+
),
|
363 |
+
'public' => false,
|
364 |
+
'hierarchical' => true,
|
365 |
+
'show_ui' => true,
|
366 |
+
'show_in_menu' => false,
|
367 |
+
'_builtin' => false,
|
368 |
+
'capability_type' => 'post',
|
369 |
+
'capabilities' => array(
|
370 |
+
'edit_post' => $cap,
|
371 |
+
'delete_post' => $cap,
|
372 |
+
'edit_posts' => $cap,
|
373 |
+
'delete_posts' => $cap,
|
374 |
+
),
|
375 |
+
'supports' => array( 'title' ),
|
376 |
+
'rewrite' => false,
|
377 |
+
'query_var' => false,
|
378 |
+
)
|
379 |
+
);
|
380 |
+
|
381 |
+
// Register the Field post type.
|
382 |
+
register_post_type(
|
383 |
+
'acf-field',
|
384 |
+
array(
|
385 |
+
'labels' => array(
|
386 |
+
'name' => __( 'Fields', 'acf' ),
|
387 |
+
'singular_name' => __( 'Field', 'acf' ),
|
388 |
+
'add_new' => __( 'Add New', 'acf' ),
|
389 |
+
'add_new_item' => __( 'Add New Field', 'acf' ),
|
390 |
+
'edit_item' => __( 'Edit Field', 'acf' ),
|
391 |
+
'new_item' => __( 'New Field', 'acf' ),
|
392 |
+
'view_item' => __( 'View Field', 'acf' ),
|
393 |
+
'search_items' => __( 'Search Fields', 'acf' ),
|
394 |
+
'not_found' => __( 'No Fields found', 'acf' ),
|
395 |
+
'not_found_in_trash' => __( 'No Fields found in Trash', 'acf' ),
|
396 |
+
),
|
397 |
+
'public' => false,
|
398 |
+
'hierarchical' => true,
|
399 |
+
'show_ui' => false,
|
400 |
+
'show_in_menu' => false,
|
401 |
+
'_builtin' => false,
|
402 |
+
'capability_type' => 'post',
|
403 |
+
'capabilities' => array(
|
404 |
+
'edit_post' => $cap,
|
405 |
+
'delete_post' => $cap,
|
406 |
+
'edit_posts' => $cap,
|
407 |
+
'delete_posts' => $cap,
|
408 |
+
),
|
409 |
+
'supports' => array( 'title' ),
|
410 |
+
'rewrite' => false,
|
411 |
+
'query_var' => false,
|
412 |
+
)
|
413 |
+
);
|
414 |
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* register_post_status
|
418 |
+
*
|
419 |
+
* Registers the ACF post statuses.
|
420 |
+
*
|
421 |
+
* @date 22/10/2015
|
422 |
+
* @since 5.3.2
|
423 |
+
*
|
424 |
+
* @param void
|
425 |
+
* @return void
|
426 |
+
*/
|
427 |
+
function register_post_status() {
|
428 |
+
|
429 |
+
// Register the Disabled post status.
|
430 |
+
register_post_status(
|
431 |
+
'acf-disabled',
|
432 |
+
array(
|
433 |
+
'label' => _x( 'Disabled', 'post status', 'acf' ),
|
434 |
+
'public' => true,
|
435 |
+
'exclude_from_search' => false,
|
436 |
+
'show_in_admin_all_list' => true,
|
437 |
+
'show_in_admin_status_list' => true,
|
438 |
+
'label_count' => _n_noop( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', 'acf' ),
|
439 |
+
)
|
440 |
+
);
|
441 |
}
|
442 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
/**
|
444 |
+
* posts_where
|
445 |
*
|
446 |
+
* Filters the $where clause allowing for custom WP_Query args.
|
|
|
447 |
*
|
448 |
+
* @date 31/8/19
|
449 |
+
* @since 5.8.1
|
450 |
+
*
|
451 |
+
* @param string $where The WHERE clause.
|
452 |
+
* @return WP_Query $wp_query The query object.
|
453 |
*/
|
454 |
+
function posts_where( $where, $wp_query ) {
|
455 |
+
global $wpdb;
|
456 |
+
|
457 |
+
// Add custom "acf_field_key" arg.
|
458 |
+
if ( $field_key = $wp_query->get( 'acf_field_key' ) ) {
|
459 |
+
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $field_key );
|
460 |
+
}
|
461 |
+
|
462 |
+
// Add custom "acf_field_name" arg.
|
463 |
+
if ( $field_name = $wp_query->get( 'acf_field_name' ) ) {
|
464 |
+
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_excerpt = %s", $field_name );
|
465 |
+
}
|
466 |
+
|
467 |
+
// Add custom "acf_group_key" arg.
|
468 |
+
if ( $group_key = $wp_query->get( 'acf_group_key' ) ) {
|
469 |
+
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $group_key );
|
470 |
+
}
|
471 |
+
|
472 |
+
// Return.
|
473 |
+
return $where;
|
474 |
+
}
|
475 |
+
|
|
|
|
|
|
|
476 |
/**
|
477 |
+
* define
|
478 |
*
|
479 |
+
* Defines a constant if doesnt already exist.
|
|
|
480 |
*
|
481 |
+
* @date 3/5/17
|
482 |
+
* @since 5.5.13
|
483 |
+
*
|
484 |
+
* @param string $name The constant name.
|
485 |
+
* @param mixed $value The constant value.
|
486 |
+
* @return void
|
487 |
*/
|
488 |
+
function define( $name, $value = true ) {
|
489 |
+
if ( ! defined( $name ) ) {
|
490 |
+
define( $name, $value );
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
/**
|
495 |
+
* has_setting
|
496 |
+
*
|
497 |
+
* Returns true if a setting exists for this name.
|
498 |
*
|
499 |
+
* @date 2/2/18
|
500 |
+
* @since 5.6.5
|
501 |
*
|
502 |
+
* @param string $name The setting name.
|
503 |
+
* @return boolean
|
504 |
*/
|
505 |
+
function has_setting( $name ) {
|
506 |
+
return isset( $this->settings[ $name ] );
|
507 |
+
}
|
508 |
+
|
509 |
/**
|
510 |
+
* get_setting
|
511 |
+
*
|
512 |
+
* Returns a setting or null if doesn't exist.
|
513 |
*
|
514 |
+
* @date 28/09/13
|
515 |
+
* @since 5.0.0
|
516 |
*
|
517 |
+
* @param string $name The setting name.
|
518 |
+
* @return mixed
|
519 |
*/
|
520 |
+
function get_setting( $name ) {
|
521 |
+
return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
}
|
523 |
+
|
524 |
+
/**
|
525 |
+
* update_setting
|
526 |
+
*
|
527 |
+
* Updates a setting for the given name and value.
|
528 |
+
*
|
529 |
+
* @date 28/09/13
|
530 |
+
* @since 5.0.0
|
531 |
+
*
|
532 |
+
* @param string $name The setting name.
|
533 |
+
* @param mixed $value The setting value.
|
534 |
+
* @return true
|
535 |
+
*/
|
536 |
+
function update_setting( $name, $value ) {
|
537 |
+
$this->settings[ $name ] = $value;
|
538 |
+
return true;
|
539 |
+
}
|
540 |
+
|
541 |
+
/**
|
542 |
+
* get_data
|
543 |
+
*
|
544 |
+
* Returns data or null if doesn't exist.
|
545 |
+
*
|
546 |
+
* @date 28/09/13
|
547 |
+
* @since 5.0.0
|
548 |
+
*
|
549 |
+
* @param string $name The data name.
|
550 |
+
* @return mixed
|
551 |
+
*/
|
552 |
+
function get_data( $name ) {
|
553 |
+
return isset( $this->data[ $name ] ) ? $this->data[ $name ] : null;
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* set_data
|
558 |
+
*
|
559 |
+
* Sets data for the given name and value.
|
560 |
+
*
|
561 |
+
* @date 28/09/13
|
562 |
+
* @since 5.0.0
|
563 |
+
*
|
564 |
+
* @param string $name The data name.
|
565 |
+
* @param mixed $value The data value.
|
566 |
+
* @return void
|
567 |
+
*/
|
568 |
+
function set_data( $name, $value ) {
|
569 |
+
$this->data[ $name ] = $value;
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* get_instance
|
574 |
+
*
|
575 |
+
* Returns an instance or null if doesn't exist.
|
576 |
+
*
|
577 |
+
* @date 13/2/18
|
578 |
+
* @since 5.6.9
|
579 |
+
*
|
580 |
+
* @param string $class The instance class name.
|
581 |
+
* @return object
|
582 |
+
*/
|
583 |
+
function get_instance( $class ) {
|
584 |
+
$name = strtolower( $class );
|
585 |
+
return isset( $this->instances[ $name ] ) ? $this->instances[ $name ] : null;
|
586 |
+
}
|
587 |
+
|
588 |
+
/**
|
589 |
+
* new_instance
|
590 |
+
*
|
591 |
+
* Creates and stores an instance of the given class.
|
592 |
+
*
|
593 |
+
* @date 13/2/18
|
594 |
+
* @since 5.6.9
|
595 |
+
*
|
596 |
+
* @param string $class The instance class name.
|
597 |
+
* @return object
|
598 |
+
*/
|
599 |
+
function new_instance( $class ) {
|
600 |
+
$instance = new $class();
|
601 |
+
$name = strtolower( $class );
|
602 |
+
$this->instances[ $name ] = $instance;
|
603 |
+
return $instance;
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Magic __isset method for backwards compatibility.
|
608 |
+
*
|
609 |
+
* @date 24/4/20
|
610 |
+
* @since 5.9.0
|
611 |
+
*
|
612 |
+
* @param string $key Key name.
|
613 |
+
* @return bool
|
614 |
+
*/
|
615 |
+
public function __isset( $key ) {
|
616 |
+
return in_array( $key, array( 'locations', 'json' ) );
|
617 |
+
}
|
618 |
+
|
619 |
+
/**
|
620 |
+
* Magic __get method for backwards compatibility.
|
621 |
+
*
|
622 |
+
* @date 24/4/20
|
623 |
+
* @since 5.9.0
|
624 |
+
*
|
625 |
+
* @param string $key Key name.
|
626 |
+
* @return mixed
|
627 |
+
*/
|
628 |
+
public function __get( $key ) {
|
629 |
+
switch ( $key ) {
|
630 |
+
case 'locations':
|
631 |
+
return acf_get_instance( 'ACF_Legacy_Locations' );
|
632 |
+
case 'json':
|
633 |
+
return acf_get_instance( 'ACF_Local_JSON' );
|
634 |
+
}
|
635 |
+
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
636 |
}
|
|
|
637 |
}
|
|
|
638 |
|
639 |
+
/*
|
640 |
+
* acf
|
641 |
+
*
|
642 |
+
* The main function responsible for returning the one true acf Instance to functions everywhere.
|
643 |
+
* Use this function like you would a global variable, except without needing to declare the global.
|
644 |
+
*
|
645 |
+
* Example: <?php $acf = acf(); ?>
|
646 |
+
*
|
647 |
+
* @date 4/09/13
|
648 |
+
* @since 4.3.0
|
649 |
+
*
|
650 |
+
* @param void
|
651 |
+
* @return ACF
|
652 |
+
*/
|
653 |
+
function acf() {
|
654 |
+
global $acf;
|
655 |
+
|
656 |
+
// Instantiate only once.
|
657 |
+
if ( ! isset( $acf ) ) {
|
658 |
+
$acf = new ACF();
|
659 |
+
$acf->initialize();
|
660 |
+
}
|
661 |
+
return $acf;
|
662 |
}
|
|
|
|
|
663 |
|
664 |
+
// Instantiate.
|
665 |
+
acf();
|
666 |
|
667 |
endif; // class_exists check
|
assets/build/css/acf-field-group.css
CHANGED
@@ -255,7 +255,6 @@
|
|
255 |
}
|
256 |
.rule-groups .rule-group {
|
257 |
margin: 0 0 5px;
|
258 |
-
/* Don't allow user to delete the first field group */
|
259 |
}
|
260 |
.rule-groups .rule-group h4 {
|
261 |
margin: 0 0 3px;
|
@@ -279,12 +278,13 @@
|
|
279 |
.rule-groups .rule-group tr:hover td.remove a {
|
280 |
visibility: visible;
|
281 |
}
|
282 |
-
.rule-groups .rule-group:first-child tr:first-child td.remove a {
|
283 |
-
visibility: hidden !important;
|
284 |
-
}
|
285 |
.rule-groups .rule-group select:empty {
|
286 |
background: #f8f8f8;
|
287 |
}
|
|
|
|
|
|
|
|
|
288 |
|
289 |
/*---------------------------------------------------------------------------------------------
|
290 |
*
|
255 |
}
|
256 |
.rule-groups .rule-group {
|
257 |
margin: 0 0 5px;
|
|
|
258 |
}
|
259 |
.rule-groups .rule-group h4 {
|
260 |
margin: 0 0 3px;
|
278 |
.rule-groups .rule-group tr:hover td.remove a {
|
279 |
visibility: visible;
|
280 |
}
|
|
|
|
|
|
|
281 |
.rule-groups .rule-group select:empty {
|
282 |
background: #f8f8f8;
|
283 |
}
|
284 |
+
.rule-groups:not(.rule-groups-multiple) .rule-group:first-child tr:first-child td.remove a {
|
285 |
+
/* Don't allow user to delete the only rule group */
|
286 |
+
visibility: hidden !important;
|
287 |
+
}
|
288 |
|
289 |
/*---------------------------------------------------------------------------------------------
|
290 |
*
|
assets/build/css/acf-field-group.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
#acf-field-group-fields>.inside,#acf-field-group-locations>.inside,#acf-field-group-options>.inside{padding:0;margin:0}.postbox .handle-order-higher,.postbox .handle-order-lower{display:none}#minor-publishing-actions,#misc-publishing-actions #visibility,#misc-publishing-actions .edit-timestamp{display:none}#minor-publishing{border-bottom:0 none}#misc-pub-section{border-bottom:0 none}#misc-publishing-actions .misc-pub-section{border-bottom-color:#f5f5f5}#acf-field-group-fields{border:0 none;box-shadow:none}#acf-field-group-fields>.handlediv,#acf-field-group-fields>.hndle,#acf-field-group-fields>.postbox-header{display:none}#acf-field-group-fields a{text-decoration:none}#acf-field-group-fields a:active,#acf-field-group-fields a:focus{outline:0;box-shadow:none}#acf-field-group-fields .li-field-order{width:20%}#acf-field-group-fields .li-field-label{width:30%}#acf-field-group-fields .li-field-name{width:25%}#acf-field-group-fields .li-field-type{width:25%}#acf-field-group-fields .li-field-key{display:none}#acf-field-group-fields.show-field-keys .li-field-key,#acf-field-group-fields.show-field-keys .li-field-label,#acf-field-group-fields.show-field-keys .li-field-name,#acf-field-group-fields.show-field-keys .li-field-type{width:20%}#acf-field-group-fields.show-field-keys .li-field-key{display:block}#acf-field-group-fields .acf-field-list-wrap{border:#ccd0d4 solid 1px}#acf-field-group-fields .acf-field-list{background:#f5f5f5;margin-top:-1px}#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}.acf-admin-3-8 #acf-field-group-fields .acf-field-list-wrap{border-color:#dfdfdf}.acf-field-object{border-top:#eee solid 1px;background:#fff}.acf-field-object.ui-sortable-helper{border-top-color:#fff;box-shadow:0 0 0 1px #dfdfdf,0 1px 4px rgba(0,0,0,.1)}.acf-field-object.ui-sortable-placeholder{box-shadow:0 -1px 0 0 #dfdfdf;visibility:visible!important;background:#f9f9f9;border-top-color:transparent;min-height:54px}.acf-field-object.ui-sortable-placeholder:after,.acf-field-object.ui-sortable-placeholder:before{visibility:hidden}.acf-field-object>.meta{display:none}.acf-field-object>.handle a{-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none}.acf-field-object>.handle li{padding-top:10px;padding-bottom:10px;word-wrap:break-word}.acf-field-object>.handle .acf-icon{margin:1px 0 0;cursor:move;background:0 0;float:left;height:28px;line-height:26px;width:28px;font-size:13px;color:#444;position:relative;z-index:1}.acf-field-object>.handle strong{display:block;padding-bottom:6px;font-size:14px;line-height:14px;min-height:14px}.acf-field-object>.handle .row-options{visibility:hidden}.acf-field-object>.handle .row-options a{margin-right:4px}.acf-field-object>.handle .row-options a.delete-field{color:#a00}.acf-field-object>.handle .row-options a.delete-field:hover{color:red}.acf-field-object.open+.acf-field-object{border-top-color:#e1e1e1}.acf-field-object.open>.handle{background:#2a9bd9;border:#2696d3 solid 1px;text-shadow:#268fbb 0 1px 0;color:#fff;position:relative;margin:-1px -1px 0 -1px}.acf-field-object.open>.handle a{color:#fff!important}.acf-field-object.open>.handle a:hover{text-decoration:underline!important}.acf-field-object.open>.handle .acf-icon{border-color:#fff;color:#fff}.acf-field-object.open>.handle .acf-required{color:#fff}.acf-field-object.-hover>.handle .row-options,.acf-field-object:hover>.handle .row-options{visibility:visible}.acf-field-object>.settings{display:none;width:100%}.acf-field-object>.settings>.acf-table{border:none}.acf-field-object .rule-groups{margin-top:20px}.rule-groups h4{margin:3px 0}.rule-groups .rule-group{margin:0 0 5px}.rule-groups .rule-group h4{margin:0 0 3px}.rule-groups .rule-group td.param{width:35%}.rule-groups .rule-group td.operator{width:20%}.rule-groups .rule-group td.add{width:40px}.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 a{visibility:visible}.rule-groups .rule-group:first-child tr:first-child td.remove a{visibility:hidden!important}
|
1 |
+
#acf-field-group-fields>.inside,#acf-field-group-locations>.inside,#acf-field-group-options>.inside{padding:0;margin:0}.postbox .handle-order-higher,.postbox .handle-order-lower{display:none}#minor-publishing-actions,#misc-publishing-actions #visibility,#misc-publishing-actions .edit-timestamp{display:none}#minor-publishing{border-bottom:0 none}#misc-pub-section{border-bottom:0 none}#misc-publishing-actions .misc-pub-section{border-bottom-color:#f5f5f5}#acf-field-group-fields{border:0 none;box-shadow:none}#acf-field-group-fields>.handlediv,#acf-field-group-fields>.hndle,#acf-field-group-fields>.postbox-header{display:none}#acf-field-group-fields a{text-decoration:none}#acf-field-group-fields a:active,#acf-field-group-fields a:focus{outline:0;box-shadow:none}#acf-field-group-fields .li-field-order{width:20%}#acf-field-group-fields .li-field-label{width:30%}#acf-field-group-fields .li-field-name{width:25%}#acf-field-group-fields .li-field-type{width:25%}#acf-field-group-fields .li-field-key{display:none}#acf-field-group-fields.show-field-keys .li-field-key,#acf-field-group-fields.show-field-keys .li-field-label,#acf-field-group-fields.show-field-keys .li-field-name,#acf-field-group-fields.show-field-keys .li-field-type{width:20%}#acf-field-group-fields.show-field-keys .li-field-key{display:block}#acf-field-group-fields .acf-field-list-wrap{border:#ccd0d4 solid 1px}#acf-field-group-fields .acf-field-list{background:#f5f5f5;margin-top:-1px}#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}.acf-admin-3-8 #acf-field-group-fields .acf-field-list-wrap{border-color:#dfdfdf}.acf-field-object{border-top:#eee solid 1px;background:#fff}.acf-field-object.ui-sortable-helper{border-top-color:#fff;box-shadow:0 0 0 1px #dfdfdf,0 1px 4px rgba(0,0,0,.1)}.acf-field-object.ui-sortable-placeholder{box-shadow:0 -1px 0 0 #dfdfdf;visibility:visible!important;background:#f9f9f9;border-top-color:transparent;min-height:54px}.acf-field-object.ui-sortable-placeholder:after,.acf-field-object.ui-sortable-placeholder:before{visibility:hidden}.acf-field-object>.meta{display:none}.acf-field-object>.handle a{-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none}.acf-field-object>.handle li{padding-top:10px;padding-bottom:10px;word-wrap:break-word}.acf-field-object>.handle .acf-icon{margin:1px 0 0;cursor:move;background:0 0;float:left;height:28px;line-height:26px;width:28px;font-size:13px;color:#444;position:relative;z-index:1}.acf-field-object>.handle strong{display:block;padding-bottom:6px;font-size:14px;line-height:14px;min-height:14px}.acf-field-object>.handle .row-options{visibility:hidden}.acf-field-object>.handle .row-options a{margin-right:4px}.acf-field-object>.handle .row-options a.delete-field{color:#a00}.acf-field-object>.handle .row-options a.delete-field:hover{color:red}.acf-field-object.open+.acf-field-object{border-top-color:#e1e1e1}.acf-field-object.open>.handle{background:#2a9bd9;border:#2696d3 solid 1px;text-shadow:#268fbb 0 1px 0;color:#fff;position:relative;margin:-1px -1px 0 -1px}.acf-field-object.open>.handle a{color:#fff!important}.acf-field-object.open>.handle a:hover{text-decoration:underline!important}.acf-field-object.open>.handle .acf-icon{border-color:#fff;color:#fff}.acf-field-object.open>.handle .acf-required{color:#fff}.acf-field-object.-hover>.handle .row-options,.acf-field-object:hover>.handle .row-options{visibility:visible}.acf-field-object>.settings{display:none;width:100%}.acf-field-object>.settings>.acf-table{border:none}.acf-field-object .rule-groups{margin-top:20px}.rule-groups h4{margin:3px 0}.rule-groups .rule-group{margin:0 0 5px}.rule-groups .rule-group h4{margin:0 0 3px}.rule-groups .rule-group td.param{width:35%}.rule-groups .rule-group td.operator{width:20%}.rule-groups .rule-group td.add{width:40px}.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 a{visibility:visible}.rule-groups .rule-group select:empty{background:#f8f8f8}.rule-groups:not(.rule-groups-multiple) .rule-group:first-child tr:first-child td.remove a{visibility:hidden!important}#acf-field-group-options tr[data-name=hide_on_screen] li{float:left;width:33%}@media (max-width:1100px){#acf-field-group-options tr[data-name=hide_on_screen] li{width:50%}}table.conditional-logic-rules{background:0 0;border:0 none;border-radius:0}table.conditional-logic-rules tbody td{background:0 0;border:0 none!important;padding:5px 2px!important}.acf-field-object-accordion .acf-field-setting-instructions,.acf-field-object-accordion .acf-field-setting-name,.acf-field-object-accordion .acf-field-setting-required,.acf-field-object-accordion .acf-field-setting-warning,.acf-field-object-accordion .acf-field-setting-wrapper,.acf-field-object-tab .acf-field-setting-instructions,.acf-field-object-tab .acf-field-setting-name,.acf-field-object-tab .acf-field-setting-required,.acf-field-object-tab .acf-field-setting-warning,.acf-field-object-tab .acf-field-setting-wrapper{display:none}.acf-field-object-accordion .li-field-name,.acf-field-object-tab .li-field-name{visibility:hidden}.acf-field-object+.acf-field-object-accordion:before,.acf-field-object+.acf-field-object-tab:before{display:block;content:"";height:5px;width:100%;background:#f5f5f5;border-top:#e1e1e1 solid 1px;border-bottom:#e1e1e1 solid 1px;margin-top:-1px}.acf-admin-3-8 .acf-field-object+.acf-field-object-accordion:before,.acf-admin-3-8 .acf-field-object+.acf-field-object-tab:before{border-color:#e5e5e5}.acf-field-object-accordion p:first-child,.acf-field-object-tab p:first-child{margin:.5em 0}.acf-field-object-accordion .acf-field-setting-instructions{display:table-row}.acf-field-object-message tr[data-name=instructions],.acf-field-object-message tr[data-name=name],.acf-field-object-message tr[data-name=required]{display:none!important}.acf-field-object-message .li-field-name{visibility:hidden}.acf-field-object-message textarea{height:175px!important}.acf-field-object-separator tr[data-name=instructions],.acf-field-object-separator tr[data-name=name],.acf-field-object-separator tr[data-name=required]{display:none!important}.acf-field-object-date-picker .acf-radio-list li,.acf-field-object-date-time-picker .acf-radio-list li,.acf-field-object-time-picker .acf-radio-list li{line-height:25px}.acf-field-object-date-picker .acf-radio-list span,.acf-field-object-date-time-picker .acf-radio-list span,.acf-field-object-time-picker .acf-radio-list span{display:inline-block;min-width:10em}.acf-field-object-date-picker .acf-radio-list input[type=text],.acf-field-object-date-time-picker .acf-radio-list input[type=text],.acf-field-object-time-picker .acf-radio-list input[type=text]{width:100px}.acf-field-object-date-time-picker .acf-radio-list span{min-width:15em}.acf-field-object-date-time-picker .acf-radio-list input[type=text]{width:200px}#slugdiv .inside{padding:12px;margin:0}#slugdiv input[type=text]{width:100%;height:28px;font-size:14px}html[dir=rtl] .acf-field-object.open>.handle{margin:-1px -1px 0}html[dir=rtl] .acf-field-object.open>.handle .acf-icon{float:right}html[dir=rtl] .acf-field-object.open>.handle .li-field-order{padding-left:0!important;padding-right:15px!important}@media only screen and (max-width:850px){td.acf-input,td.acf-label,tr.acf-field{display:block!important;width:auto!important;border:0 none!important}tr.acf-field{border-top:#ededed solid 1px!important;margin-bottom:0!important}td.acf-label{background:0 0!important;padding-bottom:0!important}}
|
assets/build/js/acf-field-group.js
CHANGED
@@ -1266,6 +1266,36 @@
|
|
1266 |
acf.registerFieldSetting( TimePickerDisplayFormatFieldSetting );
|
1267 |
acf.registerFieldSetting( TimePickerReturnFormatFieldSetting );
|
1268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1269 |
})(jQuery);
|
1270 |
(function($, undefined){
|
1271 |
|
@@ -2166,6 +2196,7 @@
|
|
2166 |
|
2167 |
initialize: function(){
|
2168 |
this.$el = $('#acf-field-group-locations');
|
|
|
2169 |
},
|
2170 |
|
2171 |
onClickAddRule: function( e, $el ){
|
@@ -2186,6 +2217,7 @@
|
|
2186 |
|
2187 |
addRule: function( $tr ){
|
2188 |
acf.duplicate( $tr );
|
|
|
2189 |
},
|
2190 |
|
2191 |
removeRule: function( $tr ){
|
@@ -2194,6 +2226,13 @@
|
|
2194 |
} else {
|
2195 |
$tr.remove();
|
2196 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2197 |
},
|
2198 |
|
2199 |
changeRule: function( $rule ){
|
@@ -2238,7 +2277,24 @@
|
|
2238 |
|
2239 |
// remove all tr's except the first one
|
2240 |
$group2.find('tr').not(':first').remove();
|
2241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2242 |
});
|
2243 |
|
2244 |
})(jQuery);
|
1266 |
acf.registerFieldSetting( TimePickerDisplayFormatFieldSetting );
|
1267 |
acf.registerFieldSetting( TimePickerReturnFormatFieldSetting );
|
1268 |
|
1269 |
+
/**
|
1270 |
+
* Color Picker Settings.
|
1271 |
+
*
|
1272 |
+
* @date 16/12/20
|
1273 |
+
* @since 5.9.4
|
1274 |
+
*
|
1275 |
+
* @param type $var Description. Default.
|
1276 |
+
* @return type Description.
|
1277 |
+
*/
|
1278 |
+
var ColorPickerReturnFormat = acf.FieldSetting.extend({
|
1279 |
+
type: 'color_picker',
|
1280 |
+
name: 'enable_opacity',
|
1281 |
+
render: function(){
|
1282 |
+
var $return_format_setting = this.fieldObject.$setting('return_format');
|
1283 |
+
var $default_value_setting = this.fieldObject.$setting('default_value');
|
1284 |
+
var $labelText = $return_format_setting.find('input[type="radio"][value="string"]').parent('label').contents().last();
|
1285 |
+
var $defaultPlaceholder = $default_value_setting.find('input[type="text"]');
|
1286 |
+
var l10n = acf.get('colorPickerL10n');
|
1287 |
+
|
1288 |
+
if( this.field.val() ) {
|
1289 |
+
$labelText.replaceWith( l10n.rgba_string );
|
1290 |
+
$defaultPlaceholder.attr('placeholder', 'rgba(255,255,255,0.8)');
|
1291 |
+
} else {
|
1292 |
+
$labelText.replaceWith( l10n.hex_string );
|
1293 |
+
$defaultPlaceholder.attr('placeholder', '#FFFFFF');
|
1294 |
+
}
|
1295 |
+
}
|
1296 |
+
});
|
1297 |
+
acf.registerFieldSetting( ColorPickerReturnFormat );
|
1298 |
+
|
1299 |
})(jQuery);
|
1300 |
(function($, undefined){
|
1301 |
|
2196 |
|
2197 |
initialize: function(){
|
2198 |
this.$el = $('#acf-field-group-locations');
|
2199 |
+
this.updateGroupsClass();
|
2200 |
},
|
2201 |
|
2202 |
onClickAddRule: function( e, $el ){
|
2217 |
|
2218 |
addRule: function( $tr ){
|
2219 |
acf.duplicate( $tr );
|
2220 |
+
this.updateGroupsClass();
|
2221 |
},
|
2222 |
|
2223 |
removeRule: function( $tr ){
|
2226 |
} else {
|
2227 |
$tr.remove();
|
2228 |
}
|
2229 |
+
|
2230 |
+
// Update h4
|
2231 |
+
var $group = this.$('.rule-group:first');
|
2232 |
+
$group.find('h4').text( acf.__('Show this field group if') );
|
2233 |
+
|
2234 |
+
|
2235 |
+
this.updateGroupsClass();
|
2236 |
},
|
2237 |
|
2238 |
changeRule: function( $rule ){
|
2277 |
|
2278 |
// remove all tr's except the first one
|
2279 |
$group2.find('tr').not(':first').remove();
|
2280 |
+
|
2281 |
+
// update the groups class
|
2282 |
+
this.updateGroupsClass();
|
2283 |
+
},
|
2284 |
+
|
2285 |
+
updateGroupsClass: function () {
|
2286 |
+
var $group = this.$(".rule-group:last");
|
2287 |
+
|
2288 |
+
var $ruleGroups = $group.closest(".rule-groups");
|
2289 |
+
|
2290 |
+
var rows_count = $ruleGroups.find(".acf-table tr").length;
|
2291 |
+
|
2292 |
+
if (rows_count > 1) {
|
2293 |
+
$ruleGroups.addClass("rule-groups-multiple");
|
2294 |
+
} else {
|
2295 |
+
$ruleGroups.removeClass("rule-groups-multiple");
|
2296 |
+
}
|
2297 |
+
},
|
2298 |
});
|
2299 |
|
2300 |
})(jQuery);
|
assets/build/js/acf-field-group.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(n){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=n("#titlewrap #title");i.val()||(e.preventDefault(),acf.unlockForm(t),alert(acf.__("Field group title is required")),i.trigger("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}}),new acf.Model({id:"screenOptionsManager",wait:"prepare",events:{change:"onChange"},initialize:function(){var e=n("#adv-settings"),t=n("#acf-append-show-on-screen");e.find(".metabox-prefs").append(t.html()),e.find(".metabox-prefs br").remove(),t.remove(),this.$el=n("#acf-field-key-hide"),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()?n("#acf-field-group-fields").addClass("show-field-keys"):n("#acf-field-group-fields").removeClass("show-field-keys")}}),new acf.Model({actions:{new_field:"onNewField"},onNewField:function(e){var t,i;e.has("append")&&(i=e.get("append"),(t=e.$el.siblings('[data-name="'+i+'"]').first()).length&&((t=(i=t.children(".acf-input")).children("ul")).length||(i.wrapInner('<ul class="acf-hl"><li></li></ul>'),t=i.children("ul")),i=e.$(".acf-input").html(),i=n("<li>"+i+"</li>"),t.append(i),t.attr("data-cols",t.children().length),e.remove()))}})}(jQuery),function(r){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 r("#"+this.getInputId()+"-"+e)},$meta:function(){return this.$(".meta:first")},$handle:function(){return this.$(".handle:first")},$settings:function(){return this.$(".settings:first")},$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+"]");t=r("<input />").attr({id:i,name:n,value:t});return this.$("> .meta").append(t),t},getProp:function(e){if(this.has(e))return this.get(e);var t=this.$input(e),t=t.length?t.val():null;return this.set(e,t,!0),t},setProp:function(e,t){var i=this.$input(e);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(t){Object.keys(t).map(function(e){this.setProp(e,t[e])},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(){this.addProFields()},addProFields:function(){var e;acf.data.fieldTypes.hasOwnProperty("clone")||((e=r(".field-type").not(".acf-free-field-type")).find('optgroup option[value="group"]').parent().append('<option value="null" disabled="disabled">'+acf.__("Repeater (Pro only)")+'</option><option value="null" disabled="disabled">'+acf.__("Flexible Content (Pro only)")+'</option><option value="null" disabled="disabled">'+acf.__("Clone (Pro only)")+"</option>"),e.find('optgroup option[value="image"]').parent().append('<option value="null" disabled="disabled">'+acf.__("Gallery (Pro only)")+"</option>"),e.addClass("acf-free-field-type"))},render:function(){var e=this.$(".handle:first"),t=this.prop("menu_order"),i=this.getLabel(),n=this.prop("name"),a=this.getTypeLabel(),l=this.prop("key"),o=this.$input("required").prop("checked");e.find(".acf-icon").html(parseInt(t)+1),o&&(i+=' <span class="acf-required">*</span>'),e.find(".li-field-label strong a").html(i),e.find(".li-field-name").text(n),e.find(".li-field-type").text(a),e.find(".li-field-key").text(l),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+'"]'):this.$('[name^="'+e+'"]')).remove(),acf.doAction("submit_field_object",this)},onChange:function(e,t){this.save(),acf.doAction("change_field_object",this)},onChanged:function(e,t,i,n){"save"!=i&&(-1<["menu_order","parent"].indexOf(i)?this.save("meta"):this.save(),-1<["menu_order","label","required","name","type","key"].indexOf(i)&&this.render(),acf.doAction("change_field_object_"+i,this,n))},onChangeLabel:function(e,t){t=t.val();this.set("label",t),""==this.prop("name")&&(t=acf.applyFilters("generate_field_object_name",acf.strSanitize(t),this),this.prop("name",t))},onChangeName:function(e,t){t=t.val();this.set("name",t),"field_"===t.substr(0,6)&&alert(acf.__('The string "field_" may not be used at the start of a field name'))},onChangeRequired:function(e,t){t=t.prop("checked")?1:0;this.set("required",t)},delete:function(e){e=acf.parseArgs(e,{animate:!0});var t,i=this.prop("ID");i&&(i=(t=r("#_acf_delete_fields")).val()+"|"+i,t.val(i)),acf.doAction("delete_field_object",this),e.animate?this.removeAnimate():this.remove()},onClickDelete:function(e,t){if(e.shiftKey)return this.delete();this.$el.addClass("-hover");acf.newTooltip({confirmRemove:!0,target:t,context:this,confirm:function(){this.delete()},cancel:function(){this.$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.trigger("focus")},251);var a,l=i.prop("label"),o=i.prop("name"),c=o.split("_").pop(),t=acf.__("copy");acf.isNumeric(c)?(l=l.replace(c,a=+c+1),o=o.replace(c,a)):0===c.indexOf(t)?(a=+c.replace(t,""),l=l.replace(c,t+(a=a?a+1:2)),o=o.replace(c,t+a)):(l+=" ("+t+")",o+="_"+t),i.prop("ID",0),i.prop("label",l),i.prop("name",o),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(){function t(e){return"settings"==e.get("save")}var i,n,a,l,o,c,d=t(this);d||acf.getFieldObjects({parent:this.$el}).map(function(e){d=t(e)||e.changed}),d?alert(acf.__("This field cannot be moved until its changes have been saved")):(i=this.prop("ID"),n=this,a=!1,l=function(e){a.loading(!1),a.content(e),a.on("submit","form",o)},o=function(e,t){e.preventDefault(),acf.startButtonLoading(a.$(".button"));e={action:"acf/field_group/move_field",field_id:i,field_group_id:a.$("select").val()};r.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"html",success:c})},c=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};r.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"html",success:l})}())},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"),n=a.children('[data-setting="'+t+'"]');if(this.set("settings-"+t,n),n.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=r('<tr class="acf-field"><td class="acf-label"></td><td class="acf-input"><div class="acf-loading"></div></td></tr>');this.$setting("conditional_logic").before(o);l={action:"acf/field_group/render_field_settings",field:this.serialize(),prefix:this.getInputName()},l=r.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(l),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",l)},updateParent:function(){var e=acf.get("post_id"),t=this.getParent();t&&(e=parseInt(t.prop("ID"))||t.prop("key")),this.prop("parent",e)}})}(jQuery),function(i){function n(e){return acf.strPascalCase(e||"")+"FieldSetting"}acf.registerFieldSetting=function(e){var t=e.prototype,t=n(t.type+" "+t.name);this.models[t]=e},acf.newFieldSetting=function(e){var t=e.get("setting")||"",i=e.get("name")||"",i=n(t+" "+i),i=acf.models[i]||null;return null!==i&&new i(e)},acf.getFieldSetting=function(e){return(e=e instanceof jQuery?acf.getField(e):e).setting};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),i.extend(this.data,e.data)},initialize:function(){this.render()},render:function(){}});var e=acf.FieldSetting.extend({type:"",name:"",render:function(){var e=this.$('input[type="radio"]:checked');"other"!=e.val()&&this.$('input[type="text"]').val(e.val())}}),t=e.extend({type:"date_picker",name:"display_format"}),a=e.extend({type:"date_picker",name:"return_format"});acf.registerFieldSetting(t),acf.registerFieldSetting(a);t=e.extend({type:"date_time_picker",name:"display_format"}),a=e.extend({type:"date_time_picker",name:"return_format"});acf.registerFieldSetting(t),acf.registerFieldSetting(a);a=e.extend({type:"time_picker",name:"display_format"}),e=e.extend({name:"return_format"});acf.registerFieldSetting(a),acf.registerFieldSetting(e)}(jQuery),function(l){var e=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(l(this))})},renderRule:function(e){this.scope(e),this.renderField(),this.renderOperator(),this.renderValue()},renderField:function(){var i=[],n=this.fieldObject.cid,e=this.$input("field");acf.getFieldObjects().map(function(e){var t={id:e.getKey(),text:e.getLabel()};e.cid===n&&(t.text+=acf.__("(this field)"),t.disabled=!0),acf.getConditionTypes({fieldType:e.getType()}).length||(t.disabled=!0);e=e.getParents().length;t.text="- ".repeat(e)+t.text,i.push(t)}),i.length||i.push({id:"",text:acf.__("No toggle fields available")}),acf.renderSelect(e,i),this.ruleData("field",e.val())},renderOperator:function(){var e,t,i;this.ruleData("field")&&((e=this.$input("operator")).val(),t=[],null===e.val()&&acf.renderSelect(e,[{id:this.ruleData("operator"),text:""}]),i=acf.findFieldObject(this.ruleData("field")),i=acf.getFieldObject(i),acf.getConditionTypes({fieldType:i.getType()}).map(function(e){t.push({id:e.prototype.operator,text:e.prototype.label})}),acf.renderSelect(e,t),this.ruleData("operator",e.val()))},renderValue:function(){var t,e,i,n,a;this.ruleData("field")&&this.ruleData("operator")&&(t=this.$input("value"),e=this.$td("value"),i=t.val(),n=acf.findFieldObject(this.ruleData("field")),n=acf.getFieldObject(n),(n=acf.getConditionTypes({fieldType:n.getType(),operator:this.ruleData("operator")})[0].prototype.choices(n))instanceof Array?(a=l("<select></select>"),acf.renderSelect(a,n)):a=l(n),t.detach(),e.html(a),setTimeout(function(){["class","name","id"].map(function(e){a.attr(e,t.attr(e))})},0),a.prop("disabled")||acf.val(a,i,!0),this.ruleData("value",a.val()))},onChangeToggle:function(){this.render()},onClickAddGroup:function(e,t){this.addGroup()},addGroup:function(){var e=this.$(".rule-group:last"),e=acf.duplicate(e);e.find("h4").text(acf.__("or")),e.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){t=acf.duplicate(t.closest(".rule"));this.renderRule(t)},onClickRemove:function(e,t){t=t.closest(".rule");this.fieldObject.save(),0==t.siblings(".rule").length&&t.closest(".rule-group").remove(),t.remove()}});acf.registerFieldSetting(e);new acf.Model({actions:{duplicate_field_objects:"onDuplicateFieldObjects"},onDuplicateFieldObjects:function(e,t,i){var n={},a=l();e.map(function(e){n[e.get("prevKey")]=e.get("key"),a=a.add(e.$(".condition-rule-field"))}),a.each(function(){var e=l(this),t=e.val();t&&n[t]&&(e.find("option:selected").attr("value",n[t]),e.val(n[t]))})}})}(jQuery),function(l){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})).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):l(t),i=e.limit?i.slice(0,e.limit):i},acf.getFieldObject=function(e){return(e="string"==typeof e?acf.findFieldObject(e):e).data("acf")||acf.newFieldObject(e)},acf.getFieldObjects=function(e){var e=acf.findFieldObjects(e),t=[];return e.each(function(){var e=acf.getFieldObject(l(this));t.push(e)}),t},acf.newFieldObject=function(e){e=new acf.FieldObject(e);return acf.doAction("new_field_object",e),e};new acf.Model({priority:5,initialize:function(){["prepare","ready","append","remove"].map(function(e){this.addFieldActions(e)},this)},addFieldActions:function(e){var n=e+"_field_objects",a=e+"_field_object",l=e+"FieldObject";acf.addAction(e,function(e){var t,i=acf.getFieldObjects({parent:e});i.length&&((t=acf.arrayArgs(arguments)).splice(0,1,n,i),acf.doAction.apply(null,t))},5),acf.addAction(n,function(e){var t=acf.arrayArgs(arguments);t.unshift(a),e.map(function(e){t[1]=e,acf.doAction.apply(null,t)})},5),acf.addAction(a,function(t){var i=acf.arrayArgs(arguments);i.unshift(a);["type","name","key"].map(function(e){i[0]=a+"/"+e+"="+t.get(e),acf.doAction.apply(null,i)}),i.splice(0,2),t.trigger(l,i)},5)}}),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,n){n.hasClass("ui-sortable")||n.sortable({handle:".acf-sortable-handle",connectWith:".acf-field-list",start:function(e,t){var i=acf.getFieldObject(t.item);t.placeholder.height(t.item.height()),acf.doAction("sortstart_field_object",i,n)},update:function(e,t){t=acf.getFieldObject(t.item);acf.doAction("sortstop_field_object",t,n)}})},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});t.length?(e.removeClass("-empty"),t.map(function(e,t){e.prop("menu_order",t)})):e.addClass("-empty")},onClickAdd:function(e,t){t=t.closest(".acf-tfoot").siblings(".acf-field-list");this.addField(t)},addField:function(i){var e=l("#tmpl-acf-field").html(),t=l(e),n=t.data("id"),e=acf.uniqid("field_"),t=acf.duplicate({target:t,search:n,replace:e,append:function(e,t){i.append(t)}}),n=acf.getFieldObject(t);n.prop("key",e),n.prop("ID",0),n.prop("label",""),n.prop("name",""),t.attr("data-key",e),t.attr("data-id",e),n.updateParent();var a=n.$input("label");setTimeout(function(){a.trigger("focus")},251),n.open(),this.renderFields(i),acf.doAction("add_field_object",n),acf.doAction("append_field_object",n)}})}(jQuery),function(a){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=a("#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"):e).remove()},changeRule:function(t){var e=t.closest(".rule-group"),i=t.find("td.param select").attr("name").replace("[param]",""),n={action:"acf/field_group/render_location_rule"};n.rule=acf.serialize(t,i),n.rule.id=t.data("id"),n.rule.group=e.data("id"),acf.disable(t.find("td.value")),a.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(n),type:"post",dataType:"html",success:function(e){e&&t.replaceWith(e)}})},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(l){var e=acf.getCompatibility(acf);e.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)}},e.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),e=this.selector();l(document).on(n,e+" "+a,function(e){e.$el=l(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)}});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);
|
1 |
+
!function(n){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=n("#titlewrap #title");i.val()||(e.preventDefault(),acf.unlockForm(t),alert(acf.__("Field group title is required")),i.trigger("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}}),new acf.Model({id:"screenOptionsManager",wait:"prepare",events:{change:"onChange"},initialize:function(){var e=n("#adv-settings"),t=n("#acf-append-show-on-screen");e.find(".metabox-prefs").append(t.html()),e.find(".metabox-prefs br").remove(),t.remove(),this.$el=n("#acf-field-key-hide"),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()?n("#acf-field-group-fields").addClass("show-field-keys"):n("#acf-field-group-fields").removeClass("show-field-keys")}}),new acf.Model({actions:{new_field:"onNewField"},onNewField:function(e){var t,i;e.has("append")&&(i=e.get("append"),(t=e.$el.siblings('[data-name="'+i+'"]').first()).length&&((t=(i=t.children(".acf-input")).children("ul")).length||(i.wrapInner('<ul class="acf-hl"><li></li></ul>'),t=i.children("ul")),i=e.$(".acf-input").html(),i=n("<li>"+i+"</li>"),t.append(i),t.attr("data-cols",t.children().length),e.remove()))}})}(jQuery),function(r){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 r("#"+this.getInputId()+"-"+e)},$meta:function(){return this.$(".meta:first")},$handle:function(){return this.$(".handle:first")},$settings:function(){return this.$(".settings:first")},$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+"]");t=r("<input />").attr({id:i,name:n,value:t});return this.$("> .meta").append(t),t},getProp:function(e){if(this.has(e))return this.get(e);var t=this.$input(e),t=t.length?t.val():null;return this.set(e,t,!0),t},setProp:function(e,t){var i=this.$input(e);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(t){Object.keys(t).map(function(e){this.setProp(e,t[e])},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(){this.addProFields()},addProFields:function(){var e;acf.data.fieldTypes.hasOwnProperty("clone")||((e=r(".field-type").not(".acf-free-field-type")).find('optgroup option[value="group"]').parent().append('<option value="null" disabled="disabled">'+acf.__("Repeater (Pro only)")+'</option><option value="null" disabled="disabled">'+acf.__("Flexible Content (Pro only)")+'</option><option value="null" disabled="disabled">'+acf.__("Clone (Pro only)")+"</option>"),e.find('optgroup option[value="image"]').parent().append('<option value="null" disabled="disabled">'+acf.__("Gallery (Pro only)")+"</option>"),e.addClass("acf-free-field-type"))},render:function(){var e=this.$(".handle:first"),t=this.prop("menu_order"),i=this.getLabel(),n=this.prop("name"),a=this.getTypeLabel(),l=this.prop("key"),o=this.$input("required").prop("checked");e.find(".acf-icon").html(parseInt(t)+1),o&&(i+=' <span class="acf-required">*</span>'),e.find(".li-field-label strong a").html(i),e.find(".li-field-name").text(n),e.find(".li-field-type").text(a),e.find(".li-field-key").text(l),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+'"]'):this.$('[name^="'+e+'"]')).remove(),acf.doAction("submit_field_object",this)},onChange:function(e,t){this.save(),acf.doAction("change_field_object",this)},onChanged:function(e,t,i,n){"save"!=i&&(-1<["menu_order","parent"].indexOf(i)?this.save("meta"):this.save(),-1<["menu_order","label","required","name","type","key"].indexOf(i)&&this.render(),acf.doAction("change_field_object_"+i,this,n))},onChangeLabel:function(e,t){t=t.val();this.set("label",t),""==this.prop("name")&&(t=acf.applyFilters("generate_field_object_name",acf.strSanitize(t),this),this.prop("name",t))},onChangeName:function(e,t){t=t.val();this.set("name",t),"field_"===t.substr(0,6)&&alert(acf.__('The string "field_" may not be used at the start of a field name'))},onChangeRequired:function(e,t){t=t.prop("checked")?1:0;this.set("required",t)},delete:function(e){e=acf.parseArgs(e,{animate:!0});var t,i=this.prop("ID");i&&(i=(t=r("#_acf_delete_fields")).val()+"|"+i,t.val(i)),acf.doAction("delete_field_object",this),e.animate?this.removeAnimate():this.remove()},onClickDelete:function(e,t){if(e.shiftKey)return this.delete();this.$el.addClass("-hover");acf.newTooltip({confirmRemove:!0,target:t,context:this,confirm:function(){this.delete()},cancel:function(){this.$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.trigger("focus")},251);var a,l=i.prop("label"),o=i.prop("name"),c=o.split("_").pop(),t=acf.__("copy");acf.isNumeric(c)?(l=l.replace(c,a=+c+1),o=o.replace(c,a)):0===c.indexOf(t)?(a=+c.replace(t,""),l=l.replace(c,t+(a=a?a+1:2)),o=o.replace(c,t+a)):(l+=" ("+t+")",o+="_"+t),i.prop("ID",0),i.prop("label",l),i.prop("name",o),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(){function t(e){return"settings"==e.get("save")}var i,n,a,l,o,c,d=t(this);d||acf.getFieldObjects({parent:this.$el}).map(function(e){d=t(e)||e.changed}),d?alert(acf.__("This field cannot be moved until its changes have been saved")):(i=this.prop("ID"),n=this,a=!1,l=function(e){a.loading(!1),a.content(e),a.on("submit","form",o)},o=function(e,t){e.preventDefault(),acf.startButtonLoading(a.$(".button"));e={action:"acf/field_group/move_field",field_id:i,field_group_id:a.$("select").val()};r.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"html",success:c})},c=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};r.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"html",success:l})}())},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"),n=a.children('[data-setting="'+t+'"]');if(this.set("settings-"+t,n),n.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=r('<tr class="acf-field"><td class="acf-label"></td><td class="acf-input"><div class="acf-loading"></div></td></tr>');this.$setting("conditional_logic").before(o);l={action:"acf/field_group/render_field_settings",field:this.serialize(),prefix:this.getInputName()},l=r.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(l),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",l)},updateParent:function(){var e=acf.get("post_id"),t=this.getParent();t&&(e=parseInt(t.prop("ID"))||t.prop("key")),this.prop("parent",e)}})}(jQuery),function(i){function n(e){return acf.strPascalCase(e||"")+"FieldSetting"}acf.registerFieldSetting=function(e){var t=e.prototype,t=n(t.type+" "+t.name);this.models[t]=e},acf.newFieldSetting=function(e){var t=e.get("setting")||"",i=e.get("name")||"",i=n(t+" "+i),i=acf.models[i]||null;return null!==i&&new i(e)},acf.getFieldSetting=function(e){return(e=e instanceof jQuery?acf.getField(e):e).setting};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),i.extend(this.data,e.data)},initialize:function(){this.render()},render:function(){}});var e=acf.FieldSetting.extend({type:"",name:"",render:function(){var e=this.$('input[type="radio"]:checked');"other"!=e.val()&&this.$('input[type="text"]').val(e.val())}}),t=e.extend({type:"date_picker",name:"display_format"}),a=e.extend({type:"date_picker",name:"return_format"});acf.registerFieldSetting(t),acf.registerFieldSetting(a);t=e.extend({type:"date_time_picker",name:"display_format"}),a=e.extend({type:"date_time_picker",name:"return_format"});acf.registerFieldSetting(t),acf.registerFieldSetting(a);a=e.extend({type:"time_picker",name:"display_format"}),e=e.extend({name:"return_format"});acf.registerFieldSetting(a),acf.registerFieldSetting(e);e=acf.FieldSetting.extend({type:"color_picker",name:"enable_opacity",render:function(){var e=this.fieldObject.$setting("return_format"),t=this.fieldObject.$setting("default_value"),i=e.find('input[type="radio"][value="string"]').parent("label").contents().last(),e=t.find('input[type="text"]'),t=acf.get("colorPickerL10n");this.field.val()?(i.replaceWith(t.rgba_string),e.attr("placeholder","rgba(255,255,255,0.8)")):(i.replaceWith(t.hex_string),e.attr("placeholder","#FFFFFF"))}});acf.registerFieldSetting(e)}(jQuery),function(l){var e=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(l(this))})},renderRule:function(e){this.scope(e),this.renderField(),this.renderOperator(),this.renderValue()},renderField:function(){var i=[],n=this.fieldObject.cid,e=this.$input("field");acf.getFieldObjects().map(function(e){var t={id:e.getKey(),text:e.getLabel()};e.cid===n&&(t.text+=acf.__("(this field)"),t.disabled=!0),acf.getConditionTypes({fieldType:e.getType()}).length||(t.disabled=!0);e=e.getParents().length;t.text="- ".repeat(e)+t.text,i.push(t)}),i.length||i.push({id:"",text:acf.__("No toggle fields available")}),acf.renderSelect(e,i),this.ruleData("field",e.val())},renderOperator:function(){var e,t,i;this.ruleData("field")&&((e=this.$input("operator")).val(),t=[],null===e.val()&&acf.renderSelect(e,[{id:this.ruleData("operator"),text:""}]),i=acf.findFieldObject(this.ruleData("field")),i=acf.getFieldObject(i),acf.getConditionTypes({fieldType:i.getType()}).map(function(e){t.push({id:e.prototype.operator,text:e.prototype.label})}),acf.renderSelect(e,t),this.ruleData("operator",e.val()))},renderValue:function(){var t,e,i,n,a;this.ruleData("field")&&this.ruleData("operator")&&(t=this.$input("value"),e=this.$td("value"),i=t.val(),n=acf.findFieldObject(this.ruleData("field")),n=acf.getFieldObject(n),(n=acf.getConditionTypes({fieldType:n.getType(),operator:this.ruleData("operator")})[0].prototype.choices(n))instanceof Array?(a=l("<select></select>"),acf.renderSelect(a,n)):a=l(n),t.detach(),e.html(a),setTimeout(function(){["class","name","id"].map(function(e){a.attr(e,t.attr(e))})},0),a.prop("disabled")||acf.val(a,i,!0),this.ruleData("value",a.val()))},onChangeToggle:function(){this.render()},onClickAddGroup:function(e,t){this.addGroup()},addGroup:function(){var e=this.$(".rule-group:last"),e=acf.duplicate(e);e.find("h4").text(acf.__("or")),e.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){t=acf.duplicate(t.closest(".rule"));this.renderRule(t)},onClickRemove:function(e,t){t=t.closest(".rule");this.fieldObject.save(),0==t.siblings(".rule").length&&t.closest(".rule-group").remove(),t.remove()}});acf.registerFieldSetting(e);new acf.Model({actions:{duplicate_field_objects:"onDuplicateFieldObjects"},onDuplicateFieldObjects:function(e,t,i){var n={},a=l();e.map(function(e){n[e.get("prevKey")]=e.get("key"),a=a.add(e.$(".condition-rule-field"))}),a.each(function(){var e=l(this),t=e.val();t&&n[t]&&(e.find("option:selected").attr("value",n[t]),e.val(n[t]))})}})}(jQuery),function(l){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})).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):l(t),i=e.limit?i.slice(0,e.limit):i},acf.getFieldObject=function(e){return(e="string"==typeof e?acf.findFieldObject(e):e).data("acf")||acf.newFieldObject(e)},acf.getFieldObjects=function(e){var e=acf.findFieldObjects(e),t=[];return e.each(function(){var e=acf.getFieldObject(l(this));t.push(e)}),t},acf.newFieldObject=function(e){e=new acf.FieldObject(e);return acf.doAction("new_field_object",e),e};new acf.Model({priority:5,initialize:function(){["prepare","ready","append","remove"].map(function(e){this.addFieldActions(e)},this)},addFieldActions:function(e){var n=e+"_field_objects",a=e+"_field_object",l=e+"FieldObject";acf.addAction(e,function(e){var t,i=acf.getFieldObjects({parent:e});i.length&&((t=acf.arrayArgs(arguments)).splice(0,1,n,i),acf.doAction.apply(null,t))},5),acf.addAction(n,function(e){var t=acf.arrayArgs(arguments);t.unshift(a),e.map(function(e){t[1]=e,acf.doAction.apply(null,t)})},5),acf.addAction(a,function(t){var i=acf.arrayArgs(arguments);i.unshift(a);["type","name","key"].map(function(e){i[0]=a+"/"+e+"="+t.get(e),acf.doAction.apply(null,i)}),i.splice(0,2),t.trigger(l,i)},5)}}),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,n){n.hasClass("ui-sortable")||n.sortable({handle:".acf-sortable-handle",connectWith:".acf-field-list",start:function(e,t){var i=acf.getFieldObject(t.item);t.placeholder.height(t.item.height()),acf.doAction("sortstart_field_object",i,n)},update:function(e,t){t=acf.getFieldObject(t.item);acf.doAction("sortstop_field_object",t,n)}})},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});t.length?(e.removeClass("-empty"),t.map(function(e,t){e.prop("menu_order",t)})):e.addClass("-empty")},onClickAdd:function(e,t){t=t.closest(".acf-tfoot").siblings(".acf-field-list");this.addField(t)},addField:function(i){var e=l("#tmpl-acf-field").html(),t=l(e),n=t.data("id"),e=acf.uniqid("field_"),t=acf.duplicate({target:t,search:n,replace:e,append:function(e,t){i.append(t)}}),n=acf.getFieldObject(t);n.prop("key",e),n.prop("ID",0),n.prop("label",""),n.prop("name",""),t.attr("data-key",e),t.attr("data-id",e),n.updateParent();var a=n.$input("label");setTimeout(function(){a.trigger("focus")},251),n.open(),this.renderFields(i),acf.doAction("add_field_object",n),acf.doAction("append_field_object",n)}})}(jQuery),function(a){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=a("#acf-field-group-locations"),this.updateGroupsClass()},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),this.updateGroupsClass()},removeRule:function(e){(0==e.siblings("tr").length?e.closest(".rule-group"):e).remove(),this.$(".rule-group:first").find("h4").text(acf.__("Show this field group if")),this.updateGroupsClass()},changeRule:function(t){var e=t.closest(".rule-group"),i=t.find("td.param select").attr("name").replace("[param]",""),n={action:"acf/field_group/render_location_rule"};n.rule=acf.serialize(t,i),n.rule.id=t.data("id"),n.rule.group=e.data("id"),acf.disable(t.find("td.value")),a.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(n),type:"post",dataType:"html",success:function(e){e&&t.replaceWith(e)}})},addGroup:function(){var e=this.$(".rule-group:last");$group2=acf.duplicate(e),$group2.find("h4").text(acf.__("or")),$group2.find("tr").not(":first").remove(),this.updateGroupsClass()},updateGroupsClass:function(){var e=this.$(".rule-group:last").closest(".rule-groups");1<e.find(".acf-table tr").length?e.addClass("rule-groups-multiple"):e.removeClass("rule-groups-multiple")}})}(jQuery),function(l){var e=acf.getCompatibility(acf);e.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)}},e.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),e=this.selector();l(document).on(n,e+" "+a,function(e){e.$el=l(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)}});new acf.Model({actions:{open_field_object:"onOpenFieldObject",close_field_object:"onCloseFieldObject",add_field_object:"onAddFieldObject",duplicate_field_object:"onDuplicateFieldObject",delete_field_object:"onDeleteFieldObject",change_field_object_type:"onChangeFieldObjectType",change_field_object_label:"onChangeFieldObjectLabel",change_field_object_name:"onChangeFieldObjectName",change_field_object_parent:"onChangeFieldObjectParent",sortstop_field_object:"onChangeFieldObjectParent"},onOpenFieldObject:function(e){acf.doAction("open_field",e.$el),acf.doAction("open_field/type="+e.get("type"),e.$el),acf.doAction("render_field_settings",e.$el),acf.doAction("render_field_settings/type="+e.get("type"),e.$el)},onCloseFieldObject:function(e){acf.doAction("close_field",e.$el),acf.doAction("close_field/type="+e.get("type"),e.$el)},onAddFieldObject:function(e){acf.doAction("add_field",e.$el),acf.doAction("add_field/type="+e.get("type"),e.$el)},onDuplicateFieldObject:function(e){acf.doAction("duplicate_field",e.$el),acf.doAction("duplicate_field/type="+e.get("type"),e.$el)},onDeleteFieldObject:function(e){acf.doAction("delete_field",e.$el),acf.doAction("delete_field/type="+e.get("type"),e.$el)},onChangeFieldObjectType:function(e){acf.doAction("change_field_type",e.$el),acf.doAction("change_field_type/type="+e.get("type"),e.$el),acf.doAction("render_field_settings",e.$el),acf.doAction("render_field_settings/type="+e.get("type"),e.$el)},onChangeFieldObjectLabel:function(e){acf.doAction("change_field_label",e.$el),acf.doAction("change_field_label/type="+e.get("type"),e.$el)},onChangeFieldObjectName:function(e){acf.doAction("change_field_name",e.$el),acf.doAction("change_field_name/type="+e.get("type"),e.$el)},onChangeFieldObjectParent:function(e){acf.doAction("update_field_parent",e.$el)}})}(jQuery);
|
assets/build/js/acf-input.js
CHANGED
@@ -7729,9 +7729,12 @@
|
|
7729 |
placeholder: this.get('placeholder'),
|
7730 |
multiple: this.get('multiple'),
|
7731 |
data: [],
|
7732 |
-
|
7733 |
-
|
7734 |
-
|
|
|
|
|
|
|
7735 |
};
|
7736 |
|
7737 |
// multiple
|
@@ -7789,7 +7792,7 @@
|
|
7789 |
$ul.find('.select2-selection__choice').each(function() {
|
7790 |
|
7791 |
// vars
|
7792 |
-
var $option = $( $(this).
|
7793 |
|
7794 |
// detach and re-append to end
|
7795 |
$option.detach().appendTo( $select );
|
@@ -9656,7 +9659,7 @@
|
|
9656 |
var lastPostStatus = '';
|
9657 |
wp.data.subscribe(function() {
|
9658 |
var postStatus = editorSelect.getEditedPostAttribute( 'status' );
|
9659 |
-
useValidation = ( postStatus === 'publish' );
|
9660 |
lastPostStatus = ( postStatus !== 'publish' ) ? postStatus : lastPostStatus;
|
9661 |
});
|
9662 |
|
@@ -9676,7 +9679,7 @@
|
|
9676 |
return resolve( 'Validation ignored (autosave).' );
|
9677 |
}
|
9678 |
|
9679 |
-
// Bail early if validation is not
|
9680 |
if( !useValidation ) {
|
9681 |
return resolve( 'Validation ignored (draft).' );
|
9682 |
}
|
@@ -9728,6 +9731,8 @@
|
|
9728 |
}
|
9729 |
}).then(function(){
|
9730 |
return savePost.apply(_this, _args);
|
|
|
|
|
9731 |
});
|
9732 |
};
|
9733 |
}
|
7729 |
placeholder: this.get('placeholder'),
|
7730 |
multiple: this.get('multiple'),
|
7731 |
data: [],
|
7732 |
+
templateSelection: function( selection ){
|
7733 |
+
var $selection = $('<span class="acf-selection"></span>');
|
7734 |
+
$selection.text( acf.escHtml( selection.text ) );
|
7735 |
+
$selection.data('element', selection.element);
|
7736 |
+
return $selection;
|
7737 |
+
}
|
7738 |
};
|
7739 |
|
7740 |
// multiple
|
7792 |
$ul.find('.select2-selection__choice').each(function() {
|
7793 |
|
7794 |
// vars
|
7795 |
+
var $option = $( $(this).children('span.acf-selection').data('element') );
|
7796 |
|
7797 |
// detach and re-append to end
|
7798 |
$option.detach().appendTo( $select );
|
9659 |
var lastPostStatus = '';
|
9660 |
wp.data.subscribe(function() {
|
9661 |
var postStatus = editorSelect.getEditedPostAttribute( 'status' );
|
9662 |
+
useValidation = ( postStatus === 'publish' || postStatus === 'future' );
|
9663 |
lastPostStatus = ( postStatus !== 'publish' ) ? postStatus : lastPostStatus;
|
9664 |
});
|
9665 |
|
9679 |
return resolve( 'Validation ignored (autosave).' );
|
9680 |
}
|
9681 |
|
9682 |
+
// Bail early if validation is not needed.
|
9683 |
if( !useValidation ) {
|
9684 |
return resolve( 'Validation ignored (draft).' );
|
9685 |
}
|
9731 |
}
|
9732 |
}).then(function(){
|
9733 |
return savePost.apply(_this, _args);
|
9734 |
+
}).catch(function(err){
|
9735 |
+
// Nothing to do here, user is alerted of validation issues.
|
9736 |
});
|
9737 |
};
|
9738 |
}
|
assets/build/js/acf-input.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,i){var a=[];acf.Field=acf.Model.extend({type:"",eventScope:".acf-field",wait:"ready",setup:function(t){this.$el=t,this.inherit(t),this.inherit(this.$control())},val:function(t){return t!==i?this.setValue(t):this.prop("disabled")?null:this.getValue()},getValue:function(){return this.$input().val()},setValue:function(t){return acf.val(this.$input(),t)},__:function(t){return acf._e(this.type,t)},$control:function(){return!1},$input:function(){return this.$("[name]:first")},$inputWrap:function(){return this.$(".acf-input:first")},$labelWrap:function(){return this.$(".acf-label:first")},getInputName:function(){return this.$input().attr("name")||""},parent:function(){var t=this.parents();return!!t.length&&t[0]},parents:function(){var t=this.$el.parents(".acf-field");return acf.getFields(t)},show:function(t,e){t=acf.show(this.$el,t);return t&&(this.prop("hidden",!1),acf.doAction("show_field",this,e)),t},hide:function(t,e){t=acf.hide(this.$el,t);return t&&(this.prop("hidden",!0),acf.doAction("hide_field",this,e)),t},enable:function(t,e){t=acf.enable(this.$el,t);return t&&(this.prop("disabled",!1),acf.doAction("enable_field",this,e)),t},disable:function(t,e){t=acf.disable(this.$el,t);return t&&(this.prop("disabled",!0),acf.doAction("disable_field",this,e)),t},showEnable:function(t,e){return this.enable.apply(this,arguments),this.show.apply(this,arguments)},hideDisable:function(t,e){return this.disable.apply(this,arguments),this.hide.apply(this,arguments)},showNotice:function(t){"object"!=typeof t&&(t={text:t}),this.notice&&this.notice.remove(),t.target=this.$inputWrap(),this.notice=acf.newNotice(t)},removeNotice:function(t){this.notice&&(this.notice.away(t||0),this.notice=!1)},showError:function(t){this.$el.addClass("acf-error"),t!==i&&this.showNotice({text:t,type:"error",dismiss:!1}),acf.doAction("invalid_field",this),this.$el.one("focus change","input, select, textarea",e.proxy(this.removeError,this))},removeError:function(){this.$el.removeClass("acf-error"),this.removeNotice(250),acf.doAction("valid_field",this)},trigger:function(t,e,i){return"invalidField"==t&&(i=!0),acf.Model.prototype.trigger.apply(this,[t,e,i])}}),acf.newField=function(t){var e=t.data("type"),e=n(e),t=new(acf.models[e]||acf.Field)(t);return acf.doAction("new_field",t),t};var n=function(t){return acf.strPascalCase(t||"")+"Field"};acf.registerFieldType=function(t){var e=t.prototype.type,i=n(e);acf.models[i]=t,a.push(e)},acf.getFieldType=function(t){t=n(t);return acf.models[t]||!1},acf.getFieldTypes=function(i){i=acf.parseArgs(i,{category:""});var n=[];return a.map(function(t){var e=acf.getFieldType(t),t=e.prototype;i.category&&t.category!==i.category||n.push(e)}),n}}(jQuery),function(n){acf.findFields=function(t){var e=".acf-field",i=!1;return(t=!(t=acf.parseArgs(t,{key:"",name:"",type:"",is:"",parent:!1,sibling:!1,limit:!1,visible:!1,suppressFilters:!1})).suppressFilters?acf.applyFilters("find_fields_args",t):t).key&&(e+='[data-key="'+t.key+'"]'),t.type&&(e+='[data-type="'+t.type+'"]'),t.name&&(e+='[data-name="'+t.name+'"]'),t.is&&(e+=t.is),t.visible&&(e+=":visible"),i=t.parent?t.parent.find(e):t.sibling?t.sibling.siblings(e):n(e),t.suppressFilters||(i=i.not(".acf-clone .acf-field"),i=acf.applyFilters("find_fields",i)),i=t.limit?i.slice(0,t.limit):i},acf.findField=function(t,e){return acf.findFields({key:t,limit:1,parent:e,suppressFilters:!0})},acf.getField=function(t){return(t=!(t instanceof jQuery)?acf.findField(t):t).data("acf")||acf.newField(t)},acf.getFields=function(t){t instanceof jQuery||(t=acf.findFields(t));var e=[];return t.each(function(){var t=acf.getField(n(this));e.push(t)}),e},acf.findClosestField=function(t){return t.closest(".acf-field")},acf.getClosestField=function(t){t=acf.findClosestField(t);return this.getField(t)};var e=function(t){var a=t+"_field",s=t+"Field";acf.addAction(a,function(e){var i=acf.arrayArgs(arguments),n=i.slice(1);["type","name","key"].map(function(t){t="/"+t+"="+e.get(t);i=[a+t,e].concat(n),acf.doAction.apply(null,i)}),-1<o.indexOf(t)&&e.trigger(s,n)})},o=["remove","unmount","remount","sortstart","sortstop","show","hide","unload","valid","invalid","enable","disable","duplicate"];["prepare","ready","load","append","remove","unmount","remount","sortstart","sortstop","show","hide","unload"].map(function(t){var n=t+"_fields",a=t+"_field";acf.addAction(t,function(t){var e=acf.arrayArgs(arguments).slice(1),i=acf.getFields({parent:t});i.length&&(e=[n,i].concat(e),acf.doAction.apply(null,e))}),acf.addAction(n,function(t){var i=acf.arrayArgs(arguments).slice(1);t.map(function(t,e){t=[a,t].concat(i);acf.doAction.apply(null,t)})}),e(t)}),["valid","invalid","enable","disable","new","duplicate"].map(e);new acf.Model({id:"fieldsEventManager",events:{'click .acf-field a[href="#"]':"onClick","change .acf-field":"onChange"},onClick:function(t){t.preventDefault()},onChange:function(){n("#_acf_changed").val(1)}}),new acf.Model({id:"duplicateFieldsManager",actions:{duplicate:"onDuplicate",duplicate_fields:"onDuplicateFields"},onDuplicate:function(t,e){t=acf.getFields({parent:t});t.length&&(e=acf.findFields({parent:e}),acf.doAction("duplicate_fields",t,e))},onDuplicateFields:function(t,i){t.map(function(t,e){acf.doAction("duplicate_field",t,n(i[e]))})}})}(jQuery),function(c){var l=0,t=acf.Field.extend({type:"accordion",wait:"",$control:function(){return this.$(".acf-fields:first")},initialize:function(){if(!this.$el.hasClass("acf-accordion")&&!this.$el.is("td")){if(this.get("endpoint"))return this.remove();var t,e,i=this.$el,n=this.$labelWrap(),a=this.$inputWrap(),s=this.$control(),o=a.children(".description");o.length&&n.append(o),this.$el.is("tr")&&(r=this.$el.closest("table"),t=c('<div class="acf-accordion-title"/>'),e=c('<div class="acf-accordion-content"/>'),o=c('<table class="'+r.attr("class")+'"/>'),r=c("<tbody/>"),t.append(n.html()),o.append(r),e.append(o),a.append(t),a.append(e),n.remove(),s.remove(),a.attr("colspan",2),n=t,a=e,s=r),i.addClass("acf-accordion"),n.addClass("acf-accordion-title"),a.addClass("acf-accordion-content"),l++,this.get("multi_expand")&&i.attr("multi-expand",1);var r=acf.getPreference("this.accordions")||[];void 0!==r[l-1]&&this.set("open",r[l-1]),this.get("open")&&(i.addClass("-open"),a.css("display","block")),n.prepend(d.iconHtml({open:this.get("open")}));n=i.parent();s.addClass(n.hasClass("-left")?"-left":""),s.addClass(n.hasClass("-clear")?"-clear":""),s.append(i.nextUntil(".acf-field-accordion",".acf-field")),s.removeAttr("data-open data-multi_expand data-endpoint")}}});acf.registerFieldType(t);var d=new acf.Model({actions:{unload:"onUnload"},events:{"click .acf-accordion-title":"onClick","invalidField .acf-accordion":"onInvalidField"},isOpen:function(t){return t.hasClass("-open")},toggle:function(t){this.isOpen(t)?this.close(t):this.open(t)},iconHtml:function(t){return acf.isGutenberg()?t.open?'<svg class="acf-accordion-icon" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" focusable="false"><g><path fill="none" d="M0,0h24v24H0V0z"></path></g><g><path d="M12,8l-6,6l1.41,1.41L12,10.83l4.59,4.58L18,14L12,8z"></path></g></svg>':'<svg class="acf-accordion-icon" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" focusable="false"><g><path fill="none" d="M0,0h24v24H0V0z"></path></g><g><path d="M7.41,8.59L12,13.17l4.59-4.58L18,10l-6,6l-6-6L7.41,8.59z"></path></g></svg>':t.open?'<i class="acf-accordion-icon dashicons dashicons-arrow-down"></i>':'<i class="acf-accordion-icon dashicons dashicons-arrow-right"></i>'},open:function(t){var e=acf.isGutenberg()?0:300;t.find(".acf-accordion-content:first").slideDown(e).css("display","block"),t.find(".acf-accordion-icon:first").replaceWith(this.iconHtml({open:!0})),t.addClass("-open"),acf.doAction("show",t),t.attr("multi-expand")||t.siblings(".acf-accordion.-open").each(function(){d.close(c(this))})},close:function(t){var e=acf.isGutenberg()?0:300;t.find(".acf-accordion-content:first").slideUp(e),t.find(".acf-accordion-icon:first").replaceWith(this.iconHtml({open:!1})),t.removeClass("-open"),acf.doAction("hide",t)},onClick:function(t,e){t.preventDefault(),this.toggle(e.parent())},onInvalidField:function(t,e){this.busy||(this.busy=!0,this.setTimeout(function(){this.busy=!1},1e3),this.open(e))},onUnload:function(t){var e=[];c(".acf-accordion").each(function(){var t=c(this).hasClass("-open")?1:0;e.push(t)}),e.length&&acf.setPreference("this.accordions",e)}})}(jQuery),function(){var t=acf.Field.extend({type:"button_group",events:{'click input[type="radio"]':"onClick"},$control:function(){return this.$(".acf-button-group")},$input:function(){return this.$("input:checked")},setValue:function(t){this.$('input[value="'+t+'"]').prop("checked",!0).trigger("change")},onClick:function(t,e){var i=e.parent("label"),n=i.hasClass("selected");this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"))}});acf.registerFieldType(t)}(jQuery),function(e){var t=acf.Field.extend({type:"checkbox",events:{"change input":"onChange","click .acf-add-checkbox":"onClickAdd","click .acf-checkbox-toggle":"onClickToggle","click .acf-checkbox-custom":"onClickCustom"},$control:function(){return this.$(".acf-checkbox-list")},$toggle:function(){return this.$(".acf-checkbox-toggle")},$input:function(){return this.$('input[type="hidden"]')},$inputs:function(){return this.$('input[type="checkbox"]').not(".acf-checkbox-toggle")},getValue:function(){var t=[];return this.$(":checked").each(function(){t.push(e(this).val())}),!!t.length&&t},onChange:function(t,e){var i=e.prop("checked"),n=e.parent("label"),e=this.$toggle();i?n.addClass("selected"):n.removeClass("selected"),e.length&&(0==this.$inputs().not(":checked").length?e.prop("checked",!0):e.prop("checked",!1))},onClickAdd:function(t,e){var i='<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input type="text" name="'+this.getInputName()+'[]" /></li>';e.parent("li").before(i)},onClickToggle:function(t,e){var i=e.prop("checked"),n=this.$('input[type="checkbox"]'),e=this.$("label");n.prop("checked",i),i?e.addClass("selected"):e.removeClass("selected")},onClickCustom:function(t,e){var i=e.prop("checked"),n=e.next('input[type="text"]');i?n.prop("disabled",!1):(n.prop("disabled",!0),""==n.val()&&e.parent("li").remove())}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"color_picker",wait:"load",events:{duplicateField:"onDuplicate"},$control:function(){return this.$(".acf-color-picker")},$input:function(){return this.$('input[type="hidden"]')},$inputText:function(){return this.$('input[type="text"]')},setValue:function(t){acf.val(this.$input(),t),this.$inputText().iris("color",t)},initialize:function(){var e=this.$input(),i=this.$inputText(),t=function(t){setTimeout(function(){acf.val(e,i.val())},1)},t={defaultColor:!1,palettes:!0,hide:!0,change:t,clear:t},t=acf.applyFilters("color_picker_args",t,this);i.wpColorPicker(t)},onDuplicate:function(t,e,i){$colorPicker=i.find(".wp-picker-container"),$inputText=i.find('input[type="text"]'),$colorPicker.replaceWith($inputText)}});acf.registerFieldType(t)}(jQuery),function(n){var t=acf.Field.extend({type:"date_picker",events:{'blur input[type="text"]':"onBlur",duplicateField:"onDuplicate"},$control:function(){return this.$(".acf-date-picker")},$input:function(){return this.$('input[type="hidden"]')},$inputText:function(){return this.$('input[type="text"]')},initialize:function(){if(this.has("save_format"))return this.initializeCompatibility();var t=this.$input(),e=this.$inputText(),t={dateFormat:this.get("date_format"),altField:t,altFormat:"yymmdd",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day")},t=acf.applyFilters("date_picker_args",t,this);acf.newDatePicker(e,t),acf.doAction("date_picker_init",e,t,this)},initializeCompatibility:function(){var t=this.$input(),e=this.$inputText();e.val(t.val());var i={dateFormat:this.get("date_format"),altField:t,altFormat:this.get("save_format"),changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day")},t=(i=acf.applyFilters("date_picker_args",i,this)).dateFormat;i.dateFormat=this.get("save_format"),acf.newDatePicker(e,i),e.datepicker("option","dateFormat",t),acf.doAction("date_picker_init",e,i,this)},onBlur:function(){this.$inputText().val()||acf.val(this.$input(),"")},onDuplicate:function(t,e,i){i.find('input[type="text"]').removeClass("hasDatepicker").removeAttr("id")}});acf.registerFieldType(t);new acf.Model({priority:5,wait:"ready",initialize:function(){var t=acf.get("locale"),e=acf.get("rtl"),i=acf.get("datePickerL10n");return!!i&&(void 0!==n.datepicker&&(i.isRTL=e,n.datepicker.regional[t]=i,void n.datepicker.setDefaults(i)))}});acf.newDatePicker=function(t,e){if(void 0===n.datepicker)return!1;t.datepicker(e=e||{}),n("body > #ui-datepicker-div").exists()&&n("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function(n){var t=acf.models.DatePickerField.extend({type:"date_time_picker",$control:function(){return this.$(".acf-date-time-picker")},initialize:function(){var t=this.$input(),e=this.$inputText(),t={dateFormat:this.get("date_format"),timeFormat:this.get("time_format"),altField:t,altFieldTimeOnly:!1,altFormat:"yy-mm-dd",altTimeFormat:"HH:mm:ss",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day"),controlType:"select",oneLine:!0},t=acf.applyFilters("date_time_picker_args",t,this);acf.newDateTimePicker(e,t),acf.doAction("date_time_picker_init",e,t,this)}});acf.registerFieldType(t);new acf.Model({priority:5,wait:"ready",initialize:function(){var t=acf.get("locale"),e=acf.get("rtl"),i=acf.get("dateTimePickerL10n");return!!i&&(void 0!==n.timepicker&&(i.isRTL=e,n.timepicker.regional[t]=i,void n.timepicker.setDefaults(i)))}});acf.newDateTimePicker=function(t,e){if(void 0===n.timepicker)return!1;t.datetimepicker(e=e||{}),n("body > #ui-datepicker-div").exists()&&n("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function(e){var t=acf.Field.extend({type:"google_map",map:!1,wait:"load",events:{'click a[data-name="clear"]':"onClickClear",'click a[data-name="locate"]':"onClickLocate",'click a[data-name="search"]':"onClickSearch","keydown .search":"onKeydownSearch","keyup .search":"onKeyupSearch","focus .search":"onFocusSearch","blur .search":"onBlurSearch",showField:"onShow"},$control:function(){return this.$(".acf-google-map")},$search:function(){return this.$(".search")},$canvas:function(){return this.$(".canvas")},setState:function(t){this.$control().removeClass("-value -loading -searching"),(t="default"===t?this.val()?"value":"":t)&&this.$control().addClass("-"+t)},getValue:function(){var t=this.$input().val();return!!t&&JSON.parse(t)},setValue:function(t,e){var i="";t&&(i=JSON.stringify(t)),acf.val(this.$input(),i),e||(this.renderVal(t),acf.doAction("google_map_change",t,this.map,this))},renderVal:function(t){t?(this.setState("value"),this.$search().val(t.address),this.setPosition(t.lat,t.lng)):(this.setState(""),this.$search().val(""),this.map.marker.setVisible(!1))},newLatLng:function(t,e){return new google.maps.LatLng(parseFloat(t),parseFloat(e))},setPosition:function(t,e){this.map.marker.setPosition({lat:parseFloat(t),lng:parseFloat(e)}),this.map.marker.setVisible(!0),this.center()},center:function(){var t,e=this.map.marker.getPosition();e=e?(t=e.lat(),e.lng()):(t=this.get("lat"),this.get("lng")),this.map.setCenter({lat:parseFloat(t),lng:parseFloat(e)})},initialize:function(){!function(t){if(a)return t();if(acf.isset(window,"google","maps","Geocoder"))return a=new google.maps.Geocoder,t();acf.addAction("google_map_api_loaded",t),i||(t=acf.get("google_map_api"))&&(i=!0,e.ajax({url:t,dataType:"script",cache:!0,success:function(){a=new google.maps.Geocoder,acf.doAction("google_map_api_loaded")}}))}(this.initializeMap.bind(this))},initializeMap:function(){var t=this.getValue(),e=acf.parseArgs(t,{zoom:this.get("zoom"),lat:this.get("lat"),lng:this.get("lng")}),i={scrollwheel:!1,zoom:parseInt(e.zoom),center:{lat:parseFloat(e.lat),lng:parseFloat(e.lng)},mapTypeId:google.maps.MapTypeId.ROADMAP,marker:{draggable:!0,raiseOnDrag:!0},autocomplete:{}},i=acf.applyFilters("google_map_args",i,this),n=new google.maps.Map(this.$canvas()[0],i),a=acf.parseArgs(i.marker,{draggable:!0,raiseOnDrag:!0,map:n}),a=acf.applyFilters("google_map_marker_args",a,this),e=new google.maps.Marker(a),a=!1;acf.isset(google,"maps","places","Autocomplete")&&(i=i.autocomplete||{},i=acf.applyFilters("google_map_autocomplete_args",i,this),(a=new google.maps.places.Autocomplete(this.$search()[0],i)).bindTo("bounds",n)),this.addMapEvents(this,n,e,a),n.acf=this,n.marker=e,n.autocomplete=a,this.map=n,t&&this.setPosition(t.lat,t.lng),acf.doAction("google_map_init",n,e,this)},addMapEvents:function(i,e,t,n){google.maps.event.addListener(e,"click",function(t){var e=t.latLng.lat(),t=t.latLng.lng();i.searchPosition(e,t)}),google.maps.event.addListener(t,"dragend",function(){var t=this.getPosition().lat(),e=this.getPosition().lng();i.searchPosition(t,e)}),n&&google.maps.event.addListener(n,"place_changed",function(){var t=this.getPlace();i.searchPlace(t)}),google.maps.event.addListener(e,"zoom_changed",function(){var t=i.val();t&&(t.zoom=e.getZoom(),i.setValue(t,!0))})},searchPosition:function(i,n){this.setState("loading"),a.geocode({location:{lat:i,lng:n}},function(t,e){this.setState(""),"OK"!==e?this.showNotice({text:acf.__("Location not found: %s").replace("%s",e),type:"warning"}):((t=this.parseResult(t[0])).lat=i,t.lng=n,this.val(t))}.bind(this))},searchPlace:function(t){var e;t&&(t.geometry?(t.formatted_address=this.$search().val(),e=this.parseResult(t),this.val(e)):t.name&&this.searchAddress(t.name))},searchAddress:function(i){if(i){var t=i.split(",");if(2==t.length){var e=parseFloat(t[0]),t=parseFloat(t[1]);if(e&&t)return this.searchPosition(e,t)}this.setState("loading"),a.geocode({address:i},function(t,e){this.setState(""),"OK"!==e?this.showNotice({text:acf.__("Location not found: %s").replace("%s",e),type:"warning"}):((t=this.parseResult(t[0])).address=i,this.val(t))}.bind(this))}},searchLocation:function(){if(!navigator.geolocation)return alert(acf.__("Sorry, this browser does not support geolocation"));this.setState("loading"),navigator.geolocation.getCurrentPosition(function(t){this.setState("");var e=t.coords.latitude,t=t.coords.longitude;this.searchPosition(e,t)}.bind(this),function(t){this.setState("")}.bind(this))},parseResult:function(t){var e={address:t.formatted_address,lat:t.geometry.location.lat(),lng:t.geometry.location.lng()};e.zoom=this.map.getZoom(),t.place_id&&(e.place_id=t.place_id),t.name&&(e.name=t.name);var i,n={street_number:["street_number"],street_name:["street_address","route"],city:["locality"],state:["administrative_area_level_1","administrative_area_level_2","administrative_area_level_3","administrative_area_level_4","administrative_area_level_5"],post_code:["postal_code"],country:["country"]};for(i in n)for(var a=n[i],s=0;s<t.address_components.length;s++){var o=t.address_components[s],r=o.types[0];-1!==a.indexOf(r)&&(e[i]=o.long_name,o.long_name!==o.short_name&&(e[i+"_short"]=o.short_name))}return acf.applyFilters("google_map_result",e,t,this.map,this)},onClickClear:function(){this.val(!1)},onClickLocate:function(){this.searchLocation()},onClickSearch:function(){this.searchAddress(this.$search().val())},onFocusSearch:function(t,e){this.setState("searching")},onBlurSearch:function(t,e){var i=this.val(),i=i?i.address:"";e.val()===i&&this.setState("default")},onKeyupSearch:function(t,e){e.val()||this.val(!1)},onKeydownSearch:function(t,e){13==t.which&&(t.preventDefault(),e.blur())},onShow:function(){this.map&&this.setTimeout(this.center)}});acf.registerFieldType(t);var i=!1,a=!1}(jQuery),function(n){var t=acf.Field.extend({type:"image",$control:function(){return this.$(".acf-image-uploader")},$input:function(){return this.$('input[type="hidden"]')},events:{'click a[data-name="add"]':"onClickAdd",'click a[data-name="edit"]':"onClickEdit",'click a[data-name="remove"]':"onClickRemove",'change input[type="file"]':"onChange"},initialize:function(){"basic"===this.get("uploader")&&this.$el.closest("form").attr("enctype","multipart/form-data")},validateAttachment:function(t){t&&t.attributes&&(t=t.attributes),t=acf.parseArgs(t,{id:0,url:"",alt:"",title:"",caption:"",description:"",width:0,height:0});var e=acf.isget(t,"sizes",this.get("preview_size"));return e&&(t.url=e.url,t.width=e.width,t.height=e.height),t},render:function(t){t=this.validateAttachment(t),this.$("img").attr({src:t.url,alt:t.alt}),t.id?(this.val(t.id),this.$control().addClass("has-value")):(this.val(""),this.$control().removeClass("has-value"))},append:function(t,e){function i(t,e){for(var i=acf.getFields({key:t.get("key"),parent:e.$el}),n=0;n<i.length;n++)if(!i[n].val())return i[n];return!1}var n=i(this,e);n||(e.$(".acf-button:last").trigger("click"),n=i(this,e)),n&&n.render(t)},selectAttachment:function(){var i=this.parent(),t=i&&"repeater"===i.get("type");acf.newMediaPopup({mode:"select",type:"image",title:acf.__("Select Image"),field:this.get("key"),multiple:t,library:this.get("library"),allowedTypes:this.get("mime_types"),select:n.proxy(function(t,e){0<e?this.append(t,i):this.render(t)},this)})},editAttachment:function(){var t=this.val();t&&acf.newMediaPopup({mode:"edit",title:acf.__("Edit Image"),button:acf.__("Update Image"),attachment:t,field:this.get("key"),select:n.proxy(function(t,e){this.render(t)},this)})},removeAttachment:function(){this.render(!1)},onClickAdd:function(t,e){this.selectAttachment()},onClickEdit:function(t,e){this.editAttachment()},onClickRemove:function(t,e){this.removeAttachment()},onChange:function(t,e){var i=this.$input();acf.getFileInputData(e,function(t){i.val(n.param(t))})}});acf.registerFieldType(t)}(jQuery),function(e){var t=acf.models.ImageField.extend({type:"file",$control:function(){return this.$(".acf-file-uploader")},$input:function(){return this.$('input[type="hidden"]')},validateAttachment:function(t){return void 0!==(t=t||{}).id&&(t=t.attributes),t=acf.parseArgs(t,{url:"",alt:"",title:"",filename:"",filesizeHumanReadable:"",icon:"/wp-includes/images/media/default.png"})},render:function(t){t=this.validateAttachment(t),this.$("img").attr({src:t.icon,alt:t.alt,title:t.title}),this.$('[data-name="title"]').text(t.title),this.$('[data-name="filename"]').text(t.filename).attr("href",t.url),this.$('[data-name="filesize"]').text(t.filesizeHumanReadable);t=t.id||"";acf.val(this.$input(),t),t?this.$control().addClass("has-value"):this.$control().removeClass("has-value")},selectAttachment:function(){var i=this.parent(),t=i&&"repeater"===i.get("type");acf.newMediaPopup({mode:"select",title:acf.__("Select File"),field:this.get("key"),multiple:t,library:this.get("library"),allowedTypes:this.get("mime_types"),select:e.proxy(function(t,e){0<e?this.append(t,i):this.render(t)},this)})},editAttachment:function(){var t=this.val();if(!t)return!1;acf.newMediaPopup({mode:"edit",title:acf.__("Edit File"),button:acf.__("Update File"),attachment:t,field:this.get("key"),select:e.proxy(function(t,e){this.render(t)},this)})}});acf.registerFieldType(t)}(jQuery),function(e){var t=acf.Field.extend({type:"link",events:{'click a[data-name="add"]':"onClickEdit",'click a[data-name="edit"]':"onClickEdit",'click a[data-name="remove"]':"onClickRemove","change .link-node":"onChange"},$control:function(){return this.$(".acf-link")},$node:function(){return this.$(".link-node")},getValue:function(){var t=this.$node();return!!t.attr("href")&&{title:t.html(),url:t.attr("href"),target:t.attr("target")}},setValue:function(t){t=acf.parseArgs(t,{title:"",url:"",target:""});var e=this.$control(),i=this.$node();e.removeClass("-value -external"),t.url&&e.addClass("-value"),"_blank"===t.target&&e.addClass("-external"),this.$(".link-title").html(t.title),this.$(".link-url").attr("href",t.url).html(t.url),i.html(t.title),i.attr("href",t.url),i.attr("target",t.target),this.$(".input-title").val(t.title),this.$(".input-target").val(t.target),this.$(".input-url").val(t.url).trigger("change")},onClickEdit:function(t,e){acf.wpLink.open(this.$node())},onClickRemove:function(t,e){this.setValue(!1)},onChange:function(t,e){var i=this.getValue();this.setValue(i)}});acf.registerFieldType(t),acf.wpLink=new acf.Model({getNodeValue:function(){var t=this.get("node");return{title:acf.decode(t.html()),url:t.attr("href"),target:t.attr("target")}},setNodeValue:function(t){var e=this.get("node");e.text(t.title),e.attr("href",t.url),e.attr("target",t.target),e.trigger("change")},getInputValue:function(){return{title:e("#wp-link-text").val(),url:e("#wp-link-url").val(),target:e("#wp-link-target").prop("checked")?"_blank":""}},setInputValue:function(t){e("#wp-link-text").val(t.title),e("#wp-link-url").val(t.url),e("#wp-link-target").prop("checked","_blank"===t.target)},open:function(t){this.on("wplink-open","onOpen"),this.on("wplink-close","onClose"),this.set("node",t);t=e('<textarea id="acf-link-textarea" style="display:none;"></textarea>');e("body").append(t);t=this.getNodeValue();wpLink.open("acf-link-textarea",t.url,t.title,null)},onOpen:function(){e("#wp-link-wrap").addClass("has-text-field");var t=this.getNodeValue();this.setInputValue(t),t.url&&wpLinkL10n&&e("#wp-link-submit").val(wpLinkL10n.update)},close:function(){wpLink.close()},onClose:function(){if(!this.has("node"))return!1;var t=e("#wp-link-submit");(t.is(":hover")||t.is(":focus"))&&(t=this.getInputValue(),this.setNodeValue(t)),this.off("wplink-open"),this.off("wplink-close"),e("#acf-link-textarea").remove(),this.set("node",null)}})}(jQuery),function(i){var t=acf.Field.extend({type:"oembed",events:{'click [data-name="clear-button"]':"onClickClear","keypress .input-search":"onKeypressSearch","keyup .input-search":"onKeyupSearch","change .input-search":"onChangeSearch"},$control:function(){return this.$(".acf-oembed")},$input:function(){return this.$(".input-value")},$search:function(){return this.$(".input-search")},getValue:function(){return this.$input().val()},getSearchVal:function(){return this.$search().val()},setValue:function(t){t?this.$control().addClass("has-value"):this.$control().removeClass("has-value"),acf.val(this.$input(),t)},showLoading:function(t){acf.showLoading(this.$(".canvas"))},hideLoading:function(){acf.hideLoading(this.$(".canvas"))},maybeSearch:function(){var t=this.val(),e=this.getSearchVal();if(!e)return this.clear();(e="http"!=e.substr(0,4)?"http://"+e:e)!==t&&((t=this.get("timeout"))&&clearTimeout(t),e=i.proxy(this.search,this,e),this.set("timeout",setTimeout(e,300)))},search:function(t){var e={action:"acf/fields/oembed/search",s:t,field_key:this.get("key")};(t=this.get("xhr"))&&t.abort(),this.showLoading();t=i.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"json",context:this,success:function(t){t&&t.html||(t={url:!1,html:""}),this.val(t.url),this.$(".canvas-media").html(t.html)},complete:function(){this.hideLoading()}});this.set("xhr",t)},clear:function(){this.val(""),this.$search().val(""),this.$(".canvas-media").html("")},onClickClear:function(t,e){this.clear()},onKeypressSearch:function(t,e){13==t.which&&(t.preventDefault(),this.maybeSearch())},onKeyupSearch:function(t,e){e.val()&&this.maybeSearch()},onChangeSearch:function(t,e){this.maybeSearch()}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"radio",events:{'click input[type="radio"]':"onClick"},$control:function(){return this.$(".acf-radio-list")},$input:function(){return this.$("input:checked")},$inputText:function(){return this.$('input[type="text"]')},getValue:function(){var t=this.$input().val();return t="other"===t&&this.get("other_choice")?this.$inputText().val():t},onClick:function(t,e){var i=e.parent("label"),n=i.hasClass("selected"),a=e.val();this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"),a=!1),this.get("other_choice")&&("other"===a?this.$inputText().prop("disabled",!1):this.$inputText().prop("disabled",!0))}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"range",events:{'input input[type="range"]':"onChange","change input":"onChange"},$input:function(){return this.$('input[type="range"]')},$inputAlt:function(){return this.$('input[type="number"]')},setValue:function(t){this.busy=!0,acf.val(this.$input(),t),acf.val(this.$inputAlt(),this.$input().val(),!0),this.busy=!1},onChange:function(t,e){this.busy||this.setValue(e.val())}});acf.registerFieldType(t)}(jQuery),function(s){var t=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"},$control:function(){return this.$(".acf-relationship")},$list:function(t){return this.$("."+t+"-list")},$listItems:function(t){return this.$list(t).find(".acf-rel-item")},$listItem:function(t,e){return this.$list(t).find('.acf-rel-item[data-id="'+e+'"]')},getValue:function(){var t=[];return this.$listItems("values").each(function(){t.push(s(this).data("id"))}),!!t.length&&t},newChoice:function(t){return["<li>",'<span data-id="'+t.id+'" class="acf-rel-item">'+t.text+"</span>","</li>"].join("")},newValue:function(t){return["<li>",'<input type="hidden" name="'+this.getInputName()+'[]" value="'+t.id+'" />','<span data-id="'+t.id+'" class="acf-rel-item">'+t.text,'<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>',"</span>","</li>"].join("")},initialize:function(){var t=this.proxy(acf.once(function(){this.$list("values").sortable({items:"li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:this.proxy(function(){this.$input().trigger("change")})}),this.$list("choices").scrollTop(0).on("scroll",this.proxy(this.onScrollChoices)),this.fetch()}));this.$el.one("mouseover",t),this.$el.one("focus","input",t),acf.onceInView(this.$el,t)},onScrollChoices:function(t){var e,i,n,a;!this.get("loading")&&this.get("more")&&(a=this.$list("choices"),e=Math.ceil(a.scrollTop()),i=Math.ceil(a[0].scrollHeight),n=Math.ceil(a.innerHeight()),a=this.get("paged")||1,i<=e+n&&(this.set("paged",a+1),this.fetch()))},onKeypressFilter:function(t,e){13==t.which&&t.preventDefault()},onChangeFilter:function(t,e){var i=e.val(),n=e.data("filter");this.get(n)!==i&&(this.set(n,i),this.set("paged",1),e.is("select")?this.fetch():this.maybeFetch())},onClickAdd:function(t,e){var i=this.val(),n=parseInt(this.get("max"));if(e.hasClass("disabled"))return!1;if(0<n&&i&&i.length>=n)return this.showNotice({text:acf.__("Maximum values reached ( {max} values )").replace("{max}",n),type:"warning"}),!1;e.addClass("disabled");e=this.newValue({id:e.data("id"),text:e.html()});this.$list("values").append(e),this.$input().trigger("change")},onClickRemove:function(t,e){t.preventDefault();t=e.parent(),e=t.parent(),t=t.data("id");e.remove(),this.$listItem("choices",t).removeClass("disabled"),this.$input().trigger("change")},maybeFetch:function(){var t=this.get("timeout");t&&clearTimeout(t),t=this.setTimeout(this.fetch,300),this.set("timeout",t)},getAjaxData:function(){var t,e=this.$control().data();for(t in e)e[t]=this.get(t);return e.action="acf/fields/relationship/query",e.field_key=this.get("key"),e=acf.applyFilters("relationship_ajax_data",e,this)},fetch:function(){(i=this.get("xhr"))&&i.abort();var t=this.getAjaxData(),a=this.$list("choices");1==t.paged&&a.html("");var e=s('<li><i class="acf-loading"></i> '+acf.__("Loading")+"</li>");a.append(e),this.set("loading",!0);var i=s.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",data:acf.prepareForAjax(t),context:this,success:function(t){if(!t||!t.results||!t.results.length)return this.set("more",!1),void(1==this.get("paged")&&this.$list("choices").append("<li>"+acf.__("No matches found")+"</li>"));this.set("more",t.more);var t=this.walkChoices(t.results),e=s(t),t=this.val();t&&t.length&&t.map(function(t){e.find('.acf-rel-item[data-id="'+t+'"]').addClass("disabled")}),a.append(e);var i=!1,n=!1;a.find(".acf-rel-label").each(function(){var t=s(this),e=t.siblings("ul");if(i&&i.text()==t.text())return n.append(e.children()),void s(this).parent().remove();i=t,n=e})},complete:function(){this.set("loading",!1),e.remove()}});this.set("xhr",i)},walkChoices:function(t){var i=function(t){var e="";return s.isArray(t)?t.map(function(t){e+=i(t)}):s.isPlainObject(t)&&(void 0!==t.children?(e+='<li><span class="acf-rel-label">'+acf.escHtml(t.text)+'</span><ul class="acf-bl">',e+=i(t.children),e+="</ul></li>"):e+='<li><span class="acf-rel-item" data-id="'+acf.escAttr(t.id)+'">'+acf.escHtml(t.text)+"</span></li>"),e};return i(t)}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"select",select2:!1,wait:"load",events:{removeField:"onRemove",duplicateField:"onDuplicate"},$input:function(){return this.$("select")},initialize:function(){var t,e=this.$input();this.inherit(e),this.get("ui")&&(t=(t=this.get("ajax_action"))||"acf/fields/"+this.get("type")+"/query",this.select2=acf.newSelect2(e,{field:this,ajax:this.get("ajax"),multiple:this.get("multiple"),placeholder:this.get("placeholder"),allowNull:this.get("allow_null"),ajaxAction:t}))},onRemove:function(){this.select2&&this.select2.destroy()},onDuplicate:function(t,e,i){this.select2&&(i.find(".select2-container").remove(),i.find("select").removeClass("select2-hidden-accessible"))}});acf.registerFieldType(t)}(jQuery),function(n){var e="tab",t=acf.Field.extend({type:"tab",wait:"",tabs:!1,tab:!1,events:{duplicateField:"onDuplicate"},findFields:function(){return this.$el.nextUntil(".acf-field-tab",".acf-field")},getFields:function(){return acf.getFields(this.findFields())},findTabs:function(){return this.$el.prevAll(".acf-tab-wrap:first")},findTab:function(){return this.$(".acf-tab-button")},initialize:function(){if(this.$el.is("td"))return!(this.events={});var t=this.findTabs(),e=this.findTab(),i=acf.parseArgs(e.data(),{endpoint:!1,placement:"",before:this.$el});!t.length||i.endpoint?this.tabs=new s(i):this.tabs=t.data("acf"),this.tab=this.tabs.addTab(e,this)},isActive:function(){return this.tab.isActive()},showFields:function(){this.getFields().map(function(t){t.show(this.cid,e),t.hiddenByTab=!1},this)},hideFields:function(){this.getFields().map(function(t){t.hide(this.cid,e),t.hiddenByTab=this.tab},this)},show:function(t){var e=acf.Field.prototype.show.apply(this,arguments);return e&&(this.tab.show(),this.tabs.refresh()),e},hide:function(t){var e=acf.Field.prototype.hide.apply(this,arguments);return e&&(this.tab.hide(),this.isActive()&&this.tabs.reset()),e},enable:function(t){this.getFields().map(function(t){t.enable(e)})},disable:function(t){this.getFields().map(function(t){t.disable(e)})},onDuplicate:function(t,e,i){this.isActive()&&i.prevAll(".acf-tab-wrap:first").remove()}});acf.registerFieldType(t);var a=0,s=acf.Model.extend({tabs:[],active:!1,actions:{refresh:"onRefresh"},data:{before:!1,placement:"top",index:0,initialized:!1},setup:function(t){n.extend(this.data,t),this.tabs=[],this.active=!1;var e=this.get("placement"),i=this.get("before"),t=i.parent();"left"==e&&t.hasClass("acf-fields")&&t.addClass("-sidebar"),i.is("tr")?this.$el=n('<tr class="acf-tab-wrap"><td colspan="2"><ul class="acf-hl acf-tab-group"></ul></td></tr>'):this.$el=n('<div class="acf-tab-wrap -'+e+'"><ul class="acf-hl acf-tab-group"></ul></div>'),i.before(this.$el),this.set("index",a,!0),a++},initializeTabs:function(){var t=this.getVisible().shift(),e=(acf.getPreference("this.tabs")||[])[this.get("index")];(t=this.tabs[e]&&this.tabs[e].isVisible()?this.tabs[e]:t)?this.selectTab(t):this.closeTabs(),this.set("initialized",!0)},getVisible:function(){return this.tabs.filter(function(t){return t.isVisible()})},getActive:function(){return this.active},setActive:function(t){return this.active=t},hasActive:function(){return!1!==this.active},isActive:function(t){var e=this.getActive();return e&&e.cid===t.cid},closeActive:function(){this.hasActive()&&this.closeTab(this.getActive())},openTab:function(t){this.closeActive(),t.open(),this.setActive(t)},closeTab:function(t){t.close(),this.setActive(!1)},closeTabs:function(){this.tabs.map(this.closeTab,this)},selectTab:function(e){this.tabs.map(function(t){e.cid!==t.cid&&this.closeTab(t)},this),this.openTab(e)},addTab:function(t,e){t=n("<li>"+t.outerHTML()+"</li>");this.$("ul").append(t);e=new i({$el:t,field:e,group:this});return this.tabs.push(e),e},reset:function(){return this.closeActive(),this.refresh()},refresh:function(){if(this.hasActive())return!1;var t=this.getVisible().shift();return t&&this.openTab(t),t},onRefresh:function(){var t,e,i;"left"===this.get("placement")&&(t=this.$el.parent(),i=this.$el.children("ul"),e=t.is("td")?"height":"min-height",i=i.position().top+i.outerHeight(!0)-1,t.css(e,i))}}),i=acf.Model.extend({group:!1,field:!1,events:{"click a":"onClick"},index:function(){return this.$el.index()},isVisible:function(){return acf.isVisible(this.$el)},isActive:function(){return this.$el.hasClass("active")},open:function(){this.$el.addClass("active"),this.field.showFields()},close:function(){this.$el.removeClass("active"),this.field.hideFields()},onClick:function(t,e){t.preventDefault(),this.toggle()},toggle:function(){this.isActive()||this.group.openTab(this)}});new acf.Model({priority:50,actions:{prepare:"render",append:"render",unload:"onUnload",invalid_field:"onInvalidField"},findTabs:function(){return n(".acf-tab-wrap")},getTabs:function(){return acf.getInstances(this.findTabs())},render:function(t){this.getTabs().map(function(t){t.get("initialized")||t.initializeTabs()})},onInvalidField:function(t){this.busy||t.hiddenByTab&&(t.hiddenByTab.toggle(),this.busy=!0,this.setTimeout(function(){this.busy=!1},100))},onUnload:function(){var e=[];this.getTabs().map(function(t){t=t.hasActive()?t.getActive().index():0;e.push(t)}),e.length&&acf.setPreference("this.tabs",e)}})}(jQuery),function(){var t=acf.models.SelectField.extend({type:"post_object"});acf.registerFieldType(t)}(jQuery),function(){var t=acf.models.SelectField.extend({type:"page_link"});acf.registerFieldType(t)}(jQuery),function(){var t=acf.models.SelectField.extend({type:"user"});acf.registerFieldType(t)}(jQuery),function(p){var t=acf.Field.extend({type:"taxonomy",data:{ftype:"select"},select2:!1,wait:"load",events:{'click a[data-name="add"]':"onClickAdd",'click input[type="radio"]':"onClickRadio",removeField:"onRemove"},$control:function(){return this.$(".acf-taxonomy-field")},$input:function(){return this.getRelatedPrototype().$input.apply(this,arguments)},getRelatedType:function(){var t=this.get("ftype");return t="multi_select"==t?"select":t},getRelatedPrototype:function(){return acf.getFieldType(this.getRelatedType()).prototype},getValue:function(){return this.getRelatedPrototype().getValue.apply(this,arguments)},setValue:function(){return this.getRelatedPrototype().setValue.apply(this,arguments)},initialize:function(){this.getRelatedPrototype().initialize.apply(this,arguments)},onRemove:function(){var t=this.getRelatedPrototype();t.onRemove&&t.onRemove.apply(this,arguments)},onClickAdd:function(t,e){var i=this,n=!1,a=!1,s=!1,o=!1,r=!1,c=!1,l=function(t){n.loading(!1),n.content(t),a=n.$("form"),s=n.$('input[name="term_name"]'),o=n.$('select[name="term_parent"]'),r=n.$(".acf-submit-button"),s.trigger("focus"),n.on("submit","form",d)},d=function(t,e){if(t.preventDefault(),t.stopImmediatePropagation(),""===s.val())return s.trigger("focus"),!1;acf.startButtonLoading(r);t={action:"acf/fields/taxonomy/add_term",field_key:i.get("key"),term_name:s.val(),term_parent:o.length?o.val():0};p.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(t),type:"post",dataType:"json",success:u})},u=function(t){acf.stopButtonLoading(r),c&&c.remove(),c=acf.isAjaxSuccess(t)?(s.val(""),f(t.data),acf.newNotice({type:"success",text:acf.getAjaxMessage(t),target:a,timeout:2e3,dismiss:!1})):acf.newNotice({type:"error",text:acf.getAjaxError(t),target:a,timeout:2e3,dismiss:!1}),s.trigger("focus")},f=function(e){var t=p('<option value="'+e.term_id+'">'+e.term_label+"</option>");e.term_parent?o.children('option[value="'+e.term_parent+'"]').after(t):o.append(t),acf.getFields({type:"taxonomy"}).map(function(t){t.get("taxonomy")==i.get("taxonomy")&&t.appendTerm(e)}),i.selectTerm(e.term_id)};!function(){n=acf.newPopup({title:e.attr("title"),loading:!0,width:"300px"});var t={action:"acf/fields/taxonomy/add_term",field_key:i.get("key")};p.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(t),type:"post",dataType:"html",success:l})}()},appendTerm:function(t){"select"==this.getRelatedType()?this.appendTermSelect(t):this.appendTermCheckbox(t)},appendTermSelect:function(t){this.select2.addOption({id:t.term_id,text:t.term_label})},appendTermCheckbox:function(t){var e=this.$("[name]:first").attr("name"),i=this.$("ul:first");"checkbox"==this.getRelatedType()&&(e+="[]");e=p(['<li data-id="'+t.term_id+'">',"<label>",'<input type="'+this.get("ftype")+'" value="'+t.term_id+'" name="'+e+'" /> ',"<span>"+t.term_name+"</span>","</label>","</li>"].join(""));t.term_parent&&((i=(t=i.find('li[data-id="'+t.term_parent+'"]')).children("ul")).exists()||(i=p('<ul class="children acf-bl"></ul>'),t.append(i))),i.append(e)},selectTerm:function(t){"select"==this.getRelatedType()?this.select2.selectOption(t):this.$('input[value="'+t+'"]').prop("checked",!0).trigger("change")},onClickRadio:function(t,e){var i=e.parent("label"),n=i.hasClass("selected");this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"))}});acf.registerFieldType(t)}(jQuery),function(i){var t=acf.models.DatePickerField.extend({type:"time_picker",$control:function(){return this.$(".acf-time-picker")},initialize:function(){var t=this.$input(),e=this.$inputText(),t={timeFormat:this.get("time_format"),altField:t,altFieldTimeOnly:!1,altTimeFormat:"HH:mm:ss",showButtonPanel:!0,controlType:"select",oneLine:!0,closeText:acf.get("dateTimePickerL10n").selectText,timeOnly:!0,onClose:function(t,e,i){e=e.dpDiv.find(".ui-datepicker-close");!t&&e.is(":hover")&&i._updateDateTime()}},t=acf.applyFilters("time_picker_args",t,this);acf.newTimePicker(e,t),acf.doAction("time_picker_init",e,t,this)}});acf.registerFieldType(t),acf.newTimePicker=function(t,e){if(void 0===i.timepicker)return!1;t.timepicker(e=e||{}),i("body > #ui-datepicker-div").exists()&&i("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function(){var t=acf.Field.extend({type:"true_false",events:{"change .acf-switch-input":"onChange","focus .acf-switch-input":"onFocus","blur .acf-switch-input":"onBlur","keypress .acf-switch-input":"onKeypress"},$input:function(){return this.$('input[type="checkbox"]')},$switch:function(){return this.$(".acf-switch")},getValue:function(){return this.$input().prop("checked")?1:0},initialize:function(){this.render()},render:function(){var t,e,i=this.$switch();i.length&&(t=i.children(".acf-switch-on"),e=i.children(".acf-switch-off"),(i=Math.max(t.width(),e.width()))&&(t.css("min-width",i),e.css("min-width",i)))},switchOn:function(){this.$input().prop("checked",!0),this.$switch().addClass("-on")},switchOff:function(){this.$input().prop("checked",!1),this.$switch().removeClass("-on")},onChange:function(t,e){e.prop("checked")?this.switchOn():this.switchOff()},onFocus:function(t,e){this.$switch().addClass("-focus")},onBlur:function(t,e){this.$switch().removeClass("-focus")},onKeypress:function(t,e){return 37===t.keyCode?this.switchOff():39===t.keyCode?this.switchOn():void 0}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"url",events:{'keyup input[type="url"]':"onkeyup"},$control:function(){return this.$(".acf-input-wrap")},$input:function(){return this.$('input[type="url"]')},initialize:function(){this.render()},isValid:function(){var t=this.val();return!!t&&(-1!==t.indexOf("://")||0===t.indexOf("//"))},render:function(){this.isValid()?this.$control().addClass("-valid"):this.$control().removeClass("-valid")},onkeyup:function(t,e){this.render()}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"wysiwyg",wait:"load",events:{"mousedown .acf-editor-wrap.delay":"onMousedown",unmountField:"disableEditor",remountField:"enableEditor",removeField:"disableEditor"},$control:function(){return this.$(".acf-editor-wrap")},$input:function(){return this.$("textarea")},getMode:function(){return this.$control().hasClass("tmce-active")?"visual":"text"},initialize:function(){this.$control().hasClass("delay")||this.initializeEditor()},initializeEditor:function(){var t=this.$control(),e=this.$input(),i={tinymce:!0,quicktags:!0,toolbar:this.get("toolbar"),mode:this.getMode(),field:this},n=e.attr("id"),a=acf.uniqueId("acf-editor-"),s=e.data(),e=e.val();acf.rename({target:t,search:n,replace:a,destructive:!0}),this.set("id",a,!0),this.$input().data(s).val(e),acf.tinymce.initialize(a,i)},onMousedown:function(t){t.preventDefault();t=this.$control();t.removeClass("delay"),t.find(".acf-editor-toolbar").remove(),this.initializeEditor()},enableEditor:function(){"visual"==this.getMode()&&acf.tinymce.enable(this.get("id"))},disableEditor:function(){acf.tinymce.destroy(this.get("id"))}});acf.registerFieldType(t)}(jQuery),function(e){var s=[];acf.Condition=acf.Model.extend({type:"",operator:"==",label:"",choiceType:"input",fieldTypes:[],data:{conditions:!1,field:!1,rule:{}},events:{change:"change",keyup:"change",enableField:"change",disableField:"change"},setup:function(t){e.extend(this.data,t)},getEventTarget:function(t,e){return t||this.get("field").$el},change:function(t,e){this.get("conditions").change(t)},match:function(t,e){return!1},calculate:function(){return this.match(this.get("rule"),this.get("field"))},choices:function(t){return'<input type="text" />'}}),acf.newCondition=function(t,e){var i=e.get("field"),n=i.getField(t.field);if(!i||!n)return!1;e={rule:t,target:i,conditions:e,field:n},n=n.get("type"),t=t.operator;return new(acf.getConditionTypes({fieldType:n,operator:t})[0]||acf.Condition)(e)};function n(t){return acf.strPascalCase(t||"")+"Condition"}acf.registerConditionType=function(t){var e=t.prototype.type,i=n(e);acf.models[i]=t,s.push(e)},acf.getConditionType=function(t){t=n(t);return acf.models[t]||!1},acf.registerConditionForFieldType=function(t,e){t=acf.getConditionType(t);t&&t.prototype.fieldTypes.push(e)},acf.getConditionTypes=function(n){n=acf.parseArgs(n,{fieldType:"",operator:""});var a=[];return s.map(function(t){var e=acf.getConditionType(t),i=e.prototype.fieldTypes,t=e.prototype.operator;n.fieldType&&-1===i.indexOf(n.fieldType)||n.operator&&t!==n.operator||a.push(e)}),a}}(jQuery),function(){function a(t,e){var i=acf.getFields({key:e,sibling:t.$el,suppressFilters:!0});return!!(i=!i.length?acf.getFields({key:e,parent:t.$el.parent(),suppressFilters:!0}):i).length&&i[0]}var t="conditional_logic";new acf.Model({id:"conditionsManager",priority:20,actions:{new_field:"onNewField"},onNewField:function(t){t.has("conditions")&&t.getConditions().render()}});acf.Field.prototype.getField=function(t){var e=a(this,t);if(e)return e;for(var i=this.parents(),n=0;n<i.length;n++)if(e=a(i[n],t))return e;return!1};acf.Field.prototype.getConditions=function(){return this.conditions||(this.conditions=new e(this)),this.conditions};var e=acf.Model.extend({id:"Conditions",data:{field:!1,timeStamp:!1,groups:[]},setup:function(t){t=(this.data.field=t).get("conditions");t instanceof Array?t[0]instanceof Array?t.map(function(t,e){this.addRules(t,e)},this):this.addRules(t):this.addRule(t)},change:function(t){if(this.get("timeStamp")===t.timeStamp)return!1;this.set("timeStamp",t.timeStamp,!0);this.render()},render:function(){return this.calculate()?this.show():this.hide()},show:function(){return this.get("field").showEnable(this.cid,t)},hide:function(){return this.get("field").hideDisable(this.cid,t)},calculate:function(){var e=!1;return this.getGroups().map(function(t){e||t.filter(function(t){return t.calculate()}).length==t.length&&(e=!0)}),e},hasGroups:function(){return null!=this.data.groups},getGroups:function(){return this.data.groups},addGroup:function(){var t=[];return this.data.groups.push(t),t},hasGroup:function(t){return null!=this.data.groups[t]},getGroup:function(t){return this.data.groups[t]},removeGroup:function(t){return this.data.groups[t].delete,this},addRules:function(t,e){t.map(function(t){this.addRule(t,e)},this)},addRule:function(t,e){e=this.hasGroup(e=e||0)?this.getGroup(e):this.addGroup(),t=acf.newCondition(t,this);if(!t)return!1;e.push(t)},hasRule:function(){},getRule:function(t,e){return this.data.groups[e=e||0][t=t||0]},removeRule:function(){}})}(jQuery),function(){function n(t){return t?""+t:""}function a(t,e){return n(t).toLowerCase()===n(e).toLowerCase()}var s=acf.__,i=acf.Condition.extend({type:"hasValue",operator:"!=empty",label:s("Has any value"),fieldTypes:["text","textarea","number","range","email","url","password","image","file","wysiwyg","oembed","select","checkbox","radio","button_group","link","post_object","page_link","relationship","taxonomy","user","google_map","date_picker","date_time_picker","time_picker","color_picker"],match:function(t,e){return!!e.val()},choices:function(t){return'<input type="text" disabled="" />'}});acf.registerConditionType(i);var t=i.extend({type:"hasNoValue",operator:"==empty",label:s("Has no value"),match:function(t,e){return!i.prototype.match.apply(this,arguments)}});acf.registerConditionType(t);var o=acf.Condition.extend({type:"equalTo",operator:"==",label:s("Value is equal to"),fieldTypes:["text","textarea","number","range","email","url","password"],match:function(t,e){return acf.isNumeric(t.value)?(i=t.value,n=e.val(),parseFloat(i)===parseFloat(n)):a(t.value,e.val());var i,n},choices:function(t){return'<input type="text" />'}});acf.registerConditionType(o);var e=o.extend({type:"notEqualTo",operator:"!=",label:s("Value is not equal to"),match:function(t,e){return!o.prototype.match.apply(this,arguments)}});acf.registerConditionType(e);t=acf.Condition.extend({type:"patternMatch",operator:"==pattern",label:s("Value matches pattern"),fieldTypes:["text","textarea","email","url","password","wysiwyg"],match:function(t,e){return function(t,e){e=new RegExp(n(e),"gi");return n(t).match(e)}(e.val(),t.value)},choices:function(t){return'<input type="text" placeholder="[a-z0-9]" />'}});acf.registerConditionType(t);t=acf.Condition.extend({type:"contains",operator:"==contains",label:s("Value contains"),fieldTypes:["text","textarea","number","email","url","password","wysiwyg","oembed","select"],match:function(t,e){return e=e.val(),t=t.value,-1<n(e).indexOf(n(t))},choices:function(t){return'<input type="text" />'}});acf.registerConditionType(t);t=o.extend({type:"trueFalseEqualTo",choiceType:"select",fieldTypes:["true_false"],choices:function(t){return[{id:1,text:s("Checked")}]}});acf.registerConditionType(t);t=e.extend({type:"trueFalseNotEqualTo",choiceType:"select",fieldTypes:["true_false"],choices:function(t){return[{id:1,text:s("Checked")}]}});acf.registerConditionType(t);var r=acf.Condition.extend({type:"selectEqualTo",operator:"==",label:s("Value is equal to"),fieldTypes:["select","checkbox","radio","button_group"],match:function(t,e){var i=e.val();return i instanceof Array?(e=t.value,-1<i.map(n).indexOf(e)):a(t.value,i)},choices:function(t){var e=[],i=t.$setting("choices textarea").val().split("\n");return t.$input("allow_null").prop("checked")&&e.push({id:"",text:s("Null")}),i.map(function(t){(t=t.split(":"))[1]=t[1]||t[0],e.push({id:t[0].trim(),text:t[1].trim()})}),e}});acf.registerConditionType(r);e=r.extend({type:"selectNotEqualTo",operator:"!=",label:s("Value is not equal to"),match:function(t,e){return!r.prototype.match.apply(this,arguments)}});acf.registerConditionType(e);t=acf.Condition.extend({type:"greaterThan",operator:">",label:s("Value is greater than"),fieldTypes:["number","range"],match:function(t,e){e=e.val();return e instanceof Array&&(e=e.length),e=e,t=t.value,parseFloat(e)>parseFloat(t)},choices:function(t){return'<input type="number" />'}});acf.registerConditionType(t);e=t.extend({type:"lessThan",operator:"<",label:s("Value is less than"),match:function(t,e){e=e.val();return e instanceof Array&&(e=e.length),e=e,t=t.value,parseFloat(e)<parseFloat(t)},choices:function(t){return'<input type="number" />'}});acf.registerConditionType(e);t=t.extend({type:"selectionGreaterThan",label:s("Selection is greater than"),fieldTypes:["checkbox","select","post_object","page_link","relationship","taxonomy","user"]});acf.registerConditionType(t);e=e.extend({type:"selectionLessThan",label:s("Selection is less than"),fieldTypes:["checkbox","select","post_object","page_link","relationship","taxonomy","user"]});acf.registerConditionType(e)}(jQuery),function(t){acf.unload=new acf.Model({wait:"load",active:!0,changed:!1,actions:{validation_failure:"startListening",validation_success:"stopListening"},events:{"change form .acf-field":"startListening","submit form":"stopListening"},enable:function(){this.active=!0},disable:function(){this.active=!1},reset:function(){this.stopListening()},startListening:function(){!this.changed&&this.active&&(this.changed=!0,t(window).on("beforeunload",this.onUnload))},stopListening:function(){this.changed=!1,t(window).off("beforeunload",this.onUnload)},onUnload:function(){return acf.__("The changes you made will be lost if you navigate away from this page")}})}(jQuery),function(e){new acf.Model({wait:"prepare",priority:1,initialize:function(){(acf.get("postboxes")||[]).map(acf.newPostbox)}});acf.getPostbox=function(t){return"string"==typeof arguments[0]&&(t=e("#"+arguments[0])),acf.getInstance(t)},acf.getPostboxes=function(){return acf.getInstances(e(".acf-postbox"))},acf.newPostbox=function(t){return new acf.models.Postbox(t)},acf.models.Postbox=acf.Model.extend({data:{id:"",key:"",style:"default",label:"top",edit:""},setup:function(t){t.editLink&&(t.edit=t.editLink),e.extend(this.data,t),this.$el=this.$postbox()},$postbox:function(){return e("#"+this.get("id"))},$hide:function(){return e("#"+this.get("id")+"-hide")},$hideLabel:function(){return this.$hide().parent()},$hndle:function(){return this.$("> .hndle")},$handleActions:function(){return this.$("> .postbox-header .handle-actions")},$inside:function(){return this.$("> .inside")},isVisible:function(){return this.$el.hasClass("acf-hidden")},initialize:function(){this.$el.addClass("acf-postbox"),this.$el.removeClass("hide-if-js"),"block"===acf.get("editor")||"default"!==(t=this.get("style"))&&this.$el.addClass(t),this.$inside().addClass("acf-fields").addClass("-"+this.get("label"));var t,e=this.get("edit");e&&(t='<a href="'+e+'" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="'+acf.__("Edit field group")+'"></a>',(e=this.$handleActions()).length?e.prepend(t):this.$hndle().append(t)),this.show()},show:function(){this.$hideLabel().show(),this.$hide().prop("checked",!0),this.$el.show().removeClass("acf-hidden"),acf.doAction("show_postbox",this)},enable:function(){acf.enable(this.$el,"postbox")},showEnable:function(){this.enable(),this.show()},hide:function(){this.$hideLabel().hide(),this.$el.hide().addClass("acf-hidden"),acf.doAction("hide_postbox",this)},disable:function(){acf.disable(this.$el,"postbox")},hideDisable:function(){this.disable(),this.hide()},html:function(t){this.$inside().html(t),acf.doAction("append",this.$el)}})}(jQuery),function(a){acf.newMediaPopup=function(t){var e=null,e=new("edit"==(t=acf.parseArgs(t,{mode:"select",title:"",button:"",type:"",field:!1,allowedTypes:"",library:"all",multiple:!1,attachment:0,autoOpen:!0,open:function(){},select:function(){},close:function(){}})).mode?acf.models.EditMediaPopup:acf.models.SelectMediaPopup)(t);return t.autoOpen&&setTimeout(function(){e.open()},1),acf.doAction("new_media_popup",e),e};function e(){var t=acf.get("post_id");return acf.isNumeric(t)?t:0}acf.getMimeTypes=function(){return this.get("mimeTypes")},acf.getMimeType=function(t){var e,i=acf.getMimeTypes();if(void 0!==i[t])return i[t];for(e in i)if(-1!==e.indexOf(t))return i[e];return!1};var n=acf.Model.extend({id:"MediaPopup",data:{},defaults:{},frame:!1,setup:function(t){a.extend(this.data,t)},initialize:function(){var t=this.getFrameOptions();this.addFrameStates(t);var e=wp.media(t);(e.acf=this).addFrameEvents(e,t),this.frame=e},open:function(){this.frame.open()},close:function(){this.frame.close()},remove:function(){this.frame.detach(),this.frame.remove()},getFrameOptions:function(){var t={title:this.get("title"),multiple:this.get("multiple"),library:{},states:[]};return this.get("type")&&(t.library.type=this.get("type")),"uploadedTo"===this.get("library")&&(t.library.uploadedTo=e()),this.get("attachment")&&(t.library.post__in=[this.get("attachment")]),this.get("button")&&(t.button={text:this.get("button")}),t},addFrameStates:function(t){var e=wp.media.query(t.library);this.get("field")&&acf.isset(e,"mirroring","args")&&(e.mirroring.args._acfuploader=this.get("field")),t.states.push(new wp.media.controller.Library({library:e,multiple:this.get("multiple"),title:this.get("title"),priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})),acf.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage)},addFrameEvents:function(i,t){i.on("open",function(){this.$el.closest(".media-modal").addClass("acf-media-modal -"+this.acf.get("mode"))},i),i.on("content:render:edit-image",function(){var t=this.state().get("image"),t=new wp.media.view.EditImage({model:t,controller:this}).render();this.content.set(t),t.loadEditor()},i),i.on("select",function(){var t=i.state().get("selection");t&&t.each(function(t,e){i.acf.get("select").apply(i.acf,[t,e])})}),i.on("close",function(){setTimeout(function(){i.acf.get("close").apply(i.acf),i.acf.remove()},1)})}});acf.models.SelectMediaPopup=n.extend({id:"SelectMediaPopup",setup:function(t){t.button||(t.button=acf._x("Select","verb")),n.prototype.setup.apply(this,arguments)},addFrameEvents:function(e,t){acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=this.get("field"),e.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),e.on("content:activate:browse",function(){var t=!1;try{t=e.content.get().toolbar}catch(t){return void console.log(t)}e.acf.customizeFilters.apply(e.acf,[t])}),n.prototype.addFrameEvents.apply(this,arguments)},customizeFilters:function(t){var i,e=t.get("filters");"image"==this.get("type")&&(e.filters.all.text=acf.__("All images"),delete e.filters.audio,delete e.filters.video,delete e.filters.image,a.each(e.filters,function(t,e){e.props.type=e.props.type||"image"})),this.get("allowedTypes")&&this.get("allowedTypes").split(" ").join("").split(".").join("").split(",").map(function(t){t=acf.getMimeType(t);t&&(e.filters[t]={text:t,props:{status:null,type:t,uploadedTo:null,orderby:"date",order:"DESC"},priority:20})}),"uploadedTo"===this.get("library")&&(i=this.frame.options.library.uploadedTo,delete e.filters.unattached,delete e.filters.uploaded,a.each(e.filters,function(t,e){e.text+=" ("+acf.__("Uploaded to this post")+")",e.props.uploadedTo=i}));var n=this.get("field");a.each(e.filters,function(t,e){e.props._acfuploader=n}),t.get("search").model.attributes._acfuploader=n,e.renderFilters&&e.renderFilters()}}),acf.models.EditMediaPopup=n.extend({id:"SelectMediaPopup",setup:function(t){t.button||(t.button=acf._x("Update","verb")),n.prototype.setup.apply(this,arguments)},addFrameEvents:function(i,t){i.on("open",function(){this.$el.closest(".media-modal").addClass("acf-expanded"),"browse"!=this.content.mode()&&this.content.mode("browse");var t=this.state().get("selection"),e=wp.media.attachment(i.acf.get("attachment"));t.add(e)},i),n.prototype.addFrameEvents.apply(this,arguments)}});new acf.Model({id:"customizePrototypes",wait:"ready",initialize:function(){var t;acf.isset(window,"wp","media","view")&&((t=e())&&acf.isset(wp,"media","view","settings","post")&&(wp.media.view.settings.post.id=t),this.customizeAttachmentsButton(),this.customizeAttachmentsRouter(),this.customizeAttachmentFilters(),this.customizeAttachmentCompat(),this.customizeAttachmentLibrary())},customizeAttachmentsButton:function(){var t;acf.isset(wp,"media","view","Button")&&(t=wp.media.view.Button,wp.media.view.Button=t.extend({initialize:function(){var t=_.defaults(this.options,this.defaults);this.model=new Backbone.Model(t),this.listenTo(this.model,"change",this.render)}}))},customizeAttachmentsRouter:function(){var t;acf.isset(wp,"media","view","Router")&&(t=wp.media.view.Router,wp.media.view.Router=t.extend({addExpand:function(){var t=a(['<a href="#" class="acf-expand-details">','<span class="is-closed"><i class="acf-icon -left -small"></i>'+acf.__("Expand Details")+"</span>",'<span class="is-open"><i class="acf-icon -right -small"></i>'+acf.__("Collapse Details")+"</span>","</a>"].join(""));t.on("click",function(t){t.preventDefault();t=a(this).closest(".media-modal");t.hasClass("acf-expanded")?t.removeClass("acf-expanded"):t.addClass("acf-expanded")}),this.$el.append(t)},initialize:function(){return t.prototype.initialize.apply(this,arguments),this.addExpand(),this}}))},customizeAttachmentFilters:function(){acf.isset(wp,"media","view","AttachmentFilters","All")&&(wp.media.view.AttachmentFilters.All.prototype.renderFilters=function(){this.$el.html(_.chain(this.filters).map(function(t,e){return{el:a("<option></option>").val(e).html(t.text)[0],priority:t.priority||50}},this).sortBy("priority").pluck("el").value())})},customizeAttachmentCompat:function(){var t,e;acf.isset(wp,"media","view","AttachmentCompat")&&(t=wp.media.view.AttachmentCompat,e=!1,wp.media.view.AttachmentCompat=t.extend({render:function(){return this.rendered?this:(t.prototype.render.apply(this,arguments),this.$("#acf-form-data").length&&(clearTimeout(e),e=setTimeout(a.proxy(function(){this.rendered=!0,acf.doAction("append",this.$el)},this),50)),this)},save:function(t){var e;t&&t.preventDefault(),e=acf.serializeForAjax(this.$el),this.controller.trigger("attachment:compat:waiting",["waiting"]),this.model.saveCompat(e).always(_.bind(this.postSave,this))}}))},customizeAttachmentLibrary:function(){var o;acf.isset(wp,"media","view","Attachment","Library")&&(o=wp.media.view.Attachment.Library,wp.media.view.Attachment.Library=o.extend({render:function(){var t=acf.isget(this,"controller","acf"),e=acf.isget(this,"model","attributes");return t&&e&&(e.acf_errors&&this.$el.addClass("acf-disabled"),(t=t.get("selected"))&&-1<t.indexOf(e.id)&&this.$el.addClass("acf-selected")),o.prototype.render.apply(this,arguments)},toggleSelection:function(t){this.collection;var e=this.options.selection,i=this.model,n=(e.single(),this.controller),a=acf.isget(this,"model","attributes","acf_errors"),s=n.$el.find(".media-frame-content .media-sidebar");if(s.children(".acf-selection-error").remove(),s.children().removeClass("acf-hidden"),n&&a){n=acf.isget(this,"model","attributes","filename");return s.children().addClass("acf-hidden"),s.prepend(['<div class="acf-selection-error">','<span class="selection-error-label">'+acf.__("Restricted")+"</span>",'<span class="selection-error-filename">'+n+"</span>",'<span class="selection-error-message">'+a+"</span>","</div>"].join("")),e.reset(),void e.single(i)}return o.prototype.toggleSelection.apply(this,arguments)}}))}})}(jQuery),function(u){acf.screen=new acf.Model({active:!0,xhr:!1,timeout:!1,wait:"load",events:{"change #page_template":"onChange","change #parent_id":"onChange","change #post-formats-select":"onChange","change .categorychecklist":"onChange","change .tagsdiv":"onChange",'change .acf-taxonomy-field[data-save="1"]':"onChange","change #product-type":"onChange"},isPost:function(){return"post"===acf.get("screen")},isUser:function(){return"user"===acf.get("screen")},isTaxonomy:function(){return"taxonomy"===acf.get("screen")},isAttachment:function(){return"attachment"===acf.get("screen")},isNavMenu:function(){return"nav_menu"===acf.get("screen")},isWidget:function(){return"widget"===acf.get("screen")},isComment:function(){return"comment"===acf.get("screen")},getPageTemplate:function(){var t=u("#page_template");return t.length?t.val():null},getPageParent:function(t,e){return(e=u("#parent_id")).length?e.val():null},getPageType:function(t,e){return this.getPageParent()?"child":"parent"},getPostType:function(){return u("#post_type").val()},getPostFormat:function(t,e){if((e=u("#post-formats-select input:checked")).length){e=e.val();return"0"==e?"standard":e}return null},getPostCoreTerms:function(){var t,e={},i=acf.serialize(u(".categorydiv, .tagsdiv"));for(t in i.tax_input&&(e=i.tax_input),i.post_category&&(e.category=i.post_category),e)acf.isArray(e[t])||(e[t]=e[t].split(/,[\s]?/));return e},getPostTerms:function(){var t,i=this.getPostCoreTerms();for(t in acf.getFields({type:"taxonomy"}).map(function(t){var e;t.get("save")&&(e=t.val(),t=t.get("taxonomy"),e&&(i[t]=i[t]||[],e=acf.isArray(e)?e:[e],i[t]=i[t].concat(e)))}),null!==(productType=this.getProductType())&&(i.product_type=[productType]),i)i[t]=acf.uniqueArray(i[t]);return i},getProductType:function(){var t=u("#product-type");return t.length?t.val():null},check:function(){var e;"post"===acf.get("screen")&&(this.xhr&&this.xhr.abort(),e=acf.parseArgs(this.data,{action:"acf/ajax/check_screen",screen:acf.get("screen"),exists:[]}),this.isPost()&&(e.post_id=acf.get("post_id")),null!==(postType=this.getPostType())&&(e.post_type=postType),null!==(pageTemplate=this.getPageTemplate())&&(e.page_template=pageTemplate),null!==(pageParent=this.getPageParent())&&(e.page_parent=pageParent),null!==(pageType=this.getPageType())&&(e.page_type=pageType),null!==(postFormat=this.getPostFormat())&&(e.post_format=postFormat),null!==(postTerms=this.getPostTerms())&&(e.post_terms=postTerms),acf.getPostboxes().map(function(t){e.exists.push(t.get("key"))}),e=acf.applyFilters("check_screen_args",e),this.xhr=u.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"json",context:this,success:function(t){"post"==acf.get("screen")?this.renderPostScreen(t):"user"==acf.get("screen")&&this.renderUserScreen(t),acf.doAction("check_screen_complete",t,e)}}))},onChange:function(t,e){this.setTimeout(this.check,1)},renderPostScreen:function(c){function l(t,e){var i,n=u._data(t[0]).events;for(i in n)for(var a=0;a<n[i].length;a++)e.on(i,n[i][a].handler)}function d(t,e){var i=e.indexOf(t);if(-1!=i){for(var n=i-1;0<=n;n--)if(u("#"+e[n]).length)return u("#"+e[n]).after(u("#"+t));for(n=i+1;n<e.length;n++)if(u("#"+e[n]).length)return u("#"+e[n]).before(u("#"+t))}}c.visible=[],c.hidden=[],c.results=c.results.map(function(e,t){var i=acf.getPostbox(e.id);if(acf.isGutenberg()&&"acf_after_title"==e.position&&(e.position="normal"),!i){a=(5.5<=parseFloat(acf.get("wp_version"))?['<div class="postbox-header">','<h2 class="hndle ui-sortable-handle">',"<span>"+acf.escHtml(e.title)+"</span>","</h2>",'<div class="handle-actions hide-if-no-js">','<button type="button" class="handlediv" aria-expanded="true">','<span class="screen-reader-text">Toggle panel: '+acf.escHtml(e.title)+"</span>",'<span class="toggle-indicator" aria-hidden="true"></span>',"</button>","</div>","</div>"]:['<button type="button" class="handlediv" aria-expanded="true">','<span class="screen-reader-text">Toggle panel: '+acf.escHtml(e.title)+"</span>",'<span class="toggle-indicator" aria-hidden="true"></span>',"</button>",'<h2 class="hndle ui-sortable-handle">',"<span>"+acf.escHtml(e.title)+"</span>","</h2>"]).join("");var n,a,s=u(['<div id="'+e.id+'" class="postbox">',a,'<div class="inside">',e.html,"</div>","</div>"].join(""));u("#adv-settings").length&&(n=u("#adv-settings .metabox-prefs"),a=u(['<label for="'+e.id+'-hide">','<input class="hide-postbox-tog" name="'+e.id+'-hide" type="checkbox" id="'+e.id+'-hide" value="'+e.id+'" checked="checked">'," "+e.title,"</label>"].join("")),l(n.find("input").first(),a.find("input")),n.append(a)),u(".postbox").length&&(l(u(".postbox .handlediv").first(),s.children(".handlediv")),l(u(".postbox .hndle").first(),s.children(".hndle"))),"side"===e.position?u("#"+e.position+"-sortables").append(s):u("#"+e.position+"-sortables").prepend(s);var o=[];if(c.results.map(function(t){e.position===t.position&&u("#"+e.position+"-sortables #"+t.id).length&&o.push(t.id)}),d(e.id,o),c.sorted)for(var r in c.sorted){o=c.sorted[r].split(",");if(d(e.id,o))break}i=acf.newPostbox(e),acf.doAction("append",s),acf.doAction("append_postbox",i)}return i.showEnable(),c.visible.push(e.id),e}),acf.getPostboxes().map(function(t){-1===c.visible.indexOf(t.get("id"))&&(t.hideDisable(),c.hidden.push(t.get("id")))}),u("#acf-style").html(c.style),acf.doAction("refresh_post_screen",c)},renderUserScreen:function(t){}});new acf.Model({postEdits:{},wait:"prepare",initialize:function(){acf.isGutenberg()&&(wp.data.subscribe(acf.debounce(this.onChange).bind(this)),acf.screen.getPageTemplate=this.getPageTemplate,acf.screen.getPageParent=this.getPageParent,acf.screen.getPostType=this.getPostType,acf.screen.getPostFormat=this.getPostFormat,acf.screen.getPostCoreTerms=this.getPostCoreTerms,acf.unload.disable(),5.3<=parseFloat(acf.get("wp_version"))&&this.addAction("refresh_post_screen",this.onRefreshPostScreen),wp.domReady(acf.refresh))},onChange:function(){var e=["template","parent","format"];(wp.data.select("core").getTaxonomies()||[]).map(function(t){e.push(t.rest_base)});var i=wp.data.select("core/editor").getPostEdits(),n={};e.map(function(t){void 0!==i[t]&&(n[t]=i[t])}),JSON.stringify(n)!==JSON.stringify(this.postEdits)&&(this.postEdits=n,acf.screen.check())},getPageTemplate:function(){return wp.data.select("core/editor").getEditedPostAttribute("template")},getPageParent:function(t,e){return wp.data.select("core/editor").getEditedPostAttribute("parent")},getPostType:function(){return wp.data.select("core/editor").getEditedPostAttribute("type")},getPostFormat:function(t,e){return wp.data.select("core/editor").getEditedPostAttribute("format")},getPostCoreTerms:function(){var i={};return(wp.data.select("core").getTaxonomies()||[]).map(function(t){var e=wp.data.select("core/editor").getEditedPostAttribute(t.rest_base);e&&(i[t.slug]=e)}),i},onRefreshPostScreen:function(e){var i=wp.data.select("core/edit-post"),t=wp.data.dispatch("core/edit-post"),n={};i.getActiveMetaBoxLocations().map(function(t){n[t]=i.getMetaBoxesPerLocation(t)});var a,s=[];for(a in n)n[a].map(function(t){s.push(t.id)});for(a in e.results.filter(function(t){return-1===s.indexOf(t.id)}).map(function(t,e){var i=t.position;n[i]=n[i]||[],n[i].push({id:t.id,title:t.title})}),n)n[a]=n[a].filter(function(t){return-1===e.hidden.indexOf(t.id)});t.setAvailableMetaBoxesPerLocation(n)}})}(jQuery),function(l){function n(){return acf.isset(window,"jQuery","fn","select2","amd")?4:!!acf.isset(window,"Select2")&&3}acf.newSelect2=function(t,e){return e=acf.parseArgs(e,{allowNull:!1,placeholder:"",multiple:!1,field:!1,ajax:!1,ajaxAction:"",ajaxData:function(t){return t},ajaxResults:function(t){return t}}),e=new(4==n()?a:s)(t,e),acf.doAction("new_select2",e),e};var i=acf.Model.extend({setup:function(t,e){l.extend(this.data,e),this.$el=t},initialize:function(){},selectOption:function(t){t=this.getOption(t);t.prop("selected")||t.prop("selected",!0).trigger("change")},unselectOption:function(t){t=this.getOption(t);t.prop("selected")&&t.prop("selected",!1).trigger("change")},getOption:function(t){return this.$('option[value="'+t+'"]')},addOption:function(t){t=acf.parseArgs(t,{id:"",text:"",selected:!1});var e=this.getOption(t.id);return e.length||((e=l("<option></option>")).html(t.text),e.attr("value",t.id),e.prop("selected",t.selected),this.$el.append(e)),e},getValue:function(){var e=[],t=this.$el.find("option:selected");return t.exists()&&(t=t.sort(function(t,e){return+t.getAttribute("data-i")-+e.getAttribute("data-i")})).each(function(){var t=l(this);e.push({$el:t,id:t.attr("value"),text:t.text()})}),e},mergeOptions:function(){},getChoices:function(){var i=function(t){var e=[];return t.children().each(function(){var t=l(this);t.is("optgroup")?e.push({text:t.attr("label"),children:i(t)}):e.push({id:t.attr("value"),text:t.text()})}),e};return i(this.$el)},getAjaxData:function(t){var e={action:this.get("ajaxAction"),s:t.term||"",paged:t.page||1},i=this.get("field");i&&(e.field_key=i.get("key"));var n=this.get("ajaxData");return n&&(e=n.apply(this,[e,t])),e=acf.applyFilters("select2_ajax_data",e,this.data,this.$el,i||!1,this),acf.prepareForAjax(e)},getAjaxResults:function(t,e){t=acf.parseArgs(t,{results:!1,more:!1});var i=this.get("ajaxResults");return i&&(t=i.apply(this,[t,e])),t=acf.applyFilters("select2_ajax_results",t,e,this)},processAjaxResults:function(t,e){return(t=this.getAjaxResults(t,e)).more&&(t.pagination={more:!0}),setTimeout(l.proxy(this.mergeOptions,this),1),t},destroy:function(){this.$el.data("select2")&&this.$el.select2("destroy"),this.$el.siblings(".select2-container").remove()}}),a=i.extend({initialize:function(){var e=this.$el;(n={width:"100%",allowClear:this.get("allowNull"),placeholder:this.get("placeholder"),multiple:this.get("multiple"),data:[],escapeMarkup:function(t){return acf.escHtml(t)}}).multiple&&this.getValue().map(function(t){t.$el.detach().appendTo(e)});var t=e.attr("data-ajax");void 0!==t&&(e.removeData("ajax"),e.removeAttr("data-ajax")),this.get("ajax")&&(n.ajax={url:acf.get("ajaxurl"),delay:250,dataType:"json",type:"post",cache:!1,data:l.proxy(this.getAjaxData,this),processResults:l.proxy(this.processAjaxResults,this)});var i=this.get("field"),n=acf.applyFilters("select2_args",n,e,this.data,i||!1,this);e.select2(n);var a,s=e.next(".select2-container");n.multiple&&((a=s.find("ul")).sortable({stop:function(t){a.find(".select2-selection__choice").each(function(){l(l(this).data("data").element).detach().appendTo(e)}),e.trigger("change")}}),e.on("select2:select",this.proxy(function(t){this.getOption(t.params.data.id).detach().appendTo(this.$el)}))),s.addClass("-acf"),void 0!==t&&e.attr("data-ajax",t),acf.doAction("select2_init",e,n,this.data,i||!1,this)},mergeOptions:function(){var i=!1,n=!1;l('.select2-results__option[role="group"]').each(function(){var t=l(this).children("ul"),e=l(this).children("strong");if(n&&n.text()===e.text())return i.append(t.children()),void l(this).remove();i=t,n=e})}}),s=i.extend({initialize:function(){var i=this.$el,n=this.getValue(),a=this.get("multiple"),t={width:"100%",allowClear:this.get("allowNull"),placeholder:this.get("placeholder"),separator:"||",multiple:this.get("multiple"),data:this.getChoices(),escapeMarkup:function(t){return acf.escHtml(t)},dropdownCss:{"z-index":"999999999"},initSelection:function(t,e){e(a?n:n.shift())}},e=i.siblings("input");e.length||(e=l('<input type="hidden" />'),i.before(e)),inputValue=n.map(function(t){return t.id}).join("||"),e.val(inputValue),t.multiple&&n.map(function(t){t.$el.detach().appendTo(i)}),t.allowClear&&(t.data=t.data.filter(function(t){return""!==t.id})),i.removeData("ajax"),i.removeAttr("data-ajax"),this.get("ajax")&&(t.ajax={url:acf.get("ajaxurl"),quietMillis:250,dataType:"json",type:"post",cache:!1,data:l.proxy(this.getAjaxData,this),results:l.proxy(this.processAjaxResults,this)});var s=this.get("field"),t=acf.applyFilters("select2_args",t,i,this.data,s||!1,this);e.select2(t);var o,r=e.select2("container"),c=l.proxy(this.getOption,this);t.multiple&&(o=r.find("ul")).sortable({stop:function(){o.find(".select2-search-choice").each(function(){var t=l(this).data("select2Data");c(t.id).detach().appendTo(i)}),i.trigger("change")}}),e.on("select2-selecting",function(t){var e=t.choice,t=c(e.id);(t=!t.length?l('<option value="'+e.id+'">'+e.text+"</option>"):t).detach().appendTo(i)}),r.addClass("-acf"),acf.doAction("select2_init",i,t,this.data,s||!1,this),e.on("change",function(){var t=e.val();t.indexOf("||")&&(t=t.split("||")),i.val(t).trigger("change")}),i.hide()},mergeOptions:function(){var i=!1;l("#select2-drop .select2-result-with-children").each(function(){var t=l(this).children("ul"),e=l(this).children(".select2-result-label");if(i&&i.text()===e.text())return i.append(t.children()),void l(this).remove();i=e})},getAjaxData:function(t,e){return i.prototype.getAjaxData.apply(this,[{term:t,page:e}])}});new acf.Model({priority:5,wait:"prepare",actions:{duplicate:"onDuplicate"},initialize:function(){var t=acf.get("locale"),e=(acf.get("rtl"),acf.get("select2L10n")),i=n();return!!e&&(0!==t.indexOf("en")&&void(4==i?this.addTranslations4():3==i&&this.addTranslations3()))},addTranslations4:function(){var e=acf.get("select2L10n"),t=(t=acf.get("locale")).replace("_","-"),i={errorLoading:function(){return e.load_fail},inputTooLong:function(t){t=t.input.length-t.maximum;return 1<t?e.input_too_long_n.replace("%d",t):e.input_too_long_1},inputTooShort:function(t){t=t.minimum-t.input.length;return 1<t?e.input_too_short_n.replace("%d",t):e.input_too_short_1},loadingMore:function(){return e.load_more},maximumSelected:function(t){t=t.maximum;return 1<t?e.selection_too_long_n.replace("%d",t):e.selection_too_long_1},noResults:function(){return e.matches_0},searching:function(){return e.searching}};jQuery.fn.select2.amd.define("select2/i18n/"+t,[],function(){return i})},addTranslations3:function(){var i=acf.get("select2L10n"),t=(t=acf.get("locale")).replace("_","-"),e={formatMatches:function(t){return 1<t?i.matches_n.replace("%d",t):i.matches_1},formatNoMatches:function(){return i.matches_0},formatAjaxError:function(){return i.load_fail},formatInputTooShort:function(t,e){t=e-t.length;return 1<t?i.input_too_short_n.replace("%d",t):i.input_too_short_1},formatInputTooLong:function(t,e){e=t.length-e;return 1<e?i.input_too_long_n.replace("%d",e):i.input_too_long_1},formatSelectionTooBig:function(t){return 1<t?i.selection_too_long_n.replace("%d",t):i.selection_too_long_1},formatLoadMore:function(){return i.load_more},formatSearching:function(){return i.searching}};l.fn.select2.locales=l.fn.select2.locales||{},l.fn.select2.locales[t]=e,l.extend(l.fn.select2.defaults,e)},onDuplicate:function(t,e){e.find(".select2-container").remove()}})}(jQuery),function(l){acf.tinymce={defaults:function(){return"undefined"!=typeof tinyMCEPreInit&&{tinymce:tinyMCEPreInit.mceInit.acf_content,quicktags:tinyMCEPreInit.qtInit.acf_content}},initialize:function(t,e){(e=acf.parseArgs(e,{tinymce:!0,quicktags:!0,toolbar:"full",mode:"visual",field:!1})).tinymce&&this.initializeTinymce(t,e),e.quicktags&&this.initializeQuicktags(t,e)},initializeTinymce:function(t,e){var i=l("#"+t),n=this.defaults(),a=acf.get("toolbars"),s=e.field||!1;s.$el;if("undefined"==typeof tinymce)return!1;if(!n)return!1;if(tinymce.get(t))return this.enable(t);var o=l.extend({},n.tinymce,e.tinymce);o.id=t,o.selector="#"+t;var r=e.toolbar;if(r&&a&&a[r])for(var c=1;c<=4;c++)o["toolbar"+c]=a[r][c]||"";if(o.setup=function(e){e.on("change",function(t){e.save(),i.trigger("change")}),e.on("mouseup",function(t){var e=new MouseEvent("mouseup");window.dispatchEvent(e)})},o.wp_autoresize_on=!1,o.tadv_noautop||(o.wpautop=!0),o=acf.applyFilters("wysiwyg_tinymce_settings",o,t,s),tinyMCEPreInit.mceInit[t]=o,"visual"==e.mode){tinymce.init(o);t=tinymce.get(t);if(!t)return!1;t.acf=e.field,acf.doAction("wysiwyg_tinymce_init",t,t.id,o,s)}},initializeQuicktags:function(t,e){var i=this.defaults();if("undefined"==typeof quicktags)return!1;if(!i)return!1;(i=l.extend({},i.quicktags,e.quicktags)).id=t;e=e.field||!1,e.$el,i=acf.applyFilters("wysiwyg_quicktags_settings",i,i.id,e);tinyMCEPreInit.qtInit[t]=i;t=quicktags(i);if(!t)return!1;this.buildQuicktags(t),acf.doAction("wysiwyg_quicktags_init",t,t.id,i,e)},buildQuicktags:function(t){t.canvas;var e,i,n=t.name,a=t.settings,s="",o={},r="",c=t.id;for(i in a.buttons&&(r=","+a.buttons+","),edButtons)edButtons[i]&&(e=edButtons[i].id,r&&-1!==",strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,".indexOf(","+e+",")&&-1===r.indexOf(","+e+",")||edButtons[i].instance&&edButtons[i].instance!==c||(o[e]=edButtons[i],edButtons[i].html&&(s+=edButtons[i].html(n+"_"))));r&&-1!==r.indexOf(",dfw,")&&(o.dfw=new QTags.DFWButton,s+=o.dfw.html(n+"_")),"rtl"===document.getElementsByTagName("html")[0].dir&&(o.textdirection=new QTags.TextDirectionButton,s+=o.textdirection.html(n+"_")),t.toolbar.innerHTML=s,t.theButtons=o,"undefined"!=typeof jQuery&&jQuery(document).triggerHandler("quicktags-init",[t])},disable:function(t){this.destroyTinymce(t)},remove:function(t){this.destroyTinymce(t)},destroy:function(t){this.destroyTinymce(t)},destroyTinymce:function(t){if("undefined"==typeof tinymce)return!1;t=tinymce.get(t);return!!t&&(t.save(),t.destroy(),!0)},enable:function(t){this.enableTinymce(t)},enableTinymce:function(t){return"undefined"!=typeof switchEditors&&(void 0!==tinyMCEPreInit.mceInit[t]&&(l("#"+t).show(),switchEditors.go(t,"tmce"),!0))}};new acf.Model({priority:5,actions:{prepare:"onPrepare",ready:"onReady"},onPrepare:function(){var t=l("#acf-hidden-wp-editor");t.exists()&&t.appendTo("body")},onReady:function(){acf.isset(window,"wp","oldEditor")&&(wp.editor.autop=wp.oldEditor.autop,wp.editor.removep=wp.oldEditor.removep),acf.isset(window,"tinymce","on")&&tinymce.on("AddEditor",function(t){t=t.editor;"acf"===t.id.substr(0,3)&&(t=tinymce.editors.content||t,tinymce.activeEditor=t,wpActiveEditor=t.id)})}})}(jQuery),function(c){function n(t){return t.data("acf")||new e(t)}var e=acf.Model.extend({id:"Validator",data:{errors:[],notice:null,status:""},events:{"changed:status":"onChangeStatus"},addErrors:function(t){t.map(this.addError,this)},addError:function(t){this.data.errors.push(t)},hasErrors:function(){return this.data.errors.length},clearErrors:function(){return this.data.errors=[]},getErrors:function(){return this.data.errors},getFieldErrors:function(){var i=[],n=[];return this.getErrors().map(function(t){var e;t.input&&(-1<(e=n.indexOf(t.input))?i[e]=t:(i.push(t),n.push(t.input)))}),i},getGlobalErrors:function(){return this.getErrors().filter(function(t){return!t.input})},showErrors:function(){var t,i,n,e,a;this.hasErrors()&&(t=this.getFieldErrors(),a=this.getGlobalErrors(),i=0,n=!1,t.map(function(t){var e=this.$('[name="'+t.input+'"]').first();(e=!e.length?this.$('[name^="'+t.input+'"]').first():e).length&&(i++,(e=acf.getClosestField(e)).showError(t.message),n=n||e.$el)},this),e=acf.__("Validation failed"),a.map(function(t){e+=". "+t.message}),1==i?e+=". "+acf.__("1 field requires attention"):1<i&&(e+=". "+acf.__("%d fields require attention").replace("%d",i)),this.has("notice")?this.get("notice").update({type:"error",text:e}):(a=acf.newNotice({type:"error",text:e,target:this.$el}),this.set("notice",a)),n=n||this.get("notice").$el,setTimeout(function(){c("html, body").animate({scrollTop:n.offset().top-c(window).height()/2},500)},10))},onChangeStatus:function(t,e,i,n){this.$el.removeClass("is-"+n).addClass("is-"+i)},validate:function(t){if(t=acf.parseArgs(t,{event:!1,reset:!1,loading:function(){},complete:function(){},failure:function(){},success:function(t){t.submit()}}),"valid"==this.get("status"))return!0;if("validating"==this.get("status"))return!1;if(!this.$(".acf-field").length)return!0;var e;t.event&&(e=c.Event(null,t.event),t.success=function(){acf.enableSubmit(c(e.target)).trigger(e)}),acf.doAction("validation_begin",this.$el),acf.lockForm(this.$el),t.loading(this.$el,this),this.set("status","validating");var i=acf.serialize(this.$el);return i.action="acf/validate_save_post",c.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(i),type:"post",dataType:"json",context:this,success:function(t){acf.isAjaxSuccess(t)&&((t=acf.applyFilters("validation_complete",t.data,this.$el,this)).valid||this.addErrors(t.errors))},complete:function(){acf.unlockForm(this.$el),this.hasErrors()?(this.set("status","invalid"),acf.doAction("validation_failure",this.$el,this),this.showErrors(),t.failure(this.$el,this)):(this.set("status","valid"),this.has("notice")&&this.get("notice").update({type:"success",text:acf.__("Validation successful"),timeout:1e3}),acf.doAction("validation_success",this.$el,this),acf.doAction("submit",this.$el),t.success(this.$el,this),acf.lockForm(this.$el),t.reset&&this.reset()),t.complete(this.$el,this),this.clearErrors()}}),!1},setup:function(t){this.$el=t},reset:function(){this.set("errors",[]),this.set("notice",null),this.set("status",""),acf.unlockForm(this.$el)}});acf.validateForm=function(t){return n(t.form).validate(t)},acf.enableSubmit=function(t){return t.removeClass("disabled")},acf.disableSubmit=function(t){return t.addClass("disabled")},acf.showSpinner=function(t){return t.addClass("is-active"),t.css("display","inline-block"),t},acf.hideSpinner=function(t){return t.removeClass("is-active"),t.css("display","none"),t},acf.lockForm=function(t){var e=a(t),i=e.find('.button, [type="submit"]'),e=e.find(".spinner, .acf-spinner");return acf.hideSpinner(e),acf.disableSubmit(i),acf.showSpinner(e.last()),t},acf.unlockForm=function(t){var e=a(t),i=e.find('.button, [type="submit"]'),e=e.find(".spinner, .acf-spinner");return acf.enableSubmit(i),acf.hideSpinner(e),t};var a=function(t){var e=t.find("#submitdiv");return e.length||(e=t.find("#submitpost")).length||(e=t.find("p.submit").last()).length||(e=t.find(".acf-form-submit")).length?e:t},s=acf.debounce(function(t){t.submit()});acf.validation=new acf.Model({id:"validation",active:!0,wait:"prepare",actions:{ready:"addInputEvents",append:"addInputEvents"},events:{'click input[type="submit"]':"onClickSubmit",'click button[type="submit"]':"onClickSubmit","click #save-post":"onClickSave","submit form#post":"onSubmitPost","submit form":"onSubmit"},initialize:function(){acf.get("validation")||(this.active=!1,this.actions={},this.events={})},enable:function(){this.active=!0},disable:function(){this.active=!1},reset:function(t){n(t).reset()},addInputEvents:function(t){"safari"===acf.get("browser")||(t=c(".acf-field [name]",t)).length&&this.on(t,"invalid","onInvalid")},onInvalid:function(t,e){t.preventDefault();var i=e.closest("form");i.length&&(n(i).addError({input:e.attr("name"),message:acf.strEscape(t.target.validationMessage)}),s(i))},onClickSubmit:function(t,e){this.set("originalEvent",t)},onClickSave:function(t,e){this.set("ignore",!0)},onClickSubmitGutenberg:function(t,e){acf.validateForm({form:c("#editor"),event:t,reset:!0,failure:function(t,e){e=e.get("notice").$el;e.appendTo(".components-notice-list"),e.find(".acf-notice-dismiss").removeClass("small")}})||(t.preventDefault(),t.stopImmediatePropagation())},onSubmitPost:function(t,e){"dopreview"===c("input#wp-preview").val()&&(this.set("ignore",!0),acf.unlockForm(e))},onSubmit:function(t,e){if(!this.active||this.get("ignore")||t.isDefaultPrevented())return this.allowSubmit();acf.validateForm({form:e,event:this.get("originalEvent")})||t.preventDefault()},allowSubmit:function(){return this.set("ignore",!1),this.set("originalEvent",!1),!0}});new acf.Model({wait:"prepare",initialize:function(){acf.isGutenberg()&&this.customizeEditor()},customizeEditor:function(){var n=wp.data.dispatch("core/editor"),e=wp.data.select("core/editor"),a=wp.data.dispatch("core/notices"),s=n.savePost,o=!1,r="";wp.data.subscribe(function(){var t=e.getEditedPostAttribute("status");o="publish"===t,r="publish"!==t?t:r}),n.savePost=function(e){e=e||{};var t=this,i=arguments;return new Promise(function(t,i){return e.isAutosave||e.isPreview?t("Validation ignored (autosave)."):o?void(acf.validateForm({form:c("#editor"),reset:!0,complete:function(t,e){n.unlockPostSaving("acf")},failure:function(t,e){e=e.get("notice");a.createErrorNotice(e.get("text"),{id:"acf-validation",isDismissible:!0}),e.remove(),r&&n.editPost({status:r}),i("Validation failed.")},success:function(){a.removeNotice("acf-validation"),t("Validation success.")}})?t("Validation bypassed."):n.lockPostSaving("acf")):t("Validation ignored (draft).")}).then(function(){return s.apply(t,i)})}}})}(jQuery),function(c){new acf.Model({priority:90,actions:{new_field:"refresh",show_field:"refresh",hide_field:"refresh",remove_field:"refresh",unmount_field:"refresh",remount_field:"refresh"},refresh:function(){acf.refresh()}}),new acf.Model({priority:1,actions:{sortstart:"onSortstart",sortstop:"onSortstop"},onSortstart:function(t){acf.doAction("unmount",t)},onSortstop:function(t){acf.doAction("remount",t)}}),new acf.Model({actions:{sortstart:"onSortstart"},onSortstart:function(t,e){t.is("tr")&&(e.html('<td style="padding:0;" colspan="'+e.children().length+'"></td>'),t.addClass("acf-sortable-tr-helper"),t.children().each(function(){c(this).width(c(this).width())}),e.height(t.height()+"px"),t.removeClass("acf-sortable-tr-helper"))}}),new acf.Model({actions:{after_duplicate:"onAfterDuplicate"},onAfterDuplicate:function(t,e){var i=[];t.find("select").each(function(t){i.push(c(this).val())}),e.find("select").each(function(t){c(this).val(i[t])})}}),new acf.Model({id:"tableHelper",priority:20,actions:{refresh:"renderTables"},renderTables:function(t){var e=this;c(".acf-table:visible").each(function(){e.renderTable(c(this))})},renderTable:function(t){var e=t.find("> thead > tr:visible > th[data-key]"),a=t.find("> tbody > tr:visible > td[data-key]");if(!e.length||!a.length)return!1;e.each(function(t){var e=c(this),i=e.data("key"),n=a.filter('[data-key="'+i+'"]'),i=n.filter(".acf-hidden");n.removeClass("acf-empty"),n.length===i.length?acf.hide(e):(acf.show(e),i.addClass("acf-empty"))}),e.css("width","auto");var e=e.not(".acf-hidden"),i=100;e.length;e.filter("[data-width]").each(function(){var t=c(this).data("width");c(this).css("width",t+"%"),i-=t});var n=e.not("[data-width]");n.length&&(t=i/n.length,n.css("width",t+"%"),i=0),0<i&&e.last().css("width","auto"),a.filter(".-collapsed-target").each(function(){var t=c(this);t.parent().hasClass("-collapsed")?t.attr("colspan",e.length):t.removeAttr("colspan")})}}),new acf.Model({id:"fieldsHelper",priority:30,actions:{refresh:"renderGroups"},renderGroups:function(){var t=this;c(".acf-fields:visible").each(function(){t.renderGroup(c(this))})},renderGroup:function(t){var s=0,o=0,r=c(),e=t.children(".acf-field[data-width]:visible");return!!e.length&&(t.hasClass("-left")?(e.removeAttr("data-width"),e.css("width","auto"),!1):(e.removeClass("-r0 -c0").css({"min-height":0}),e.each(function(t){var e=c(this),i=e.position(),n=Math.ceil(i.top),a=Math.ceil(i.left);r.length&&s<n&&(r.css({"min-height":o+"px"}),i=e.position(),n=Math.ceil(i.top),a=Math.ceil(i.left),o=s=0,r=c()),acf.get("rtl")&&(a=Math.ceil(e.parent().width()-(i.left+e.outerWidth()))),0==n?e.addClass("-r0"):0==a&&e.addClass("-c0");a=Math.ceil(e.outerHeight())+1;o=Math.max(o,a),s=Math.max(s,n),r=r.add(e)}),void(r.length&&r.css({"min-height":o+"px"}))))}}),new acf.Model({id:"bodyClassShiftHelper",events:{keydown:"onKeyDown",keyup:"onKeyUp"},isShiftKey:function(t){return 16===t.keyCode},onKeyDown:function(t){this.isShiftKey(t)&&c("body").addClass("acf-keydown-shift")},onKeyUp:function(t){this.isShiftKey(t)&&c("body").removeClass("acf-keydown-shift")}})}(jQuery),function(s){acf.newCompatibility=function(t,e){return(e=e||{}).__proto__=t.__proto__,t.__proto__=e,t.compatibility=e},acf.getCompatibility=function(t){return t.compatibility||null};var r=acf.newCompatibility(acf,{l10n:{},o:{},fields:{},update:acf.set,add_action:acf.addAction,remove_action:acf.removeAction,do_action:acf.doAction,add_filter:acf.addFilter,remove_filter:acf.removeFilter,apply_filters:acf.applyFilters,parse_args:acf.parseArgs,disable_el:acf.disable,disable_form:acf.disable,enable_el:acf.enable,enable_form:acf.enable,update_user_setting:acf.updateUserSetting,prepare_for_ajax:acf.prepareForAjax,is_ajax_success:acf.isAjaxSuccess,remove_el:acf.remove,remove_tr:acf.remove,str_replace:acf.strReplace,render_select:acf.renderSelect,get_uniqid:acf.uniqid,serialize_form:acf.serialize,esc_html:acf.strEscape,str_sanitize:acf.strSanitize});r._e=function(t,e){t=t||"";var i=(e=e||"")?t+"."+e:t,n={"image.select":"Select Image","image.edit":"Edit Image","image.update":"Update Image"};if(n[i])return acf.__(n[i]);t=this.l10n[t]||"";return t=e?t[e]||"":t},r.get_selector=function(t){var e=".acf-field";if(!t)return e;if(s.isPlainObject(t)){if(s.isEmptyObject(t))return e;for(var i in t){t=t[i];break}}return e+="-"+t,e=acf.strReplace("_","-",e),e=acf.strReplace("field-field-","field-",e)},r.get_fields=function(t,e,i){i={is:t||"",parent:e||!1,suppressFilters:i||!1};return i.is&&(i.is=this.get_selector(i.is)),acf.findFields(i)},r.get_field=function(t,e){var i=this.get_fields.apply(this,arguments);return!!i.length&&i.first()},r.get_closest_field=function(t,e){return t.closest(this.get_selector(e))},r.get_field_wrap=function(t){return t.closest(this.get_selector())},r.get_field_key=function(t){return t.data("key")},r.get_field_type=function(t){return t.data("type")},r.get_data=function(t,e){return acf.parseArgs(t.data(),e)},r.maybe_get=function(t,e,i){void 0===i&&(i=null),keys=String(e).split(".");for(var n=0;n<keys.length;n++){if(!t.hasOwnProperty(keys[n]))return i;t=t[keys[n]]}return t};function i(t){return t instanceof acf.Field?t.$el:t}function c(e){return function(){var t;return t=arguments.length?(t=arguments,acf.arrayArgs(t).map(i)):[s(document)],e.apply(this,t)}}r.add_action=function(t,e,i,n){var a=t.split(" "),s=a.length;if(1<s){for(var o=0;o<s;o++)t=a[o],r.add_action.apply(this,arguments);return this}e=c(e);return acf.addAction.apply(this,arguments)},r.add_filter=function(t,e,i,n){e=c(e);return acf.addFilter.apply(this,arguments)},r.model={actions:{},filters:{},events:{},extend:function(t){var i=s.extend({},this,t);return s.each(i.actions,function(t,e){i._add_action(t,e)}),s.each(i.filters,function(t,e){i._add_filter(t,e)}),s.each(i.events,function(t,e){i._add_event(t,e)}),i},_add_action:function(t,e){var i=t.split(" "),t=i[0]||"",i=i[1]||10;acf.add_action(t,this[e],i,this)},_add_filter:function(t,e){var i=t.split(" "),t=i[0]||"",i=i[1]||10;acf.add_filter(t,this[e],i,this)},_add_event:function(t,e){var i=this,n=t.indexOf(" "),a=0<n?t.substr(0,n):t,t=0<n?t.substr(n+1):"",n=function(t){t.$el=s(this),acf.field_group&&(t.$field=t.$el.closest(".acf-field-object")),"function"==typeof i.event&&(t=i.event(t)),i[e].apply(i,arguments)};t?s(document).on(a,t,n):s(document).on(a,n)},get:function(t,e){return e=e||null,e=void 0!==this[t]?this[t]:e},set:function(t,e){return this[t]=e,"function"==typeof this["_set_"+t]&&this["_set_"+t].apply(this),this}},r.field=acf.model.extend({type:"",o:{},$field:null,_add_action:function(t,e){var i=this;t=t+"_field/type="+i.type,acf.add_action(t,function(t){i.set("$field",t),i[e].apply(i,arguments)})},_add_filter:function(t,e){var i=this;t=t+"_field/type="+i.type,acf.add_filter(t,function(t){i.set("$field",t),i[e].apply(i,arguments)})},_add_event:function(t,n){var a=this,e=t.substr(0,t.indexOf(" ")),i=t.substr(t.indexOf(" ")+1),t=acf.get_selector(a.type);s(document).on(e,t+" "+i,function(t){var e=s(this),i=acf.get_closest_field(e,a.type);i.length&&(i.is(a.$field)||a.set("$field",i),t.$el=e,t.$field=i,a[n].apply(a,[t]))})},_set_$field:function(){"function"==typeof this.focus&&this.focus()},doFocus:function(t){return this.set("$field",t)}});acf.newCompatibility(acf.validation,{remove_error:function(t){acf.getField(t).removeError()},add_warning:function(t,e){acf.getField(t).showNotice({text:e,type:"warning",timeout:1e3})},fetch:acf.validateForm,enableSubmit:acf.enableSubmit,disableSubmit:acf.disableSubmit,showSpinner:acf.showSpinner,hideSpinner:acf.hideSpinner,unlockForm:acf.unlockForm,lockForm:acf.lockForm});r.tooltip={tooltip:function(t,e){return acf.newTooltip({text:t,target:e}).$el},temp:function(t,e){acf.newTooltip({text:t,target:e,timeout:250})},confirm:function(t,e,i,n,a){acf.newTooltip({confirm:function(){e(!0)},text:i,target:t,cancel:function(){e(!1)}})},confirm_remove:function(t,e){acf.newTooltip({confirmRemove:!0,target:t,confirm:function(){e(!0)},cancel:function(){e(!1)}})}},r.media=new acf.Model({activeFrame:!1,actions:{new_media_popup:"onNewMediaPopup"},frame:function(){return this.activeFrame},onNewMediaPopup:function(t){this.activeFrame=t.frame},popup:function(t){return t.mime_types&&(t.allowedTypes=t.mime_types),t.id&&(t.attachment=t.id),acf.newMediaPopup(t).frame}}),r.select2={init:function(t,e,i){return e.allow_null&&(e.allowNull=e.allow_null),e.ajax_action&&(e.ajaxAction=e.ajax_action),i&&(e.field=acf.getField(i)),acf.newSelect2(t,e)},destroy:function(t){return acf.getInstance(t).destroy()}},r.postbox={render:function(t){return t.edit_url&&(t.editLink=t.edit_url),t.edit_title&&(t.editTitle=t.edit_title),acf.newPostbox(t)}},acf.newCompatibility(acf.screen,{update:function(){return this.set.apply(this,arguments)},fetch:acf.screen.check}),r.ajax=acf.screen}(jQuery);
|
1 |
+
!function(e,i){var a=[];acf.Field=acf.Model.extend({type:"",eventScope:".acf-field",wait:"ready",setup:function(t){this.$el=t,this.inherit(t),this.inherit(this.$control())},val:function(t){return t!==i?this.setValue(t):this.prop("disabled")?null:this.getValue()},getValue:function(){return this.$input().val()},setValue:function(t){return acf.val(this.$input(),t)},__:function(t){return acf._e(this.type,t)},$control:function(){return!1},$input:function(){return this.$("[name]:first")},$inputWrap:function(){return this.$(".acf-input:first")},$labelWrap:function(){return this.$(".acf-label:first")},getInputName:function(){return this.$input().attr("name")||""},parent:function(){var t=this.parents();return!!t.length&&t[0]},parents:function(){var t=this.$el.parents(".acf-field");return acf.getFields(t)},show:function(t,e){t=acf.show(this.$el,t);return t&&(this.prop("hidden",!1),acf.doAction("show_field",this,e)),t},hide:function(t,e){t=acf.hide(this.$el,t);return t&&(this.prop("hidden",!0),acf.doAction("hide_field",this,e)),t},enable:function(t,e){t=acf.enable(this.$el,t);return t&&(this.prop("disabled",!1),acf.doAction("enable_field",this,e)),t},disable:function(t,e){t=acf.disable(this.$el,t);return t&&(this.prop("disabled",!0),acf.doAction("disable_field",this,e)),t},showEnable:function(t,e){return this.enable.apply(this,arguments),this.show.apply(this,arguments)},hideDisable:function(t,e){return this.disable.apply(this,arguments),this.hide.apply(this,arguments)},showNotice:function(t){"object"!=typeof t&&(t={text:t}),this.notice&&this.notice.remove(),t.target=this.$inputWrap(),this.notice=acf.newNotice(t)},removeNotice:function(t){this.notice&&(this.notice.away(t||0),this.notice=!1)},showError:function(t){this.$el.addClass("acf-error"),t!==i&&this.showNotice({text:t,type:"error",dismiss:!1}),acf.doAction("invalid_field",this),this.$el.one("focus change","input, select, textarea",e.proxy(this.removeError,this))},removeError:function(){this.$el.removeClass("acf-error"),this.removeNotice(250),acf.doAction("valid_field",this)},trigger:function(t,e,i){return"invalidField"==t&&(i=!0),acf.Model.prototype.trigger.apply(this,[t,e,i])}}),acf.newField=function(t){var e=t.data("type"),e=n(e),t=new(acf.models[e]||acf.Field)(t);return acf.doAction("new_field",t),t};var n=function(t){return acf.strPascalCase(t||"")+"Field"};acf.registerFieldType=function(t){var e=t.prototype.type,i=n(e);acf.models[i]=t,a.push(e)},acf.getFieldType=function(t){t=n(t);return acf.models[t]||!1},acf.getFieldTypes=function(i){i=acf.parseArgs(i,{category:""});var n=[];return a.map(function(t){var e=acf.getFieldType(t),t=e.prototype;i.category&&t.category!==i.category||n.push(e)}),n}}(jQuery),function(n){acf.findFields=function(t){var e=".acf-field",i=!1;return(t=!(t=acf.parseArgs(t,{key:"",name:"",type:"",is:"",parent:!1,sibling:!1,limit:!1,visible:!1,suppressFilters:!1})).suppressFilters?acf.applyFilters("find_fields_args",t):t).key&&(e+='[data-key="'+t.key+'"]'),t.type&&(e+='[data-type="'+t.type+'"]'),t.name&&(e+='[data-name="'+t.name+'"]'),t.is&&(e+=t.is),t.visible&&(e+=":visible"),i=t.parent?t.parent.find(e):t.sibling?t.sibling.siblings(e):n(e),t.suppressFilters||(i=i.not(".acf-clone .acf-field"),i=acf.applyFilters("find_fields",i)),i=t.limit?i.slice(0,t.limit):i},acf.findField=function(t,e){return acf.findFields({key:t,limit:1,parent:e,suppressFilters:!0})},acf.getField=function(t){return(t=!(t instanceof jQuery)?acf.findField(t):t).data("acf")||acf.newField(t)},acf.getFields=function(t){t instanceof jQuery||(t=acf.findFields(t));var e=[];return t.each(function(){var t=acf.getField(n(this));e.push(t)}),e},acf.findClosestField=function(t){return t.closest(".acf-field")},acf.getClosestField=function(t){t=acf.findClosestField(t);return this.getField(t)};var e=function(t){var a=t+"_field",s=t+"Field";acf.addAction(a,function(e){var i=acf.arrayArgs(arguments),n=i.slice(1);["type","name","key"].map(function(t){t="/"+t+"="+e.get(t);i=[a+t,e].concat(n),acf.doAction.apply(null,i)}),-1<o.indexOf(t)&&e.trigger(s,n)})},o=["remove","unmount","remount","sortstart","sortstop","show","hide","unload","valid","invalid","enable","disable","duplicate"];["prepare","ready","load","append","remove","unmount","remount","sortstart","sortstop","show","hide","unload"].map(function(t){var n=t+"_fields",a=t+"_field";acf.addAction(t,function(t){var e=acf.arrayArgs(arguments).slice(1),i=acf.getFields({parent:t});i.length&&(e=[n,i].concat(e),acf.doAction.apply(null,e))}),acf.addAction(n,function(t){var i=acf.arrayArgs(arguments).slice(1);t.map(function(t,e){t=[a,t].concat(i);acf.doAction.apply(null,t)})}),e(t)}),["valid","invalid","enable","disable","new","duplicate"].map(e);new acf.Model({id:"fieldsEventManager",events:{'click .acf-field a[href="#"]':"onClick","change .acf-field":"onChange"},onClick:function(t){t.preventDefault()},onChange:function(){n("#_acf_changed").val(1)}}),new acf.Model({id:"duplicateFieldsManager",actions:{duplicate:"onDuplicate",duplicate_fields:"onDuplicateFields"},onDuplicate:function(t,e){t=acf.getFields({parent:t});t.length&&(e=acf.findFields({parent:e}),acf.doAction("duplicate_fields",t,e))},onDuplicateFields:function(t,i){t.map(function(t,e){acf.doAction("duplicate_field",t,n(i[e]))})}})}(jQuery),function(c){var l=0,t=acf.Field.extend({type:"accordion",wait:"",$control:function(){return this.$(".acf-fields:first")},initialize:function(){if(!this.$el.hasClass("acf-accordion")&&!this.$el.is("td")){if(this.get("endpoint"))return this.remove();var t,e,i=this.$el,n=this.$labelWrap(),a=this.$inputWrap(),s=this.$control(),o=a.children(".description");o.length&&n.append(o),this.$el.is("tr")&&(r=this.$el.closest("table"),t=c('<div class="acf-accordion-title"/>'),e=c('<div class="acf-accordion-content"/>'),o=c('<table class="'+r.attr("class")+'"/>'),r=c("<tbody/>"),t.append(n.html()),o.append(r),e.append(o),a.append(t),a.append(e),n.remove(),s.remove(),a.attr("colspan",2),n=t,a=e,s=r),i.addClass("acf-accordion"),n.addClass("acf-accordion-title"),a.addClass("acf-accordion-content"),l++,this.get("multi_expand")&&i.attr("multi-expand",1);var r=acf.getPreference("this.accordions")||[];void 0!==r[l-1]&&this.set("open",r[l-1]),this.get("open")&&(i.addClass("-open"),a.css("display","block")),n.prepend(d.iconHtml({open:this.get("open")}));n=i.parent();s.addClass(n.hasClass("-left")?"-left":""),s.addClass(n.hasClass("-clear")?"-clear":""),s.append(i.nextUntil(".acf-field-accordion",".acf-field")),s.removeAttr("data-open data-multi_expand data-endpoint")}}});acf.registerFieldType(t);var d=new acf.Model({actions:{unload:"onUnload"},events:{"click .acf-accordion-title":"onClick","invalidField .acf-accordion":"onInvalidField"},isOpen:function(t){return t.hasClass("-open")},toggle:function(t){this.isOpen(t)?this.close(t):this.open(t)},iconHtml:function(t){return acf.isGutenberg()?t.open?'<svg class="acf-accordion-icon" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" focusable="false"><g><path fill="none" d="M0,0h24v24H0V0z"></path></g><g><path d="M12,8l-6,6l1.41,1.41L12,10.83l4.59,4.58L18,14L12,8z"></path></g></svg>':'<svg class="acf-accordion-icon" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" focusable="false"><g><path fill="none" d="M0,0h24v24H0V0z"></path></g><g><path d="M7.41,8.59L12,13.17l4.59-4.58L18,10l-6,6l-6-6L7.41,8.59z"></path></g></svg>':t.open?'<i class="acf-accordion-icon dashicons dashicons-arrow-down"></i>':'<i class="acf-accordion-icon dashicons dashicons-arrow-right"></i>'},open:function(t){var e=acf.isGutenberg()?0:300;t.find(".acf-accordion-content:first").slideDown(e).css("display","block"),t.find(".acf-accordion-icon:first").replaceWith(this.iconHtml({open:!0})),t.addClass("-open"),acf.doAction("show",t),t.attr("multi-expand")||t.siblings(".acf-accordion.-open").each(function(){d.close(c(this))})},close:function(t){var e=acf.isGutenberg()?0:300;t.find(".acf-accordion-content:first").slideUp(e),t.find(".acf-accordion-icon:first").replaceWith(this.iconHtml({open:!1})),t.removeClass("-open"),acf.doAction("hide",t)},onClick:function(t,e){t.preventDefault(),this.toggle(e.parent())},onInvalidField:function(t,e){this.busy||(this.busy=!0,this.setTimeout(function(){this.busy=!1},1e3),this.open(e))},onUnload:function(t){var e=[];c(".acf-accordion").each(function(){var t=c(this).hasClass("-open")?1:0;e.push(t)}),e.length&&acf.setPreference("this.accordions",e)}})}(jQuery),function(){var t=acf.Field.extend({type:"button_group",events:{'click input[type="radio"]':"onClick"},$control:function(){return this.$(".acf-button-group")},$input:function(){return this.$("input:checked")},setValue:function(t){this.$('input[value="'+t+'"]').prop("checked",!0).trigger("change")},onClick:function(t,e){var i=e.parent("label"),n=i.hasClass("selected");this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"))}});acf.registerFieldType(t)}(jQuery),function(e){var t=acf.Field.extend({type:"checkbox",events:{"change input":"onChange","click .acf-add-checkbox":"onClickAdd","click .acf-checkbox-toggle":"onClickToggle","click .acf-checkbox-custom":"onClickCustom"},$control:function(){return this.$(".acf-checkbox-list")},$toggle:function(){return this.$(".acf-checkbox-toggle")},$input:function(){return this.$('input[type="hidden"]')},$inputs:function(){return this.$('input[type="checkbox"]').not(".acf-checkbox-toggle")},getValue:function(){var t=[];return this.$(":checked").each(function(){t.push(e(this).val())}),!!t.length&&t},onChange:function(t,e){var i=e.prop("checked"),n=e.parent("label"),e=this.$toggle();i?n.addClass("selected"):n.removeClass("selected"),e.length&&(0==this.$inputs().not(":checked").length?e.prop("checked",!0):e.prop("checked",!1))},onClickAdd:function(t,e){var i='<li><input class="acf-checkbox-custom" type="checkbox" checked="checked" /><input type="text" name="'+this.getInputName()+'[]" /></li>';e.parent("li").before(i)},onClickToggle:function(t,e){var i=e.prop("checked"),n=this.$('input[type="checkbox"]'),e=this.$("label");n.prop("checked",i),i?e.addClass("selected"):e.removeClass("selected")},onClickCustom:function(t,e){var i=e.prop("checked"),n=e.next('input[type="text"]');i?n.prop("disabled",!1):(n.prop("disabled",!0),""==n.val()&&e.parent("li").remove())}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"color_picker",wait:"load",events:{duplicateField:"onDuplicate"},$control:function(){return this.$(".acf-color-picker")},$input:function(){return this.$('input[type="hidden"]')},$inputText:function(){return this.$('input[type="text"]')},setValue:function(t){acf.val(this.$input(),t),this.$inputText().iris("color",t)},initialize:function(){var e=this.$input(),i=this.$inputText(),t=function(t){setTimeout(function(){acf.val(e,i.val())},1)},t={defaultColor:!1,palettes:!0,hide:!0,change:t,clear:t},t=acf.applyFilters("color_picker_args",t,this);i.wpColorPicker(t)},onDuplicate:function(t,e,i){$colorPicker=i.find(".wp-picker-container"),$inputText=i.find('input[type="text"]'),$colorPicker.replaceWith($inputText)}});acf.registerFieldType(t)}(jQuery),function(n){var t=acf.Field.extend({type:"date_picker",events:{'blur input[type="text"]':"onBlur",duplicateField:"onDuplicate"},$control:function(){return this.$(".acf-date-picker")},$input:function(){return this.$('input[type="hidden"]')},$inputText:function(){return this.$('input[type="text"]')},initialize:function(){if(this.has("save_format"))return this.initializeCompatibility();var t=this.$input(),e=this.$inputText(),t={dateFormat:this.get("date_format"),altField:t,altFormat:"yymmdd",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day")},t=acf.applyFilters("date_picker_args",t,this);acf.newDatePicker(e,t),acf.doAction("date_picker_init",e,t,this)},initializeCompatibility:function(){var t=this.$input(),e=this.$inputText();e.val(t.val());var i={dateFormat:this.get("date_format"),altField:t,altFormat:this.get("save_format"),changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day")},t=(i=acf.applyFilters("date_picker_args",i,this)).dateFormat;i.dateFormat=this.get("save_format"),acf.newDatePicker(e,i),e.datepicker("option","dateFormat",t),acf.doAction("date_picker_init",e,i,this)},onBlur:function(){this.$inputText().val()||acf.val(this.$input(),"")},onDuplicate:function(t,e,i){i.find('input[type="text"]').removeClass("hasDatepicker").removeAttr("id")}});acf.registerFieldType(t);new acf.Model({priority:5,wait:"ready",initialize:function(){var t=acf.get("locale"),e=acf.get("rtl"),i=acf.get("datePickerL10n");return!!i&&(void 0!==n.datepicker&&(i.isRTL=e,n.datepicker.regional[t]=i,void n.datepicker.setDefaults(i)))}});acf.newDatePicker=function(t,e){if(void 0===n.datepicker)return!1;t.datepicker(e=e||{}),n("body > #ui-datepicker-div").exists()&&n("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function(n){var t=acf.models.DatePickerField.extend({type:"date_time_picker",$control:function(){return this.$(".acf-date-time-picker")},initialize:function(){var t=this.$input(),e=this.$inputText(),t={dateFormat:this.get("date_format"),timeFormat:this.get("time_format"),altField:t,altFieldTimeOnly:!1,altFormat:"yy-mm-dd",altTimeFormat:"HH:mm:ss",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.get("first_day"),controlType:"select",oneLine:!0},t=acf.applyFilters("date_time_picker_args",t,this);acf.newDateTimePicker(e,t),acf.doAction("date_time_picker_init",e,t,this)}});acf.registerFieldType(t);new acf.Model({priority:5,wait:"ready",initialize:function(){var t=acf.get("locale"),e=acf.get("rtl"),i=acf.get("dateTimePickerL10n");return!!i&&(void 0!==n.timepicker&&(i.isRTL=e,n.timepicker.regional[t]=i,void n.timepicker.setDefaults(i)))}});acf.newDateTimePicker=function(t,e){if(void 0===n.timepicker)return!1;t.datetimepicker(e=e||{}),n("body > #ui-datepicker-div").exists()&&n("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function(e){var t=acf.Field.extend({type:"google_map",map:!1,wait:"load",events:{'click a[data-name="clear"]':"onClickClear",'click a[data-name="locate"]':"onClickLocate",'click a[data-name="search"]':"onClickSearch","keydown .search":"onKeydownSearch","keyup .search":"onKeyupSearch","focus .search":"onFocusSearch","blur .search":"onBlurSearch",showField:"onShow"},$control:function(){return this.$(".acf-google-map")},$search:function(){return this.$(".search")},$canvas:function(){return this.$(".canvas")},setState:function(t){this.$control().removeClass("-value -loading -searching"),(t="default"===t?this.val()?"value":"":t)&&this.$control().addClass("-"+t)},getValue:function(){var t=this.$input().val();return!!t&&JSON.parse(t)},setValue:function(t,e){var i="";t&&(i=JSON.stringify(t)),acf.val(this.$input(),i),e||(this.renderVal(t),acf.doAction("google_map_change",t,this.map,this))},renderVal:function(t){t?(this.setState("value"),this.$search().val(t.address),this.setPosition(t.lat,t.lng)):(this.setState(""),this.$search().val(""),this.map.marker.setVisible(!1))},newLatLng:function(t,e){return new google.maps.LatLng(parseFloat(t),parseFloat(e))},setPosition:function(t,e){this.map.marker.setPosition({lat:parseFloat(t),lng:parseFloat(e)}),this.map.marker.setVisible(!0),this.center()},center:function(){var t,e=this.map.marker.getPosition();e=e?(t=e.lat(),e.lng()):(t=this.get("lat"),this.get("lng")),this.map.setCenter({lat:parseFloat(t),lng:parseFloat(e)})},initialize:function(){!function(t){if(a)return t();if(acf.isset(window,"google","maps","Geocoder"))return a=new google.maps.Geocoder,t();acf.addAction("google_map_api_loaded",t),i||(t=acf.get("google_map_api"))&&(i=!0,e.ajax({url:t,dataType:"script",cache:!0,success:function(){a=new google.maps.Geocoder,acf.doAction("google_map_api_loaded")}}))}(this.initializeMap.bind(this))},initializeMap:function(){var t=this.getValue(),e=acf.parseArgs(t,{zoom:this.get("zoom"),lat:this.get("lat"),lng:this.get("lng")}),i={scrollwheel:!1,zoom:parseInt(e.zoom),center:{lat:parseFloat(e.lat),lng:parseFloat(e.lng)},mapTypeId:google.maps.MapTypeId.ROADMAP,marker:{draggable:!0,raiseOnDrag:!0},autocomplete:{}},i=acf.applyFilters("google_map_args",i,this),n=new google.maps.Map(this.$canvas()[0],i),a=acf.parseArgs(i.marker,{draggable:!0,raiseOnDrag:!0,map:n}),a=acf.applyFilters("google_map_marker_args",a,this),e=new google.maps.Marker(a),a=!1;acf.isset(google,"maps","places","Autocomplete")&&(i=i.autocomplete||{},i=acf.applyFilters("google_map_autocomplete_args",i,this),(a=new google.maps.places.Autocomplete(this.$search()[0],i)).bindTo("bounds",n)),this.addMapEvents(this,n,e,a),n.acf=this,n.marker=e,n.autocomplete=a,this.map=n,t&&this.setPosition(t.lat,t.lng),acf.doAction("google_map_init",n,e,this)},addMapEvents:function(i,e,t,n){google.maps.event.addListener(e,"click",function(t){var e=t.latLng.lat(),t=t.latLng.lng();i.searchPosition(e,t)}),google.maps.event.addListener(t,"dragend",function(){var t=this.getPosition().lat(),e=this.getPosition().lng();i.searchPosition(t,e)}),n&&google.maps.event.addListener(n,"place_changed",function(){var t=this.getPlace();i.searchPlace(t)}),google.maps.event.addListener(e,"zoom_changed",function(){var t=i.val();t&&(t.zoom=e.getZoom(),i.setValue(t,!0))})},searchPosition:function(i,n){this.setState("loading"),a.geocode({location:{lat:i,lng:n}},function(t,e){this.setState(""),"OK"!==e?this.showNotice({text:acf.__("Location not found: %s").replace("%s",e),type:"warning"}):((t=this.parseResult(t[0])).lat=i,t.lng=n,this.val(t))}.bind(this))},searchPlace:function(t){var e;t&&(t.geometry?(t.formatted_address=this.$search().val(),e=this.parseResult(t),this.val(e)):t.name&&this.searchAddress(t.name))},searchAddress:function(i){if(i){var t=i.split(",");if(2==t.length){var e=parseFloat(t[0]),t=parseFloat(t[1]);if(e&&t)return this.searchPosition(e,t)}this.setState("loading"),a.geocode({address:i},function(t,e){this.setState(""),"OK"!==e?this.showNotice({text:acf.__("Location not found: %s").replace("%s",e),type:"warning"}):((t=this.parseResult(t[0])).address=i,this.val(t))}.bind(this))}},searchLocation:function(){if(!navigator.geolocation)return alert(acf.__("Sorry, this browser does not support geolocation"));this.setState("loading"),navigator.geolocation.getCurrentPosition(function(t){this.setState("");var e=t.coords.latitude,t=t.coords.longitude;this.searchPosition(e,t)}.bind(this),function(t){this.setState("")}.bind(this))},parseResult:function(t){var e={address:t.formatted_address,lat:t.geometry.location.lat(),lng:t.geometry.location.lng()};e.zoom=this.map.getZoom(),t.place_id&&(e.place_id=t.place_id),t.name&&(e.name=t.name);var i,n={street_number:["street_number"],street_name:["street_address","route"],city:["locality"],state:["administrative_area_level_1","administrative_area_level_2","administrative_area_level_3","administrative_area_level_4","administrative_area_level_5"],post_code:["postal_code"],country:["country"]};for(i in n)for(var a=n[i],s=0;s<t.address_components.length;s++){var o=t.address_components[s],r=o.types[0];-1!==a.indexOf(r)&&(e[i]=o.long_name,o.long_name!==o.short_name&&(e[i+"_short"]=o.short_name))}return acf.applyFilters("google_map_result",e,t,this.map,this)},onClickClear:function(){this.val(!1)},onClickLocate:function(){this.searchLocation()},onClickSearch:function(){this.searchAddress(this.$search().val())},onFocusSearch:function(t,e){this.setState("searching")},onBlurSearch:function(t,e){var i=this.val(),i=i?i.address:"";e.val()===i&&this.setState("default")},onKeyupSearch:function(t,e){e.val()||this.val(!1)},onKeydownSearch:function(t,e){13==t.which&&(t.preventDefault(),e.blur())},onShow:function(){this.map&&this.setTimeout(this.center)}});acf.registerFieldType(t);var i=!1,a=!1}(jQuery),function(n){var t=acf.Field.extend({type:"image",$control:function(){return this.$(".acf-image-uploader")},$input:function(){return this.$('input[type="hidden"]')},events:{'click a[data-name="add"]':"onClickAdd",'click a[data-name="edit"]':"onClickEdit",'click a[data-name="remove"]':"onClickRemove",'change input[type="file"]':"onChange"},initialize:function(){"basic"===this.get("uploader")&&this.$el.closest("form").attr("enctype","multipart/form-data")},validateAttachment:function(t){t&&t.attributes&&(t=t.attributes),t=acf.parseArgs(t,{id:0,url:"",alt:"",title:"",caption:"",description:"",width:0,height:0});var e=acf.isget(t,"sizes",this.get("preview_size"));return e&&(t.url=e.url,t.width=e.width,t.height=e.height),t},render:function(t){t=this.validateAttachment(t),this.$("img").attr({src:t.url,alt:t.alt}),t.id?(this.val(t.id),this.$control().addClass("has-value")):(this.val(""),this.$control().removeClass("has-value"))},append:function(t,e){function i(t,e){for(var i=acf.getFields({key:t.get("key"),parent:e.$el}),n=0;n<i.length;n++)if(!i[n].val())return i[n];return!1}var n=i(this,e);n||(e.$(".acf-button:last").trigger("click"),n=i(this,e)),n&&n.render(t)},selectAttachment:function(){var i=this.parent(),t=i&&"repeater"===i.get("type");acf.newMediaPopup({mode:"select",type:"image",title:acf.__("Select Image"),field:this.get("key"),multiple:t,library:this.get("library"),allowedTypes:this.get("mime_types"),select:n.proxy(function(t,e){0<e?this.append(t,i):this.render(t)},this)})},editAttachment:function(){var t=this.val();t&&acf.newMediaPopup({mode:"edit",title:acf.__("Edit Image"),button:acf.__("Update Image"),attachment:t,field:this.get("key"),select:n.proxy(function(t,e){this.render(t)},this)})},removeAttachment:function(){this.render(!1)},onClickAdd:function(t,e){this.selectAttachment()},onClickEdit:function(t,e){this.editAttachment()},onClickRemove:function(t,e){this.removeAttachment()},onChange:function(t,e){var i=this.$input();acf.getFileInputData(e,function(t){i.val(n.param(t))})}});acf.registerFieldType(t)}(jQuery),function(e){var t=acf.models.ImageField.extend({type:"file",$control:function(){return this.$(".acf-file-uploader")},$input:function(){return this.$('input[type="hidden"]')},validateAttachment:function(t){return void 0!==(t=t||{}).id&&(t=t.attributes),t=acf.parseArgs(t,{url:"",alt:"",title:"",filename:"",filesizeHumanReadable:"",icon:"/wp-includes/images/media/default.png"})},render:function(t){t=this.validateAttachment(t),this.$("img").attr({src:t.icon,alt:t.alt,title:t.title}),this.$('[data-name="title"]').text(t.title),this.$('[data-name="filename"]').text(t.filename).attr("href",t.url),this.$('[data-name="filesize"]').text(t.filesizeHumanReadable);t=t.id||"";acf.val(this.$input(),t),t?this.$control().addClass("has-value"):this.$control().removeClass("has-value")},selectAttachment:function(){var i=this.parent(),t=i&&"repeater"===i.get("type");acf.newMediaPopup({mode:"select",title:acf.__("Select File"),field:this.get("key"),multiple:t,library:this.get("library"),allowedTypes:this.get("mime_types"),select:e.proxy(function(t,e){0<e?this.append(t,i):this.render(t)},this)})},editAttachment:function(){var t=this.val();if(!t)return!1;acf.newMediaPopup({mode:"edit",title:acf.__("Edit File"),button:acf.__("Update File"),attachment:t,field:this.get("key"),select:e.proxy(function(t,e){this.render(t)},this)})}});acf.registerFieldType(t)}(jQuery),function(e){var t=acf.Field.extend({type:"link",events:{'click a[data-name="add"]':"onClickEdit",'click a[data-name="edit"]':"onClickEdit",'click a[data-name="remove"]':"onClickRemove","change .link-node":"onChange"},$control:function(){return this.$(".acf-link")},$node:function(){return this.$(".link-node")},getValue:function(){var t=this.$node();return!!t.attr("href")&&{title:t.html(),url:t.attr("href"),target:t.attr("target")}},setValue:function(t){t=acf.parseArgs(t,{title:"",url:"",target:""});var e=this.$control(),i=this.$node();e.removeClass("-value -external"),t.url&&e.addClass("-value"),"_blank"===t.target&&e.addClass("-external"),this.$(".link-title").html(t.title),this.$(".link-url").attr("href",t.url).html(t.url),i.html(t.title),i.attr("href",t.url),i.attr("target",t.target),this.$(".input-title").val(t.title),this.$(".input-target").val(t.target),this.$(".input-url").val(t.url).trigger("change")},onClickEdit:function(t,e){acf.wpLink.open(this.$node())},onClickRemove:function(t,e){this.setValue(!1)},onChange:function(t,e){var i=this.getValue();this.setValue(i)}});acf.registerFieldType(t),acf.wpLink=new acf.Model({getNodeValue:function(){var t=this.get("node");return{title:acf.decode(t.html()),url:t.attr("href"),target:t.attr("target")}},setNodeValue:function(t){var e=this.get("node");e.text(t.title),e.attr("href",t.url),e.attr("target",t.target),e.trigger("change")},getInputValue:function(){return{title:e("#wp-link-text").val(),url:e("#wp-link-url").val(),target:e("#wp-link-target").prop("checked")?"_blank":""}},setInputValue:function(t){e("#wp-link-text").val(t.title),e("#wp-link-url").val(t.url),e("#wp-link-target").prop("checked","_blank"===t.target)},open:function(t){this.on("wplink-open","onOpen"),this.on("wplink-close","onClose"),this.set("node",t);t=e('<textarea id="acf-link-textarea" style="display:none;"></textarea>');e("body").append(t);t=this.getNodeValue();wpLink.open("acf-link-textarea",t.url,t.title,null)},onOpen:function(){e("#wp-link-wrap").addClass("has-text-field");var t=this.getNodeValue();this.setInputValue(t),t.url&&wpLinkL10n&&e("#wp-link-submit").val(wpLinkL10n.update)},close:function(){wpLink.close()},onClose:function(){if(!this.has("node"))return!1;var t=e("#wp-link-submit");(t.is(":hover")||t.is(":focus"))&&(t=this.getInputValue(),this.setNodeValue(t)),this.off("wplink-open"),this.off("wplink-close"),e("#acf-link-textarea").remove(),this.set("node",null)}})}(jQuery),function(i){var t=acf.Field.extend({type:"oembed",events:{'click [data-name="clear-button"]':"onClickClear","keypress .input-search":"onKeypressSearch","keyup .input-search":"onKeyupSearch","change .input-search":"onChangeSearch"},$control:function(){return this.$(".acf-oembed")},$input:function(){return this.$(".input-value")},$search:function(){return this.$(".input-search")},getValue:function(){return this.$input().val()},getSearchVal:function(){return this.$search().val()},setValue:function(t){t?this.$control().addClass("has-value"):this.$control().removeClass("has-value"),acf.val(this.$input(),t)},showLoading:function(t){acf.showLoading(this.$(".canvas"))},hideLoading:function(){acf.hideLoading(this.$(".canvas"))},maybeSearch:function(){var t=this.val(),e=this.getSearchVal();if(!e)return this.clear();(e="http"!=e.substr(0,4)?"http://"+e:e)!==t&&((t=this.get("timeout"))&&clearTimeout(t),e=i.proxy(this.search,this,e),this.set("timeout",setTimeout(e,300)))},search:function(t){var e={action:"acf/fields/oembed/search",s:t,field_key:this.get("key")};(t=this.get("xhr"))&&t.abort(),this.showLoading();t=i.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"json",context:this,success:function(t){t&&t.html||(t={url:!1,html:""}),this.val(t.url),this.$(".canvas-media").html(t.html)},complete:function(){this.hideLoading()}});this.set("xhr",t)},clear:function(){this.val(""),this.$search().val(""),this.$(".canvas-media").html("")},onClickClear:function(t,e){this.clear()},onKeypressSearch:function(t,e){13==t.which&&(t.preventDefault(),this.maybeSearch())},onKeyupSearch:function(t,e){e.val()&&this.maybeSearch()},onChangeSearch:function(t,e){this.maybeSearch()}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"radio",events:{'click input[type="radio"]':"onClick"},$control:function(){return this.$(".acf-radio-list")},$input:function(){return this.$("input:checked")},$inputText:function(){return this.$('input[type="text"]')},getValue:function(){var t=this.$input().val();return t="other"===t&&this.get("other_choice")?this.$inputText().val():t},onClick:function(t,e){var i=e.parent("label"),n=i.hasClass("selected"),a=e.val();this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"),a=!1),this.get("other_choice")&&("other"===a?this.$inputText().prop("disabled",!1):this.$inputText().prop("disabled",!0))}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"range",events:{'input input[type="range"]':"onChange","change input":"onChange"},$input:function(){return this.$('input[type="range"]')},$inputAlt:function(){return this.$('input[type="number"]')},setValue:function(t){this.busy=!0,acf.val(this.$input(),t),acf.val(this.$inputAlt(),this.$input().val(),!0),this.busy=!1},onChange:function(t,e){this.busy||this.setValue(e.val())}});acf.registerFieldType(t)}(jQuery),function(s){var t=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"},$control:function(){return this.$(".acf-relationship")},$list:function(t){return this.$("."+t+"-list")},$listItems:function(t){return this.$list(t).find(".acf-rel-item")},$listItem:function(t,e){return this.$list(t).find('.acf-rel-item[data-id="'+e+'"]')},getValue:function(){var t=[];return this.$listItems("values").each(function(){t.push(s(this).data("id"))}),!!t.length&&t},newChoice:function(t){return["<li>",'<span data-id="'+t.id+'" class="acf-rel-item">'+t.text+"</span>","</li>"].join("")},newValue:function(t){return["<li>",'<input type="hidden" name="'+this.getInputName()+'[]" value="'+t.id+'" />','<span data-id="'+t.id+'" class="acf-rel-item">'+t.text,'<a href="#" class="acf-icon -minus small dark" data-name="remove_item"></a>',"</span>","</li>"].join("")},initialize:function(){var t=this.proxy(acf.once(function(){this.$list("values").sortable({items:"li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:this.proxy(function(){this.$input().trigger("change")})}),this.$list("choices").scrollTop(0).on("scroll",this.proxy(this.onScrollChoices)),this.fetch()}));this.$el.one("mouseover",t),this.$el.one("focus","input",t),acf.onceInView(this.$el,t)},onScrollChoices:function(t){var e,i,n,a;!this.get("loading")&&this.get("more")&&(a=this.$list("choices"),e=Math.ceil(a.scrollTop()),i=Math.ceil(a[0].scrollHeight),n=Math.ceil(a.innerHeight()),a=this.get("paged")||1,i<=e+n&&(this.set("paged",a+1),this.fetch()))},onKeypressFilter:function(t,e){13==t.which&&t.preventDefault()},onChangeFilter:function(t,e){var i=e.val(),n=e.data("filter");this.get(n)!==i&&(this.set(n,i),this.set("paged",1),e.is("select")?this.fetch():this.maybeFetch())},onClickAdd:function(t,e){var i=this.val(),n=parseInt(this.get("max"));if(e.hasClass("disabled"))return!1;if(0<n&&i&&i.length>=n)return this.showNotice({text:acf.__("Maximum values reached ( {max} values )").replace("{max}",n),type:"warning"}),!1;e.addClass("disabled");e=this.newValue({id:e.data("id"),text:e.html()});this.$list("values").append(e),this.$input().trigger("change")},onClickRemove:function(t,e){t.preventDefault();t=e.parent(),e=t.parent(),t=t.data("id");e.remove(),this.$listItem("choices",t).removeClass("disabled"),this.$input().trigger("change")},maybeFetch:function(){var t=this.get("timeout");t&&clearTimeout(t),t=this.setTimeout(this.fetch,300),this.set("timeout",t)},getAjaxData:function(){var t,e=this.$control().data();for(t in e)e[t]=this.get(t);return e.action="acf/fields/relationship/query",e.field_key=this.get("key"),e=acf.applyFilters("relationship_ajax_data",e,this)},fetch:function(){(i=this.get("xhr"))&&i.abort();var t=this.getAjaxData(),a=this.$list("choices");1==t.paged&&a.html("");var e=s('<li><i class="acf-loading"></i> '+acf.__("Loading")+"</li>");a.append(e),this.set("loading",!0);var i=s.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",data:acf.prepareForAjax(t),context:this,success:function(t){if(!t||!t.results||!t.results.length)return this.set("more",!1),void(1==this.get("paged")&&this.$list("choices").append("<li>"+acf.__("No matches found")+"</li>"));this.set("more",t.more);var t=this.walkChoices(t.results),e=s(t),t=this.val();t&&t.length&&t.map(function(t){e.find('.acf-rel-item[data-id="'+t+'"]').addClass("disabled")}),a.append(e);var i=!1,n=!1;a.find(".acf-rel-label").each(function(){var t=s(this),e=t.siblings("ul");if(i&&i.text()==t.text())return n.append(e.children()),void s(this).parent().remove();i=t,n=e})},complete:function(){this.set("loading",!1),e.remove()}});this.set("xhr",i)},walkChoices:function(t){var i=function(t){var e="";return s.isArray(t)?t.map(function(t){e+=i(t)}):s.isPlainObject(t)&&(void 0!==t.children?(e+='<li><span class="acf-rel-label">'+acf.escHtml(t.text)+'</span><ul class="acf-bl">',e+=i(t.children),e+="</ul></li>"):e+='<li><span class="acf-rel-item" data-id="'+acf.escAttr(t.id)+'">'+acf.escHtml(t.text)+"</span></li>"),e};return i(t)}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"select",select2:!1,wait:"load",events:{removeField:"onRemove",duplicateField:"onDuplicate"},$input:function(){return this.$("select")},initialize:function(){var t,e=this.$input();this.inherit(e),this.get("ui")&&(t=(t=this.get("ajax_action"))||"acf/fields/"+this.get("type")+"/query",this.select2=acf.newSelect2(e,{field:this,ajax:this.get("ajax"),multiple:this.get("multiple"),placeholder:this.get("placeholder"),allowNull:this.get("allow_null"),ajaxAction:t}))},onRemove:function(){this.select2&&this.select2.destroy()},onDuplicate:function(t,e,i){this.select2&&(i.find(".select2-container").remove(),i.find("select").removeClass("select2-hidden-accessible"))}});acf.registerFieldType(t)}(jQuery),function(n){var e="tab",t=acf.Field.extend({type:"tab",wait:"",tabs:!1,tab:!1,events:{duplicateField:"onDuplicate"},findFields:function(){return this.$el.nextUntil(".acf-field-tab",".acf-field")},getFields:function(){return acf.getFields(this.findFields())},findTabs:function(){return this.$el.prevAll(".acf-tab-wrap:first")},findTab:function(){return this.$(".acf-tab-button")},initialize:function(){if(this.$el.is("td"))return!(this.events={});var t=this.findTabs(),e=this.findTab(),i=acf.parseArgs(e.data(),{endpoint:!1,placement:"",before:this.$el});!t.length||i.endpoint?this.tabs=new s(i):this.tabs=t.data("acf"),this.tab=this.tabs.addTab(e,this)},isActive:function(){return this.tab.isActive()},showFields:function(){this.getFields().map(function(t){t.show(this.cid,e),t.hiddenByTab=!1},this)},hideFields:function(){this.getFields().map(function(t){t.hide(this.cid,e),t.hiddenByTab=this.tab},this)},show:function(t){var e=acf.Field.prototype.show.apply(this,arguments);return e&&(this.tab.show(),this.tabs.refresh()),e},hide:function(t){var e=acf.Field.prototype.hide.apply(this,arguments);return e&&(this.tab.hide(),this.isActive()&&this.tabs.reset()),e},enable:function(t){this.getFields().map(function(t){t.enable(e)})},disable:function(t){this.getFields().map(function(t){t.disable(e)})},onDuplicate:function(t,e,i){this.isActive()&&i.prevAll(".acf-tab-wrap:first").remove()}});acf.registerFieldType(t);var a=0,s=acf.Model.extend({tabs:[],active:!1,actions:{refresh:"onRefresh"},data:{before:!1,placement:"top",index:0,initialized:!1},setup:function(t){n.extend(this.data,t),this.tabs=[],this.active=!1;var e=this.get("placement"),i=this.get("before"),t=i.parent();"left"==e&&t.hasClass("acf-fields")&&t.addClass("-sidebar"),i.is("tr")?this.$el=n('<tr class="acf-tab-wrap"><td colspan="2"><ul class="acf-hl acf-tab-group"></ul></td></tr>'):this.$el=n('<div class="acf-tab-wrap -'+e+'"><ul class="acf-hl acf-tab-group"></ul></div>'),i.before(this.$el),this.set("index",a,!0),a++},initializeTabs:function(){var t=this.getVisible().shift(),e=(acf.getPreference("this.tabs")||[])[this.get("index")];(t=this.tabs[e]&&this.tabs[e].isVisible()?this.tabs[e]:t)?this.selectTab(t):this.closeTabs(),this.set("initialized",!0)},getVisible:function(){return this.tabs.filter(function(t){return t.isVisible()})},getActive:function(){return this.active},setActive:function(t){return this.active=t},hasActive:function(){return!1!==this.active},isActive:function(t){var e=this.getActive();return e&&e.cid===t.cid},closeActive:function(){this.hasActive()&&this.closeTab(this.getActive())},openTab:function(t){this.closeActive(),t.open(),this.setActive(t)},closeTab:function(t){t.close(),this.setActive(!1)},closeTabs:function(){this.tabs.map(this.closeTab,this)},selectTab:function(e){this.tabs.map(function(t){e.cid!==t.cid&&this.closeTab(t)},this),this.openTab(e)},addTab:function(t,e){t=n("<li>"+t.outerHTML()+"</li>");this.$("ul").append(t);e=new i({$el:t,field:e,group:this});return this.tabs.push(e),e},reset:function(){return this.closeActive(),this.refresh()},refresh:function(){if(this.hasActive())return!1;var t=this.getVisible().shift();return t&&this.openTab(t),t},onRefresh:function(){var t,e,i;"left"===this.get("placement")&&(t=this.$el.parent(),i=this.$el.children("ul"),e=t.is("td")?"height":"min-height",i=i.position().top+i.outerHeight(!0)-1,t.css(e,i))}}),i=acf.Model.extend({group:!1,field:!1,events:{"click a":"onClick"},index:function(){return this.$el.index()},isVisible:function(){return acf.isVisible(this.$el)},isActive:function(){return this.$el.hasClass("active")},open:function(){this.$el.addClass("active"),this.field.showFields()},close:function(){this.$el.removeClass("active"),this.field.hideFields()},onClick:function(t,e){t.preventDefault(),this.toggle()},toggle:function(){this.isActive()||this.group.openTab(this)}});new acf.Model({priority:50,actions:{prepare:"render",append:"render",unload:"onUnload",invalid_field:"onInvalidField"},findTabs:function(){return n(".acf-tab-wrap")},getTabs:function(){return acf.getInstances(this.findTabs())},render:function(t){this.getTabs().map(function(t){t.get("initialized")||t.initializeTabs()})},onInvalidField:function(t){this.busy||t.hiddenByTab&&(t.hiddenByTab.toggle(),this.busy=!0,this.setTimeout(function(){this.busy=!1},100))},onUnload:function(){var e=[];this.getTabs().map(function(t){t=t.hasActive()?t.getActive().index():0;e.push(t)}),e.length&&acf.setPreference("this.tabs",e)}})}(jQuery),function(){var t=acf.models.SelectField.extend({type:"post_object"});acf.registerFieldType(t)}(jQuery),function(){var t=acf.models.SelectField.extend({type:"page_link"});acf.registerFieldType(t)}(jQuery),function(){var t=acf.models.SelectField.extend({type:"user"});acf.registerFieldType(t)}(jQuery),function(p){var t=acf.Field.extend({type:"taxonomy",data:{ftype:"select"},select2:!1,wait:"load",events:{'click a[data-name="add"]':"onClickAdd",'click input[type="radio"]':"onClickRadio",removeField:"onRemove"},$control:function(){return this.$(".acf-taxonomy-field")},$input:function(){return this.getRelatedPrototype().$input.apply(this,arguments)},getRelatedType:function(){var t=this.get("ftype");return t="multi_select"==t?"select":t},getRelatedPrototype:function(){return acf.getFieldType(this.getRelatedType()).prototype},getValue:function(){return this.getRelatedPrototype().getValue.apply(this,arguments)},setValue:function(){return this.getRelatedPrototype().setValue.apply(this,arguments)},initialize:function(){this.getRelatedPrototype().initialize.apply(this,arguments)},onRemove:function(){var t=this.getRelatedPrototype();t.onRemove&&t.onRemove.apply(this,arguments)},onClickAdd:function(t,e){var i=this,n=!1,a=!1,s=!1,o=!1,r=!1,c=!1,l=function(t){n.loading(!1),n.content(t),a=n.$("form"),s=n.$('input[name="term_name"]'),o=n.$('select[name="term_parent"]'),r=n.$(".acf-submit-button"),s.trigger("focus"),n.on("submit","form",d)},d=function(t,e){if(t.preventDefault(),t.stopImmediatePropagation(),""===s.val())return s.trigger("focus"),!1;acf.startButtonLoading(r);t={action:"acf/fields/taxonomy/add_term",field_key:i.get("key"),term_name:s.val(),term_parent:o.length?o.val():0};p.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(t),type:"post",dataType:"json",success:u})},u=function(t){acf.stopButtonLoading(r),c&&c.remove(),c=acf.isAjaxSuccess(t)?(s.val(""),f(t.data),acf.newNotice({type:"success",text:acf.getAjaxMessage(t),target:a,timeout:2e3,dismiss:!1})):acf.newNotice({type:"error",text:acf.getAjaxError(t),target:a,timeout:2e3,dismiss:!1}),s.trigger("focus")},f=function(e){var t=p('<option value="'+e.term_id+'">'+e.term_label+"</option>");e.term_parent?o.children('option[value="'+e.term_parent+'"]').after(t):o.append(t),acf.getFields({type:"taxonomy"}).map(function(t){t.get("taxonomy")==i.get("taxonomy")&&t.appendTerm(e)}),i.selectTerm(e.term_id)};!function(){n=acf.newPopup({title:e.attr("title"),loading:!0,width:"300px"});var t={action:"acf/fields/taxonomy/add_term",field_key:i.get("key")};p.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(t),type:"post",dataType:"html",success:l})}()},appendTerm:function(t){"select"==this.getRelatedType()?this.appendTermSelect(t):this.appendTermCheckbox(t)},appendTermSelect:function(t){this.select2.addOption({id:t.term_id,text:t.term_label})},appendTermCheckbox:function(t){var e=this.$("[name]:first").attr("name"),i=this.$("ul:first");"checkbox"==this.getRelatedType()&&(e+="[]");e=p(['<li data-id="'+t.term_id+'">',"<label>",'<input type="'+this.get("ftype")+'" value="'+t.term_id+'" name="'+e+'" /> ',"<span>"+t.term_name+"</span>","</label>","</li>"].join(""));t.term_parent&&((i=(t=i.find('li[data-id="'+t.term_parent+'"]')).children("ul")).exists()||(i=p('<ul class="children acf-bl"></ul>'),t.append(i))),i.append(e)},selectTerm:function(t){"select"==this.getRelatedType()?this.select2.selectOption(t):this.$('input[value="'+t+'"]').prop("checked",!0).trigger("change")},onClickRadio:function(t,e){var i=e.parent("label"),n=i.hasClass("selected");this.$(".selected").removeClass("selected"),i.addClass("selected"),this.get("allow_null")&&n&&(i.removeClass("selected"),e.prop("checked",!1).trigger("change"))}});acf.registerFieldType(t)}(jQuery),function(i){var t=acf.models.DatePickerField.extend({type:"time_picker",$control:function(){return this.$(".acf-time-picker")},initialize:function(){var t=this.$input(),e=this.$inputText(),t={timeFormat:this.get("time_format"),altField:t,altFieldTimeOnly:!1,altTimeFormat:"HH:mm:ss",showButtonPanel:!0,controlType:"select",oneLine:!0,closeText:acf.get("dateTimePickerL10n").selectText,timeOnly:!0,onClose:function(t,e,i){e=e.dpDiv.find(".ui-datepicker-close");!t&&e.is(":hover")&&i._updateDateTime()}},t=acf.applyFilters("time_picker_args",t,this);acf.newTimePicker(e,t),acf.doAction("time_picker_init",e,t,this)}});acf.registerFieldType(t),acf.newTimePicker=function(t,e){if(void 0===i.timepicker)return!1;t.timepicker(e=e||{}),i("body > #ui-datepicker-div").exists()&&i("body > #ui-datepicker-div").wrap('<div class="acf-ui-datepicker" />')}}(jQuery),function(){var t=acf.Field.extend({type:"true_false",events:{"change .acf-switch-input":"onChange","focus .acf-switch-input":"onFocus","blur .acf-switch-input":"onBlur","keypress .acf-switch-input":"onKeypress"},$input:function(){return this.$('input[type="checkbox"]')},$switch:function(){return this.$(".acf-switch")},getValue:function(){return this.$input().prop("checked")?1:0},initialize:function(){this.render()},render:function(){var t,e,i=this.$switch();i.length&&(t=i.children(".acf-switch-on"),e=i.children(".acf-switch-off"),(i=Math.max(t.width(),e.width()))&&(t.css("min-width",i),e.css("min-width",i)))},switchOn:function(){this.$input().prop("checked",!0),this.$switch().addClass("-on")},switchOff:function(){this.$input().prop("checked",!1),this.$switch().removeClass("-on")},onChange:function(t,e){e.prop("checked")?this.switchOn():this.switchOff()},onFocus:function(t,e){this.$switch().addClass("-focus")},onBlur:function(t,e){this.$switch().removeClass("-focus")},onKeypress:function(t,e){return 37===t.keyCode?this.switchOff():39===t.keyCode?this.switchOn():void 0}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"url",events:{'keyup input[type="url"]':"onkeyup"},$control:function(){return this.$(".acf-input-wrap")},$input:function(){return this.$('input[type="url"]')},initialize:function(){this.render()},isValid:function(){var t=this.val();return!!t&&(-1!==t.indexOf("://")||0===t.indexOf("//"))},render:function(){this.isValid()?this.$control().addClass("-valid"):this.$control().removeClass("-valid")},onkeyup:function(t,e){this.render()}});acf.registerFieldType(t)}(jQuery),function(){var t=acf.Field.extend({type:"wysiwyg",wait:"load",events:{"mousedown .acf-editor-wrap.delay":"onMousedown",unmountField:"disableEditor",remountField:"enableEditor",removeField:"disableEditor"},$control:function(){return this.$(".acf-editor-wrap")},$input:function(){return this.$("textarea")},getMode:function(){return this.$control().hasClass("tmce-active")?"visual":"text"},initialize:function(){this.$control().hasClass("delay")||this.initializeEditor()},initializeEditor:function(){var t=this.$control(),e=this.$input(),i={tinymce:!0,quicktags:!0,toolbar:this.get("toolbar"),mode:this.getMode(),field:this},n=e.attr("id"),a=acf.uniqueId("acf-editor-"),s=e.data(),e=e.val();acf.rename({target:t,search:n,replace:a,destructive:!0}),this.set("id",a,!0),this.$input().data(s).val(e),acf.tinymce.initialize(a,i)},onMousedown:function(t){t.preventDefault();t=this.$control();t.removeClass("delay"),t.find(".acf-editor-toolbar").remove(),this.initializeEditor()},enableEditor:function(){"visual"==this.getMode()&&acf.tinymce.enable(this.get("id"))},disableEditor:function(){acf.tinymce.destroy(this.get("id"))}});acf.registerFieldType(t)}(jQuery),function(e){var s=[];acf.Condition=acf.Model.extend({type:"",operator:"==",label:"",choiceType:"input",fieldTypes:[],data:{conditions:!1,field:!1,rule:{}},events:{change:"change",keyup:"change",enableField:"change",disableField:"change"},setup:function(t){e.extend(this.data,t)},getEventTarget:function(t,e){return t||this.get("field").$el},change:function(t,e){this.get("conditions").change(t)},match:function(t,e){return!1},calculate:function(){return this.match(this.get("rule"),this.get("field"))},choices:function(t){return'<input type="text" />'}}),acf.newCondition=function(t,e){var i=e.get("field"),n=i.getField(t.field);if(!i||!n)return!1;e={rule:t,target:i,conditions:e,field:n},n=n.get("type"),t=t.operator;return new(acf.getConditionTypes({fieldType:n,operator:t})[0]||acf.Condition)(e)};function n(t){return acf.strPascalCase(t||"")+"Condition"}acf.registerConditionType=function(t){var e=t.prototype.type,i=n(e);acf.models[i]=t,s.push(e)},acf.getConditionType=function(t){t=n(t);return acf.models[t]||!1},acf.registerConditionForFieldType=function(t,e){t=acf.getConditionType(t);t&&t.prototype.fieldTypes.push(e)},acf.getConditionTypes=function(n){n=acf.parseArgs(n,{fieldType:"",operator:""});var a=[];return s.map(function(t){var e=acf.getConditionType(t),i=e.prototype.fieldTypes,t=e.prototype.operator;n.fieldType&&-1===i.indexOf(n.fieldType)||n.operator&&t!==n.operator||a.push(e)}),a}}(jQuery),function(){function a(t,e){var i=acf.getFields({key:e,sibling:t.$el,suppressFilters:!0});return!!(i=!i.length?acf.getFields({key:e,parent:t.$el.parent(),suppressFilters:!0}):i).length&&i[0]}var t="conditional_logic";new acf.Model({id:"conditionsManager",priority:20,actions:{new_field:"onNewField"},onNewField:function(t){t.has("conditions")&&t.getConditions().render()}});acf.Field.prototype.getField=function(t){var e=a(this,t);if(e)return e;for(var i=this.parents(),n=0;n<i.length;n++)if(e=a(i[n],t))return e;return!1};acf.Field.prototype.getConditions=function(){return this.conditions||(this.conditions=new e(this)),this.conditions};var e=acf.Model.extend({id:"Conditions",data:{field:!1,timeStamp:!1,groups:[]},setup:function(t){t=(this.data.field=t).get("conditions");t instanceof Array?t[0]instanceof Array?t.map(function(t,e){this.addRules(t,e)},this):this.addRules(t):this.addRule(t)},change:function(t){if(this.get("timeStamp")===t.timeStamp)return!1;this.set("timeStamp",t.timeStamp,!0);this.render()},render:function(){return this.calculate()?this.show():this.hide()},show:function(){return this.get("field").showEnable(this.cid,t)},hide:function(){return this.get("field").hideDisable(this.cid,t)},calculate:function(){var e=!1;return this.getGroups().map(function(t){e||t.filter(function(t){return t.calculate()}).length==t.length&&(e=!0)}),e},hasGroups:function(){return null!=this.data.groups},getGroups:function(){return this.data.groups},addGroup:function(){var t=[];return this.data.groups.push(t),t},hasGroup:function(t){return null!=this.data.groups[t]},getGroup:function(t){return this.data.groups[t]},removeGroup:function(t){return this.data.groups[t].delete,this},addRules:function(t,e){t.map(function(t){this.addRule(t,e)},this)},addRule:function(t,e){e=this.hasGroup(e=e||0)?this.getGroup(e):this.addGroup(),t=acf.newCondition(t,this);if(!t)return!1;e.push(t)},hasRule:function(){},getRule:function(t,e){return this.data.groups[e=e||0][t=t||0]},removeRule:function(){}})}(jQuery),function(){function n(t){return t?""+t:""}function a(t,e){return n(t).toLowerCase()===n(e).toLowerCase()}var s=acf.__,i=acf.Condition.extend({type:"hasValue",operator:"!=empty",label:s("Has any value"),fieldTypes:["text","textarea","number","range","email","url","password","image","file","wysiwyg","oembed","select","checkbox","radio","button_group","link","post_object","page_link","relationship","taxonomy","user","google_map","date_picker","date_time_picker","time_picker","color_picker"],match:function(t,e){return!!e.val()},choices:function(t){return'<input type="text" disabled="" />'}});acf.registerConditionType(i);var t=i.extend({type:"hasNoValue",operator:"==empty",label:s("Has no value"),match:function(t,e){return!i.prototype.match.apply(this,arguments)}});acf.registerConditionType(t);var o=acf.Condition.extend({type:"equalTo",operator:"==",label:s("Value is equal to"),fieldTypes:["text","textarea","number","range","email","url","password"],match:function(t,e){return acf.isNumeric(t.value)?(i=t.value,n=e.val(),parseFloat(i)===parseFloat(n)):a(t.value,e.val());var i,n},choices:function(t){return'<input type="text" />'}});acf.registerConditionType(o);var e=o.extend({type:"notEqualTo",operator:"!=",label:s("Value is not equal to"),match:function(t,e){return!o.prototype.match.apply(this,arguments)}});acf.registerConditionType(e);t=acf.Condition.extend({type:"patternMatch",operator:"==pattern",label:s("Value matches pattern"),fieldTypes:["text","textarea","email","url","password","wysiwyg"],match:function(t,e){return function(t,e){e=new RegExp(n(e),"gi");return n(t).match(e)}(e.val(),t.value)},choices:function(t){return'<input type="text" placeholder="[a-z0-9]" />'}});acf.registerConditionType(t);t=acf.Condition.extend({type:"contains",operator:"==contains",label:s("Value contains"),fieldTypes:["text","textarea","number","email","url","password","wysiwyg","oembed","select"],match:function(t,e){return e=e.val(),t=t.value,-1<n(e).indexOf(n(t))},choices:function(t){return'<input type="text" />'}});acf.registerConditionType(t);t=o.extend({type:"trueFalseEqualTo",choiceType:"select",fieldTypes:["true_false"],choices:function(t){return[{id:1,text:s("Checked")}]}});acf.registerConditionType(t);t=e.extend({type:"trueFalseNotEqualTo",choiceType:"select",fieldTypes:["true_false"],choices:function(t){return[{id:1,text:s("Checked")}]}});acf.registerConditionType(t);var r=acf.Condition.extend({type:"selectEqualTo",operator:"==",label:s("Value is equal to"),fieldTypes:["select","checkbox","radio","button_group"],match:function(t,e){var i=e.val();return i instanceof Array?(e=t.value,-1<i.map(n).indexOf(e)):a(t.value,i)},choices:function(t){var e=[],i=t.$setting("choices textarea").val().split("\n");return t.$input("allow_null").prop("checked")&&e.push({id:"",text:s("Null")}),i.map(function(t){(t=t.split(":"))[1]=t[1]||t[0],e.push({id:t[0].trim(),text:t[1].trim()})}),e}});acf.registerConditionType(r);e=r.extend({type:"selectNotEqualTo",operator:"!=",label:s("Value is not equal to"),match:function(t,e){return!r.prototype.match.apply(this,arguments)}});acf.registerConditionType(e);t=acf.Condition.extend({type:"greaterThan",operator:">",label:s("Value is greater than"),fieldTypes:["number","range"],match:function(t,e){e=e.val();return e instanceof Array&&(e=e.length),e=e,t=t.value,parseFloat(e)>parseFloat(t)},choices:function(t){return'<input type="number" />'}});acf.registerConditionType(t);e=t.extend({type:"lessThan",operator:"<",label:s("Value is less than"),match:function(t,e){e=e.val();return e instanceof Array&&(e=e.length),e=e,t=t.value,parseFloat(e)<parseFloat(t)},choices:function(t){return'<input type="number" />'}});acf.registerConditionType(e);t=t.extend({type:"selectionGreaterThan",label:s("Selection is greater than"),fieldTypes:["checkbox","select","post_object","page_link","relationship","taxonomy","user"]});acf.registerConditionType(t);e=e.extend({type:"selectionLessThan",label:s("Selection is less than"),fieldTypes:["checkbox","select","post_object","page_link","relationship","taxonomy","user"]});acf.registerConditionType(e)}(jQuery),function(t){acf.unload=new acf.Model({wait:"load",active:!0,changed:!1,actions:{validation_failure:"startListening",validation_success:"stopListening"},events:{"change form .acf-field":"startListening","submit form":"stopListening"},enable:function(){this.active=!0},disable:function(){this.active=!1},reset:function(){this.stopListening()},startListening:function(){!this.changed&&this.active&&(this.changed=!0,t(window).on("beforeunload",this.onUnload))},stopListening:function(){this.changed=!1,t(window).off("beforeunload",this.onUnload)},onUnload:function(){return acf.__("The changes you made will be lost if you navigate away from this page")}})}(jQuery),function(e){new acf.Model({wait:"prepare",priority:1,initialize:function(){(acf.get("postboxes")||[]).map(acf.newPostbox)}});acf.getPostbox=function(t){return"string"==typeof arguments[0]&&(t=e("#"+arguments[0])),acf.getInstance(t)},acf.getPostboxes=function(){return acf.getInstances(e(".acf-postbox"))},acf.newPostbox=function(t){return new acf.models.Postbox(t)},acf.models.Postbox=acf.Model.extend({data:{id:"",key:"",style:"default",label:"top",edit:""},setup:function(t){t.editLink&&(t.edit=t.editLink),e.extend(this.data,t),this.$el=this.$postbox()},$postbox:function(){return e("#"+this.get("id"))},$hide:function(){return e("#"+this.get("id")+"-hide")},$hideLabel:function(){return this.$hide().parent()},$hndle:function(){return this.$("> .hndle")},$handleActions:function(){return this.$("> .postbox-header .handle-actions")},$inside:function(){return this.$("> .inside")},isVisible:function(){return this.$el.hasClass("acf-hidden")},initialize:function(){this.$el.addClass("acf-postbox"),this.$el.removeClass("hide-if-js"),"block"===acf.get("editor")||"default"!==(t=this.get("style"))&&this.$el.addClass(t),this.$inside().addClass("acf-fields").addClass("-"+this.get("label"));var t,e=this.get("edit");e&&(t='<a href="'+e+'" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="'+acf.__("Edit field group")+'"></a>',(e=this.$handleActions()).length?e.prepend(t):this.$hndle().append(t)),this.show()},show:function(){this.$hideLabel().show(),this.$hide().prop("checked",!0),this.$el.show().removeClass("acf-hidden"),acf.doAction("show_postbox",this)},enable:function(){acf.enable(this.$el,"postbox")},showEnable:function(){this.enable(),this.show()},hide:function(){this.$hideLabel().hide(),this.$el.hide().addClass("acf-hidden"),acf.doAction("hide_postbox",this)},disable:function(){acf.disable(this.$el,"postbox")},hideDisable:function(){this.disable(),this.hide()},html:function(t){this.$inside().html(t),acf.doAction("append",this.$el)}})}(jQuery),function(a){acf.newMediaPopup=function(t){var e=null,e=new("edit"==(t=acf.parseArgs(t,{mode:"select",title:"",button:"",type:"",field:!1,allowedTypes:"",library:"all",multiple:!1,attachment:0,autoOpen:!0,open:function(){},select:function(){},close:function(){}})).mode?acf.models.EditMediaPopup:acf.models.SelectMediaPopup)(t);return t.autoOpen&&setTimeout(function(){e.open()},1),acf.doAction("new_media_popup",e),e};function e(){var t=acf.get("post_id");return acf.isNumeric(t)?t:0}acf.getMimeTypes=function(){return this.get("mimeTypes")},acf.getMimeType=function(t){var e,i=acf.getMimeTypes();if(void 0!==i[t])return i[t];for(e in i)if(-1!==e.indexOf(t))return i[e];return!1};var n=acf.Model.extend({id:"MediaPopup",data:{},defaults:{},frame:!1,setup:function(t){a.extend(this.data,t)},initialize:function(){var t=this.getFrameOptions();this.addFrameStates(t);var e=wp.media(t);(e.acf=this).addFrameEvents(e,t),this.frame=e},open:function(){this.frame.open()},close:function(){this.frame.close()},remove:function(){this.frame.detach(),this.frame.remove()},getFrameOptions:function(){var t={title:this.get("title"),multiple:this.get("multiple"),library:{},states:[]};return this.get("type")&&(t.library.type=this.get("type")),"uploadedTo"===this.get("library")&&(t.library.uploadedTo=e()),this.get("attachment")&&(t.library.post__in=[this.get("attachment")]),this.get("button")&&(t.button={text:this.get("button")}),t},addFrameStates:function(t){var e=wp.media.query(t.library);this.get("field")&&acf.isset(e,"mirroring","args")&&(e.mirroring.args._acfuploader=this.get("field")),t.states.push(new wp.media.controller.Library({library:e,multiple:this.get("multiple"),title:this.get("title"),priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})),acf.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage)},addFrameEvents:function(i,t){i.on("open",function(){this.$el.closest(".media-modal").addClass("acf-media-modal -"+this.acf.get("mode"))},i),i.on("content:render:edit-image",function(){var t=this.state().get("image"),t=new wp.media.view.EditImage({model:t,controller:this}).render();this.content.set(t),t.loadEditor()},i),i.on("select",function(){var t=i.state().get("selection");t&&t.each(function(t,e){i.acf.get("select").apply(i.acf,[t,e])})}),i.on("close",function(){setTimeout(function(){i.acf.get("close").apply(i.acf),i.acf.remove()},1)})}});acf.models.SelectMediaPopup=n.extend({id:"SelectMediaPopup",setup:function(t){t.button||(t.button=acf._x("Select","verb")),n.prototype.setup.apply(this,arguments)},addFrameEvents:function(e,t){acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=this.get("field"),e.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),e.on("content:activate:browse",function(){var t=!1;try{t=e.content.get().toolbar}catch(t){return void console.log(t)}e.acf.customizeFilters.apply(e.acf,[t])}),n.prototype.addFrameEvents.apply(this,arguments)},customizeFilters:function(t){var i,e=t.get("filters");"image"==this.get("type")&&(e.filters.all.text=acf.__("All images"),delete e.filters.audio,delete e.filters.video,delete e.filters.image,a.each(e.filters,function(t,e){e.props.type=e.props.type||"image"})),this.get("allowedTypes")&&this.get("allowedTypes").split(" ").join("").split(".").join("").split(",").map(function(t){t=acf.getMimeType(t);t&&(e.filters[t]={text:t,props:{status:null,type:t,uploadedTo:null,orderby:"date",order:"DESC"},priority:20})}),"uploadedTo"===this.get("library")&&(i=this.frame.options.library.uploadedTo,delete e.filters.unattached,delete e.filters.uploaded,a.each(e.filters,function(t,e){e.text+=" ("+acf.__("Uploaded to this post")+")",e.props.uploadedTo=i}));var n=this.get("field");a.each(e.filters,function(t,e){e.props._acfuploader=n}),t.get("search").model.attributes._acfuploader=n,e.renderFilters&&e.renderFilters()}}),acf.models.EditMediaPopup=n.extend({id:"SelectMediaPopup",setup:function(t){t.button||(t.button=acf._x("Update","verb")),n.prototype.setup.apply(this,arguments)},addFrameEvents:function(i,t){i.on("open",function(){this.$el.closest(".media-modal").addClass("acf-expanded"),"browse"!=this.content.mode()&&this.content.mode("browse");var t=this.state().get("selection"),e=wp.media.attachment(i.acf.get("attachment"));t.add(e)},i),n.prototype.addFrameEvents.apply(this,arguments)}});new acf.Model({id:"customizePrototypes",wait:"ready",initialize:function(){var t;acf.isset(window,"wp","media","view")&&((t=e())&&acf.isset(wp,"media","view","settings","post")&&(wp.media.view.settings.post.id=t),this.customizeAttachmentsButton(),this.customizeAttachmentsRouter(),this.customizeAttachmentFilters(),this.customizeAttachmentCompat(),this.customizeAttachmentLibrary())},customizeAttachmentsButton:function(){var t;acf.isset(wp,"media","view","Button")&&(t=wp.media.view.Button,wp.media.view.Button=t.extend({initialize:function(){var t=_.defaults(this.options,this.defaults);this.model=new Backbone.Model(t),this.listenTo(this.model,"change",this.render)}}))},customizeAttachmentsRouter:function(){var t;acf.isset(wp,"media","view","Router")&&(t=wp.media.view.Router,wp.media.view.Router=t.extend({addExpand:function(){var t=a(['<a href="#" class="acf-expand-details">','<span class="is-closed"><i class="acf-icon -left -small"></i>'+acf.__("Expand Details")+"</span>",'<span class="is-open"><i class="acf-icon -right -small"></i>'+acf.__("Collapse Details")+"</span>","</a>"].join(""));t.on("click",function(t){t.preventDefault();t=a(this).closest(".media-modal");t.hasClass("acf-expanded")?t.removeClass("acf-expanded"):t.addClass("acf-expanded")}),this.$el.append(t)},initialize:function(){return t.prototype.initialize.apply(this,arguments),this.addExpand(),this}}))},customizeAttachmentFilters:function(){acf.isset(wp,"media","view","AttachmentFilters","All")&&(wp.media.view.AttachmentFilters.All.prototype.renderFilters=function(){this.$el.html(_.chain(this.filters).map(function(t,e){return{el:a("<option></option>").val(e).html(t.text)[0],priority:t.priority||50}},this).sortBy("priority").pluck("el").value())})},customizeAttachmentCompat:function(){var t,e;acf.isset(wp,"media","view","AttachmentCompat")&&(t=wp.media.view.AttachmentCompat,e=!1,wp.media.view.AttachmentCompat=t.extend({render:function(){return this.rendered?this:(t.prototype.render.apply(this,arguments),this.$("#acf-form-data").length&&(clearTimeout(e),e=setTimeout(a.proxy(function(){this.rendered=!0,acf.doAction("append",this.$el)},this),50)),this)},save:function(t){var e;t&&t.preventDefault(),e=acf.serializeForAjax(this.$el),this.controller.trigger("attachment:compat:waiting",["waiting"]),this.model.saveCompat(e).always(_.bind(this.postSave,this))}}))},customizeAttachmentLibrary:function(){var o;acf.isset(wp,"media","view","Attachment","Library")&&(o=wp.media.view.Attachment.Library,wp.media.view.Attachment.Library=o.extend({render:function(){var t=acf.isget(this,"controller","acf"),e=acf.isget(this,"model","attributes");return t&&e&&(e.acf_errors&&this.$el.addClass("acf-disabled"),(t=t.get("selected"))&&-1<t.indexOf(e.id)&&this.$el.addClass("acf-selected")),o.prototype.render.apply(this,arguments)},toggleSelection:function(t){this.collection;var e=this.options.selection,i=this.model,n=(e.single(),this.controller),a=acf.isget(this,"model","attributes","acf_errors"),s=n.$el.find(".media-frame-content .media-sidebar");if(s.children(".acf-selection-error").remove(),s.children().removeClass("acf-hidden"),n&&a){n=acf.isget(this,"model","attributes","filename");return s.children().addClass("acf-hidden"),s.prepend(['<div class="acf-selection-error">','<span class="selection-error-label">'+acf.__("Restricted")+"</span>",'<span class="selection-error-filename">'+n+"</span>",'<span class="selection-error-message">'+a+"</span>","</div>"].join("")),e.reset(),void e.single(i)}return o.prototype.toggleSelection.apply(this,arguments)}}))}})}(jQuery),function(u){acf.screen=new acf.Model({active:!0,xhr:!1,timeout:!1,wait:"load",events:{"change #page_template":"onChange","change #parent_id":"onChange","change #post-formats-select":"onChange","change .categorychecklist":"onChange","change .tagsdiv":"onChange",'change .acf-taxonomy-field[data-save="1"]':"onChange","change #product-type":"onChange"},isPost:function(){return"post"===acf.get("screen")},isUser:function(){return"user"===acf.get("screen")},isTaxonomy:function(){return"taxonomy"===acf.get("screen")},isAttachment:function(){return"attachment"===acf.get("screen")},isNavMenu:function(){return"nav_menu"===acf.get("screen")},isWidget:function(){return"widget"===acf.get("screen")},isComment:function(){return"comment"===acf.get("screen")},getPageTemplate:function(){var t=u("#page_template");return t.length?t.val():null},getPageParent:function(t,e){return(e=u("#parent_id")).length?e.val():null},getPageType:function(t,e){return this.getPageParent()?"child":"parent"},getPostType:function(){return u("#post_type").val()},getPostFormat:function(t,e){if((e=u("#post-formats-select input:checked")).length){e=e.val();return"0"==e?"standard":e}return null},getPostCoreTerms:function(){var t,e={},i=acf.serialize(u(".categorydiv, .tagsdiv"));for(t in i.tax_input&&(e=i.tax_input),i.post_category&&(e.category=i.post_category),e)acf.isArray(e[t])||(e[t]=e[t].split(/,[\s]?/));return e},getPostTerms:function(){var t,i=this.getPostCoreTerms();for(t in acf.getFields({type:"taxonomy"}).map(function(t){var e;t.get("save")&&(e=t.val(),t=t.get("taxonomy"),e&&(i[t]=i[t]||[],e=acf.isArray(e)?e:[e],i[t]=i[t].concat(e)))}),null!==(productType=this.getProductType())&&(i.product_type=[productType]),i)i[t]=acf.uniqueArray(i[t]);return i},getProductType:function(){var t=u("#product-type");return t.length?t.val():null},check:function(){var e;"post"===acf.get("screen")&&(this.xhr&&this.xhr.abort(),e=acf.parseArgs(this.data,{action:"acf/ajax/check_screen",screen:acf.get("screen"),exists:[]}),this.isPost()&&(e.post_id=acf.get("post_id")),null!==(postType=this.getPostType())&&(e.post_type=postType),null!==(pageTemplate=this.getPageTemplate())&&(e.page_template=pageTemplate),null!==(pageParent=this.getPageParent())&&(e.page_parent=pageParent),null!==(pageType=this.getPageType())&&(e.page_type=pageType),null!==(postFormat=this.getPostFormat())&&(e.post_format=postFormat),null!==(postTerms=this.getPostTerms())&&(e.post_terms=postTerms),acf.getPostboxes().map(function(t){e.exists.push(t.get("key"))}),e=acf.applyFilters("check_screen_args",e),this.xhr=u.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(e),type:"post",dataType:"json",context:this,success:function(t){"post"==acf.get("screen")?this.renderPostScreen(t):"user"==acf.get("screen")&&this.renderUserScreen(t),acf.doAction("check_screen_complete",t,e)}}))},onChange:function(t,e){this.setTimeout(this.check,1)},renderPostScreen:function(c){function l(t,e){var i,n=u._data(t[0]).events;for(i in n)for(var a=0;a<n[i].length;a++)e.on(i,n[i][a].handler)}function d(t,e){var i=e.indexOf(t);if(-1!=i){for(var n=i-1;0<=n;n--)if(u("#"+e[n]).length)return u("#"+e[n]).after(u("#"+t));for(n=i+1;n<e.length;n++)if(u("#"+e[n]).length)return u("#"+e[n]).before(u("#"+t))}}c.visible=[],c.hidden=[],c.results=c.results.map(function(e,t){var i=acf.getPostbox(e.id);if(acf.isGutenberg()&&"acf_after_title"==e.position&&(e.position="normal"),!i){a=(5.5<=parseFloat(acf.get("wp_version"))?['<div class="postbox-header">','<h2 class="hndle ui-sortable-handle">',"<span>"+acf.escHtml(e.title)+"</span>","</h2>",'<div class="handle-actions hide-if-no-js">','<button type="button" class="handlediv" aria-expanded="true">','<span class="screen-reader-text">Toggle panel: '+acf.escHtml(e.title)+"</span>",'<span class="toggle-indicator" aria-hidden="true"></span>',"</button>","</div>","</div>"]:['<button type="button" class="handlediv" aria-expanded="true">','<span class="screen-reader-text">Toggle panel: '+acf.escHtml(e.title)+"</span>",'<span class="toggle-indicator" aria-hidden="true"></span>',"</button>",'<h2 class="hndle ui-sortable-handle">',"<span>"+acf.escHtml(e.title)+"</span>","</h2>"]).join("");var n,a,s=u(['<div id="'+e.id+'" class="postbox">',a,'<div class="inside">',e.html,"</div>","</div>"].join(""));u("#adv-settings").length&&(n=u("#adv-settings .metabox-prefs"),a=u(['<label for="'+e.id+'-hide">','<input class="hide-postbox-tog" name="'+e.id+'-hide" type="checkbox" id="'+e.id+'-hide" value="'+e.id+'" checked="checked">'," "+e.title,"</label>"].join("")),l(n.find("input").first(),a.find("input")),n.append(a)),u(".postbox").length&&(l(u(".postbox .handlediv").first(),s.children(".handlediv")),l(u(".postbox .hndle").first(),s.children(".hndle"))),"side"===e.position?u("#"+e.position+"-sortables").append(s):u("#"+e.position+"-sortables").prepend(s);var o=[];if(c.results.map(function(t){e.position===t.position&&u("#"+e.position+"-sortables #"+t.id).length&&o.push(t.id)}),d(e.id,o),c.sorted)for(var r in c.sorted){o=c.sorted[r].split(",");if(d(e.id,o))break}i=acf.newPostbox(e),acf.doAction("append",s),acf.doAction("append_postbox",i)}return i.showEnable(),c.visible.push(e.id),e}),acf.getPostboxes().map(function(t){-1===c.visible.indexOf(t.get("id"))&&(t.hideDisable(),c.hidden.push(t.get("id")))}),u("#acf-style").html(c.style),acf.doAction("refresh_post_screen",c)},renderUserScreen:function(t){}});new acf.Model({postEdits:{},wait:"prepare",initialize:function(){acf.isGutenberg()&&(wp.data.subscribe(acf.debounce(this.onChange).bind(this)),acf.screen.getPageTemplate=this.getPageTemplate,acf.screen.getPageParent=this.getPageParent,acf.screen.getPostType=this.getPostType,acf.screen.getPostFormat=this.getPostFormat,acf.screen.getPostCoreTerms=this.getPostCoreTerms,acf.unload.disable(),5.3<=parseFloat(acf.get("wp_version"))&&this.addAction("refresh_post_screen",this.onRefreshPostScreen),wp.domReady(acf.refresh))},onChange:function(){var e=["template","parent","format"];(wp.data.select("core").getTaxonomies()||[]).map(function(t){e.push(t.rest_base)});var i=wp.data.select("core/editor").getPostEdits(),n={};e.map(function(t){void 0!==i[t]&&(n[t]=i[t])}),JSON.stringify(n)!==JSON.stringify(this.postEdits)&&(this.postEdits=n,acf.screen.check())},getPageTemplate:function(){return wp.data.select("core/editor").getEditedPostAttribute("template")},getPageParent:function(t,e){return wp.data.select("core/editor").getEditedPostAttribute("parent")},getPostType:function(){return wp.data.select("core/editor").getEditedPostAttribute("type")},getPostFormat:function(t,e){return wp.data.select("core/editor").getEditedPostAttribute("format")},getPostCoreTerms:function(){var i={};return(wp.data.select("core").getTaxonomies()||[]).map(function(t){var e=wp.data.select("core/editor").getEditedPostAttribute(t.rest_base);e&&(i[t.slug]=e)}),i},onRefreshPostScreen:function(e){var i=wp.data.select("core/edit-post"),t=wp.data.dispatch("core/edit-post"),n={};i.getActiveMetaBoxLocations().map(function(t){n[t]=i.getMetaBoxesPerLocation(t)});var a,s=[];for(a in n)n[a].map(function(t){s.push(t.id)});for(a in e.results.filter(function(t){return-1===s.indexOf(t.id)}).map(function(t,e){var i=t.position;n[i]=n[i]||[],n[i].push({id:t.id,title:t.title})}),n)n[a]=n[a].filter(function(t){return-1===e.hidden.indexOf(t.id)});t.setAvailableMetaBoxesPerLocation(n)}})}(jQuery),function(l){function n(){return acf.isset(window,"jQuery","fn","select2","amd")?4:!!acf.isset(window,"Select2")&&3}acf.newSelect2=function(t,e){return e=acf.parseArgs(e,{allowNull:!1,placeholder:"",multiple:!1,field:!1,ajax:!1,ajaxAction:"",ajaxData:function(t){return t},ajaxResults:function(t){return t}}),e=new(4==n()?a:s)(t,e),acf.doAction("new_select2",e),e};var i=acf.Model.extend({setup:function(t,e){l.extend(this.data,e),this.$el=t},initialize:function(){},selectOption:function(t){t=this.getOption(t);t.prop("selected")||t.prop("selected",!0).trigger("change")},unselectOption:function(t){t=this.getOption(t);t.prop("selected")&&t.prop("selected",!1).trigger("change")},getOption:function(t){return this.$('option[value="'+t+'"]')},addOption:function(t){t=acf.parseArgs(t,{id:"",text:"",selected:!1});var e=this.getOption(t.id);return e.length||((e=l("<option></option>")).html(t.text),e.attr("value",t.id),e.prop("selected",t.selected),this.$el.append(e)),e},getValue:function(){var e=[],t=this.$el.find("option:selected");return t.exists()&&(t=t.sort(function(t,e){return+t.getAttribute("data-i")-+e.getAttribute("data-i")})).each(function(){var t=l(this);e.push({$el:t,id:t.attr("value"),text:t.text()})}),e},mergeOptions:function(){},getChoices:function(){var i=function(t){var e=[];return t.children().each(function(){var t=l(this);t.is("optgroup")?e.push({text:t.attr("label"),children:i(t)}):e.push({id:t.attr("value"),text:t.text()})}),e};return i(this.$el)},getAjaxData:function(t){var e={action:this.get("ajaxAction"),s:t.term||"",paged:t.page||1},i=this.get("field");i&&(e.field_key=i.get("key"));var n=this.get("ajaxData");return n&&(e=n.apply(this,[e,t])),e=acf.applyFilters("select2_ajax_data",e,this.data,this.$el,i||!1,this),acf.prepareForAjax(e)},getAjaxResults:function(t,e){t=acf.parseArgs(t,{results:!1,more:!1});var i=this.get("ajaxResults");return i&&(t=i.apply(this,[t,e])),t=acf.applyFilters("select2_ajax_results",t,e,this)},processAjaxResults:function(t,e){return(t=this.getAjaxResults(t,e)).more&&(t.pagination={more:!0}),setTimeout(l.proxy(this.mergeOptions,this),1),t},destroy:function(){this.$el.data("select2")&&this.$el.select2("destroy"),this.$el.siblings(".select2-container").remove()}}),a=i.extend({initialize:function(){var e=this.$el;(n={width:"100%",allowClear:this.get("allowNull"),placeholder:this.get("placeholder"),multiple:this.get("multiple"),data:[],templateSelection:function(t){var e=l('<span class="acf-selection"></span>');return e.text(acf.escHtml(t.text)),e.data("element",t.element),e}}).multiple&&this.getValue().map(function(t){t.$el.detach().appendTo(e)});var t=e.attr("data-ajax");void 0!==t&&(e.removeData("ajax"),e.removeAttr("data-ajax")),this.get("ajax")&&(n.ajax={url:acf.get("ajaxurl"),delay:250,dataType:"json",type:"post",cache:!1,data:l.proxy(this.getAjaxData,this),processResults:l.proxy(this.processAjaxResults,this)});var i=this.get("field"),n=acf.applyFilters("select2_args",n,e,this.data,i||!1,this);e.select2(n);var a,s=e.next(".select2-container");n.multiple&&((a=s.find("ul")).sortable({stop:function(t){a.find(".select2-selection__choice").each(function(){l(l(this).children("span.acf-selection").data("element")).detach().appendTo(e)}),e.trigger("change")}}),e.on("select2:select",this.proxy(function(t){this.getOption(t.params.data.id).detach().appendTo(this.$el)}))),s.addClass("-acf"),void 0!==t&&e.attr("data-ajax",t),acf.doAction("select2_init",e,n,this.data,i||!1,this)},mergeOptions:function(){var i=!1,n=!1;l('.select2-results__option[role="group"]').each(function(){var t=l(this).children("ul"),e=l(this).children("strong");if(n&&n.text()===e.text())return i.append(t.children()),void l(this).remove();i=t,n=e})}}),s=i.extend({initialize:function(){var i=this.$el,n=this.getValue(),a=this.get("multiple"),t={width:"100%",allowClear:this.get("allowNull"),placeholder:this.get("placeholder"),separator:"||",multiple:this.get("multiple"),data:this.getChoices(),escapeMarkup:function(t){return acf.escHtml(t)},dropdownCss:{"z-index":"999999999"},initSelection:function(t,e){e(a?n:n.shift())}},e=i.siblings("input");e.length||(e=l('<input type="hidden" />'),i.before(e)),inputValue=n.map(function(t){return t.id}).join("||"),e.val(inputValue),t.multiple&&n.map(function(t){t.$el.detach().appendTo(i)}),t.allowClear&&(t.data=t.data.filter(function(t){return""!==t.id})),i.removeData("ajax"),i.removeAttr("data-ajax"),this.get("ajax")&&(t.ajax={url:acf.get("ajaxurl"),quietMillis:250,dataType:"json",type:"post",cache:!1,data:l.proxy(this.getAjaxData,this),results:l.proxy(this.processAjaxResults,this)});var s=this.get("field"),t=acf.applyFilters("select2_args",t,i,this.data,s||!1,this);e.select2(t);var o,r=e.select2("container"),c=l.proxy(this.getOption,this);t.multiple&&(o=r.find("ul")).sortable({stop:function(){o.find(".select2-search-choice").each(function(){var t=l(this).data("select2Data");c(t.id).detach().appendTo(i)}),i.trigger("change")}}),e.on("select2-selecting",function(t){var e=t.choice,t=c(e.id);(t=!t.length?l('<option value="'+e.id+'">'+e.text+"</option>"):t).detach().appendTo(i)}),r.addClass("-acf"),acf.doAction("select2_init",i,t,this.data,s||!1,this),e.on("change",function(){var t=e.val();t.indexOf("||")&&(t=t.split("||")),i.val(t).trigger("change")}),i.hide()},mergeOptions:function(){var i=!1;l("#select2-drop .select2-result-with-children").each(function(){var t=l(this).children("ul"),e=l(this).children(".select2-result-label");if(i&&i.text()===e.text())return i.append(t.children()),void l(this).remove();i=e})},getAjaxData:function(t,e){return i.prototype.getAjaxData.apply(this,[{term:t,page:e}])}});new acf.Model({priority:5,wait:"prepare",actions:{duplicate:"onDuplicate"},initialize:function(){var t=acf.get("locale"),e=(acf.get("rtl"),acf.get("select2L10n")),i=n();return!!e&&(0!==t.indexOf("en")&&void(4==i?this.addTranslations4():3==i&&this.addTranslations3()))},addTranslations4:function(){var e=acf.get("select2L10n"),t=(t=acf.get("locale")).replace("_","-"),i={errorLoading:function(){return e.load_fail},inputTooLong:function(t){t=t.input.length-t.maximum;return 1<t?e.input_too_long_n.replace("%d",t):e.input_too_long_1},inputTooShort:function(t){t=t.minimum-t.input.length;return 1<t?e.input_too_short_n.replace("%d",t):e.input_too_short_1},loadingMore:function(){return e.load_more},maximumSelected:function(t){t=t.maximum;return 1<t?e.selection_too_long_n.replace("%d",t):e.selection_too_long_1},noResults:function(){return e.matches_0},searching:function(){return e.searching}};jQuery.fn.select2.amd.define("select2/i18n/"+t,[],function(){return i})},addTranslations3:function(){var i=acf.get("select2L10n"),t=(t=acf.get("locale")).replace("_","-"),e={formatMatches:function(t){return 1<t?i.matches_n.replace("%d",t):i.matches_1},formatNoMatches:function(){return i.matches_0},formatAjaxError:function(){return i.load_fail},formatInputTooShort:function(t,e){t=e-t.length;return 1<t?i.input_too_short_n.replace("%d",t):i.input_too_short_1},formatInputTooLong:function(t,e){e=t.length-e;return 1<e?i.input_too_long_n.replace("%d",e):i.input_too_long_1},formatSelectionTooBig:function(t){return 1<t?i.selection_too_long_n.replace("%d",t):i.selection_too_long_1},formatLoadMore:function(){return i.load_more},formatSearching:function(){return i.searching}};l.fn.select2.locales=l.fn.select2.locales||{},l.fn.select2.locales[t]=e,l.extend(l.fn.select2.defaults,e)},onDuplicate:function(t,e){e.find(".select2-container").remove()}})}(jQuery),function(l){acf.tinymce={defaults:function(){return"undefined"!=typeof tinyMCEPreInit&&{tinymce:tinyMCEPreInit.mceInit.acf_content,quicktags:tinyMCEPreInit.qtInit.acf_content}},initialize:function(t,e){(e=acf.parseArgs(e,{tinymce:!0,quicktags:!0,toolbar:"full",mode:"visual",field:!1})).tinymce&&this.initializeTinymce(t,e),e.quicktags&&this.initializeQuicktags(t,e)},initializeTinymce:function(t,e){var i=l("#"+t),n=this.defaults(),a=acf.get("toolbars"),s=e.field||!1;s.$el;if("undefined"==typeof tinymce)return!1;if(!n)return!1;if(tinymce.get(t))return this.enable(t);var o=l.extend({},n.tinymce,e.tinymce);o.id=t,o.selector="#"+t;var r=e.toolbar;if(r&&a&&a[r])for(var c=1;c<=4;c++)o["toolbar"+c]=a[r][c]||"";if(o.setup=function(e){e.on("change",function(t){e.save(),i.trigger("change")}),e.on("mouseup",function(t){var e=new MouseEvent("mouseup");window.dispatchEvent(e)})},o.wp_autoresize_on=!1,o.tadv_noautop||(o.wpautop=!0),o=acf.applyFilters("wysiwyg_tinymce_settings",o,t,s),tinyMCEPreInit.mceInit[t]=o,"visual"==e.mode){tinymce.init(o);t=tinymce.get(t);if(!t)return!1;t.acf=e.field,acf.doAction("wysiwyg_tinymce_init",t,t.id,o,s)}},initializeQuicktags:function(t,e){var i=this.defaults();if("undefined"==typeof quicktags)return!1;if(!i)return!1;(i=l.extend({},i.quicktags,e.quicktags)).id=t;e=e.field||!1,e.$el,i=acf.applyFilters("wysiwyg_quicktags_settings",i,i.id,e);tinyMCEPreInit.qtInit[t]=i;t=quicktags(i);if(!t)return!1;this.buildQuicktags(t),acf.doAction("wysiwyg_quicktags_init",t,t.id,i,e)},buildQuicktags:function(t){t.canvas;var e,i,n=t.name,a=t.settings,s="",o={},r="",c=t.id;for(i in a.buttons&&(r=","+a.buttons+","),edButtons)edButtons[i]&&(e=edButtons[i].id,r&&-1!==",strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,".indexOf(","+e+",")&&-1===r.indexOf(","+e+",")||edButtons[i].instance&&edButtons[i].instance!==c||(o[e]=edButtons[i],edButtons[i].html&&(s+=edButtons[i].html(n+"_"))));r&&-1!==r.indexOf(",dfw,")&&(o.dfw=new QTags.DFWButton,s+=o.dfw.html(n+"_")),"rtl"===document.getElementsByTagName("html")[0].dir&&(o.textdirection=new QTags.TextDirectionButton,s+=o.textdirection.html(n+"_")),t.toolbar.innerHTML=s,t.theButtons=o,"undefined"!=typeof jQuery&&jQuery(document).triggerHandler("quicktags-init",[t])},disable:function(t){this.destroyTinymce(t)},remove:function(t){this.destroyTinymce(t)},destroy:function(t){this.destroyTinymce(t)},destroyTinymce:function(t){if("undefined"==typeof tinymce)return!1;t=tinymce.get(t);return!!t&&(t.save(),t.destroy(),!0)},enable:function(t){this.enableTinymce(t)},enableTinymce:function(t){return"undefined"!=typeof switchEditors&&(void 0!==tinyMCEPreInit.mceInit[t]&&(l("#"+t).show(),switchEditors.go(t,"tmce"),!0))}};new acf.Model({priority:5,actions:{prepare:"onPrepare",ready:"onReady"},onPrepare:function(){var t=l("#acf-hidden-wp-editor");t.exists()&&t.appendTo("body")},onReady:function(){acf.isset(window,"wp","oldEditor")&&(wp.editor.autop=wp.oldEditor.autop,wp.editor.removep=wp.oldEditor.removep),acf.isset(window,"tinymce","on")&&tinymce.on("AddEditor",function(t){t=t.editor;"acf"===t.id.substr(0,3)&&(t=tinymce.editors.content||t,tinymce.activeEditor=t,wpActiveEditor=t.id)})}})}(jQuery),function(c){function n(t){return t.data("acf")||new e(t)}var e=acf.Model.extend({id:"Validator",data:{errors:[],notice:null,status:""},events:{"changed:status":"onChangeStatus"},addErrors:function(t){t.map(this.addError,this)},addError:function(t){this.data.errors.push(t)},hasErrors:function(){return this.data.errors.length},clearErrors:function(){return this.data.errors=[]},getErrors:function(){return this.data.errors},getFieldErrors:function(){var i=[],n=[];return this.getErrors().map(function(t){var e;t.input&&(-1<(e=n.indexOf(t.input))?i[e]=t:(i.push(t),n.push(t.input)))}),i},getGlobalErrors:function(){return this.getErrors().filter(function(t){return!t.input})},showErrors:function(){var t,i,n,e,a;this.hasErrors()&&(t=this.getFieldErrors(),a=this.getGlobalErrors(),i=0,n=!1,t.map(function(t){var e=this.$('[name="'+t.input+'"]').first();(e=!e.length?this.$('[name^="'+t.input+'"]').first():e).length&&(i++,(e=acf.getClosestField(e)).showError(t.message),n=n||e.$el)},this),e=acf.__("Validation failed"),a.map(function(t){e+=". "+t.message}),1==i?e+=". "+acf.__("1 field requires attention"):1<i&&(e+=". "+acf.__("%d fields require attention").replace("%d",i)),this.has("notice")?this.get("notice").update({type:"error",text:e}):(a=acf.newNotice({type:"error",text:e,target:this.$el}),this.set("notice",a)),n=n||this.get("notice").$el,setTimeout(function(){c("html, body").animate({scrollTop:n.offset().top-c(window).height()/2},500)},10))},onChangeStatus:function(t,e,i,n){this.$el.removeClass("is-"+n).addClass("is-"+i)},validate:function(t){if(t=acf.parseArgs(t,{event:!1,reset:!1,loading:function(){},complete:function(){},failure:function(){},success:function(t){t.submit()}}),"valid"==this.get("status"))return!0;if("validating"==this.get("status"))return!1;if(!this.$(".acf-field").length)return!0;var e;t.event&&(e=c.Event(null,t.event),t.success=function(){acf.enableSubmit(c(e.target)).trigger(e)}),acf.doAction("validation_begin",this.$el),acf.lockForm(this.$el),t.loading(this.$el,this),this.set("status","validating");var i=acf.serialize(this.$el);return i.action="acf/validate_save_post",c.ajax({url:acf.get("ajaxurl"),data:acf.prepareForAjax(i),type:"post",dataType:"json",context:this,success:function(t){acf.isAjaxSuccess(t)&&((t=acf.applyFilters("validation_complete",t.data,this.$el,this)).valid||this.addErrors(t.errors))},complete:function(){acf.unlockForm(this.$el),this.hasErrors()?(this.set("status","invalid"),acf.doAction("validation_failure",this.$el,this),this.showErrors(),t.failure(this.$el,this)):(this.set("status","valid"),this.has("notice")&&this.get("notice").update({type:"success",text:acf.__("Validation successful"),timeout:1e3}),acf.doAction("validation_success",this.$el,this),acf.doAction("submit",this.$el),t.success(this.$el,this),acf.lockForm(this.$el),t.reset&&this.reset()),t.complete(this.$el,this),this.clearErrors()}}),!1},setup:function(t){this.$el=t},reset:function(){this.set("errors",[]),this.set("notice",null),this.set("status",""),acf.unlockForm(this.$el)}});acf.validateForm=function(t){return n(t.form).validate(t)},acf.enableSubmit=function(t){return t.removeClass("disabled")},acf.disableSubmit=function(t){return t.addClass("disabled")},acf.showSpinner=function(t){return t.addClass("is-active"),t.css("display","inline-block"),t},acf.hideSpinner=function(t){return t.removeClass("is-active"),t.css("display","none"),t},acf.lockForm=function(t){var e=a(t),i=e.find('.button, [type="submit"]'),e=e.find(".spinner, .acf-spinner");return acf.hideSpinner(e),acf.disableSubmit(i),acf.showSpinner(e.last()),t},acf.unlockForm=function(t){var e=a(t),i=e.find('.button, [type="submit"]'),e=e.find(".spinner, .acf-spinner");return acf.enableSubmit(i),acf.hideSpinner(e),t};var a=function(t){var e=t.find("#submitdiv");return e.length||(e=t.find("#submitpost")).length||(e=t.find("p.submit").last()).length||(e=t.find(".acf-form-submit")).length?e:t},s=acf.debounce(function(t){t.submit()});acf.validation=new acf.Model({id:"validation",active:!0,wait:"prepare",actions:{ready:"addInputEvents",append:"addInputEvents"},events:{'click input[type="submit"]':"onClickSubmit",'click button[type="submit"]':"onClickSubmit","click #save-post":"onClickSave","submit form#post":"onSubmitPost","submit form":"onSubmit"},initialize:function(){acf.get("validation")||(this.active=!1,this.actions={},this.events={})},enable:function(){this.active=!0},disable:function(){this.active=!1},reset:function(t){n(t).reset()},addInputEvents:function(t){"safari"===acf.get("browser")||(t=c(".acf-field [name]",t)).length&&this.on(t,"invalid","onInvalid")},onInvalid:function(t,e){t.preventDefault();var i=e.closest("form");i.length&&(n(i).addError({input:e.attr("name"),message:acf.strEscape(t.target.validationMessage)}),s(i))},onClickSubmit:function(t,e){this.set("originalEvent",t)},onClickSave:function(t,e){this.set("ignore",!0)},onClickSubmitGutenberg:function(t,e){acf.validateForm({form:c("#editor"),event:t,reset:!0,failure:function(t,e){e=e.get("notice").$el;e.appendTo(".components-notice-list"),e.find(".acf-notice-dismiss").removeClass("small")}})||(t.preventDefault(),t.stopImmediatePropagation())},onSubmitPost:function(t,e){"dopreview"===c("input#wp-preview").val()&&(this.set("ignore",!0),acf.unlockForm(e))},onSubmit:function(t,e){if(!this.active||this.get("ignore")||t.isDefaultPrevented())return this.allowSubmit();acf.validateForm({form:e,event:this.get("originalEvent")})||t.preventDefault()},allowSubmit:function(){return this.set("ignore",!1),this.set("originalEvent",!1),!0}});new acf.Model({wait:"prepare",initialize:function(){acf.isGutenberg()&&this.customizeEditor()},customizeEditor:function(){var n=wp.data.dispatch("core/editor"),e=wp.data.select("core/editor"),a=wp.data.dispatch("core/notices"),s=n.savePost,o=!1,r="";wp.data.subscribe(function(){var t=e.getEditedPostAttribute("status");o="publish"===t||"future"===t,r="publish"!==t?t:r}),n.savePost=function(e){e=e||{};var t=this,i=arguments;return new Promise(function(t,i){return e.isAutosave||e.isPreview?t("Validation ignored (autosave)."):o?void(acf.validateForm({form:c("#editor"),reset:!0,complete:function(t,e){n.unlockPostSaving("acf")},failure:function(t,e){e=e.get("notice");a.createErrorNotice(e.get("text"),{id:"acf-validation",isDismissible:!0}),e.remove(),r&&n.editPost({status:r}),i("Validation failed.")},success:function(){a.removeNotice("acf-validation"),t("Validation success.")}})?t("Validation bypassed."):n.lockPostSaving("acf")):t("Validation ignored (draft).")}).then(function(){return s.apply(t,i)}).catch(function(t){})}}})}(jQuery),function(c){new acf.Model({priority:90,actions:{new_field:"refresh",show_field:"refresh",hide_field:"refresh",remove_field:"refresh",unmount_field:"refresh",remount_field:"refresh"},refresh:function(){acf.refresh()}}),new acf.Model({priority:1,actions:{sortstart:"onSortstart",sortstop:"onSortstop"},onSortstart:function(t){acf.doAction("unmount",t)},onSortstop:function(t){acf.doAction("remount",t)}}),new acf.Model({actions:{sortstart:"onSortstart"},onSortstart:function(t,e){t.is("tr")&&(e.html('<td style="padding:0;" colspan="'+e.children().length+'"></td>'),t.addClass("acf-sortable-tr-helper"),t.children().each(function(){c(this).width(c(this).width())}),e.height(t.height()+"px"),t.removeClass("acf-sortable-tr-helper"))}}),new acf.Model({actions:{after_duplicate:"onAfterDuplicate"},onAfterDuplicate:function(t,e){var i=[];t.find("select").each(function(t){i.push(c(this).val())}),e.find("select").each(function(t){c(this).val(i[t])})}}),new acf.Model({id:"tableHelper",priority:20,actions:{refresh:"renderTables"},renderTables:function(t){var e=this;c(".acf-table:visible").each(function(){e.renderTable(c(this))})},renderTable:function(t){var e=t.find("> thead > tr:visible > th[data-key]"),a=t.find("> tbody > tr:visible > td[data-key]");if(!e.length||!a.length)return!1;e.each(function(t){var e=c(this),i=e.data("key"),n=a.filter('[data-key="'+i+'"]'),i=n.filter(".acf-hidden");n.removeClass("acf-empty"),n.length===i.length?acf.hide(e):(acf.show(e),i.addClass("acf-empty"))}),e.css("width","auto");var e=e.not(".acf-hidden"),i=100;e.length;e.filter("[data-width]").each(function(){var t=c(this).data("width");c(this).css("width",t+"%"),i-=t});var n=e.not("[data-width]");n.length&&(t=i/n.length,n.css("width",t+"%"),i=0),0<i&&e.last().css("width","auto"),a.filter(".-collapsed-target").each(function(){var t=c(this);t.parent().hasClass("-collapsed")?t.attr("colspan",e.length):t.removeAttr("colspan")})}}),new acf.Model({id:"fieldsHelper",priority:30,actions:{refresh:"renderGroups"},renderGroups:function(){var t=this;c(".acf-fields:visible").each(function(){t.renderGroup(c(this))})},renderGroup:function(t){var s=0,o=0,r=c(),e=t.children(".acf-field[data-width]:visible");return!!e.length&&(t.hasClass("-left")?(e.removeAttr("data-width"),e.css("width","auto"),!1):(e.removeClass("-r0 -c0").css({"min-height":0}),e.each(function(t){var e=c(this),i=e.position(),n=Math.ceil(i.top),a=Math.ceil(i.left);r.length&&s<n&&(r.css({"min-height":o+"px"}),i=e.position(),n=Math.ceil(i.top),a=Math.ceil(i.left),o=s=0,r=c()),acf.get("rtl")&&(a=Math.ceil(e.parent().width()-(i.left+e.outerWidth()))),0==n?e.addClass("-r0"):0==a&&e.addClass("-c0");a=Math.ceil(e.outerHeight())+1;o=Math.max(o,a),s=Math.max(s,n),r=r.add(e)}),void(r.length&&r.css({"min-height":o+"px"}))))}}),new acf.Model({id:"bodyClassShiftHelper",events:{keydown:"onKeyDown",keyup:"onKeyUp"},isShiftKey:function(t){return 16===t.keyCode},onKeyDown:function(t){this.isShiftKey(t)&&c("body").addClass("acf-keydown-shift")},onKeyUp:function(t){this.isShiftKey(t)&&c("body").removeClass("acf-keydown-shift")}})}(jQuery),function(s){acf.newCompatibility=function(t,e){return(e=e||{}).__proto__=t.__proto__,t.__proto__=e,t.compatibility=e},acf.getCompatibility=function(t){return t.compatibility||null};var r=acf.newCompatibility(acf,{l10n:{},o:{},fields:{},update:acf.set,add_action:acf.addAction,remove_action:acf.removeAction,do_action:acf.doAction,add_filter:acf.addFilter,remove_filter:acf.removeFilter,apply_filters:acf.applyFilters,parse_args:acf.parseArgs,disable_el:acf.disable,disable_form:acf.disable,enable_el:acf.enable,enable_form:acf.enable,update_user_setting:acf.updateUserSetting,prepare_for_ajax:acf.prepareForAjax,is_ajax_success:acf.isAjaxSuccess,remove_el:acf.remove,remove_tr:acf.remove,str_replace:acf.strReplace,render_select:acf.renderSelect,get_uniqid:acf.uniqid,serialize_form:acf.serialize,esc_html:acf.strEscape,str_sanitize:acf.strSanitize});r._e=function(t,e){t=t||"";var i=(e=e||"")?t+"."+e:t,n={"image.select":"Select Image","image.edit":"Edit Image","image.update":"Update Image"};if(n[i])return acf.__(n[i]);t=this.l10n[t]||"";return t=e?t[e]||"":t},r.get_selector=function(t){var e=".acf-field";if(!t)return e;if(s.isPlainObject(t)){if(s.isEmptyObject(t))return e;for(var i in t){t=t[i];break}}return e+="-"+t,e=acf.strReplace("_","-",e),e=acf.strReplace("field-field-","field-",e)},r.get_fields=function(t,e,i){i={is:t||"",parent:e||!1,suppressFilters:i||!1};return i.is&&(i.is=this.get_selector(i.is)),acf.findFields(i)},r.get_field=function(t,e){var i=this.get_fields.apply(this,arguments);return!!i.length&&i.first()},r.get_closest_field=function(t,e){return t.closest(this.get_selector(e))},r.get_field_wrap=function(t){return t.closest(this.get_selector())},r.get_field_key=function(t){return t.data("key")},r.get_field_type=function(t){return t.data("type")},r.get_data=function(t,e){return acf.parseArgs(t.data(),e)},r.maybe_get=function(t,e,i){void 0===i&&(i=null),keys=String(e).split(".");for(var n=0;n<keys.length;n++){if(!t.hasOwnProperty(keys[n]))return i;t=t[keys[n]]}return t};function i(t){return t instanceof acf.Field?t.$el:t}function c(e){return function(){var t;return t=arguments.length?(t=arguments,acf.arrayArgs(t).map(i)):[s(document)],e.apply(this,t)}}r.add_action=function(t,e,i,n){var a=t.split(" "),s=a.length;if(1<s){for(var o=0;o<s;o++)t=a[o],r.add_action.apply(this,arguments);return this}e=c(e);return acf.addAction.apply(this,arguments)},r.add_filter=function(t,e,i,n){e=c(e);return acf.addFilter.apply(this,arguments)},r.model={actions:{},filters:{},events:{},extend:function(t){var i=s.extend({},this,t);return s.each(i.actions,function(t,e){i._add_action(t,e)}),s.each(i.filters,function(t,e){i._add_filter(t,e)}),s.each(i.events,function(t,e){i._add_event(t,e)}),i},_add_action:function(t,e){var i=t.split(" "),t=i[0]||"",i=i[1]||10;acf.add_action(t,this[e],i,this)},_add_filter:function(t,e){var i=t.split(" "),t=i[0]||"",i=i[1]||10;acf.add_filter(t,this[e],i,this)},_add_event:function(t,e){var i=this,n=t.indexOf(" "),a=0<n?t.substr(0,n):t,t=0<n?t.substr(n+1):"",n=function(t){t.$el=s(this),acf.field_group&&(t.$field=t.$el.closest(".acf-field-object")),"function"==typeof i.event&&(t=i.event(t)),i[e].apply(i,arguments)};t?s(document).on(a,t,n):s(document).on(a,n)},get:function(t,e){return e=e||null,e=void 0!==this[t]?this[t]:e},set:function(t,e){return this[t]=e,"function"==typeof this["_set_"+t]&&this["_set_"+t].apply(this),this}},r.field=acf.model.extend({type:"",o:{},$field:null,_add_action:function(t,e){var i=this;t=t+"_field/type="+i.type,acf.add_action(t,function(t){i.set("$field",t),i[e].apply(i,arguments)})},_add_filter:function(t,e){var i=this;t=t+"_field/type="+i.type,acf.add_filter(t,function(t){i.set("$field",t),i[e].apply(i,arguments)})},_add_event:function(t,n){var a=this,e=t.substr(0,t.indexOf(" ")),i=t.substr(t.indexOf(" ")+1),t=acf.get_selector(a.type);s(document).on(e,t+" "+i,function(t){var e=s(this),i=acf.get_closest_field(e,a.type);i.length&&(i.is(a.$field)||a.set("$field",i),t.$el=e,t.$field=i,a[n].apply(a,[t]))})},_set_$field:function(){"function"==typeof this.focus&&this.focus()},doFocus:function(t){return this.set("$field",t)}});acf.newCompatibility(acf.validation,{remove_error:function(t){acf.getField(t).removeError()},add_warning:function(t,e){acf.getField(t).showNotice({text:e,type:"warning",timeout:1e3})},fetch:acf.validateForm,enableSubmit:acf.enableSubmit,disableSubmit:acf.disableSubmit,showSpinner:acf.showSpinner,hideSpinner:acf.hideSpinner,unlockForm:acf.unlockForm,lockForm:acf.lockForm});r.tooltip={tooltip:function(t,e){return acf.newTooltip({text:t,target:e}).$el},temp:function(t,e){acf.newTooltip({text:t,target:e,timeout:250})},confirm:function(t,e,i,n,a){acf.newTooltip({confirm:function(){e(!0)},text:i,target:t,cancel:function(){e(!1)}})},confirm_remove:function(t,e){acf.newTooltip({confirmRemove:!0,target:t,confirm:function(){e(!0)},cancel:function(){e(!1)}})}},r.media=new acf.Model({activeFrame:!1,actions:{new_media_popup:"onNewMediaPopup"},frame:function(){return this.activeFrame},onNewMediaPopup:function(t){this.activeFrame=t.frame},popup:function(t){return t.mime_types&&(t.allowedTypes=t.mime_types),t.id&&(t.attachment=t.id),acf.newMediaPopup(t).frame}}),r.select2={init:function(t,e,i){return e.allow_null&&(e.allowNull=e.allow_null),e.ajax_action&&(e.ajaxAction=e.ajax_action),i&&(e.field=acf.getField(i)),acf.newSelect2(t,e)},destroy:function(t){return acf.getInstance(t).destroy()}},r.postbox={render:function(t){return t.edit_url&&(t.editLink=t.edit_url),t.edit_title&&(t.editTitle=t.edit_title),acf.newPostbox(t)}},acf.newCompatibility(acf.screen,{update:function(){return this.set.apply(this,arguments)},fetch:acf.screen.check}),r.ajax=acf.screen}(jQuery);
|
assets/inc/color-picker-alpha/wp-color-picker-alpha.js
ADDED
@@ -0,0 +1,635 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**!
|
2 |
+
* wp-color-picker-alpha
|
3 |
+
*
|
4 |
+
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
|
5 |
+
* Only run in input and is defined data alpha in true
|
6 |
+
*
|
7 |
+
* Version: 3.0.0
|
8 |
+
* https://github.com/kallookoo/wp-color-picker-alpha
|
9 |
+
* Licensed under the GPLv2 license or later.
|
10 |
+
*/
|
11 |
+
|
12 |
+
( function( $, undef ) {
|
13 |
+
|
14 |
+
var wpColorPickerAlpha = {
|
15 |
+
'version' : 300
|
16 |
+
};
|
17 |
+
|
18 |
+
// Always try to use the last version of this script.
|
19 |
+
if ( 'wpColorPickerAlpha' in window && 'version' in window.wpColorPickerAlpha ) {
|
20 |
+
var version = parseInt( window.wpColorPickerAlpha.version, 10 );
|
21 |
+
if ( ! isNaN( version ) && version >= wpColorPickerAlpha.version ) {
|
22 |
+
return;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
// Prevent multiple initiations
|
27 |
+
if ( Color.fn.hasOwnProperty( 'to_s' ) ) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
// Create new method to replace the `Color.toString()` inside the scripts.
|
32 |
+
Color.fn.to_s = function( type ) {
|
33 |
+
type = ( type || 'hex' );
|
34 |
+
// Change hex to rgba to return the correct color.
|
35 |
+
if ( 'hex' === type && this._alpha < 1 ) {
|
36 |
+
type = 'rgba';
|
37 |
+
}
|
38 |
+
|
39 |
+
var color = '';
|
40 |
+
if ( 'hex' === type ) {
|
41 |
+
color = this.toString();
|
42 |
+
} else if ( ! this.error ) {
|
43 |
+
color = this.toCSS( type ).replace( /\(\s+/, '(' ).replace( /\s+\)/, ')' );
|
44 |
+
}
|
45 |
+
return color;
|
46 |
+
}
|
47 |
+
|
48 |
+
// Register the global variable.
|
49 |
+
window.wpColorPickerAlpha = wpColorPickerAlpha;
|
50 |
+
|
51 |
+
// Background image encoded
|
52 |
+
var backgroundImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Iris
|
56 |
+
*/
|
57 |
+
$.widget( 'a8c.iris', $.a8c.iris, {
|
58 |
+
/**
|
59 |
+
* Alpha options
|
60 |
+
*
|
61 |
+
* @since 3.0.0
|
62 |
+
*
|
63 |
+
* @type {Object}
|
64 |
+
*/
|
65 |
+
alphaOptions: {
|
66 |
+
alphaEnabled: false,
|
67 |
+
},
|
68 |
+
/**
|
69 |
+
* Get the current color or the new color.
|
70 |
+
*
|
71 |
+
* @since 3.0.0
|
72 |
+
* @access private
|
73 |
+
*
|
74 |
+
* @param {Object|*} The color instance if not defined return the cuurent color.
|
75 |
+
*
|
76 |
+
* @return {string} The element's color.
|
77 |
+
*/
|
78 |
+
_getColor: function( color ) {
|
79 |
+
if ( color === undef ) {
|
80 |
+
color = this._color;
|
81 |
+
}
|
82 |
+
|
83 |
+
if ( this.alphaOptions.alphaEnabled ) {
|
84 |
+
color = color.to_s( this.alphaOptions.alphaColorType );
|
85 |
+
if ( ! this.alphaOptions.alphaColorWithSpace ) {
|
86 |
+
color = color.replace( /\s+/g, '' );
|
87 |
+
}
|
88 |
+
return color;
|
89 |
+
}
|
90 |
+
return color.toString();
|
91 |
+
},
|
92 |
+
/**
|
93 |
+
* Create widget
|
94 |
+
*
|
95 |
+
* @since 3.0.0
|
96 |
+
* @access private
|
97 |
+
*
|
98 |
+
* @return {void}
|
99 |
+
*/
|
100 |
+
_create: function() {
|
101 |
+
try {
|
102 |
+
// Try to get the wpColorPicker alpha options.
|
103 |
+
this.alphaOptions = this.element.wpColorPicker( 'instance' ).alphaOptions;
|
104 |
+
} catch( e ) {}
|
105 |
+
|
106 |
+
// We make sure there are all options
|
107 |
+
$.extend( {}, this.alphaOptions, {
|
108 |
+
alphaEnabled: false,
|
109 |
+
alphaCustomWidth: 130,
|
110 |
+
alphaReset: false,
|
111 |
+
alphaColorType: 'hex',
|
112 |
+
alphaColorWithSpace: false,
|
113 |
+
} );
|
114 |
+
|
115 |
+
this._super();
|
116 |
+
},
|
117 |
+
/**
|
118 |
+
* Binds event listeners to the Iris.
|
119 |
+
*
|
120 |
+
* @since 3.0.0
|
121 |
+
* @access private
|
122 |
+
*
|
123 |
+
* @return {void}
|
124 |
+
*/
|
125 |
+
_addInputListeners: function( input ) {
|
126 |
+
var self = this,
|
127 |
+
debounceTimeout = 100,
|
128 |
+
callback = function( event ){
|
129 |
+
var val = input.val(),
|
130 |
+
color = new Color( val ),
|
131 |
+
val = val.replace( /^(#|(rgb|hsl)a?)/, '' ),
|
132 |
+
type = self.alphaOptions.alphaColorType;
|
133 |
+
|
134 |
+
input.removeClass( 'iris-error' );
|
135 |
+
|
136 |
+
if ( ! color.error ) {
|
137 |
+
// let's not do this on keyup for hex shortcodes
|
138 |
+
if ( 'hex' !== type || ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) ) {
|
139 |
+
// Compare color ( #AARRGGBB )
|
140 |
+
if ( color.toIEOctoHex() !== self._color.toIEOctoHex() ) {
|
141 |
+
self._setOption( 'color', self._getColor( color ) );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
} else if ( val !== '' ) {
|
145 |
+
input.addClass( 'iris-error' );
|
146 |
+
}
|
147 |
+
};
|
148 |
+
|
149 |
+
input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
|
150 |
+
|
151 |
+
// If we initialized hidden, show on first focus. The rest is up to you.
|
152 |
+
if ( self.options.hide ) {
|
153 |
+
input.one( 'focus', function() {
|
154 |
+
self.show();
|
155 |
+
});
|
156 |
+
}
|
157 |
+
},
|
158 |
+
/**
|
159 |
+
* Init Controls
|
160 |
+
*
|
161 |
+
* @since 3.0.0
|
162 |
+
* @access private
|
163 |
+
*
|
164 |
+
* @return {void}
|
165 |
+
*/
|
166 |
+
_initControls: function() {
|
167 |
+
this._super();
|
168 |
+
|
169 |
+
if ( this.alphaOptions.alphaEnabled ) {
|
170 |
+
// Create Alpha controls
|
171 |
+
var self = this,
|
172 |
+
stripAlpha = self.controls.strip.clone(false, false),
|
173 |
+
stripAlphaSlider = stripAlpha.find( '.iris-slider-offset' ),
|
174 |
+
controls = {
|
175 |
+
stripAlpha : stripAlpha,
|
176 |
+
stripAlphaSlider : stripAlphaSlider
|
177 |
+
};
|
178 |
+
|
179 |
+
stripAlpha.addClass( 'iris-strip-alpha' );
|
180 |
+
stripAlphaSlider.addClass( 'iris-slider-offset-alpha' );
|
181 |
+
stripAlpha.appendTo( self.picker.find( '.iris-picker-inner' ) );
|
182 |
+
|
183 |
+
// Push new controls
|
184 |
+
$.each( controls, function( k, v ) {
|
185 |
+
self.controls[k] = v;
|
186 |
+
} );
|
187 |
+
|
188 |
+
// Create slider
|
189 |
+
self.controls.stripAlphaSlider.slider( {
|
190 |
+
orientation : 'vertical',
|
191 |
+
min : 0,
|
192 |
+
max : 100,
|
193 |
+
step : 1,
|
194 |
+
value : parseInt( self._color._alpha * 100 ),
|
195 |
+
slide : function( event, ui ) {
|
196 |
+
self.active = 'strip';
|
197 |
+
// Update alpha value
|
198 |
+
self._color._alpha = parseFloat( ui.value / 100 );
|
199 |
+
self._change.apply( self, arguments );
|
200 |
+
}
|
201 |
+
} );
|
202 |
+
}
|
203 |
+
},
|
204 |
+
/**
|
205 |
+
* Create the controls sizes
|
206 |
+
*
|
207 |
+
* @since 3.0.0
|
208 |
+
* @access private
|
209 |
+
*
|
210 |
+
* @param {bool} reset Set to True for recreate the controls sizes.
|
211 |
+
*
|
212 |
+
* @return {void}
|
213 |
+
*/
|
214 |
+
_dimensions: function( reset ) {
|
215 |
+
this._super( reset );
|
216 |
+
|
217 |
+
if ( this.alphaOptions.alphaEnabled ) {
|
218 |
+
var self = this,
|
219 |
+
opts = self.options,
|
220 |
+
controls = self.controls,
|
221 |
+
square = controls.square,
|
222 |
+
strip = self.picker.find( '.iris-strip' ),
|
223 |
+
innerWidth, squareWidth, stripWidth, stripMargin, totalWidth;
|
224 |
+
|
225 |
+
/**
|
226 |
+
* I use Math.round() to avoid possible size errors,
|
227 |
+
* this function returns the value of a number rounded
|
228 |
+
* to the nearest integer.
|
229 |
+
*
|
230 |
+
* The width to append all widgets,
|
231 |
+
* if border is enabled, 22 is subtracted.
|
232 |
+
* 20 for css left and right property
|
233 |
+
* 2 for css border
|
234 |
+
*/
|
235 |
+
innerWidth = Math.round( self.picker.outerWidth( true ) - ( opts.border ? 22 : 0 ) );
|
236 |
+
// The width of the draggable, aka square.
|
237 |
+
squareWidth = Math.round( square.outerWidth() );
|
238 |
+
// The width for the sliders
|
239 |
+
stripWidth = Math.round( ( innerWidth - squareWidth ) / 2 );
|
240 |
+
// The margin for the sliders
|
241 |
+
stripMargin = Math.round( stripWidth / 2 );
|
242 |
+
// The total width of the elements.
|
243 |
+
totalWidth = Math.round( squareWidth + ( stripWidth * 2 ) + ( stripMargin * 2 ) );
|
244 |
+
|
245 |
+
// Check and change if necessary.
|
246 |
+
while ( totalWidth > innerWidth ) {
|
247 |
+
stripWidth = Math.round( stripWidth - 2 );
|
248 |
+
stripMargin = Math.round( stripMargin - 1 );
|
249 |
+
totalWidth = Math.round( squareWidth + ( stripWidth * 2 ) + ( stripMargin * 2 ) );
|
250 |
+
}
|
251 |
+
|
252 |
+
|
253 |
+
square.css( 'margin', '0' );
|
254 |
+
strip.width( stripWidth ).css( 'margin-left', stripMargin + 'px' );
|
255 |
+
}
|
256 |
+
},
|
257 |
+
/**
|
258 |
+
* Callback to update the controls and the current color.
|
259 |
+
*
|
260 |
+
* @since 3.0.0
|
261 |
+
* @access private
|
262 |
+
*
|
263 |
+
* @return {void}
|
264 |
+
*/
|
265 |
+
_change: function() {
|
266 |
+
var self = this,
|
267 |
+
active = self.active;
|
268 |
+
|
269 |
+
self._super();
|
270 |
+
|
271 |
+
if ( self.alphaOptions.alphaEnabled ) {
|
272 |
+
var controls = self.controls,
|
273 |
+
alpha = parseInt( self._color._alpha * 100 ),
|
274 |
+
color = self._color.toRgb(),
|
275 |
+
gradient = [
|
276 |
+
'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
|
277 |
+
'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
|
278 |
+
],
|
279 |
+
target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
|
280 |
+
|
281 |
+
self.options.color = self._getColor();
|
282 |
+
// Generate background slider alpha, only for CSS3.
|
283 |
+
controls.stripAlpha.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + backgroundImage + ')' } );
|
284 |
+
// Update alpha value
|
285 |
+
if ( active ) {
|
286 |
+
controls.stripAlphaSlider.slider( 'value', alpha );
|
287 |
+
}
|
288 |
+
|
289 |
+
if ( ! self._color.error ) {
|
290 |
+
self.element.removeClass( 'iris-error' ).val( self.options.color );
|
291 |
+
}
|
292 |
+
|
293 |
+
self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
|
294 |
+
var color = $( this ).data( 'color' );
|
295 |
+
if ( self.alphaOptions.alphaReset ) {
|
296 |
+
self._color._alpha = 1;
|
297 |
+
color = self._getColor();
|
298 |
+
}
|
299 |
+
self._setOption( 'color', color );
|
300 |
+
} );
|
301 |
+
}
|
302 |
+
},
|
303 |
+
/**
|
304 |
+
* Paint dimensions.
|
305 |
+
*
|
306 |
+
* @since 3.0.0
|
307 |
+
* @access private
|
308 |
+
*
|
309 |
+
* @param {string} origin Origin (position).
|
310 |
+
* @param {string} control Type of the control,
|
311 |
+
*
|
312 |
+
* @return {void}
|
313 |
+
*/
|
314 |
+
_paintDimension: function( origin, control ) {
|
315 |
+
var self = this,
|
316 |
+
color = false;
|
317 |
+
|
318 |
+
// Fix for slider hue opacity.
|
319 |
+
if ( self.alphaOptions.alphaEnabled && 'strip' === control ) {
|
320 |
+
color = self._color;
|
321 |
+
self._color = new Color( color.toString() );
|
322 |
+
self.hue = self._color.h();
|
323 |
+
}
|
324 |
+
|
325 |
+
self._super( origin, control );
|
326 |
+
|
327 |
+
// Restore the color after paint.
|
328 |
+
if ( color ) {
|
329 |
+
self._color = color;
|
330 |
+
}
|
331 |
+
},
|
332 |
+
/**
|
333 |
+
* To update the options, see original source to view the available options.
|
334 |
+
*
|
335 |
+
* @since 3.0.0
|
336 |
+
*
|
337 |
+
* @param {string} key The Option name.
|
338 |
+
* @param {mixed} value The Option value to update.
|
339 |
+
*
|
340 |
+
* @return {void}
|
341 |
+
*/
|
342 |
+
_setOption: function( key, value ) {
|
343 |
+
var self = this;
|
344 |
+
if ( 'color' === key && self.alphaOptions.alphaEnabled ) {
|
345 |
+
// cast to string in case we have a number
|
346 |
+
value = '' + value;
|
347 |
+
newColor = new Color( value ).setHSpace( self.options.mode );
|
348 |
+
// Check if error && Check the color to prevent callbacks with the same color.
|
349 |
+
if ( ! newColor.error && self._getColor( newColor ) !== self._getColor() ) {
|
350 |
+
self._color = newColor;
|
351 |
+
self.options.color = self._getColor();
|
352 |
+
self.active = 'external';
|
353 |
+
self._change();
|
354 |
+
}
|
355 |
+
} else {
|
356 |
+
return self._super( key, value );
|
357 |
+
}
|
358 |
+
},
|
359 |
+
/**
|
360 |
+
* Returns the iris object if no new color is provided. If a new color is provided, it sets the new color.
|
361 |
+
*
|
362 |
+
* @param newColor {string|*} The new color to use. Can be undefined.
|
363 |
+
*
|
364 |
+
* @since 3.0.0
|
365 |
+
*
|
366 |
+
* @return {string} The element's color.
|
367 |
+
*/
|
368 |
+
color: function( newColor ) {
|
369 |
+
if ( newColor === true ) {
|
370 |
+
return this._color.clone();
|
371 |
+
}
|
372 |
+
if ( newColor === undef ) {
|
373 |
+
return this._getColor();
|
374 |
+
}
|
375 |
+
this.option( 'color', newColor );
|
376 |
+
},
|
377 |
+
} );
|
378 |
+
|
379 |
+
/**
|
380 |
+
* wpColorPicker
|
381 |
+
*/
|
382 |
+
$.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
|
383 |
+
/**
|
384 |
+
* Alpha options
|
385 |
+
*
|
386 |
+
* @since 3.0.0
|
387 |
+
*
|
388 |
+
* @type {Object}
|
389 |
+
*/
|
390 |
+
alphaOptions: {
|
391 |
+
alphaEnabled: false,
|
392 |
+
},
|
393 |
+
/**
|
394 |
+
* Get the alpha options.
|
395 |
+
*
|
396 |
+
* @since 3.0.0
|
397 |
+
* @access private
|
398 |
+
*
|
399 |
+
* @return {object} The current alpha options.
|
400 |
+
*/
|
401 |
+
_getAlphaOptions: function() {
|
402 |
+
var el = this.element,
|
403 |
+
type = ( el.data( 'type' ) || this.options.type ),
|
404 |
+
color = ( el.data( 'defaultColor' ) || el.val() ),
|
405 |
+
options = {
|
406 |
+
alphaEnabled: ( el.data( 'alphaEnabled' ) || false ),
|
407 |
+
alphaCustomWidth: 130,
|
408 |
+
alphaReset: false,
|
409 |
+
alphaColorType: 'rgb',
|
410 |
+
alphaColorWithSpace: false,
|
411 |
+
};
|
412 |
+
|
413 |
+
if ( options.alphaEnabled ) {
|
414 |
+
options.alphaEnabled = ( el.is( 'input' ) && 'full' === type );
|
415 |
+
}
|
416 |
+
|
417 |
+
if ( ! options.alphaEnabled ) {
|
418 |
+
return options;
|
419 |
+
}
|
420 |
+
|
421 |
+
options.alphaColorWithSpace = ( color && color.match( /\s/ ) );
|
422 |
+
|
423 |
+
$.each( options, function( name, defaultValue ) {
|
424 |
+
var value = ( el.data( name ) || defaultValue );
|
425 |
+
switch ( name ) {
|
426 |
+
case 'alphaCustomWidth':
|
427 |
+
value = ( value ? parseInt( value, 10 ) : 0 );
|
428 |
+
value = ( isNaN( value ) ? defaultValue : value );
|
429 |
+
break;
|
430 |
+
case 'alphaColorType':
|
431 |
+
if ( ! value.match( /^(hex|(rgb|hsl)a?)$/ ) ) {
|
432 |
+
if ( color && color.match( /^#/ ) ) {
|
433 |
+
value = 'hex';
|
434 |
+
} else if ( color && color.match( /^hsla?/ ) ) {
|
435 |
+
value = 'hsl';
|
436 |
+
} else {
|
437 |
+
value = defaultValue;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
break;
|
441 |
+
default:
|
442 |
+
value = !!value;
|
443 |
+
break;
|
444 |
+
}
|
445 |
+
options[name] = value;
|
446 |
+
} );
|
447 |
+
|
448 |
+
return options;
|
449 |
+
},
|
450 |
+
/**
|
451 |
+
* Create widget
|
452 |
+
*
|
453 |
+
* @since 3.0.0
|
454 |
+
* @access private
|
455 |
+
*
|
456 |
+
* @return {void}
|
457 |
+
*/
|
458 |
+
_create: function() {
|
459 |
+
// Return early if Iris support is missing.
|
460 |
+
if ( ! $.support.iris ) {
|
461 |
+
return;
|
462 |
+
}
|
463 |
+
|
464 |
+
// Set the alpha options for the current instance.
|
465 |
+
this.alphaOptions = this._getAlphaOptions();
|
466 |
+
|
467 |
+
// Create widget.
|
468 |
+
this._super();
|
469 |
+
},
|
470 |
+
/**
|
471 |
+
* Binds event listeners to the color picker and create options, etc...
|
472 |
+
*
|
473 |
+
* @since 3.0.0
|
474 |
+
* @access private
|
475 |
+
*
|
476 |
+
* @return {void}
|
477 |
+
*/
|
478 |
+
_addListeners: function() {
|
479 |
+
if ( ! this.alphaOptions.alphaEnabled ) {
|
480 |
+
return this._super();
|
481 |
+
}
|
482 |
+
|
483 |
+
var self = this,
|
484 |
+
el = self.element,
|
485 |
+
isDeprecated = self.toggler.is( 'a' );
|
486 |
+
|
487 |
+
this.alphaOptions.defaultWidth = el.width();
|
488 |
+
if ( this.alphaOptions.alphaCustomWidth ) {
|
489 |
+
el.width( parseInt( this.alphaOptions.defaultWidth + this.alphaOptions.alphaCustomWidth, 10 ) );
|
490 |
+
}
|
491 |
+
|
492 |
+
self.toggler.css( {
|
493 |
+
'position': 'relative',
|
494 |
+
'background-image' : 'url(' + backgroundImage + ')'
|
495 |
+
} );
|
496 |
+
|
497 |
+
if ( isDeprecated ) {
|
498 |
+
self.toggler.html( '<span class="color-alpha" />' );
|
499 |
+
} else {
|
500 |
+
self.toggler.append( '<span class="color-alpha" />' );
|
501 |
+
}
|
502 |
+
|
503 |
+
self.colorAlpha = self.toggler.find( 'span.color-alpha' ).css( {
|
504 |
+
'width' : '30px',
|
505 |
+
'height' : '100%',
|
506 |
+
'position' : 'absolute',
|
507 |
+
'top' : 0,
|
508 |
+
'background-color' : el.val(),
|
509 |
+
} );
|
510 |
+
|
511 |
+
// Define the correct position for ltr or rtl direction.
|
512 |
+
if ( 'ltr' === self.colorAlpha.css( 'direction' ) ) {
|
513 |
+
self.colorAlpha.css( {
|
514 |
+
'border-bottom-left-radius' : '2px',
|
515 |
+
'border-top-left-radius' : '2px',
|
516 |
+
'left' : 0
|
517 |
+
} );
|
518 |
+
} else {
|
519 |
+
self.colorAlpha.css( {
|
520 |
+
'border-bottom-right-radius' : '2px',
|
521 |
+
'border-top-right-radius' : '2px',
|
522 |
+
'right' : 0
|
523 |
+
} );
|
524 |
+
}
|
525 |
+
|
526 |
+
|
527 |
+
el.iris( {
|
528 |
+
/**
|
529 |
+
* @summary Handles the onChange event if one has been defined in the options.
|
530 |
+
*
|
531 |
+
* Handles the onChange event if one has been defined in the options and additionally
|
532 |
+
* sets the background color for the toggler element.
|
533 |
+
*
|
534 |
+
* @since 3.0.0
|
535 |
+
*
|
536 |
+
* @param {Event} event The event that's being called.
|
537 |
+
* @param {HTMLElement} ui The HTMLElement containing the color picker.
|
538 |
+
*
|
539 |
+
* @returns {void}
|
540 |
+
*/
|
541 |
+
change: function( event, ui ) {
|
542 |
+
self.colorAlpha.css( { 'background-color': ui.color.to_s( self.alphaOptions.alphaColorType ) } );
|
543 |
+
|
544 |
+
// fire change callback if we have one
|
545 |
+
if ( $.isFunction( self.options.change ) ) {
|
546 |
+
self.options.change.call( this, event, ui );
|
547 |
+
}
|
548 |
+
}
|
549 |
+
} );
|
550 |
+
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Prevent any clicks inside this widget from leaking to the top and closing it.
|
554 |
+
*
|
555 |
+
* @since 3.0.0
|
556 |
+
*
|
557 |
+
* @param {Event} event The event that's being called.
|
558 |
+
*
|
559 |
+
* @return {void}
|
560 |
+
*/
|
561 |
+
self.wrap.on( 'click.wpcolorpicker', function( event ) {
|
562 |
+
event.stopPropagation();
|
563 |
+
});
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Open or close the color picker depending on the class.
|
567 |
+
*
|
568 |
+
* @since 3.0.0
|
569 |
+
*/
|
570 |
+
self.toggler.click( function() {
|
571 |
+
if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
|
572 |
+
self.close();
|
573 |
+
} else {
|
574 |
+
self.open();
|
575 |
+
}
|
576 |
+
});
|
577 |
+
|
578 |
+
/**
|
579 |
+
* Checks if value is empty when changing the color in the color picker.
|
580 |
+
* If so, the background color is cleared.
|
581 |
+
*
|
582 |
+
* @since 3.0.0
|
583 |
+
*
|
584 |
+
* @param {Event} event The event that's being called.
|
585 |
+
*
|
586 |
+
* @return {void}
|
587 |
+
*/
|
588 |
+
el.change( function( event ) {
|
589 |
+
var val = $( this ).val();
|
590 |
+
|
591 |
+
if ( el.hasClass( 'iris-error' ) || val === '' || val.match( /^(#|(rgb|hsl)a?)$/ ) ) {
|
592 |
+
if ( isDeprecated ) {
|
593 |
+
self.toggler.removeAttr( 'style' );
|
594 |
+
}
|
595 |
+
|
596 |
+
self.colorAlpha.css( 'background-color', '' );
|
597 |
+
|
598 |
+
// fire clear callback if we have one
|
599 |
+
if ( $.isFunction( self.options.clear ) ) {
|
600 |
+
self.options.clear.call( this, event );
|
601 |
+
}
|
602 |
+
}
|
603 |
+
} );
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Enables the user to either clear the color in the color picker or revert back to the default color.
|
607 |
+
*
|
608 |
+
* @since 3.0.0
|
609 |
+
*
|
610 |
+
* @param {Event} event The event that's being called.
|
611 |
+
*
|
612 |
+
* @return {void}
|
613 |
+
*/
|
614 |
+
self.button.click( function( event ) {
|
615 |
+
if ( $( this ).hasClass( 'wp-picker-default' ) ) {
|
616 |
+
el.val( self.options.defaultColor ).change();
|
617 |
+
} else if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
|
618 |
+
el.val( '' );
|
619 |
+
if ( isDeprecated ) {
|
620 |
+
self.toggler.removeAttr( 'style' );
|
621 |
+
}
|
622 |
+
|
623 |
+
self.colorAlpha.css( 'background-color', '' );
|
624 |
+
|
625 |
+
// fire clear callback if we have one
|
626 |
+
if ( $.isFunction( self.options.clear ) ) {
|
627 |
+
self.options.clear.call( this, event );
|
628 |
+
}
|
629 |
+
|
630 |
+
el.trigger( 'change' );
|
631 |
+
}
|
632 |
+
} );
|
633 |
+
},
|
634 |
+
} );
|
635 |
+
} ( jQuery ) );
|
assets/inc/color-picker-alpha/wp-color-picker-alpha.min.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**!
|
2 |
+
* wp-color-picker-alpha
|
3 |
+
*
|
4 |
+
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
|
5 |
+
* Only run in input and is defined data alpha in true
|
6 |
+
*
|
7 |
+
* Version: 3.0.0
|
8 |
+
* https://github.com/kallookoo/wp-color-picker-alpha
|
9 |
+
* Licensed under the GPLv2 license or later.
|
10 |
+
*/
|
11 |
+
!function(e,a){var l,o={version:300};if("wpColorPickerAlpha"in window&&"version"in window.wpColorPickerAlpha){var t=parseInt(window.wpColorPickerAlpha.version,10);if(!isNaN(t)&&o.version<=t)return}Color.fn.hasOwnProperty("to_s")||(Color.fn.to_s=function(o){"hex"===(o=o||"hex")&&this._alpha<1&&(o="rgba");var a="";return"hex"===o?a=this.toString():this.error||(a=this.toCSS(o).replace(/\(\s+/,"(").replace(/\s+\)/,")")),a},window.wpColorPickerAlpha=o,l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==",e.widget("a8c.iris",e.a8c.iris,{alphaOptions:{alphaEnabled:!1},_getColor:function(o){return o===a&&(o=this._color),this.alphaOptions.alphaEnabled?(o=o.to_s(this.alphaOptions.alphaColorType),this.alphaOptions.alphaColorWithSpace||(o=o.replace(/\s+/g,"")),o):o.toString()},_create:function(){try{this.alphaOptions=this.element.wpColorPicker("instance").alphaOptions}catch(o){}e.extend({},this.alphaOptions,{alphaEnabled:!1,alphaCustomWidth:130,alphaReset:!1,alphaColorType:"hex",alphaColorWithSpace:!1}),this._super()},_addInputListeners:function(i){function o(o){var a=i.val(),t=new Color(a),a=a.replace(/^(#|(rgb|hsl)a?)/,""),r=l.alphaOptions.alphaColorType;i.removeClass("iris-error"),t.error?""!==a&&i.addClass("iris-error"):"hex"===r&&"keyup"===o.type&&a.match(/^[0-9a-fA-F]{3}$/)||t.toIEOctoHex()!==l._color.toIEOctoHex()&&l._setOption("color",l._getColor(t))}var l=this;i.on("change",o).on("keyup",l._debounce(o,100)),l.options.hide&&i.one("focus",function(){l.show()})},_initControls:function(){var t,o,a,r;this._super(),this.alphaOptions.alphaEnabled&&(a=(o=(t=this).controls.strip.clone(!1,!1)).find(".iris-slider-offset"),r={stripAlpha:o,stripAlphaSlider:a},o.addClass("iris-strip-alpha"),a.addClass("iris-slider-offset-alpha"),o.appendTo(t.picker.find(".iris-picker-inner")),e.each(r,function(o,a){t.controls[o]=a}),t.controls.stripAlphaSlider.slider({orientation:"vertical",min:0,max:100,step:1,value:parseInt(100*t._color._alpha),slide:function(o,a){t.active="strip",t._color._alpha=parseFloat(a.value/100),t._change.apply(t,arguments)}}))},_dimensions:function(o){if(this._super(o),this.alphaOptions.alphaEnabled){for(var a=this,t=a.options,r=a.controls.square,o=a.picker.find(".iris-strip"),i=Math.round(a.picker.outerWidth(!0)-(t.border?22:0)),l=Math.round(r.outerWidth()),e=Math.round((i-l)/2),s=Math.round(e/2),n=Math.round(l+2*e+2*s);i<n;)e=Math.round(e-2),s=Math.round(s-1),n=Math.round(l+2*e+2*s);r.css("margin","0"),o.width(e).css("margin-left",s+"px")}},_change:function(){var o,a,t,r=this,i=r.active;r._super(),r.alphaOptions.alphaEnabled&&(o=r.controls,a=parseInt(100*r._color._alpha),t=["rgb("+(t=r._color.toRgb()).r+","+t.g+","+t.b+") 0%","rgba("+t.r+","+t.g+","+t.b+", 0) 100%"],r.picker.closest(".wp-picker-container").find(".wp-color-result"),r.options.color=r._getColor(),o.stripAlpha.css({background:"linear-gradient(to bottom, "+t.join(", ")+"), url("+l+")"}),i&&o.stripAlphaSlider.slider("value",a),r._color.error||r.element.removeClass("iris-error").val(r.options.color),r.picker.find(".iris-palette-container").on("click.palette",".iris-palette",function(){var o=e(this).data("color");r.alphaOptions.alphaReset&&(r._color._alpha=1,o=r._getColor()),r._setOption("color",o)}))},_paintDimension:function(o,a){var t=this,r=!1;t.alphaOptions.alphaEnabled&&"strip"===a&&(r=t._color,t._color=new Color(r.toString()),t.hue=t._color.h()),t._super(o,a),r&&(t._color=r)},_setOption:function(o,a){var t=this;if("color"!==o||!t.alphaOptions.alphaEnabled)return t._super(o,a);a=""+a,newColor=new Color(a).setHSpace(t.options.mode),newColor.error||t._getColor(newColor)===t._getColor()||(t._color=newColor,t.options.color=t._getColor(),t.active="external",t._change())},color:function(o){return!0===o?this._color.clone():o===a?this._getColor():void this.option("color",o)}}),e.widget("wp.wpColorPicker",e.wp.wpColorPicker,{alphaOptions:{alphaEnabled:!1},_getAlphaOptions:function(){var r=this.element,o=r.data("type")||this.options.type,i=r.data("defaultColor")||r.val(),l={alphaEnabled:r.data("alphaEnabled")||!1,alphaCustomWidth:130,alphaReset:!1,alphaColorType:"rgb",alphaColorWithSpace:!1};return l.alphaEnabled&&(l.alphaEnabled=r.is("input")&&"full"===o),l.alphaEnabled&&(l.alphaColorWithSpace=i&&i.match(/\s/),e.each(l,function(o,a){var t=r.data(o)||a;switch(o){case"alphaCustomWidth":t=t?parseInt(t,10):0,t=isNaN(t)?a:t;break;case"alphaColorType":t.match(/^(hex|(rgb|hsl)a?)$/)||(t=i&&i.match(/^#/)?"hex":i&&i.match(/^hsla?/)?"hsl":a);break;default:t=!!t}l[o]=t})),l},_create:function(){e.support.iris&&(this.alphaOptions=this._getAlphaOptions(),this._super())},_addListeners:function(){if(!this.alphaOptions.alphaEnabled)return this._super();var t=this,r=t.element,i=t.toggler.is("a");this.alphaOptions.defaultWidth=r.width(),this.alphaOptions.alphaCustomWidth&&r.width(parseInt(this.alphaOptions.defaultWidth+this.alphaOptions.alphaCustomWidth,10)),t.toggler.css({position:"relative","background-image":"url("+l+")"}),i?t.toggler.html('<span class="color-alpha" />'):t.toggler.append('<span class="color-alpha" />'),t.colorAlpha=t.toggler.find("span.color-alpha").css({width:"30px",height:"100%",position:"absolute",top:0,"background-color":r.val()}),"ltr"===t.colorAlpha.css("direction")?t.colorAlpha.css({"border-bottom-left-radius":"2px","border-top-left-radius":"2px",left:0}):t.colorAlpha.css({"border-bottom-right-radius":"2px","border-top-right-radius":"2px",right:0}),r.iris({change:function(o,a){t.colorAlpha.css({"background-color":a.color.to_s(t.alphaOptions.alphaColorType)}),e.isFunction(t.options.change)&&t.options.change.call(this,o,a)}}),t.wrap.on("click.wpcolorpicker",function(o){o.stopPropagation()}),t.toggler.click(function(){t.toggler.hasClass("wp-picker-open")?t.close():t.open()}),r.change(function(o){var a=e(this).val();(r.hasClass("iris-error")||""===a||a.match(/^(#|(rgb|hsl)a?)$/))&&(i&&t.toggler.removeAttr("style"),t.colorAlpha.css("background-color",""),e.isFunction(t.options.clear)&&t.options.clear.call(this,o))}),t.button.click(function(o){e(this).hasClass("wp-picker-default")?r.val(t.options.defaultColor).change():e(this).hasClass("wp-picker-clear")&&(r.val(""),i&&t.toggler.removeAttr("style"),t.colorAlpha.css("background-color",""),e.isFunction(t.options.clear)&&t.options.clear.call(this,o),r.trigger("change"))})}}))}(jQuery);
|
assets/inc/select2/4/select2.css
CHANGED
@@ -118,12 +118,14 @@
|
|
118 |
.select2-hidden-accessible {
|
119 |
border: 0 !important;
|
120 |
clip: rect(0 0 0 0) !important;
|
|
|
|
|
121 |
height: 1px !important;
|
122 |
-
margin: -1px !important;
|
123 |
overflow: hidden !important;
|
124 |
padding: 0 !important;
|
125 |
position: absolute !important;
|
126 |
-
width: 1px !important;
|
|
|
127 |
|
128 |
.select2-container--default .select2-selection--single {
|
129 |
background-color: #fff;
|
@@ -186,16 +188,13 @@
|
|
186 |
width: 100%; }
|
187 |
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
188 |
list-style: none; }
|
189 |
-
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
|
190 |
-
color: #999;
|
191 |
-
margin-top: 5px;
|
192 |
-
float: left; }
|
193 |
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
194 |
cursor: pointer;
|
195 |
float: right;
|
196 |
font-weight: bold;
|
197 |
margin-top: 5px;
|
198 |
-
margin-right: 10px;
|
|
|
199 |
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
200 |
background-color: #e4e4e4;
|
201 |
border: 1px solid #aaa;
|
@@ -214,7 +213,7 @@
|
|
214 |
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
|
215 |
color: #333; }
|
216 |
|
217 |
-
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-
|
218 |
float: right; }
|
219 |
|
220 |
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
@@ -420,9 +419,7 @@
|
|
420 |
color: #555; }
|
421 |
|
422 |
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
423 |
-
float: right;
|
424 |
-
|
425 |
-
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
426 |
margin-left: 5px;
|
427 |
margin-right: auto; }
|
428 |
|
118 |
.select2-hidden-accessible {
|
119 |
border: 0 !important;
|
120 |
clip: rect(0 0 0 0) !important;
|
121 |
+
-webkit-clip-path: inset(50%) !important;
|
122 |
+
clip-path: inset(50%) !important;
|
123 |
height: 1px !important;
|
|
|
124 |
overflow: hidden !important;
|
125 |
padding: 0 !important;
|
126 |
position: absolute !important;
|
127 |
+
width: 1px !important;
|
128 |
+
white-space: nowrap !important; }
|
129 |
|
130 |
.select2-container--default .select2-selection--single {
|
131 |
background-color: #fff;
|
188 |
width: 100%; }
|
189 |
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
190 |
list-style: none; }
|
|
|
|
|
|
|
|
|
191 |
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
192 |
cursor: pointer;
|
193 |
float: right;
|
194 |
font-weight: bold;
|
195 |
margin-top: 5px;
|
196 |
+
margin-right: 10px;
|
197 |
+
padding: 1px; }
|
198 |
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
199 |
background-color: #e4e4e4;
|
200 |
border: 1px solid #aaa;
|
213 |
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
|
214 |
color: #333; }
|
215 |
|
216 |
+
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
|
217 |
float: right; }
|
218 |
|
219 |
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
419 |
color: #555; }
|
420 |
|
421 |
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
422 |
+
float: right;
|
|
|
|
|
423 |
margin-left: 5px;
|
424 |
margin-right: auto; }
|
425 |
|
assets/inc/select2/4/select2.full.js
CHANGED
@@ -1,27 +1,41 @@
|
|
1 |
/*!
|
2 |
-
* Select2 4.0.
|
3 |
* https://select2.github.io
|
4 |
-
*
|
5 |
* Released under the MIT license
|
6 |
* https://github.com/select2/select2/blob/master/LICENSE.md
|
7 |
*/
|
8 |
-
(function (factory) {
|
9 |
if (typeof define === 'function' && define.amd) {
|
10 |
// AMD. Register as an anonymous module.
|
11 |
define(['jquery'], factory);
|
12 |
-
} else if (typeof
|
13 |
// Node/CommonJS
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
} else {
|
16 |
// Browser globals
|
17 |
factory(jQuery);
|
18 |
}
|
19 |
-
}(function (jQuery) {
|
20 |
// This is needed so we can catch the AMD loader configuration and use it
|
21 |
// The inner file should be wrapped (by `banner.start.js`) in a function that
|
22 |
// returns the AMD loader references.
|
23 |
-
var S2 =
|
24 |
-
(function () {
|
25 |
// Restore the Select2 AMD loader so it can be used
|
26 |
// Needed mostly in the language files, where the loader is not inserted
|
27 |
if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
|
@@ -30,13 +44,11 @@
|
|
30 |
var S2;(function () { if (!S2 || !S2.requirejs) {
|
31 |
if (!S2) { S2 = {}; } else { require = S2; }
|
32 |
/**
|
33 |
-
* @license almond 0.3.
|
34 |
-
*
|
35 |
-
* see: http://github.com/jrburke/almond for details
|
36 |
*/
|
37 |
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
38 |
//be followed.
|
39 |
-
/*jslint sloppy: true */
|
40 |
/*global setTimeout: false */
|
41 |
|
42 |
var requirejs, require, define;
|
@@ -64,60 +76,58 @@ var requirejs, require, define;
|
|
64 |
*/
|
65 |
function normalize(name, baseName) {
|
66 |
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
67 |
-
foundI, foundStarMap, starI, i, j, part,
|
68 |
baseParts = baseName && baseName.split("/"),
|
69 |
map = config.map,
|
70 |
starMap = (map && map['*']) || {};
|
71 |
|
72 |
//Adjust any relative paths.
|
73 |
-
if (name
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
}
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
//baseName
|
89 |
-
//
|
90 |
-
|
91 |
-
|
92 |
-
//
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
111 |
}
|
112 |
}
|
113 |
-
//end trimDots
|
114 |
-
|
115 |
-
name = name.join("/");
|
116 |
-
} else if (name.indexOf('./') === 0) {
|
117 |
-
// No baseName, so this is ID is resolved relative
|
118 |
-
// to baseUrl, pull off the leading dot.
|
119 |
-
name = name.substring(2);
|
120 |
}
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
//Apply map config if available.
|
@@ -230,32 +240,39 @@ var requirejs, require, define;
|
|
230 |
return [prefix, name];
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
/**
|
234 |
* Makes a name map, normalizing the name, and using a plugin
|
235 |
* for normalization if necessary. Grabs a ref to plugin
|
236 |
* too, as an optimization.
|
237 |
*/
|
238 |
-
makeMap = function (name,
|
239 |
var plugin,
|
240 |
parts = splitPrefix(name),
|
241 |
-
prefix = parts[0]
|
|
|
242 |
|
243 |
name = parts[1];
|
244 |
|
245 |
if (prefix) {
|
246 |
-
prefix = normalize(prefix,
|
247 |
plugin = callDep(prefix);
|
248 |
}
|
249 |
|
250 |
//Normalize according
|
251 |
if (prefix) {
|
252 |
if (plugin && plugin.normalize) {
|
253 |
-
name = plugin.normalize(name, makeNormalize(
|
254 |
} else {
|
255 |
-
name = normalize(name,
|
256 |
}
|
257 |
} else {
|
258 |
-
name = normalize(name,
|
259 |
parts = splitPrefix(name);
|
260 |
prefix = parts[0];
|
261 |
name = parts[1];
|
@@ -302,13 +319,14 @@ var requirejs, require, define;
|
|
302 |
};
|
303 |
|
304 |
main = function (name, deps, callback, relName) {
|
305 |
-
var cjsModule, depName, ret, map, i,
|
306 |
args = [],
|
307 |
callbackType = typeof callback,
|
308 |
usingExports;
|
309 |
|
310 |
//Use name if no relName
|
311 |
relName = relName || name;
|
|
|
312 |
|
313 |
//Call the callback to define the module, if necessary.
|
314 |
if (callbackType === 'undefined' || callbackType === 'function') {
|
@@ -317,7 +335,7 @@ var requirejs, require, define;
|
|
317 |
//Default to [require, exports, module] if no deps
|
318 |
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
319 |
for (i = 0; i < deps.length; i += 1) {
|
320 |
-
map = makeMap(deps[i],
|
321 |
depName = map.f;
|
322 |
|
323 |
//Fast path CommonJS standard dependencies.
|
@@ -373,7 +391,7 @@ var requirejs, require, define;
|
|
373 |
//deps arg is the module name, and second arg (if passed)
|
374 |
//is just the relName.
|
375 |
//Normalize module name, if it contains . or ..
|
376 |
-
return callDep(makeMap(deps, callback).f);
|
377 |
} else if (!deps.splice) {
|
378 |
//deps is a config object, not an array.
|
379 |
config = deps;
|
@@ -556,10 +574,10 @@ S2.define('select2/utils',[
|
|
556 |
DecoratedClass.prototype = new ctr();
|
557 |
|
558 |
for (var m = 0; m < superMethods.length; m++) {
|
559 |
-
|
560 |
|
561 |
-
|
562 |
-
|
563 |
}
|
564 |
|
565 |
var calledMethod = function (methodName) {
|
@@ -754,6 +772,70 @@ S2.define('select2/utils',[
|
|
754 |
$element.append($nodes);
|
755 |
};
|
756 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
757 |
return Utils;
|
758 |
});
|
759 |
|
@@ -773,7 +855,7 @@ S2.define('select2/results',[
|
|
773 |
|
774 |
Results.prototype.render = function () {
|
775 |
var $results = $(
|
776 |
-
'<ul class="select2-results__options" role="
|
777 |
);
|
778 |
|
779 |
if (this.options.get('multiple')) {
|
@@ -796,7 +878,7 @@ S2.define('select2/results',[
|
|
796 |
this.hideLoading();
|
797 |
|
798 |
var $message = $(
|
799 |
-
'<li role="
|
800 |
' class="select2-results__option"></li>'
|
801 |
);
|
802 |
|
@@ -889,7 +971,7 @@ S2.define('select2/results',[
|
|
889 |
$options.each(function () {
|
890 |
var $option = $(this);
|
891 |
|
892 |
-
var item =
|
893 |
|
894 |
// id needs to be converted to a string when comparing
|
895 |
var id = '' + item.id;
|
@@ -930,11 +1012,16 @@ S2.define('select2/results',[
|
|
930 |
option.className = 'select2-results__option';
|
931 |
|
932 |
var attrs = {
|
933 |
-
'role': '
|
934 |
'aria-selected': 'false'
|
935 |
};
|
936 |
|
937 |
-
|
|
|
|
|
|
|
|
|
|
|
938 |
delete attrs['aria-selected'];
|
939 |
attrs['aria-disabled'] = 'true';
|
940 |
}
|
@@ -994,7 +1081,7 @@ S2.define('select2/results',[
|
|
994 |
this.template(data, option);
|
995 |
}
|
996 |
|
997 |
-
|
998 |
|
999 |
return option;
|
1000 |
};
|
@@ -1035,7 +1122,10 @@ S2.define('select2/results',[
|
|
1035 |
}
|
1036 |
|
1037 |
self.setClasses();
|
1038 |
-
|
|
|
|
|
|
|
1039 |
});
|
1040 |
|
1041 |
container.on('unselect', function () {
|
@@ -1044,7 +1134,10 @@ S2.define('select2/results',[
|
|
1044 |
}
|
1045 |
|
1046 |
self.setClasses();
|
1047 |
-
|
|
|
|
|
|
|
1048 |
});
|
1049 |
|
1050 |
container.on('open', function () {
|
@@ -1080,7 +1173,7 @@ S2.define('select2/results',[
|
|
1080 |
return;
|
1081 |
}
|
1082 |
|
1083 |
-
var data = $highlighted
|
1084 |
|
1085 |
if ($highlighted.attr('aria-selected') == 'true') {
|
1086 |
self.trigger('close', {});
|
@@ -1098,8 +1191,9 @@ S2.define('select2/results',[
|
|
1098 |
|
1099 |
var currentIndex = $options.index($highlighted);
|
1100 |
|
1101 |
-
// If we are already at
|
1102 |
-
|
|
|
1103 |
return;
|
1104 |
}
|
1105 |
|
@@ -1192,7 +1286,7 @@ S2.define('select2/results',[
|
|
1192 |
function (evt) {
|
1193 |
var $this = $(this);
|
1194 |
|
1195 |
-
var data =
|
1196 |
|
1197 |
if ($this.attr('aria-selected') === 'true') {
|
1198 |
if (self.options.get('multiple')) {
|
@@ -1215,7 +1309,7 @@ S2.define('select2/results',[
|
|
1215 |
|
1216 |
this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
|
1217 |
function (evt) {
|
1218 |
-
var data =
|
1219 |
|
1220 |
self.getHighlightedResults()
|
1221 |
.removeClass('select2-results__option--highlighted');
|
@@ -1330,14 +1424,15 @@ S2.define('select2/selection/base',[
|
|
1330 |
|
1331 |
this._tabindex = 0;
|
1332 |
|
1333 |
-
if (this.$element
|
1334 |
-
this._tabindex = this.$element
|
1335 |
} else if (this.$element.attr('tabindex') != null) {
|
1336 |
this._tabindex = this.$element.attr('tabindex');
|
1337 |
}
|
1338 |
|
1339 |
$selection.attr('title', this.$element.attr('title'));
|
1340 |
$selection.attr('tabindex', this._tabindex);
|
|
|
1341 |
|
1342 |
this.$selection = $selection;
|
1343 |
|
@@ -1347,7 +1442,6 @@ S2.define('select2/selection/base',[
|
|
1347 |
BaseSelection.prototype.bind = function (container, $container) {
|
1348 |
var self = this;
|
1349 |
|
1350 |
-
var id = container.id + '-container';
|
1351 |
var resultsId = container.id + '-results';
|
1352 |
|
1353 |
this.container = container;
|
@@ -1390,17 +1484,19 @@ S2.define('select2/selection/base',[
|
|
1390 |
self.$selection.removeAttr('aria-activedescendant');
|
1391 |
self.$selection.removeAttr('aria-owns');
|
1392 |
|
1393 |
-
self.$selection.focus
|
1394 |
|
1395 |
self._detachCloseHandler(container);
|
1396 |
});
|
1397 |
|
1398 |
container.on('enable', function () {
|
1399 |
self.$selection.attr('tabindex', self._tabindex);
|
|
|
1400 |
});
|
1401 |
|
1402 |
container.on('disable', function () {
|
1403 |
self.$selection.attr('tabindex', '-1');
|
|
|
1404 |
});
|
1405 |
};
|
1406 |
|
@@ -1423,7 +1519,6 @@ S2.define('select2/selection/base',[
|
|
1423 |
};
|
1424 |
|
1425 |
BaseSelection.prototype._attachCloseHandler = function (container) {
|
1426 |
-
var self = this;
|
1427 |
|
1428 |
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
1429 |
var $target = $(e.target);
|
@@ -1433,13 +1528,11 @@ S2.define('select2/selection/base',[
|
|
1433 |
var $all = $('.select2.select2-container--open');
|
1434 |
|
1435 |
$all.each(function () {
|
1436 |
-
var $this = $(this);
|
1437 |
-
|
1438 |
if (this == $select[0]) {
|
1439 |
return;
|
1440 |
}
|
1441 |
|
1442 |
-
var $element =
|
1443 |
|
1444 |
$element.select2('close');
|
1445 |
});
|
@@ -1463,6 +1556,27 @@ S2.define('select2/selection/base',[
|
|
1463 |
throw new Error('The `update` method must be defined in child classes.');
|
1464 |
};
|
1465 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1466 |
return BaseSelection;
|
1467 |
});
|
1468 |
|
@@ -1500,7 +1614,10 @@ S2.define('select2/selection/single',[
|
|
1500 |
|
1501 |
var id = container.id + '-container';
|
1502 |
|
1503 |
-
this.$selection.find('.select2-selection__rendered')
|
|
|
|
|
|
|
1504 |
this.$selection.attr('aria-labelledby', id);
|
1505 |
|
1506 |
this.$selection.on('mousedown', function (evt) {
|
@@ -1524,17 +1641,15 @@ S2.define('select2/selection/single',[
|
|
1524 |
|
1525 |
container.on('focus', function (evt) {
|
1526 |
if (!container.isOpen()) {
|
1527 |
-
self.$selection.focus
|
1528 |
}
|
1529 |
});
|
1530 |
-
|
1531 |
-
container.on('selection:update', function (params) {
|
1532 |
-
self.update(params.data);
|
1533 |
-
});
|
1534 |
};
|
1535 |
|
1536 |
SingleSelection.prototype.clear = function () {
|
1537 |
-
this.$selection.find('.select2-selection__rendered')
|
|
|
|
|
1538 |
};
|
1539 |
|
1540 |
SingleSelection.prototype.display = function (data, container) {
|
@@ -1560,7 +1675,14 @@ S2.define('select2/selection/single',[
|
|
1560 |
var formatted = this.display(selection, $rendered);
|
1561 |
|
1562 |
$rendered.empty().append(formatted);
|
1563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1564 |
};
|
1565 |
|
1566 |
return SingleSelection;
|
@@ -1605,14 +1727,14 @@ S2.define('select2/selection/multiple',[
|
|
1605 |
'.select2-selection__choice__remove',
|
1606 |
function (evt) {
|
1607 |
// Ignore the event if it is disabled
|
1608 |
-
if (self.
|
1609 |
return;
|
1610 |
}
|
1611 |
|
1612 |
var $remove = $(this);
|
1613 |
var $selection = $remove.parent();
|
1614 |
|
1615 |
-
var data = $selection
|
1616 |
|
1617 |
self.trigger('unselect', {
|
1618 |
originalEvent: evt,
|
@@ -1623,7 +1745,9 @@ S2.define('select2/selection/multiple',[
|
|
1623 |
};
|
1624 |
|
1625 |
MultipleSelection.prototype.clear = function () {
|
1626 |
-
this.$selection.find('.select2-selection__rendered')
|
|
|
|
|
1627 |
};
|
1628 |
|
1629 |
MultipleSelection.prototype.display = function (data, container) {
|
@@ -1661,9 +1785,14 @@ S2.define('select2/selection/multiple',[
|
|
1661 |
var formatted = this.display(selection, $selection);
|
1662 |
|
1663 |
$selection.append(formatted);
|
1664 |
-
$selection.prop('title', selection.title || selection.text);
|
1665 |
|
1666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1667 |
|
1668 |
$selections.push($selection);
|
1669 |
}
|
@@ -1728,8 +1857,9 @@ S2.define('select2/selection/placeholder',[
|
|
1728 |
|
1729 |
S2.define('select2/selection/allowClear',[
|
1730 |
'jquery',
|
1731 |
-
'../keys'
|
1732 |
-
|
|
|
1733 |
function AllowClear () { }
|
1734 |
|
1735 |
AllowClear.prototype.bind = function (decorated, container, $container) {
|
@@ -1758,7 +1888,7 @@ S2.define('select2/selection/allowClear',[
|
|
1758 |
|
1759 |
AllowClear.prototype._handleClear = function (_, evt) {
|
1760 |
// Ignore the event if it is disabled
|
1761 |
-
if (this.
|
1762 |
return;
|
1763 |
}
|
1764 |
|
@@ -1771,10 +1901,22 @@ S2.define('select2/selection/allowClear',[
|
|
1771 |
|
1772 |
evt.stopPropagation();
|
1773 |
|
1774 |
-
var data = $clear
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1775 |
|
1776 |
for (var d = 0; d < data.length; d++) {
|
1777 |
-
|
1778 |
data: data[d]
|
1779 |
};
|
1780 |
|
@@ -1784,11 +1926,12 @@ S2.define('select2/selection/allowClear',[
|
|
1784 |
|
1785 |
// If the event was prevented, don't clear it out.
|
1786 |
if (unselectData.prevented) {
|
|
|
1787 |
return;
|
1788 |
}
|
1789 |
}
|
1790 |
|
1791 |
-
this.$element.
|
1792 |
|
1793 |
this.trigger('toggle', {});
|
1794 |
};
|
@@ -1811,12 +1954,14 @@ S2.define('select2/selection/allowClear',[
|
|
1811 |
return;
|
1812 |
}
|
1813 |
|
|
|
|
|
1814 |
var $remove = $(
|
1815 |
-
'<span class="select2-selection__clear">' +
|
1816 |
'×' +
|
1817 |
'</span>'
|
1818 |
);
|
1819 |
-
$remove
|
1820 |
|
1821 |
this.$selection.find('.select2-selection__rendered').prepend($remove);
|
1822 |
};
|
@@ -1837,8 +1982,8 @@ S2.define('select2/selection/search',[
|
|
1837 |
var $search = $(
|
1838 |
'<li class="select2-search select2-search--inline">' +
|
1839 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
1840 |
-
' autocomplete="off" autocorrect="off" autocapitalize="
|
1841 |
-
' spellcheck="false" role="
|
1842 |
'</li>'
|
1843 |
);
|
1844 |
|
@@ -1855,14 +2000,18 @@ S2.define('select2/selection/search',[
|
|
1855 |
Search.prototype.bind = function (decorated, container, $container) {
|
1856 |
var self = this;
|
1857 |
|
|
|
|
|
1858 |
decorated.call(this, container, $container);
|
1859 |
|
1860 |
container.on('open', function () {
|
|
|
1861 |
self.$search.trigger('focus');
|
1862 |
});
|
1863 |
|
1864 |
container.on('close', function () {
|
1865 |
self.$search.val('');
|
|
|
1866 |
self.$search.removeAttr('aria-activedescendant');
|
1867 |
self.$search.trigger('focus');
|
1868 |
});
|
@@ -1882,7 +2031,11 @@ S2.define('select2/selection/search',[
|
|
1882 |
});
|
1883 |
|
1884 |
container.on('results:focus', function (params) {
|
1885 |
-
|
|
|
|
|
|
|
|
|
1886 |
});
|
1887 |
|
1888 |
this.$selection.on('focusin', '.select2-search--inline', function (evt) {
|
@@ -1907,7 +2060,7 @@ S2.define('select2/selection/search',[
|
|
1907 |
.prev('.select2-selection__choice');
|
1908 |
|
1909 |
if ($previousChoice.length > 0) {
|
1910 |
-
var item = $previousChoice
|
1911 |
|
1912 |
self.searchRemoveChoice(item);
|
1913 |
|
@@ -1916,6 +2069,12 @@ S2.define('select2/selection/search',[
|
|
1916 |
}
|
1917 |
});
|
1918 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1919 |
// Try to detect the IE version should the `documentMode` property that
|
1920 |
// is stored on the document. This is only implemented in IE and is
|
1921 |
// slightly cleaner than doing a user agent check.
|
@@ -2001,7 +2160,7 @@ S2.define('select2/selection/search',[
|
|
2001 |
|
2002 |
this.resizeSearch();
|
2003 |
if (searchHadFocus) {
|
2004 |
-
this.$search.focus
|
2005 |
}
|
2006 |
};
|
2007 |
|
@@ -2034,7 +2193,7 @@ S2.define('select2/selection/search',[
|
|
2034 |
var width = '';
|
2035 |
|
2036 |
if (this.$search.attr('placeholder') !== '') {
|
2037 |
-
width = this.$selection.find('.select2-selection__rendered').
|
2038 |
} else {
|
2039 |
var minimumWidth = this.$search.val().length + 1;
|
2040 |
|
@@ -2058,10 +2217,13 @@ S2.define('select2/selection/eventRelay',[
|
|
2058 |
'open', 'opening',
|
2059 |
'close', 'closing',
|
2060 |
'select', 'selecting',
|
2061 |
-
'unselect', 'unselecting'
|
|
|
2062 |
];
|
2063 |
|
2064 |
-
var preventableEvents = [
|
|
|
|
|
2065 |
|
2066 |
decorated.call(this, container, $container);
|
2067 |
|
@@ -2394,6 +2556,7 @@ S2.define('select2/diacritics',[
|
|
2394 |
'\u019F': 'O',
|
2395 |
'\uA74A': 'O',
|
2396 |
'\uA74C': 'O',
|
|
|
2397 |
'\u01A2': 'OI',
|
2398 |
'\uA74E': 'OO',
|
2399 |
'\u0222': 'OU',
|
@@ -2803,6 +2966,7 @@ S2.define('select2/diacritics',[
|
|
2803 |
'\uA74B': 'o',
|
2804 |
'\uA74D': 'o',
|
2805 |
'\u0275': 'o',
|
|
|
2806 |
'\u01A3': 'oi',
|
2807 |
'\u0223': 'ou',
|
2808 |
'\uA74F': 'oo',
|
@@ -2971,8 +3135,9 @@ S2.define('select2/diacritics',[
|
|
2971 |
'\u03CD': '\u03C5',
|
2972 |
'\u03CB': '\u03C5',
|
2973 |
'\u03B0': '\u03C5',
|
2974 |
-
'\
|
2975 |
-
'\u03C2': '\u03C3'
|
|
|
2976 |
};
|
2977 |
|
2978 |
return diacritics;
|
@@ -3057,7 +3222,7 @@ S2.define('select2/data/select',[
|
|
3057 |
if ($(data.element).is('option')) {
|
3058 |
data.element.selected = true;
|
3059 |
|
3060 |
-
this.$element.trigger('change');
|
3061 |
|
3062 |
return;
|
3063 |
}
|
@@ -3078,13 +3243,13 @@ S2.define('select2/data/select',[
|
|
3078 |
}
|
3079 |
|
3080 |
self.$element.val(val);
|
3081 |
-
self.$element.trigger('change');
|
3082 |
});
|
3083 |
} else {
|
3084 |
var val = data.id;
|
3085 |
|
3086 |
this.$element.val(val);
|
3087 |
-
this.$element.trigger('change');
|
3088 |
}
|
3089 |
};
|
3090 |
|
@@ -3100,7 +3265,7 @@ S2.define('select2/data/select',[
|
|
3100 |
if ($(data.element).is('option')) {
|
3101 |
data.element.selected = false;
|
3102 |
|
3103 |
-
this.$element.trigger('change');
|
3104 |
|
3105 |
return;
|
3106 |
}
|
@@ -3118,7 +3283,7 @@ S2.define('select2/data/select',[
|
|
3118 |
|
3119 |
self.$element.val(val);
|
3120 |
|
3121 |
-
self.$element.trigger('change');
|
3122 |
});
|
3123 |
};
|
3124 |
|
@@ -3140,7 +3305,7 @@ S2.define('select2/data/select',[
|
|
3140 |
// Remove anything added to child elements
|
3141 |
this.$element.find('*').each(function () {
|
3142 |
// Remove any custom data set by Select2
|
3143 |
-
|
3144 |
});
|
3145 |
};
|
3146 |
|
@@ -3191,7 +3356,7 @@ S2.define('select2/data/select',[
|
|
3191 |
}
|
3192 |
}
|
3193 |
|
3194 |
-
if (data.id) {
|
3195 |
option.value = data.id;
|
3196 |
}
|
3197 |
|
@@ -3213,7 +3378,7 @@ S2.define('select2/data/select',[
|
|
3213 |
normalizedData.element = option;
|
3214 |
|
3215 |
// Override the option's data with the combined data
|
3216 |
-
|
3217 |
|
3218 |
return $option;
|
3219 |
};
|
@@ -3221,7 +3386,7 @@ S2.define('select2/data/select',[
|
|
3221 |
SelectAdapter.prototype.item = function ($option) {
|
3222 |
var data = {};
|
3223 |
|
3224 |
-
data =
|
3225 |
|
3226 |
if (data != null) {
|
3227 |
return data;
|
@@ -3259,13 +3424,13 @@ S2.define('select2/data/select',[
|
|
3259 |
data = this._normalizeItem(data);
|
3260 |
data.element = $option[0];
|
3261 |
|
3262 |
-
|
3263 |
|
3264 |
return data;
|
3265 |
};
|
3266 |
|
3267 |
SelectAdapter.prototype._normalizeItem = function (item) {
|
3268 |
-
if (
|
3269 |
item = {
|
3270 |
id: item,
|
3271 |
text: item
|
@@ -3311,15 +3476,19 @@ S2.define('select2/data/array',[
|
|
3311 |
'jquery'
|
3312 |
], function (SelectAdapter, Utils, $) {
|
3313 |
function ArrayAdapter ($element, options) {
|
3314 |
-
|
3315 |
|
3316 |
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
3317 |
-
|
3318 |
-
this.addOptions(this.convertToOptions(data));
|
3319 |
}
|
3320 |
|
3321 |
Utils.Extend(ArrayAdapter, SelectAdapter);
|
3322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3323 |
ArrayAdapter.prototype.select = function (data) {
|
3324 |
var $option = this.$element.find('option').filter(function (i, elm) {
|
3325 |
return elm.value == data.id.toString();
|
@@ -3469,7 +3638,8 @@ S2.define('select2/data/ajax',[
|
|
3469 |
}, function () {
|
3470 |
// Attempt to detect if a request was aborted
|
3471 |
// Only works if the transport exposes a status property
|
3472 |
-
if (
|
|
|
3473 |
return;
|
3474 |
}
|
3475 |
|
@@ -3550,7 +3720,10 @@ S2.define('select2/data/tags',[
|
|
3550 |
}, true)
|
3551 |
);
|
3552 |
|
3553 |
-
var
|
|
|
|
|
|
|
3554 |
|
3555 |
if (checkText || checkChildren) {
|
3556 |
if (child) {
|
@@ -3605,8 +3778,6 @@ S2.define('select2/data/tags',[
|
|
3605 |
};
|
3606 |
|
3607 |
Tags.prototype._removeOldTags = function (_) {
|
3608 |
-
var tag = this._lastTag;
|
3609 |
-
|
3610 |
var $options = this.$element.find('option[data-select2-tag]');
|
3611 |
|
3612 |
$options.each(function () {
|
@@ -3681,7 +3852,7 @@ S2.define('select2/data/tokenizer',[
|
|
3681 |
// Replace the search term if we have the search box
|
3682 |
if (this.$search.length) {
|
3683 |
this.$search.val(tokenData.term);
|
3684 |
-
this.$search.focus
|
3685 |
}
|
3686 |
|
3687 |
params.term = tokenData.term;
|
@@ -3810,10 +3981,30 @@ S2.define('select2/data/maximumSelectionLength',[
|
|
3810 |
decorated.call(this, $e, options);
|
3811 |
}
|
3812 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3813 |
MaximumSelectionLength.prototype.query =
|
3814 |
function (decorated, params, callback) {
|
3815 |
var self = this;
|
3816 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3817 |
this.current(function (currentData) {
|
3818 |
var count = currentData != null ? currentData.length : 0;
|
3819 |
if (self.maximumSelectionLength > 0 &&
|
@@ -3826,7 +4017,10 @@ S2.define('select2/data/maximumSelectionLength',[
|
|
3826 |
});
|
3827 |
return;
|
3828 |
}
|
3829 |
-
|
|
|
|
|
|
|
3830 |
});
|
3831 |
};
|
3832 |
|
@@ -3865,7 +4059,7 @@ S2.define('select2/dropdown',[
|
|
3865 |
};
|
3866 |
|
3867 |
Dropdown.prototype.position = function ($dropdown, $container) {
|
3868 |
-
// Should be
|
3869 |
};
|
3870 |
|
3871 |
Dropdown.prototype.destroy = function () {
|
@@ -3888,8 +4082,8 @@ S2.define('select2/dropdown/search',[
|
|
3888 |
var $search = $(
|
3889 |
'<span class="select2-search select2-search--dropdown">' +
|
3890 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
3891 |
-
' autocomplete="off" autocorrect="off" autocapitalize="
|
3892 |
-
' spellcheck="false" role="
|
3893 |
'</span>'
|
3894 |
);
|
3895 |
|
@@ -3904,6 +4098,8 @@ S2.define('select2/dropdown/search',[
|
|
3904 |
Search.prototype.bind = function (decorated, container, $container) {
|
3905 |
var self = this;
|
3906 |
|
|
|
|
|
3907 |
decorated.call(this, container, $container);
|
3908 |
|
3909 |
this.$search.on('keydown', function (evt) {
|
@@ -3926,24 +4122,20 @@ S2.define('select2/dropdown/search',[
|
|
3926 |
|
3927 |
container.on('open', function () {
|
3928 |
self.$search.attr('tabindex', 0);
|
3929 |
-
|
3930 |
-
self.$search.focus();
|
3931 |
|
3932 |
window.setTimeout(function () {
|
3933 |
-
self.$search.focus
|
3934 |
}, 0);
|
3935 |
});
|
3936 |
|
3937 |
container.on('close', function () {
|
3938 |
self.$search.attr('tabindex', -1);
|
|
|
|
|
3939 |
|
3940 |
self.$search.val('');
|
3941 |
-
|
3942 |
-
|
3943 |
-
container.on('focus', function () {
|
3944 |
-
if (container.isOpen()) {
|
3945 |
-
self.$search.focus();
|
3946 |
-
}
|
3947 |
});
|
3948 |
|
3949 |
container.on('results:all', function (params) {
|
@@ -3957,6 +4149,14 @@ S2.define('select2/dropdown/search',[
|
|
3957 |
}
|
3958 |
}
|
3959 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3960 |
};
|
3961 |
|
3962 |
Search.prototype.handleSearch = function (evt) {
|
@@ -4041,6 +4241,7 @@ S2.define('select2/dropdown/infiniteScroll',[
|
|
4041 |
|
4042 |
if (this.showLoadingMore(data)) {
|
4043 |
this.$results.append(this.$loadingMore);
|
|
|
4044 |
}
|
4045 |
};
|
4046 |
|
@@ -4059,25 +4260,27 @@ S2.define('select2/dropdown/infiniteScroll',[
|
|
4059 |
self.loading = true;
|
4060 |
});
|
4061 |
|
4062 |
-
this.$results.on('scroll',
|
4063 |
-
|
4064 |
-
document.documentElement,
|
4065 |
-
self.$loadingMore[0]
|
4066 |
-
);
|
4067 |
|
4068 |
-
|
4069 |
-
|
4070 |
-
|
|
|
|
|
4071 |
|
4072 |
-
|
4073 |
-
|
4074 |
-
|
4075 |
-
self.$loadingMore.outerHeight(false);
|
4076 |
|
4077 |
-
|
4078 |
-
|
4079 |
-
|
4080 |
-
|
|
|
|
|
|
|
|
|
4081 |
};
|
4082 |
|
4083 |
InfiniteScroll.prototype.loadMore = function () {
|
@@ -4098,7 +4301,7 @@ S2.define('select2/dropdown/infiniteScroll',[
|
|
4098 |
var $option = $(
|
4099 |
'<li ' +
|
4100 |
'class="select2-results__option select2-results__option--load-more"' +
|
4101 |
-
'role="
|
4102 |
);
|
4103 |
|
4104 |
var message = this.options.get('translations').get('loadingMore');
|
@@ -4116,7 +4319,7 @@ S2.define('select2/dropdown/attachBody',[
|
|
4116 |
'../utils'
|
4117 |
], function ($, Utils) {
|
4118 |
function AttachBody (decorated, $element, options) {
|
4119 |
-
this.$dropdownParent = options.get('dropdownParent') ||
|
4120 |
|
4121 |
decorated.call(this, $element, options);
|
4122 |
}
|
@@ -4124,27 +4327,14 @@ S2.define('select2/dropdown/attachBody',[
|
|
4124 |
AttachBody.prototype.bind = function (decorated, container, $container) {
|
4125 |
var self = this;
|
4126 |
|
4127 |
-
var setupResultsEvents = false;
|
4128 |
-
|
4129 |
decorated.call(this, container, $container);
|
4130 |
|
4131 |
container.on('open', function () {
|
4132 |
self._showDropdown();
|
4133 |
self._attachPositioningHandler(container);
|
4134 |
|
4135 |
-
|
4136 |
-
|
4137 |
-
|
4138 |
-
container.on('results:all', function () {
|
4139 |
-
self._positionDropdown();
|
4140 |
-
self._resizeDropdown();
|
4141 |
-
});
|
4142 |
-
|
4143 |
-
container.on('results:append', function () {
|
4144 |
-
self._positionDropdown();
|
4145 |
-
self._resizeDropdown();
|
4146 |
-
});
|
4147 |
-
}
|
4148 |
});
|
4149 |
|
4150 |
container.on('close', function () {
|
@@ -4193,6 +4383,44 @@ S2.define('select2/dropdown/attachBody',[
|
|
4193 |
this.$dropdownContainer.detach();
|
4194 |
};
|
4195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4196 |
AttachBody.prototype._attachPositioningHandler =
|
4197 |
function (decorated, container) {
|
4198 |
var self = this;
|
@@ -4203,14 +4431,14 @@ S2.define('select2/dropdown/attachBody',[
|
|
4203 |
|
4204 |
var $watchers = this.$container.parents().filter(Utils.hasScroll);
|
4205 |
$watchers.each(function () {
|
4206 |
-
|
4207 |
x: $(this).scrollLeft(),
|
4208 |
y: $(this).scrollTop()
|
4209 |
});
|
4210 |
});
|
4211 |
|
4212 |
$watchers.on(scrollEvent, function (ev) {
|
4213 |
-
var position =
|
4214 |
$(this).scrollTop(position.y);
|
4215 |
});
|
4216 |
|
@@ -4269,16 +4497,26 @@ S2.define('select2/dropdown/attachBody',[
|
|
4269 |
top: container.bottom
|
4270 |
};
|
4271 |
|
4272 |
-
// Determine what the parent element is to use for
|
4273 |
var $offsetParent = this.$dropdownParent;
|
4274 |
|
4275 |
-
// For statically
|
4276 |
// that is determining the offset
|
4277 |
if ($offsetParent.css('position') === 'static') {
|
4278 |
$offsetParent = $offsetParent.offsetParent();
|
4279 |
}
|
4280 |
|
4281 |
-
var parentOffset =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4282 |
|
4283 |
css.top -= parentOffset.top;
|
4284 |
css.left -= parentOffset.left;
|
@@ -4375,8 +4613,8 @@ S2.define('select2/dropdown/minimumResultsForSearch',[
|
|
4375 |
});
|
4376 |
|
4377 |
S2.define('select2/dropdown/selectOnClose',[
|
4378 |
-
|
4379 |
-
], function () {
|
4380 |
function SelectOnClose () { }
|
4381 |
|
4382 |
SelectOnClose.prototype.bind = function (decorated, container, $container) {
|
@@ -4407,7 +4645,7 @@ S2.define('select2/dropdown/selectOnClose',[
|
|
4407 |
return;
|
4408 |
}
|
4409 |
|
4410 |
-
var data = $highlightedResults
|
4411 |
|
4412 |
// Don't re-select already selected resulte
|
4413 |
if (
|
@@ -4448,7 +4686,7 @@ S2.define('select2/dropdown/closeOnSelect',[
|
|
4448 |
var originalEvent = evt.originalEvent;
|
4449 |
|
4450 |
// Don't close if the control key is being held
|
4451 |
-
if (originalEvent && originalEvent.ctrlKey) {
|
4452 |
return;
|
4453 |
}
|
4454 |
|
@@ -4502,6 +4740,9 @@ S2.define('select2/i18n/en',[],function () {
|
|
4502 |
},
|
4503 |
searching: function () {
|
4504 |
return 'Searching…';
|
|
|
|
|
|
|
4505 |
}
|
4506 |
};
|
4507 |
});
|
@@ -4740,66 +4981,29 @@ S2.define('select2/defaults',[
|
|
4740 |
);
|
4741 |
}
|
4742 |
|
4743 |
-
|
4744 |
-
|
4745 |
-
|
4746 |
-
// Extract the region information if it is included
|
4747 |
-
var languageParts = options.language.split('-');
|
4748 |
-
var baseLanguage = languageParts[0];
|
4749 |
|
4750 |
-
|
4751 |
-
|
4752 |
-
options.language = [options.language];
|
4753 |
-
}
|
4754 |
-
}
|
4755 |
|
4756 |
-
|
4757 |
-
var languages = new Translation();
|
4758 |
-
options.language.push('en');
|
4759 |
|
4760 |
-
|
|
|
4761 |
|
4762 |
-
|
4763 |
-
|
4764 |
-
var language = {};
|
4765 |
-
|
4766 |
-
try {
|
4767 |
-
// Try to load it with the original name
|
4768 |
-
language = Translation.loadPath(name);
|
4769 |
-
} catch (e) {
|
4770 |
-
try {
|
4771 |
-
// If we couldn't load it, check if it wasn't the full path
|
4772 |
-
name = this.defaults.amdLanguageBase + name;
|
4773 |
-
language = Translation.loadPath(name);
|
4774 |
-
} catch (ex) {
|
4775 |
-
// The translation could not be loaded at all. Sometimes this is
|
4776 |
-
// because of a configuration problem, other times this can be
|
4777 |
-
// because of how Select2 helps load all possible translation files.
|
4778 |
-
if (options.debug && window.console && console.warn) {
|
4779 |
-
console.warn(
|
4780 |
-
'Select2: The language file for "' + name + '" could not be ' +
|
4781 |
-
'automatically loaded. A fallback will be used instead.'
|
4782 |
-
);
|
4783 |
-
}
|
4784 |
-
|
4785 |
-
continue;
|
4786 |
-
}
|
4787 |
-
}
|
4788 |
-
|
4789 |
-
languages.extend(language);
|
4790 |
}
|
|
|
4791 |
|
4792 |
-
|
4793 |
-
} else {
|
4794 |
-
var baseTranslation = Translation.loadPath(
|
4795 |
-
this.defaults.amdLanguageBase + 'en'
|
4796 |
-
);
|
4797 |
-
var customTranslation = new Translation(options.language);
|
4798 |
-
|
4799 |
-
customTranslation.extend(baseTranslation);
|
4800 |
|
4801 |
-
|
4802 |
-
|
|
|
|
|
4803 |
|
4804 |
return options;
|
4805 |
};
|
@@ -4866,13 +5070,14 @@ S2.define('select2/defaults',[
|
|
4866 |
debug: false,
|
4867 |
dropdownAutoWidth: false,
|
4868 |
escapeMarkup: Utils.escapeMarkup,
|
4869 |
-
language:
|
4870 |
matcher: matcher,
|
4871 |
minimumInputLength: 0,
|
4872 |
maximumInputLength: 0,
|
4873 |
maximumSelectionLength: 0,
|
4874 |
minimumResultsForSearch: 0,
|
4875 |
selectOnClose: false,
|
|
|
4876 |
sorter: function (data) {
|
4877 |
return data;
|
4878 |
},
|
@@ -4887,6 +5092,103 @@ S2.define('select2/defaults',[
|
|
4887 |
};
|
4888 |
};
|
4889 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4890 |
Defaults.prototype.set = function (key, value) {
|
4891 |
var camelKey = $.camelCase(key);
|
4892 |
|
@@ -4895,7 +5197,7 @@ S2.define('select2/defaults',[
|
|
4895 |
|
4896 |
var convertedData = Utils._convertData(data);
|
4897 |
|
4898 |
-
$.extend(this.defaults, convertedData);
|
4899 |
};
|
4900 |
|
4901 |
var defaults = new Defaults();
|
@@ -4916,6 +5218,10 @@ S2.define('select2/options',[
|
|
4916 |
this.fromElement($element);
|
4917 |
}
|
4918 |
|
|
|
|
|
|
|
|
|
4919 |
this.options = Defaults.apply(this.options);
|
4920 |
|
4921 |
if ($element && $element.is('input')) {
|
@@ -4939,14 +5245,6 @@ S2.define('select2/options',[
|
|
4939 |
this.options.disabled = $e.prop('disabled');
|
4940 |
}
|
4941 |
|
4942 |
-
if (this.options.language == null) {
|
4943 |
-
if ($e.prop('lang')) {
|
4944 |
-
this.options.language = $e.prop('lang').toLowerCase();
|
4945 |
-
} else if ($e.closest('[lang]').prop('lang')) {
|
4946 |
-
this.options.language = $e.closest('[lang]').prop('lang');
|
4947 |
-
}
|
4948 |
-
}
|
4949 |
-
|
4950 |
if (this.options.dir == null) {
|
4951 |
if ($e.prop('dir')) {
|
4952 |
this.options.dir = $e.prop('dir');
|
@@ -4960,7 +5258,7 @@ S2.define('select2/options',[
|
|
4960 |
$e.prop('disabled', this.options.disabled);
|
4961 |
$e.prop('multiple', this.options.multiple);
|
4962 |
|
4963 |
-
if ($e
|
4964 |
if (this.options.debug && window.console && console.warn) {
|
4965 |
console.warn(
|
4966 |
'Select2: The `data-select2-tags` attribute has been changed to ' +
|
@@ -4969,11 +5267,11 @@ S2.define('select2/options',[
|
|
4969 |
);
|
4970 |
}
|
4971 |
|
4972 |
-
$e
|
4973 |
-
$e
|
4974 |
}
|
4975 |
|
4976 |
-
if ($e
|
4977 |
if (this.options.debug && window.console && console.warn) {
|
4978 |
console.warn(
|
4979 |
'Select2: The `data-ajax-url` attribute has been changed to ' +
|
@@ -4982,21 +5280,45 @@ S2.define('select2/options',[
|
|
4982 |
);
|
4983 |
}
|
4984 |
|
4985 |
-
$e.attr('ajax--url', $e
|
4986 |
-
$e
|
4987 |
}
|
4988 |
|
4989 |
var dataset = {};
|
4990 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4991 |
// Prefer the element's `dataset` attribute if it exists
|
4992 |
// jQuery 1.x does not correctly handle data attributes with multiple dashes
|
4993 |
if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
|
4994 |
-
dataset = $.extend(true, {}, $e[0].dataset,
|
4995 |
-
} else {
|
4996 |
-
dataset = $e.data();
|
4997 |
}
|
4998 |
|
4999 |
-
|
|
|
5000 |
|
5001 |
data = Utils._convertData(data);
|
5002 |
|
@@ -5033,8 +5355,8 @@ S2.define('select2/core',[
|
|
5033 |
'./keys'
|
5034 |
], function ($, Options, Utils, KEYS) {
|
5035 |
var Select2 = function ($element, options) {
|
5036 |
-
if ($element
|
5037 |
-
$element
|
5038 |
}
|
5039 |
|
5040 |
this.$element = $element;
|
@@ -5050,7 +5372,7 @@ S2.define('select2/core',[
|
|
5050 |
// Set up the tabindex
|
5051 |
|
5052 |
var tabindex = $element.attr('tabindex') || 0;
|
5053 |
-
$element
|
5054 |
$element.attr('tabindex', '-1');
|
5055 |
|
5056 |
// Set up containers and adapters
|
@@ -5111,6 +5433,9 @@ S2.define('select2/core',[
|
|
5111 |
// Synchronize any monitored attributes
|
5112 |
this._syncAttributes();
|
5113 |
|
|
|
|
|
|
|
5114 |
$element.data('select2', this);
|
5115 |
};
|
5116 |
|
@@ -5187,6 +5512,12 @@ S2.define('select2/core',[
|
|
5187 |
return null;
|
5188 |
}
|
5189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5190 |
return method;
|
5191 |
};
|
5192 |
|
@@ -5227,8 +5558,8 @@ S2.define('select2/core',[
|
|
5227 |
|
5228 |
if (observer != null) {
|
5229 |
this._observer = new observer(function (mutations) {
|
5230 |
-
|
5231 |
-
|
5232 |
});
|
5233 |
this._observer.observe(this.$element[0], {
|
5234 |
attributes: true,
|
@@ -5350,7 +5681,7 @@ S2.define('select2/core',[
|
|
5350 |
if (self.isOpen()) {
|
5351 |
if (key === KEYS.ESC || key === KEYS.TAB ||
|
5352 |
(key === KEYS.UP && evt.altKey)) {
|
5353 |
-
self.close();
|
5354 |
|
5355 |
evt.preventDefault();
|
5356 |
} else if (key === KEYS.ENTER) {
|
@@ -5384,7 +5715,7 @@ S2.define('select2/core',[
|
|
5384 |
Select2.prototype._syncAttributes = function () {
|
5385 |
this.options.set('disabled', this.$element.prop('disabled'));
|
5386 |
|
5387 |
-
if (this.
|
5388 |
if (this.isOpen()) {
|
5389 |
this.close();
|
5390 |
}
|
@@ -5395,7 +5726,7 @@ S2.define('select2/core',[
|
|
5395 |
}
|
5396 |
};
|
5397 |
|
5398 |
-
Select2.prototype.
|
5399 |
var changed = false;
|
5400 |
var self = this;
|
5401 |
|
@@ -5423,7 +5754,22 @@ S2.define('select2/core',[
|
|
5423 |
}
|
5424 |
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
|
5425 |
changed = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5426 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
5427 |
|
5428 |
// Only re-pull the data if we think there is a change
|
5429 |
if (changed) {
|
@@ -5445,7 +5791,8 @@ S2.define('select2/core',[
|
|
5445 |
'open': 'opening',
|
5446 |
'close': 'closing',
|
5447 |
'select': 'selecting',
|
5448 |
-
'unselect': 'unselecting'
|
|
|
5449 |
};
|
5450 |
|
5451 |
if (args === undefined) {
|
@@ -5473,7 +5820,7 @@ S2.define('select2/core',[
|
|
5473 |
};
|
5474 |
|
5475 |
Select2.prototype.toggleDropdown = function () {
|
5476 |
-
if (this.
|
5477 |
return;
|
5478 |
}
|
5479 |
|
@@ -5489,15 +5836,40 @@ S2.define('select2/core',[
|
|
5489 |
return;
|
5490 |
}
|
5491 |
|
|
|
|
|
|
|
|
|
5492 |
this.trigger('query', {});
|
5493 |
};
|
5494 |
|
5495 |
-
Select2.prototype.close = function () {
|
5496 |
if (!this.isOpen()) {
|
5497 |
return;
|
5498 |
}
|
5499 |
|
5500 |
-
this.trigger('close', {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5501 |
};
|
5502 |
|
5503 |
Select2.prototype.isOpen = function () {
|
@@ -5574,7 +5946,7 @@ S2.define('select2/core',[
|
|
5574 |
});
|
5575 |
}
|
5576 |
|
5577 |
-
this.$element.val(newVal).trigger('change');
|
5578 |
};
|
5579 |
|
5580 |
Select2.prototype.destroy = function () {
|
@@ -5600,10 +5972,12 @@ S2.define('select2/core',[
|
|
5600 |
this._syncS = null;
|
5601 |
|
5602 |
this.$element.off('.select2');
|
5603 |
-
this.$element.attr('tabindex',
|
|
|
5604 |
|
5605 |
this.$element.removeClass('select2-hidden-accessible');
|
5606 |
this.$element.attr('aria-hidden', 'false');
|
|
|
5607 |
this.$element.removeData('select2');
|
5608 |
|
5609 |
this.dataAdapter.destroy();
|
@@ -5631,7 +6005,7 @@ S2.define('select2/core',[
|
|
5631 |
|
5632 |
this.$container.addClass('select2-container--' + this.options.get('theme'));
|
5633 |
|
5634 |
-
$container
|
5635 |
|
5636 |
return $container;
|
5637 |
};
|
@@ -5841,8 +6215,9 @@ S2.define('select2/compat/initSelection',[
|
|
5841 |
});
|
5842 |
|
5843 |
S2.define('select2/compat/inputData',[
|
5844 |
-
'jquery'
|
5845 |
-
|
|
|
5846 |
function InputData (decorated, $element, options) {
|
5847 |
this._currentData = [];
|
5848 |
this._valueSeparator = options.get('valueSeparator') || ',';
|
@@ -5906,13 +6281,13 @@ S2.define('select2/compat/inputData',[
|
|
5906 |
});
|
5907 |
|
5908 |
this.$element.val(data.id);
|
5909 |
-
this.$element.trigger('change');
|
5910 |
} else {
|
5911 |
var value = this.$element.val();
|
5912 |
value += this._valueSeparator + data.id;
|
5913 |
|
5914 |
this.$element.val(value);
|
5915 |
-
this.$element.trigger('change');
|
5916 |
}
|
5917 |
};
|
5918 |
|
@@ -5935,7 +6310,7 @@ S2.define('select2/compat/inputData',[
|
|
5935 |
}
|
5936 |
|
5937 |
self.$element.val(values.join(self._valueSeparator));
|
5938 |
-
self.$element.trigger('change');
|
5939 |
});
|
5940 |
};
|
5941 |
|
@@ -5959,7 +6334,7 @@ S2.define('select2/compat/inputData',[
|
|
5959 |
|
5960 |
InputData.prototype.addOptions = function (_, $options) {
|
5961 |
var options = $.map($options, function ($option) {
|
5962 |
-
return
|
5963 |
});
|
5964 |
|
5965 |
this._currentData.push.apply(this._currentData, options);
|
@@ -6362,8 +6737,9 @@ S2.define('jquery.select2',[
|
|
6362 |
'jquery-mousewheel',
|
6363 |
|
6364 |
'./select2/core',
|
6365 |
-
'./select2/defaults'
|
6366 |
-
|
|
|
6367 |
if ($.fn.select2 == null) {
|
6368 |
// All methods that should return the element
|
6369 |
var thisMethods = ['open', 'close', 'destroy'];
|
@@ -6384,7 +6760,7 @@ S2.define('jquery.select2',[
|
|
6384 |
var args = Array.prototype.slice.call(arguments, 1);
|
6385 |
|
6386 |
this.each(function () {
|
6387 |
-
var instance =
|
6388 |
|
6389 |
if (instance == null && window.console && console.error) {
|
6390 |
console.error(
|
1 |
/*!
|
2 |
+
* Select2 4.0.13 + focus fix (https://github.com/select2/select2/pull/6044)
|
3 |
* https://select2.github.io
|
4 |
+
*
|
5 |
* Released under the MIT license
|
6 |
* https://github.com/select2/select2/blob/master/LICENSE.md
|
7 |
*/
|
8 |
+
;(function (factory) {
|
9 |
if (typeof define === 'function' && define.amd) {
|
10 |
// AMD. Register as an anonymous module.
|
11 |
define(['jquery'], factory);
|
12 |
+
} else if (typeof module === 'object' && module.exports) {
|
13 |
// Node/CommonJS
|
14 |
+
module.exports = function (root, jQuery) {
|
15 |
+
if (jQuery === undefined) {
|
16 |
+
// require('jQuery') returns a factory that requires window to
|
17 |
+
// build a jQuery instance, we normalize how we use modules
|
18 |
+
// that require this pattern but the window provided is a noop
|
19 |
+
// if it's defined (how jquery works)
|
20 |
+
if (typeof window !== 'undefined') {
|
21 |
+
jQuery = require('jquery');
|
22 |
+
}
|
23 |
+
else {
|
24 |
+
jQuery = require('jquery')(root);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
factory(jQuery);
|
28 |
+
return jQuery;
|
29 |
+
};
|
30 |
} else {
|
31 |
// Browser globals
|
32 |
factory(jQuery);
|
33 |
}
|
34 |
+
} (function (jQuery) {
|
35 |
// This is needed so we can catch the AMD loader configuration and use it
|
36 |
// The inner file should be wrapped (by `banner.start.js`) in a function that
|
37 |
// returns the AMD loader references.
|
38 |
+
var S2 =(function () {
|
|
|
39 |
// Restore the Select2 AMD loader so it can be used
|
40 |
// Needed mostly in the language files, where the loader is not inserted
|
41 |
if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
|
44 |
var S2;(function () { if (!S2 || !S2.requirejs) {
|
45 |
if (!S2) { S2 = {}; } else { require = S2; }
|
46 |
/**
|
47 |
+
* @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
|
48 |
+
* Released under MIT license, http://github.com/requirejs/almond/LICENSE
|
|
|
49 |
*/
|
50 |
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
51 |
//be followed.
|
|
|
52 |
/*global setTimeout: false */
|
53 |
|
54 |
var requirejs, require, define;
|
76 |
*/
|
77 |
function normalize(name, baseName) {
|
78 |
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
79 |
+
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
|
80 |
baseParts = baseName && baseName.split("/"),
|
81 |
map = config.map,
|
82 |
starMap = (map && map['*']) || {};
|
83 |
|
84 |
//Adjust any relative paths.
|
85 |
+
if (name) {
|
86 |
+
name = name.split('/');
|
87 |
+
lastIndex = name.length - 1;
|
88 |
+
|
89 |
+
// If wanting node ID compatibility, strip .js from end
|
90 |
+
// of IDs. Have to do this here, and not in nameToUrl
|
91 |
+
// because node allows either .js or non .js to map
|
92 |
+
// to same file.
|
93 |
+
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
|
94 |
+
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
|
95 |
+
}
|
|
|
96 |
|
97 |
+
// Starts with a '.' so need the baseName
|
98 |
+
if (name[0].charAt(0) === '.' && baseParts) {
|
99 |
+
//Convert baseName to array, and lop off the last part,
|
100 |
+
//so that . matches that 'directory' and not name of the baseName's
|
101 |
+
//module. For instance, baseName of 'one/two/three', maps to
|
102 |
+
//'one/two/three.js', but we want the directory, 'one/two' for
|
103 |
+
//this normalization.
|
104 |
+
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
|
105 |
+
name = normalizedBaseParts.concat(name);
|
106 |
+
}
|
107 |
+
|
108 |
+
//start trimDots
|
109 |
+
for (i = 0; i < name.length; i++) {
|
110 |
+
part = name[i];
|
111 |
+
if (part === '.') {
|
112 |
+
name.splice(i, 1);
|
113 |
+
i -= 1;
|
114 |
+
} else if (part === '..') {
|
115 |
+
// If at the start, or previous value is still ..,
|
116 |
+
// keep them so that when converted to a path it may
|
117 |
+
// still work when converted to a path, even though
|
118 |
+
// as an ID it is less than ideal. In larger point
|
119 |
+
// releases, may be better to just kick out an error.
|
120 |
+
if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
|
121 |
+
continue;
|
122 |
+
} else if (i > 0) {
|
123 |
+
name.splice(i - 1, 2);
|
124 |
+
i -= 2;
|
125 |
}
|
126 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
+
//end trimDots
|
129 |
+
|
130 |
+
name = name.join('/');
|
131 |
}
|
132 |
|
133 |
//Apply map config if available.
|
240 |
return [prefix, name];
|
241 |
}
|
242 |
|
243 |
+
//Creates a parts array for a relName where first part is plugin ID,
|
244 |
+
//second part is resource ID. Assumes relName has already been normalized.
|
245 |
+
function makeRelParts(relName) {
|
246 |
+
return relName ? splitPrefix(relName) : [];
|
247 |
+
}
|
248 |
+
|
249 |
/**
|
250 |
* Makes a name map, normalizing the name, and using a plugin
|
251 |
* for normalization if necessary. Grabs a ref to plugin
|
252 |
* too, as an optimization.
|
253 |
*/
|
254 |
+
makeMap = function (name, relParts) {
|
255 |
var plugin,
|
256 |
parts = splitPrefix(name),
|
257 |
+
prefix = parts[0],
|
258 |
+
relResourceName = relParts[1];
|
259 |
|
260 |
name = parts[1];
|
261 |
|
262 |
if (prefix) {
|
263 |
+
prefix = normalize(prefix, relResourceName);
|
264 |
plugin = callDep(prefix);
|
265 |
}
|
266 |
|
267 |
//Normalize according
|
268 |
if (prefix) {
|
269 |
if (plugin && plugin.normalize) {
|
270 |
+
name = plugin.normalize(name, makeNormalize(relResourceName));
|
271 |
} else {
|
272 |
+
name = normalize(name, relResourceName);
|
273 |
}
|
274 |
} else {
|
275 |
+
name = normalize(name, relResourceName);
|
276 |
parts = splitPrefix(name);
|
277 |
prefix = parts[0];
|
278 |
name = parts[1];
|
319 |
};
|
320 |
|
321 |
main = function (name, deps, callback, relName) {
|
322 |
+
var cjsModule, depName, ret, map, i, relParts,
|
323 |
args = [],
|
324 |
callbackType = typeof callback,
|
325 |
usingExports;
|
326 |
|
327 |
//Use name if no relName
|
328 |
relName = relName || name;
|
329 |
+
relParts = makeRelParts(relName);
|
330 |
|
331 |
//Call the callback to define the module, if necessary.
|
332 |
if (callbackType === 'undefined' || callbackType === 'function') {
|
335 |
//Default to [require, exports, module] if no deps
|
336 |
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
337 |
for (i = 0; i < deps.length; i += 1) {
|
338 |
+
map = makeMap(deps[i], relParts);
|
339 |
depName = map.f;
|
340 |
|
341 |
//Fast path CommonJS standard dependencies.
|
391 |
//deps arg is the module name, and second arg (if passed)
|
392 |
//is just the relName.
|
393 |
//Normalize module name, if it contains . or ..
|
394 |
+
return callDep(makeMap(deps, makeRelParts(callback)).f);
|
395 |
} else if (!deps.splice) {
|
396 |
//deps is a config object, not an array.
|
397 |
config = deps;
|
574 |
DecoratedClass.prototype = new ctr();
|
575 |
|
576 |
for (var m = 0; m < superMethods.length; m++) {
|
577 |
+
var superMethod = superMethods[m];
|
578 |
|
579 |
+
DecoratedClass.prototype[superMethod] =
|
580 |
+
SuperClass.prototype[superMethod];
|
581 |
}
|
582 |
|
583 |
var calledMethod = function (methodName) {
|
772 |
$element.append($nodes);
|
773 |
};
|
774 |
|
775 |
+
// Cache objects in Utils.__cache instead of $.data (see #4346)
|
776 |
+
Utils.__cache = {};
|
777 |
+
|
778 |
+
var id = 0;
|
779 |
+
Utils.GetUniqueElementId = function (element) {
|
780 |
+
// Get a unique element Id. If element has no id,
|
781 |
+
// creates a new unique number, stores it in the id
|
782 |
+
// attribute and returns the new id.
|
783 |
+
// If an id already exists, it simply returns it.
|
784 |
+
|
785 |
+
var select2Id = element.getAttribute('data-select2-id');
|
786 |
+
if (select2Id == null) {
|
787 |
+
// If element has id, use it.
|
788 |
+
if (element.id) {
|
789 |
+
select2Id = element.id;
|
790 |
+
element.setAttribute('data-select2-id', select2Id);
|
791 |
+
} else {
|
792 |
+
element.setAttribute('data-select2-id', ++id);
|
793 |
+
select2Id = id.toString();
|
794 |
+
}
|
795 |
+
}
|
796 |
+
return select2Id;
|
797 |
+
};
|
798 |
+
|
799 |
+
Utils.StoreData = function (element, name, value) {
|
800 |
+
// Stores an item in the cache for a specified element.
|
801 |
+
// name is the cache key.
|
802 |
+
var id = Utils.GetUniqueElementId(element);
|
803 |
+
if (!Utils.__cache[id]) {
|
804 |
+
Utils.__cache[id] = {};
|
805 |
+
}
|
806 |
+
|
807 |
+
Utils.__cache[id][name] = value;
|
808 |
+
};
|
809 |
+
|
810 |
+
Utils.GetData = function (element, name) {
|
811 |
+
// Retrieves a value from the cache by its key (name)
|
812 |
+
// name is optional. If no name specified, return
|
813 |
+
// all cache items for the specified element.
|
814 |
+
// and for a specified element.
|
815 |
+
var id = Utils.GetUniqueElementId(element);
|
816 |
+
if (name) {
|
817 |
+
if (Utils.__cache[id]) {
|
818 |
+
if (Utils.__cache[id][name] != null) {
|
819 |
+
return Utils.__cache[id][name];
|
820 |
+
}
|
821 |
+
return $(element).data(name); // Fallback to HTML5 data attribs.
|
822 |
+
}
|
823 |
+
return $(element).data(name); // Fallback to HTML5 data attribs.
|
824 |
+
} else {
|
825 |
+
return Utils.__cache[id];
|
826 |
+
}
|
827 |
+
};
|
828 |
+
|
829 |
+
Utils.RemoveData = function (element) {
|
830 |
+
// Removes all cached items for a specified element.
|
831 |
+
var id = Utils.GetUniqueElementId(element);
|
832 |
+
if (Utils.__cache[id] != null) {
|
833 |
+
delete Utils.__cache[id];
|
834 |
+
}
|
835 |
+
|
836 |
+
element.removeAttribute('data-select2-id');
|
837 |
+
};
|
838 |
+
|
839 |
return Utils;
|
840 |
});
|
841 |
|
855 |
|
856 |
Results.prototype.render = function () {
|
857 |
var $results = $(
|
858 |
+
'<ul class="select2-results__options" role="listbox"></ul>'
|
859 |
);
|
860 |
|
861 |
if (this.options.get('multiple')) {
|
878 |
this.hideLoading();
|
879 |
|
880 |
var $message = $(
|
881 |
+
'<li role="alert" aria-live="assertive"' +
|
882 |
' class="select2-results__option"></li>'
|
883 |
);
|
884 |
|
971 |
$options.each(function () {
|
972 |
var $option = $(this);
|
973 |
|
974 |
+
var item = Utils.GetData(this, 'data');
|
975 |
|
976 |
// id needs to be converted to a string when comparing
|
977 |
var id = '' + item.id;
|
1012 |
option.className = 'select2-results__option';
|
1013 |
|
1014 |
var attrs = {
|
1015 |
+
'role': 'option',
|
1016 |
'aria-selected': 'false'
|
1017 |
};
|
1018 |
|
1019 |
+
var matches = window.Element.prototype.matches ||
|
1020 |
+
window.Element.prototype.msMatchesSelector ||
|
1021 |
+
window.Element.prototype.webkitMatchesSelector;
|
1022 |
+
|
1023 |
+
if ((data.element != null && matches.call(data.element, ':disabled')) ||
|
1024 |
+
(data.element == null && data.disabled)) {
|
1025 |
delete attrs['aria-selected'];
|
1026 |
attrs['aria-disabled'] = 'true';
|
1027 |
}
|
1081 |
this.template(data, option);
|
1082 |
}
|
1083 |
|
1084 |
+
Utils.StoreData(option, 'data', data);
|
1085 |
|
1086 |
return option;
|
1087 |
};
|
1122 |
}
|
1123 |
|
1124 |
self.setClasses();
|
1125 |
+
|
1126 |
+
if (self.options.get('scrollAfterSelect')) {
|
1127 |
+
self.highlightFirstItem();
|
1128 |
+
}
|
1129 |
});
|
1130 |
|
1131 |
container.on('unselect', function () {
|
1134 |
}
|
1135 |
|
1136 |
self.setClasses();
|
1137 |
+
|
1138 |
+
if (self.options.get('scrollAfterSelect')) {
|
1139 |
+
self.highlightFirstItem();
|
1140 |
+
}
|
1141 |
});
|
1142 |
|
1143 |
container.on('open', function () {
|
1173 |
return;
|
1174 |
}
|
1175 |
|
1176 |
+
var data = Utils.GetData($highlighted[0], 'data');
|
1177 |
|
1178 |
if ($highlighted.attr('aria-selected') == 'true') {
|
1179 |
self.trigger('close', {});
|
1191 |
|
1192 |
var currentIndex = $options.index($highlighted);
|
1193 |
|
1194 |
+
// If we are already at the top, don't move further
|
1195 |
+
// If no options, currentIndex will be -1
|
1196 |
+
if (currentIndex <= 0) {
|
1197 |
return;
|
1198 |
}
|
1199 |
|
1286 |
function (evt) {
|
1287 |
var $this = $(this);
|
1288 |
|
1289 |
+
var data = Utils.GetData(this, 'data');
|
1290 |
|
1291 |
if ($this.attr('aria-selected') === 'true') {
|
1292 |
if (self.options.get('multiple')) {
|
1309 |
|
1310 |
this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
|
1311 |
function (evt) {
|
1312 |
+
var data = Utils.GetData(this, 'data');
|
1313 |
|
1314 |
self.getHighlightedResults()
|
1315 |
.removeClass('select2-results__option--highlighted');
|
1424 |
|
1425 |
this._tabindex = 0;
|
1426 |
|
1427 |
+
if (Utils.GetData(this.$element[0], 'old-tabindex') != null) {
|
1428 |
+
this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex');
|
1429 |
} else if (this.$element.attr('tabindex') != null) {
|
1430 |
this._tabindex = this.$element.attr('tabindex');
|
1431 |
}
|
1432 |
|
1433 |
$selection.attr('title', this.$element.attr('title'));
|
1434 |
$selection.attr('tabindex', this._tabindex);
|
1435 |
+
$selection.attr('aria-disabled', 'false');
|
1436 |
|
1437 |
this.$selection = $selection;
|
1438 |
|
1442 |
BaseSelection.prototype.bind = function (container, $container) {
|
1443 |
var self = this;
|
1444 |
|
|
|
1445 |
var resultsId = container.id + '-results';
|
1446 |
|
1447 |
this.container = container;
|
1484 |
self.$selection.removeAttr('aria-activedescendant');
|
1485 |
self.$selection.removeAttr('aria-owns');
|
1486 |
|
1487 |
+
self.$selection.trigger('focus');
|
1488 |
|
1489 |
self._detachCloseHandler(container);
|
1490 |
});
|
1491 |
|
1492 |
container.on('enable', function () {
|
1493 |
self.$selection.attr('tabindex', self._tabindex);
|
1494 |
+
self.$selection.attr('aria-disabled', 'false');
|
1495 |
});
|
1496 |
|
1497 |
container.on('disable', function () {
|
1498 |
self.$selection.attr('tabindex', '-1');
|
1499 |
+
self.$selection.attr('aria-disabled', 'true');
|
1500 |
});
|
1501 |
};
|
1502 |
|
1519 |
};
|
1520 |
|
1521 |
BaseSelection.prototype._attachCloseHandler = function (container) {
|
|
|
1522 |
|
1523 |
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
1524 |
var $target = $(e.target);
|
1528 |
var $all = $('.select2.select2-container--open');
|
1529 |
|
1530 |
$all.each(function () {
|
|
|
|
|
1531 |
if (this == $select[0]) {
|
1532 |
return;
|
1533 |
}
|
1534 |
|
1535 |
+
var $element = Utils.GetData(this, 'element');
|
1536 |
|
1537 |
$element.select2('close');
|
1538 |
});
|
1556 |
throw new Error('The `update` method must be defined in child classes.');
|
1557 |
};
|
1558 |
|
1559 |
+
/**
|
1560 |
+
* Helper method to abstract the "enabled" (not "disabled") state of this
|
1561 |
+
* object.
|
1562 |
+
*
|
1563 |
+
* @return {true} if the instance is not disabled.
|
1564 |
+
* @return {false} if the instance is disabled.
|
1565 |
+
*/
|
1566 |
+
BaseSelection.prototype.isEnabled = function () {
|
1567 |
+
return !this.isDisabled();
|
1568 |
+
};
|
1569 |
+
|
1570 |
+
/**
|
1571 |
+
* Helper method to abstract the "disabled" state of this object.
|
1572 |
+
*
|
1573 |
+
* @return {true} if the disabled option is true.
|
1574 |
+
* @return {false} if the disabled option is false.
|
1575 |
+
*/
|
1576 |
+
BaseSelection.prototype.isDisabled = function () {
|
1577 |
+
return this.options.get('disabled');
|
1578 |
+
};
|
1579 |
+
|
1580 |
return BaseSelection;
|
1581 |
});
|
1582 |
|
1614 |
|
1615 |
var id = container.id + '-container';
|
1616 |
|
1617 |
+
this.$selection.find('.select2-selection__rendered')
|
1618 |
+
.attr('id', id)
|
1619 |
+
.attr('role', 'textbox')
|
1620 |
+
.attr('aria-readonly', 'true');
|
1621 |
this.$selection.attr('aria-labelledby', id);
|
1622 |
|
1623 |
this.$selection.on('mousedown', function (evt) {
|
1641 |
|
1642 |
container.on('focus', function (evt) {
|
1643 |
if (!container.isOpen()) {
|
1644 |
+
self.$selection.trigger('focus');
|
1645 |
}
|
1646 |
});
|
|
|
|
|
|
|
|
|
1647 |
};
|
1648 |
|
1649 |
SingleSelection.prototype.clear = function () {
|
1650 |
+
var $rendered = this.$selection.find('.select2-selection__rendered');
|
1651 |
+
$rendered.empty();
|
1652 |
+
$rendered.removeAttr('title'); // clear tooltip on empty
|
1653 |
};
|
1654 |
|
1655 |
SingleSelection.prototype.display = function (data, container) {
|
1675 |
var formatted = this.display(selection, $rendered);
|
1676 |
|
1677 |
$rendered.empty().append(formatted);
|
1678 |
+
|
1679 |
+
var title = selection.title || selection.text;
|
1680 |
+
|
1681 |
+
if (title) {
|
1682 |
+
$rendered.attr('title', title);
|
1683 |
+
} else {
|
1684 |
+
$rendered.removeAttr('title');
|
1685 |
+
}
|
1686 |
};
|
1687 |
|
1688 |
return SingleSelection;
|
1727 |
'.select2-selection__choice__remove',
|
1728 |
function (evt) {
|
1729 |
// Ignore the event if it is disabled
|
1730 |
+
if (self.isDisabled()) {
|
1731 |
return;
|
1732 |
}
|
1733 |
|
1734 |
var $remove = $(this);
|
1735 |
var $selection = $remove.parent();
|
1736 |
|
1737 |
+
var data = Utils.GetData($selection[0], 'data');
|
1738 |
|
1739 |
self.trigger('unselect', {
|
1740 |
originalEvent: evt,
|
1745 |
};
|
1746 |
|
1747 |
MultipleSelection.prototype.clear = function () {
|
1748 |
+
var $rendered = this.$selection.find('.select2-selection__rendered');
|
1749 |
+
$rendered.empty();
|
1750 |
+
$rendered.removeAttr('title');
|
1751 |
};
|
1752 |
|
1753 |
MultipleSelection.prototype.display = function (data, container) {
|
1785 |
var formatted = this.display(selection, $selection);
|
1786 |
|
1787 |
$selection.append(formatted);
|
|
|
1788 |
|
1789 |
+
var title = selection.title || selection.text;
|
1790 |
+
|
1791 |
+
if (title) {
|
1792 |
+
$selection.attr('title', title);
|
1793 |
+
}
|
1794 |
+
|
1795 |
+
Utils.StoreData($selection[0], 'data', selection);
|
1796 |
|
1797 |
$selections.push($selection);
|
1798 |
}
|
1857 |
|
1858 |
S2.define('select2/selection/allowClear',[
|
1859 |
'jquery',
|
1860 |
+
'../keys',
|
1861 |
+
'../utils'
|
1862 |
+
], function ($, KEYS, Utils) {
|
1863 |
function AllowClear () { }
|
1864 |
|
1865 |
AllowClear.prototype.bind = function (decorated, container, $container) {
|
1888 |
|
1889 |
AllowClear.prototype._handleClear = function (_, evt) {
|
1890 |
// Ignore the event if it is disabled
|
1891 |
+
if (this.isDisabled()) {
|
1892 |
return;
|
1893 |
}
|
1894 |
|
1901 |
|
1902 |
evt.stopPropagation();
|
1903 |
|
1904 |
+
var data = Utils.GetData($clear[0], 'data');
|
1905 |
+
|
1906 |
+
var previousVal = this.$element.val();
|
1907 |
+
this.$element.val(this.placeholder.id);
|
1908 |
+
|
1909 |
+
var unselectData = {
|
1910 |
+
data: data
|
1911 |
+
};
|
1912 |
+
this.trigger('clear', unselectData);
|
1913 |
+
if (unselectData.prevented) {
|
1914 |
+
this.$element.val(previousVal);
|
1915 |
+
return;
|
1916 |
+
}
|
1917 |
|
1918 |
for (var d = 0; d < data.length; d++) {
|
1919 |
+
unselectData = {
|
1920 |
data: data[d]
|
1921 |
};
|
1922 |
|
1926 |
|
1927 |
// If the event was prevented, don't clear it out.
|
1928 |
if (unselectData.prevented) {
|
1929 |
+
this.$element.val(previousVal);
|
1930 |
return;
|
1931 |
}
|
1932 |
}
|
1933 |
|
1934 |
+
this.$element.trigger('input').trigger('change');
|
1935 |
|
1936 |
this.trigger('toggle', {});
|
1937 |
};
|
1954 |
return;
|
1955 |
}
|
1956 |
|
1957 |
+
var removeAll = this.options.get('translations').get('removeAllItems');
|
1958 |
+
|
1959 |
var $remove = $(
|
1960 |
+
'<span class="select2-selection__clear" title="' + removeAll() +'">' +
|
1961 |
'×' +
|
1962 |
'</span>'
|
1963 |
);
|
1964 |
+
Utils.StoreData($remove[0], 'data', data);
|
1965 |
|
1966 |
this.$selection.find('.select2-selection__rendered').prepend($remove);
|
1967 |
};
|
1982 |
var $search = $(
|
1983 |
'<li class="select2-search select2-search--inline">' +
|
1984 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
1985 |
+
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
|
1986 |
+
' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
|
1987 |
'</li>'
|
1988 |
);
|
1989 |
|
2000 |
Search.prototype.bind = function (decorated, container, $container) {
|
2001 |
var self = this;
|
2002 |
|
2003 |
+
var resultsId = container.id + '-results';
|
2004 |
+
|
2005 |
decorated.call(this, container, $container);
|
2006 |
|
2007 |
container.on('open', function () {
|
2008 |
+
self.$search.attr('aria-controls', resultsId);
|
2009 |
self.$search.trigger('focus');
|
2010 |
});
|
2011 |
|
2012 |
container.on('close', function () {
|
2013 |
self.$search.val('');
|
2014 |
+
self.$search.removeAttr('aria-controls');
|
2015 |
self.$search.removeAttr('aria-activedescendant');
|
2016 |
self.$search.trigger('focus');
|
2017 |
});
|
2031 |
});
|
2032 |
|
2033 |
container.on('results:focus', function (params) {
|
2034 |
+
if (params.data._resultId) {
|
2035 |
+
self.$search.attr('aria-activedescendant', params.data._resultId);
|
2036 |
+
} else {
|
2037 |
+
self.$search.removeAttr('aria-activedescendant');
|
2038 |
+
}
|
2039 |
});
|
2040 |
|
2041 |
this.$selection.on('focusin', '.select2-search--inline', function (evt) {
|
2060 |
.prev('.select2-selection__choice');
|
2061 |
|
2062 |
if ($previousChoice.length > 0) {
|
2063 |
+
var item = Utils.GetData($previousChoice[0], 'data');
|
2064 |
|
2065 |
self.searchRemoveChoice(item);
|
2066 |
|
2069 |
}
|
2070 |
});
|
2071 |
|
2072 |
+
this.$selection.on('click', '.select2-search--inline', function (evt) {
|
2073 |
+
if (self.$search.val()) {
|
2074 |
+
evt.stopPropagation();
|
2075 |
+
}
|
2076 |
+
});
|
2077 |
+
|
2078 |
// Try to detect the IE version should the `documentMode` property that
|
2079 |
// is stored on the document. This is only implemented in IE and is
|
2080 |
// slightly cleaner than doing a user agent check.
|
2160 |
|
2161 |
this.resizeSearch();
|
2162 |
if (searchHadFocus) {
|
2163 |
+
this.$search.trigger('focus');
|
2164 |
}
|
2165 |
};
|
2166 |
|
2193 |
var width = '';
|
2194 |
|
2195 |
if (this.$search.attr('placeholder') !== '') {
|
2196 |
+
width = this.$selection.find('.select2-selection__rendered').width();
|
2197 |
} else {
|
2198 |
var minimumWidth = this.$search.val().length + 1;
|
2199 |
|
2217 |
'open', 'opening',
|
2218 |
'close', 'closing',
|
2219 |
'select', 'selecting',
|
2220 |
+
'unselect', 'unselecting',
|
2221 |
+
'clear', 'clearing'
|
2222 |
];
|
2223 |
|
2224 |
+
var preventableEvents = [
|
2225 |
+
'opening', 'closing', 'selecting', 'unselecting', 'clearing'
|
2226 |
+
];
|
2227 |
|
2228 |
decorated.call(this, container, $container);
|
2229 |
|
2556 |
'\u019F': 'O',
|
2557 |
'\uA74A': 'O',
|
2558 |
'\uA74C': 'O',
|
2559 |
+
'\u0152': 'OE',
|
2560 |
'\u01A2': 'OI',
|
2561 |
'\uA74E': 'OO',
|
2562 |
'\u0222': 'OU',
|
2966 |
'\uA74B': 'o',
|
2967 |
'\uA74D': 'o',
|
2968 |
'\u0275': 'o',
|
2969 |
+
'\u0153': 'oe',
|
2970 |
'\u01A3': 'oi',
|
2971 |
'\u0223': 'ou',
|
2972 |
'\uA74F': 'oo',
|
3135 |
'\u03CD': '\u03C5',
|
3136 |
'\u03CB': '\u03C5',
|
3137 |
'\u03B0': '\u03C5',
|
3138 |
+
'\u03CE': '\u03C9',
|
3139 |
+
'\u03C2': '\u03C3',
|
3140 |
+
'\u2019': '\''
|
3141 |
};
|
3142 |
|
3143 |
return diacritics;
|
3222 |
if ($(data.element).is('option')) {
|
3223 |
data.element.selected = true;
|
3224 |
|
3225 |
+
this.$element.trigger('input').trigger('change');
|
3226 |
|
3227 |
return;
|
3228 |
}
|
3243 |
}
|
3244 |
|
3245 |
self.$element.val(val);
|
3246 |
+
self.$element.trigger('input').trigger('change');
|
3247 |
});
|
3248 |
} else {
|
3249 |
var val = data.id;
|
3250 |
|
3251 |
this.$element.val(val);
|
3252 |
+
this.$element.trigger('input').trigger('change');
|
3253 |
}
|
3254 |
};
|
3255 |
|
3265 |
if ($(data.element).is('option')) {
|
3266 |
data.element.selected = false;
|
3267 |
|
3268 |
+
this.$element.trigger('input').trigger('change');
|
3269 |
|
3270 |
return;
|
3271 |
}
|
3283 |
|
3284 |
self.$element.val(val);
|
3285 |
|
3286 |
+
self.$element.trigger('input').trigger('change');
|
3287 |
});
|
3288 |
};
|
3289 |
|
3305 |
// Remove anything added to child elements
|
3306 |
this.$element.find('*').each(function () {
|
3307 |
// Remove any custom data set by Select2
|
3308 |
+
Utils.RemoveData(this);
|
3309 |
});
|
3310 |
};
|
3311 |
|
3356 |
}
|
3357 |
}
|
3358 |
|
3359 |
+
if (data.id !== undefined) {
|
3360 |
option.value = data.id;
|
3361 |
}
|
3362 |
|
3378 |
normalizedData.element = option;
|
3379 |
|
3380 |
// Override the option's data with the combined data
|
3381 |
+
Utils.StoreData(option, 'data', normalizedData);
|
3382 |
|
3383 |
return $option;
|
3384 |
};
|
3386 |
SelectAdapter.prototype.item = function ($option) {
|
3387 |
var data = {};
|
3388 |
|
3389 |
+
data = Utils.GetData($option[0], 'data');
|
3390 |
|
3391 |
if (data != null) {
|
3392 |
return data;
|
3424 |
data = this._normalizeItem(data);
|
3425 |
data.element = $option[0];
|
3426 |
|
3427 |
+
Utils.StoreData($option[0], 'data', data);
|
3428 |
|
3429 |
return data;
|
3430 |
};
|
3431 |
|
3432 |
SelectAdapter.prototype._normalizeItem = function (item) {
|
3433 |
+
if (item !== Object(item)) {
|
3434 |
item = {
|
3435 |
id: item,
|
3436 |
text: item
|
3476 |
'jquery'
|
3477 |
], function (SelectAdapter, Utils, $) {
|
3478 |
function ArrayAdapter ($element, options) {
|
3479 |
+
this._dataToConvert = options.get('data') || [];
|
3480 |
|
3481 |
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
|
|
|
|
3482 |
}
|
3483 |
|
3484 |
Utils.Extend(ArrayAdapter, SelectAdapter);
|
3485 |
|
3486 |
+
ArrayAdapter.prototype.bind = function (container, $container) {
|
3487 |
+
ArrayAdapter.__super__.bind.call(this, container, $container);
|
3488 |
+
|
3489 |
+
this.addOptions(this.convertToOptions(this._dataToConvert));
|
3490 |
+
};
|
3491 |
+
|
3492 |
ArrayAdapter.prototype.select = function (data) {
|
3493 |
var $option = this.$element.find('option').filter(function (i, elm) {
|
3494 |
return elm.value == data.id.toString();
|
3638 |
}, function () {
|
3639 |
// Attempt to detect if a request was aborted
|
3640 |
// Only works if the transport exposes a status property
|
3641 |
+
if ('status' in $request &&
|
3642 |
+
($request.status === 0 || $request.status === '0')) {
|
3643 |
return;
|
3644 |
}
|
3645 |
|
3720 |
}, true)
|
3721 |
);
|
3722 |
|
3723 |
+
var optionText = (option.text || '').toUpperCase();
|
3724 |
+
var paramsTerm = (params.term || '').toUpperCase();
|
3725 |
+
|
3726 |
+
var checkText = optionText === paramsTerm;
|
3727 |
|
3728 |
if (checkText || checkChildren) {
|
3729 |
if (child) {
|
3778 |
};
|
3779 |
|
3780 |
Tags.prototype._removeOldTags = function (_) {
|
|
|
|
|
3781 |
var $options = this.$element.find('option[data-select2-tag]');
|
3782 |
|
3783 |
$options.each(function () {
|
3852 |
// Replace the search term if we have the search box
|
3853 |
if (this.$search.length) {
|
3854 |
this.$search.val(tokenData.term);
|
3855 |
+
this.$search.trigger('focus');
|
3856 |
}
|
3857 |
|
3858 |
params.term = tokenData.term;
|
3981 |
decorated.call(this, $e, options);
|
3982 |
}
|
3983 |
|
3984 |
+
MaximumSelectionLength.prototype.bind =
|
3985 |
+
function (decorated, container, $container) {
|
3986 |
+
var self = this;
|
3987 |
+
|
3988 |
+
decorated.call(this, container, $container);
|
3989 |
+
|
3990 |
+
container.on('select', function () {
|
3991 |
+
self._checkIfMaximumSelected();
|
3992 |
+
});
|
3993 |
+
};
|
3994 |
+
|
3995 |
MaximumSelectionLength.prototype.query =
|
3996 |
function (decorated, params, callback) {
|
3997 |
var self = this;
|
3998 |
|
3999 |
+
this._checkIfMaximumSelected(function () {
|
4000 |
+
decorated.call(self, params, callback);
|
4001 |
+
});
|
4002 |
+
};
|
4003 |
+
|
4004 |
+
MaximumSelectionLength.prototype._checkIfMaximumSelected =
|
4005 |
+
function (_, successCallback) {
|
4006 |
+
var self = this;
|
4007 |
+
|
4008 |
this.current(function (currentData) {
|
4009 |
var count = currentData != null ? currentData.length : 0;
|
4010 |
if (self.maximumSelectionLength > 0 &&
|
4017 |
});
|
4018 |
return;
|
4019 |
}
|
4020 |
+
|
4021 |
+
if (successCallback) {
|
4022 |
+
successCallback();
|
4023 |
+
}
|
4024 |
});
|
4025 |
};
|
4026 |
|
4059 |
};
|
4060 |
|
4061 |
Dropdown.prototype.position = function ($dropdown, $container) {
|
4062 |
+
// Should be implemented in subclasses
|
4063 |
};
|
4064 |
|
4065 |
Dropdown.prototype.destroy = function () {
|
4082 |
var $search = $(
|
4083 |
'<span class="select2-search select2-search--dropdown">' +
|
4084 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
4085 |
+
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
|
4086 |
+
' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
|
4087 |
'</span>'
|
4088 |
);
|
4089 |
|
4098 |
Search.prototype.bind = function (decorated, container, $container) {
|
4099 |
var self = this;
|
4100 |
|
4101 |
+
var resultsId = container.id + '-results';
|
4102 |
+
|
4103 |
decorated.call(this, container, $container);
|
4104 |
|
4105 |
this.$search.on('keydown', function (evt) {
|
4122 |
|
4123 |
container.on('open', function () {
|
4124 |
self.$search.attr('tabindex', 0);
|
4125 |
+
self.$search.attr('aria-controls', resultsId);
|
|
|
4126 |
|
4127 |
window.setTimeout(function () {
|
4128 |
+
self.$search.trigger('focus');
|
4129 |
}, 0);
|
4130 |
});
|
4131 |
|
4132 |
container.on('close', function () {
|
4133 |
self.$search.attr('tabindex', -1);
|
4134 |
+
self.$search.removeAttr('aria-controls');
|
4135 |
+
self.$search.removeAttr('aria-activedescendant');
|
4136 |
|
4137 |
self.$search.val('');
|
4138 |
+
self.$search.trigger('blur');
|
|
|
|
|
|
|
|
|
|
|
4139 |
});
|
4140 |
|
4141 |
container.on('results:all', function (params) {
|
4149 |
}
|
4150 |
}
|
4151 |
});
|
4152 |
+
|
4153 |
+
container.on('results:focus', function (params) {
|
4154 |
+
if (params.data._resultId) {
|
4155 |
+
self.$search.attr('aria-activedescendant', params.data._resultId);
|
4156 |
+
} else {
|
4157 |
+
self.$search.removeAttr('aria-activedescendant');
|
4158 |
+
}
|
4159 |
+
});
|
4160 |
};
|
4161 |
|
4162 |
Search.prototype.handleSearch = function (evt) {
|
4241 |
|
4242 |
if (this.showLoadingMore(data)) {
|
4243 |
this.$results.append(this.$loadingMore);
|
4244 |
+
this.loadMoreIfNeeded();
|
4245 |
}
|
4246 |
};
|
4247 |
|
4260 |
self.loading = true;
|
4261 |
});
|
4262 |
|
4263 |
+
this.$results.on('scroll', this.loadMoreIfNeeded.bind(this));
|
4264 |
+
};
|
|
|
|
|
|
|
4265 |
|
4266 |
+
InfiniteScroll.prototype.loadMoreIfNeeded = function () {
|
4267 |
+
var isLoadMoreVisible = $.contains(
|
4268 |
+
document.documentElement,
|
4269 |
+
this.$loadingMore[0]
|
4270 |
+
);
|
4271 |
|
4272 |
+
if (this.loading || !isLoadMoreVisible) {
|
4273 |
+
return;
|
4274 |
+
}
|
|
|
4275 |
|
4276 |
+
var currentOffset = this.$results.offset().top +
|
4277 |
+
this.$results.outerHeight(false);
|
4278 |
+
var loadingMoreOffset = this.$loadingMore.offset().top +
|
4279 |
+
this.$loadingMore.outerHeight(false);
|
4280 |
+
|
4281 |
+
if (currentOffset + 50 >= loadingMoreOffset) {
|
4282 |
+
this.loadMore();
|
4283 |
+
}
|
4284 |
};
|
4285 |
|
4286 |
InfiniteScroll.prototype.loadMore = function () {
|
4301 |
var $option = $(
|
4302 |
'<li ' +
|
4303 |
'class="select2-results__option select2-results__option--load-more"' +
|
4304 |
+
'role="option" aria-disabled="true"></li>'
|
4305 |
);
|
4306 |
|
4307 |
var message = this.options.get('translations').get('loadingMore');
|
4319 |
'../utils'
|
4320 |
], function ($, Utils) {
|
4321 |
function AttachBody (decorated, $element, options) {
|
4322 |
+
this.$dropdownParent = $(options.get('dropdownParent') || document.body);
|
4323 |
|
4324 |
decorated.call(this, $element, options);
|
4325 |
}
|
4327 |
AttachBody.prototype.bind = function (decorated, container, $container) {
|
4328 |
var self = this;
|
4329 |
|
|
|
|
|
4330 |
decorated.call(this, container, $container);
|
4331 |
|
4332 |
container.on('open', function () {
|
4333 |
self._showDropdown();
|
4334 |
self._attachPositioningHandler(container);
|
4335 |
|
4336 |
+
// Must bind after the results handlers to ensure correct sizing
|
4337 |
+
self._bindContainerResultHandlers(container);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4338 |
});
|
4339 |
|
4340 |
container.on('close', function () {
|
4383 |
this.$dropdownContainer.detach();
|
4384 |
};
|
4385 |
|
4386 |
+
AttachBody.prototype._bindContainerResultHandlers =
|
4387 |
+
function (decorated, container) {
|
4388 |
+
|
4389 |
+
// These should only be bound once
|
4390 |
+
if (this._containerResultsHandlersBound) {
|
4391 |
+
return;
|
4392 |
+
}
|
4393 |
+
|
4394 |
+
var self = this;
|
4395 |
+
|
4396 |
+
container.on('results:all', function () {
|
4397 |
+
self._positionDropdown();
|
4398 |
+
self._resizeDropdown();
|
4399 |
+
});
|
4400 |
+
|
4401 |
+
container.on('results:append', function () {
|
4402 |
+
self._positionDropdown();
|
4403 |
+
self._resizeDropdown();
|
4404 |
+
});
|
4405 |
+
|
4406 |
+
container.on('results:message', function () {
|
4407 |
+
self._positionDropdown();
|
4408 |
+
self._resizeDropdown();
|
4409 |
+
});
|
4410 |
+
|
4411 |
+
container.on('select', function () {
|
4412 |
+
self._positionDropdown();
|
4413 |
+
self._resizeDropdown();
|
4414 |
+
});
|
4415 |
+
|
4416 |
+
container.on('unselect', function () {
|
4417 |
+
self._positionDropdown();
|
4418 |
+
self._resizeDropdown();
|
4419 |
+
});
|
4420 |
+
|
4421 |
+
this._containerResultsHandlersBound = true;
|
4422 |
+
};
|
4423 |
+
|
4424 |
AttachBody.prototype._attachPositioningHandler =
|
4425 |
function (decorated, container) {
|
4426 |
var self = this;
|
4431 |
|
4432 |
var $watchers = this.$container.parents().filter(Utils.hasScroll);
|
4433 |
$watchers.each(function () {
|
4434 |
+
Utils.StoreData(this, 'select2-scroll-position', {
|
4435 |
x: $(this).scrollLeft(),
|
4436 |
y: $(this).scrollTop()
|
4437 |
});
|
4438 |
});
|
4439 |
|
4440 |
$watchers.on(scrollEvent, function (ev) {
|
4441 |
+
var position = Utils.GetData(this, 'select2-scroll-position');
|
4442 |
$(this).scrollTop(position.y);
|
4443 |
});
|
4444 |
|
4497 |
top: container.bottom
|
4498 |
};
|
4499 |
|
4500 |
+
// Determine what the parent element is to use for calculating the offset
|
4501 |
var $offsetParent = this.$dropdownParent;
|
4502 |
|
4503 |
+
// For statically positioned elements, we need to get the element
|
4504 |
// that is determining the offset
|
4505 |
if ($offsetParent.css('position') === 'static') {
|
4506 |
$offsetParent = $offsetParent.offsetParent();
|
4507 |
}
|
4508 |
|
4509 |
+
var parentOffset = {
|
4510 |
+
top: 0,
|
4511 |
+
left: 0
|
4512 |
+
};
|
4513 |
+
|
4514 |
+
if (
|
4515 |
+
$.contains(document.body, $offsetParent[0]) ||
|
4516 |
+
$offsetParent[0].isConnected
|
4517 |
+
) {
|
4518 |
+
parentOffset = $offsetParent.offset();
|
4519 |
+
}
|
4520 |
|
4521 |
css.top -= parentOffset.top;
|
4522 |
css.left -= parentOffset.left;
|
4613 |
});
|
4614 |
|
4615 |
S2.define('select2/dropdown/selectOnClose',[
|
4616 |
+
'../utils'
|
4617 |
+
], function (Utils) {
|
4618 |
function SelectOnClose () { }
|
4619 |
|
4620 |
SelectOnClose.prototype.bind = function (decorated, container, $container) {
|
4645 |
return;
|
4646 |
}
|
4647 |
|
4648 |
+
var data = Utils.GetData($highlightedResults[0], 'data');
|
4649 |
|
4650 |
// Don't re-select already selected resulte
|
4651 |
if (
|
4686 |
var originalEvent = evt.originalEvent;
|
4687 |
|
4688 |
// Don't close if the control key is being held
|
4689 |
+
if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) {
|
4690 |
return;
|
4691 |
}
|
4692 |
|
4740 |
},
|
4741 |
searching: function () {
|
4742 |
return 'Searching…';
|
4743 |
+
},
|
4744 |
+
removeAllItems: function () {
|
4745 |
+
return 'Remove all items';
|
4746 |
}
|
4747 |
};
|
4748 |
});
|
4981 |
);
|
4982 |
}
|
4983 |
|
4984 |
+
// If the defaults were not previously applied from an element, it is
|
4985 |
+
// possible for the language option to have not been resolved
|
4986 |
+
options.language = this._resolveLanguage(options.language);
|
|
|
|
|
|
|
4987 |
|
4988 |
+
// Always fall back to English since it will always be complete
|
4989 |
+
options.language.push('en');
|
|
|
|
|
|
|
4990 |
|
4991 |
+
var uniqueLanguages = [];
|
|
|
|
|
4992 |
|
4993 |
+
for (var l = 0; l < options.language.length; l++) {
|
4994 |
+
var language = options.language[l];
|
4995 |
|
4996 |
+
if (uniqueLanguages.indexOf(language) === -1) {
|
4997 |
+
uniqueLanguages.push(language);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4998 |
}
|
4999 |
+
}
|
5000 |
|
5001 |
+
options.language = uniqueLanguages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5002 |
|
5003 |
+
options.translations = this._processTranslations(
|
5004 |
+
options.language,
|
5005 |
+
options.debug
|
5006 |
+
);
|
5007 |
|
5008 |
return options;
|
5009 |
};
|
5070 |
debug: false,
|
5071 |
dropdownAutoWidth: false,
|
5072 |
escapeMarkup: Utils.escapeMarkup,
|
5073 |
+
language: {},
|
5074 |
matcher: matcher,
|
5075 |
minimumInputLength: 0,
|
5076 |
maximumInputLength: 0,
|
5077 |
maximumSelectionLength: 0,
|
5078 |
minimumResultsForSearch: 0,
|
5079 |
selectOnClose: false,
|
5080 |
+
scrollAfterSelect: false,
|
5081 |
sorter: function (data) {
|
5082 |
return data;
|
5083 |
},
|
5092 |
};
|
5093 |
};
|
5094 |
|
5095 |
+
Defaults.prototype.applyFromElement = function (options, $element) {
|
5096 |
+
var optionLanguage = options.language;
|
5097 |
+
var defaultLanguage = this.defaults.language;
|
5098 |
+
var elementLanguage = $element.prop('lang');
|
5099 |
+
var parentLanguage = $element.closest('[lang]').prop('lang');
|
5100 |
+
|
5101 |
+
var languages = Array.prototype.concat.call(
|
5102 |
+
this._resolveLanguage(elementLanguage),
|
5103 |
+
this._resolveLanguage(optionLanguage),
|
5104 |
+
this._resolveLanguage(defaultLanguage),
|
5105 |
+
this._resolveLanguage(parentLanguage)
|
5106 |
+
);
|
5107 |
+
|
5108 |
+
options.language = languages;
|
5109 |
+
|
5110 |
+
return options;
|
5111 |
+
};
|
5112 |
+
|
5113 |
+
Defaults.prototype._resolveLanguage = function (language) {
|
5114 |
+
if (!language) {
|
5115 |
+
return [];
|
5116 |
+
}
|
5117 |
+
|
5118 |
+
if ($.isEmptyObject(language)) {
|
5119 |
+
return [];
|
5120 |
+
}
|
5121 |
+
|
5122 |
+
if ($.isPlainObject(language)) {
|
5123 |
+
return [language];
|
5124 |
+
}
|
5125 |
+
|
5126 |
+
var languages;
|
5127 |
+
|
5128 |
+
if (!$.isArray(language)) {
|
5129 |
+
languages = [language];
|
5130 |
+
} else {
|
5131 |
+
languages = language;
|
5132 |
+
}
|
5133 |
+
|
5134 |
+
var resolvedLanguages = [];
|
5135 |
+
|
5136 |
+
for (var l = 0; l < languages.length; l++) {
|
5137 |
+
resolvedLanguages.push(languages[l]);
|
5138 |
+
|
5139 |
+
if (typeof languages[l] === 'string' && languages[l].indexOf('-') > 0) {
|
5140 |
+
// Extract the region information if it is included
|
5141 |
+
var languageParts = languages[l].split('-');
|
5142 |
+
var baseLanguage = languageParts[0];
|
5143 |
+
|
5144 |
+
resolvedLanguages.push(baseLanguage);
|
5145 |
+
}
|
5146 |
+
}
|
5147 |
+
|
5148 |
+
return resolvedLanguages;
|
5149 |
+
};
|
5150 |
+
|
5151 |
+
Defaults.prototype._processTranslations = function (languages, debug) {
|
5152 |
+
var translations = new Translation();
|
5153 |
+
|
5154 |
+
for (var l = 0; l < languages.length; l++) {
|
5155 |
+
var languageData = new Translation();
|
5156 |
+
|
5157 |
+
var language = languages[l];
|
5158 |
+
|
5159 |
+
if (typeof language === 'string') {
|
5160 |
+
try {
|
5161 |
+
// Try to load it with the original name
|
5162 |
+
languageData = Translation.loadPath(language);
|
5163 |
+
} catch (e) {
|
5164 |
+
try {
|
5165 |
+
// If we couldn't load it, check if it wasn't the full path
|
5166 |
+
language = this.defaults.amdLanguageBase + language;
|
5167 |
+
languageData = Translation.loadPath(language);
|
5168 |
+
} catch (ex) {
|
5169 |
+
// The translation could not be loaded at all. Sometimes this is
|
5170 |
+
// because of a configuration problem, other times this can be
|
5171 |
+
// because of how Select2 helps load all possible translation files
|
5172 |
+
if (debug && window.console && console.warn) {
|
5173 |
+
console.warn(
|
5174 |
+
'Select2: The language file for "' + language + '" could ' +
|
5175 |
+
'not be automatically loaded. A fallback will be used instead.'
|
5176 |
+
);
|
5177 |
+
}
|
5178 |
+
}
|
5179 |
+
}
|
5180 |
+
} else if ($.isPlainObject(language)) {
|
5181 |
+
languageData = new Translation(language);
|
5182 |
+
} else {
|
5183 |
+
languageData = language;
|
5184 |
+
}
|
5185 |
+
|
5186 |
+
translations.extend(languageData);
|
5187 |
+
}
|
5188 |
+
|
5189 |
+
return translations;
|
5190 |
+
};
|
5191 |
+
|
5192 |
Defaults.prototype.set = function (key, value) {
|
5193 |
var camelKey = $.camelCase(key);
|
5194 |
|
5197 |
|
5198 |
var convertedData = Utils._convertData(data);
|
5199 |
|
5200 |
+
$.extend(true, this.defaults, convertedData);
|
5201 |
};
|
5202 |
|
5203 |
var defaults = new Defaults();
|
5218 |
this.fromElement($element);
|
5219 |
}
|
5220 |
|
5221 |
+
if ($element != null) {
|
5222 |
+
this.options = Defaults.applyFromElement(this.options, $element);
|
5223 |
+
}
|
5224 |
+
|
5225 |
this.options = Defaults.apply(this.options);
|
5226 |
|
5227 |
if ($element && $element.is('input')) {
|
5245 |
this.options.disabled = $e.prop('disabled');
|
5246 |
}
|
5247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5248 |
if (this.options.dir == null) {
|
5249 |
if ($e.prop('dir')) {
|
5250 |
this.options.dir = $e.prop('dir');
|
5258 |
$e.prop('disabled', this.options.disabled);
|
5259 |
$e.prop('multiple', this.options.multiple);
|
5260 |
|
5261 |
+
if (Utils.GetData($e[0], 'select2Tags')) {
|
5262 |
if (this.options.debug && window.console && console.warn) {
|
5263 |
console.warn(
|
5264 |
'Select2: The `data-select2-tags` attribute has been changed to ' +
|
5267 |
);
|
5268 |
}
|
5269 |
|
5270 |
+
Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags'));
|
5271 |
+
Utils.StoreData($e[0], 'tags', true);
|
5272 |
}
|
5273 |
|
5274 |
+
if (Utils.GetData($e[0], 'ajaxUrl')) {
|
5275 |
if (this.options.debug && window.console && console.warn) {
|
5276 |
console.warn(
|
5277 |
'Select2: The `data-ajax-url` attribute has been changed to ' +
|
5280 |
);
|
5281 |
}
|
5282 |
|
5283 |
+
$e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl'));
|
5284 |
+
Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl'));
|
5285 |
}
|
5286 |
|
5287 |
var dataset = {};
|
5288 |
|
5289 |
+
function upperCaseLetter(_, letter) {
|
5290 |
+
return letter.toUpperCase();
|
5291 |
+
}
|
5292 |
+
|
5293 |
+
// Pre-load all of the attributes which are prefixed with `data-`
|
5294 |
+
for (var attr = 0; attr < $e[0].attributes.length; attr++) {
|
5295 |
+
var attributeName = $e[0].attributes[attr].name;
|
5296 |
+
var prefix = 'data-';
|
5297 |
+
|
5298 |
+
if (attributeName.substr(0, prefix.length) == prefix) {
|
5299 |
+
// Get the contents of the attribute after `data-`
|
5300 |
+
var dataName = attributeName.substring(prefix.length);
|
5301 |
+
|
5302 |
+
// Get the data contents from the consistent source
|
5303 |
+
// This is more than likely the jQuery data helper
|
5304 |
+
var dataValue = Utils.GetData($e[0], dataName);
|
5305 |
+
|
5306 |
+
// camelCase the attribute name to match the spec
|
5307 |
+
var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter);
|
5308 |
+
|
5309 |
+
// Store the data attribute contents into the dataset since
|
5310 |
+
dataset[camelDataName] = dataValue;
|
5311 |
+
}
|
5312 |
+
}
|
5313 |
+
|
5314 |
// Prefer the element's `dataset` attribute if it exists
|
5315 |
// jQuery 1.x does not correctly handle data attributes with multiple dashes
|
5316 |
if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
|
5317 |
+
dataset = $.extend(true, {}, $e[0].dataset, dataset);
|
|
|
|
|
5318 |
}
|
5319 |
|
5320 |
+
// Prefer our internal data cache if it exists
|
5321 |
+
var data = $.extend(true, {}, Utils.GetData($e[0]), dataset);
|
5322 |
|
5323 |
data = Utils._convertData(data);
|
5324 |
|
5355 |
'./keys'
|
5356 |
], function ($, Options, Utils, KEYS) {
|
5357 |
var Select2 = function ($element, options) {
|
5358 |
+
if (Utils.GetData($element[0], 'select2') != null) {
|
5359 |
+
Utils.GetData($element[0], 'select2').destroy();
|
5360 |
}
|
5361 |
|
5362 |
this.$element = $element;
|
5372 |
// Set up the tabindex
|
5373 |
|
5374 |
var tabindex = $element.attr('tabindex') || 0;
|
5375 |
+
Utils.StoreData($element[0], 'old-tabindex', tabindex);
|
5376 |
$element.attr('tabindex', '-1');
|
5377 |
|
5378 |
// Set up containers and adapters
|
5433 |
// Synchronize any monitored attributes
|
5434 |
this._syncAttributes();
|
5435 |
|
5436 |
+
Utils.StoreData($element[0], 'select2', this);
|
5437 |
+
|
5438 |
+
// Ensure backwards compatibility with $element.data('select2').
|
5439 |
$element.data('select2', this);
|
5440 |
};
|
5441 |
|
5512 |
return null;
|
5513 |
}
|
5514 |
|
5515 |
+
if (method == 'computedstyle') {
|
5516 |
+
var computedStyle = window.getComputedStyle($element[0]);
|
5517 |
+
|
5518 |
+
return computedStyle.width;
|
5519 |
+
}
|
5520 |
+
|
5521 |
return method;
|
5522 |
};
|
5523 |
|
5558 |
|
5559 |
if (observer != null) {
|
5560 |
this._observer = new observer(function (mutations) {
|
5561 |
+
self._syncA();
|
5562 |
+
self._syncS(null, mutations);
|
5563 |
});
|
5564 |
this._observer.observe(this.$element[0], {
|
5565 |
attributes: true,
|
5681 |
if (self.isOpen()) {
|
5682 |
if (key === KEYS.ESC || key === KEYS.TAB ||
|
5683 |
(key === KEYS.UP && evt.altKey)) {
|
5684 |
+
self.close(evt);
|
5685 |
|
5686 |
evt.preventDefault();
|
5687 |
} else if (key === KEYS.ENTER) {
|
5715 |
Select2.prototype._syncAttributes = function () {
|
5716 |
this.options.set('disabled', this.$element.prop('disabled'));
|
5717 |
|
5718 |
+
if (this.isDisabled()) {
|
5719 |
if (this.isOpen()) {
|
5720 |
this.close();
|
5721 |
}
|
5726 |
}
|
5727 |
};
|
5728 |
|
5729 |
+
Select2.prototype._isChangeMutation = function (evt, mutations) {
|
5730 |
var changed = false;
|
5731 |
var self = this;
|
5732 |
|
5754 |
}
|
5755 |
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
|
5756 |
changed = true;
|
5757 |
+
} else if ($.isArray(mutations)) {
|
5758 |
+
$.each(mutations, function(evt, mutation) {
|
5759 |
+
if (self._isChangeMutation(evt, mutation)) {
|
5760 |
+
// We've found a change mutation.
|
5761 |
+
// Let's escape from the loop and continue
|
5762 |
+
changed = true;
|
5763 |
+
return false;
|
5764 |
+
}
|
5765 |
+
});
|
5766 |
}
|
5767 |
+
return changed;
|
5768 |
+
};
|
5769 |
+
|
5770 |
+
Select2.prototype._syncSubtree = function (evt, mutations) {
|
5771 |
+
var changed = this._isChangeMutation(evt, mutations);
|
5772 |
+
var self = this;
|
5773 |
|
5774 |
// Only re-pull the data if we think there is a change
|
5775 |
if (changed) {
|
5791 |
'open': 'opening',
|
5792 |
'close': 'closing',
|
5793 |
'select': 'selecting',
|
5794 |
+
'unselect': 'unselecting',
|
5795 |
+
'clear': 'clearing'
|
5796 |
};
|
5797 |
|
5798 |
if (args === undefined) {
|
5820 |
};
|
5821 |
|
5822 |
Select2.prototype.toggleDropdown = function () {
|
5823 |
+
if (this.isDisabled()) {
|
5824 |
return;
|
5825 |
}
|
5826 |
|
5836 |
return;
|
5837 |
}
|
5838 |
|
5839 |
+
if (this.isDisabled()) {
|
5840 |
+
return;
|
5841 |
+
}
|
5842 |
+
|
5843 |
this.trigger('query', {});
|
5844 |
};
|
5845 |
|
5846 |
+
Select2.prototype.close = function (evt) {
|
5847 |
if (!this.isOpen()) {
|
5848 |
return;
|
5849 |
}
|
5850 |
|
5851 |
+
this.trigger('close', { originalEvent : evt });
|
5852 |
+
};
|
5853 |
+
|
5854 |
+
/**
|
5855 |
+
* Helper method to abstract the "enabled" (not "disabled") state of this
|
5856 |
+
* object.
|
5857 |
+
*
|
5858 |
+
* @return {true} if the instance is not disabled.
|
5859 |
+
* @return {false} if the instance is disabled.
|
5860 |
+
*/
|
5861 |
+
Select2.prototype.isEnabled = function () {
|
5862 |
+
return !this.isDisabled();
|
5863 |
+
};
|
5864 |
+
|
5865 |
+
/**
|
5866 |
+
* Helper method to abstract the "disabled" state of this object.
|
5867 |
+
*
|
5868 |
+
* @return {true} if the disabled option is true.
|
5869 |
+
* @return {false} if the disabled option is false.
|
5870 |
+
*/
|
5871 |
+
Select2.prototype.isDisabled = function () {
|
5872 |
+
return this.options.get('disabled');
|
5873 |
};
|
5874 |
|
5875 |
Select2.prototype.isOpen = function () {
|
5946 |
});
|
5947 |
}
|
5948 |
|
5949 |
+
this.$element.val(newVal).trigger('input').trigger('change');
|
5950 |
};
|
5951 |
|
5952 |
Select2.prototype.destroy = function () {
|
5972 |
this._syncS = null;
|
5973 |
|
5974 |
this.$element.off('.select2');
|
5975 |
+
this.$element.attr('tabindex',
|
5976 |
+
Utils.GetData(this.$element[0], 'old-tabindex'));
|
5977 |
|
5978 |
this.$element.removeClass('select2-hidden-accessible');
|
5979 |
this.$element.attr('aria-hidden', 'false');
|
5980 |
+
Utils.RemoveData(this.$element[0]);
|
5981 |
this.$element.removeData('select2');
|
5982 |
|
5983 |
this.dataAdapter.destroy();
|
6005 |
|
6006 |
this.$container.addClass('select2-container--' + this.options.get('theme'));
|
6007 |
|
6008 |
+
Utils.StoreData($container[0], 'element', this.$element);
|
6009 |
|
6010 |
return $container;
|
6011 |
};
|
6215 |
});
|
6216 |
|
6217 |
S2.define('select2/compat/inputData',[
|
6218 |
+
'jquery',
|
6219 |
+
'../utils'
|
6220 |
+
], function ($, Utils) {
|
6221 |
function InputData (decorated, $element, options) {
|
6222 |
this._currentData = [];
|
6223 |
this._valueSeparator = options.get('valueSeparator') || ',';
|
6281 |
});
|
6282 |
|
6283 |
this.$element.val(data.id);
|
6284 |
+
this.$element.trigger('input').trigger('change');
|
6285 |
} else {
|
6286 |
var value = this.$element.val();
|
6287 |
value += this._valueSeparator + data.id;
|
6288 |
|
6289 |
this.$element.val(value);
|
6290 |
+
this.$element.trigger('input').trigger('change');
|
6291 |
}
|
6292 |
};
|
6293 |
|
6310 |
}
|
6311 |
|
6312 |
self.$element.val(values.join(self._valueSeparator));
|
6313 |
+
self.$element.trigger('input').trigger('change');
|
6314 |
});
|
6315 |
};
|
6316 |
|
6334 |
|
6335 |
InputData.prototype.addOptions = function (_, $options) {
|
6336 |
var options = $.map($options, function ($option) {
|
6337 |
+
return Utils.GetData($option[0], 'data');
|
6338 |
});
|
6339 |
|
6340 |
this._currentData.push.apply(this._currentData, options);
|
6737 |
'jquery-mousewheel',
|
6738 |
|
6739 |
'./select2/core',
|
6740 |
+
'./select2/defaults',
|
6741 |
+
'./select2/utils'
|
6742 |
+
], function ($, _, Select2, Defaults, Utils) {
|
6743 |
if ($.fn.select2 == null) {
|
6744 |
// All methods that should return the element
|
6745 |
var thisMethods = ['open', 'close', 'destroy'];
|
6760 |
var args = Array.prototype.slice.call(arguments, 1);
|
6761 |
|
6762 |
this.each(function () {
|
6763 |
+
var instance = Utils.GetData(this, 'select2');
|
6764 |
|
6765 |
if (instance == null && window.console && console.error) {
|
6766 |
console.error(
|
assets/inc/select2/4/select2.full.min.js
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n<c.length;n+=1)if(m=o(c[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=d?d.apply(q[a],u):void 0,a&&(h&&h.exports!==b&&h.exports!==q[a]?q[a]=h.exports:l===b&&s||(q[a]=l))}else a&&(q[a]=d)},a=c=n=function(a,c,d,e,f){if("string"==typeof a)return p[a]?p[a](c):j(o(a,c).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?m(b,a,c,d):setTimeout(function(){m(b,a,c,d)},4),n},n.config=function(a){return n(a)},a._defined=q,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){var e=b[d];"function"==typeof e&&"constructor"!==d&&c.push(d)}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){var a=Array.prototype.unshift;return a.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};return d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]._type=a,a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},d.prototype.invoke=function(a,b){for(var c=0,d=a.length;d>c;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e<c.length;e++){var f=c[e];f=f.substring(0,1).toLowerCase()+f.substring(1),f in d||(d[f]={}),e==c.length-1&&(d[f]=a[b]),d=d[f]}delete a[b]}}return a},c.hasScroll=function(b,c){var d=a(c),e=c.style.overflowX,f=c.style.overflowY;return e!==f||"hidden"!==f&&"visible"!==f?"scroll"===e||"scroll"===f?!0:d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth:!1},c.escapeMarkup=function(a){var b={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('<li role="treeitem" aria-live="assertive" class="select2-results__option"></li>'),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c<a.results.length;c++){var d=a.results[c],e=this.option(d);b.push(e)}this.$results.append(b)},c.prototype.position=function(a,b){var c=b.find(".select2-results");c.append(a)},c.prototype.sort=function(a){var b=this.options.get("sorter");return b(a)},c.prototype.highlightFirstItem=function(){var a=this.$results.find(".select2-results__option[aria-selected]"),b=a.filter("[aria-selected=true]");b.length>0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j<b.children.length;j++){var k=b.children[j],l=this.option(k);i.push(l)}var m=a("<ul></ul>",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("<span></span>")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('<ul class="select2-selection__rendered"></ul>'),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">×</span></li>');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d<a.length;d++){var e=a[d],f=this.selectionContainer(),g=this.display(e,f);f.append(g),f.prop("title",e.title||e.text),f.data("data",e),b.push(f)}var h=this.$selection.find(".select2-selection__rendered");c.appendMany(h,b)}},d}),b.define("select2/selection/placeholder",["../utils"],function(a){function b(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return b.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},b.prototype.createPlaceholder=function(a,b){var c=this.selectionContainer();return c.html(this.display(b)),c.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),c},b.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id,d=b.length>1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e<d.length;e++){var f={data:d[e]};if(this.trigger("unselect",f),f.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},c.prototype._handleKeyboardClear=function(a,c,d){d.isOpen()||(c.which==b.DELETE||c.which==b.BACKSPACE)&&this._handleClear(c)},c.prototype.update=function(b,c){if(b.call(this,c),!(this.$selection.find(".select2-selection__placeholder").length>0||0===c.length)){var d=a('<span class="select2-selection__clear">×</span>');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");
|
2 |
-
if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f<a.length;f++){var g=a[f].id;-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;if(this.$element.prop("multiple"))return a.selected=!1,c(a.element).is("option")?(a.element.selected=!1,void this.$element.trigger("change")):void this.current(function(d){for(var e=[],f=0;f<d.length;f++){var g=d[f].id;g!==a.id&&-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")})},d.prototype.bind=function(a,b){var c=this;this.container=a,a.on("select",function(a){c.select(a.data)}),a.on("unselect",function(a){c.unselect(a.data)})},d.prototype.destroy=function(){this.$element.find("*").each(function(){c.removeData(this,"data")})},d.prototype.query=function(a,b){var d=[],e=this,f=this.$element.children();f.each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b({results:d})},d.prototype.addOptions=function(a){b.appendMany(this.$element,a)},d.prototype.option=function(a){var b;a.children?(b=document.createElement("optgroup"),b.label=a.text):(b=document.createElement("option"),void 0!==b.textContent?b.textContent=a.text:b.innerText=a.text),a.id&&(b.value=a.id),a.disabled&&(b.disabled=!0),a.selected&&(b.selected=!0),a.title&&(b.title=a.title);var d=c(b),e=this._normalizeItem(a);return e.element=b,c.data(b,"data",e),d},d.prototype.item=function(a){var b={};if(b=c.data(a[0],"data"),null!=b)return b;if(a.is("option"))b={id:a.val(),text:a.text(),disabled:a.prop("disabled"),selected:a.prop("selected"),title:a.prop("title")};else if(a.is("optgroup")){b={text:a.prop("label"),children:[],title:a.prop("title")};for(var d=a.children("option"),e=[],f=0;f<d.length;f++){var g=c(d[f]),h=this.item(g);e.push(h)}b.children=e}return b=this._normalizeItem(b),b.element=a[0],c.data(a[0],"data",b),b},d.prototype._normalizeItem=function(a){c.isPlainObject(a)||(a={id:a,text:a}),a=c.extend({},{text:""},a);var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){var c=this.options.get("matcher");return c(a,b)},d}),b.define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data")||[];d.__super__.constructor.call(this,a,b),this.addOptions(this.convertToOptions(c))}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find("option").filter(function(b,c){return c.value==a.id.toString()});0===b.length&&(b=this.option(a),this.addOptions(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function d(a){return function(){return c(this).val()==a.id}}for(var e=this,f=this.$element.find("option"),g=f.map(function(){return e.item(c(this)).id}).get(),h=[],i=0;i<a.length;i++){var j=this._normalizeItem(a[i]);if(c.inArray(j.id,g)>=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h<e.length;h++){var i=e[h],j=this._normalizeItem(i),k=this.option(j);this.$element.append(k)}}return b.prototype.query=function(a,b,c){function d(a,f){for(var g=a.results,h=0;h<g.length;h++){var i=g[h],j=null!=i.children&&!d({results:i.children},!0),k=i.text===b.term;if(k||j)return f?!1:(a.data=g,void c(a))}if(f)return!0;var l=e.createTag(b);if(null!=l){var m=e.option(l);m.attr("data-select2-tag",!0),e.addOptions([m]),e.insertTag(g,l)}a.results=g,c(a)}var e=this;return this._removeOldTags(),null==b.term||null!=b.page?void a.call(this,b,c):void a.call(this,b,d)},b.prototype.createTag=function(b,c){var d=a.trim(c.term);return""===d?null:{id:d,text:d}},b.prototype.insertTag=function(a,b,c){b.unshift(c)},b.prototype._removeOldTags=function(b){var c=(this._lastTag,this.$element.find("option[data-select2-tag]"));c.each(function(){this.selected||a(this).remove()})},b}),b.define("select2/data/tokenizer",["jquery"],function(a){function b(a,b,c){var d=c.get("tokenizer");void 0!==d&&(this.tokenizer=d),a.call(this,b,c)}return b.prototype.bind=function(a,b,c){a.call(this,b,c),this.$search=b.dropdown.$search||b.selection.$search||c.find(".select2-search__field")},b.prototype.query=function(b,c,d){function e(b){var c=g._normalizeItem(b),d=g.$element.find("option").filter(function(){return a(this).val()===c.id});if(!d.length){var e=g.option(c);e.attr("data-select2-tag",!0),g._removeOldTags(),g.addOptions([e])}f(c)}function f(a){g.trigger("select",{data:a})}var g=this;c.term=c.term||"";var h=this.tokenizer(c,this.options,e);h.term!==c.term&&(this.$search.length&&(this.$search.val(h.term),this.$search.focus()),c.term=h.term),b.call(this,c,d)},b.prototype.tokenizer=function(b,c,d,e){for(var f=d.get("tokenSeparators")||[],g=c.term,h=0,i=this.createTag||function(a){return{id:a.term,text:a.term}};h<g.length;){var j=g[h];if(-1!==a.inArray(j,f)){var k=g.substr(0,h),l=a.extend({},c,{term:k}),m=i(l);null!=m?(e(m),g=g.substr(h+1)||"",h=0):h++}else h++}return{term:g}},b}),b.define("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",b.term.length<this.minimumInputLength?void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumInputLength",[],function(){function a(a,b,c){this.maximumInputLength=c.get("maximumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",this.maximumInputLength>0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<span class="select2-dropdown"><span class="select2-results"></span></span>');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('<li class="select2-results__option select2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a("<span></span>"),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.top<f.top-h.height,k=i.bottom>f.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d<b.length;d++){var e=b[d];e.children?c+=a(e.children):c++}return c}function b(a,b,c,d){this.minimumResultsForSearch=c.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),a.call(this,b,c,d)}return b.prototype.showSearch=function(b,c){return a(c.data.results)<this.minimumResultsForSearch?!1:b.call(this,c)},b}),b.define("select2/dropdown/selectOnClose",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("close",function(a){d._handleSelectOnClose(a)})},a.prototype._handleSelectOnClose=function(a,b){if(b&&null!=b.originalSelect2Event){var c=b.originalSelect2Event;if("select"===c._type||"unselect"===c._type)return}var d=this.getHighlightedResults();if(!(d.length<1)){var e=d.data("data");null!=e.element&&e.element.selected||null==e.element&&e.selected||this.trigger("select",{data:e})}},a}),b.define("select2/dropdown/closeOnSelect",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("select",function(a){d._selectTriggered(a)}),b.on("unselect",function(a){d._selectTriggered(a)})},a.prototype._selectTriggered=function(a,b){var c=b.originalEvent;c&&c.ctrlKey||this.trigger("close",{originalEvent:c,originalSelect2Event:b})},a}),b.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(a){var b=a.input.length-a.maximum,c="Please delete "+b+" character";return 1!=b&&(c+="s"),c},inputTooShort:function(a){var b=a.minimum-a.input.length,c="Please enter "+b+" or more characters";return c},loadingMore:function(){return"Loading more results…"},maximumSelected:function(a){var b="You can only select "+a.maximum+" item";return 1!=a.maximum&&(b+="s"),b},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),b.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C){function D(){this.reset()}D.prototype.apply=function(l){if(l=a.extend(!0,{},this.defaults,l),null==l.dataAdapter){if(null!=l.ajax?l.dataAdapter=o:null!=l.data?l.dataAdapter=n:l.dataAdapter=m,l.minimumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L<K.length;L++){var M=K[L],N={};try{N=k.loadPath(M)}catch(O){try{M=this.defaults.amdLanguageBase+M,N=k.loadPath(M)}catch(P){l.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+M+'" could not be automatically loaded. A fallback will be used instead.');continue}}J.extend(N)}l.translations=J}else{var Q=k.loadPath(this.defaults.amdLanguageBase+"en"),R=new k(l.language);R.extend(Q),l.translations=R}return l},D.prototype.reset=function(){function b(a){function b(a){return l[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function c(d,e){if(""===a.trim(d.term))return e;if(e.children&&e.children.length>0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e<b.addedNodes.length;e++){var f=b.addedNodes[e];f.selected&&(c=!0)}else b.removedNodes&&b.removedNodes.length>0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null;
|
3 |
-
},e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("select2/compat/utils",["jquery"],function(a){function b(b,c,d){var e,f,g=[];e=a.trim(b.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0===this.indexOf("select2-")&&g.push(this)})),e=a.trim(c.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&(f=d(this),null!=f&&g.push(f))})),b.attr("class",g.join(" "))}return{syncCssClasses:b}}),b.define("select2/compat/containerCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("containerCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptContainerCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("containerCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/dropdownCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("dropdownCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptDropdownCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("dropdownCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/initSelection",["jquery"],function(a){function b(a,b,c){c.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=c.get("initSelection"),this._isInitialized=!1,a.call(this,b,c)}return b.prototype.current=function(b,c){var d=this;return this._isInitialized?void b.call(this,c):void this.initSelection.call(null,this.$element,function(b){d._isInitialized=!0,a.isArray(b)||(b=[b]),c(b)})},b}),b.define("select2/compat/inputData",["jquery"],function(a){function b(a,b,c){this._currentData=[],this._valueSeparator=c.get("valueSeparator")||",","hidden"===b.prop("type")&&c.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `<select>` element instead."),a.call(this,b,c)}return b.prototype.current=function(b,c){function d(b,c){var e=[];return b.selected||-1!==a.inArray(b.id,c)?(b.selected=!0,e.push(b)):b.selected=!1,b.children&&e.push.apply(e,d(b.children,c)),e}for(var e=[],f=0;f<this._currentData.length;f++){var g=this._currentData[f];e.push.apply(e,d(g,this.$element.val().split(this._valueSeparator)))}c(e)},b.prototype.select=function(b,c){if(this.options.get("multiple")){var d=this.$element.val();d+=this._valueSeparator+c.id,this.$element.val(d),this.$element.trigger("change")}else this.current(function(b){a.map(b,function(a){a.selected=!1})}),this.$element.val(c.id),this.$element.trigger("change")},b.prototype.unselect=function(a,b){var c=this;b.selected=!1,this.current(function(a){for(var d=[],e=0;e<a.length;e++){var f=a[e];b.id!=f.id&&d.push(f.id)}c.$element.val(d.join(c._valueSeparator)),c.$element.trigger("change")})},b.prototype.query=function(a,b,c){for(var d=[],e=0;e<this._currentData.length;e++){var f=this._currentData[e],g=this.matches(b,f);null!==g&&d.push(g)}c({results:d})},b.prototype.addOptions=function(b,c){var d=a.map(c,function(b){return a.data(b[0],"data")});this._currentData.push.apply(this._currentData,d)},b}),b.define("select2/compat/matcher",["jquery"],function(a){function b(b){function c(c,d){var e=a.extend(!0,{},d);if(null==c.term||""===a.trim(c.term))return e;if(d.children){for(var f=d.children.length-1;f>=0;f--){var g=d.children[f],h=b(c.term,g.text,g);h||e.children.splice(f,1)}if(e.children.length>0)return e}return b(c.term,d.text,d)?e:null}return c}return b}),b.define("select2/compat/query",[],function(){function a(a,b,c){c.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `query` option has been deprecated in favor of a custom data adapter that overrides the `query` method. Support will be removed for the `query` option in future versions of Select2."),a.call(this,b,c)}return a.prototype.query=function(a,b,c){b.callback=c;var d=this.options.get("query");d.call(null,b)},a}),b.define("select2/dropdown/attachContainer",[],function(){function a(a,b,c){a.call(this,b,c)}return a.prototype.position=function(a,b,c){var d=c.find(".dropdown-wrapper");d.append(b),b.addClass("select2-dropdown--below"),c.addClass("select2-container--below")},a}),b.define("select2/dropdown/stopPropagation",[],function(){function a(){}return a.prototype.bind=function(a,b,c){a.call(this,b,c);var d=["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"];this.$dropdown.on(d.join(" "),function(a){a.stopPropagation()})},a}),b.define("select2/selection/stopPropagation",[],function(){function a(){}return a.prototype.bind=function(a,b,c){a.call(this,b,c);var d=["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"];this.$selection.on(d.join(" "),function(a){a.stopPropagation()})},a}),function(c){"function"==typeof b.define&&b.define.amd?b.define("jquery-mousewheel",["jquery"],c):"object"==typeof exports?module.exports=c:c(a)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c});
|
1 |
+
!function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),n(t),t}:n(jQuery)}(function(t){var e,n,p,r,s,h,f,g,m,v,y,i,o,_,a,a=((u=t&&t.fn&&t.fn.select2&&t.fn.select2.amd?t.fn.select2.amd:u)&&u.requirejs||(u?n=u:u={},g={},m={},v={},y={},i=Object.prototype.hasOwnProperty,o=[].slice,_=/\.js$/,h=function(e,t){var n,i,o=c(e),r=o[0],t=t[1];return e=o[1],r&&(n=A(r=l(r,t))),r?e=n&&n.normalize?n.normalize(e,(i=t,function(e){return l(e,i)})):l(e,t):(r=(o=c(e=l(e,t)))[0],e=o[1],r&&(n=A(r))),{f:r?r+"!"+e:e,n:e,pr:r,p:n}},f={require:function(e){return b(e)},exports:function(e){var t=g[e];return void 0!==t?t:g[e]={}},module:function(e){return{id:e,uri:"",exports:g[e],config:(t=e,function(){return v&&v.config&&v.config[t]||{}})};var t}},r=function(e,t,n,i){var o,r,s,a,l,c=[],u=typeof n,d=x(i=i||e);if("undefined"==u||"function"==u){for(t=!t.length&&n.length?["require","exports","module"]:t,a=0;a<t.length;a+=1)if("require"===(r=(s=h(t[a],d)).f))c[a]=f.require(e);else if("exports"===r)c[a]=f.exports(e),l=!0;else if("module"===r)o=c[a]=f.module(e);else if(w(g,r)||w(m,r)||w(y,r))c[a]=A(r);else{if(!s.p)throw new Error(e+" missing "+r);s.p.load(s.n,b(i,!0),function(t){return function(e){g[t]=e}}(r),{}),c[a]=g[r]}u=n?n.apply(g[e],c):void 0,e&&(o&&o.exports!==p&&o.exports!==g[e]?g[e]=o.exports:u===p&&l||(g[e]=u))}else e&&(g[e]=n)},e=n=s=function(e,t,n,i,o){if("string"==typeof e)return f[e]?f[e](t):A(h(e,x(t)).f);if(!e.splice){if((v=e).deps&&s(v.deps,v.callback),!t)return;t.splice?(e=t,t=n,n=null):e=p}return t=t||function(){},"function"==typeof n&&(n=i,i=o),i?r(p,e,t,n):setTimeout(function(){r(p,e,t,n)},4),s},s.config=function(e){return s(e)},e._defined=g,(a=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),w(g,e)||w(m,e)||(m[e]=[e,t,n])}).amd={jQuery:!0},u.requirejs=e,u.require=n,u.define=a),u.define("almond",function(){}),u.define("jquery",[],function(){var e=t||$;return null==e&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),e}),u.define("select2/utils",["jquery"],function(r){var i={};function c(e){var t,n=e.prototype,i=[];for(t in n)"function"==typeof n[t]&&"constructor"!==t&&i.push(t);return i}i.Extend=function(e,t){var n,i={}.hasOwnProperty;function o(){this.constructor=e}for(n in t)i.call(t,n)&&(e[n]=t[n]);return o.prototype=t.prototype,e.prototype=new o,e.__super__=t.prototype,e},i.Decorate=function(i,o){var e=c(o),t=c(i);function r(){var e=Array.prototype.unshift,t=o.prototype.constructor.length,n=i.prototype.constructor;0<t&&(e.call(arguments,i.prototype.constructor),n=o.prototype.constructor),n.apply(this,arguments)}o.displayName=i.displayName,r.prototype=new function(){this.constructor=r};for(var n=0;n<t.length;n++){var s=t[n];r.prototype[s]=i.prototype[s]}for(var a=0;a<e.length;a++){var l=e[a];r.prototype[l]=function(e){var t=function(){};e in r.prototype&&(t=r.prototype[e]);var n=o.prototype[e];return function(){return Array.prototype.unshift.call(arguments,t),n.apply(this,arguments)}}(l)}return r};function e(){this.listeners={}}e.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},e.prototype.trigger=function(e){var t=Array.prototype.slice,n=t.call(arguments,1);this.listeners=this.listeners||{},0===(n=null==n?[]:n).length&&n.push({}),(n[0]._type=e)in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},e.prototype.invoke=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n].apply(this,t)},i.Observable=e,i.generateChars=function(e){for(var t="",n=0;n<e;n++)t+=Math.floor(36*Math.random()).toString(36);return t},i.bind=function(e,t){return function(){e.apply(t,arguments)}},i._convertData=function(e){for(var t in e){var n=t.split("-"),i=e;if(1!==n.length){for(var o=0;o<n.length;o++){var r=n[o];(r=r.substring(0,1).toLowerCase()+r.substring(1))in i||(i[r]={}),o==n.length-1&&(i[r]=e[t]),i=i[r]}delete e[t]}}return e},i.hasScroll=function(e,t){var n=r(t),i=t.style.overflowX,o=t.style.overflowY;return(i!==o||"hidden"!==o&&"visible"!==o)&&("scroll"===i||"scroll"===o||(n.innerHeight()<t.scrollHeight||n.innerWidth()<t.scrollWidth))},i.escapeMarkup=function(e){var t={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},i.appendMany=function(e,t){var n;"1.7"===r.fn.jquery.substr(0,3)&&(n=r(),r.map(t,function(e){n=n.add(e)}),t=n),e.append(t)},i.__cache={};var n=0;return i.GetUniqueElementId=function(e){var t=e.getAttribute("data-select2-id");return null==t&&(e.id?(t=e.id,e.setAttribute("data-select2-id",t)):(e.setAttribute("data-select2-id",++n),t=n.toString())),t},i.StoreData=function(e,t,n){e=i.GetUniqueElementId(e);i.__cache[e]||(i.__cache[e]={}),i.__cache[e][t]=n},i.GetData=function(e,t){var n=i.GetUniqueElementId(e);return t?i.__cache[n]&&null!=i.__cache[n][t]?i.__cache[n][t]:r(e).data(t):i.__cache[n]},i.RemoveData=function(e){var t=i.GetUniqueElementId(e);null!=i.__cache[t]&&delete i.__cache[t],e.removeAttribute("data-select2-id")},i}),u.define("select2/results",["jquery","./utils"],function(d,p){function i(e,t,n){this.$element=e,this.data=n,this.options=t,i.__super__.constructor.call(this)}return p.Extend(i,p.Observable),i.prototype.render=function(){var e=d('<ul class="select2-results__options" role="listbox"></ul>');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},i.prototype.clear=function(){this.$results.empty()},i.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=d('<li role="alert" aria-live="assertive" class="select2-results__option"></li>'),i=this.options.get("translations").get(e.message);n.append(t(i(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},i.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},i.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var i=e.results[n],i=this.option(i);t.push(i)}this.$results.append(t)}else 0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"})},i.prototype.position=function(e,t){t.find(".select2-results").append(e)},i.prototype.sort=function(e){return this.options.get("sorter")(e)},i.prototype.highlightFirstItem=function(){var e=this.$results.find(".select2-results__option[aria-selected]"),t=e.filter("[aria-selected=true]");(0<t.length?t:e).first().trigger("mouseenter"),this.ensureHighlightVisible()},i.prototype.setClasses=function(){var t=this;this.data.current(function(e){var i=d.map(e,function(e){return e.id.toString()});t.$results.find(".select2-results__option[aria-selected]").each(function(){var e=d(this),t=p.GetData(this,"data"),n=""+t.id;null!=t.element&&t.element.selected||null==t.element&&-1<d.inArray(n,i)?e.attr("aria-selected","true"):e.attr("aria-selected","false")})})},i.prototype.showLoading=function(e){this.hideLoading();e={disabled:!0,loading:!0,text:this.options.get("translations").get("searching")(e)},e=this.option(e);e.className+=" loading-results",this.$results.prepend(e)},i.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},i.prototype.option=function(e){var t=document.createElement("li");t.className="select2-results__option";var n,i={role:"option","aria-selected":"false"},o=window.Element.prototype.matches||window.Element.prototype.msMatchesSelector||window.Element.prototype.webkitMatchesSelector;for(n in(null!=e.element&&o.call(e.element,":disabled")||null==e.element&&e.disabled)&&(delete i["aria-selected"],i["aria-disabled"]="true"),null==e.id&&delete i["aria-selected"],null!=e._resultId&&(t.id=e._resultId),e.title&&(t.title=e.title),e.children&&(i.role="group",i["aria-label"]=e.text,delete i["aria-selected"]),i){var r=i[n];t.setAttribute(n,r)}if(e.children){var s=d(t),a=document.createElement("strong");a.className="select2-results__group";d(a);this.template(e,a);for(var l=[],c=0;c<e.children.length;c++){var u=e.children[c],u=this.option(u);l.push(u)}o=d("<ul></ul>",{class:"select2-results__options select2-results__options--nested"});o.append(l),s.append(a),s.append(o)}else this.template(e,t);return p.StoreData(t,"data",e),t},i.prototype.bind=function(t,e){var o=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){o.clear(),o.append(e.data),t.isOpen()&&(o.setClasses(),o.highlightFirstItem())}),t.on("results:append",function(e){o.append(e.data),t.isOpen()&&o.setClasses()}),t.on("query",function(e){o.hideMessages(),o.showLoading(e)}),t.on("select",function(){t.isOpen()&&(o.setClasses(),o.options.get("scrollAfterSelect")&&o.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(o.setClasses(),o.options.get("scrollAfterSelect")&&o.highlightFirstItem())}),t.on("open",function(){o.$results.attr("aria-expanded","true"),o.$results.attr("aria-hidden","false"),o.setClasses(),o.ensureHighlightVisible()}),t.on("close",function(){o.$results.attr("aria-expanded","false"),o.$results.attr("aria-hidden","true"),o.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=o.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e,t=o.getHighlightedResults();0!==t.length&&(e=p.GetData(t[0],"data"),"true"==t.attr("aria-selected")?o.trigger("close",{}):o.trigger("select",{data:e}))}),t.on("results:previous",function(){var e,t=o.getHighlightedResults(),n=o.$results.find("[aria-selected]"),i=n.index(t);i<=0||(e=i-1,0===t.length&&(e=0),(i=n.eq(e)).trigger("mouseenter"),t=o.$results.offset().top,n=i.offset().top,i=o.$results.scrollTop()+(n-t),0===e?o.$results.scrollTop(0):n-t<0&&o.$results.scrollTop(i))}),t.on("results:next",function(){var e,t=o.getHighlightedResults(),n=o.$results.find("[aria-selected]"),i=n.index(t)+1;i>=n.length||((e=n.eq(i)).trigger("mouseenter"),t=o.$results.offset().top+o.$results.outerHeight(!1),n=e.offset().top+e.outerHeight(!1),e=o.$results.scrollTop()+n-t,0===i?o.$results.scrollTop(0):t<n&&o.$results.scrollTop(e))}),t.on("results:focus",function(e){e.element.addClass("select2-results__option--highlighted")}),t.on("results:message",function(e){o.displayMessage(e)}),d.fn.mousewheel&&this.$results.on("mousewheel",function(e){var t=o.$results.scrollTop(),n=o.$results.get(0).scrollHeight-t+e.deltaY,t=0<e.deltaY&&t-e.deltaY<=0,n=e.deltaY<0&&n<=o.$results.height();t?(o.$results.scrollTop(0),e.preventDefault(),e.stopPropagation()):n&&(o.$results.scrollTop(o.$results.get(0).scrollHeight-o.$results.height()),e.preventDefault(),e.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(e){var t=d(this),n=p.GetData(this,"data");"true"!==t.attr("aria-selected")?o.trigger("select",{originalEvent:e,data:n}):o.options.get("multiple")?o.trigger("unselect",{originalEvent:e,data:n}):o.trigger("close",{})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(e){var t=p.GetData(this,"data");o.getHighlightedResults().removeClass("select2-results__option--highlighted"),o.trigger("results:focus",{data:t,element:d(this)})})},i.prototype.getHighlightedResults=function(){return this.$results.find(".select2-results__option--highlighted")},i.prototype.destroy=function(){this.$results.remove()},i.prototype.ensureHighlightVisible=function(){var e,t,n,i,o=this.getHighlightedResults();0!==o.length&&(e=this.$results.find("[aria-selected]").index(o),i=this.$results.offset().top,t=o.offset().top,n=this.$results.scrollTop()+(t-i),i=t-i,n-=2*o.outerHeight(!1),e<=2?this.$results.scrollTop(0):(i>this.$results.outerHeight()||i<0)&&this.$results.scrollTop(n))},i.prototype.template=function(e,t){var n=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),e=n(e,t);null==e?t.style.display="none":"string"==typeof e?t.innerHTML=i(e):d(t).append(e)},i}),u.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),u.define("select2/selection/base",["jquery","../utils","../keys"],function(n,i,o){function r(e,t){this.$element=e,this.options=t,r.__super__.constructor.call(this)}return i.Extend(r,i.Observable),r.prototype.render=function(){var e=n('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=i.GetData(this.$element[0],"old-tabindex")?this._tabindex=i.GetData(this.$element[0],"old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),e.attr("aria-disabled","false"),this.$selection=e},r.prototype.bind=function(e,t){var n=this,i=e.id+"-results";this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===o.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",i),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),n.$selection.trigger("focus"),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex),n.$selection.attr("aria-disabled","false")}),e.on("disable",function(){n.$selection.attr("tabindex","-1"),n.$selection.attr("aria-disabled","true")})},r.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||n.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},r.prototype._attachCloseHandler=function(e){n(document.body).on("mousedown.select2."+e.id,function(e){var t=n(e.target).closest(".select2");n(".select2.select2-container--open").each(function(){this!=t[0]&&i.GetData(this,"element").select2("close")})})},r.prototype._detachCloseHandler=function(e){n(document.body).off("mousedown.select2."+e.id)},r.prototype.position=function(e,t){t.find(".selection").append(e)},r.prototype.destroy=function(){this._detachCloseHandler(this.container)},r.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},r.prototype.isEnabled=function(){return!this.isDisabled()},r.prototype.isDisabled=function(){return this.options.get("disabled")},r}),u.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,i){function o(){o.__super__.constructor.apply(this,arguments)}return n.Extend(o,t),o.prototype.render=function(){var e=o.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),e},o.prototype.bind=function(t,e){var n=this;o.__super__.bind.apply(this,arguments);var i=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",i).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",i),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.trigger("focus")})},o.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},o.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},o.prototype.selectionContainer=function(){return e("<span></span>")},o.prototype.update=function(e){var t,n;0!==e.length?(n=e[0],t=this.$selection.find(".select2-selection__rendered"),e=this.display(n,t),t.empty().append(e),(n=n.title||n.text)?t.attr("title",n):t.removeAttr("title")):this.clear()},o}),u.define("select2/selection/multiple",["jquery","./base","../utils"],function(i,e,a){function o(e,t){o.__super__.constructor.apply(this,arguments)}return a.Extend(o,e),o.prototype.render=function(){var e=o.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('<ul class="select2-selection__rendered"></ul>'),e},o.prototype.bind=function(e,t){var n=this;o.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){var t;n.isDisabled()||(t=i(this).parent(),t=a.GetData(t[0],"data"),n.trigger("unselect",{originalEvent:e,data:t}))})},o.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},o.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},o.prototype.selectionContainer=function(){return i('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">×</span></li>')},o.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n<e.length;n++){var i=e[n],o=this.selectionContainer(),r=this.display(i,o);o.append(r);r=i.title||i.text;r&&o.attr("title",r),a.StoreData(o[0],"data",i),t.push(o)}var s=this.$selection.find(".select2-selection__rendered");a.appendMany(s,t)}},o}),u.define("select2/selection/placeholder",["../utils"],function(e){function t(e,t,n){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n)}return t.prototype.normalizePlaceholder=function(e,t){return t="string"==typeof t?{id:"",text:t}:t},t.prototype.createPlaceholder=function(e,t){var n=this.selectionContainer();return n.html(this.display(t)),n.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),n},t.prototype.update=function(e,t){var n=1==t.length&&t[0].id!=this.placeholder.id;if(1<t.length||n)return e.call(this,t);this.clear();t=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(t)},t}),u.define("select2/selection/allowClear",["jquery","../keys","../utils"],function(n,i,a){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(e){i._handleClear(e)}),t.on("keypress",function(e){i._handleKeyboardClear(e,t)})},e.prototype._handleClear=function(e,t){if(!this.isDisabled()){var n=this.$selection.find(".select2-selection__clear");if(0!==n.length){t.stopPropagation();var i=a.GetData(n[0],"data"),o=this.$element.val();this.$element.val(this.placeholder.id);var r={data:i};if(this.trigger("clear",r),r.prevented)this.$element.val(o);else{for(var s=0;s<i.length;s++)if(r={data:i[s]},this.trigger("unselect",r),r.prevented)return void this.$element.val(o);this.$element.trigger("input").trigger("change"),this.trigger("toggle",{})}}}},e.prototype._handleKeyboardClear=function(e,t,n){n.isOpen()||t.which!=i.DELETE&&t.which!=i.BACKSPACE||this._handleClear(t)},e.prototype.update=function(e,t){e.call(this,t),0<this.$selection.find(".select2-selection__placeholder").length||0===t.length||(e=this.options.get("translations").get("removeAllItems"),e=n('<span class="select2-selection__clear" title="'+e()+'">×</span>'),a.StoreData(e[0],"data",t),this.$selection.find(".select2-selection__rendered").prepend(e))},e}),u.define("select2/selection/search",["jquery","../utils","../keys"],function(n,s,a){function e(e,t,n){e.call(this,t,n)}return e.prototype.render=function(e){var t=n('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" /></li>');this.$searchContainer=t,this.$search=t.find("input");e=e.call(this);return this._transferTabIndex(),e},e.prototype.bind=function(e,t,n){var i=this,o=t.id+"-results";e.call(this,t,n),t.on("open",function(){i.$search.attr("aria-controls",o),i.$search.trigger("focus")}),t.on("close",function(){i.$search.val(""),i.$search.removeAttr("aria-controls"),i.$search.removeAttr("aria-activedescendant"),i.$search.trigger("focus")}),t.on("enable",function(){i.$search.prop("disabled",!1),i._transferTabIndex()}),t.on("disable",function(){i.$search.prop("disabled",!0)}),t.on("focus",function(e){i.$search.trigger("focus")}),t.on("results:focus",function(e){e.data._resultId?i.$search.attr("aria-activedescendant",e.data._resultId):i.$search.removeAttr("aria-activedescendant")}),this.$selection.on("focusin",".select2-search--inline",function(e){i.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){i._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){var t;e.stopPropagation(),i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented(),e.which!==a.BACKSPACE||""!==i.$search.val()||0<(t=i.$searchContainer.prev(".select2-selection__choice")).length&&(t=s.GetData(t[0],"data"),i.searchRemoveChoice(t),e.preventDefault())}),this.$selection.on("click",".select2-search--inline",function(e){i.$search.val()&&e.stopPropagation()});var t=document.documentMode,r=t&&t<=11;this.$selection.on("input.searchcheck",".select2-search--inline",function(e){r?i.$selection.off("input.search input.searchcheck"):i.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(e){var t;r&&"input"===e.type?i.$selection.off("input.search input.searchcheck"):(t=e.which)!=a.SHIFT&&t!=a.CTRL&&t!=a.ALT&&t!=a.TAB&&i.handleSearch(e)})},e.prototype._transferTabIndex=function(e){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},e.prototype.createPlaceholder=function(e,t){this.$search.attr("placeholder",t.text)},e.prototype.update=function(e,t){var n=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),e.call(this,t),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),n&&this.$search.trigger("focus")},e.prototype.handleSearch=function(){var e;this.resizeSearch(),this._keyUpPrevented||(e=this.$search.val(),this.trigger("query",{term:e})),this._keyUpPrevented=!1},e.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(t.text),this.handleSearch()},e.prototype.resizeSearch=function(){this.$search.css("width","25px");var e="";e=""!==this.$search.attr("placeholder")?this.$selection.find(".select2-selection__rendered").width():.75*(this.$search.val().length+1)+"em",this.$search.css("width",e)},e}),u.define("select2/selection/eventRelay",["jquery"],function(s){function e(){}return e.prototype.bind=function(e,t,n){var i=this,o=["open","opening","close","closing","select","selecting","unselect","unselecting","clear","clearing"],r=["opening","closing","selecting","unselecting","clearing"];e.call(this,t,n),t.on("*",function(e,t){var n;-1!==s.inArray(e,o)&&(n=s.Event("select2:"+e,{params:t=t||{}}),i.$element.trigger(n),-1!==s.inArray(e,r)&&(t.prevented=n.isDefaultPrevented()))})},e}),u.define("select2/translation",["jquery","require"],function(t,n){function i(e){this.dict=e||{}}return i.prototype.all=function(){return this.dict},i.prototype.get=function(e){return this.dict[e]},i.prototype.extend=function(e){this.dict=t.extend({},e.all(),this.dict)},i._cache={},i.loadPath=function(e){var t;return e in i._cache||(t=n(e),i._cache[e]=t),new i(i._cache[e])},i}),u.define("select2/diacritics",[],function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Œ":"OE","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","œ":"oe","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ώ":"ω","ς":"σ","’":"'"}}),u.define("select2/data/base",["../utils"],function(n){function i(e,t){i.__super__.constructor.call(this)}return n.Extend(i,n.Observable),i.prototype.current=function(e){throw new Error("The `current` method must be defined in child classes.")},i.prototype.query=function(e,t){throw new Error("The `query` method must be defined in child classes.")},i.prototype.bind=function(e,t){},i.prototype.destroy=function(){},i.prototype.generateResultId=function(e,t){e=e.id+"-result-";return e+=n.generateChars(4),null!=t.id?e+="-"+t.id.toString():e+="-"+n.generateChars(4),e},i}),u.define("select2/data/select",["./base","../utils","jquery"],function(e,s,a){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return s.Extend(n,e),n.prototype.current=function(e){var t=[],n=this;this.$element.find(":selected").each(function(){var e=a(this),e=n.item(e);t.push(e)}),e(t)},n.prototype.select=function(o){var e,r=this;if(o.selected=!0,a(o.element).is("option"))return o.element.selected=!0,void this.$element.trigger("input").trigger("change");this.$element.prop("multiple")?this.current(function(e){var t=[];(o=[o]).push.apply(o,e);for(var n=0;n<o.length;n++){var i=o[n].id;-1===a.inArray(i,t)&&t.push(i)}r.$element.val(t),r.$element.trigger("input").trigger("change")}):(e=o.id,this.$element.val(e),this.$element.trigger("input").trigger("change"))},n.prototype.unselect=function(o){var r=this;if(this.$element.prop("multiple")){if(o.selected=!1,a(o.element).is("option"))return o.element.selected=!1,void this.$element.trigger("input").trigger("change");this.current(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n].id;i!==o.id&&-1===a.inArray(i,t)&&t.push(i)}r.$element.val(t),r.$element.trigger("input").trigger("change")})}},n.prototype.bind=function(e,t){var n=this;(this.container=e).on("select",function(e){n.select(e.data)}),e.on("unselect",function(e){n.unselect(e.data)})},n.prototype.destroy=function(){this.$element.find("*").each(function(){s.RemoveData(this)})},n.prototype.query=function(t,e){var n=[],i=this;this.$element.children().each(function(){var e=a(this);(e.is("option")||e.is("optgroup"))&&(e=i.item(e),null!==(e=i.matches(t,e))&&n.push(e))}),e({results:n})},n.prototype.addOptions=function(e){s.appendMany(this.$element,e)},n.prototype.option=function(e){var t;e.children?(t=document.createElement("optgroup")).label=e.text:void 0!==(t=document.createElement("option")).textContent?t.textContent=e.text:t.innerText=e.text,void 0!==e.id&&(t.value=e.id),e.disabled&&(t.disabled=!0),e.selected&&(t.selected=!0),e.title&&(t.title=e.title);var n=a(t),e=this._normalizeItem(e);return e.element=t,s.StoreData(t,"data",e),n},n.prototype.item=function(e){var t={};if(null!=(t=s.GetData(e[0],"data")))return t;if(e.is("option"))t={id:e.val(),text:e.text(),disabled:e.prop("disabled"),selected:e.prop("selected"),title:e.prop("title")};else if(e.is("optgroup")){for(var t={text:e.prop("label"),children:[],title:e.prop("title")},n=e.children("option"),i=[],o=0;o<n.length;o++){var r=a(n[o]),r=this.item(r);i.push(r)}t.children=i}return(t=this._normalizeItem(t)).element=e[0],s.StoreData(e[0],"data",t),t},n.prototype._normalizeItem=function(e){e!==Object(e)&&(e={id:e,text:e});return null!=(e=a.extend({},{text:""},e)).id&&(e.id=e.id.toString()),null!=e.text&&(e.text=e.text.toString()),null==e._resultId&&e.id&&null!=this.container&&(e._resultId=this.generateResultId(this.container,e)),a.extend({},{selected:!1,disabled:!1},e)},n.prototype.matches=function(e,t){return this.options.get("matcher")(e,t)},n}),u.define("select2/data/array",["./select","../utils","jquery"],function(e,c,u){function i(e,t){this._dataToConvert=t.get("data")||[],i.__super__.constructor.call(this,e,t)}return c.Extend(i,e),i.prototype.bind=function(e,t){i.__super__.bind.call(this,e,t),this.addOptions(this.convertToOptions(this._dataToConvert))},i.prototype.select=function(n){var e;0===(e=this.$element.find("option").filter(function(e,t){return t.value==n.id.toString()})).length&&(e=this.option(n),this.addOptions(e)),i.__super__.select.call(this,n)},i.prototype.convertToOptions=function(e){var t=this,n=this.$element.find("option"),i=n.map(function(){return t.item(u(this)).id}).get(),o=[];for(var r=0;r<e.length;r++){var s,a,l=this._normalizeItem(e[r]);0<=u.inArray(l.id,i)?(s=n.filter(function(e){return function(){return u(this).val()==e.id}}(l)),a=this.item(s),a=u.extend(!0,{},l,a),a=this.option(a),s.replaceWith(a)):(a=this.option(l),l.children&&(l=this.convertToOptions(l.children),c.appendMany(a,l)),o.push(a))}return o},i}),u.define("select2/data/ajax",["./array","../utils","jquery"],function(e,t,r){function n(e,t){this.ajaxOptions=this._applyDefaults(t.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),n.__super__.constructor.call(this,e,t)}return t.Extend(n,e),n.prototype._applyDefaults=function(e){var t={data:function(e){return r.extend({},e,{q:e.term})},transport:function(e,t,n){e=r.ajax(e);return e.then(t),e.fail(n),e}};return r.extend({},t,e,!0)},n.prototype.processResults=function(e){return e},n.prototype.query=function(t,n){var i=this;null!=this._request&&(r.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var o=r.extend({type:"GET"},this.ajaxOptions);function e(){var e=o.transport(o,function(e){e=i.processResults(e,t);i.options.get("debug")&&window.console&&console.error&&(e&&e.results&&r.isArray(e.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),n(e)},function(){"status"in e&&(0===e.status||"0"===e.status)||i.trigger("results:message",{message:"errorLoading"})});i._request=e}"function"==typeof o.url&&(o.url=o.url.call(this.$element,t)),"function"==typeof o.data&&(o.data=o.data.call(this.$element,t)),this.ajaxOptions.delay&&null!=t.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(e,this.ajaxOptions.delay)):e()},n}),u.define("select2/data/tags",["jquery"],function(a){function e(e,t,n){var i=n.get("tags"),o=n.get("createTag");void 0!==o&&(this.createTag=o);o=n.get("insertTag");if(void 0!==o&&(this.insertTag=o),e.call(this,t,n),a.isArray(i))for(var r=0;r<i.length;r++){var s=i[r],s=this._normalizeItem(s),s=this.option(s);this.$element.append(s)}}return e.prototype.query=function(e,c,u){var d=this;this._removeOldTags(),null!=c.term&&null==c.page?e.call(this,c,function e(t,n){for(var i=t.results,o=0;o<i.length;o++){var r=i[o],s=null!=r.children&&!e({results:r.children},!0);if((r.text||"").toUpperCase()===(c.term||"").toUpperCase()||s)return!n&&(t.data=i,void u(t))}if(n)return!0;var a,l=d.createTag(c);null!=l&&((a=d.option(l)).attr("data-select2-tag",!0),d.addOptions([a]),d.insertTag(i,l)),t.results=i,u(t)}):e.call(this,c,u)},e.prototype.createTag=function(e,t){t=a.trim(t.term);return""===t?null:{id:t,text:t}},e.prototype.insertTag=function(e,t,n){t.unshift(n)},e.prototype._removeOldTags=function(e){this.$element.find("option[data-select2-tag]").each(function(){this.selected||a(this).remove()})},e}),u.define("select2/data/tokenizer",["jquery"],function(c){function e(e,t,n){var i=n.get("tokenizer");void 0!==i&&(this.tokenizer=i),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){e.call(this,t,n),this.$search=t.dropdown.$search||t.selection.$search||n.find(".select2-search__field")},e.prototype.query=function(e,t,n){var i=this;t.term=t.term||"";var o=this.tokenizer(t,this.options,function(e){var t=i._normalizeItem(e);i.$element.find("option").filter(function(){return c(this).val()===t.id}).length||((e=i.option(t)).attr("data-select2-tag",!0),i._removeOldTags(),i.addOptions([e])),i.trigger("select",{data:t})});o.term!==t.term&&(this.$search.length&&(this.$search.val(o.term),this.$search.trigger("focus")),t.term=o.term),e.call(this,t,n)},e.prototype.tokenizer=function(e,t,n,i){for(var o=n.get("tokenSeparators")||[],r=t.term,s=0,a=this.createTag||function(e){return{id:e.term,text:e.term}};s<r.length;){var l=r[s];-1!==c.inArray(l,o)?(l=r.substr(0,s),null!=(l=a(c.extend({},t,{term:l})))?(i(l),r=r.substr(s+1)||"",s=0):s++):s++}return{term:r}},e}),u.define("select2/data/minimumInputLength",[],function(){function e(e,t,n){this.minimumInputLength=n.get("minimumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",t.term.length<this.minimumInputLength?this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),u.define("select2/data/maximumInputLength",[],function(){function e(e,t,n){this.maximumInputLength=n.get("maximumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",0<this.maximumInputLength&&t.term.length>this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),u.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("select",function(){i._checkIfMaximumSelected()})},e.prototype.query=function(e,t,n){var i=this;this._checkIfMaximumSelected(function(){e.call(i,t,n)})},e.prototype._checkIfMaximumSelected=function(e,t){var n=this;this.current(function(e){e=null!=e?e.length:0;0<n.maximumSelectionLength&&e>=n.maximumSelectionLength?n.trigger("results:message",{message:"maximumSelected",args:{maximum:n.maximumSelectionLength}}):t&&t()})},e}),u.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('<span class="select2-dropdown"><span class="select2-results"></span></span>');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),u.define("select2/dropdown/search",["jquery","../utils"],function(r,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),e=r('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" /></span>');return this.$searchContainer=e,this.$search=e.find("input"),t.prepend(e),t},t.prototype.bind=function(e,t,n){var i=this,o=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){r(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-controls",o),window.setTimeout(function(){i.$search.trigger("focus")},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-controls"),i.$search.removeAttr("aria-activedescendant"),i.$search.val(""),i.$search.trigger("blur")}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){e.data._resultId?i.$search.attr("aria-activedescendant",e.data._resultId):i.$search.removeAttr("aria-activedescendant")})},t.prototype.handleSearch=function(e){var t;this._keyUpPrevented||(t=this.$search.val(),this.trigger("query",{term:t})),this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),u.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return t="string"==typeof t?{id:"",text:t}:t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var o=t[i];this.placeholder.id===o.id&&n.splice(i,1)}return n},e}),u.define("select2/dropdown/infiniteScroll",["jquery"],function(n){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&(this.$results.append(this.$loadingMore),this.loadMoreIfNeeded())},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",this.loadMoreIfNeeded.bind(this))},e.prototype.loadMoreIfNeeded=function(){var e=n.contains(document.documentElement,this.$loadingMore[0]);!this.loading&&e&&(e=this.$results.offset().top+this.$results.outerHeight(!1),this.$loadingMore.offset().top+this.$loadingMore.outerHeight(!1)<=e+50&&this.loadMore())},e.prototype.loadMore=function(){this.loading=!0;var e=n.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=n('<li class="select2-results__option select2-results__option--load-more"role="option" aria-disabled="true"></li>'),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),u.define("select2/dropdown/attachBody",["jquery","../utils"],function(u,s){function e(e,t,n){this.$dropdownParent=u(n.get("dropdownParent")||document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),i._bindContainerResultHandlers(t)}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=u("<span></span>"),e=e.call(this);return t.append(e),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._bindContainerResultHandlers=function(e,t){var n;this._containerResultsHandlersBound||(n=this,t.on("results:all",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:append",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:message",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("select",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("unselect",function(){n._positionDropdown(),n._resizeDropdown()}),this._containerResultsHandlersBound=!0)},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,o="resize.select2."+t.id,r="orientationchange.select2."+t.id,t=this.$container.parents().filter(s.hasScroll);t.each(function(){s.StoreData(this,"select2-scroll-position",{x:u(this).scrollLeft(),y:u(this).scrollTop()})}),t.on(i,function(e){var t=s.GetData(this,"select2-scroll-position");u(this).scrollTop(t.y)}),u(window).on(i+" "+o+" "+r,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,t="orientationchange.select2."+t.id;this.$container.parents().filter(s.hasScroll).off(n),u(window).off(n+" "+i+" "+t)},e.prototype._positionDropdown=function(){var e=u(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,o=this.$container.offset();o.bottom=o.top+this.$container.outerHeight(!1);var r={height:this.$container.outerHeight(!1)};r.top=o.top,r.bottom=o.top+r.height;var s=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=a<o.top-s,e=l>o.bottom+s,a={left:o.left,top:r.bottom},l=this.$dropdownParent;"static"===l.css("position")&&(l=l.offsetParent());o={top:0,left:0};(u.contains(document.body,l[0])||l[0].isConnected)&&(o=l.offset()),a.top-=o.top,a.left-=o.left,t||n||(i="below"),e||!c||t?!c&&e&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(a.top=r.top-o.top-s),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(a)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),u.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,i=0;i<t.length;i++){var o=t[i];o.children?n+=e(o.children):n++}return n}(t.data.results)<this.minimumResultsForSearch)&&e.call(this,t)},e}),u.define("select2/dropdown/selectOnClose",["../utils"],function(i){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("close",function(e){i._handleSelectOnClose(e)})},e.prototype._handleSelectOnClose=function(e,t){if(t&&null!=t.originalSelect2Event){var n=t.originalSelect2Event;if("select"===n._type||"unselect"===n._type)return}n=this.getHighlightedResults();n.length<1||(null!=(n=i.GetData(n[0],"data")).element&&n.element.selected||null==n.element&&n.selected||this.trigger("select",{data:n}))},e}),u.define("select2/dropdown/closeOnSelect",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("select",function(e){i._selectTriggered(e)}),t.on("unselect",function(e){i._selectTriggered(e)})},e.prototype._selectTriggered=function(e,t){var n=t.originalEvent;n&&(n.ctrlKey||n.metaKey)||this.trigger("close",{originalEvent:n,originalSelect2Event:t})},e}),u.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,e="Please delete "+t+" character";return 1!=t&&(e+="s"),e},inputTooShort:function(e){return"Please enter "+(e.minimum-e.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return 1!=e.maximum&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"},removeAllItems:function(){return"Remove all items"}}}),u.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(l,a,c,u,d,p,h,f,g,m,s,t,v,y,_,w,b,$,A,x,D,S,C,E,O,T,q,j,e){function n(){this.reset()}return n.prototype.apply=function(e){var t,n,i;null==(e=l.extend(!0,{},this.defaults,e)).dataAdapter&&(null!=e.ajax?e.dataAdapter=_:null!=e.data?e.dataAdapter=y:e.dataAdapter=v,0<e.minimumInputLength&&(e.dataAdapter=m.Decorate(e.dataAdapter,$)),0<e.maximumInputLength&&(e.dataAdapter=m.Decorate(e.dataAdapter,A)),0<e.maximumSelectionLength&&(e.dataAdapter=m.Decorate(e.dataAdapter,x)),e.tags&&(e.dataAdapter=m.Decorate(e.dataAdapter,w)),null==e.tokenSeparators&&null==e.tokenizer||(e.dataAdapter=m.Decorate(e.dataAdapter,b)),null!=e.query&&(t=a(e.amdBase+"compat/query"),e.dataAdapter=m.Decorate(e.dataAdapter,t)),null!=e.initSelection&&(n=a(e.amdBase+"compat/initSelection"),e.dataAdapter=m.Decorate(e.dataAdapter,n))),null==e.resultsAdapter&&(e.resultsAdapter=c,null!=e.ajax&&(e.resultsAdapter=m.Decorate(e.resultsAdapter,E)),null!=e.placeholder&&(e.resultsAdapter=m.Decorate(e.resultsAdapter,C)),e.selectOnClose&&(e.resultsAdapter=m.Decorate(e.resultsAdapter,q))),null==e.dropdownAdapter&&(e.multiple?e.dropdownAdapter=D:(n=m.Decorate(D,S),e.dropdownAdapter=n),0!==e.minimumResultsForSearch&&(e.dropdownAdapter=m.Decorate(e.dropdownAdapter,T)),e.closeOnSelect&&(e.dropdownAdapter=m.Decorate(e.dropdownAdapter,j)),null==e.dropdownCssClass&&null==e.dropdownCss&&null==e.adaptDropdownCssClass||(i=a(e.amdBase+"compat/dropdownCss"),e.dropdownAdapter=m.Decorate(e.dropdownAdapter,i)),e.dropdownAdapter=m.Decorate(e.dropdownAdapter,O)),null==e.selectionAdapter&&(e.multiple?e.selectionAdapter=d:e.selectionAdapter=u,null!=e.placeholder&&(e.selectionAdapter=m.Decorate(e.selectionAdapter,p)),e.allowClear&&(e.selectionAdapter=m.Decorate(e.selectionAdapter,h)),e.multiple&&(e.selectionAdapter=m.Decorate(e.selectionAdapter,f)),null==e.containerCssClass&&null==e.containerCss&&null==e.adaptContainerCssClass||(i=a(e.amdBase+"compat/containerCss"),e.selectionAdapter=m.Decorate(e.selectionAdapter,i)),e.selectionAdapter=m.Decorate(e.selectionAdapter,g)),e.language=this._resolveLanguage(e.language),e.language.push("en");for(var o=[],r=0;r<e.language.length;r++){var s=e.language[r];-1===o.indexOf(s)&&o.push(s)}return e.language=o,e.translations=this._processTranslations(e.language,e.debug),e},n.prototype.reset=function(){function a(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return t[e]||e})}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:m.escapeMarkup,language:{},matcher:function e(t,n){if(""===l.trim(t.term))return n;if(n.children&&0<n.children.length){for(var i=l.extend(!0,{},n),o=n.children.length-1;0<=o;o--)null==e(t,n.children[o])&&i.children.splice(o,1);return 0<i.children.length?i:e(t,i)}var r=a(n.text).toUpperCase(),s=a(t.term).toUpperCase();return-1<r.indexOf(s)?n:null},minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,scrollAfterSelect:!1,sorter:function(e){return e},templateResult:function(e){return e.text},templateSelection:function(e){return e.text},theme:"default",width:"resolve"}},n.prototype.applyFromElement=function(e,t){var n=e.language,i=this.defaults.language,o=t.prop("lang"),t=t.closest("[lang]").prop("lang"),t=Array.prototype.concat.call(this._resolveLanguage(o),this._resolveLanguage(n),this._resolveLanguage(i),this._resolveLanguage(t));return e.language=t,e},n.prototype._resolveLanguage=function(e){if(!e)return[];if(l.isEmptyObject(e))return[];if(l.isPlainObject(e))return[e];for(var t,n=l.isArray(e)?e:[e],i=[],o=0;o<n.length;o++)i.push(n[o]),"string"==typeof n[o]&&0<n[o].indexOf("-")&&(t=n[o].split("-")[0],i.push(t));return i},n.prototype._processTranslations=function(e,t){for(var n=new s,i=0;i<e.length;i++){var o=new s,r=e[i];if("string"==typeof r)try{o=s.loadPath(r)}catch(e){try{r=this.defaults.amdLanguageBase+r,o=s.loadPath(r)}catch(e){t&&window.console&&console.warn&&console.warn('Select2: The language file for "'+r+'" could not be automatically loaded. A fallback will be used instead.')}}else o=l.isPlainObject(r)?new s(r):r;n.extend(o)}return n},n.prototype.set=function(e,t){var n={};n[l.camelCase(e)]=t;n=m._convertData(n);l.extend(!0,this.defaults,n)},new n}),u.define("select2/options",["require","jquery","./defaults","./utils"],function(n,c,i,u){function e(e,t){this.options=e,null!=t&&this.fromElement(t),null!=t&&(this.options=i.applyFromElement(this.options,t)),this.options=i.apply(this.options),t&&t.is("input")&&(t=n(this.get("amdBase")+"compat/inputData"),this.options.dataAdapter=u.Decorate(this.options.dataAdapter,t))}return e.prototype.fromElement=function(e){var t=["select2"];null==this.options.multiple&&(this.options.multiple=e.prop("multiple")),null==this.options.disabled&&(this.options.disabled=e.prop("disabled")),null==this.options.dir&&(e.prop("dir")?this.options.dir=e.prop("dir"):e.closest("[dir]").prop("dir")?this.options.dir=e.closest("[dir]").prop("dir"):this.options.dir="ltr"),e.prop("disabled",this.options.disabled),e.prop("multiple",this.options.multiple),u.GetData(e[0],"select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),u.StoreData(e[0],"data",u.GetData(e[0],"select2Tags")),u.StoreData(e[0],"tags",!0)),u.GetData(e[0],"ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),e.attr("ajax--url",u.GetData(e[0],"ajaxUrl")),u.StoreData(e[0],"ajax-Url",u.GetData(e[0],"ajaxUrl")));var n={};function i(e,t){return t.toUpperCase()}for(var o=0;o<e[0].attributes.length;o++){var r=e[0].attributes[o].name,s="data-";r.substr(0,s.length)==s&&(r=r.substring(s.length),s=u.GetData(e[0],r),n[r.replace(/-([a-z])/g,i)]=s)}c.fn.jquery&&"1."==c.fn.jquery.substr(0,2)&&e[0].dataset&&(n=c.extend(!0,{},e[0].dataset,n));var a,l=c.extend(!0,{},u.GetData(e[0]),n);for(a in l=u._convertData(l))-1<c.inArray(a,t)||(c.isPlainObject(this.options[a])?c.extend(this.options[a],l[a]):this.options[a]=l[a]);return this},e.prototype.get=function(e){return this.options[e]},e.prototype.set=function(e,t){this.options[e]=t},e}),u.define("select2/core",["jquery","./options","./utils","./keys"],function(r,o,s,i){function a(e,t){null!=s.GetData(e[0],"select2")&&s.GetData(e[0],"select2").destroy(),this.$element=e,this.id=this._generateId(e),this.options=new o(t=t||{},e),a.__super__.constructor.call(this);var n=e.attr("tabindex")||0;s.StoreData(e[0],"old-tabindex",n),e.attr("tabindex","-1"),t=this.options.get("dataAdapter"),this.dataAdapter=new t(e,this.options),n=this.render(),this._placeContainer(n),t=this.options.get("selectionAdapter"),this.selection=new t(e,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,n),t=this.options.get("dropdownAdapter"),this.dropdown=new t(e,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,n),n=this.options.get("resultsAdapter"),this.results=new n(e,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var i=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(e){i.trigger("selection:update",{data:e})}),e.addClass("select2-hidden-accessible"),e.attr("aria-hidden","true"),this._syncAttributes(),s.StoreData(e[0],"select2",this),e.data("select2",this)}return s.Extend(a,s.Observable),a.prototype._generateId=function(e){return"select2-"+(null!=e.attr("id")?e.attr("id"):null!=e.attr("name")?e.attr("name")+"-"+s.generateChars(2):s.generateChars(4)).replace(/(:|\.|\[|\]|,)/g,"")},a.prototype._placeContainer=function(e){e.insertAfter(this.$element);var t=this._resolveWidth(this.$element,this.options.get("width"));null!=t&&e.css("width",t)},a.prototype._resolveWidth=function(e,t){var n=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==t){var i=this._resolveWidth(e,"style");return null!=i?i:this._resolveWidth(e,"element")}if("element"==t){i=e.outerWidth(!1);return i<=0?"auto":i+"px"}if("style"!=t)return"computedstyle"!=t?t:window.getComputedStyle(e[0]).width;e=e.attr("style");if("string"!=typeof e)return null;for(var o=e.split(";"),r=0,s=o.length;r<s;r+=1){var a=o[r].replace(/\s/g,"").match(n);if(null!==a&&1<=a.length)return a[1]}return null},a.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},a.prototype._registerDomEvents=function(){var t=this;this.$element.on("change.select2",function(){t.dataAdapter.current(function(e){t.trigger("selection:update",{data:e})})}),this.$element.on("focus.select2",function(e){t.trigger("focus",e)}),this._syncA=s.bind(this._syncAttributes,this),this._syncS=s.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=e?(this._observer=new e(function(e){t._syncA(),t._syncS(null,e)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",t._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",t._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",t._syncS,!1))},a.prototype._registerDataEvents=function(){var n=this;this.dataAdapter.on("*",function(e,t){n.trigger(e,t)})},a.prototype._registerSelectionEvents=function(){var n=this,i=["toggle","focus"];this.selection.on("toggle",function(){n.toggleDropdown()}),this.selection.on("focus",function(e){n.focus(e)}),this.selection.on("*",function(e,t){-1===r.inArray(e,i)&&n.trigger(e,t)})},a.prototype._registerDropdownEvents=function(){var n=this;this.dropdown.on("*",function(e,t){n.trigger(e,t)})},a.prototype._registerResultsEvents=function(){var n=this;this.results.on("*",function(e,t){n.trigger(e,t)})},a.prototype._registerEvents=function(){var n=this;this.on("open",function(){n.$container.addClass("select2-container--open")}),this.on("close",function(){n.$container.removeClass("select2-container--open")}),this.on("enable",function(){n.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){n.$container.addClass("select2-container--disabled")}),this.on("blur",function(){n.$container.removeClass("select2-container--focus")}),this.on("query",function(t){n.isOpen()||n.trigger("open",{}),this.dataAdapter.query(t,function(e){n.trigger("results:all",{data:e,query:t})})}),this.on("query:append",function(t){this.dataAdapter.query(t,function(e){n.trigger("results:append",{data:e,query:t})})}),this.on("keypress",function(e){var t=e.which;n.isOpen()?t===i.ESC||t===i.TAB||t===i.UP&&e.altKey?(n.close(e),e.preventDefault()):t===i.ENTER?(n.trigger("results:select",{}),e.preventDefault()):t===i.SPACE&&e.ctrlKey?(n.trigger("results:toggle",{}),e.preventDefault()):t===i.UP?(n.trigger("results:previous",{}),e.preventDefault()):t===i.DOWN&&(n.trigger("results:next",{}),e.preventDefault()):(t===i.ENTER||t===i.SPACE||t===i.DOWN&&e.altKey)&&(n.open(),e.preventDefault())})},a.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.isDisabled()?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},a.prototype._isChangeMutation=function(e,t){var n=!1,i=this;if(!e||!e.target||"OPTION"===e.target.nodeName||"OPTGROUP"===e.target.nodeName){if(t)if(t.addedNodes&&0<t.addedNodes.length)for(var o=0;o<t.addedNodes.length;o++)t.addedNodes[o].selected&&(n=!0);else t.removedNodes&&0<t.removedNodes.length?n=!0:r.isArray(t)&&r.each(t,function(e,t){if(i._isChangeMutation(e,t))return!(n=!0)});else n=!0;return n}},a.prototype._syncSubtree=function(e,t){var t=this._isChangeMutation(e,t),n=this;t&&this.dataAdapter.current(function(e){n.trigger("selection:update",{data:e})})},a.prototype.trigger=function(e,t){var n=a.__super__.trigger,i={open:"opening",close:"closing",select:"selecting",unselect:"unselecting",clear:"clearing"};if(void 0===t&&(t={}),e in i){var o={prevented:!1,name:e,args:t};if(n.call(this,i[e],o),o.prevented)return void(t.prevented=!0)}n.call(this,e,t)},a.prototype.toggleDropdown=function(){this.isDisabled()||(this.isOpen()?this.close():this.open())},a.prototype.open=function(){this.isOpen()||this.isDisabled()||this.trigger("query",{})},a.prototype.close=function(e){this.isOpen()&&this.trigger("close",{originalEvent:e})},a.prototype.isEnabled=function(){return!this.isDisabled()},a.prototype.isDisabled=function(){return this.options.get("disabled")},a.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},a.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},a.prototype.focus=function(e){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},a.prototype.enable=function(e){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.');e=!(e=null==e||0===e.length?[!0]:e)[0];this.$element.prop("disabled",e)},a.prototype.data=function(){this.options.get("debug")&&0<arguments.length&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var t=[];return this.dataAdapter.current(function(e){t=e}),t},a.prototype.val=function(e){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==e||0===e.length)return this.$element.val();e=e[0];r.isArray(e)&&(e=r.map(e,function(e){return e.toString()})),this.$element.val(e).trigger("input").trigger("change")},a.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",s.GetData(this.$element[0],"old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),s.RemoveData(this.$element[0]),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},a.prototype.render=function(){var e=r('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),s.StoreData(e[0],"element",this.$element),e},a}),u.define("select2/compat/utils",["jquery"],function(s){return{syncCssClasses:function(e,t,n){var i,o=[],r=s.trim(e.attr("class"));r&&s((r=""+r).split(/\s+/)).each(function(){0===this.indexOf("select2-")&&o.push(this)}),(r=s.trim(t.attr("class")))&&s((r=""+r).split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&null!=(i=n(this))&&o.push(i)}),e.attr("class",o.join(" "))}}}),u.define("select2/compat/containerCss",["jquery","./utils"],function(r,s){function a(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("containerCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i,o=this.options.get("adaptContainerCssClass");o=o||a,-1!==n.indexOf(":all:")&&(n=n.replace(":all:",""),i=o,o=function(e){var t=i(e);return null!=t?t+" "+e:e});e=this.options.get("containerCss")||{};return r.isFunction(e)&&(e=e(this.$element)),s.syncCssClasses(t,this.$element,o),t.css(e),t.addClass(n),t},e}),u.define("select2/compat/dropdownCss",["jquery","./utils"],function(r,s){function a(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("dropdownCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i,o=this.options.get("adaptDropdownCssClass");o=o||a,-1!==n.indexOf(":all:")&&(n=n.replace(":all:",""),i=o,o=function(e){var t=i(e);return null!=t?t+" "+e:e});e=this.options.get("dropdownCss")||{};return r.isFunction(e)&&(e=e(this.$element)),s.syncCssClasses(t,this.$element,o),t.css(e),t.addClass(n),t},e}),u.define("select2/compat/initSelection",["jquery"],function(i){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=n.get("initSelection"),this._isInitialized=!1,e.call(this,t,n)}return e.prototype.current=function(e,t){var n=this;this._isInitialized?e.call(this,t):this.initSelection.call(null,this.$element,function(e){n._isInitialized=!0,i.isArray(e)||(e=[e]),t(e)})},e}),u.define("select2/compat/inputData",["jquery","../utils"],function(r,n){function e(e,t,n){this._currentData=[],this._valueSeparator=n.get("valueSeparator")||",","hidden"===t.prop("type")&&n.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `<select>` element instead."),e.call(this,t,n)}return e.prototype.current=function(e,t){for(var n=[],i=0;i<this._currentData.length;i++){var o=this._currentData[i];n.push.apply(n,function e(t,n){var i=[];return t.selected||-1!==r.inArray(t.id,n)?(t.selected=!0,i.push(t)):t.selected=!1,t.children&&i.push.apply(i,e(t.children,n)),i}(o,this.$element.val().split(this._valueSeparator)))}t(n)},e.prototype.select=function(e,t){var n;this.options.get("multiple")?(n=this.$element.val(),n+=this._valueSeparator+t.id,this.$element.val(n)):(this.current(function(e){r.map(e,function(e){e.selected=!1})}),this.$element.val(t.id)),this.$element.trigger("input").trigger("change")},e.prototype.unselect=function(e,o){var r=this;o.selected=!1,this.current(function(e){for(var t=[],n=0;n<e.length;n++){var i=e[n];o.id!=i.id&&t.push(i.id)}r.$element.val(t.join(r._valueSeparator)),r.$element.trigger("input").trigger("change")})},e.prototype.query=function(e,t,n){for(var i=[],o=0;o<this._currentData.length;o++){var r=this._currentData[o],r=this.matches(t,r);null!==r&&i.push(r)}n({results:i})},e.prototype.addOptions=function(e,t){t=r.map(t,function(e){return n.GetData(e[0],"data")});this._currentData.push.apply(this._currentData,t)},e}),u.define("select2/compat/matcher",["jquery"],function(s){return function(r){return function(e,t){var n=s.extend(!0,{},t);if(null==e.term||""===s.trim(e.term))return n;if(t.children){for(var i=t.children.length-1;0<=i;i--){var o=t.children[i];r(e.term,o.text,o)||n.children.splice(i,1)}if(0<n.children.length)return n}return r(e.term,t.text,t)?n:null}}}),u.define("select2/compat/query",[],function(){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `query` option has been deprecated in favor of a custom data adapter that overrides the `query` method. Support will be removed for the `query` option in future versions of Select2."),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.callback=n,this.options.get("query").call(null,t)},e}),u.define("select2/dropdown/attachContainer",[],function(){function e(e,t,n){e.call(this,t,n)}return e.prototype.position=function(e,t,n){n.find(".dropdown-wrapper").append(t),t.addClass("select2-dropdown--below"),n.addClass("select2-container--below")},e}),u.define("select2/dropdown/stopPropagation",[],function(){function e(){}return e.prototype.bind=function(e,t,n){e.call(this,t,n);this.$dropdown.on(["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"].join(" "),function(e){e.stopPropagation()})},e}),u.define("select2/selection/stopPropagation",[],function(){function e(){}return e.prototype.bind=function(e,t,n){e.call(this,t,n);this.$selection.on(["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"].join(" "),function(e){e.stopPropagation()})},e}),a=function(u){var d,p,e=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],t="onwheel"in document||9<=document.documentMode?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],h=Array.prototype.slice;if(u.event.fixHooks)for(var n=e.length;n;)u.event.fixHooks[e[--n]]=u.event.mouseHooks;var f=u.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var e=t.length;e;)this.addEventListener(t[--e],i,!1);else this.onmousewheel=i;u.data(this,"mousewheel-line-height",f.getLineHeight(this)),u.data(this,"mousewheel-page-height",f.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var e=t.length;e;)this.removeEventListener(t[--e],i,!1);else this.onmousewheel=null;u.removeData(this,"mousewheel-line-height"),u.removeData(this,"mousewheel-page-height")},getLineHeight:function(e){var t=u(e),e=t["offsetParent"in u.fn?"offsetParent":"parent"]();return e.length||(e=u("body")),parseInt(e.css("fontSize"),10)||parseInt(t.css("fontSize"),10)||16},getPageHeight:function(e){return u(e).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function i(e){var t,n=e||window.event,i=h.call(arguments,1),o=0,r=0,s=0,a=0,l=0,c=0;if((e=u.event.fix(n)).type="mousewheel","detail"in n&&(s=-1*n.detail),"wheelDelta"in n&&(s=n.wheelDelta),"wheelDeltaY"in n&&(s=n.wheelDeltaY),"wheelDeltaX"in n&&(r=-1*n.wheelDeltaX),"axis"in n&&n.axis===n.HORIZONTAL_AXIS&&(r=-1*s,s=0),o=0===s?r:s,"deltaY"in n&&(o=s=-1*n.deltaY),"deltaX"in n&&(r=n.deltaX,0===s&&(o=-1*r)),0!==s||0!==r)return 1===n.deltaMode?(o*=t=u.data(this,"mousewheel-line-height"),s*=t,r*=t):2===n.deltaMode&&(o*=t=u.data(this,"mousewheel-page-height"),s*=t,r*=t),a=Math.max(Math.abs(s),Math.abs(r)),(!p||a<p)&&m(n,p=a)&&(p/=40),m(n,a)&&(o/=40,r/=40,s/=40),o=Math[1<=o?"floor":"ceil"](o/p),r=Math[1<=r?"floor":"ceil"](r/p),s=Math[1<=s?"floor":"ceil"](s/p),f.settings.normalizeOffset&&this.getBoundingClientRect&&(a=this.getBoundingClientRect(),l=e.clientX-a.left,c=e.clientY-a.top),e.deltaX=r,e.deltaY=s,e.deltaFactor=p,e.offsetX=l,e.offsetY=c,e.deltaMode=0,i.unshift(e,o,r,s),d&&clearTimeout(d),d=setTimeout(g,200),(u.event.dispatch||u.event.handle).apply(this,i)}function g(){p=null}function m(e,t){return f.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120==0}u.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})},"function"==typeof u.define&&u.define.amd?u.define("jquery-mousewheel",["jquery"],a):"object"==typeof exports?module.exports=a:a(t),u.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults","./select2/utils"],function(o,e,r,t,s){var a;return null==o.fn.select2&&(a=["open","close","destroy"],o.fn.select2=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=o.extend(!0,{},t);new r(o(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=s.GetData(this,"select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,i)}),-1<o.inArray(t,a)?this:n}),null==o.fn.select2.defaults&&(o.fn.select2.defaults=t),r}),{define:u.define,require:u.require});function w(e,t){return i.call(e,t)}function l(e,t){var n,i,o,r,s,a,l,c,u,d,p=t&&t.split("/"),h=v.map,f=h&&h["*"]||{};if(e){for(t=(e=e.split("/")).length-1,v.nodeIdCompat&&_.test(e[t])&&(e[t]=e[t].replace(_,"")),"."===e[0].charAt(0)&&p&&(e=p.slice(0,p.length-1).concat(e)),c=0;c<e.length;c++)"."===(d=e[c])?(e.splice(c,1),--c):".."===d&&(0===c||1===c&&".."===e[2]||".."===e[c-1]||0<c&&(e.splice(c-1,2),c-=2));e=e.join("/")}if((p||f)&&h){for(c=(n=e.split("/")).length;0<c;--c){if(i=n.slice(0,c).join("/"),p)for(u=p.length;0<u;--u)if(o=(o=h[p.slice(0,u).join("/")])&&o[i]){r=o,s=c;break}if(r)break;!a&&f&&f[i]&&(a=f[i],l=c)}!r&&a&&(r=a,s=l),r&&(n.splice(0,s,r),e=n.join("/"))}return e}function b(t,n){return function(){var e=o.call(arguments,0);return"string"!=typeof e[0]&&1===e.length&&e.push(null),s.apply(p,e.concat([t,n]))}}function A(e){var t;if(w(m,e)&&(t=m[e],delete m[e],y[e]=!0,r.apply(p,t)),!w(g,e)&&!w(y,e))throw new Error("No "+e);return g[e]}function c(e){var t,n=e?e.indexOf("!"):-1;return-1<n&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function x(e){return e?c(e):[]}var u=a.require("jquery.select2");return t.fn.select2.amd=a,u});
|
|
|
|
assets/inc/select2/4/select2.js
CHANGED
@@ -1,27 +1,41 @@
|
|
1 |
/*!
|
2 |
-
* Select2 4.0.
|
3 |
* https://select2.github.io
|
4 |
*
|
5 |
* Released under the MIT license
|
6 |
* https://github.com/select2/select2/blob/master/LICENSE.md
|
7 |
*/
|
8 |
-
(function (factory) {
|
9 |
if (typeof define === 'function' && define.amd) {
|
10 |
// AMD. Register as an anonymous module.
|
11 |
define(['jquery'], factory);
|
12 |
-
} else if (typeof
|
13 |
// Node/CommonJS
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
} else {
|
16 |
// Browser globals
|
17 |
factory(jQuery);
|
18 |
}
|
19 |
-
}(function (jQuery) {
|
20 |
// This is needed so we can catch the AMD loader configuration and use it
|
21 |
// The inner file should be wrapped (by `banner.start.js`) in a function that
|
22 |
// returns the AMD loader references.
|
23 |
-
var S2 =
|
24 |
-
(function () {
|
25 |
// Restore the Select2 AMD loader so it can be used
|
26 |
// Needed mostly in the language files, where the loader is not inserted
|
27 |
if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
|
@@ -30,13 +44,11 @@
|
|
30 |
var S2;(function () { if (!S2 || !S2.requirejs) {
|
31 |
if (!S2) { S2 = {}; } else { require = S2; }
|
32 |
/**
|
33 |
-
* @license almond 0.3.
|
34 |
-
*
|
35 |
-
* see: http://github.com/jrburke/almond for details
|
36 |
*/
|
37 |
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
38 |
//be followed.
|
39 |
-
/*jslint sloppy: true */
|
40 |
/*global setTimeout: false */
|
41 |
|
42 |
var requirejs, require, define;
|
@@ -64,60 +76,58 @@ var requirejs, require, define;
|
|
64 |
*/
|
65 |
function normalize(name, baseName) {
|
66 |
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
67 |
-
foundI, foundStarMap, starI, i, j, part,
|
68 |
baseParts = baseName && baseName.split("/"),
|
69 |
map = config.map,
|
70 |
starMap = (map && map['*']) || {};
|
71 |
|
72 |
//Adjust any relative paths.
|
73 |
-
if (name
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
}
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
//baseName
|
89 |
-
//
|
90 |
-
|
91 |
-
|
92 |
-
//
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
111 |
}
|
112 |
}
|
113 |
-
//end trimDots
|
114 |
-
|
115 |
-
name = name.join("/");
|
116 |
-
} else if (name.indexOf('./') === 0) {
|
117 |
-
// No baseName, so this is ID is resolved relative
|
118 |
-
// to baseUrl, pull off the leading dot.
|
119 |
-
name = name.substring(2);
|
120 |
}
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
//Apply map config if available.
|
@@ -230,32 +240,39 @@ var requirejs, require, define;
|
|
230 |
return [prefix, name];
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
/**
|
234 |
* Makes a name map, normalizing the name, and using a plugin
|
235 |
* for normalization if necessary. Grabs a ref to plugin
|
236 |
* too, as an optimization.
|
237 |
*/
|
238 |
-
makeMap = function (name,
|
239 |
var plugin,
|
240 |
parts = splitPrefix(name),
|
241 |
-
prefix = parts[0]
|
|
|
242 |
|
243 |
name = parts[1];
|
244 |
|
245 |
if (prefix) {
|
246 |
-
prefix = normalize(prefix,
|
247 |
plugin = callDep(prefix);
|
248 |
}
|
249 |
|
250 |
//Normalize according
|
251 |
if (prefix) {
|
252 |
if (plugin && plugin.normalize) {
|
253 |
-
name = plugin.normalize(name, makeNormalize(
|
254 |
} else {
|
255 |
-
name = normalize(name,
|
256 |
}
|
257 |
} else {
|
258 |
-
name = normalize(name,
|
259 |
parts = splitPrefix(name);
|
260 |
prefix = parts[0];
|
261 |
name = parts[1];
|
@@ -302,13 +319,14 @@ var requirejs, require, define;
|
|
302 |
};
|
303 |
|
304 |
main = function (name, deps, callback, relName) {
|
305 |
-
var cjsModule, depName, ret, map, i,
|
306 |
args = [],
|
307 |
callbackType = typeof callback,
|
308 |
usingExports;
|
309 |
|
310 |
//Use name if no relName
|
311 |
relName = relName || name;
|
|
|
312 |
|
313 |
//Call the callback to define the module, if necessary.
|
314 |
if (callbackType === 'undefined' || callbackType === 'function') {
|
@@ -317,7 +335,7 @@ var requirejs, require, define;
|
|
317 |
//Default to [require, exports, module] if no deps
|
318 |
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
319 |
for (i = 0; i < deps.length; i += 1) {
|
320 |
-
map = makeMap(deps[i],
|
321 |
depName = map.f;
|
322 |
|
323 |
//Fast path CommonJS standard dependencies.
|
@@ -373,7 +391,7 @@ var requirejs, require, define;
|
|
373 |
//deps arg is the module name, and second arg (if passed)
|
374 |
//is just the relName.
|
375 |
//Normalize module name, if it contains . or ..
|
376 |
-
return callDep(makeMap(deps, callback).f);
|
377 |
} else if (!deps.splice) {
|
378 |
//deps is a config object, not an array.
|
379 |
config = deps;
|
@@ -556,10 +574,10 @@ S2.define('select2/utils',[
|
|
556 |
DecoratedClass.prototype = new ctr();
|
557 |
|
558 |
for (var m = 0; m < superMethods.length; m++) {
|
559 |
-
|
560 |
|
561 |
-
|
562 |
-
|
563 |
}
|
564 |
|
565 |
var calledMethod = function (methodName) {
|
@@ -754,6 +772,70 @@ S2.define('select2/utils',[
|
|
754 |
$element.append($nodes);
|
755 |
};
|
756 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
757 |
return Utils;
|
758 |
});
|
759 |
|
@@ -773,7 +855,7 @@ S2.define('select2/results',[
|
|
773 |
|
774 |
Results.prototype.render = function () {
|
775 |
var $results = $(
|
776 |
-
'<ul class="select2-results__options" role="
|
777 |
);
|
778 |
|
779 |
if (this.options.get('multiple')) {
|
@@ -796,7 +878,7 @@ S2.define('select2/results',[
|
|
796 |
this.hideLoading();
|
797 |
|
798 |
var $message = $(
|
799 |
-
'<li role="
|
800 |
' class="select2-results__option"></li>'
|
801 |
);
|
802 |
|
@@ -889,7 +971,7 @@ S2.define('select2/results',[
|
|
889 |
$options.each(function () {
|
890 |
var $option = $(this);
|
891 |
|
892 |
-
var item =
|
893 |
|
894 |
// id needs to be converted to a string when comparing
|
895 |
var id = '' + item.id;
|
@@ -930,11 +1012,16 @@ S2.define('select2/results',[
|
|
930 |
option.className = 'select2-results__option';
|
931 |
|
932 |
var attrs = {
|
933 |
-
'role': '
|
934 |
'aria-selected': 'false'
|
935 |
};
|
936 |
|
937 |
-
|
|
|
|
|
|
|
|
|
|
|
938 |
delete attrs['aria-selected'];
|
939 |
attrs['aria-disabled'] = 'true';
|
940 |
}
|
@@ -994,7 +1081,7 @@ S2.define('select2/results',[
|
|
994 |
this.template(data, option);
|
995 |
}
|
996 |
|
997 |
-
|
998 |
|
999 |
return option;
|
1000 |
};
|
@@ -1035,7 +1122,10 @@ S2.define('select2/results',[
|
|
1035 |
}
|
1036 |
|
1037 |
self.setClasses();
|
1038 |
-
|
|
|
|
|
|
|
1039 |
});
|
1040 |
|
1041 |
container.on('unselect', function () {
|
@@ -1044,7 +1134,10 @@ S2.define('select2/results',[
|
|
1044 |
}
|
1045 |
|
1046 |
self.setClasses();
|
1047 |
-
|
|
|
|
|
|
|
1048 |
});
|
1049 |
|
1050 |
container.on('open', function () {
|
@@ -1080,7 +1173,7 @@ S2.define('select2/results',[
|
|
1080 |
return;
|
1081 |
}
|
1082 |
|
1083 |
-
var data = $highlighted
|
1084 |
|
1085 |
if ($highlighted.attr('aria-selected') == 'true') {
|
1086 |
self.trigger('close', {});
|
@@ -1098,8 +1191,9 @@ S2.define('select2/results',[
|
|
1098 |
|
1099 |
var currentIndex = $options.index($highlighted);
|
1100 |
|
1101 |
-
// If we are already at
|
1102 |
-
|
|
|
1103 |
return;
|
1104 |
}
|
1105 |
|
@@ -1192,7 +1286,7 @@ S2.define('select2/results',[
|
|
1192 |
function (evt) {
|
1193 |
var $this = $(this);
|
1194 |
|
1195 |
-
var data =
|
1196 |
|
1197 |
if ($this.attr('aria-selected') === 'true') {
|
1198 |
if (self.options.get('multiple')) {
|
@@ -1215,7 +1309,7 @@ S2.define('select2/results',[
|
|
1215 |
|
1216 |
this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
|
1217 |
function (evt) {
|
1218 |
-
var data =
|
1219 |
|
1220 |
self.getHighlightedResults()
|
1221 |
.removeClass('select2-results__option--highlighted');
|
@@ -1330,14 +1424,15 @@ S2.define('select2/selection/base',[
|
|
1330 |
|
1331 |
this._tabindex = 0;
|
1332 |
|
1333 |
-
if (this.$element
|
1334 |
-
this._tabindex = this.$element
|
1335 |
} else if (this.$element.attr('tabindex') != null) {
|
1336 |
this._tabindex = this.$element.attr('tabindex');
|
1337 |
}
|
1338 |
|
1339 |
$selection.attr('title', this.$element.attr('title'));
|
1340 |
$selection.attr('tabindex', this._tabindex);
|
|
|
1341 |
|
1342 |
this.$selection = $selection;
|
1343 |
|
@@ -1347,7 +1442,6 @@ S2.define('select2/selection/base',[
|
|
1347 |
BaseSelection.prototype.bind = function (container, $container) {
|
1348 |
var self = this;
|
1349 |
|
1350 |
-
var id = container.id + '-container';
|
1351 |
var resultsId = container.id + '-results';
|
1352 |
|
1353 |
this.container = container;
|
@@ -1390,17 +1484,19 @@ S2.define('select2/selection/base',[
|
|
1390 |
self.$selection.removeAttr('aria-activedescendant');
|
1391 |
self.$selection.removeAttr('aria-owns');
|
1392 |
|
1393 |
-
self.$selection.focus
|
1394 |
|
1395 |
self._detachCloseHandler(container);
|
1396 |
});
|
1397 |
|
1398 |
container.on('enable', function () {
|
1399 |
self.$selection.attr('tabindex', self._tabindex);
|
|
|
1400 |
});
|
1401 |
|
1402 |
container.on('disable', function () {
|
1403 |
self.$selection.attr('tabindex', '-1');
|
|
|
1404 |
});
|
1405 |
};
|
1406 |
|
@@ -1423,7 +1519,6 @@ S2.define('select2/selection/base',[
|
|
1423 |
};
|
1424 |
|
1425 |
BaseSelection.prototype._attachCloseHandler = function (container) {
|
1426 |
-
var self = this;
|
1427 |
|
1428 |
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
1429 |
var $target = $(e.target);
|
@@ -1433,13 +1528,11 @@ S2.define('select2/selection/base',[
|
|
1433 |
var $all = $('.select2.select2-container--open');
|
1434 |
|
1435 |
$all.each(function () {
|
1436 |
-
var $this = $(this);
|
1437 |
-
|
1438 |
if (this == $select[0]) {
|
1439 |
return;
|
1440 |
}
|
1441 |
|
1442 |
-
var $element =
|
1443 |
|
1444 |
$element.select2('close');
|
1445 |
});
|
@@ -1463,6 +1556,27 @@ S2.define('select2/selection/base',[
|
|
1463 |
throw new Error('The `update` method must be defined in child classes.');
|
1464 |
};
|
1465 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1466 |
return BaseSelection;
|
1467 |
});
|
1468 |
|
@@ -1500,7 +1614,10 @@ S2.define('select2/selection/single',[
|
|
1500 |
|
1501 |
var id = container.id + '-container';
|
1502 |
|
1503 |
-
this.$selection.find('.select2-selection__rendered')
|
|
|
|
|
|
|
1504 |
this.$selection.attr('aria-labelledby', id);
|
1505 |
|
1506 |
this.$selection.on('mousedown', function (evt) {
|
@@ -1524,17 +1641,15 @@ S2.define('select2/selection/single',[
|
|
1524 |
|
1525 |
container.on('focus', function (evt) {
|
1526 |
if (!container.isOpen()) {
|
1527 |
-
self.$selection.focus
|
1528 |
}
|
1529 |
});
|
1530 |
-
|
1531 |
-
container.on('selection:update', function (params) {
|
1532 |
-
self.update(params.data);
|
1533 |
-
});
|
1534 |
};
|
1535 |
|
1536 |
SingleSelection.prototype.clear = function () {
|
1537 |
-
this.$selection.find('.select2-selection__rendered')
|
|
|
|
|
1538 |
};
|
1539 |
|
1540 |
SingleSelection.prototype.display = function (data, container) {
|
@@ -1560,7 +1675,14 @@ S2.define('select2/selection/single',[
|
|
1560 |
var formatted = this.display(selection, $rendered);
|
1561 |
|
1562 |
$rendered.empty().append(formatted);
|
1563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1564 |
};
|
1565 |
|
1566 |
return SingleSelection;
|
@@ -1605,14 +1727,14 @@ S2.define('select2/selection/multiple',[
|
|
1605 |
'.select2-selection__choice__remove',
|
1606 |
function (evt) {
|
1607 |
// Ignore the event if it is disabled
|
1608 |
-
if (self.
|
1609 |
return;
|
1610 |
}
|
1611 |
|
1612 |
var $remove = $(this);
|
1613 |
var $selection = $remove.parent();
|
1614 |
|
1615 |
-
var data = $selection
|
1616 |
|
1617 |
self.trigger('unselect', {
|
1618 |
originalEvent: evt,
|
@@ -1623,7 +1745,9 @@ S2.define('select2/selection/multiple',[
|
|
1623 |
};
|
1624 |
|
1625 |
MultipleSelection.prototype.clear = function () {
|
1626 |
-
this.$selection.find('.select2-selection__rendered')
|
|
|
|
|
1627 |
};
|
1628 |
|
1629 |
MultipleSelection.prototype.display = function (data, container) {
|
@@ -1661,9 +1785,14 @@ S2.define('select2/selection/multiple',[
|
|
1661 |
var formatted = this.display(selection, $selection);
|
1662 |
|
1663 |
$selection.append(formatted);
|
1664 |
-
$selection.prop('title', selection.title || selection.text);
|
1665 |
|
1666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1667 |
|
1668 |
$selections.push($selection);
|
1669 |
}
|
@@ -1728,8 +1857,9 @@ S2.define('select2/selection/placeholder',[
|
|
1728 |
|
1729 |
S2.define('select2/selection/allowClear',[
|
1730 |
'jquery',
|
1731 |
-
'../keys'
|
1732 |
-
|
|
|
1733 |
function AllowClear () { }
|
1734 |
|
1735 |
AllowClear.prototype.bind = function (decorated, container, $container) {
|
@@ -1758,7 +1888,7 @@ S2.define('select2/selection/allowClear',[
|
|
1758 |
|
1759 |
AllowClear.prototype._handleClear = function (_, evt) {
|
1760 |
// Ignore the event if it is disabled
|
1761 |
-
if (this.
|
1762 |
return;
|
1763 |
}
|
1764 |
|
@@ -1771,10 +1901,22 @@ S2.define('select2/selection/allowClear',[
|
|
1771 |
|
1772 |
evt.stopPropagation();
|
1773 |
|
1774 |
-
var data = $clear
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1775 |
|
1776 |
for (var d = 0; d < data.length; d++) {
|
1777 |
-
|
1778 |
data: data[d]
|
1779 |
};
|
1780 |
|
@@ -1784,11 +1926,12 @@ S2.define('select2/selection/allowClear',[
|
|
1784 |
|
1785 |
// If the event was prevented, don't clear it out.
|
1786 |
if (unselectData.prevented) {
|
|
|
1787 |
return;
|
1788 |
}
|
1789 |
}
|
1790 |
|
1791 |
-
this.$element.
|
1792 |
|
1793 |
this.trigger('toggle', {});
|
1794 |
};
|
@@ -1811,12 +1954,14 @@ S2.define('select2/selection/allowClear',[
|
|
1811 |
return;
|
1812 |
}
|
1813 |
|
|
|
|
|
1814 |
var $remove = $(
|
1815 |
-
'<span class="select2-selection__clear">' +
|
1816 |
'×' +
|
1817 |
'</span>'
|
1818 |
);
|
1819 |
-
$remove
|
1820 |
|
1821 |
this.$selection.find('.select2-selection__rendered').prepend($remove);
|
1822 |
};
|
@@ -1837,8 +1982,8 @@ S2.define('select2/selection/search',[
|
|
1837 |
var $search = $(
|
1838 |
'<li class="select2-search select2-search--inline">' +
|
1839 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
1840 |
-
' autocomplete="off" autocorrect="off" autocapitalize="
|
1841 |
-
' spellcheck="false" role="
|
1842 |
'</li>'
|
1843 |
);
|
1844 |
|
@@ -1855,14 +2000,18 @@ S2.define('select2/selection/search',[
|
|
1855 |
Search.prototype.bind = function (decorated, container, $container) {
|
1856 |
var self = this;
|
1857 |
|
|
|
|
|
1858 |
decorated.call(this, container, $container);
|
1859 |
|
1860 |
container.on('open', function () {
|
|
|
1861 |
self.$search.trigger('focus');
|
1862 |
});
|
1863 |
|
1864 |
container.on('close', function () {
|
1865 |
self.$search.val('');
|
|
|
1866 |
self.$search.removeAttr('aria-activedescendant');
|
1867 |
self.$search.trigger('focus');
|
1868 |
});
|
@@ -1882,7 +2031,11 @@ S2.define('select2/selection/search',[
|
|
1882 |
});
|
1883 |
|
1884 |
container.on('results:focus', function (params) {
|
1885 |
-
|
|
|
|
|
|
|
|
|
1886 |
});
|
1887 |
|
1888 |
this.$selection.on('focusin', '.select2-search--inline', function (evt) {
|
@@ -1907,7 +2060,7 @@ S2.define('select2/selection/search',[
|
|
1907 |
.prev('.select2-selection__choice');
|
1908 |
|
1909 |
if ($previousChoice.length > 0) {
|
1910 |
-
var item = $previousChoice
|
1911 |
|
1912 |
self.searchRemoveChoice(item);
|
1913 |
|
@@ -1916,6 +2069,12 @@ S2.define('select2/selection/search',[
|
|
1916 |
}
|
1917 |
});
|
1918 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1919 |
// Try to detect the IE version should the `documentMode` property that
|
1920 |
// is stored on the document. This is only implemented in IE and is
|
1921 |
// slightly cleaner than doing a user agent check.
|
@@ -2001,7 +2160,7 @@ S2.define('select2/selection/search',[
|
|
2001 |
|
2002 |
this.resizeSearch();
|
2003 |
if (searchHadFocus) {
|
2004 |
-
this.$search.focus
|
2005 |
}
|
2006 |
};
|
2007 |
|
@@ -2034,7 +2193,7 @@ S2.define('select2/selection/search',[
|
|
2034 |
var width = '';
|
2035 |
|
2036 |
if (this.$search.attr('placeholder') !== '') {
|
2037 |
-
width = this.$selection.find('.select2-selection__rendered').
|
2038 |
} else {
|
2039 |
var minimumWidth = this.$search.val().length + 1;
|
2040 |
|
@@ -2058,10 +2217,13 @@ S2.define('select2/selection/eventRelay',[
|
|
2058 |
'open', 'opening',
|
2059 |
'close', 'closing',
|
2060 |
'select', 'selecting',
|
2061 |
-
'unselect', 'unselecting'
|
|
|
2062 |
];
|
2063 |
|
2064 |
-
var preventableEvents = [
|
|
|
|
|
2065 |
|
2066 |
decorated.call(this, container, $container);
|
2067 |
|
@@ -2394,6 +2556,7 @@ S2.define('select2/diacritics',[
|
|
2394 |
'\u019F': 'O',
|
2395 |
'\uA74A': 'O',
|
2396 |
'\uA74C': 'O',
|
|
|
2397 |
'\u01A2': 'OI',
|
2398 |
'\uA74E': 'OO',
|
2399 |
'\u0222': 'OU',
|
@@ -2803,6 +2966,7 @@ S2.define('select2/diacritics',[
|
|
2803 |
'\uA74B': 'o',
|
2804 |
'\uA74D': 'o',
|
2805 |
'\u0275': 'o',
|
|
|
2806 |
'\u01A3': 'oi',
|
2807 |
'\u0223': 'ou',
|
2808 |
'\uA74F': 'oo',
|
@@ -2971,8 +3135,9 @@ S2.define('select2/diacritics',[
|
|
2971 |
'\u03CD': '\u03C5',
|
2972 |
'\u03CB': '\u03C5',
|
2973 |
'\u03B0': '\u03C5',
|
2974 |
-
'\
|
2975 |
-
'\u03C2': '\u03C3'
|
|
|
2976 |
};
|
2977 |
|
2978 |
return diacritics;
|
@@ -3057,7 +3222,7 @@ S2.define('select2/data/select',[
|
|
3057 |
if ($(data.element).is('option')) {
|
3058 |
data.element.selected = true;
|
3059 |
|
3060 |
-
this.$element.trigger('change');
|
3061 |
|
3062 |
return;
|
3063 |
}
|
@@ -3078,13 +3243,13 @@ S2.define('select2/data/select',[
|
|
3078 |
}
|
3079 |
|
3080 |
self.$element.val(val);
|
3081 |
-
self.$element.trigger('change');
|
3082 |
});
|
3083 |
} else {
|
3084 |
var val = data.id;
|
3085 |
|
3086 |
this.$element.val(val);
|
3087 |
-
this.$element.trigger('change');
|
3088 |
}
|
3089 |
};
|
3090 |
|
@@ -3100,7 +3265,7 @@ S2.define('select2/data/select',[
|
|
3100 |
if ($(data.element).is('option')) {
|
3101 |
data.element.selected = false;
|
3102 |
|
3103 |
-
this.$element.trigger('change');
|
3104 |
|
3105 |
return;
|
3106 |
}
|
@@ -3118,7 +3283,7 @@ S2.define('select2/data/select',[
|
|
3118 |
|
3119 |
self.$element.val(val);
|
3120 |
|
3121 |
-
self.$element.trigger('change');
|
3122 |
});
|
3123 |
};
|
3124 |
|
@@ -3140,7 +3305,7 @@ S2.define('select2/data/select',[
|
|
3140 |
// Remove anything added to child elements
|
3141 |
this.$element.find('*').each(function () {
|
3142 |
// Remove any custom data set by Select2
|
3143 |
-
|
3144 |
});
|
3145 |
};
|
3146 |
|
@@ -3191,7 +3356,7 @@ S2.define('select2/data/select',[
|
|
3191 |
}
|
3192 |
}
|
3193 |
|
3194 |
-
if (data.id) {
|
3195 |
option.value = data.id;
|
3196 |
}
|
3197 |
|
@@ -3213,7 +3378,7 @@ S2.define('select2/data/select',[
|
|
3213 |
normalizedData.element = option;
|
3214 |
|
3215 |
// Override the option's data with the combined data
|
3216 |
-
|
3217 |
|
3218 |
return $option;
|
3219 |
};
|
@@ -3221,7 +3386,7 @@ S2.define('select2/data/select',[
|
|
3221 |
SelectAdapter.prototype.item = function ($option) {
|
3222 |
var data = {};
|
3223 |
|
3224 |
-
data =
|
3225 |
|
3226 |
if (data != null) {
|
3227 |
return data;
|
@@ -3259,13 +3424,13 @@ S2.define('select2/data/select',[
|
|
3259 |
data = this._normalizeItem(data);
|
3260 |
data.element = $option[0];
|
3261 |
|
3262 |
-
|
3263 |
|
3264 |
return data;
|
3265 |
};
|
3266 |
|
3267 |
SelectAdapter.prototype._normalizeItem = function (item) {
|
3268 |
-
if (
|
3269 |
item = {
|
3270 |
id: item,
|
3271 |
text: item
|
@@ -3311,15 +3476,19 @@ S2.define('select2/data/array',[
|
|
3311 |
'jquery'
|
3312 |
], function (SelectAdapter, Utils, $) {
|
3313 |
function ArrayAdapter ($element, options) {
|
3314 |
-
|
3315 |
|
3316 |
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
3317 |
-
|
3318 |
-
this.addOptions(this.convertToOptions(data));
|
3319 |
}
|
3320 |
|
3321 |
Utils.Extend(ArrayAdapter, SelectAdapter);
|
3322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3323 |
ArrayAdapter.prototype.select = function (data) {
|
3324 |
var $option = this.$element.find('option').filter(function (i, elm) {
|
3325 |
return elm.value == data.id.toString();
|
@@ -3469,7 +3638,8 @@ S2.define('select2/data/ajax',[
|
|
3469 |
}, function () {
|
3470 |
// Attempt to detect if a request was aborted
|
3471 |
// Only works if the transport exposes a status property
|
3472 |
-
if (
|
|
|
3473 |
return;
|
3474 |
}
|
3475 |
|
@@ -3550,7 +3720,10 @@ S2.define('select2/data/tags',[
|
|
3550 |
}, true)
|
3551 |
);
|
3552 |
|
3553 |
-
var
|
|
|
|
|
|
|
3554 |
|
3555 |
if (checkText || checkChildren) {
|
3556 |
if (child) {
|
@@ -3605,8 +3778,6 @@ S2.define('select2/data/tags',[
|
|
3605 |
};
|
3606 |
|
3607 |
Tags.prototype._removeOldTags = function (_) {
|
3608 |
-
var tag = this._lastTag;
|
3609 |
-
|
3610 |
var $options = this.$element.find('option[data-select2-tag]');
|
3611 |
|
3612 |
$options.each(function () {
|
@@ -3681,7 +3852,7 @@ S2.define('select2/data/tokenizer',[
|
|
3681 |
// Replace the search term if we have the search box
|
3682 |
if (this.$search.length) {
|
3683 |
this.$search.val(tokenData.term);
|
3684 |
-
this.$search.focus
|
3685 |
}
|
3686 |
|
3687 |
params.term = tokenData.term;
|
@@ -3810,10 +3981,30 @@ S2.define('select2/data/maximumSelectionLength',[
|
|
3810 |
decorated.call(this, $e, options);
|
3811 |
}
|
3812 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3813 |
MaximumSelectionLength.prototype.query =
|
3814 |
function (decorated, params, callback) {
|
3815 |
var self = this;
|
3816 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3817 |
this.current(function (currentData) {
|
3818 |
var count = currentData != null ? currentData.length : 0;
|
3819 |
if (self.maximumSelectionLength > 0 &&
|
@@ -3826,7 +4017,10 @@ S2.define('select2/data/maximumSelectionLength',[
|
|
3826 |
});
|
3827 |
return;
|
3828 |
}
|
3829 |
-
|
|
|
|
|
|
|
3830 |
});
|
3831 |
};
|
3832 |
|
@@ -3865,7 +4059,7 @@ S2.define('select2/dropdown',[
|
|
3865 |
};
|
3866 |
|
3867 |
Dropdown.prototype.position = function ($dropdown, $container) {
|
3868 |
-
// Should be
|
3869 |
};
|
3870 |
|
3871 |
Dropdown.prototype.destroy = function () {
|
@@ -3888,8 +4082,8 @@ S2.define('select2/dropdown/search',[
|
|
3888 |
var $search = $(
|
3889 |
'<span class="select2-search select2-search--dropdown">' +
|
3890 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
3891 |
-
' autocomplete="off" autocorrect="off" autocapitalize="
|
3892 |
-
' spellcheck="false" role="
|
3893 |
'</span>'
|
3894 |
);
|
3895 |
|
@@ -3904,6 +4098,8 @@ S2.define('select2/dropdown/search',[
|
|
3904 |
Search.prototype.bind = function (decorated, container, $container) {
|
3905 |
var self = this;
|
3906 |
|
|
|
|
|
3907 |
decorated.call(this, container, $container);
|
3908 |
|
3909 |
this.$search.on('keydown', function (evt) {
|
@@ -3926,23 +4122,27 @@ S2.define('select2/dropdown/search',[
|
|
3926 |
|
3927 |
container.on('open', function () {
|
3928 |
self.$search.attr('tabindex', 0);
|
|
|
3929 |
|
3930 |
-
self.$search.focus
|
3931 |
|
3932 |
window.setTimeout(function () {
|
3933 |
-
self.$search.focus
|
3934 |
}, 0);
|
3935 |
});
|
3936 |
|
3937 |
container.on('close', function () {
|
3938 |
self.$search.attr('tabindex', -1);
|
|
|
|
|
3939 |
|
3940 |
self.$search.val('');
|
|
|
3941 |
});
|
3942 |
|
3943 |
container.on('focus', function () {
|
3944 |
-
if (container.isOpen()) {
|
3945 |
-
self.$search.focus
|
3946 |
}
|
3947 |
});
|
3948 |
|
@@ -3957,6 +4157,14 @@ S2.define('select2/dropdown/search',[
|
|
3957 |
}
|
3958 |
}
|
3959 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3960 |
};
|
3961 |
|
3962 |
Search.prototype.handleSearch = function (evt) {
|
@@ -4041,6 +4249,7 @@ S2.define('select2/dropdown/infiniteScroll',[
|
|
4041 |
|
4042 |
if (this.showLoadingMore(data)) {
|
4043 |
this.$results.append(this.$loadingMore);
|
|
|
4044 |
}
|
4045 |
};
|
4046 |
|
@@ -4059,25 +4268,27 @@ S2.define('select2/dropdown/infiniteScroll',[
|
|
4059 |
self.loading = true;
|
4060 |
});
|
4061 |
|
4062 |
-
this.$results.on('scroll',
|
4063 |
-
|
4064 |
-
document.documentElement,
|
4065 |
-
self.$loadingMore[0]
|
4066 |
-
);
|
4067 |
|
4068 |
-
|
4069 |
-
|
4070 |
-
|
|
|
|
|
4071 |
|
4072 |
-
|
4073 |
-
|
4074 |
-
|
4075 |
-
self.$loadingMore.outerHeight(false);
|
4076 |
|
4077 |
-
|
4078 |
-
|
4079 |
-
|
4080 |
-
|
|
|
|
|
|
|
|
|
4081 |
};
|
4082 |
|
4083 |
InfiniteScroll.prototype.loadMore = function () {
|
@@ -4098,7 +4309,7 @@ S2.define('select2/dropdown/infiniteScroll',[
|
|
4098 |
var $option = $(
|
4099 |
'<li ' +
|
4100 |
'class="select2-results__option select2-results__option--load-more"' +
|
4101 |
-
'role="
|
4102 |
);
|
4103 |
|
4104 |
var message = this.options.get('translations').get('loadingMore');
|
@@ -4116,7 +4327,7 @@ S2.define('select2/dropdown/attachBody',[
|
|
4116 |
'../utils'
|
4117 |
], function ($, Utils) {
|
4118 |
function AttachBody (decorated, $element, options) {
|
4119 |
-
this.$dropdownParent = options.get('dropdownParent') ||
|
4120 |
|
4121 |
decorated.call(this, $element, options);
|
4122 |
}
|
@@ -4124,27 +4335,14 @@ S2.define('select2/dropdown/attachBody',[
|
|
4124 |
AttachBody.prototype.bind = function (decorated, container, $container) {
|
4125 |
var self = this;
|
4126 |
|
4127 |
-
var setupResultsEvents = false;
|
4128 |
-
|
4129 |
decorated.call(this, container, $container);
|
4130 |
|
4131 |
container.on('open', function () {
|
4132 |
self._showDropdown();
|
4133 |
self._attachPositioningHandler(container);
|
4134 |
|
4135 |
-
|
4136 |
-
|
4137 |
-
|
4138 |
-
container.on('results:all', function () {
|
4139 |
-
self._positionDropdown();
|
4140 |
-
self._resizeDropdown();
|
4141 |
-
});
|
4142 |
-
|
4143 |
-
container.on('results:append', function () {
|
4144 |
-
self._positionDropdown();
|
4145 |
-
self._resizeDropdown();
|
4146 |
-
});
|
4147 |
-
}
|
4148 |
});
|
4149 |
|
4150 |
container.on('close', function () {
|
@@ -4193,6 +4391,44 @@ S2.define('select2/dropdown/attachBody',[
|
|
4193 |
this.$dropdownContainer.detach();
|
4194 |
};
|
4195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4196 |
AttachBody.prototype._attachPositioningHandler =
|
4197 |
function (decorated, container) {
|
4198 |
var self = this;
|
@@ -4203,14 +4439,14 @@ S2.define('select2/dropdown/attachBody',[
|
|
4203 |
|
4204 |
var $watchers = this.$container.parents().filter(Utils.hasScroll);
|
4205 |
$watchers.each(function () {
|
4206 |
-
|
4207 |
x: $(this).scrollLeft(),
|
4208 |
y: $(this).scrollTop()
|
4209 |
});
|
4210 |
});
|
4211 |
|
4212 |
$watchers.on(scrollEvent, function (ev) {
|
4213 |
-
var position =
|
4214 |
$(this).scrollTop(position.y);
|
4215 |
});
|
4216 |
|
@@ -4269,16 +4505,26 @@ S2.define('select2/dropdown/attachBody',[
|
|
4269 |
top: container.bottom
|
4270 |
};
|
4271 |
|
4272 |
-
// Determine what the parent element is to use for
|
4273 |
var $offsetParent = this.$dropdownParent;
|
4274 |
|
4275 |
-
// For statically
|
4276 |
// that is determining the offset
|
4277 |
if ($offsetParent.css('position') === 'static') {
|
4278 |
$offsetParent = $offsetParent.offsetParent();
|
4279 |
}
|
4280 |
|
4281 |
-
var parentOffset =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4282 |
|
4283 |
css.top -= parentOffset.top;
|
4284 |
css.left -= parentOffset.left;
|
@@ -4375,8 +4621,8 @@ S2.define('select2/dropdown/minimumResultsForSearch',[
|
|
4375 |
});
|
4376 |
|
4377 |
S2.define('select2/dropdown/selectOnClose',[
|
4378 |
-
|
4379 |
-
], function () {
|
4380 |
function SelectOnClose () { }
|
4381 |
|
4382 |
SelectOnClose.prototype.bind = function (decorated, container, $container) {
|
@@ -4407,7 +4653,7 @@ S2.define('select2/dropdown/selectOnClose',[
|
|
4407 |
return;
|
4408 |
}
|
4409 |
|
4410 |
-
var data = $highlightedResults
|
4411 |
|
4412 |
// Don't re-select already selected resulte
|
4413 |
if (
|
@@ -4448,7 +4694,7 @@ S2.define('select2/dropdown/closeOnSelect',[
|
|
4448 |
var originalEvent = evt.originalEvent;
|
4449 |
|
4450 |
// Don't close if the control key is being held
|
4451 |
-
if (originalEvent && originalEvent.ctrlKey) {
|
4452 |
return;
|
4453 |
}
|
4454 |
|
@@ -4502,6 +4748,9 @@ S2.define('select2/i18n/en',[],function () {
|
|
4502 |
},
|
4503 |
searching: function () {
|
4504 |
return 'Searching…';
|
|
|
|
|
|
|
4505 |
}
|
4506 |
};
|
4507 |
});
|
@@ -4740,66 +4989,29 @@ S2.define('select2/defaults',[
|
|
4740 |
);
|
4741 |
}
|
4742 |
|
4743 |
-
|
4744 |
-
|
4745 |
-
|
4746 |
-
// Extract the region information if it is included
|
4747 |
-
var languageParts = options.language.split('-');
|
4748 |
-
var baseLanguage = languageParts[0];
|
4749 |
-
|
4750 |
-
options.language = [options.language, baseLanguage];
|
4751 |
-
} else {
|
4752 |
-
options.language = [options.language];
|
4753 |
-
}
|
4754 |
-
}
|
4755 |
-
|
4756 |
-
if ($.isArray(options.language)) {
|
4757 |
-
var languages = new Translation();
|
4758 |
-
options.language.push('en');
|
4759 |
|
4760 |
-
|
|
|
4761 |
|
4762 |
-
|
4763 |
-
var name = languageNames[l];
|
4764 |
-
var language = {};
|
4765 |
|
4766 |
-
|
4767 |
-
|
4768 |
-
language = Translation.loadPath(name);
|
4769 |
-
} catch (e) {
|
4770 |
-
try {
|
4771 |
-
// If we couldn't load it, check if it wasn't the full path
|
4772 |
-
name = this.defaults.amdLanguageBase + name;
|
4773 |
-
language = Translation.loadPath(name);
|
4774 |
-
} catch (ex) {
|
4775 |
-
// The translation could not be loaded at all. Sometimes this is
|
4776 |
-
// because of a configuration problem, other times this can be
|
4777 |
-
// because of how Select2 helps load all possible translation files.
|
4778 |
-
if (options.debug && window.console && console.warn) {
|
4779 |
-
console.warn(
|
4780 |
-
'Select2: The language file for "' + name + '" could not be ' +
|
4781 |
-
'automatically loaded. A fallback will be used instead.'
|
4782 |
-
);
|
4783 |
-
}
|
4784 |
|
4785 |
-
|
4786 |
-
|
4787 |
-
}
|
4788 |
-
|
4789 |
-
languages.extend(language);
|
4790 |
}
|
|
|
4791 |
|
4792 |
-
|
4793 |
-
} else {
|
4794 |
-
var baseTranslation = Translation.loadPath(
|
4795 |
-
this.defaults.amdLanguageBase + 'en'
|
4796 |
-
);
|
4797 |
-
var customTranslation = new Translation(options.language);
|
4798 |
-
|
4799 |
-
customTranslation.extend(baseTranslation);
|
4800 |
|
4801 |
-
|
4802 |
-
|
|
|
|
|
4803 |
|
4804 |
return options;
|
4805 |
};
|
@@ -4866,13 +5078,14 @@ S2.define('select2/defaults',[
|
|
4866 |
debug: false,
|
4867 |
dropdownAutoWidth: false,
|
4868 |
escapeMarkup: Utils.escapeMarkup,
|
4869 |
-
language:
|
4870 |
matcher: matcher,
|
4871 |
minimumInputLength: 0,
|
4872 |
maximumInputLength: 0,
|
4873 |
maximumSelectionLength: 0,
|
4874 |
minimumResultsForSearch: 0,
|
4875 |
selectOnClose: false,
|
|
|
4876 |
sorter: function (data) {
|
4877 |
return data;
|
4878 |
},
|
@@ -4887,6 +5100,103 @@ S2.define('select2/defaults',[
|
|
4887 |
};
|
4888 |
};
|
4889 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4890 |
Defaults.prototype.set = function (key, value) {
|
4891 |
var camelKey = $.camelCase(key);
|
4892 |
|
@@ -4895,7 +5205,7 @@ S2.define('select2/defaults',[
|
|
4895 |
|
4896 |
var convertedData = Utils._convertData(data);
|
4897 |
|
4898 |
-
$.extend(this.defaults, convertedData);
|
4899 |
};
|
4900 |
|
4901 |
var defaults = new Defaults();
|
@@ -4916,6 +5226,10 @@ S2.define('select2/options',[
|
|
4916 |
this.fromElement($element);
|
4917 |
}
|
4918 |
|
|
|
|
|
|
|
|
|
4919 |
this.options = Defaults.apply(this.options);
|
4920 |
|
4921 |
if ($element && $element.is('input')) {
|
@@ -4939,14 +5253,6 @@ S2.define('select2/options',[
|
|
4939 |
this.options.disabled = $e.prop('disabled');
|
4940 |
}
|
4941 |
|
4942 |
-
if (this.options.language == null) {
|
4943 |
-
if ($e.prop('lang')) {
|
4944 |
-
this.options.language = $e.prop('lang').toLowerCase();
|
4945 |
-
} else if ($e.closest('[lang]').prop('lang')) {
|
4946 |
-
this.options.language = $e.closest('[lang]').prop('lang');
|
4947 |
-
}
|
4948 |
-
}
|
4949 |
-
|
4950 |
if (this.options.dir == null) {
|
4951 |
if ($e.prop('dir')) {
|
4952 |
this.options.dir = $e.prop('dir');
|
@@ -4960,7 +5266,7 @@ S2.define('select2/options',[
|
|
4960 |
$e.prop('disabled', this.options.disabled);
|
4961 |
$e.prop('multiple', this.options.multiple);
|
4962 |
|
4963 |
-
if ($e
|
4964 |
if (this.options.debug && window.console && console.warn) {
|
4965 |
console.warn(
|
4966 |
'Select2: The `data-select2-tags` attribute has been changed to ' +
|
@@ -4969,11 +5275,11 @@ S2.define('select2/options',[
|
|
4969 |
);
|
4970 |
}
|
4971 |
|
4972 |
-
$e
|
4973 |
-
$e
|
4974 |
}
|
4975 |
|
4976 |
-
if ($e
|
4977 |
if (this.options.debug && window.console && console.warn) {
|
4978 |
console.warn(
|
4979 |
'Select2: The `data-ajax-url` attribute has been changed to ' +
|
@@ -4982,21 +5288,45 @@ S2.define('select2/options',[
|
|
4982 |
);
|
4983 |
}
|
4984 |
|
4985 |
-
$e.attr('ajax--url', $e
|
4986 |
-
$e
|
4987 |
}
|
4988 |
|
4989 |
var dataset = {};
|
4990 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4991 |
// Prefer the element's `dataset` attribute if it exists
|
4992 |
// jQuery 1.x does not correctly handle data attributes with multiple dashes
|
4993 |
if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
|
4994 |
-
dataset = $.extend(true, {}, $e[0].dataset,
|
4995 |
-
} else {
|
4996 |
-
dataset = $e.data();
|
4997 |
}
|
4998 |
|
4999 |
-
|
|
|
5000 |
|
5001 |
data = Utils._convertData(data);
|
5002 |
|
@@ -5033,8 +5363,8 @@ S2.define('select2/core',[
|
|
5033 |
'./keys'
|
5034 |
], function ($, Options, Utils, KEYS) {
|
5035 |
var Select2 = function ($element, options) {
|
5036 |
-
if ($element
|
5037 |
-
$element
|
5038 |
}
|
5039 |
|
5040 |
this.$element = $element;
|
@@ -5050,7 +5380,7 @@ S2.define('select2/core',[
|
|
5050 |
// Set up the tabindex
|
5051 |
|
5052 |
var tabindex = $element.attr('tabindex') || 0;
|
5053 |
-
$element
|
5054 |
$element.attr('tabindex', '-1');
|
5055 |
|
5056 |
// Set up containers and adapters
|
@@ -5111,6 +5441,9 @@ S2.define('select2/core',[
|
|
5111 |
// Synchronize any monitored attributes
|
5112 |
this._syncAttributes();
|
5113 |
|
|
|
|
|
|
|
5114 |
$element.data('select2', this);
|
5115 |
};
|
5116 |
|
@@ -5187,6 +5520,12 @@ S2.define('select2/core',[
|
|
5187 |
return null;
|
5188 |
}
|
5189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5190 |
return method;
|
5191 |
};
|
5192 |
|
@@ -5227,8 +5566,8 @@ S2.define('select2/core',[
|
|
5227 |
|
5228 |
if (observer != null) {
|
5229 |
this._observer = new observer(function (mutations) {
|
5230 |
-
|
5231 |
-
|
5232 |
});
|
5233 |
this._observer.observe(this.$element[0], {
|
5234 |
attributes: true,
|
@@ -5350,7 +5689,7 @@ S2.define('select2/core',[
|
|
5350 |
if (self.isOpen()) {
|
5351 |
if (key === KEYS.ESC || key === KEYS.TAB ||
|
5352 |
(key === KEYS.UP && evt.altKey)) {
|
5353 |
-
self.close();
|
5354 |
|
5355 |
evt.preventDefault();
|
5356 |
} else if (key === KEYS.ENTER) {
|
@@ -5384,7 +5723,7 @@ S2.define('select2/core',[
|
|
5384 |
Select2.prototype._syncAttributes = function () {
|
5385 |
this.options.set('disabled', this.$element.prop('disabled'));
|
5386 |
|
5387 |
-
if (this.
|
5388 |
if (this.isOpen()) {
|
5389 |
this.close();
|
5390 |
}
|
@@ -5395,7 +5734,7 @@ S2.define('select2/core',[
|
|
5395 |
}
|
5396 |
};
|
5397 |
|
5398 |
-
Select2.prototype.
|
5399 |
var changed = false;
|
5400 |
var self = this;
|
5401 |
|
@@ -5423,7 +5762,22 @@ S2.define('select2/core',[
|
|
5423 |
}
|
5424 |
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
|
5425 |
changed = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5426 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
5427 |
|
5428 |
// Only re-pull the data if we think there is a change
|
5429 |
if (changed) {
|
@@ -5445,7 +5799,8 @@ S2.define('select2/core',[
|
|
5445 |
'open': 'opening',
|
5446 |
'close': 'closing',
|
5447 |
'select': 'selecting',
|
5448 |
-
'unselect': 'unselecting'
|
|
|
5449 |
};
|
5450 |
|
5451 |
if (args === undefined) {
|
@@ -5473,7 +5828,7 @@ S2.define('select2/core',[
|
|
5473 |
};
|
5474 |
|
5475 |
Select2.prototype.toggleDropdown = function () {
|
5476 |
-
if (this.
|
5477 |
return;
|
5478 |
}
|
5479 |
|
@@ -5489,15 +5844,40 @@ S2.define('select2/core',[
|
|
5489 |
return;
|
5490 |
}
|
5491 |
|
|
|
|
|
|
|
|
|
5492 |
this.trigger('query', {});
|
5493 |
};
|
5494 |
|
5495 |
-
Select2.prototype.close = function () {
|
5496 |
if (!this.isOpen()) {
|
5497 |
return;
|
5498 |
}
|
5499 |
|
5500 |
-
this.trigger('close', {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5501 |
};
|
5502 |
|
5503 |
Select2.prototype.isOpen = function () {
|
@@ -5574,7 +5954,7 @@ S2.define('select2/core',[
|
|
5574 |
});
|
5575 |
}
|
5576 |
|
5577 |
-
this.$element.val(newVal).trigger('change');
|
5578 |
};
|
5579 |
|
5580 |
Select2.prototype.destroy = function () {
|
@@ -5600,10 +5980,12 @@ S2.define('select2/core',[
|
|
5600 |
this._syncS = null;
|
5601 |
|
5602 |
this.$element.off('.select2');
|
5603 |
-
this.$element.attr('tabindex',
|
|
|
5604 |
|
5605 |
this.$element.removeClass('select2-hidden-accessible');
|
5606 |
this.$element.attr('aria-hidden', 'false');
|
|
|
5607 |
this.$element.removeData('select2');
|
5608 |
|
5609 |
this.dataAdapter.destroy();
|
@@ -5631,7 +6013,7 @@ S2.define('select2/core',[
|
|
5631 |
|
5632 |
this.$container.addClass('select2-container--' + this.options.get('theme'));
|
5633 |
|
5634 |
-
$container
|
5635 |
|
5636 |
return $container;
|
5637 |
};
|
@@ -5651,8 +6033,9 @@ S2.define('jquery.select2',[
|
|
5651 |
'jquery-mousewheel',
|
5652 |
|
5653 |
'./select2/core',
|
5654 |
-
'./select2/defaults'
|
5655 |
-
|
|
|
5656 |
if ($.fn.select2 == null) {
|
5657 |
// All methods that should return the element
|
5658 |
var thisMethods = ['open', 'close', 'destroy'];
|
@@ -5673,7 +6056,7 @@ S2.define('jquery.select2',[
|
|
5673 |
var args = Array.prototype.slice.call(arguments, 1);
|
5674 |
|
5675 |
this.each(function () {
|
5676 |
-
var instance =
|
5677 |
|
5678 |
if (instance == null && window.console && console.error) {
|
5679 |
console.error(
|
1 |
/*!
|
2 |
+
* Select2 4.0.13
|
3 |
* https://select2.github.io
|
4 |
*
|
5 |
* Released under the MIT license
|
6 |
* https://github.com/select2/select2/blob/master/LICENSE.md
|
7 |
*/
|
8 |
+
;(function (factory) {
|
9 |
if (typeof define === 'function' && define.amd) {
|
10 |
// AMD. Register as an anonymous module.
|
11 |
define(['jquery'], factory);
|
12 |
+
} else if (typeof module === 'object' && module.exports) {
|
13 |
// Node/CommonJS
|
14 |
+
module.exports = function (root, jQuery) {
|
15 |
+
if (jQuery === undefined) {
|
16 |
+
// require('jQuery') returns a factory that requires window to
|
17 |
+
// build a jQuery instance, we normalize how we use modules
|
18 |
+
// that require this pattern but the window provided is a noop
|
19 |
+
// if it's defined (how jquery works)
|
20 |
+
if (typeof window !== 'undefined') {
|
21 |
+
jQuery = require('jquery');
|
22 |
+
}
|
23 |
+
else {
|
24 |
+
jQuery = require('jquery')(root);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
factory(jQuery);
|
28 |
+
return jQuery;
|
29 |
+
};
|
30 |
} else {
|
31 |
// Browser globals
|
32 |
factory(jQuery);
|
33 |
}
|
34 |
+
} (function (jQuery) {
|
35 |
// This is needed so we can catch the AMD loader configuration and use it
|
36 |
// The inner file should be wrapped (by `banner.start.js`) in a function that
|
37 |
// returns the AMD loader references.
|
38 |
+
var S2 =(function () {
|
|
|
39 |
// Restore the Select2 AMD loader so it can be used
|
40 |
// Needed mostly in the language files, where the loader is not inserted
|
41 |
if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
|
44 |
var S2;(function () { if (!S2 || !S2.requirejs) {
|
45 |
if (!S2) { S2 = {}; } else { require = S2; }
|
46 |
/**
|
47 |
+
* @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
|
48 |
+
* Released under MIT license, http://github.com/requirejs/almond/LICENSE
|
|
|
49 |
*/
|
50 |
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
51 |
//be followed.
|
|
|
52 |
/*global setTimeout: false */
|
53 |
|
54 |
var requirejs, require, define;
|
76 |
*/
|
77 |
function normalize(name, baseName) {
|
78 |
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
79 |
+
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
|
80 |
baseParts = baseName && baseName.split("/"),
|
81 |
map = config.map,
|
82 |
starMap = (map && map['*']) || {};
|
83 |
|
84 |
//Adjust any relative paths.
|
85 |
+
if (name) {
|
86 |
+
name = name.split('/');
|
87 |
+
lastIndex = name.length - 1;
|
88 |
+
|
89 |
+
// If wanting node ID compatibility, strip .js from end
|
90 |
+
// of IDs. Have to do this here, and not in nameToUrl
|
91 |
+
// because node allows either .js or non .js to map
|
92 |
+
// to same file.
|
93 |
+
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
|
94 |
+
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
|
95 |
+
}
|
|
|
96 |
|
97 |
+
// Starts with a '.' so need the baseName
|
98 |
+
if (name[0].charAt(0) === '.' && baseParts) {
|
99 |
+
//Convert baseName to array, and lop off the last part,
|
100 |
+
//so that . matches that 'directory' and not name of the baseName's
|
101 |
+
//module. For instance, baseName of 'one/two/three', maps to
|
102 |
+
//'one/two/three.js', but we want the directory, 'one/two' for
|
103 |
+
//this normalization.
|
104 |
+
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
|
105 |
+
name = normalizedBaseParts.concat(name);
|
106 |
+
}
|
107 |
+
|
108 |
+
//start trimDots
|
109 |
+
for (i = 0; i < name.length; i++) {
|
110 |
+
part = name[i];
|
111 |
+
if (part === '.') {
|
112 |
+
name.splice(i, 1);
|
113 |
+
i -= 1;
|
114 |
+
} else if (part === '..') {
|
115 |
+
// If at the start, or previous value is still ..,
|
116 |
+
// keep them so that when converted to a path it may
|
117 |
+
// still work when converted to a path, even though
|
118 |
+
// as an ID it is less than ideal. In larger point
|
119 |
+
// releases, may be better to just kick out an error.
|
120 |
+
if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
|
121 |
+
continue;
|
122 |
+
} else if (i > 0) {
|
123 |
+
name.splice(i - 1, 2);
|
124 |
+
i -= 2;
|
125 |
}
|
126 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
+
//end trimDots
|
129 |
+
|
130 |
+
name = name.join('/');
|
131 |
}
|
132 |
|
133 |
//Apply map config if available.
|
240 |
return [prefix, name];
|
241 |
}
|
242 |
|
243 |
+
//Creates a parts array for a relName where first part is plugin ID,
|
244 |
+
//second part is resource ID. Assumes relName has already been normalized.
|
245 |
+
function makeRelParts(relName) {
|
246 |
+
return relName ? splitPrefix(relName) : [];
|
247 |
+
}
|
248 |
+
|
249 |
/**
|
250 |
* Makes a name map, normalizing the name, and using a plugin
|
251 |
* for normalization if necessary. Grabs a ref to plugin
|
252 |
* too, as an optimization.
|
253 |
*/
|
254 |
+
makeMap = function (name, relParts) {
|
255 |
var plugin,
|
256 |
parts = splitPrefix(name),
|
257 |
+
prefix = parts[0],
|
258 |
+
relResourceName = relParts[1];
|
259 |
|
260 |
name = parts[1];
|
261 |
|
262 |
if (prefix) {
|
263 |
+
prefix = normalize(prefix, relResourceName);
|
264 |
plugin = callDep(prefix);
|
265 |
}
|
266 |
|
267 |
//Normalize according
|
268 |
if (prefix) {
|
269 |
if (plugin && plugin.normalize) {
|
270 |
+
name = plugin.normalize(name, makeNormalize(relResourceName));
|
271 |
} else {
|
272 |
+
name = normalize(name, relResourceName);
|
273 |
}
|
274 |
} else {
|
275 |
+
name = normalize(name, relResourceName);
|
276 |
parts = splitPrefix(name);
|
277 |
prefix = parts[0];
|
278 |
name = parts[1];
|
319 |
};
|
320 |
|
321 |
main = function (name, deps, callback, relName) {
|
322 |
+
var cjsModule, depName, ret, map, i, relParts,
|
323 |
args = [],
|
324 |
callbackType = typeof callback,
|
325 |
usingExports;
|
326 |
|
327 |
//Use name if no relName
|
328 |
relName = relName || name;
|
329 |
+
relParts = makeRelParts(relName);
|
330 |
|
331 |
//Call the callback to define the module, if necessary.
|
332 |
if (callbackType === 'undefined' || callbackType === 'function') {
|
335 |
//Default to [require, exports, module] if no deps
|
336 |
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
337 |
for (i = 0; i < deps.length; i += 1) {
|
338 |
+
map = makeMap(deps[i], relParts);
|
339 |
depName = map.f;
|
340 |
|
341 |
//Fast path CommonJS standard dependencies.
|
391 |
//deps arg is the module name, and second arg (if passed)
|
392 |
//is just the relName.
|
393 |
//Normalize module name, if it contains . or ..
|
394 |
+
return callDep(makeMap(deps, makeRelParts(callback)).f);
|
395 |
} else if (!deps.splice) {
|
396 |
//deps is a config object, not an array.
|
397 |
config = deps;
|
574 |
DecoratedClass.prototype = new ctr();
|
575 |
|
576 |
for (var m = 0; m < superMethods.length; m++) {
|
577 |
+
var superMethod = superMethods[m];
|
578 |
|
579 |
+
DecoratedClass.prototype[superMethod] =
|
580 |
+
SuperClass.prototype[superMethod];
|
581 |
}
|
582 |
|
583 |
var calledMethod = function (methodName) {
|
772 |
$element.append($nodes);
|
773 |
};
|
774 |
|
775 |
+
// Cache objects in Utils.__cache instead of $.data (see #4346)
|
776 |
+
Utils.__cache = {};
|
777 |
+
|
778 |
+
var id = 0;
|
779 |
+
Utils.GetUniqueElementId = function (element) {
|
780 |
+
// Get a unique element Id. If element has no id,
|
781 |
+
// creates a new unique number, stores it in the id
|
782 |
+
// attribute and returns the new id.
|
783 |
+
// If an id already exists, it simply returns it.
|
784 |
+
|
785 |
+
var select2Id = element.getAttribute('data-select2-id');
|
786 |
+
if (select2Id == null) {
|
787 |
+
// If element has id, use it.
|
788 |
+
if (element.id) {
|
789 |
+
select2Id = element.id;
|
790 |
+
element.setAttribute('data-select2-id', select2Id);
|
791 |
+
} else {
|
792 |
+
element.setAttribute('data-select2-id', ++id);
|
793 |
+
select2Id = id.toString();
|
794 |
+
}
|
795 |
+
}
|
796 |
+
return select2Id;
|
797 |
+
};
|
798 |
+
|
799 |
+
Utils.StoreData = function (element, name, value) {
|
800 |
+
// Stores an item in the cache for a specified element.
|
801 |
+
// name is the cache key.
|
802 |
+
var id = Utils.GetUniqueElementId(element);
|
803 |
+
if (!Utils.__cache[id]) {
|
804 |
+
Utils.__cache[id] = {};
|
805 |
+
}
|
806 |
+
|
807 |
+
Utils.__cache[id][name] = value;
|
808 |
+
};
|
809 |
+
|
810 |
+
Utils.GetData = function (element, name) {
|
811 |
+
// Retrieves a value from the cache by its key (name)
|
812 |
+
// name is optional. If no name specified, return
|
813 |
+
// all cache items for the specified element.
|
814 |
+
// and for a specified element.
|
815 |
+
var id = Utils.GetUniqueElementId(element);
|
816 |
+
if (name) {
|
817 |
+
if (Utils.__cache[id]) {
|
818 |
+
if (Utils.__cache[id][name] != null) {
|
819 |
+
return Utils.__cache[id][name];
|
820 |
+
}
|
821 |
+
return $(element).data(name); // Fallback to HTML5 data attribs.
|
822 |
+
}
|
823 |
+
return $(element).data(name); // Fallback to HTML5 data attribs.
|
824 |
+
} else {
|
825 |
+
return Utils.__cache[id];
|
826 |
+
}
|
827 |
+
};
|
828 |
+
|
829 |
+
Utils.RemoveData = function (element) {
|
830 |
+
// Removes all cached items for a specified element.
|
831 |
+
var id = Utils.GetUniqueElementId(element);
|
832 |
+
if (Utils.__cache[id] != null) {
|
833 |
+
delete Utils.__cache[id];
|
834 |
+
}
|
835 |
+
|
836 |
+
element.removeAttribute('data-select2-id');
|
837 |
+
};
|
838 |
+
|
839 |
return Utils;
|
840 |
});
|
841 |
|
855 |
|
856 |
Results.prototype.render = function () {
|
857 |
var $results = $(
|
858 |
+
'<ul class="select2-results__options" role="listbox"></ul>'
|
859 |
);
|
860 |
|
861 |
if (this.options.get('multiple')) {
|
878 |
this.hideLoading();
|
879 |
|
880 |
var $message = $(
|
881 |
+
'<li role="alert" aria-live="assertive"' +
|
882 |
' class="select2-results__option"></li>'
|
883 |
);
|
884 |
|
971 |
$options.each(function () {
|
972 |
var $option = $(this);
|
973 |
|
974 |
+
var item = Utils.GetData(this, 'data');
|
975 |
|
976 |
// id needs to be converted to a string when comparing
|
977 |
var id = '' + item.id;
|
1012 |
option.className = 'select2-results__option';
|
1013 |
|
1014 |
var attrs = {
|
1015 |
+
'role': 'option',
|
1016 |
'aria-selected': 'false'
|
1017 |
};
|
1018 |
|
1019 |
+
var matches = window.Element.prototype.matches ||
|
1020 |
+
window.Element.prototype.msMatchesSelector ||
|
1021 |
+
window.Element.prototype.webkitMatchesSelector;
|
1022 |
+
|
1023 |
+
if ((data.element != null && matches.call(data.element, ':disabled')) ||
|
1024 |
+
(data.element == null && data.disabled)) {
|
1025 |
delete attrs['aria-selected'];
|
1026 |
attrs['aria-disabled'] = 'true';
|
1027 |
}
|
1081 |
this.template(data, option);
|
1082 |
}
|
1083 |
|
1084 |
+
Utils.StoreData(option, 'data', data);
|
1085 |
|
1086 |
return option;
|
1087 |
};
|
1122 |
}
|
1123 |
|
1124 |
self.setClasses();
|
1125 |
+
|
1126 |
+
if (self.options.get('scrollAfterSelect')) {
|
1127 |
+
self.highlightFirstItem();
|
1128 |
+
}
|
1129 |
});
|
1130 |
|
1131 |
container.on('unselect', function () {
|
1134 |
}
|
1135 |
|
1136 |
self.setClasses();
|
1137 |
+
|
1138 |
+
if (self.options.get('scrollAfterSelect')) {
|
1139 |
+
self.highlightFirstItem();
|
1140 |
+
}
|
1141 |
});
|
1142 |
|
1143 |
container.on('open', function () {
|
1173 |
return;
|
1174 |
}
|
1175 |
|
1176 |
+
var data = Utils.GetData($highlighted[0], 'data');
|
1177 |
|
1178 |
if ($highlighted.attr('aria-selected') == 'true') {
|
1179 |
self.trigger('close', {});
|
1191 |
|
1192 |
var currentIndex = $options.index($highlighted);
|
1193 |
|
1194 |
+
// If we are already at the top, don't move further
|
1195 |
+
// If no options, currentIndex will be -1
|
1196 |
+
if (currentIndex <= 0) {
|
1197 |
return;
|
1198 |
}
|
1199 |
|
1286 |
function (evt) {
|
1287 |
var $this = $(this);
|
1288 |
|
1289 |
+
var data = Utils.GetData(this, 'data');
|
1290 |
|
1291 |
if ($this.attr('aria-selected') === 'true') {
|
1292 |
if (self.options.get('multiple')) {
|
1309 |
|
1310 |
this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
|
1311 |
function (evt) {
|
1312 |
+
var data = Utils.GetData(this, 'data');
|
1313 |
|
1314 |
self.getHighlightedResults()
|
1315 |
.removeClass('select2-results__option--highlighted');
|
1424 |
|
1425 |
this._tabindex = 0;
|
1426 |
|
1427 |
+
if (Utils.GetData(this.$element[0], 'old-tabindex') != null) {
|
1428 |
+
this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex');
|
1429 |
} else if (this.$element.attr('tabindex') != null) {
|
1430 |
this._tabindex = this.$element.attr('tabindex');
|
1431 |
}
|
1432 |
|
1433 |
$selection.attr('title', this.$element.attr('title'));
|
1434 |
$selection.attr('tabindex', this._tabindex);
|
1435 |
+
$selection.attr('aria-disabled', 'false');
|
1436 |
|
1437 |
this.$selection = $selection;
|
1438 |
|
1442 |
BaseSelection.prototype.bind = function (container, $container) {
|
1443 |
var self = this;
|
1444 |
|
|
|
1445 |
var resultsId = container.id + '-results';
|
1446 |
|
1447 |
this.container = container;
|
1484 |
self.$selection.removeAttr('aria-activedescendant');
|
1485 |
self.$selection.removeAttr('aria-owns');
|
1486 |
|
1487 |
+
self.$selection.trigger('focus');
|
1488 |
|
1489 |
self._detachCloseHandler(container);
|
1490 |
});
|
1491 |
|
1492 |
container.on('enable', function () {
|
1493 |
self.$selection.attr('tabindex', self._tabindex);
|
1494 |
+
self.$selection.attr('aria-disabled', 'false');
|
1495 |
});
|
1496 |
|
1497 |
container.on('disable', function () {
|
1498 |
self.$selection.attr('tabindex', '-1');
|
1499 |
+
self.$selection.attr('aria-disabled', 'true');
|
1500 |
});
|
1501 |
};
|
1502 |
|
1519 |
};
|
1520 |
|
1521 |
BaseSelection.prototype._attachCloseHandler = function (container) {
|
|
|
1522 |
|
1523 |
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
1524 |
var $target = $(e.target);
|
1528 |
var $all = $('.select2.select2-container--open');
|
1529 |
|
1530 |
$all.each(function () {
|
|
|
|
|
1531 |
if (this == $select[0]) {
|
1532 |
return;
|
1533 |
}
|
1534 |
|
1535 |
+
var $element = Utils.GetData(this, 'element');
|
1536 |
|
1537 |
$element.select2('close');
|
1538 |
});
|
1556 |
throw new Error('The `update` method must be defined in child classes.');
|
1557 |
};
|
1558 |
|
1559 |
+
/**
|
1560 |
+
* Helper method to abstract the "enabled" (not "disabled") state of this
|
1561 |
+
* object.
|
1562 |
+
*
|
1563 |
+
* @return {true} if the instance is not disabled.
|
1564 |
+
* @return {false} if the instance is disabled.
|
1565 |
+
*/
|
1566 |
+
BaseSelection.prototype.isEnabled = function () {
|
1567 |
+
return !this.isDisabled();
|
1568 |
+
};
|
1569 |
+
|
1570 |
+
/**
|
1571 |
+
* Helper method to abstract the "disabled" state of this object.
|
1572 |
+
*
|
1573 |
+
* @return {true} if the disabled option is true.
|
1574 |
+
* @return {false} if the disabled option is false.
|
1575 |
+
*/
|
1576 |
+
BaseSelection.prototype.isDisabled = function () {
|
1577 |
+
return this.options.get('disabled');
|
1578 |
+
};
|
1579 |
+
|
1580 |
return BaseSelection;
|
1581 |
});
|
1582 |
|
1614 |
|
1615 |
var id = container.id + '-container';
|
1616 |
|
1617 |
+
this.$selection.find('.select2-selection__rendered')
|
1618 |
+
.attr('id', id)
|
1619 |
+
.attr('role', 'textbox')
|
1620 |
+
.attr('aria-readonly', 'true');
|
1621 |
this.$selection.attr('aria-labelledby', id);
|
1622 |
|
1623 |
this.$selection.on('mousedown', function (evt) {
|
1641 |
|
1642 |
container.on('focus', function (evt) {
|
1643 |
if (!container.isOpen()) {
|
1644 |
+
self.$selection.trigger('focus');
|
1645 |
}
|
1646 |
});
|
|
|
|
|
|
|
|
|
1647 |
};
|
1648 |
|
1649 |
SingleSelection.prototype.clear = function () {
|
1650 |
+
var $rendered = this.$selection.find('.select2-selection__rendered');
|
1651 |
+
$rendered.empty();
|
1652 |
+
$rendered.removeAttr('title'); // clear tooltip on empty
|
1653 |
};
|
1654 |
|
1655 |
SingleSelection.prototype.display = function (data, container) {
|
1675 |
var formatted = this.display(selection, $rendered);
|
1676 |
|
1677 |
$rendered.empty().append(formatted);
|
1678 |
+
|
1679 |
+
var title = selection.title || selection.text;
|
1680 |
+
|
1681 |
+
if (title) {
|
1682 |
+
$rendered.attr('title', title);
|
1683 |
+
} else {
|
1684 |
+
$rendered.removeAttr('title');
|
1685 |
+
}
|
1686 |
};
|
1687 |
|
1688 |
return SingleSelection;
|
1727 |
'.select2-selection__choice__remove',
|
1728 |
function (evt) {
|
1729 |
// Ignore the event if it is disabled
|
1730 |
+
if (self.isDisabled()) {
|
1731 |
return;
|
1732 |
}
|
1733 |
|
1734 |
var $remove = $(this);
|
1735 |
var $selection = $remove.parent();
|
1736 |
|
1737 |
+
var data = Utils.GetData($selection[0], 'data');
|
1738 |
|
1739 |
self.trigger('unselect', {
|
1740 |
originalEvent: evt,
|
1745 |
};
|
1746 |
|
1747 |
MultipleSelection.prototype.clear = function () {
|
1748 |
+
var $rendered = this.$selection.find('.select2-selection__rendered');
|
1749 |
+
$rendered.empty();
|
1750 |
+
$rendered.removeAttr('title');
|
1751 |
};
|
1752 |
|
1753 |
MultipleSelection.prototype.display = function (data, container) {
|
1785 |
var formatted = this.display(selection, $selection);
|
1786 |
|
1787 |
$selection.append(formatted);
|
|
|
1788 |
|
1789 |
+
var title = selection.title || selection.text;
|
1790 |
+
|
1791 |
+
if (title) {
|
1792 |
+
$selection.attr('title', title);
|
1793 |
+
}
|
1794 |
+
|
1795 |
+
Utils.StoreData($selection[0], 'data', selection);
|
1796 |
|
1797 |
$selections.push($selection);
|
1798 |
}
|
1857 |
|
1858 |
S2.define('select2/selection/allowClear',[
|
1859 |
'jquery',
|
1860 |
+
'../keys',
|
1861 |
+
'../utils'
|
1862 |
+
], function ($, KEYS, Utils) {
|
1863 |
function AllowClear () { }
|
1864 |
|
1865 |
AllowClear.prototype.bind = function (decorated, container, $container) {
|
1888 |
|
1889 |
AllowClear.prototype._handleClear = function (_, evt) {
|
1890 |
// Ignore the event if it is disabled
|
1891 |
+
if (this.isDisabled()) {
|
1892 |
return;
|
1893 |
}
|
1894 |
|
1901 |
|
1902 |
evt.stopPropagation();
|
1903 |
|
1904 |
+
var data = Utils.GetData($clear[0], 'data');
|
1905 |
+
|
1906 |
+
var previousVal = this.$element.val();
|
1907 |
+
this.$element.val(this.placeholder.id);
|
1908 |
+
|
1909 |
+
var unselectData = {
|
1910 |
+
data: data
|
1911 |
+
};
|
1912 |
+
this.trigger('clear', unselectData);
|
1913 |
+
if (unselectData.prevented) {
|
1914 |
+
this.$element.val(previousVal);
|
1915 |
+
return;
|
1916 |
+
}
|
1917 |
|
1918 |
for (var d = 0; d < data.length; d++) {
|
1919 |
+
unselectData = {
|
1920 |
data: data[d]
|
1921 |
};
|
1922 |
|
1926 |
|
1927 |
// If the event was prevented, don't clear it out.
|
1928 |
if (unselectData.prevented) {
|
1929 |
+
this.$element.val(previousVal);
|
1930 |
return;
|
1931 |
}
|
1932 |
}
|
1933 |
|
1934 |
+
this.$element.trigger('input').trigger('change');
|
1935 |
|
1936 |
this.trigger('toggle', {});
|
1937 |
};
|
1954 |
return;
|
1955 |
}
|
1956 |
|
1957 |
+
var removeAll = this.options.get('translations').get('removeAllItems');
|
1958 |
+
|
1959 |
var $remove = $(
|
1960 |
+
'<span class="select2-selection__clear" title="' + removeAll() +'">' +
|
1961 |
'×' +
|
1962 |
'</span>'
|
1963 |
);
|
1964 |
+
Utils.StoreData($remove[0], 'data', data);
|
1965 |
|
1966 |
this.$selection.find('.select2-selection__rendered').prepend($remove);
|
1967 |
};
|
1982 |
var $search = $(
|
1983 |
'<li class="select2-search select2-search--inline">' +
|
1984 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
1985 |
+
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
|
1986 |
+
' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
|
1987 |
'</li>'
|
1988 |
);
|
1989 |
|
2000 |
Search.prototype.bind = function (decorated, container, $container) {
|
2001 |
var self = this;
|
2002 |
|
2003 |
+
var resultsId = container.id + '-results';
|
2004 |
+
|
2005 |
decorated.call(this, container, $container);
|
2006 |
|
2007 |
container.on('open', function () {
|
2008 |
+
self.$search.attr('aria-controls', resultsId);
|
2009 |
self.$search.trigger('focus');
|
2010 |
});
|
2011 |
|
2012 |
container.on('close', function () {
|
2013 |
self.$search.val('');
|
2014 |
+
self.$search.removeAttr('aria-controls');
|
2015 |
self.$search.removeAttr('aria-activedescendant');
|
2016 |
self.$search.trigger('focus');
|
2017 |
});
|
2031 |
});
|
2032 |
|
2033 |
container.on('results:focus', function (params) {
|
2034 |
+
if (params.data._resultId) {
|
2035 |
+
self.$search.attr('aria-activedescendant', params.data._resultId);
|
2036 |
+
} else {
|
2037 |
+
self.$search.removeAttr('aria-activedescendant');
|
2038 |
+
}
|
2039 |
});
|
2040 |
|
2041 |
this.$selection.on('focusin', '.select2-search--inline', function (evt) {
|
2060 |
.prev('.select2-selection__choice');
|
2061 |
|
2062 |
if ($previousChoice.length > 0) {
|
2063 |
+
var item = Utils.GetData($previousChoice[0], 'data');
|
2064 |
|
2065 |
self.searchRemoveChoice(item);
|
2066 |
|
2069 |
}
|
2070 |
});
|
2071 |
|
2072 |
+
this.$selection.on('click', '.select2-search--inline', function (evt) {
|
2073 |
+
if (self.$search.val()) {
|
2074 |
+
evt.stopPropagation();
|
2075 |
+
}
|
2076 |
+
});
|
2077 |
+
|
2078 |
// Try to detect the IE version should the `documentMode` property that
|
2079 |
// is stored on the document. This is only implemented in IE and is
|
2080 |
// slightly cleaner than doing a user agent check.
|
2160 |
|
2161 |
this.resizeSearch();
|
2162 |
if (searchHadFocus) {
|
2163 |
+
this.$search.trigger('focus');
|
2164 |
}
|
2165 |
};
|
2166 |
|
2193 |
var width = '';
|
2194 |
|
2195 |
if (this.$search.attr('placeholder') !== '') {
|
2196 |
+
width = this.$selection.find('.select2-selection__rendered').width();
|
2197 |
} else {
|
2198 |
var minimumWidth = this.$search.val().length + 1;
|
2199 |
|
2217 |
'open', 'opening',
|
2218 |
'close', 'closing',
|
2219 |
'select', 'selecting',
|
2220 |
+
'unselect', 'unselecting',
|
2221 |
+
'clear', 'clearing'
|
2222 |
];
|
2223 |
|
2224 |
+
var preventableEvents = [
|
2225 |
+
'opening', 'closing', 'selecting', 'unselecting', 'clearing'
|
2226 |
+
];
|
2227 |
|
2228 |
decorated.call(this, container, $container);
|
2229 |
|
2556 |
'\u019F': 'O',
|
2557 |
'\uA74A': 'O',
|
2558 |
'\uA74C': 'O',
|
2559 |
+
'\u0152': 'OE',
|
2560 |
'\u01A2': 'OI',
|
2561 |
'\uA74E': 'OO',
|
2562 |
'\u0222': 'OU',
|
2966 |
'\uA74B': 'o',
|
2967 |
'\uA74D': 'o',
|
2968 |
'\u0275': 'o',
|
2969 |
+
'\u0153': 'oe',
|
2970 |
'\u01A3': 'oi',
|
2971 |
'\u0223': 'ou',
|
2972 |
'\uA74F': 'oo',
|
3135 |
'\u03CD': '\u03C5',
|
3136 |
'\u03CB': '\u03C5',
|
3137 |
'\u03B0': '\u03C5',
|
3138 |
+
'\u03CE': '\u03C9',
|
3139 |
+
'\u03C2': '\u03C3',
|
3140 |
+
'\u2019': '\''
|
3141 |
};
|
3142 |
|
3143 |
return diacritics;
|
3222 |
if ($(data.element).is('option')) {
|
3223 |
data.element.selected = true;
|
3224 |
|
3225 |
+
this.$element.trigger('input').trigger('change');
|
3226 |
|
3227 |
return;
|
3228 |
}
|
3243 |
}
|
3244 |
|
3245 |
self.$element.val(val);
|
3246 |
+
self.$element.trigger('input').trigger('change');
|
3247 |
});
|
3248 |
} else {
|
3249 |
var val = data.id;
|
3250 |
|
3251 |
this.$element.val(val);
|
3252 |
+
this.$element.trigger('input').trigger('change');
|
3253 |
}
|
3254 |
};
|
3255 |
|
3265 |
if ($(data.element).is('option')) {
|
3266 |
data.element.selected = false;
|
3267 |
|
3268 |
+
this.$element.trigger('input').trigger('change');
|
3269 |
|
3270 |
return;
|
3271 |
}
|
3283 |
|
3284 |
self.$element.val(val);
|
3285 |
|
3286 |
+
self.$element.trigger('input').trigger('change');
|
3287 |
});
|
3288 |
};
|
3289 |
|
3305 |
// Remove anything added to child elements
|
3306 |
this.$element.find('*').each(function () {
|
3307 |
// Remove any custom data set by Select2
|
3308 |
+
Utils.RemoveData(this);
|
3309 |
});
|
3310 |
};
|
3311 |
|
3356 |
}
|
3357 |
}
|
3358 |
|
3359 |
+
if (data.id !== undefined) {
|
3360 |
option.value = data.id;
|
3361 |
}
|
3362 |
|
3378 |
normalizedData.element = option;
|
3379 |
|
3380 |
// Override the option's data with the combined data
|
3381 |
+
Utils.StoreData(option, 'data', normalizedData);
|
3382 |
|
3383 |
return $option;
|
3384 |
};
|
3386 |
SelectAdapter.prototype.item = function ($option) {
|
3387 |
var data = {};
|
3388 |
|
3389 |
+
data = Utils.GetData($option[0], 'data');
|
3390 |
|
3391 |
if (data != null) {
|
3392 |
return data;
|
3424 |
data = this._normalizeItem(data);
|
3425 |
data.element = $option[0];
|
3426 |
|
3427 |
+
Utils.StoreData($option[0], 'data', data);
|
3428 |
|
3429 |
return data;
|
3430 |
};
|
3431 |
|
3432 |
SelectAdapter.prototype._normalizeItem = function (item) {
|
3433 |
+
if (item !== Object(item)) {
|
3434 |
item = {
|
3435 |
id: item,
|
3436 |
text: item
|
3476 |
'jquery'
|
3477 |
], function (SelectAdapter, Utils, $) {
|
3478 |
function ArrayAdapter ($element, options) {
|
3479 |
+
this._dataToConvert = options.get('data') || [];
|
3480 |
|
3481 |
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
|
|
|
|
3482 |
}
|
3483 |
|
3484 |
Utils.Extend(ArrayAdapter, SelectAdapter);
|
3485 |
|
3486 |
+
ArrayAdapter.prototype.bind = function (container, $container) {
|
3487 |
+
ArrayAdapter.__super__.bind.call(this, container, $container);
|
3488 |
+
|
3489 |
+
this.addOptions(this.convertToOptions(this._dataToConvert));
|
3490 |
+
};
|
3491 |
+
|
3492 |
ArrayAdapter.prototype.select = function (data) {
|
3493 |
var $option = this.$element.find('option').filter(function (i, elm) {
|
3494 |
return elm.value == data.id.toString();
|
3638 |
}, function () {
|
3639 |
// Attempt to detect if a request was aborted
|
3640 |
// Only works if the transport exposes a status property
|
3641 |
+
if ('status' in $request &&
|
3642 |
+
($request.status === 0 || $request.status === '0')) {
|
3643 |
return;
|
3644 |
}
|
3645 |
|
3720 |
}, true)
|
3721 |
);
|
3722 |
|
3723 |
+
var optionText = (option.text || '').toUpperCase();
|
3724 |
+
var paramsTerm = (params.term || '').toUpperCase();
|
3725 |
+
|
3726 |
+
var checkText = optionText === paramsTerm;
|
3727 |
|
3728 |
if (checkText || checkChildren) {
|
3729 |
if (child) {
|
3778 |
};
|
3779 |
|
3780 |
Tags.prototype._removeOldTags = function (_) {
|
|
|
|
|
3781 |
var $options = this.$element.find('option[data-select2-tag]');
|
3782 |
|
3783 |
$options.each(function () {
|
3852 |
// Replace the search term if we have the search box
|
3853 |
if (this.$search.length) {
|
3854 |
this.$search.val(tokenData.term);
|
3855 |
+
this.$search.trigger('focus');
|
3856 |
}
|
3857 |
|
3858 |
params.term = tokenData.term;
|
3981 |
decorated.call(this, $e, options);
|
3982 |
}
|
3983 |
|
3984 |
+
MaximumSelectionLength.prototype.bind =
|
3985 |
+
function (decorated, container, $container) {
|
3986 |
+
var self = this;
|
3987 |
+
|
3988 |
+
decorated.call(this, container, $container);
|
3989 |
+
|
3990 |
+
container.on('select', function () {
|
3991 |
+
self._checkIfMaximumSelected();
|
3992 |
+
});
|
3993 |
+
};
|
3994 |
+
|
3995 |
MaximumSelectionLength.prototype.query =
|
3996 |
function (decorated, params, callback) {
|
3997 |
var self = this;
|
3998 |
|
3999 |
+
this._checkIfMaximumSelected(function () {
|
4000 |
+
decorated.call(self, params, callback);
|
4001 |
+
});
|
4002 |
+
};
|
4003 |
+
|
4004 |
+
MaximumSelectionLength.prototype._checkIfMaximumSelected =
|
4005 |
+
function (_, successCallback) {
|
4006 |
+
var self = this;
|
4007 |
+
|
4008 |
this.current(function (currentData) {
|
4009 |
var count = currentData != null ? currentData.length : 0;
|
4010 |
if (self.maximumSelectionLength > 0 &&
|
4017 |
});
|
4018 |
return;
|
4019 |
}
|
4020 |
+
|
4021 |
+
if (successCallback) {
|
4022 |
+
successCallback();
|
4023 |
+
}
|
4024 |
});
|
4025 |
};
|
4026 |
|
4059 |
};
|
4060 |
|
4061 |
Dropdown.prototype.position = function ($dropdown, $container) {
|
4062 |
+
// Should be implemented in subclasses
|
4063 |
};
|
4064 |
|
4065 |
Dropdown.prototype.destroy = function () {
|
4082 |
var $search = $(
|
4083 |
'<span class="select2-search select2-search--dropdown">' +
|
4084 |
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
4085 |
+
' autocomplete="off" autocorrect="off" autocapitalize="none"' +
|
4086 |
+
' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
|
4087 |
'</span>'
|
4088 |
);
|
4089 |
|
4098 |
Search.prototype.bind = function (decorated, container, $container) {
|
4099 |
var self = this;
|
4100 |
|
4101 |
+
var resultsId = container.id + '-results';
|
4102 |
+
|
4103 |
decorated.call(this, container, $container);
|
4104 |
|
4105 |
this.$search.on('keydown', function (evt) {
|
4122 |
|
4123 |
container.on('open', function () {
|
4124 |
self.$search.attr('tabindex', 0);
|
4125 |
+
self.$search.attr('aria-controls', resultsId);
|
4126 |
|
4127 |
+
self.$search.trigger('focus');
|
4128 |
|
4129 |
window.setTimeout(function () {
|
4130 |
+
self.$search.trigger('focus');
|
4131 |
}, 0);
|
4132 |
});
|
4133 |
|
4134 |
container.on('close', function () {
|
4135 |
self.$search.attr('tabindex', -1);
|
4136 |
+
self.$search.removeAttr('aria-controls');
|
4137 |
+
self.$search.removeAttr('aria-activedescendant');
|
4138 |
|
4139 |
self.$search.val('');
|
4140 |
+
self.$search.trigger('blur');
|
4141 |
});
|
4142 |
|
4143 |
container.on('focus', function () {
|
4144 |
+
if (!container.isOpen()) {
|
4145 |
+
self.$search.trigger('focus');
|
4146 |
}
|
4147 |
});
|
4148 |
|
4157 |
}
|
4158 |
}
|
4159 |
});
|
4160 |
+
|
4161 |
+
container.on('results:focus', function (params) {
|
4162 |
+
if (params.data._resultId) {
|
4163 |
+
self.$search.attr('aria-activedescendant', params.data._resultId);
|
4164 |
+
} else {
|
4165 |
+
self.$search.removeAttr('aria-activedescendant');
|
4166 |
+
}
|
4167 |
+
});
|
4168 |
};
|
4169 |
|
4170 |
Search.prototype.handleSearch = function (evt) {
|
4249 |
|
4250 |
if (this.showLoadingMore(data)) {
|
4251 |
this.$results.append(this.$loadingMore);
|
4252 |
+
this.loadMoreIfNeeded();
|
4253 |
}
|
4254 |
};
|
4255 |
|
4268 |
self.loading = true;
|
4269 |
});
|
4270 |
|
4271 |
+
this.$results.on('scroll', this.loadMoreIfNeeded.bind(this));
|
4272 |
+
};
|
|
|
|
|
|
|
4273 |
|
4274 |
+
InfiniteScroll.prototype.loadMoreIfNeeded = function () {
|
4275 |
+
var isLoadMoreVisible = $.contains(
|
4276 |
+
document.documentElement,
|
4277 |
+
this.$loadingMore[0]
|
4278 |
+
);
|
4279 |
|
4280 |
+
if (this.loading || !isLoadMoreVisible) {
|
4281 |
+
return;
|
4282 |
+
}
|
|
|
4283 |
|
4284 |
+
var currentOffset = this.$results.offset().top +
|
4285 |
+
this.$results.outerHeight(false);
|
4286 |
+
var loadingMoreOffset = this.$loadingMore.offset().top +
|
4287 |
+
this.$loadingMore.outerHeight(false);
|
4288 |
+
|
4289 |
+
if (currentOffset + 50 >= loadingMoreOffset) {
|
4290 |
+
this.loadMore();
|
4291 |
+
}
|
4292 |
};
|
4293 |
|
4294 |
InfiniteScroll.prototype.loadMore = function () {
|
4309 |
var $option = $(
|
4310 |
'<li ' +
|
4311 |
'class="select2-results__option select2-results__option--load-more"' +
|
4312 |
+
'role="option" aria-disabled="true"></li>'
|
4313 |
);
|
4314 |
|
4315 |
var message = this.options.get('translations').get('loadingMore');
|
4327 |
'../utils'
|
4328 |
], function ($, Utils) {
|
4329 |
function AttachBody (decorated, $element, options) {
|
4330 |
+
this.$dropdownParent = $(options.get('dropdownParent') || document.body);
|
4331 |
|
4332 |
decorated.call(this, $element, options);
|
4333 |
}
|
4335 |
AttachBody.prototype.bind = function (decorated, container, $container) {
|
4336 |
var self = this;
|
4337 |
|
|
|
|
|
4338 |
decorated.call(this, container, $container);
|
4339 |
|
4340 |
container.on('open', function () {
|
4341 |
self._showDropdown();
|
4342 |
self._attachPositioningHandler(container);
|
4343 |
|
4344 |
+
// Must bind after the results handlers to ensure correct sizing
|
4345 |
+
self._bindContainerResultHandlers(container);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4346 |
});
|
4347 |
|
4348 |
container.on('close', function () {
|
4391 |
this.$dropdownContainer.detach();
|
4392 |
};
|
4393 |
|
4394 |
+
AttachBody.prototype._bindContainerResultHandlers =
|
4395 |
+
function (decorated, container) {
|
4396 |
+
|
4397 |
+
// These should only be bound once
|
4398 |
+
if (this._containerResultsHandlersBound) {
|
4399 |
+
return;
|
4400 |
+
}
|
4401 |
+
|
4402 |
+
var self = this;
|
4403 |
+
|
4404 |
+
container.on('results:all', function () {
|
4405 |
+
self._positionDropdown();
|
4406 |
+
self._resizeDropdown();
|
4407 |
+
});
|
4408 |
+
|
4409 |
+
container.on('results:append', function () {
|
4410 |
+
self._positionDropdown();
|
4411 |
+
self._resizeDropdown();
|
4412 |
+
});
|
4413 |
+
|
4414 |
+
container.on('results:message', function () {
|
4415 |
+
self._positionDropdown();
|
4416 |
+
self._resizeDropdown();
|
4417 |
+
});
|
4418 |
+
|
4419 |
+
container.on('select', function () {
|
4420 |
+
self._positionDropdown();
|
4421 |
+
self._resizeDropdown();
|
4422 |
+
});
|
4423 |
+
|
4424 |
+
container.on('unselect', function () {
|
4425 |
+
self._positionDropdown();
|
4426 |
+
self._resizeDropdown();
|
4427 |
+
});
|
4428 |
+
|
4429 |
+
this._containerResultsHandlersBound = true;
|
4430 |
+
};
|
4431 |
+
|
4432 |
AttachBody.prototype._attachPositioningHandler =
|
4433 |
function (decorated, container) {
|
4434 |
var self = this;
|
4439 |
|
4440 |
var $watchers = this.$container.parents().filter(Utils.hasScroll);
|
4441 |
$watchers.each(function () {
|
4442 |
+
Utils.StoreData(this, 'select2-scroll-position', {
|
4443 |
x: $(this).scrollLeft(),
|
4444 |
y: $(this).scrollTop()
|
4445 |
});
|
4446 |
});
|
4447 |
|
4448 |
$watchers.on(scrollEvent, function (ev) {
|
4449 |
+
var position = Utils.GetData(this, 'select2-scroll-position');
|
4450 |
$(this).scrollTop(position.y);
|
4451 |
});
|
4452 |
|
4505 |
top: container.bottom
|
4506 |
};
|
4507 |
|
4508 |
+
// Determine what the parent element is to use for calculating the offset
|
4509 |
var $offsetParent = this.$dropdownParent;
|
4510 |
|
4511 |
+
// For statically positioned elements, we need to get the element
|
4512 |
// that is determining the offset
|
4513 |
if ($offsetParent.css('position') === 'static') {
|
4514 |
$offsetParent = $offsetParent.offsetParent();
|
4515 |
}
|
4516 |
|
4517 |
+
var parentOffset = {
|
4518 |
+
top: 0,
|
4519 |
+
left: 0
|
4520 |
+
};
|
4521 |
+
|
4522 |
+
if (
|
4523 |
+
$.contains(document.body, $offsetParent[0]) ||
|
4524 |
+
$offsetParent[0].isConnected
|
4525 |
+
) {
|
4526 |
+
parentOffset = $offsetParent.offset();
|
4527 |
+
}
|
4528 |
|
4529 |
css.top -= parentOffset.top;
|
4530 |
css.left -= parentOffset.left;
|
4621 |
});
|
4622 |
|
4623 |
S2.define('select2/dropdown/selectOnClose',[
|
4624 |
+
'../utils'
|
4625 |
+
], function (Utils) {
|
4626 |
function SelectOnClose () { }
|
4627 |
|
4628 |
SelectOnClose.prototype.bind = function (decorated, container, $container) {
|
4653 |
return;
|
4654 |
}
|
4655 |
|
4656 |
+
var data = Utils.GetData($highlightedResults[0], 'data');
|
4657 |
|
4658 |
// Don't re-select already selected resulte
|
4659 |
if (
|
4694 |
var originalEvent = evt.originalEvent;
|
4695 |
|
4696 |
// Don't close if the control key is being held
|
4697 |
+
if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) {
|
4698 |
return;
|
4699 |
}
|
4700 |
|
4748 |
},
|
4749 |
searching: function () {
|
4750 |
return 'Searching…';
|
4751 |
+
},
|
4752 |
+
removeAllItems: function () {
|
4753 |
+
return 'Remove all items';
|
4754 |
}
|
4755 |
};
|
4756 |
});
|
4989 |
);
|
4990 |
}
|
4991 |
|
4992 |
+
// If the defaults were not previously applied from an element, it is
|
4993 |
+
// possible for the language option to have not been resolved
|
4994 |
+
options.language = this._resolveLanguage(options.language);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4995 |
|
4996 |
+
// Always fall back to English since it will always be complete
|
4997 |
+
options.language.push('en');
|
4998 |
|
4999 |
+
var uniqueLanguages = [];
|
|
|
|
|
5000 |
|
5001 |
+
for (var l = 0; l < options.language.length; l++) {
|
5002 |
+
var language = options.language[l];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5003 |
|
5004 |
+
if (uniqueLanguages.indexOf(language) === -1) {
|
5005 |
+
uniqueLanguages.push(language);
|
|
|
|
|
|
|
5006 |
}
|
5007 |
+
}
|
5008 |
|
5009 |
+
options.language = uniqueLanguages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5010 |
|
5011 |
+
options.translations = this._processTranslations(
|
5012 |
+
options.language,
|
5013 |
+
options.debug
|
5014 |
+
);
|
5015 |
|
5016 |
return options;
|
5017 |
};
|
5078 |
debug: false,
|
5079 |
dropdownAutoWidth: false,
|
5080 |
escapeMarkup: Utils.escapeMarkup,
|
5081 |
+
language: {},
|
5082 |
matcher: matcher,
|
5083 |
minimumInputLength: 0,
|
5084 |
maximumInputLength: 0,
|
5085 |
maximumSelectionLength: 0,
|
5086 |
minimumResultsForSearch: 0,
|
5087 |
selectOnClose: false,
|
5088 |
+
scrollAfterSelect: false,
|
5089 |
sorter: function (data) {
|
5090 |
return data;
|
5091 |
},
|
5100 |
};
|
5101 |
};
|
5102 |
|
5103 |
+
Defaults.prototype.applyFromElement = function (options, $element) {
|
5104 |
+
var optionLanguage = options.language;
|
5105 |
+
var defaultLanguage = this.defaults.language;
|
5106 |
+
var elementLanguage = $element.prop('lang');
|
5107 |
+
var parentLanguage = $element.closest('[lang]').prop('lang');
|
5108 |
+
|
5109 |
+
var languages = Array.prototype.concat.call(
|
5110 |
+
this._resolveLanguage(elementLanguage),
|
5111 |
+
this._resolveLanguage(optionLanguage),
|
5112 |
+
this._resolveLanguage(defaultLanguage),
|
5113 |
+
this._resolveLanguage(parentLanguage)
|
5114 |
+
);
|
5115 |
+
|
5116 |
+
options.language = languages;
|
5117 |
+
|
5118 |
+
return options;
|
5119 |
+
};
|
5120 |
+
|
5121 |
+
Defaults.prototype._resolveLanguage = function (language) {
|
5122 |
+
if (!language) {
|
5123 |
+
return [];
|
5124 |
+
}
|
5125 |
+
|
5126 |
+
if ($.isEmptyObject(language)) {
|
5127 |
+
return [];
|
5128 |
+
}
|
5129 |
+
|
5130 |
+
if ($.isPlainObject(language)) {
|
5131 |
+
return [language];
|
5132 |
+
}
|
5133 |
+
|
5134 |
+
var languages;
|
5135 |
+
|
5136 |
+
if (!$.isArray(language)) {
|
5137 |
+
languages = [language];
|
5138 |
+
} else {
|
5139 |
+
languages = language;
|
5140 |
+
}
|
5141 |
+
|
5142 |
+
var resolvedLanguages = [];
|
5143 |
+
|
5144 |
+
for (var l = 0; l < languages.length; l++) {
|
5145 |
+
resolvedLanguages.push(languages[l]);
|
5146 |
+
|
5147 |
+
if (typeof languages[l] === 'string' && languages[l].indexOf('-') > 0) {
|
5148 |
+
// Extract the region information if it is included
|
5149 |
+
var languageParts = languages[l].split('-');
|
5150 |
+
var baseLanguage = languageParts[0];
|
5151 |
+
|
5152 |
+
resolvedLanguages.push(baseLanguage);
|
5153 |
+
}
|
5154 |
+
}
|
5155 |
+
|
5156 |
+
return resolvedLanguages;
|
5157 |
+
};
|
5158 |
+
|
5159 |
+
Defaults.prototype._processTranslations = function (languages, debug) {
|
5160 |
+
var translations = new Translation();
|
5161 |
+
|
5162 |
+
for (var l = 0; l < languages.length; l++) {
|
5163 |
+
var languageData = new Translation();
|
5164 |
+
|
5165 |
+
var language = languages[l];
|
5166 |
+
|
5167 |
+
if (typeof language === 'string') {
|
5168 |
+
try {
|
5169 |
+
// Try to load it with the original name
|
5170 |
+
languageData = Translation.loadPath(language);
|
5171 |
+
} catch (e) {
|
5172 |
+
try {
|
5173 |
+
// If we couldn't load it, check if it wasn't the full path
|
5174 |
+
language = this.defaults.amdLanguageBase + language;
|
5175 |
+
languageData = Translation.loadPath(language);
|
5176 |
+
} catch (ex) {
|
5177 |
+
// The translation could not be loaded at all. Sometimes this is
|
5178 |
+
// because of a configuration problem, other times this can be
|
5179 |
+
// because of how Select2 helps load all possible translation files
|
5180 |
+
if (debug && window.console && console.warn) {
|
5181 |
+
console.warn(
|
5182 |
+
'Select2: The language file for "' + language + '" could ' +
|
5183 |
+
'not be automatically loaded. A fallback will be used instead.'
|
5184 |
+
);
|
5185 |
+
}
|
5186 |
+
}
|
5187 |
+
}
|
5188 |
+
} else if ($.isPlainObject(language)) {
|
5189 |
+
languageData = new Translation(language);
|
5190 |
+
} else {
|
5191 |
+
languageData = language;
|
5192 |
+
}
|
5193 |
+
|
5194 |
+
translations.extend(languageData);
|
5195 |
+
}
|
5196 |
+
|
5197 |
+
return translations;
|
5198 |
+
};
|
5199 |
+
|
5200 |
Defaults.prototype.set = function (key, value) {
|
5201 |
var camelKey = $.camelCase(key);
|
5202 |
|
5205 |
|
5206 |
var convertedData = Utils._convertData(data);
|
5207 |
|
5208 |
+
$.extend(true, this.defaults, convertedData);
|
5209 |
};
|
5210 |
|
5211 |
var defaults = new Defaults();
|
5226 |
this.fromElement($element);
|
5227 |
}
|
5228 |
|
5229 |
+
if ($element != null) {
|
5230 |
+
this.options = Defaults.applyFromElement(this.options, $element);
|
5231 |
+
}
|
5232 |
+
|
5233 |
this.options = Defaults.apply(this.options);
|
5234 |
|
5235 |
if ($element && $element.is('input')) {
|
5253 |
this.options.disabled = $e.prop('disabled');
|
5254 |
}
|
5255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5256 |
if (this.options.dir == null) {
|
5257 |
if ($e.prop('dir')) {
|
5258 |
this.options.dir = $e.prop('dir');
|
5266 |
$e.prop('disabled', this.options.disabled);
|
5267 |
$e.prop('multiple', this.options.multiple);
|
5268 |
|
5269 |
+
if (Utils.GetData($e[0], 'select2Tags')) {
|
5270 |
if (this.options.debug && window.console && console.warn) {
|
5271 |
console.warn(
|
5272 |
'Select2: The `data-select2-tags` attribute has been changed to ' +
|
5275 |
);
|
5276 |
}
|
5277 |
|
5278 |
+
Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags'));
|
5279 |
+
Utils.StoreData($e[0], 'tags', true);
|
5280 |
}
|
5281 |
|
5282 |
+
if (Utils.GetData($e[0], 'ajaxUrl')) {
|
5283 |
if (this.options.debug && window.console && console.warn) {
|
5284 |
console.warn(
|
5285 |
'Select2: The `data-ajax-url` attribute has been changed to ' +
|
5288 |
);
|
5289 |
}
|
5290 |
|
5291 |
+
$e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl'));
|
5292 |
+
Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl'));
|
5293 |
}
|
5294 |
|
5295 |
var dataset = {};
|
5296 |
|
5297 |
+
function upperCaseLetter(_, letter) {
|
5298 |
+
return letter.toUpperCase();
|
5299 |
+
}
|
5300 |
+
|
5301 |
+
// Pre-load all of the attributes which are prefixed with `data-`
|
5302 |
+
for (var attr = 0; attr < $e[0].attributes.length; attr++) {
|
5303 |
+
var attributeName = $e[0].attributes[attr].name;
|
5304 |
+
var prefix = 'data-';
|
5305 |
+
|
5306 |
+
if (attributeName.substr(0, prefix.length) == prefix) {
|
5307 |
+
// Get the contents of the attribute after `data-`
|
5308 |
+
var dataName = attributeName.substring(prefix.length);
|
5309 |
+
|
5310 |
+
// Get the data contents from the consistent source
|
5311 |
+
// This is more than likely the jQuery data helper
|
5312 |
+
var dataValue = Utils.GetData($e[0], dataName);
|
5313 |
+
|
5314 |
+
// camelCase the attribute name to match the spec
|
5315 |
+
var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter);
|
5316 |
+
|
5317 |
+
// Store the data attribute contents into the dataset since
|
5318 |
+
dataset[camelDataName] = dataValue;
|
5319 |
+
}
|
5320 |
+
}
|
5321 |
+
|
5322 |
// Prefer the element's `dataset` attribute if it exists
|
5323 |
// jQuery 1.x does not correctly handle data attributes with multiple dashes
|
5324 |
if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
|
5325 |
+
dataset = $.extend(true, {}, $e[0].dataset, dataset);
|
|
|
|
|
5326 |
}
|
5327 |
|
5328 |
+
// Prefer our internal data cache if it exists
|
5329 |
+
var data = $.extend(true, {}, Utils.GetData($e[0]), dataset);
|
5330 |
|
5331 |
data = Utils._convertData(data);
|
5332 |
|
5363 |
'./keys'
|
5364 |
], function ($, Options, Utils, KEYS) {
|
5365 |
var Select2 = function ($element, options) {
|
5366 |
+
if (Utils.GetData($element[0], 'select2') != null) {
|
5367 |
+
Utils.GetData($element[0], 'select2').destroy();
|
5368 |
}
|
5369 |
|
5370 |
this.$element = $element;
|
5380 |
// Set up the tabindex
|
5381 |
|
5382 |
var tabindex = $element.attr('tabindex') || 0;
|
5383 |
+
Utils.StoreData($element[0], 'old-tabindex', tabindex);
|
5384 |
$element.attr('tabindex', '-1');
|
5385 |
|
5386 |
// Set up containers and adapters
|
5441 |
// Synchronize any monitored attributes
|
5442 |
this._syncAttributes();
|
5443 |
|
5444 |
+
Utils.StoreData($element[0], 'select2', this);
|
5445 |
+
|
5446 |
+
// Ensure backwards compatibility with $element.data('select2').
|
5447 |
$element.data('select2', this);
|
5448 |
};
|
5449 |
|
5520 |
return null;
|
5521 |
}
|
5522 |
|
5523 |
+
if (method == 'computedstyle') {
|
5524 |
+
var computedStyle = window.getComputedStyle($element[0]);
|
5525 |
+
|
5526 |
+
return computedStyle.width;
|
5527 |
+
}
|
5528 |
+
|
5529 |
return method;
|
5530 |
};
|
5531 |
|
5566 |
|
5567 |
if (observer != null) {
|
5568 |
this._observer = new observer(function (mutations) {
|
5569 |
+
self._syncA();
|
5570 |
+
self._syncS(null, mutations);
|
5571 |
});
|
5572 |
this._observer.observe(this.$element[0], {
|
5573 |
attributes: true,
|
5689 |
if (self.isOpen()) {
|
5690 |
if (key === KEYS.ESC || key === KEYS.TAB ||
|
5691 |
(key === KEYS.UP && evt.altKey)) {
|
5692 |
+
self.close(evt);
|
5693 |
|
5694 |
evt.preventDefault();
|
5695 |
} else if (key === KEYS.ENTER) {
|
5723 |
Select2.prototype._syncAttributes = function () {
|
5724 |
this.options.set('disabled', this.$element.prop('disabled'));
|
5725 |
|
5726 |
+
if (this.isDisabled()) {
|
5727 |
if (this.isOpen()) {
|
5728 |
this.close();
|
5729 |
}
|
5734 |
}
|
5735 |
};
|
5736 |
|
5737 |
+
Select2.prototype._isChangeMutation = function (evt, mutations) {
|
5738 |
var changed = false;
|
5739 |
var self = this;
|
5740 |
|
5762 |
}
|
5763 |
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
|
5764 |
changed = true;
|
5765 |
+
} else if ($.isArray(mutations)) {
|
5766 |
+
$.each(mutations, function(evt, mutation) {
|
5767 |
+
if (self._isChangeMutation(evt, mutation)) {
|
5768 |
+
// We've found a change mutation.
|
5769 |
+
// Let's escape from the loop and continue
|
5770 |
+
changed = true;
|
5771 |
+
return false;
|
5772 |
+
}
|
5773 |
+
});
|
5774 |
}
|
5775 |
+
return changed;
|
5776 |
+
};
|
5777 |
+
|
5778 |
+
Select2.prototype._syncSubtree = function (evt, mutations) {
|
5779 |
+
var changed = this._isChangeMutation(evt, mutations);
|
5780 |
+
var self = this;
|
5781 |
|
5782 |
// Only re-pull the data if we think there is a change
|
5783 |
if (changed) {
|
5799 |
'open': 'opening',
|
5800 |
'close': 'closing',
|
5801 |
'select': 'selecting',
|
5802 |
+
'unselect': 'unselecting',
|
5803 |
+
'clear': 'clearing'
|
5804 |
};
|
5805 |
|
5806 |
if (args === undefined) {
|
5828 |
};
|
5829 |
|
5830 |
Select2.prototype.toggleDropdown = function () {
|
5831 |
+
if (this.isDisabled()) {
|
5832 |
return;
|
5833 |
}
|
5834 |
|
5844 |
return;
|
5845 |
}
|
5846 |
|
5847 |
+
if (this.isDisabled()) {
|
5848 |
+
return;
|
5849 |
+
}
|
5850 |
+
|
5851 |
this.trigger('query', {});
|
5852 |
};
|
5853 |
|
5854 |
+
Select2.prototype.close = function (evt) {
|
5855 |
if (!this.isOpen()) {
|
5856 |
return;
|
5857 |
}
|
5858 |
|
5859 |
+
this.trigger('close', { originalEvent : evt });
|
5860 |
+
};
|
5861 |
+
|
5862 |
+
/**
|
5863 |
+
* Helper method to abstract the "enabled" (not "disabled") state of this
|
5864 |
+
* object.
|
5865 |
+
*
|
5866 |
+
* @return {true} if the instance is not disabled.
|
5867 |
+
* @return {false} if the instance is disabled.
|
5868 |
+
*/
|
5869 |
+
Select2.prototype.isEnabled = function () {
|
5870 |
+
return !this.isDisabled();
|
5871 |
+
};
|
5872 |
+
|
5873 |
+
/**
|
5874 |
+
* Helper method to abstract the "disabled" state of this object.
|
5875 |
+
*
|
5876 |
+
* @return {true} if the disabled option is true.
|
5877 |
+
* @return {false} if the disabled option is false.
|
5878 |
+
*/
|
5879 |
+
Select2.prototype.isDisabled = function () {
|
5880 |
+
return this.options.get('disabled');
|
5881 |
};
|
5882 |
|
5883 |
Select2.prototype.isOpen = function () {
|
5954 |
});
|
5955 |
}
|
5956 |
|
5957 |
+
this.$element.val(newVal).trigger('input').trigger('change');
|
5958 |
};
|
5959 |
|
5960 |
Select2.prototype.destroy = function () {
|
5980 |
this._syncS = null;
|
5981 |
|
5982 |
this.$element.off('.select2');
|
5983 |
+
this.$element.attr('tabindex',
|
5984 |
+
Utils.GetData(this.$element[0], 'old-tabindex'));
|
5985 |
|
5986 |
this.$element.removeClass('select2-hidden-accessible');
|
5987 |
this.$element.attr('aria-hidden', 'false');
|
5988 |
+
Utils.RemoveData(this.$element[0]);
|
5989 |
this.$element.removeData('select2');
|
5990 |
|
5991 |
this.dataAdapter.destroy();
|
6013 |
|
6014 |
this.$container.addClass('select2-container--' + this.options.get('theme'));
|
6015 |
|
6016 |
+
Utils.StoreData($container[0], 'element', this.$element);
|
6017 |
|
6018 |
return $container;
|
6019 |
};
|
6033 |
'jquery-mousewheel',
|
6034 |
|
6035 |
'./select2/core',
|
6036 |
+
'./select2/defaults',
|
6037 |
+
'./select2/utils'
|
6038 |
+
], function ($, _, Select2, Defaults, Utils) {
|
6039 |
if ($.fn.select2 == null) {
|
6040 |
// All methods that should return the element
|
6041 |
var thisMethods = ['open', 'close', 'destroy'];
|
6056 |
var args = Array.prototype.slice.call(arguments, 1);
|
6057 |
|
6058 |
this.each(function () {
|
6059 |
+
var instance = Utils.GetData(this, 'select2');
|
6060 |
|
6061 |
if (instance == null && window.console && console.error) {
|
6062 |
console.error(
|
assets/inc/select2/4/select2.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
|
1 |
+
.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px;padding:1px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right;margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
|
assets/inc/select2/4/select2.min.js
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
-
/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n<c.length;n+=1)if(m=o(c[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=d?d.apply(q[a],u):void 0,a&&(h&&h.exports!==b&&h.exports!==q[a]?q[a]=h.exports:l===b&&s||(q[a]=l))}else a&&(q[a]=d)},a=c=n=function(a,c,d,e,f){if("string"==typeof a)return p[a]?p[a](c):j(o(a,c).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?m(b,a,c,d):setTimeout(function(){m(b,a,c,d)},4),n},n.config=function(a){return n(a)},a._defined=q,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){var e=b[d];"function"==typeof e&&"constructor"!==d&&c.push(d)}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){var a=Array.prototype.unshift;return a.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};return d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]._type=a,a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},d.prototype.invoke=function(a,b){for(var c=0,d=a.length;d>c;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e<c.length;e++){var f=c[e];f=f.substring(0,1).toLowerCase()+f.substring(1),f in d||(d[f]={}),e==c.length-1&&(d[f]=a[b]),d=d[f]}delete a[b]}}return a},c.hasScroll=function(b,c){var d=a(c),e=c.style.overflowX,f=c.style.overflowY;return e!==f||"hidden"!==f&&"visible"!==f?"scroll"===e||"scroll"===f?!0:d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth:!1},c.escapeMarkup=function(a){var b={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('<li role="treeitem" aria-live="assertive" class="select2-results__option"></li>'),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c<a.results.length;c++){var d=a.results[c],e=this.option(d);b.push(e)}this.$results.append(b)},c.prototype.position=function(a,b){var c=b.find(".select2-results");c.append(a)},c.prototype.sort=function(a){var b=this.options.get("sorter");return b(a)},c.prototype.highlightFirstItem=function(){var a=this.$results.find(".select2-results__option[aria-selected]"),b=a.filter("[aria-selected=true]");b.length>0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j<b.children.length;j++){var k=b.children[j],l=this.option(k);i.push(l)}var m=a("<ul></ul>",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("<span></span>")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('<ul class="select2-selection__rendered"></ul>'),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">×</span></li>');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d<a.length;d++){var e=a[d],f=this.selectionContainer(),g=this.display(e,f);f.append(g),f.prop("title",e.title||e.text),f.data("data",e),b.push(f)}var h=this.$selection.find(".select2-selection__rendered");c.appendMany(h,b)}},d}),b.define("select2/selection/placeholder",["../utils"],function(a){function b(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return b.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},b.prototype.createPlaceholder=function(a,b){var c=this.selectionContainer();return c.html(this.display(b)),c.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),c},b.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id,d=b.length>1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e<d.length;e++){var f={data:d[e]};if(this.trigger("unselect",f),f.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},c.prototype._handleKeyboardClear=function(a,c,d){d.isOpen()||(c.which==b.DELETE||c.which==b.BACKSPACE)&&this._handleClear(c)},c.prototype.update=function(b,c){if(b.call(this,c),!(this.$selection.find(".select2-selection__placeholder").length>0||0===c.length)){var d=a('<span class="select2-selection__clear">×</span>');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");
|
2 |
-
if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f<a.length;f++){var g=a[f].id;-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;if(this.$element.prop("multiple"))return a.selected=!1,c(a.element).is("option")?(a.element.selected=!1,void this.$element.trigger("change")):void this.current(function(d){for(var e=[],f=0;f<d.length;f++){var g=d[f].id;g!==a.id&&-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")})},d.prototype.bind=function(a,b){var c=this;this.container=a,a.on("select",function(a){c.select(a.data)}),a.on("unselect",function(a){c.unselect(a.data)})},d.prototype.destroy=function(){this.$element.find("*").each(function(){c.removeData(this,"data")})},d.prototype.query=function(a,b){var d=[],e=this,f=this.$element.children();f.each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b({results:d})},d.prototype.addOptions=function(a){b.appendMany(this.$element,a)},d.prototype.option=function(a){var b;a.children?(b=document.createElement("optgroup"),b.label=a.text):(b=document.createElement("option"),void 0!==b.textContent?b.textContent=a.text:b.innerText=a.text),a.id&&(b.value=a.id),a.disabled&&(b.disabled=!0),a.selected&&(b.selected=!0),a.title&&(b.title=a.title);var d=c(b),e=this._normalizeItem(a);return e.element=b,c.data(b,"data",e),d},d.prototype.item=function(a){var b={};if(b=c.data(a[0],"data"),null!=b)return b;if(a.is("option"))b={id:a.val(),text:a.text(),disabled:a.prop("disabled"),selected:a.prop("selected"),title:a.prop("title")};else if(a.is("optgroup")){b={text:a.prop("label"),children:[],title:a.prop("title")};for(var d=a.children("option"),e=[],f=0;f<d.length;f++){var g=c(d[f]),h=this.item(g);e.push(h)}b.children=e}return b=this._normalizeItem(b),b.element=a[0],c.data(a[0],"data",b),b},d.prototype._normalizeItem=function(a){c.isPlainObject(a)||(a={id:a,text:a}),a=c.extend({},{text:""},a);var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){var c=this.options.get("matcher");return c(a,b)},d}),b.define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data")||[];d.__super__.constructor.call(this,a,b),this.addOptions(this.convertToOptions(c))}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find("option").filter(function(b,c){return c.value==a.id.toString()});0===b.length&&(b=this.option(a),this.addOptions(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function d(a){return function(){return c(this).val()==a.id}}for(var e=this,f=this.$element.find("option"),g=f.map(function(){return e.item(c(this)).id}).get(),h=[],i=0;i<a.length;i++){var j=this._normalizeItem(a[i]);if(c.inArray(j.id,g)>=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h<e.length;h++){var i=e[h],j=this._normalizeItem(i),k=this.option(j);this.$element.append(k)}}return b.prototype.query=function(a,b,c){function d(a,f){for(var g=a.results,h=0;h<g.length;h++){var i=g[h],j=null!=i.children&&!d({results:i.children},!0),k=i.text===b.term;if(k||j)return f?!1:(a.data=g,void c(a))}if(f)return!0;var l=e.createTag(b);if(null!=l){var m=e.option(l);m.attr("data-select2-tag",!0),e.addOptions([m]),e.insertTag(g,l)}a.results=g,c(a)}var e=this;return this._removeOldTags(),null==b.term||null!=b.page?void a.call(this,b,c):void a.call(this,b,d)},b.prototype.createTag=function(b,c){var d=a.trim(c.term);return""===d?null:{id:d,text:d}},b.prototype.insertTag=function(a,b,c){b.unshift(c)},b.prototype._removeOldTags=function(b){var c=(this._lastTag,this.$element.find("option[data-select2-tag]"));c.each(function(){this.selected||a(this).remove()})},b}),b.define("select2/data/tokenizer",["jquery"],function(a){function b(a,b,c){var d=c.get("tokenizer");void 0!==d&&(this.tokenizer=d),a.call(this,b,c)}return b.prototype.bind=function(a,b,c){a.call(this,b,c),this.$search=b.dropdown.$search||b.selection.$search||c.find(".select2-search__field")},b.prototype.query=function(b,c,d){function e(b){var c=g._normalizeItem(b),d=g.$element.find("option").filter(function(){return a(this).val()===c.id});if(!d.length){var e=g.option(c);e.attr("data-select2-tag",!0),g._removeOldTags(),g.addOptions([e])}f(c)}function f(a){g.trigger("select",{data:a})}var g=this;c.term=c.term||"";var h=this.tokenizer(c,this.options,e);h.term!==c.term&&(this.$search.length&&(this.$search.val(h.term),this.$search.focus()),c.term=h.term),b.call(this,c,d)},b.prototype.tokenizer=function(b,c,d,e){for(var f=d.get("tokenSeparators")||[],g=c.term,h=0,i=this.createTag||function(a){return{id:a.term,text:a.term}};h<g.length;){var j=g[h];if(-1!==a.inArray(j,f)){var k=g.substr(0,h),l=a.extend({},c,{term:k}),m=i(l);null!=m?(e(m),g=g.substr(h+1)||"",h=0):h++}else h++}return{term:g}},b}),b.define("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",b.term.length<this.minimumInputLength?void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumInputLength",[],function(){function a(a,b,c){this.maximumInputLength=c.get("maximumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",this.maximumInputLength>0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<span class="select2-dropdown"><span class="select2-results"></span></span>');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('<li class="select2-results__option select2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a("<span></span>"),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.top<f.top-h.height,k=i.bottom>f.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d<b.length;d++){var e=b[d];e.children?c+=a(e.children):c++}return c}function b(a,b,c,d){this.minimumResultsForSearch=c.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),a.call(this,b,c,d)}return b.prototype.showSearch=function(b,c){return a(c.data.results)<this.minimumResultsForSearch?!1:b.call(this,c)},b}),b.define("select2/dropdown/selectOnClose",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("close",function(a){d._handleSelectOnClose(a)})},a.prototype._handleSelectOnClose=function(a,b){if(b&&null!=b.originalSelect2Event){var c=b.originalSelect2Event;if("select"===c._type||"unselect"===c._type)return}var d=this.getHighlightedResults();if(!(d.length<1)){var e=d.data("data");null!=e.element&&e.element.selected||null==e.element&&e.selected||this.trigger("select",{data:e})}},a}),b.define("select2/dropdown/closeOnSelect",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("select",function(a){d._selectTriggered(a)}),b.on("unselect",function(a){d._selectTriggered(a)})},a.prototype._selectTriggered=function(a,b){var c=b.originalEvent;c&&c.ctrlKey||this.trigger("close",{originalEvent:c,originalSelect2Event:b})},a}),b.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(a){var b=a.input.length-a.maximum,c="Please delete "+b+" character";return 1!=b&&(c+="s"),c},inputTooShort:function(a){var b=a.minimum-a.input.length,c="Please enter "+b+" or more characters";return c},loadingMore:function(){return"Loading more results…"},maximumSelected:function(a){var b="You can only select "+a.maximum+" item";return 1!=a.maximum&&(b+="s"),b},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),b.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C){function D(){this.reset()}D.prototype.apply=function(l){if(l=a.extend(!0,{},this.defaults,l),null==l.dataAdapter){if(null!=l.ajax?l.dataAdapter=o:null!=l.data?l.dataAdapter=n:l.dataAdapter=m,l.minimumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L<K.length;L++){var M=K[L],N={};try{N=k.loadPath(M)}catch(O){try{M=this.defaults.amdLanguageBase+M,N=k.loadPath(M)}catch(P){l.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+M+'" could not be automatically loaded. A fallback will be used instead.');continue}}J.extend(N)}l.translations=J}else{var Q=k.loadPath(this.defaults.amdLanguageBase+"en"),R=new k(l.language);R.extend(Q),l.translations=R}return l},D.prototype.reset=function(){function b(a){function b(a){return l[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function c(d,e){if(""===a.trim(d.term))return e;if(e.children&&e.children.length>0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e<b.addedNodes.length;e++){var f=b.addedNodes[e];f.selected&&(c=!0)}else b.removedNodes&&b.removedNodes.length>0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null;
|
3 |
-
},e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("jquery-mousewheel",["jquery"],function(a){return a}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c});
|
1 |
+
/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */
|
2 |
+
!function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),n(t),t}:n(jQuery)}(function(u){var e=function(){if(u&&u.fn&&u.fn.select2&&u.fn.select2.amd)var e=u.fn.select2.amd;var t,n,r,h,o,s,f,g,m,v,y,_,i,a,b;function w(e,t){return i.call(e,t)}function l(e,t){var n,r,i,o,s,a,l,c,u,d,p,h=t&&t.split("/"),f=y.map,g=f&&f["*"]||{};if(e){for(s=(e=e.split("/")).length-1,y.nodeIdCompat&&b.test(e[s])&&(e[s]=e[s].replace(b,"")),"."===e[0].charAt(0)&&h&&(e=h.slice(0,h.length-1).concat(e)),u=0;u<e.length;u++)if("."===(p=e[u]))e.splice(u,1),u-=1;else if(".."===p){if(0===u||1===u&&".."===e[2]||".."===e[u-1])continue;0<u&&(e.splice(u-1,2),u-=2)}e=e.join("/")}if((h||g)&&f){for(u=(n=e.split("/")).length;0<u;u-=1){if(r=n.slice(0,u).join("/"),h)for(d=h.length;0<d;d-=1)if(i=(i=f[h.slice(0,d).join("/")])&&i[r]){o=i,a=u;break}if(o)break;!l&&g&&g[r]&&(l=g[r],c=u)}!o&&l&&(o=l,a=c),o&&(n.splice(0,a,o),e=n.join("/"))}return e}function A(t,n){return function(){var e=a.call(arguments,0);return"string"!=typeof e[0]&&1===e.length&&e.push(null),s.apply(h,e.concat([t,n]))}}function x(t){return function(e){m[t]=e}}function D(e){if(w(v,e)){var t=v[e];delete v[e],_[e]=!0,o.apply(h,t)}if(!w(m,e)&&!w(_,e))throw new Error("No "+e);return m[e]}function c(e){var t,n=e?e.indexOf("!"):-1;return-1<n&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function S(e){return e?c(e):[]}return e&&e.requirejs||(e?n=e:e={},m={},v={},y={},_={},i=Object.prototype.hasOwnProperty,a=[].slice,b=/\.js$/,f=function(e,t){var n,r=c(e),i=r[0],o=t[1];return e=r[1],i&&(n=D(i=l(i,o))),i?e=n&&n.normalize?n.normalize(e,function(t){return function(e){return l(e,t)}}(o)):l(e,o):(i=(r=c(e=l(e,o)))[0],e=r[1],i&&(n=D(i))),{f:i?i+"!"+e:e,n:e,pr:i,p:n}},g={require:function(e){return A(e)},exports:function(e){var t=m[e];return void 0!==t?t:m[e]={}},module:function(e){return{id:e,uri:"",exports:m[e],config:function(e){return function(){return y&&y.config&&y.config[e]||{}}}(e)}}},o=function(e,t,n,r){var i,o,s,a,l,c,u,d=[],p=typeof n;if(c=S(r=r||e),"undefined"==p||"function"==p){for(t=!t.length&&n.length?["require","exports","module"]:t,l=0;l<t.length;l+=1)if("require"===(o=(a=f(t[l],c)).f))d[l]=g.require(e);else if("exports"===o)d[l]=g.exports(e),u=!0;else if("module"===o)i=d[l]=g.module(e);else if(w(m,o)||w(v,o)||w(_,o))d[l]=D(o);else{if(!a.p)throw new Error(e+" missing "+o);a.p.load(a.n,A(r,!0),x(o),{}),d[l]=m[o]}s=n?n.apply(m[e],d):void 0,e&&(i&&i.exports!==h&&i.exports!==m[e]?m[e]=i.exports:s===h&&u||(m[e]=s))}else e&&(m[e]=n)},t=n=s=function(e,t,n,r,i){if("string"==typeof e)return g[e]?g[e](t):D(f(e,S(t)).f);if(!e.splice){if((y=e).deps&&s(y.deps,y.callback),!t)return;t.splice?(e=t,t=n,n=null):e=h}return t=t||function(){},"function"==typeof n&&(n=r,r=i),r?o(h,e,t,n):setTimeout(function(){o(h,e,t,n)},4),s},s.config=function(e){return s(e)},t._defined=m,(r=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),w(m,e)||w(v,e)||(v[e]=[e,t,n])}).amd={jQuery:!0},e.requirejs=t,e.require=n,e.define=r),e.define("almond",function(){}),e.define("jquery",[],function(){var e=u||$;return null==e&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),e}),e.define("select2/utils",["jquery"],function(o){var i={};function u(e){var t=e.prototype,n=[];for(var r in t){"function"==typeof t[r]&&"constructor"!==r&&n.push(r)}return n}i.Extend=function(e,t){var n={}.hasOwnProperty;function r(){this.constructor=e}for(var i in t)n.call(t,i)&&(e[i]=t[i]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e},i.Decorate=function(r,i){var e=u(i),t=u(r);function o(){var e=Array.prototype.unshift,t=i.prototype.constructor.length,n=r.prototype.constructor;0<t&&(e.call(arguments,r.prototype.constructor),n=i.prototype.constructor),n.apply(this,arguments)}i.displayName=r.displayName,o.prototype=new function(){this.constructor=o};for(var n=0;n<t.length;n++){var s=t[n];o.prototype[s]=r.prototype[s]}function a(e){var t=function(){};e in o.prototype&&(t=o.prototype[e]);var n=i.prototype[e];return function(){return Array.prototype.unshift.call(arguments,t),n.apply(this,arguments)}}for(var l=0;l<e.length;l++){var c=e[l];o.prototype[c]=a(c)}return o};function e(){this.listeners={}}e.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},e.prototype.trigger=function(e){var t=Array.prototype.slice,n=t.call(arguments,1);this.listeners=this.listeners||{},null==n&&(n=[]),0===n.length&&n.push({}),(n[0]._type=e)in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},e.prototype.invoke=function(e,t){for(var n=0,r=e.length;n<r;n++)e[n].apply(this,t)},i.Observable=e,i.generateChars=function(e){for(var t="",n=0;n<e;n++){t+=Math.floor(36*Math.random()).toString(36)}return t},i.bind=function(e,t){return function(){e.apply(t,arguments)}},i._convertData=function(e){for(var t in e){var n=t.split("-"),r=e;if(1!==n.length){for(var i=0;i<n.length;i++){var o=n[i];(o=o.substring(0,1).toLowerCase()+o.substring(1))in r||(r[o]={}),i==n.length-1&&(r[o]=e[t]),r=r[o]}delete e[t]}}return e},i.hasScroll=function(e,t){var n=o(t),r=t.style.overflowX,i=t.style.overflowY;return(r!==i||"hidden"!==i&&"visible"!==i)&&("scroll"===r||"scroll"===i||(n.innerHeight()<t.scrollHeight||n.innerWidth()<t.scrollWidth))},i.escapeMarkup=function(e){var t={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},i.appendMany=function(e,t){if("1.7"===o.fn.jquery.substr(0,3)){var n=o();o.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},i.__cache={};var n=0;return i.GetUniqueElementId=function(e){var t=e.getAttribute("data-select2-id");return null==t&&(e.id?(t=e.id,e.setAttribute("data-select2-id",t)):(e.setAttribute("data-select2-id",++n),t=n.toString())),t},i.StoreData=function(e,t,n){var r=i.GetUniqueElementId(e);i.__cache[r]||(i.__cache[r]={}),i.__cache[r][t]=n},i.GetData=function(e,t){var n=i.GetUniqueElementId(e);return t?i.__cache[n]&&null!=i.__cache[n][t]?i.__cache[n][t]:o(e).data(t):i.__cache[n]},i.RemoveData=function(e){var t=i.GetUniqueElementId(e);null!=i.__cache[t]&&delete i.__cache[t],e.removeAttribute("data-select2-id")},i}),e.define("select2/results",["jquery","./utils"],function(h,f){function r(e,t,n){this.$element=e,this.data=n,this.options=t,r.__super__.constructor.call(this)}return f.Extend(r,f.Observable),r.prototype.render=function(){var e=h('<ul class="select2-results__options" role="listbox"></ul>');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},r.prototype.clear=function(){this.$results.empty()},r.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=h('<li role="alert" aria-live="assertive" class="select2-results__option"></li>'),r=this.options.get("translations").get(e.message);n.append(t(r(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},r.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},r.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var r=e.results[n],i=this.option(r);t.push(i)}this.$results.append(t)}else 0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"})},r.prototype.position=function(e,t){t.find(".select2-results").append(e)},r.prototype.sort=function(e){return this.options.get("sorter")(e)},r.prototype.highlightFirstItem=function(){var e=this.$results.find(".select2-results__option[aria-selected]"),t=e.filter("[aria-selected=true]");0<t.length?t.first().trigger("mouseenter"):e.first().trigger("mouseenter"),this.ensureHighlightVisible()},r.prototype.setClasses=function(){var t=this;this.data.current(function(e){var r=h.map(e,function(e){return e.id.toString()});t.$results.find(".select2-results__option[aria-selected]").each(function(){var e=h(this),t=f.GetData(this,"data"),n=""+t.id;null!=t.element&&t.element.selected||null==t.element&&-1<h.inArray(n,r)?e.attr("aria-selected","true"):e.attr("aria-selected","false")})})},r.prototype.showLoading=function(e){this.hideLoading();var t={disabled:!0,loading:!0,text:this.options.get("translations").get("searching")(e)},n=this.option(t);n.className+=" loading-results",this.$results.prepend(n)},r.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},r.prototype.option=function(e){var t=document.createElement("li");t.className="select2-results__option";var n={role:"option","aria-selected":"false"},r=window.Element.prototype.matches||window.Element.prototype.msMatchesSelector||window.Element.prototype.webkitMatchesSelector;for(var i in(null!=e.element&&r.call(e.element,":disabled")||null==e.element&&e.disabled)&&(delete n["aria-selected"],n["aria-disabled"]="true"),null==e.id&&delete n["aria-selected"],null!=e._resultId&&(t.id=e._resultId),e.title&&(t.title=e.title),e.children&&(n.role="group",n["aria-label"]=e.text,delete n["aria-selected"]),n){var o=n[i];t.setAttribute(i,o)}if(e.children){var s=h(t),a=document.createElement("strong");a.className="select2-results__group";h(a);this.template(e,a);for(var l=[],c=0;c<e.children.length;c++){var u=e.children[c],d=this.option(u);l.push(d)}var p=h("<ul></ul>",{class:"select2-results__options select2-results__options--nested"});p.append(l),s.append(a),s.append(p)}else this.template(e,t);return f.StoreData(t,"data",e),t},r.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&(l.setClasses(),l.options.get("scrollAfterSelect")&&l.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(l.setClasses(),l.options.get("scrollAfterSelect")&&l.highlightFirstItem())}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=f.GetData(e[0],"data");"true"==e.attr("aria-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e);if(!(n<=0)){var r=n-1;0===e.length&&(r=0);var i=t.eq(r);i.trigger("mouseenter");var o=l.$results.offset().top,s=i.offset().top,a=l.$results.scrollTop()+(s-o);0===r?l.$results.scrollTop(0):s-o<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var r=t.eq(n);r.trigger("mouseenter");var i=l.$results.offset().top+l.$results.outerHeight(!1),o=r.offset().top+r.outerHeight(!1),s=l.$results.scrollTop()+o-i;0===n?l.$results.scrollTop(0):i<o&&l.$results.scrollTop(s)}}),t.on("results:focus",function(e){e.element.addClass("select2-results__option--highlighted")}),t.on("results:message",function(e){l.displayMessage(e)}),h.fn.mousewheel&&this.$results.on("mousewheel",function(e){var t=l.$results.scrollTop(),n=l.$results.get(0).scrollHeight-t+e.deltaY,r=0<e.deltaY&&t-e.deltaY<=0,i=e.deltaY<0&&n<=l.$results.height();r?(l.$results.scrollTop(0),e.preventDefault(),e.stopPropagation()):i&&(l.$results.scrollTop(l.$results.get(0).scrollHeight-l.$results.height()),e.preventDefault(),e.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(e){var t=h(this),n=f.GetData(this,"data");"true"!==t.attr("aria-selected")?l.trigger("select",{originalEvent:e,data:n}):l.options.get("multiple")?l.trigger("unselect",{originalEvent:e,data:n}):l.trigger("close",{})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(e){var t=f.GetData(this,"data");l.getHighlightedResults().removeClass("select2-results__option--highlighted"),l.trigger("results:focus",{data:t,element:h(this)})})},r.prototype.getHighlightedResults=function(){return this.$results.find(".select2-results__option--highlighted")},r.prototype.destroy=function(){this.$results.remove()},r.prototype.ensureHighlightVisible=function(){var e=this.getHighlightedResults();if(0!==e.length){var t=this.$results.find("[aria-selected]").index(e),n=this.$results.offset().top,r=e.offset().top,i=this.$results.scrollTop()+(r-n),o=r-n;i-=2*e.outerHeight(!1),t<=2?this.$results.scrollTop(0):(o>this.$results.outerHeight()||o<0)&&this.$results.scrollTop(i)}},r.prototype.template=function(e,t){var n=this.options.get("templateResult"),r=this.options.get("escapeMarkup"),i=n(e,t);null==i?t.style.display="none":"string"==typeof i?t.innerHTML=r(i):h(t).append(i)},r}),e.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("select2/selection/base",["jquery","../utils","../keys"],function(n,r,i){function o(e,t){this.$element=e,this.options=t,o.__super__.constructor.call(this)}return r.Extend(o,r.Observable),o.prototype.render=function(){var e=n('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=r.GetData(this.$element[0],"old-tabindex")?this._tabindex=r.GetData(this.$element[0],"old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),e.attr("aria-disabled","false"),this.$selection=e},o.prototype.bind=function(e,t){var n=this,r=e.id+"-results";this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===i.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",r),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),n.$selection.trigger("focus"),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex),n.$selection.attr("aria-disabled","false")}),e.on("disable",function(){n.$selection.attr("tabindex","-1"),n.$selection.attr("aria-disabled","true")})},o.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||n.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},o.prototype._attachCloseHandler=function(e){n(document.body).on("mousedown.select2."+e.id,function(e){var t=n(e.target).closest(".select2");n(".select2.select2-container--open").each(function(){this!=t[0]&&r.GetData(this,"element").select2("close")})})},o.prototype._detachCloseHandler=function(e){n(document.body).off("mousedown.select2."+e.id)},o.prototype.position=function(e,t){t.find(".selection").append(e)},o.prototype.destroy=function(){this._detachCloseHandler(this.container)},o.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},o.prototype.isEnabled=function(){return!this.isDisabled()},o.prototype.isDisabled=function(){return this.options.get("disabled")},o}),e.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,r){function i(){i.__super__.constructor.apply(this,arguments)}return n.Extend(i,t),i.prototype.render=function(){var e=i.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),e},i.prototype.bind=function(t,e){var n=this;i.__super__.bind.apply(this,arguments);var r=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",r).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",r),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.trigger("focus")})},i.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},i.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},i.prototype.selectionContainer=function(){return e("<span></span>")},i.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2-selection__rendered"),r=this.display(t,n);n.empty().append(r);var i=t.title||t.text;i?n.attr("title",i):n.removeAttr("title")}else this.clear()},i}),e.define("select2/selection/multiple",["jquery","./base","../utils"],function(i,e,l){function n(e,t){n.__super__.constructor.apply(this,arguments)}return l.Extend(n,e),n.prototype.render=function(){var e=n.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('<ul class="select2-selection__rendered"></ul>'),e},n.prototype.bind=function(e,t){var r=this;n.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){r.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){if(!r.isDisabled()){var t=i(this).parent(),n=l.GetData(t[0],"data");r.trigger("unselect",{originalEvent:e,data:n})}})},n.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},n.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},n.prototype.selectionContainer=function(){return i('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">×</span></li>')},n.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n<e.length;n++){var r=e[n],i=this.selectionContainer(),o=this.display(r,i);i.append(o);var s=r.title||r.text;s&&i.attr("title",s),l.StoreData(i[0],"data",r),t.push(i)}var a=this.$selection.find(".select2-selection__rendered");l.appendMany(a,t)}},n}),e.define("select2/selection/placeholder",["../utils"],function(e){function t(e,t,n){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n)}return t.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},t.prototype.createPlaceholder=function(e,t){var n=this.selectionContainer();return n.html(this.display(t)),n.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),n},t.prototype.update=function(e,t){var n=1==t.length&&t[0].id!=this.placeholder.id;if(1<t.length||n)return e.call(this,t);this.clear();var r=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(r)},t}),e.define("select2/selection/allowClear",["jquery","../keys","../utils"],function(i,r,a){function e(){}return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(e){r._handleClear(e)}),t.on("keypress",function(e){r._handleKeyboardClear(e,t)})},e.prototype._handleClear=function(e,t){if(!this.isDisabled()){var n=this.$selection.find(".select2-selection__clear");if(0!==n.length){t.stopPropagation();var r=a.GetData(n[0],"data"),i=this.$element.val();this.$element.val(this.placeholder.id);var o={data:r};if(this.trigger("clear",o),o.prevented)this.$element.val(i);else{for(var s=0;s<r.length;s++)if(o={data:r[s]},this.trigger("unselect",o),o.prevented)return void this.$element.val(i);this.$element.trigger("input").trigger("change"),this.trigger("toggle",{})}}}},e.prototype._handleKeyboardClear=function(e,t,n){n.isOpen()||t.which!=r.DELETE&&t.which!=r.BACKSPACE||this._handleClear(t)},e.prototype.update=function(e,t){if(e.call(this,t),!(0<this.$selection.find(".select2-selection__placeholder").length||0===t.length)){var n=this.options.get("translations").get("removeAllItems"),r=i('<span class="select2-selection__clear" title="'+n()+'">×</span>');a.StoreData(r[0],"data",t),this.$selection.find(".select2-selection__rendered").prepend(r)}},e}),e.define("select2/selection/search",["jquery","../utils","../keys"],function(r,a,l){function e(e,t,n){e.call(this,t,n)}return e.prototype.render=function(e){var t=r('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" /></li>');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},e.prototype.bind=function(e,t,n){var r=this,i=t.id+"-results";e.call(this,t,n),t.on("open",function(){r.$search.attr("aria-controls",i),r.$search.trigger("focus")}),t.on("close",function(){r.$search.val(""),r.$search.removeAttr("aria-controls"),r.$search.removeAttr("aria-activedescendant"),r.$search.trigger("focus")}),t.on("enable",function(){r.$search.prop("disabled",!1),r._transferTabIndex()}),t.on("disable",function(){r.$search.prop("disabled",!0)}),t.on("focus",function(e){r.$search.trigger("focus")}),t.on("results:focus",function(e){e.data._resultId?r.$search.attr("aria-activedescendant",e.data._resultId):r.$search.removeAttr("aria-activedescendant")}),this.$selection.on("focusin",".select2-search--inline",function(e){r.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){r._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented(),e.which===l.BACKSPACE&&""===r.$search.val()){var t=r.$searchContainer.prev(".select2-selection__choice");if(0<t.length){var n=a.GetData(t[0],"data");r.searchRemoveChoice(n),e.preventDefault()}}}),this.$selection.on("click",".select2-search--inline",function(e){r.$search.val()&&e.stopPropagation()});var o=document.documentMode,s=o&&o<=11;this.$selection.on("input.searchcheck",".select2-search--inline",function(e){s?r.$selection.off("input.search input.searchcheck"):r.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(e){if(s&&"input"===e.type)r.$selection.off("input.search input.searchcheck");else{var t=e.which;t!=l.SHIFT&&t!=l.CTRL&&t!=l.ALT&&t!=l.TAB&&r.handleSearch(e)}})},e.prototype._transferTabIndex=function(e){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},e.prototype.createPlaceholder=function(e,t){this.$search.attr("placeholder",t.text)},e.prototype.update=function(e,t){var n=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),e.call(this,t),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),n&&this.$search.trigger("focus")},e.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var e=this.$search.val();this.trigger("query",{term:e})}this._keyUpPrevented=!1},e.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(t.text),this.handleSearch()},e.prototype.resizeSearch=function(){this.$search.css("width","25px");var e="";""!==this.$search.attr("placeholder")?e=this.$selection.find(".select2-selection__rendered").width():e=.75*(this.$search.val().length+1)+"em";this.$search.css("width",e)},e}),e.define("select2/selection/eventRelay",["jquery"],function(s){function e(){}return e.prototype.bind=function(e,t,n){var r=this,i=["open","opening","close","closing","select","selecting","unselect","unselecting","clear","clearing"],o=["opening","closing","selecting","unselecting","clearing"];e.call(this,t,n),t.on("*",function(e,t){if(-1!==s.inArray(e,i)){t=t||{};var n=s.Event("select2:"+e,{params:t});r.$element.trigger(n),-1!==s.inArray(e,o)&&(t.prevented=n.isDefaultPrevented())}})},e}),e.define("select2/translation",["jquery","require"],function(t,n){function r(e){this.dict=e||{}}return r.prototype.all=function(){return this.dict},r.prototype.get=function(e){return this.dict[e]},r.prototype.extend=function(e){this.dict=t.extend({},e.all(),this.dict)},r._cache={},r.loadPath=function(e){if(!(e in r._cache)){var t=n(e);r._cache[e]=t}return new r(r._cache[e])},r}),e.define("select2/diacritics",[],function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Œ":"OE","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","œ":"oe","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ώ":"ω","ς":"σ","’":"'"}}),e.define("select2/data/base",["../utils"],function(r){function n(e,t){n.__super__.constructor.call(this)}return r.Extend(n,r.Observable),n.prototype.current=function(e){throw new Error("The `current` method must be defined in child classes.")},n.prototype.query=function(e,t){throw new Error("The `query` method must be defined in child classes.")},n.prototype.bind=function(e,t){},n.prototype.destroy=function(){},n.prototype.generateResultId=function(e,t){var n=e.id+"-result-";return n+=r.generateChars(4),null!=t.id?n+="-"+t.id.toString():n+="-"+r.generateChars(4),n},n}),e.define("select2/data/select",["./base","../utils","jquery"],function(e,a,l){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return a.Extend(n,e),n.prototype.current=function(e){var n=[],r=this;this.$element.find(":selected").each(function(){var e=l(this),t=r.item(e);n.push(t)}),e(n)},n.prototype.select=function(i){var o=this;if(i.selected=!0,l(i.element).is("option"))return i.element.selected=!0,void this.$element.trigger("input").trigger("change");if(this.$element.prop("multiple"))this.current(function(e){var t=[];(i=[i]).push.apply(i,e);for(var n=0;n<i.length;n++){var r=i[n].id;-1===l.inArray(r,t)&&t.push(r)}o.$element.val(t),o.$element.trigger("input").trigger("change")});else{var e=i.id;this.$element.val(e),this.$element.trigger("input").trigger("change")}},n.prototype.unselect=function(i){var o=this;if(this.$element.prop("multiple")){if(i.selected=!1,l(i.element).is("option"))return i.element.selected=!1,void this.$element.trigger("input").trigger("change");this.current(function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n].id;r!==i.id&&-1===l.inArray(r,t)&&t.push(r)}o.$element.val(t),o.$element.trigger("input").trigger("change")})}},n.prototype.bind=function(e,t){var n=this;(this.container=e).on("select",function(e){n.select(e.data)}),e.on("unselect",function(e){n.unselect(e.data)})},n.prototype.destroy=function(){this.$element.find("*").each(function(){a.RemoveData(this)})},n.prototype.query=function(r,e){var i=[],o=this;this.$element.children().each(function(){var e=l(this);if(e.is("option")||e.is("optgroup")){var t=o.item(e),n=o.matches(r,t);null!==n&&i.push(n)}}),e({results:i})},n.prototype.addOptions=function(e){a.appendMany(this.$element,e)},n.prototype.option=function(e){var t;e.children?(t=document.createElement("optgroup")).label=e.text:void 0!==(t=document.createElement("option")).textContent?t.textContent=e.text:t.innerText=e.text,void 0!==e.id&&(t.value=e.id),e.disabled&&(t.disabled=!0),e.selected&&(t.selected=!0),e.title&&(t.title=e.title);var n=l(t),r=this._normalizeItem(e);return r.element=t,a.StoreData(t,"data",r),n},n.prototype.item=function(e){var t={};if(null!=(t=a.GetData(e[0],"data")))return t;if(e.is("option"))t={id:e.val(),text:e.text(),disabled:e.prop("disabled"),selected:e.prop("selected"),title:e.prop("title")};else if(e.is("optgroup")){t={text:e.prop("label"),children:[],title:e.prop("title")};for(var n=e.children("option"),r=[],i=0;i<n.length;i++){var o=l(n[i]),s=this.item(o);r.push(s)}t.children=r}return(t=this._normalizeItem(t)).element=e[0],a.StoreData(e[0],"data",t),t},n.prototype._normalizeItem=function(e){e!==Object(e)&&(e={id:e,text:e});return null!=(e=l.extend({},{text:""},e)).id&&(e.id=e.id.toString()),null!=e.text&&(e.text=e.text.toString()),null==e._resultId&&e.id&&null!=this.container&&(e._resultId=this.generateResultId(this.container,e)),l.extend({},{selected:!1,disabled:!1},e)},n.prototype.matches=function(e,t){return this.options.get("matcher")(e,t)},n}),e.define("select2/data/array",["./select","../utils","jquery"],function(e,f,g){function r(e,t){this._dataToConvert=t.get("data")||[],r.__super__.constructor.call(this,e,t)}return f.Extend(r,e),r.prototype.bind=function(e,t){r.__super__.bind.call(this,e,t),this.addOptions(this.convertToOptions(this._dataToConvert))},r.prototype.select=function(n){var e=this.$element.find("option").filter(function(e,t){return t.value==n.id.toString()});0===e.length&&(e=this.option(n),this.addOptions(e)),r.__super__.select.call(this,n)},r.prototype.convertToOptions=function(e){var t=this,n=this.$element.find("option"),r=n.map(function(){return t.item(g(this)).id}).get(),i=[];function o(e){return function(){return g(this).val()==e.id}}for(var s=0;s<e.length;s++){var a=this._normalizeItem(e[s]);if(0<=g.inArray(a.id,r)){var l=n.filter(o(a)),c=this.item(l),u=g.extend(!0,{},a,c),d=this.option(u);l.replaceWith(d)}else{var p=this.option(a);if(a.children){var h=this.convertToOptions(a.children);f.appendMany(p,h)}i.push(p)}}return i},r}),e.define("select2/data/ajax",["./array","../utils","jquery"],function(e,t,o){function n(e,t){this.ajaxOptions=this._applyDefaults(t.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),n.__super__.constructor.call(this,e,t)}return t.Extend(n,e),n.prototype._applyDefaults=function(e){var t={data:function(e){return o.extend({},e,{q:e.term})},transport:function(e,t,n){var r=o.ajax(e);return r.then(t),r.fail(n),r}};return o.extend({},t,e,!0)},n.prototype.processResults=function(e){return e},n.prototype.query=function(n,r){var i=this;null!=this._request&&(o.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var t=o.extend({type:"GET"},this.ajaxOptions);function e(){var e=t.transport(t,function(e){var t=i.processResults(e,n);i.options.get("debug")&&window.console&&console.error&&(t&&t.results&&o.isArray(t.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),r(t)},function(){"status"in e&&(0===e.status||"0"===e.status)||i.trigger("results:message",{message:"errorLoading"})});i._request=e}"function"==typeof t.url&&(t.url=t.url.call(this.$element,n)),"function"==typeof t.data&&(t.data=t.data.call(this.$element,n)),this.ajaxOptions.delay&&null!=n.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(e,this.ajaxOptions.delay)):e()},n}),e.define("select2/data/tags",["jquery"],function(u){function e(e,t,n){var r=n.get("tags"),i=n.get("createTag");void 0!==i&&(this.createTag=i);var o=n.get("insertTag");if(void 0!==o&&(this.insertTag=o),e.call(this,t,n),u.isArray(r))for(var s=0;s<r.length;s++){var a=r[s],l=this._normalizeItem(a),c=this.option(l);this.$element.append(c)}}return e.prototype.query=function(e,c,u){var d=this;this._removeOldTags(),null!=c.term&&null==c.page?e.call(this,c,function e(t,n){for(var r=t.results,i=0;i<r.length;i++){var o=r[i],s=null!=o.children&&!e({results:o.children},!0);if((o.text||"").toUpperCase()===(c.term||"").toUpperCase()||s)return!n&&(t.data=r,void u(t))}if(n)return!0;var a=d.createTag(c);if(null!=a){var l=d.option(a);l.attr("data-select2-tag",!0),d.addOptions([l]),d.insertTag(r,a)}t.results=r,u(t)}):e.call(this,c,u)},e.prototype.createTag=function(e,t){var n=u.trim(t.term);return""===n?null:{id:n,text:n}},e.prototype.insertTag=function(e,t,n){t.unshift(n)},e.prototype._removeOldTags=function(e){this.$element.find("option[data-select2-tag]").each(function(){this.selected||u(this).remove()})},e}),e.define("select2/data/tokenizer",["jquery"],function(d){function e(e,t,n){var r=n.get("tokenizer");void 0!==r&&(this.tokenizer=r),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){e.call(this,t,n),this.$search=t.dropdown.$search||t.selection.$search||n.find(".select2-search__field")},e.prototype.query=function(e,t,n){var r=this;t.term=t.term||"";var i=this.tokenizer(t,this.options,function(e){var t=r._normalizeItem(e);if(!r.$element.find("option").filter(function(){return d(this).val()===t.id}).length){var n=r.option(t);n.attr("data-select2-tag",!0),r._removeOldTags(),r.addOptions([n])}!function(e){r.trigger("select",{data:e})}(t)});i.term!==t.term&&(this.$search.length&&(this.$search.val(i.term),this.$search.trigger("focus")),t.term=i.term),e.call(this,t,n)},e.prototype.tokenizer=function(e,t,n,r){for(var i=n.get("tokenSeparators")||[],o=t.term,s=0,a=this.createTag||function(e){return{id:e.term,text:e.term}};s<o.length;){var l=o[s];if(-1!==d.inArray(l,i)){var c=o.substr(0,s),u=a(d.extend({},t,{term:c}));null!=u?(r(u),o=o.substr(s+1)||"",s=0):s++}else s++}return{term:o}},e}),e.define("select2/data/minimumInputLength",[],function(){function e(e,t,n){this.minimumInputLength=n.get("minimumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",t.term.length<this.minimumInputLength?this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumInputLength",[],function(){function e(e,t,n){this.maximumInputLength=n.get("maximumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",0<this.maximumInputLength&&t.term.length>this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("select",function(){r._checkIfMaximumSelected()})},e.prototype.query=function(e,t,n){var r=this;this._checkIfMaximumSelected(function(){e.call(r,t,n)})},e.prototype._checkIfMaximumSelected=function(e,n){var r=this;this.current(function(e){var t=null!=e?e.length:0;0<r.maximumSelectionLength&&t>=r.maximumSelectionLength?r.trigger("results:message",{message:"maximumSelected",args:{maximum:r.maximumSelectionLength}}):n&&n()})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('<span class="select2-dropdown"><span class="select2-results"></span></span>');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(o,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=o('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" /></span>');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var r=this,i=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){o(this).off("keyup")}),this.$search.on("keyup input",function(e){r.handleSearch(e)}),t.on("open",function(){r.$search.attr("tabindex",0),r.$search.attr("aria-controls",i),r.$search.trigger("focus"),window.setTimeout(function(){r.$search.trigger("focus")},0)}),t.on("close",function(){r.$search.attr("tabindex",-1),r.$search.removeAttr("aria-controls"),r.$search.removeAttr("aria-activedescendant"),r.$search.val(""),r.$search.trigger("blur")}),t.on("focus",function(){t.isOpen()||r.$search.trigger("focus")}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(r.showSearch(e)?r.$searchContainer.removeClass("select2-search--hide"):r.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){e.data._resultId?r.$search.attr("aria-activedescendant",e.data._resultId):r.$search.removeAttr("aria-activedescendant")})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,r){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,r)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),r=t.length-1;0<=r;r--){var i=t[r];this.placeholder.id===i.id&&n.splice(r,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(n){function e(e,t,n,r){this.lastParams={},e.call(this,t,n,r),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&(this.$results.append(this.$loadingMore),this.loadMoreIfNeeded())},e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("query",function(e){r.lastParams=e,r.loading=!0}),t.on("query:append",function(e){r.lastParams=e,r.loading=!0}),this.$results.on("scroll",this.loadMoreIfNeeded.bind(this))},e.prototype.loadMoreIfNeeded=function(){var e=n.contains(document.documentElement,this.$loadingMore[0]);if(!this.loading&&e){var t=this.$results.offset().top+this.$results.outerHeight(!1);this.$loadingMore.offset().top+this.$loadingMore.outerHeight(!1)<=t+50&&this.loadMore()}},e.prototype.loadMore=function(){this.loading=!0;var e=n.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=n('<li class="select2-results__option select2-results__option--load-more"role="option" aria-disabled="true"></li>'),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=f(n.get("dropdownParent")||document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("open",function(){r._showDropdown(),r._attachPositioningHandler(t),r._bindContainerResultHandlers(t)}),t.on("close",function(){r._hideDropdown(),r._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f("<span></span>"),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._bindContainerResultHandlers=function(e,t){if(!this._containerResultsHandlersBound){var n=this;t.on("results:all",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:append",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:message",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("select",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("unselect",function(){n._positionDropdown(),n._resizeDropdown()}),this._containerResultsHandlersBound=!0}},e.prototype._attachPositioningHandler=function(e,t){var n=this,r="scroll.select2."+t.id,i="resize.select2."+t.id,o="orientationchange.select2."+t.id,s=this.$container.parents().filter(a.hasScroll);s.each(function(){a.StoreData(this,"select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),s.on(r,function(e){var t=a.GetData(this,"select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(r+" "+i+" "+o,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,r="resize.select2."+t.id,i="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+r+" "+i)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),r=null,i=this.$container.offset();i.bottom=i.top+this.$container.outerHeight(!1);var o={height:this.$container.outerHeight(!1)};o.top=i.top,o.bottom=i.top+o.height;var s=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=a<i.top-s,u=l>i.bottom+s,d={left:i.left,top:o.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h={top:0,left:0};(f.contains(document.body,p[0])||p[0].isConnected)&&(h=p.offset()),d.top-=h.top,d.left-=h.left,t||n||(r="below"),u||!c||t?!c&&u&&t&&(r="below"):r="above",("above"==r||t&&"below"!==r)&&(d.top=o.top-h.top-s),null!=r&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+r),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+r)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,r){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,r)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,r=0;r<t.length;r++){var i=t[r];i.children?n+=e(i.children):n++}return n}(t.data.results)<this.minimumResultsForSearch)&&e.call(this,t)},e}),e.define("select2/dropdown/selectOnClose",["../utils"],function(o){function e(){}return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("close",function(e){r._handleSelectOnClose(e)})},e.prototype._handleSelectOnClose=function(e,t){if(t&&null!=t.originalSelect2Event){var n=t.originalSelect2Event;if("select"===n._type||"unselect"===n._type)return}var r=this.getHighlightedResults();if(!(r.length<1)){var i=o.GetData(r[0],"data");null!=i.element&&i.element.selected||null==i.element&&i.selected||this.trigger("select",{data:i})}},e}),e.define("select2/dropdown/closeOnSelect",[],function(){function e(){}return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("select",function(e){r._selectTriggered(e)}),t.on("unselect",function(e){r._selectTriggered(e)})},e.prototype._selectTriggered=function(e,t){var n=t.originalEvent;n&&(n.ctrlKey||n.metaKey)||this.trigger("close",{originalEvent:n,originalSelect2Event:t})},e}),e.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Please delete "+t+" character";return 1!=t&&(n+="s"),n},inputTooShort:function(e){return"Please enter "+(e.minimum-e.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return 1!=e.maximum&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"},removeAllItems:function(){return"Remove all items"}}}),e.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(c,u,d,p,h,f,g,m,v,y,s,t,_,$,b,w,A,x,D,S,E,C,O,T,q,L,I,j,e){function n(){this.reset()}return n.prototype.apply=function(e){if(null==(e=c.extend(!0,{},this.defaults,e)).dataAdapter){if(null!=e.ajax?e.dataAdapter=b:null!=e.data?e.dataAdapter=$:e.dataAdapter=_,0<e.minimumInputLength&&(e.dataAdapter=y.Decorate(e.dataAdapter,x)),0<e.maximumInputLength&&(e.dataAdapter=y.Decorate(e.dataAdapter,D)),0<e.maximumSelectionLength&&(e.dataAdapter=y.Decorate(e.dataAdapter,S)),e.tags&&(e.dataAdapter=y.Decorate(e.dataAdapter,w)),null==e.tokenSeparators&&null==e.tokenizer||(e.dataAdapter=y.Decorate(e.dataAdapter,A)),null!=e.query){var t=u(e.amdBase+"compat/query");e.dataAdapter=y.Decorate(e.dataAdapter,t)}if(null!=e.initSelection){var n=u(e.amdBase+"compat/initSelection");e.dataAdapter=y.Decorate(e.dataAdapter,n)}}if(null==e.resultsAdapter&&(e.resultsAdapter=d,null!=e.ajax&&(e.resultsAdapter=y.Decorate(e.resultsAdapter,T)),null!=e.placeholder&&(e.resultsAdapter=y.Decorate(e.resultsAdapter,O)),e.selectOnClose&&(e.resultsAdapter=y.Decorate(e.resultsAdapter,I))),null==e.dropdownAdapter){if(e.multiple)e.dropdownAdapter=E;else{var r=y.Decorate(E,C);e.dropdownAdapter=r}if(0!==e.minimumResultsForSearch&&(e.dropdownAdapter=y.Decorate(e.dropdownAdapter,L)),e.closeOnSelect&&(e.dropdownAdapter=y.Decorate(e.dropdownAdapter,j)),null!=e.dropdownCssClass||null!=e.dropdownCss||null!=e.adaptDropdownCssClass){var i=u(e.amdBase+"compat/dropdownCss");e.dropdownAdapter=y.Decorate(e.dropdownAdapter,i)}e.dropdownAdapter=y.Decorate(e.dropdownAdapter,q)}if(null==e.selectionAdapter){if(e.multiple?e.selectionAdapter=h:e.selectionAdapter=p,null!=e.placeholder&&(e.selectionAdapter=y.Decorate(e.selectionAdapter,f)),e.allowClear&&(e.selectionAdapter=y.Decorate(e.selectionAdapter,g)),e.multiple&&(e.selectionAdapter=y.Decorate(e.selectionAdapter,m)),null!=e.containerCssClass||null!=e.containerCss||null!=e.adaptContainerCssClass){var o=u(e.amdBase+"compat/containerCss");e.selectionAdapter=y.Decorate(e.selectionAdapter,o)}e.selectionAdapter=y.Decorate(e.selectionAdapter,v)}e.language=this._resolveLanguage(e.language),e.language.push("en");for(var s=[],a=0;a<e.language.length;a++){var l=e.language[a];-1===s.indexOf(l)&&s.push(l)}return e.language=s,e.translations=this._processTranslations(e.language,e.debug),e},n.prototype.reset=function(){function a(e){return e.replace(/[^\u0000-\u007E]/g,function(e){return t[e]||e})}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:y.escapeMarkup,language:{},matcher:function e(t,n){if(""===c.trim(t.term))return n;if(n.children&&0<n.children.length){for(var r=c.extend(!0,{},n),i=n.children.length-1;0<=i;i--)null==e(t,n.children[i])&&r.children.splice(i,1);return 0<r.children.length?r:e(t,r)}var o=a(n.text).toUpperCase(),s=a(t.term).toUpperCase();return-1<o.indexOf(s)?n:null},minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,scrollAfterSelect:!1,sorter:function(e){return e},templateResult:function(e){return e.text},templateSelection:function(e){return e.text},theme:"default",width:"resolve"}},n.prototype.applyFromElement=function(e,t){var n=e.language,r=this.defaults.language,i=t.prop("lang"),o=t.closest("[lang]").prop("lang"),s=Array.prototype.concat.call(this._resolveLanguage(i),this._resolveLanguage(n),this._resolveLanguage(r),this._resolveLanguage(o));return e.language=s,e},n.prototype._resolveLanguage=function(e){if(!e)return[];if(c.isEmptyObject(e))return[];if(c.isPlainObject(e))return[e];var t;t=c.isArray(e)?e:[e];for(var n=[],r=0;r<t.length;r++)if(n.push(t[r]),"string"==typeof t[r]&&0<t[r].indexOf("-")){var i=t[r].split("-")[0];n.push(i)}return n},n.prototype._processTranslations=function(e,t){for(var n=new s,r=0;r<e.length;r++){var i=new s,o=e[r];if("string"==typeof o)try{i=s.loadPath(o)}catch(e){try{o=this.defaults.amdLanguageBase+o,i=s.loadPath(o)}catch(e){t&&window.console&&console.warn&&console.warn('Select2: The language file for "'+o+'" could not be automatically loaded. A fallback will be used instead.')}}else i=c.isPlainObject(o)?new s(o):o;n.extend(i)}return n},n.prototype.set=function(e,t){var n={};n[c.camelCase(e)]=t;var r=y._convertData(n);c.extend(!0,this.defaults,r)},new n}),e.define("select2/options",["require","jquery","./defaults","./utils"],function(r,d,i,p){function e(e,t){if(this.options=e,null!=t&&this.fromElement(t),null!=t&&(this.options=i.applyFromElement(this.options,t)),this.options=i.apply(this.options),t&&t.is("input")){var n=r(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=p.Decorate(this.options.dataAdapter,n)}}return e.prototype.fromElement=function(e){var t=["select2"];null==this.options.multiple&&(this.options.multiple=e.prop("multiple")),null==this.options.disabled&&(this.options.disabled=e.prop("disabled")),null==this.options.dir&&(e.prop("dir")?this.options.dir=e.prop("dir"):e.closest("[dir]").prop("dir")?this.options.dir=e.closest("[dir]").prop("dir"):this.options.dir="ltr"),e.prop("disabled",this.options.disabled),e.prop("multiple",this.options.multiple),p.GetData(e[0],"select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),p.StoreData(e[0],"data",p.GetData(e[0],"select2Tags")),p.StoreData(e[0],"tags",!0)),p.GetData(e[0],"ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),e.attr("ajax--url",p.GetData(e[0],"ajaxUrl")),p.StoreData(e[0],"ajax-Url",p.GetData(e[0],"ajaxUrl")));var n={};function r(e,t){return t.toUpperCase()}for(var i=0;i<e[0].attributes.length;i++){var o=e[0].attributes[i].name,s="data-";if(o.substr(0,s.length)==s){var a=o.substring(s.length),l=p.GetData(e[0],a);n[a.replace(/-([a-z])/g,r)]=l}}d.fn.jquery&&"1."==d.fn.jquery.substr(0,2)&&e[0].dataset&&(n=d.extend(!0,{},e[0].dataset,n));var c=d.extend(!0,{},p.GetData(e[0]),n);for(var u in c=p._convertData(c))-1<d.inArray(u,t)||(d.isPlainObject(this.options[u])?d.extend(this.options[u],c[u]):this.options[u]=c[u]);return this},e.prototype.get=function(e){return this.options[e]},e.prototype.set=function(e,t){this.options[e]=t},e}),e.define("select2/core",["jquery","./options","./utils","./keys"],function(o,c,u,r){var d=function(e,t){null!=u.GetData(e[0],"select2")&&u.GetData(e[0],"select2").destroy(),this.$element=e,this.id=this._generateId(e),t=t||{},this.options=new c(t,e),d.__super__.constructor.call(this);var n=e.attr("tabindex")||0;u.StoreData(e[0],"old-tabindex",n),e.attr("tabindex","-1");var r=this.options.get("dataAdapter");this.dataAdapter=new r(e,this.options);var i=this.render();this._placeContainer(i);var o=this.options.get("selectionAdapter");this.selection=new o(e,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,i);var s=this.options.get("dropdownAdapter");this.dropdown=new s(e,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,i);var a=this.options.get("resultsAdapter");this.results=new a(e,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var l=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(e){l.trigger("selection:update",{data:e})}),e.addClass("select2-hidden-accessible"),e.attr("aria-hidden","true"),this._syncAttributes(),u.StoreData(e[0],"select2",this),e.data("select2",this)};return u.Extend(d,u.Observable),d.prototype._generateId=function(e){return"select2-"+(null!=e.attr("id")?e.attr("id"):null!=e.attr("name")?e.attr("name")+"-"+u.generateChars(2):u.generateChars(4)).replace(/(:|\.|\[|\]|,)/g,"")},d.prototype._placeContainer=function(e){e.insertAfter(this.$element);var t=this._resolveWidth(this.$element,this.options.get("width"));null!=t&&e.css("width",t)},d.prototype._resolveWidth=function(e,t){var n=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==t){var r=this._resolveWidth(e,"style");return null!=r?r:this._resolveWidth(e,"element")}if("element"==t){var i=e.outerWidth(!1);return i<=0?"auto":i+"px"}if("style"!=t)return"computedstyle"!=t?t:window.getComputedStyle(e[0]).width;var o=e.attr("style");if("string"!=typeof o)return null;for(var s=o.split(";"),a=0,l=s.length;a<l;a+=1){var c=s[a].replace(/\s/g,"").match(n);if(null!==c&&1<=c.length)return c[1]}return null},d.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},d.prototype._registerDomEvents=function(){var t=this;this.$element.on("change.select2",function(){t.dataAdapter.current(function(e){t.trigger("selection:update",{data:e})})}),this.$element.on("focus.select2",function(e){t.trigger("focus",e)}),this._syncA=u.bind(this._syncAttributes,this),this._syncS=u.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=e?(this._observer=new e(function(e){t._syncA(),t._syncS(null,e)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",t._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",t._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",t._syncS,!1))},d.prototype._registerDataEvents=function(){var n=this;this.dataAdapter.on("*",function(e,t){n.trigger(e,t)})},d.prototype._registerSelectionEvents=function(){var n=this,r=["toggle","focus"];this.selection.on("toggle",function(){n.toggleDropdown()}),this.selection.on("focus",function(e){n.focus(e)}),this.selection.on("*",function(e,t){-1===o.inArray(e,r)&&n.trigger(e,t)})},d.prototype._registerDropdownEvents=function(){var n=this;this.dropdown.on("*",function(e,t){n.trigger(e,t)})},d.prototype._registerResultsEvents=function(){var n=this;this.results.on("*",function(e,t){n.trigger(e,t)})},d.prototype._registerEvents=function(){var n=this;this.on("open",function(){n.$container.addClass("select2-container--open")}),this.on("close",function(){n.$container.removeClass("select2-container--open")}),this.on("enable",function(){n.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){n.$container.addClass("select2-container--disabled")}),this.on("blur",function(){n.$container.removeClass("select2-container--focus")}),this.on("query",function(t){n.isOpen()||n.trigger("open",{}),this.dataAdapter.query(t,function(e){n.trigger("results:all",{data:e,query:t})})}),this.on("query:append",function(t){this.dataAdapter.query(t,function(e){n.trigger("results:append",{data:e,query:t})})}),this.on("keypress",function(e){var t=e.which;n.isOpen()?t===r.ESC||t===r.TAB||t===r.UP&&e.altKey?(n.close(e),e.preventDefault()):t===r.ENTER?(n.trigger("results:select",{}),e.preventDefault()):t===r.SPACE&&e.ctrlKey?(n.trigger("results:toggle",{}),e.preventDefault()):t===r.UP?(n.trigger("results:previous",{}),e.preventDefault()):t===r.DOWN&&(n.trigger("results:next",{}),e.preventDefault()):(t===r.ENTER||t===r.SPACE||t===r.DOWN&&e.altKey)&&(n.open(),e.preventDefault())})},d.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.isDisabled()?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},d.prototype._isChangeMutation=function(e,t){var n=!1,r=this;if(!e||!e.target||"OPTION"===e.target.nodeName||"OPTGROUP"===e.target.nodeName){if(t)if(t.addedNodes&&0<t.addedNodes.length)for(var i=0;i<t.addedNodes.length;i++){t.addedNodes[i].selected&&(n=!0)}else t.removedNodes&&0<t.removedNodes.length?n=!0:o.isArray(t)&&o.each(t,function(e,t){if(r._isChangeMutation(e,t))return!(n=!0)});else n=!0;return n}},d.prototype._syncSubtree=function(e,t){var n=this._isChangeMutation(e,t),r=this;n&&this.dataAdapter.current(function(e){r.trigger("selection:update",{data:e})})},d.prototype.trigger=function(e,t){var n=d.__super__.trigger,r={open:"opening",close:"closing",select:"selecting",unselect:"unselecting",clear:"clearing"};if(void 0===t&&(t={}),e in r){var i=r[e],o={prevented:!1,name:e,args:t};if(n.call(this,i,o),o.prevented)return void(t.prevented=!0)}n.call(this,e,t)},d.prototype.toggleDropdown=function(){this.isDisabled()||(this.isOpen()?this.close():this.open())},d.prototype.open=function(){this.isOpen()||this.isDisabled()||this.trigger("query",{})},d.prototype.close=function(e){this.isOpen()&&this.trigger("close",{originalEvent:e})},d.prototype.isEnabled=function(){return!this.isDisabled()},d.prototype.isDisabled=function(){return this.options.get("disabled")},d.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},d.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},d.prototype.focus=function(e){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},d.prototype.enable=function(e){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),null!=e&&0!==e.length||(e=[!0]);var t=!e[0];this.$element.prop("disabled",t)},d.prototype.data=function(){this.options.get("debug")&&0<arguments.length&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var t=[];return this.dataAdapter.current(function(e){t=e}),t},d.prototype.val=function(e){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==e||0===e.length)return this.$element.val();var t=e[0];o.isArray(t)&&(t=o.map(t,function(e){return e.toString()})),this.$element.val(t).trigger("input").trigger("change")},d.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",u.GetData(this.$element[0],"old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),u.RemoveData(this.$element[0]),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},d.prototype.render=function(){var e=o('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),u.StoreData(e[0],"element",this.$element),e},d}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults","./select2/utils"],function(i,e,o,t,s){if(null==i.fn.select2){var a=["open","close","destroy"];i.fn.select2=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=i.extend(!0,{},t);new o(i(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,r=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=s.GetData(this,"select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,r)}),-1<i.inArray(t,a)?this:n}}return null==i.fn.select2.defaults&&(i.fn.select2.defaults=t),o}),{define:e.define,require:e.require}}(),t=e.require("jquery.select2");return u.fn.select2.amd=e,t});
|
|
includes/acf-field-functions.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'fields' )->prop( 'multisite', true );
|
@@ -8,100 +8,100 @@ acf_register_store( 'fields' )->prop( 'multisite', true );
|
|
8 |
*
|
9 |
* Retrieves a field for the given identifier.
|
10 |
*
|
11 |
-
* @date
|
12 |
-
* @since
|
13 |
*
|
14 |
-
* @param
|
15 |
-
* @return
|
16 |
*/
|
17 |
function acf_get_field( $id = 0 ) {
|
18 |
-
|
19 |
// Allow WP_Post to be passed.
|
20 |
-
if( is_object($id) ) {
|
21 |
$id = $id->ID;
|
22 |
}
|
23 |
-
|
24 |
// Check store.
|
25 |
$store = acf_get_store( 'fields' );
|
26 |
-
if( $store->has( $id ) ) {
|
27 |
return $store->get( $id );
|
28 |
}
|
29 |
-
|
30 |
// Check local fields first.
|
31 |
-
if( acf_is_local_field($id) ) {
|
32 |
$field = acf_get_local_field( $id );
|
33 |
-
|
34 |
-
|
35 |
} else {
|
36 |
$field = acf_get_raw_field( $id );
|
37 |
}
|
38 |
-
|
39 |
// Bail early if no field.
|
40 |
-
if(
|
41 |
return false;
|
42 |
}
|
43 |
-
|
44 |
// Validate field.
|
45 |
$field = acf_validate_field( $field );
|
46 |
-
|
47 |
// Set input prefix.
|
48 |
$field['prefix'] = 'acf';
|
49 |
-
|
50 |
/**
|
51 |
* Filters the $field array after it has been loaded.
|
52 |
*
|
53 |
-
* @date
|
54 |
-
* @since
|
55 |
*
|
56 |
-
* @param
|
57 |
*/
|
58 |
-
$field = apply_filters(
|
59 |
-
|
60 |
// Store field using aliasses to also find via key, ID and name.
|
61 |
$store->set( $field['key'], $field );
|
62 |
$store->alias( $field['key'], $field['ID'], $field['name'] );
|
63 |
-
|
64 |
// Return.
|
65 |
return $field;
|
66 |
}
|
67 |
|
68 |
// Register variation.
|
69 |
-
acf_add_filter_variations( 'acf/load_field', array('type', 'name', 'key'), 0 );
|
70 |
|
71 |
/**
|
72 |
* acf_get_raw_field
|
73 |
*
|
74 |
* Retrieves raw field data for the given identifier.
|
75 |
*
|
76 |
-
* @date
|
77 |
-
* @since
|
78 |
*
|
79 |
-
* @param
|
80 |
-
* @return
|
81 |
*/
|
82 |
function acf_get_raw_field( $id = 0 ) {
|
83 |
-
|
84 |
// Get raw field from database.
|
85 |
$post = acf_get_field_post( $id );
|
86 |
-
if(
|
87 |
return false;
|
88 |
}
|
89 |
-
|
90 |
// Bail early if incorrect post type.
|
91 |
-
if( $post->post_type !== 'acf-field' ) {
|
92 |
return false;
|
93 |
}
|
94 |
-
|
95 |
// Unserialize post_content.
|
96 |
$field = (array) maybe_unserialize( $post->post_content );
|
97 |
-
|
98 |
// update attributes
|
99 |
-
$field['ID']
|
100 |
-
$field['key']
|
101 |
-
$field['label']
|
102 |
-
$field['name']
|
103 |
$field['menu_order'] = $post->menu_order;
|
104 |
-
$field['parent']
|
105 |
|
106 |
// Return field.
|
107 |
return $field;
|
@@ -112,55 +112,57 @@ function acf_get_raw_field( $id = 0 ) {
|
|
112 |
*
|
113 |
* Retrieves the field's WP_Post object.
|
114 |
*
|
115 |
-
* @date
|
116 |
-
* @since
|
117 |
*
|
118 |
-
* @param
|
119 |
-
* @return
|
120 |
*/
|
121 |
function acf_get_field_post( $id = 0 ) {
|
122 |
-
|
123 |
// Get post if numeric.
|
124 |
-
if( is_numeric($id) ) {
|
125 |
return get_post( $id );
|
126 |
-
|
127 |
-
|
128 |
-
} elseif( is_string($id) ) {
|
129 |
-
|
130 |
// Determine id type.
|
131 |
-
$type = acf_is_field_key($id) ? 'key' : 'name';
|
132 |
-
|
133 |
// Try cache.
|
134 |
$cache_key = acf_cache_key( "acf_get_field_post:$type:$id" );
|
135 |
-
$post_id
|
136 |
-
if( $post_id === false ) {
|
137 |
-
|
138 |
// Query posts.
|
139 |
-
$posts = get_posts(
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
151 |
// Update $post_id with a non false value.
|
152 |
$post_id = $posts ? $posts[0]->ID : 0;
|
153 |
-
|
154 |
// Update cache.
|
155 |
wp_cache_set( $cache_key, $post_id, 'acf' );
|
156 |
}
|
157 |
-
|
158 |
// Check $post_id and return the post when possible.
|
159 |
-
if( $post_id ) {
|
160 |
return get_post( $post_id );
|
161 |
}
|
162 |
}
|
163 |
-
|
164 |
// Return false by default.
|
165 |
return false;
|
166 |
}
|
@@ -170,27 +172,27 @@ function acf_get_field_post( $id = 0 ) {
|
|
170 |
*
|
171 |
* Returns true if the given identifier is a field key.
|
172 |
*
|
173 |
-
* @date
|
174 |
-
* @since
|
175 |
*
|
176 |
-
* @param
|
177 |
-
* @return
|
178 |
*/
|
179 |
function acf_is_field_key( $id = '' ) {
|
180 |
-
|
181 |
// Check if $id is a string starting with "field_".
|
182 |
-
if( is_string($id) && substr($id, 0, 6) === 'field_' ) {
|
183 |
return true;
|
184 |
}
|
185 |
-
|
186 |
/**
|
187 |
* Filters whether the $id is a field key.
|
188 |
*
|
189 |
-
* @date
|
190 |
-
* @since
|
191 |
*
|
192 |
-
* @param
|
193 |
-
* @param
|
194 |
*/
|
195 |
return apply_filters( 'acf/is_field_key', false, $id );
|
196 |
}
|
@@ -200,82 +202,88 @@ function acf_is_field_key( $id = '' ) {
|
|
200 |
*
|
201 |
* Ensures the given field valid.
|
202 |
*
|
203 |
-
* @date
|
204 |
-
* @since
|
205 |
*
|
206 |
-
* @param
|
207 |
-
* @return
|
208 |
*/
|
209 |
function acf_validate_field( $field = array() ) {
|
210 |
-
|
211 |
// Bail early if already valid.
|
212 |
-
if( is_array($field) && !empty($field['_valid']) ) {
|
213 |
return $field;
|
214 |
}
|
215 |
-
|
216 |
// Apply defaults.
|
217 |
-
$field = wp_parse_args(
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
236 |
// Convert types.
|
237 |
-
$field['ID']
|
238 |
$field['menu_order'] = (int) $field['menu_order'];
|
239 |
-
|
240 |
// Add backwards compatibility for wrapper attributes.
|
241 |
// Todo: Remove need for this.
|
242 |
-
$field['wrapper'] = wp_parse_args(
|
243 |
-
'
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
248 |
// Store backups.
|
249 |
-
$field['_name']
|
250 |
$field['_valid'] = 1;
|
251 |
-
|
252 |
/**
|
253 |
* Filters the $field array to validate settings.
|
254 |
*
|
255 |
-
* @date
|
256 |
-
* @since
|
257 |
*
|
258 |
-
* @param
|
259 |
*/
|
260 |
-
$field = apply_filters(
|
261 |
-
|
262 |
// return
|
263 |
return $field;
|
264 |
}
|
265 |
|
266 |
// Register variation.
|
267 |
-
acf_add_filter_variations( 'acf/validate_field', array('type'), 0 );
|
268 |
|
269 |
/**
|
270 |
* acf_get_valid_field
|
271 |
*
|
272 |
* Ensures the given field valid.
|
273 |
*
|
274 |
-
* @date
|
275 |
-
* @since
|
276 |
*
|
277 |
-
* @param
|
278 |
-
* @return
|
279 |
*/
|
280 |
function acf_get_valid_field( $field = false ) {
|
281 |
return acf_validate_field( $field );
|
@@ -286,96 +294,96 @@ function acf_get_valid_field( $field = false ) {
|
|
286 |
*
|
287 |
* Translates a field's settings.
|
288 |
*
|
289 |
-
* @date
|
290 |
-
* @since
|
291 |
*
|
292 |
-
* @param
|
293 |
-
* @return
|
294 |
*/
|
295 |
function acf_translate_field( $field = array() ) {
|
296 |
-
|
297 |
// Get settings.
|
298 |
-
$l10n
|
299 |
-
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
300 |
-
|
301 |
// Translate field settings if textdomain is set.
|
302 |
-
if( $l10n && $l10n_textdomain ) {
|
303 |
-
|
304 |
-
$field['label']
|
305 |
$field['instructions'] = acf_translate( $field['instructions'] );
|
306 |
-
|
307 |
/**
|
308 |
* Filters the $field array to translate strings.
|
309 |
*
|
310 |
-
* @date
|
311 |
-
* @since
|
312 |
*
|
313 |
-
* @param
|
314 |
*/
|
315 |
-
$field = apply_filters(
|
316 |
}
|
317 |
-
|
318 |
// Return field.
|
319 |
return $field;
|
320 |
}
|
321 |
|
322 |
// Register variation.
|
323 |
-
acf_add_filter_variations( 'acf/translate_field', array('type'), 0 );
|
324 |
|
325 |
// Translate fields passing through validation.
|
326 |
-
add_action('acf/validate_field', 'acf_translate_field');
|
327 |
|
328 |
/**
|
329 |
* acf_get_fields
|
330 |
*
|
331 |
* Returns and array of fields for the given $parent.
|
332 |
*
|
333 |
-
* @date
|
334 |
-
* @since
|
335 |
*
|
336 |
-
* @param
|
337 |
-
* @return
|
338 |
*/
|
339 |
function acf_get_fields( $parent ) {
|
340 |
-
|
341 |
// Allow field group selector as $parent.
|
342 |
-
if( !is_array($parent) ) {
|
343 |
$parent = acf_get_field_group( $parent );
|
344 |
-
if(
|
345 |
return array();
|
346 |
}
|
347 |
}
|
348 |
-
|
349 |
// Vars.
|
350 |
$fields = array();
|
351 |
-
|
352 |
// Check local fields first.
|
353 |
-
if( acf_have_local_fields($parent['key']) ) {
|
354 |
$raw_fields = acf_get_local_fields( $parent['key'] );
|
355 |
-
foreach( $raw_fields as $raw_field ) {
|
356 |
$fields[] = acf_get_field( $raw_field['key'] );
|
357 |
}
|
358 |
-
|
359 |
-
|
360 |
} else {
|
361 |
$raw_fields = acf_get_raw_fields( $parent['ID'] );
|
362 |
-
foreach( $raw_fields as $raw_field ) {
|
363 |
$fields[] = acf_get_field( $raw_field['ID'] );
|
364 |
}
|
365 |
}
|
366 |
-
|
367 |
/**
|
368 |
* Filters the $fields array.
|
369 |
*
|
370 |
-
* @date
|
371 |
-
* @since
|
372 |
*
|
373 |
-
* @param
|
374 |
*/
|
375 |
$fields = apply_filters( 'acf/load_fields', $fields, $parent );
|
376 |
-
|
377 |
// Return fields
|
378 |
-
return $fields;
|
379 |
}
|
380 |
|
381 |
/**
|
@@ -383,49 +391,51 @@ function acf_get_fields( $parent ) {
|
|
383 |
*
|
384 |
* Returns and array of raw field data for the given parent id.
|
385 |
*
|
386 |
-
* @date
|
387 |
-
* @since
|
388 |
*
|
389 |
-
* @param
|
390 |
-
* @return
|
391 |
*/
|
392 |
function acf_get_raw_fields( $id = 0 ) {
|
393 |
-
|
394 |
// Try cache.
|
395 |
$cache_key = acf_cache_key( "acf_get_field_posts:$id" );
|
396 |
-
$post_ids
|
397 |
-
if( $post_ids === false ) {
|
398 |
-
|
399 |
// Query posts.
|
400 |
-
$posts = get_posts(
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
|
|
|
|
413 |
// Update $post_ids with a non false value.
|
414 |
$post_ids = array();
|
415 |
-
foreach( $posts as $post ) {
|
416 |
$post_ids[] = $post->ID;
|
417 |
}
|
418 |
-
|
419 |
// Update cache.
|
420 |
wp_cache_set( $cache_key, $post_ids, 'acf' );
|
421 |
}
|
422 |
-
|
423 |
// Loop over ids and populate array of fields.
|
424 |
$fields = array();
|
425 |
-
foreach( $post_ids as $post_id ) {
|
426 |
$fields[] = acf_get_raw_field( $post_id );
|
427 |
}
|
428 |
-
|
429 |
// Return fields.
|
430 |
return $fields;
|
431 |
}
|
@@ -435,33 +445,33 @@ function acf_get_raw_fields( $id = 0 ) {
|
|
435 |
*
|
436 |
* Return the number of fields for the given field group.
|
437 |
*
|
438 |
-
* @date
|
439 |
-
* @since
|
440 |
*
|
441 |
-
* @param
|
442 |
-
* @return
|
443 |
*/
|
444 |
function acf_get_field_count( $parent ) {
|
445 |
-
|
446 |
// Check local fields first.
|
447 |
-
if( acf_have_local_fields($parent['key']) ) {
|
448 |
$raw_fields = acf_get_local_fields( $parent['key'] );
|
449 |
-
|
450 |
-
|
451 |
} else {
|
452 |
$raw_fields = acf_get_raw_fields( $parent['ID'] );
|
453 |
}
|
454 |
-
|
455 |
/**
|
456 |
* Filters the counted number of fields.
|
457 |
*
|
458 |
-
* @date
|
459 |
-
* @since
|
460 |
*
|
461 |
-
* @param
|
462 |
-
* @param
|
463 |
*/
|
464 |
-
return apply_filters( 'acf/get_field_count', count($raw_fields), $parent );
|
465 |
}
|
466 |
|
467 |
/**
|
@@ -469,149 +479,149 @@ function acf_get_field_count( $parent ) {
|
|
469 |
*
|
470 |
* Allows customization to a field when it is cloned. Used by the clone field.
|
471 |
*
|
472 |
-
* @date
|
473 |
-
* @since
|
474 |
*
|
475 |
-
* @param
|
476 |
-
* @param
|
477 |
-
* @return
|
478 |
*/
|
479 |
function acf_clone_field( $field, $clone_field ) {
|
480 |
-
|
481 |
// Add reference to the clone field.
|
482 |
$field['_clone'] = $clone_field['key'];
|
483 |
-
|
484 |
/**
|
485 |
* Filters the $field array when it is being cloned.
|
486 |
*
|
487 |
-
* @date
|
488 |
-
* @since
|
489 |
*
|
490 |
-
* @param
|
491 |
-
* @param
|
492 |
*/
|
493 |
-
$field = apply_filters(
|
494 |
-
|
495 |
// Return field.
|
496 |
return $field;
|
497 |
}
|
498 |
|
499 |
// Register variation.
|
500 |
-
acf_add_filter_variations( 'acf/clone_field', array('type'), 0 );
|
501 |
|
502 |
/**
|
503 |
* acf_prepare_field
|
504 |
*
|
505 |
* Prepare a field for input.
|
506 |
*
|
507 |
-
* @date
|
508 |
-
* @since
|
509 |
*
|
510 |
-
* @param
|
511 |
-
* @return
|
512 |
*/
|
513 |
function acf_prepare_field( $field ) {
|
514 |
-
|
515 |
// Bail early if already prepared.
|
516 |
-
if( !empty($field['_prepare']) ) {
|
517 |
return $field;
|
518 |
}
|
519 |
-
|
520 |
// Use field key to override input name.
|
521 |
-
if( $field['key'] ) {
|
522 |
$field['name'] = $field['key'];
|
523 |
}
|
524 |
|
525 |
// Use field prefix to modify input name.
|
526 |
-
if( $field['prefix'] ) {
|
527 |
$field['name'] = "{$field['prefix']}[{$field['name']}]";
|
528 |
}
|
529 |
-
|
530 |
// Generate id attribute from name.
|
531 |
$field['id'] = acf_idify( $field['name'] );
|
532 |
-
|
533 |
// Add state to field.
|
534 |
$field['_prepare'] = true;
|
535 |
-
|
536 |
/**
|
537 |
* Filters the $field array.
|
538 |
*
|
539 |
* Allows developers to modify field settings or return false to remove field.
|
540 |
*
|
541 |
-
* @date
|
542 |
-
* @since
|
543 |
*
|
544 |
-
* @param
|
545 |
*/
|
546 |
-
$field = apply_filters(
|
547 |
-
|
548 |
// return
|
549 |
return $field;
|
550 |
}
|
551 |
|
552 |
// Register variation.
|
553 |
-
acf_add_filter_variations( 'acf/prepare_field', array('type', 'name', 'key'), 0 );
|
554 |
|
555 |
/**
|
556 |
* acf_render_fields
|
557 |
*
|
558 |
* Renders an array of fields. Also loads the field's value.
|
559 |
*
|
560 |
-
* @date
|
561 |
-
* @since
|
562 |
-
* @since
|
563 |
*
|
564 |
-
* @param
|
565 |
-
* @param
|
566 |
-
* @param
|
567 |
-
* @param
|
568 |
-
* @return
|
569 |
*/
|
570 |
function acf_render_fields( $fields, $post_id = 0, $el = 'div', $instruction = 'label' ) {
|
571 |
-
|
572 |
// Parameter order changed in ACF 5.6.9.
|
573 |
-
if( is_array($post_id) ) {
|
574 |
-
$args
|
575 |
-
$fields
|
576 |
$post_id = $args[0];
|
577 |
}
|
578 |
-
|
579 |
/**
|
580 |
* Filters the $fields array before they are rendered.
|
581 |
*
|
582 |
-
* @date
|
583 |
-
* @since
|
584 |
*
|
585 |
-
* @param
|
586 |
-
* @param
|
587 |
*/
|
588 |
$fields = apply_filters( 'acf/pre_render_fields', $fields, $post_id );
|
589 |
-
|
590 |
// Filter our false results.
|
591 |
$fields = array_filter( $fields );
|
592 |
-
|
593 |
// Loop over and render fields.
|
594 |
-
if( $fields ) {
|
595 |
-
foreach( $fields as $field ) {
|
596 |
-
|
597 |
// Load value if not already loaded.
|
598 |
-
if( $field['value'] === null ) {
|
599 |
$field['value'] = acf_get_value( $post_id, $field );
|
600 |
-
}
|
601 |
-
|
602 |
// Render wrap.
|
603 |
acf_render_field_wrap( $field, $el, $instruction );
|
604 |
}
|
605 |
}
|
606 |
-
|
607 |
/**
|
608 |
* Fires after fields have been rendered.
|
609 |
*
|
610 |
-
* @date
|
611 |
-
* @since
|
612 |
*
|
613 |
-
* @param
|
614 |
-
* @param
|
615 |
*/
|
616 |
do_action( 'acf/render_fields', $fields, $post_id );
|
617 |
}
|
@@ -621,130 +631,130 @@ function acf_render_fields( $fields, $post_id = 0, $el = 'div', $instruction = '
|
|
621 |
*
|
622 |
* Render the wrapping element for a given field.
|
623 |
*
|
624 |
-
* @date
|
625 |
-
* @since
|
626 |
*
|
627 |
-
* @param
|
628 |
-
* @param
|
629 |
-
* @param
|
630 |
-
* @return
|
631 |
*/
|
632 |
function acf_render_field_wrap( $field, $element = 'div', $instruction = 'label' ) {
|
633 |
-
|
634 |
// Ensure field is complete (adds all settings).
|
635 |
$field = acf_validate_field( $field );
|
636 |
-
|
637 |
// Prepare field for input (modifies settings).
|
638 |
$field = acf_prepare_field( $field );
|
639 |
-
|
640 |
// Allow filters to cancel render.
|
641 |
-
if(
|
642 |
return;
|
643 |
}
|
644 |
-
|
645 |
// Determine wrapping element.
|
646 |
$elements = array(
|
647 |
-
'div'
|
648 |
-
'tr'
|
649 |
-
'td'
|
650 |
-
'ul'
|
651 |
-
'ol'
|
652 |
-
'dl'
|
653 |
);
|
654 |
-
|
655 |
-
if( isset($elements[$element]) ) {
|
656 |
-
$inner_element = $elements[$element];
|
657 |
} else {
|
658 |
$element = $inner_element = 'div';
|
659 |
}
|
660 |
-
|
661 |
// Generate wrapper attributes.
|
662 |
$wrapper = array(
|
663 |
-
'id'
|
664 |
-
'class'
|
665 |
-
'width'
|
666 |
-
'style'
|
667 |
-
'data-name'
|
668 |
-
'data-type'
|
669 |
-
'data-key'
|
670 |
);
|
671 |
-
|
672 |
// Add field type attributes.
|
673 |
$wrapper['class'] .= " acf-field-{$field['type']}";
|
674 |
-
|
675 |
// add field key attributes
|
676 |
-
if( $field['key'] ) {
|
677 |
$wrapper['class'] .= " acf-field-{$field['key']}";
|
678 |
}
|
679 |
-
|
680 |
// Add required attributes.
|
681 |
// Todo: Remove data-required
|
682 |
-
if( $field['required'] ) {
|
683 |
-
$wrapper['class']
|
684 |
$wrapper['data-required'] = 1;
|
685 |
}
|
686 |
-
|
687 |
// Clean up class attribute.
|
688 |
$wrapper['class'] = str_replace( '_', '-', $wrapper['class'] );
|
689 |
$wrapper['class'] = str_replace( 'field-field-', 'field-', $wrapper['class'] );
|
690 |
-
|
691 |
// Merge in field 'wrapper' setting without destroying class and style.
|
692 |
-
if( $field['wrapper'] ) {
|
693 |
$wrapper = acf_merge_attributes( $wrapper, $field['wrapper'] );
|
694 |
}
|
695 |
-
|
696 |
// Extract wrapper width and generate style.
|
697 |
// Todo: Move from $wrapper out into $field.
|
698 |
$width = acf_extract_var( $wrapper, 'width' );
|
699 |
-
if( $width ) {
|
700 |
$width = acf_numval( $width );
|
701 |
-
if( $element !== 'tr' && $element !== 'td' ) {
|
702 |
$wrapper['data-width'] = $width;
|
703 |
-
$wrapper['style']
|
704 |
}
|
705 |
}
|
706 |
-
|
707 |
// Clean up all attributes.
|
708 |
$wrapper = array_map( 'trim', $wrapper );
|
709 |
$wrapper = array_filter( $wrapper );
|
710 |
-
|
711 |
/**
|
712 |
* Filters the $wrapper array before rendering.
|
713 |
*
|
714 |
-
* @date
|
715 |
-
* @since
|
716 |
*
|
717 |
-
* @param
|
718 |
-
* @param
|
719 |
*/
|
720 |
$wrapper = apply_filters( 'acf/field_wrapper_attributes', $wrapper, $field );
|
721 |
-
|
722 |
// Append conditional logic attributes.
|
723 |
-
if( !empty($field['conditional_logic']) ) {
|
724 |
$wrapper['data-conditions'] = $field['conditional_logic'];
|
725 |
}
|
726 |
-
if( !empty($field['conditions']) ) {
|
727 |
$wrapper['data-conditions'] = $field['conditions'];
|
728 |
}
|
729 |
-
|
730 |
// Vars for render.
|
731 |
$attributes_html = acf_esc_attr( $wrapper );
|
732 |
-
|
733 |
// Render HTML
|
734 |
echo "<$element $attributes_html>" . "\n";
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
}
|
741 |
-
echo "</$inner_element>" . "\n";
|
742 |
}
|
|
|
|
|
743 |
echo "<$inner_element class=\"acf-input\">" . "\n";
|
744 |
acf_render_field( $field );
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
echo "</$inner_element>" . "\n";
|
749 |
echo "</$element>" . "\n";
|
750 |
}
|
@@ -754,58 +764,58 @@ function acf_render_field_wrap( $field, $element = 'div', $instruction = 'label'
|
|
754 |
*
|
755 |
* Render the input element for a given field.
|
756 |
*
|
757 |
-
* @date
|
758 |
-
* @since
|
759 |
*
|
760 |
-
* @param
|
761 |
-
* @return
|
762 |
*/
|
763 |
function acf_render_field( $field ) {
|
764 |
-
|
765 |
// Ensure field is complete (adds all settings).
|
766 |
$field = acf_validate_field( $field );
|
767 |
-
|
768 |
// Prepare field for input (modifies settings).
|
769 |
$field = acf_prepare_field( $field );
|
770 |
-
|
771 |
// Allow filters to cancel render.
|
772 |
-
if(
|
773 |
return;
|
774 |
}
|
775 |
-
|
776 |
/**
|
777 |
* Fires when rendering a field.
|
778 |
*
|
779 |
-
* @date
|
780 |
-
* @since
|
781 |
*
|
782 |
-
* @param
|
783 |
*/
|
784 |
-
do_action(
|
785 |
}
|
786 |
|
787 |
// Register variation.
|
788 |
-
acf_add_action_variations( 'acf/render_field', array('type', 'name', 'key'), 0 );
|
789 |
|
790 |
/**
|
791 |
* acf_render_field_label
|
792 |
*
|
793 |
* Renders the field's label.
|
794 |
*
|
795 |
-
* @date
|
796 |
-
* @since
|
797 |
*
|
798 |
-
* @param
|
799 |
-
* @return
|
800 |
*/
|
801 |
function acf_render_field_label( $field ) {
|
802 |
-
|
803 |
// Get label.
|
804 |
$label = acf_get_field_label( $field );
|
805 |
-
|
806 |
// Output label.
|
807 |
-
if( $label ) {
|
808 |
-
echo '<label' . ($field['id'] ? ' for="' . esc_attr($field['id']) . '"' : '' ) . '>' . acf_esc_html($label) . '</label>';
|
809 |
}
|
810 |
}
|
811 |
|
@@ -814,40 +824,40 @@ function acf_render_field_label( $field ) {
|
|
814 |
*
|
815 |
* Returns the field's label with appropriate required label.
|
816 |
*
|
817 |
-
* @date
|
818 |
-
* @since
|
819 |
*
|
820 |
-
* @param
|
821 |
-
* @param
|
822 |
-
* @return
|
823 |
*/
|
824 |
function acf_get_field_label( $field, $context = '' ) {
|
825 |
-
|
826 |
// Get label.
|
827 |
$label = $field['label'];
|
828 |
-
|
829 |
// Display empty text when editing field.
|
830 |
-
if( $context == 'admin' && $label === '' ) {
|
831 |
-
$label = __('(no label)', 'acf');
|
832 |
}
|
833 |
-
|
834 |
// Add required HTML.
|
835 |
-
if( $field['required'] ) {
|
836 |
$label .= ' <span class="acf-required">*</span>';
|
837 |
}
|
838 |
-
|
839 |
/**
|
840 |
* Filters the field's label HTML.
|
841 |
*
|
842 |
-
* @date
|
843 |
-
* @since
|
844 |
*
|
845 |
-
* @param
|
846 |
-
* @param
|
847 |
-
* @param
|
848 |
*/
|
849 |
-
$label = apply_filters(
|
850 |
-
|
851 |
// Return label.
|
852 |
return $label;
|
853 |
}
|
@@ -857,17 +867,17 @@ function acf_get_field_label( $field, $context = '' ) {
|
|
857 |
*
|
858 |
* Renders the field's instructions.
|
859 |
*
|
860 |
-
* @date
|
861 |
-
* @since
|
862 |
*
|
863 |
-
* @param
|
864 |
-
* @return
|
865 |
*/
|
866 |
function acf_render_field_instructions( $field ) {
|
867 |
-
|
868 |
// Output instructions.
|
869 |
-
if( $field['instructions'] ) {
|
870 |
-
echo '<p class="description">' . acf_esc_html($field['instructions']) . '</p>';
|
871 |
}
|
872 |
}
|
873 |
|
@@ -876,47 +886,47 @@ function acf_render_field_instructions( $field ) {
|
|
876 |
*
|
877 |
* Renders a field setting used in the admin edit screen.
|
878 |
*
|
879 |
-
* @date
|
880 |
-
* @since
|
881 |
*
|
882 |
-
* @param
|
883 |
-
* @param
|
884 |
-
* @param
|
885 |
-
* @return
|
886 |
*/
|
887 |
function acf_render_field_setting( $field, $setting, $global = false ) {
|
888 |
-
|
889 |
// Validate field.
|
890 |
$setting = acf_validate_field( $setting );
|
891 |
-
|
892 |
// Add custom attributes to setting wrapper.
|
893 |
$setting['wrapper']['data-key'] = $setting['name'];
|
894 |
-
$setting['wrapper']['class']
|
895 |
-
if(
|
896 |
$setting['wrapper']['data-setting'] = $field['type'];
|
897 |
}
|
898 |
-
|
899 |
// Copy across prefix.
|
900 |
$setting['prefix'] = $field['prefix'];
|
901 |
-
|
902 |
// Find setting value from field.
|
903 |
-
if( $setting['value'] === null ) {
|
904 |
-
|
905 |
// Name.
|
906 |
-
if( isset($field[ $setting['name'] ]) ) {
|
907 |
$setting['value'] = $field[ $setting['name'] ];
|
908 |
-
|
909 |
-
|
910 |
-
} elseif( isset($setting['default_value']) ) {
|
911 |
$setting['value'] = $setting['default_value'];
|
912 |
}
|
913 |
}
|
914 |
-
|
915 |
// Add append attribute used by JS to join settings.
|
916 |
-
if( isset($setting['_append']) ) {
|
917 |
$setting['wrapper']['data-append'] = $setting['_append'];
|
918 |
}
|
919 |
-
|
920 |
// Render setting.
|
921 |
acf_render_field_wrap( $setting, 'tr', 'label' );
|
922 |
}
|
@@ -926,114 +936,114 @@ function acf_render_field_setting( $field, $setting, $global = false ) {
|
|
926 |
*
|
927 |
* Updates a field in the database.
|
928 |
*
|
929 |
-
* @date
|
930 |
-
* @since
|
931 |
*
|
932 |
-
* @param
|
933 |
-
* @param
|
934 |
-
* @return
|
935 |
*/
|
936 |
function acf_update_field( $field, $specific = array() ) {
|
937 |
-
|
938 |
// Validate field.
|
939 |
$field = acf_validate_field( $field );
|
940 |
-
|
941 |
// May have been posted. Remove slashes.
|
942 |
$field = wp_unslash( $field );
|
943 |
-
|
944 |
// Parse types (converts string '0' to int 0).
|
945 |
$field = acf_parse_types( $field );
|
946 |
-
|
947 |
// Clean up conditional logic keys.
|
948 |
-
if( $field['conditional_logic'] ) {
|
949 |
-
|
950 |
// Remove empty values and convert to associated array.
|
951 |
$field['conditional_logic'] = array_filter( $field['conditional_logic'] );
|
952 |
$field['conditional_logic'] = array_values( $field['conditional_logic'] );
|
953 |
$field['conditional_logic'] = array_map( 'array_filter', $field['conditional_logic'] );
|
954 |
$field['conditional_logic'] = array_map( 'array_values', $field['conditional_logic'] );
|
955 |
}
|
956 |
-
|
957 |
// Parent may be provided as a field key.
|
958 |
-
if( $field['parent'] && !is_numeric($field['parent']) ) {
|
959 |
-
$parent
|
960 |
$field['parent'] = $parent ? $parent->ID : 0;
|
961 |
}
|
962 |
-
|
963 |
/**
|
964 |
* Filters the $field array before it is updated.
|
965 |
*
|
966 |
-
* @date
|
967 |
-
* @since
|
968 |
*
|
969 |
-
* @param
|
970 |
*/
|
971 |
-
$field = apply_filters(
|
972 |
-
|
973 |
// Make a backup of field data and remove some args.
|
974 |
$_field = $field;
|
975 |
acf_extract_vars( $_field, array( 'ID', 'key', 'label', 'name', 'prefix', 'value', 'menu_order', 'id', 'class', 'parent', '_name', '_prepare', '_valid' ) );
|
976 |
-
|
977 |
// Create array of data to save.
|
978 |
$save = array(
|
979 |
-
'ID'
|
980 |
-
'post_status'
|
981 |
-
'post_type'
|
982 |
-
'post_title'
|
983 |
-
'post_name'
|
984 |
-
'post_excerpt'
|
985 |
-
'post_content'
|
986 |
-
'post_parent'
|
987 |
-
'menu_order'
|
988 |
);
|
989 |
-
|
990 |
// Reduce save data if specific key list is provided.
|
991 |
-
if( $specific ) {
|
992 |
$specific[] = 'ID';
|
993 |
-
$save
|
994 |
}
|
995 |
-
|
996 |
// Unhook wp_targeted_link_rel() filter from WP 5.1 corrupting serialized data.
|
997 |
remove_filter( 'content_save_pre', 'wp_targeted_link_rel' );
|
998 |
-
|
999 |
// Slash data.
|
1000 |
// WP expects all data to be slashed and will unslash it (fixes '\' character issues).
|
1001 |
$save = wp_slash( $save );
|
1002 |
-
|
1003 |
// Update or Insert.
|
1004 |
-
if( $field['ID'] ) {
|
1005 |
wp_update_post( $save );
|
1006 |
-
} else
|
1007 |
$field['ID'] = wp_insert_post( $save );
|
1008 |
}
|
1009 |
-
|
1010 |
// Flush field cache.
|
1011 |
acf_flush_field_cache( $field );
|
1012 |
-
|
1013 |
/**
|
1014 |
* Fires after a field has been updated, and the field cache has been cleaned.
|
1015 |
*
|
1016 |
-
* @date
|
1017 |
-
* @since
|
1018 |
*
|
1019 |
-
* @param
|
1020 |
*/
|
1021 |
-
do_action(
|
1022 |
-
|
1023 |
// Return field.
|
1024 |
return $field;
|
1025 |
}
|
1026 |
|
1027 |
// Register variation.
|
1028 |
-
acf_add_filter_variations( 'acf/update_field', array('type', 'name', 'key'), 0 );
|
1029 |
|
1030 |
/**
|
1031 |
* _acf_apply_unique_field_slug
|
1032 |
*
|
1033 |
* Allows full control over 'acf-field' slugs.
|
1034 |
*
|
1035 |
-
* @date
|
1036 |
-
* @since
|
1037 |
*
|
1038 |
* @param string $slug The post slug.
|
1039 |
* @param int $post_ID Post ID.
|
@@ -1043,12 +1053,12 @@ acf_add_filter_variations( 'acf/update_field', array('type', 'name', 'key'), 0 )
|
|
1043 |
* @param string $original_slug The original post slug.
|
1044 |
*/
|
1045 |
function _acf_apply_unique_field_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
1046 |
-
|
1047 |
// Check post type and reset to original value.
|
1048 |
-
if( $post_type === 'acf-field' ) {
|
1049 |
return $original_slug;
|
1050 |
}
|
1051 |
-
|
1052 |
// Return slug.
|
1053 |
return $slug;
|
1054 |
}
|
@@ -1061,23 +1071,23 @@ add_filter( 'wp_unique_post_slug', '_acf_apply_unique_field_slug', 999, 6 );
|
|
1061 |
*
|
1062 |
* Deletes all caches for this field.
|
1063 |
*
|
1064 |
-
* @date
|
1065 |
-
* @since
|
1066 |
*
|
1067 |
-
* @param
|
1068 |
-
* @return
|
1069 |
*/
|
1070 |
function acf_flush_field_cache( $field ) {
|
1071 |
-
|
1072 |
// Delete stored data.
|
1073 |
acf_get_store( 'fields' )->remove( $field['key'] );
|
1074 |
-
|
1075 |
// Flush cached post_id for this field's name and key.
|
1076 |
-
wp_cache_delete( acf_cache_key("acf_get_field_post:name:{$field['name']}"), 'acf' );
|
1077 |
-
wp_cache_delete( acf_cache_key("acf_get_field_post:key:{$field['key']}"), 'acf' );
|
1078 |
-
|
1079 |
// Flush cached array of post_ids for this field's parent.
|
1080 |
-
wp_cache_delete( acf_cache_key("acf_get_field_posts:{$field['parent']}"), 'acf' );
|
1081 |
}
|
1082 |
|
1083 |
/**
|
@@ -1085,79 +1095,79 @@ function acf_flush_field_cache( $field ) {
|
|
1085 |
*
|
1086 |
* Deletes a field from the database.
|
1087 |
*
|
1088 |
-
* @date
|
1089 |
-
* @since
|
1090 |
*
|
1091 |
-
* @param
|
1092 |
-
* @return
|
1093 |
*/
|
1094 |
function acf_delete_field( $id = 0 ) {
|
1095 |
-
|
1096 |
// Get the field.
|
1097 |
$field = acf_get_field( $id );
|
1098 |
-
|
1099 |
// Bail early if field was not found.
|
1100 |
-
if(
|
1101 |
return false;
|
1102 |
}
|
1103 |
-
|
1104 |
// Delete post.
|
1105 |
wp_delete_post( $field['ID'], true );
|
1106 |
-
|
1107 |
// Flush field cache.
|
1108 |
acf_flush_field_cache( $field );
|
1109 |
-
|
1110 |
/**
|
1111 |
* Fires immediately after a field has been deleted.
|
1112 |
*
|
1113 |
-
* @date
|
1114 |
-
* @since
|
1115 |
*
|
1116 |
-
* @param
|
1117 |
*/
|
1118 |
-
do_action(
|
1119 |
-
|
1120 |
// Return true.
|
1121 |
return true;
|
1122 |
}
|
1123 |
|
1124 |
// Register variation.
|
1125 |
-
acf_add_action_variations( 'acf/delete_field', array('type', 'name', 'key'), 0 );
|
1126 |
|
1127 |
/**
|
1128 |
* acf_trash_field
|
1129 |
*
|
1130 |
* Trashes a field from the database.
|
1131 |
*
|
1132 |
-
* @date
|
1133 |
-
* @since
|
1134 |
*
|
1135 |
-
* @param
|
1136 |
-
* @return
|
1137 |
*/
|
1138 |
function acf_trash_field( $id = 0 ) {
|
1139 |
-
|
1140 |
// Get the field.
|
1141 |
$field = acf_get_field( $id );
|
1142 |
-
|
1143 |
// Bail early if field was not found.
|
1144 |
-
if(
|
1145 |
return false;
|
1146 |
}
|
1147 |
-
|
1148 |
// Trash post.
|
1149 |
wp_trash_post( $field['ID'], true );
|
1150 |
-
|
1151 |
/**
|
1152 |
* Fires immediately after a field has been trashed.
|
1153 |
*
|
1154 |
-
* @date
|
1155 |
-
* @since
|
1156 |
*
|
1157 |
-
* @param
|
1158 |
*/
|
1159 |
do_action( 'acf/trash_field', $field );
|
1160 |
-
|
1161 |
// Return true.
|
1162 |
return true;
|
1163 |
}
|
@@ -1167,38 +1177,38 @@ function acf_trash_field( $id = 0 ) {
|
|
1167 |
*
|
1168 |
* Restores a field from the trash.
|
1169 |
*
|
1170 |
-
* @date
|
1171 |
-
* @since
|
1172 |
*
|
1173 |
-
* @param
|
1174 |
-
* @return
|
1175 |
*/
|
1176 |
function acf_untrash_field( $id = 0 ) {
|
1177 |
-
|
1178 |
// Get the field.
|
1179 |
$field = acf_get_field( $id );
|
1180 |
-
|
1181 |
// Bail early if field was not found.
|
1182 |
-
if(
|
1183 |
return false;
|
1184 |
}
|
1185 |
-
|
1186 |
// Untrash post.
|
1187 |
wp_untrash_post( $field['ID'], true );
|
1188 |
-
|
1189 |
// Flush field cache.
|
1190 |
acf_flush_field_cache( $field );
|
1191 |
-
|
1192 |
/**
|
1193 |
* Fires immediately after a field has been trashed.
|
1194 |
*
|
1195 |
-
* @date
|
1196 |
-
* @since
|
1197 |
*
|
1198 |
-
* @param
|
1199 |
*/
|
1200 |
do_action( 'acf/untrash_field', $field );
|
1201 |
-
|
1202 |
// Return true.
|
1203 |
return true;
|
1204 |
}
|
@@ -1226,91 +1236,91 @@ add_action( 'wp_untrash_post_status', '_acf_untrash_field_post_status', 10, 3 );
|
|
1226 |
*
|
1227 |
* Changes the prefix for an array of fields by reference.
|
1228 |
*
|
1229 |
-
* @date
|
1230 |
-
* @since
|
1231 |
*
|
1232 |
-
* @param
|
1233 |
-
* @param
|
1234 |
-
* @return
|
1235 |
*/
|
1236 |
function acf_prefix_fields( &$fields, $prefix = 'acf' ) {
|
1237 |
-
|
1238 |
// Loopover fields.
|
1239 |
-
foreach( $fields as &$field ) {
|
1240 |
-
|
1241 |
// Replace 'acf' with $prefix.
|
1242 |
-
$field['prefix'] = $prefix . substr($field['prefix'], 3);
|
1243 |
}
|
1244 |
}
|
1245 |
|
1246 |
/**
|
1247 |
* acf_get_sub_field
|
1248 |
*
|
1249 |
-
* Searches a field for sub fields matching the given selector.
|
1250 |
*
|
1251 |
-
* @date
|
1252 |
-
* @since
|
1253 |
*
|
1254 |
-
* @param
|
1255 |
-
* @param
|
1256 |
-
* @return
|
1257 |
*/
|
1258 |
function acf_get_sub_field( $id, $field ) {
|
1259 |
-
|
1260 |
// Vars.
|
1261 |
$sub_field = false;
|
1262 |
-
|
1263 |
// Search sub fields.
|
1264 |
-
if( isset($field['sub_fields']) ) {
|
1265 |
$sub_field = acf_search_fields( $id, $field['sub_fields'] );
|
1266 |
}
|
1267 |
-
|
1268 |
/**
|
1269 |
* Filters the $sub_field found.
|
1270 |
*
|
1271 |
-
* @date
|
1272 |
-
* @since
|
1273 |
*
|
1274 |
-
* @param
|
1275 |
-
* @param
|
1276 |
-
* @param
|
1277 |
*/
|
1278 |
-
$sub_field = apply_filters(
|
1279 |
-
|
1280 |
// return
|
1281 |
return $sub_field;
|
1282 |
-
|
1283 |
}
|
1284 |
|
1285 |
// Register variation.
|
1286 |
-
acf_add_filter_variations( 'acf/get_sub_field', array('type'), 2 );
|
1287 |
|
1288 |
/**
|
1289 |
* acf_search_fields
|
1290 |
*
|
1291 |
* Searches an array of fields for one that matches the given identifier.
|
1292 |
*
|
1293 |
-
* @date
|
1294 |
-
* @since
|
1295 |
*
|
1296 |
-
* @param
|
1297 |
-
* @param
|
1298 |
-
* @return
|
1299 |
*/
|
1300 |
function acf_search_fields( $id, $fields ) {
|
1301 |
-
|
1302 |
// Loop over searchable keys in order of priority.
|
1303 |
// Important to search "name" on all fields before "_name" backup.
|
1304 |
-
foreach( array( 'key', 'name', '_name', '__name' ) as $key ) {
|
1305 |
-
|
1306 |
// Loop over fields and compare.
|
1307 |
-
foreach( $fields as $field ) {
|
1308 |
-
if( isset($field[$key]) && $field[$key] === $id ) {
|
1309 |
return $field;
|
1310 |
}
|
1311 |
}
|
1312 |
}
|
1313 |
-
|
1314 |
// Return not found.
|
1315 |
return false;
|
1316 |
}
|
@@ -1320,18 +1330,18 @@ function acf_search_fields( $id, $fields ) {
|
|
1320 |
*
|
1321 |
* Returns true if the given params match a field.
|
1322 |
*
|
1323 |
-
* @date
|
1324 |
-
* @since
|
1325 |
*
|
1326 |
-
* @param
|
1327 |
-
* @param
|
1328 |
-
* @return
|
1329 |
*/
|
1330 |
function acf_is_field( $field = false, $id = '' ) {
|
1331 |
-
return (
|
1332 |
-
is_array($field)
|
1333 |
-
&& isset($field['key'])
|
1334 |
-
&& isset($field['name'])
|
1335 |
);
|
1336 |
}
|
1337 |
|
@@ -1340,22 +1350,22 @@ function acf_is_field( $field = false, $id = '' ) {
|
|
1340 |
*
|
1341 |
* Returns an array of ancestor field ID's or keys.
|
1342 |
*
|
1343 |
-
* @date
|
1344 |
-
* @since
|
1345 |
*
|
1346 |
-
* @param
|
1347 |
-
* @return
|
1348 |
*/
|
1349 |
function acf_get_field_ancestors( $field ) {
|
1350 |
-
|
1351 |
// Vars.
|
1352 |
$ancestors = array();
|
1353 |
-
|
1354 |
// Loop over parents.
|
1355 |
-
while( $field['parent'] && $field = acf_get_field($field['parent']) ) {
|
1356 |
$ancestors[] = $field['ID'] ? $field['ID'] : $field['key'];
|
1357 |
}
|
1358 |
-
|
1359 |
// return
|
1360 |
return $ancestors;
|
1361 |
}
|
@@ -1365,12 +1375,12 @@ function acf_get_field_ancestors( $field ) {
|
|
1365 |
*
|
1366 |
* Duplicate an array of fields.
|
1367 |
*
|
1368 |
-
* @date
|
1369 |
-
* @since
|
1370 |
*
|
1371 |
-
* @param
|
1372 |
-
* @param
|
1373 |
-
* @return
|
1374 |
*/
|
1375 |
function acf_duplicate_fields( $fields = array(), $parent_id = 0 ) {
|
1376 |
|
@@ -1378,18 +1388,18 @@ function acf_duplicate_fields( $fields = array(), $parent_id = 0 ) {
|
|
1378 |
// - Needed to alter conditional logic rules
|
1379 |
// - Use usleep() to ensure unique keys.
|
1380 |
$keys = array();
|
1381 |
-
foreach( $fields as $field ) {
|
1382 |
-
usleep(1);
|
1383 |
-
$keys[ $field['key'] ] = uniqid('field_');
|
1384 |
}
|
1385 |
acf_append_data( 'generated_keys', $keys );
|
1386 |
|
1387 |
// Duplicate fields.
|
1388 |
-
foreach( $fields as $field ) {
|
1389 |
-
$field_id
|
1390 |
$duplicates[] = acf_duplicate_field( $field_id, $parent_id );
|
1391 |
}
|
1392 |
-
|
1393 |
// Return.
|
1394 |
return $duplicates;
|
1395 |
}
|
@@ -1399,82 +1409,82 @@ function acf_duplicate_fields( $fields = array(), $parent_id = 0 ) {
|
|
1399 |
*
|
1400 |
* Duplicates a field.
|
1401 |
*
|
1402 |
-
* @date
|
1403 |
-
* @since
|
1404 |
*
|
1405 |
-
* @param
|
1406 |
-
* @param
|
1407 |
-
* @return
|
1408 |
*/
|
1409 |
-
function acf_duplicate_field( $id = 0, $parent_id = 0 ){
|
1410 |
-
|
1411 |
// Get the field.
|
1412 |
$field = acf_get_field( $id );
|
1413 |
-
|
1414 |
// Bail early if field was not found.
|
1415 |
-
if(
|
1416 |
return false;
|
1417 |
}
|
1418 |
-
|
1419 |
// Remove ID to avoid update.
|
1420 |
$field['ID'] = 0;
|
1421 |
-
|
1422 |
// Generate key.
|
1423 |
$keys = acf_get_data( 'generated_keys' );
|
1424 |
-
if( isset( $keys[ $field['key'] ] ) ) {
|
1425 |
$field['key'] = $keys[ $field['key'] ];
|
1426 |
} else {
|
1427 |
-
$field['key'] = uniqid('field_');
|
1428 |
}
|
1429 |
-
|
1430 |
// Set parent.
|
1431 |
-
if( $parent_id ) {
|
1432 |
$field['parent'] = $parent_id;
|
1433 |
}
|
1434 |
-
|
1435 |
// Update conditional logic references because field keys have changed.
|
1436 |
-
if( $field['conditional_logic'] ) {
|
1437 |
-
|
1438 |
// Loop over groups
|
1439 |
-
foreach( $field['conditional_logic'] as $group_i => $group ) {
|
1440 |
-
|
1441 |
// Loop over rules
|
1442 |
-
foreach( $group as $rule_i => $rule ) {
|
1443 |
-
$field['conditional_logic'][ $group_i ][ $rule_i ]['field'] = isset($keys[ $rule['field'] ]) ? $keys[ $rule['field'] ] : $rule['field'];
|
1444 |
}
|
1445 |
}
|
1446 |
}
|
1447 |
-
|
1448 |
/**
|
1449 |
* Filters the $field array after it has been duplicated.
|
1450 |
*
|
1451 |
-
* @date
|
1452 |
-
* @since
|
1453 |
*
|
1454 |
-
* @param
|
1455 |
*/
|
1456 |
-
$field = apply_filters(
|
1457 |
-
|
1458 |
// Update and return.
|
1459 |
return acf_update_field( $field );
|
1460 |
}
|
1461 |
|
1462 |
// Register variation.
|
1463 |
-
acf_add_filter_variations( 'acf/duplicate_field', array('type'), 0 );
|
1464 |
|
1465 |
/**
|
1466 |
* acf_prepare_fields_for_export
|
1467 |
*
|
1468 |
* Returns a modified array of fields ready for export.
|
1469 |
*
|
1470 |
-
* @date
|
1471 |
-
* @since
|
1472 |
*
|
1473 |
-
* @param
|
1474 |
-
* @return
|
1475 |
*/
|
1476 |
function acf_prepare_fields_for_export( $fields = array() ) {
|
1477 |
-
|
1478 |
// Map function and return.
|
1479 |
return array_map( 'acf_prepare_field_for_export', $fields );
|
1480 |
}
|
@@ -1484,74 +1494,74 @@ function acf_prepare_fields_for_export( $fields = array() ) {
|
|
1484 |
*
|
1485 |
* Returns a modified field ready for export.
|
1486 |
*
|
1487 |
-
* @date
|
1488 |
-
* @since
|
1489 |
*
|
1490 |
-
* @param
|
1491 |
-
* @return
|
1492 |
*/
|
1493 |
function acf_prepare_field_for_export( $field ) {
|
1494 |
-
|
1495 |
// Remove args.
|
1496 |
acf_extract_vars( $field, array( 'ID', 'prefix', 'value', 'menu_order', 'id', 'class', 'parent', '_name', '_prepare', '_valid' ) );
|
1497 |
-
|
1498 |
/**
|
1499 |
* Filters the $field array before being returned to the export tool.
|
1500 |
*
|
1501 |
-
* @date
|
1502 |
-
* @since
|
1503 |
*
|
1504 |
-
* @param
|
1505 |
*/
|
1506 |
-
return apply_filters(
|
1507 |
}
|
1508 |
|
1509 |
// Register variation.
|
1510 |
-
acf_add_filter_variations( 'acf/prepare_field_for_export', array('type'), 0 );
|
1511 |
|
1512 |
/**
|
1513 |
* acf_prepare_field_for_import
|
1514 |
*
|
1515 |
* Returns a modified array of fields ready for import.
|
1516 |
*
|
1517 |
-
* @date
|
1518 |
-
* @since
|
1519 |
*
|
1520 |
-
* @param
|
1521 |
-
* @return
|
1522 |
*/
|
1523 |
function acf_prepare_fields_for_import( $fields = array() ) {
|
1524 |
-
|
1525 |
// Ensure array is sequential.
|
1526 |
-
$fields = array_values($fields);
|
1527 |
-
|
1528 |
// Prepare each field for import making sure to detect additional sub fields.
|
1529 |
$i = 0;
|
1530 |
-
while( $i < count($fields) ) {
|
1531 |
-
|
1532 |
// Prepare field.
|
1533 |
$field = acf_prepare_field_for_import( $fields[ $i ] );
|
1534 |
-
|
1535 |
// Update single field.
|
1536 |
-
if( isset($field['key']) ) {
|
1537 |
$fields[ $i ] = $field;
|
1538 |
-
|
1539 |
-
|
1540 |
} else {
|
1541 |
array_splice( $fields, $i, 1, $field );
|
1542 |
}
|
1543 |
-
|
1544 |
// Iterate.
|
1545 |
$i++;
|
1546 |
}
|
1547 |
-
|
1548 |
/**
|
1549 |
* Filters the $fields array before being returned to the import tool.
|
1550 |
*
|
1551 |
-
* @date
|
1552 |
-
* @since
|
1553 |
*
|
1554 |
-
* @param
|
1555 |
*/
|
1556 |
return apply_filters( 'acf/prepare_fields_for_import', $fields );
|
1557 |
}
|
@@ -1562,24 +1572,24 @@ function acf_prepare_fields_for_import( $fields = array() ) {
|
|
1562 |
* Returns a modified field ready for import.
|
1563 |
* Allows parent fields to modify themselves and also return sub fields.
|
1564 |
*
|
1565 |
-
* @date
|
1566 |
-
* @since
|
1567 |
*
|
1568 |
-
* @param
|
1569 |
-
* @return
|
1570 |
*/
|
1571 |
function acf_prepare_field_for_import( $field ) {
|
1572 |
-
|
1573 |
/**
|
1574 |
* Filters the $field array before being returned to the import tool.
|
1575 |
*
|
1576 |
-
* @date
|
1577 |
-
* @since
|
1578 |
*
|
1579 |
-
* @param
|
1580 |
*/
|
1581 |
-
return apply_filters(
|
1582 |
}
|
1583 |
|
1584 |
// Register variation.
|
1585 |
-
acf_add_filter_variations( 'acf/prepare_field_for_import', array('type'), 0 );
|
1 |
+
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'fields' )->prop( 'multisite', true );
|
8 |
*
|
9 |
* Retrieves a field for the given identifier.
|
10 |
*
|
11 |
+
* @date 17/1/19
|
12 |
+
* @since 5.7.10
|
13 |
*
|
14 |
+
* @param (int|string) $id The field ID, key or name.
|
15 |
+
* @return (array|false) The field array.
|
16 |
*/
|
17 |
function acf_get_field( $id = 0 ) {
|
18 |
+
|
19 |
// Allow WP_Post to be passed.
|
20 |
+
if ( is_object( $id ) ) {
|
21 |
$id = $id->ID;
|
22 |
}
|
23 |
+
|
24 |
// Check store.
|
25 |
$store = acf_get_store( 'fields' );
|
26 |
+
if ( $store->has( $id ) ) {
|
27 |
return $store->get( $id );
|
28 |
}
|
29 |
+
|
30 |
// Check local fields first.
|
31 |
+
if ( acf_is_local_field( $id ) ) {
|
32 |
$field = acf_get_local_field( $id );
|
33 |
+
|
34 |
+
// Then check database.
|
35 |
} else {
|
36 |
$field = acf_get_raw_field( $id );
|
37 |
}
|
38 |
+
|
39 |
// Bail early if no field.
|
40 |
+
if ( ! $field ) {
|
41 |
return false;
|
42 |
}
|
43 |
+
|
44 |
// Validate field.
|
45 |
$field = acf_validate_field( $field );
|
46 |
+
|
47 |
// Set input prefix.
|
48 |
$field['prefix'] = 'acf';
|
49 |
+
|
50 |
/**
|
51 |
* Filters the $field array after it has been loaded.
|
52 |
*
|
53 |
+
* @date 12/02/2014
|
54 |
+
* @since 5.0.0
|
55 |
*
|
56 |
+
* @param array The field array.
|
57 |
*/
|
58 |
+
$field = apply_filters( 'acf/load_field', $field );
|
59 |
+
|
60 |
// Store field using aliasses to also find via key, ID and name.
|
61 |
$store->set( $field['key'], $field );
|
62 |
$store->alias( $field['key'], $field['ID'], $field['name'] );
|
63 |
+
|
64 |
// Return.
|
65 |
return $field;
|
66 |
}
|
67 |
|
68 |
// Register variation.
|
69 |
+
acf_add_filter_variations( 'acf/load_field', array( 'type', 'name', 'key' ), 0 );
|
70 |
|
71 |
/**
|
72 |
* acf_get_raw_field
|
73 |
*
|
74 |
* Retrieves raw field data for the given identifier.
|
75 |
*
|
76 |
+
* @date 18/1/19
|
77 |
+
* @since 5.7.10
|
78 |
*
|
79 |
+
* @param (int|string) $id The field ID, key or name.
|
80 |
+
* @return (array|false) The field array.
|
81 |
*/
|
82 |
function acf_get_raw_field( $id = 0 ) {
|
83 |
+
|
84 |
// Get raw field from database.
|
85 |
$post = acf_get_field_post( $id );
|
86 |
+
if ( ! $post ) {
|
87 |
return false;
|
88 |
}
|
89 |
+
|
90 |
// Bail early if incorrect post type.
|
91 |
+
if ( $post->post_type !== 'acf-field' ) {
|
92 |
return false;
|
93 |
}
|
94 |
+
|
95 |
// Unserialize post_content.
|
96 |
$field = (array) maybe_unserialize( $post->post_content );
|
97 |
+
|
98 |
// update attributes
|
99 |
+
$field['ID'] = $post->ID;
|
100 |
+
$field['key'] = $post->post_name;
|
101 |
+
$field['label'] = $post->post_title;
|
102 |
+
$field['name'] = $post->post_excerpt;
|
103 |
$field['menu_order'] = $post->menu_order;
|
104 |
+
$field['parent'] = $post->post_parent;
|
105 |
|
106 |
// Return field.
|
107 |
return $field;
|
112 |
*
|
113 |
* Retrieves the field's WP_Post object.
|
114 |
*
|
115 |
+
* @date 18/1/19
|
116 |
+
* @since 5.7.10
|
117 |
*
|
118 |
+
* @param (int|string) $id The field ID, key or name.
|
119 |
+
* @return (array|false) The field array.
|
120 |
*/
|
121 |
function acf_get_field_post( $id = 0 ) {
|
122 |
+
|
123 |
// Get post if numeric.
|
124 |
+
if ( is_numeric( $id ) ) {
|
125 |
return get_post( $id );
|
126 |
+
|
127 |
+
// Search posts if is string.
|
128 |
+
} elseif ( is_string( $id ) ) {
|
129 |
+
|
130 |
// Determine id type.
|
131 |
+
$type = acf_is_field_key( $id ) ? 'key' : 'name';
|
132 |
+
|
133 |
// Try cache.
|
134 |
$cache_key = acf_cache_key( "acf_get_field_post:$type:$id" );
|
135 |
+
$post_id = wp_cache_get( $cache_key, 'acf' );
|
136 |
+
if ( $post_id === false ) {
|
137 |
+
|
138 |
// Query posts.
|
139 |
+
$posts = get_posts(
|
140 |
+
array(
|
141 |
+
'posts_per_page' => 1,
|
142 |
+
'post_type' => 'acf-field',
|
143 |
+
'orderby' => 'menu_order title',
|
144 |
+
'order' => 'ASC',
|
145 |
+
'suppress_filters' => false,
|
146 |
+
'cache_results' => true,
|
147 |
+
'update_post_meta_cache' => false,
|
148 |
+
'update_post_term_cache' => false,
|
149 |
+
"acf_field_$type" => $id,
|
150 |
+
)
|
151 |
+
);
|
152 |
+
|
153 |
// Update $post_id with a non false value.
|
154 |
$post_id = $posts ? $posts[0]->ID : 0;
|
155 |
+
|
156 |
// Update cache.
|
157 |
wp_cache_set( $cache_key, $post_id, 'acf' );
|
158 |
}
|
159 |
+
|
160 |
// Check $post_id and return the post when possible.
|
161 |
+
if ( $post_id ) {
|
162 |
return get_post( $post_id );
|
163 |
}
|
164 |
}
|
165 |
+
|
166 |
// Return false by default.
|
167 |
return false;
|
168 |
}
|
172 |
*
|
173 |
* Returns true if the given identifier is a field key.
|
174 |
*
|
175 |
+
* @date 6/12/2013
|
176 |
+
* @since 5.0.0
|
177 |
*
|
178 |
+
* @param string $id The identifier.
|
179 |
+
* @return bool
|
180 |
*/
|
181 |
function acf_is_field_key( $id = '' ) {
|
182 |
+
|
183 |
// Check if $id is a string starting with "field_".
|
184 |
+
if ( is_string( $id ) && substr( $id, 0, 6 ) === 'field_' ) {
|
185 |
return true;
|
186 |
}
|
187 |
+
|
188 |
/**
|
189 |
* Filters whether the $id is a field key.
|
190 |
*
|
191 |
+
* @date 23/1/19
|
192 |
+
* @since 5.7.10
|
193 |
*
|
194 |
+
* @param bool $bool The result.
|
195 |
+
* @param string $id The identifier.
|
196 |
*/
|
197 |
return apply_filters( 'acf/is_field_key', false, $id );
|
198 |
}
|
202 |
*
|
203 |
* Ensures the given field valid.
|
204 |
*
|
205 |
+
* @date 18/1/19
|
206 |
+
* @since 5.7.10
|
207 |
*
|
208 |
+
* @param array $field The field array.
|
209 |
+
* @return array
|
210 |
*/
|
211 |
function acf_validate_field( $field = array() ) {
|
212 |
+
|
213 |
// Bail early if already valid.
|
214 |
+
if ( is_array( $field ) && ! empty( $field['_valid'] ) ) {
|
215 |
return $field;
|
216 |
}
|
217 |
+
|
218 |
// Apply defaults.
|
219 |
+
$field = wp_parse_args(
|
220 |
+
$field,
|
221 |
+
array(
|
222 |
+
'ID' => 0,
|
223 |
+
'key' => '',
|
224 |
+
'label' => '',
|
225 |
+
'name' => '',
|
226 |
+
'prefix' => '',
|
227 |
+
'type' => 'text',
|
228 |
+
'value' => null,
|
229 |
+
'menu_order' => 0,
|
230 |
+
'instructions' => '',
|
231 |
+
'required' => false,
|
232 |
+
'id' => '',
|
233 |
+
'class' => '',
|
234 |
+
'conditional_logic' => false,
|
235 |
+
'parent' => 0,
|
236 |
+
'wrapper' => array(),
|
237 |
+
// 'attributes' => array()
|
238 |
+
)
|
239 |
+
);
|
240 |
+
|
241 |
// Convert types.
|
242 |
+
$field['ID'] = (int) $field['ID'];
|
243 |
$field['menu_order'] = (int) $field['menu_order'];
|
244 |
+
|
245 |
// Add backwards compatibility for wrapper attributes.
|
246 |
// Todo: Remove need for this.
|
247 |
+
$field['wrapper'] = wp_parse_args(
|
248 |
+
$field['wrapper'],
|
249 |
+
array(
|
250 |
+
'width' => '',
|
251 |
+
'class' => '',
|
252 |
+
'id' => '',
|
253 |
+
)
|
254 |
+
);
|
255 |
+
|
256 |
// Store backups.
|
257 |
+
$field['_name'] = $field['name'];
|
258 |
$field['_valid'] = 1;
|
259 |
+
|
260 |
/**
|
261 |
* Filters the $field array to validate settings.
|
262 |
*
|
263 |
+
* @date 12/02/2014
|
264 |
+
* @since 5.0.0
|
265 |
*
|
266 |
+
* @param array $field The field array.
|
267 |
*/
|
268 |
+
$field = apply_filters( 'acf/validate_field', $field );
|
269 |
+
|
270 |
// return
|
271 |
return $field;
|
272 |
}
|
273 |
|
274 |
// Register variation.
|
275 |
+
acf_add_filter_variations( 'acf/validate_field', array( 'type' ), 0 );
|
276 |
|
277 |
/**
|
278 |
* acf_get_valid_field
|
279 |
*
|
280 |
* Ensures the given field valid.
|
281 |
*
|
282 |
+
* @date 28/09/13
|
283 |
+
* @since 5.0.0
|
284 |
*
|
285 |
+
* @param array $field The field array.
|
286 |
+
* @return array
|
287 |
*/
|
288 |
function acf_get_valid_field( $field = false ) {
|
289 |
return acf_validate_field( $field );
|
294 |
*
|
295 |
* Translates a field's settings.
|
296 |
*
|
297 |
+
* @date 8/03/2016
|
298 |
+
* @since 5.3.2
|
299 |
*
|
300 |
+
* @param array $field The field array.
|
301 |
+
* @return array
|
302 |
*/
|
303 |
function acf_translate_field( $field = array() ) {
|
304 |
+
|
305 |
// Get settings.
|
306 |
+
$l10n = acf_get_setting( 'l10n' );
|
307 |
+
$l10n_textdomain = acf_get_setting( 'l10n_textdomain' );
|
308 |
+
|
309 |
// Translate field settings if textdomain is set.
|
310 |
+
if ( $l10n && $l10n_textdomain ) {
|
311 |
+
|
312 |
+
$field['label'] = acf_translate( $field['label'] );
|
313 |
$field['instructions'] = acf_translate( $field['instructions'] );
|
314 |
+
|
315 |
/**
|
316 |
* Filters the $field array to translate strings.
|
317 |
*
|
318 |
+
* @date 12/02/2014
|
319 |
+
* @since 5.0.0
|
320 |
*
|
321 |
+
* @param array $field The field array.
|
322 |
*/
|
323 |
+
$field = apply_filters( 'acf/translate_field', $field );
|
324 |
}
|
325 |
+
|
326 |
// Return field.
|
327 |
return $field;
|
328 |
}
|
329 |
|
330 |
// Register variation.
|
331 |
+
acf_add_filter_variations( 'acf/translate_field', array( 'type' ), 0 );
|
332 |
|
333 |
// Translate fields passing through validation.
|
334 |
+
add_action( 'acf/validate_field', 'acf_translate_field' );
|
335 |
|
336 |
/**
|
337 |
* acf_get_fields
|
338 |
*
|
339 |
* Returns and array of fields for the given $parent.
|
340 |
*
|
341 |
+
* @date 30/09/13
|
342 |
+
* @since 5.0.0
|
343 |
*
|
344 |
+
* @param (int|string|array) $parent The field group or field settings. Also accepts the field group ID or key.
|
345 |
+
* @return array
|
346 |
*/
|
347 |
function acf_get_fields( $parent ) {
|
348 |
+
|
349 |
// Allow field group selector as $parent.
|
350 |
+
if ( ! is_array( $parent ) ) {
|
351 |
$parent = acf_get_field_group( $parent );
|
352 |
+
if ( ! $parent ) {
|
353 |
return array();
|
354 |
}
|
355 |
}
|
356 |
+
|
357 |
// Vars.
|
358 |
$fields = array();
|
359 |
+
|
360 |
// Check local fields first.
|
361 |
+
if ( acf_have_local_fields( $parent['key'] ) ) {
|
362 |
$raw_fields = acf_get_local_fields( $parent['key'] );
|
363 |
+
foreach ( $raw_fields as $raw_field ) {
|
364 |
$fields[] = acf_get_field( $raw_field['key'] );
|
365 |
}
|
366 |
+
|
367 |
+
// Then check database.
|
368 |
} else {
|
369 |
$raw_fields = acf_get_raw_fields( $parent['ID'] );
|
370 |
+
foreach ( $raw_fields as $raw_field ) {
|
371 |
$fields[] = acf_get_field( $raw_field['ID'] );
|
372 |
}
|
373 |
}
|
374 |
+
|
375 |
/**
|
376 |
* Filters the $fields array.
|
377 |
*
|
378 |
+
* @date 12/02/2014
|
379 |
+
* @since 5.0.0
|
380 |
*
|
381 |
+
* @param array $fields The array of fields.
|
382 |
*/
|
383 |
$fields = apply_filters( 'acf/load_fields', $fields, $parent );
|
384 |
+
|
385 |
// Return fields
|
386 |
+
return $fields;
|
387 |
}
|
388 |
|
389 |
/**
|
391 |
*
|
392 |
* Returns and array of raw field data for the given parent id.
|
393 |
*
|
394 |
+
* @date 18/1/19
|
395 |
+
* @since 5.7.10
|
396 |
*
|
397 |
+
* @param int $id The field group or field id.
|
398 |
+
* @return array
|
399 |
*/
|
400 |
function acf_get_raw_fields( $id = 0 ) {
|
401 |
+
|
402 |
// Try cache.
|
403 |
$cache_key = acf_cache_key( "acf_get_field_posts:$id" );
|
404 |
+
$post_ids = wp_cache_get( $cache_key, 'acf' );
|
405 |
+
if ( $post_ids === false ) {
|
406 |
+
|
407 |
// Query posts.
|
408 |
+
$posts = get_posts(
|
409 |
+
array(
|
410 |
+
'posts_per_page' => -1,
|
411 |
+
'post_type' => 'acf-field',
|
412 |
+
'orderby' => 'menu_order',
|
413 |
+
'order' => 'ASC',
|
414 |
+
'suppress_filters' => true, // DO NOT allow WPML to modify the query
|
415 |
+
'cache_results' => true,
|
416 |
+
'update_post_meta_cache' => false,
|
417 |
+
'update_post_term_cache' => false,
|
418 |
+
'post_parent' => $id,
|
419 |
+
'post_status' => array( 'publish', 'trash' ),
|
420 |
+
)
|
421 |
+
);
|
422 |
+
|
423 |
// Update $post_ids with a non false value.
|
424 |
$post_ids = array();
|
425 |
+
foreach ( $posts as $post ) {
|
426 |
$post_ids[] = $post->ID;
|
427 |
}
|
428 |
+
|
429 |
// Update cache.
|
430 |
wp_cache_set( $cache_key, $post_ids, 'acf' );
|
431 |
}
|
432 |
+
|
433 |
// Loop over ids and populate array of fields.
|
434 |
$fields = array();
|
435 |
+
foreach ( $post_ids as $post_id ) {
|
436 |
$fields[] = acf_get_raw_field( $post_id );
|
437 |
}
|
438 |
+
|
439 |
// Return fields.
|
440 |
return $fields;
|
441 |
}
|
445 |
*
|
446 |
* Return the number of fields for the given field group.
|
447 |
*
|
448 |
+
* @date 17/10/13
|
449 |
+
* @since 5.0.0
|
450 |
*
|
451 |
+
* @param array $parent The field group or field array.
|
452 |
+
* @return int
|
453 |
*/
|
454 |
function acf_get_field_count( $parent ) {
|
455 |
+
|
456 |
// Check local fields first.
|
457 |
+
if ( acf_have_local_fields( $parent['key'] ) ) {
|
458 |
$raw_fields = acf_get_local_fields( $parent['key'] );
|
459 |
+
|
460 |
+
// Then check database.
|
461 |
} else {
|
462 |
$raw_fields = acf_get_raw_fields( $parent['ID'] );
|
463 |
}
|
464 |
+
|
465 |
/**
|
466 |
* Filters the counted number of fields.
|
467 |
*
|
468 |
+
* @date 12/02/2014
|
469 |
+
* @since 5.0.0
|
470 |
*
|
471 |
+
* @param int $count The number of fields.
|
472 |
+
* @param array $parent The field group or field array.
|
473 |
*/
|
474 |
+
return apply_filters( 'acf/get_field_count', count( $raw_fields ), $parent );
|
475 |
}
|
476 |
|
477 |
/**
|
479 |
*
|
480 |
* Allows customization to a field when it is cloned. Used by the clone field.
|
481 |
*
|
482 |
+
* @date 8/03/2016
|
483 |
+
* @since 5.3.2
|
484 |
*
|
485 |
+
* @param array $field The field being cloned.
|
486 |
+
* @param array $clone_field The clone field.
|
487 |
+
* @return array
|
488 |
*/
|
489 |
function acf_clone_field( $field, $clone_field ) {
|
490 |
+
|
491 |
// Add reference to the clone field.
|
492 |
$field['_clone'] = $clone_field['key'];
|
493 |
+
|
494 |
/**
|
495 |
* Filters the $field array when it is being cloned.
|
496 |
*
|
497 |
+
* @date 12/02/2014
|
498 |
+
* @since 5.0.0
|
499 |
*
|
500 |
+
* @param array $field The field array.
|
501 |
+
* @param array $clone_field The clone field array.
|
502 |
*/
|
503 |
+
$field = apply_filters( 'acf/clone_field', $field, $clone_field );
|
504 |
+
|
505 |
// Return field.
|
506 |
return $field;
|
507 |
}
|
508 |
|
509 |
// Register variation.
|
510 |
+
acf_add_filter_variations( 'acf/clone_field', array( 'type' ), 0 );
|
511 |
|
512 |
/**
|
513 |
* acf_prepare_field
|
514 |
*
|
515 |
* Prepare a field for input.
|
516 |
*
|
517 |
+
* @date 20/1/19
|
518 |
+
* @since 5.7.10
|
519 |
*
|
520 |
+
* @param array $field The field array.
|
521 |
+
* @return array
|
522 |
*/
|
523 |
function acf_prepare_field( $field ) {
|
524 |
+
|
525 |
// Bail early if already prepared.
|
526 |
+
if ( ! empty( $field['_prepare'] ) ) {
|
527 |
return $field;
|
528 |
}
|
529 |
+
|
530 |
// Use field key to override input name.
|
531 |
+
if ( $field['key'] ) {
|
532 |
$field['name'] = $field['key'];
|
533 |
}
|
534 |
|
535 |
// Use field prefix to modify input name.
|
536 |
+
if ( $field['prefix'] ) {
|
537 |
$field['name'] = "{$field['prefix']}[{$field['name']}]";
|
538 |
}
|
539 |
+
|
540 |
// Generate id attribute from name.
|
541 |
$field['id'] = acf_idify( $field['name'] );
|
542 |
+
|
543 |
// Add state to field.
|
544 |
$field['_prepare'] = true;
|
545 |
+
|
546 |
/**
|
547 |
* Filters the $field array.
|
548 |
*
|
549 |
* Allows developers to modify field settings or return false to remove field.
|
550 |
*
|
551 |
+
* @date 12/02/2014
|
552 |
+
* @since 5.0.0
|
553 |
*
|
554 |
+
* @param array $field The field array.
|
555 |
*/
|
556 |
+
$field = apply_filters( 'acf/prepare_field', $field );
|
557 |
+
|
558 |
// return
|
559 |
return $field;
|
560 |
}
|
561 |
|
562 |
// Register variation.
|
563 |
+
acf_add_filter_variations( 'acf/prepare_field', array( 'type', 'name', 'key' ), 0 );
|
564 |
|
565 |
/**
|
566 |
* acf_render_fields
|
567 |
*
|
568 |
* Renders an array of fields. Also loads the field's value.
|
569 |
*
|
570 |
+
* @date 8/10/13
|
571 |
+
* @since 5.0.0
|
572 |
+
* @since 5.6.9 Changed parameter order.
|
573 |
*
|
574 |
+
* @param array $fields An array of fields.
|
575 |
+
* @param (int|string) $post_id The post ID to load values from.
|
576 |
+
* @param string $element The wrapping element type.
|
577 |
+
* @param string $instruction The instruction render position (label|field).
|
578 |
+
* @return void
|
579 |
*/
|
580 |
function acf_render_fields( $fields, $post_id = 0, $el = 'div', $instruction = 'label' ) {
|
581 |
+
|
582 |
// Parameter order changed in ACF 5.6.9.
|
583 |
+
if ( is_array( $post_id ) ) {
|
584 |
+
$args = func_get_args();
|
585 |
+
$fields = $args[1];
|
586 |
$post_id = $args[0];
|
587 |
}
|
588 |
+
|
589 |
/**
|
590 |
* Filters the $fields array before they are rendered.
|
591 |
*
|
592 |
+
* @date 12/02/2014
|
593 |
+
* @since 5.0.0
|
594 |
*
|
595 |
+
* @param array $fields An array of fields.
|
596 |
+
* @param (int|string) $post_id The post ID to load values from.
|
597 |
*/
|
598 |
$fields = apply_filters( 'acf/pre_render_fields', $fields, $post_id );
|
599 |
+
|
600 |
// Filter our false results.
|
601 |
$fields = array_filter( $fields );
|
602 |
+
|
603 |
// Loop over and render fields.
|
604 |
+
if ( $fields ) {
|
605 |
+
foreach ( $fields as $field ) {
|
606 |
+
|
607 |
// Load value if not already loaded.
|
608 |
+
if ( $field['value'] === null ) {
|
609 |
$field['value'] = acf_get_value( $post_id, $field );
|
610 |
+
}
|
611 |
+
|
612 |
// Render wrap.
|
613 |
acf_render_field_wrap( $field, $el, $instruction );
|
614 |
}
|
615 |
}
|
616 |
+
|
617 |
/**
|
618 |
* Fires after fields have been rendered.
|
619 |
*
|
620 |
+
* @date 12/02/2014
|
621 |
+
* @since 5.0.0
|
622 |
*
|
623 |
+
* @param array $fields An array of fields.
|
624 |
+
* @param (int|string) $post_id The post ID to load values from.
|
625 |
*/
|
626 |
do_action( 'acf/render_fields', $fields, $post_id );
|
627 |
}
|
631 |
*
|
632 |
* Render the wrapping element for a given field.
|
633 |
*
|
634 |
+
* @date 28/09/13
|
635 |
+
* @since 5.0.0
|
636 |
*
|
637 |
+
* @param array $field The field array.
|
638 |
+
* @param string $element The wrapping element type.
|
639 |
+
* @param string $instruction The instruction render position (label|field).
|
640 |
+
* @return void
|
641 |
*/
|
642 |
function acf_render_field_wrap( $field, $element = 'div', $instruction = 'label' ) {
|
643 |
+
|
644 |
// Ensure field is complete (adds all settings).
|
645 |
$field = acf_validate_field( $field );
|
646 |
+
|
647 |
// Prepare field for input (modifies settings).
|
648 |
$field = acf_prepare_field( $field );
|
649 |
+
|
650 |
// Allow filters to cancel render.
|
651 |
+
if ( ! $field ) {
|
652 |
return;
|
653 |
}
|
654 |
+
|
655 |
// Determine wrapping element.
|
656 |
$elements = array(
|
657 |
+
'div' => 'div',
|
658 |
+
'tr' => 'td',
|
659 |
+
'td' => 'div',
|
660 |
+
'ul' => 'li',
|
661 |
+
'ol' => 'li',
|
662 |
+
'dl' => 'dt',
|
663 |
);
|
664 |
+
|
665 |
+
if ( isset( $elements[ $element ] ) ) {
|
666 |
+
$inner_element = $elements[ $element ];
|
667 |
} else {
|
668 |
$element = $inner_element = 'div';
|
669 |
}
|
670 |
+
|
671 |
// Generate wrapper attributes.
|
672 |
$wrapper = array(
|
673 |
+
'id' => '',
|
674 |
+
'class' => 'acf-field',
|
675 |
+
'width' => '',
|
676 |
+
'style' => '',
|
677 |
+
'data-name' => $field['_name'],
|
678 |
+
'data-type' => $field['type'],
|
679 |
+
'data-key' => $field['key'],
|
680 |
);
|
681 |
+
|
682 |
// Add field type attributes.
|
683 |
$wrapper['class'] .= " acf-field-{$field['type']}";
|
684 |
+
|
685 |
// add field key attributes
|
686 |
+
if ( $field['key'] ) {
|
687 |
$wrapper['class'] .= " acf-field-{$field['key']}";
|
688 |
}
|
689 |
+
|
690 |
// Add required attributes.
|
691 |
// Todo: Remove data-required
|
692 |
+
if ( $field['required'] ) {
|
693 |
+
$wrapper['class'] .= ' is-required';
|
694 |
$wrapper['data-required'] = 1;
|
695 |
}
|
696 |
+
|
697 |
// Clean up class attribute.
|
698 |
$wrapper['class'] = str_replace( '_', '-', $wrapper['class'] );
|
699 |
$wrapper['class'] = str_replace( 'field-field-', 'field-', $wrapper['class'] );
|
700 |
+
|
701 |
// Merge in field 'wrapper' setting without destroying class and style.
|
702 |
+
if ( $field['wrapper'] ) {
|
703 |
$wrapper = acf_merge_attributes( $wrapper, $field['wrapper'] );
|
704 |
}
|
705 |
+
|
706 |
// Extract wrapper width and generate style.
|
707 |
// Todo: Move from $wrapper out into $field.
|
708 |
$width = acf_extract_var( $wrapper, 'width' );
|
709 |
+
if ( $width ) {
|
710 |
$width = acf_numval( $width );
|
711 |
+
if ( $element !== 'tr' && $element !== 'td' ) {
|
712 |
$wrapper['data-width'] = $width;
|
713 |
+
$wrapper['style'] .= " width:{$width}%;";
|
714 |
}
|
715 |
}
|
716 |
+
|
717 |
// Clean up all attributes.
|
718 |
$wrapper = array_map( 'trim', $wrapper );
|
719 |
$wrapper = array_filter( $wrapper );
|
720 |
+
|
721 |
/**
|
722 |
* Filters the $wrapper array before rendering.
|
723 |
*
|
724 |
+
* @date 21/1/19
|
725 |
+
* @since 5.7.10
|
726 |
*
|
727 |
+
* @param array $wrapper The wrapper attributes array.
|
728 |
+
* @param array $field The field array.
|
729 |
*/
|
730 |
$wrapper = apply_filters( 'acf/field_wrapper_attributes', $wrapper, $field );
|
731 |
+
|
732 |
// Append conditional logic attributes.
|
733 |
+
if ( ! empty( $field['conditional_logic'] ) ) {
|
734 |
$wrapper['data-conditions'] = $field['conditional_logic'];
|
735 |
}
|
736 |
+
if ( ! empty( $field['conditions'] ) ) {
|
737 |
$wrapper['data-conditions'] = $field['conditions'];
|
738 |
}
|
739 |
+
|
740 |
// Vars for render.
|
741 |
$attributes_html = acf_esc_attr( $wrapper );
|
742 |
+
|
743 |
// Render HTML
|
744 |
echo "<$element $attributes_html>" . "\n";
|
745 |
+
if ( $element !== 'td' ) {
|
746 |
+
echo "<$inner_element class=\"acf-label\">" . "\n";
|
747 |
+
acf_render_field_label( $field );
|
748 |
+
if ( $instruction == 'label' ) {
|
749 |
+
acf_render_field_instructions( $field );
|
|
|
|
|
750 |
}
|
751 |
+
echo "</$inner_element>" . "\n";
|
752 |
+
}
|
753 |
echo "<$inner_element class=\"acf-input\">" . "\n";
|
754 |
acf_render_field( $field );
|
755 |
+
if ( $instruction == 'field' ) {
|
756 |
+
acf_render_field_instructions( $field );
|
757 |
+
}
|
758 |
echo "</$inner_element>" . "\n";
|
759 |
echo "</$element>" . "\n";
|
760 |
}
|
764 |
*
|
765 |
* Render the input element for a given field.
|
766 |
*
|
767 |
+
* @date 21/1/19
|
768 |
+
* @since 5.7.10
|
769 |
*
|
770 |
+
* @param array $field The field array.
|
771 |
+
* @return void
|
772 |
*/
|
773 |
function acf_render_field( $field ) {
|
774 |
+
|
775 |
// Ensure field is complete (adds all settings).
|
776 |
$field = acf_validate_field( $field );
|
777 |
+
|
778 |
// Prepare field for input (modifies settings).
|
779 |
$field = acf_prepare_field( $field );
|
780 |
+
|
781 |
// Allow filters to cancel render.
|
782 |
+
if ( ! $field ) {
|
783 |
return;
|
784 |
}
|
785 |
+
|
786 |
/**
|
787 |
* Fires when rendering a field.
|
788 |
*
|
789 |
+
* @date 12/02/2014
|
790 |
+
* @since 5.0.0
|
791 |
*
|
792 |
+
* @param array $field The field array.
|
793 |
*/
|
794 |
+
do_action( 'acf/render_field', $field );
|
795 |
}
|
796 |
|
797 |
// Register variation.
|
798 |
+
acf_add_action_variations( 'acf/render_field', array( 'type', 'name', 'key' ), 0 );
|
799 |
|
800 |
/**
|
801 |
* acf_render_field_label
|
802 |
*
|
803 |
* Renders the field's label.
|
804 |
*
|
805 |
+
* @date 19/9/17
|
806 |
+
* @since 5.6.3
|
807 |
*
|
808 |
+
* @param array $field The field array.
|
809 |
+
* @return void
|
810 |
*/
|
811 |
function acf_render_field_label( $field ) {
|
812 |
+
|
813 |
// Get label.
|
814 |
$label = acf_get_field_label( $field );
|
815 |
+
|
816 |
// Output label.
|
817 |
+
if ( $label ) {
|
818 |
+
echo '<label' . ( $field['id'] ? ' for="' . esc_attr( $field['id'] ) . '"' : '' ) . '>' . acf_esc_html( $label ) . '</label>';
|
819 |
}
|
820 |
}
|
821 |
|
824 |
*
|
825 |
* Returns the field's label with appropriate required label.
|
826 |
*
|
827 |
+
* @date 4/11/2013
|
828 |
+
* @since 5.0.0
|
829 |
*
|
830 |
+
* @param array $field The field array.
|
831 |
+
* @param string $context The output context (admin).
|
832 |
+
* @return void
|
833 |
*/
|
834 |
function acf_get_field_label( $field, $context = '' ) {
|
835 |
+
|
836 |
// Get label.
|
837 |
$label = $field['label'];
|
838 |
+
|
839 |
// Display empty text when editing field.
|
840 |
+
if ( $context == 'admin' && $label === '' ) {
|
841 |
+
$label = __( '(no label)', 'acf' );
|
842 |
}
|
843 |
+
|
844 |
// Add required HTML.
|
845 |
+
if ( $field['required'] ) {
|
846 |
$label .= ' <span class="acf-required">*</span>';
|
847 |
}
|
848 |
+
|
849 |
/**
|
850 |
* Filters the field's label HTML.
|
851 |
*
|
852 |
+
* @date 21/1/19
|
853 |
+
* @since 5.7.10
|
854 |
*
|
855 |
+
* @param string The label HTML.
|
856 |
+
* @param array $field The field array.
|
857 |
+
* @param string $context The output context (admin).
|
858 |
*/
|
859 |
+
$label = apply_filters( 'acf/get_field_label', $label, $field, $context );
|
860 |
+
|
861 |
// Return label.
|
862 |
return $label;
|
863 |
}
|
867 |
*
|
868 |
* Renders the field's instructions.
|
869 |
*
|
870 |
+
* @date 19/9/17
|
871 |
+
* @since 5.6.3
|
872 |
*
|
873 |
+
* @param array $field The field array.
|
874 |
+
* @return void
|
875 |
*/
|
876 |
function acf_render_field_instructions( $field ) {
|
877 |
+
|
878 |
// Output instructions.
|
879 |
+
if ( $field['instructions'] ) {
|
880 |
+
echo '<p class="description">' . acf_esc_html( $field['instructions'] ) . '</p>';
|
881 |
}
|
882 |
}
|
883 |
|
886 |
*
|
887 |
* Renders a field setting used in the admin edit screen.
|
888 |
*
|
889 |
+
* @date 21/1/19
|
890 |
+
* @since 5.7.10
|
891 |
*
|
892 |
+
* @param array $field The field array.
|
893 |
+
* @param array $setting The settings field array.
|
894 |
+
* @param bool $global Whether this setting is a global or field type specific one.
|
895 |
+
* @return void
|
896 |
*/
|
897 |
function acf_render_field_setting( $field, $setting, $global = false ) {
|
898 |
+
|
899 |
// Validate field.
|
900 |
$setting = acf_validate_field( $setting );
|
901 |
+
|
902 |
// Add custom attributes to setting wrapper.
|
903 |
$setting['wrapper']['data-key'] = $setting['name'];
|
904 |
+
$setting['wrapper']['class'] .= ' acf-field-setting-' . $setting['name'];
|
905 |
+
if ( ! $global ) {
|
906 |
$setting['wrapper']['data-setting'] = $field['type'];
|
907 |
}
|
908 |
+
|
909 |
// Copy across prefix.
|
910 |
$setting['prefix'] = $field['prefix'];
|
911 |
+
|
912 |
// Find setting value from field.
|
913 |
+
if ( $setting['value'] === null ) {
|
914 |
+
|
915 |
// Name.
|
916 |
+
if ( isset( $field[ $setting['name'] ] ) ) {
|
917 |
$setting['value'] = $field[ $setting['name'] ];
|
918 |
+
|
919 |
+
// Default value.
|
920 |
+
} elseif ( isset( $setting['default_value'] ) ) {
|
921 |
$setting['value'] = $setting['default_value'];
|
922 |
}
|
923 |
}
|
924 |
+
|
925 |
// Add append attribute used by JS to join settings.
|
926 |
+
if ( isset( $setting['_append'] ) ) {
|
927 |
$setting['wrapper']['data-append'] = $setting['_append'];
|
928 |
}
|
929 |
+
|
930 |
// Render setting.
|
931 |
acf_render_field_wrap( $setting, 'tr', 'label' );
|
932 |
}
|
936 |
*
|
937 |
* Updates a field in the database.
|
938 |
*
|
939 |
+
* @date 21/1/19
|
940 |
+
* @since 5.7.10
|
941 |
*
|
942 |
+
* @param array $field The field array.
|
943 |
+
* @param array $specific An array of specific field attributes to update.
|
944 |
+
* @return void
|
945 |
*/
|
946 |
function acf_update_field( $field, $specific = array() ) {
|
947 |
+
|
948 |
// Validate field.
|
949 |
$field = acf_validate_field( $field );
|
950 |
+
|
951 |
// May have been posted. Remove slashes.
|
952 |
$field = wp_unslash( $field );
|
953 |
+
|
954 |
// Parse types (converts string '0' to int 0).
|
955 |
$field = acf_parse_types( $field );
|
956 |
+
|
957 |
// Clean up conditional logic keys.
|
958 |
+
if ( $field['conditional_logic'] ) {
|
959 |
+
|
960 |
// Remove empty values and convert to associated array.
|
961 |
$field['conditional_logic'] = array_filter( $field['conditional_logic'] );
|
962 |
$field['conditional_logic'] = array_values( $field['conditional_logic'] );
|
963 |
$field['conditional_logic'] = array_map( 'array_filter', $field['conditional_logic'] );
|
964 |
$field['conditional_logic'] = array_map( 'array_values', $field['conditional_logic'] );
|
965 |
}
|
966 |
+
|
967 |
// Parent may be provided as a field key.
|
968 |
+
if ( $field['parent'] && ! is_numeric( $field['parent'] ) ) {
|
969 |
+
$parent = acf_get_field_post( $field['parent'] );
|
970 |
$field['parent'] = $parent ? $parent->ID : 0;
|
971 |
}
|
972 |
+
|
973 |
/**
|
974 |
* Filters the $field array before it is updated.
|
975 |
*
|
976 |
+
* @date 12/02/2014
|
977 |
+
* @since 5.0.0
|
978 |
*
|
979 |
+
* @param array $field The field array.
|
980 |
*/
|
981 |
+
$field = apply_filters( 'acf/update_field', $field );
|
982 |
+
|
983 |
// Make a backup of field data and remove some args.
|
984 |
$_field = $field;
|
985 |
acf_extract_vars( $_field, array( 'ID', 'key', 'label', 'name', 'prefix', 'value', 'menu_order', 'id', 'class', 'parent', '_name', '_prepare', '_valid' ) );
|
986 |
+
|
987 |
// Create array of data to save.
|
988 |
$save = array(
|
989 |
+
'ID' => $field['ID'],
|
990 |
+
'post_status' => 'publish',
|
991 |
+
'post_type' => 'acf-field',
|
992 |
+
'post_title' => $field['label'],
|
993 |
+
'post_name' => $field['key'],
|
994 |
+
'post_excerpt' => $field['name'],
|
995 |
+
'post_content' => maybe_serialize( $_field ),
|
996 |
+
'post_parent' => $field['parent'],
|
997 |
+
'menu_order' => $field['menu_order'],
|
998 |
);
|
999 |
+
|
1000 |
// Reduce save data if specific key list is provided.
|
1001 |
+
if ( $specific ) {
|
1002 |
$specific[] = 'ID';
|
1003 |
+
$save = acf_get_sub_array( $save, $specific );
|
1004 |
}
|
1005 |
+
|
1006 |
// Unhook wp_targeted_link_rel() filter from WP 5.1 corrupting serialized data.
|
1007 |
remove_filter( 'content_save_pre', 'wp_targeted_link_rel' );
|
1008 |
+
|
1009 |
// Slash data.
|
1010 |
// WP expects all data to be slashed and will unslash it (fixes '\' character issues).
|
1011 |
$save = wp_slash( $save );
|
1012 |
+
|
1013 |
// Update or Insert.
|
1014 |
+
if ( $field['ID'] ) {
|
1015 |
wp_update_post( $save );
|
1016 |
+
} else {
|
1017 |
$field['ID'] = wp_insert_post( $save );
|
1018 |
}
|
1019 |
+
|
1020 |
// Flush field cache.
|
1021 |
acf_flush_field_cache( $field );
|
1022 |
+
|
1023 |
/**
|
1024 |
* Fires after a field has been updated, and the field cache has been cleaned.
|
1025 |
*
|
1026 |
+
* @date 24/1/19
|
1027 |
+
* @since 5.7.10
|
1028 |
*
|
1029 |
+
* @param array $field The field array.
|
1030 |
*/
|
1031 |
+
do_action( 'acf/updated_field', $field );
|
1032 |
+
|
1033 |
// Return field.
|
1034 |
return $field;
|
1035 |
}
|
1036 |
|
1037 |
// Register variation.
|
1038 |
+
acf_add_filter_variations( 'acf/update_field', array( 'type', 'name', 'key' ), 0 );
|
1039 |
|
1040 |
/**
|
1041 |
* _acf_apply_unique_field_slug
|
1042 |
*
|
1043 |
* Allows full control over 'acf-field' slugs.
|
1044 |
*
|
1045 |
+
* @date 21/1/19
|
1046 |
+
* @since 5.7.10
|
1047 |
*
|
1048 |
* @param string $slug The post slug.
|
1049 |
* @param int $post_ID Post ID.
|
1053 |
* @param string $original_slug The original post slug.
|
1054 |
*/
|
1055 |
function _acf_apply_unique_field_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
1056 |
+
|
1057 |
// Check post type and reset to original value.
|
1058 |
+
if ( $post_type === 'acf-field' ) {
|
1059 |
return $original_slug;
|
1060 |
}
|
1061 |
+
|
1062 |
// Return slug.
|
1063 |
return $slug;
|
1064 |
}
|
1071 |
*
|
1072 |
* Deletes all caches for this field.
|
1073 |
*
|
1074 |
+
* @date 22/1/19
|
1075 |
+
* @since 5.7.10
|
1076 |
*
|
1077 |
+
* @param array $field The field array.
|
1078 |
+
* @return void
|
1079 |
*/
|
1080 |
function acf_flush_field_cache( $field ) {
|
1081 |
+
|
1082 |
// Delete stored data.
|
1083 |
acf_get_store( 'fields' )->remove( $field['key'] );
|
1084 |
+
|
1085 |
// Flush cached post_id for this field's name and key.
|
1086 |
+
wp_cache_delete( acf_cache_key( "acf_get_field_post:name:{$field['name']}" ), 'acf' );
|
1087 |
+
wp_cache_delete( acf_cache_key( "acf_get_field_post:key:{$field['key']}" ), 'acf' );
|
1088 |
+
|
1089 |
// Flush cached array of post_ids for this field's parent.
|
1090 |
+
wp_cache_delete( acf_cache_key( "acf_get_field_posts:{$field['parent']}" ), 'acf' );
|
1091 |
}
|
1092 |
|
1093 |
/**
|
1095 |
*
|
1096 |
* Deletes a field from the database.
|
1097 |
*
|
1098 |
+
* @date 21/1/19
|
1099 |
+
* @since 5.7.10
|
1100 |
*
|
1101 |
+
* @param (int|string) $id The field ID, key or name.
|
1102 |
+
* @return bool True if field was deleted.
|
1103 |
*/
|
1104 |
function acf_delete_field( $id = 0 ) {
|
1105 |
+
|
1106 |
// Get the field.
|
1107 |
$field = acf_get_field( $id );
|
1108 |
+
|
1109 |
// Bail early if field was not found.
|
1110 |
+
if ( ! $field || ! $field['ID'] ) {
|
1111 |
return false;
|
1112 |
}
|
1113 |
+
|
1114 |
// Delete post.
|
1115 |
wp_delete_post( $field['ID'], true );
|
1116 |
+
|
1117 |
// Flush field cache.
|
1118 |
acf_flush_field_cache( $field );
|
1119 |
+
|
1120 |
/**
|
1121 |
* Fires immediately after a field has been deleted.
|
1122 |
*
|
1123 |
+
* @date 12/02/2014
|
1124 |
+
* @since 5.0.0
|
1125 |
*
|
1126 |
+
* @param array $field The field array.
|
1127 |
*/
|
1128 |
+
do_action( 'acf/delete_field', $field );
|
1129 |
+
|
1130 |
// Return true.
|
1131 |
return true;
|
1132 |
}
|
1133 |
|
1134 |
// Register variation.
|
1135 |
+
acf_add_action_variations( 'acf/delete_field', array( 'type', 'name', 'key' ), 0 );
|
1136 |
|
1137 |
/**
|
1138 |
* acf_trash_field
|
1139 |
*
|
1140 |
* Trashes a field from the database.
|
1141 |
*
|
1142 |
+
* @date 2/10/13
|
1143 |
+
* @since 5.0.0
|
1144 |
*
|
1145 |
+
* @param (int|string) $id The field ID, key or name.
|
1146 |
+
* @return bool True if field was trashed.
|
1147 |
*/
|
1148 |
function acf_trash_field( $id = 0 ) {
|
1149 |
+
|
1150 |
// Get the field.
|
1151 |
$field = acf_get_field( $id );
|
1152 |
+
|
1153 |
// Bail early if field was not found.
|
1154 |
+
if ( ! $field || ! $field['ID'] ) {
|
1155 |
return false;
|
1156 |
}
|
1157 |
+
|
1158 |
// Trash post.
|
1159 |
wp_trash_post( $field['ID'], true );
|
1160 |
+
|
1161 |
/**
|
1162 |
* Fires immediately after a field has been trashed.
|
1163 |
*
|
1164 |
+
* @date 12/02/2014
|
1165 |
+
* @since 5.0.0
|
1166 |
*
|
1167 |
+
* @param array $field The field array.
|
1168 |
*/
|
1169 |
do_action( 'acf/trash_field', $field );
|
1170 |
+
|
1171 |
// Return true.
|
1172 |
return true;
|
1173 |
}
|
1177 |
*
|
1178 |
* Restores a field from the trash.
|
1179 |
*
|
1180 |
+
* @date 2/10/13
|
1181 |
+
* @since 5.0.0
|
1182 |
*
|
1183 |
+
* @param (int|string) $id The field ID, key or name.
|
1184 |
+
* @return bool True if field was trashed.
|
1185 |
*/
|
1186 |
function acf_untrash_field( $id = 0 ) {
|
1187 |
+
|
1188 |
// Get the field.
|
1189 |
$field = acf_get_field( $id );
|
1190 |
+
|
1191 |
// Bail early if field was not found.
|
1192 |
+
if ( ! $field || ! $field['ID'] ) {
|
1193 |
return false;
|
1194 |
}
|
1195 |
+
|
1196 |
// Untrash post.
|
1197 |
wp_untrash_post( $field['ID'], true );
|
1198 |
+
|
1199 |
// Flush field cache.
|
1200 |
acf_flush_field_cache( $field );
|
1201 |
+
|
1202 |
/**
|
1203 |
* Fires immediately after a field has been trashed.
|
1204 |
*
|
1205 |
+
* @date 12/02/2014
|
1206 |
+
* @since 5.0.0
|
1207 |
*
|
1208 |
+
* @param array $field The field array.
|
1209 |
*/
|
1210 |
do_action( 'acf/untrash_field', $field );
|
1211 |
+
|
1212 |
// Return true.
|
1213 |
return true;
|
1214 |
}
|
1236 |
*
|
1237 |
* Changes the prefix for an array of fields by reference.
|
1238 |
*
|
1239 |
+
* @date 5/9/17
|
1240 |
+
* @since 5.6.0
|
1241 |
*
|
1242 |
+
* @param array $fields An array of fields.
|
1243 |
+
* @param string $prefix The new prefix.
|
1244 |
+
* @return void
|
1245 |
*/
|
1246 |
function acf_prefix_fields( &$fields, $prefix = 'acf' ) {
|
1247 |
+
|
1248 |
// Loopover fields.
|
1249 |
+
foreach ( $fields as &$field ) {
|
1250 |
+
|
1251 |
// Replace 'acf' with $prefix.
|
1252 |
+
$field['prefix'] = $prefix . substr( $field['prefix'], 3 );
|
1253 |
}
|
1254 |
}
|
1255 |
|
1256 |
/**
|
1257 |
* acf_get_sub_field
|
1258 |
*
|
1259 |
+
* Searches a field for sub fields matching the given selector.
|
1260 |
*
|
1261 |
+
* @date 21/1/19
|
1262 |
+
* @since 5.7.10
|
1263 |
*
|
1264 |
+
* @param (int|string) $id The field ID, key or name.
|
1265 |
+
* @param array $field The parent field array.
|
1266 |
+
* @return (array|false)
|
1267 |
*/
|
1268 |
function acf_get_sub_field( $id, $field ) {
|
1269 |
+
|
1270 |
// Vars.
|
1271 |
$sub_field = false;
|
1272 |
+
|
1273 |
// Search sub fields.
|
1274 |
+
if ( isset( $field['sub_fields'] ) ) {
|
1275 |
$sub_field = acf_search_fields( $id, $field['sub_fields'] );
|
1276 |
}
|
1277 |
+
|
1278 |
/**
|
1279 |
* Filters the $sub_field found.
|
1280 |
*
|
1281 |
+
* @date 12/02/2014
|
1282 |
+
* @since 5.0.0
|
1283 |
*
|
1284 |
+
* @param array $sub_field The found sub field array.
|
1285 |
+
* @param string $selector The selector used to search.
|
1286 |
+
* @param array $field The parent field array.
|
1287 |
*/
|
1288 |
+
$sub_field = apply_filters( 'acf/get_sub_field', $sub_field, $id, $field );
|
1289 |
+
|
1290 |
// return
|
1291 |
return $sub_field;
|
1292 |
+
|
1293 |
}
|
1294 |
|
1295 |
// Register variation.
|
1296 |
+
acf_add_filter_variations( 'acf/get_sub_field', array( 'type' ), 2 );
|
1297 |
|
1298 |
/**
|
1299 |
* acf_search_fields
|
1300 |
*
|
1301 |
* Searches an array of fields for one that matches the given identifier.
|
1302 |
*
|
1303 |
+
* @date 12/2/19
|
1304 |
+
* @since 5.7.11
|
1305 |
*
|
1306 |
+
* @param (int|string) $id The field ID, key or name.
|
1307 |
+
* @param array $haystack The array of fields.
|
1308 |
+
* @return (int|false)
|
1309 |
*/
|
1310 |
function acf_search_fields( $id, $fields ) {
|
1311 |
+
|
1312 |
// Loop over searchable keys in order of priority.
|
1313 |
// Important to search "name" on all fields before "_name" backup.
|
1314 |
+
foreach ( array( 'key', 'name', '_name', '__name' ) as $key ) {
|
1315 |
+
|
1316 |
// Loop over fields and compare.
|
1317 |
+
foreach ( $fields as $field ) {
|
1318 |
+
if ( isset( $field[ $key ] ) && $field[ $key ] === $id ) {
|
1319 |
return $field;
|
1320 |
}
|
1321 |
}
|
1322 |
}
|
1323 |
+
|
1324 |
// Return not found.
|
1325 |
return false;
|
1326 |
}
|
1330 |
*
|
1331 |
* Returns true if the given params match a field.
|
1332 |
*
|
1333 |
+
* @date 21/1/19
|
1334 |
+
* @since 5.7.10
|
1335 |
*
|
1336 |
+
* @param array $field The field array.
|
1337 |
+
* @param mixed $id An optional identifier to search for.
|
1338 |
+
* @return bool
|
1339 |
*/
|
1340 |
function acf_is_field( $field = false, $id = '' ) {
|
1341 |
+
return (
|
1342 |
+
is_array( $field )
|
1343 |
+
&& isset( $field['key'] )
|
1344 |
+
&& isset( $field['name'] )
|
1345 |
);
|
1346 |
}
|
1347 |
|
1350 |
*
|
1351 |
* Returns an array of ancestor field ID's or keys.
|
1352 |
*
|
1353 |
+
* @date 22/06/2016
|
1354 |
+
* @since 5.3.8
|
1355 |
*
|
1356 |
+
* @param array $field The field array.
|
1357 |
+
* @return array
|
1358 |
*/
|
1359 |
function acf_get_field_ancestors( $field ) {
|
1360 |
+
|
1361 |
// Vars.
|
1362 |
$ancestors = array();
|
1363 |
+
|
1364 |
// Loop over parents.
|
1365 |
+
while ( $field['parent'] && $field = acf_get_field( $field['parent'] ) ) {
|
1366 |
$ancestors[] = $field['ID'] ? $field['ID'] : $field['key'];
|
1367 |
}
|
1368 |
+
|
1369 |
// return
|
1370 |
return $ancestors;
|
1371 |
}
|
1375 |
*
|
1376 |
* Duplicate an array of fields.
|
1377 |
*
|
1378 |
+
* @date 16/06/2014
|
1379 |
+
* @since 5.0.0
|
1380 |
*
|
1381 |
+
* @param array $fields An array of fields.
|
1382 |
+
* @param int $parent_id The new parent ID.
|
1383 |
+
* @return array
|
1384 |
*/
|
1385 |
function acf_duplicate_fields( $fields = array(), $parent_id = 0 ) {
|
1386 |
|
1388 |
// - Needed to alter conditional logic rules
|
1389 |
// - Use usleep() to ensure unique keys.
|
1390 |
$keys = array();
|
1391 |
+
foreach ( $fields as $field ) {
|
1392 |
+
usleep( 1 );
|
1393 |
+
$keys[ $field['key'] ] = uniqid( 'field_' );
|
1394 |
}
|
1395 |
acf_append_data( 'generated_keys', $keys );
|
1396 |
|
1397 |
// Duplicate fields.
|
1398 |
+
foreach ( $fields as $field ) {
|
1399 |
+
$field_id = $field['ID'] ? $field['ID'] : $field['key'];
|
1400 |
$duplicates[] = acf_duplicate_field( $field_id, $parent_id );
|
1401 |
}
|
1402 |
+
|
1403 |
// Return.
|
1404 |
return $duplicates;
|
1405 |
}
|
1409 |
*
|
1410 |
* Duplicates a field.
|
1411 |
*
|
1412 |
+
* @date 16/06/2014
|
1413 |
+
* @since 5.0.0
|
1414 |
*
|
1415 |
+
* @param (int|string) $id The field ID, key or name.
|
1416 |
+
* @param int $parent_id The new parent ID.
|
1417 |
+
* @return bool True if field was duplicated.
|
1418 |
*/
|
1419 |
+
function acf_duplicate_field( $id = 0, $parent_id = 0 ) {
|
1420 |
+
|
1421 |
// Get the field.
|
1422 |
$field = acf_get_field( $id );
|
1423 |
+
|
1424 |
// Bail early if field was not found.
|
1425 |
+
if ( ! $field ) {
|
1426 |
return false;
|
1427 |
}
|
1428 |
+
|
1429 |
// Remove ID to avoid update.
|
1430 |
$field['ID'] = 0;
|
1431 |
+
|
1432 |
// Generate key.
|
1433 |
$keys = acf_get_data( 'generated_keys' );
|
1434 |
+
if ( isset( $keys[ $field['key'] ] ) ) {
|
1435 |
$field['key'] = $keys[ $field['key'] ];
|
1436 |
} else {
|
1437 |
+
$field['key'] = uniqid( 'field_' );
|
1438 |
}
|
1439 |
+
|
1440 |
// Set parent.
|
1441 |
+
if ( $parent_id ) {
|
1442 |
$field['parent'] = $parent_id;
|
1443 |
}
|
1444 |
+
|
1445 |
// Update conditional logic references because field keys have changed.
|
1446 |
+
if ( $field['conditional_logic'] ) {
|
1447 |
+
|
1448 |
// Loop over groups
|
1449 |
+
foreach ( $field['conditional_logic'] as $group_i => $group ) {
|
1450 |
+
|
1451 |
// Loop over rules
|
1452 |
+
foreach ( $group as $rule_i => $rule ) {
|
1453 |
+
$field['conditional_logic'][ $group_i ][ $rule_i ]['field'] = isset( $keys[ $rule['field'] ] ) ? $keys[ $rule['field'] ] : $rule['field'];
|
1454 |
}
|
1455 |
}
|
1456 |
}
|
1457 |
+
|
1458 |
/**
|
1459 |
* Filters the $field array after it has been duplicated.
|
1460 |
*
|
1461 |
+
* @date 12/02/2014
|
1462 |
+
* @since 5.0.0
|
1463 |
*
|
1464 |
+
* @param array $field The field array.
|
1465 |
*/
|
1466 |
+
$field = apply_filters( 'acf/duplicate_field', $field );
|
1467 |
+
|
1468 |
// Update and return.
|
1469 |
return acf_update_field( $field );
|
1470 |
}
|
1471 |
|
1472 |
// Register variation.
|
1473 |
+
acf_add_filter_variations( 'acf/duplicate_field', array( 'type' ), 0 );
|
1474 |
|
1475 |
/**
|
1476 |
* acf_prepare_fields_for_export
|
1477 |
*
|
1478 |
* Returns a modified array of fields ready for export.
|
1479 |
*
|
1480 |
+
* @date 11/03/2014
|
1481 |
+
* @since 5.0.0
|
1482 |
*
|
1483 |
+
* @param array $fields An array of fields.
|
1484 |
+
* @return array
|
1485 |
*/
|
1486 |
function acf_prepare_fields_for_export( $fields = array() ) {
|
1487 |
+
|
1488 |
// Map function and return.
|
1489 |
return array_map( 'acf_prepare_field_for_export', $fields );
|
1490 |
}
|
1494 |
*
|
1495 |
* Returns a modified field ready for export.
|
1496 |
*
|
1497 |
+
* @date 11/03/2014
|
1498 |
+
* @since 5.0.0
|
1499 |
*
|
1500 |
+
* @param array $field The field array.
|
1501 |
+
* @return array
|
1502 |
*/
|
1503 |
function acf_prepare_field_for_export( $field ) {
|
1504 |
+
|
1505 |
// Remove args.
|
1506 |
acf_extract_vars( $field, array( 'ID', 'prefix', 'value', 'menu_order', 'id', 'class', 'parent', '_name', '_prepare', '_valid' ) );
|
1507 |
+
|
1508 |
/**
|
1509 |
* Filters the $field array before being returned to the export tool.
|
1510 |
*
|
1511 |
+
* @date 12/02/2014
|
1512 |
+
* @since 5.0.0
|
1513 |
*
|
1514 |
+
* @param array $field The field array.
|
1515 |
*/
|
1516 |
+
return apply_filters( 'acf/prepare_field_for_export', $field );
|
1517 |
}
|
1518 |
|
1519 |
// Register variation.
|
1520 |
+
acf_add_filter_variations( 'acf/prepare_field_for_export', array( 'type' ), 0 );
|
1521 |
|
1522 |
/**
|
1523 |
* acf_prepare_field_for_import
|
1524 |
*
|
1525 |
* Returns a modified array of fields ready for import.
|
1526 |
*
|
1527 |
+
* @date 11/03/2014
|
1528 |
+
* @since 5.0.0
|
1529 |
*
|
1530 |
+
* @param array $fields An array of fields.
|
1531 |
+
* @return array
|
1532 |
*/
|
1533 |
function acf_prepare_fields_for_import( $fields = array() ) {
|
1534 |
+
|
1535 |
// Ensure array is sequential.
|
1536 |
+
$fields = array_values( $fields );
|
1537 |
+
|
1538 |
// Prepare each field for import making sure to detect additional sub fields.
|
1539 |
$i = 0;
|
1540 |
+
while ( $i < count( $fields ) ) {
|
1541 |
+
|
1542 |
// Prepare field.
|
1543 |
$field = acf_prepare_field_for_import( $fields[ $i ] );
|
1544 |
+
|
1545 |
// Update single field.
|
1546 |
+
if ( isset( $field['key'] ) ) {
|
1547 |
$fields[ $i ] = $field;
|
1548 |
+
|
1549 |
+
// Insert multiple fields.
|
1550 |
} else {
|
1551 |
array_splice( $fields, $i, 1, $field );
|
1552 |
}
|
1553 |
+
|
1554 |
// Iterate.
|
1555 |
$i++;
|
1556 |
}
|
1557 |
+
|
1558 |
/**
|
1559 |
* Filters the $fields array before being returned to the import tool.
|
1560 |
*
|
1561 |
+
* @date 12/02/2014
|
1562 |
+
* @since 5.0.0
|
1563 |
*
|
1564 |
+
* @param array $fields The array of fields.
|
1565 |
*/
|
1566 |
return apply_filters( 'acf/prepare_fields_for_import', $fields );
|
1567 |
}
|
1572 |
* Returns a modified field ready for import.
|
1573 |
* Allows parent fields to modify themselves and also return sub fields.
|
1574 |
*
|
1575 |
+
* @date 11/03/2014
|
1576 |
+
* @since 5.0.0
|
1577 |
*
|
1578 |
+
* @param array $field The field array.
|
1579 |
+
* @return array
|
1580 |
*/
|
1581 |
function acf_prepare_field_for_import( $field ) {
|
1582 |
+
|
1583 |
/**
|
1584 |
* Filters the $field array before being returned to the import tool.
|
1585 |
*
|
1586 |
+
* @date 12/02/2014
|
1587 |
+
* @since 5.0.0
|
1588 |
*
|
1589 |
+
* @param array $field The field array.
|
1590 |
*/
|
1591 |
+
return apply_filters( 'acf/prepare_field_for_import', $field );
|
1592 |
}
|
1593 |
|
1594 |
// Register variation.
|
1595 |
+
acf_add_filter_variations( 'acf/prepare_field_for_import', array( 'type' ), 0 );
|
includes/acf-field-group-functions.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'field-groups' )->prop( 'multisite', true );
|
@@ -8,56 +8,56 @@ acf_register_store( 'field-groups' )->prop( 'multisite', true );
|
|
8 |
*
|
9 |
* Retrieves a field group for the given identifier.
|
10 |
*
|
11 |
-
* @date
|
12 |
-
* @since
|
13 |
*
|
14 |
-
* @param
|
15 |
-
* @return
|
16 |
*/
|
17 |
function acf_get_field_group( $id = 0 ) {
|
18 |
-
|
19 |
// Allow WP_Post to be passed.
|
20 |
-
if( is_object($id) ) {
|
21 |
$id = $id->ID;
|
22 |
}
|
23 |
-
|
24 |
// Check store.
|
25 |
$store = acf_get_store( 'field-groups' );
|
26 |
-
if( $store->has( $id ) ) {
|
27 |
return $store->get( $id );
|
28 |
}
|
29 |
-
|
30 |
// Check local fields first.
|
31 |
-
if( acf_is_local_field_group($id) ) {
|
32 |
$field_group = acf_get_local_field_group( $id );
|
33 |
-
|
34 |
-
|
35 |
} else {
|
36 |
$field_group = acf_get_raw_field_group( $id );
|
37 |
}
|
38 |
-
|
39 |
// Bail early if no field group.
|
40 |
-
if(
|
41 |
return false;
|
42 |
}
|
43 |
-
|
44 |
// Validate field group.
|
45 |
$field_group = acf_validate_field_group( $field_group );
|
46 |
-
|
47 |
/**
|
48 |
* Filters the $field_group array after it has been loaded.
|
49 |
*
|
50 |
-
* @date
|
51 |
-
* @since
|
52 |
*
|
53 |
-
* @param
|
54 |
*/
|
55 |
$field_group = apply_filters( 'acf/load_field_group', $field_group );
|
56 |
-
|
57 |
// Store field group using aliasses to also find via key, ID and name.
|
58 |
$store->set( $field_group['key'], $field_group );
|
59 |
$store->alias( $field_group['key'], $field_group['ID'] );
|
60 |
-
|
61 |
// Return.
|
62 |
return $field_group;
|
63 |
}
|
@@ -67,34 +67,34 @@ function acf_get_field_group( $id = 0 ) {
|
|
67 |
*
|
68 |
* Retrieves raw field group data for the given identifier.
|
69 |
*
|
70 |
-
* @date
|
71 |
-
* @since
|
72 |
*
|
73 |
-
* @param
|
74 |
-
* @return
|
75 |
*/
|
76 |
function acf_get_raw_field_group( $id = 0 ) {
|
77 |
-
|
78 |
// Get raw field group from database.
|
79 |
$post = acf_get_field_group_post( $id );
|
80 |
-
if(
|
81 |
return false;
|
82 |
}
|
83 |
-
|
84 |
// Bail early if incorrect post type.
|
85 |
-
if( $post->post_type !== 'acf-field-group' ) {
|
86 |
return false;
|
87 |
}
|
88 |
-
|
89 |
// Unserialize post_content.
|
90 |
$field_group = (array) maybe_unserialize( $post->post_content );
|
91 |
-
|
92 |
// update attributes
|
93 |
-
$field_group['ID']
|
94 |
-
$field_group['title']
|
95 |
-
$field_group['key']
|
96 |
$field_group['menu_order'] = $post->menu_order;
|
97 |
-
$field_group['active']
|
98 |
|
99 |
// Return field.
|
100 |
return $field_group;
|
@@ -105,53 +105,55 @@ function acf_get_raw_field_group( $id = 0 ) {
|
|
105 |
*
|
106 |
* Retrieves the field group's WP_Post object.
|
107 |
*
|
108 |
-
* @date
|
109 |
-
* @since
|
110 |
*
|
111 |
-
* @param
|
112 |
-
* @return
|
113 |
*/
|
114 |
function acf_get_field_group_post( $id = 0 ) {
|
115 |
-
|
116 |
// Get post if numeric.
|
117 |
-
if( is_numeric($id) ) {
|
118 |
return get_post( $id );
|
119 |
-
|
120 |
-
|
121 |
-
} elseif( is_string($id) ) {
|
122 |
-
|
123 |
// Try cache.
|
124 |
$cache_key = acf_cache_key( "acf_get_field_group_post:key:$id" );
|
125 |
-
$post_id
|
126 |
-
if( $post_id === false ) {
|
127 |
-
|
128 |
// Query posts.
|
129 |
-
$posts = get_posts(
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
142 |
// Update $post_id with a non false value.
|
143 |
$post_id = $posts ? $posts[0]->ID : 0;
|
144 |
-
|
145 |
// Update cache.
|
146 |
wp_cache_set( $cache_key, $post_id, 'acf' );
|
147 |
}
|
148 |
-
|
149 |
// Check $post_id and return the post when possible.
|
150 |
-
if( $post_id ) {
|
151 |
return get_post( $post_id );
|
152 |
}
|
153 |
}
|
154 |
-
|
155 |
// Return false by default.
|
156 |
return false;
|
157 |
}
|
@@ -161,27 +163,27 @@ function acf_get_field_group_post( $id = 0 ) {
|
|
161 |
*
|
162 |
* Returns true if the given identifier is a field group key.
|
163 |
*
|
164 |
-
* @date
|
165 |
-
* @since
|
166 |
*
|
167 |
-
* @param
|
168 |
-
* @return
|
169 |
*/
|
170 |
function acf_is_field_group_key( $id = '' ) {
|
171 |
-
|
172 |
// Check if $id is a string starting with "group_".
|
173 |
-
if( is_string($id) && substr($id, 0, 6) === 'group_' ) {
|
174 |
return true;
|
175 |
}
|
176 |
-
|
177 |
/**
|
178 |
* Filters whether the $id is a field group key.
|
179 |
*
|
180 |
-
* @date
|
181 |
-
* @since
|
182 |
*
|
183 |
-
* @param
|
184 |
-
* @param
|
185 |
*/
|
186 |
return apply_filters( 'acf/is_field_group_key', false, $id );
|
187 |
}
|
@@ -191,54 +193,57 @@ function acf_is_field_group_key( $id = '' ) {
|
|
191 |
*
|
192 |
* Ensures the given field group is valid.
|
193 |
*
|
194 |
-
* @date
|
195 |
-
* @since
|
196 |
*
|
197 |
-
* @param
|
198 |
-
* @return
|
199 |
*/
|
200 |
function acf_validate_field_group( $field_group = array() ) {
|
201 |
-
|
202 |
// Bail early if already valid.
|
203 |
-
if( is_array($field_group) && !empty($field_group['_valid']) ) {
|
204 |
return $field_group;
|
205 |
}
|
206 |
-
|
207 |
// Apply defaults.
|
208 |
-
$field_group = wp_parse_args(
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
224 |
// Convert types.
|
225 |
-
$field_group['ID']
|
226 |
$field_group['menu_order'] = (int) $field_group['menu_order'];
|
227 |
-
$field_group['active']
|
228 |
-
|
229 |
// Field group is now valid.
|
230 |
$field_group['_valid'] = true;
|
231 |
-
|
232 |
/**
|
233 |
* Filters the $field_group array to validate settings.
|
234 |
*
|
235 |
-
* @date
|
236 |
-
* @since
|
237 |
*
|
238 |
-
* @param
|
239 |
*/
|
240 |
$field_group = apply_filters( 'acf/validate_field_group', $field_group );
|
241 |
-
|
242 |
// return
|
243 |
return $field_group;
|
244 |
}
|
@@ -248,11 +253,11 @@ function acf_validate_field_group( $field_group = array() ) {
|
|
248 |
*
|
249 |
* Ensures the given field group is valid.
|
250 |
*
|
251 |
-
* @date
|
252 |
-
* @since
|
253 |
*
|
254 |
-
* @param
|
255 |
-
* @return
|
256 |
*/
|
257 |
function acf_get_valid_field_group( $field_group = false ) {
|
258 |
return acf_validate_field_group( $field_group );
|
@@ -263,40 +268,40 @@ function acf_get_valid_field_group( $field_group = false ) {
|
|
263 |
*
|
264 |
* Translates a field group's settings.
|
265 |
*
|
266 |
-
* @date
|
267 |
-
* @since
|
268 |
*
|
269 |
-
* @param
|
270 |
-
* @return
|
271 |
*/
|
272 |
function acf_translate_field_group( $field_group = array() ) {
|
273 |
-
|
274 |
// Get settings.
|
275 |
-
$l10n
|
276 |
-
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
277 |
-
|
278 |
// Translate field settings if textdomain is set.
|
279 |
-
if( $l10n && $l10n_textdomain ) {
|
280 |
-
|
281 |
$field_group['title'] = acf_translate( $field_group['title'] );
|
282 |
-
|
283 |
/**
|
284 |
* Filters the $field group array to translate strings.
|
285 |
*
|
286 |
-
* @date
|
287 |
-
* @since
|
288 |
*
|
289 |
-
* @param
|
290 |
*/
|
291 |
-
$field_group = apply_filters(
|
292 |
}
|
293 |
-
|
294 |
// Return field.
|
295 |
return $field_group;
|
296 |
}
|
297 |
|
298 |
// Translate field groups passing through validation.
|
299 |
-
add_action('acf/validate_field_group', 'acf_translate_field_group');
|
300 |
|
301 |
|
302 |
/**
|
@@ -304,40 +309,40 @@ add_action('acf/validate_field_group', 'acf_translate_field_group');
|
|
304 |
*
|
305 |
* Returns and array of field_groups for the given $filter.
|
306 |
*
|
307 |
-
* @date
|
308 |
-
* @since
|
309 |
*
|
310 |
-
* @param
|
311 |
-
* @return
|
312 |
*/
|
313 |
function acf_get_field_groups( $filter = array() ) {
|
314 |
-
|
315 |
// Vars.
|
316 |
$field_groups = array();
|
317 |
-
|
318 |
// Check database.
|
319 |
$raw_field_groups = acf_get_raw_field_groups();
|
320 |
-
if( $raw_field_groups ) {
|
321 |
-
foreach( $raw_field_groups as $raw_field_group ) {
|
322 |
$field_groups[] = acf_get_field_group( $raw_field_group['ID'] );
|
323 |
}
|
324 |
}
|
325 |
-
|
326 |
/**
|
327 |
* Filters the $field_groups array.
|
328 |
*
|
329 |
-
* @date
|
330 |
-
* @since
|
331 |
*
|
332 |
-
* @param
|
333 |
*/
|
334 |
$field_groups = apply_filters( 'acf/load_field_groups', $field_groups );
|
335 |
-
|
336 |
// Filter results.
|
337 |
-
if( $filter ) {
|
338 |
return acf_filter_field_groups( $field_groups, $filter );
|
339 |
}
|
340 |
-
|
341 |
// Return field groups.
|
342 |
return $field_groups;
|
343 |
}
|
@@ -347,48 +352,50 @@ function acf_get_field_groups( $filter = array() ) {
|
|
347 |
*
|
348 |
* Returns and array of raw field_group data.
|
349 |
*
|
350 |
-
* @date
|
351 |
-
* @since
|
352 |
*
|
353 |
-
* @param
|
354 |
-
* @return
|
355 |
*/
|
356 |
function acf_get_raw_field_groups() {
|
357 |
-
|
358 |
// Try cache.
|
359 |
-
$cache_key = acf_cache_key(
|
360 |
-
$post_ids
|
361 |
-
if( $post_ids === false ) {
|
362 |
-
|
363 |
// Query posts.
|
364 |
-
$posts = get_posts(
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
|
|
376 |
// Update $post_ids with a non false value.
|
377 |
$post_ids = array();
|
378 |
-
foreach( $posts as $post ) {
|
379 |
$post_ids[] = $post->ID;
|
380 |
}
|
381 |
-
|
382 |
// Update cache.
|
383 |
wp_cache_set( $cache_key, $post_ids, 'acf' );
|
384 |
}
|
385 |
-
|
386 |
// Loop over ids and populate array of field groups.
|
387 |
$field_groups = array();
|
388 |
-
foreach( $post_ids as $post_id ) {
|
389 |
$field_groups[] = acf_get_raw_field_group( $post_id );
|
390 |
}
|
391 |
-
|
392 |
// Return field groups.
|
393 |
return $field_groups;
|
394 |
}
|
@@ -398,25 +405,25 @@ function acf_get_raw_field_groups() {
|
|
398 |
*
|
399 |
* Returns a filtered aray of field groups based on the given $args.
|
400 |
*
|
401 |
-
* @date
|
402 |
-
* @since
|
403 |
*
|
404 |
-
* @param
|
405 |
-
* @param
|
406 |
-
* @return
|
407 |
*/
|
408 |
function acf_filter_field_groups( $field_groups, $args = array() ) {
|
409 |
-
|
410 |
// Loop over field groups and check visibility.
|
411 |
$filtered = array();
|
412 |
-
if( $field_groups ) {
|
413 |
-
foreach( $field_groups as $field_group ) {
|
414 |
-
if( acf_get_field_group_visibility( $field_group, $args ) ) {
|
415 |
$filtered[] = $field_group;
|
416 |
}
|
417 |
}
|
418 |
}
|
419 |
-
|
420 |
// Return filtered.
|
421 |
return $filtered;
|
422 |
}
|
@@ -426,50 +433,50 @@ function acf_filter_field_groups( $field_groups, $args = array() ) {
|
|
426 |
*
|
427 |
* Returns true if the given field group's location rules match the given $args.
|
428 |
*
|
429 |
-
* @date
|
430 |
-
* @since
|
431 |
*
|
432 |
-
* @param
|
433 |
-
* @param
|
434 |
-
* @return
|
435 |
*/
|
436 |
function acf_get_field_group_visibility( $field_group, $args = array() ) {
|
437 |
-
|
438 |
// Check if active.
|
439 |
-
if(
|
440 |
return false;
|
441 |
}
|
442 |
-
|
443 |
// Check if location rules exist
|
444 |
-
if( $field_group['location'] ) {
|
445 |
-
|
446 |
// Get the current screen.
|
447 |
$screen = acf_get_location_screen( $args );
|
448 |
-
|
449 |
// Loop through location groups.
|
450 |
-
foreach( $field_group['location'] as $group ) {
|
451 |
-
|
452 |
// ignore group if no rules.
|
453 |
-
if( empty($group) ) {
|
454 |
continue;
|
455 |
}
|
456 |
-
|
457 |
// Loop over rules and determine if all rules match.
|
458 |
$match_group = true;
|
459 |
-
foreach( $group as $rule ) {
|
460 |
-
if( !acf_match_location_rule( $rule, $screen, $field_group ) ) {
|
461 |
$match_group = false;
|
462 |
break;
|
463 |
}
|
464 |
}
|
465 |
-
|
466 |
// If this group matches, show the field group.
|
467 |
-
if( $match_group ) {
|
468 |
return true;
|
469 |
}
|
470 |
}
|
471 |
}
|
472 |
-
|
473 |
// Return default.
|
474 |
return false;
|
475 |
}
|
@@ -479,78 +486,78 @@ function acf_get_field_group_visibility( $field_group, $args = array() ) {
|
|
479 |
*
|
480 |
* Updates a field group in the database.
|
481 |
*
|
482 |
-
* @date
|
483 |
-
* @since
|
484 |
*
|
485 |
-
* @param
|
486 |
-
* @return
|
487 |
*/
|
488 |
function acf_update_field_group( $field_group ) {
|
489 |
-
|
490 |
// Validate field group.
|
491 |
$field_group = acf_get_valid_field_group( $field_group );
|
492 |
-
|
493 |
// May have been posted. Remove slashes.
|
494 |
$field_group = wp_unslash( $field_group );
|
495 |
-
|
496 |
// Parse types (converts string '0' to int 0).
|
497 |
$field_group = acf_parse_types( $field_group );
|
498 |
-
|
499 |
// Clean up location keys.
|
500 |
-
if( $field_group['location'] ) {
|
501 |
-
|
502 |
// Remove empty values and convert to associated array.
|
503 |
$field_group['location'] = array_filter( $field_group['location'] );
|
504 |
$field_group['location'] = array_values( $field_group['location'] );
|
505 |
$field_group['location'] = array_map( 'array_filter', $field_group['location'] );
|
506 |
$field_group['location'] = array_map( 'array_values', $field_group['location'] );
|
507 |
}
|
508 |
-
|
509 |
// Make a backup of field group data and remove some args.
|
510 |
$_field_group = $field_group;
|
511 |
acf_extract_vars( $_field_group, array( 'ID', 'key', 'title', 'menu_order', 'fields', 'active', '_valid' ) );
|
512 |
-
|
513 |
// Create array of data to save.
|
514 |
$save = array(
|
515 |
-
'ID'
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
);
|
526 |
-
|
527 |
// Unhook wp_targeted_link_rel() filter from WP 5.1 corrupting serialized data.
|
528 |
remove_filter( 'content_save_pre', 'wp_targeted_link_rel' );
|
529 |
-
|
530 |
// Slash data.
|
531 |
// WP expects all data to be slashed and will unslash it (fixes '\' character issues).
|
532 |
$save = wp_slash( $save );
|
533 |
-
|
534 |
// Update or Insert.
|
535 |
-
if( $field_group['ID'] ) {
|
536 |
wp_update_post( $save );
|
537 |
-
} else
|
538 |
$field_group['ID'] = wp_insert_post( $save );
|
539 |
}
|
540 |
-
|
541 |
// Flush field group cache.
|
542 |
-
acf_flush_field_group_cache( $field_group );
|
543 |
-
|
544 |
/**
|
545 |
* Fires immediately after a field group has been updated.
|
546 |
*
|
547 |
-
* @date
|
548 |
-
* @since
|
549 |
*
|
550 |
-
* @param
|
551 |
*/
|
552 |
do_action( 'acf/update_field_group', $field_group );
|
553 |
-
|
554 |
// Return field group.
|
555 |
return $field_group;
|
556 |
}
|
@@ -560,8 +567,8 @@ function acf_update_field_group( $field_group ) {
|
|
560 |
*
|
561 |
* Allows full control over 'acf-field-group' slugs.
|
562 |
*
|
563 |
-
* @date
|
564 |
-
* @since
|
565 |
*
|
566 |
* @param string $slug The post slug.
|
567 |
* @param int $post_ID Post ID.
|
@@ -571,12 +578,12 @@ function acf_update_field_group( $field_group ) {
|
|
571 |
* @param string $original_slug The original post slug.
|
572 |
*/
|
573 |
function _acf_apply_unique_field_group_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
574 |
-
|
575 |
// Check post type and reset to original value.
|
576 |
-
if( $post_type === 'acf-field-group' ) {
|
577 |
return $original_slug;
|
578 |
}
|
579 |
-
|
580 |
// Return slug.
|
581 |
return $slug;
|
582 |
}
|
@@ -589,22 +596,22 @@ add_filter( 'wp_unique_post_slug', '_acf_apply_unique_field_group_slug', 999, 6
|
|
589 |
*
|
590 |
* Deletes all caches for this field group.
|
591 |
*
|
592 |
-
* @date
|
593 |
-
* @since
|
594 |
*
|
595 |
-
* @param
|
596 |
-
* @return
|
597 |
*/
|
598 |
function acf_flush_field_group_cache( $field_group ) {
|
599 |
-
|
600 |
// Delete stored data.
|
601 |
acf_get_store( 'field-groups' )->remove( $field_group['key'] );
|
602 |
-
|
603 |
// Flush cached post_id for this field group's key.
|
604 |
wp_cache_delete( acf_cache_key( "acf_get_field_group_post:key:{$field_group['key']}" ), 'acf' );
|
605 |
-
|
606 |
// Flush cached array of post_ids for collection of field groups.
|
607 |
-
wp_cache_delete( acf_cache_key(
|
608 |
}
|
609 |
|
610 |
/**
|
@@ -612,49 +619,49 @@ function acf_flush_field_group_cache( $field_group ) {
|
|
612 |
*
|
613 |
* Deletes a field group from the database.
|
614 |
*
|
615 |
-
* @date
|
616 |
-
* @since
|
617 |
*
|
618 |
-
* @param
|
619 |
-
* @return
|
620 |
*/
|
621 |
function acf_delete_field_group( $id = 0 ) {
|
622 |
-
|
623 |
// Disable filters to ensure ACF loads data from DB.
|
624 |
acf_disable_filters();
|
625 |
-
|
626 |
// Get the field_group.
|
627 |
$field_group = acf_get_field_group( $id );
|
628 |
-
|
629 |
// Bail early if field group was not found.
|
630 |
-
if(
|
631 |
return false;
|
632 |
}
|
633 |
-
|
634 |
// Delete fields.
|
635 |
$fields = acf_get_fields( $field_group );
|
636 |
-
if( $fields ) {
|
637 |
-
foreach( $fields as $field ) {
|
638 |
acf_delete_field( $field['ID'] );
|
639 |
}
|
640 |
}
|
641 |
-
|
642 |
// Delete post.
|
643 |
wp_delete_post( $field_group['ID'], true );
|
644 |
-
|
645 |
// Flush field group cache.
|
646 |
acf_flush_field_group_cache( $field_group );
|
647 |
-
|
648 |
/**
|
649 |
* Fires immediately after a field group has been deleted.
|
650 |
*
|
651 |
-
* @date
|
652 |
-
* @since
|
653 |
*
|
654 |
-
* @param
|
655 |
*/
|
656 |
do_action( 'acf/delete_field_group', $field_group );
|
657 |
-
|
658 |
// Return true.
|
659 |
return true;
|
660 |
}
|
@@ -664,49 +671,49 @@ function acf_delete_field_group( $id = 0 ) {
|
|
664 |
*
|
665 |
* Trashes a field group from the database.
|
666 |
*
|
667 |
-
* @date
|
668 |
-
* @since
|
669 |
*
|
670 |
-
* @param
|
671 |
-
* @return
|
672 |
*/
|
673 |
function acf_trash_field_group( $id = 0 ) {
|
674 |
-
|
675 |
// Disable filters to ensure ACF loads data from DB.
|
676 |
acf_disable_filters();
|
677 |
-
|
678 |
// Get the field_group.
|
679 |
$field_group = acf_get_field_group( $id );
|
680 |
-
|
681 |
// Bail early if field_group was not found.
|
682 |
-
if(
|
683 |
return false;
|
684 |
}
|
685 |
-
|
686 |
// Trash fields.
|
687 |
$fields = acf_get_fields( $field_group );
|
688 |
-
if( $fields ) {
|
689 |
-
foreach( $fields as $field ) {
|
690 |
acf_trash_field( $field['ID'] );
|
691 |
}
|
692 |
}
|
693 |
-
|
694 |
// Trash post.
|
695 |
wp_trash_post( $field_group['ID'], true );
|
696 |
-
|
697 |
// Flush field group cache.
|
698 |
acf_flush_field_group_cache( $field_group );
|
699 |
-
|
700 |
/**
|
701 |
* Fires immediately after a field_group has been trashed.
|
702 |
*
|
703 |
-
* @date
|
704 |
-
* @since
|
705 |
*
|
706 |
-
* @param
|
707 |
*/
|
708 |
do_action( 'acf/trash_field_group', $field_group );
|
709 |
-
|
710 |
// Return true.
|
711 |
return true;
|
712 |
}
|
@@ -716,49 +723,49 @@ function acf_trash_field_group( $id = 0 ) {
|
|
716 |
*
|
717 |
* Restores a field_group from the trash.
|
718 |
*
|
719 |
-
* @date
|
720 |
-
* @since
|
721 |
*
|
722 |
-
* @param
|
723 |
-
* @return
|
724 |
*/
|
725 |
function acf_untrash_field_group( $id = 0 ) {
|
726 |
-
|
727 |
// Disable filters to ensure ACF loads data from DB.
|
728 |
acf_disable_filters();
|
729 |
-
|
730 |
// Get the field_group.
|
731 |
$field_group = acf_get_field_group( $id );
|
732 |
-
|
733 |
// Bail early if field_group was not found.
|
734 |
-
if(
|
735 |
return false;
|
736 |
}
|
737 |
-
|
738 |
// Untrash fields.
|
739 |
$fields = acf_get_fields( $field_group );
|
740 |
-
if( $fields ) {
|
741 |
-
foreach( $fields as $field ) {
|
742 |
acf_untrash_field( $field['ID'] );
|
743 |
}
|
744 |
}
|
745 |
-
|
746 |
// Untrash post.
|
747 |
wp_untrash_post( $field_group['ID'], true );
|
748 |
-
|
749 |
// Flush field group cache.
|
750 |
acf_flush_field_group_cache( $field_group );
|
751 |
-
|
752 |
/**
|
753 |
* Fires immediately after a field_group has been trashed.
|
754 |
*
|
755 |
-
* @date
|
756 |
-
* @since
|
757 |
*
|
758 |
-
* @param
|
759 |
*/
|
760 |
do_action( 'acf/untrash_field_group', $field_group );
|
761 |
-
|
762 |
// Return true.
|
763 |
return true;
|
764 |
}
|
@@ -786,18 +793,18 @@ add_action( 'wp_untrash_post_status', '_acf_untrash_field_group_post_status', 10
|
|
786 |
*
|
787 |
* Returns true if the given params match a field group.
|
788 |
*
|
789 |
-
* @date
|
790 |
-
* @since
|
791 |
*
|
792 |
-
* @param
|
793 |
-
* @param
|
794 |
-
* @return
|
795 |
*/
|
796 |
function acf_is_field_group( $field_group = false ) {
|
797 |
-
return (
|
798 |
-
is_array($field_group)
|
799 |
-
&& isset($field_group['key'])
|
800 |
-
&& isset($field_group['title'])
|
801 |
);
|
802 |
}
|
803 |
|
@@ -806,60 +813,60 @@ function acf_is_field_group( $field_group = false ) {
|
|
806 |
*
|
807 |
* Duplicates a field group.
|
808 |
*
|
809 |
-
* @date
|
810 |
-
* @since
|
811 |
*
|
812 |
-
* @param
|
813 |
-
* @param
|
814 |
-
* @return
|
815 |
*/
|
816 |
-
function acf_duplicate_field_group( $id = 0, $new_post_id = 0 ){
|
817 |
-
|
818 |
// Disable filters to ensure ACF loads data from DB.
|
819 |
acf_disable_filters();
|
820 |
-
|
821 |
// Get the field_group.
|
822 |
$field_group = acf_get_field_group( $id );
|
823 |
-
|
824 |
// Bail early if field_group was not found.
|
825 |
-
if(
|
826 |
return false;
|
827 |
}
|
828 |
-
|
829 |
// Get fields.
|
830 |
$fields = acf_get_fields( $field_group );
|
831 |
-
|
832 |
// Update attributes.
|
833 |
-
$field_group['ID']
|
834 |
-
$field_group['key'] = uniqid('group_');
|
835 |
-
|
836 |
// Add (copy) to title when apropriate.
|
837 |
-
if(
|
838 |
-
$field_group['title'] .= ' (' . __(
|
839 |
}
|
840 |
-
|
841 |
// When importing a new field group, insert a temporary post and set the field group's ID.
|
842 |
// This allows fields to be updated before the field group (field group ID is needed for field parent setting).
|
843 |
-
if(
|
844 |
$field_group['ID'] = wp_insert_post( array( 'post_title' => $field_group['key'] ) );
|
845 |
}
|
846 |
-
|
847 |
// Duplicate fields.
|
848 |
$duplicates = acf_duplicate_fields( $fields, $field_group['ID'] );
|
849 |
-
|
850 |
// Save field group.
|
851 |
$field_group = acf_update_field_group( $field_group );
|
852 |
-
|
853 |
/**
|
854 |
* Fires immediately after a field_group has been duplicated.
|
855 |
*
|
856 |
-
* @date
|
857 |
-
* @since
|
858 |
*
|
859 |
-
* @param
|
860 |
*/
|
861 |
do_action( 'acf/duplicate_field_group', $field_group );
|
862 |
-
|
863 |
// return
|
864 |
return $field_group;
|
865 |
}
|
@@ -869,57 +876,57 @@ function acf_duplicate_field_group( $id = 0, $new_post_id = 0 ){
|
|
869 |
*
|
870 |
* Returns the CSS styles generated from field group settings.
|
871 |
*
|
872 |
-
* @date
|
873 |
-
* @since
|
874 |
*
|
875 |
-
* @param
|
876 |
-
* @return
|
877 |
*/
|
878 |
function acf_get_field_group_style( $field_group ) {
|
879 |
-
|
880 |
// Vars.
|
881 |
-
$style
|
882 |
$elements = array(
|
883 |
-
'permalink'
|
884 |
-
'the_content'
|
885 |
-
'excerpt'
|
886 |
-
'custom_fields'
|
887 |
-
'discussion'
|
888 |
-
'comments'
|
889 |
-
'slug'
|
890 |
-
'author'
|
891 |
-
'format'
|
892 |
-
'page_attributes'
|
893 |
-
'featured_image'
|
894 |
-
'revisions'
|
895 |
-
'categories'
|
896 |
-
'tags'
|
897 |
-
'send-trackbacks'
|
898 |
);
|
899 |
-
|
900 |
// Loop over field group settings and generate list of selectors to hide.
|
901 |
-
if( is_array($field_group['hide_on_screen']) ) {
|
902 |
$hide = array();
|
903 |
-
foreach( $field_group['hide_on_screen'] as $k ) {
|
904 |
-
if( isset($elements[ $k ]) ) {
|
905 |
-
$id
|
906 |
$hide[] = $id;
|
907 |
-
$hide[] = '#screen-meta label[for=' . substr($id, 1) . '-hide]';
|
908 |
}
|
909 |
}
|
910 |
-
$style = implode(', ', $hide) . ' {display: none;}';
|
911 |
}
|
912 |
-
|
913 |
/**
|
914 |
* Filters the generated CSS styles.
|
915 |
*
|
916 |
-
* @date
|
917 |
-
* @since
|
918 |
*
|
919 |
-
* @param
|
920 |
-
* @param
|
921 |
*/
|
922 |
-
return apply_filters('acf/get_field_group_style', $style, $field_group);
|
923 |
}
|
924 |
|
925 |
/**
|
@@ -927,15 +934,15 @@ function acf_get_field_group_style( $field_group ) {
|
|
927 |
*
|
928 |
* Checks if the current user can edit the field group and returns the edit url.
|
929 |
*
|
930 |
-
* @date
|
931 |
-
* @since
|
932 |
*
|
933 |
-
* @param
|
934 |
-
* @return
|
935 |
*/
|
936 |
function acf_get_field_group_edit_link( $post_id ) {
|
937 |
-
if( $post_id && acf_current_user_can_admin() ) {
|
938 |
-
return admin_url('post.php?post=' . $post_id . '&action=edit');
|
939 |
}
|
940 |
return '';
|
941 |
}
|
@@ -945,27 +952,27 @@ function acf_get_field_group_edit_link( $post_id ) {
|
|
945 |
*
|
946 |
* Returns a modified field group ready for export.
|
947 |
*
|
948 |
-
* @date
|
949 |
-
* @since
|
950 |
*
|
951 |
-
* @param
|
952 |
-
* @return
|
953 |
*/
|
954 |
function acf_prepare_field_group_for_export( $field_group = array() ) {
|
955 |
|
956 |
// Remove args.
|
957 |
acf_extract_vars( $field_group, array( 'ID', 'local', '_valid' ) );
|
958 |
-
|
959 |
// Prepare fields.
|
960 |
$field_group['fields'] = acf_prepare_fields_for_export( $field_group['fields'] );
|
961 |
-
|
962 |
/**
|
963 |
* Filters the $field_group array before being returned to the export tool.
|
964 |
*
|
965 |
-
* @date
|
966 |
-
* @since
|
967 |
*
|
968 |
-
* @param
|
969 |
*/
|
970 |
return apply_filters( 'acf/prepare_field_group_for_export', $field_group );
|
971 |
}
|
@@ -975,31 +982,31 @@ function acf_prepare_field_group_for_export( $field_group = array() ) {
|
|
975 |
*
|
976 |
* Prepares a field group for the import process.
|
977 |
*
|
978 |
-
* @date
|
979 |
-
* @since
|
980 |
*
|
981 |
-
* @param
|
982 |
-
* @return
|
983 |
*/
|
984 |
function acf_prepare_field_group_for_import( $field_group ) {
|
985 |
-
|
986 |
// Update parent and menu_order properties for all fields.
|
987 |
-
if( $field_group['fields'] ) {
|
988 |
-
foreach( $field_group['fields'] as $i => &$field ) {
|
989 |
-
$field['parent']
|
990 |
$field['menu_order'] = $i;
|
991 |
}
|
992 |
}
|
993 |
-
|
994 |
/**
|
995 |
* Filters the $field_group array before being returned to the import tool.
|
996 |
*
|
997 |
-
* @date
|
998 |
-
* @since
|
999 |
*
|
1000 |
-
* @param
|
1001 |
*/
|
1002 |
-
return apply_filters(
|
1003 |
}
|
1004 |
|
1005 |
/**
|
@@ -1007,96 +1014,96 @@ function acf_prepare_field_group_for_import( $field_group ) {
|
|
1007 |
*
|
1008 |
* Imports a field group into the databse.
|
1009 |
*
|
1010 |
-
* @date
|
1011 |
-
* @since
|
1012 |
*
|
1013 |
-
* @param
|
1014 |
-
* @return
|
1015 |
*/
|
1016 |
function acf_import_field_group( $field_group ) {
|
1017 |
-
|
1018 |
// Disable filters to ensure data is not modified by local, clone, etc.
|
1019 |
$filters = acf_disable_filters();
|
1020 |
-
|
1021 |
// Validate field group (ensures all settings exist).
|
1022 |
$field_group = acf_get_valid_field_group( $field_group );
|
1023 |
-
|
1024 |
// Prepare group for import (modifies settings).
|
1025 |
$field_group = acf_prepare_field_group_for_import( $field_group );
|
1026 |
-
|
1027 |
// Prepare fields for import (modifies settings).
|
1028 |
$fields = acf_prepare_fields_for_import( $field_group['fields'] );
|
1029 |
-
|
1030 |
// Stores a map of field "key" => "ID".
|
1031 |
$ids = array();
|
1032 |
-
|
1033 |
-
// If the field group has an ID, review and delete stale fields in the database.
|
1034 |
-
if( $field_group['ID'] ) {
|
1035 |
-
|
1036 |
// Load database fields.
|
1037 |
$db_fields = acf_prepare_fields_for_import( acf_get_fields( $field_group ) );
|
1038 |
-
|
1039 |
// Generate map of "index" => "key" data.
|
1040 |
$keys = wp_list_pluck( $fields, 'key' );
|
1041 |
-
|
1042 |
// Loop over db fields and delete those who don't exist in $new_fields.
|
1043 |
-
foreach( $db_fields as $field ) {
|
1044 |
-
|
1045 |
// Add field data to $ids map.
|
1046 |
$ids[ $field['key'] ] = $field['ID'];
|
1047 |
-
|
1048 |
// Delete field if not in $keys.
|
1049 |
-
if( !in_array($field['key'], $keys) ) {
|
1050 |
acf_delete_field( $field['ID'] );
|
1051 |
}
|
1052 |
}
|
1053 |
}
|
1054 |
-
|
1055 |
// When importing a new field group, insert a temporary post and set the field group's ID.
|
1056 |
// This allows fields to be updated before the field group (field group ID is needed for field parent setting).
|
1057 |
-
if(
|
1058 |
$field_group['ID'] = wp_insert_post( array( 'post_title' => $field_group['key'] ) );
|
1059 |
}
|
1060 |
-
|
1061 |
// Add field group data to $ids map.
|
1062 |
$ids[ $field_group['key'] ] = $field_group['ID'];
|
1063 |
-
|
1064 |
// Loop over and add fields.
|
1065 |
-
if( $fields ) {
|
1066 |
-
foreach( $fields as $field ) {
|
1067 |
-
|
1068 |
// Replace any "key" references with "ID".
|
1069 |
-
if( isset($ids[ $field['key'] ]) ) {
|
1070 |
-
$field['ID'] = $ids[ $field['key'] ];
|
1071 |
}
|
1072 |
-
if( isset($ids[ $field['parent'] ]) ) {
|
1073 |
-
$field['parent'] = $ids[ $field['parent'] ];
|
1074 |
}
|
1075 |
-
|
1076 |
// Save field.
|
1077 |
$field = acf_update_field( $field );
|
1078 |
-
|
1079 |
// Add field data to $ids map for children.
|
1080 |
$ids[ $field['key'] ] = $field['ID'];
|
1081 |
}
|
1082 |
}
|
1083 |
-
|
1084 |
// Save field group.
|
1085 |
$field_group = acf_update_field_group( $field_group );
|
1086 |
-
|
1087 |
// Enable filters again.
|
1088 |
acf_enable_filters( $filters );
|
1089 |
-
|
1090 |
/**
|
1091 |
* Fires immediately after a field_group has been imported.
|
1092 |
*
|
1093 |
-
* @date
|
1094 |
-
* @since
|
1095 |
*
|
1096 |
-
* @param
|
1097 |
*/
|
1098 |
do_action( 'acf/import_field_group', $field_group );
|
1099 |
-
|
1100 |
// return new field group.
|
1101 |
return $field_group;
|
1102 |
}
|
1 |
+
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'field-groups' )->prop( 'multisite', true );
|
8 |
*
|
9 |
* Retrieves a field group for the given identifier.
|
10 |
*
|
11 |
+
* @date 30/09/13
|
12 |
+
* @since 5.0.0
|
13 |
*
|
14 |
+
* @param (int|string) $id The field group ID, key or name.
|
15 |
+
* @return (array|false) The field group array.
|
16 |
*/
|
17 |
function acf_get_field_group( $id = 0 ) {
|
18 |
+
|
19 |
// Allow WP_Post to be passed.
|
20 |
+
if ( is_object( $id ) ) {
|
21 |
$id = $id->ID;
|
22 |
}
|
23 |
+
|
24 |
// Check store.
|
25 |
$store = acf_get_store( 'field-groups' );
|
26 |
+
if ( $store->has( $id ) ) {
|
27 |
return $store->get( $id );
|
28 |
}
|
29 |
+
|
30 |
// Check local fields first.
|
31 |
+
if ( acf_is_local_field_group( $id ) ) {
|
32 |
$field_group = acf_get_local_field_group( $id );
|
33 |
+
|
34 |
+
// Then check database.
|
35 |
} else {
|
36 |
$field_group = acf_get_raw_field_group( $id );
|
37 |
}
|
38 |
+
|
39 |
// Bail early if no field group.
|
40 |
+
if ( ! $field_group ) {
|
41 |
return false;
|
42 |
}
|
43 |
+
|
44 |
// Validate field group.
|
45 |
$field_group = acf_validate_field_group( $field_group );
|
46 |
+
|
47 |
/**
|
48 |
* Filters the $field_group array after it has been loaded.
|
49 |
*
|
50 |
+
* @date 12/02/2014
|
51 |
+
* @since 5.0.0
|
52 |
*
|
53 |
+
* @param array The field_group array.
|
54 |
*/
|
55 |
$field_group = apply_filters( 'acf/load_field_group', $field_group );
|
56 |
+
|
57 |
// Store field group using aliasses to also find via key, ID and name.
|
58 |
$store->set( $field_group['key'], $field_group );
|
59 |
$store->alias( $field_group['key'], $field_group['ID'] );
|
60 |
+
|
61 |
// Return.
|
62 |
return $field_group;
|
63 |
}
|
67 |
*
|
68 |
* Retrieves raw field group data for the given identifier.
|
69 |
*
|
70 |
+
* @date 18/1/19
|
71 |
+
* @since 5.7.10
|
72 |
*
|
73 |
+
* @param (int|string) $id The field ID, key or name.
|
74 |
+
* @return (array|false) The field group array.
|
75 |
*/
|
76 |
function acf_get_raw_field_group( $id = 0 ) {
|
77 |
+
|
78 |
// Get raw field group from database.
|
79 |
$post = acf_get_field_group_post( $id );
|
80 |
+
if ( ! $post ) {
|
81 |
return false;
|
82 |
}
|
83 |
+
|
84 |
// Bail early if incorrect post type.
|
85 |
+
if ( $post->post_type !== 'acf-field-group' ) {
|
86 |
return false;
|
87 |
}
|
88 |
+
|
89 |
// Unserialize post_content.
|
90 |
$field_group = (array) maybe_unserialize( $post->post_content );
|
91 |
+
|
92 |
// update attributes
|
93 |
+
$field_group['ID'] = $post->ID;
|
94 |
+
$field_group['title'] = $post->post_title;
|
95 |
+
$field_group['key'] = $post->post_name;
|
96 |
$field_group['menu_order'] = $post->menu_order;
|
97 |
+
$field_group['active'] = in_array( $post->post_status, array( 'publish', 'auto-draft' ) );
|
98 |
|
99 |
// Return field.
|
100 |
return $field_group;
|
105 |
*
|
106 |
* Retrieves the field group's WP_Post object.
|
107 |
*
|
108 |
+
* @date 18/1/19
|
109 |
+
* @since 5.7.10
|
110 |
*
|
111 |
+
* @param (int|string) $id The field group's ID, key or name.
|
112 |
+
* @return (array|false) The field group's array.
|
113 |
*/
|
114 |
function acf_get_field_group_post( $id = 0 ) {
|
115 |
+
|
116 |
// Get post if numeric.
|
117 |
+
if ( is_numeric( $id ) ) {
|
118 |
return get_post( $id );
|
119 |
+
|
120 |
+
// Search posts if is string.
|
121 |
+
} elseif ( is_string( $id ) ) {
|
122 |
+
|
123 |
// Try cache.
|
124 |
$cache_key = acf_cache_key( "acf_get_field_group_post:key:$id" );
|
125 |
+
$post_id = wp_cache_get( $cache_key, 'acf' );
|
126 |
+
if ( $post_id === false ) {
|
127 |
+
|
128 |
// Query posts.
|
129 |
+
$posts = get_posts(
|
130 |
+
array(
|
131 |
+
'posts_per_page' => 1,
|
132 |
+
'post_type' => 'acf-field-group',
|
133 |
+
'post_status' => array( 'publish', 'acf-disabled', 'trash' ),
|
134 |
+
'orderby' => 'menu_order title',
|
135 |
+
'order' => 'ASC',
|
136 |
+
'suppress_filters' => false,
|
137 |
+
'cache_results' => true,
|
138 |
+
'update_post_meta_cache' => false,
|
139 |
+
'update_post_term_cache' => false,
|
140 |
+
'acf_group_key' => $id,
|
141 |
+
)
|
142 |
+
);
|
143 |
+
|
144 |
// Update $post_id with a non false value.
|
145 |
$post_id = $posts ? $posts[0]->ID : 0;
|
146 |
+
|
147 |
// Update cache.
|
148 |
wp_cache_set( $cache_key, $post_id, 'acf' );
|
149 |
}
|
150 |
+
|
151 |
// Check $post_id and return the post when possible.
|
152 |
+
if ( $post_id ) {
|
153 |
return get_post( $post_id );
|
154 |
}
|
155 |
}
|
156 |
+
|
157 |
// Return false by default.
|
158 |
return false;
|
159 |
}
|
163 |
*
|
164 |
* Returns true if the given identifier is a field group key.
|
165 |
*
|
166 |
+
* @date 6/12/2013
|
167 |
+
* @since 5.0.0
|
168 |
*
|
169 |
+
* @param string $id The identifier.
|
170 |
+
* @return bool
|
171 |
*/
|
172 |
function acf_is_field_group_key( $id = '' ) {
|
173 |
+
|
174 |
// Check if $id is a string starting with "group_".
|
175 |
+
if ( is_string( $id ) && substr( $id, 0, 6 ) === 'group_' ) {
|
176 |
return true;
|
177 |
}
|
178 |
+
|
179 |
/**
|
180 |
* Filters whether the $id is a field group key.
|
181 |
*
|
182 |
+
* @date 23/1/19
|
183 |
+
* @since 5.7.10
|
184 |
*
|
185 |
+
* @param bool $bool The result.
|
186 |
+
* @param string $id The identifier.
|
187 |
*/
|
188 |
return apply_filters( 'acf/is_field_group_key', false, $id );
|
189 |
}
|
193 |
*
|
194 |
* Ensures the given field group is valid.
|
195 |
*
|
196 |
+
* @date 18/1/19
|
197 |
+
* @since 5.7.10
|
198 |
*
|
199 |
+
* @param array $field The field group array.
|
200 |
+
* @return array
|
201 |
*/
|
202 |
function acf_validate_field_group( $field_group = array() ) {
|
203 |
+
|
204 |
// Bail early if already valid.
|
205 |
+
if ( is_array( $field_group ) && ! empty( $field_group['_valid'] ) ) {
|
206 |
return $field_group;
|
207 |
}
|
208 |
+
|
209 |
// Apply defaults.
|
210 |
+
$field_group = wp_parse_args(
|
211 |
+
$field_group,
|
212 |
+
array(
|
213 |
+
'ID' => 0,
|
214 |
+
'key' => '',
|
215 |
+
'title' => '',
|
216 |
+
'fields' => array(),
|
217 |
+
'location' => array(),
|
218 |
+
'menu_order' => 0,
|
219 |
+
'position' => 'normal',
|
220 |
+
'style' => 'default',
|
221 |
+
'label_placement' => 'top',
|
222 |
+
'instruction_placement' => 'label',
|
223 |
+
'hide_on_screen' => array(),
|
224 |
+
'active' => true,
|
225 |
+
'description' => '',
|
226 |
+
)
|
227 |
+
);
|
228 |
+
|
229 |
// Convert types.
|
230 |
+
$field_group['ID'] = (int) $field_group['ID'];
|
231 |
$field_group['menu_order'] = (int) $field_group['menu_order'];
|
232 |
+
$field_group['active'] = (bool) $field_group['active'];
|
233 |
+
|
234 |
// Field group is now valid.
|
235 |
$field_group['_valid'] = true;
|
236 |
+
|
237 |
/**
|
238 |
* Filters the $field_group array to validate settings.
|
239 |
*
|
240 |
+
* @date 12/02/2014
|
241 |
+
* @since 5.0.0
|
242 |
*
|
243 |
+
* @param array $field_group The field group array.
|
244 |
*/
|
245 |
$field_group = apply_filters( 'acf/validate_field_group', $field_group );
|
246 |
+
|
247 |
// return
|
248 |
return $field_group;
|
249 |
}
|
253 |
*
|
254 |
* Ensures the given field group is valid.
|
255 |
*
|
256 |
+
* @date 28/09/13
|
257 |
+
* @since 5.0.0
|
258 |
*
|
259 |
+
* @param array $field_group The field group array.
|
260 |
+
* @return array
|
261 |
*/
|
262 |
function acf_get_valid_field_group( $field_group = false ) {
|
263 |
return acf_validate_field_group( $field_group );
|
268 |
*
|
269 |
* Translates a field group's settings.
|
270 |
*
|
271 |
+
* @date 8/03/2016
|
272 |
+
* @since 5.3.2
|
273 |
*
|
274 |
+
* @param array $field_group The field group array.
|
275 |
+
* @return array
|
276 |
*/
|
277 |
function acf_translate_field_group( $field_group = array() ) {
|
278 |
+
|
279 |
// Get settings.
|
280 |
+
$l10n = acf_get_setting( 'l10n' );
|
281 |
+
$l10n_textdomain = acf_get_setting( 'l10n_textdomain' );
|
282 |
+
|
283 |
// Translate field settings if textdomain is set.
|
284 |
+
if ( $l10n && $l10n_textdomain ) {
|
285 |
+
|
286 |
$field_group['title'] = acf_translate( $field_group['title'] );
|
287 |
+
|
288 |
/**
|
289 |
* Filters the $field group array to translate strings.
|
290 |
*
|
291 |
+
* @date 12/02/2014
|
292 |
+
* @since 5.0.0
|
293 |
*
|
294 |
+
* @param array $field_group The field group array.
|
295 |
*/
|
296 |
+
$field_group = apply_filters( 'acf/translate_field_group', $field_group );
|
297 |
}
|
298 |
+
|
299 |
// Return field.
|
300 |
return $field_group;
|
301 |
}
|
302 |
|
303 |
// Translate field groups passing through validation.
|
304 |
+
add_action( 'acf/validate_field_group', 'acf_translate_field_group' );
|
305 |
|
306 |
|
307 |
/**
|
309 |
*
|
310 |
* Returns and array of field_groups for the given $filter.
|
311 |
*
|
312 |
+
* @date 30/09/13
|
313 |
+
* @since 5.0.0
|
314 |
*
|
315 |
+
* @param array $filter An array of args to filter results by.
|
316 |
+
* @return array
|
317 |
*/
|
318 |
function acf_get_field_groups( $filter = array() ) {
|
319 |
+
|
320 |
// Vars.
|
321 |
$field_groups = array();
|
322 |
+
|
323 |
// Check database.
|
324 |
$raw_field_groups = acf_get_raw_field_groups();
|
325 |
+
if ( $raw_field_groups ) {
|
326 |
+
foreach ( $raw_field_groups as $raw_field_group ) {
|
327 |
$field_groups[] = acf_get_field_group( $raw_field_group['ID'] );
|
328 |
}
|
329 |
}
|
330 |
+
|
331 |
/**
|
332 |
* Filters the $field_groups array.
|
333 |
*
|
334 |
+
* @date 12/02/2014
|
335 |
+
* @since 5.0.0
|
336 |
*
|
337 |
+
* @param array $field_groups The array of field_groups.
|
338 |
*/
|
339 |
$field_groups = apply_filters( 'acf/load_field_groups', $field_groups );
|
340 |
+
|
341 |
// Filter results.
|
342 |
+
if ( $filter ) {
|
343 |
return acf_filter_field_groups( $field_groups, $filter );
|
344 |
}
|
345 |
+
|
346 |
// Return field groups.
|
347 |
return $field_groups;
|
348 |
}
|
352 |
*
|
353 |
* Returns and array of raw field_group data.
|
354 |
*
|
355 |
+
* @date 18/1/19
|
356 |
+
* @since 5.7.10
|
357 |
*
|
358 |
+
* @param void
|
359 |
+
* @return array
|
360 |
*/
|
361 |
function acf_get_raw_field_groups() {
|
362 |
+
|
363 |
// Try cache.
|
364 |
+
$cache_key = acf_cache_key( 'acf_get_field_group_posts' );
|
365 |
+
$post_ids = wp_cache_get( $cache_key, 'acf' );
|
366 |
+
if ( $post_ids === false ) {
|
367 |
+
|
368 |
// Query posts.
|
369 |
+
$posts = get_posts(
|
370 |
+
array(
|
371 |
+
'posts_per_page' => -1,
|
372 |
+
'post_type' => 'acf-field-group',
|
373 |
+
'orderby' => 'menu_order title',
|
374 |
+
'order' => 'ASC',
|
375 |
+
'suppress_filters' => false, // Allow WPML to modify the query
|
376 |
+
'cache_results' => true,
|
377 |
+
'update_post_meta_cache' => false,
|
378 |
+
'update_post_term_cache' => false,
|
379 |
+
'post_status' => array( 'publish', 'acf-disabled' ),
|
380 |
+
)
|
381 |
+
);
|
382 |
+
|
383 |
// Update $post_ids with a non false value.
|
384 |
$post_ids = array();
|
385 |
+
foreach ( $posts as $post ) {
|
386 |
$post_ids[] = $post->ID;
|
387 |
}
|
388 |
+
|
389 |
// Update cache.
|
390 |
wp_cache_set( $cache_key, $post_ids, 'acf' );
|
391 |
}
|
392 |
+
|
393 |
// Loop over ids and populate array of field groups.
|
394 |
$field_groups = array();
|
395 |
+
foreach ( $post_ids as $post_id ) {
|
396 |
$field_groups[] = acf_get_raw_field_group( $post_id );
|
397 |
}
|
398 |
+
|
399 |
// Return field groups.
|
400 |
return $field_groups;
|
401 |
}
|
405 |
*
|
406 |
* Returns a filtered aray of field groups based on the given $args.
|
407 |
*
|
408 |
+
* @date 29/11/2013
|
409 |
+
* @since 5.0.0
|
410 |
*
|
411 |
+
* @param array $field_groups An array of field groups.
|
412 |
+
* @param array $args An array of location args.
|
413 |
+
* @return array
|
414 |
*/
|
415 |
function acf_filter_field_groups( $field_groups, $args = array() ) {
|
416 |
+
|
417 |
// Loop over field groups and check visibility.
|
418 |
$filtered = array();
|
419 |
+
if ( $field_groups ) {
|
420 |
+
foreach ( $field_groups as $field_group ) {
|
421 |
+
if ( acf_get_field_group_visibility( $field_group, $args ) ) {
|
422 |
$filtered[] = $field_group;
|
423 |
}
|
424 |
}
|
425 |
}
|
426 |
+
|
427 |
// Return filtered.
|
428 |
return $filtered;
|
429 |
}
|
433 |
*
|
434 |
* Returns true if the given field group's location rules match the given $args.
|
435 |
*
|
436 |
+
* @date 7/10/13
|
437 |
+
* @since 5.0.0
|
438 |
*
|
439 |
+
* @param array $field_groups An array of field groups.
|
440 |
+
* @param array $args An array of location args.
|
441 |
+
* @return bool
|
442 |
*/
|
443 |
function acf_get_field_group_visibility( $field_group, $args = array() ) {
|
444 |
+
|
445 |
// Check if active.
|
446 |
+
if ( ! $field_group['active'] ) {
|
447 |
return false;
|
448 |
}
|
449 |
+
|
450 |
// Check if location rules exist
|
451 |
+
if ( $field_group['location'] ) {
|
452 |
+
|
453 |
// Get the current screen.
|
454 |
$screen = acf_get_location_screen( $args );
|
455 |
+
|
456 |
// Loop through location groups.
|
457 |
+
foreach ( $field_group['location'] as $group ) {
|
458 |
+
|
459 |
// ignore group if no rules.
|
460 |
+
if ( empty( $group ) ) {
|
461 |
continue;
|
462 |
}
|
463 |
+
|
464 |
// Loop over rules and determine if all rules match.
|
465 |
$match_group = true;
|
466 |
+
foreach ( $group as $rule ) {
|
467 |
+
if ( ! acf_match_location_rule( $rule, $screen, $field_group ) ) {
|
468 |
$match_group = false;
|
469 |
break;
|
470 |
}
|
471 |
}
|
472 |
+
|
473 |
// If this group matches, show the field group.
|
474 |
+
if ( $match_group ) {
|
475 |
return true;
|
476 |
}
|
477 |
}
|
478 |
}
|
479 |
+
|
480 |
// Return default.
|
481 |
return false;
|
482 |
}
|
486 |
*
|
487 |
* Updates a field group in the database.
|
488 |
*
|
489 |
+
* @date 21/1/19
|
490 |
+
* @since 5.7.10
|
491 |
*
|
492 |
+
* @param array $field_group The field group array.
|
493 |
+
* @return array
|
494 |
*/
|
495 |
function acf_update_field_group( $field_group ) {
|
496 |
+
|
497 |
// Validate field group.
|
498 |
$field_group = acf_get_valid_field_group( $field_group );
|
499 |
+
|
500 |
// May have been posted. Remove slashes.
|
501 |
$field_group = wp_unslash( $field_group );
|
502 |
+
|
503 |
// Parse types (converts string '0' to int 0).
|
504 |
$field_group = acf_parse_types( $field_group );
|
505 |
+
|
506 |
// Clean up location keys.
|
507 |
+
if ( $field_group['location'] ) {
|
508 |
+
|
509 |
// Remove empty values and convert to associated array.
|
510 |
$field_group['location'] = array_filter( $field_group['location'] );
|
511 |
$field_group['location'] = array_values( $field_group['location'] );
|
512 |
$field_group['location'] = array_map( 'array_filter', $field_group['location'] );
|
513 |
$field_group['location'] = array_map( 'array_values', $field_group['location'] );
|
514 |
}
|
515 |
+
|
516 |
// Make a backup of field group data and remove some args.
|
517 |
$_field_group = $field_group;
|
518 |
acf_extract_vars( $_field_group, array( 'ID', 'key', 'title', 'menu_order', 'fields', 'active', '_valid' ) );
|
519 |
+
|
520 |
// Create array of data to save.
|
521 |
$save = array(
|
522 |
+
'ID' => $field_group['ID'],
|
523 |
+
'post_status' => $field_group['active'] ? 'publish' : 'acf-disabled',
|
524 |
+
'post_type' => 'acf-field-group',
|
525 |
+
'post_title' => $field_group['title'],
|
526 |
+
'post_name' => $field_group['key'],
|
527 |
+
'post_excerpt' => sanitize_title( $field_group['title'] ),
|
528 |
+
'post_content' => maybe_serialize( $_field_group ),
|
529 |
+
'menu_order' => $field_group['menu_order'],
|
530 |
+
'comment_status' => 'closed',
|
531 |
+
'ping_status' => 'closed',
|
532 |
);
|
533 |
+
|
534 |
// Unhook wp_targeted_link_rel() filter from WP 5.1 corrupting serialized data.
|
535 |
remove_filter( 'content_save_pre', 'wp_targeted_link_rel' );
|
536 |
+
|
537 |
// Slash data.
|
538 |
// WP expects all data to be slashed and will unslash it (fixes '\' character issues).
|
539 |
$save = wp_slash( $save );
|
540 |
+
|
541 |
// Update or Insert.
|
542 |
+
if ( $field_group['ID'] ) {
|
543 |
wp_update_post( $save );
|
544 |
+
} else {
|
545 |
$field_group['ID'] = wp_insert_post( $save );
|
546 |
}
|
547 |
+
|
548 |
// Flush field group cache.
|
549 |
+
acf_flush_field_group_cache( $field_group );
|
550 |
+
|
551 |
/**
|
552 |
* Fires immediately after a field group has been updated.
|
553 |
*
|
554 |
+
* @date 12/02/2014
|
555 |
+
* @since 5.0.0
|
556 |
*
|
557 |
+
* @param array $field_group The field group array.
|
558 |
*/
|
559 |
do_action( 'acf/update_field_group', $field_group );
|
560 |
+
|
561 |
// Return field group.
|
562 |
return $field_group;
|
563 |
}
|
567 |
*
|
568 |
* Allows full control over 'acf-field-group' slugs.
|
569 |
*
|
570 |
+
* @date 21/1/19
|
571 |
+
* @since 5.7.10
|
572 |
*
|
573 |
* @param string $slug The post slug.
|
574 |
* @param int $post_ID Post ID.
|
578 |
* @param string $original_slug The original post slug.
|
579 |
*/
|
580 |
function _acf_apply_unique_field_group_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
581 |
+
|
582 |
// Check post type and reset to original value.
|
583 |
+
if ( $post_type === 'acf-field-group' ) {
|
584 |
return $original_slug;
|
585 |
}
|
586 |
+
|
587 |
// Return slug.
|
588 |
return $slug;
|
589 |
}
|
596 |
*
|
597 |
* Deletes all caches for this field group.
|
598 |
*
|
599 |
+
* @date 22/1/19
|
600 |
+
* @since 5.7.10
|
601 |
*
|
602 |
+
* @param array $field_group The field group array.
|
603 |
+
* @return void
|
604 |
*/
|
605 |
function acf_flush_field_group_cache( $field_group ) {
|
606 |
+
|
607 |
// Delete stored data.
|
608 |
acf_get_store( 'field-groups' )->remove( $field_group['key'] );
|
609 |
+
|
610 |
// Flush cached post_id for this field group's key.
|
611 |
wp_cache_delete( acf_cache_key( "acf_get_field_group_post:key:{$field_group['key']}" ), 'acf' );
|
612 |
+
|
613 |
// Flush cached array of post_ids for collection of field groups.
|
614 |
+
wp_cache_delete( acf_cache_key( 'acf_get_field_group_posts' ), 'acf' );
|
615 |
}
|
616 |
|
617 |
/**
|
619 |
*
|
620 |
* Deletes a field group from the database.
|
621 |
*
|
622 |
+
* @date 21/1/19
|
623 |
+
* @since 5.7.10
|
624 |
*
|
625 |
+
* @param (int|string) $id The field group ID, key or name.
|
626 |
+
* @return bool True if field group was deleted.
|
627 |
*/
|
628 |
function acf_delete_field_group( $id = 0 ) {
|
629 |
+
|
630 |
// Disable filters to ensure ACF loads data from DB.
|
631 |
acf_disable_filters();
|
632 |
+
|
633 |
// Get the field_group.
|
634 |
$field_group = acf_get_field_group( $id );
|
635 |
+
|
636 |
// Bail early if field group was not found.
|
637 |
+
if ( ! $field_group || ! $field_group['ID'] ) {
|
638 |
return false;
|
639 |
}
|
640 |
+
|
641 |
// Delete fields.
|
642 |
$fields = acf_get_fields( $field_group );
|
643 |
+
if ( $fields ) {
|
644 |
+
foreach ( $fields as $field ) {
|
645 |
acf_delete_field( $field['ID'] );
|
646 |
}
|
647 |
}
|
648 |
+
|
649 |
// Delete post.
|
650 |
wp_delete_post( $field_group['ID'], true );
|
651 |
+
|
652 |
// Flush field group cache.
|
653 |
acf_flush_field_group_cache( $field_group );
|
654 |
+
|
655 |
/**
|
656 |
* Fires immediately after a field group has been deleted.
|
657 |
*
|
658 |
+
* @date 12/02/2014
|
659 |
+
* @since 5.0.0
|
660 |
*
|
661 |
+
* @param array $field_group The field group array.
|
662 |
*/
|
663 |
do_action( 'acf/delete_field_group', $field_group );
|
664 |
+
|
665 |
// Return true.
|
666 |
return true;
|
667 |
}
|
671 |
*
|
672 |
* Trashes a field group from the database.
|
673 |
*
|
674 |
+
* @date 2/10/13
|
675 |
+
* @since 5.0.0
|
676 |
*
|
677 |
+
* @param (int|string) $id The field group ID, key or name.
|
678 |
+
* @return bool True if field group was trashed.
|
679 |
*/
|
680 |
function acf_trash_field_group( $id = 0 ) {
|
681 |
+
|
682 |
// Disable filters to ensure ACF loads data from DB.
|
683 |
acf_disable_filters();
|
684 |
+
|
685 |
// Get the field_group.
|
686 |
$field_group = acf_get_field_group( $id );
|
687 |
+
|
688 |
// Bail early if field_group was not found.
|
689 |
+
if ( ! $field_group || ! $field_group['ID'] ) {
|
690 |
return false;
|
691 |
}
|
692 |
+
|
693 |
// Trash fields.
|
694 |
$fields = acf_get_fields( $field_group );
|
695 |
+
if ( $fields ) {
|
696 |
+
foreach ( $fields as $field ) {
|
697 |
acf_trash_field( $field['ID'] );
|
698 |
}
|
699 |
}
|
700 |
+
|
701 |
// Trash post.
|
702 |
wp_trash_post( $field_group['ID'], true );
|
703 |
+
|
704 |
// Flush field group cache.
|
705 |
acf_flush_field_group_cache( $field_group );
|
706 |
+
|
707 |
/**
|
708 |
* Fires immediately after a field_group has been trashed.
|
709 |
*
|
710 |
+
* @date 12/02/2014
|
711 |
+
* @since 5.0.0
|
712 |
*
|
713 |
+
* @param array $field_group The field_group array.
|
714 |
*/
|
715 |
do_action( 'acf/trash_field_group', $field_group );
|
716 |
+
|
717 |
// Return true.
|
718 |
return true;
|
719 |
}
|
723 |
*
|
724 |
* Restores a field_group from the trash.
|
725 |
*
|
726 |
+
* @date 2/10/13
|
727 |
+
* @since 5.0.0
|
728 |
*
|
729 |
+
* @param (int|string) $id The field_group ID, key or name.
|
730 |
+
* @return bool True if field_group was trashed.
|
731 |
*/
|
732 |
function acf_untrash_field_group( $id = 0 ) {
|
733 |
+
|
734 |
// Disable filters to ensure ACF loads data from DB.
|
735 |
acf_disable_filters();
|
736 |
+
|
737 |
// Get the field_group.
|
738 |
$field_group = acf_get_field_group( $id );
|
739 |
+
|
740 |
// Bail early if field_group was not found.
|
741 |
+
if ( ! $field_group || ! $field_group['ID'] ) {
|
742 |
return false;
|
743 |
}
|
744 |
+
|
745 |
// Untrash fields.
|
746 |
$fields = acf_get_fields( $field_group );
|
747 |
+
if ( $fields ) {
|
748 |
+
foreach ( $fields as $field ) {
|
749 |
acf_untrash_field( $field['ID'] );
|
750 |
}
|
751 |
}
|
752 |
+
|
753 |
// Untrash post.
|
754 |
wp_untrash_post( $field_group['ID'], true );
|
755 |
+
|
756 |
// Flush field group cache.
|
757 |
acf_flush_field_group_cache( $field_group );
|
758 |
+
|
759 |
/**
|
760 |
* Fires immediately after a field_group has been trashed.
|
761 |
*
|
762 |
+
* @date 12/02/2014
|
763 |
+
* @since 5.0.0
|
764 |
*
|
765 |
+
* @param array $field_group The field_group array.
|
766 |
*/
|
767 |
do_action( 'acf/untrash_field_group', $field_group );
|
768 |
+
|
769 |
// Return true.
|
770 |
return true;
|
771 |
}
|
793 |
*
|
794 |
* Returns true if the given params match a field group.
|
795 |
*
|
796 |
+
* @date 21/1/19
|
797 |
+
* @since 5.7.10
|
798 |
*
|
799 |
+
* @param array $field_group The field group array.
|
800 |
+
* @param mixed $id An optional identifier to search for.
|
801 |
+
* @return bool
|
802 |
*/
|
803 |
function acf_is_field_group( $field_group = false ) {
|
804 |
+
return (
|
805 |
+
is_array( $field_group )
|
806 |
+
&& isset( $field_group['key'] )
|
807 |
+
&& isset( $field_group['title'] )
|
808 |
);
|
809 |
}
|
810 |
|
813 |
*
|
814 |
* Duplicates a field group.
|
815 |
*
|
816 |
+
* @date 16/06/2014
|
817 |
+
* @since 5.0.0
|
818 |
*
|
819 |
+
* @param (int|string) $id The field_group ID, key or name.
|
820 |
+
* @param int $new_post_id Optional post ID to override.
|
821 |
+
* @return array The new field group.
|
822 |
*/
|
823 |
+
function acf_duplicate_field_group( $id = 0, $new_post_id = 0 ) {
|
824 |
+
|
825 |
// Disable filters to ensure ACF loads data from DB.
|
826 |
acf_disable_filters();
|
827 |
+
|
828 |
// Get the field_group.
|
829 |
$field_group = acf_get_field_group( $id );
|
830 |
+
|
831 |
// Bail early if field_group was not found.
|
832 |
+
if ( ! $field_group || ! $field_group['ID'] ) {
|
833 |
return false;
|
834 |
}
|
835 |
+
|
836 |
// Get fields.
|
837 |
$fields = acf_get_fields( $field_group );
|
838 |
+
|
839 |
// Update attributes.
|
840 |
+
$field_group['ID'] = $new_post_id;
|
841 |
+
$field_group['key'] = uniqid( 'group_' );
|
842 |
+
|
843 |
// Add (copy) to title when apropriate.
|
844 |
+
if ( ! $new_post_id ) {
|
845 |
+
$field_group['title'] .= ' (' . __( 'copy', 'acf' ) . ')';
|
846 |
}
|
847 |
+
|
848 |
// When importing a new field group, insert a temporary post and set the field group's ID.
|
849 |
// This allows fields to be updated before the field group (field group ID is needed for field parent setting).
|
850 |
+
if ( ! $field_group['ID'] ) {
|
851 |
$field_group['ID'] = wp_insert_post( array( 'post_title' => $field_group['key'] ) );
|
852 |
}
|
853 |
+
|
854 |
// Duplicate fields.
|
855 |
$duplicates = acf_duplicate_fields( $fields, $field_group['ID'] );
|
856 |
+
|
857 |
// Save field group.
|
858 |
$field_group = acf_update_field_group( $field_group );
|
859 |
+
|
860 |
/**
|
861 |
* Fires immediately after a field_group has been duplicated.
|
862 |
*
|
863 |
+
* @date 12/02/2014
|
864 |
+
* @since 5.0.0
|
865 |
*
|
866 |
+
* @param array $field_group The field_group array.
|
867 |
*/
|
868 |
do_action( 'acf/duplicate_field_group', $field_group );
|
869 |
+
|
870 |
// return
|
871 |
return $field_group;
|
872 |
}
|
876 |
*
|
877 |
* Returns the CSS styles generated from field group settings.
|
878 |
*
|
879 |
+
* @date 20/10/13
|
880 |
+
* @since 5.0.0
|
881 |
*
|
882 |
+
* @param array $field_group The field group array.
|
883 |
+
* @return string.
|
884 |
*/
|
885 |
function acf_get_field_group_style( $field_group ) {
|
886 |
+
|
887 |
// Vars.
|
888 |
+
$style = '';
|
889 |
$elements = array(
|
890 |
+
'permalink' => '#edit-slug-box',
|
891 |
+
'the_content' => '#postdivrich',
|
892 |
+
'excerpt' => '#postexcerpt',
|
893 |
+
'custom_fields' => '#postcustom',
|
894 |
+
'discussion' => '#commentstatusdiv',
|
895 |
+
'comments' => '#commentsdiv',
|
896 |
+
'slug' => '#slugdiv',
|
897 |
+
'author' => '#authordiv',
|
898 |
+
'format' => '#formatdiv',
|
899 |
+
'page_attributes' => '#pageparentdiv',
|
900 |
+
'featured_image' => '#postimagediv',
|
901 |
+
'revisions' => '#revisionsdiv',
|
902 |
+
'categories' => '#categorydiv',
|
903 |
+
'tags' => '#tagsdiv-post_tag',
|
904 |
+
'send-trackbacks' => '#trackbacksdiv',
|
905 |
);
|
906 |
+
|
907 |
// Loop over field group settings and generate list of selectors to hide.
|
908 |
+
if ( is_array( $field_group['hide_on_screen'] ) ) {
|
909 |
$hide = array();
|
910 |
+
foreach ( $field_group['hide_on_screen'] as $k ) {
|
911 |
+
if ( isset( $elements[ $k ] ) ) {
|
912 |
+
$id = $elements[ $k ];
|
913 |
$hide[] = $id;
|
914 |
+
$hide[] = '#screen-meta label[for=' . substr( $id, 1 ) . '-hide]';
|
915 |
}
|
916 |
}
|
917 |
+
$style = implode( ', ', $hide ) . ' {display: none;}';
|
918 |
}
|
919 |
+
|
920 |
/**
|
921 |
* Filters the generated CSS styles.
|
922 |
*
|
923 |
+
* @date 12/02/2014
|
924 |
+
* @since 5.0.0
|
925 |
*
|
926 |
+
* @param string $style The CSS styles.
|
927 |
+
* @param array $field_group The field group array.
|
928 |
*/
|
929 |
+
return apply_filters( 'acf/get_field_group_style', $style, $field_group );
|
930 |
}
|
931 |
|
932 |
/**
|
934 |
*
|
935 |
* Checks if the current user can edit the field group and returns the edit url.
|
936 |
*
|
937 |
+
* @date 23/9/18
|
938 |
+
* @since 5.7.7
|
939 |
*
|
940 |
+
* @param int $post_id The field group ID.
|
941 |
+
* @return string
|
942 |
*/
|
943 |
function acf_get_field_group_edit_link( $post_id ) {
|
944 |
+
if ( $post_id && acf_current_user_can_admin() ) {
|
945 |
+
return admin_url( 'post.php?post=' . $post_id . '&action=edit' );
|
946 |
}
|
947 |
return '';
|
948 |
}
|
952 |
*
|
953 |
* Returns a modified field group ready for export.
|
954 |
*
|
955 |
+
* @date 11/03/2014
|
956 |
+
* @since 5.0.0
|
957 |
*
|
958 |
+
* @param array $field_group The field group array.
|
959 |
+
* @return array
|
960 |
*/
|
961 |
function acf_prepare_field_group_for_export( $field_group = array() ) {
|
962 |
|
963 |
// Remove args.
|
964 |
acf_extract_vars( $field_group, array( 'ID', 'local', '_valid' ) );
|
965 |
+
|
966 |
// Prepare fields.
|
967 |
$field_group['fields'] = acf_prepare_fields_for_export( $field_group['fields'] );
|
968 |
+
|
969 |
/**
|
970 |
* Filters the $field_group array before being returned to the export tool.
|
971 |
*
|
972 |
+
* @date 12/02/2014
|
973 |
+
* @since 5.0.0
|
974 |
*
|
975 |
+
* @param array $field_group The $field group array.
|
976 |
*/
|
977 |
return apply_filters( 'acf/prepare_field_group_for_export', $field_group );
|
978 |
}
|
982 |
*
|
983 |
* Prepares a field group for the import process.
|
984 |
*
|
985 |
+
* @date 21/11/19
|
986 |
+
* @since 5.8.8
|
987 |
*
|
988 |
+
* @param array $field_group The field group array.
|
989 |
+
* @return array
|
990 |
*/
|
991 |
function acf_prepare_field_group_for_import( $field_group ) {
|
992 |
+
|
993 |
// Update parent and menu_order properties for all fields.
|
994 |
+
if ( $field_group['fields'] ) {
|
995 |
+
foreach ( $field_group['fields'] as $i => &$field ) {
|
996 |
+
$field['parent'] = $field_group['key'];
|
997 |
$field['menu_order'] = $i;
|
998 |
}
|
999 |
}
|
1000 |
+
|
1001 |
/**
|
1002 |
* Filters the $field_group array before being returned to the import tool.
|
1003 |
*
|
1004 |
+
* @date 21/11/19
|
1005 |
+
* @since 5.8.8
|
1006 |
*
|
1007 |
+
* @param array $field_group The field group array.
|
1008 |
*/
|
1009 |
+
return apply_filters( 'acf/prepare_field_group_for_import', $field_group );
|
1010 |
}
|
1011 |
|
1012 |
/**
|
1014 |
*
|
1015 |
* Imports a field group into the databse.
|
1016 |
*
|
1017 |
+
* @date 11/03/2014
|
1018 |
+
* @since 5.0.0
|
1019 |
*
|
1020 |
+
* @param array $field_group The field group array.
|
1021 |
+
* @return array The new field group.
|
1022 |
*/
|
1023 |
function acf_import_field_group( $field_group ) {
|
1024 |
+
|
1025 |
// Disable filters to ensure data is not modified by local, clone, etc.
|
1026 |
$filters = acf_disable_filters();
|
1027 |
+
|
1028 |
// Validate field group (ensures all settings exist).
|
1029 |
$field_group = acf_get_valid_field_group( $field_group );
|
1030 |
+
|
1031 |
// Prepare group for import (modifies settings).
|
1032 |
$field_group = acf_prepare_field_group_for_import( $field_group );
|
1033 |
+
|
1034 |
// Prepare fields for import (modifies settings).
|
1035 |
$fields = acf_prepare_fields_for_import( $field_group['fields'] );
|
1036 |
+
|
1037 |
// Stores a map of field "key" => "ID".
|
1038 |
$ids = array();
|
1039 |
+
|
1040 |
+
// If the field group has an ID, review and delete stale fields in the database.
|
1041 |
+
if ( $field_group['ID'] ) {
|
1042 |
+
|
1043 |
// Load database fields.
|
1044 |
$db_fields = acf_prepare_fields_for_import( acf_get_fields( $field_group ) );
|
1045 |
+
|
1046 |
// Generate map of "index" => "key" data.
|
1047 |
$keys = wp_list_pluck( $fields, 'key' );
|
1048 |
+
|
1049 |
// Loop over db fields and delete those who don't exist in $new_fields.
|
1050 |
+
foreach ( $db_fields as $field ) {
|
1051 |
+
|
1052 |
// Add field data to $ids map.
|
1053 |
$ids[ $field['key'] ] = $field['ID'];
|
1054 |
+
|
1055 |
// Delete field if not in $keys.
|
1056 |
+
if ( ! in_array( $field['key'], $keys ) ) {
|
1057 |
acf_delete_field( $field['ID'] );
|
1058 |
}
|
1059 |
}
|
1060 |
}
|
1061 |
+
|
1062 |
// When importing a new field group, insert a temporary post and set the field group's ID.
|
1063 |
// This allows fields to be updated before the field group (field group ID is needed for field parent setting).
|
1064 |
+
if ( ! $field_group['ID'] ) {
|
1065 |
$field_group['ID'] = wp_insert_post( array( 'post_title' => $field_group['key'] ) );
|
1066 |
}
|
1067 |
+
|
1068 |
// Add field group data to $ids map.
|
1069 |
$ids[ $field_group['key'] ] = $field_group['ID'];
|
1070 |
+
|
1071 |
// Loop over and add fields.
|
1072 |
+
if ( $fields ) {
|
1073 |
+
foreach ( $fields as $field ) {
|
1074 |
+
|
1075 |
// Replace any "key" references with "ID".
|
1076 |
+
if ( isset( $ids[ $field['key'] ] ) ) {
|
1077 |
+
$field['ID'] = $ids[ $field['key'] ];
|
1078 |
}
|
1079 |
+
if ( isset( $ids[ $field['parent'] ] ) ) {
|
1080 |
+
$field['parent'] = $ids[ $field['parent'] ];
|
1081 |
}
|
1082 |
+
|
1083 |
// Save field.
|
1084 |
$field = acf_update_field( $field );
|
1085 |
+
|
1086 |
// Add field data to $ids map for children.
|
1087 |
$ids[ $field['key'] ] = $field['ID'];
|
1088 |
}
|
1089 |
}
|
1090 |
+
|
1091 |
// Save field group.
|
1092 |
$field_group = acf_update_field_group( $field_group );
|
1093 |
+
|
1094 |
// Enable filters again.
|
1095 |
acf_enable_filters( $filters );
|
1096 |
+
|
1097 |
/**
|
1098 |
* Fires immediately after a field_group has been imported.
|
1099 |
*
|
1100 |
+
* @date 12/02/2014
|
1101 |
+
* @since 5.0.0
|
1102 |
*
|
1103 |
+
* @param array $field_group The field_group array.
|
1104 |
*/
|
1105 |
do_action( 'acf/import_field_group', $field_group );
|
1106 |
+
|
1107 |
// return new field group.
|
1108 |
return $field_group;
|
1109 |
}
|
includes/acf-form-functions.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
// Register store for form data.
|
4 |
acf_register_store( 'form' );
|
@@ -8,12 +8,12 @@ acf_register_store( 'form' );
|
|
8 |
*
|
9 |
* Sets data about the current form.
|
10 |
*
|
11 |
-
* @date
|
12 |
-
* @since
|
13 |
*
|
14 |
-
* @param
|
15 |
-
* @param
|
16 |
-
* @return
|
17 |
*/
|
18 |
function acf_set_form_data( $name = '', $data = false ) {
|
19 |
return acf_get_store( 'form' )->set( $name, $data );
|
@@ -24,11 +24,11 @@ function acf_set_form_data( $name = '', $data = false ) {
|
|
24 |
*
|
25 |
* Gets data about the current form.
|
26 |
*
|
27 |
-
* @date
|
28 |
-
* @since
|
29 |
*
|
30 |
-
* @param
|
31 |
-
* @return
|
32 |
*/
|
33 |
function acf_get_form_data( $name = '' ) {
|
34 |
return acf_get_store( 'form' )->get( $name );
|
@@ -39,61 +39,66 @@ function acf_get_form_data( $name = '' ) {
|
|
39 |
*
|
40 |
* Called within a form to set important information and render hidden inputs.
|
41 |
*
|
42 |
-
* @date
|
43 |
-
* @since
|
44 |
*
|
45 |
-
* @param
|
46 |
-
* @return
|
47 |
*/
|
48 |
function acf_form_data( $data = array() ) {
|
49 |
-
|
50 |
// Apply defaults.
|
51 |
-
$data = wp_parse_args(
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
// Create nonce using screen.
|
64 |
$data['nonce'] = wp_create_nonce( $data['screen'] );
|
65 |
-
|
66 |
// Append "changed" input used within "_wp_post_revision_fields" action.
|
67 |
$data['changed'] = 0;
|
68 |
-
|
69 |
// Set data.
|
70 |
acf_set_form_data( $data );
|
71 |
-
|
72 |
// Render HTML.
|
73 |
?>
|
74 |
<div id="acf-form-data" class="acf-hidden">
|
75 |
-
<?php
|
76 |
-
|
77 |
// Create hidden inputs from $data
|
78 |
-
foreach( $data as $name => $value ) {
|
79 |
-
acf_hidden_input(
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
84 |
}
|
85 |
-
|
86 |
/**
|
87 |
* Fires within the #acf-form-data element to add extra HTML.
|
88 |
*
|
89 |
-
* @date
|
90 |
-
* @since
|
91 |
*
|
92 |
-
* @param
|
93 |
*/
|
94 |
do_action( 'acf/form_data', $data );
|
95 |
do_action( 'acf/input/form_data', $data );
|
96 |
-
|
97 |
?>
|
98 |
</div>
|
99 |
<?php
|
@@ -105,36 +110,36 @@ function acf_form_data( $data = array() ) {
|
|
105 |
*
|
106 |
* Saves the $_POST data.
|
107 |
*
|
108 |
-
* @date
|
109 |
-
* @since
|
110 |
*
|
111 |
-
* @param
|
112 |
-
* @param
|
113 |
-
* @return
|
114 |
*/
|
115 |
function acf_save_post( $post_id = 0, $values = null ) {
|
116 |
-
|
117 |
// Override $_POST data with $values.
|
118 |
-
if( $values !== null ) {
|
119 |
$_POST['acf'] = $values;
|
120 |
}
|
121 |
-
|
122 |
// Bail early if no data to save.
|
123 |
-
if( empty($_POST['acf']) ) {
|
124 |
return false;
|
125 |
}
|
126 |
-
|
127 |
// Set form data (useful in various filters/actions).
|
128 |
acf_set_form_data( 'post_id', $post_id );
|
129 |
-
|
130 |
// Filter $_POST data for users without the 'unfiltered_html' capability.
|
131 |
-
if( !acf_allow_unfiltered_html() ) {
|
132 |
$_POST['acf'] = wp_kses_post_deep( $_POST['acf'] );
|
133 |
}
|
134 |
-
|
135 |
// Do generic action.
|
136 |
do_action( 'acf/save_post', $post_id );
|
137 |
-
|
138 |
// Return true.
|
139 |
return true;
|
140 |
}
|
@@ -145,18 +150,18 @@ function acf_save_post( $post_id = 0, $values = null ) {
|
|
145 |
* Private function hooked into 'acf/save_post' to actually save the $_POST data.
|
146 |
* This allows developers to hook in before and after ACF has actually saved the data.
|
147 |
*
|
148 |
-
* @date
|
149 |
-
* @since
|
150 |
*
|
151 |
-
* @param
|
152 |
-
* @return
|
153 |
*/
|
154 |
function _acf_do_save_post( $post_id = 0 ) {
|
155 |
-
|
156 |
// Check and update $_POST data.
|
157 |
-
if( $_POST['acf'] ) {
|
158 |
acf_update_values( $_POST['acf'], $post_id );
|
159 |
-
}
|
160 |
}
|
161 |
|
162 |
// Run during generic action.
|
1 |
+
<?php
|
2 |
|
3 |
// Register store for form data.
|
4 |
acf_register_store( 'form' );
|
8 |
*
|
9 |
* Sets data about the current form.
|
10 |
*
|
11 |
+
* @date 6/10/13
|
12 |
+
* @since 5.0.0
|
13 |
*
|
14 |
+
* @param string $name The store name.
|
15 |
+
* @param array $data Array of data to start the store with.
|
16 |
+
* @return ACF_Data
|
17 |
*/
|
18 |
function acf_set_form_data( $name = '', $data = false ) {
|
19 |
return acf_get_store( 'form' )->set( $name, $data );
|
24 |
*
|
25 |
* Gets data about the current form.
|
26 |
*
|
27 |
+
* @date 6/10/13
|
28 |
+
* @since 5.0.0
|
29 |
*
|
30 |
+
* @param string $name The store name.
|
31 |
+
* @return mixed
|
32 |
*/
|
33 |
function acf_get_form_data( $name = '' ) {
|
34 |
return acf_get_store( 'form' )->get( $name );
|
39 |
*
|
40 |
* Called within a form to set important information and render hidden inputs.
|
41 |
*
|
42 |
+
* @date 15/10/13
|
43 |
+
* @since 5.0.0
|
44 |
*
|
45 |
+
* @param void
|
46 |
+
* @return void
|
47 |
*/
|
48 |
function acf_form_data( $data = array() ) {
|
49 |
+
|
50 |
// Apply defaults.
|
51 |
+
$data = wp_parse_args(
|
52 |
+
$data,
|
53 |
+
array(
|
54 |
+
|
55 |
+
/** @type string The current screen (post, user, taxonomy, etc). */
|
56 |
+
'screen' => 'post',
|
57 |
+
|
58 |
+
/** @type int|string The ID of current post being edited. */
|
59 |
+
'post_id' => 0,
|
60 |
+
|
61 |
+
/** @type bool Enables AJAX validation. */
|
62 |
+
'validation' => true,
|
63 |
+
)
|
64 |
+
);
|
65 |
+
|
66 |
// Create nonce using screen.
|
67 |
$data['nonce'] = wp_create_nonce( $data['screen'] );
|
68 |
+
|
69 |
// Append "changed" input used within "_wp_post_revision_fields" action.
|
70 |
$data['changed'] = 0;
|
71 |
+
|
72 |
// Set data.
|
73 |
acf_set_form_data( $data );
|
74 |
+
|
75 |
// Render HTML.
|
76 |
?>
|
77 |
<div id="acf-form-data" class="acf-hidden">
|
78 |
+
<?php
|
79 |
+
|
80 |
// Create hidden inputs from $data
|
81 |
+
foreach ( $data as $name => $value ) {
|
82 |
+
acf_hidden_input(
|
83 |
+
array(
|
84 |
+
'id' => '_acf_' . $name,
|
85 |
+
'name' => '_acf_' . $name,
|
86 |
+
'value' => $value,
|
87 |
+
)
|
88 |
+
);
|
89 |
}
|
90 |
+
|
91 |
/**
|
92 |
* Fires within the #acf-form-data element to add extra HTML.
|
93 |
*
|
94 |
+
* @date 15/10/13
|
95 |
+
* @since 5.0.0
|
96 |
*
|
97 |
+
* @param array $data The form data.
|
98 |
*/
|
99 |
do_action( 'acf/form_data', $data );
|
100 |
do_action( 'acf/input/form_data', $data );
|
101 |
+
|
102 |
?>
|
103 |
</div>
|
104 |
<?php
|
110 |
*
|
111 |
* Saves the $_POST data.
|
112 |
*
|
113 |
+
* @date 15/10/13
|
114 |
+
* @since 5.0.0
|
115 |
*
|
116 |
+
* @param int|string $post_id The post id.
|
117 |
+
* @param array $values An array of values to override $_POST.
|
118 |
+
* @return bool True if save was successful.
|
119 |
*/
|
120 |
function acf_save_post( $post_id = 0, $values = null ) {
|
121 |
+
|
122 |
// Override $_POST data with $values.
|
123 |
+
if ( $values !== null ) {
|
124 |
$_POST['acf'] = $values;
|
125 |
}
|
126 |
+
|
127 |
// Bail early if no data to save.
|
128 |
+
if ( empty( $_POST['acf'] ) ) {
|
129 |
return false;
|
130 |
}
|
131 |
+
|
132 |
// Set form data (useful in various filters/actions).
|
133 |
acf_set_form_data( 'post_id', $post_id );
|
134 |
+
|
135 |
// Filter $_POST data for users without the 'unfiltered_html' capability.
|
136 |
+
if ( ! acf_allow_unfiltered_html() ) {
|
137 |
$_POST['acf'] = wp_kses_post_deep( $_POST['acf'] );
|
138 |
}
|
139 |
+
|
140 |
// Do generic action.
|
141 |
do_action( 'acf/save_post', $post_id );
|
142 |
+
|
143 |
// Return true.
|
144 |
return true;
|
145 |
}
|
150 |
* Private function hooked into 'acf/save_post' to actually save the $_POST data.
|
151 |
* This allows developers to hook in before and after ACF has actually saved the data.
|
152 |
*
|
153 |
+
* @date 11/1/19
|
154 |
+
* @since 5.7.10
|
155 |
*
|
156 |
+
* @param int|string $post_id The post id.
|
157 |
+
* @return void
|
158 |
*/
|
159 |
function _acf_do_save_post( $post_id = 0 ) {
|
160 |
+
|
161 |
// Check and update $_POST data.
|
162 |
+
if ( $_POST['acf'] ) {
|
163 |
acf_update_values( $_POST['acf'], $post_id );
|
164 |
+
}
|
165 |
}
|
166 |
|
167 |
// Run during generic action.
|
includes/acf-helper-functions.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/*
|
4 |
* acf_is_empty
|
5 |
*
|
6 |
* Returns true if the value provided is considered "empty". Allows numbers such as 0.
|
7 |
*
|
8 |
-
* @date
|
9 |
-
* @since
|
10 |
*
|
11 |
-
* @param
|
12 |
-
* @return
|
13 |
*/
|
14 |
function acf_is_empty( $var ) {
|
15 |
-
return (
|
16 |
}
|
17 |
|
18 |
/**
|
@@ -20,14 +20,14 @@ function acf_is_empty( $var ) {
|
|
20 |
*
|
21 |
* Returns true if the value provided is considered "not empty". Allows numbers such as 0.
|
22 |
*
|
23 |
-
* @date
|
24 |
-
* @since
|
25 |
*
|
26 |
-
* @param
|
27 |
-
* @return
|
28 |
*/
|
29 |
function acf_not_empty( $var ) {
|
30 |
-
return ( $var || is_numeric($var) );
|
31 |
}
|
32 |
|
33 |
/**
|
@@ -35,20 +35,20 @@ function acf_not_empty( $var ) {
|
|
35 |
*
|
36 |
* Returns a unique numeric based id.
|
37 |
*
|
38 |
-
* @date
|
39 |
-
* @since
|
40 |
*
|
41 |
-
* @param
|
42 |
-
* @return
|
43 |
*/
|
44 |
function acf_uniqid( $prefix = 'acf' ) {
|
45 |
-
|
46 |
// Instantiate global counter.
|
47 |
global $acf_uniqid;
|
48 |
-
if( !isset($acf_uniqid) ) {
|
49 |
$acf_uniqid = 1;
|
50 |
}
|
51 |
-
|
52 |
// Return id.
|
53 |
return $prefix . '-' . $acf_uniqid++;
|
54 |
}
|
@@ -58,25 +58,25 @@ function acf_uniqid( $prefix = 'acf' ) {
|
|
58 |
*
|
59 |
* Merges together two arrays but with extra functionality to append class names.
|
60 |
*
|
61 |
-
* @date
|
62 |
-
* @since
|
63 |
*
|
64 |
-
* @param
|
65 |
-
* @param
|
66 |
-
* @return
|
67 |
*/
|
68 |
function acf_merge_attributes( $array1, $array2 ) {
|
69 |
-
|
70 |
// Merge together attributes.
|
71 |
$array3 = array_merge( $array1, $array2 );
|
72 |
-
|
73 |
// Append together special attributes.
|
74 |
-
foreach( array('class', 'style') as $key ) {
|
75 |
-
if( isset($array1[$key]) && isset($array2[$key]) ) {
|
76 |
-
$array3[$key] = trim($array1[$key]) . ' ' . trim($array2[$key]);
|
77 |
}
|
78 |
}
|
79 |
-
|
80 |
// Return.
|
81 |
return $array3;
|
82 |
}
|
@@ -86,24 +86,24 @@ function acf_merge_attributes( $array1, $array2 ) {
|
|
86 |
*
|
87 |
* Returns a filtered cache key.
|
88 |
*
|
89 |
-
* @date
|
90 |
-
* @since
|
91 |
*
|
92 |
-
* @param
|
93 |
-
* @return
|
94 |
*/
|
95 |
function acf_cache_key( $key = '' ) {
|
96 |
-
|
97 |
/**
|
98 |
* Filters the cache key.
|
99 |
*
|
100 |
-
* @date
|
101 |
-
* @since
|
102 |
*
|
103 |
-
* @param
|
104 |
-
* @param
|
105 |
*/
|
106 |
-
return apply_filters(
|
107 |
}
|
108 |
|
109 |
/**
|
@@ -111,15 +111,15 @@ function acf_cache_key( $key = '' ) {
|
|
111 |
*
|
112 |
* Returns an array of $_REQUEST values using the provided defaults.
|
113 |
*
|
114 |
-
* @date
|
115 |
-
* @since
|
116 |
*
|
117 |
-
* @param
|
118 |
-
* @return
|
119 |
*/
|
120 |
function acf_request_args( $args = array() ) {
|
121 |
-
foreach( $args as $k => $v ) {
|
122 |
-
$args[ $k ] = isset($_REQUEST[ $k ]) ? $_REQUEST[ $k ] : $args[ $k ];
|
123 |
}
|
124 |
return $args;
|
125 |
}
|
@@ -127,12 +127,12 @@ function acf_request_args( $args = array() ) {
|
|
127 |
/**
|
128 |
* Returns a single $_REQUEST arg with fallback.
|
129 |
*
|
130 |
-
* @date
|
131 |
-
* @since
|
132 |
*
|
133 |
-
* @param
|
134 |
-
* @param
|
135 |
-
* @return
|
136 |
*/
|
137 |
function acf_request_arg( $name = '', $default = null ) {
|
138 |
return isset( $_REQUEST[ $name ] ) ? $_REQUEST[ $name ] : $default;
|
@@ -146,11 +146,11 @@ acf_register_store( 'filters' );
|
|
146 |
*
|
147 |
* Enables a filter with the given name.
|
148 |
*
|
149 |
-
* @date
|
150 |
-
* @since
|
151 |
*
|
152 |
-
* @param
|
153 |
-
* @return
|
154 |
*/
|
155 |
function acf_enable_filter( $name = '' ) {
|
156 |
acf_get_store( 'filters' )->set( $name, true );
|
@@ -161,11 +161,11 @@ function acf_enable_filter( $name = '' ) {
|
|
161 |
*
|
162 |
* Disables a filter with the given name.
|
163 |
*
|
164 |
-
* @date
|
165 |
-
* @since
|
166 |
*
|
167 |
-
* @param
|
168 |
-
* @return
|
169 |
*/
|
170 |
function acf_disable_filter( $name = '' ) {
|
171 |
acf_get_store( 'filters' )->set( $name, false );
|
@@ -176,11 +176,11 @@ function acf_disable_filter( $name = '' ) {
|
|
176 |
*
|
177 |
* Returns the state of a filter for the given name.
|
178 |
*
|
179 |
-
* @date
|
180 |
-
* @since
|
181 |
*
|
182 |
-
* @param
|
183 |
-
* @return
|
184 |
*/
|
185 |
function acf_is_filter_enabled( $name = '' ) {
|
186 |
return acf_get_store( 'filters' )->get( $name );
|
@@ -191,11 +191,11 @@ function acf_is_filter_enabled( $name = '' ) {
|
|
191 |
*
|
192 |
* Returns an array of filters in their current state.
|
193 |
*
|
194 |
-
* @date
|
195 |
-
* @since
|
196 |
*
|
197 |
-
* @param
|
198 |
-
* @return
|
199 |
*/
|
200 |
function acf_get_filters() {
|
201 |
return acf_get_store( 'filters' )->get();
|
@@ -206,11 +206,11 @@ function acf_get_filters() {
|
|
206 |
*
|
207 |
* Sets an array of filter states.
|
208 |
*
|
209 |
-
* @date
|
210 |
-
* @since
|
211 |
*
|
212 |
-
* @param
|
213 |
-
* @return
|
214 |
*/
|
215 |
function acf_set_filters( $filters = array() ) {
|
216 |
acf_get_store( 'filters' )->set( $filters );
|
@@ -221,20 +221,20 @@ function acf_set_filters( $filters = array() ) {
|
|
221 |
*
|
222 |
* Disables all filters and returns the previous state.
|
223 |
*
|
224 |
-
* @date
|
225 |
-
* @since
|
226 |
*
|
227 |
-
* @param
|
228 |
-
* @return
|
229 |
*/
|
230 |
function acf_disable_filters() {
|
231 |
-
|
232 |
// Get state.
|
233 |
$prev_state = acf_get_filters();
|
234 |
-
|
235 |
// Set all modifers as false.
|
236 |
-
acf_set_filters( array_map('__return_false', $prev_state) );
|
237 |
-
|
238 |
// Return prev state.
|
239 |
return $prev_state;
|
240 |
}
|
@@ -244,26 +244,26 @@ function acf_disable_filters() {
|
|
244 |
*
|
245 |
* Enables all or an array of specific filters and returns the previous state.
|
246 |
*
|
247 |
-
* @date
|
248 |
-
* @since
|
249 |
*
|
250 |
-
* @param
|
251 |
-
* @return
|
252 |
*/
|
253 |
function acf_enable_filters( $filters = array() ) {
|
254 |
-
|
255 |
// Get state.
|
256 |
$prev_state = acf_get_filters();
|
257 |
-
|
258 |
// Allow specific filters to be enabled.
|
259 |
-
if( $filters ) {
|
260 |
acf_set_filters( $filters );
|
261 |
-
|
262 |
-
|
263 |
} else {
|
264 |
-
acf_set_filters( array_map('__return_true', $prev_state) );
|
265 |
}
|
266 |
-
|
267 |
// Return prev state.
|
268 |
return $prev_state;
|
269 |
}
|
@@ -273,27 +273,27 @@ function acf_enable_filters( $filters = array() ) {
|
|
273 |
*
|
274 |
* Parses the provided value for an ID.
|
275 |
*
|
276 |
-
* @date
|
277 |
-
* @since
|
278 |
*
|
279 |
-
* @param
|
280 |
-
* @return
|
281 |
*/
|
282 |
function acf_idval( $value ) {
|
283 |
-
|
284 |
// Check if value is numeric.
|
285 |
-
if( is_numeric($value) ) {
|
286 |
return (int) $value;
|
287 |
-
|
288 |
-
|
289 |
-
} elseif( is_array($value) ) {
|
290 |
-
return (int) isset($value['ID']) ? $value['ID'] : 0;
|
291 |
-
|
292 |
-
|
293 |
-
} elseif( is_object($value) ) {
|
294 |
-
return (int) isset($value->ID) ? $value->ID : 0;
|
295 |
}
|
296 |
-
|
297 |
// Return default.
|
298 |
return 0;
|
299 |
}
|
@@ -303,14 +303,14 @@ function acf_idval( $value ) {
|
|
303 |
*
|
304 |
* Checks value for potential id value.
|
305 |
*
|
306 |
-
* @date
|
307 |
-
* @since
|
308 |
*
|
309 |
-
* @param
|
310 |
-
* @return
|
311 |
*/
|
312 |
function acf_maybe_idval( $value ) {
|
313 |
-
if( $id = acf_idval( $value ) ) {
|
314 |
return $id;
|
315 |
}
|
316 |
return $value;
|
@@ -321,14 +321,14 @@ function acf_maybe_idval( $value ) {
|
|
321 |
*
|
322 |
* Casts the provided value as eiter an int or float using a simple hack.
|
323 |
*
|
324 |
-
* @date
|
325 |
-
* @since
|
326 |
*
|
327 |
-
* @param
|
328 |
-
* @return
|
329 |
*/
|
330 |
function acf_numval( $value ) {
|
331 |
-
return ( intval($value) == floatval($value) ) ? intval($value) : floatval($value);
|
332 |
}
|
333 |
|
334 |
/**
|
@@ -336,14 +336,14 @@ function acf_numval( $value ) {
|
|
336 |
*
|
337 |
* Returns an id attribute friendly string.
|
338 |
*
|
339 |
-
* @date
|
340 |
-
* @since
|
341 |
*
|
342 |
-
* @param
|
343 |
-
* @return
|
344 |
*/
|
345 |
function acf_idify( $str = '' ) {
|
346 |
-
return str_replace(array('][', '[', ']'), array('-', '-', ''), strtolower($str));
|
347 |
}
|
348 |
|
349 |
/**
|
@@ -351,28 +351,28 @@ function acf_idify( $str = '' ) {
|
|
351 |
*
|
352 |
* Returns a slug friendly string.
|
353 |
*
|
354 |
-
* @date
|
355 |
-
* @since
|
356 |
*
|
357 |
-
* @param
|
358 |
-
* @param
|
359 |
-
* @return
|
360 |
*/
|
361 |
function acf_slugify( $str = '', $glue = '-' ) {
|
362 |
-
return str_replace(array('_', '-', '/', ' '), $glue, strtolower($str));
|
363 |
}
|
364 |
|
365 |
/**
|
366 |
* Returns a string with correct full stop punctuation.
|
367 |
*
|
368 |
-
* @date
|
369 |
-
* @since
|
370 |
*
|
371 |
-
* @param
|
372 |
-
* @return
|
373 |
*/
|
374 |
function acf_punctify( $str = '' ) {
|
375 |
-
if ( substr( trim( strip_tags( $str ) ), -1) !== '.' ) {
|
376 |
return trim( $str ) . '.';
|
377 |
}
|
378 |
return trim( $str );
|
@@ -383,21 +383,21 @@ function acf_punctify( $str = '' ) {
|
|
383 |
*
|
384 |
* Returns true if ACF already did an event.
|
385 |
*
|
386 |
-
* @date
|
387 |
-
* @since
|
388 |
*
|
389 |
-
* @param
|
390 |
-
* @return
|
391 |
*/
|
392 |
function acf_did( $name ) {
|
393 |
-
|
394 |
// Return true if already did the event (preventing event).
|
395 |
-
if( acf_get_data("acf_did_$name") ) {
|
396 |
return true;
|
397 |
-
|
398 |
-
|
399 |
} else {
|
400 |
-
acf_set_data("acf_did_$name", true);
|
401 |
return false;
|
402 |
}
|
403 |
}
|
@@ -410,26 +410,26 @@ function acf_did( $name ) {
|
|
410 |
* 2. Decode special characters because wp_kses() will normalize entities.
|
411 |
* 3. Treat line-breaks as a single character instead of two.
|
412 |
* 4. Use mb_strlen() to accomodate special characters.
|
413 |
-
*
|
414 |
-
* @date 04/06/2020
|
415 |
-
* @since 5.9.0
|
416 |
*
|
417 |
-
* @
|
418 |
-
* @
|
|
|
|
|
|
|
419 |
*/
|
420 |
function acf_strlen( $str ) {
|
421 |
-
return mb_strlen( str_replace("\r\n", "\n", wp_specialchars_decode( wp_unslash( $str ) ) ) );
|
422 |
}
|
423 |
|
424 |
/**
|
425 |
* Returns a value with default fallback.
|
426 |
*
|
427 |
-
* @date
|
428 |
-
* @since
|
429 |
*
|
430 |
-
* @param
|
431 |
-
* @param
|
432 |
-
* @return
|
433 |
*/
|
434 |
function acf_with_default( $value, $default_value ) {
|
435 |
return $value ? $value : $default_value;
|
@@ -438,15 +438,15 @@ function acf_with_default( $value, $default_value ) {
|
|
438 |
/**
|
439 |
* Returns the current priority of a running action.
|
440 |
*
|
441 |
-
* @date
|
442 |
-
* @since
|
443 |
*
|
444 |
-
* @param
|
445 |
-
* @return
|
446 |
*/
|
447 |
function acf_doing_action( $action ) {
|
448 |
global $wp_filter;
|
449 |
-
if( isset( $wp_filter[ $action ] ) ) {
|
450 |
return $wp_filter[ $action ]->current_priority();
|
451 |
}
|
452 |
return false;
|
@@ -455,16 +455,16 @@ function acf_doing_action( $action ) {
|
|
455 |
/**
|
456 |
* Returns the current URL.
|
457 |
*
|
458 |
-
* @date
|
459 |
-
* @since
|
460 |
*
|
461 |
-
* @param
|
462 |
-
* @return
|
463 |
*/
|
464 |
function acf_get_current_url() {
|
465 |
// Ensure props exist to avoid PHP Notice during CLI commands.
|
466 |
-
if( isset( $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] ) ) {
|
467 |
return ( is_ssl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
468 |
}
|
469 |
return '';
|
470 |
-
}
|
1 |
+
<?php
|
2 |
|
3 |
/*
|
4 |
* acf_is_empty
|
5 |
*
|
6 |
* Returns true if the value provided is considered "empty". Allows numbers such as 0.
|
7 |
*
|
8 |
+
* @date 6/7/16
|
9 |
+
* @since 5.4.0
|
10 |
*
|
11 |
+
* @param mixed $var The value to check.
|
12 |
+
* @return bool
|
13 |
*/
|
14 |
function acf_is_empty( $var ) {
|
15 |
+
return ( ! $var && ! is_numeric( $var ) );
|
16 |
}
|
17 |
|
18 |
/**
|
20 |
*
|
21 |
* Returns true if the value provided is considered "not empty". Allows numbers such as 0.
|
22 |
*
|
23 |
+
* @date 15/7/19
|
24 |
+
* @since 5.8.1
|
25 |
*
|
26 |
+
* @param mixed $var The value to check.
|
27 |
+
* @return bool
|
28 |
*/
|
29 |
function acf_not_empty( $var ) {
|
30 |
+
return ( $var || is_numeric( $var ) );
|
31 |
}
|
32 |
|
33 |
/**
|
35 |
*
|
36 |
* Returns a unique numeric based id.
|
37 |
*
|
38 |
+
* @date 9/1/19
|
39 |
+
* @since 5.7.10
|
40 |
*
|
41 |
+
* @param string $prefix The id prefix. Defaults to 'acf'.
|
42 |
+
* @return string
|
43 |
*/
|
44 |
function acf_uniqid( $prefix = 'acf' ) {
|
45 |
+
|
46 |
// Instantiate global counter.
|
47 |
global $acf_uniqid;
|
48 |
+
if ( ! isset( $acf_uniqid ) ) {
|
49 |
$acf_uniqid = 1;
|
50 |
}
|
51 |
+
|
52 |
// Return id.
|
53 |
return $prefix . '-' . $acf_uniqid++;
|
54 |
}
|
58 |
*
|
59 |
* Merges together two arrays but with extra functionality to append class names.
|
60 |
*
|
61 |
+
* @date 22/1/19
|
62 |
+
* @since 5.7.10
|
63 |
*
|
64 |
+
* @param array $array1 An array of attributes.
|
65 |
+
* @param array $array2 An array of attributes.
|
66 |
+
* @return array
|
67 |
*/
|
68 |
function acf_merge_attributes( $array1, $array2 ) {
|
69 |
+
|
70 |
// Merge together attributes.
|
71 |
$array3 = array_merge( $array1, $array2 );
|
72 |
+
|
73 |
// Append together special attributes.
|
74 |
+
foreach ( array( 'class', 'style' ) as $key ) {
|
75 |
+
if ( isset( $array1[ $key ] ) && isset( $array2[ $key ] ) ) {
|
76 |
+
$array3[ $key ] = trim( $array1[ $key ] ) . ' ' . trim( $array2[ $key ] );
|
77 |
}
|
78 |
}
|
79 |
+
|
80 |
// Return.
|
81 |
return $array3;
|
82 |
}
|
86 |
*
|
87 |
* Returns a filtered cache key.
|
88 |
*
|
89 |
+
* @date 25/1/19
|
90 |
+
* @since 5.7.11
|
91 |
*
|
92 |
+
* @param string $key The cache key.
|
93 |
+
* @return string
|
94 |
*/
|
95 |
function acf_cache_key( $key = '' ) {
|
96 |
+
|
97 |
/**
|
98 |
* Filters the cache key.
|
99 |
*
|
100 |
+
* @date 25/1/19
|
101 |
+
* @since 5.7.11
|
102 |
*
|
103 |
+
* @param string $key The cache key.
|
104 |
+
* @param string $original_key The original cache key.
|
105 |
*/
|
106 |
+
return apply_filters( 'acf/get_cache_key', $key, $key );
|
107 |
}
|
108 |
|
109 |
/**
|
111 |
*
|
112 |
* Returns an array of $_REQUEST values using the provided defaults.
|
113 |
*
|
114 |
+
* @date 28/2/19
|
115 |
+
* @since 5.7.13
|
116 |
*
|
117 |
+
* @param array $args An array of args.
|
118 |
+
* @return array
|
119 |
*/
|
120 |
function acf_request_args( $args = array() ) {
|
121 |
+
foreach ( $args as $k => $v ) {
|
122 |
+
$args[ $k ] = isset( $_REQUEST[ $k ] ) ? $_REQUEST[ $k ] : $args[ $k ];
|
123 |
}
|
124 |
return $args;
|
125 |
}
|
127 |
/**
|
128 |
* Returns a single $_REQUEST arg with fallback.
|
129 |
*
|
130 |
+
* @date 23/10/20
|
131 |
+
* @since 5.9.2
|
132 |
*
|
133 |
+
* @param string $key The property name.
|
134 |
+
* @param mixed $default The default value to fallback to.
|
135 |
+
* @return mixed
|
136 |
*/
|
137 |
function acf_request_arg( $name = '', $default = null ) {
|
138 |
return isset( $_REQUEST[ $name ] ) ? $_REQUEST[ $name ] : $default;
|
146 |
*
|
147 |
* Enables a filter with the given name.
|
148 |
*
|
149 |
+
* @date 14/7/16
|
150 |
+
* @since 5.4.0
|
151 |
*
|
152 |
+
* @param string name The modifer name.
|
153 |
+
* @return void
|
154 |
*/
|
155 |
function acf_enable_filter( $name = '' ) {
|
156 |
acf_get_store( 'filters' )->set( $name, true );
|
161 |
*
|
162 |
* Disables a filter with the given name.
|
163 |
*
|
164 |
+
* @date 14/7/16
|
165 |
+
* @since 5.4.0
|
166 |
*
|
167 |
+
* @param string name The modifer name.
|
168 |
+
* @return void
|
169 |
*/
|
170 |
function acf_disable_filter( $name = '' ) {
|
171 |
acf_get_store( 'filters' )->set( $name, false );
|
176 |
*
|
177 |
* Returns the state of a filter for the given name.
|
178 |
*
|
179 |
+
* @date 14/7/16
|
180 |
+
* @since 5.4.0
|
181 |
*
|
182 |
+
* @param string name The modifer name.
|
183 |
+
* @return array
|
184 |
*/
|
185 |
function acf_is_filter_enabled( $name = '' ) {
|
186 |
return acf_get_store( 'filters' )->get( $name );
|
191 |
*
|
192 |
* Returns an array of filters in their current state.
|
193 |
*
|
194 |
+
* @date 14/7/16
|
195 |
+
* @since 5.4.0
|
196 |
*
|
197 |
+
* @param void
|
198 |
+
* @return array
|
199 |
*/
|
200 |
function acf_get_filters() {
|
201 |
return acf_get_store( 'filters' )->get();
|
206 |
*
|
207 |
* Sets an array of filter states.
|
208 |
*
|
209 |
+
* @date 14/7/16
|
210 |
+
* @since 5.4.0
|
211 |
*
|
212 |
+
* @param array $filters An Array of modifers
|
213 |
+
* @return array
|
214 |
*/
|
215 |
function acf_set_filters( $filters = array() ) {
|
216 |
acf_get_store( 'filters' )->set( $filters );
|
221 |
*
|
222 |
* Disables all filters and returns the previous state.
|
223 |
*
|
224 |
+
* @date 14/7/16
|
225 |
+
* @since 5.4.0
|
226 |
*
|
227 |
+
* @param void
|
228 |
+
* @return array
|
229 |
*/
|
230 |
function acf_disable_filters() {
|
231 |
+
|
232 |
// Get state.
|
233 |
$prev_state = acf_get_filters();
|
234 |
+
|
235 |
// Set all modifers as false.
|
236 |
+
acf_set_filters( array_map( '__return_false', $prev_state ) );
|
237 |
+
|
238 |
// Return prev state.
|
239 |
return $prev_state;
|
240 |
}
|
244 |
*
|
245 |
* Enables all or an array of specific filters and returns the previous state.
|
246 |
*
|
247 |
+
* @date 14/7/16
|
248 |
+
* @since 5.4.0
|
249 |
*
|
250 |
+
* @param array $filters An Array of modifers
|
251 |
+
* @return array
|
252 |
*/
|
253 |
function acf_enable_filters( $filters = array() ) {
|
254 |
+
|
255 |
// Get state.
|
256 |
$prev_state = acf_get_filters();
|
257 |
+
|
258 |
// Allow specific filters to be enabled.
|
259 |
+
if ( $filters ) {
|
260 |
acf_set_filters( $filters );
|
261 |
+
|
262 |
+
// Set all modifers as true.
|
263 |
} else {
|
264 |
+
acf_set_filters( array_map( '__return_true', $prev_state ) );
|
265 |
}
|
266 |
+
|
267 |
// Return prev state.
|
268 |
return $prev_state;
|
269 |
}
|
273 |
*
|
274 |
* Parses the provided value for an ID.
|
275 |
*
|
276 |
+
* @date 29/3/19
|
277 |
+
* @since 5.7.14
|
278 |
*
|
279 |
+
* @param mixed $value A value to parse.
|
280 |
+
* @return int
|
281 |
*/
|
282 |
function acf_idval( $value ) {
|
283 |
+
|
284 |
// Check if value is numeric.
|
285 |
+
if ( is_numeric( $value ) ) {
|
286 |
return (int) $value;
|
287 |
+
|
288 |
+
// Check if value is array.
|
289 |
+
} elseif ( is_array( $value ) ) {
|
290 |
+
return (int) isset( $value['ID'] ) ? $value['ID'] : 0;
|
291 |
+
|
292 |
+
// Check if value is object.
|
293 |
+
} elseif ( is_object( $value ) ) {
|
294 |
+
return (int) isset( $value->ID ) ? $value->ID : 0;
|
295 |
}
|
296 |
+
|
297 |
// Return default.
|
298 |
return 0;
|
299 |
}
|
303 |
*
|
304 |
* Checks value for potential id value.
|
305 |
*
|
306 |
+
* @date 6/4/19
|
307 |
+
* @since 5.7.14
|
308 |
*
|
309 |
+
* @param mixed $value A value to parse.
|
310 |
+
* @return mixed
|
311 |
*/
|
312 |
function acf_maybe_idval( $value ) {
|
313 |
+
if ( $id = acf_idval( $value ) ) {
|
314 |
return $id;
|
315 |
}
|
316 |
return $value;
|
321 |
*
|
322 |
* Casts the provided value as eiter an int or float using a simple hack.
|
323 |
*
|
324 |
+
* @date 11/4/19
|
325 |
+
* @since 5.7.14
|
326 |
*
|
327 |
+
* @param mixed $value A value to parse.
|
328 |
+
* @return (int|float)
|
329 |
*/
|
330 |
function acf_numval( $value ) {
|
331 |
+
return ( intval( $value ) == floatval( $value ) ) ? intval( $value ) : floatval( $value );
|
332 |
}
|
333 |
|
334 |
/**
|
336 |
*
|
337 |
* Returns an id attribute friendly string.
|
338 |
*
|
339 |
+
* @date 24/12/17
|
340 |
+
* @since 5.6.5
|
341 |
*
|
342 |
+
* @param string $str The string to convert.
|
343 |
+
* @return string
|
344 |
*/
|
345 |
function acf_idify( $str = '' ) {
|
346 |
+
return str_replace( array( '][', '[', ']' ), array( '-', '-', '' ), strtolower( $str ) );
|
347 |
}
|
348 |
|
349 |
/**
|
351 |
*
|
352 |
* Returns a slug friendly string.
|
353 |
*
|
354 |
+
* @date 24/12/17
|
355 |
+
* @since 5.6.5
|
356 |
*
|
357 |
+
* @param string $str The string to convert.
|
358 |
+
* @param string $glue The glue between each slug piece.
|
359 |
+
* @return string
|
360 |
*/
|
361 |
function acf_slugify( $str = '', $glue = '-' ) {
|
362 |
+
return str_replace( array( '_', '-', '/', ' ' ), $glue, strtolower( $str ) );
|
363 |
}
|
364 |
|
365 |
/**
|
366 |
* Returns a string with correct full stop punctuation.
|
367 |
*
|
368 |
+
* @date 12/7/19
|
369 |
+
* @since 5.8.2
|
370 |
*
|
371 |
+
* @param string $str The string to format.
|
372 |
+
* @return string
|
373 |
*/
|
374 |
function acf_punctify( $str = '' ) {
|
375 |
+
if ( substr( trim( strip_tags( $str ) ), -1 ) !== '.' ) {
|
376 |
return trim( $str ) . '.';
|
377 |
}
|
378 |
return trim( $str );
|
383 |
*
|
384 |
* Returns true if ACF already did an event.
|
385 |
*
|
386 |
+
* @date 30/8/19
|
387 |
+
* @since 5.8.1
|
388 |
*
|
389 |
+
* @param string $name The name of the event.
|
390 |
+
* @return bool
|
391 |
*/
|
392 |
function acf_did( $name ) {
|
393 |
+
|
394 |
// Return true if already did the event (preventing event).
|
395 |
+
if ( acf_get_data( "acf_did_$name" ) ) {
|
396 |
return true;
|
397 |
+
|
398 |
+
// Otherwise, update store and return false (alowing event).
|
399 |
} else {
|
400 |
+
acf_set_data( "acf_did_$name", true );
|
401 |
return false;
|
402 |
}
|
403 |
}
|
410 |
* 2. Decode special characters because wp_kses() will normalize entities.
|
411 |
* 3. Treat line-breaks as a single character instead of two.
|
412 |
* 4. Use mb_strlen() to accomodate special characters.
|
|
|
|
|
|
|
413 |
*
|
414 |
+
* @date 04/06/2020
|
415 |
+
* @since 5.9.0
|
416 |
+
*
|
417 |
+
* @param string $str The string to review.
|
418 |
+
* @return int
|
419 |
*/
|
420 |
function acf_strlen( $str ) {
|
421 |
+
return mb_strlen( str_replace( "\r\n", "\n", wp_specialchars_decode( wp_unslash( $str ) ) ) );
|
422 |
}
|
423 |
|
424 |
/**
|
425 |
* Returns a value with default fallback.
|
426 |
*
|
427 |
+
* @date 6/4/20
|
428 |
+
* @since 5.9.0
|
429 |
*
|
430 |
+
* @param mixed $value The value.
|
431 |
+
* @param mixed $default_value The default value.
|
432 |
+
* @return mixed
|
433 |
*/
|
434 |
function acf_with_default( $value, $default_value ) {
|
435 |
return $value ? $value : $default_value;
|
438 |
/**
|
439 |
* Returns the current priority of a running action.
|
440 |
*
|
441 |
+
* @date 14/07/2020
|
442 |
+
* @since 5.9.0
|
443 |
*
|
444 |
+
* @param string $action The action name.
|
445 |
+
* @return int|bool
|
446 |
*/
|
447 |
function acf_doing_action( $action ) {
|
448 |
global $wp_filter;
|
449 |
+
if ( isset( $wp_filter[ $action ] ) ) {
|
450 |
return $wp_filter[ $action ]->current_priority();
|
451 |
}
|
452 |
return false;
|
455 |
/**
|
456 |
* Returns the current URL.
|
457 |
*
|
458 |
+
* @date 23/01/2015
|
459 |
+
* @since 5.1.5
|
460 |
*
|
461 |
+
* @param void
|
462 |
+
* @return string
|
463 |
*/
|
464 |
function acf_get_current_url() {
|
465 |
// Ensure props exist to avoid PHP Notice during CLI commands.
|
466 |
+
if ( isset( $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] ) ) {
|
467 |
return ( is_ssl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
468 |
}
|
469 |
return '';
|
470 |
+
}
|
includes/acf-hook-functions.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'hook-variations' );
|
@@ -8,23 +8,26 @@ acf_register_store( 'hook-variations' );
|
|
8 |
*
|
9 |
* Registers variations for the given filter.
|
10 |
*
|
11 |
-
* @date
|
12 |
-
* @since
|
13 |
*
|
14 |
-
* @param
|
15 |
-
* @param
|
16 |
-
* @param
|
17 |
-
* @return
|
18 |
*/
|
19 |
function acf_add_filter_variations( $filter = '', $variations = array(), $index = 0 ) {
|
20 |
-
|
21 |
// Store replacement data.
|
22 |
-
acf_get_store('hook-variations')->set(
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
28 |
// Add generic handler.
|
29 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
30 |
add_filter( $filter, '_acf_apply_hook_variations', 10, 10 );
|
@@ -35,23 +38,26 @@ function acf_add_filter_variations( $filter = '', $variations = array(), $index
|
|
35 |
*
|
36 |
* Registers variations for the given action.
|
37 |
*
|
38 |
-
* @date
|
39 |
-
* @since
|
40 |
*
|
41 |
-
* @param
|
42 |
-
* @param
|
43 |
-
* @param
|
44 |
-
* @return
|
45 |
*/
|
46 |
function acf_add_action_variations( $action = '', $variations = array(), $index = 0 ) {
|
47 |
-
|
48 |
// Store replacement data.
|
49 |
-
acf_get_store('hook-variations')->set(
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
// Add generic handler.
|
56 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
57 |
add_action( $action, '_acf_apply_hook_variations', 10, 10 );
|
@@ -62,50 +68,50 @@ function acf_add_action_variations( $action = '', $variations = array(), $index
|
|
62 |
*
|
63 |
* Applys hook variations during apply_filters() or do_action().
|
64 |
*
|
65 |
-
* @date
|
66 |
-
* @since
|
67 |
*
|
68 |
-
* @param
|
69 |
-
* @return
|
70 |
*/
|
71 |
function _acf_apply_hook_variations() {
|
72 |
-
|
73 |
// Get current filter.
|
74 |
$filter = current_filter();
|
75 |
-
|
76 |
// Get args provided.
|
77 |
$args = func_get_args();
|
78 |
-
|
79 |
// Get variation information.
|
80 |
-
$variations = acf_get_store('hook-variations')->get( $filter );
|
81 |
extract( $variations );
|
82 |
-
|
83 |
// Find field in args using index.
|
84 |
$field = $args[ $index ];
|
85 |
-
|
86 |
// Loop over variations and apply filters.
|
87 |
-
foreach( $variations as $variation ) {
|
88 |
-
|
89 |
// Get value from field.
|
90 |
// First look for "backup" value ("_name", "_key").
|
91 |
-
if( isset($field[ "_$variation" ]) ) {
|
92 |
$value = $field[ "_$variation" ];
|
93 |
-
} elseif( isset($field[ $variation ]) ) {
|
94 |
$value = $field[ $variation ];
|
95 |
} else {
|
96 |
continue;
|
97 |
}
|
98 |
-
|
99 |
// Apply filters.
|
100 |
-
if( $type === 'filter' ) {
|
101 |
$args[0] = apply_filters_ref_array( "$filter/$variation=$value", $args );
|
102 |
-
|
103 |
-
|
104 |
} else {
|
105 |
do_action_ref_array( "$filter/$variation=$value", $args );
|
106 |
}
|
107 |
}
|
108 |
-
|
109 |
// Return first arg.
|
110 |
return $args[0];
|
111 |
}
|
@@ -118,24 +124,26 @@ acf_register_store( 'deprecated-hooks' );
|
|
118 |
*
|
119 |
* Registers a deprecated filter to run during the replacement.
|
120 |
*
|
121 |
-
* @date
|
122 |
-
* @since
|
123 |
*
|
124 |
-
* @param
|
125 |
-
* @param
|
126 |
-
* @param
|
127 |
-
* @return
|
128 |
*/
|
129 |
function acf_add_deprecated_filter( $deprecated, $version, $replacement ) {
|
130 |
-
|
131 |
// Store replacement data.
|
132 |
-
acf_get_store('deprecated-hooks')->append(
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
139 |
// Add generic handler.
|
140 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
141 |
add_filter( $replacement, '_acf_apply_deprecated_hook', 10, 10 );
|
@@ -146,24 +154,26 @@ function acf_add_deprecated_filter( $deprecated, $version, $replacement ) {
|
|
146 |
*
|
147 |
* Registers a deprecated action to run during the replacement.
|
148 |
*
|
149 |
-
* @date
|
150 |
-
* @since
|
151 |
*
|
152 |
-
* @param
|
153 |
-
* @param
|
154 |
-
* @param
|
155 |
-
* @return
|
156 |
*/
|
157 |
function acf_add_deprecated_action( $deprecated, $version, $replacement ) {
|
158 |
-
|
159 |
// Store replacement data.
|
160 |
-
acf_get_store('deprecated-hooks')->append(
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
167 |
// Add generic handler.
|
168 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
169 |
add_filter( $replacement, '_acf_apply_deprecated_hook', 10, 10 );
|
@@ -174,46 +184,46 @@ function acf_add_deprecated_action( $deprecated, $version, $replacement ) {
|
|
174 |
*
|
175 |
* Applys a deprecated filter during apply_filters() or do_action().
|
176 |
*
|
177 |
-
* @date
|
178 |
-
* @since
|
179 |
*
|
180 |
-
* @param
|
181 |
-
* @return
|
182 |
*/
|
183 |
function _acf_apply_deprecated_hook() {
|
184 |
-
|
185 |
// Get current hook.
|
186 |
$hook = current_filter();
|
187 |
-
|
188 |
// Get args provided.
|
189 |
$args = func_get_args();
|
190 |
-
|
191 |
// Get deprecated items for this hook.
|
192 |
-
$items = acf_get_store('deprecated-hooks')->query(array( 'replacement' => $hook ));
|
193 |
-
|
194 |
// Loop over results.
|
195 |
-
foreach( $items as $item ) {
|
196 |
-
|
197 |
// Extract data.
|
198 |
extract( $item );
|
199 |
-
|
200 |
// Check if anyone is hooked into this deprecated hook.
|
201 |
-
if( has_filter($deprecated) ) {
|
202 |
-
|
203 |
// Log warning.
|
204 |
-
//_deprecated_hook( $deprecated, $version, $hook );
|
205 |
-
|
206 |
// Apply filters.
|
207 |
-
if( $type === 'filter' ) {
|
208 |
$args[0] = apply_filters_ref_array( $deprecated, $args );
|
209 |
-
|
210 |
-
|
211 |
} else {
|
212 |
do_action_ref_array( $deprecated, $args );
|
213 |
}
|
214 |
}
|
215 |
}
|
216 |
-
|
217 |
// Return first arg.
|
218 |
return $args[0];
|
219 |
}
|
1 |
+
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'hook-variations' );
|
8 |
*
|
9 |
* Registers variations for the given filter.
|
10 |
*
|
11 |
+
* @date 26/1/19
|
12 |
+
* @since 5.7.11
|
13 |
*
|
14 |
+
* @param string $filter The filter name.
|
15 |
+
* @param array $variations An array variation keys.
|
16 |
+
* @param int $index The param index to find variation values.
|
17 |
+
* @return void
|
18 |
*/
|
19 |
function acf_add_filter_variations( $filter = '', $variations = array(), $index = 0 ) {
|
20 |
+
|
21 |
// Store replacement data.
|
22 |
+
acf_get_store( 'hook-variations' )->set(
|
23 |
+
$filter,
|
24 |
+
array(
|
25 |
+
'type' => 'filter',
|
26 |
+
'variations' => $variations,
|
27 |
+
'index' => $index,
|
28 |
+
)
|
29 |
+
);
|
30 |
+
|
31 |
// Add generic handler.
|
32 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
33 |
add_filter( $filter, '_acf_apply_hook_variations', 10, 10 );
|
38 |
*
|
39 |
* Registers variations for the given action.
|
40 |
*
|
41 |
+
* @date 26/1/19
|
42 |
+
* @since 5.7.11
|
43 |
*
|
44 |
+
* @param string $action The action name.
|
45 |
+
* @param array $variations An array variation keys.
|
46 |
+
* @param int $index The param index to find variation values.
|
47 |
+
* @return void
|
48 |
*/
|
49 |
function acf_add_action_variations( $action = '', $variations = array(), $index = 0 ) {
|
50 |
+
|
51 |
// Store replacement data.
|
52 |
+
acf_get_store( 'hook-variations' )->set(
|
53 |
+
$action,
|
54 |
+
array(
|
55 |
+
'type' => 'action',
|
56 |
+
'variations' => $variations,
|
57 |
+
'index' => $index,
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
// Add generic handler.
|
62 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
63 |
add_action( $action, '_acf_apply_hook_variations', 10, 10 );
|
68 |
*
|
69 |
* Applys hook variations during apply_filters() or do_action().
|
70 |
*
|
71 |
+
* @date 25/1/19
|
72 |
+
* @since 5.7.11
|
73 |
*
|
74 |
+
* @param mixed
|
75 |
+
* @return mixed
|
76 |
*/
|
77 |
function _acf_apply_hook_variations() {
|
78 |
+
|
79 |
// Get current filter.
|
80 |
$filter = current_filter();
|
81 |
+
|
82 |
// Get args provided.
|
83 |
$args = func_get_args();
|
84 |
+
|
85 |
// Get variation information.
|
86 |
+
$variations = acf_get_store( 'hook-variations' )->get( $filter );
|
87 |
extract( $variations );
|
88 |
+
|
89 |
// Find field in args using index.
|
90 |
$field = $args[ $index ];
|
91 |
+
|
92 |
// Loop over variations and apply filters.
|
93 |
+
foreach ( $variations as $variation ) {
|
94 |
+
|
95 |
// Get value from field.
|
96 |
// First look for "backup" value ("_name", "_key").
|
97 |
+
if ( isset( $field[ "_$variation" ] ) ) {
|
98 |
$value = $field[ "_$variation" ];
|
99 |
+
} elseif ( isset( $field[ $variation ] ) ) {
|
100 |
$value = $field[ $variation ];
|
101 |
} else {
|
102 |
continue;
|
103 |
}
|
104 |
+
|
105 |
// Apply filters.
|
106 |
+
if ( $type === 'filter' ) {
|
107 |
$args[0] = apply_filters_ref_array( "$filter/$variation=$value", $args );
|
108 |
+
|
109 |
+
// Or do action.
|
110 |
} else {
|
111 |
do_action_ref_array( "$filter/$variation=$value", $args );
|
112 |
}
|
113 |
}
|
114 |
+
|
115 |
// Return first arg.
|
116 |
return $args[0];
|
117 |
}
|
124 |
*
|
125 |
* Registers a deprecated filter to run during the replacement.
|
126 |
*
|
127 |
+
* @date 25/1/19
|
128 |
+
* @since 5.7.11
|
129 |
*
|
130 |
+
* @param string $deprecated The deprecated hook.
|
131 |
+
* @param string $version The version this hook was deprecated.
|
132 |
+
* @param string $replacement The replacement hook.
|
133 |
+
* @return void
|
134 |
*/
|
135 |
function acf_add_deprecated_filter( $deprecated, $version, $replacement ) {
|
136 |
+
|
137 |
// Store replacement data.
|
138 |
+
acf_get_store( 'deprecated-hooks' )->append(
|
139 |
+
array(
|
140 |
+
'type' => 'filter',
|
141 |
+
'deprecated' => $deprecated,
|
142 |
+
'replacement' => $replacement,
|
143 |
+
'version' => $version,
|
144 |
+
)
|
145 |
+
);
|
146 |
+
|
147 |
// Add generic handler.
|
148 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
149 |
add_filter( $replacement, '_acf_apply_deprecated_hook', 10, 10 );
|
154 |
*
|
155 |
* Registers a deprecated action to run during the replacement.
|
156 |
*
|
157 |
+
* @date 25/1/19
|
158 |
+
* @since 5.7.11
|
159 |
*
|
160 |
+
* @param string $deprecated The deprecated hook.
|
161 |
+
* @param string $version The version this hook was deprecated.
|
162 |
+
* @param string $replacement The replacement hook.
|
163 |
+
* @return void
|
164 |
*/
|
165 |
function acf_add_deprecated_action( $deprecated, $version, $replacement ) {
|
166 |
+
|
167 |
// Store replacement data.
|
168 |
+
acf_get_store( 'deprecated-hooks' )->append(
|
169 |
+
array(
|
170 |
+
'type' => 'action',
|
171 |
+
'deprecated' => $deprecated,
|
172 |
+
'replacement' => $replacement,
|
173 |
+
'version' => $version,
|
174 |
+
)
|
175 |
+
);
|
176 |
+
|
177 |
// Add generic handler.
|
178 |
// Use a priotiry of 10, and accepted args of 10 (ignored by WP).
|
179 |
add_filter( $replacement, '_acf_apply_deprecated_hook', 10, 10 );
|
184 |
*
|
185 |
* Applys a deprecated filter during apply_filters() or do_action().
|
186 |
*
|
187 |
+
* @date 25/1/19
|
188 |
+
* @since 5.7.11
|
189 |
*
|
190 |
+
* @param mixed
|
191 |
+
* @return mixed
|
192 |
*/
|
193 |
function _acf_apply_deprecated_hook() {
|
194 |
+
|
195 |
// Get current hook.
|
196 |
$hook = current_filter();
|
197 |
+
|
198 |
// Get args provided.
|
199 |
$args = func_get_args();
|
200 |
+
|
201 |
// Get deprecated items for this hook.
|
202 |
+
$items = acf_get_store( 'deprecated-hooks' )->query( array( 'replacement' => $hook ) );
|
203 |
+
|
204 |
// Loop over results.
|
205 |
+
foreach ( $items as $item ) {
|
206 |
+
|
207 |
// Extract data.
|
208 |
extract( $item );
|
209 |
+
|
210 |
// Check if anyone is hooked into this deprecated hook.
|
211 |
+
if ( has_filter( $deprecated ) ) {
|
212 |
+
|
213 |
// Log warning.
|
214 |
+
// _deprecated_hook( $deprecated, $version, $hook );
|
215 |
+
|
216 |
// Apply filters.
|
217 |
+
if ( $type === 'filter' ) {
|
218 |
$args[0] = apply_filters_ref_array( $deprecated, $args );
|
219 |
+
|
220 |
+
// Or do action.
|
221 |
} else {
|
222 |
do_action_ref_array( $deprecated, $args );
|
223 |
}
|
224 |
}
|
225 |
}
|
226 |
+
|
227 |
// Return first arg.
|
228 |
return $args[0];
|
229 |
}
|
includes/acf-input-functions.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/**
|
4 |
* acf_filter_attrs
|
5 |
*
|
6 |
* Filters out empty attrs from the provided array.
|
7 |
*
|
8 |
-
* @date
|
9 |
-
* @since
|
10 |
*
|
11 |
-
* @param
|
12 |
-
* @return
|
13 |
*/
|
14 |
function acf_filter_attrs( $attrs ) {
|
15 |
-
|
16 |
// Filter out empty attrs but allow "0" values.
|
17 |
$filtered = array_filter( $attrs, 'acf_not_empty' );
|
18 |
-
|
19 |
// Correct specific attributes (required="required").
|
20 |
-
foreach( array('required', 'readonly', 'disabled', 'multiple') as $key ) {
|
21 |
-
unset($filtered[ $key ]);
|
22 |
-
if( !empty($attrs[ $key ]) ) {
|
23 |
$filtered[ $key ] = $key;
|
24 |
}
|
25 |
}
|
@@ -31,128 +31,102 @@ function acf_filter_attrs( $attrs ) {
|
|
31 |
*
|
32 |
* Generated valid HTML from an array of attrs.
|
33 |
*
|
34 |
-
* @date
|
35 |
-
* @since
|
36 |
*
|
37 |
-
* @param
|
38 |
-
* @return
|
39 |
*/
|
40 |
function acf_esc_attrs( $attrs ) {
|
41 |
$html = '';
|
42 |
-
|
43 |
// Loop over attrs and validate data types.
|
44 |
-
foreach( $attrs as $k => $v ) {
|
45 |
-
|
46 |
// String (but don't trim value).
|
47 |
-
if( is_string($v) && ($k !== 'value') ) {
|
48 |
-
$v = trim($v);
|
49 |
-
|
50 |
-
|
51 |
-
} elseif( is_bool($v) ) {
|
52 |
$v = $v ? 1 : 0;
|
53 |
-
|
54 |
-
|
55 |
-
} elseif( is_array($v) || is_object($v) ) {
|
56 |
-
$v = json_encode($v);
|
57 |
}
|
58 |
-
|
59 |
// Generate HTML.
|
60 |
-
$html .= sprintf( ' %s="%s"', esc_attr($k), esc_attr($v) );
|
61 |
}
|
62 |
-
|
63 |
// Return trimmed.
|
64 |
return trim( $html );
|
65 |
}
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
return $allowedposttags;
|
100 |
-
}
|
101 |
-
return $tags;
|
102 |
-
}
|
103 |
-
|
104 |
-
add_filter( 'wp_kses_allowed_html', '_acf_kses_allowed_html', 0, 2 );
|
105 |
-
|
106 |
-
} else {
|
107 |
-
|
108 |
-
/**
|
109 |
-
* acf_esc_html
|
110 |
-
*
|
111 |
-
* Encodes <script> tags for safe HTML output.
|
112 |
-
*
|
113 |
-
* @date 12/6/19
|
114 |
-
* @since 5.8.1
|
115 |
-
*
|
116 |
-
* @param string $string
|
117 |
-
* @return string
|
118 |
-
*/
|
119 |
-
function acf_esc_html( $string = '' ) {
|
120 |
-
$string = strval($string);
|
121 |
-
|
122 |
-
// Encode "<script" tags to invalidate DOM elements.
|
123 |
-
if( strpos($string, '<script') !== false ) {
|
124 |
-
$string = str_replace('<script', htmlspecialchars('<script'), $string);
|
125 |
-
$string = str_replace('</script', htmlspecialchars('</script'), $string);
|
126 |
-
}
|
127 |
-
return $string;
|
128 |
}
|
|
|
129 |
}
|
130 |
|
|
|
|
|
131 |
/**
|
132 |
* acf_html_input
|
133 |
*
|
134 |
* Returns the HTML of an input.
|
135 |
*
|
136 |
-
* @date
|
137 |
-
* @since
|
138 |
*
|
139 |
-
* @param
|
140 |
-
* @return
|
141 |
*/
|
142 |
-
//function acf_html_input( $attrs = array() ) {
|
143 |
-
//
|
144 |
-
//}
|
145 |
|
146 |
/**
|
147 |
* acf_hidden_input
|
148 |
*
|
149 |
* Renders the HTML of a hidden input.
|
150 |
*
|
151 |
-
* @date
|
152 |
-
* @since
|
153 |
*
|
154 |
-
* @param
|
155 |
-
* @return
|
156 |
*/
|
157 |
function acf_hidden_input( $attrs = array() ) {
|
158 |
echo acf_get_hidden_input( $attrs );
|
@@ -163,14 +137,14 @@ function acf_hidden_input( $attrs = array() ) {
|
|
163 |
*
|
164 |
* Returns the HTML of a hidden input.
|
165 |
*
|
166 |
-
* @date
|
167 |
-
* @since
|
168 |
*
|
169 |
-
* @param
|
170 |
-
* @return
|
171 |
*/
|
172 |
function acf_get_hidden_input( $attrs = array() ) {
|
173 |
-
return sprintf( '<input type="hidden" %s/>', acf_esc_attrs($attrs) );
|
174 |
}
|
175 |
|
176 |
/**
|
@@ -178,11 +152,11 @@ function acf_get_hidden_input( $attrs = array() ) {
|
|
178 |
*
|
179 |
* Renders the HTML of a text input.
|
180 |
*
|
181 |
-
* @date
|
182 |
-
* @since
|
183 |
*
|
184 |
-
* @param
|
185 |
-
* @return
|
186 |
*/
|
187 |
function acf_text_input( $attrs = array() ) {
|
188 |
echo acf_get_text_input( $attrs );
|
@@ -193,16 +167,19 @@ function acf_text_input( $attrs = array() ) {
|
|
193 |
*
|
194 |
* Returns the HTML of a text input.
|
195 |
*
|
196 |
-
* @date
|
197 |
-
* @since
|
198 |
*
|
199 |
-
* @param
|
200 |
-
* @return
|
201 |
*/
|
202 |
function acf_get_text_input( $attrs = array() ) {
|
203 |
-
$attrs = wp_parse_args(
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
206 |
if ( isset( $attrs['value'] ) && is_string( $attrs['value'] ) ) {
|
207 |
$attrs['value'] = htmlspecialchars( $attrs['value'] );
|
208 |
}
|
@@ -214,11 +191,11 @@ function acf_get_text_input( $attrs = array() ) {
|
|
214 |
*
|
215 |
* Renders the HTML of a file input.
|
216 |
*
|
217 |
-
* @date
|
218 |
-
* @since
|
219 |
*
|
220 |
-
* @param
|
221 |
-
* @return
|
222 |
*/
|
223 |
function acf_file_input( $attrs = array() ) {
|
224 |
echo acf_get_file_input( $attrs );
|
@@ -229,14 +206,14 @@ function acf_file_input( $attrs = array() ) {
|
|
229 |
*
|
230 |
* Returns the HTML of a file input.
|
231 |
*
|
232 |
-
* @date
|
233 |
-
* @since
|
234 |
*
|
235 |
-
* @param
|
236 |
-
* @return
|
237 |
*/
|
238 |
function acf_get_file_input( $attrs = array() ) {
|
239 |
-
return sprintf( '<input type="file" %s/>', acf_esc_attrs($attrs) );
|
240 |
}
|
241 |
|
242 |
/**
|
@@ -244,11 +221,11 @@ function acf_get_file_input( $attrs = array() ) {
|
|
244 |
*
|
245 |
* Renders the HTML of a textarea input.
|
246 |
*
|
247 |
-
* @date
|
248 |
-
* @since
|
249 |
*
|
250 |
-
* @param
|
251 |
-
* @return
|
252 |
*/
|
253 |
function acf_textarea_input( $attrs = array() ) {
|
254 |
echo acf_get_textarea_input( $attrs );
|
@@ -259,19 +236,19 @@ function acf_textarea_input( $attrs = array() ) {
|
|
259 |
*
|
260 |
* Returns the HTML of a textarea input.
|
261 |
*
|
262 |
-
* @date
|
263 |
-
* @since
|
264 |
*
|
265 |
-
* @param
|
266 |
-
* @return
|
267 |
*/
|
268 |
function acf_get_textarea_input( $attrs = array() ) {
|
269 |
$value = '';
|
270 |
-
if( isset($attrs['value']) ) {
|
271 |
$value = $attrs['value'];
|
272 |
unset( $attrs['value'] );
|
273 |
}
|
274 |
-
return sprintf( '<textarea %s>%s</textarea>', acf_esc_attrs($attrs), esc_textarea($value) );
|
275 |
}
|
276 |
|
277 |
/**
|
@@ -279,11 +256,11 @@ function acf_get_textarea_input( $attrs = array() ) {
|
|
279 |
*
|
280 |
* Renders the HTML of a checkbox input.
|
281 |
*
|
282 |
-
* @date
|
283 |
-
* @since
|
284 |
*
|
285 |
-
* @param
|
286 |
-
* @return
|
287 |
*/
|
288 |
function acf_checkbox_input( $attrs = array() ) {
|
289 |
echo acf_get_checkbox_input( $attrs );
|
@@ -294,29 +271,32 @@ function acf_checkbox_input( $attrs = array() ) {
|
|
294 |
*
|
295 |
* Returns the HTML of a checkbox input.
|
296 |
*
|
297 |
-
* @date
|
298 |
-
* @since
|
299 |
*
|
300 |
-
* @param
|
301 |
-
* @return
|
302 |
*/
|
303 |
function acf_get_checkbox_input( $attrs = array() ) {
|
304 |
-
|
305 |
// Allow radio or checkbox type.
|
306 |
-
$attrs = wp_parse_args(
|
307 |
-
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
310 |
// Get label.
|
311 |
$label = '';
|
312 |
-
if( isset($attrs['label']) ) {
|
313 |
-
$label= $attrs['label'];
|
314 |
unset( $attrs['label'] );
|
315 |
}
|
316 |
-
|
317 |
// Render.
|
318 |
-
$checked = isset($attrs['checked']);
|
319 |
-
return '<label' . ($checked ? ' class="selected"' : '') . '><input ' . acf_esc_attr($attrs) . '/> ' . acf_esc_html($label) . '</label>';
|
320 |
}
|
321 |
|
322 |
/**
|
@@ -324,11 +304,11 @@ function acf_get_checkbox_input( $attrs = array() ) {
|
|
324 |
*
|
325 |
* Renders the HTML of a radio input.
|
326 |
*
|
327 |
-
* @date
|
328 |
-
* @since
|
329 |
*
|
330 |
-
* @param
|
331 |
-
* @return
|
332 |
*/
|
333 |
function acf_radio_input( $attrs = array() ) {
|
334 |
echo acf_get_radio_input( $attrs );
|
@@ -339,11 +319,11 @@ function acf_radio_input( $attrs = array() ) {
|
|
339 |
*
|
340 |
* Returns the HTML of a radio input.
|
341 |
*
|
342 |
-
* @date
|
343 |
-
* @since
|
344 |
*
|
345 |
-
* @param
|
346 |
-
* @return
|
347 |
*/
|
348 |
function acf_get_radio_input( $attrs = array() ) {
|
349 |
$attrs['type'] = 'radio';
|
@@ -355,11 +335,11 @@ function acf_get_radio_input( $attrs = array() ) {
|
|
355 |
*
|
356 |
* Renders the HTML of a select input.
|
357 |
*
|
358 |
-
* @date
|
359 |
-
* @since
|
360 |
*
|
361 |
-
* @param
|
362 |
-
* @return
|
363 |
*/
|
364 |
function acf_select_input( $attrs = array() ) {
|
365 |
echo acf_get_select_input( $attrs );
|
@@ -370,19 +350,19 @@ function acf_select_input( $attrs = array() ) {
|
|
370 |
*
|
371 |
* Returns the HTML of a select input.
|
372 |
*
|
373 |
-
* @date
|
374 |
-
* @since
|
375 |
*
|
376 |
-
* @param
|
377 |
-
* @return
|
378 |
*/
|
379 |
function acf_get_select_input( $attrs = array() ) {
|
380 |
-
$value
|
381 |
$choices = (array) acf_extract_var( $attrs, 'choices' );
|
382 |
return sprintf(
|
383 |
'<select %s>%s</select>',
|
384 |
-
acf_esc_attrs($attrs),
|
385 |
-
acf_walk_select_input($choices, $value)
|
386 |
);
|
387 |
}
|
388 |
|
@@ -391,47 +371,47 @@ function acf_get_select_input( $attrs = array() ) {
|
|
391 |
*
|
392 |
* Returns the HTML of a select input's choices.
|
393 |
*
|
394 |
-
* @date
|
395 |
-
* @since
|
396 |
*
|
397 |
-
* @param
|
398 |
-
* @param
|
399 |
-
* @param
|
400 |
-
* @return
|
401 |
*/
|
402 |
function acf_walk_select_input( $choices = array(), $values = array(), $depth = 0 ) {
|
403 |
$html = '';
|
404 |
-
|
405 |
// Sanitize values for 'selected' matching (only once).
|
406 |
-
if( $depth == 0 ) {
|
407 |
-
$values = array_map('esc_attr', $values);
|
408 |
}
|
409 |
-
|
410 |
// Loop over choices and append to html.
|
411 |
-
if( $choices ) {
|
412 |
-
foreach( $choices as $value => $label ) {
|
413 |
-
|
414 |
// Multiple (optgroup)
|
415 |
-
if( is_array($label) ){
|
416 |
$html .= sprintf(
|
417 |
'<optgroup label="%s">%s</optgroup>',
|
418 |
-
esc_attr($value),
|
419 |
-
acf_walk_select_input( $label, $values, $depth+1 )
|
420 |
);
|
421 |
-
|
422 |
-
|
423 |
} else {
|
424 |
$attrs = array(
|
425 |
-
'value' => $value
|
426 |
);
|
427 |
-
|
428 |
// If is selected.
|
429 |
-
$pos = array_search( esc_attr($value), $values );
|
430 |
-
if( $pos !== false ) {
|
431 |
$attrs['selected'] = 'selected';
|
432 |
-
$attrs['data-i']
|
433 |
}
|
434 |
-
$html .= sprintf( '<option %s>%s</option>', acf_esc_attr($attrs), esc_html($label) );
|
435 |
}
|
436 |
}
|
437 |
}
|
@@ -443,11 +423,11 @@ function acf_walk_select_input( $choices = array(), $values = array(), $depth =
|
|
443 |
*
|
444 |
* See acf_filter_attrs().
|
445 |
*
|
446 |
-
* @date
|
447 |
-
* @since
|
448 |
*
|
449 |
-
* @param
|
450 |
-
* @return
|
451 |
*/
|
452 |
function acf_clean_atts( $attrs ) {
|
453 |
return acf_filter_attrs( $attrs );
|
@@ -458,11 +438,11 @@ function acf_clean_atts( $attrs ) {
|
|
458 |
*
|
459 |
* See acf_esc_attrs().
|
460 |
*
|
461 |
-
* @date
|
462 |
-
* @since
|
463 |
*
|
464 |
-
* @param
|
465 |
-
* @return
|
466 |
*/
|
467 |
function acf_esc_atts( $attrs ) {
|
468 |
return acf_esc_attrs( $attrs );
|
@@ -473,12 +453,12 @@ function acf_esc_atts( $attrs ) {
|
|
473 |
*
|
474 |
* See acf_esc_attrs().
|
475 |
*
|
476 |
-
* @date
|
477 |
-
* @since
|
478 |
-
* @deprecated
|
479 |
*
|
480 |
-
* @param
|
481 |
-
* @return
|
482 |
*/
|
483 |
function acf_esc_attr( $attrs ) {
|
484 |
return acf_esc_attrs( $attrs );
|
@@ -489,12 +469,12 @@ function acf_esc_attr( $attrs ) {
|
|
489 |
*
|
490 |
* See acf_esc_attrs().
|
491 |
*
|
492 |
-
* @date
|
493 |
-
* @since
|
494 |
-
* @deprecated
|
495 |
*
|
496 |
-
* @param
|
497 |
-
* @return
|
498 |
*/
|
499 |
function acf_esc_attr_e( $attrs ) {
|
500 |
echo acf_esc_attrs( $attrs );
|
@@ -505,12 +485,12 @@ function acf_esc_attr_e( $attrs ) {
|
|
505 |
*
|
506 |
* See acf_esc_attrs().
|
507 |
*
|
508 |
-
* @date
|
509 |
-
* @since
|
510 |
-
* @deprecated
|
511 |
*
|
512 |
-
* @param
|
513 |
-
* @return
|
514 |
*/
|
515 |
function acf_esc_atts_e( $attrs ) {
|
516 |
echo acf_esc_attrs( $attrs );
|
1 |
+
<?php
|
2 |
|
3 |
/**
|
4 |
* acf_filter_attrs
|
5 |
*
|
6 |
* Filters out empty attrs from the provided array.
|
7 |
*
|
8 |
+
* @date 11/6/19
|
9 |
+
* @since 5.8.1
|
10 |
*
|
11 |
+
* @param array $attrs The array of attrs.
|
12 |
+
* @return array
|
13 |
*/
|
14 |
function acf_filter_attrs( $attrs ) {
|
15 |
+
|
16 |
// Filter out empty attrs but allow "0" values.
|
17 |
$filtered = array_filter( $attrs, 'acf_not_empty' );
|
18 |
+
|
19 |
// Correct specific attributes (required="required").
|
20 |
+
foreach ( array( 'required', 'readonly', 'disabled', 'multiple' ) as $key ) {
|
21 |
+
unset( $filtered[ $key ] );
|
22 |
+
if ( ! empty( $attrs[ $key ] ) ) {
|
23 |
$filtered[ $key ] = $key;
|
24 |
}
|
25 |
}
|
31 |
*
|
32 |
* Generated valid HTML from an array of attrs.
|
33 |
*
|
34 |
+
* @date 11/6/19
|
35 |
+
* @since 5.8.1
|
36 |
*
|
37 |
+
* @param array $attrs The array of attrs.
|
38 |
+
* @return string
|
39 |
*/
|
40 |
function acf_esc_attrs( $attrs ) {
|
41 |
$html = '';
|
42 |
+
|
43 |
// Loop over attrs and validate data types.
|
44 |
+
foreach ( $attrs as $k => $v ) {
|
45 |
+
|
46 |
// String (but don't trim value).
|
47 |
+
if ( is_string( $v ) && ( $k !== 'value' ) ) {
|
48 |
+
$v = trim( $v );
|
49 |
+
|
50 |
+
// Boolean
|
51 |
+
} elseif ( is_bool( $v ) ) {
|
52 |
$v = $v ? 1 : 0;
|
53 |
+
|
54 |
+
// Object
|
55 |
+
} elseif ( is_array( $v ) || is_object( $v ) ) {
|
56 |
+
$v = json_encode( $v );
|
57 |
}
|
58 |
+
|
59 |
// Generate HTML.
|
60 |
+
$html .= sprintf( ' %s="%s"', esc_attr( $k ), esc_attr( $v ) );
|
61 |
}
|
62 |
+
|
63 |
// Return trimmed.
|
64 |
return trim( $html );
|
65 |
}
|
66 |
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Sanitizes text content and strips out disallowed HTML.
|
70 |
+
*
|
71 |
+
* This function emulates `wp_kses_post()` with a context of "acf" for extensibility.
|
72 |
+
*
|
73 |
+
* @date 16/4/21
|
74 |
+
* @since 5.9.6
|
75 |
+
*
|
76 |
+
* @param string $string
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
function acf_esc_html( $string = '' ) {
|
80 |
+
return wp_kses( (string) $string, 'acf' );
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Private callback for the "wp_kses_allowed_html" filter used to return allowed HTML for "acf" context.
|
85 |
+
*
|
86 |
+
* @date 16/4/21
|
87 |
+
* @since 5.9.6
|
88 |
+
*
|
89 |
+
* @param array $tags An array of allowed tags.
|
90 |
+
* @param string $context The context name.
|
91 |
+
* @return array.
|
92 |
+
*/
|
93 |
+
|
94 |
+
function _acf_kses_allowed_html( $tags, $context ) {
|
95 |
+
global $allowedposttags;
|
96 |
+
|
97 |
+
if ( $context === 'acf' ) {
|
98 |
+
return $allowedposttags;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
+
return $tags;
|
101 |
}
|
102 |
|
103 |
+
add_filter( 'wp_kses_allowed_html', '_acf_kses_allowed_html', 0, 2 );
|
104 |
+
|
105 |
/**
|
106 |
* acf_html_input
|
107 |
*
|
108 |
* Returns the HTML of an input.
|
109 |
*
|
110 |
+
* @date 13/6/19
|
111 |
+
* @since 5.8.1
|
112 |
*
|
113 |
+
* @param array $attrs The array of attrs.
|
114 |
+
* @return string
|
115 |
*/
|
116 |
+
// function acf_html_input( $attrs = array() ) {
|
117 |
+
// return sprintf( '<input %s/>', acf_esc_attrs($attrs) );
|
118 |
+
// }
|
119 |
|
120 |
/**
|
121 |
* acf_hidden_input
|
122 |
*
|
123 |
* Renders the HTML of a hidden input.
|
124 |
*
|
125 |
+
* @date 3/02/2014
|
126 |
+
* @since 5.0.0
|
127 |
*
|
128 |
+
* @param array $attrs The array of attrs.
|
129 |
+
* @return string
|
130 |
*/
|
131 |
function acf_hidden_input( $attrs = array() ) {
|
132 |
echo acf_get_hidden_input( $attrs );
|
137 |
*
|
138 |
* Returns the HTML of a hidden input.
|
139 |
*
|
140 |
+
* @date 3/02/2014
|
141 |
+
* @since 5.0.0
|
142 |
*
|
143 |
+
* @param array $attrs The array of attrs.
|
144 |
+
* @return string
|
145 |
*/
|
146 |
function acf_get_hidden_input( $attrs = array() ) {
|
147 |
+
return sprintf( '<input type="hidden" %s/>', acf_esc_attrs( $attrs ) );
|
148 |
}
|
149 |
|
150 |
/**
|
152 |
*
|
153 |
* Renders the HTML of a text input.
|
154 |
*
|
155 |
+
* @date 3/02/2014
|
156 |
+
* @since 5.0.0
|
157 |
*
|
158 |
+
* @param array $attrs The array of attrs.
|
159 |
+
* @return string
|
160 |
*/
|
161 |
function acf_text_input( $attrs = array() ) {
|
162 |
echo acf_get_text_input( $attrs );
|
167 |
*
|
168 |
* Returns the HTML of a text input.
|
169 |
*
|
170 |
+
* @date 3/02/2014
|
171 |
+
* @since 5.0.0
|
172 |
*
|
173 |
+
* @param array $attrs The array of attrs.
|
174 |
+
* @return string
|
175 |
*/
|
176 |
function acf_get_text_input( $attrs = array() ) {
|
177 |
+
$attrs = wp_parse_args(
|
178 |
+
$attrs,
|
179 |
+
array(
|
180 |
+
'type' => 'text',
|
181 |
+
)
|
182 |
+
);
|
183 |
if ( isset( $attrs['value'] ) && is_string( $attrs['value'] ) ) {
|
184 |
$attrs['value'] = htmlspecialchars( $attrs['value'] );
|
185 |
}
|
191 |
*
|
192 |
* Renders the HTML of a file input.
|
193 |
*
|
194 |
+
* @date 3/02/2014
|
195 |
+
* @since 5.0.0
|
196 |
*
|
197 |
+
* @param array $attrs The array of attrs.
|
198 |
+
* @return string
|
199 |
*/
|
200 |
function acf_file_input( $attrs = array() ) {
|
201 |
echo acf_get_file_input( $attrs );
|
206 |
*
|
207 |
* Returns the HTML of a file input.
|
208 |
*
|
209 |
+
* @date 3/02/2014
|
210 |
+
* @since 5.0.0
|
211 |
*
|
212 |
+
* @param array $attrs The array of attrs.
|
213 |
+
* @return string
|
214 |
*/
|
215 |
function acf_get_file_input( $attrs = array() ) {
|
216 |
+
return sprintf( '<input type="file" %s/>', acf_esc_attrs( $attrs ) );
|
217 |
}
|
218 |
|
219 |
/**
|
221 |
*
|
222 |
* Renders the HTML of a textarea input.
|
223 |
*
|
224 |
+
* @date 3/02/2014
|
225 |
+
* @since 5.0.0
|
226 |
*
|
227 |
+
* @param array $attrs The array of attrs.
|
228 |
+
* @return string
|
229 |
*/
|
230 |
function acf_textarea_input( $attrs = array() ) {
|
231 |
echo acf_get_textarea_input( $attrs );
|
236 |
*
|
237 |
* Returns the HTML of a textarea input.
|
238 |
*
|
239 |
+
* @date 3/02/2014
|
240 |
+
* @since 5.0.0
|
241 |
*
|
242 |
+
* @param array $attrs The array of attrs.
|
243 |
+
* @return string
|
244 |
*/
|
245 |
function acf_get_textarea_input( $attrs = array() ) {
|
246 |
$value = '';
|
247 |
+
if ( isset( $attrs['value'] ) ) {
|
248 |
$value = $attrs['value'];
|
249 |
unset( $attrs['value'] );
|
250 |
}
|
251 |
+
return sprintf( '<textarea %s>%s</textarea>', acf_esc_attrs( $attrs ), esc_textarea( $value ) );
|
252 |
}
|
253 |
|
254 |
/**
|
256 |
*
|
257 |
* Renders the HTML of a checkbox input.
|
258 |
*
|
259 |
+
* @date 3/02/2014
|
260 |
+
* @since 5.0.0
|
261 |
*
|
262 |
+
* @param array $attrs The array of attrs.
|
263 |
+
* @return string
|
264 |
*/
|
265 |
function acf_checkbox_input( $attrs = array() ) {
|
266 |
echo acf_get_checkbox_input( $attrs );
|
271 |
*
|
272 |
* Returns the HTML of a checkbox input.
|
273 |
*
|
274 |
+
* @date 3/02/2014
|
275 |
+
* @since 5.0.0
|
276 |
*
|
277 |
+
* @param array $attrs The array of attrs.
|
278 |
+
* @return string
|
279 |
*/
|
280 |
function acf_get_checkbox_input( $attrs = array() ) {
|
281 |
+
|
282 |
// Allow radio or checkbox type.
|
283 |
+
$attrs = wp_parse_args(
|
284 |
+
$attrs,
|
285 |
+
array(
|
286 |
+
'type' => 'checkbox',
|
287 |
+
)
|
288 |
+
);
|
289 |
+
|
290 |
// Get label.
|
291 |
$label = '';
|
292 |
+
if ( isset( $attrs['label'] ) ) {
|
293 |
+
$label = $attrs['label'];
|
294 |
unset( $attrs['label'] );
|
295 |
}
|
296 |
+
|
297 |
// Render.
|
298 |
+
$checked = isset( $attrs['checked'] );
|
299 |
+
return '<label' . ( $checked ? ' class="selected"' : '' ) . '><input ' . acf_esc_attr( $attrs ) . '/> ' . acf_esc_html( $label ) . '</label>';
|
300 |
}
|
301 |
|
302 |
/**
|
304 |
*
|
305 |
* Renders the HTML of a radio input.
|
306 |
*
|
307 |
+
* @date 3/02/2014
|
308 |
+
* @since 5.0.0
|
309 |
*
|
310 |
+
* @param array $attrs The array of attrs.
|
311 |
+
* @return string
|
312 |
*/
|
313 |
function acf_radio_input( $attrs = array() ) {
|
314 |
echo acf_get_radio_input( $attrs );
|
319 |
*
|
320 |
* Returns the HTML of a radio input.
|
321 |
*
|
322 |
+
* @date 3/02/2014
|
323 |
+
* @since 5.0.0
|
324 |
*
|
325 |
+
* @param array $attrs The array of attrs.
|
326 |
+
* @return string
|
327 |
*/
|
328 |
function acf_get_radio_input( $attrs = array() ) {
|
329 |
$attrs['type'] = 'radio';
|
335 |
*
|
336 |
* Renders the HTML of a select input.
|
337 |
*
|
338 |
+
* @date 3/02/2014
|
339 |
+
* @since 5.0.0
|
340 |
*
|
341 |
+
* @param array $attrs The array of attrs.
|
342 |
+
* @return string
|
343 |
*/
|
344 |
function acf_select_input( $attrs = array() ) {
|
345 |
echo acf_get_select_input( $attrs );
|
350 |
*
|
351 |
* Returns the HTML of a select input.
|
352 |
*
|
353 |
+
* @date 3/02/2014
|
354 |
+
* @since 5.0.0
|
355 |
*
|
356 |
+
* @param array $attrs The array of attrs.
|
357 |
+
* @return string
|
358 |
*/
|
359 |
function acf_get_select_input( $attrs = array() ) {
|
360 |
+
$value = (array) acf_extract_var( $attrs, 'value' );
|
361 |
$choices = (array) acf_extract_var( $attrs, 'choices' );
|
362 |
return sprintf(
|
363 |
'<select %s>%s</select>',
|
364 |
+
acf_esc_attrs( $attrs ),
|
365 |
+
acf_walk_select_input( $choices, $value )
|
366 |
);
|
367 |
}
|
368 |
|
371 |
*
|
372 |
* Returns the HTML of a select input's choices.
|
373 |
*
|
374 |
+
* @date 27/6/17
|
375 |
+
* @since 5.6.0
|
376 |
*
|
377 |
+
* @param array $choices The choices to walk through.
|
378 |
+
* @param array $values The selected choices.
|
379 |
+
* @param array $depth The current walk depth.
|
380 |
+
* @return string
|
381 |
*/
|
382 |
function acf_walk_select_input( $choices = array(), $values = array(), $depth = 0 ) {
|
383 |
$html = '';
|
384 |
+
|
385 |
// Sanitize values for 'selected' matching (only once).
|
386 |
+
if ( $depth == 0 ) {
|
387 |
+
$values = array_map( 'esc_attr', $values );
|
388 |
}
|
389 |
+
|
390 |
// Loop over choices and append to html.
|
391 |
+
if ( $choices ) {
|
392 |
+
foreach ( $choices as $value => $label ) {
|
393 |
+
|
394 |
// Multiple (optgroup)
|
395 |
+
if ( is_array( $label ) ) {
|
396 |
$html .= sprintf(
|
397 |
'<optgroup label="%s">%s</optgroup>',
|
398 |
+
esc_attr( $value ),
|
399 |
+
acf_walk_select_input( $label, $values, $depth + 1 )
|
400 |
);
|
401 |
+
|
402 |
+
// single (option)
|
403 |
} else {
|
404 |
$attrs = array(
|
405 |
+
'value' => $value,
|
406 |
);
|
407 |
+
|
408 |
// If is selected.
|
409 |
+
$pos = array_search( esc_attr( $value ), $values );
|
410 |
+
if ( $pos !== false ) {
|
411 |
$attrs['selected'] = 'selected';
|
412 |
+
$attrs['data-i'] = $pos;
|
413 |
}
|
414 |
+
$html .= sprintf( '<option %s>%s</option>', acf_esc_attr( $attrs ), esc_html( $label ) );
|
415 |
}
|
416 |
}
|
417 |
}
|
423 |
*
|
424 |
* See acf_filter_attrs().
|
425 |
*
|
426 |
+
* @date 3/10/17
|
427 |
+
* @since 5.6.3
|
428 |
*
|
429 |
+
* @param array $attrs The array of attrs.
|
430 |
+
* @return string
|
431 |
*/
|
432 |
function acf_clean_atts( $attrs ) {
|
433 |
return acf_filter_attrs( $attrs );
|
438 |
*
|
439 |
* See acf_esc_attrs().
|
440 |
*
|
441 |
+
* @date 27/6/17
|
442 |
+
* @since 5.6.0
|
443 |
*
|
444 |
+
* @param array $attrs The array of attrs.
|
445 |
+
* @return string
|
446 |
*/
|
447 |
function acf_esc_atts( $attrs ) {
|
448 |
return acf_esc_attrs( $attrs );
|
453 |
*
|
454 |
* See acf_esc_attrs().
|
455 |
*
|
456 |
+
* @date 13/6/19
|
457 |
+
* @since 5.8.1
|
458 |
+
* @deprecated 5.6.0
|
459 |
*
|
460 |
+
* @param array $attrs The array of attrs.
|
461 |
+
* @return string
|
462 |
*/
|
463 |
function acf_esc_attr( $attrs ) {
|
464 |
return acf_esc_attrs( $attrs );
|
469 |
*
|
470 |
* See acf_esc_attrs().
|
471 |
*
|
472 |
+
* @date 13/6/19
|
473 |
+
* @since 5.8.1
|
474 |
+
* @deprecated 5.6.0
|
475 |
*
|
476 |
+
* @param array $attrs The array of attrs.
|
477 |
+
* @return string
|
478 |
*/
|
479 |
function acf_esc_attr_e( $attrs ) {
|
480 |
echo acf_esc_attrs( $attrs );
|
485 |
*
|
486 |
* See acf_esc_attrs().
|
487 |
*
|
488 |
+
* @date 13/6/19
|
489 |
+
* @since 5.8.1
|
490 |
+
* @deprecated 5.6.0
|
491 |
*
|
492 |
+
* @param array $attrs The array of attrs.
|
493 |
+
* @return string
|
494 |
*/
|
495 |
function acf_esc_atts_e( $attrs ) {
|
496 |
echo acf_esc_attrs( $attrs );
|
includes/acf-meta-functions.php
CHANGED
@@ -1,62 +1,62 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/**
|
4 |
* acf_get_meta
|
5 |
*
|
6 |
* Returns an array of "ACF only" meta for the given post_id.
|
7 |
*
|
8 |
-
* @date
|
9 |
-
* @since
|
10 |
*
|
11 |
-
* @param
|
12 |
-
* @return
|
13 |
*/
|
14 |
function acf_get_meta( $post_id = 0 ) {
|
15 |
-
|
16 |
// Allow filter to short-circuit load_value logic.
|
17 |
-
$null = apply_filters(
|
18 |
-
if( $null !== null ) {
|
19 |
return ( $null === '__return_null' ) ? null : $null;
|
20 |
}
|
21 |
-
|
22 |
// Decode $post_id for $type and $id.
|
23 |
-
extract( acf_decode_post_id($post_id) );
|
24 |
-
|
25 |
// Determine CRUD function.
|
26 |
// - Relies on decoded post_id result to identify option or meta types.
|
27 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
28 |
-
if( $type === 'option' ) {
|
29 |
$allmeta = acf_get_option_meta( $id );
|
30 |
} else {
|
31 |
$allmeta = get_metadata( $type, $id, '' );
|
32 |
}
|
33 |
-
|
34 |
// Loop over meta and check that a reference exists for each value.
|
35 |
$meta = array();
|
36 |
-
if( $allmeta ) {
|
37 |
-
foreach( $allmeta as $key => $value ) {
|
38 |
-
|
39 |
// If a reference exists for this value, add it to the meta array.
|
40 |
-
if( isset($allmeta["_$key"]) ) {
|
41 |
-
$meta[ $key ]
|
42 |
$meta[ "_$key" ] = $allmeta[ "_$key" ][0];
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
-
|
47 |
// Unserialized results (get_metadata does not unserialize if $key is empty).
|
48 |
-
$meta = array_map('maybe_unserialize', $meta);
|
49 |
-
|
50 |
/**
|
51 |
* Filters the $meta array after it has been loaded.
|
52 |
*
|
53 |
-
* @date
|
54 |
-
* @since
|
55 |
*
|
56 |
-
* @param
|
57 |
-
* @param
|
58 |
*/
|
59 |
-
return apply_filters(
|
60 |
}
|
61 |
|
62 |
|
@@ -65,42 +65,45 @@ function acf_get_meta( $post_id = 0 ) {
|
|
65 |
*
|
66 |
* Returns an array of meta for the given wp_option name prefix in the same format as get_post_meta().
|
67 |
*
|
68 |
-
* @date
|
69 |
-
* @since
|
70 |
*
|
71 |
-
* @param
|
72 |
-
* @return
|
73 |
*/
|
74 |
function acf_get_option_meta( $prefix = '' ) {
|
75 |
-
|
76 |
// Globals.
|
77 |
global $wpdb;
|
78 |
-
|
79 |
// Vars.
|
80 |
-
$meta
|
81 |
-
$search
|
82 |
$_search = "_{$prefix}_%";
|
83 |
-
|
84 |
// Escape underscores for LIKE.
|
85 |
-
$search
|
86 |
-
$_search = str_replace('_', '\_', $_search);
|
87 |
-
|
88 |
// Query database for results.
|
89 |
-
$rows = $wpdb->get_results(
|
90 |
-
|
|
|
91 |
FROM $wpdb->options
|
92 |
WHERE option_name LIKE %s
|
93 |
OR option_name LIKE %s",
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
98 |
// Loop over results and append meta (removing the $prefix from the option name).
|
99 |
-
$len = strlen("{$prefix}_");
|
100 |
-
foreach( $rows as $row ) {
|
101 |
-
$meta[ substr($row['option_name'], $len) ][] = $row['option_value'];
|
102 |
}
|
103 |
-
|
104 |
// Return results.
|
105 |
return $meta;
|
106 |
}
|
@@ -110,41 +113,41 @@ function acf_get_option_meta( $prefix = '' ) {
|
|
110 |
*
|
111 |
* Retrieves specific metadata from the database.
|
112 |
*
|
113 |
-
* @date
|
114 |
-
* @since
|
115 |
*
|
116 |
-
* @param
|
117 |
-
* @param
|
118 |
-
* @param
|
119 |
-
* @return
|
120 |
*/
|
121 |
function acf_get_metadata( $post_id = 0, $name = '', $hidden = false ) {
|
122 |
-
|
123 |
// Allow filter to short-circuit logic.
|
124 |
-
$null = apply_filters(
|
125 |
-
if( $null !== null ) {
|
126 |
return ( $null === '__return_null' ) ? null : $null;
|
127 |
}
|
128 |
-
|
129 |
// Decode $post_id for $type and $id.
|
130 |
-
extract( acf_decode_post_id($post_id) );
|
131 |
-
|
132 |
// Hidden meta uses an underscore prefix.
|
133 |
$prefix = $hidden ? '_' : '';
|
134 |
-
|
135 |
// Bail early if no $id (possible during new acf_form).
|
136 |
-
if(
|
137 |
return null;
|
138 |
}
|
139 |
-
|
140 |
// Determine CRUD function.
|
141 |
// - Relies on decoded post_id result to identify option or meta types.
|
142 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
143 |
-
if( $type === 'option' ) {
|
144 |
return get_option( "{$prefix}{$id}_{$name}", null );
|
145 |
} else {
|
146 |
$meta = get_metadata( $type, $id, "{$prefix}{$name}", false );
|
147 |
-
return isset($meta[0]) ? $meta[0] : null;
|
148 |
}
|
149 |
}
|
150 |
|
@@ -153,40 +156,40 @@ function acf_get_metadata( $post_id = 0, $name = '', $hidden = false ) {
|
|
153 |
*
|
154 |
* Updates metadata in the database.
|
155 |
*
|
156 |
-
* @date
|
157 |
-
* @since
|
158 |
*
|
159 |
-
* @param
|
160 |
-
* @param
|
161 |
-
* @param
|
162 |
-
* @param
|
163 |
-
* @return
|
164 |
*/
|
165 |
function acf_update_metadata( $post_id = 0, $name = '', $value = '', $hidden = false ) {
|
166 |
-
|
167 |
// Allow filter to short-circuit logic.
|
168 |
-
$pre = apply_filters(
|
169 |
-
if( $pre !== null ) {
|
170 |
return $pre;
|
171 |
}
|
172 |
-
|
173 |
// Decode $post_id for $type and $id.
|
174 |
-
extract( acf_decode_post_id($post_id) );
|
175 |
-
|
176 |
// Hidden meta uses an underscore prefix.
|
177 |
$prefix = $hidden ? '_' : '';
|
178 |
-
|
179 |
// Bail early if no $id (possible during new acf_form).
|
180 |
-
if(
|
181 |
return false;
|
182 |
}
|
183 |
-
|
184 |
// Determine CRUD function.
|
185 |
// - Relies on decoded post_id result to identify option or meta types.
|
186 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
187 |
-
if( $type === 'option' ) {
|
188 |
-
$value
|
189 |
-
$autoload = (bool) acf_get_setting('autoload');
|
190 |
return update_option( "{$prefix}{$id}_{$name}", $value, $autoload );
|
191 |
} else {
|
192 |
return update_metadata( $type, $id, "{$prefix}{$name}", $value );
|
@@ -198,37 +201,37 @@ function acf_update_metadata( $post_id = 0, $name = '', $value = '', $hidden = f
|
|
198 |
*
|
199 |
* Deletes metadata from the database.
|
200 |
*
|
201 |
-
* @date
|
202 |
-
* @since
|
203 |
*
|
204 |
-
* @param
|
205 |
-
* @param
|
206 |
-
* @param
|
207 |
-
* @return
|
208 |
*/
|
209 |
function acf_delete_metadata( $post_id = 0, $name = '', $hidden = false ) {
|
210 |
-
|
211 |
// Allow filter to short-circuit logic.
|
212 |
-
$pre = apply_filters(
|
213 |
-
if( $pre !== null ) {
|
214 |
return $pre;
|
215 |
}
|
216 |
-
|
217 |
// Decode $post_id for $type and $id.
|
218 |
-
extract( acf_decode_post_id($post_id) );
|
219 |
-
|
220 |
// Hidden meta uses an underscore prefix.
|
221 |
$prefix = $hidden ? '_' : '';
|
222 |
-
|
223 |
// Bail early if no $id (possible during new acf_form).
|
224 |
-
if(
|
225 |
return false;
|
226 |
}
|
227 |
-
|
228 |
// Determine CRUD function.
|
229 |
// - Relies on decoded post_id result to identify option or meta types.
|
230 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
231 |
-
if( $type === 'option' ) {
|
232 |
return delete_option( "{$prefix}{$id}_{$name}" );
|
233 |
} else {
|
234 |
return delete_metadata( $type, $id, "{$prefix}{$name}" );
|
@@ -240,27 +243,27 @@ function acf_delete_metadata( $post_id = 0, $name = '', $hidden = false ) {
|
|
240 |
*
|
241 |
* Copies meta from one post to another. Useful for saving and restoring revisions.
|
242 |
*
|
243 |
-
* @date
|
244 |
-
* @since
|
245 |
*
|
246 |
-
* @param
|
247 |
-
* @param
|
248 |
-
* @return
|
249 |
*/
|
250 |
function acf_copy_metadata( $from_post_id = 0, $to_post_id = 0 ) {
|
251 |
-
|
252 |
// Get all postmeta.
|
253 |
$meta = acf_get_meta( $from_post_id );
|
254 |
-
|
255 |
// Check meta.
|
256 |
-
if( $meta ) {
|
257 |
-
|
258 |
// Slash data. WP expects all data to be slashed and will unslash it (fixes '\' character issues).
|
259 |
$meta = wp_slash( $meta );
|
260 |
-
|
261 |
// Loop over meta.
|
262 |
-
foreach( $meta as $name => $value ) {
|
263 |
-
acf_update_metadata( $to_post_id, $name, $value );
|
264 |
}
|
265 |
}
|
266 |
}
|
@@ -270,13 +273,13 @@ function acf_copy_metadata( $from_post_id = 0, $to_post_id = 0 ) {
|
|
270 |
*
|
271 |
* Copies meta from one post to another. Useful for saving and restoring revisions.
|
272 |
*
|
273 |
-
* @date
|
274 |
-
* @since
|
275 |
* @deprecated 5.7.11
|
276 |
*
|
277 |
-
* @param
|
278 |
-
* @param
|
279 |
-
* @return
|
280 |
*/
|
281 |
function acf_copy_postmeta( $from_post_id = 0, $to_post_id = 0 ) {
|
282 |
return acf_copy_metadata( $from_post_id, $to_post_id );
|
@@ -288,26 +291,26 @@ function acf_copy_postmeta( $from_post_id = 0, $to_post_id = 0 ) {
|
|
288 |
* Returns a field using the provided $id and $post_id parameters.
|
289 |
* Looks for a reference to help loading the correct field via name.
|
290 |
*
|
291 |
-
* @date
|
292 |
-
* @since
|
293 |
*
|
294 |
-
* @param
|
295 |
-
* @param
|
296 |
-
* @return
|
297 |
*/
|
298 |
function acf_get_meta_field( $key = 0, $post_id = 0 ) {
|
299 |
-
|
300 |
// Try reference.
|
301 |
$field_key = acf_get_reference( $key, $post_id );
|
302 |
-
|
303 |
-
if( $field_key ) {
|
304 |
$field = acf_get_field( $field_key );
|
305 |
-
if( $field ) {
|
306 |
$field['name'] = $key;
|
307 |
return $field;
|
308 |
}
|
309 |
}
|
310 |
-
|
311 |
// Return false.
|
312 |
return false;
|
313 |
}
|
@@ -317,29 +320,29 @@ function acf_get_meta_field( $key = 0, $post_id = 0 ) {
|
|
317 |
*
|
318 |
* Retrieves reference metadata from the database.
|
319 |
*
|
320 |
-
* @date
|
321 |
-
* @since
|
322 |
*
|
323 |
-
* @param
|
324 |
-
* @param
|
325 |
-
* @param
|
326 |
-
* @return
|
327 |
*/
|
328 |
function acf_get_metaref( $post_id = 0, $type = 'fields', $name = '' ) {
|
329 |
-
|
330 |
// Load existing meta.
|
331 |
$meta = acf_get_metadata( $post_id, "_acf_$type" );
|
332 |
-
|
333 |
// Handle no meta.
|
334 |
-
if(
|
335 |
return $name ? '' : array();
|
336 |
}
|
337 |
-
|
338 |
// Return specific reference.
|
339 |
-
if( $name ) {
|
340 |
-
return isset($meta[ $name ]) ? $meta[ $name ] : '';
|
341 |
-
|
342 |
-
|
343 |
} else {
|
344 |
return $meta;
|
345 |
}
|
@@ -350,30 +353,30 @@ function acf_get_metaref( $post_id = 0, $type = 'fields', $name = '' ) {
|
|
350 |
*
|
351 |
* Updates reference metadata in the database.
|
352 |
*
|
353 |
-
* @date
|
354 |
-
* @since
|
355 |
*
|
356 |
-
* @param
|
357 |
-
* @param
|
358 |
-
* @param
|
359 |
-
* @return
|
360 |
*/
|
361 |
function acf_update_metaref( $post_id = 0, $type = 'fields', $references = array() ) {
|
362 |
-
|
363 |
// Get current references.
|
364 |
$current = acf_get_metaref( $post_id, $type );
|
365 |
-
|
366 |
// Merge in new references.
|
367 |
$references = array_merge( $current, $references );
|
368 |
-
|
369 |
// Simplify groups
|
370 |
-
if( $type === 'groups' ) {
|
371 |
-
$references = array_values($references);
|
372 |
}
|
373 |
-
|
374 |
// Remove duplicate references.
|
375 |
-
$references = array_unique($references);
|
376 |
-
|
377 |
// Update metadata.
|
378 |
return acf_update_metadata( $post_id, "_acf_$type", $references );
|
379 |
-
}
|
1 |
+
<?php
|
2 |
|
3 |
/**
|
4 |
* acf_get_meta
|
5 |
*
|
6 |
* Returns an array of "ACF only" meta for the given post_id.
|
7 |
*
|
8 |
+
* @date 9/10/18
|
9 |
+
* @since 5.8.0
|
10 |
*
|
11 |
+
* @param mixed $post_id The post_id for this data.
|
12 |
+
* @return array
|
13 |
*/
|
14 |
function acf_get_meta( $post_id = 0 ) {
|
15 |
+
|
16 |
// Allow filter to short-circuit load_value logic.
|
17 |
+
$null = apply_filters( 'acf/pre_load_meta', null, $post_id );
|
18 |
+
if ( $null !== null ) {
|
19 |
return ( $null === '__return_null' ) ? null : $null;
|
20 |
}
|
21 |
+
|
22 |
// Decode $post_id for $type and $id.
|
23 |
+
extract( acf_decode_post_id( $post_id ) );
|
24 |
+
|
25 |
// Determine CRUD function.
|
26 |
// - Relies on decoded post_id result to identify option or meta types.
|
27 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
28 |
+
if ( $type === 'option' ) {
|
29 |
$allmeta = acf_get_option_meta( $id );
|
30 |
} else {
|
31 |
$allmeta = get_metadata( $type, $id, '' );
|
32 |
}
|
33 |
+
|
34 |
// Loop over meta and check that a reference exists for each value.
|
35 |
$meta = array();
|
36 |
+
if ( $allmeta ) {
|
37 |
+
foreach ( $allmeta as $key => $value ) {
|
38 |
+
|
39 |
// If a reference exists for this value, add it to the meta array.
|
40 |
+
if ( isset( $allmeta[ "_$key" ] ) ) {
|
41 |
+
$meta[ $key ] = $allmeta[ $key ][0];
|
42 |
$meta[ "_$key" ] = $allmeta[ "_$key" ][0];
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
+
|
47 |
// Unserialized results (get_metadata does not unserialize if $key is empty).
|
48 |
+
$meta = array_map( 'maybe_unserialize', $meta );
|
49 |
+
|
50 |
/**
|
51 |
* Filters the $meta array after it has been loaded.
|
52 |
*
|
53 |
+
* @date 25/1/19
|
54 |
+
* @since 5.7.11
|
55 |
*
|
56 |
+
* @param array $meta The arary of loaded meta.
|
57 |
+
* @param string $post_id The $post_id for this meta.
|
58 |
*/
|
59 |
+
return apply_filters( 'acf/load_meta', $meta, $post_id );
|
60 |
}
|
61 |
|
62 |
|
65 |
*
|
66 |
* Returns an array of meta for the given wp_option name prefix in the same format as get_post_meta().
|
67 |
*
|
68 |
+
* @date 9/10/18
|
69 |
+
* @since 5.8.0
|
70 |
*
|
71 |
+
* @param string $prefix The wp_option name prefix.
|
72 |
+
* @return array
|
73 |
*/
|
74 |
function acf_get_option_meta( $prefix = '' ) {
|
75 |
+
|
76 |
// Globals.
|
77 |
global $wpdb;
|
78 |
+
|
79 |
// Vars.
|
80 |
+
$meta = array();
|
81 |
+
$search = "{$prefix}_%";
|
82 |
$_search = "_{$prefix}_%";
|
83 |
+
|
84 |
// Escape underscores for LIKE.
|
85 |
+
$search = str_replace( '_', '\_', $search );
|
86 |
+
$_search = str_replace( '_', '\_', $_search );
|
87 |
+
|
88 |
// Query database for results.
|
89 |
+
$rows = $wpdb->get_results(
|
90 |
+
$wpdb->prepare(
|
91 |
+
"SELECT *
|
92 |
FROM $wpdb->options
|
93 |
WHERE option_name LIKE %s
|
94 |
OR option_name LIKE %s",
|
95 |
+
$search,
|
96 |
+
$_search
|
97 |
+
),
|
98 |
+
ARRAY_A
|
99 |
+
);
|
100 |
+
|
101 |
// Loop over results and append meta (removing the $prefix from the option name).
|
102 |
+
$len = strlen( "{$prefix}_" );
|
103 |
+
foreach ( $rows as $row ) {
|
104 |
+
$meta[ substr( $row['option_name'], $len ) ][] = $row['option_value'];
|
105 |
}
|
106 |
+
|
107 |
// Return results.
|
108 |
return $meta;
|
109 |
}
|
113 |
*
|
114 |
* Retrieves specific metadata from the database.
|
115 |
*
|
116 |
+
* @date 16/10/2015
|
117 |
+
* @since 5.2.3
|
118 |
*
|
119 |
+
* @param (int|string) $post_id The post id.
|
120 |
+
* @param string $name The meta name.
|
121 |
+
* @param bool $hidden If the meta is hidden (starts with an underscore).
|
122 |
+
* @return mixed
|
123 |
*/
|
124 |
function acf_get_metadata( $post_id = 0, $name = '', $hidden = false ) {
|
125 |
+
|
126 |
// Allow filter to short-circuit logic.
|
127 |
+
$null = apply_filters( 'acf/pre_load_metadata', null, $post_id, $name, $hidden );
|
128 |
+
if ( $null !== null ) {
|
129 |
return ( $null === '__return_null' ) ? null : $null;
|
130 |
}
|
131 |
+
|
132 |
// Decode $post_id for $type and $id.
|
133 |
+
extract( acf_decode_post_id( $post_id ) );
|
134 |
+
|
135 |
// Hidden meta uses an underscore prefix.
|
136 |
$prefix = $hidden ? '_' : '';
|
137 |
+
|
138 |
// Bail early if no $id (possible during new acf_form).
|
139 |
+
if ( ! $id ) {
|
140 |
return null;
|
141 |
}
|
142 |
+
|
143 |
// Determine CRUD function.
|
144 |
// - Relies on decoded post_id result to identify option or meta types.
|
145 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
146 |
+
if ( $type === 'option' ) {
|
147 |
return get_option( "{$prefix}{$id}_{$name}", null );
|
148 |
} else {
|
149 |
$meta = get_metadata( $type, $id, "{$prefix}{$name}", false );
|
150 |
+
return isset( $meta[0] ) ? $meta[0] : null;
|
151 |
}
|
152 |
}
|
153 |
|
156 |
*
|
157 |
* Updates metadata in the database.
|
158 |
*
|
159 |
+
* @date 16/10/2015
|
160 |
+
* @since 5.2.3
|
161 |
*
|
162 |
+
* @param (int|string) $post_id The post id.
|
163 |
+
* @param string $name The meta name.
|
164 |
+
* @param mixed $value The meta value.
|
165 |
+
* @param bool $hidden If the meta is hidden (starts with an underscore).
|
166 |
+
* @return (int|bool) Meta ID if the key didn't exist, true on successful update, false on failure.
|
167 |
*/
|
168 |
function acf_update_metadata( $post_id = 0, $name = '', $value = '', $hidden = false ) {
|
169 |
+
|
170 |
// Allow filter to short-circuit logic.
|
171 |
+
$pre = apply_filters( 'acf/pre_update_metadata', null, $post_id, $name, $value, $hidden );
|
172 |
+
if ( $pre !== null ) {
|
173 |
return $pre;
|
174 |
}
|
175 |
+
|
176 |
// Decode $post_id for $type and $id.
|
177 |
+
extract( acf_decode_post_id( $post_id ) );
|
178 |
+
|
179 |
// Hidden meta uses an underscore prefix.
|
180 |
$prefix = $hidden ? '_' : '';
|
181 |
+
|
182 |
// Bail early if no $id (possible during new acf_form).
|
183 |
+
if ( ! $id ) {
|
184 |
return false;
|
185 |
}
|
186 |
+
|
187 |
// Determine CRUD function.
|
188 |
// - Relies on decoded post_id result to identify option or meta types.
|
189 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
190 |
+
if ( $type === 'option' ) {
|
191 |
+
$value = wp_unslash( $value );
|
192 |
+
$autoload = (bool) acf_get_setting( 'autoload' );
|
193 |
return update_option( "{$prefix}{$id}_{$name}", $value, $autoload );
|
194 |
} else {
|
195 |
return update_metadata( $type, $id, "{$prefix}{$name}", $value );
|
201 |
*
|
202 |
* Deletes metadata from the database.
|
203 |
*
|
204 |
+
* @date 16/10/2015
|
205 |
+
* @since 5.2.3
|
206 |
*
|
207 |
+
* @param (int|string) $post_id The post id.
|
208 |
+
* @param string $name The meta name.
|
209 |
+
* @param bool $hidden If the meta is hidden (starts with an underscore).
|
210 |
+
* @return bool
|
211 |
*/
|
212 |
function acf_delete_metadata( $post_id = 0, $name = '', $hidden = false ) {
|
213 |
+
|
214 |
// Allow filter to short-circuit logic.
|
215 |
+
$pre = apply_filters( 'acf/pre_delete_metadata', null, $post_id, $name, $hidden );
|
216 |
+
if ( $pre !== null ) {
|
217 |
return $pre;
|
218 |
}
|
219 |
+
|
220 |
// Decode $post_id for $type and $id.
|
221 |
+
extract( acf_decode_post_id( $post_id ) );
|
222 |
+
|
223 |
// Hidden meta uses an underscore prefix.
|
224 |
$prefix = $hidden ? '_' : '';
|
225 |
+
|
226 |
// Bail early if no $id (possible during new acf_form).
|
227 |
+
if ( ! $id ) {
|
228 |
return false;
|
229 |
}
|
230 |
+
|
231 |
// Determine CRUD function.
|
232 |
// - Relies on decoded post_id result to identify option or meta types.
|
233 |
// - Uses xxx_metadata(type) instead of xxx_type_meta() to bypass additional logic that could alter the ID.
|
234 |
+
if ( $type === 'option' ) {
|
235 |
return delete_option( "{$prefix}{$id}_{$name}" );
|
236 |
} else {
|
237 |
return delete_metadata( $type, $id, "{$prefix}{$name}" );
|
243 |
*
|
244 |
* Copies meta from one post to another. Useful for saving and restoring revisions.
|
245 |
*
|
246 |
+
* @date 25/06/2016
|
247 |
+
* @since 5.3.8
|
248 |
*
|
249 |
+
* @param (int|string) $from_post_id The post id to copy from.
|
250 |
+
* @param (int|string) $to_post_id The post id to paste to.
|
251 |
+
* @return void
|
252 |
*/
|
253 |
function acf_copy_metadata( $from_post_id = 0, $to_post_id = 0 ) {
|
254 |
+
|
255 |
// Get all postmeta.
|
256 |
$meta = acf_get_meta( $from_post_id );
|
257 |
+
|
258 |
// Check meta.
|
259 |
+
if ( $meta ) {
|
260 |
+
|
261 |
// Slash data. WP expects all data to be slashed and will unslash it (fixes '\' character issues).
|
262 |
$meta = wp_slash( $meta );
|
263 |
+
|
264 |
// Loop over meta.
|
265 |
+
foreach ( $meta as $name => $value ) {
|
266 |
+
acf_update_metadata( $to_post_id, $name, $value );
|
267 |
}
|
268 |
}
|
269 |
}
|
273 |
*
|
274 |
* Copies meta from one post to another. Useful for saving and restoring revisions.
|
275 |
*
|
276 |
+
* @date 25/06/2016
|
277 |
+
* @since 5.3.8
|
278 |
* @deprecated 5.7.11
|
279 |
*
|
280 |
+
* @param int $from_post_id The post id to copy from.
|
281 |
+
* @param int $to_post_id The post id to paste to.
|
282 |
+
* @return void
|
283 |
*/
|
284 |
function acf_copy_postmeta( $from_post_id = 0, $to_post_id = 0 ) {
|
285 |
return acf_copy_metadata( $from_post_id, $to_post_id );
|
291 |
* Returns a field using the provided $id and $post_id parameters.
|
292 |
* Looks for a reference to help loading the correct field via name.
|
293 |
*
|
294 |
+
* @date 21/1/19
|
295 |
+
* @since 5.7.10
|
296 |
*
|
297 |
+
* @param string $key The meta name (field name).
|
298 |
+
* @param (int|string) $post_id The post_id where this field's value is saved.
|
299 |
+
* @return (array|false) The field array.
|
300 |
*/
|
301 |
function acf_get_meta_field( $key = 0, $post_id = 0 ) {
|
302 |
+
|
303 |
// Try reference.
|
304 |
$field_key = acf_get_reference( $key, $post_id );
|
305 |
+
|
306 |
+
if ( $field_key ) {
|
307 |
$field = acf_get_field( $field_key );
|
308 |
+
if ( $field ) {
|
309 |
$field['name'] = $key;
|
310 |
return $field;
|
311 |
}
|
312 |
}
|
313 |
+
|
314 |
// Return false.
|
315 |
return false;
|
316 |
}
|
320 |
*
|
321 |
* Retrieves reference metadata from the database.
|
322 |
*
|
323 |
+
* @date 16/10/2015
|
324 |
+
* @since 5.2.3
|
325 |
*
|
326 |
+
* @param (int|string) $post_id The post id.
|
327 |
+
* @param string type The reference type (fields|groups).
|
328 |
+
* @param string $name An optional specific name
|
329 |
+
* @return mixed
|
330 |
*/
|
331 |
function acf_get_metaref( $post_id = 0, $type = 'fields', $name = '' ) {
|
332 |
+
|
333 |
// Load existing meta.
|
334 |
$meta = acf_get_metadata( $post_id, "_acf_$type" );
|
335 |
+
|
336 |
// Handle no meta.
|
337 |
+
if ( ! $meta ) {
|
338 |
return $name ? '' : array();
|
339 |
}
|
340 |
+
|
341 |
// Return specific reference.
|
342 |
+
if ( $name ) {
|
343 |
+
return isset( $meta[ $name ] ) ? $meta[ $name ] : '';
|
344 |
+
|
345 |
+
// Or return all references.
|
346 |
} else {
|
347 |
return $meta;
|
348 |
}
|
353 |
*
|
354 |
* Updates reference metadata in the database.
|
355 |
*
|
356 |
+
* @date 16/10/2015
|
357 |
+
* @since 5.2.3
|
358 |
*
|
359 |
+
* @param (int|string) $post_id The post id.
|
360 |
+
* @param string type The reference type (fields|groups).
|
361 |
+
* @param array $references An array of references.
|
362 |
+
* @return (int|bool) Meta ID if the key didn't exist, true on successful update, false on failure.
|
363 |
*/
|
364 |
function acf_update_metaref( $post_id = 0, $type = 'fields', $references = array() ) {
|
365 |
+
|
366 |
// Get current references.
|
367 |
$current = acf_get_metaref( $post_id, $type );
|
368 |
+
|
369 |
// Merge in new references.
|
370 |
$references = array_merge( $current, $references );
|
371 |
+
|
372 |
// Simplify groups
|
373 |
+
if ( $type === 'groups' ) {
|
374 |
+
$references = array_values( $references );
|
375 |
}
|
376 |
+
|
377 |
// Remove duplicate references.
|
378 |
+
$references = array_unique( $references );
|
379 |
+
|
380 |
// Update metadata.
|
381 |
return acf_update_metadata( $post_id, "_acf_$type", $references );
|
382 |
+
}
|
includes/acf-post-functions.php
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/**
|
4 |
* Returns available templates for each post type.
|
5 |
*
|
6 |
-
* @date
|
7 |
-
* @since
|
8 |
*
|
9 |
-
* @param
|
10 |
-
* @return
|
11 |
*/
|
12 |
function acf_get_post_templates() {
|
13 |
-
|
14 |
// Check store.
|
15 |
$cache = acf_get_data( 'post_templates' );
|
16 |
-
if( $cache !== null ) {
|
17 |
return $cache;
|
18 |
}
|
19 |
-
|
20 |
// Initialize templates with default placeholder for pages.
|
21 |
-
$post_templates
|
22 |
$post_templates['page'] = array();
|
23 |
-
|
24 |
// Loop over post types and append their templates.
|
25 |
-
if( method_exists('WP_Theme', 'get_page_templates') ) {
|
26 |
$post_types = get_post_types();
|
27 |
-
foreach( $post_types as $post_type ) {
|
28 |
$templates = wp_get_theme()->get_page_templates( null, $post_type );
|
29 |
-
if( $templates ) {
|
30 |
$post_templates[ $post_type ] = $templates;
|
31 |
}
|
32 |
}
|
33 |
}
|
34 |
-
|
35 |
// Update store.
|
36 |
acf_set_data( 'post_templates', $post_templates );
|
37 |
|
38 |
// Return templates.
|
39 |
return $post_templates;
|
40 |
-
}
|
1 |
+
<?php
|
2 |
|
3 |
/**
|
4 |
* Returns available templates for each post type.
|
5 |
*
|
6 |
+
* @date 29/8/17
|
7 |
+
* @since 5.6.2
|
8 |
*
|
9 |
+
* @param void
|
10 |
+
* @return array
|
11 |
*/
|
12 |
function acf_get_post_templates() {
|
13 |
+
|
14 |
// Check store.
|
15 |
$cache = acf_get_data( 'post_templates' );
|
16 |
+
if ( $cache !== null ) {
|
17 |
return $cache;
|
18 |
}
|
19 |
+
|
20 |
// Initialize templates with default placeholder for pages.
|
21 |
+
$post_templates = array();
|
22 |
$post_templates['page'] = array();
|
23 |
+
|
24 |
// Loop over post types and append their templates.
|
25 |
+
if ( method_exists( 'WP_Theme', 'get_page_templates' ) ) {
|
26 |
$post_types = get_post_types();
|
27 |
+
foreach ( $post_types as $post_type ) {
|
28 |
$templates = wp_get_theme()->get_page_templates( null, $post_type );
|
29 |
+
if ( $templates ) {
|
30 |
$post_templates[ $post_type ] = $templates;
|
31 |
}
|
32 |
}
|
33 |
}
|
34 |
+
|
35 |
// Update store.
|
36 |
acf_set_data( 'post_templates', $post_templates );
|
37 |
|
38 |
// Return templates.
|
39 |
return $post_templates;
|
40 |
+
}
|
includes/acf-user-functions.php
CHANGED
@@ -1,34 +1,34 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/**
|
4 |
* acf_get_users
|
5 |
*
|
6 |
* Similar to the get_users() function but with extra functionality.
|
7 |
*
|
8 |
-
* @date
|
9 |
-
* @since
|
10 |
*
|
11 |
-
* @param
|
12 |
-
* @return
|
13 |
*/
|
14 |
function acf_get_users( $args = array() ) {
|
15 |
-
|
16 |
// Get users.
|
17 |
$users = get_users( $args );
|
18 |
-
|
19 |
// Maintain order.
|
20 |
-
if( $users && $args['include'] ) {
|
21 |
-
|
22 |
// Generate order array.
|
23 |
$order = array();
|
24 |
-
foreach( $users as $i => $user ) {
|
25 |
-
$order[ $i ] = array_search($user->ID, $args['include']);
|
26 |
}
|
27 |
-
|
28 |
// Sort results.
|
29 |
-
array_multisort($order, $users);
|
30 |
}
|
31 |
-
|
32 |
// Return
|
33 |
return $users;
|
34 |
}
|
@@ -38,25 +38,25 @@ function acf_get_users( $args = array() ) {
|
|
38 |
*
|
39 |
* Returns a result containing "id" and "text" for the given user.
|
40 |
*
|
41 |
-
* @date
|
42 |
-
* @since
|
43 |
*
|
44 |
-
* @param
|
45 |
-
* @return
|
46 |
*/
|
47 |
function acf_get_user_result( $user ) {
|
48 |
-
|
49 |
// Vars.
|
50 |
-
$id
|
51 |
$text = $user->user_login;
|
52 |
-
|
53 |
// Add name.
|
54 |
-
if( $user->first_name && $user->last_name ) {
|
55 |
$text .= " ({$user->first_name} {$user->last_name})";
|
56 |
-
} elseif( $user->first_name ) {
|
57 |
$text .= " ({$user->first_name})";
|
58 |
}
|
59 |
-
return compact('id', 'text');
|
60 |
}
|
61 |
|
62 |
|
@@ -65,28 +65,28 @@ function acf_get_user_result( $user ) {
|
|
65 |
*
|
66 |
* Returns an array of user roles in the format "name => label".
|
67 |
*
|
68 |
-
* @date
|
69 |
-
* @since
|
70 |
*
|
71 |
-
* @param
|
72 |
-
* @return
|
73 |
*/
|
74 |
function acf_get_user_role_labels( $roles = array() ) {
|
75 |
$all_roles = wp_roles()->get_names();
|
76 |
-
|
77 |
// Load all roles if none provided.
|
78 |
-
if( empty($roles) ) {
|
79 |
$roles = array_keys( $all_roles );
|
80 |
}
|
81 |
-
|
82 |
// Loop over roles and populare labels.
|
83 |
$lables = array();
|
84 |
-
foreach( $roles as $role ) {
|
85 |
-
if( isset($all_roles[ $role ]) ) {
|
86 |
$lables[ $role ] = translate_user_role( $all_roles[ $role ] );
|
87 |
}
|
88 |
}
|
89 |
-
|
90 |
// Return labels.
|
91 |
return $lables;
|
92 |
}
|
@@ -96,24 +96,24 @@ function acf_get_user_role_labels( $roles = array() ) {
|
|
96 |
*
|
97 |
* Returns true if the current user is allowed to save unfiltered HTML.
|
98 |
*
|
99 |
-
* @date
|
100 |
-
* @since
|
101 |
*
|
102 |
-
* @param
|
103 |
-
* @return
|
104 |
*/
|
105 |
function acf_allow_unfiltered_html() {
|
106 |
-
|
107 |
// Check capability.
|
108 |
-
$allow_unfiltered_html = current_user_can('unfiltered_html');
|
109 |
-
|
110 |
/**
|
111 |
* Filters whether the current user is allowed to save unfiltered HTML.
|
112 |
*
|
113 |
-
* @date
|
114 |
-
* @since
|
115 |
*
|
116 |
-
* @param
|
117 |
*/
|
118 |
return apply_filters( 'acf/allow_unfiltered_html', $allow_unfiltered_html );
|
119 |
-
}
|
1 |
+
<?php
|
2 |
|
3 |
/**
|
4 |
* acf_get_users
|
5 |
*
|
6 |
* Similar to the get_users() function but with extra functionality.
|
7 |
*
|
8 |
+
* @date 9/1/19
|
9 |
+
* @since 5.7.10
|
10 |
*
|
11 |
+
* @param array $args The query args.
|
12 |
+
* @return array
|
13 |
*/
|
14 |
function acf_get_users( $args = array() ) {
|
15 |
+
|
16 |
// Get users.
|
17 |
$users = get_users( $args );
|
18 |
+
|
19 |
// Maintain order.
|
20 |
+
if ( $users && $args['include'] ) {
|
21 |
+
|
22 |
// Generate order array.
|
23 |
$order = array();
|
24 |
+
foreach ( $users as $i => $user ) {
|
25 |
+
$order[ $i ] = array_search( $user->ID, $args['include'] );
|
26 |
}
|
27 |
+
|
28 |
// Sort results.
|
29 |
+
array_multisort( $order, $users );
|
30 |
}
|
31 |
+
|
32 |
// Return
|
33 |
return $users;
|
34 |
}
|
38 |
*
|
39 |
* Returns a result containing "id" and "text" for the given user.
|
40 |
*
|
41 |
+
* @date 21/5/19
|
42 |
+
* @since 5.8.1
|
43 |
*
|
44 |
+
* @param WP_User $user The user object.
|
45 |
+
* @return array
|
46 |
*/
|
47 |
function acf_get_user_result( $user ) {
|
48 |
+
|
49 |
// Vars.
|
50 |
+
$id = $user->ID;
|
51 |
$text = $user->user_login;
|
52 |
+
|
53 |
// Add name.
|
54 |
+
if ( $user->first_name && $user->last_name ) {
|
55 |
$text .= " ({$user->first_name} {$user->last_name})";
|
56 |
+
} elseif ( $user->first_name ) {
|
57 |
$text .= " ({$user->first_name})";
|
58 |
}
|
59 |
+
return compact( 'id', 'text' );
|
60 |
}
|
61 |
|
62 |
|
65 |
*
|
66 |
* Returns an array of user roles in the format "name => label".
|
67 |
*
|
68 |
+
* @date 20/5/19
|
69 |
+
* @since 5.8.1
|
70 |
*
|
71 |
+
* @param array $roles A specific array of roles.
|
72 |
+
* @return array
|
73 |
*/
|
74 |
function acf_get_user_role_labels( $roles = array() ) {
|
75 |
$all_roles = wp_roles()->get_names();
|
76 |
+
|
77 |
// Load all roles if none provided.
|
78 |
+
if ( empty( $roles ) ) {
|
79 |
$roles = array_keys( $all_roles );
|
80 |
}
|
81 |
+
|
82 |
// Loop over roles and populare labels.
|
83 |
$lables = array();
|
84 |
+
foreach ( $roles as $role ) {
|
85 |
+
if ( isset( $all_roles[ $role ] ) ) {
|
86 |
$lables[ $role ] = translate_user_role( $all_roles[ $role ] );
|
87 |
}
|
88 |
}
|
89 |
+
|
90 |
// Return labels.
|
91 |
return $lables;
|
92 |
}
|
96 |
*
|
97 |
* Returns true if the current user is allowed to save unfiltered HTML.
|
98 |
*
|
99 |
+
* @date 9/1/19
|
100 |
+
* @since 5.7.10
|
101 |
*
|
102 |
+
* @param void
|
103 |
+
* @return bool
|
104 |
*/
|
105 |
function acf_allow_unfiltered_html() {
|
106 |
+
|
107 |
// Check capability.
|
108 |
+
$allow_unfiltered_html = current_user_can( 'unfiltered_html' );
|
109 |
+
|
110 |
/**
|
111 |
* Filters whether the current user is allowed to save unfiltered HTML.
|
112 |
*
|
113 |
+
* @date 9/1/19
|
114 |
+
* @since 5.7.10
|
115 |
*
|
116 |
+
* @param bool allow_unfiltered_html The result.
|
117 |
*/
|
118 |
return apply_filters( 'acf/allow_unfiltered_html', $allow_unfiltered_html );
|
119 |
+
}
|
includes/acf-utility-functions.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
// Globals.
|
4 |
global $acf_stores, $acf_instances;
|
5 |
|
6 |
// Initialize plaeholders.
|
7 |
-
$acf_stores
|
8 |
$acf_instances = array();
|
9 |
|
10 |
/**
|
@@ -12,11 +12,11 @@ $acf_instances = array();
|
|
12 |
*
|
13 |
* Creates a new instance of the given class and stores it in the instances data store.
|
14 |
*
|
15 |
-
* @date
|
16 |
-
* @since
|
17 |
*
|
18 |
-
* @param
|
19 |
-
* @return
|
20 |
*/
|
21 |
function acf_new_instance( $class = '' ) {
|
22 |
global $acf_instances;
|
@@ -28,15 +28,15 @@ function acf_new_instance( $class = '' ) {
|
|
28 |
*
|
29 |
* Returns an instance for the given class.
|
30 |
*
|
31 |
-
* @date
|
32 |
-
* @since
|
33 |
*
|
34 |
-
* @param
|
35 |
-
* @return
|
36 |
*/
|
37 |
function acf_get_instance( $class = '' ) {
|
38 |
global $acf_instances;
|
39 |
-
if( !isset($acf_instances[ $class ]) ) {
|
40 |
$acf_instances[ $class ] = new $class();
|
41 |
}
|
42 |
return $acf_instances[ $class ];
|
@@ -47,36 +47,36 @@ function acf_get_instance( $class = '' ) {
|
|
47 |
*
|
48 |
* Registers a data store.
|
49 |
*
|
50 |
-
* @date
|
51 |
-
* @since
|
52 |
*
|
53 |
-
* @param
|
54 |
-
* @param
|
55 |
-
* @return
|
56 |
*/
|
57 |
function acf_register_store( $name = '', $data = false ) {
|
58 |
-
|
59 |
// Create store.
|
60 |
$store = new ACF_Data( $data );
|
61 |
-
|
62 |
// Register store.
|
63 |
global $acf_stores;
|
64 |
$acf_stores[ $name ] = $store;
|
65 |
-
|
66 |
// Return store.
|
67 |
return $store;
|
68 |
-
|
69 |
-
|
70 |
/**
|
71 |
* acf_get_store
|
72 |
*
|
73 |
* Returns a data store.
|
74 |
*
|
75 |
-
* @date
|
76 |
-
* @since
|
77 |
*
|
78 |
-
* @param
|
79 |
-
* @return
|
80 |
*/
|
81 |
function acf_get_store( $name = '' ) {
|
82 |
global $acf_stores;
|
@@ -88,18 +88,18 @@ function acf_get_store( $name = '' ) {
|
|
88 |
*
|
89 |
* Triggered when switching between sites on a multisite installation.
|
90 |
*
|
91 |
-
* @date
|
92 |
-
* @since
|
93 |
*
|
94 |
-
* @param
|
95 |
-
* @param
|
96 |
-
* @return
|
97 |
*/
|
98 |
function acf_switch_stores( $site_id, $prev_site_id ) {
|
99 |
-
|
100 |
// Loop over stores and call switch_site().
|
101 |
global $acf_stores;
|
102 |
-
foreach( $acf_stores as $store ) {
|
103 |
$store->switch_site( $site_id, $prev_site_id );
|
104 |
}
|
105 |
}
|
@@ -110,14 +110,14 @@ add_action( 'switch_blog', 'acf_switch_stores', 10, 2 );
|
|
110 |
*
|
111 |
* Returns the plugin path to a specified file.
|
112 |
*
|
113 |
-
* @date
|
114 |
-
* @since
|
115 |
*
|
116 |
-
* @param
|
117 |
-
* @return
|
118 |
*/
|
119 |
function acf_get_path( $filename = '' ) {
|
120 |
-
return ACF_PATH . ltrim($filename, '/');
|
121 |
}
|
122 |
|
123 |
/**
|
@@ -126,17 +126,17 @@ function acf_get_path( $filename = '' ) {
|
|
126 |
* Returns the plugin url to a specified file.
|
127 |
* This function also defines the ACF_URL constant.
|
128 |
*
|
129 |
-
* @date
|
130 |
-
* @since
|
131 |
*
|
132 |
-
* @param
|
133 |
-
* @return
|
134 |
*/
|
135 |
function acf_get_url( $filename = '' ) {
|
136 |
-
if( !defined('ACF_URL') ) {
|
137 |
-
define( 'ACF_URL', acf_get_setting('url') );
|
138 |
}
|
139 |
-
return ACF_URL . ltrim($filename, '/');
|
140 |
}
|
141 |
|
142 |
/*
|
@@ -144,15 +144,15 @@ function acf_get_url( $filename = '' ) {
|
|
144 |
*
|
145 |
* Includes a file within the ACF plugin.
|
146 |
*
|
147 |
-
* @date
|
148 |
-
* @since
|
149 |
*
|
150 |
-
* @param
|
151 |
-
* @return
|
152 |
*/
|
153 |
function acf_include( $filename = '' ) {
|
154 |
-
$file_path = acf_get_path($filename);
|
155 |
-
if( file_exists($file_path) ) {
|
156 |
-
include_once
|
157 |
}
|
158 |
}
|
1 |
+
<?php
|
2 |
|
3 |
// Globals.
|
4 |
global $acf_stores, $acf_instances;
|
5 |
|
6 |
// Initialize plaeholders.
|
7 |
+
$acf_stores = array();
|
8 |
$acf_instances = array();
|
9 |
|
10 |
/**
|
12 |
*
|
13 |
* Creates a new instance of the given class and stores it in the instances data store.
|
14 |
*
|
15 |
+
* @date 9/1/19
|
16 |
+
* @since 5.7.10
|
17 |
*
|
18 |
+
* @param string $class The class name.
|
19 |
+
* @return object The instance.
|
20 |
*/
|
21 |
function acf_new_instance( $class = '' ) {
|
22 |
global $acf_instances;
|
28 |
*
|
29 |
* Returns an instance for the given class.
|
30 |
*
|
31 |
+
* @date 9/1/19
|
32 |
+
* @since 5.7.10
|
33 |
*
|
34 |
+
* @param string $class The class name.
|
35 |
+
* @return object The instance.
|
36 |
*/
|
37 |
function acf_get_instance( $class = '' ) {
|
38 |
global $acf_instances;
|
39 |
+
if ( ! isset( $acf_instances[ $class ] ) ) {
|
40 |
$acf_instances[ $class ] = new $class();
|
41 |
}
|
42 |
return $acf_instances[ $class ];
|
47 |
*
|
48 |
* Registers a data store.
|
49 |
*
|
50 |
+
* @date 9/1/19
|
51 |
+
* @since 5.7.10
|
52 |
*
|
53 |
+
* @param string $name The store name.
|
54 |
+
* @param array $data Array of data to start the store with.
|
55 |
+
* @return ACF_Data
|
56 |
*/
|
57 |
function acf_register_store( $name = '', $data = false ) {
|
58 |
+
|
59 |
// Create store.
|
60 |
$store = new ACF_Data( $data );
|
61 |
+
|
62 |
// Register store.
|
63 |
global $acf_stores;
|
64 |
$acf_stores[ $name ] = $store;
|
65 |
+
|
66 |
// Return store.
|
67 |
return $store;
|
68 |
+
}
|
69 |
+
|
70 |
/**
|
71 |
* acf_get_store
|
72 |
*
|
73 |
* Returns a data store.
|
74 |
*
|
75 |
+
* @date 9/1/19
|
76 |
+
* @since 5.7.10
|
77 |
*
|
78 |
+
* @param string $name The store name.
|
79 |
+
* @return ACF_Data
|
80 |
*/
|
81 |
function acf_get_store( $name = '' ) {
|
82 |
global $acf_stores;
|
88 |
*
|
89 |
* Triggered when switching between sites on a multisite installation.
|
90 |
*
|
91 |
+
* @date 13/2/19
|
92 |
+
* @since 5.7.11
|
93 |
*
|
94 |
+
* @param int $site_id New blog ID.
|
95 |
+
* @param int prev_blog_id Prev blog ID.
|
96 |
+
* @return void
|
97 |
*/
|
98 |
function acf_switch_stores( $site_id, $prev_site_id ) {
|
99 |
+
|
100 |
// Loop over stores and call switch_site().
|
101 |
global $acf_stores;
|
102 |
+
foreach ( $acf_stores as $store ) {
|
103 |
$store->switch_site( $site_id, $prev_site_id );
|
104 |
}
|
105 |
}
|
110 |
*
|
111 |
* Returns the plugin path to a specified file.
|
112 |
*
|
113 |
+
* @date 28/9/13
|
114 |
+
* @since 5.0.0
|
115 |
*
|
116 |
+
* @param string $filename The specified file.
|
117 |
+
* @return string
|
118 |
*/
|
119 |
function acf_get_path( $filename = '' ) {
|
120 |
+
return ACF_PATH . ltrim( $filename, '/' );
|
121 |
}
|
122 |
|
123 |
/**
|
126 |
* Returns the plugin url to a specified file.
|
127 |
* This function also defines the ACF_URL constant.
|
128 |
*
|
129 |
+
* @date 12/12/17
|
130 |
+
* @since 5.6.8
|
131 |
*
|
132 |
+
* @param string $filename The specified file.
|
133 |
+
* @return string
|
134 |
*/
|
135 |
function acf_get_url( $filename = '' ) {
|
136 |
+
if ( ! defined( 'ACF_URL' ) ) {
|
137 |
+
define( 'ACF_URL', acf_get_setting( 'url' ) );
|
138 |
}
|
139 |
+
return ACF_URL . ltrim( $filename, '/' );
|
140 |
}
|
141 |
|
142 |
/*
|
144 |
*
|
145 |
* Includes a file within the ACF plugin.
|
146 |
*
|
147 |
+
* @date 10/3/14
|
148 |
+
* @since 5.0.0
|
149 |
*
|
150 |
+
* @param string $filename The specified file.
|
151 |
+
* @return void
|
152 |
*/
|
153 |
function acf_include( $filename = '' ) {
|
154 |
+
$file_path = acf_get_path( $filename );
|
155 |
+
if ( file_exists( $file_path ) ) {
|
156 |
+
include_once $file_path;
|
157 |
}
|
158 |
}
|
includes/acf-value-functions.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'values' )->prop( 'multisite', true );
|
@@ -8,84 +8,84 @@ acf_register_store( 'values' )->prop( 'multisite', true );
|
|
8 |
*
|
9 |
* Retrieves the field key for a given field name and post_id.
|
10 |
*
|
11 |
-
* @date
|
12 |
-
* @since
|
13 |
*
|
14 |
-
* @param
|
15 |
-
* @param
|
16 |
-
* @return
|
17 |
*/
|
18 |
function acf_get_reference( $field_name, $post_id ) {
|
19 |
-
|
20 |
// Allow filter to short-circuit load_value logic.
|
21 |
-
$reference = apply_filters(
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
// Get hidden meta for this field name.
|
27 |
$reference = acf_get_metadata( $post_id, $field_name, true );
|
28 |
-
|
29 |
/**
|
30 |
* Filters the reference value.
|
31 |
*
|
32 |
-
* @date
|
33 |
-
* @since
|
34 |
*
|
35 |
-
* @param
|
36 |
-
* @param
|
37 |
-
* @param
|
38 |
*/
|
39 |
-
return apply_filters(
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
* Retrieves the value for a given field and post_id.
|
44 |
*
|
45 |
-
* @date
|
46 |
-
* @since
|
47 |
*
|
48 |
-
* @param
|
49 |
-
* @param
|
50 |
-
* @return
|
51 |
*/
|
52 |
function acf_get_value( $post_id, $field ) {
|
53 |
-
|
54 |
// Allow filter to short-circuit load_value logic.
|
55 |
-
$value = apply_filters(
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
$store = acf_get_store( 'values' );
|
65 |
-
if( $store->has( "$post_id:$field_name" ) ) {
|
66 |
return $store->get( "$post_id:$field_name" );
|
67 |
}
|
68 |
-
|
69 |
// Load value from database.
|
70 |
$value = acf_get_metadata( $post_id, $field_name );
|
71 |
-
|
72 |
// Use field's default_value if no meta was found.
|
73 |
-
if( $value === null && isset($field['default_value']) ) {
|
74 |
$value = $field['default_value'];
|
75 |
}
|
76 |
-
|
77 |
/**
|
78 |
* Filters the $value after it has been loaded.
|
79 |
*
|
80 |
-
* @date
|
81 |
-
* @since
|
82 |
*
|
83 |
-
* @param
|
84 |
-
* @param
|
85 |
-
* @param
|
86 |
*/
|
87 |
-
$value = apply_filters(
|
88 |
-
|
89 |
// Update store.
|
90 |
$store->set( "$post_id:$field_name", $value );
|
91 |
|
@@ -94,50 +94,50 @@ function acf_get_value( $post_id, $field ) {
|
|
94 |
}
|
95 |
|
96 |
// Register variation.
|
97 |
-
acf_add_filter_variations( 'acf/load_value', array('type', 'name', 'key'), 2 );
|
98 |
|
99 |
/**
|
100 |
* acf_format_value
|
101 |
*
|
102 |
* Returns a formatted version of the provided value.
|
103 |
*
|
104 |
-
* @date
|
105 |
-
* @since
|
106 |
*
|
107 |
-
* @param
|
108 |
-
* @param
|
109 |
-
* @param
|
110 |
-
* @return
|
111 |
*/
|
112 |
function acf_format_value( $value, $post_id, $field ) {
|
113 |
-
|
114 |
// Allow filter to short-circuit load_value logic.
|
115 |
-
$check = apply_filters(
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
$store = acf_get_store( 'values' );
|
125 |
-
if( $store->has( "$post_id:$field_name:formatted" ) ) {
|
126 |
return $store->get( "$post_id:$field_name:formatted" );
|
127 |
}
|
128 |
-
|
129 |
/**
|
130 |
* Filters the $value for use in a template function.
|
131 |
*
|
132 |
-
* @date
|
133 |
-
* @since
|
134 |
*
|
135 |
-
* @param
|
136 |
-
* @param
|
137 |
-
* @param
|
138 |
*/
|
139 |
-
$value = apply_filters(
|
140 |
-
|
141 |
// Update store.
|
142 |
$store->set( "$post_id:$field_name:formatted", $value );
|
143 |
|
@@ -146,85 +146,85 @@ function acf_format_value( $value, $post_id, $field ) {
|
|
146 |
}
|
147 |
|
148 |
// Register variation.
|
149 |
-
acf_add_filter_variations( 'acf/format_value', array('type', 'name', 'key'), 2 );
|
150 |
|
151 |
/**
|
152 |
* acf_update_value
|
153 |
*
|
154 |
* Updates the value for a given field and post_id.
|
155 |
*
|
156 |
-
* @date
|
157 |
-
* @since
|
158 |
*
|
159 |
-
* @param
|
160 |
-
* @param
|
161 |
-
* @param
|
162 |
-
* @return
|
163 |
*/
|
164 |
function acf_update_value( $value, $post_id, $field ) {
|
165 |
-
|
166 |
// Allow filter to short-circuit update_value logic.
|
167 |
-
$check = apply_filters(
|
168 |
-
if( $check !== null ) {
|
169 |
return $check;
|
170 |
}
|
171 |
-
|
172 |
-
|
173 |
* Filters the $value before it is updated.
|
174 |
*
|
175 |
-
* @date
|
176 |
-
* @since
|
177 |
*
|
178 |
-
* @param
|
179 |
-
* @param
|
180 |
-
* @param
|
181 |
-
* @param
|
182 |
*/
|
183 |
-
$value = apply_filters(
|
184 |
-
|
185 |
// Allow null to delete value.
|
186 |
-
if( $value === null ) {
|
187 |
return acf_delete_value( $post_id, $field );
|
188 |
}
|
189 |
-
|
190 |
// Update meta.
|
191 |
$return = acf_update_metadata( $post_id, $field['name'], $value );
|
192 |
-
|
193 |
// Update reference.
|
194 |
acf_update_metadata( $post_id, $field['name'], $field['key'], true );
|
195 |
-
|
196 |
// Delete stored data.
|
197 |
acf_flush_value_cache( $post_id, $field['name'] );
|
198 |
-
|
199 |
// Return update status.
|
200 |
return $return;
|
201 |
}
|
202 |
|
203 |
// Register variation.
|
204 |
-
acf_add_filter_variations( 'acf/update_value', array('type', 'name', 'key'), 2 );
|
205 |
|
206 |
/**
|
207 |
* acf_update_values
|
208 |
*
|
209 |
* Updates an array of values.
|
210 |
*
|
211 |
-
* @date
|
212 |
-
* @since
|
213 |
*
|
214 |
-
* @param
|
215 |
-
* @param
|
216 |
-
* @return
|
217 |
*/
|
218 |
function acf_update_values( $values, $post_id ) {
|
219 |
-
|
220 |
// Loop over values.
|
221 |
-
foreach( $values as $key => $value ) {
|
222 |
-
|
223 |
// Get field.
|
224 |
$field = acf_get_field( $key );
|
225 |
-
|
226 |
// Update value.
|
227 |
-
if( $field ) {
|
228 |
acf_update_value( $value, $post_id, $field );
|
229 |
}
|
230 |
}
|
@@ -235,15 +235,15 @@ function acf_update_values( $values, $post_id ) {
|
|
235 |
*
|
236 |
* Deletes all cached data for this value.
|
237 |
*
|
238 |
-
* @date
|
239 |
-
* @since
|
240 |
*
|
241 |
-
* @param
|
242 |
-
* @param
|
243 |
-
* @return
|
244 |
*/
|
245 |
function acf_flush_value_cache( $post_id = 0, $field_name = '' ) {
|
246 |
-
|
247 |
// Delete stored data.
|
248 |
acf_get_store( 'values' )
|
249 |
->remove( "$post_id:$field_name" )
|
@@ -255,70 +255,70 @@ function acf_flush_value_cache( $post_id = 0, $field_name = '' ) {
|
|
255 |
*
|
256 |
* Deletes the value for a given field and post_id.
|
257 |
*
|
258 |
-
* @date
|
259 |
-
* @since
|
260 |
*
|
261 |
-
* @param
|
262 |
-
* @param
|
263 |
-
* @return
|
264 |
*/
|
265 |
function acf_delete_value( $post_id, $field ) {
|
266 |
-
|
267 |
/**
|
268 |
* Fires before a value is deleted.
|
269 |
*
|
270 |
-
* @date
|
271 |
-
* @since
|
272 |
*
|
273 |
-
* @param
|
274 |
-
* @param
|
275 |
-
* @param
|
276 |
*/
|
277 |
-
do_action(
|
278 |
-
|
279 |
// Delete meta.
|
280 |
$return = acf_delete_metadata( $post_id, $field['name'] );
|
281 |
-
|
282 |
// Delete reference.
|
283 |
acf_delete_metadata( $post_id, $field['name'], true );
|
284 |
-
|
285 |
// Delete stored data.
|
286 |
acf_flush_value_cache( $post_id, $field['name'] );
|
287 |
-
|
288 |
// Return delete status.
|
289 |
return $return;
|
290 |
}
|
291 |
|
292 |
// Register variation.
|
293 |
-
acf_add_filter_variations( 'acf/delete_value', array('type', 'name', 'key'), 2 );
|
294 |
|
295 |
/**
|
296 |
* acf_preview_value
|
297 |
*
|
298 |
* Return a human friendly 'preview' for a given field value.
|
299 |
*
|
300 |
-
* @date
|
301 |
-
* @since
|
302 |
*
|
303 |
-
* @param
|
304 |
-
* @param
|
305 |
-
* @param
|
306 |
-
* @return
|
307 |
*/
|
308 |
function acf_preview_value( $value, $post_id, $field ) {
|
309 |
-
|
310 |
/**
|
311 |
* Filters the $value before used in HTML.
|
312 |
*
|
313 |
-
* @date
|
314 |
-
* @since
|
315 |
*
|
316 |
-
* @param
|
317 |
-
* @param
|
318 |
-
* @param
|
319 |
*/
|
320 |
-
return apply_filters(
|
321 |
}
|
322 |
|
323 |
// Register variation.
|
324 |
-
acf_add_filter_variations( 'acf/preview_value', array('type', 'name', 'key'), 2 );
|
1 |
+
<?php
|
2 |
|
3 |
// Register store.
|
4 |
acf_register_store( 'values' )->prop( 'multisite', true );
|
8 |
*
|
9 |
* Retrieves the field key for a given field name and post_id.
|
10 |
*
|
11 |
+
* @date 26/1/18
|
12 |
+
* @since 5.6.5
|
13 |
*
|
14 |
+
* @param string $field_name The name of the field. eg 'sub_heading'.
|
15 |
+
* @param mixed $post_id The post_id of which the value is saved against.
|
16 |
+
* @return string The field key.
|
17 |
*/
|
18 |
function acf_get_reference( $field_name, $post_id ) {
|
19 |
+
|
20 |
// Allow filter to short-circuit load_value logic.
|
21 |
+
$reference = apply_filters( 'acf/pre_load_reference', null, $field_name, $post_id );
|
22 |
+
if ( $reference !== null ) {
|
23 |
+
return $reference;
|
24 |
+
}
|
25 |
+
|
26 |
// Get hidden meta for this field name.
|
27 |
$reference = acf_get_metadata( $post_id, $field_name, true );
|
28 |
+
|
29 |
/**
|
30 |
* Filters the reference value.
|
31 |
*
|
32 |
+
* @date 25/1/19
|
33 |
+
* @since 5.7.11
|
34 |
*
|
35 |
+
* @param string $reference The reference value.
|
36 |
+
* @param string $field_name The field name.
|
37 |
+
* @param (int|string) $post_id The post ID where meta is stored.
|
38 |
*/
|
39 |
+
return apply_filters( 'acf/load_reference', $reference, $field_name, $post_id );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
* Retrieves the value for a given field and post_id.
|
44 |
*
|
45 |
+
* @date 28/09/13
|
46 |
+
* @since 5.0.0
|
47 |
*
|
48 |
+
* @param int|string $post_id The post id.
|
49 |
+
* @param array $field The field array.
|
50 |
+
* @return mixed
|
51 |
*/
|
52 |
function acf_get_value( $post_id, $field ) {
|
53 |
+
|
54 |
// Allow filter to short-circuit load_value logic.
|
55 |
+
$value = apply_filters( 'acf/pre_load_value', null, $post_id, $field );
|
56 |
+
if ( $value !== null ) {
|
57 |
+
return $value;
|
58 |
+
}
|
59 |
+
|
60 |
+
// Get field name.
|
61 |
+
$field_name = $field['name'];
|
62 |
+
|
63 |
+
// Check store.
|
64 |
$store = acf_get_store( 'values' );
|
65 |
+
if ( $store->has( "$post_id:$field_name" ) ) {
|
66 |
return $store->get( "$post_id:$field_name" );
|
67 |
}
|
68 |
+
|
69 |
// Load value from database.
|
70 |
$value = acf_get_metadata( $post_id, $field_name );
|
71 |
+
|
72 |
// Use field's default_value if no meta was found.
|
73 |
+
if ( $value === null && isset( $field['default_value'] ) ) {
|
74 |
$value = $field['default_value'];
|
75 |
}
|
76 |
+
|
77 |
/**
|
78 |
* Filters the $value after it has been loaded.
|
79 |
*
|
80 |
+
* @date 28/09/13
|
81 |
+
* @since 5.0.0
|
82 |
*
|
83 |
+
* @param mixed $value The value to preview.
|
84 |
+
* @param string $post_id The post ID for this value.
|
85 |
+
* @param array $field The field array.
|
86 |
*/
|
87 |
+
$value = apply_filters( 'acf/load_value', $value, $post_id, $field );
|
88 |
+
|
89 |
// Update store.
|
90 |
$store->set( "$post_id:$field_name", $value );
|
91 |
|
94 |
}
|
95 |
|
96 |
// Register variation.
|
97 |
+
acf_add_filter_variations( 'acf/load_value', array( 'type', 'name', 'key' ), 2 );
|
98 |
|
99 |
/**
|
100 |
* acf_format_value
|
101 |
*
|
102 |
* Returns a formatted version of the provided value.
|
103 |
*
|
104 |
+
* @date 28/09/13
|
105 |
+
* @since 5.0.0
|
106 |
*
|
107 |
+
* @param mixed $value The field value.
|
108 |
+
* @param (int|string) $post_id The post id.
|
109 |
+
* @param array $field The field array.
|
110 |
+
* @return mixed.
|
111 |
*/
|
112 |
function acf_format_value( $value, $post_id, $field ) {
|
113 |
+
|
114 |
// Allow filter to short-circuit load_value logic.
|
115 |
+
$check = apply_filters( 'acf/pre_format_value', null, $value, $post_id, $field );
|
116 |
+
if ( $check !== null ) {
|
117 |
+
return $check;
|
118 |
+
}
|
119 |
+
|
120 |
+
// Get field name.
|
121 |
+
$field_name = $field['name'];
|
122 |
+
|
123 |
+
// Check store.
|
124 |
$store = acf_get_store( 'values' );
|
125 |
+
if ( $store->has( "$post_id:$field_name:formatted" ) ) {
|
126 |
return $store->get( "$post_id:$field_name:formatted" );
|
127 |
}
|
128 |
+
|
129 |
/**
|
130 |
* Filters the $value for use in a template function.
|
131 |
*
|
132 |
+
* @date 28/09/13
|
133 |
+
* @since 5.0.0
|
134 |
*
|
135 |
+
* @param mixed $value The value to preview.
|
136 |
+
* @param string $post_id The post ID for this value.
|
137 |
+
* @param array $field The field array.
|
138 |
*/
|
139 |
+
$value = apply_filters( 'acf/format_value', $value, $post_id, $field );
|
140 |
+
|
141 |
// Update store.
|
142 |
$store->set( "$post_id:$field_name:formatted", $value );
|
143 |
|
146 |
}
|
147 |
|
148 |
// Register variation.
|
149 |
+
acf_add_filter_variations( 'acf/format_value', array( 'type', 'name', 'key' ), 2 );
|
150 |
|
151 |
/**
|
152 |
* acf_update_value
|
153 |
*
|
154 |
* Updates the value for a given field and post_id.
|
155 |
*
|
156 |
+
* @date 28/09/13
|
157 |
+
* @since 5.0.0
|
158 |
*
|
159 |
+
* @param mixed $value The new value.
|
160 |
+
* @param (int|string) $post_id The post id.
|
161 |
+
* @param array $field The field array.
|
162 |
+
* @return bool.
|
163 |
*/
|
164 |
function acf_update_value( $value, $post_id, $field ) {
|
165 |
+
|
166 |
// Allow filter to short-circuit update_value logic.
|
167 |
+
$check = apply_filters( 'acf/pre_update_value', null, $value, $post_id, $field );
|
168 |
+
if ( $check !== null ) {
|
169 |
return $check;
|
170 |
}
|
171 |
+
|
172 |
+
/**
|
173 |
* Filters the $value before it is updated.
|
174 |
*
|
175 |
+
* @date 28/09/13
|
176 |
+
* @since 5.0.0
|
177 |
*
|
178 |
+
* @param mixed $value The value to update.
|
179 |
+
* @param string $post_id The post ID for this value.
|
180 |
+
* @param array $field The field array.
|
181 |
+
* @param mixed $original The original value before modification.
|
182 |
*/
|
183 |
+
$value = apply_filters( 'acf/update_value', $value, $post_id, $field, $value );
|
184 |
+
|
185 |
// Allow null to delete value.
|
186 |
+
if ( $value === null ) {
|
187 |
return acf_delete_value( $post_id, $field );
|
188 |
}
|
189 |
+
|
190 |
// Update meta.
|
191 |
$return = acf_update_metadata( $post_id, $field['name'], $value );
|
192 |
+
|
193 |
// Update reference.
|
194 |
acf_update_metadata( $post_id, $field['name'], $field['key'], true );
|
195 |
+
|
196 |
// Delete stored data.
|
197 |
acf_flush_value_cache( $post_id, $field['name'] );
|
198 |
+
|
199 |
// Return update status.
|
200 |
return $return;
|
201 |
}
|
202 |
|
203 |
// Register variation.
|
204 |
+
acf_add_filter_variations( 'acf/update_value', array( 'type', 'name', 'key' ), 2 );
|
205 |
|
206 |
/**
|
207 |
* acf_update_values
|
208 |
*
|
209 |
* Updates an array of values.
|
210 |
*
|
211 |
+
* @date 26/2/19
|
212 |
+
* @since 5.7.13
|
213 |
*
|
214 |
+
* @param array values The array of values.
|
215 |
+
* @param (int|string) $post_id The post id.
|
216 |
+
* @return void
|
217 |
*/
|
218 |
function acf_update_values( $values, $post_id ) {
|
219 |
+
|
220 |
// Loop over values.
|
221 |
+
foreach ( $values as $key => $value ) {
|
222 |
+
|
223 |
// Get field.
|
224 |
$field = acf_get_field( $key );
|
225 |
+
|
226 |
// Update value.
|
227 |
+
if ( $field ) {
|
228 |
acf_update_value( $value, $post_id, $field );
|
229 |
}
|
230 |
}
|
235 |
*
|
236 |
* Deletes all cached data for this value.
|
237 |
*
|
238 |
+
* @date 22/1/19
|
239 |
+
* @since 5.7.10
|
240 |
*
|
241 |
+
* @param (int|string) $post_id The post id.
|
242 |
+
* @param string $field_name The field name.
|
243 |
+
* @return void
|
244 |
*/
|
245 |
function acf_flush_value_cache( $post_id = 0, $field_name = '' ) {
|
246 |
+
|
247 |
// Delete stored data.
|
248 |
acf_get_store( 'values' )
|
249 |
->remove( "$post_id:$field_name" )
|
255 |
*
|
256 |
* Deletes the value for a given field and post_id.
|
257 |
*
|
258 |
+
* @date 28/09/13
|
259 |
+
* @since 5.0.0
|
260 |
*
|
261 |
+
* @param (int|string) $post_id The post id.
|
262 |
+
* @param array $field The field array.
|
263 |
+
* @return bool.
|
264 |
*/
|
265 |
function acf_delete_value( $post_id, $field ) {
|
266 |
+
|
267 |
/**
|
268 |
* Fires before a value is deleted.
|
269 |
*
|
270 |
+
* @date 28/09/13
|
271 |
+
* @since 5.0.0
|
272 |
*
|
273 |
+
* @param string $post_id The post ID for this value.
|
274 |
+
* @param mixed $name The meta name.
|
275 |
+
* @param array $field The field array.
|
276 |
*/
|
277 |
+
do_action( 'acf/delete_value', $post_id, $field['name'], $field );
|
278 |
+
|
279 |
// Delete meta.
|
280 |
$return = acf_delete_metadata( $post_id, $field['name'] );
|
281 |
+
|
282 |
// Delete reference.
|
283 |
acf_delete_metadata( $post_id, $field['name'], true );
|
284 |
+
|
285 |
// Delete stored data.
|
286 |
acf_flush_value_cache( $post_id, $field['name'] );
|
287 |
+
|
288 |
// Return delete status.
|
289 |
return $return;
|
290 |
}
|
291 |
|
292 |
// Register variation.
|
293 |
+
acf_add_filter_variations( 'acf/delete_value', array( 'type', 'name', 'key' ), 2 );
|
294 |
|
295 |
/**
|
296 |
* acf_preview_value
|
297 |
*
|
298 |
* Return a human friendly 'preview' for a given field value.
|
299 |
*
|
300 |
+
* @date 28/09/13
|
301 |
+
* @since 5.0.0
|
302 |
*
|
303 |
+
* @param mixed $value The new value.
|
304 |
+
* @param (int|string) $post_id The post id.
|
305 |
+
* @param array $field The field array.
|
306 |
+
* @return bool.
|
307 |
*/
|
308 |
function acf_preview_value( $value, $post_id, $field ) {
|
309 |
+
|
310 |
/**
|
311 |
* Filters the $value before used in HTML.
|
312 |
*
|
313 |
+
* @date 24/10/16
|
314 |
+
* @since 5.5.0
|
315 |
*
|
316 |
+
* @param mixed $value The value to preview.
|
317 |
+
* @param string $post_id The post ID for this value.
|
318 |
+
* @param array $field The field array.
|
319 |
*/
|
320 |
+
return apply_filters( 'acf/preview_value', $value, $post_id, $field );
|
321 |
}
|
322 |
|
323 |
// Register variation.
|
324 |
+
acf_add_filter_variations( 'acf/preview_value', array( 'type', 'name', 'key' ), 2 );
|
includes/acf-wp-functions.php
CHANGED
@@ -3,106 +3,106 @@
|
|
3 |
/**
|
4 |
* Returns a WordPress object type.
|
5 |
*
|
6 |
-
* @date
|
7 |
-
* @since
|
8 |
*
|
9 |
-
* @param
|
10 |
-
* @param
|
11 |
-
* @return
|
12 |
*/
|
13 |
function acf_get_object_type( $object_type, $object_subtype = '' ) {
|
14 |
$props = array(
|
15 |
-
'type'
|
16 |
-
'subtype'
|
17 |
-
'name'
|
18 |
-
'label'
|
19 |
-
'icon'
|
20 |
);
|
21 |
-
|
22 |
// Set unique identifier as name.
|
23 |
-
if( $object_subtype ) {
|
24 |
$props['name'] = "$object_type/$object_subtype";
|
25 |
} else {
|
26 |
$props['name'] = $object_type;
|
27 |
}
|
28 |
-
|
29 |
// Set label and icon.
|
30 |
switch ( $object_type ) {
|
31 |
case 'post':
|
32 |
-
if( $object_subtype ) {
|
33 |
$post_type = get_post_type_object( $object_subtype );
|
34 |
-
if( $post_type ) {
|
35 |
$props['label'] = $post_type->labels->name;
|
36 |
-
$props['icon']
|
37 |
} else {
|
38 |
return false;
|
39 |
}
|
40 |
} else {
|
41 |
-
$props['label'] = __('Posts', 'acf');
|
42 |
-
$props['icon']
|
43 |
}
|
44 |
break;
|
45 |
case 'term':
|
46 |
-
if( $object_subtype ) {
|
47 |
$taxonomy = get_taxonomy( $object_subtype );
|
48 |
-
if( $taxonomy ) {
|
49 |
$props['label'] = $taxonomy->labels->name;
|
50 |
} else {
|
51 |
return false;
|
52 |
}
|
53 |
} else {
|
54 |
-
$props['label'] = __('Taxonomies', 'acf');
|
55 |
}
|
56 |
$props['icon'] = 'dashicons-tag';
|
57 |
break;
|
58 |
case 'attachment':
|
59 |
-
$props['label'] = __('Attachments', 'acf');
|
60 |
-
$props['icon']
|
61 |
break;
|
62 |
case 'comment':
|
63 |
-
$props['label'] = __('Comments', 'acf');
|
64 |
-
$props['icon']
|
65 |
break;
|
66 |
case 'widget':
|
67 |
-
$props['label'] = __('Widgets', 'acf');
|
68 |
-
$props['icon']
|
69 |
break;
|
70 |
case 'menu':
|
71 |
-
$props['label'] = __('Menus', 'acf');
|
72 |
-
$props['icon']
|
73 |
break;
|
74 |
case 'menu_item':
|
75 |
-
$props['label'] = __('Menu items', 'acf');
|
76 |
-
$props['icon']
|
77 |
break;
|
78 |
case 'user':
|
79 |
-
$props['label'] = __('Users', 'acf');
|
80 |
-
$props['icon']
|
81 |
break;
|
82 |
case 'option':
|
83 |
-
$props['label'] = __('Options', 'acf');
|
84 |
-
$props['icon']
|
85 |
break;
|
86 |
case 'block':
|
87 |
-
$props['label'] = __('Blocks', 'acf');
|
88 |
-
$props['icon']
|
89 |
break;
|
90 |
default:
|
91 |
return false;
|
92 |
}
|
93 |
-
|
94 |
// Convert to object.
|
95 |
$object = (object) $props;
|
96 |
-
|
97 |
/**
|
98 |
* Filters the object type.
|
99 |
*
|
100 |
-
* @date
|
101 |
-
* @since
|
102 |
*
|
103 |
-
* @param
|
104 |
-
* @param
|
105 |
-
* @param
|
106 |
*/
|
107 |
return apply_filters( 'acf/get_object_type', $object, $object_type, $object_subtype );
|
108 |
}
|
@@ -110,109 +110,109 @@ function acf_get_object_type( $object_type, $object_subtype = '' ) {
|
|
110 |
/**
|
111 |
* Decodes a post_id value such as 1 or "user_1" into an array containing the type and ID.
|
112 |
*
|
113 |
-
* @date
|
114 |
-
* @since
|
115 |
*
|
116 |
-
* @param
|
117 |
-
* @return
|
118 |
*/
|
119 |
function acf_decode_post_id( $post_id = 0 ) {
|
120 |
$type = '';
|
121 |
-
$id
|
122 |
-
|
123 |
// Interpret numeric value (123).
|
124 |
-
if ( is_numeric($post_id) ) {
|
125 |
$type = 'post';
|
126 |
-
$id
|
127 |
-
|
128 |
-
|
129 |
-
} elseif ( is_string($post_id) ) {
|
130 |
-
$i = strrpos($post_id, '_');
|
131 |
-
if( $i > 0 ) {
|
132 |
-
$type = substr($post_id, 0, $i);
|
133 |
-
$id
|
134 |
} else {
|
135 |
$type = $post_id;
|
136 |
-
$id
|
137 |
}
|
138 |
-
|
139 |
-
|
140 |
} else {
|
141 |
return compact( 'type', 'id' );
|
142 |
}
|
143 |
-
|
144 |
// Validate props based on param format.
|
145 |
-
$format = $type . '_' . (is_numeric($id) ? '%d' : '%s');
|
146 |
switch ( $format ) {
|
147 |
case 'post_%d':
|
148 |
$type = 'post';
|
149 |
-
$id
|
150 |
break;
|
151 |
case 'term_%d':
|
152 |
$type = 'term';
|
153 |
-
$id
|
154 |
break;
|
155 |
case 'attachment_%d':
|
156 |
$type = 'post';
|
157 |
-
$id
|
158 |
break;
|
159 |
case 'comment_%d':
|
160 |
$type = 'comment';
|
161 |
-
$id
|
162 |
break;
|
163 |
case 'widget_%s':
|
164 |
case 'widget_%d':
|
165 |
$type = 'option';
|
166 |
-
$id
|
167 |
break;
|
168 |
case 'menu_%d':
|
169 |
$type = 'term';
|
170 |
-
$id
|
171 |
break;
|
172 |
case 'menu_item_%d':
|
173 |
$type = 'post';
|
174 |
-
$id
|
175 |
break;
|
176 |
case 'user_%d':
|
177 |
$type = 'user';
|
178 |
-
$id
|
179 |
break;
|
180 |
case 'block_%s':
|
181 |
$type = 'block';
|
182 |
-
$id
|
183 |
break;
|
184 |
case 'option_%s':
|
185 |
$type = 'option';
|
186 |
-
$id
|
187 |
break;
|
188 |
case 'blog_%d':
|
189 |
case 'site_%d':
|
190 |
// Allow backwards compatibility for custom taxonomies.
|
191 |
-
$type = taxonomy_exists($type) ? 'term' : 'blog';
|
192 |
-
$id
|
193 |
break;
|
194 |
default:
|
195 |
// Check for taxonomy name.
|
196 |
-
if( taxonomy_exists($type) && is_numeric($id) ) {
|
197 |
$type = 'term';
|
198 |
-
$id
|
199 |
break;
|
200 |
}
|
201 |
-
|
202 |
// Treat unknown post_id format as an option.
|
203 |
$type = 'option';
|
204 |
-
$id
|
205 |
break;
|
206 |
}
|
207 |
-
|
208 |
/**
|
209 |
* Filters the decoded post_id information.
|
210 |
*
|
211 |
-
* @date
|
212 |
-
* @since
|
213 |
*
|
214 |
-
* @param
|
215 |
-
* @param
|
216 |
*/
|
217 |
-
return apply_filters(
|
218 |
}
|
3 |
/**
|
4 |
* Returns a WordPress object type.
|
5 |
*
|
6 |
+
* @date 1/4/20
|
7 |
+
* @since 5.9.0
|
8 |
*
|
9 |
+
* @param string $object_type The object type (post, term, user, etc).
|
10 |
+
* @param string $object_subtype Optional object subtype (post type, taxonomy).
|
11 |
+
* @return object
|
12 |
*/
|
13 |
function acf_get_object_type( $object_type, $object_subtype = '' ) {
|
14 |
$props = array(
|
15 |
+
'type' => $object_type,
|
16 |
+
'subtype' => $object_subtype,
|
17 |
+
'name' => '',
|
18 |
+
'label' => '',
|
19 |
+
'icon' => '',
|
20 |
);
|
21 |
+
|
22 |
// Set unique identifier as name.
|
23 |
+
if ( $object_subtype ) {
|
24 |
$props['name'] = "$object_type/$object_subtype";
|
25 |
} else {
|
26 |
$props['name'] = $object_type;
|
27 |
}
|
28 |
+
|
29 |
// Set label and icon.
|
30 |
switch ( $object_type ) {
|
31 |
case 'post':
|
32 |
+
if ( $object_subtype ) {
|
33 |
$post_type = get_post_type_object( $object_subtype );
|
34 |
+
if ( $post_type ) {
|
35 |
$props['label'] = $post_type->labels->name;
|
36 |
+
$props['icon'] = acf_with_default( $post_type->menu_icon, 'dashicons-admin-post' );
|
37 |
} else {
|
38 |
return false;
|
39 |
}
|
40 |
} else {
|
41 |
+
$props['label'] = __( 'Posts', 'acf' );
|
42 |
+
$props['icon'] = 'dashicons-admin-post';
|
43 |
}
|
44 |
break;
|
45 |
case 'term':
|
46 |
+
if ( $object_subtype ) {
|
47 |
$taxonomy = get_taxonomy( $object_subtype );
|
48 |
+
if ( $taxonomy ) {
|
49 |
$props['label'] = $taxonomy->labels->name;
|
50 |
} else {
|
51 |
return false;
|
52 |
}
|
53 |
} else {
|
54 |
+
$props['label'] = __( 'Taxonomies', 'acf' );
|
55 |
}
|
56 |
$props['icon'] = 'dashicons-tag';
|
57 |
break;
|
58 |
case 'attachment':
|
59 |
+
$props['label'] = __( 'Attachments', 'acf' );
|
60 |
+
$props['icon'] = 'dashicons-admin-media';
|
61 |
break;
|
62 |
case 'comment':
|
63 |
+
$props['label'] = __( 'Comments', 'acf' );
|
64 |
+
$props['icon'] = 'dashicons-admin-comments';
|
65 |
break;
|
66 |
case 'widget':
|
67 |
+
$props['label'] = __( 'Widgets', 'acf' );
|
68 |
+
$props['icon'] = 'dashicons-screenoptions';
|
69 |
break;
|
70 |
case 'menu':
|
71 |
+
$props['label'] = __( 'Menus', 'acf' );
|
72 |
+
$props['icon'] = 'dashicons-admin-appearance';
|
73 |
break;
|
74 |
case 'menu_item':
|
75 |
+
$props['label'] = __( 'Menu items', 'acf' );
|
76 |
+
$props['icon'] = 'dashicons-admin-appearance';
|
77 |
break;
|
78 |
case 'user':
|
79 |
+
$props['label'] = __( 'Users', 'acf' );
|
80 |
+
$props['icon'] = 'dashicons-admin-users';
|
81 |
break;
|
82 |
case 'option':
|
83 |
+
$props['label'] = __( 'Options', 'acf' );
|
84 |
+
$props['icon'] = 'dashicons-admin-generic';
|
85 |
break;
|
86 |
case 'block':
|
87 |
+
$props['label'] = __( 'Blocks', 'acf' );
|
88 |
+
$props['icon'] = acf_version_compare( 'wp', '>=', '5.5' ) ? 'dashicons-block-default' : 'dashicons-layout';
|
89 |
break;
|
90 |
default:
|
91 |
return false;
|
92 |
}
|
93 |
+
|
94 |
// Convert to object.
|
95 |
$object = (object) $props;
|
96 |
+
|
97 |
/**
|
98 |
* Filters the object type.
|
99 |
*
|
100 |
+
* @date 6/4/20
|
101 |
+
* @since 5.9.0
|
102 |
*
|
103 |
+
* @param object $object The object props.
|
104 |
+
* @param string $object_type The object type (post, term, user, etc).
|
105 |
+
* @param string $object_subtype Optional object subtype (post type, taxonomy).
|
106 |
*/
|
107 |
return apply_filters( 'acf/get_object_type', $object, $object_type, $object_subtype );
|
108 |
}
|
110 |
/**
|
111 |
* Decodes a post_id value such as 1 or "user_1" into an array containing the type and ID.
|
112 |
*
|
113 |
+
* @date 25/1/19
|
114 |
+
* @since 5.7.11
|
115 |
*
|
116 |
+
* @param (int|string) $post_id The post id.
|
117 |
+
* @return array
|
118 |
*/
|
119 |
function acf_decode_post_id( $post_id = 0 ) {
|
120 |
$type = '';
|
121 |
+
$id = 0;
|
122 |
+
|
123 |
// Interpret numeric value (123).
|
124 |
+
if ( is_numeric( $post_id ) ) {
|
125 |
$type = 'post';
|
126 |
+
$id = $post_id;
|
127 |
+
|
128 |
+
// Interpret string value ("user_123" or "option").
|
129 |
+
} elseif ( is_string( $post_id ) ) {
|
130 |
+
$i = strrpos( $post_id, '_' );
|
131 |
+
if ( $i > 0 ) {
|
132 |
+
$type = substr( $post_id, 0, $i );
|
133 |
+
$id = substr( $post_id, $i + 1 );
|
134 |
} else {
|
135 |
$type = $post_id;
|
136 |
+
$id = '';
|
137 |
}
|
138 |
+
|
139 |
+
// Handle incorrect param type.
|
140 |
} else {
|
141 |
return compact( 'type', 'id' );
|
142 |
}
|
143 |
+
|
144 |
// Validate props based on param format.
|
145 |
+
$format = $type . '_' . ( is_numeric( $id ) ? '%d' : '%s' );
|
146 |
switch ( $format ) {
|
147 |
case 'post_%d':
|
148 |
$type = 'post';
|
149 |
+
$id = absint( $id );
|
150 |
break;
|
151 |
case 'term_%d':
|
152 |
$type = 'term';
|
153 |
+
$id = absint( $id );
|
154 |
break;
|
155 |
case 'attachment_%d':
|
156 |
$type = 'post';
|
157 |
+
$id = absint( $id );
|
158 |
break;
|
159 |
case 'comment_%d':
|
160 |
$type = 'comment';
|
161 |
+
$id = absint( $id );
|
162 |
break;
|
163 |
case 'widget_%s':
|
164 |
case 'widget_%d':
|
165 |
$type = 'option';
|
166 |
+
$id = $post_id;
|
167 |
break;
|
168 |
case 'menu_%d':
|
169 |
$type = 'term';
|
170 |
+
$id = absint( $id );
|
171 |
break;
|
172 |
case 'menu_item_%d':
|
173 |
$type = 'post';
|
174 |
+
$id = absint( $id );
|
175 |
break;
|
176 |
case 'user_%d':
|
177 |
$type = 'user';
|
178 |
+
$id = absint( $id );
|
179 |
break;
|
180 |
case 'block_%s':
|
181 |
$type = 'block';
|
182 |
+
$id = $post_id;
|
183 |
break;
|
184 |
case 'option_%s':
|
185 |
$type = 'option';
|
186 |
+
$id = $post_id;
|
187 |
break;
|
188 |
case 'blog_%d':
|
189 |
case 'site_%d':
|
190 |
// Allow backwards compatibility for custom taxonomies.
|
191 |
+
$type = taxonomy_exists( $type ) ? 'term' : 'blog';
|
192 |
+
$id = absint( $id );
|
193 |
break;
|
194 |
default:
|
195 |
// Check for taxonomy name.
|
196 |
+
if ( taxonomy_exists( $type ) && is_numeric( $id ) ) {
|
197 |
$type = 'term';
|
198 |
+
$id = absint( $id );
|
199 |
break;
|
200 |
}
|
201 |
+
|
202 |
// Treat unknown post_id format as an option.
|
203 |
$type = 'option';
|
204 |
+
$id = $post_id;
|
205 |
break;
|
206 |
}
|
207 |
+
|
208 |
/**
|
209 |
* Filters the decoded post_id information.
|
210 |
*
|
211 |
+
* @date 25/1/19
|
212 |
+
* @since 5.7.11
|
213 |
*
|
214 |
+
* @param array $props An array containing "type" and "id" information.
|
215 |
+
* @param (int|string) $post_id The post id.
|
216 |
*/
|
217 |
+
return apply_filters( 'acf/decode_post_id', compact( 'type', 'id' ), $post_id );
|
218 |
}
|
includes/admin/admin-field-group.php
CHANGED
@@ -5,818 +5,816 @@
|
|
5 |
*
|
6 |
* All the logic for editing a field group
|
7 |
*
|
8 |
-
* @class
|
9 |
-
* @package
|
10 |
-
* @subpackage
|
11 |
*/
|
12 |
|
13 |
-
if( ! class_exists('acf_admin_field_group') ) :
|
14 |
-
|
15 |
-
class acf_admin_field_group {
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
add_filter('post_updated_messages', array($this, 'post_updated_messages'));
|
46 |
-
add_filter('use_block_editor_for_post_type', array($this, 'use_block_editor_for_post_type'), 10, 2);
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* use_block_editor_for_post_type
|
51 |
-
*
|
52 |
-
* Prevents the block editor from loading when editing an ACF field group.
|
53 |
-
*
|
54 |
-
* @date 7/12/18
|
55 |
-
* @since 5.8.0
|
56 |
-
*
|
57 |
-
* @param bool $use_block_editor Whether the post type can be edited or not. Default true.
|
58 |
-
* @param string $post_type The post type being checked.
|
59 |
-
* @return bool
|
60 |
-
*/
|
61 |
-
function use_block_editor_for_post_type( $use_block_editor, $post_type ) {
|
62 |
-
if( $post_type === 'acf-field-group' ) {
|
63 |
-
return false;
|
64 |
}
|
65 |
-
return $use_block_editor;
|
66 |
-
}
|
67 |
-
|
68 |
-
/*
|
69 |
-
* post_updated_messages
|
70 |
-
*
|
71 |
-
* This function will customize the message shown when editing a field group
|
72 |
-
*
|
73 |
-
* @type action (post_updated_messages)
|
74 |
-
* @date 30/04/2014
|
75 |
-
* @since 5.0.0
|
76 |
-
*
|
77 |
-
* @param $messages (array)
|
78 |
-
* @return $messages
|
79 |
-
*/
|
80 |
-
|
81 |
-
function post_updated_messages( $messages ) {
|
82 |
-
|
83 |
-
// append to messages
|
84 |
-
$messages['acf-field-group'] = array(
|
85 |
-
0 => '', // Unused. Messages start at index 1.
|
86 |
-
1 => __('Field group updated.', 'acf'),
|
87 |
-
2 => __('Field group updated.', 'acf'),
|
88 |
-
3 => __('Field group deleted.', 'acf'),
|
89 |
-
4 => __('Field group updated.', 'acf'),
|
90 |
-
5 => false, // field group does not support revisions
|
91 |
-
6 => __('Field group published.', 'acf'),
|
92 |
-
7 => __('Field group saved.', 'acf'),
|
93 |
-
8 => __('Field group submitted.', 'acf'),
|
94 |
-
9 => __('Field group scheduled for.', 'acf'),
|
95 |
-
10 => __('Field group draft updated.', 'acf')
|
96 |
-
);
|
97 |
-
|
98 |
-
|
99 |
-
// return
|
100 |
-
return $messages;
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/*
|
105 |
-
* current_screen
|
106 |
-
*
|
107 |
-
* This function is fired when loading the admin page before HTML has been rendered.
|
108 |
-
*
|
109 |
-
* @type action (current_screen)
|
110 |
-
* @date 21/07/2014
|
111 |
-
* @since 5.0.0
|
112 |
-
*
|
113 |
-
* @param n/a
|
114 |
-
* @return n/a
|
115 |
-
*/
|
116 |
-
|
117 |
-
function current_screen() {
|
118 |
-
|
119 |
-
// validate screen
|
120 |
-
if( !acf_is_screen('acf-field-group') ) return;
|
121 |
-
|
122 |
-
|
123 |
-
// disable filters to ensure ACF loads raw data from DB
|
124 |
-
acf_disable_filters();
|
125 |
-
|
126 |
-
|
127 |
-
// enqueue scripts
|
128 |
-
acf_enqueue_scripts();
|
129 |
-
|
130 |
-
|
131 |
-
// actions
|
132 |
-
add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
133 |
-
add_action('acf/input/admin_head', array($this, 'admin_head'));
|
134 |
-
add_action('acf/input/form_data', array($this, 'form_data'));
|
135 |
-
add_action('acf/input/admin_footer', array($this, 'admin_footer'));
|
136 |
-
|
137 |
-
|
138 |
-
// filters
|
139 |
-
add_filter('acf/input/admin_l10n', array($this, 'admin_l10n'));
|
140 |
-
}
|
141 |
-
|
142 |
-
|
143 |
-
/*
|
144 |
-
* admin_enqueue_scripts
|
145 |
-
*
|
146 |
-
* This action is run after post query but before any admin script / head actions.
|
147 |
-
* It is a good place to register all actions.
|
148 |
-
*
|
149 |
-
* @type action (admin_enqueue_scripts)
|
150 |
-
* @date 30/06/2014
|
151 |
-
* @since 5.0.0
|
152 |
-
*
|
153 |
-
* @param n/a
|
154 |
-
* @return n/a
|
155 |
-
*/
|
156 |
-
|
157 |
-
function admin_enqueue_scripts() {
|
158 |
-
|
159 |
-
// no autosave
|
160 |
-
wp_dequeue_script('autosave');
|
161 |
-
|
162 |
-
|
163 |
-
// custom scripts
|
164 |
-
wp_enqueue_style('acf-field-group');
|
165 |
-
wp_enqueue_script('acf-field-group');
|
166 |
-
|
167 |
-
|
168 |
-
// localize text
|
169 |
-
acf_localize_text(array(
|
170 |
-
'The string "field_" may not be used at the start of a field name' => __('The string "field_" may not be used at the start of a field name', 'acf'),
|
171 |
-
'This field cannot be moved until its changes have been saved' => __('This field cannot be moved until its changes have been saved', 'acf'),
|
172 |
-
'Field group title is required' => __('Field group title is required', 'acf'),
|
173 |
-
'Move to trash. Are you sure?' => __('Move to trash. Are you sure?', 'acf'),
|
174 |
-
'No toggle fields available' => __('No toggle fields available', 'acf'),
|
175 |
-
'Move Custom Field' => __('Move Custom Field', 'acf'),
|
176 |
-
'Checked' => __('Checked', 'acf'),
|
177 |
-
'(no label)' => __('(no label)', 'acf'),
|
178 |
-
'(this field)' => __('(this field)', 'acf'),
|
179 |
-
'copy' => __('copy', 'acf'),
|
180 |
-
'or' => __('or', 'acf'),
|
181 |
-
'Null' => __('Null', 'acf'),
|
182 |
-
|
183 |
-
// Conditions
|
184 |
-
'Has any value' => __('Has any value', 'acf'),
|
185 |
-
'Has no value' => __('Has no value', 'acf'),
|
186 |
-
'Value is equal to' => __('Value is equal to', 'acf'),
|
187 |
-
'Value is not equal to' => __('Value is not equal to', 'acf'),
|
188 |
-
'Value matches pattern' => __('Value matches pattern', 'acf'),
|
189 |
-
'Value contains' => __('Value contains', 'acf'),
|
190 |
-
'Value is greater than' => __('Value is greater than', 'acf'),
|
191 |
-
'Value is less than' => __('Value is less than', 'acf'),
|
192 |
-
'Selection is greater than' => __('Selection is greater than', 'acf'),
|
193 |
-
'Selection is less than' => __('Selection is less than', 'acf'),
|
194 |
-
|
195 |
-
// Pro-only fields
|
196 |
-
'Repeater (Pro only)' => __('Repeater (Pro only)', 'acf'),
|
197 |
-
'Flexibly Content (Pro only)' => __('Flexible Content (Pro only)', 'acf'),
|
198 |
-
'Clone (Pro only)' => __('Clone (Pro only)', 'acf'),
|
199 |
-
'Gallery (Pro only)' => __('Gallery (Pro only)', 'acf'),
|
200 |
-
));
|
201 |
-
|
202 |
-
// localize data
|
203 |
-
acf_localize_data(array(
|
204 |
-
'fieldTypes' => acf_get_field_types_info()
|
205 |
-
));
|
206 |
-
|
207 |
-
// 3rd party hook
|
208 |
-
do_action('acf/field_group/admin_enqueue_scripts');
|
209 |
-
|
210 |
-
}
|
211 |
-
|
212 |
-
|
213 |
-
/*
|
214 |
-
* admin_head
|
215 |
-
*
|
216 |
-
* This function will setup all functionality for the field group edit page to work
|
217 |
-
*
|
218 |
-
* @type action (admin_head)
|
219 |
-
* @date 23/06/12
|
220 |
-
* @since 3.1.8
|
221 |
-
*
|
222 |
-
* @param $post_id (int)
|
223 |
-
* @return $post_id (int)
|
224 |
-
*/
|
225 |
-
|
226 |
-
function admin_head() {
|
227 |
-
|
228 |
-
// global
|
229 |
-
global $post, $field_group;
|
230 |
-
|
231 |
-
|
232 |
-
// set global var
|
233 |
-
$field_group = acf_get_field_group( $post->ID );
|
234 |
-
|
235 |
-
|
236 |
-
// metaboxes
|
237 |
-
add_meta_box('acf-field-group-fields', __("Fields",'acf'), array($this, 'mb_fields'), 'acf-field-group', 'normal', 'high');
|
238 |
-
add_meta_box('acf-field-group-locations', __("Location",'acf'), array($this, 'mb_locations'), 'acf-field-group', 'normal', 'high');
|
239 |
-
add_meta_box('acf-field-group-options', __("Settings",'acf'), array($this, 'mb_options'), 'acf-field-group', 'normal', 'high');
|
240 |
-
|
241 |
-
|
242 |
-
// actions
|
243 |
-
add_action('post_submitbox_misc_actions', array($this, 'post_submitbox_misc_actions'), 10, 0);
|
244 |
-
add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10, 0);
|
245 |
-
|
246 |
-
|
247 |
-
// filters
|
248 |
-
add_filter('screen_settings', array($this, 'screen_settings'), 10, 1);
|
249 |
-
|
250 |
-
|
251 |
-
// 3rd party hook
|
252 |
-
do_action('acf/field_group/admin_head');
|
253 |
-
|
254 |
-
}
|
255 |
-
|
256 |
-
|
257 |
-
/*
|
258 |
-
* edit_form_after_title
|
259 |
-
*
|
260 |
-
* This action will allow ACF to render metaboxes after the title
|
261 |
-
*
|
262 |
-
* @type action
|
263 |
-
* @date 17/08/13
|
264 |
-
*
|
265 |
-
* @param n/a
|
266 |
-
* @return n/a
|
267 |
-
*/
|
268 |
-
|
269 |
-
function edit_form_after_title() {
|
270 |
-
|
271 |
-
// globals
|
272 |
-
global $post;
|
273 |
-
|
274 |
-
|
275 |
-
// render post data
|
276 |
-
acf_form_data(array(
|
277 |
-
'screen' => 'field_group',
|
278 |
-
'post_id' => $post->ID,
|
279 |
-
'delete_fields' => 0,
|
280 |
-
'validation' => 0
|
281 |
-
));
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
<script type="text/javascript">
|
397 |
(function($) {
|
398 |
$('#post-status-display').html( '<?php echo esc_html( $status_label ); ?>' );
|
399 |
})(jQuery);
|
400 |
</script>
|
401 |
-
|
402 |
-
}
|
403 |
-
|
404 |
-
|
405 |
-
/*
|
406 |
-
* save_post
|
407 |
-
*
|
408 |
-
* This function will save all the field group data
|
409 |
-
*
|
410 |
-
* @type function
|
411 |
-
* @date 23/06/12
|
412 |
-
* @since 1.0.0
|
413 |
-
*
|
414 |
-
* @param $post_id (int)
|
415 |
-
* @return $post_id (int)
|
416 |
-
*/
|
417 |
-
|
418 |
-
function save_post( $post_id, $post ) {
|
419 |
-
|
420 |
-
// do not save if this is an auto save routine
|
421 |
-
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
|
422 |
-
return $post_id;
|
423 |
-
}
|
424 |
-
|
425 |
-
// bail early if not acf-field-group
|
426 |
-
if( $post->post_type !== 'acf-field-group' ) {
|
427 |
-
return $post_id;
|
428 |
}
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
return $post_id;
|
438 |
}
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
}
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
// set parent
|
470 |
-
if( !$field['parent'] ) {
|
471 |
-
$field['parent'] = $post_id;
|
472 |
-
}
|
473 |
-
|
474 |
-
// save field
|
475 |
-
acf_update_field( $field, $specific );
|
476 |
-
|
477 |
}
|
|
|
|
|
|
|
|
|
478 |
}
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
}
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
// add args
|
505 |
-
$_POST['acf_field_group']['ID'] = $post_id;
|
506 |
-
$_POST['acf_field_group']['title'] = $_POST['post_title'];
|
507 |
-
|
508 |
-
|
509 |
-
// save field group
|
510 |
-
acf_update_field_group( $_POST['acf_field_group'] );
|
511 |
-
|
512 |
-
|
513 |
-
// return
|
514 |
-
return $post_id;
|
515 |
-
}
|
516 |
-
|
517 |
-
|
518 |
-
/*
|
519 |
-
* mb_fields
|
520 |
-
*
|
521 |
-
* This function will render the HTML for the medtabox 'acf-field-group-fields'
|
522 |
-
*
|
523 |
-
* @type function
|
524 |
-
* @date 28/09/13
|
525 |
-
* @since 5.0.0
|
526 |
-
*
|
527 |
-
* @param N/A
|
528 |
-
* @return N/A
|
529 |
-
*/
|
530 |
-
|
531 |
-
function mb_fields() {
|
532 |
-
|
533 |
-
// global
|
534 |
-
global $field_group;
|
535 |
-
|
536 |
-
|
537 |
-
// get fields
|
538 |
-
$view = array(
|
539 |
-
'fields' => acf_get_fields( $field_group ),
|
540 |
-
'parent' => 0
|
541 |
-
);
|
542 |
-
|
543 |
-
|
544 |
-
// load view
|
545 |
-
acf_get_view('field-group-fields', $view);
|
546 |
-
|
547 |
-
}
|
548 |
-
|
549 |
-
|
550 |
-
/*
|
551 |
-
* mb_options
|
552 |
-
*
|
553 |
-
* This function will render the HTML for the medtabox 'acf-field-group-options'
|
554 |
-
*
|
555 |
-
* @type function
|
556 |
-
* @date 28/09/13
|
557 |
-
* @since 5.0.0
|
558 |
-
*
|
559 |
-
* @param N/A
|
560 |
-
* @return N/A
|
561 |
-
*/
|
562 |
-
|
563 |
-
function mb_options() {
|
564 |
-
|
565 |
-
// global
|
566 |
-
global $field_group;
|
567 |
-
|
568 |
-
|
569 |
-
// field key (leave in for compatibility)
|
570 |
-
if( !acf_is_field_group_key( $field_group['key']) ) {
|
571 |
-
|
572 |
-
$field_group['key'] = uniqid('group_');
|
573 |
-
|
574 |
}
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
array(
|
609 |
-
|
610 |
-
// rule 0
|
611 |
-
array(
|
612 |
-
'param' => 'post_type',
|
613 |
-
'operator' => '==',
|
614 |
-
'value' => 'post',
|
615 |
-
)
|
616 |
)
|
617 |
-
|
618 |
);
|
|
|
|
|
|
|
619 |
}
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
* @date 30/09/13
|
666 |
-
* @since 5.0.0
|
667 |
-
*
|
668 |
-
* @param n/a
|
669 |
-
* @return n/a
|
670 |
-
*/
|
671 |
-
|
672 |
-
function ajax_render_field_settings() {
|
673 |
-
|
674 |
-
// validate
|
675 |
-
if( !acf_verify_ajax() ) die();
|
676 |
-
|
677 |
-
// vars
|
678 |
-
$field = acf_maybe_get_POST('field');
|
679 |
-
|
680 |
-
// check
|
681 |
-
if( !$field ) die();
|
682 |
-
|
683 |
-
// set prefix
|
684 |
-
$field['prefix'] = acf_maybe_get_POST('prefix');
|
685 |
-
|
686 |
-
// validate
|
687 |
-
$field = acf_get_valid_field( $field );
|
688 |
-
|
689 |
-
// render
|
690 |
-
do_action("acf/render_field_settings/type={$field['type']}", $field);
|
691 |
-
|
692 |
-
// return
|
693 |
-
die();
|
694 |
-
|
695 |
-
}
|
696 |
-
|
697 |
-
/*
|
698 |
-
* ajax_move_field
|
699 |
-
*
|
700 |
-
* description
|
701 |
-
*
|
702 |
-
* @type function
|
703 |
-
* @date 20/01/2014
|
704 |
-
* @since 5.0.0
|
705 |
-
*
|
706 |
-
* @param $post_id (int)
|
707 |
-
* @return $post_id (int)
|
708 |
-
*/
|
709 |
-
|
710 |
-
function ajax_move_field() {
|
711 |
-
|
712 |
-
// disable filters to ensure ACF loads raw data from DB
|
713 |
-
acf_disable_filters();
|
714 |
-
|
715 |
-
|
716 |
-
$args = acf_parse_args($_POST, array(
|
717 |
-
'nonce' => '',
|
718 |
-
'post_id' => 0,
|
719 |
-
'field_id' => 0,
|
720 |
-
'field_group_id' => 0
|
721 |
-
));
|
722 |
-
|
723 |
-
|
724 |
-
// verify nonce
|
725 |
-
if( !wp_verify_nonce($args['nonce'], 'acf_nonce') ) die();
|
726 |
-
|
727 |
-
|
728 |
-
// confirm?
|
729 |
-
if( $args['field_id'] && $args['field_group_id'] ) {
|
730 |
-
|
731 |
-
// vars
|
732 |
-
$field = acf_get_field($args['field_id']);
|
733 |
-
$field_group = acf_get_field_group($args['field_group_id']);
|
734 |
-
|
735 |
-
|
736 |
-
// update parent
|
737 |
-
$field['parent'] = $field_group['ID'];
|
738 |
-
|
739 |
-
|
740 |
-
// remove conditional logic
|
741 |
-
$field['conditional_logic'] = 0;
|
742 |
-
|
743 |
-
|
744 |
-
// update field
|
745 |
-
acf_update_field($field);
|
746 |
-
|
747 |
-
|
748 |
-
// Output HTML.
|
749 |
-
$link = '<a href="' . admin_url( 'post.php?post=' . $field_group['ID'] . '&action=edit' ) . '" target="_blank">' . esc_html( $field_group['title'] ) . '</a>';
|
750 |
-
|
751 |
-
echo '' .
|
752 |
-
'<p><strong>' . __( 'Move Complete.', 'acf' ) . '</strong></p>' .
|
753 |
-
'<p>' . sprintf(
|
754 |
-
acf_punctify( __( 'The %s field can now be found in the %s field group', 'acf' ) ),
|
755 |
-
esc_html( $field['label'] ),
|
756 |
-
$link
|
757 |
-
). '</p>' .
|
758 |
-
'<a href="#" class="button button-primary acf-close-popup">' . __( 'Close Window', 'acf' ) . '</a>';
|
759 |
die();
|
|
|
760 |
}
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
785 |
}
|
786 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
787 |
}
|
788 |
-
|
789 |
-
|
790 |
-
// render options
|
791 |
-
$field = acf_get_valid_field(array(
|
792 |
-
'type' => 'select',
|
793 |
-
'name' => 'acf_field_group',
|
794 |
-
'choices' => $choices
|
795 |
-
));
|
796 |
-
|
797 |
-
|
798 |
-
echo '<p>' . __('Please select the destination for this field', 'acf') . '</p>';
|
799 |
-
|
800 |
-
echo '<form id="acf-move-field-form">';
|
801 |
-
|
802 |
-
// render
|
803 |
-
acf_render_field_wrap( $field );
|
804 |
-
|
805 |
-
echo '<button type="submit" class="button button-primary">' . __("Move Field",'acf') . '</button>';
|
806 |
-
|
807 |
-
echo '</form>';
|
808 |
-
|
809 |
-
|
810 |
-
// die
|
811 |
-
die();
|
812 |
-
|
813 |
}
|
814 |
-
|
815 |
-
}
|
816 |
|
817 |
-
// initialize
|
818 |
-
new acf_admin_field_group();
|
819 |
|
820 |
endif;
|
821 |
|
822 |
-
?>
|
5 |
*
|
6 |
* All the logic for editing a field group
|
7 |
*
|
8 |
+
* @class acf_admin_field_group
|
9 |
+
* @package ACF
|
10 |
+
* @subpackage Admin
|
11 |
*/
|
12 |
|
13 |
+
if ( ! class_exists( 'acf_admin_field_group' ) ) :
|
14 |
+
|
15 |
+
class acf_admin_field_group {
|
16 |
+
|
17 |
+
|
18 |
+
/*
|
19 |
+
* __construct
|
20 |
+
*
|
21 |
+
* This function will setup the class functionality
|
22 |
+
*
|
23 |
+
* @type function
|
24 |
+
* @date 5/03/2014
|
25 |
+
* @since 5.0.0
|
26 |
+
*
|
27 |
+
* @param n/a
|
28 |
+
* @return n/a
|
29 |
+
*/
|
30 |
+
|
31 |
+
function __construct() {
|
32 |
+
|
33 |
+
// actions
|
34 |
+
add_action( 'current_screen', array( $this, 'current_screen' ) );
|
35 |
+
add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
|
36 |
+
|
37 |
+
// ajax
|
38 |
+
add_action( 'wp_ajax_acf/field_group/render_field_settings', array( $this, 'ajax_render_field_settings' ) );
|
39 |
+
add_action( 'wp_ajax_acf/field_group/render_location_rule', array( $this, 'ajax_render_location_rule' ) );
|
40 |
+
add_action( 'wp_ajax_acf/field_group/move_field', array( $this, 'ajax_move_field' ) );
|
41 |
+
|
42 |
+
// filters
|
43 |
+
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
|
44 |
+
add_filter( 'use_block_editor_for_post_type', array( $this, 'use_block_editor_for_post_type' ), 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
+
/**
|
48 |
+
* use_block_editor_for_post_type
|
49 |
+
*
|
50 |
+
* Prevents the block editor from loading when editing an ACF field group.
|
51 |
+
*
|
52 |
+
* @date 7/12/18
|
53 |
+
* @since 5.8.0
|
54 |
+
*
|
55 |
+
* @param bool $use_block_editor Whether the post type can be edited or not. Default true.
|
56 |
+
* @param string $post_type The post type being checked.
|
57 |
+
* @return bool
|
58 |
+
*/
|
59 |
+
function use_block_editor_for_post_type( $use_block_editor, $post_type ) {
|
60 |
+
if ( $post_type === 'acf-field-group' ) {
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
return $use_block_editor;
|
64 |
+
}
|
65 |
+
|
66 |
+
/*
|
67 |
+
* post_updated_messages
|
68 |
+
*
|
69 |
+
* This function will customize the message shown when editing a field group
|
70 |
+
*
|
71 |
+
* @type action (post_updated_messages)
|
72 |
+
* @date 30/04/2014
|
73 |
+
* @since 5.0.0
|
74 |
+
*
|
75 |
+
* @param $messages (array)
|
76 |
+
* @return $messages
|
77 |
+
*/
|
78 |
+
|
79 |
+
function post_updated_messages( $messages ) {
|
80 |
+
|
81 |
+
// append to messages
|
82 |
+
$messages['acf-field-group'] = array(
|
83 |
+
0 => '', // Unused. Messages start at index 1.
|
84 |
+
1 => __( 'Field group updated.', 'acf' ),
|
85 |
+
2 => __( 'Field group updated.', 'acf' ),
|
86 |
+
3 => __( 'Field group deleted.', 'acf' ),
|
87 |
+
4 => __( 'Field group updated.', 'acf' ),
|
88 |
+
5 => false, // field group does not support revisions
|
89 |
+
6 => __( 'Field group published.', 'acf' ),
|
90 |
+
7 => __( 'Field group saved.', 'acf' ),
|
91 |
+
8 => __( 'Field group submitted.', 'acf' ),
|
92 |
+
9 => __( 'Field group scheduled for.', 'acf' ),
|
93 |
+
10 => __( 'Field group draft updated.', 'acf' ),
|
94 |
+
);
|
95 |
+
|
96 |
+
// return
|
97 |
+
return $messages;
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/*
|
102 |
+
* current_screen
|
103 |
+
*
|
104 |
+
* This function is fired when loading the admin page before HTML has been rendered.
|
105 |
+
*
|
106 |
+
* @type action (current_screen)
|
107 |
+
* @date 21/07/2014
|
108 |
+
* @since 5.0.0
|
109 |
+
*
|
110 |
+
* @param n/a
|
111 |
+
* @return n/a
|
112 |
+
*/
|
113 |
+
|
114 |
+
function current_screen() {
|
115 |
+
|
116 |
+
// validate screen
|
117 |
+
if ( ! acf_is_screen( 'acf-field-group' ) ) {
|
118 |
+
return;
|
119 |
+
}
|
120 |
+
|
121 |
+
// disable filters to ensure ACF loads raw data from DB
|
122 |
+
acf_disable_filters();
|
123 |
+
|
124 |
+
// enqueue scripts
|
125 |
+
acf_enqueue_scripts();
|
126 |
+
|
127 |
+
// actions
|
128 |
+
add_action( 'acf/input/admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
129 |
+
add_action( 'acf/input/admin_head', array( $this, 'admin_head' ) );
|
130 |
+
add_action( 'acf/input/form_data', array( $this, 'form_data' ) );
|
131 |
+
add_action( 'acf/input/admin_footer', array( $this, 'admin_footer' ) );
|
132 |
+
|
133 |
+
// filters
|
134 |
+
add_filter( 'acf/input/admin_l10n', array( $this, 'admin_l10n' ) );
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
/*
|
139 |
+
* admin_enqueue_scripts
|
140 |
+
*
|
141 |
+
* This action is run after post query but before any admin script / head actions.
|
142 |
+
* It is a good place to register all actions.
|
143 |
+
*
|
144 |
+
* @type action (admin_enqueue_scripts)
|
145 |
+
* @date 30/06/2014
|
146 |
+
* @since 5.0.0
|
147 |
+
*
|
148 |
+
* @param n/a
|
149 |
+
* @return n/a
|
150 |
+
*/
|
151 |
+
|
152 |
+
function admin_enqueue_scripts() {
|
153 |
+
|
154 |
+
// no autosave
|
155 |
+
wp_dequeue_script( 'autosave' );
|
156 |
+
|
157 |
+
// custom scripts
|
158 |
+
wp_enqueue_style( 'acf-field-group' );
|
159 |
+
wp_enqueue_script( 'acf-field-group' );
|
160 |
+
|
161 |
+
// localize text
|
162 |
+
acf_localize_text(
|
163 |
+
array(
|
164 |
+
'The string "field_" may not be used at the start of a field name' => __( 'The string "field_" may not be used at the start of a field name', 'acf' ),
|
165 |
+
'This field cannot be moved until its changes have been saved' => __( 'This field cannot be moved until its changes have been saved', 'acf' ),
|
166 |
+
'Field group title is required' => __( 'Field group title is required', 'acf' ),
|
167 |
+
'Move to trash. Are you sure?' => __( 'Move to trash. Are you sure?', 'acf' ),
|
168 |
+
'No toggle fields available' => __( 'No toggle fields available', 'acf' ),
|
169 |
+
'Move Custom Field' => __( 'Move Custom Field', 'acf' ),
|
170 |
+
'Checked' => __( 'Checked', 'acf' ),
|
171 |
+
'(no label)' => __( '(no label)', 'acf' ),
|
172 |
+
'(this field)' => __( '(this field)', 'acf' ),
|
173 |
+
'copy' => __( 'copy', 'acf' ),
|
174 |
+
'or' => __( 'or', 'acf' ),
|
175 |
+
'Show this field group if' => __( 'Show this field group if', 'acf' ),
|
176 |
+
'Null' => __( 'Null', 'acf' ),
|
177 |
+
|
178 |
+
// Conditions
|
179 |
+
'Has any value' => __( 'Has any value', 'acf' ),
|
180 |
+
'Has no value' => __( 'Has no value', 'acf' ),
|
181 |
+
'Value is equal to' => __( 'Value is equal to', 'acf' ),
|
182 |
+
'Value is not equal to' => __( 'Value is not equal to', 'acf' ),
|
183 |
+
'Value matches pattern' => __( 'Value matches pattern', 'acf' ),
|
184 |
+
'Value contains' => __( 'Value contains', 'acf' ),
|
185 |
+
'Value is greater than' => __( 'Value is greater than', 'acf' ),
|
186 |
+
'Value is less than' => __( 'Value is less than', 'acf' ),
|
187 |
+
'Selection is greater than' => __( 'Selection is greater than', 'acf' ),
|
188 |
+
'Selection is less than' => __( 'Selection is less than', 'acf' ),
|
189 |
+
|
190 |
+
// Pro-only fields
|
191 |
+
'Repeater (Pro only)' => __( 'Repeater (Pro only)', 'acf' ),
|
192 |
+
'Flexibly Content (Pro only)' => __( 'Flexible Content (Pro only)', 'acf' ),
|
193 |
+
'Clone (Pro only)' => __( 'Clone (Pro only)', 'acf' ),
|
194 |
+
'Gallery (Pro only)' => __( 'Gallery (Pro only)', 'acf' ),
|
195 |
+
)
|
196 |
+
);
|
197 |
+
|
198 |
+
// localize data
|
199 |
+
acf_localize_data(
|
200 |
+
array(
|
201 |
+
'fieldTypes' => acf_get_field_types_info(),
|
202 |
+
)
|
203 |
+
);
|
204 |
+
|
205 |
+
// 3rd party hook
|
206 |
+
do_action( 'acf/field_group/admin_enqueue_scripts' );
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
/*
|
212 |
+
* admin_head
|
213 |
+
*
|
214 |
+
* This function will setup all functionality for the field group edit page to work
|
215 |
+
*
|
216 |
+
* @type action (admin_head)
|
217 |
+
* @date 23/06/12
|
218 |
+
* @since 3.1.8
|
219 |
+
*
|
220 |
+
* @param $post_id (int)
|
221 |
+
* @return $post_id (int)
|
222 |
+
*/
|
223 |
+
|
224 |
+
function admin_head() {
|
225 |
+
|
226 |
+
// global
|
227 |
+
global $post, $field_group;
|
228 |
+
|
229 |
+
// set global var
|
230 |
+
$field_group = acf_get_field_group( $post->ID );
|
231 |
+
|
232 |
+
// metaboxes
|
233 |
+
add_meta_box( 'acf-field-group-fields', __( 'Fields', 'acf' ), array( $this, 'mb_fields' ), 'acf-field-group', 'normal', 'high' );
|
234 |
+
add_meta_box( 'acf-field-group-locations', __( 'Location', 'acf' ), array( $this, 'mb_locations' ), 'acf-field-group', 'normal', 'high' );
|
235 |
+
add_meta_box( 'acf-field-group-options', __( 'Settings', 'acf' ), array( $this, 'mb_options' ), 'acf-field-group', 'normal', 'high' );
|
236 |
+
|
237 |
+
// actions
|
238 |
+
add_action( 'post_submitbox_misc_actions', array( $this, 'post_submitbox_misc_actions' ), 10, 0 );
|
239 |
+
add_action( 'edit_form_after_title', array( $this, 'edit_form_after_title' ), 10, 0 );
|
240 |
+
|
241 |
+
// filters
|
242 |
+
add_filter( 'screen_settings', array( $this, 'screen_settings' ), 10, 1 );
|
243 |
+
|
244 |
+
// 3rd party hook
|
245 |
+
do_action( 'acf/field_group/admin_head' );
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
|
250 |
+
/*
|
251 |
+
* edit_form_after_title
|
252 |
+
*
|
253 |
+
* This action will allow ACF to render metaboxes after the title
|
254 |
+
*
|
255 |
+
* @type action
|
256 |
+
* @date 17/08/13
|
257 |
+
*
|
258 |
+
* @param n/a
|
259 |
+
* @return n/a
|
260 |
+
*/
|
261 |
+
|
262 |
+
function edit_form_after_title() {
|
263 |
+
|
264 |
+
// globals
|
265 |
+
global $post;
|
266 |
+
|
267 |
+
// render post data
|
268 |
+
acf_form_data(
|
269 |
+
array(
|
270 |
+
'screen' => 'field_group',
|
271 |
+
'post_id' => $post->ID,
|
272 |
+
'delete_fields' => 0,
|
273 |
+
'validation' => 0,
|
274 |
+
)
|
275 |
+
);
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
+
|
280 |
+
/*
|
281 |
+
* form_data
|
282 |
+
*
|
283 |
+
* This function will add extra HTML to the acf form data element
|
284 |
+
*
|
285 |
+
* @type function
|
286 |
+
* @date 31/05/2016
|
287 |
+
* @since 5.3.8
|
288 |
+
*
|
289 |
+
* @param n/a
|
290 |
+
* @return n/a
|
291 |
+
*/
|
292 |
+
|
293 |
+
function form_data( $args ) {
|
294 |
+
|
295 |
+
// do action
|
296 |
+
do_action( 'acf/field_group/form_data', $args );
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
/*
|
302 |
+
* admin_l10n
|
303 |
+
*
|
304 |
+
* This function will append extra l10n strings to the acf JS object
|
305 |
+
*
|
306 |
+
* @type function
|
307 |
+
* @date 31/05/2016
|
308 |
+
* @since 5.3.8
|
309 |
+
*
|
310 |
+
* @param $l10n (array)
|
311 |
+
* @return $l10n
|
312 |
+
*/
|
313 |
+
|
314 |
+
function admin_l10n( $l10n ) {
|
315 |
+
return apply_filters( 'acf/field_group/admin_l10n', $l10n );
|
316 |
+
}
|
317 |
+
|
318 |
+
|
319 |
+
|
320 |
+
/*
|
321 |
+
* admin_footer
|
322 |
+
*
|
323 |
+
* description
|
324 |
+
*
|
325 |
+
* @type function
|
326 |
+
* @date 11/01/2016
|
327 |
+
* @since 5.3.2
|
328 |
+
*
|
329 |
+
* @param $post_id (int)
|
330 |
+
* @return $post_id (int)
|
331 |
+
*/
|
332 |
+
|
333 |
+
function admin_footer() {
|
334 |
+
|
335 |
+
// 3rd party hook
|
336 |
+
do_action( 'acf/field_group/admin_footer' );
|
337 |
+
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
/*
|
342 |
+
* screen_settings
|
343 |
+
*
|
344 |
+
* description
|
345 |
+
*
|
346 |
+
* @type function
|
347 |
+
* @date 26/01/13
|
348 |
+
* @since 3.6.0
|
349 |
+
*
|
350 |
+
* @param $current (string)
|
351 |
+
* @return $current
|
352 |
+
*/
|
353 |
+
|
354 |
+
function screen_settings( $html ) {
|
355 |
+
|
356 |
+
// vars
|
357 |
+
$checked = acf_get_user_setting( 'show_field_keys' ) ? 'checked="checked"' : '';
|
358 |
+
|
359 |
+
// append
|
360 |
+
$html .= '<div id="acf-append-show-on-screen" class="acf-hidden">';
|
361 |
+
$html .= '<label for="acf-field-key-hide"><input id="acf-field-key-hide" type="checkbox" value="1" name="show_field_keys" ' . $checked . ' /> ' . __( 'Field Keys', 'acf' ) . '</label>';
|
362 |
+
$html .= '</div>';
|
363 |
+
|
364 |
+
// return
|
365 |
+
return $html;
|
366 |
+
|
367 |
+
}
|
368 |
+
|
369 |
+
|
370 |
+
/*
|
371 |
+
* post_submitbox_misc_actions
|
372 |
+
*
|
373 |
+
* This function will customize the publish metabox
|
374 |
+
*
|
375 |
+
* @type function
|
376 |
+
* @date 17/07/2015
|
377 |
+
* @since 5.2.9
|
378 |
+
*
|
379 |
+
* @param n/a
|
380 |
+
* @return n/a
|
381 |
+
*/
|
382 |
+
|
383 |
+
function post_submitbox_misc_actions() {
|
384 |
+
global $field_group;
|
385 |
+
$status_label = $field_group['active'] ? _x( 'Active', 'post status', 'acf' ) : _x( 'Disabled', 'post status', 'acf' );
|
386 |
+
|
387 |
+
?>
|
388 |
<script type="text/javascript">
|
389 |
(function($) {
|
390 |
$('#post-status-display').html( '<?php echo esc_html( $status_label ); ?>' );
|
391 |
})(jQuery);
|
392 |
</script>
|
393 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
}
|
395 |
+
|
396 |
+
|
397 |
+
/*
|
398 |
+
* save_post
|
399 |
+
*
|
400 |
+
* This function will save all the field group data
|
401 |
+
*
|
402 |
+
* @type function
|
403 |
+
* @date 23/06/12
|
404 |
+
* @since 1.0.0
|
405 |
+
*
|
406 |
+
* @param $post_id (int)
|
407 |
+
* @return $post_id (int)
|
408 |
+
*/
|
409 |
+
|
410 |
+
function save_post( $post_id, $post ) {
|
411 |
+
|
412 |
+
// do not save if this is an auto save routine
|
413 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
414 |
+
return $post_id;
|
415 |
+
}
|
416 |
+
|
417 |
+
// bail early if not acf-field-group
|
418 |
+
if ( $post->post_type !== 'acf-field-group' ) {
|
419 |
+
return $post_id;
|
420 |
+
}
|
421 |
+
|
422 |
+
// only save once! WordPress save's a revision as well.
|
423 |
+
if ( wp_is_post_revision( $post_id ) ) {
|
424 |
+
return $post_id;
|
425 |
+
}
|
426 |
+
|
427 |
+
// verify nonce
|
428 |
+
if ( ! acf_verify_nonce( 'field_group' ) ) {
|
429 |
+
return $post_id;
|
430 |
+
}
|
431 |
+
|
432 |
+
// Bail early if request came from an unauthorised user.
|
433 |
+
if ( ! current_user_can( acf_get_setting( 'capability' ) ) ) {
|
434 |
+
return $post_id;
|
435 |
+
}
|
436 |
+
|
437 |
+
// disable filters to ensure ACF loads raw data from DB
|
438 |
+
acf_disable_filters();
|
439 |
+
|
440 |
+
// save fields
|
441 |
+
if ( ! empty( $_POST['acf_fields'] ) ) {
|
442 |
+
|
443 |
+
// loop
|
444 |
+
foreach ( $_POST['acf_fields'] as $field ) {
|
445 |
+
|
446 |
+
// vars
|
447 |
+
$specific = false;
|
448 |
+
$save = acf_extract_var( $field, 'save' );
|
449 |
+
|
450 |
+
// only saved field if has changed
|
451 |
+
if ( $save == 'meta' ) {
|
452 |
+
$specific = array(
|
453 |
+
'menu_order',
|
454 |
+
'post_parent',
|
455 |
+
);
|
456 |
+
}
|
457 |
+
|
458 |
+
// set parent
|
459 |
+
if ( ! $field['parent'] ) {
|
460 |
+
$field['parent'] = $post_id;
|
461 |
+
}
|
462 |
+
|
463 |
+
// save field
|
464 |
+
acf_update_field( $field, $specific );
|
465 |
+
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
// delete fields
|
470 |
+
if ( $_POST['_acf_delete_fields'] ) {
|
471 |
+
|
472 |
+
// clean
|
473 |
+
$ids = explode( '|', $_POST['_acf_delete_fields'] );
|
474 |
+
$ids = array_map( 'intval', $ids );
|
475 |
+
|
476 |
+
// loop
|
477 |
+
foreach ( $ids as $id ) {
|
478 |
+
|
479 |
+
// bai early if no id
|
480 |
+
if ( ! $id ) {
|
481 |
+
continue;
|
482 |
+
}
|
483 |
+
|
484 |
+
// delete
|
485 |
+
acf_delete_field( $id );
|
486 |
+
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
// add args
|
491 |
+
$_POST['acf_field_group']['ID'] = $post_id;
|
492 |
+
$_POST['acf_field_group']['title'] = $_POST['post_title'];
|
493 |
+
|
494 |
+
// save field group
|
495 |
+
acf_update_field_group( $_POST['acf_field_group'] );
|
496 |
+
|
497 |
+
// return
|
498 |
return $post_id;
|
499 |
}
|
500 |
+
|
501 |
+
|
502 |
+
/*
|
503 |
+
* mb_fields
|
504 |
+
*
|
505 |
+
* This function will render the HTML for the medtabox 'acf-field-group-fields'
|
506 |
+
*
|
507 |
+
* @type function
|
508 |
+
* @date 28/09/13
|
509 |
+
* @since 5.0.0
|
510 |
+
*
|
511 |
+
* @param N/A
|
512 |
+
* @return N/A
|
513 |
+
*/
|
514 |
+
|
515 |
+
function mb_fields() {
|
516 |
+
|
517 |
+
// global
|
518 |
+
global $field_group;
|
519 |
+
|
520 |
+
// get fields
|
521 |
+
$view = array(
|
522 |
+
'fields' => acf_get_fields( $field_group ),
|
523 |
+
'parent' => 0,
|
524 |
+
);
|
525 |
+
|
526 |
+
// load view
|
527 |
+
acf_get_view( 'field-group-fields', $view );
|
528 |
+
|
529 |
}
|
530 |
+
|
531 |
+
|
532 |
+
/*
|
533 |
+
* mb_options
|
534 |
+
*
|
535 |
+
* This function will render the HTML for the medtabox 'acf-field-group-options'
|
536 |
+
*
|
537 |
+
* @type function
|
538 |
+
* @date 28/09/13
|
539 |
+
* @since 5.0.0
|
540 |
+
*
|
541 |
+
* @param N/A
|
542 |
+
* @return N/A
|
543 |
+
*/
|
544 |
+
|
545 |
+
function mb_options() {
|
546 |
+
|
547 |
+
// global
|
548 |
+
global $field_group;
|
549 |
+
|
550 |
+
// field key (leave in for compatibility)
|
551 |
+
if ( ! acf_is_field_group_key( $field_group['key'] ) ) {
|
552 |
+
|
553 |
+
$field_group['key'] = uniqid( 'group_' );
|
554 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
}
|
556 |
+
|
557 |
+
// view
|
558 |
+
acf_get_view( 'field-group-options' );
|
559 |
+
|
560 |
}
|
561 |
+
|
562 |
+
|
563 |
+
/*
|
564 |
+
* mb_locations
|
565 |
+
*
|
566 |
+
* This function will render the HTML for the medtabox 'acf-field-group-locations'
|
567 |
+
*
|
568 |
+
* @type function
|
569 |
+
* @date 28/09/13
|
570 |
+
* @since 5.0.0
|
571 |
+
*
|
572 |
+
* @param N/A
|
573 |
+
* @return N/A
|
574 |
+
*/
|
575 |
+
|
576 |
+
function mb_locations() {
|
577 |
+
|
578 |
+
// global
|
579 |
+
global $field_group;
|
580 |
+
|
581 |
+
// UI needs at lease 1 location rule
|
582 |
+
if ( empty( $field_group['location'] ) ) {
|
583 |
+
|
584 |
+
$field_group['location'] = array(
|
585 |
+
|
586 |
+
// group 0
|
587 |
+
array(
|
588 |
+
|
589 |
+
// rule 0
|
590 |
+
array(
|
591 |
+
'param' => 'post_type',
|
592 |
+
'operator' => '==',
|
593 |
+
'value' => 'post',
|
594 |
+
),
|
595 |
+
),
|
596 |
+
|
597 |
+
);
|
598 |
}
|
599 |
+
|
600 |
+
// view
|
601 |
+
acf_get_view( 'field-group-locations' );
|
602 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
}
|
604 |
+
|
605 |
+
|
606 |
+
/*
|
607 |
+
* ajax_render_location_rule
|
608 |
+
*
|
609 |
+
* This function can be accessed via an AJAX action and will return the result from the render_location_value function
|
610 |
+
*
|
611 |
+
* @type function (ajax)
|
612 |
+
* @date 30/09/13
|
613 |
+
* @since 5.0.0
|
614 |
+
*
|
615 |
+
* @param n/a
|
616 |
+
* @return n/a
|
617 |
+
*/
|
618 |
+
|
619 |
+
function ajax_render_location_rule() {
|
620 |
+
|
621 |
+
// validate
|
622 |
+
if ( ! acf_verify_ajax() ) {
|
623 |
+
die();
|
624 |
+
}
|
625 |
+
|
626 |
+
// verify user capability
|
627 |
+
if ( ! acf_current_user_can_admin() ) {
|
628 |
+
die();
|
629 |
+
}
|
630 |
+
|
631 |
+
// validate rule
|
632 |
+
$rule = acf_validate_location_rule( $_POST['rule'] );
|
633 |
+
|
634 |
+
// view
|
635 |
+
acf_get_view(
|
636 |
+
'html-location-rule',
|
637 |
array(
|
638 |
+
'rule' => $rule,
|
|
|
|
|
|
|
|
|
|
|
|
|
639 |
)
|
|
|
640 |
);
|
641 |
+
|
642 |
+
// die
|
643 |
+
die();
|
644 |
}
|
645 |
+
|
646 |
+
|
647 |
+
/*
|
648 |
+
* ajax_render_field_settings
|
649 |
+
*
|
650 |
+
* This function will return HTML containing the field's settings based on it's new type
|
651 |
+
*
|
652 |
+
* @type function (ajax)
|
653 |
+
* @date 30/09/13
|
654 |
+
* @since 5.0.0
|
655 |
+
*
|
656 |
+
* @param n/a
|
657 |
+
* @return n/a
|
658 |
+
*/
|
659 |
+
|
660 |
+
function ajax_render_field_settings() {
|
661 |
+
|
662 |
+
// validate
|
663 |
+
if ( ! acf_verify_ajax() ) {
|
664 |
+
die();
|
665 |
+
}
|
666 |
+
|
667 |
+
// verify user capability
|
668 |
+
if ( ! acf_current_user_can_admin() ) {
|
669 |
+
die();
|
670 |
+
}
|
671 |
+
|
672 |
+
// vars
|
673 |
+
$field = acf_maybe_get_POST( 'field' );
|
674 |
+
|
675 |
+
// check
|
676 |
+
if ( ! $field ) {
|
677 |
+
die();
|
678 |
+
}
|
679 |
+
|
680 |
+
// set prefix
|
681 |
+
$field['prefix'] = acf_maybe_get_POST( 'prefix' );
|
682 |
+
|
683 |
+
// validate
|
684 |
+
$field = acf_get_valid_field( $field );
|
685 |
+
|
686 |
+
// render
|
687 |
+
do_action( "acf/render_field_settings/type={$field['type']}", $field );
|
688 |
+
|
689 |
+
// return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
690 |
die();
|
691 |
+
|
692 |
}
|
693 |
+
|
694 |
+
/*
|
695 |
+
* ajax_move_field
|
696 |
+
*
|
697 |
+
* description
|
698 |
+
*
|
699 |
+
* @type function
|
700 |
+
* @date 20/01/2014
|
701 |
+
* @since 5.0.0
|
702 |
+
*
|
703 |
+
* @param $post_id (int)
|
704 |
+
* @return $post_id (int)
|
705 |
+
*/
|
706 |
+
|
707 |
+
function ajax_move_field() {
|
708 |
+
|
709 |
+
// disable filters to ensure ACF loads raw data from DB
|
710 |
+
acf_disable_filters();
|
711 |
+
|
712 |
+
$args = acf_parse_args(
|
713 |
+
$_POST,
|
714 |
+
array(
|
715 |
+
'nonce' => '',
|
716 |
+
'post_id' => 0,
|
717 |
+
'field_id' => 0,
|
718 |
+
'field_group_id' => 0,
|
719 |
+
)
|
720 |
+
);
|
721 |
+
|
722 |
+
// verify nonce
|
723 |
+
if ( ! wp_verify_nonce( $args['nonce'], 'acf_nonce' ) ) {
|
724 |
+
die();
|
725 |
+
}
|
726 |
+
|
727 |
+
// verify user capability
|
728 |
+
if ( ! acf_current_user_can_admin() ) {
|
729 |
+
die();
|
730 |
+
}
|
731 |
+
|
732 |
+
// confirm?
|
733 |
+
if ( $args['field_id'] && $args['field_group_id'] ) {
|
734 |
+
|
735 |
+
// vars
|
736 |
+
$field = acf_get_field( $args['field_id'] );
|
737 |
+
$field_group = acf_get_field_group( $args['field_group_id'] );
|
738 |
+
|
739 |
+
// update parent
|
740 |
+
$field['parent'] = $field_group['ID'];
|
741 |
+
|
742 |
+
// remove conditional logic
|
743 |
+
$field['conditional_logic'] = 0;
|
744 |
+
|
745 |
+
// update field
|
746 |
+
acf_update_field( $field );
|
747 |
+
|
748 |
+
// Output HTML.
|
749 |
+
$link = '<a href="' . admin_url( 'post.php?post=' . $field_group['ID'] . '&action=edit' ) . '" target="_blank">' . esc_html( $field_group['title'] ) . '</a>';
|
750 |
+
|
751 |
+
echo '' .
|
752 |
+
'<p><strong>' . __( 'Move Complete.', 'acf' ) . '</strong></p>' .
|
753 |
+
'<p>' . sprintf(
|
754 |
+
acf_punctify( __( 'The %1$s field can now be found in the %2$s field group', 'acf' ) ),
|
755 |
+
esc_html( $field['label'] ),
|
756 |
+
$link
|
757 |
+
) . '</p>' .
|
758 |
+
'<a href="#" class="button button-primary acf-close-popup">' . __( 'Close Window', 'acf' ) . '</a>';
|
759 |
+
die();
|
760 |
}
|
761 |
+
|
762 |
+
// get all field groups
|
763 |
+
$field_groups = acf_get_field_groups();
|
764 |
+
$choices = array();
|
765 |
+
|
766 |
+
// check
|
767 |
+
if ( ! empty( $field_groups ) ) {
|
768 |
+
|
769 |
+
// loop
|
770 |
+
foreach ( $field_groups as $field_group ) {
|
771 |
+
|
772 |
+
// bail early if no ID
|
773 |
+
if ( ! $field_group['ID'] ) {
|
774 |
+
continue;
|
775 |
+
}
|
776 |
+
|
777 |
+
// bail ealry if is current
|
778 |
+
if ( $field_group['ID'] == $args['post_id'] ) {
|
779 |
+
continue;
|
780 |
+
}
|
781 |
+
|
782 |
+
// append
|
783 |
+
$choices[ $field_group['ID'] ] = $field_group['title'];
|
784 |
+
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
// render options
|
789 |
+
$field = acf_get_valid_field(
|
790 |
+
array(
|
791 |
+
'type' => 'select',
|
792 |
+
'name' => 'acf_field_group',
|
793 |
+
'choices' => $choices,
|
794 |
+
)
|
795 |
+
);
|
796 |
+
|
797 |
+
echo '<p>' . __( 'Please select the destination for this field', 'acf' ) . '</p>';
|
798 |
+
|
799 |
+
echo '<form id="acf-move-field-form">';
|
800 |
+
|
801 |
+
// render
|
802 |
+
acf_render_field_wrap( $field );
|
803 |
+
|
804 |
+
echo '<button type="submit" class="button button-primary">' . __( 'Move Field', 'acf' ) . '</button>';
|
805 |
+
|
806 |
+
echo '</form>';
|
807 |
+
|
808 |
+
// die
|
809 |
+
die();
|
810 |
+
|
811 |
}
|
812 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
813 |
}
|
|
|
|
|
814 |
|
815 |
+
// initialize
|
816 |
+
new acf_admin_field_group();
|
817 |
|
818 |
endif;
|
819 |
|
820 |
+
?>
|
includes/admin/admin-field-groups.php
CHANGED
@@ -1,713 +1,719 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
-
if( ! defined( 'ABSPATH' ) )
|
|
|
|
|
4 |
|
5 |
-
if( ! class_exists('ACF_Admin_Field_Groups') ) :
|
6 |
|
7 |
-
class ACF_Admin_Field_Groups {
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Array of field groups availbale for sync.
|
11 |
-
*
|
12 |
-
* @since 5.9.0
|
13 |
-
* @var array
|
14 |
-
*/
|
15 |
-
public $sync = array();
|
16 |
-
|
17 |
-
/**
|
18 |
-
* The current view (post_status).
|
19 |
-
*
|
20 |
-
* @since 5.9.0
|
21 |
-
* @var string
|
22 |
-
*/
|
23 |
-
public $view = '';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Constructor.
|
27 |
-
*
|
28 |
-
* @date 5/03/2014
|
29 |
-
* @since 5.0.0
|
30 |
-
*
|
31 |
-
* @param void
|
32 |
-
* @return void
|
33 |
-
*/
|
34 |
-
public function __construct() {
|
35 |
-
|
36 |
-
// Add hooks.
|
37 |
-
add_action( 'load-edit.php', array( $this, 'handle_redirection') );
|
38 |
-
add_action( 'current_screen', array( $this, 'current_screen' ) );
|
39 |
-
|
40 |
-
// Handle post status change events.
|
41 |
-
add_action( 'trashed_post', array( $this, 'trashed_post') );
|
42 |
-
add_action( 'untrashed_post', array( $this, 'untrashed_post') );
|
43 |
-
add_action( 'deleted_post', array( $this, 'deleted_post') );
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Returns the Field Groups admin URL.
|
48 |
-
*
|
49 |
-
* @date 27/3/20
|
50 |
-
* @since 5.9.0
|
51 |
-
*
|
52 |
-
* @param string $params Extra URL params.
|
53 |
-
* @return string
|
54 |
-
*/
|
55 |
-
public function get_admin_url( $params = '' ) {
|
56 |
-
return admin_url( "edit.php?post_type=acf-field-group{$params}" );
|
57 |
-
}
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
// Bail early if not Field Groups admin page.
|
100 |
-
if( !acf_is_screen('edit-acf-field-group') ) {
|
101 |
-
return;
|
102 |
}
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$wp_post_statuses['trash'] = acf_extract_var( $wp_post_statuses, 'trash' );
|
116 |
-
|
117 |
-
// Add hooks.
|
118 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') );
|
119 |
-
add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
120 |
-
add_filter( 'views_edit-acf-field-group', array( $this, 'admin_table_views' ), 10, 1 );
|
121 |
-
add_filter( 'manage_acf-field-group_posts_columns', array( $this, 'admin_table_columns' ), 10, 1 );
|
122 |
-
add_action( 'manage_acf-field-group_posts_custom_column', array( $this, 'admin_table_columns_html' ), 10, 2 );
|
123 |
-
add_filter( 'display_post_states', array( $this, 'display_post_states' ), 10, 2 );
|
124 |
-
add_filter( 'bulk_actions-edit-acf-field-group', array( $this, 'admin_table_bulk_actions' ), 10, 1 );
|
125 |
-
add_action( 'admin_footer', array( $this, 'admin_footer' ), 1 );
|
126 |
-
if( $this->view !== 'trash' ) {
|
127 |
-
add_filter( 'page_row_actions', array( $this, 'page_row_actions' ), 10, 2 );
|
128 |
}
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
}
|
176 |
}
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Modifies the admin body class.
|
201 |
-
*
|
202 |
-
* @date 18/4/20
|
203 |
-
* @since 5.9.0
|
204 |
-
*
|
205 |
-
* @param string $classes Space-separated list of CSS classes.
|
206 |
-
* @return string
|
207 |
-
*/
|
208 |
-
public function admin_body_class( $classes ) {
|
209 |
-
$classes .= ' acf-admin-field-groups';
|
210 |
-
if( $this->view ) {
|
211 |
-
$classes .= " view-{$this->view}";
|
212 |
}
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Adds the "disabled" post state for the admin table title.
|
231 |
-
*
|
232 |
-
* @date 1/4/20
|
233 |
-
* @since 5.9.0
|
234 |
-
*
|
235 |
-
* @param array $post_states An array of post display states.
|
236 |
-
* @param WP_Post $post The current post object.
|
237 |
-
* @return array
|
238 |
-
*/
|
239 |
-
public function display_post_states( $post_states, $post ) {
|
240 |
-
if( $post->post_status === 'acf-disabled' ) {
|
241 |
-
$post_states['acf-disabled'] = $this->get_disabled_post_state();
|
242 |
}
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
public function admin_table_columns( $_columns ) {
|
256 |
-
$columns = array(
|
257 |
-
'cb' => $_columns['cb'],
|
258 |
-
'title' => $_columns['title'],
|
259 |
-
'acf-description' => __('Description', 'acf'),
|
260 |
-
'acf-key' => __('Key', 'acf'),
|
261 |
-
'acf-location' => __('Location', 'acf'),
|
262 |
-
'acf-count' => __('Fields', 'acf'),
|
263 |
-
);
|
264 |
-
if( acf_get_local_json_files() ) {
|
265 |
-
$columns['acf-json'] = __('Local JSON', 'acf');
|
266 |
}
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
$this->render_admin_table_column( $column_name, $field_group );
|
284 |
}
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
echo '<span class="acf-description">' . acf_esc_html( $field_group['description'] ) . '</span>';
|
309 |
-
}
|
310 |
-
break;
|
311 |
-
|
312 |
-
// Location.
|
313 |
-
case 'acf-location':
|
314 |
-
$this->render_admin_table_column_locations( $field_group );
|
315 |
-
break;
|
316 |
-
|
317 |
-
// Count.
|
318 |
-
case 'acf-count':
|
319 |
-
echo esc_html( acf_get_field_count( $field_group ) );
|
320 |
-
break;
|
321 |
-
|
322 |
-
// Local JSON.
|
323 |
-
case 'acf-json':
|
324 |
-
$this->render_admin_table_column_local_status( $field_group );
|
325 |
-
break;
|
326 |
}
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
$
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
$object_subtypes = array_values( $object_subtypes );
|
377 |
-
|
378 |
-
$object_subtypes
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
|
|
|
|
|
|
|
|
|
|
388 |
}
|
389 |
}
|
390 |
}
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
|
|
|
|
413 |
}
|
414 |
-
|
415 |
-
|
|
|
416 |
}
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
$rel_file = str_replace( ABSPATH, '', $file );
|
445 |
-
$located = sprintf( __('Located in: %s', 'acf'), $rel_file );
|
446 |
}
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
if( $field_group['ID'] ) {
|
467 |
-
echo '<div class="row-actions">
|
468 |
<span class="sync"><a href="' . esc_url( $url ) . '">' . __( 'Sync', 'acf' ) . '</a> | </span>
|
469 |
-
<span class="review"><a href="#" data-event="review-sync" data-id="' . esc_attr($field_group['ID']) . '" data-href="' . esc_url( $url ) . '">' . __( 'Review changes', 'acf' ) . '</a></span>
|
470 |
</div>';
|
471 |
-
|
472 |
-
|
473 |
<span class="sync"><a href="' . esc_url( $url ) . '">' . __( 'Import', 'acf' ) . '</a></span>
|
474 |
</div>';
|
|
|
|
|
|
|
475 |
}
|
476 |
} else {
|
477 |
-
echo __( '
|
478 |
}
|
479 |
-
} else {
|
480 |
-
echo '<span class="acf-secondary-text">' . __( 'Awaiting save', 'acf' ) . '</span>';
|
481 |
}
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
return array_merge( array_flip($order), $actions );
|
506 |
-
}
|
507 |
-
|
508 |
-
/**
|
509 |
-
* Modifies the admin table bulk actions dropdown.
|
510 |
-
*
|
511 |
-
* @date 15/4/20
|
512 |
-
* @since 5.9.0
|
513 |
-
*
|
514 |
-
* @param array $actions The actions array.
|
515 |
-
* @return array
|
516 |
-
*/
|
517 |
-
public function admin_table_bulk_actions( $actions ) {
|
518 |
-
|
519 |
-
// Add "duplicate" action.
|
520 |
-
if( $this->view !== 'sync' ) {
|
521 |
-
$actions[ 'acfduplicate' ] = __( 'Duplicate', 'acf' );
|
522 |
}
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
}
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
*
|
537 |
-
* @date 15/4/20
|
538 |
-
* @since 5.9.0
|
539 |
-
*
|
540 |
-
* @param void
|
541 |
-
* @return void
|
542 |
-
*/
|
543 |
-
public function check_duplicate() {
|
544 |
-
|
545 |
-
// Display notice on success redirect.
|
546 |
-
if( isset($_GET['acfduplicatecomplete']) ) {
|
547 |
-
$ids = array_map( 'intval', explode(',', $_GET['acfduplicatecomplete']) );
|
548 |
-
|
549 |
-
// Generate text.
|
550 |
-
$text = sprintf(
|
551 |
-
_n( 'Field group duplicated.', '%s field groups duplicated.', count($ids), 'acf' ),
|
552 |
-
count($ids)
|
553 |
-
);
|
554 |
-
|
555 |
-
// Append links to text.
|
556 |
-
$links = array();
|
557 |
-
foreach( $ids as $id ) {
|
558 |
-
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
559 |
}
|
560 |
-
|
561 |
-
|
562 |
-
// Add notice.
|
563 |
-
acf_add_admin_notice( $text, 'success' );
|
564 |
-
return;
|
565 |
-
}
|
566 |
-
|
567 |
-
// Find items to duplicate.
|
568 |
-
$ids = array();
|
569 |
-
if( isset($_GET['acfduplicate']) ) {
|
570 |
-
$ids[] = intval( $_GET['acfduplicate'] );
|
571 |
-
} elseif( isset($_GET['post'], $_GET['action2']) && $_GET['action2'] === 'acfduplicate' ) {
|
572 |
-
$ids = array_map( 'intval', $_GET['post'] );
|
573 |
}
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
}
|
584 |
-
|
585 |
-
//
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
/**
|
592 |
-
* Checks for the custom "acfsync" action.
|
593 |
-
*
|
594 |
-
* @date 15/4/20
|
595 |
-
* @since 5.9.0
|
596 |
-
*
|
597 |
-
* @param void
|
598 |
-
* @return void
|
599 |
-
*/
|
600 |
-
public function check_sync() {
|
601 |
-
|
602 |
-
// Display notice on success redirect.
|
603 |
-
if( isset($_GET['acfsynccomplete']) ) {
|
604 |
-
$ids = array_map( 'intval', explode(',', $_GET['acfsynccomplete']) );
|
605 |
-
|
606 |
-
// Generate text.
|
607 |
-
$text = sprintf(
|
608 |
-
_n( 'Field group synchronised.', '%s field groups synchronised.', count($ids), 'acf' ),
|
609 |
-
count($ids)
|
610 |
-
);
|
611 |
-
|
612 |
-
// Append links to text.
|
613 |
-
$links = array();
|
614 |
-
foreach( $ids as $id ) {
|
615 |
-
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
616 |
}
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
if( isset($_GET['acfsync']) ) {
|
627 |
-
$keys[] = sanitize_text_field( $_GET['acfsync'] );
|
628 |
-
} elseif( isset($_GET['post'], $_GET['action2']) && $_GET['action2'] === 'acfsync' ) {
|
629 |
-
$keys = array_map( 'sanitize_text_field', $_GET['post'] );
|
630 |
-
}
|
631 |
-
|
632 |
-
if( $keys && $this->sync ) {
|
633 |
-
check_admin_referer('bulk-posts');
|
634 |
-
|
635 |
-
// Disabled "Local JSON" controller to prevent the .json file from being modified during import.
|
636 |
-
acf_update_setting( 'json', false );
|
637 |
-
|
638 |
-
// Sync field groups and generate array of new IDs.
|
639 |
-
$files = acf_get_local_json_files();
|
640 |
-
$new_ids = array();
|
641 |
-
foreach( $this->sync as $key => $field_group ) {
|
642 |
-
if( $field_group['key'] && in_array($field_group['key'], $keys) ) {
|
643 |
-
// Import.
|
644 |
-
} elseif( $field_group['ID'] && in_array($field_group['ID'], $keys) ) {
|
645 |
-
// Import.
|
646 |
-
} else {
|
647 |
-
// Ignore.
|
648 |
-
continue;
|
649 |
}
|
650 |
-
|
651 |
-
|
652 |
-
$
|
653 |
-
|
654 |
}
|
655 |
-
|
656 |
-
// Redirect.
|
657 |
-
wp_redirect( $this->get_current_admin_url( '&acfsynccomplete=' . implode(',', $new_ids) ) );
|
658 |
-
exit;
|
659 |
}
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
$
|
685 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
}
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
696 |
}
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
function admin_footer() {
|
710 |
-
?>
|
711 |
<script type="text/javascript">
|
712 |
(function($){
|
713 |
|
@@ -747,75 +753,75 @@ class ACF_Admin_Field_Groups {
|
|
747 |
});
|
748 |
})(jQuery);
|
749 |
</script>
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
<div style="display: none;">
|
770 |
<table>
|
771 |
<tbody id="acf-the-list">
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
}
|
786 |
-
if( in_array( $column_name, $hidden, true ) ) {
|
787 |
-
$classes .= ' hidden';
|
788 |
-
}
|
789 |
-
echo "<$el class=\"$classes\" data-colname=\"$column_label\">";
|
790 |
-
switch ( $column_name ) {
|
791 |
-
|
792 |
-
// Checkbox.
|
793 |
-
case 'cb':
|
794 |
-
echo '<label for="cb-select-' . esc_attr( $k ) .'" class="screen-reader-text">' .esc_html( sprintf( __( 'Select %s', 'acf' ), $field_group['title'] ) ) . '</label>';
|
795 |
-
echo '<input id="cb-select-' . esc_attr( $k ) .'" type="checkbox" value="'. esc_attr( $k ) .'" name="post[]">';
|
796 |
-
break;
|
797 |
-
|
798 |
-
// Title.
|
799 |
-
case 'title':
|
800 |
-
$post_state = '';
|
801 |
-
if( !$field_group['active'] ) {
|
802 |
-
$post_state = ' — <span class="post-state">' . $this->get_disabled_post_state() . '</span>';
|
803 |
}
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
813 |
}
|
814 |
-
|
815 |
-
}
|
816 |
-
echo '</tr>';
|
817 |
-
}
|
818 |
-
?>
|
819 |
</tbody>
|
820 |
</table>
|
821 |
</div>
|
@@ -824,56 +830,56 @@ class ACF_Admin_Field_Groups {
|
|
824 |
$('#the-list').html( $('#acf-the-list').children() );
|
825 |
})(jQuery);
|
826 |
</script>
|
827 |
-
|
828 |
-
}
|
829 |
-
|
830 |
-
/**
|
831 |
-
* Fires when trashing a field group post.
|
832 |
-
*
|
833 |
-
* @date 8/01/2014
|
834 |
-
* @since 5.0.0
|
835 |
-
*
|
836 |
-
* @param int $post_id The post ID.
|
837 |
-
* @return void
|
838 |
-
*/
|
839 |
-
public function trashed_post( $post_id ) {
|
840 |
-
if( get_post_type($post_id) === 'acf-field-group' ) {
|
841 |
-
acf_trash_field_group( $post_id );
|
842 |
}
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
}
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
}
|
873 |
-
}
|
874 |
-
}
|
875 |
|
876 |
-
|
877 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // Exit if accessed directly
|
5 |
+
}
|
6 |
|
7 |
+
if ( ! class_exists( 'ACF_Admin_Field_Groups' ) ) :
|
8 |
|
9 |
+
class ACF_Admin_Field_Groups {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
/**
|
12 |
+
* Array of field groups availbale for sync.
|
13 |
+
*
|
14 |
+
* @since 5.9.0
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
public $sync = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The current view (post_status).
|
21 |
+
*
|
22 |
+
* @since 5.9.0
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
public $view = '';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Constructor.
|
29 |
+
*
|
30 |
+
* @date 5/03/2014
|
31 |
+
* @since 5.0.0
|
32 |
+
*
|
33 |
+
* @param void
|
34 |
+
* @return void
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
// Add hooks.
|
39 |
+
add_action( 'load-edit.php', array( $this, 'handle_redirection' ) );
|
40 |
+
add_action( 'current_screen', array( $this, 'current_screen' ) );
|
41 |
+
|
42 |
+
// Handle post status change events.
|
43 |
+
add_action( 'trashed_post', array( $this, 'trashed_post' ) );
|
44 |
+
add_action( 'untrashed_post', array( $this, 'untrashed_post' ) );
|
45 |
+
add_action( 'deleted_post', array( $this, 'deleted_post' ) );
|
46 |
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Returns the Field Groups admin URL.
|
50 |
+
*
|
51 |
+
* @date 27/3/20
|
52 |
+
* @since 5.9.0
|
53 |
+
*
|
54 |
+
* @param string $params Extra URL params.
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function get_admin_url( $params = '' ) {
|
58 |
+
return admin_url( "edit.php?post_type=acf-field-group{$params}" );
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Returns the Field Groups admin URL taking into account the current view.
|
63 |
+
*
|
64 |
+
* @date 27/3/20
|
65 |
+
* @since 5.9.0
|
66 |
+
*
|
67 |
+
* @param string $params Extra URL params.
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
public function get_current_admin_url( $params = '' ) {
|
71 |
+
return $this->get_admin_url( ( $this->view ? '&post_status=' . $this->view : '' ) . $params );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
+
/**
|
75 |
+
* Redirects users from ACF 4.0 admin page.
|
76 |
+
*
|
77 |
+
* @date 17/9/18
|
78 |
+
* @since 5.7.6
|
79 |
+
*
|
80 |
+
* @param void
|
81 |
+
* @return void
|
82 |
+
*/
|
83 |
+
public function handle_redirection() {
|
84 |
+
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'acf' ) {
|
85 |
+
wp_redirect( $this->get_admin_url() );
|
86 |
+
exit;
|
87 |
+
}
|
88 |
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Constructor for the Field Groups admin page.
|
92 |
+
*
|
93 |
+
* @date 21/07/2014
|
94 |
+
* @since 5.0.0
|
95 |
+
*
|
96 |
+
* @param void
|
97 |
+
* @return void
|
98 |
+
*/
|
99 |
+
public function current_screen() {
|
100 |
+
|
101 |
+
// Bail early if not Field Groups admin page.
|
102 |
+
if ( ! acf_is_screen( 'edit-acf-field-group' ) ) {
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
|
106 |
+
// Get the current view.
|
107 |
+
$this->view = isset( $_GET['post_status'] ) ? sanitize_text_field( $_GET['post_status'] ) : '';
|
108 |
+
|
109 |
+
// Setup and check for custom actions..
|
110 |
+
$this->setup_sync();
|
111 |
+
$this->check_sync();
|
112 |
+
$this->check_duplicate();
|
113 |
+
|
114 |
+
// Modify publish post status text and order.
|
115 |
+
global $wp_post_statuses;
|
116 |
+
$wp_post_statuses['publish']->label_count = _n_noop( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', 'acf' );
|
117 |
+
$wp_post_statuses['trash'] = acf_extract_var( $wp_post_statuses, 'trash' );
|
118 |
+
|
119 |
+
// Add hooks.
|
120 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
121 |
+
add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
122 |
+
add_filter( 'views_edit-acf-field-group', array( $this, 'admin_table_views' ), 10, 1 );
|
123 |
+
add_filter( 'manage_acf-field-group_posts_columns', array( $this, 'admin_table_columns' ), 10, 1 );
|
124 |
+
add_action( 'manage_acf-field-group_posts_custom_column', array( $this, 'admin_table_columns_html' ), 10, 2 );
|
125 |
+
add_filter( 'display_post_states', array( $this, 'display_post_states' ), 10, 2 );
|
126 |
+
add_filter( 'bulk_actions-edit-acf-field-group', array( $this, 'admin_table_bulk_actions' ), 10, 1 );
|
127 |
+
add_action( 'admin_footer', array( $this, 'admin_footer' ), 1 );
|
128 |
+
if ( $this->view !== 'trash' ) {
|
129 |
+
add_filter( 'page_row_actions', array( $this, 'page_row_actions' ), 10, 2 );
|
130 |
+
}
|
131 |
+
|
132 |
+
// Add hooks for "sync" view.
|
133 |
+
if ( $this->view === 'sync' ) {
|
134 |
+
add_action( 'admin_footer', array( $this, 'admin_footer__sync' ), 1 );
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Sets up the field groups ready for sync.
|
140 |
+
*
|
141 |
+
* @date 17/4/20
|
142 |
+
* @since 5.9.0
|
143 |
+
*
|
144 |
+
* @param void
|
145 |
+
* @return void
|
146 |
+
*/
|
147 |
+
public function setup_sync() {
|
148 |
+
|
149 |
+
// Review local json field groups.
|
150 |
+
if ( acf_get_local_json_files() ) {
|
151 |
+
|
152 |
+
// Get all groups in a single cached query to check if sync is available.
|
153 |
+
$all_field_groups = acf_get_field_groups();
|
154 |
+
foreach ( $all_field_groups as $field_group ) {
|
155 |
+
|
156 |
+
// Extract vars.
|
157 |
+
$local = acf_maybe_get( $field_group, 'local' );
|
158 |
+
$modified = acf_maybe_get( $field_group, 'modified' );
|
159 |
+
$private = acf_maybe_get( $field_group, 'private' );
|
160 |
+
|
161 |
+
// Ignore if is private.
|
162 |
+
if ( $private ) {
|
163 |
+
continue;
|
164 |
+
|
165 |
+
// Ignore not local "json".
|
166 |
+
} elseif ( $local !== 'json' ) {
|
167 |
+
continue;
|
168 |
+
|
169 |
+
// Append to sync if not yet in database.
|
170 |
+
} elseif ( ! $field_group['ID'] ) {
|
171 |
+
$this->sync[ $field_group['key'] ] = $field_group;
|
172 |
+
|
173 |
+
// Append to sync if "json" modified time is newer than database.
|
174 |
+
} elseif ( $modified && $modified > get_post_modified_time( 'U', true, $field_group['ID'] ) ) {
|
175 |
+
$this->sync[ $field_group['key'] ] = $field_group;
|
176 |
+
}
|
177 |
}
|
178 |
}
|
179 |
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Enqueues admin scripts.
|
183 |
+
*
|
184 |
+
* @date 18/4/20
|
185 |
+
* @since 5.9.0
|
186 |
+
*
|
187 |
+
* @param void
|
188 |
+
* @return void
|
189 |
+
*/
|
190 |
+
public function admin_enqueue_scripts() {
|
191 |
+
acf_enqueue_script( 'acf' );
|
192 |
+
|
193 |
+
// Localize text.
|
194 |
+
acf_localize_text(
|
195 |
+
array(
|
196 |
+
'Review local JSON changes' => __( 'Review local JSON changes', 'acf' ),
|
197 |
+
'Loading diff' => __( 'Loading diff', 'acf' ),
|
198 |
+
'Sync changes' => __( 'Sync changes', 'acf' ),
|
199 |
+
)
|
200 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Modifies the admin body class.
|
205 |
+
*
|
206 |
+
* @date 18/4/20
|
207 |
+
* @since 5.9.0
|
208 |
+
*
|
209 |
+
* @param string $classes Space-separated list of CSS classes.
|
210 |
+
* @return string
|
211 |
+
*/
|
212 |
+
public function admin_body_class( $classes ) {
|
213 |
+
$classes .= ' acf-admin-field-groups';
|
214 |
+
if ( $this->view ) {
|
215 |
+
$classes .= " view-{$this->view}";
|
216 |
+
}
|
217 |
+
return $classes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* returns the disabled post state HTML.
|
222 |
+
*
|
223 |
+
* @date 17/4/20
|
224 |
+
* @since 5.9.0
|
225 |
+
*
|
226 |
+
* @param void
|
227 |
+
* @return string
|
228 |
+
*/
|
229 |
+
public function get_disabled_post_state() {
|
230 |
+
return '<span class="dashicons dashicons-hidden"></span> ' . _x( 'Disabled', 'post status', 'acf' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Adds the "disabled" post state for the admin table title.
|
235 |
+
*
|
236 |
+
* @date 1/4/20
|
237 |
+
* @since 5.9.0
|
238 |
+
*
|
239 |
+
* @param array $post_states An array of post display states.
|
240 |
+
* @param WP_Post $post The current post object.
|
241 |
+
* @return array
|
242 |
+
*/
|
243 |
+
public function display_post_states( $post_states, $post ) {
|
244 |
+
if ( $post->post_status === 'acf-disabled' ) {
|
245 |
+
$post_states['acf-disabled'] = $this->get_disabled_post_state();
|
246 |
+
}
|
247 |
+
return $post_states;
|
|
|
248 |
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Customizes the admin table columns.
|
252 |
+
*
|
253 |
+
* @date 1/4/20
|
254 |
+
* @since 5.9.0
|
255 |
+
*
|
256 |
+
* @param array $columns The columns array.
|
257 |
+
* @return array
|
258 |
+
*/
|
259 |
+
public function admin_table_columns( $_columns ) {
|
260 |
+
$columns = array(
|
261 |
+
'cb' => $_columns['cb'],
|
262 |
+
'title' => $_columns['title'],
|
263 |
+
'acf-description' => __( 'Description', 'acf' ),
|
264 |
+
'acf-key' => __( 'Key', 'acf' ),
|
265 |
+
'acf-location' => __( 'Location', 'acf' ),
|
266 |
+
'acf-count' => __( 'Fields', 'acf' ),
|
267 |
+
);
|
268 |
+
if ( acf_get_local_json_files() ) {
|
269 |
+
$columns['acf-json'] = __( 'Local JSON', 'acf' );
|
270 |
+
}
|
271 |
+
return $columns;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Renders the admin table column HTML
|
276 |
+
*
|
277 |
+
* @date 1/4/20
|
278 |
+
* @since 5.9.0
|
279 |
+
*
|
280 |
+
* @param string $column_name The name of the column to display.
|
281 |
+
* @param int $post_id The current post ID.
|
282 |
+
* @return void
|
283 |
+
*/
|
284 |
+
public function admin_table_columns_html( $column_name, $post_id ) {
|
285 |
+
$field_group = acf_get_field_group( $post_id );
|
286 |
+
if ( $field_group ) {
|
287 |
+
$this->render_admin_table_column( $column_name, $field_group );
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Renders a specific admin table column.
|
293 |
+
*
|
294 |
+
* @date 17/4/20
|
295 |
+
* @since 5.9.0
|
296 |
+
*
|
297 |
+
* @param string $column_name The name of the column to display.
|
298 |
+
* @param array $field_group The field group.
|
299 |
+
* @return void
|
300 |
+
*/
|
301 |
+
public function render_admin_table_column( $column_name, $field_group ) {
|
302 |
+
switch ( $column_name ) {
|
303 |
+
|
304 |
+
// Key.
|
305 |
+
case 'acf-key':
|
306 |
+
echo esc_html( $field_group['key'] );
|
307 |
+
break;
|
308 |
+
|
309 |
+
// Description.
|
310 |
+
case 'acf-description':
|
311 |
+
if ( $field_group['description'] ) {
|
312 |
+
echo '<span class="acf-description">' . acf_esc_html( $field_group['description'] ) . '</span>';
|
313 |
}
|
314 |
+
break;
|
315 |
+
|
316 |
+
// Location.
|
317 |
+
case 'acf-location':
|
318 |
+
$this->render_admin_table_column_locations( $field_group );
|
319 |
+
break;
|
320 |
+
|
321 |
+
// Count.
|
322 |
+
case 'acf-count':
|
323 |
+
echo esc_html( acf_get_field_count( $field_group ) );
|
324 |
+
break;
|
325 |
+
|
326 |
+
// Local JSON.
|
327 |
+
case 'acf-json':
|
328 |
+
$this->render_admin_table_column_local_status( $field_group );
|
329 |
+
break;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Displays a visual representation of the field group's locations.
|
335 |
+
*
|
336 |
+
* @date 1/4/20
|
337 |
+
* @since 5.9.0
|
338 |
+
*
|
339 |
+
* @param array $field_group The field group.
|
340 |
+
* @return void
|
341 |
+
*/
|
342 |
+
public function render_admin_table_column_locations( $field_group ) {
|
343 |
+
$objects = array();
|
344 |
+
|
345 |
+
// Loop over location rules and determine connected object types.
|
346 |
+
if ( $field_group['location'] ) {
|
347 |
+
foreach ( $field_group['location'] as $i => $rules ) {
|
348 |
+
|
349 |
+
// Determine object types for each rule.
|
350 |
+
foreach ( $rules as $j => $rule ) {
|
351 |
+
|
352 |
+
// Get location type and subtype for the current rule.
|
353 |
+
$location = acf_get_location_rule( $rule['param'] );
|
354 |
+
$location_object_type = '';
|
355 |
+
$location_object_subtype = '';
|
356 |
+
if ( $location ) {
|
357 |
+
$location_object_type = $location->get_object_type( $rule );
|
358 |
+
$location_object_subtype = $location->get_object_subtype( $rule );
|
359 |
+
}
|
360 |
+
$rules[ $j ]['object_type'] = $location_object_type;
|
361 |
+
$rules[ $j ]['object_subtype'] = $location_object_subtype;
|
362 |
+
}
|
363 |
+
|
364 |
+
// Now that each $rule conains object type data...
|
365 |
+
$object_types = array_column( $rules, 'object_type' );
|
366 |
+
$object_types = array_filter( $object_types );
|
367 |
+
$object_types = array_values( $object_types );
|
368 |
+
if ( $object_types ) {
|
369 |
+
$object_type = $object_types[0];
|
370 |
+
} else {
|
371 |
+
continue;
|
372 |
+
}
|
373 |
+
|
374 |
+
$object_subtypes = array_column( $rules, 'object_subtype' );
|
375 |
+
$object_subtypes = array_filter( $object_subtypes );
|
376 |
$object_subtypes = array_values( $object_subtypes );
|
377 |
+
$object_subtypes = array_map( 'acf_array', $object_subtypes );
|
378 |
+
if ( count( $object_subtypes ) > 1 ) {
|
379 |
+
$object_subtypes = call_user_func_array( 'array_intersect', $object_subtypes );
|
380 |
+
$object_subtypes = array_values( $object_subtypes );
|
381 |
+
} elseif ( $object_subtypes ) {
|
382 |
+
$object_subtypes = $object_subtypes[0];
|
383 |
+
} else {
|
384 |
+
$object_subtypes = array( '' );
|
385 |
+
}
|
386 |
+
|
387 |
+
// Append to objects.
|
388 |
+
foreach ( $object_subtypes as $object_subtype ) {
|
389 |
+
$object = acf_get_object_type( $object_type, $object_subtype );
|
390 |
+
if ( $object ) {
|
391 |
+
$objects[ $object->name ] = $object;
|
392 |
+
}
|
393 |
}
|
394 |
}
|
395 |
}
|
396 |
+
|
397 |
+
// Reset keys.
|
398 |
+
$objects = array_values( $objects );
|
399 |
+
|
400 |
+
// Display.
|
401 |
+
$html = '';
|
402 |
+
if ( $objects ) {
|
403 |
+
$limit = 3;
|
404 |
+
$total = count( $objects );
|
405 |
+
|
406 |
+
// Icon.
|
407 |
+
$html .= '<span class="dashicons ' . $objects[0]->icon . ( $total > 1 ? ' acf-multi-dashicon' : '' ) . '"></span> ';
|
408 |
+
|
409 |
+
// Labels.
|
410 |
+
$labels = array_column( $objects, 'label' );
|
411 |
+
$labels = array_slice( $labels, 0, 3 );
|
412 |
+
$html .= implode( ', ', $labels );
|
413 |
+
|
414 |
+
// More.
|
415 |
+
if ( $total > $limit ) {
|
416 |
+
$html .= ', ...';
|
417 |
+
}
|
418 |
+
} else {
|
419 |
+
$html = '<span class="dashicons dashicons-businesswoman"></span> ' . __( 'Various', 'acf' );
|
420 |
}
|
421 |
+
|
422 |
+
// Filter.
|
423 |
+
echo acf_esc_html( $html );
|
424 |
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* Returns a human readable file location.
|
428 |
+
*
|
429 |
+
* @date 17/4/20
|
430 |
+
* @since 5.9.0
|
431 |
+
*
|
432 |
+
* @param string $file The full file path.
|
433 |
+
* @return string
|
434 |
+
*/
|
435 |
+
public function get_human_readable_file_location( $file ) {
|
436 |
+
|
437 |
+
// Generate friendly file path.
|
438 |
+
$theme_path = get_stylesheet_directory();
|
439 |
+
if ( strpos( $file, $theme_path ) !== false ) {
|
440 |
+
$rel_file = str_replace( $theme_path, '', $file );
|
441 |
+
$located = sprintf( __( 'Located in theme: %s', 'acf' ), $rel_file );
|
442 |
+
|
443 |
+
} elseif ( strpos( $file, WP_PLUGIN_DIR ) !== false ) {
|
444 |
+
$rel_file = str_replace( WP_PLUGIN_DIR, '', $file );
|
445 |
+
$located = sprintf( __( 'Located in plugin: %s', 'acf' ), $rel_file );
|
446 |
+
|
447 |
+
} else {
|
448 |
+
$rel_file = str_replace( ABSPATH, '', $file );
|
449 |
+
$located = sprintf( __( 'Located in: %s', 'acf' ), $rel_file );
|
450 |
+
}
|
451 |
+
return $located;
|
|
|
|
|
452 |
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Displays the local JSON status of a field group.
|
456 |
+
*
|
457 |
+
* @date 14/4/20
|
458 |
+
* @since 5.9.0
|
459 |
+
*
|
460 |
+
* @param type $var Description. Default.
|
461 |
+
* @return type Description.
|
462 |
+
*/
|
463 |
+
public function render_admin_table_column_local_status( $field_group ) {
|
464 |
+
$json = acf_get_local_json_files();
|
465 |
+
if ( isset( $json[ $field_group['key'] ] ) ) {
|
466 |
+
$file = $json[ $field_group['key'] ];
|
467 |
+
if ( isset( $this->sync[ $field_group['key'] ] ) ) {
|
468 |
+
$url = $this->get_admin_url( '&acfsync=' . $field_group['key'] . '&_wpnonce=' . wp_create_nonce( 'bulk-posts' ) );
|
469 |
+
echo '<strong>' . __( 'Sync available', 'acf' ) . '</strong>';
|
470 |
+
if ( $field_group['ID'] ) {
|
471 |
+
echo '<div class="row-actions">
|
|
|
|
|
472 |
<span class="sync"><a href="' . esc_url( $url ) . '">' . __( 'Sync', 'acf' ) . '</a> | </span>
|
473 |
+
<span class="review"><a href="#" data-event="review-sync" data-id="' . esc_attr( $field_group['ID'] ) . '" data-href="' . esc_url( $url ) . '">' . __( 'Review changes', 'acf' ) . '</a></span>
|
474 |
</div>';
|
475 |
+
} else {
|
476 |
+
echo '<div class="row-actions">
|
477 |
<span class="sync"><a href="' . esc_url( $url ) . '">' . __( 'Import', 'acf' ) . '</a></span>
|
478 |
</div>';
|
479 |
+
}
|
480 |
+
} else {
|
481 |
+
echo __( 'Saved', 'acf' );
|
482 |
}
|
483 |
} else {
|
484 |
+
echo '<span class="acf-secondary-text">' . __( 'Awaiting save', 'acf' ) . '</span>';
|
485 |
}
|
|
|
|
|
486 |
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Customizes the page row actions visible on hover.
|
490 |
+
*
|
491 |
+
* @date 14/4/20
|
492 |
+
* @since 5.9.0
|
493 |
+
*
|
494 |
+
* @param array $actions The array of actions HTML.
|
495 |
+
* @param WP_Post $post The post.
|
496 |
+
* @return array
|
497 |
+
*/
|
498 |
+
public function page_row_actions( $actions, $post ) {
|
499 |
+
|
500 |
+
// Remove "Quick Edit" action.
|
501 |
+
unset( $actions['inline'], $actions['inline hide-if-no-js'] );
|
502 |
+
|
503 |
+
// Append "Duplicate" action.
|
504 |
+
$duplicate_action_url = $this->get_admin_url( '&acfduplicate=' . $post->ID . '&_wpnonce=' . wp_create_nonce( 'bulk-posts' ) );
|
505 |
+
$actions['acfduplicate'] = '<a href="' . esc_url( $duplicate_action_url ) . '" aria-label="' . esc_attr__( 'Duplicate this item', 'acf' ) . '">' . __( 'Duplicate', 'acf' ) . '</a>';
|
506 |
+
|
507 |
+
// Return actions in custom order.
|
508 |
+
$order = array( 'edit', 'acfduplicate', 'trash' );
|
509 |
+
return array_merge( array_flip( $order ), $actions );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Modifies the admin table bulk actions dropdown.
|
514 |
+
*
|
515 |
+
* @date 15/4/20
|
516 |
+
* @since 5.9.0
|
517 |
+
*
|
518 |
+
* @param array $actions The actions array.
|
519 |
+
* @return array
|
520 |
+
*/
|
521 |
+
public function admin_table_bulk_actions( $actions ) {
|
522 |
+
|
523 |
+
// Add "duplicate" action.
|
524 |
+
if ( $this->view !== 'sync' ) {
|
525 |
+
$actions['acfduplicate'] = __( 'Duplicate', 'acf' );
|
526 |
}
|
527 |
+
|
528 |
+
// Add "Sync" action.
|
529 |
+
if ( $this->sync ) {
|
530 |
+
if ( $this->view === 'sync' ) {
|
531 |
+
$actions = array();
|
532 |
+
}
|
533 |
+
$actions['acfsync'] = __( 'Sync changes', 'acf' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
}
|
535 |
+
return $actions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Checks for the custom "duplicate" action.
|
540 |
+
*
|
541 |
+
* @date 15/4/20
|
542 |
+
* @since 5.9.0
|
543 |
+
*
|
544 |
+
* @param void
|
545 |
+
* @return void
|
546 |
+
*/
|
547 |
+
public function check_duplicate() {
|
548 |
+
|
549 |
+
// Display notice on success redirect.
|
550 |
+
if ( isset( $_GET['acfduplicatecomplete'] ) ) {
|
551 |
+
$ids = array_map( 'intval', explode( ',', $_GET['acfduplicatecomplete'] ) );
|
552 |
+
|
553 |
+
// Generate text.
|
554 |
+
$text = sprintf(
|
555 |
+
_n( 'Field group duplicated.', '%s field groups duplicated.', count( $ids ), 'acf' ),
|
556 |
+
count( $ids )
|
557 |
+
);
|
558 |
+
|
559 |
+
// Append links to text.
|
560 |
+
$links = array();
|
561 |
+
foreach ( $ids as $id ) {
|
562 |
+
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
563 |
+
}
|
564 |
+
$text .= ' ' . implode( ', ', $links );
|
565 |
+
|
566 |
+
// Add notice.
|
567 |
+
acf_add_admin_notice( $text, 'success' );
|
568 |
+
return;
|
569 |
}
|
570 |
+
|
571 |
+
// Find items to duplicate.
|
572 |
+
$ids = array();
|
573 |
+
if ( isset( $_GET['acfduplicate'] ) ) {
|
574 |
+
$ids[] = intval( $_GET['acfduplicate'] );
|
575 |
+
} elseif ( isset( $_GET['post'], $_GET['action2'] ) && $_GET['action2'] === 'acfduplicate' ) {
|
576 |
+
$ids = array_map( 'intval', $_GET['post'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
+
|
579 |
+
if ( $ids ) {
|
580 |
+
check_admin_referer( 'bulk-posts' );
|
581 |
+
|
582 |
+
// Duplicate field groups and generate array of new IDs.
|
583 |
+
$new_ids = array();
|
584 |
+
foreach ( $ids as $id ) {
|
585 |
+
$field_group = acf_duplicate_field_group( $id );
|
586 |
+
$new_ids[] = $field_group['ID'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
}
|
588 |
+
|
589 |
+
// Redirect.
|
590 |
+
wp_redirect( $this->get_admin_url( '&acfduplicatecomplete=' . implode( ',', $new_ids ) ) );
|
591 |
+
exit;
|
592 |
}
|
|
|
|
|
|
|
|
|
593 |
}
|
594 |
+
|
595 |
+
/**
|
596 |
+
* Checks for the custom "acfsync" action.
|
597 |
+
*
|
598 |
+
* @date 15/4/20
|
599 |
+
* @since 5.9.0
|
600 |
+
*
|
601 |
+
* @param void
|
602 |
+
* @return void
|
603 |
+
*/
|
604 |
+
public function check_sync() {
|
605 |
+
|
606 |
+
// Display notice on success redirect.
|
607 |
+
if ( isset( $_GET['acfsynccomplete'] ) ) {
|
608 |
+
$ids = array_map( 'intval', explode( ',', $_GET['acfsynccomplete'] ) );
|
609 |
+
|
610 |
+
// Generate text.
|
611 |
+
$text = sprintf(
|
612 |
+
_n( 'Field group synchronised.', '%s field groups synchronised.', count( $ids ), 'acf' ),
|
613 |
+
count( $ids )
|
614 |
+
);
|
615 |
+
|
616 |
+
// Append links to text.
|
617 |
+
$links = array();
|
618 |
+
foreach ( $ids as $id ) {
|
619 |
+
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
620 |
+
}
|
621 |
+
$text .= ' ' . implode( ', ', $links );
|
622 |
+
|
623 |
+
// Add notice.
|
624 |
+
acf_add_admin_notice( $text, 'success' );
|
625 |
+
return;
|
626 |
+
}
|
627 |
+
|
628 |
+
// Find items to sync.
|
629 |
+
$keys = array();
|
630 |
+
if ( isset( $_GET['acfsync'] ) ) {
|
631 |
+
$keys[] = sanitize_text_field( $_GET['acfsync'] );
|
632 |
+
} elseif ( isset( $_GET['post'], $_GET['action2'] ) && $_GET['action2'] === 'acfsync' ) {
|
633 |
+
$keys = array_map( 'sanitize_text_field', $_GET['post'] );
|
634 |
+
}
|
635 |
+
|
636 |
+
if ( $keys && $this->sync ) {
|
637 |
+
check_admin_referer( 'bulk-posts' );
|
638 |
+
|
639 |
+
// Disabled "Local JSON" controller to prevent the .json file from being modified during import.
|
640 |
+
acf_update_setting( 'json', false );
|
641 |
+
|
642 |
+
// Sync field groups and generate array of new IDs.
|
643 |
+
$files = acf_get_local_json_files();
|
644 |
+
$new_ids = array();
|
645 |
+
foreach ( $this->sync as $key => $field_group ) {
|
646 |
+
if ( $field_group['key'] && in_array( $field_group['key'], $keys ) ) {
|
647 |
+
// Import.
|
648 |
+
} elseif ( $field_group['ID'] && in_array( $field_group['ID'], $keys ) ) {
|
649 |
+
// Import.
|
650 |
+
} else {
|
651 |
+
// Ignore.
|
652 |
+
continue;
|
653 |
+
}
|
654 |
+
$local_field_group = json_decode( file_get_contents( $files[ $key ] ), true );
|
655 |
+
$local_field_group['ID'] = $field_group['ID'];
|
656 |
+
$result = acf_import_field_group( $local_field_group );
|
657 |
+
$new_ids[] = $result['ID'];
|
658 |
+
}
|
659 |
+
|
660 |
+
// Redirect.
|
661 |
+
wp_redirect( $this->get_current_admin_url( '&acfsynccomplete=' . implode( ',', $new_ids ) ) );
|
662 |
+
exit;
|
663 |
+
}
|
664 |
}
|
665 |
+
|
666 |
+
/**
|
667 |
+
* Customizes the admin table subnav.
|
668 |
+
*
|
669 |
+
* @date 17/4/20
|
670 |
+
* @since 5.9.0
|
671 |
+
*
|
672 |
+
* @param array $views The available views.
|
673 |
+
* @return array
|
674 |
+
*/
|
675 |
+
public function admin_table_views( $views ) {
|
676 |
+
global $wp_list_table, $wp_query;
|
677 |
+
|
678 |
+
// Count items.
|
679 |
+
$count = count( $this->sync );
|
680 |
+
|
681 |
+
// Append "sync" link to subnav.
|
682 |
+
if ( $count ) {
|
683 |
+
$views['sync'] = sprintf(
|
684 |
+
'<a %s href="%s">%s <span class="count">(%s)</span></a>',
|
685 |
+
( $this->view === 'sync' ? 'class="current"' : '' ),
|
686 |
+
esc_url( $this->get_admin_url( '&post_status=sync' ) ),
|
687 |
+
esc_html( __( 'Sync available', 'acf' ) ),
|
688 |
+
$count
|
689 |
+
);
|
690 |
+
}
|
691 |
+
|
692 |
+
// Modify table pagination args to match JSON data.
|
693 |
+
if ( $this->view === 'sync' ) {
|
694 |
+
$wp_list_table->set_pagination_args(
|
695 |
+
array(
|
696 |
+
'total_items' => $count,
|
697 |
+
'total_pages' => 1,
|
698 |
+
'per_page' => $count,
|
699 |
+
)
|
700 |
+
);
|
701 |
+
$wp_query->post_count = 1; // At least one post is needed to render bulk drop-down.
|
702 |
+
}
|
703 |
+
return $views;
|
704 |
}
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Prints scripts into the admin footer.
|
708 |
+
*
|
709 |
+
* @date 20/4/20
|
710 |
+
* @since 5.9.0
|
711 |
+
*
|
712 |
+
* @param void
|
713 |
+
* @return void
|
714 |
+
*/
|
715 |
+
function admin_footer() {
|
716 |
+
?>
|
|
|
|
|
717 |
<script type="text/javascript">
|
718 |
(function($){
|
719 |
|
753 |
});
|
754 |
})(jQuery);
|
755 |
</script>
|
756 |
+
<?php
|
757 |
+
}
|
758 |
+
|
759 |
+
/**
|
760 |
+
* Customizes the admin table HTML when viewing "sync" post_status.
|
761 |
+
*
|
762 |
+
* @date 17/4/20
|
763 |
+
* @since 5.9.0
|
764 |
+
*
|
765 |
+
* @param array $views The available views.
|
766 |
+
* @return array
|
767 |
+
*/
|
768 |
+
public function admin_footer__sync() {
|
769 |
+
global $wp_list_table;
|
770 |
+
|
771 |
+
// Get table columns.
|
772 |
+
$columns = $wp_list_table->get_columns();
|
773 |
+
$hidden = get_hidden_columns( $wp_list_table->screen );
|
774 |
+
?>
|
775 |
<div style="display: none;">
|
776 |
<table>
|
777 |
<tbody id="acf-the-list">
|
778 |
+
<?php
|
779 |
+
foreach ( $this->sync as $k => $field_group ) {
|
780 |
+
echo '<tr>';
|
781 |
+
foreach ( $columns as $column_name => $column_label ) {
|
782 |
+
$el = 'td';
|
783 |
+
if ( $column_name === 'cb' ) {
|
784 |
+
$el = 'th';
|
785 |
+
$classes = 'check-column';
|
786 |
+
$column_label = '';
|
787 |
+
} elseif ( $column_name === 'title' ) {
|
788 |
+
$classes = "$column_name column-$column_name column-primary";
|
789 |
+
} else {
|
790 |
+
$classes = "$column_name column-$column_name";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
791 |
}
|
792 |
+
if ( in_array( $column_name, $hidden, true ) ) {
|
793 |
+
$classes .= ' hidden';
|
794 |
+
}
|
795 |
+
echo "<$el class=\"$classes\" data-colname=\"$column_label\">";
|
796 |
+
switch ( $column_name ) {
|
797 |
+
|
798 |
+
// Checkbox.
|
799 |
+
case 'cb':
|
800 |
+
echo '<label for="cb-select-' . esc_attr( $k ) . '" class="screen-reader-text">' . esc_html( sprintf( __( 'Select %s', 'acf' ), $field_group['title'] ) ) . '</label>';
|
801 |
+
echo '<input id="cb-select-' . esc_attr( $k ) . '" type="checkbox" value="' . esc_attr( $k ) . '" name="post[]">';
|
802 |
+
break;
|
803 |
+
|
804 |
+
// Title.
|
805 |
+
case 'title':
|
806 |
+
$post_state = '';
|
807 |
+
if ( ! $field_group['active'] ) {
|
808 |
+
$post_state = ' — <span class="post-state">' . $this->get_disabled_post_state() . '</span>';
|
809 |
+
}
|
810 |
+
echo '<strong><span class="row-title">' . esc_html( $field_group['title'] ) . '</span>' . $post_state . '</strong>';
|
811 |
+
echo '<div class="row-actions"><span class="file acf-secondary-text">' . $this->get_human_readable_file_location( $field_group['local_file'] ) . '</span></div>';
|
812 |
+
echo '<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
813 |
+
break;
|
814 |
+
|
815 |
+
// All other columns.
|
816 |
+
default:
|
817 |
+
$this->render_admin_table_column( $column_name, $field_group );
|
818 |
+
break;
|
819 |
+
}
|
820 |
+
echo "</$el>";
|
821 |
+
}
|
822 |
+
echo '</tr>';
|
823 |
}
|
824 |
+
?>
|
|
|
|
|
|
|
|
|
825 |
</tbody>
|
826 |
</table>
|
827 |
</div>
|
830 |
$('#the-list').html( $('#acf-the-list').children() );
|
831 |
})(jQuery);
|
832 |
</script>
|
833 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
834 |
}
|
835 |
+
|
836 |
+
/**
|
837 |
+
* Fires when trashing a field group post.
|
838 |
+
*
|
839 |
+
* @date 8/01/2014
|
840 |
+
* @since 5.0.0
|
841 |
+
*
|
842 |
+
* @param int $post_id The post ID.
|
843 |
+
* @return void
|
844 |
+
*/
|
845 |
+
public function trashed_post( $post_id ) {
|
846 |
+
if ( get_post_type( $post_id ) === 'acf-field-group' ) {
|
847 |
+
acf_trash_field_group( $post_id );
|
848 |
+
}
|
849 |
}
|
850 |
+
|
851 |
+
/**
|
852 |
+
* Fires when untrashing a field group post.
|
853 |
+
*
|
854 |
+
* @date 8/01/2014
|
855 |
+
* @since 5.0.0
|
856 |
+
*
|
857 |
+
* @param int $post_id The post ID.
|
858 |
+
* @return void
|
859 |
+
*/
|
860 |
+
public function untrashed_post( $post_id ) {
|
861 |
+
if ( get_post_type( $post_id ) === 'acf-field-group' ) {
|
862 |
+
acf_untrash_field_group( $post_id );
|
863 |
+
}
|
864 |
}
|
|
|
|
|
865 |
|
866 |
+
/**
|
867 |
+
* Fires when deleting a field group post.
|
868 |
+
*
|
869 |
+
* @date 8/01/2014
|
870 |
+
* @since 5.0.0
|
871 |
+
*
|
872 |
+
* @param int $post_id The post ID.
|
873 |
+
* @return void
|
874 |
+
*/
|
875 |
+
public function
|