Name: cockpit/lib/ui.js
| 1: | /* |
| 2: | This file is part of CPEE. |
| 3: | |
| 4: | CPEE is free software: you can redistribute it and/or modify it under the terms |
| 5: | of the GNU General Public License as published by the Free Software Foundation, |
| 6: | either version 3 of the License, or (at your option) any later version. |
| 7: | |
| 8: | CPEE is distributed in the hope that it will be useful, but WITHOUT ANY |
| 9: | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 10: | PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 11: | |
| 12: | You should have received a copy of the GNU General Public License along with |
| 13: | CPEE (file COPYING in the main directory). If not, see |
| 14: | <http://www.gnu.org/licenses/>. |
| 15: | */ |
| 16: | |
| 17: | function ui_tab_click(moi) { // {{{ |
| 18: | var active = $(moi).attr('id').replace(/tab/,''); |
| 19: | var tab = $(moi).parent().parent().parent().parent(); |
| 20: | var tabs = []; |
| 21: | $("td.tab",tab).each(function(){ |
| 22: | if (!$(this).attr('class').match(/switch/)) |
| 23: | tabs.push($(this).attr('id').replace(/tab/,'')); |
| 24: | }); |
| 25: | $(".inactive",tab).removeClass("inactive"); |
| 26: | $.each(tabs,function(a,b){ |
| 27: | if (b != active) { |
| 28: | $("#tab" + b).addClass("inactive"); |
| 29: | $("#area" + b).addClass("inactive"); |
| 30: | } |
| 31: | }); |
| 32: | ui_rest_resize(); |
| 33: | } // }}} |
| 34: | function ui_toggle_vis_tab(moi) {// {{{ |
| 35: | var tabbar = $(moi).parent().parent().parent(); |
| 36: | var tab = $(tabbar).parent(); |
| 37: | var fix = $(tab).parent(); |
| 38: | $('h1',moi).toggleClass('margin'); |
| 39: | $("tr.border",tabbar).toggleClass('hidden'); |
| 40: | $("div.tabbelow",tab).toggleClass('hidden'); |
| 41: | $("td.tabbehind button",tabbar).toggleClass('hidden'); |
| 42: | if ($(fix).attr('class') && $(fix).attr('class').match(/fixedstate/)) { |
| 43: | $(".fixedstatehollow").height($(fix).height()); |
| 44: | } |
| 45: | ui_rest_resize(); |
| 46: | }// }}} |
| 47: | |
| 48: | function ui_rest_resize() { |
| 49: | if ($('div.tabbed.rest .tabbar')) { |
| 50: | var theight = $(window).height() - $('div.tabbed.rest .tabbar').offset().top - $('div.tabbed.rest .tabbar').height(); |
| 51: | $('div.tabbed.rest .tabbelow').height(theight); |
| 52: | $('div.tabbed.rest .tabbelow .column').height(theight); |
| 53: | } |
| 54: | } |
| 55: | |
| 56: | $(document).ready(function() { |
| 57: | $(window).resize(ui_rest_resize); |
| 58: | $('.tabbed table.tabbar td.tab.switch').click(function(){ui_toggle_vis_tab(this);}); |
| 59: | $('.tabbed table.tabbar td.tab').not('.switch').click(function(){ui_tab_click(this);}); |
| 60: | }); |
