[Kimchi-devel] [PATCH] [Wok] Issue #79: All error messages should keep on UI until user dismiss it

sguimaraes943 at gmail.com sguimaraes943 at gmail.com
Wed Jun 22 15:45:27 UTC 2016


From: Samuel Guimarães <sguimaraes943 at gmail.com>

Signed-off-by: Samuel Guimarães <sguimaraes943 at gmail.com>
---
 ui/js/src/wok.message.js | 53 +++++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/ui/js/src/wok.message.js b/ui/js/src/wok.message.js
index e4c2ebd..cf682d2 100644
--- a/ui/js/src/wok.message.js
+++ b/ui/js/src/wok.message.js
@@ -18,34 +18,37 @@
  * 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 = $('<div id="alert-fields"/>').appendTo($('#alert-container'));
-    }
-    var message = '<div role="alert" class="alert ' + (level || '') + ' alert-dismissible fade in" style="display: none;">';
-    if(!node || closeable) {
-        message += '<button type="button" class="close" data-dismiss="alert" aria-label="Close" onclick="' + (onclick || '') + '"><span aria-hidden="true"><i class="fa fa-times-circle"></i></span></button>';
-    }
-    message += msg;
-    message += '</div>';
-    var $message = $(message);
-    $(container).show();
-    $(container).append($message);
-    $message.alert();
-    $message.fadeIn(100);
+    if($("#" + alertId).length === 0) {
+        if ($(container).size() < 1) {
+            container = $('<div id="alert-fields"/>').appendTo($('#alert-container'));
+        }
+        var message = '<div '+( alertId ? 'id="'+alertId+'"' : '')+' role="alert" class="alert ' + (level || '') + ' alert-dismissible fade in" style="display: none;">';
+        if(!node || closeable) {
+            message += '<button type="button" class="close" data-dismiss="alert" aria-label="Close" onclick="' + (onclick || '') + '"><span aria-hidden="true"><i class="fa fa-times-circle"></i></span></button>';
+        }
+        message += msg;
+        message += '</div>';
+        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);
+        }
     }
 };
 
-- 
1.8.3.1




More information about the Kimchi-devel mailing list