From d201a4350d8ce0adb97e8f161ab916bb6bc066a5 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 27 Sep 2010 23:35:09 -0500 Subject: Fixed tab selection on page reload. jQuery tabs by default will display the first tab, so reloading a page or opening a page from bookmark may not show the active tab correctly. The nav_select_tabs() has been added to get the list of active tabs from the hash values in the URL and then activate the appropriate tabs. It will be called during page initialization and whenever the hash values change. The navigation.js and webui.js has been cleaned up to better utilize jQuery API. jQuery selectors are used to create DOM objects that can be used by subsequent codes. Tab selection handler is now added to the tabs object instead of anchors. The change event no longer needs to be triggered manually. --- install/static/navigation.js | 63 ++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 23 deletions(-) (limited to 'install/static/navigation.js') diff --git a/install/static/navigation.js b/install/static/navigation.js index 351c7c38..683c8726 100644 --- a/install/static/navigation.js +++ b/install/static/navigation.js @@ -28,17 +28,25 @@ function nav_create(nls, container, tabclass) nav_generate_tabs(nls, container, tabclass, 1); var tabs = $('.' + tabclass); - tabs.tabs({event: 'change'}); - tabs.find('ul.ui-tabs-nav a').click(_nav_tab_on_click); + tabs.tabs({ + select: function(event, ui) { + var state = {}; + var id = $(ui.panel).parent().attr('id'); + state[id] = ui.index; + $.bbq.pushState(state); + return true; + } + }); } function nav_generate_tabs(nls, container, tabclass, depth) { container.addClass(tabclass); container.addClass('tabs'+depth); - container.prepend(''); - var ul = container.children().first(); + var ul = $('