PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.5.4
Secure Custom Fields v6.5.4
6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / assets / src / js / _acf-field-date-picker.js
secure-custom-fields / assets / src / js Last commit date
bindings 1 year ago commands 1 year ago pro 1 year ago _acf-compatibility.js 1 year ago _acf-condition-types.js 1 year ago _acf-condition.js 1 year ago _acf-conditions.js 1 year ago _acf-field-accordion.js 1 year ago _acf-field-button-group.js 1 year ago _acf-field-checkbox.js 1 year ago _acf-field-color-picker.js 1 year ago _acf-field-date-picker.js 1 year ago _acf-field-date-time-picker.js 1 year ago _acf-field-file.js 1 year ago _acf-field-google-map.js 1 year ago _acf-field-icon-picker.js 1 year ago _acf-field-image.js 1 year ago _acf-field-link.js 1 year ago _acf-field-oembed.js 1 year ago _acf-field-page-link.js 1 year ago _acf-field-post-object.js 1 year ago _acf-field-radio.js 1 year ago _acf-field-range.js 1 year ago _acf-field-relationship.js 1 year ago _acf-field-select.js 1 year ago _acf-field-tab.js 1 year ago _acf-field-taxonomy.js 1 year ago _acf-field-time-picker.js 1 year ago _acf-field-true-false.js 1 year ago _acf-field-url.js 1 year ago _acf-field-user.js 1 year ago _acf-field-wysiwyg.js 1 year 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 1 year ago _acf-media.js 1 year ago _acf-modal.js 1 year ago _acf-model.js 1 year ago _acf-notice.js 1 year ago _acf-panel.js 1 year ago _acf-popup.js 1 year ago _acf-postbox.js 1 year ago _acf-screen.js 1 year ago _acf-select2.js 1 year ago _acf-tinymce.js 1 year ago _acf-tooltip.js 1 year ago _acf-unload.js 1 year ago _acf-validation.js 1 year ago _acf.js 1 year ago _browse-fields-modal.js 1 year ago _field-group-compatibility.js 1 year ago _field-group-conditions.js 1 year ago _field-group-field.js 1 year ago _field-group-fields.js 1 year ago _field-group-locations.js 1 year ago _field-group-settings.js 1 year ago _field-group.js 1 year 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-date-picker.js
159 lines
1 ( function ( $, undefined ) {
2 var Field = acf.Field.extend( {
3 type: 'date_picker',
4
5 events: {
6 'blur input[type="text"]': 'onBlur',
7 duplicateField: 'onDuplicate',
8 },
9
10 $control: function () {
11 return this.$( '.acf-date-picker' );
12 },
13
14 $input: function () {
15 return this.$( 'input[type="hidden"]' );
16 },
17
18 $inputText: function () {
19 return this.$( 'input[type="text"]' );
20 },
21
22 initialize: function () {
23 // save_format: compatibility with ACF < 5.0.0
24 if ( this.has( 'save_format' ) ) {
25 return this.initializeCompatibility();
26 }
27
28 // vars
29 var $input = this.$input();
30 var $inputText = this.$inputText();
31
32 // args
33 var args = {
34 dateFormat: this.get( 'date_format' ),
35 altField: $input,
36 altFormat: 'yymmdd',
37 changeYear: true,
38 yearRange: '-100:+100',
39 changeMonth: true,
40 showButtonPanel: true,
41 firstDay: this.get( 'first_day' ),
42 };
43
44 // filter
45 args = acf.applyFilters( 'date_picker_args', args, this );
46
47 // add date picker
48 acf.newDatePicker( $inputText, args );
49
50 // action
51 acf.doAction( 'date_picker_init', $inputText, args, this );
52 },
53
54 initializeCompatibility: function () {
55 // vars
56 var $input = this.$input();
57 var $inputText = this.$inputText();
58
59 // get and set value from alt field
60 $inputText.val( $input.val() );
61
62 // args
63 var args = {
64 dateFormat: this.get( 'date_format' ),
65 altField: $input,
66 altFormat: this.get( 'save_format' ),
67 changeYear: true,
68 yearRange: '-100:+100',
69 changeMonth: true,
70 showButtonPanel: true,
71 firstDay: this.get( 'first_day' ),
72 };
73
74 // filter for 3rd party customization
75 args = acf.applyFilters( 'date_picker_args', args, this );
76
77 // backup
78 var dateFormat = args.dateFormat;
79
80 // change args.dateFormat
81 args.dateFormat = this.get( 'save_format' );
82
83 // add date picker
84 acf.newDatePicker( $inputText, args );
85
86 // now change the format back to how it should be.
87 $inputText.datepicker( 'option', 'dateFormat', dateFormat );
88
89 // action for 3rd party customization
90 acf.doAction( 'date_picker_init', $inputText, args, this );
91 },
92
93 onBlur: function () {
94 if ( ! this.$inputText().val() ) {
95 acf.val( this.$input(), '' );
96 }
97 },
98
99 onDuplicate: function ( e, $el, $duplicate ) {
100 $duplicate
101 .find( 'input[type="text"]' )
102 .removeClass( 'hasDatepicker' )
103 .removeAttr( 'id' );
104 },
105 } );
106
107 acf.registerFieldType( Field );
108
109 // manager
110 var datePickerManager = new acf.Model( {
111 priority: 5,
112 wait: 'ready',
113 initialize: function () {
114 // vars
115 var locale = acf.get( 'locale' );
116 var rtl = acf.get( 'rtl' );
117 var l10n = acf.get( 'datePickerL10n' );
118
119 // bail early if no l10n
120 if ( ! l10n ) {
121 return false;
122 }
123
124 // bail early if no datepicker library
125 if ( typeof $.datepicker === 'undefined' ) {
126 return false;
127 }
128
129 // rtl
130 l10n.isRTL = rtl;
131
132 // append
133 $.datepicker.regional[ locale ] = l10n;
134 $.datepicker.setDefaults( l10n );
135 },
136 } );
137
138 // add
139 acf.newDatePicker = function ( $input, args ) {
140 // bail early if no datepicker library
141 if ( typeof $.datepicker === 'undefined' ) {
142 return false;
143 }
144
145 // defaults
146 args = args || {};
147
148 // initialize
149 $input.datepicker( args );
150
151 // wrap the datepicker (only if it hasn't already been wrapped)
152 if ( $( 'body > #ui-datepicker-div' ).exists() ) {
153 $( 'body > #ui-datepicker-div' ).wrap(
154 '<div class="acf-ui-datepicker" />'
155 );
156 }
157 };
158 } )( jQuery );
159