This support forum belongs to the Accordion Gallery Module.
Accordion has a bug tracker here: http://github.com/ipeychev/yui3-gallery/issues
| Page 1 of 1 | [ 8 posts ] |
|
Hi, thank you for this library,
I am trying to manage different levels of items by modifying their styles - my sub-item would be smaller or have a different background, etc... However I could not find a way to dynamically set the styles rendering the acc items. I am happy with css but a newbie to YUI so a little help or an example would be really useful for me. Thank you, regards |
|
pasx wrote: Hi, thank you for this library, I am trying to manage different levels of items by modifying their styles - my sub-item would be smaller or have a different background, etc... However I could not find a way to dynamically set the styles rendering the acc items. I am happy with css but a newbie to YUI so a little help or an example would be really useful for me. Thank you, regards Well, each item is actually Widget, so you can use the full power of Widget's methods. For example, you can get its contentBox via: var node = item1.get('contentBox'); That will return you instance of Y.Node and in this case you can use .setStyle method for example. Moreover, you can retrieve item's icons and set different styles to them. Check the documentation here. |
|
Hi Ilyan,
Thank you for your answer. I tried setStyle but ran into problems with the background-image property which does not seem to do anything. This is my code for background image if you have any idea what's wrong there Code: var node = event.currentTarget.get('contentBox'); var nodes = node.get('children'); var child = nodes.item(0); child.setStyle("background-image", 'url("bando_small_green.png")'); I also tried addClass with some success but my problem is mostly that the css styles used in your model is quite complex so that makes it uneasy to figure out which part of the item or which style to set. Another problem is that my test code is event based but what I'd really want to be able to is to change the styles of the "sub-items" when adding then to the accordion. Any way this can be done? Thank you |
Alberto SantiniYUI Contributor
|
Hello pasx.
For the background issue you may give a look at "How do I change a background image" thread: viewtopic.php?f=92&t=7396 As Dav said: Node setStyle doesn't support '-' properties, always use the JS camelCase property. Hope that helps, IceBox |
|
Hi Alberto,
Thank you for the reply. So for the record, the two syntaxes below are working fine. The second also works as a get which makes it easier to debug. Code: child.setStyle("backgroundImage", "url(bando_small_green.png)"); child._node.style.backgroundImage ="url(bando_small_green.png)"; So I will continue today to alter the content of the items at rendering time that seems to do the trick for me. Pasx |
|
Hi,
FYI, I managed to modify the rendering of the acc. items in the following ways: This code is called right after adding the item to the accordion with addItem. The variable ai is an acc. item and t A call to ai.get('children') returns undefined at this point - as the acc. is not yet displayed I guess - but the properties headerNode and bodyNode are already valid. var node = ai.headerNode; node._node.style.backgroundImage = "url(img/header_small.png)"; //background image node.setStyle("height", "22px"); //header height node._node.children[1].style.fontWeight = "normal"; //modify style of the label node node._node.children[2].children[0].style.visibility = "hidden"; //hide the alwaysvisible icon header_small.png contains the background image at the top of accordion_sprite.png shrinked to 22px In Firebug here is the content of the headerNode. ai.headerNode._node = header (div tag) ai.headerNode._node.children[0] = icon (a tag) ai.headerNode._node.children[1] = icon (a tag) ai.headerNode._node.children[2] = other icons (div tag) ai.headerNode._node.children[2].children[0] = icon always vis. (a) ai.headerNode._node.children[2].children[1] = icon expanded (a) ai.headerNode._node.children[2].children[2] = icon close (a) So far the result looks pretty good. I tried to manage the display of "sub-items" with javascript when expanding the "parent" item. Parsing nextSibling(s) and setting the styles for visibility and height ("0px" or ""). To modify the nextSiblings of current node I managed to access them via: event.item._stdModNode._node.nextSibling; And one can access the style property on this object. It looks ugly but I couldn't find any other object to start from. But all this works fine in Firefox but for some reason not in IE, some white space remain b/w the remaining accordion items and the accordion is not refreshed. Since IE is my target I finally settled for emptying the accordion and refilling it with only the items that I want to show which is much simpler to code though less responsive. |
|
Umm, this is a little bit risky (ugly too).
There is no need to modify the styles directly, moreover by using YUI internal (private or protected) properties (like node._node.). You can get header node via getStdModNode. Once you have this node, you may ask it for its children - via headerNode.one(...). The other option is to ask AccordionItem for these properties. Take a look here: There are properties like iconAlwaysVisible which you can modify with setStyle for example. Iliyan |
|
Quote: ... To modify the nextSiblings of current node I managed to access them via: event.item._stdModNode._node.nextSibling ... and setting the styles for visibility and height ("0px" or ""). I found out that there is no need to parse the nodes with the nextSibling property and mess up with the styles for removing items. It is much simpler to use accordion properties getItem for parsing and removeItem. And I agree that: Code: var nodeAlwaysVisible = ai.get('iconAlwaysVisible'); nodeAlwaysVisible.setStyle('visibility', 'hidden'); is much better than: Code: node._node.children[2].children[0].style.visibility = "hidden"; I am not used to the set/get syntax for accessing properties and tend to assume that if I can't see them on the object in the debugger they just don't exist... Thanks for the tip |
| Page 1 of 1 | [ 8 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group