Skip to content

Commit

Permalink
Changed from ionic-plugin-keyboard to cordova-plugin-keyboard
Browse files Browse the repository at this point in the history
Refactored ionKeyboard to suits changes.
  • Loading branch information
Oliver Klein committed Mar 22, 2016
1 parent 93a2d4e commit f91c727
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
39 changes: 8 additions & 31 deletions components/ionKeyboard/ionKeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,42 @@ Meteor.startup(function () {
IonKeyboard = {
close: function () {
if (Meteor.isCordova) {
cordova.plugins.Keyboard.close();
Keyboard.hide();
}
},

show: function () {
if (Meteor.isCordova) {
cordova.plugins.Keyboard.show();
Keyboard.show();
}
},

hideKeyboardAccessoryBar: function () {
if (Meteor.isCordova) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
Keyboard.hideFormAccessoryBar(true);
}
},

showKeyboardAccessoryBar: function () {
if (Meteor.isCordova) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
Keyboard.hideFormAccessoryBar(false);
}
},

disableScroll: function () {
if (Meteor.isCordova) {
cordova.plugins.Keyboard.disableScroll(true);
Keyboard.disableScrollingInShrinkView(true);
}
},

enableScroll: function () {
if (Meteor.isCordova) {
cordova.plugins.Keyboard.disableScroll(false);
Keyboard.disableScrollingInShrinkView(false);
}
}
};

window.addEventListener('native.keyboardshow', function (event) {

window.addEventListener('keyboardHeightWillChange', function (event) {
// TODO: Android is having problems
if (Platform.isAndroid()) {
return;
Expand All @@ -52,24 +51,12 @@ window.addEventListener('native.keyboardshow', function (event) {
$('body').addClass('keyboard-open');
var keyboardHeight = event.keyboardHeight;

// Attach any elements that want to be attached
$('[data-keyboard-attach]').each(function (index, el) {
$(el).data('ionkeyboard.bottom', $(el).css('bottom'));
$(el).css({bottom: keyboardHeight});
});

// Move the bottom of the content area(s) above the top of the keyboard
$('.content.overflow-scroll').each(function (index, el) {
$(el).data('ionkeyboard.bottom', $(el).css('bottom'));
$(el).css({bottom: keyboardHeight});
});

// Scroll to the focused element
scrollToFocusedElement(null, keyboardHeight);

});

window.addEventListener('native.keyboardhide', function (event) {
window.addEventListener('keyboardDidHide', function (event) {

// TODO: Android is having problems
if (Platform.isAndroid()) {
Expand All @@ -79,14 +66,4 @@ window.addEventListener('native.keyboardhide', function (event) {
// $('input, textarea').blur();
$('body').removeClass('keyboard-open');

// Detach any elements that were attached
$('[data-keyboard-attach]').each(function (index, el) {
$(el).css({bottom: $(el).data('ionkeyboard.bottom')});
});

// Reset the content area(s)
$('.content.overflow-scroll').each(function (index, el) {
$(el).css({bottom: $(el).data('ionkeyboard.bottom')});
});

});
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Package.describe({
});

Cordova.depends({
'ionic-plugin-keyboard': '1.0.8'
'cordova-plugin-keyboard': '1.1.3'
});

Package.onUse(function(api) {
Expand Down

0 comments on commit f91c727

Please sign in to comment.