* fixed context menu to work with scrolled document

This commit is contained in:
Max Pozdeev 2009-12-27 15:49:24 +03:00
parent 9ff55df1e9
commit 3ed56a03ce
2 changed files with 6 additions and 6 deletions

View file

@ -1250,10 +1250,10 @@ function mttMenu(container, options)
this.caller = caller;
$caller = $(caller);
var offset = $caller.offset();
var x = offset.left;
if(offset.left + this.container.outerWidth() > $(window).width()) x = $(window).width() - this.container.outerWidth() - 1;
var x2 = $(window).width() + $(document).scrollLeft() - this.container.outerWidth() - 1;
var x = offset.left < x2 ? offset.left : x2;
var y = offset.top+caller.offsetHeight-1;
if(y + this.container.outerHeight() > $(window).height()) y = offset.top - this.container.outerHeight();
if(y + this.container.outerHeight() > $(window).height() + $(document).scrollTop()) y = offset.top - this.container.outerHeight();
this.container.css({ position: 'absolute', top: y, left: x /*, 'min-width': $caller.width()*/ }).show();
var menu = this;
$(document).bind('click.mttmenuclose', function(e){ menu.close(e) });
@ -1264,9 +1264,9 @@ function mttMenu(container, options)
{
var offset = this.$caller.offset();
var x = offset.left+this.$caller.outerWidth();
if(x + this.container.outerWidth() > $(window).width()) x = offset.left - this.container.outerWidth() - 1;
if(x + this.container.outerWidth() > $(window).width() + $(document).scrollLeft()) x = offset.left - this.container.outerWidth() - 1;
var y = offset.top + this.parent.container.offset().top-this.parent.container.find('li:first').offset().top;
if(y + this.container.outerHeight() > $(window).height()) y = $(window).height() - this.container.outerHeight() - 1;
if(y + this.container.outerHeight() > $(window).height() + $(document).scrollTop()) y = $(window).height() + $(document).scrollTop()- this.container.outerHeight() - 1;
this.container.css({ position: 'absolute', top: y, left: x /*, 'min-width': this.$caller.outerWidth()*/ }).show();
this.menuOpen = true;
}

View file

@ -187,7 +187,7 @@ div.task-note-area textarea { color:#999999; width:100%; display:block; height:6
.mtt-btnmenu-container { overflow: hidden; z-index:100; background-color:#f9f9f9; border:1px solid #cccccc; padding:3px; }
.mtt-btnmenu-container ul { list-style: none; padding:0; margin:0; }
.mtt-btnmenu-container li { margin:1px 0px; padding:2px; cursor:pointer; color:#000; }
.mtt-btnmenu-container li { margin:1px 0px; padding:2px; cursor:pointer; color:#000; white-space:nowrap; }
.mtt-btnmenu-container li:hover { background-color:#316AC5; color:white; }
.mtt-btnmenu-container li.mtt-need-list.mtt-disabled { color:#ACA899; }
.mtt-btnmenu-delimiter { height:0px; border-top:1px solid #cccccc; margin:2px -1px 2px -1px }