woocommerce-paypal-payments/modules/ppcp-axo/resources/js/Components/DomElement.js

42 lines
904 B
JavaScript
Raw Normal View History

2024-03-08 17:41:21 +00:00
import {setVisible} from "../../../../ppcp-button/resources/js/modules/Helper/Hiding";
2024-03-08 14:39:50 +00:00
class DomElement {
constructor(config) {
2024-03-08 17:41:21 +00:00
this.$ = jQuery;
2024-03-08 14:39:50 +00:00
this.config = config;
this.selector = this.config.selector;
2024-03-08 17:41:21 +00:00
this.id = this.config.id || null;
this.className = this.config.className || null;
2024-03-12 09:23:42 +00:00
this.attributes = this.config.attributes || null;
2024-03-08 17:41:21 +00:00
this.anchorSelector = this.config.anchorSelector || null;
2024-03-08 14:39:50 +00:00
}
2024-03-08 17:41:21 +00:00
trigger(action) {
this.$(this.selector).trigger(action);
}
on(action, callable) {
this.$(document).on(action, this.selector, callable);
}
2024-03-12 09:23:42 +00:00
hide() {
this.$(this.selector).hide();
2024-03-08 17:41:21 +00:00
}
show() {
2024-03-12 09:23:42 +00:00
this.$(this.selector).show();
2024-03-08 17:41:21 +00:00
}
click() {
2024-04-08 11:31:12 +01:00
this.get().click();
2024-03-08 17:41:21 +00:00
}
2024-04-08 11:31:12 +01:00
get() {
return document.querySelector(this.selector);
}
2024-03-08 14:39:50 +00:00
}
export default DomElement;