Updated Branches: refs/heads/master 6cb1486f2 -> 5a9ccce0f
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/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/5a9ccce0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/5a9ccce0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/5a9ccce0 Branch: refs/heads/master Commit: 5a9ccce0f3a131bcbb53f8c1daa57e3309127537 Parents: 6cb1486 Author: Jessica Wang <[email protected]> Authored: Wed Mar 20 16:41:26 2013 -0700 Committer: Jessica Wang <[email protected]> Committed: Wed Mar 20 16:41:26 2013 -0700 ---------------------------------------------------------------------- ui/scripts/regions.js | 10 +++++++--- ui/scripts/ui-custom/regions.js | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a9ccce0/ui/scripts/regions.js ---------------------------------------------------------------------- diff --git a/ui/scripts/regions.js b/ui/scripts/regions.js index 68191c0..0959e3b 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 + ] }); } }); @@ -132,7 +131,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/incubator-cloudstack/blob/5a9ccce0/ui/scripts/ui-custom/regions.js ---------------------------------------------------------------------- diff --git a/ui/scripts/ui-custom/regions.js b/ui/scripts/ui-custom/regions.js index 474e498..4620ea4 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)); + } } } });
