getaddress-autocomplete-modal
Version:
GetAddress.io - Autocomplete modal plug-in
33 lines • 1.47 kB
JavaScript
import { Debug } from "./Debug.js";
import Storage from "./Storage.js";
export default class ClearHistoryButton {
constructor(attributeValues, addressId, historyContainer) {
this.attributeValues = attributeValues;
this.addressId = addressId;
this.historyContainer = historyContainer;
this.button = document.createElement('BUTTON');
this.element = this.button;
this.build = () => {
var cancelIcon = document.createElement('i');
cancelIcon.className = this.attributeValues.iconCancelClassName;
cancelIcon.classList.add(this.attributeValues.iconClassName);
cancelIcon.classList.add(this.attributeValues.histroyIconCancelClassName);
this.button.insertAdjacentElement('afterbegin', cancelIcon);
this.button.className = this.attributeValues.historyClearButtonClassName;
this.button.classList.add(this.attributeValues.buttonClassName);
this.button.addEventListener('click', this.handleClick);
};
this.handleClick = (e) => {
Debug.Log(this.attributeValues, e);
Storage.remove(this.addressId);
this.historyContainer.historyList.populate();
e.preventDefault();
e.stopPropagation();
};
this.build();
}
destroy() {
this.button.removeEventListener('click', this.handleClick);
}
}
//# sourceMappingURL=ClearHistoryButton.js.map