fix #5789 gradebook2 dropdown cut off on the left

Change-Id: If1fe394d020e46172618eda43c00b8838389406c
Reviewed-on: https://gerrit.instructure.com/6290
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Reviewed-by: Ryan Florence <ryanf@instructure.com>
This commit is contained in:
Ryan Shaw 2011-10-18 17:08:16 -06:00
parent 1fd1eba0c6
commit 2fa3451714
2 changed files with 9 additions and 7 deletions

View File

@ -12,18 +12,18 @@ $.fn.kyleMenu = (options) ->
$.fn.kyleMenu.defaults =
popupOpts:
position: { my: 'center top', at: 'center bottom', offset: '0 10px' },
position: { my: 'center top', at: 'center bottom', offset: '0 10px', within: '#main', collision: 'fit' },
open: (event) ->
# handle sticking the carat right below where you clicked on the button
$(this).find(".ui-menu-carat").remove()
$trigger = $(this).popup("option", "trigger")
triggerWidth = $trigger.width()
differenceInWidth = $(this).width() - triggerWidth
differenceInOffset = $trigger.offset().left - $(this).offset().left
actualOffset = event.pageX - $trigger.offset().left
caratOffset = Math.min(
Math.max(20, actualOffset),
triggerWidth - 20
) + differenceInWidth/2
) + differenceInOffset
$('<span class="ui-menu-carat"><span /></span>').css('left', caratOffset).prependTo(this)
# this, along with the webkit animation makes it bounce into place.

View File

@ -19,16 +19,18 @@
position: {
my: 'center top',
at: 'center bottom',
offset: '0 10px'
offset: '0 10px',
within: '#main',
collision: 'fit'
},
open: function(event) {
var $trigger, actualOffset, caratOffset, differenceInWidth, triggerWidth;
var $trigger, actualOffset, caratOffset, differenceInOffset, triggerWidth;
$(this).find(".ui-menu-carat").remove();
$trigger = $(this).popup("option", "trigger");
triggerWidth = $trigger.width();
differenceInWidth = $(this).width() - triggerWidth;
differenceInOffset = $trigger.offset().left - $(this).offset().left;
actualOffset = event.pageX - $trigger.offset().left;
caratOffset = Math.min(Math.max(20, actualOffset), triggerWidth - 20) + differenceInWidth / 2;
caratOffset = Math.min(Math.max(20, actualOffset), triggerWidth - 20) + differenceInOffset;
$('<span class="ui-menu-carat"><span /></span>').css('left', caratOffset).prependTo(this);
return $(this).css('-webkit-transform-origin-x', caratOffset + 'px').addClass('ui-state-open');
},