Compare commits

...

3 Commits

5 changed files with 85 additions and 27 deletions

View File

@@ -201,8 +201,9 @@ $ibo-input-select--autocomplete-item-image--border: 1px solid $ibo-color-grey-60
} }
// N°7982 Default selectize stylesheet override // N°7982 Default selectize stylesheet override
// N°9468 Dropdown content needs to be a few pixel shorter than the dropdown itself to avoid double scrollbar
.selectize-dropdown-content{ .selectize-dropdown-content{
max-height: $ibo-input-select-selectize--dropdown--max-height; max-height: calc(#{$ibo-input-select-selectize--dropdown--max-height} - 4px);
} }
.selectize-dropdown.ui-menu .ui-state-active { .selectize-dropdown.ui-menu .ui-state-active {

View File

@@ -175,6 +175,7 @@ $ibo-input-select--action-button--color: $ibo-input-select-wrapper--after--color
$ibo-input-select-selectize--item--active--text-color: $ibo-color-grey-100 !default; $ibo-input-select-selectize--item--active--text-color: $ibo-color-grey-100 !default;
$ibo-input-select-selectize--item--active--background-color: $ibo-color-grey-500 !default; $ibo-input-select-selectize--item--active--background-color: $ibo-color-grey-500 !default;
$ibo-input-select--autocomplete-item-image--background-color: $ibo-color-grey-800 !default; $ibo-input-select--autocomplete-item-image--background-color: $ibo-color-grey-800 !default;
$ibo-input-date--button--color: $ibo-input-select--action-button--color;
$ibo-vendors-selectize-input--color: $ibo-body-text-color !default; $ibo-vendors-selectize-input--color: $ibo-body-text-color !default;
$ibo-vendors-selectize-input--background-color: $ibo-input--background-color !default; $ibo-vendors-selectize-input--background-color: $ibo-input--background-color !default;
$ibo-vendors-selectize--input--border-color: $ibo-input--border-color !default; $ibo-vendors-selectize--input--border-color: $ibo-input--border-color !default;
@@ -222,6 +223,11 @@ $ibo-vendors-datatables--row-highlight--colors:('red': ($ibo-color-red-700),'dan
$ibo-vendors-jqueryui--ui-dialog--background-color: $ibo-color-grey-800 !default; $ibo-vendors-jqueryui--ui-dialog--background-color: $ibo-color-grey-800 !default;
$ibo-vendors-jqueryui--ui-dialog-titlebar--border-bottom: solid 1px $ibo-color-grey-500 !default; $ibo-vendors-jqueryui--ui-dialog-titlebar--border-bottom: solid 1px $ibo-color-grey-500 !default;
$ibo-vendors-jqueryui--ui-datepicker--background-color: $ibo-color-grey-700 !default;
$ibo-vendors-jqueryui--ui-datepicker-days--color: $ibo-color-primary-200 !default;
$ibo-vendors-jqueryui--ui-datepicker-days--highlight--background-color: $ibo-color-primary-800 !default;
$ibo-vendors-jqueryui--ui-datepicker-days--hover--background-color: $ibo-color-primary-500 !default;
$ibo-vendors-jqueryui--ui-datepicker-days--active--background-color: $ibo-color-primary-700 !default;

View File

@@ -171,7 +171,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
// To avoid dropdown to be cut by the container's overflow hidden rule // To avoid dropdown to be cut by the container's overflow hidden rule
dropdownParent: 'body', dropdownParent: 'body',
onDropdownOpen: function (oDropdownElem) { onDropdownOpen: function (oDropdownElem) {
me.UpdateDropdownPosition(this.$control, oDropdownElem); me.UpdateDropdownPosition(this.$control, oDropdownElem, this.$dropdown_content);
}, },
}); });
let $selectize = $select[0].selectize; // This stores the selectize object to a variable (with name 'selectize') let $selectize = $select[0].selectize; // This stores the selectize object to a variable (with name 'selectize')
@@ -314,13 +314,14 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
}; };
/** /**
* Update the dropdown's position so it always fits in the screen * Update the dropdown's position so it always fits in the screen
* *
* @param {object} oControlElem jQuery object representing the "control" input (= where the user types) of the external key * @param {object} oControlElem jQuery object representing the "control" input (= where the user types) of the external key
* @param {object} oDropdownElem jQuery object representing the results dropdown * @param {object} oDropdownElem jQuery object representing the results dropdown
* @return {void} * @param {object|undefined} oDropdownContentElem
*/ * @return {void}
this.UpdateDropdownPosition = function (oControlElem, oDropdownElem) { */
this.UpdateDropdownPosition = function (oControlElem, oDropdownElem, oDropdownContentElem) {
// First fix width to ensure it's not too long // First fix width to ensure it's not too long
const fControlWidth = oControlElem.outerWidth(); const fControlWidth = oControlElem.outerWidth();
oDropdownElem.css('width', fControlWidth); oDropdownElem.css('width', fControlWidth);
@@ -328,6 +329,13 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
// Then, fix height / position to ensure it's within the viewport // Then, fix height / position to ensure it's within the viewport
const fWindowHeight = window.innerHeight; const fWindowHeight = window.innerHeight;
// Clear previously set rule so the comparison is done with dropdown real height
oDropdownElem.css('max-height', '');
if(oDropdownContentElem) {
oDropdownContentElem.css('max-height', '');
}
const fControlTopY = oControlElem.offset().top; const fControlTopY = oControlElem.offset().top;
const fControlHeight = oControlElem.outerHeight(); const fControlHeight = oControlElem.outerHeight();
@@ -338,14 +346,38 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
if (fDropdownBottomY > fWindowHeight) { if (fDropdownBottomY > fWindowHeight) {
// Set dropdown max-height to 1/3 of the screen, this way we are sure the dropdown will fit in either the top / bottom half of the screen // Set dropdown max-height to 1/3 of the screen, this way we are sure the dropdown will fit in either the top / bottom half of the screen
oDropdownElem.css('max-height', '30vh'); oDropdownElem.css({
maxHeight: '30vh',
});
fDropdownHeight = oDropdownElem.outerHeight(); fDropdownHeight = oDropdownElem.outerHeight();
// Position dropdown above input if not enough space on the bottom part of the screen // N°9468 Dropdown content needs to be a few pixel shorter than the dropdown itself to avoid double scrollbar
if(oDropdownContentElem) {
oDropdownContentElem.css('max-height', 'calc(30vh - 4px)');
}
/* Position dropdown above input if not enough space on the bottom part of the screen
Doesn't seem to work with selectize as an internal plugin "auto_position" refreshes the top position after
this method is called, input set use a custom plugin to avoid fix this issue "plugin_combodo_auto_position"
This would need to take the potential 4px difference into account if this is fixed.
*/
if ((fDropdownTopY / fWindowHeight) > 0.6) { if ((fDropdownTopY / fWindowHeight) > 0.6) {
oDropdownElem.css('top', fDropdownTopY - fDropdownHeight - fControlHeight); oDropdownElem.css({
} top: fDropdownTopY - fDropdownHeight - fControlHeight,
borderTop: oDropdownElem.css('border-bottom')
});
}
else {
oDropdownElem.css({
borderTop: 'none'
})
}
} }
else {
oDropdownElem.css({
borderTop: 'none'
})
}
}; };
this.ManageScroll = function () { this.ManageScroll = function () {
if ($('#label_'+me.id).scrollParent()[0].tagName != 'HTML') { if ($('#label_'+me.id).scrollParent()[0].tagName != 'HTML') {

View File

@@ -22,7 +22,7 @@ Selectize.define("combodo_auto_position", function (aOptions) {
// Plugin options // Plugin options
aOptions = $.extend({ aOptions = $.extend({
maxDropDownHeight: 200, maxDropDownHeight: '200px',
}, },
aOptions aOptions
); );
@@ -33,28 +33,47 @@ Selectize.define("combodo_auto_position", function (aOptions) {
// Override position dropdown function // Override position dropdown function
oSelf.positionDropdown = (function () { oSelf.positionDropdown = (function () {
return function () { return function () {
let iRefHeight = oSelf.$dropdown.outerHeight() < aOptions.maxDropDownHeight ? // Clear previously set rules so the comparison is done with dropdown real height
oSelf.$dropdown.outerHeight() : aOptions.maxDropDownHeight; oSelf.$dropdown.css({
'max-height': '',
});
if(oSelf.$control.offset().top + oSelf.$control.outerHeight() + iRefHeight > window.innerHeight){ oSelf.$dropdown_content.css({
'max-height': '',
});
oSelf.$dropdown.css({ let iDropdownHeight = oSelf.$dropdown.outerHeight();
top: oSelf.$control.offset().top - iRefHeight, if(oSelf.$control.offset().top + oSelf.$control.outerHeight() + iDropdownHeight > window.innerHeight){
left: oSelf.$control.offset().left,
// Apply max-height as we are overflowing, that'll allow us to calculate where we should place ourselves later
oSelf.$dropdown.css({
maxHeight: `${aOptions.maxDropDownHeight}`,
})
iDropdownHeight = oSelf.$dropdown.outerHeight();
oSelf.$dropdown.css({
top: oSelf.$control.offset().top - iDropdownHeight + 4, // Content will be shorter, so our real height too
left: oSelf.$control.offset().left,
width: oSelf.$wrapper.outerWidth(), width: oSelf.$wrapper.outerWidth(),
'max-height': `${aOptions.maxDropDownHeight}px`, overflowY: 'auto',
'overflow-y': 'auto', borderTop : oSelf.$dropdown.css('border-bottom')
'border-top': '1px solid #d0d0d0',
}); });
// N°9468 Dropdown content needs to be a few pixel shorter than the dropdown itself to avoid double scrollbar
oSelf.$dropdown_content.css({
'max-height': `calc(${aOptions.maxDropDownHeight} - 4px)`
});
} }
else{ else{
oSelf.$dropdown.css({ oSelf.$dropdown.css({
top: oSelf.$control.offset().top + oSelf.$control.outerHeight(), top: oSelf.$control.offset().top + oSelf.$control.outerHeight(),
left: oSelf.$control.offset().left, left: oSelf.$control.offset().left,
width: oSelf.$wrapper.outerWidth(), width: oSelf.$wrapper.outerWidth(),
'max-height': `${aOptions.maxDropDownHeight}px`, overflowY: 'auto',
'overflow-y': 'auto' borderTop: 'none'
}); });
} }
}; };
}()); }());

View File

@@ -23,7 +23,7 @@ let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({
}, },
{# PLUGIN combodo auto position #} {# PLUGIN combodo auto position #}
'combodo_auto_position' : { 'combodo_auto_position' : {
maxDropDownHeight: 300, {# in px #} maxDropDownHeight: '30vh', {# same value as external key widget #}
}, },
{# PLUGIN combodo add button #} {# PLUGIN combodo add button #}
{% if oUIBlock.HasAddOptionButton() %} {% if oUIBlock.HasAddOptionButton() %}