-
Notifications
You must be signed in to change notification settings - Fork 1
/
dock-panel.js
85 lines (81 loc) · 3.76 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
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
$(function () {
$.widget("dock.panel", {
options: {
dock: undefined,
panelId: undefined,
panelType: "empty",
panelTitle: "",
panelSubtitle: "",
collapsible: false
},
_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(buttonId, buttonContent) {
var buttonContainer = this.panelBody.find(".panel-btn-container");
if (buttonContainer.length == 0) {
buttonContainer = $("<div>", {class: "panel-btn-container"})
.appendTo(this.panelBody);
}
var button = $("<button>", {id: buttonId, 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"}).appendTo(panel);
if (this.options.collapsible) {
panel.addClass("collapsible");
panelBody.uniqueId().addClass("collapse in");
/*panel.children(".panel-heading")
.attr({"data-toggle":"collapse", "data-target": "#" + panelBody.attr("id"), "aria-expanded": false, "aria-controls": "panelCollapse"});*/
panel.find(".panel-title:not(.panel-subtitle)")
.addClass("panel-collapser")
.append($("<span>", {
class: "glyphicon glyphicon-minus",
"data-toggle": "collapse",
"data-target": "#" + panelBody.attr("id"),
"aria-expanded": false,
"aria-controls": "panelCollapse"
}).hover(function() {
$(this).parents(".collapsible").addClass("hovered");
}, function() {
$(this).parents(".collapsible").removeClass("hovered");
})
.click(function() {
if (panelBody.hasClass("in")) {
$(this).removeClass("glyphicon glyphicon-minus");
$(this).addClass("glyphicon glyphicon-modal-window");
} else {
$(this).removeClass("glyphicon glyphicon-modal-window");
$(this).addClass("glyphicon glyphicon-minus");
}
}));
}
return {panel: panel, panelBody: panelBody};
}
})
});