Ketika modal Todo view, Todo create, Todo Edit, Todo item create, dan todo item edit muncul lalu menekan tombol ESC pada keyboard, maka akan menutup modal tersebut.

This commit is contained in:
Supan Adit Pratama 2020-07-02 19:07:04 +07:00
parent 6a536babea
commit 1c17fa89f1
2 changed files with 36 additions and 2 deletions

View File

@ -219,6 +219,41 @@
let todoModalIsShown = false; let todoModalIsShown = false;
$(document).bind('keydown', function (e) { $(document).bind('keydown', function (e) {
// ESC Key
if (e.key === "Escape") {
// Ketika Todo View Modal terbuka
const statusTodoViewModal = ($("#todo-view-modal").data('bs.modal') || {}).isShown;
if (statusTodoViewModal !== "undefined" && statusTodoViewModal) {
$("#todo-view-modal").modal('hide');
}
// Ketika Todo Create Modal terbuka
const statusTodoCreateModal = ($("#todo-create-modal").data('bs.modal') || {}).isShown;
if (statusTodoCreateModal !== "undefined" && statusTodoCreateModal) {
$("#todo-create-modal").modal('hide');
}
// Ketika Todo Edit Modal terbuka
const statusTodoEditModal = ($("#todo-edit-modal").data('bs.modal') || {}).isShown;
if (statusTodoEditModal !== "undefined" && statusTodoEditModal) {
$("#todo-edit-modal").modal('hide');
$("#todo-view-modal").modal('show');
}
// Ketika Todo Item Create Modal terbuka
const statusTodoItemCreateModal = ($("#todo-item-create-modal").data('bs.modal') || {}).isShown;
if (statusTodoItemCreateModal !== "undefined" && statusTodoItemCreateModal) {
$("#todo-item-create-modal").modal('hide');
$("#todo-view-modal").modal('show');
}
// Ketika Todo Item Edit Modal terbuka
const statusTodoItemEditModal = ($("#todo-item-edit-modal").data('bs.modal') || {}).isShown;
if (statusTodoItemEditModal !== "undefined" && statusTodoItemEditModal) {
$("#todo-item-edit-modal").modal('hide');
$("#todo-view-modal").modal('show');
}
}
// CTRL + S // CTRL + S
if (e.ctrlKey && e.which === 83) { if (e.ctrlKey && e.which === 83) {
toastr.error("Prevented"); toastr.error("Prevented");

View File

@ -154,8 +154,7 @@
<div class="pull-right hidden-xs"> <div class="pull-right hidden-xs">
<b>Version</b> 1.0.5 <b>Version</b> 1.0.5
</div> </div>
<strong>Copyright &copy; @php echo date('Y'); @endphp <b>Todo</b>&nbsp;<i>App</i>.</strong> <strong>Copyright &copy; @php echo date('Y'); @endphp <b>Todo</b>&nbsp;<i>App</i>.</strong> All rights
All rights
reserved. reserved.
</div> </div>
<!-- /.container --> <!-- /.container -->