Skip to content

Commit

Permalink
Merge pull request #50 from acsone/10.0-fix_dropdown_menu_position-lmi
Browse files Browse the repository at this point in the history
[10.0] [FIX] dropdown menu position
  • Loading branch information
lmignon committed Mar 17, 2017
2 parents ab5d052 + 8b19a4b commit 451d2ff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
10.0.?.?.? (?)
~~~~~~~~~~~~~~

* Fix: For items displayed into the datatable, adjust the dropdown menu
position based on page width.
* Fix: A name in CMIS can not ends with a dot. On the CMIS backend the
'sanitize_cmis_name' method removes this character if it's found at the
end of the string to sanitize and this case is detected by the method
Expand Down
25 changes: 22 additions & 3 deletions cmis_web/static/src/js/form_widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,28 @@ var CmisMixin = {
*/
dropdown_fix_position: function(button){
var dropdown = $(button.parent()).find('.dropdown-menu');
var dropDownTop = button.offset().top + button.outerHeight();
dropdown.css('top', dropDownTop + "px");
dropdown.css('left', button.offset().left + "px");
var offset = button.offset();
var dropDownTop = offset.top + button.outerHeight();
dropdown.css('top', dropDownTop + "px");

// For the left position we need to take care of the available space
// on the right and the width of the dropdown to display according to
// its content.
// see http://codereview.stackexchange.com/questions/31501/adjust-bootstrap-dropdown-menu-based-on-page-width/39580
var offsetLeft = offset.left;
var dropdownWidth = dropdown.width();
var docWidth = $(window).width();
var subDropdown = dropdown.eq(1);
var subDropdownWidth = subDropdown.width();
var isDropdownVisible = (offsetLeft + dropdownWidth <= docWidth);
var isSubDropdownVisible = (offsetLeft + dropdownWidth + subDropdownWidth <= docWidth);
if (!isDropdownVisible || !isSubDropdownVisible) {
dropdown.addClass('pull-right');
dropdown.css('left', '');
} else {
dropdown.removeClass('pull-right');
dropdown.css('left', button.offset().left + "px");
}
},


Expand Down
6 changes: 6 additions & 0 deletions cmis_web/static/src/less/form_widgets.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
.btn-xs {
.button-size(@padding-xs-vertical; @padding-xs-horizontal; @font-size-small; @line-height-small; @btn-border-radius-small) !important;
}
.dropdown-menu {
> li > a {
padding-top: 3px !important;
padding-bottom: 3px !important;
}
}
}
}

Expand Down

0 comments on commit 451d2ff

Please sign in to comment.