assets/js/romo/dropdown.js in romo-0.19.6 vs assets/js/romo/dropdown.js in romo-0.19.7
- old
+ new
@@ -36,10 +36,18 @@
this.doInitBody();
this.elem.trigger('dropdown:ready', [this]);
}
+RomoDropdown.prototype.popupOpen = function() {
+ return this.popupElem.hasClass('romo-dropdown-open') === true;
+}
+
+RomoDropdown.prototype.popupClosed = function() {
+ return this.popupElem.hasClass('romo-dropdown-open') === false;
+}
+
RomoDropdown.prototype.doInit = function() {
// override as needed
}
RomoDropdown.prototype.doInitPopup = function() {
@@ -175,11 +183,11 @@
}
return false;
}
RomoDropdown.prototype.doToggle = function() {
- if (this.popupElem.hasClass('romo-dropdown-open')) {
+ if (this.popupOpen()) {
setTimeout($.proxy(function() {
this.doPopupClose();
}, this), 100);
} else {
setTimeout($.proxy(function() {
@@ -192,12 +200,11 @@
RomoDropdown.prototype.onPopupOpen = function(e) {
if (e !== undefined) {
e.preventDefault();
}
- if (this.elem.hasClass('disabled') === false &&
- this.popupElem.hasClass('romo-dropdown-open') === false) {
+ if (this.elem.hasClass('disabled') === false && this.popupClosed()) {
setTimeout($.proxy(function() {
this.doPopupOpen();
}, this), 100);
}
}
@@ -233,12 +240,11 @@
RomoDropdown.prototype.onPopupClose = function(e) {
if (e !== undefined) {
e.preventDefault();
}
- if (this.elem.hasClass('disabled') === false &&
- this.popupElem.hasClass('romo-dropdown-open') === true) {
+ if (this.elem.hasClass('disabled') === false && this.popupOpen()) {
setTimeout($.proxy(function() {
this.doPopupClose();
}, this), 100);
}
}
@@ -273,10 +279,10 @@
this.popupElem.off('keyup', $.proxy(this.onElemKeyUp, this));
}
RomoDropdown.prototype.onElemKeyUp = function(e) {
if (this.elem.hasClass('disabled') === false) {
- if (this.popupElem.hasClass('romo-dropdown-open')) {
+ if (this.popupOpen()) {
if(e.keyCode === 27 /* Esc */ ) {
this.doPopupClose();
this.elem.trigger('dropdown:popupClosedByEsc', [this]);
return false;
} else {