2024-07-12 12:58:34 +02:00
|
|
|
import BaseCondition from './BaseCondition';
|
|
|
|
import { inputValue } from '../../../helper/form';
|
2023-09-15 17:32:00 +01:00
|
|
|
|
|
|
|
class ElementCondition extends BaseCondition {
|
2024-07-12 12:58:34 +02:00
|
|
|
register() {
|
|
|
|
jQuery( document ).on( 'change', this.config.selector, () => {
|
|
|
|
const status = this.check();
|
|
|
|
if ( status !== this.status ) {
|
|
|
|
this.status = status;
|
|
|
|
this.triggerUpdate();
|
|
|
|
}
|
|
|
|
} );
|
2023-09-15 17:32:00 +01:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
this.status = this.check();
|
|
|
|
}
|
2023-09-15 17:32:00 +01:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
check() {
|
|
|
|
let value = inputValue( this.config.selector );
|
|
|
|
value = value !== null ? value.toString() : value;
|
2023-09-15 17:32:00 +01:00
|
|
|
|
2024-07-12 12:58:34 +02:00
|
|
|
return this.config.value === value;
|
|
|
|
}
|
2023-09-15 17:32:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ElementCondition;
|