-
-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathvpAccordionBox.js
More file actions
130 lines (114 loc) · 4.45 KB
/
Copy pathvpAccordionBox.js
File metadata and controls
130 lines (114 loc) · 4.45 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
define([
'require'
, 'jquery'
, 'nbextensions/visualpython/src/common/vpCommon'
, 'nbextensions/visualpython/src/common/constant'
, 'nbextensions/visualpython/src/common/StringBuilder'
, 'nbextensions/visualpython/src/common/component/vpComComponent'
], function (requirejs, $, vpCommon, vpConst, sb, vpComComponent) {
/**
* @class vpAccordionBox 아코디언 박스 객체
* @constructor
* @param {String} caption 박스 캡션
* @param {boolean} open 초기 오픈 상태
* @param {boolean} uniqueness 동일레벨에서 한 박스만 오픈 허용
*/
var vpAccordionBox = function(caption = " ", open = false, uniqueness = false) {
this.setUUID();
if (caption == "") {
caption = " ";
}
this._contents = "";
this._caption = caption;
this._isOpen = open;
this._uniqueness = uniqueness;
this._additionalClass = "";
this._attributes = "";
};
vpAccordionBox.prototype = Object.create(vpComComponent.vpComComponent.prototype);
/**
* 박스 헤더 캡션 설정
* @param {String} caption 박스 캡션
*/
vpAccordionBox.prototype.setCaption = function(caption = " ") {
if (caption == "") {
caption = " ";
}
this._caption = caption;
}
/**
* 박스 컨텐츠 내용 설정
* @param {String} html contents
*/
vpAccordionBox.prototype.setContent = function(html = "") {
this._contents = html;
}
/**
* 박스 컨텐츠 내용 append
* @param {String} html contents
*/
vpAccordionBox.prototype.appendContent = function(html = "") {
this._contents = vpCommon.formatString("{0}{1}", this._contents, html);
}
/**
* 박스 컨텐츠 내용 preppend
* @param {String} html contents
*/
vpAccordionBox.prototype.prependContent = function(html = "") {
this._contents = vpCommon.formatString("{0}{1}", html, this._contents);
}
/**
* 박스 생성시 오픈 여부 설정
* @param {boolean} open 초기 오픈 상태
* @param {boolean} uniqueness 동일레벨에서 한 박스만 오픈 허용
*/
vpAccordionBox.prototype.setOpenBox = function(open = false) {
this._isOpen = open;
}
/**
* 동일 레벨에서 한개만 오픈 허용여부 설정
* @param {boolean} uniqueness 동일레벨에서 한 박스만 오픈 허용
*/
vpAccordionBox.prototype.setUniqueness = function(uniqueness = false) {
this._uniqueness = uniqueness;
}
/**
* 추가 클래스 설정
* @param {String} additionalClass 추가 클래스
*/
vpAccordionBox.prototype.addClass = function(additionalClass = "") {
if (additionalClass == "") return;
var that = this;
that._additionalClass = vpCommon.formatString("{0} {1}", that._additionalClass, additionalClass);
}
/**
* 추가 속성 부여
* @param {String} attrName 속성명
* @param {String} attrValue 속성값
*/
vpAccordionBox.prototype.addAttribute = function(attrName = "", attrValue = "") {
if (attrName == "") return;
var that = this;
that._attributes = vpCommon.formatString("{0} {1}='{2}'", that._attributes, attrName, attrValue);
}
/**
* 아코디언 박스 태그 생성
* @returns html accordion box tag string
*/
vpAccordionBox.prototype.toTagString = function() {
var sbTagString = new sb.StringBuilder();
var that = this;
sbTagString.appendFormatLine("<div class='{0} {1} {2} {3} {4}' {5}>"
, that._UUID, vpConst.ACCORDION_CONTAINER, that._isOpen ? vpConst.ACCORDION_OPEN_CLASS : "", that._uniqueness ? "uniqueType" : "", that._additionalClass, that._attributes);
sbTagString.appendFormatLine("<div class='{0}'>", vpConst.ACCORDION_HEADER);
sbTagString.appendFormatLine("<span class='{0}{1}'></span>", vpConst.VP_CLASS_PREFIX, "accordion-indicator");
sbTagString.appendFormatLine("<span class='{0}{1}'>{2}</span>", vpConst.VP_CLASS_PREFIX, "accordion-caption", that._caption);
sbTagString.appendLine("</div>");
sbTagString.appendFormatLine("<div class='{0}'>{1}</div>", vpConst.ACCORDION_CONTENT_CLASS, that._contents);
sbTagString.appendLine("</div>");
return sbTagString.toString();
}
return {
vpAccordionBox: vpAccordionBox
}
});