assets/js/romo/dropdown.js in romo-0.17.0 vs assets/js/romo/dropdown.js in romo-0.17.1
- old
+ new
@@ -276,10 +276,11 @@
RomoDropdown.prototype.onElemKeyUp = function(e) {
if (this.elem.hasClass('disabled') === false) {
if (this.popupElem.hasClass('romo-dropdown-open')) {
if(e.keyCode === 27 /* Esc */ ) {
this.doPopupClose();
+ this.elem.trigger('dropdown:popupClosedByEsc', [this]);
return false;
} else {
return true;
}
} else {
@@ -319,10 +320,11 @@
}
RomoDropdown.prototype.onWindowBodyKeyUp = function(e) {
if (e.keyCode === 27 /* Esc */) {
this.doPopupClose();
+ this.elem.trigger('dropdown:popupClosedByEsc', [this]);
}
return true;
}
RomoDropdown.prototype.onResizeWindow = function(e) {
@@ -331,11 +333,10 @@
}
RomoDropdown.prototype.doPlacePopupElem = function() {
if (this.elem.parents('.romo-modal-popup').size() !== 0) {
this.popupElem.css({'position': 'fixed'});
- this.popupElem.offset(this.elem.offset());
}
var pos = $.extend({}, this.elem[0].getBoundingClientRect(), this.elem.offset());
var w = this.popupElem[0].offsetWidth;
var h = this.popupElem[0].offsetHeight;
@@ -358,10 +359,13 @@
} else {
configPosition = 'bottom';
configHeight = bottomAvailHeight;
}
+ // remove any height difference between the popup and content elems
+ // assumes popup height always greater than or equal to content height
+ configHeight = configHeight - (h - this.contentElem[0].offsetHeight);
this.contentElem.css({'max-height': configHeight.toString() + 'px'});
}
if(h > configHeight) {
h = configHeight;
@@ -384,10 +388,14 @@
case 'right':
$.extend(offset, { left: pos.left + pos.width - w });
break;
}
+ $.extend(offset, {
+ top: this._roundPosOffsetVal(offset['top']),
+ left: this._roundPosOffsetVal(offset['left'])
+ });
this.popupElem.offset(offset);
}
RomoDropdown.prototype.doSetPopupZIndex = function(relativeElem) {
var relativeZIndex = Romo.parseZIndex(relativeElem);
@@ -416,9 +424,13 @@
return maxHeight;
}
RomoDropdown.prototype._getPopupMaxHeightDetectPad = function(position) {
return this.elem.data('romo-dropdown-max-height-detect-pad-'+position) || this.elem.data('romo-dropdown-max-height-detect-pad') || 10;
+}
+
+RomoDropdown.prototype._roundPosOffsetVal = function(value) {
+ return Math.round(value*100) / 100;
}
Romo.onInitUI(function(e) {
Romo.initUIElems(e, '[data-romo-dropdown-auto="true"]').romoDropdown();
});