summaryrefslogtreecommitdiff
path: root/help3xsl/tabs.js
blob: d9f1e246b820222fa68720193d1b62cdc774775e (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
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

function tabs(a, g, j) {
    document.body.className = "js-on";
    var g = a.getElementsByTagName(g),
        d = [],
        c;
    this.active;
    this.total = g.length;
    this.container = a;
    e = a.insertBefore(document.createElement("nav"), g[0]), change = function (f) {
        if (typeof this.active !== "undefined") {
            d[this.active].className = g[this.active].className = ""
        }
        d[f].className = g[f].className = "active";
        this.active = f
    }, clickEvent = function (h, f) {
        h.onclick = function () {
            change(f);
            return false
        }
    };
    for (var b = 0; b < g.length; b++) {
        d[b] = e.appendChild(document.createElement("a"));
        d[b].href = "#";
        c = [g[b].getAttribute("data-title"), g[b].getElementsByTagName(j)[0]];
        d[b].innerHTML = c[0] !== null ? c[0] : c[1] ? c[1]["innerText" || "textContent"] : b + 1;
        new clickEvent(d[b], b)
    }
    change(0)
}
tabs.prototype.change = function (b) {
    change(b - 1)
};
tabs.prototype.next = function (b) {
    active === this.total - 1 ? change(0) : change(active + 1)
};
tabs.prototype.prev = function (b) {
    active === 0 ? change(this.total - 1) : change(active - 1)
};
tabs.prototype.responsive = function (d, c) {
    nav = document.createElement("nav");
    nav.id = "mobiles";
    nav.innerHTML = '<a href="#" onclick="' + d + '.prev(); return false">' + c.prev + '</a><a href="#" onclick="' + d + '.next(); return false">' + c.next + "</a>";
    this.container.insertBefore(nav, this.container.firstChild);
    return this
};