/*
class MyCboList
created : 081031
last Updated : 081229
lee jong su
*/
{
function MyCboBox(targetElement)
{
this.mo_targetElement = targetElement;
this.ms_text = "MENU";
this.ms_value = "";
this.mi_boxWidth = 100;
this.mi_boxHeight = 0;
this.ms_boxFont = "gulim";
this.mi_boxFontSize = 12;
this.ms_boxFontColor = "222222";
this.ms_boxBorder = "1px solid";
this.ms_boxBorderColor = "B8B8B8";
this.ma_childs = null;
this.mi_width = 0;
this.mi_height = 0;
this.mi_left = 0;
this.mi_top = 0;
this.mo_shadowLayer = null;
this.mo_listLayer = null;
this.mo_callbackFunction = null;
}
MyCboBox.prototype =
{
setListSize: function(width, height) {
this.mi_width = width;
this.mi_height = height;
},
setListPosition: function(left, top) {
this.mi_left = left;
this.mi_top = top;
},
checkList: function() {
if (this.mo_shadowLayer) return true;
return false;
},
setDefaultValue: function(text, value) {
this.ms_text = text;
this.ms_value = value;
},
setBoxWidth: function(width) {
this.mi_boxWidth = width;
},
setBoxHeight: function(height) {
this.mi_boxHeight = height;
},
setBoxFont: function(font) {
this.ms_boxFont = font;
},
setBoxFontSize: function(size) {
this.mi_boxFontSize = size;
},
setBoxFontColor: function(color) {
this.ms_boxFontColor = color;
},
setBoxBorder: function(border) {
this.ms_boxBorder = border;
},
setBoxBorderColor: function(color) {
this.ms_boxBorderColor = color;
},
createBox: function(func) {
this.mo_callbackFunction = func;
this.mo_targetElement.innerHTML =
'
' +
'
' + this.ms_text + '
' +
'
' +
'

' +
'
' +
'
';
this.mo_targetElement.firstChild.childNodes[1].style.height = (Element.getHeight(this.mo_targetElement.firstChild) - 14) + "px";
var width = Element.getWidth(this.mo_targetElement.firstChild);
var height = Element.getHeight(this.mo_targetElement.firstChild);
this.setListSize(width - 2, 150);
var thisElement = this;
this.mo_targetElement.firstChild.onclick = function() {
var pos = Element.cumulativeOffset(thisElement.mo_targetElement.firstChild);
if (navigator.appVersion.indexOf("MSIE 6") > -1) { pos[1] -= document.body.scrollTop; } // IE 6.0
thisElement.setListPosition(pos[0], pos[1] + height - 1);
if (thisElement.mo_shadowLayer) {
thisElement.removeList();
}
else {
thisElement.createList();
}
}
},
createList: function() {
var thisElement = this;
try {
var listLayer = document.getElementById("myCboList");
var listShadowLayer = document.getElementById("myCboListShadow");
listLayer.parentNode.removeChild(listLayer);
listShadowLayer.parentNode.removeChild(listShadowLayer);
} catch(e) {}
this.mo_shadowLayer = document.createElement("DIV");
this.mo_listLayer = document.createElement("DIV");
this.mo_listLayer.className = "x-layer x-combo-list";
this.mo_listLayer.setAttribute("id", "myCboList");
this.mo_listLayer.style.zIndex = 11000;
this.mo_listLayer.style.position = "absolute";
this.mo_listLayer.style.left = this.mi_left + "px";
this.mo_listLayer.style.top = this.mi_top + "px";
this.mo_listLayer.style.width = this.mi_width + "px";
this.mo_listLayer.style.border = "1px solid #B3B3B3";
if (this.mi_boxHeight) {
this.mo_listLayer.style.maxHeight = this.mi_boxHeight + "px";
this.mo_listLayer.style.overflowY = "auto";
this.mo_listLayer.className = "scroll";
}
else {
this.mo_listLayer.style.height = "auto";
}
this.mo_shadowLayer.className = "x-id-shadow";
this.mo_shadowLayer.setAttribute("id", "myCboListShadow");
this.mo_shadowLayer.style.zIndex = "10999";
this.mo_shadowLayer.style.backgroundColor = "#676767";
this.mo_shadowLayer.style.filter = " progid:DXImageTransform.Microsoft.alpha(opacity=30) progid:DXImageTransform.Microsoft.Blur(pixelradius=4)";
this.mo_shadowLayer.style.position = "absolute";
this.mo_shadowLayer.style.left = (this.mi_left - 4) + "px";
this.mo_shadowLayer.style.top = (this.mi_top - 3) + "px";
this.mo_shadowLayer.style.width = (this.mi_width + 6) + "px";
//높이 : 목록을 불러 온 후 계산
document.body.appendChild(this.mo_shadowLayer);
document.body.appendChild(this.mo_listLayer);
try {
this.mo_listLayer.style.display = "none";
this.mo_shadowLayer.style.display = "none";
Effect.Appear(this.mo_listLayer, { duration: 0.1 });
Effect.Appear(this.mo_shadowLayer, { duration: 0.1 });
} catch(e) {
this.mo_listLayer.style.display = "block";
this.mo_shadowLayer.style.display = "block";
}
this.fillList();
},
setList: function(text, value, selected) {
if (!this.ma_childs) this.ma_childs = new Array();
var tmp = new Array();
tmp['text'] = text;
tmp['value'] = value;
this.ma_childs.push(tmp);
if (selected) this.setDefaultValue(text, value);
},
fillList: function() {
var thisElement = this;
this.ma_childs.each (function(e) {
var child = document.createElement("DIV");
child.className = "x-combo-list-item";
child.setAttribute("value", e['value']);
child.innerHTML = e['text'];
child.style.fontFamily = thisElement.ms_boxFont;
child.style.fontSize = thisElement.mi_boxFontSize;
child.style.color = "#" + thisElement.ms_boxFontColor;
child.style.padding = "5px 5px 5px 5px";
child.style.cursor = "pointer";
child.onmouseover = function() {
this.className = "x-combo-list-item x-combo-selected";
this.style.backgroundColor = "#" + thisElement.ms_boxBorderColor;
}
child.onmouseout = function() {
this.className = "x-combo-list-item";
this.style.backgroundColor = "#FFFFFF";
}
child.onclick = function() {
thisElement.mo_targetElement.firstChild.firstChild.innerHTML = this.innerHTML;
thisElement.setDefaultValue(this.innerHTML, this.getAttribute("value"));
thisElement.removeList();
thisElement.click(thisElement.mo_callbackFunction);
}
thisElement.mo_listLayer.appendChild(child);
});
this.mo_shadowLayer.style.height = (Element.getHeight(this.mo_listLayer) + 3) + "px";
/*
this.mo_listLayer.focus();
this.mo_listLayer.onblur = function() {
alert(3);
}
*/
},
click: function(func) {
func(
this.ms_text,
this.ms_value
);
},
removeList: function() {
try {
this.mo_shadowLayer.parentNode.removeChild(this.mo_shadowLayer);
this.mo_listLayer.parentNode.removeChild(this.mo_listLayer);
this.mo_shadowLayer = null;
this.mo_listLayer = null;
} catch(e) {}
}
}
}