From cd577ca9e7d540cec2aac99490f80a2e5ac4ba76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Guimar=C3=A3es?= Date: Thu, 23 Jun 2016 09:40:29 -0400 Subject: [PATCH] Issue #79: All error messages should keep on UI until user dismiss it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit also fixes a bug where alert "close" buttons would close modal windows. Signed-off-by: Samuel GuimarĂ£es --- ui/js/src/wok.message.js | 69 +++++++++++++++++++++------------------- ui/js/src/wok.window.js | 2 +- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/ui/js/src/wok.message.js b/ui/js/src/wok.message.js index e4c2ebd41..159dc36b4 100644 --- a/ui/js/src/wok.message.js +++ b/ui/js/src/wok.message.js @@ -18,53 +18,56 @@ * limitations under the License. */ -wok.message = function(msg, level, node, closeable, onclick) { +wok.message = function(msg, level, node, closeable, onclick, alertId) { "use strict"; + var close = closeable || true; var container = node || $('#alert-fields'); - if ($(container).size() < 1) { - container = $('
').appendTo($('#alert-container')); - } - var message = ''; - var $message = $(message); - $(container).show(); - $(container).append($message); - $message.alert(); - $message.fadeIn(100); + if($("#" + alertId).length === 0) { + if ($(container).size() < 1) { + container = $('
').appendTo($('#alert-container')); + } + var message = ''; + var $message = $(message); + $(container).show(); + $(container).append($message); + $message.alert(); + $message.fadeIn(100); - if(!closeable){ - var timeout = setTimeout(function() { - $message.delay(4000).fadeOut(100, function() { - $message.alert('close'); - $(this).remove(); - if ($(container).children().length < 1) { - $(container).hide(); - } - }); - }, 10000); + if(!close){ + var timeout = setTimeout(function() { + $message.delay(4000).fadeOut(100, function() { + $message.alert('close'); + $(this).remove(); + if ($(container).children().length < 1) { + $(container).hide(); + } + }); + }, 10000); + } } }; -wok.message.warn = function(msg, node, closeable) { +wok.message.warn = function(msg, node, closeable, alertId) { "use strict"; - wok.message(msg, 'alert-warning', node, closeable); + wok.message(msg, 'alert-warning', node, closeable, null, alertId); }; -wok.message.error = function(msg, node, closeable) { +wok.message.error = function(msg, node, closeable, alertId) { "use strict"; - wok.message(msg, 'alert-danger', node, closeable); + wok.message(msg, 'alert-danger', node, closeable, null, alertId); }; -wok.message.error.code = function(code, node, closeable) { +wok.message.error.code = function(code, node, closeable, alertId) { "use strict"; var msg = code + ": " + i18n[code]; - wok.message(msg, 'alert-danger', node, closeable); + wok.message(msg, 'alert-danger', node, closeable, null, alertId); }; -wok.message.success = function(msg, node, closeable) { +wok.message.success = function(msg, node, closeable, alertId) { "use strict"; - wok.message(msg, 'alert-success', node, closeable); + wok.message(msg, 'alert-success', node, closeable, null, alertId); }; wok.message.notify = function(notification, node) { "use strict"; diff --git a/ui/js/src/wok.window.js b/ui/js/src/wok.window.js index 1386e0959..b021605e0 100644 --- a/ui/js/src/wok.window.js +++ b/ui/js/src/wok.window.js @@ -49,7 +49,7 @@ wok.window = (function() { $('#' + windowID).remove(); }); - $(windowNode).appendTo('#' + target).on('click', '.window .close', function() { + $(windowNode).appendTo('#' + target).on('click', '.modal-header > .close', function() { wok.window.close(); });