Revert "Easier closing of dialogs" (introduces regression on date time picker)

This reverts commit 71630aaa77.
This commit is contained in:
Frédéric Guillot 2018-10-23 15:12:44 -07:00
parent 2deb6cc917
commit 5a2836bf39
7 changed files with 18 additions and 53 deletions

View File

@ -51,7 +51,6 @@
data-js-lang="<?= $this->app->jsLang() ?>"
data-js-date-format="<?= $this->app->getJsDateFormat() ?>"
data-js-time-format="<?= $this->app->getJsTimeFormat() ?>"
data-js-modal-close-msg="<?= t('Close window?\\n\\nChanges that you made have not been saved.') ?>"
>
<?php if (isset($no_layout) && $no_layout): ?>

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@
var url = KB.dom(baseElement).data('url');
if (url) {
KB.modal.open(url, 'medium', true);
KB.modal.open(url, 'medium', false);
}
}

View File

@ -27,7 +27,7 @@ KB.keyboardShortcuts = function () {
KB.onKey('?', function () {
if (! KB.modal.isOpen()) {
KB.modal.open(KB.find('body').data('keyboardShortcutUrl'), '', true);
KB.modal.open(KB.find('body').data('keyboardShortcutUrl'));
}
});
@ -62,7 +62,7 @@ KB.keyboardShortcuts = function () {
KB.onKey('n', function () {
if (! KB.modal.isOpen()) {
KB.modal.open(KB.find('#board').data('taskCreationUrl'), 'large', true);
KB.modal.open(KB.find('#board').data('taskCreationUrl'), 'large', false);
}
});
}
@ -70,25 +70,25 @@ KB.keyboardShortcuts = function () {
if (KB.exists('#task-view')) {
KB.onKey('e', function () {
if (! KB.modal.isOpen()) {
KB.modal.open(KB.find('#task-view').data('editUrl'), 'large', true);
KB.modal.open(KB.find('#task-view').data('editUrl'), 'large', false);
}
});
KB.onKey('c', function () {
if (! KB.modal.isOpen()) {
KB.modal.open(KB.find('#task-view').data('commentUrl'), 'medium', true);
KB.modal.open(KB.find('#task-view').data('commentUrl'), 'medium', false);
}
});
KB.onKey('s', function () {
if (! KB.modal.isOpen()) {
KB.modal.open(KB.find('#task-view').data('subtaskUrl'), 'medium', true);
KB.modal.open(KB.find('#task-view').data('subtaskUrl'), 'medium', false);
}
});
KB.onKey('l', function () {
if (! KB.modal.isOpen()) {
KB.modal.open(KB.find('#task-view').data('internalLinkUrl'), 'medium', true);
KB.modal.open(KB.find('#task-view').data('internalLinkUrl'), 'medium', false);
}
});
}

View File

@ -8,23 +8,23 @@
}
KB.onClick('.js-modal-large', function (e) {
KB.modal.open(getLink(e), 'large', true);
KB.modal.open(getLink(e), 'large', false);
});
KB.onClick('.js-modal-medium', function (e) {
if (KB.modal.isOpen()) {
KB.modal.replace(getLink(e));
} else {
KB.modal.open(getLink(e), 'medium', true);
KB.modal.open(getLink(e), 'medium', false);
}
});
KB.onClick('.js-modal-small', function (e) {
KB.modal.open(getLink(e), 'small', true);
KB.modal.open(getLink(e), 'small', false);
});
KB.onClick('.js-modal-confirm', function (e) {
KB.modal.open(getLink(e), 'small', true);
KB.modal.open(getLink(e), 'small');
});
KB.onClick('.js-modal-close', function () {

View File

@ -1,42 +1,18 @@
(function () {
var isOpen = false;
var isFormDirty = false;
function closeIfDirty() {
if (isFormDirty == false) {
return true;
}
return window.confirm($("body").data("js-modal-close-msg").replace(/\\n/g,"\n"));
}
function onOverlayClick(e) {
if (e.target.matches('#modal-overlay')) {
if (closeIfDirty()) {
e.stopPropagation();
e.preventDefault();
destroy();
}
e.stopPropagation();
e.preventDefault();
destroy();
}
}
function onBeforeUnload(e) {
// Cancel the event as stated by the standard.
e.preventDefault();
// Chrome requires returnValue to be set.
e.returnValue = '';
}
function onCloseButtonClick() {
KB.trigger('modal.close');
}
function onFormChange() {
isFormDirty = true;
window.addEventListener('beforeunload', onBeforeUnload, false);
}
function onFormSubmit() {
KB.trigger('modal.loading');
submitForm();
@ -75,7 +51,6 @@
function afterRendering() {
var formElement = KB.find('#modal-content form');
if (formElement) {
formElement.on('change', onFormChange, false);
formElement.on('submit', onFormSubmit, false);
}
@ -90,13 +65,6 @@
_KB.tagAutoComplete();
_KB.get('Task').onPopoverOpened();
if (formElement) {
$('.form-date').datepicker('option', 'onSelect', onFormChange);
$('.form-datetime').datepicker('option', 'onSelect', onFormChange);
$(".color-picker").on('change', onFormChange);
$(".tag-autocomplete").on('change', onFormChange);
}
KB.trigger('modal.afterRender');
}
@ -154,8 +122,6 @@
function destroy() {
isOpen = false;
isFormDirty = false;
window.removeEventListener('beforeunload', onBeforeUnload, false);
var overlayElement = KB.find('#modal-overlay');
if (overlayElement) {

File diff suppressed because one or more lines are too long