From b9ef6ab0c412913234f05f788b3fcd3c3277eb69 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 26 Nov 2012 14:28:32 +0100 Subject: Move of core Web UI files to AMD directory SSIA https://fedorahosted.org/freeipa/ticket/112 --- install/ui/src/freeipa/navigation.js | 455 +++++++++++++++++++++++++++++++++++ 1 file changed, 455 insertions(+) create mode 100644 install/ui/src/freeipa/navigation.js (limited to 'install/ui/src/freeipa/navigation.js') diff --git a/install/ui/src/freeipa/navigation.js b/install/ui/src/freeipa/navigation.js new file mode 100644 index 00000000..deef37dd --- /dev/null +++ b/install/ui/src/freeipa/navigation.js @@ -0,0 +1,455 @@ +/*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) { + + // get the selected tab + var panel = $(ui.panel); + var name = panel.attr('name'); + var selected_tab = that.get_tab(name); + + // get the tab specified in the URL state + var state = that.get_state(); + var url_tab = that.get_active_tab(state); + + if (url_tab) { + // if they are the same, the selection is triggered by hash change + if (url_tab == selected_tab) { + // use the URL state to update internal state + return that.push_state(state); + + // if the selection is for the ancestor + } else if (that.is_ancestor(url_tab, selected_tab)) { + // let the tab be updated and don't change the state + return true; + } + } + + // selection is triggered by mouse click, update the URL state + return that.show_tab(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 = $('