From c632fc6976ca908ee16e910f9d214980bf29c43d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 26 Jan 2006 22:29:26 +0100 Subject: scroll__here support This adds a simple JavaScript behavior. When an element with the id 'scroll__here' is found in the document the browser will scroll this element into view. Useful to scroll to some output after form submitting. darcs-hash:20060126212926-7ad00-b359915a5d6a299652134d8dfa64015786283b6b.gz --- lib/scripts/script.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/script.js b/lib/scripts/script.js index a8c6fe3fd..d2fbc35bf 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -47,12 +47,7 @@ function $() { */ function findPosX(object){ var curleft = 0; - var obj; - if(typeof(object) == 'object'){ - obj = object; - }else{ - obj = $(object); - } + var obj = $(object); if (obj.offsetParent){ while (obj.offsetParent){ curleft += obj.offsetLeft; @@ -72,12 +67,7 @@ function findPosX(object){ */ function findPosY(object){ var curtop = 0; - var obj; - if(typeof(object) == 'object'){ - obj = object; - }else{ - obj = $(object); - } + var obj = $(object); if (obj.offsetParent){ while (obj.offsetParent){ curtop += obj.offsetTop; @@ -392,3 +382,11 @@ function closePopups(){ } } } + +/** + * Looks for an element with the ID scroll__here at scrolls to it + */ +function scrollToMarker(){ + var obj = $('scroll__here'); + if(obj) obj.scrollIntoView(); +} -- cgit v1.2.3