witten
/
luminotes
Archived
1
0
Fork 0

Don't call ScrollTo for display of messages/errors if the error/message is fully visible within the window.

This commit is contained in:
Dan Helfman 2008-03-11 10:40:43 +00:00
parent 7c51c02928
commit db101b2c2f
2 changed files with 13 additions and 2 deletions

3
NEWS
View File

@ -1,3 +1,6 @@
1.2.10: March 11, 2008
* More intelligent scrolling when displaying messages and errors.
1.2.9: March 10, 2008
* Show list of all notes on startup if there are no startup notes and the
notebook isn't empty.

View File

@ -1540,7 +1540,7 @@ Wiki.prototype.display_message = function ( text, nodes, position_after ) {
else
appendChildNodes( "notes", div );
new ScrollTo( div );
this.scroll_to( div );
return div;
}
@ -1580,11 +1580,19 @@ Wiki.prototype.display_error = function ( text, nodes, position_after ) {
else
appendChildNodes( "notes", div );
new ScrollTo( div );
this.scroll_to( div );
return div;
}
Wiki.prototype.scroll_to = function ( node ) {
// if the message is already completely on-screen, then there's no need to scroll
var viewport_position = getViewportPosition();
if ( getElementPosition( node ).y < viewport_position.y ||
getElementPosition( node ).y + getElementDimensions( node ).h > viewport_position.y + getViewportDimensions().h )
new ScrollTo( node );
}
Wiki.prototype.clear_messages = function () {
var results = getElementsByTagAndClassName( "div", "message" );