BaseSignal.js
2 years ago
SignalCheckbox.js
2 years ago
SignalHiddenArray.js
2 years ago
SignalRadio.js
2 years ago
SignalRange.js
2 years ago
SignalRenderState.js
2 years ago
SignalSelect.js
2 years ago
SignalText.js
2 years ago
SignalWysiwyg.js
2 years ago
functions.js
2 years ago
SignalSelect.js
36 lines
| 1 | import BaseSignal from './BaseSignal'; |
| 2 | import { isSelect } from '../supports'; |
| 3 | |
| 4 | function SignalSelect() { |
| 5 | BaseSignal.call( this ); |
| 6 | |
| 7 | this.isSupported = function ( node, inputData ) { |
| 8 | return isSelect( node ); |
| 9 | }; |
| 10 | this.runSignal = function () { |
| 11 | this.input.calcValue = 0; |
| 12 | const [ node ] = this.input.nodes; |
| 13 | const isMultiple = 'select-one' !== node?.type; |
| 14 | const { value } = this.input; |
| 15 | |
| 16 | for ( const option of node.options ) { |
| 17 | option.selected = isMultiple |
| 18 | ? value.current?.includes( option.value ) |
| 19 | : option.value === value.current; |
| 20 | |
| 21 | if ( !option.selected ) { |
| 22 | continue; |
| 23 | } |
| 24 | |
| 25 | this.input.calcValue += parseFloat( |
| 26 | option.dataset?.calculate ?? option.value, |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | this.triggerJQuery( node ); |
| 31 | }; |
| 32 | } |
| 33 | |
| 34 | SignalSelect.prototype = Object.create( BaseSignal.prototype ); |
| 35 | |
| 36 | export default SignalSelect; |