Itlan
04-24-2009, 06:22 PM
1) Script Title: Animated Collapsible DIV
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm
3) Describe problem: Animated collapse is not persistent when multiple pages have collapsible DIVs. I modified the "uninit" to maintain the previous open DIVs and add only new ones. The result is as follows:
uninit:function(){
var opendivids=new Array();//ITLAN
var groupswithpersist='';
var persistopenids=this.getCookie('acopendivids'); //ITLAN
if (persistopenids!=null){ //ITLAN
persistopenids=(persistopenids=='nada')? [] : persistopenids.split(','); //ITLAN
}
else { persistopenids=new Array();} //ITLAN
opendivids=persistopenids; //ITLAN
jQuery.each(this.divholders, function(){
index=-1;
index=jQuery.inArray(this.id, persistopenids); //ITLAN
if (this.$divref.css('display')!='none'){
if (index !=-1){ //ITLAN
//Do nothing
}
else{ //ITLAN
opendivids.push(this.id); //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc' //ITLAN
}
}
else if (index !=-1) { //ITLAN
opendivids.splice(this.id,1); //ITLAN
}
else{
}
if (this.getAttr('group') && this.getAttr('persist'))
groupswithpersist+=this.getAttr('group')+','; //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc'
});
if (opendivids!=null) opendivids=opendivids.join(','); //ITLAN
opendivids = (opendivids=='') ? 'nada' : opendivids.replace(/,$/, '');
groupswithpersist = (groupswithpersist=='') ? 'nada' : groupswithpersist.replace(/,$/, '');
this.setCookie('acopendivids', opendivids);
this.setCookie('acgroupswithpersist', groupswithpersist);
},
Lines that I added or modified are noted with //ITLAN.
I am not an expert JS programmer by any means, but the script didn't work as I expected when I used the persist on 3 different pages. It only remembered 1 page instead of all three.
Hope this helps some of you, or perhaps it will be added to the main script. Let me know if there is a better way, or maybe I forgot something.
Cheers,
Itlan
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm
3) Describe problem: Animated collapse is not persistent when multiple pages have collapsible DIVs. I modified the "uninit" to maintain the previous open DIVs and add only new ones. The result is as follows:
uninit:function(){
var opendivids=new Array();//ITLAN
var groupswithpersist='';
var persistopenids=this.getCookie('acopendivids'); //ITLAN
if (persistopenids!=null){ //ITLAN
persistopenids=(persistopenids=='nada')? [] : persistopenids.split(','); //ITLAN
}
else { persistopenids=new Array();} //ITLAN
opendivids=persistopenids; //ITLAN
jQuery.each(this.divholders, function(){
index=-1;
index=jQuery.inArray(this.id, persistopenids); //ITLAN
if (this.$divref.css('display')!='none'){
if (index !=-1){ //ITLAN
//Do nothing
}
else{ //ITLAN
opendivids.push(this.id); //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc' //ITLAN
}
}
else if (index !=-1) { //ITLAN
opendivids.splice(this.id,1); //ITLAN
}
else{
}
if (this.getAttr('group') && this.getAttr('persist'))
groupswithpersist+=this.getAttr('group')+','; //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc'
});
if (opendivids!=null) opendivids=opendivids.join(','); //ITLAN
opendivids = (opendivids=='') ? 'nada' : opendivids.replace(/,$/, '');
groupswithpersist = (groupswithpersist=='') ? 'nada' : groupswithpersist.replace(/,$/, '');
this.setCookie('acopendivids', opendivids);
this.setCookie('acgroupswithpersist', groupswithpersist);
},
Lines that I added or modified are noted with //ITLAN.
I am not an expert JS programmer by any means, but the script didn't work as I expected when I used the persist on 3 different pages. It only remembered 1 page instead of all three.
Hope this helps some of you, or perhaps it will be added to the main script. Let me know if there is a better way, or maybe I forgot something.
Cheers,
Itlan