diff --git a/umbra/behaviors.d/simpleclicks.js.in b/umbra/behaviors.d/simpleclicks.js.in index 143ce14..aabb0c0 100644 --- a/umbra/behaviors.d/simpleclicks.js.in +++ b/umbra/behaviors.d/simpleclicks.js.in @@ -1,17 +1,4 @@ -var umbraEndConditionTarget; - -var umbraAboveBelowOrOnScreen = function(e) { - var eTop = e.getBoundingClientRect().top; - if (eTop < window.scrollY) { - return -1; // above - } else if (eTop > window.scrollY + window.innerHeight) { - return 1; // below - } else { - return 0; // on screen - } -} - -var umbraSimpleScrollsAndClicksBehavior = { +var umbraBehavior = { IDLE_TIMEOUT_SEC : 10, idleSince : null, alreadyClicked : {}, @@ -39,7 +26,7 @@ var umbraSimpleScrollsAndClicksBehavior = { continue; } - var where = umbraAboveBelowOrOnScreen(clickTargets[i]); + var where = this.aboveBelowOrOnScreen(clickTargets[i]); if (where == 0) { console.log("clicking on " + clickTargets[i].outerHTML); @@ -66,17 +53,17 @@ var umbraSimpleScrollsAndClicksBehavior = { if (!clickedSomething) { if (somethingLeftAbove) { - console.log("scrolling UP because everything on this screen has been clicked but we missed something above"); + // console.log("scrolling UP because everything on this screen has been clicked but we missed something above"); window.scrollBy(0, -500); this.idleSince = null; } else if (somethingLeftBelow) { - console.log("scrolling because everything on this screen has been clicked but there's more below document.body.clientHeight=" - + document.body.clientHeight); + // console.log("scrolling because everything on this screen has been clicked but there's more below document.body.clientHeight=" + // + document.body.clientHeight); window.scrollBy(0, 200); this.idleSince = null; } else if (window.scrollY + window.innerHeight < document.documentElement.scrollHeight) { - console.log("scrolling because we're not to the bottom yet document.body.clientHeight=" - + document.body.clientHeight); + // console.log("scrolling because we're not to the bottom yet document.body.clientHeight=" + // + document.body.clientHeight); window.scrollBy(0, 200); this.idleSince = null; } else if (this.idleSince == null) { @@ -105,11 +92,22 @@ var umbraSimpleScrollsAndClicksBehavior = { } return false; }, + + aboveBelowOrOnScreen : function(e) { + var eTop = e.getBoundingClientRect().top; + if (eTop < window.scrollY) { + return -1; // above + } else if (eTop > window.scrollY + window.innerHeight) { + return 1; // below + } else { + return 0; // on screen + } + }, }; // Called from outside of this script. var umbraBehaviorFinished = function() { - return umbraSimpleScrollsAndClicksBehavior.isFinished() + return umbraBehavior.isFinished() }; -umbraSimpleScrollsAndClicksBehavior.start(); \ No newline at end of file +umbraBehavior.start();