반응형
base ui class
function BDBUI(){
this.templete,
this._popup,
this.popup,
this.callback = null
}
BDBUI.prototype.init = function(){
this._popup = this._stringToHTML(this.templete)
}
BDBUI.prototype.show = function(){
this.hide()
this.popup = this._popup.cloneNode(true)
document.body.appendChild(this.popup)
}
BDBUI.prototype.has = function(){
return this.popup
}
BDBUI.prototype.hide = function(){
if (this.has()){
while(this.popup.firstChild){
this.popup.firstChild.remove()
}
this.popup.remove()
this.popup = null
return true
} else {
return false
}
}
BDBUI.prototype._stringToHTML = function (str) {
var parser = new DOMParser();
var doc = parser.parseFromString(str, 'text/html');
return doc.body.firstChild;
}
BDBUI.prototype.copy = function(obj){
return Object.assign({}, obj);
}
sub ui class
function SubUI(){
BDBUI.call(this)
this.templete = "<div></div>"
}
SubUI.prototype = Object.create(BDBUI.prototype)
SubUI.prototype.constructor = SubUI
//custom function
SubUI.prototype.sd = function(){
console.log(this.templete)
}
sub ui class 호출
const subui = new SubUI()
subui.init()
subui.sd()
subui.show()
console.log(subui)
반응형
'JAVASCRIPT' 카테고리의 다른 글
(javascript) 암호화 정리중 .. (0) | 2023.02.20 |
---|---|
(js) 파일 업로드 , 다운로드 (0) | 2023.01.10 |
(javascript)이스케이프 문자열 치환 (0) | 2022.05.12 |
(js) 자바스크립트 기초 - HTMLCollection , NodeList (0) | 2022.04.03 |
(JS) 자바스크립트 기초 - heap,stack,webApi,callback queue, event loop (0) | 2022.03.31 |