aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator
diff options
context:
space:
mode:
authoranekos2012-07-12 13:04:30 -0700
committeranekos2012-07-12 13:04:30 -0700
commit9fb3c083991053eda1f55f528a1f3f502205b4ec (patch)
tree59ff4e7274eadc3a33e099e50f0c5ab1d5a846eb /twittperator
parent49d0a7cbf7f10daf4142084396eabbede8160259 (diff)
parent135390113bd5a830f09bbc36ffb15dccf4c8de21 (diff)
downloadvimperator-plugins-9fb3c083991053eda1f55f528a1f3f502205b4ec.tar.bz2
Merge pull request #26 from Jagua/twsidebar/listOrder
twsidebar.tw のスクロール順序を変更可能に
Diffstat (limited to 'twittperator')
-rw-r--r--twittperator/twsidebar.tw48
1 files changed, 44 insertions, 4 deletions
diff --git a/twittperator/twsidebar.tw b/twittperator/twsidebar.tw
index 9418e0a..a9cc9ce 100644
--- a/twittperator/twsidebar.tw
+++ b/twittperator/twsidebar.tw
@@ -38,6 +38,12 @@ liberator.modules.TWAnekoSB = ANekoSB = (function () {
// リストの最大保持数
listMax: 100,
+ // リストの表示順(昇順/降順)
+ listAscendingOrder: true,
+
+ // ツイートされる度に最新ツイート位置までスクロールする
+ listAutoScroll: true,
+
// 日本語だけ for filter stream
jpOnly: true,
@@ -189,13 +195,47 @@ liberator.modules.TWAnekoSB = ANekoSB = (function () {
let cntr = getSidebarWindow().document.getElementById('tw-anekos-sb-' + tab + '-list');
let dom = xmlToDom(messageToXML(t));
let repDom = dom.cloneNode(true);
+ let visibleIndex = cntr.getIndexOfFirstVisibleRow();
let len = cntr.itemCount;
- cntr.appendChild(repDom);
+ if (Config.listAscendingOrder) {
+ cntr.appendChild(repDom);
+ } else {
+ cntr.insertBefore(repDom, cntr.firstChild);
+ visibleIndex += 1;
+ }
latestNode = repDom;
- cntr.scrollToIndex(len - 1);
- if (len > Config.listMax)
- cntr.removeChild(cntr.firstChild);
+ if (len > Config.listMax) {
+ if (Config.listAscendingOrder) {
+ cntr.removeChild(cntr.firstChild);
+ visibleIndex -= 1;
+ } else {
+ cntr.removeChild(cntr.lastChild);
+ }
+ len -= 1;
+ }
+
+ if (Config.listAutoScroll) {
+ if (Config.listAscendingOrder) {
+ cntr.scrollToIndex(len - 1);
+ } else {
+ cntr.scrollToIndex(0);
+ }
+ } else {
+ if (Config.listAscendingOrder) {
+ if (len - visibleIndex < 10) { // 10 = 絶妙な値!これでいいのか!
+ cntr.scrollToIndex(len - 1);
+ } else {
+ cntr.scrollToIndex(visibleIndex);
+ }
+ } else {
+ if (visibleIndex < 3) { // 3 = 絶妙な値!これでいいのか!
+ cntr.scrollToIndex(0);
+ } else {
+ cntr.scrollToIndex(visibleIndex);
+ }
+ }
+ }
}
return append;