diff --git a/NEWS b/NEWS index 3d3c906..065bfeb 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ 1.6.13: - * + * Fixed a Chrome/Safari bug in which popups such as those for export and + color were not positioned correctly if the page was scrolled past the top. + * Fixed a bug in which certain popups on the left and right side of the page + scrolled along with the page instead of staying fixed in place. 1.6.12: May 19, 2009 * Added a toolbar color button for setting text and background colors. diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 94e98ed..668a41a 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -876,6 +876,8 @@ Wiki.prototype.resize_editor = function () { } Wiki.prototype.resize_toolbar = function () { + this.clear_pulldowns(); + var last_toolbar_button = getElement( "insertOrderedList" ); var current_toolbar_bottom = getElementPosition( last_toolbar_button ).y + getElementDimensions( last_toolbar_button ).h; var viewport_size = getViewportDimensions(); @@ -3244,25 +3246,25 @@ function calculate_position( node, anchor, relative_to, always_left_align ) { } catch ( e ) {} } - // position the pulldown under the anchor - var position = getElementPosition( anchor ); + var parent_node = anchor.parentNode; + var fixed_parent = null; - // in WebKit, work around a bug in which children/grandchildren/etc of relatively positioned - // elements inside of fixed position elements have an incorrect position - if ( WEBKIT ) { - var parent_node = anchor.parentNode; - var found_fixed_parent = false; - - while ( parent_node ) { - if ( getStyle( parent_node, "position" ) == "fixed" ) - found_fixed_parent = true; - else if ( found_fixed_parent && getStyle( parent_node, "position" ) == "relative" ) { - position.x -= parent_node.offsetLeft; - position.y -= parent_node.offsetTop; - break; - } - parent_node = parent_node.parentNode; + // determine whether this node has an ancentor node that has a fixed position + while ( parent_node && parent_node.nodeName != "#document" ) { + if ( getStyle( parent_node, "position" ) == "fixed" ) { + fixed_parent = parent_node; + break; } + + parent_node = parent_node.parentNode; + } + + // position the pulldown under the anchor relative to the fixed ancestor (if any) + var position = getElementPosition( anchor, fixed_parent ); + if ( fixed_parent ) { + position.x += fixed_parent.offsetLeft; + position.y += fixed_parent.offsetTop; + setStyle( node, { "position": "fixed" } ) } if ( relative_to ) {