2 * (C) Copyright 2009 John J. Foerch
4 * Use, modification, and distribution are subject to the terms specified in the
11 * require('eye-guide.js');
12 * define_key(content_buffer_normal_keymap, "space", "eye-guide-scroll-down");
13 * define_key(content_buffer_normal_keymap, "back_space", "eye-guide-scroll-up");
17 define_variable("eye_guide_interval", 800,
18 "Interval during which the eye guide is visible (in ms). "+
19 "When 0, the eye guide will remain visible.");
21 define_variable("eye_guide_context_size", 50,
22 "Context size in pixels for eye-guide-scroll-down and "+
23 "eye-guide-scroll-up.");
25 interactive("eye-guide-scroll-down",
26 "Alternative to scroll-page-down, displays a guide to help "+
27 "your eyes follow the scroll.",
29 let win = I.buffer.focused_frame;
30 let doc = I.buffer.document;
31 let context = eye_guide_context_size;
32 let old_y = win.scrollY;
33 win.scrollBy(0, win.innerHeight - context);
34 if (win.scrollY == old_y)
36 if (win.scrollY - old_y < win.innerHeight - context)
37 context = win.innerHeight - (win.scrollY - old_y);
38 let guide = doc.getElementById("__conkeror_eye_guide");
40 guide = doc.createElementNS(XHTML_NS, "div");
41 guide.id = "__conkeror_eye_guide";
42 doc.documentElement.appendChild(guide);
44 guide.style.top = '0px';
45 guide.style.height = context+'px';
46 guide.style.display = "block";
47 guide.className = "__conkeror_eye_guide_scroll_down";
48 if (win.eye_guide_timer) {
49 win.clearTimeout(win.eye_guide_timer);
50 win.eye_guide_timer = null;
52 if (eye_guide_interval != 0)
53 win.eye_guide_timer = win.setTimeout(
55 guide.style.display = "none";
60 interactive("eye-guide-scroll-up",
61 "Alternative to scroll-page-up, displays a guide to help "+
62 "your eyes follow the scroll.",
64 let win = I.buffer.focused_frame;
65 let doc = I.buffer.document;
66 let context = eye_guide_context_size;
67 let old_y = win.scrollY;
68 win.scrollBy(0, 0 - (win.innerHeight - context));
69 if (win.scrollY == old_y)
71 if (old_y - win.scrollY < win.innerHeight - context)
72 context = win.innerHeight - old_y;
73 let guide = doc.getElementById("__conkeror_eye_guide");
75 guide = doc.createElementNS(XHTML_NS, "div");
76 guide.id = "__conkeror_eye_guide";
77 doc.documentElement.appendChild(guide);
79 guide.style.top = (win.innerHeight - context) + "px";
80 guide.style.height = context+'px';
81 guide.style.display = "block";
82 guide.className = "__conkeror_eye_guide_scroll_up";
83 if (win.eye_guide_timer) {
84 win.clearTimeout(win.eye_guide_timer);
85 win.eye_guide_timer = null;
87 if (eye_guide_interval != 0)
88 win.eye_guide_timer = win.setTimeout(
90 guide.style.display = "none";