Skip to content

Commit

Permalink
updated dateinput.js to calculate proper top offset
Browse files Browse the repository at this point in the history
  • Loading branch information
saturnflyer committed Feb 15, 2010
1 parent f02084d commit 673c109
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion public/javascripts/admin/dateinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,28 @@ DateInputBehavior.Calendar = Behavior.create({
this.date = this.selector.getDate();
this.redraw();
this.element.setStyle({
'top': this.selector.element.cumulativeOffset().top - (this.element.getHeight() + 4) + 'px',
'top': this.vertical_offset(this.selector.element) + 'px',
'left': Math.max(this.selector.element.cumulativeOffset().left + this.selector.element.getWidth() - this.element.getWidth() - 4, this.selector.element.cumulativeOffset().left) + 'px',
'z-index': 10001
});
this.element.show();
this.active = true;
},

vertical_offset: function(selector){
default_vertical_offset = this.selector.element.cumulativeOffset().top + this.selector.element.getHeight() + 2;
this_height = this.element.getHeight();
if(document.viewport.getHeight() > default_vertical_offset + this_height) {
top_value = default_vertical_offset;
} else {
top_value = (default_vertical_offset - this_height - selector.getHeight() - 6);
}
if(top_value < document.viewport.getScrollOffsets().top) {
top_value = document.viewport.getScrollOffsets().top;
}
return top_value;
},

hide: function() {
this.element.hide();
this.active = false;
Expand Down

0 comments on commit 673c109

Please sign in to comment.