View file Structura/Template/HTWF/scripts/jquery.tab-accordion.js

File size: 5.18Kb
/*
* ===========================================================
* TABS AND ACCORDION - FRAMEWORK Y
* ===========================================================
* This script manage the tabs, collpse and accordion container components.
* Documentation: www.framework-y.com/containers/others.html#tabs
* Documentation: www.framework-y.com/containers/others.html#collapse
* Documentation: www.framework-y.com/containers/others.html#accordion-lists
* 
* Schiocco - Copyright (c) Federico Schiocchet - Schiocco - Framework Y
*/

"use strict";
!function (c) { c(".collapse-box .collapse-button").toggleClick(function () { var t = this; !function (t) { var i = c(t).closest(".collapse-box"), a = c(i).find(".panel"), e = c(i).attr("data-height"), s = c(t).attr("data-height"); c(a).css("display", "block").css("height", ""); var n = c(a).height(); c(a).css("height", 0), isEmpty(s) || (n = s); var o = c(t).attr("data-time"); isEmpty(o) && (o = 500); isEmpty(e) || (c(a).css("height", e + "px"), c(a).addClass("no-gradient")); c(a).animate({ height: n }, parseInt(o, 10)) }(t); var i = c(t).attr("data-button-open-text"); isEmpty(i) || (c(t).attr("data-button-close-text", c(this).find("b").html()), setTimeout(function () { c(t).find("b").html(i) }, 500)) }, function () { var t = this; !function (t) { var i = c(t).closest(".collapse-box"), a = c(i).find(".panel"), e = c(i).attr("data-height"); isEmpty(e) || c(a).removeClass("no-gradient"); var s = c(this).attr("data-time"); isEmpty(s) && (s = 500); c(a).animate({ height: isEmpty(e) ? 0 : e }, parseInt(s, 10), function () { isEmpty(e) && (c(a).css("display", "none"), c(a).css("height", "")) }) }(t); var i = c(t).attr("data-button-close-text"); isEmpty(i) || setTimeout(function () { c(t).find("b").html(i) }, 500) }), c("body").on("click", ".accordion-list .list-group-item > a", function () { var t = c(this).closest(".accordion-list"), i = c(this).closest(".list-group-item"), a = c(t).attr("data-type"), e = c(t).attr("data-time"), s = c(t).attr("data-height"), n = c(t).find(".active-panel .panel"); if (c(t).find(".list-group-item").removeClass("active-panel"), isEmpty(a) && (a = ""), c(c(t).find(".panel")).each(function () { c(this).clearQueue() }), c(this).hasClass("active") || "block" == c(i).find(".panel").css("display")) { c(this).removeClass("active"); var o = c(i).find(".panel"); isEmpty(e) && (e = 500), c(o).animate({ height: 0 }, e, function () { c(o).css("display", "none").css("height", "") }) } else { var l = 0, h = c(t).find(".list-group-item > a"); c(h).each(function () { c(this).hasClass("active") && (l = 300) }), c(h).removeClass("active"), c(this).addClass("active"), c(i).addClass("active-panel"), "visible" == a ? c(c(i).find(".panel")).collapse({ milliseconds: e, height: s }) : (c(n).animate({ height: 0 }, l, function () { c(n).css("display", "none").css("height", "") }), "accordion" == a ? c(i).find(".panel").collapse({ milliseconds: e, height: s }) : c(n).promise().done(function () { c(i).find(".panel").collapse({ milliseconds: e, height: s }) })) } }), c.fn.collapse = function (t) { var i = "", a = ""; isEmpty(t) || (i = t.milliseconds, a = t.height), isEmpty(i) && (i = 500); var e = this; c(e).css("display", "block"); var s = c(e).height(); c(e).css("height", "0px"), isEmpty(a) || (s = a), c(e).animate({ height: s }, parseInt(i, 10)) }, c("body").on("click", ".tab-box .nav li", function (t) { var i = c(this).find("a").attr("href"); "#" == i && (i = null); var a = c(this).closest(".tab-box"), e = c(a).attr("data-tab-anima"); c(a).find("> .panel, > .panel-box .panel").removeClass("active"), c(a).find("> .nav li").removeClass("active"), c(this).addClass("active"); var s = c(a).find("> .panel:eq(" + c(this).index() + "), > .panel-box .panel:eq(" + c(this).index() + ")"); if (isEmpty(i) || (s = c(a).find(i)), c(s).addClass("active"), isEmpty(e) || (c(s).css("opacity", 0), c(s).showAnima(e)), c.isFunction(c.fn.initFlexSlider)) { var n = 0; c(s).find(".flexslider").each(function () { c(this).initFlexSlider(), n++ }), n && c(window).trigger("resize").trigger("scroll") } if (c.isFunction(c.fn.initIsotope) && c(s).find(".maso-list").each(function () { c(this).initIsotope() }), c.isFunction(c.fn.googleMap) && c(s).find(".google-map").each(function () { c(this).googleMap() }), c(this).closest(".mega-menu").length) return !1; t.preventDefault() }), c("body").on("click", "header .mega-tabs", function () { c(this).find(".nav-tabs li:first-child").addClass("active") }), c(".tab-box.left,.tab-box.right").each(function () { var t = c(this).find(".nav"), i = c(this).find(".panel-box"); c(i).outerHeight() < c(t).outerHeight() ? c(i).find(".panel").css("height", c(t).outerHeight() + "px") : c(t).css("height", c(i).find(".panel").outerHeight() + "px") }), c(".nav.nav-justified-v").each(function () { var t = c(this).find("li").length, i = c(this).find("li a"); c(i).css("height", c(this).outerHeight() / t + "px"), c(i).css("line-height", c(i).height() + "px") }), c("*[data-height].collapse-box").each(function () { var t = c(this).find(".panel"); c(t).css("height", c(this).attr("data-height") + "px"), c(t).show() }), c(".accordion-list[data-open]").each(function () { var t = c(this).attr("data-open"); c(this).find(".list-group-item").eq(parseInt(t, 10) - 1).find("a").click() }) }(jQuery);