-
Notifications
You must be signed in to change notification settings - Fork 2
/
template.js
104 lines (84 loc) · 2.37 KB
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Tab code.
function tabChange() {
var $this = $(this);
var cls = ".tab-" + $this.data("lookfor");
// Set this to be the only active tab
$this.parent().find("> li").removeClass("active");
$this.parent().find("> li").addClass("inactive");
// Hide all but the one tab
var top = $this.parent().parent();
top.find("> div").hide();
var tab = top.find("> " + cls);
tab.show();
// Hide sections irrelevant to the tab
tab.find(".tab-hide").hide();
// Show only relevant ones
tab.find(cls).show();
$this.addClass("active");
$this.removeClass("inactive");
return false;
}
jQuery(function($) {
$(".tabdiv > ul li").each(function () {
var $this = $(this);
var a = $this.find("a");
$this.data("lookfor", a.attr("href").substr(1));
$(a).attr("href", ""); // Opera hates real hrefs
$this.click(tabChange);
});
$(".tabdiv > ul li:first").click();
});
// Hidden sections
jQuery(function($) {
$(".hidden-rows").each(function () {
var $this = $(this);
$this.children(":not(.hidden-text)").hide();
$this.children(".hidden-text").click(function () {
$(this).hide().parent().find(":not(.hidden-text)").show();
});
})
});
// Help sections
jQuery(function($) {
// Add tooltip span
$('<span id="tooltip" style="position:absolute; display: none">').mouseleave(tooltipMaybeHide).appendTo("body");
// Hook tooltips
$(".help").each(function () {
var $this = $(this);
var help = $this.text();
tooltip($this.text("?"), help);
});
});
function tooltip($elem, text) {
$elem.data("tooltip", text).mouseenter(tooltipShow).mouseleave(tooltipMaybeHide);
}
function tooltipShow() {
var $this = $(this), offset = $this.offset();
offset.top += $this.height();
$("#tooltip").text($this.data("tooltip")).css(offset).data("for", this).show();
}
function tooltipMaybeHide(e) {
$tooltip = $("#tooltip");
if (e.toElement != $tooltip[0] && e.toElement != $tooltip.data("for")) {
$tooltip.data("for", null).hide().text("");
}
}
function hidecheck(s) {
$(s).prop("checked", false).parent().hide();
}
function prefixIfTrue(pfx, x, sfx) {
return x ? pfx + x + (sfx || "") : x;
}
function filterAndPrefixAll(pfx, arr, sfx) {
var out = "";
sfx = sfx || "";
for (var i = 0; i < arr.length; ++i) {
if (arr[i]) out += pfx + arr[i] + sfx;
}
return out;
}
function htmlDecode(input)
{
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}