EventUtil.addLoadHandler(function ()
{
var oMsgBox = get.byId("msgBox");
var oUserName = get.byId("userName");
var oConBox = get.byId("conBox");
var oSendBtn = get.byId("sendBtn");
var oMaxNum = get.byClass("maxNum")[0];
var oCountTxt = get.byClass("countTxt")[0];
var oList = get.byClass("list")[0];
var oUl = get.byTagName("ul", oList)[0];
var aLi = get.byTagName("li", oList);
var aFtxt = get.byClass("f-text", oMsgBox);
var aImg = get.byTagName("img", get.byId("face"));
var bSend = false;
var timer = null;
var oTmp = "";
var i = 0;
var maxNum = 140;
//禁止表单提交
EventUtil.addHandler(get.byTagName("form", oMsgBox)[0], "submit", function () {return false});
//广播按钮鼠标划过样式
EventUtil.addHandler(oSendBtn, "mouseover", function () {this.className = "hover"});
//广播按钮鼠标离开样式
EventUtil.addHandler(oSendBtn, "mouseout", function () {this.className = ""});
//li鼠标划过/离开处理函数
function liHover()
{
for (i = 0; i < aLi.length; i++)
{
//li鼠标划过样式
EventUtil.addHandler(aLi[i], "mouseover", function (event)
{
this.className = "hover";
oTmp = get.byClass("times", this)[0];
var aA = get.byTagName("a", oTmp);
if (!aA.length)
{
var oA = document.createElement("a");
oA.innerHTML = "删除";
oA.className = "del";
oA.href = "javascript:;";
oTmp.appendChild(oA)
}
else
{
aA[0].style.display = "block";
}
});
//li鼠标离开样式
EventUtil.addHandler(aLi[i], "mouseout", function ()
{
this.className = "";
var oA = get.byTagName("a", get.byClass("times", this)[0])[0];
oA.style.display = "none"
})
}
}
liHover();
//删除功能
function delLi()
{
var aA = get.byClass("del", oUl);
for (i = 0; i < aA.length; i++)
{
aA[i].onclick = function ()
{
var oParent = this.parentNode.parentNode.parentNode;
var alpha = 100;
var iHeight = oParent.offsetHeight;
timer = setInterval(function ()
{
css(oParent, "opacity", (alpha -= 10));
if (alpha < 0)
{
clearInterval(timer);
timer = setInterval(function ()
{
iHeight -= 10;
iHeight < 0 && (iHeight = 0);
css(oParent, "height", iHeight + "px");
iHeight == 0 && (clearInterval(timer), oUl.removeChild(oParent))
},30)
}
},30);
this.onclick = null
}
}
}
delLi();
//输入框获取焦点时样式
for (i = 0; i < aFtxt.length; i++)
{
EventUtil.addHandler(aFtxt[i], "focus", function (){this.className = "active"});
EventUtil.addHandler(aFtxt[i], "blur", function () {this.className = ""})
}
//格式化时间, 如果为一位数时补0
function format(str)
{
return str.toString().replace(/^(\d)$/,"0$1")
}
//头像
for (i = 0; i < aImg.length; i++)
{
aImg[i].onmouseover = function ()
{
this.className += " hover"
};
aImg[i].onmouseout = function ()
{
this.className = this.className.replace(/\s?hover/,"")
};
aImg[i].onclick = function ()
{
for (i = 0; i < aImg.length; i++) aImg[i].className = "";
this.className = "current"
}
}
});
</script>
</head>