I’ve created a ui concept for a website that requires the combination of two different code sources, but I don’t really know how to bring them together properly as I am not that fluent in javascript.
I want to combine this Javascript accordion menu with this filtered photo gallery plugin. Here’s where it gets complicated.
I have beverage flavors to display as an online catalogue. I want to be able to filter these by division (i.e. Coffee, Food, Sugar, Tea), so I’m using the gallery plugin for the filter. On the gallery’s demo page, instead of supermodels in the photos, just imagine title images for each section of products.
What happens right now when you click on an image is what I want to change. Instead of clicking on an image to see a larger lightbox version (using PrettyPhoto), I want to eliminate PrettyPhoto altogether and use the javascript menu to drop down underneath the photo to display a plain text list of flavors. If the user clicks the image again, the menu will swing back up into the photo and disappear.
Is there a way to hide my accordion menus within each image element and still be able to filter the results with all the animations and no glitches? And on-image-click the menu will display flavors over top of the surrounding images? (I don’t want everything to be relatively positioned because the dropdown menu will knock everything around, unless I keep the results vertical and not in grid layout.)
Thanks for all your help in advance. This one is really stumping me because I have no tutorials or support to go on.
Well I haven’t used the quicksand plugin, but the drop down accordion effect you want should be independent of the gallery’s filter functionality. (again, not having used it, I can’t say say for sure)
First I would drop the code base for the accordion menu and create your own drop down functionality. After inspecting the dom for the gallery page, what I would do is create a div element as the next sibling after the anchor tag on the image, setting it’s display to none. Add a jquery toggle event to the anchor element and then add the slideDown/slideUp functionality to the toggle event. (or a slideToggle method to a click event, less code, does the same thing). If you don’t want more than one slide down menu to be open at once, then use a click event to hide all dropdowns, then show current dropdown.
Each li element would have to have a position relative (which is fine without any top, left, bottom, right properties), and each div element would have position absolute. Think of it like a drop down navigation menu.
If the addition of the hidden div to the li element messes with the filter functionality, you could try creating a json object for each image with it’s corresponding slidedown data and using a function to inject the data in a dynamically created div element.
*EDIT: I must have missed it the first time I read, but what do you mean: “And on-image-click the menu will display flavors over top of the surrounding images?”
I thought you wanted the list of flavors to appear underneath the image in a drop down menu. Are you saying you want the flavors to appear in drop down underneath and at the same time, cover the other images on the page?
*Edit 2: To answer your question..
Or
These two are fine if you don’t mind having more than one drop down open at a time, but if you need only one open at a time then try this:
*new Edit: your li elements should look like this:
This layout should not change even after clicking the filter button