PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.2
Secure Custom Fields v6.4.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-true-false.js
secure-custom-fields / assets / src / js Last commit date
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-true-false.js
89 lines
1 ( function ( $, undefined ) {
2 var Field = acf.Field.extend( {
3 type: 'true_false',
4
5 events: {
6 'change .acf-switch-input': 'onChange',
7 'focus .acf-switch-input': 'onFocus',
8 'blur .acf-switch-input': 'onBlur',
9 'keypress .acf-switch-input': 'onKeypress',
10 },
11
12 $input: function () {
13 return this.$( 'input[type="checkbox"]' );
14 },
15
16 $switch: function () {
17 return this.$( '.acf-switch' );
18 },
19
20 getValue: function () {
21 return this.$input().prop( 'checked' ) ? 1 : 0;
22 },
23
24 initialize: function () {
25 this.render();
26 },
27
28 render: function () {
29 // vars
30 var $switch = this.$switch();
31
32 // bail early if no $switch
33 if ( ! $switch.length ) return;
34
35 // vars
36 var $on = $switch.children( '.acf-switch-on' );
37 var $off = $switch.children( '.acf-switch-off' );
38 var width = Math.max( $on.width(), $off.width() );
39
40 // bail early if no width
41 if ( ! width ) return;
42
43 // set widths
44 $on.css( 'min-width', width );
45 $off.css( 'min-width', width );
46 },
47
48 switchOn: function () {
49 this.$input().prop( 'checked', true );
50 this.$switch().addClass( '-on' );
51 },
52
53 switchOff: function () {
54 this.$input().prop( 'checked', false );
55 this.$switch().removeClass( '-on' );
56 },
57
58 onChange: function ( e, $el ) {
59 if ( $el.prop( 'checked' ) ) {
60 this.switchOn();
61 } else {
62 this.switchOff();
63 }
64 },
65
66 onFocus: function ( e, $el ) {
67 this.$switch().addClass( '-focus' );
68 },
69
70 onBlur: function ( e, $el ) {
71 this.$switch().removeClass( '-focus' );
72 },
73
74 onKeypress: function ( e, $el ) {
75 // left
76 if ( e.keyCode === 37 ) {
77 return this.switchOff();
78 }
79
80 // right
81 if ( e.keyCode === 39 ) {
82 return this.switchOn();
83 }
84 },
85 } );
86
87 acf.registerFieldType( Field );
88 } )( jQuery );
89