From 238da3dffd99f3ea91318eb2dd0fe77860aff345 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 20 Apr 2011 19:11:10 -0500 Subject: Refactored navigation. The singular object IPA.nav has been converted into an IPA.navigation class. The admin and self-service navigation tabs have been converted into subclasses of IPA.navigation and will be instantiated according to user authorization. --- install/ui/navigation.js | 112 +++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 53 deletions(-) (limited to 'install/ui/navigation.js') diff --git a/install/ui/navigation.js b/install/ui/navigation.js index 786a5a972..3043b7c43 100644 --- a/install/ui/navigation.js +++ b/install/ui/navigation.js @@ -2,6 +2,7 @@ /* Authors: * Pavel Zuna + * Endi S. Dewata * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information @@ -20,39 +21,38 @@ * along with this program. If not, see . */ -IPA.nav = { - tabs_lists : {}, - nav_container : {}, +IPA.navigation = function(spec) { - push_state : function (params) { - if (!IPA.test_dirty()){ + spec = spec || {}; + + var that = {}; + + that.container = spec.container; + that.tab_class = spec.tab_class || 'tabs'; + + that.tabs = spec.tabs || []; + + that.push_state = function(params) { + if (!IPA.test_dirty()) { return false; } $.bbq.pushState(params); return true; - }, + }; - get_state : function (key) { + that.get_state = function(key) { return $.bbq.getState(key, true); - }, + }; - remove_state : function (key) { + that.remove_state = function(key) { $.bbq.removeState(key); - }, + }; - create : function (nls, container, tabclass) { - if (!container){ - container = $('#navigation'); - } - if (!tabclass){ - tabclass = 'tabs'; - } - IPA.nav.tabs_lists = nls; - IPA.nav.nav_container = container; + that.create = function() { - IPA.nav.generate_tabs(nls, container, tabclass, 1); + that._create(that.tabs, that.container, 1); - var tabs = $('.' + tabclass); + var tabs = $('.' + that.tab_class); tabs.tabs({ select: function(event, ui) { var panel = $(ui.panel); @@ -60,21 +60,22 @@ IPA.nav = { var id = parent.attr('id'); var state = {}; state[id] = ui.index; - return IPA.nav.push_state(state); + return that.push_state(state); } }); - }, + }; + + that._create = function(tabs, container, depth) { - generate_tabs : function (nls, container, tabclass, depth) { - container.addClass(tabclass); + container.addClass(that.tab_class); container.addClass('tabs'+depth); - var ul = $('