Skip to content
Snippets Groups Projects
Commit c632fc69 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

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
parent 2411dd85
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,7 @@ function js_out(){ ...@@ -79,6 +79,7 @@ function js_out(){
js_runonstart("ajax_qsearch.init('qsearch_in','qsearch_out')"); js_runonstart("ajax_qsearch.init('qsearch_in','qsearch_out')");
js_runonstart("addEvent(document,'click',closePopups)"); js_runonstart("addEvent(document,'click',closePopups)");
js_runonstart('addTocToggle()'); js_runonstart('addTocToggle()');
js_runonstart('scrollToMarker()');
if($edit){ if($edit){
// size controls // size controls
......
...@@ -226,7 +226,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { ...@@ -226,7 +226,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin {
} }
if($this->_edit_user && $this->_auth->canDo('modifyUser')){ if($this->_edit_user && $this->_auth->canDo('modifyUser')){
ptln("<div".$style.">"); ptln("<div".$style." id=\"scroll__here\">");
print $this->locale_xhtml('edit'); print $this->locale_xhtml('edit');
ptln(" <div class=\"level2\">"); ptln(" <div class=\"level2\">");
......
...@@ -47,12 +47,7 @@ function $() { ...@@ -47,12 +47,7 @@ function $() {
*/ */
function findPosX(object){ function findPosX(object){
var curleft = 0; var curleft = 0;
var obj; var obj = $(object);
if(typeof(object) == 'object'){
obj = object;
}else{
obj = $(object);
}
if (obj.offsetParent){ if (obj.offsetParent){
while (obj.offsetParent){ while (obj.offsetParent){
curleft += obj.offsetLeft; curleft += obj.offsetLeft;
...@@ -72,12 +67,7 @@ function findPosX(object){ ...@@ -72,12 +67,7 @@ function findPosX(object){
*/ */
function findPosY(object){ function findPosY(object){
var curtop = 0; var curtop = 0;
var obj; var obj = $(object);
if(typeof(object) == 'object'){
obj = object;
}else{
obj = $(object);
}
if (obj.offsetParent){ if (obj.offsetParent){
while (obj.offsetParent){ while (obj.offsetParent){
curtop += obj.offsetTop; curtop += obj.offsetTop;
...@@ -392,3 +382,11 @@ function closePopups(){ ...@@ -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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment