PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / trunk
Secure Custom Fields vtrunk
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / assets / src / js / _acf-field-select.js
secure-custom-fields / assets / src / js Last commit date
bindings 6 months ago commands 3 weeks ago pro 3 weeks ago _acf-compatibility.js 1 year ago _acf-condition-types.js 8 months ago _acf-condition.js 1 year ago _acf-conditions.js 1 year ago _acf-field-accordion.js 6 months ago _acf-field-button-group.js 8 months ago _acf-field-checkbox.js 1 month ago _acf-field-color-picker.js 8 months ago _acf-field-date-picker.js 1 month ago _acf-field-date-time-picker.js 1 month ago _acf-field-file.js 1 month ago _acf-field-google-map.js 6 months ago _acf-field-icon-picker.js 1 month ago _acf-field-image.js 1 month ago _acf-field-link.js 1 year ago _acf-field-oembed.js 1 month ago _acf-field-page-link.js 1 year ago _acf-field-post-object.js 1 year ago _acf-field-radio.js 1 month ago _acf-field-range.js 1 year ago _acf-field-relationship.js 1 month ago _acf-field-select.js 1 month ago _acf-field-tab.js 1 month ago _acf-field-taxonomy.js 8 months ago _acf-field-time-picker.js 1 month ago _acf-field-true-false.js 1 month ago _acf-field-url.js 1 year ago _acf-field-user.js 1 year ago _acf-field-wysiwyg.js 1 month ago _acf-field.js 1 year ago _acf-fields.js 1 year ago _acf-helpers.js 1 year ago _acf-hooks.js 1 year ago _acf-internal-post-type.js 8 months ago _acf-media.js 3 weeks ago _acf-modal.js 1 year ago _acf-model.js 1 year ago _acf-notice.js 8 months ago _acf-panel.js 1 year ago _acf-popup.js 8 months ago _acf-postbox.js 1 year ago _acf-screen.js 10 months ago _acf-select2.js 1 year ago _acf-tinymce.js 6 months ago _acf-tooltip.js 10 months ago _acf-unload.js 1 year ago _acf-validation.js 1 month ago _acf.js 7 months ago _browse-fields-modal.js 8 months ago _field-group-compatibility.js 1 year ago _field-group-conditions.js 1 year ago _field-group-field.js 4 months ago _field-group-fields.js 10 months ago _field-group-locations.js 1 year ago _field-group-settings.js 1 year ago _field-group.js 10 months ago acf-escaped-html-notice.js 1 year ago acf-field-group.js 1 year ago acf-input.js 1 year ago acf-internal-post-type.js 1 year ago acf.js 1 year ago
_acf-field-select.js
73 lines
1 ( function ( $, undefined ) {
2 var Field = acf.Field.extend( {
3 type: 'select',
4
5 select2: false,
6
7 wait: 'load',
8
9 events: {
10 removeField: 'onRemove',
11 duplicateField: 'onDuplicate',
12 },
13
14 $input: function () {
15 return this.$( 'select' );
16 },
17
18 setValue: function ( val ) {
19 const $input = this.$input();
20 $input.val( val );
21
22 if ( this.select2 ) {
23 $input.trigger( 'change' );
24 }
25 },
26
27 initialize: function () {
28 // vars
29 var $select = this.$input();
30
31 // inherit data
32 this.inherit( $select );
33
34 // select2
35 if ( this.get( 'ui' ) ) {
36 // populate ajax_data (allowing custom attribute to already exist)
37 var ajaxAction = this.get( 'ajax_action' );
38 if ( ! ajaxAction ) {
39 ajaxAction = 'acf/fields/' + this.get( 'type' ) + '/query';
40 }
41
42 // select2
43 this.select2 = acf.newSelect2( $select, {
44 field: this,
45 ajax: this.get( 'ajax' ),
46 multiple: this.get( 'multiple' ),
47 placeholder: this.get( 'placeholder' ),
48 allowNull: this.get( 'allow_null' ),
49 tags: this.get( 'create_options' ),
50 ajaxAction: ajaxAction,
51 } );
52 }
53 },
54
55 onRemove: function () {
56 if ( this.select2 ) {
57 this.select2.destroy();
58 }
59 },
60
61 onDuplicate: function ( e, $el, $duplicate ) {
62 if ( this.select2 ) {
63 $duplicate.find( '.select2-container' ).remove();
64 $duplicate
65 .find( 'select' )
66 .removeClass( 'select2-hidden-accessible' );
67 }
68 },
69 } );
70
71 acf.registerFieldType( Field );
72 } )( jQuery );
73