From ae7e5b025e25e36bef8a8d9f2becfbfa5614196f Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 20 Mar 2013 14:34:37 -0700 Subject: [PATCH] CLOUDSTACK-1065: cloudstack UI - AWS Style Regions - set current region (whose end point matches current URL) to region button and region dropdown on top menu. --- ui/scripts/regions.js | 3 +-- ui/scripts/ui-custom/regions.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ui/scripts/regions.js b/ui/scripts/regions.js index 902d3f80ed3..79557ad595b 100644 --- a/ui/scripts/regions.js +++ b/ui/scripts/regions.js @@ -29,8 +29,7 @@ data: regions ? regions : [ { id: -1, name: '(Default)' } ], - activeRegionID: cloudStack.context.users.regionid ? - cloudStack.context.users.regionid : 1 + activeRegionID: cloudStack.context.users[0].regionid }); } }); diff --git a/ui/scripts/ui-custom/regions.js b/ui/scripts/ui-custom/regions.js index 579cdceb488..354ecee33de 100644 --- a/ui/scripts/ui-custom/regions.js +++ b/ui/scripts/ui-custom/regions.js @@ -29,23 +29,28 @@ var data = args.data; var activeRegionID = args.activeRegionID; + var currentRegion; $(data).each(function() { var region = this; var regionName = region.name; var $li = $('
  • ').append($('').html(_s(region.name))); $li.data('region-data', region); - + + if(document.location.href == region.endpoint) { + currentRegion = region; + $li.addClass('active'); + } + /* if (region.id == activeRegionID) { $li.addClass('active'); } - - $regionSwitcherButton.find('.title') - .html(regionName) - .attr('title', regionName); - - $regionList.append($li); + */ + + $regionList.append($li); }); + + $regionSwitcherButton.find('.title').html(_s(currentRegion.name)).attr('title', _s(currentRegion.name)); } } });