PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / src / frontend / main / inputs / RadioData.js
jetformbuilder / assets / src / frontend / main / inputs Last commit date
ChangeData.js 2 years ago CheckboxData.js 2 years ago InputData.js 2 years ago InputMaskedData.js 2 years ago MultiSelectData.js 2 years ago NoListenData.js 2 years ago RadioData.js 2 years ago RangeData.js 2 years ago RenderStateData.js 2 years ago WysiwygData.js 2 years ago functions.js 2 years ago
RadioData.js
75 lines
1 import InputData from './InputData';
2 import ReactiveHook from '../reactive/ReactiveHook';
3 import { STRICT_MODE } from '../signals/BaseSignal';
4 import { getParsedName } from './functions';
5
6 function RadioData() {
7 InputData.call( this );
8
9 this.wrapper = null;
10
11 this.isSupported = function ( node ) {
12 return (
13 node.classList.contains( 'checkradio-wrap' ) &&
14 node.querySelector( '.radio-wrap' )
15 );
16 };
17 this.addListeners = function () {
18 this.enterKey = new ReactiveHook();
19
20 this.wrapper.addEventListener( 'change', () => this.setValue() );
21 this.wrapper.addEventListener(
22 'keydown',
23 this.handleEnterKey.bind( this ),
24 );
25 this.wrapper.addEventListener( 'focusout', event => {
26 if ( [ ...this.nodes ].includes( event?.relatedTarget ) ) {
27 return;
28 }
29 this.reportOnBlur();
30 } );
31
32 !STRICT_MODE && jQuery( this.wrapper ).on( 'change', event => {
33 if ( this.value.current == event.target.value ) {
34 return;
35 }
36 this.callable.lockTrigger();
37 this.setValue();
38 this.callable.unlockTrigger();
39 } );
40 };
41 this.setValue = function () {
42 this.value.current = this.getActiveValue();
43 };
44 this.getActiveValue = function () {
45 for ( const node of this.nodes ) {
46 if ( node.checked ) {
47 return node.value;
48 }
49 }
50
51 return '';
52 };
53
54 this.setNode = function ( node ) {
55 node.jfbSync = this;
56 /**
57 * It should be live collection for the case when items may change
58 */
59 this.nodes = node.getElementsByClassName(
60 'jet-form-builder__field radio-field' );
61
62 this.rawName = this.nodes[ 0 ].name;
63 this.name = getParsedName( this.rawName );
64 this.inputType = 'radio';
65
66 /**
67 * @type {HTMLElement|HTMLInputElement}
68 */
69 this.wrapper = node;
70 };
71 }
72
73 RadioData.prototype = Object.create( InputData.prototype );
74
75 export default RadioData;