Skip to content

Commit a652380

Browse files
committed
bring over customizations to forked project:
angular-ui#267 angular-ui#378 angular-ui#558 angular-ui#399 angular-ui#819 angular-ui#880 angular-ui#1311 Essentially provides better control over direction to open, and we make sure the drop up/down element isnt clipped by bounding containers with overflow settings.
1 parent 5283c71 commit a652380

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/uiSelectDirective.js

+32-4
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,40 @@ uis.directive('uiSelect',
335335
var scrollTop = $document[0].documentElement.scrollTop || $document[0].body.scrollTop; //To make it cross browser (blink, webkit, IE, Firefox).
336336

337337
// Determine if the direction of the dropdown needs to be changed.
338-
if (offset.top + offset.height + offsetDropdown.height > scrollTop + $document[0].documentElement.clientHeight) {
339-
//Go UP
338+
var parents = angular.element(element).parents('.modal-dialog .ibox-content');
339+
340+
var parent = undefined;
341+
if(parents && parents.length > 1){
342+
parent = parents[1];
343+
}
344+
if(parents && parents.length == 1){
345+
parent = parents[0];
346+
}
347+
var boundingSize;
348+
349+
if(parent){
350+
var parentOffset = uisOffset([parent]);
351+
boundingSize = parentOffset.top + parentOffset.height
352+
} else {
353+
boundingSize = scrollTop + $document[0].documentElement.clientHeight - 39;
354+
}
355+
356+
if (parent && (offset.top + offset.height + offsetDropdown.height) > boundingSize) {
357+
//Go UP, but if by going up you go past the bounding box, we reduce the height and top offset for the dropdown
358+
var parentOffset = uisOffset([parent]);
359+
var availableSpaceForDropdown = offset.top - parentOffset.top;
360+
if(offsetDropdown.height > availableSpaceForDropdown){
361+
offsetDropdown.height = availableSpaceForDropdown - 10;
362+
dropdown[0].style.height = offsetDropdown.height + 'px';
363+
}
340364
setDropdownPosUp(offset, offsetDropdown);
341365
}else{
342-
//Go DOWN
343-
setDropdownPosDown(offset, offsetDropdown);
366+
if((offset.top + offset.height + offsetDropdown.height) > boundingSize){
367+
setDropdownPosUp(offset, offsetDropdown);
368+
} else {
369+
//Go DOWN
370+
setDropdownPosDown(offset, offsetDropdown);
371+
}
344372
}
345373

346374
}

0 commit comments

Comments
 (0)