Implement cancel button in input field

This commit is contained in:
Dennis Eichhorn 2019-05-07 20:02:10 +02:00
parent e72dbb45fc
commit 09bc37b59e
2 changed files with 9 additions and 46 deletions

View File

@ -47,54 +47,17 @@ export class Input {
static bindElement(input)
{
if (typeof input === 'undefined') {
throw 'Input element required'
throw 'Input element required';
}
const self = this;
const type = input.type;
input.addEventListener('change', function changeBind(event)
{
console.log('ttttttt');
/* Handle remote datalist/autocomplete input element */
let listId, list;
if (typeof (listId = this.getAttribute('list')) !== 'undefined' && (list = document.getElementById(listId)).getAttribute('data-list-src') !== 'undefined') {
self.addRemoteDatalistOptions(this, list);
}
/* Handle html defined functions */
let change;
if (typeof (change = this.getAttribute('data-change-func')) !== 'undefined') {
change(this);
}
/* Handle pre-defined dynamic change events */
let ref;
if (typeof (ref = this.getAttribute('data-ref')) !== 'undefined') {
let e = document.getElementById(ref);
if (!e) {
return;
}
switch (e.tagName) {
case 'ul':
break;
case 'table':
break;
default:
}
}
});
let dataButton;
if (typeof (dataButton = input.getAttribute('data-button')) !== 'undefined') {
this.app.inputManager.getKeyboardManager().bind(input, 13, function ()
{
const db = document.getElementById(dataButton);
if (db) {
db.click();
}
const removeContentButton = input.parentNode.querySelector('.fa-times');
if (removeContentButton !== null
&& type !== 'submit' && type !== 'button') {
removeContentButton.addEventListener('click', function() {
input.value = '';
input.focus();
});
}
};

View File

@ -1,6 +1,6 @@
import { AdvancedInput } from './Component/AdvancedInput.js';
import { UriFactory } from '../Uri/UriFactory.js';
import { AdvancedInput } from './Component/AdvancedInput.js';
/**
* UI manager for handling basic ui elements.