Difference between revisions of "Team:OUC-China/js/jquery-tocible-min"
ShuiqingWang (Talk | contribs) (Created page with "/* * jquery.tocible.min.js v1.2.0, jQuery Tocible * * Under MIT license, available at http://www.opensource.org/licenses/MIT. * * A lightweight table of contents navigati...") |
Freezingcool (Talk | contribs) |
||
Line 91: | Line 91: | ||
}); | }); | ||
g + b.outerHeight() <= c + e.height() + d.offsetTop ? e.css({ | g + b.outerHeight() <= c + e.height() + d.offsetTop ? e.css({ | ||
− | position: " | + | position: "fixed", |
− | bottom: | + | bottom: "auto", |
− | top: | + | top: d.offsetTop + 80, |
− | left: f.position().left | + | left: f.position().left - 170 |
}) : c >= g ? e.css({ | }) : c >= g ? e.css({ | ||
position: "fixed", | position: "fixed", |
Revision as of 02:36, 18 September 2015
/*
* jquery.tocible.min.js v1.2.0, jQuery Tocible * * Under MIT license, available at http://www.opensource.org/licenses/MIT. * * A lightweight table of contents navigation plugin * https://github.com/markserbol/tocible * */
(function(a) { var k = { heading: "h2", subheading: "h3", reference: ".ref", title: "", hash: !1, offsetTop: 50, speed: 800, collapsible: !0, maxWidth: 150 }; a.fn.tocible = function(m) { var d = a.extend({}, k, m); return this.each(function() { var b = a(this), e, f, g, h, l; b.find(".tocible").remove(); f = b.find(d.reference); f.css({ visibility: "hidden" }); l = f.offset().left; e = a("<div/>", { "class": "tocible", html: "<ul/>" }); e.css({ "max-width": d.maxWidth }); b.append(e).css({ position: "relative" }); if (d.title) { var k = a(d.title).length ? a(d.title).text() : d.title; a("<div/>", { "class": "tocible_header", html: k + "<span/>" }).prependTo(e).click(function() { a(this).siblings("ul").slideToggle({ duration: "slow", step: contain }); a(this).find("span").toggleClass("toc_open") }) } g = b.find(d.heading); h = b.find(d.subheading); g.add(h).each(function() { var c = a(this), e, b, f; e = c.attr("id") ? "#" + c.attr("id") : "#"; b = c.text(); c.is(g) ? f = "heading" : c.is(h) && (f = "subheading"); b = a("<a/>", { text: b, href: e });
a("