aboutsummaryrefslogtreecommitdiff
path: root/lava_scheduler_app/static/lava_scheduler_app/js/jquery.details.js
blob: 479eac3b8c885d14b2fcebbc32426dd9355f7451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*! http://mths.be/details v0.0.1 by @mathias */
(function (a, $) {
    var c = $.fn,
        b, d = (function (i) {
            var g = i.createElement("details"),
                f, e, h;
            if (!("open" in g)) {
                return false
            }
            e = i.body || (function () {
                var j = i.documentElement;
                f = true;
                return j.insertBefore(i.createElement("body"), j.firstElementChild || j.firstChild)
            }());
            g.innerHTML = "<summary>a</summary>b";
            g.style.display = "block";
            e.appendChild(g);
            h = g.offsetHeight;
            g.open = true;
            h = h != g.offsetHeight;
            e.removeChild(g);
            if (f) {
                e.parentNode.removeChild(e)
            }
            return h
        }(a));
    /*! http://mths.be/noselect v1.0.2 by @mathias */
    c.noSelect = function () {
        var e = "none";
        return this.bind("selectstart dragstart mousedown", function () {
            return false
        }).css({
            MozUserSelect: e,
            WebkitUserSelect: e,
            userSelect: e
        })
    };
    if (d) {
        b = c.details = function () {
            return this
        };
        b.support = d
    } else {
        b = c.details = function () {
            return this.each(function () {
                var e = $(this),
                    h = $("summary", e),
                    g = e.children(":not(summary)"),
                    i = e.contents(":not(summary)"),
                    f = this.getAttribute("open");
                if (!h.length) {
                    h = $(a.createElement("summary")).text("Details").prependTo(e)
                }
                if (g.length != i.length) {
                    i.filter(function () {
                        return (this.nodeType === 3) && (/[^ \t\n\f\r]/.test(this.data))
                    }).wrap("<span>");
                    g = e.children(":not(summary)")
                }
                if (typeof f == "string" || (typeof f == "boolean" && f)) {
                    e.addClass("open");
                    g.show()
                } else {
                    g.hide()
                }
                h.noSelect().attr("tabIndex", 0).click(function () {
                    h.focus();
                    typeof e.attr("open") != "undefined" ? e.removeAttr("open") : e.attr("open", "open");
                    g.toggle(0);
                    e.toggleClass("open")
                }).keyup(function (j) {
                    if (13 === j.keyCode || 32 === j.keyCode) {
                        if (!($.browser.opera && 13 === j.keyCode)) {
                            j.preventDefault();
                            h.click()
                        }
                    }
                })
            })
        };
        b.support = d
    }
}(document, jQuery));