class AddCardPopover extends Popover { viewDidAppear() { this.cardTitleField.focus(); //Call initial input event in order to initially disable button. this.onInput(); } setCategory(categoryId) { this.categoryId = categoryId; } onAddButtonPressed(event) { event.preventDefault(); if (this.creatingCardData) { return; } if (this.cardTitleField.value.length < 1) { return; } this.addButton.disabled = true; this.creatingCardData = { title: this.cardTitleField.value, description: this.cardDescriptionField.value, visibility: parseInt(this.cardVisibilitySelectController.value), id_category: this.categoryId }; TimeCards.dataManager.store("card", this.creatingCardData, this.onCardCreated.bind(this)); } onInput(event) { if (this.cardTitleField.value.length < 1) { this.addButton.disabled = true; return; } else { this.addButton.disabled = false; } } onCardCreated(cardId, card) { this.reset(); this.dismiss(); } cardCreationError(cardId, card, error) { this.creatingCardData = null; } reset() { this.creatingCardData = null; this.cardTitleField.value = null; this.cardDescriptionField.value = null; this.cardVisibilitySelectController.value = 1; this.addButton.disabled = true; } } UIKit.registerPopoverType(AddCardPopover);