[bitbake-devel] [PATCH 05/10] toaster: alerts and modals Avoid modals and alerts overlaying each other

Ed Bartosh ed.bartosh at linux.intel.com
Mon Sep 26 10:59:32 UTC 2016


From: Michael Wood <michael.g.wood at intel.com>

Make sure that when we spawn a modal we clear any notifications and also
make sure that old notifications are cleared before showing a new one.

Signed-off-by: Michael Wood <michael.g.wood at intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
 lib/toaster/toastergui/static/js/layerDepsModal.js | 12 ++++++++++--
 lib/toaster/toastergui/static/js/libtoaster.js     | 13 ++++++++++---
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/lib/toaster/toastergui/static/js/layerDepsModal.js b/lib/toaster/toastergui/static/js/layerDepsModal.js
index b79049e..e962224 100644
--- a/lib/toaster/toastergui/static/js/layerDepsModal.js
+++ b/lib/toaster/toastergui/static/js/layerDepsModal.js
@@ -6,7 +6,12 @@
  * addToProject: Whether to add layers to project on accept
  * successAdd: function to run on success
  */
-function showLayerDepsModal(layer, dependencies, title, body, addToProject, successAdd) {
+function showLayerDepsModal(layer,
+                            dependencies,
+                            title,
+                            body,
+                            addToProject,
+                            successAdd) {
 
   if ($("#dependencies-modal").length === 0) {
     $.get(libtoaster.ctx.htmlUrl + "/layer_deps_modal.html", function(html){
@@ -43,7 +48,10 @@ function showLayerDepsModal(layer, dependencies, title, body, addToProject, succ
 
     $("#dependencies-modal").data("deps", dependencies);
 
-    $('#dependencies-modal').modal('show');
+    /* Clear any alert notifications before showing the modal */
+    $(".alert").fadeOut(function(){
+      $('#dependencies-modal').modal('show');
+    });
 
     /* Discard the old submission function */
     $("#dependencies-modal-form").unbind('submit');
diff --git a/lib/toaster/toastergui/static/js/libtoaster.js b/lib/toaster/toastergui/static/js/libtoaster.js
index 8e2221d..0832ba4 100644
--- a/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/lib/toaster/toastergui/static/js/libtoaster.js
@@ -342,10 +342,12 @@ var libtoaster = (function () {
   }
 
   function _showChangeNotification(message){
-    var alertMsg = $("#change-notification-msg");
+    $(".alert").fadeOut().promise().done(function(){
+      var alertMsg = $("#change-notification-msg");
 
-    alertMsg.html(message);
-    $("#change-notification, #change-notification *").fadeIn();
+      alertMsg.html(message);
+      $("#change-notification, #change-notification *").fadeIn();
+    });
   }
 
   function _createCustomRecipe(name, baseRecipeId, doneCb){
@@ -716,6 +718,11 @@ $(document).ready(function() {
       });
     }
 
+    /* Make sure we don't have a notification overlay a modal */
+    $(".modal").on('show.bs.modal', function(){
+      $(".alert-dismissible").fadeOut();
+    });
+
     if (libtoaster.debug) {
       check_for_duplicate_ids();
     } else {
-- 
2.6.6




More information about the bitbake-devel mailing list