karansokhey
02-05-2007, 05:44 AM
http://www.desiwest.com/karan/collapse/
How would you change the "Hide" button to "Show" accordingly? Also I was wondering how you can set a cookie or have the browser remember if it was last hidden or shown. So if you reload the page, it will display the previous action.
Thank you in advance.:thumbsup:
vwphillips
02-05-2007, 07:00 AM
hmm
can the script you are using cope with opening and closing more than one DIV?
karansokhey
02-05-2007, 12:18 PM
Yes it can, but you would have to add the element ids and all that into js/collapser.js
vwphillips
02-05-2007, 01:02 PM
to add the element ids and all that into js/collapser.js
seems a bit of a pain.
may do this this but using my own script.
karansokhey
02-05-2007, 03:50 PM
Any help would be very much appreciated. How would I go upon doing this?
vwphillips
02-05-2007, 04:53 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
// DIV Change Height(with Persistance) (05-02-2007) Draft
// by Vic Phillips http://www.vicsjavascripts.org.uk
// The change height requirement is specified in the DIV class Name
// e.g.
// <div id="tst1" class="RealRule zxcCngHt,0,400,50" style="position:absolut.....
// where:
// zxcCngHt = to recognise the DIV is to have Chage Height applied
// the parameter fields are separated by commers
// parameter 0 = the minimum height
// parameter 1 = the maximum height
// parameter 2 = the number of change steps(equates to speed)
//
// The script is initialised by a BODY or window onload event call to function 'zxcInitCngHt()'.
// External control requires that each DIV is assigned a unique ID name
// Control is exercised from an event call to function zxcCngHt(zxcobj,zxcstop,zxcud)'
// Where:
// parameter 0 = obj or obj ID,
// parameter 1 = true to stop,
// parameter 2 = force direction ( 1 = down, -1 = up ).
// Persistance utalises a cookie.
// Global variable specify the Cookie Name and the Expiery duration in Days
// e.g.
var zxcCngHCookieDays=.0007; // = 1.008 minutes
var zxcCngHCookieName='Fred2';
//
// functional Code - NO changes required(I hope)
var zxcCngHAry=[];
function zxcCngHt(zxcobj,zxcstop,zxcud){
if (typeof(zxcobj)=='string'){ zxcobj=document.getElementById(zxcobj); }
var zxcoop=zxcobj.cngh;
clearTimeout(zxcoop.to);
zxcoop.ud=(zxcud==-1||zxcud==1)?zxcud:zxcoop.ud;
this.stop=zxcstop;
if (!this.stop){ zxcoop.cnght(); }
}
function zxcInitCngHt(){
var zxcdivs=document.getElementsByTagName('BODY')[0].getElementsByTagName('DIV')
for (var zxc0=0;zxc0<zxcdivs.length;zxc0++){
if (zxcdivs[zxc0].className){
if (zxcdivs[zxc0].className.match('zxcCngHt')){
var zxcpar=zxcdivs[zxc0].className.split('zxcCngHt')[1].split(',');
// object min Height max Height steps(speed)
zxcCngHAry.push(new zxcCngHtOOP(zxcdivs[zxc0],parseInt(zxcpar[1]),parseInt(zxcpar[2]),parseInt(zxcpar[3])));
}
}
}
var zxccookie=zxcCngHGetCookie();
if (zxccookie){ zxcCngHAnaliseCookie(zxccookie); }
}
// object, min H, max H, steps, ident
function zxcCngHtOOP(zxcobj,zxcmin,zxcmax,zxcstps){
zxcobj.cngh=this;
this.obj=zxcobj;
this.mmh=[zxcobj.offsetHeight,zxcmin||0,zxcmax||100];
this.stop=false;
this.ud=(this.mmh[2]<zxcobj.offsetHeight-5)?-1:1;
this.stps=zxcmax/zxcstps||1;
this.to=null;
this.dly=document.all?10:5;
this.ref='zxccngh'+zxcCngHAry.length;
window[this.ref]=this;
}
zxcCngHtOOP.prototype.cnght=function(){
if (((this.ud>0&&this.mmh[0]+this.ud*this.stps<this.mmh[2])||(this.ud<0&&this.mmh[0]+this.ud*this.stps>this.mmh[1]))&&!this.stop){ // ||(this.ud<0&&this.cnt+this.ud>0)
this.obj.style.height=(this.mmh[0]+=this.ud*this.stps)+'px';
this.setTimeOut('cnght();',this.dly);
}
else if (!this.stop){
this.obj.style.height=((this.ud<0)?this.mmh[1]:this.mmh[2])+'px';
this.ud=-this.ud;
zxcSetCngHCookie();
}
}
zxcCngHtOOP.prototype.setTimeOut=function(zxcf,zxcd){
this.to=setTimeout('window.'+this.ref+'.'+zxcf,zxcd);
}
function zxcCookieString(){
var zxcstrg='';
for (var zxc0=0;zxc0<zxcCngHAry.length;zxc0++){
zxcstrg+=zxc0+':'+zxcCngHAry[zxc0].ud+':';
}
}
function zxcSetCngHCookie(){
var zxcexp=new Date(new Date().getTime()+zxcCngHCookieDays*86400000).toGMTString();
var zxcstrg='';
for (var zxc0=0;zxc0<zxcCngHAry.length;zxc0++){ zxcstrg+=zxc0+':'+zxcCngHAry[zxc0].ud+'|'; }
document.cookie=zxcCngHCookieName+'='+encodeURI(zxcstrg)+';expires='+zxcexp+';path=/;';
}
function zxcCngHGetCookie(zxcnme){
var zxcst=document.cookie.indexOf(zxcCngHCookieName+'=');
var zxclen=zxcst+zxcCngHCookieName.length+1;
if ((!zxcst)&&(zxcCngHCookieName!=document.cookie.substring(0,zxcCngHCookieName.length))) return null;
if (zxcst==-1) return null;
var zxcend=document.cookie.indexOf(';',zxclen);
if (zxcend==-1) zxcend=document.cookie.length;
return decodeURI(document.cookie.substring(zxclen,zxcend));
}
function zxcCngHAnaliseCookie(zxcstrg){
zxcstrg=zxcstrg.split('|');
for (var zxc0=0;zxc0<zxcstrg.length-1;zxc0++){
var zxcnu=parseInt(zxcstrg[zxc0].split(':')[0]);
if (zxcCngHAry[zxcnu]){
var zxcud=(zxcstrg[zxc0].split(':')[1]=='1')?-1:1;
zxcCngHt(zxcCngHAry[zxcnu].obj,false,zxcud);
}
}
}
//-->
</script>
</head>
<body onload="zxcInitCngHt();" >
<input type="button" name="" value="Cng Height 1" onclick="zxcCngHt('tst1');" > <input type="button" name="" value="Stop Cng Height" onclick="zxcCngHt('tst1',true);" >
<input type="button" name="" value="Cng Height 2" onclick="zxcCngHt('tst2');" >
<div id="tst1" class="RealRule zxcCngHt,0,400,50" style="position:absolute;left:20px;top:40px;width:200px;height:100px;background-Color:red;" ></div>
<div id="tst2" class="RealRule zxcCngHt,20,200,150" style="position:absolute;left:250px;top:40px;width:200px;height:100px;background-Color:green;" ></div>
</body>
</html>
got called away again
Note that the Cookie does not use the ID
could have avoided ID for the external control but I guess you are happy using them
Would not take alot to add a progressive scroll and change width in addition to height.
karansokhey
02-06-2007, 10:50 PM
Thanks a lot bro you know your JavaScript =|
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.