From 3ed56a03ce7e2a226a88d9115acc40e002ae765d Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Sun, 27 Dec 2009 15:49:24 +0300 Subject: [PATCH] * fixed context menu to work with scrolled document --- src/ajax.js | 10 +++++----- src/style.css | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index c1a832a..9bdeedd 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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; } diff --git a/src/style.css b/src/style.css index 4b5bcd0..25bddcb 100644 --- a/src/style.css +++ b/src/style.css @@ -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 }