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.

This commit is contained in:
Jessica Wang 2013-03-20 14:34:37 -07:00
parent 918a7c7481
commit ae7e5b025e
2 changed files with 13 additions and 9 deletions

View File

@ -29,8 +29,7 @@
data: regions ? regions : [ data: regions ? regions : [
{ id: -1, name: '(Default)' } { id: -1, name: '(Default)' }
], ],
activeRegionID: cloudStack.context.users.regionid ? activeRegionID: cloudStack.context.users[0].regionid
cloudStack.context.users.regionid : 1
}); });
} }
}); });

View File

@ -29,23 +29,28 @@
var data = args.data; var data = args.data;
var activeRegionID = args.activeRegionID; var activeRegionID = args.activeRegionID;
var currentRegion;
$(data).each(function() { $(data).each(function() {
var region = this; var region = this;
var regionName = region.name; var regionName = region.name;
var $li = $('<li>').append($('<span>').html(_s(region.name))); var $li = $('<li>').append($('<span>').html(_s(region.name)));
$li.data('region-data', region); $li.data('region-data', region);
if(document.location.href == region.endpoint) {
currentRegion = region;
$li.addClass('active');
}
/*
if (region.id == activeRegionID) { if (region.id == activeRegionID) {
$li.addClass('active'); $li.addClass('active');
} }
*/
$regionSwitcherButton.find('.title')
.html(regionName) $regionList.append($li);
.attr('title', regionName);
$regionList.append($li);
}); });
$regionSwitcherButton.find('.title').html(_s(currentRegion.name)).attr('title', _s(currentRegion.name));
} }
} }
}); });