diff options
author | drry | 2008-09-26 07:04:29 +0000 |
---|---|---|
committer | drry | 2008-09-26 07:04:29 +0000 |
commit | 45fcaf20e6af831c736dab9a9b8d18810457fdd5 (patch) | |
tree | 80aa24a959fb178967276f3d7ca44817510f05d4 /scroll_div.js | |
parent | f1d9bb37870a3be5421a618e61e59246b4601437 (diff) | |
download | vimperator-plugins-45fcaf20e6af831c736dab9a9b8d18810457fdd5.tar.bz2 |
* Array に対する `for each` を排除しました。
* ほか。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19953 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'scroll_div.js')
-rw-r--r-- | scroll_div.js | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/scroll_div.js b/scroll_div.js index 29b30b7..90542a3 100644 --- a/scroll_div.js +++ b/scroll_div.js @@ -22,25 +22,23 @@ const re = /auto|scroll/i; let s = elem.ownerDocument.defaultView.getComputedStyle(elem, ''); if (elem.scrollHeight <= elem.clientHeight) - return; - for each (let n in ['overflow', 'overflowY', 'overflowX']) { - if (s[n] && s[n].match(re)) - return true; - } + return false; + return ['overflow', 'overflowY', 'overflowX'].some(function (n) + s[n] && re.test(s[n])); } // 光らせる function flashElement (elem) { - let indicator = elem.ownerDocument.createElement("div"); + let indicator = elem.ownerDocument.createElement('div'); let rect = elem.getBoundingClientRect(); - indicator.id = "nyantoro-element-indicator"; - let style = "background-color: blue; opacity: 0.5; z-index: 999;" + - "position: fixed; " + - "top: " + rect.top + "px;" + - "height:" + elem.clientHeight + "px;"+ - "left: " + rect.left + "px;" + - "width: " + elem.clientWidth + "px"; - indicator.setAttribute("style", style); + indicator.id = 'nyantoro-element-indicator'; + let style = 'background-color: blue; opacity: 0.5; z-index: 999;' + + 'position: fixed; ' + + 'top: ' + rect.top + 'px;' + + 'height:' + elem.clientHeight + 'px;'+ + 'left: ' + rect.left + 'px;' + + 'width: ' + elem.clientWidth + 'px'; + indicator.setAttribute('style', style); elem.appendChild(indicator); setTimeout(function () elem.removeChild(indicator), 500); } @@ -49,8 +47,8 @@ function scrollableElements () { let result = []; let doc = content.document; - let r = doc.evaluate("//div|//ul", doc, null, 7, null) - for (let i = 0; i < r.snapshotLength; i++) { + let r = doc.evaluate('//div|//ul', doc, null, 7, null) + for (let i = 0, l = r.snapshotLength; i < l; i++) { let elem = r.snapshotItem(i); if (isScrollable(elem)) result.push(elem); @@ -90,28 +88,28 @@ liberator.mappings.addUserMap( - [liberator.modes.NORMAL], + [liberator.modes.NORMAL], ['<Leader>j'], 'Scroll down', function () scroll(true) ); liberator.mappings.addUserMap( - [liberator.modes.NORMAL], + [liberator.modes.NORMAL], ['<Leader>k'], 'Scroll up', function () scroll(false) ); liberator.mappings.addUserMap( - [liberator.modes.NORMAL], + [liberator.modes.NORMAL], [']d'], 'Shift Scroll Element', function () shiftScrollElement(1) ); liberator.mappings.addUserMap( - [liberator.modes.NORMAL], + [liberator.modes.NORMAL], ['[d'], 'Shift Scroll Element', function () shiftScrollElement(-1) |