So I have this horizontal slider that I've modified to fit my needs, and some of the DOM traversal stuff the author did gets a little confusing. What I'm trying to accomplish is making the tabs being 'close-able' so that once the tabs are opened they can be reverted to their previous state by being clicked again. I feel like this should be really easy but everything I've tried by messing with the jQuery has resulted in various bugs.
Here is the fiddle:
This is the basic mechanism of the accordion:
$("div.slide div.handle").click(function () {
if ($(this).parent("div.slide").hasClass("opened")) {
$(this).siblings().css({
"opacity": "1"
});
var e = $(this).parent("div.slide");
var p = e.prevAll("div.slide.opened");
var ph = p.children("div.handle").children('.handle-arrow').children("img");
var pi = p.children("div.inside");
//e.children("div.inside").animate({"margin-left":"-883px"}, 1000);
pi.animate({
"margin-left": "-400px"
}, 800, function () {
ph.css("filter", "progid:DXImageTransform.Microsoft.BasicImage(rotation=0)");
//e.css({"width":"39px"});
pi.css({
"width": "39px"
});
//e.children("div.inside").css({"width":"0px", "margin-left":"0px"});
pi.css({
"width": "0px",
"margin-left": "0px"
});
//e.removeClass("opened");
p.removeClass("opened");
});
//e.children("div.handle").children('.handle-arrow').children("img").animate({rotate: '+=180deg'}, 1000);
ph.rotate('0deg');
} else {
$(this).siblings().css({
"opacity": "1"
});
var e = $(this).parent("div.slide");
var n = e.nextAll("div.slide:not(.opened)");
var ei = e.children("div.inside");
var ni = n.children("div.inside");
var eh = e.children("div.handle").children('.handle-arrow').children("img");
var nh = n.children("div.handle").children('.handle-arrow').children("img");
$(this).parent("div.slide").siblings().children('.inside').css({
"opacity": "0"
});
e.css({
"width": "270px"
});
n.css({
"width": "270px"
});
ei.animate({
"width": "230px",
"margin-left": "0px"
}, 800);
ni.animate({
"width": "230px",
"margin-left": "0px"
}, 800);
eh.css("filter", "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)");
nh.css("filter", "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)");
eh.rotate('180deg');
nh.rotate('180deg');
e.addClass("opened");
n.addClass("opened");
e.addClass("opened2");
n.addClass("opened2");
$(".initial-image").clearQueue().stop(true, false);
}
Thanks so much in advance to anyone who can provide me with some insight, and I apologize if this isn't the right place for this.
Best, Cooper