Please disable Adblockers and enable JavaScript for domain CEWebS.cs.univie.ac.at! We have NO ADS, but they may interfere with some of our course material.
Name: ui/lib/ui.js
1: | function ui_click_tab(moi) { // {{{ |
2: | $(moi).trigger('click'); |
3: | } // }}} |
4: | |
5: | function ui_activate_tab(moi) { // {{{ |
6: | var active = $(moi).attr('id').replace(/tab/,''); |
7: | var tab = $(moi).parent().parent().parent().parent(); |
8: | var tabs = []; |
9: | $("td.tab",tab).each(function(){ |
10: | if (!$(this).attr('class').match(/switch/)) |
11: | tabs.push($(this).attr('id').replace(/tab/,'')); |
12: | }); |
13: | $(".inactive",tab).removeClass("inactive"); |
14: | $.each(tabs,function(a,b){ |
15: | if (b != active) { |
16: | $("#tab" + b).addClass("inactive"); |
17: | $("#area" + b).addClass("inactive"); |
18: | } |
19: | }); |
20: | ui_rest_resize(); |
21: | } // }}} |
22: | function ui_activate_section(section) { |
23: | section.parent().children().each(function() { |
24: | if(!$(this).hasClass("hidden")) |
25: | $(this).addClass("hidden"); |
26: | }); |
27: | section.removeClass("hidden"); |
28: | } |
29: | function ui_toggle_vis_tab(moi) {// {{{ |
30: | var tabbar = $(moi).parent().parent().parent(); |
31: | var tab = $(tabbar).parent(); |
32: | var fix = $(tab).parent(); |
33: | $('h1',moi).toggleClass('margin'); |
34: | $("tr.border",tabbar).toggleClass('hidden'); |
35: | $("div.tabbelow",tab).toggleClass('hidden'); |
36: | $("td.tabbehind button",tabbar).toggleClass('hidden'); |
37: | if ($(fix).attr('class') && $(fix).attr('class').match(/fixedstate/)) { |
38: | $(".fixedstatehollow").height($(fix).height()); |
39: | } |
40: | ui_rest_resize(); |
41: | }// }}} |
42: | |
43: | function ui_rest_resize() { |
44: | if ($('div.tabbed.rest .tabbar')) { |
45: | var theight = $(window).height() - $('div.tabbed.rest .tabbar').offset().top - $('div.tabbed.rest .tabbar').height(); |
46: | $('div.tabbed.rest .tabbelow').height(theight); |
47: | $('div.tabbed.rest .tabbelow .column').height(theight); |
48: | } |
49: | } |
50: | |
51: | function ui_close_tab(moi){ |
52: | var active = $(moi).parent().attr('id').replace(/tab/,''); |
53: | var is_inactive = $(moi).parent().hasClass('inactive'); |
54: | $('#area' + active).remove(); |
55: | $('#tab' + active).remove(); |
56: | if (!is_inactive) |
57: | ui_click_tab($('.tabbed table.tabbar td.tab.default')); |
58: | } |
59: | |
60: | function ui_add_close(moi) { |
61: | $(moi).append($('<span class="close">✖</span>')); |
62: | } |
63: | |
64: | function ui_add_tab(tabbar,title,id,closeable,additionalclasses) { |
65: | additionalclasses = typeof additionalclasses !== 'undefined' ? additionalclasses : ''; |
66: | var instab = $("<td class='tab inactive" + (closeable ? ' closeable' : '') + (additionalclasses == '' ? '' : ' ' + additionalclasses) + "' id='tab_" + id + "'><h1>" + title + "</h1></td>"); |
67: | var insarea = $("<div id='area_" + id + "' class='inactive'></div>"); |
68: | $(tabbar).find('tr td.tabbehind').before(instab); |
69: | $(tabbar).find('.tabbelow').append(insarea); |
70: | ui_add_close($('#tab_' + id)); |
71: | } |
72: | |
73: | function ui_clone_tab(tabbar,original,title,id,closeable,additionalclasses) { |
74: | additionalclasses = typeof additionalclasses !== 'undefined' ? additionalclasses : ''; |
75: | var instab = $("<td class='tab inactive" + (closeable ? ' closeable' : '') + (additionalclasses == '' ? '' : ' ' + additionalclasses) + "' id='tab_" + id + "'><h1>" + title + "</h1></td>"); |
76: | var insarea = original.clone(); |
77: | insarea.attr("id","area_"+id); |
78: | insarea.attr("class","inactive"); |
79: | $(tabbar).find('tr td.tabbehind').before(instab); |
80: | $(tabbar).parent('.tabbed').find('.tabbelow').append(insarea); |
81: | ui_add_close($('#tab_' + id)); |
82: | } |
83: | |
84: | $(document).ready(function() { |
85: | $(window).resize(ui_rest_resize); |
86: | $('.tabbed table.tabbar td.tab.switch').click(function(){ui_toggle_vis_tab(this);}); |
87: | $(document).on('click','.tabbed table.tabbar td.tab:not(.switch)',function(){ui_activate_tab(this);}); |
88: | ui_add_close($('.tabbed table.tabbar td.tab.closeable')); |
89: | $(document).on('click','.tabbed table.tabbar td.tab.closeable .close',function(){ui_close_tab(this);}); |
90: | }); |