forked from cite-sa/es2-service-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdock-panel.js
56 lines (53 loc) · 2.12 KB
/
dock-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
51
52
53
54
55
56
$(function () {
$.widget("dock.panel", {
options: {
dock: undefined,
panelId: undefined,
panelType: "empty",
panelTitle: "",
panelSubtitle: ""
},
_create: function () {
var panel = this._buildPanel();
var container;
if (this.options.dock.find(".mCSB_container").length > 0) {
container = this.options.dock.find(".mCSB_container");
} else {
container = this.options.dock;
}
panel.panel.appendTo(container);
this.panel = panel.panel;
this.panelBody = panel.panelBody;
},
addButton: function(buttonContent) {
var buttonContainer = this.panelBody.find(".panel-btn-container");
if (buttonContainer.length == 0) {
buttonContainer = $("<div>", {class: "panel-btn-container"})
.appendTo(this.panelBody);
}
$("<button>", {class: "btn btn-default panel-btn"})
.append(buttonContent)
.appendTo(buttonContainer);
return this;
},
_buildPanel: function() {
var panel = $("<div>", {id: this.options.panelId, class: "panel panel-default " + this.options.panelType + "-panel"});
if (this.options.panelType != "tab") {
panel.append(
$("<div>", {class: "panel-heading"})
.append(
$("<h3>", {class: "panel-title"})
.append(this.options.panelTitle)
)
.append(
$("<h4>", {class: "panel-title panel-subtitle"})
.append(this.options.panelSubtitle)
)
);
}
var panelBody = $("<div>", {class: "panel-body"})/*.append(bodyContent)*/
.appendTo(panel);
return {panel: panel, panelBody: panelBody};
}
})
});