css
複製代碼 代碼如下:<style type="text/css">
#bodycontainer
{
height: 66px;
}
#leftcontainer
{
background-color: #C5C5C5;
float: left;
border: 1px solid #C5C5C5;
}
</style>
aspx: 複製代碼 代碼如下:<div id="bodycontainer">
<div id="leftcontainer+<%#Container.ItemIndex+1 %>" style="display:none;">
<%#hiSoft.AMS.BLL.BAssetAlteration.getActionLinksString(Eval("ID"), g_Sites, g_Permission)%>
</div>
<div>
<img title="show" alt="open" src="Images/x16.gif" id="showleft+<%#Container.ItemIndex+1 %>" onclick="var leftslider = new slider(this,1,50,85,20,1,20);leftslider.show();this.style.display='none';Show(this);"/>
<script type="text/javascript">
function Show(a) {
//a.style.display = 'none';
document.getElementById(a.parentElement.children[2].id).style.display = '';
}
</script>
<img title="hidden" alt="close" src="Images/x16.gif" id="hideleft+<%#Container.ItemIndex+1 %>" onclick="var leftslider = new slider(this,1,50,85,20,1,20);leftslider.hide();this.style.display='none';document.getElementById(this.parentElement.children[0].id).style.display='';" style="display:none " />
</div>
</div>
slider.js: 複製代碼 代碼如下:slider.names = new Array();
function slider()
{
this.id = slider.names.length;
slider.names[this.id] = this;
this.target = document.getElementById(arguments[0].parentElement.parentElement.children[0].id); //第一個參數:被操作div的id
this.direction = arguments[1];//第二個參數:div彈出的方向
this.height = arguments[2];//第三個參數:div的高度
this.width = arguments[3];//第四個參數:div的寬度
this.step = arguments[4];//第五個參數:希望動作分解為幾步完成
this.timer = 10 * arguments[5];//第六個參數:每個動作的間隔時間,10ms為一個單位
this.startopa = arguments[6];//第七個參數:div開始的透明度
this.sparent = this.target.parentNode;//擷取操作div的父容器
this.intervalid = null;//迴圈定時的id
this.i = 0;//迴圈的計數器
this.status = 0;//slider層的狀態:0-可以展開;1-不可以展開
this.target.style.display = "none";//先將div隱去
return this;
}
slider.prototype.initialize = function()
{
this.sparent.style.overflow = "hidden";//設定父容器overflow
this.target.style.width = Number(this.width) + 'px';//設定目標div的寬度
this.target.style.height = Number(this.height) + 'px';//設定目標div的高度
this.target.style.position = "";//設定目標div的定位方式
this.target.style.display = "";//設定目標div的顯示方式
this.target.style.filter = 'Alpha(opacity=' + Number(this.startopa) + ')';//設定目標div的透明度為初始透明度
this.target.style.overflow = "hidden";//設定overflow
switch(this.direction)//根據彈出方向設定div的margin
{
case 1://left to right
this.target.style.marginLeft = "-" + this.width + "px";
break;
case 2://top to bottom
this.target.style.marginTop = "-" + this.height + "px";
break;
case 3://right to left
this.target.style.marginRight = "-" + this.width + "px";
break;
}
}
slider.prototype.show = function()
{
if (this.status==0)//檢查狀態是否已經展開
{
this.initialize();//操作div及其父容器的初始化
this.intervalid = window.setInterval("slider.names["+this.id+"].cycle()",this.timer);//設定動作迴圈
}
}
slider.prototype.hide = function()
{
if (this.status==1)//檢查狀態是否已經展開
{
this.intervalid = window.setInterval("slider.names["+this.id+"].decycle()",this.timer);//設定動作迴圈
}
}
slider.prototype.cycle = function() //單步迴圈動作
{
var opa = this.target.style.filter.split("=")[1].split(")")[0]//擷取目標div的透明度數值
var opastep = Math.round(((100 - Number(opa)) / this.step)+2.5);//計算每步增加的透明度
var nopa = Number(opa) + Number(opastep);//當前透明度
if (nopa>100){this.target.style.filter = 'Alpha(opacity=100)';}else{this.target.style.filter = 'Alpha(opacity=' + String(nopa) + ')';}//給div透明度賦值
switch(this.direction)//根據彈出方向計算和設定div的動作
{
case 1: //left to right
var opx = this.target.style.marginLeft.split("px")[0];
var pxstep = Math.round((this.width / this.step)+0.5);
var npx = Number(opx) + Number(pxstep);
if (npx>0){this.target.style.marginLeft = '0px';}else{this.target.style.marginLeft = String(npx) + 'px';}
break;
case 2: //top to bottom
var opx = this.target.style.marginTop.split("px")[0];
var pxstep = Math.round((this.height / this.step)+0.5);
var npx = Number(opx) + Number(pxstep);
if (npx>0){this.target.style.marginTop = '0px';}else{this.target.style.marginTop = String(npx) + 'px';}
break;
case 3: //right to left
var opx = this.target.style.marginRight.split("px")[0];
var pxstep = Math.round((this.width / this.step)+0.5);
var npx = Number(opx) + Number(pxstep);
if (npx>0){this.target.style.marginRight = '0px';}else{this.target.style.marginRight = String(npx) + 'px';}
break;
}
this.i++ //計數器+1
if (this.i>(this.step-1)){window.clearInterval(this.intervalid);this.i=0;this.status=1;} //迴圈完畢,清除迴圈定時
}
slider.prototype.decycle = function() //單步迴圈動作
{
var opa = this.target.style.filter.split("=")[1].split(")")[0]//擷取目標div的透明度數值
var opastep = Math.round(((100 - Number(opa)) / this.step)+2.5)*2;//計算每步增加的透明度
var nopa = Number(opa) - Number(opastep);//當前透明度
if (nopa<this.startopa){this.target.style.filter = 'Alpha(opacity=' + this.startopa + ')';}else{this.target.style.filter = 'Alpha(opacity=' + String(nopa) + ')';}//給div透明度賦值
switch(this.direction)//根據彈出方向計算和設定div的動作
{
case 1: //left to right
var opx = this.target.style.marginLeft.split("px")[0];
var pxstep = Math.round((this.width / Math.round(this.step*0.5))+0.5);
var npx = Number(opx) - Number(pxstep);
if (Math.abs(npx)>this.width+2){this.target.style.marginLeft = '-' + this.width + 'px';}else{this.target.style.marginLeft = String(npx) + 'px';}
break;
case 2: //top to bottom
var opx = this.target.style.marginTop.split("px")[0];
var pxstep = Math.round((this.height / Math.round(this.step*0.5))+0.5);
var npx = Number(opx) - Number(pxstep);
if (Math.abs(npx)>this.height+2){this.target.style.marginTop = '-' + this.height + 'px';}else{this.target.style.marginTop = String(npx) + 'px';}
break;
case 3: //right to left
var opx = this.target.style.marginRight.split("px")[0];
var pxstep = Math.round((this.width / Math.round(this.step*0.5))+0.5);
var npx = Number(opx) - Number(pxstep);
if (Math.abs(npx)>this.width+2){this.target.style.marginRight = '-' + this.width + 'px';}else{this.target.style.marginRight = String(npx) + 'px';}
break;
}
this.i++ //計數器+1
if (this.i>(Math.round(this.step*0.5)-1)){window.clearInterval(this.intervalid);this.i=0;this.status=0;this.target.style.display = "none";} //迴圈完畢,清除迴圈定時
}