//移动层的类
function aListSetMove(){
this.Move = function(DivID,Evt){
if(DivID == "") return;
var DivObj = document.getElementById(DivID);
evt = Evt?Evt:window.event;
if(!DivObj) return;
var DivW = DivObj.offsetWidth;
var DivH = DivObj.offsetHeight;
var DivL = DivObj.offsetLeft;
var DivT = DivObj.offsetTop;
var TemDiv = document.createElement("div");
TemDiv.id = DivID + "tem";
document.body.appendChild(TemDiv);
TemDiv.style.cssText = "width:"+DivW+"px;height:"+DivH+"px;top:"+DivT+"px;left:"+DivL+"px;position:absolute; border:#ff0000 1px dotted;z-index:500";
this.MoveStart(DivID,evt);
}
this.MoveStart = function(DivID,Evt){
var TemDivObj = document.getElementById(DivID+"tem");
if(!TemDivObj) return;
evt = Evt?Evt:window.event;
var rLeft = evt.clientX - TemDivObj.offsetLeft;
var rTop = evt.clientY - TemDivObj.offsetTop;
if (!window.captureEvents){
TemDivObj.setCapture();
}else{
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
document.onmousemove = function(e)
{
if (!TemDivObj) return;
aListSetUnSelect();
e = e ? e : window.event;
if (e.clientX - rLeft <= 0){
TemDivObj.style.left = 0 +"px";
}else if(e.clientX - rLeft >= document.documentElement.clientWidth - TemDivObj.offsetWidth - 2){
TemDivObj.style.left = (document.documentElement.clientWidth - TemDivObj.offsetWidth - 2) +"px";
}else{
TemDivObj.style.left = e.clientX - rLeft +"px";
}
if (e.clientY - rTop <= 1){
}else{
TemDivObj.style.top = e.clientY - rTop +"px";
}
}
document.onmouseup = function()
{
if (!TemDivObj){
return;
}
if (!window.captureEvents){
TemDivObj.releaseCapture();
}else{
window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
var DivObj1 = document.getElementById(DivID);
if (!DivObj1) return;
var l0 = TemDivObj.offsetLeft;
var t0 = TemDivObj.offsetTop;
DivObj1.style.top = t0 + "px";
DivObj1.style.left = l0 + "px";
document.body.removeChild(TemDivObj);
TemDivObj = null;
}
}
}
function mouseMove(ev) {
ev2 = ev || window.event;
mousePos = mouseCoords(ev2);
}
function mouseCoords(ev) {
if (ev.pageX || ev.pageY) {
return {
x: ev.pageX, y: ev.pageY
};
}
try{
//IE6下,在开窗中再打开设置窗,显示错误,但不影响功能。
return {
x: ev.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft),
y: ev.clientY + (document.documentElement.scrollTop || document.body.scrollTop)
};
}catch(e){
}
}
var aListSetMoving = new aListSetMove();//创建移动层的实例
var mousePos; document.onmousemove = mouseMove;
function aListSetUnSelect(){
try{
document.selection.empty();
}
catch(e){
window.getSelection().removeAllRanges();
}
}
function aListSetIsShow(trID,sCfg,id){
// 检测id第几列状态
fCok = getcookie(aListSet_ckpre+trID+'_'+id); // (null)H/S/
fDef = sCfg.split('|')[id]; // (null)H/S/
if(fCok=='H'){
return 'H';
}
else if(fCok=='S'){
return 'S';
}
else{
if(fDef=='H'){
return 'H';
}
else {
return 'S';
}
}
}
function aListSetGetTable(trID,flag){
// 找到父级Table/CSS
if(flag=='td'){
return $id('TR_'+trID).getElementsByTagName('td')[1].className;
}else{
var tab = $id('TR_'+trID).parentNode;
if(tab.tagName.toUpperCase()!='TABLE') tab = tab.parentNode;
if(flag=='tb') return tab.className;
else return tab;
}
}
function XXX_aListSetGetCSS(trID){
// 找到Table CSS
var tab = aListSetGetTable(trID);
var objTR = $id('TR_'+trID);
var fline = 0; if(objTRs[0].getElementsByTagName('td').length==1) fline = 1;
}
function aListSetGetCols(trID,sCfg){
// IE6/IE7下,修正colspan=N
var objCols = $id('TR_'+trID).getElementsByTagName('td');
var fcols = 0;
var aCfg = sCfg.split('|');
for(var i = 0;i
if(aCfg[i]!='S'){
fcols++;
}else{
iFlg = aListSetIsShow(trID,sCfg,i);
if(iFlg=='S'){
fcols++;
}
}
}
return fcols;
}
function aListSetReset(trID,sCfg){
// 初始化Table
var objTRs = aListSetGetTable(trID).getElementsByTagName('tr');
var fline = 0; if(objTRs[0].getElementsByTagName('td').length==1) fline = 1;
for(i=fline;i
objTD = objTRs[i].getElementsByTagName('td');
for(j=0;j
if(aListSetIsShow(trID,sCfg,j)=='H'){
//objTD[j].sytle.display = 'none'; //无(width:0px)IE6报错?
objTD[j].style.cssText = 'width:0px;display:none;';
}
}
}
objTRs[fline].title = '双击进行详细设置';
sBtn = '
if(fline==0){
var aDiv = document.getElementsByTagName('div'); var flag = false;
for(i=0;i
if(aDiv[i].className=='conlist1') {
if(aDiv[i].innerHTML.indexOf('aListSetBtn'+aListSet_ckpre)<0){
//仅第一次执行,每页仅显示一个
aDiv[i].innerHTML = sBtn+aDiv[i].innerHTML; flag = true; // showMap()
}
break;
}
}
}else{
var objTD = aListSetGetTable(trID).getElementsByTagName('tr')[0].getElementsByTagName('td')[0];
if(objTD.innerHTML.indexOf('aListSetBtn'+aListSet_ckpre)<0){
objTD.innerHTML = sBtn+objTD.innerHTML; flag = true;
}
objTD.setAttribute("colSpan", aListSetGetCols(trID,sCfg));
}
/*
if(flag){
//仅第一次执行
var row1 = objTRs[0].getElementsByTagName('td'); //alert(row1.length);
for(j=0;j
if(aListSet_tCfg[j]!=''){
$iVal = row1[j].innerHTML;
if(row1[j].innerHTML.indexOf('"aListSetTDAct(')<0){
//$iVal = "\n"+$iVal+"";
//$iVal += "\n[x]隐藏此列";
//row1[j].innerHTML = $iVal;
}
//row1[j].title = '双击进行详细设置';
}
}
}
*/
}
function aListSetColumn(id,trID,type){
// 隐藏/显示某列
//aListSetReset();
if(type=='Show'){
//2^31=2,147,483,648; 1Year=31,536,000S
setcookie(aListSet_ckpre+trID+'_'+id, 'S', 321000123); type='';
}else{
setcookie(aListSet_ckpre+trID+'_'+id, 'H', 321000123); type='width:0px;display:none;';
}
var objTR = aListSetGetTable(trID).getElementsByTagName('tr');
for(var i = 0;i
objTD = objTR[i].getElementsByTagName('td');
for(var j = 0;j
if(j==id){
//objTD[j].innerHTML = '';
objTD[j].style.cssText = type;
}
}
}
aListSetGetTable(trID).style.cssText = 'width:100%';
}
function aListSetting(trID,sCfg){
// 设置窗口
aListSetUnSelect();
var alertWidth = 400; var boxID = 'aListSetBox_'+trID;
var alertW12 = Math.round(alertWidth/2);
var winWidth = document.body.clientWidth;
//alert(mousePos.y+':'+mousePos.x);
var alertTop = mousePos.y + 5; //得到滚动位置,设置对话框顶部位置
//var alertLeft = mousePos.x - alertW12; //设置对话框居中显示
var alertLeft = (document.documentElement.clientWidth-10-alertWidth)/2;
if(alertLeft<5) alertLeft = 5;
if(alertLeft+alertWidth>winWidth+5) alertLeft = winWidth - alertWidth - 5;
try{
document.body.removeChild($id(boxID));
}catch(e){
}
//if($id(boxID)){
//IE6出错! 用removeChild则不出错.
//$id(boxID).style.display =
...
...
(完整源码请下载查看)
...
展开> <收缩