From fc7d519c4b371bb44a52c839f4a26849d1e0c2a2 Mon Sep 17 00:00:00 2001 From: will Date: Thu, 18 Nov 2010 16:52:43 -0800 Subject: [PATCH] bug 7018: fixed an issue where dialog boxes were not correctly being cleaned up when you navigated in the UI. Essentially they were being duplicated. - Fixed issue where the "change" event on the Add Volume dialog was being duplicated. bug 7018: resolved fixed --- ui/scripts/cloud.core.init.js | 10 +++++----- ui/scripts/cloud.core.js | 20 +++++++++++--------- ui/scripts/cloud.core.volume.js | 16 +++++++--------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index c77cc14b8e4..cf4e404eaf4 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -395,14 +395,14 @@ $(document).ready(function() { } // Dialogs - initDialog("dialog_confirmation"); - initDialogWithOK("dialog_info"); + initDialog("dialog_confirmation", 150, false); + initDialogWithOK("dialog_info", 150, false); - initDialogWithOK("dialog_alert"); + initDialogWithOK("dialog_alert", 150, false); $("#dialog_alert").siblings(".ui-widget-header").css("background", "url('/client/css/images/ui-bg_errorglass_30_ffffff_1x400.png') repeat-x scroll 50% 50% #393939"); $("#dialog_alert").siblings(".ui-dialog-buttonpane").find(".ui-state-default").css("background", "url('/client/css/images/ui-bg_errorglass_30_ffffff_1x400.png') repeat-x scroll 50% 50% #393939"); - initDialogWithOK("dialog_error"); + initDialogWithOK("dialog_error", 150, false); $("#dialog_error").siblings(".ui-widget-header").css("background", "url('/client/css/images/ui-bg_errorglass_30_ffffff_1x400.png') repeat-x scroll 50% 50% #393939"); $("#dialog_error").siblings(".ui-dialog-buttonpane").find(".ui-state-default").css("background", "url('/client/css/images/ui-bg_errorglass_30_ffffff_1x400.png') repeat-x scroll 50% 50% #393939"); @@ -415,7 +415,7 @@ $(document).ready(function() { $("#dialog_session_expired").siblings(".ui-widget-header").css("background", "url('/client/css/images/ui-bg_errorglass_30_ffffff_1x400.png') repeat-x scroll 50% 50% #393939"); $("#dialog_session_expired").siblings(".ui-dialog-buttonpane").find(".ui-state-default").css("background", "url('/client/css/images/ui-bg_errorglass_30_ffffff_1x400.png') repeat-x scroll 50% 50% #393939"); - initDialogWithOK("dialog_info_please_select_one_item_in_middle_menu"); + initDialogWithOK("dialog_info_please_select_one_item_in_middle_menu", 150, false); // Check whether the session is valid. g_mySession = $.cookie("JSESSIONID"); diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index d2f8195275b..f204cf779c0 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -840,13 +840,13 @@ function setTemplateStateInRightPanel(stateValue, $stateField) { $stateField.text(stateValue).removeClass("status_green").addClass("status_red"); } -function initDialog(elementId, width1) { +function initDialog(elementId, width1, addToActive) { if(width1 == null) { activateDialog($("#"+elementId).dialog({ autoOpen: false, modal: true, zIndex: 2000 - })); + }), addToActive); } else { activateDialog($("#"+elementId).dialog({ @@ -854,18 +854,18 @@ function initDialog(elementId, width1) { autoOpen: false, modal: true, zIndex: 2000 - })); + }), addToActive); } } -function initDialogWithOK(elementId, width1) { +function initDialogWithOK(elementId, width1, addToActive) { if(width1 == null) { activateDialog($("#"+elementId).dialog({ autoOpen: false, modal: true, zIndex: 2000, buttons: { "OK": function() { $(this).dialog("close"); } } - })); + }), addToActive); } else { activateDialog($("#"+elementId).dialog({ @@ -874,7 +874,7 @@ function initDialogWithOK(elementId, width1) { modal: true, zIndex: 2000, buttons: { "OK": function() { $(this).dialog("close"); } } - })); + }), addToActive); } } @@ -976,7 +976,7 @@ function listMidMenuItems(commandString, jsonResponse1, jsonResponse2, rightPane $(this).find("#action_menu").hide(); return false; }); - + removeDialogs(); afterLoadRightPanelJSPFn(); listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, true); }); @@ -1786,8 +1786,10 @@ function handleError(XMLHttpResponse, handleErrorCallback) { // FUNCTION: Adds a Dialog to the list of active Dialogs so that // when you shift from one tab to another, we clean out the dialogs var activeDialogs = new Array(); -function activateDialog(dialog) { - activeDialogs[activeDialogs.length] = dialog; +function activateDialog(dialog, addToActive) { + if (addToActive == undefined || addToActive) { + activeDialogs[activeDialogs.length] = dialog; + } //bind Enter-Key-pressing event handler to the dialog dialog.keypress(function(event) { diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 87e4f4da684..596a209a6c1 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -63,19 +63,17 @@ function afterLoadVolumeJSP() { var offerings = json.listdiskofferingsresponse.diskoffering; var volumeDiskOfferingSelect = $("#dialog_add_volume").find("#volume_diskoffering").empty(); if (offerings != null && offerings.length > 0) { - if (offerings != null && offerings.length > 0) { - for (var i = 0; i < offerings.length; i++) { - var $option = $(""); - $option.data("jsonObj", offerings[i]); - volumeDiskOfferingSelect.append($option); - } - $("#dialog_add_volume").find("#volume_diskoffering").change(); - } + for (var i = 0; i < offerings.length; i++) { + var $option = $(""); + $option.data("jsonObj", offerings[i]); + volumeDiskOfferingSelect.append($option); + } + $("#dialog_add_volume").find("#volume_diskoffering").change(); } } }); - $("#dialog_add_volume").find("#volume_diskoffering").bind("change", function(event) { + $("#dialog_add_volume").find("#volume_diskoffering").unbind("change").bind("change", function(event) { var jsonObj = $(this).find("option:selected").data("jsonObj"); if(jsonObj.isCustomized == true) { $("#dialog_add_volume").find("#size_container").show();