forked from cite-sa/es2-service-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tab-panel.js
50 lines (47 loc) · 1.95 KB
/
tab-panel.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
$(function () {
$.widget("panel.tabPanel", $.dock.panel, {
options: {
panelType: "tab"
},
_create: function () {
this._super();
this.panelBody
.append(
$("<ul>", {class: "nav nav-tabs", role: "tablist"})
).append(
$("<div>", {class: "tab-content"})
);
},
addTab: function (tabId, tabText, contentTitle, contentSubtitle, content) {
var tab = $("<li>", {role: "presentation"})
.append($("<a>", {
href: "#" + tabId,
"aria-controls": tabId,
role: "tab",
"data-toggle": "tab"
}).text(tabText))
.appendTo(this.panelBody.find(".nav-tabs"));
var tabPanel = $("<div>", {role: "tabpanel", class: "tab-pane", id: tabId})
.appendTo(this.panelBody.find(".tab-content"));
this._buildTabContent(tabPanel, contentTitle, contentSubtitle, content);
if (this.panelBody.find(".nav-tabs").children().length == 1) {
tab.addClass("active");
tabPanel.addClass("active");
}
return this;
},
_buildTabContent: function(tabPanel, title, subtitle, content) {
tabPanel
.append(
$("<div>", {class: "panel panel-default"})
.append($("<div>", {class: "panel-heading"})
.append($("<div>", {class: "panel-title"})
.append(title))
.append($("<div>", {class: "panel-title panel-subtitle"})
.append(subtitle))
)
.append($("<div>", {class: "panel-body"})
.append(content)));
}
})
});