diff options
author | Adam Young <ayoung@redhat.com> | 2010-08-23 22:32:23 -0400 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2010-08-26 13:15:00 -0400 |
commit | 49584d6efc6a10fa0b76ce81b2638d424f2208a8 (patch) | |
tree | 08c87c7d7bd2ee0fef6e5045948a977a5c61cdc9 /install/static/navigation.js | |
parent | 02479babb9cd5fdd0673175fde22e40f3a1b10b4 (diff) | |
download | freeipa.git-49584d6efc6a10fa0b76ce81b2638d424f2208a8.tar.gz freeipa.git-49584d6efc6a10fa0b76ce81b2638d424f2208a8.tar.xz freeipa.git-49584d6efc6a10fa0b76ce81b2638d424f2208a8.zip |
hashchange
We now catch the hashchange event and use that to drive most of the site.
To trigger page transitions, modify location.hash.
Params start with # not ?.
Removed user-group.inc.
converted tabs to spaces
trivial imlementation of add and details for netgroup and hostgroup
lots of bug fixes based on routing problems and the refactorings.
Diffstat (limited to 'install/static/navigation.js')
-rw-r--r-- | install/static/navigation.js | 226 |
1 files changed, 121 insertions, 105 deletions
diff --git a/install/static/navigation.js b/install/static/navigation.js index 93ee4215..ff21fdf5 100644 --- a/install/static/navigation.js +++ b/install/static/navigation.js @@ -15,144 +15,165 @@ function unimplemented(facet){ } +var parentTabs; +function getParentTabs(){ + if (!parentTabs){ + parentTabs = { + user : "identity", + group : "identity", + host : "identity", + hostgroup: "identity", + netgroup : "identity", + policy : "policy", + config : "config" + }; + } + return parentTabs; +} + function buildNavigation(){ params= ipa_parse_qs(); var tab = params["tab"]; if (!tab){ - tab=$.cookie("lastpage"); + tab=$.cookie("lastpage"); } if ( !tab ) { - tab="user"; + tab="user"; } var facet = params["facet"]; var siteMap = [{name:"IDENTITY", - tab:"user", - children : [ - {name:"Users",tab:"user", setup: setupUser}, - {name:"Groups",tab:"group",setup: setupGroup}, - {name:"Hosts",tab:"host", setup: setupHost}, - {name:"Hostgroups", - tab:"hostgroup", - setup: setupHostgroup}, - {name:"Netgroups",tab:"netgroup", setup:setupNetgroup} - ]}, - {name:"POLICY", tab:"policy", setup: unimplemented}, - {name:"CONFIG", tab:"config", setup: unimplemented }]; - + tab:"identity", //Default subtab + children : [ + {name:"Users",tab:"user", setup: setupUser}, + {name:"Groups",tab:"group",setup: setupGroup}, + {name:"Hosts",tab:"host", setup: setupHost}, + {name:"Hostgroups", + tab:"hostgroup", + setup: setupHostgroup}, + {name:"Netgroups",tab:"netgroup", setup:setupNetgroup} + ]}, + {name:"POLICY", tab:"policy", setup: unimplemented}, + {name:"CONFIG", tab:"config", setup: unimplemented }]; + + //TODO autogen this from the site map var separator = $("<span class='main-separator' />"); var currentMain = siteMap[0]; for (var i = 0 ; i < siteMap.length; i++){ - current = siteMap[i]; - if (i > 0){ - $('#main-nav').append(separator.clone()); - } - var tabClass = "main-nav-off"; - if (tab == current.tab){ - currentMain = current; - tabClass = "main-nav-on"; - } - - var span = $("<span/>", { - "class": tabClass, - id: "span-tab-"+current.tab, - }); - - $("<a/>",{ - "id": "tab-"+current.tab, - href: "#?tab="+current.tab, - text: current.name, - click: setActiveTab - }).appendTo(span); - - span.appendTo("#main-nav") + current = siteMap[i]; + if (i > 0){ + $('#main-nav').append(separator.clone()); + } + var tabClass = "main-nav-off"; + if (tab == current.tab){ + currentMain = current; + tabClass = "main-nav-on"; } + var span = $("<span/>", { + "class": tabClass, + id: "span-tab-"+current.tab, + }); + + $("<a/>",{ + "id": "tab-"+current.tab, + href: "#tab="+current.tab, + text: current.name, + }).appendTo(span); + + span.appendTo("#main-nav") + } if (currentMain.children){ var selectedSub; - for (var i =0; i < currentMain.children.length; i++){ - var currentSub = currentMain.children[i]; - - var tabClass = "sub-nav-off"; - if (tab == currentSub.tab){ - tabClass = "sub-nav-on"; - selectedSub = currentSub; - } - - var span = $("<span/>", { - "class": tabClass, - id: "span-subtab-"+currentSub.tab - }); - - $("<a/>",{ - "id": "subtab-"+currentSub.tab, - href: "#?tab="+currentSub.tab, - text: currentSub.name, - click: setActiveSubtab, - }).appendTo(span); - - span.appendTo("#sub-nav"); - } - - if (selectedSub && selectedSub.setup){ - selectedSub.setup(facet); - } + for (var i =0; i < currentMain.children.length; i++){ + var currentSub = currentMain.children[i]; + + var tabClass = "sub-nav-off"; + if (tab == currentSub.tab){ + tabClass = "sub-nav-on"; + selectedSub = currentSub; + } + + var span = $("<span/>", { + "class": tabClass, + id: "span-subtab-"+currentSub.tab + }); + + $("<a/>",{ + "id": "subtab-"+currentSub.tab, + href: "#tab="+currentSub.tab, + text: currentSub.name, + //click: setActiveSubtab, + }).appendTo(span); + + span.appendTo("#sub-nav"); + } + + if (selectedSub && selectedSub.setup){ + selectedSub.setup(facet); + } }else if (currentMain && currentMain.setup){ - currentMain.setup(facet); + currentMain.setup(facet); } var whoami = $.cookie("whoami"); if (whoami == null){ - ipa_cmd( 'whoami', [], {}, whoamiSuccess, null,null, "sampledata/whoami.json"); + ipa_cmd( 'whoami', [], {}, whoamiSuccess, null,null, "sampledata/whoami.json"); }else{ - setLoggedInText(whoami); + setLoggedInText(whoami); } } +var setupFunctions; +function getSetupFunctions(){ + if (!setupFunctions){ + setupFunctions = { + user: setupUser, + group: setupGroup, + host: setupHost, + hostgroup:setupHostgroup, + netgroup:setupNetgroup, + }; + } + return setupFunctions; +} +$(window).bind( 'hashchange', function(e) { -function setActiveTab(){ + var queryParams = ipa_parse_qs(); + var tab=queryParams.tab; + if (!tab){ + tab = 'user'; + } + $(".sub-nav-on").removeClass('sub-nav-on').addClass("sub-nav-off") + var active = "#span-subtab-"+tab; + $(active).removeClass('sub-nav-off').addClass("sub-nav-on") - var setupFunctions = { - user: setupUser, - policy: unimplemented, - config: unimplemented}; + setActiveTab(getParentTabs()[tab]); + getSetupFunctions()[tab](queryParams.facet ); +}); - var tabName = this.id.substring("tab-".length); + +function setActiveTab(tabName){ + $(".main-nav-on").removeClass('main-nav-on').addClass("main-nav-off") var activeTab = "#span-tab-"+tabName; $(activeTab).removeClass('main-nav-off').addClass("main-nav-on") - - setupFunctions[tabName](); - -} - -function setActiveSubtab(){ - - var setupFunctions = { - user: setupUser, - group: setupGroup, - host: setupHost, - hostgroup:setupHostgroup, - netgroup:setupNetgroup, -}; - - var subtabName = this.id.substring("subtab-".length); - $(".sub-nav-on").removeClass('sub-nav-on').addClass("sub-nav-off") - var active = "#span-subtab-"+subtabName; - $(active).removeClass('sub-nav-off').addClass("sub-nav-on") - - setupFunctions[subtabName](); } function clearOld(){ + $('#search').css("display","none"); + $('#details').css("display","none"); + $('#content').css("display","none"); + $('#associations').css("display","none"); + $('#searchResultsTable thead').html(""); $('#searchResultsTable tfoot').html(""); $('#searchResultsTable tbody').find("tr").remove(); @@ -163,30 +184,25 @@ function clearOld(){ //remove old details $('.entryattrs dd').remove(); $('#detail-lists').html("<hr/>"); - } - - function showSearch(){ - $('#content').css("display","none"); - $('#details').css("display","none"); clearOld(); $('#search').css("display","block"); $("#filter").css("display","block"); } function showContent(){ - $('#search').css("display","none"); - $('#details').css("display","none"); clearOld(); $('#content').css("display","block"); } - function showDetails(){ - $('#search').css("display","none"); - $('#content').css("display","none"); clearOld(); $('#details').css("display","block"); } + +function showAssociations(){ + clearOld(); + $('#associations').css("display","block"); +}
\ No newline at end of file |