summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-07-21 17:33:43 -0500
committerAdam Young <ayoung@redhat.com>2011-07-22 12:25:06 -0400
commit38ed284054a0d2e436f8a2717faceabec7e996ab (patch)
treeec6a20c620325185e239d0cd922f3a7a43eb8ea6
parentca7395c35367965f8824f2bfecfa3f79f4b8a87b (diff)
downloadfreeipa-38ed284054a0d2e436f8a2717faceabec7e996ab.zip
freeipa-38ed284054a0d2e436f8a2717faceabec7e996ab.tar.gz
freeipa-38ed284054a0d2e436f8a2717faceabec7e996ab.tar.xz
Fixed problem with navigation state loading.
The select event handler in the navigation tab has been modified to distinguish the source of the event. If the event is triggered by URL hash change, it will use the state specified in the URL. If the event is triggered by a mouse click, it will use the state stored internally.
-rw-r--r--install/ui/navigation.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/install/ui/navigation.js b/install/ui/navigation.js
index 9294973..2f39d8b 100644
--- a/install/ui/navigation.js
+++ b/install/ui/navigation.js
@@ -30,6 +30,8 @@ IPA.navigation = function(spec) {
that.name = spec.name;
that.container = spec.container;
+ that.root = that.container.attr('id');
+
that.content = spec.content;
that.tab_class = spec.tab_class || 'tabs';
that.max_depth = spec.max_depth || 3;
@@ -63,6 +65,18 @@ IPA.navigation = function(spec) {
return that.tabs_by_name[name];
};
+ that.get_current_tab = function(state) {
+ var name = null;
+ var next = state[that.root];
+
+ while (next) {
+ name = next;
+ next = state[name];
+ }
+
+ return that.get_tab(name);
+ };
+
that.get_path_state = function(name) {
var path_state = {};
@@ -77,7 +91,7 @@ IPA.navigation = function(spec) {
parent = tab.parent;
}
- path_state[that.container.attr('id')] = tab.name;
+ path_state[that.root] = tab.name;
return path_state;
};
@@ -99,7 +113,7 @@ IPA.navigation = function(spec) {
};
dialog.init();
- dialog.open($('#navigation'));
+ dialog.open(that.container);
return false;
}
@@ -110,7 +124,7 @@ IPA.navigation = function(spec) {
}
var url_state ={};
- var key = 'navigation';
+ var key = that.root;
while(state[key]){
var value = state[key];
url_state[key] = value;
@@ -168,7 +182,7 @@ IPA.navigation = function(spec) {
state[entity_name + '-pkey'] = pkey;
}
- that.push_state(state);
+ return that.push_state(state);
};
/*like show page, but works for nested entities */
@@ -194,7 +208,7 @@ IPA.navigation = function(spec) {
that.create = function() {
var container = $('<div/>', {
- name: 'navigation'
+ name: that.root
}).appendTo(that.container);
that._create(that.tabs, container, 1);
@@ -205,7 +219,15 @@ IPA.navigation = function(spec) {
var panel = $(ui.panel);
var name = panel.attr('name');
- return that.show_page(name);
+ var state = $.bbq.getState();
+ var tab = that.get_current_tab(state);
+
+ if (tab && tab.name == name) { // hash change
+ return that.push_state(state);
+
+ } else { // mouse click
+ return that.show_page(name);
+ }
}
});
};
@@ -220,7 +242,7 @@ IPA.navigation = function(spec) {
for (var i=0; i<tabs.length; i++) {
var tab = tabs[i];
- var tab_id = 'navigation-'+tab.name;
+ var tab_id = that.root+'-'+tab.name;
if (tab.entity) {
var entity = IPA.get_entity(tab.entity);
@@ -275,7 +297,7 @@ IPA.navigation = function(spec) {
}
$('.entity', that.content).css('display', 'none');
- var container = $('div[name=navigation]', that.container);
+ var container = $('div[name='+that.root+']', that.container);
that._update(that.tabs, container, 1);
};