mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Javascript:
- reviewed and used objects PageTemplate and Locale - removed associated workarounds - replaced ~12k tabs with ~48k spaces - fixed some localization errors - whoops, forgot to update some Util::$pageTemplate calls to $this
This commit is contained in:
@@ -1,99 +1,99 @@
|
||||
function Book(opt) {
|
||||
if (!opt.parent || !opt.pages || opt.pages.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (!opt.parent || !opt.pages || opt.pages.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
opt.parent = $WH.ge(opt.parent);
|
||||
opt.parent = $WH.ge(opt.parent);
|
||||
|
||||
var
|
||||
var
|
||||
d,
|
||||
a,
|
||||
_;
|
||||
|
||||
this.nPages = opt.pages.length;
|
||||
this.nPages = opt.pages.length;
|
||||
|
||||
this.parent = $WH.ge(opt.parent);
|
||||
this.parent.className += ' book';
|
||||
this.parent = $WH.ge(opt.parent);
|
||||
this.parent.className += ' book';
|
||||
|
||||
d = $WH.ce('div');
|
||||
d.className = 'paging';
|
||||
if (this.nPages == 1) {
|
||||
d.style.display = 'none';
|
||||
}
|
||||
$WH.ns(d);
|
||||
d = $WH.ce('div');
|
||||
d.className = 'paging';
|
||||
if (this.nPages == 1) {
|
||||
d.style.display = 'none';
|
||||
}
|
||||
$WH.ns(d);
|
||||
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'previous';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(String.fromCharCode(8249) + LANG.lvpage_previous));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.previous.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'previous';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(String.fromCharCode(8249) + LANG.lvpage_previous));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.previous.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'next';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(LANG.lvpage_next + String.fromCharCode(8250)));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.next.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'next';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(LANG.lvpage_next + String.fromCharCode(8250)));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.next.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct('1'));
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct('1'));
|
||||
d.appendChild(_);
|
||||
|
||||
d.appendChild($WH.ct(LANG.lvpage_of));
|
||||
d.appendChild($WH.ct(LANG.lvpage_of));
|
||||
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct(this.nPages));
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct(this.nPages));
|
||||
d.appendChild(_);
|
||||
|
||||
opt.parent.appendChild(d);
|
||||
opt.parent.appendChild(d);
|
||||
|
||||
for (var i = 0; i < this.nPages; ++i) {
|
||||
d = $WH.ce('div');
|
||||
d.className = 'page';
|
||||
d.style.display = 'none';
|
||||
for (var i = 0; i < this.nPages; ++i) {
|
||||
d = $WH.ce('div');
|
||||
d.className = 'page';
|
||||
d.style.display = 'none';
|
||||
|
||||
d.innerHTML = opt.pages[i];
|
||||
d.innerHTML = opt.pages[i];
|
||||
|
||||
opt.parent.appendChild(d);
|
||||
}
|
||||
opt.parent.appendChild(d);
|
||||
}
|
||||
|
||||
this.page = 1;
|
||||
this.changePage(opt.page || 1);
|
||||
this.page = 1;
|
||||
this.changePage(opt.page || 1);
|
||||
}
|
||||
|
||||
Book.prototype = {
|
||||
changePage: function(page) {
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
changePage: function(page) {
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
else if (page > this.nPages) {
|
||||
page = this.nPages;
|
||||
}
|
||||
}
|
||||
|
||||
var _ = this.parent.childNodes;
|
||||
_[this.page].style.display = 'none';
|
||||
_[page].style.display = '';
|
||||
this.page = page;
|
||||
var _ = this.parent.childNodes;
|
||||
_[this.page].style.display = 'none';
|
||||
_[page].style.display = '';
|
||||
this.page = page;
|
||||
|
||||
_ = _[0].childNodes;
|
||||
_[0].style.visibility = (page == 1) ? 'hidden': 'visible';
|
||||
_[1].style.visibility = (page == this.nPages) ? 'hidden': 'visible';
|
||||
_ = _[0].childNodes;
|
||||
_[0].style.visibility = (page == 1) ? 'hidden': 'visible';
|
||||
_[1].style.visibility = (page == this.nPages) ? 'hidden': 'visible';
|
||||
|
||||
_[2].innerHTML = page;
|
||||
},
|
||||
_[2].innerHTML = page;
|
||||
},
|
||||
|
||||
next: function() {
|
||||
this.changePage(this.page + 1);
|
||||
},
|
||||
next: function() {
|
||||
this.changePage(this.page + 1);
|
||||
},
|
||||
|
||||
previous: function() {
|
||||
this.changePage(this.page - 1);
|
||||
}
|
||||
previous: function() {
|
||||
this.changePage(this.page - 1);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user