/*jsl:import ipa.js */ /* Authors: * Pavel Zuna * Endi S. Dewata * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ IPA.navigation = function(spec) { spec = spec || {}; var that = {}; 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; that.tabs = []; that.tabs_by_name = {}; that.path = {}; that.set_tabs = function(tabs) { that.tabs = tabs; that.tabs_by_name = {}; for (var i=0; i', { name: that.root }).appendTo(that.container); that._create(that.tabs, container, 1); var tabs = $('.' + that.tab_class, that.container); tabs.tabs({ select: function(event, ui) { var panel = $(ui.panel); var name = panel.attr('name'); var state = that.get_state(); 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); } } }); }; that._create = function(tabs, container, depth) { var parent_name = container.attr('name'); that.path[parent_name] = tabs[0].name; container.addClass(that.tab_class); container.addClass('tabs'+depth); var ul = $('