Skip to content

Commit

Permalink
Core: combine keyboard checks. See #653
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Feb 21, 2018
1 parent 7e23c23 commit f5dc7f5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions js/jquery.keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ http://www.opensource.org/licenses/mit-license.php
});
}
// add disabled/readonly class - dynamically updated on reveal
if (base.$el.is(':disabled') || (!base.options.activeOnReadonly &&
base.$el.attr('readonly') && !base.$el.hasClass(kbcss.locked))) {
if (base.isUnavailable()) {
base.$el.addClass(kbcss.noKeyboard);
}
if (o.openOn) {
Expand Down Expand Up @@ -270,6 +269,16 @@ http://www.opensource.org/licenses/mit-license.php
base.isOpen = true;
};

base.isUnavailable = function() {
return (
base.$el.is(':disabled') || (
!base.options.activeOnReadonly &&
base.$el.attr('readonly') &&
!base.$el.hasClass(kbcss.locked)
)
);
}

base.isCurrent = function (set) {
var cur = $keyboard.currentKeyboard || false;
if (set) {
Expand Down Expand Up @@ -350,9 +359,7 @@ http://www.opensource.org/licenses/mit-license.php
});

// Don't open if disabled
if (base.$el.is(':disabled') || (!base.options.activeOnReadonly && base.$el.attr('readonly') &&
!base.$el.hasClass(kbcss.locked))) {
base.$el.addClass(kbcss.noKeyboard);
if (base.isUnavailable()) {
return;
}
base.$el.removeClass(kbcss.noKeyboard);
Expand Down

0 comments on commit f5dc7f5

Please sign in to comment.