mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-12 15:48:40 +00:00
Implement cancel button in input field
This commit is contained in:
parent
e72dbb45fc
commit
09bc37b59e
|
|
@ -47,54 +47,17 @@ export class Input {
|
||||||
static bindElement(input)
|
static bindElement(input)
|
||||||
{
|
{
|
||||||
if (typeof input === 'undefined') {
|
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)
|
const removeContentButton = input.parentNode.querySelector('.fa-times');
|
||||||
{
|
if (removeContentButton !== null
|
||||||
console.log('ttttttt');
|
&& type !== 'submit' && type !== 'button') {
|
||||||
/* Handle remote datalist/autocomplete input element */
|
removeContentButton.addEventListener('click', function() {
|
||||||
let listId, list;
|
input.value = '';
|
||||||
if (typeof (listId = this.getAttribute('list')) !== 'undefined' && (list = document.getElementById(listId)).getAttribute('data-list-src') !== 'undefined') {
|
input.focus();
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import { AdvancedInput } from './Component/AdvancedInput.js';
|
|
||||||
import { UriFactory } from '../Uri/UriFactory.js';
|
import { UriFactory } from '../Uri/UriFactory.js';
|
||||||
|
import { AdvancedInput } from './Component/AdvancedInput.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI manager for handling basic ui elements.
|
* UI manager for handling basic ui elements.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user