Skip to content

Commit

Permalink
Ignore position utility if position option is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed May 29, 2014
1 parent 139bafa commit 28e4e7c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions js/jquery.keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ As a plugin to jQuery UI styling and theme will automatically
match that used by jQuery UI with the exception of the required CSS.
Requires:
jQuery
jQuery v1.4.3+
jQuery UI (position utility only) & CSS theme
Setup/Usage:
Expand Down Expand Up @@ -183,6 +183,7 @@ $.keyboard = function(el, options){
};

base.reveal = function(){
var p, s;
base.opening = true;
// remove all "extra" keyboards
$('.ui-keyboard').not('.ui-keyboard-always-open').remove();
Expand Down Expand Up @@ -219,11 +220,6 @@ $.keyboard = function(el, options){
// disable/enable accept button
if (o.acceptValid) { base.checkValid(); }

var p, s;
base.position = o.position;
// get single target position || target stored in element data (multiple targets) || default @ element
base.position.of = base.position.of || base.$el.data('keyboardPosition') || base.$el;
base.position.collision = base.position.collision || 'flipfit flipfit';
if (o.resetDefault) {
base.shiftActive = base.altActive = base.metaActive = false;
base.showKeySet();
Expand Down Expand Up @@ -255,8 +251,13 @@ $.keyboard = function(el, options){
base.$preview.width(base.width);
}

base.position = o.position;

// position after keyboard is visible (required for UI position utility) and appropriately sized
if ($.ui && $.ui.position) {
if ($.ui && $.ui.position && !$.isEmptyObject(base.position)) {
// get single target position || target stored in element data (multiple targets) || default @ element
base.position.of = base.position.of || base.$el.data('keyboardPosition') || base.$el;
base.position.collision = base.position.collision || 'flipfit flipfit';
base.$keyboard.position(base.position);
}

Expand Down Expand Up @@ -336,7 +337,9 @@ $.keyboard = function(el, options){
} else {
// No preview display, use element and reposition the keyboard under it.
base.$preview = base.$el;
o.position.at = o.position.at2;
if (!$.isEmptyObject(base.position)) {
o.position.at = o.position.at2;
}
}

}
Expand All @@ -356,7 +359,7 @@ $.keyboard = function(el, options){
base.bindKeys();

// adjust with window resize
if ($.ui && $.ui.position) {
if ($.ui && $.ui.position && !$.isEmptyObject(base.position)) {
$(window).bind('resize.keyboard', function(){
if (base.isVisible()) {
base.$keyboard.position(base.position);
Expand Down

0 comments on commit 28e4e7c

Please sign in to comment.