diff options
author | chang-zhao <chang-zhao@users.noreply.github.com> | 2015-03-21 15:57:33 +0300 |
---|---|---|
committer | chang-zhao <chang-zhao@users.noreply.github.com> | 2015-03-21 15:57:33 +0300 |
commit | e738f3a729522b648b5148e3f3e0bbf15165b9a9 (patch) | |
tree | 7cb6bb58a606cefc3ed5b30226b812f02701d2aa /lib/scripts | |
parent | 04b2c4dcc9d6084cfaa455fb4db8e87ba70f4d15 (diff) | |
download | rpg-e738f3a729522b648b5148e3f3e0bbf15165b9a9.tar.gz rpg-e738f3a729522b648b5148e3f3e0bbf15165b9a9.tar.bz2 |
Update toolbar.js
When the picker button is near the border of the screen, then an opening panel of picker buttons can go over the screen edge. That's not convenient. So we should add a check in a `function pickerToggle()` and shift picker buttons position if needed.
Diffstat (limited to 'lib/scripts')
-rw-r--r-- | lib/scripts/toolbar.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 1bb02b406..a5f831ade 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -243,7 +243,20 @@ function pickerToggle(pickerid,$btn){ } else { $picker.addClass('a11y').attr('aria-hidden', 'true'); } - $picker.offset({left: pos.left+3, top: pos.top+$btn[0].offsetHeight+3}); + var picker_left = pos.left + 3, + picker_width = $picker.width(), + window_width = jQuery(window).width(); + if (picker_width > 300) { + $picker.css("max-width", "300"); + picker_width = 300; + } + if ((picker_left + picker_width + 40) > window_width) { + picker_left = window_width - picker_width - 40; + } + if (picker_left < 0) { + picker_left = 0; + } + $picker.offset({left: picker_left, top: pos.top+$btn[0].offsetHeight+3}); } /** |