Improved modal template for text input
This commit is contained in:
parent
15ca5f6531
commit
7c918a70fc
2 changed files with 11 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
- Added server group clients list
|
- Added server group clients list
|
||||||
- Improved invite buddy dialog
|
- Improved invite buddy dialog
|
||||||
- Improved poke modal system
|
- Improved poke modal system
|
||||||
|
- Improved modal template for text input
|
||||||
|
|
||||||
* **24.05.19**
|
* **24.05.19**
|
||||||
- Implemented icon upload
|
- Implemented icon upload
|
||||||
|
|
|
@ -84,6 +84,7 @@ class Modal {
|
||||||
properties: ModalProperties;
|
properties: ModalProperties;
|
||||||
shown: boolean;
|
shown: boolean;
|
||||||
|
|
||||||
|
open_listener: (() => any)[] = [];
|
||||||
close_listener: (() => any)[] = [];
|
close_listener: (() => any)[] = [];
|
||||||
close_elements: JQuery;
|
close_elements: JQuery;
|
||||||
|
|
||||||
|
@ -121,6 +122,7 @@ class Modal {
|
||||||
this.close_elements = tag.find(".button-modal-close");
|
this.close_elements = tag.find(".button-modal-close");
|
||||||
this.close_elements.toggle(this.properties.closeable);
|
this.close_elements.toggle(this.properties.closeable);
|
||||||
this._htmlTag = tag;
|
this._htmlTag = tag;
|
||||||
|
this._htmlTag.on('shown.bs.modal', event => { for(const listener of this.open_listener) listener(); });
|
||||||
this._htmlTag.on('hide.bs.modal', event => !this.properties.closeable || this.close());
|
this._htmlTag.on('hide.bs.modal', event => !this.properties.closeable || this.close());
|
||||||
this._htmlTag.on('hidden.bs.modal', event => this._htmlTag.detach());
|
this._htmlTag.on('hidden.bs.modal', event => this._htmlTag.detach());
|
||||||
}
|
}
|
||||||
|
@ -198,6 +200,13 @@ function createInputModal(headMessage: BodyCreator, question: BodyCreator, valid
|
||||||
input.attr("pattern", valid ? null : "^[a]{1000}$").toggleClass("is-invalid", !valid);
|
input.attr("pattern", valid ? null : "^[a]{1000}$").toggleClass("is-invalid", !valid);
|
||||||
button_submit.prop("disabled", !valid);
|
button_submit.prop("disabled", !valid);
|
||||||
});
|
});
|
||||||
|
input.on('keydown', event => {
|
||||||
|
if(event.keyCode !== JQuery.Key.Enter || event.shiftKey)
|
||||||
|
return;
|
||||||
|
if(button_submit.prop("disabled"))
|
||||||
|
return;
|
||||||
|
button_submit.trigger('click');
|
||||||
|
});
|
||||||
|
|
||||||
button_submit.on('click', event => {
|
button_submit.on('click', event => {
|
||||||
if(!submited) {
|
if(!submited) {
|
||||||
|
@ -219,6 +228,7 @@ function createInputModal(headMessage: BodyCreator, question: BodyCreator, valid
|
||||||
modal.close();
|
modal.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modal.open_listener.push(() => input.focus());
|
||||||
modal.close_listener.push(() => button_cancel.trigger('click'));
|
modal.close_listener.push(() => button_cancel.trigger('click'));
|
||||||
return modal;
|
return modal;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue