By cybertron1 on
Hi!
I have done a collapsible custom login-bar that lies in the top of the whole page,
When clicking on the legend it collapses the fieldset and if clicked again it wanishes again (only text showing) , however, when having for example, the fieldset set to "open/collapsed" and changing page, it goes into it's first state.
Is there any way at all, to go around this?
I was thinking some kind of IF fieldset = caollapsed then or somthing like that, but I can't get it to work...any ideas??
this is my original code (not my if this do that piece)
<div id="login-list">
<script type="text/javascript" src="/misc/drupal.js"></script>
<script type="text/javascript" src="/misc/collapse.js"></script>
<div id="login-list" class="clear-block">
<fieldset class=" collapsible collapsed" style="border: 0; margin: 0; padding: 6px 0 0 0; background: transparent;"><legend>MiniMeny</legend>
<?php
global $user;
if (!$user->uid) { ?><?php print garland_user_bar() ?>
<div></div>
<?php
}
else {
?><?php print garland_user_bar() ?><?php
}
?>
</fieldset>
</div>
</div>
Comments
maybe
Look at collapse.js.
Add the javascript there : when the bar is opened, write a cookie.
Use a xhmtl attribute (such as "id") and dom scripting to know which fieldset is being opened.
if (user bar fieldset is being opened) { write cookie:open }
if (user bar fieldset is being closed) { write cookie:close}
Add a javascript file that will read the cookie and set the class attr node to the proper value (
collapsed, for example) on the bar element when the page is loaded.Very, very rough skeleton here.
Looking foward to see some code by someone else.
Caroline
how to know which fieldset is being used
this technique is fine but..
how do you get the value / name / legend of the fieldset that is triggering the collpase.js.
so that you can write to cookie / session variable, a value, otherwise if you have more than one fieldset, they all call the same collpase.js and would set the same variable value.
need to use something like;
var fieldset_value = this.parentNode.title
set cookie for fieldset_value
but how, in javascript, hacking collpase.js, do you get the value / name / title / legend of the fieldset that is using collapse.js ?
I am working on the same issue.
I am currently developing a module, called 'fieldset helper', that saves the state of collapsible fieldsets.
http://groups.drupal.org/node/20014
I had to use hook_form_alter() with overriding the fieldset theme function to generate unique DOM ids for all fieldsets.
For the javascript handling I had to wrap the collapse.js code with a state saving function.