Changeset 17931
- Timestamp:
- 08/20/08 18:15:46 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/scroll_div.js
r17916 r17931 13 13 // スクロールする 14 14 // 15 // TODO: 16 // フレーム対応 15 17 16 18 (function () { 17 19 18 20 // スクロール可能か? 19 function isScrollable (e , doc) {21 function isScrollable (elem) { 20 22 const re = /auto|scroll/i; 21 let s = doc.defaultView.getComputedStyle(e, '');22 if (e .scrollHeight <= e.clientHeight)23 let s = elem.ownerDocument.defaultView.getComputedStyle(elem, ''); 24 if (elem.scrollHeight <= elem.clientHeight) 23 25 return; 24 26 for each (let n in ['overflow', 'overflowY', 'overflowX']) { … … 28 30 } 29 31 30 // FIXME 31 function flashElement (e, doc) { 32 var indicator = doc.createElement("div"); 33 indicator.id = "liberator-frame-indicator"; 34 // NOTE: need to set a high z-index - it's a crapshoot! 35 var style = "background-color: red; opacity: 0.5; z-index: 999;" + 36 "position: fixed; top: 0; bottom: 0; left: 0; right: 0;"; 32 // 光らせる 33 function flashElement (elem) { 34 let indicator = elem.ownerDocument.createElement("div"); 35 let rect = elem.getBoundingClientRect(); 36 indicator.id = "nyantoro-element-indicator"; 37 let style = "background-color: blue; opacity: 0.5; z-index: 999;" + 38 "position: fixed; " + 39 "top: " + rect.top + "px;" + 40 "height:" + elem.clientHeight + "px;"+ 41 "left: " + rect.left + "px;" + 42 "width: " + elem.clientWidth + "px"; 37 43 indicator.setAttribute("style", style); 38 e.appendChild(indicator); 39 // remove the frame indicator 40 setTimeout(function () { e.removeChild(indicator); }, 500); 44 elem.appendChild(indicator); 45 setTimeout(function () elem.removeChild(indicator), 500); 41 46 } 42 47 … … 45 50 let result = []; 46 51 let doc = content.document; 47 varr = doc.evaluate("//div|//ul", doc, null, 7, null)48 for ( vari = 0; i < r.snapshotLength; i++) {49 let e = r.snapshotItem(i);50 if (isScrollable(e , doc))51 result.push(e );52 let r = doc.evaluate("//div|//ul", doc, null, 7, null) 53 for (let i = 0; i < r.snapshotLength; i++) { 54 let elem = r.snapshotItem(i); 55 if (isScrollable(elem)) 56 result.push(elem); 52 57 } 53 liberator.log('scrollableElements: ' + result.length);54 58 return result; 55 59 } … … 57 61 // スクロール対象を変更 58 62 function shiftScrollElement (n) { 59 let idx = content.document.__div_scroller_index || 0; 63 let doc = content.document; 64 let idx = doc.__div_scroller_index || 0; 60 65 let es = scrollableElements(); 66 if (es.length <= 0) 67 liberator.echoerr('scrollable element not found'); 61 68 idx += (n || 1); 62 69 if (idx < 0) … … 65 72 idx = 0; 66 73 content.document.__div_scroller_index = idx; 74 flashElement(es[idx]); 67 75 } 68 76 … … 79 87 if (elem) 80 88 elem.scrollTop += Math.max(30, elem.clientHeight - 20) * (down ? 1 : -1); 81 //for each (let elem in scrollableElements()) {82 // liberator.log(elem.tagName);83 // liberator.log(elem.id);84 // elem.scrollTop += dy;85 //}86 89 } 87 90
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)