| Line | |
|---|
| 1 | function Book(D) {
|
|---|
| 2 | if (!D.parent || !D.pages || D.pages.length == 0) {
|
|---|
| 3 | return
|
|---|
| 4 | }
|
|---|
| 5 | D.parent = $(D.parent);
|
|---|
| 6 | var E,
|
|---|
| 7 | A,
|
|---|
| 8 | B;
|
|---|
| 9 | this.nPages = D.pages.length;
|
|---|
| 10 | this.parent = $(D.parent);
|
|---|
| 11 | this.parent.className += " book";
|
|---|
| 12 | E = ce("div");
|
|---|
| 13 | E.className = "header";
|
|---|
| 14 | if (this.nPages == 1) {
|
|---|
| 15 | E.style.display = "none"
|
|---|
| 16 | }
|
|---|
| 17 | ns(E);
|
|---|
| 18 | B = ce("div");
|
|---|
| 19 | B.style.visibility = "hidden";
|
|---|
| 20 | B.className = "previous";
|
|---|
| 21 | A = ce("a");
|
|---|
| 22 | A.appendChild(ct(String.fromCharCode(8249) + LANG.book_previous));
|
|---|
| 23 | A.href = "javascript:;";
|
|---|
| 24 | A.onclick = this.previous.bind(this);
|
|---|
| 25 | B.appendChild(A);
|
|---|
| 26 | E.appendChild(B);
|
|---|
| 27 | B = ce("div");
|
|---|
| 28 | B.style.visibility = "hidden";
|
|---|
| 29 | B.className = "next";
|
|---|
| 30 | A = ce("a");
|
|---|
| 31 | A.appendChild(ct(LANG.book_next + String.fromCharCode(8250)));
|
|---|
| 32 | A.href = "javascript:;";
|
|---|
| 33 | A.onclick = this.next.bind(this);
|
|---|
| 34 | B.appendChild(A);
|
|---|
| 35 | E.appendChild(B);
|
|---|
| 36 | B = ce("b");
|
|---|
| 37 | B.appendChild(ct("1"));
|
|---|
| 38 | E.appendChild(B);
|
|---|
| 39 | E.appendChild(ct(LANG.book_of));
|
|---|
| 40 | B = ce("b");
|
|---|
| 41 | B.appendChild(ct(this.nPages));
|
|---|
| 42 | E.appendChild(B);
|
|---|
| 43 | D.parent.appendChild(E);
|
|---|
| 44 | for (var C = 0; C < this.nPages; ++C) {
|
|---|
| 45 | E = ce("div");
|
|---|
| 46 | E.className = "page";
|
|---|
| 47 | E.style.display = "none";
|
|---|
| 48 | E.innerHTML = D.pages[C];
|
|---|
| 49 | D.parent.appendChild(E)
|
|---|
| 50 | }
|
|---|
| 51 | this.page = 1;
|
|---|
| 52 | this.changePage(D.page || 1)
|
|---|
| 53 | }
|
|---|
| 54 | Book.prototype = {
|
|---|
| 55 | changePage: function(B) {
|
|---|
| 56 | if (B < 1) {
|
|---|
| 57 | B = 1
|
|---|
| 58 | } else {
|
|---|
| 59 | if (B > this.nPages) {
|
|---|
| 60 | B = this.nPages
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 | var A = this.parent.childNodes;
|
|---|
| 64 | A[this.page].style.display = "none";
|
|---|
| 65 | A[B].style.display = "";
|
|---|
| 66 | this.page = B;
|
|---|
| 67 | A = A[0].childNodes;
|
|---|
| 68 | A[0].style.visibility = (B == 1) ? "hidden": "visible";
|
|---|
| 69 | A[1].style.visibility = (B == this.nPages) ? "hidden": "visible";
|
|---|
| 70 | A[2].innerHTML = B
|
|---|
| 71 | },
|
|---|
| 72 | next: function() {
|
|---|
| 73 | this.changePage(this.page + 1)
|
|---|
| 74 | },
|
|---|
| 75 | previous: function() {
|
|---|
| 76 | this.changePage(this.page - 1)
|
|---|
| 77 | }
|
|---|
| 78 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.