Closed (fixed)
Project:
Chaos Tool Suite (ctools)
Version:
6.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Aug 2009 at 13:07 UTC
Updated:
23 Oct 2009 at 17:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
merlinofchaos commentedcan you discuss in greater detail what this would do? Is this for remembering collapsed state?
Comment #2
apanag commentedExactly.
For example i have some div's that the user has chosen to hide. I want to keep them hidden until the user decides that he wants them expanded.
The state can be changed when the user clicks the toggle button, through an ajax request that will store (maybe on the user object?or on a table?) the setting.
Comment #3
merlinofchaos commentedTypically that is done with a cookie. It is something that should be optionally available.
Comment #4
apanag commentedWhy do you prefer a cookie over a database record? For performance issues?
And what expiration time do you think is the most suitable for a cookie like that?
Comment #5
merlinofchaos commentedYes, server oriented will mean *many* extra calls. A cookie will mean no extra calls. It's a big deal.
Comment #6
apanag commentedBut what happens if the user clears browser cookies? Or he logins from a different pc?
He loses his settings and has to re-setting them all again from the start. And if there are many divs this is annoying for the user.
Is it possible to execute the queries only if the cookie is not present?
Comment #7
sdboyer commentedIt's more than just a performance issue, it's a potentially very complex data architecture question. One that happens to be very close to my heart, so please believe me when I say: we're working on it, but solving it in an abstracted, in-the-module-code-everyone-can-use kind of way is NOT going to be the fastest way to a solution that'll work for your use case, right now. Doing it with sessions/cookies has its own problems and messiness, but they're more surmountable.
Comment #8
merlinofchaos commentedA single ajax call to get the data if the cookie is not set (which is not the same as is empty) would likely be acceptable.
Putting this back ot active, as I'm interested in seeing where a patch for this might go.
Comment #9
sdboyer commentedOn re-reading, I think I probably misunderstood the original intent here. I'll just butt out, this is a part of the system I don't know well :)
Comment #10
apanag commentedI re-organized my thoughts and i am thinking something like that:
A div has been wrapped by the ctools-collapsible classes.
Firstly we checked if there is a cookie, for example a cookie named ctoos-collapsible-uid, where uid is the current users' uid.
If there is, we read the cookie, and set the divs accordingly.
else we check for a record in our database.
If a record exists we create a cookie and set the div accordingly.
else we continue as it is.
So we create a cookie for each user, which he/she wants their div to be opened/closed.
So when a user clicks on the toggle area:
An ajax request updates the database record with the user's setting and if a cookie exists we updated it, or we create a new cookie.
So in that case we read the database *only* if there isn't a cookie and we use the cookie for the rest of the users' session.
Perhaps i have some bugs in my thoughts.
Comment #11
merlinofchaos commentedTry this patch on for size.
Comment #12
merlinofchaos commentedI'm satisfied with this. Committed.
Comment #13
apanag commentedI ll tested it and post my results asap.
Thank you very much,
apanag
Comment #14
apanag commentedI tested it and it is working great.
One question though:
Why you wrote two theme functions? You can merge them in one.
For example:
Comment #15
merlinofchaos commentedI didn't want to change the existing API, and the argument order felt wrong if I just pushed them onto the end. Also, more control for themers.
Also, $remember *Requires* an $id and without it doesn't, so as a single function that ends up a little bit confusing DX.
Comment #16
apanag commentedIndeed i forgot about the $id but you can overcome the problem with an if function.
But i see your point. I agree that keep things clean and simple is a much better solution, than have one function for multiple things. (OOP related :-D )
One last question: is it possible for the API to add a function for other html elements? such as tables?
I need this API for making collapsible containers for advanced_forums: http://drupal.org/node/291084
As far as a user specifies the correct classes and has the structure you specified, it is much more flexible for other elements to have collapsible functionality.
Thank you,
apanag
Comment #17
merlinofchaos commentedAt that point, I wouldn't bother with the theme function at all.
If you add 'ctools-collapsible-container' and 'ctools-collapsible-remember' and er, one other class (check the .js file) then the container and the content don't need to be related and can be anything. The handle will then be found by id, appending '-content' to the id of the container which is now also the handle.
Comment #18
apanag commentedHello,
merlinofchaos i followed your instructions but i dont get it how it is supposed to work.
I am using the following code:
I append to id of the container the id of the handle but it still doesnt works.
I tested also on divs without any success.
Is something i am missing here?
Comment #19
apanag commentedI even try this without any success:
I added it on a custom block, but when i loaded it, nothing appeared.
Comment #20
apanag commentedOne silly question:
Isn't supposed ctools_collapsible_theme to return an array?
After i emptied my cache, the block appears correctly.
Comment #21
apanag commentedFInally i got it working with the following changes:
From:
I changed it to
So the selectors doesnt always looks for div, but for any html elements that has the requested class.
And i changed:
To
To select the id of the content. With those changes it works like a charm.
apanag
Comment #22
merlinofchaos commentedOk, those 2 changes are committed, I think.
Comment #23
apanag commentedOne small fix. You deleted the dot also. So it doesnt select the classes:
From:
To:
Thanks again for your work.
Comment #24
merlinofchaos commentedThis is why you should've provided a patch. =)
Comment #25
apanag commentedHello again merlinofchaos.
The last commit works great except of a small bug with tables related.
You use the slideToggle effect to hide and show the collapsed area. The slideToggle effect overrides the default table class providing a "display:block" instead of "display: table-row-group".
I added an if to check whether or not it is a table element. If it is a table element i use toggle effect, instead of slideToggle.
apanag
Comment #26
apanag commentedI forgot to changed the status.
Comment #27
merlinofchaos commented1) Can you please not use tabs? Your patch has some tabs, some spaces and puts things out of place
2) This uses toggle() instead of toggle(speed, callback) -- can this use the latter so that we get consistency?
Comment #28
apanag commented1) My mistake.
2) Changed.
Comment #29
merlinofchaos commentedThanks for the update. I cleaned up the comment a bit and committed!