LOUDSTACK-1065: cloudstack UI - AWS Style Regions - handle the case that 
document.location.href includes bookmark # that doesn't match region's end 
point completely.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e0a0c1f7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e0a0c1f7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e0a0c1f7

Branch: refs/heads/marvin_refactor
Commit: e0a0c1f75ad5c4f5fa26f4f84dbe3558d283e467
Parents: 7c02636
Author: Jessica Wang <[email protected]>
Authored: Wed Mar 20 16:41:26 2013 -0700
Committer: Prasanna Santhanam <[email protected]>
Committed: Sun Mar 31 22:02:01 2013 +0530

----------------------------------------------------------------------
 ui/scripts/regions.js           |   10 +++++++---
 ui/scripts/ui-custom/regions.js |   18 +++++++++---------
 2 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0a0c1f7/ui/scripts/regions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/regions.js b/ui/scripts/regions.js
index edc96cb..a271a1a 100644
--- a/ui/scripts/regions.js
+++ b/ui/scripts/regions.js
@@ -28,8 +28,7 @@
             args.response.success({
               data: regions ? regions : [
                 { id: -1, name: '(Default)' }
-              ],
-              activeRegionID: cloudStack.context.users[0].regionid
+              ]
             });
           }
         }); 
@@ -126,7 +125,12 @@
             },
                                                preAction: function(args) {
                                                  var region = 
args.context.regions[0];
-                                                       if(region.endpoint == 
document.location.href) {
+
+                                                       /* e.g.
+                                                       region.endpoint == 
"http://localhost:8080/client/";
+                                                       document.location.href 
== "http://localhost:8080/client/#";
+                                                       */
+                                                       
if(document.location.href.indexOf(region.endpoint) != -1) {
                                                          
cloudStack.dialog.notice({ message: _l('You can not remove the region that you 
are currently in.') });
                 return false;
                                                        }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e0a0c1f7/ui/scripts/ui-custom/regions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/regions.js b/ui/scripts/ui-custom/regions.js
index 819dfd0..9c139e5 100644
--- a/ui/scripts/ui-custom/regions.js
+++ b/ui/scripts/ui-custom/regions.js
@@ -27,9 +27,8 @@
         response: {
           success: function(args) {
             var data = args.data;
-            var activeRegionID = args.activeRegionID;
 
-                                               var currentRegion;
+                                               var currentRegion = null;
             $(data).each(function() {
               var region = this;
               var regionName = region.name;
@@ -37,20 +36,21 @@
 
               $li.data('region-data', region);
 
-                                                       if(region.endpoint == 
document.location.href) {
+                                                       /* e.g.
+                                                       region.endpoint == 
"http://localhost:8080/client/";
+                                                       document.location.href 
== "http://localhost:8080/client/#";
+                                                       */
+                                                       
if(document.location.href.indexOf(region.endpoint) != -1) {
                 currentRegion = region;
                                                                
$li.addClass('active');
                                                        }
-                                                       /*
-              if (region.id == activeRegionID) {
-                $li.addClass('active');
-              }
-              */
 
               $regionList.append($li);
             });
 
-                                               
$regionSwitcherButton.find('.title').html(_s(currentRegion.name)).attr('title', 
_s(currentRegion.name));
+            if(currentRegion != null)  {
+                                                 
$regionSwitcherButton.find('.title').html(_s(currentRegion.name)).attr('title', 
_s(currentRegion.name));
+            }
           }
         }
       });

Reply via email to