From e738f3a729522b648b5148e3f3e0bbf15165b9a9 Mon Sep 17 00:00:00 2001 From: chang-zhao Date: Sat, 21 Mar 2015 15:57:33 +0300 Subject: 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. --- lib/scripts/toolbar.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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}); } /** -- cgit v1.2.3