From f91c7278fdd6f1cf44c55e29d1321789e978668b Mon Sep 17 00:00:00 2001 From: Oliver Klein Date: Tue, 22 Mar 2016 09:40:19 -0700 Subject: [PATCH 1/3] Changed from ionic-plugin-keyboard to cordova-plugin-keyboard Refactored ionKeyboard to suits changes. --- components/ionKeyboard/ionKeyboard.js | 39 ++++++--------------------- package.js | 2 +- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/components/ionKeyboard/ionKeyboard.js b/components/ionKeyboard/ionKeyboard.js index 4e65130..ee3b2d6 100644 --- a/components/ionKeyboard/ionKeyboard.js +++ b/components/ionKeyboard/ionKeyboard.js @@ -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; @@ -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()) { @@ -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')}); - }); - }); diff --git a/package.js b/package.js index 7ccb336..b0be862 100644 --- a/package.js +++ b/package.js @@ -6,7 +6,7 @@ Package.describe({ }); Cordova.depends({ - 'ionic-plugin-keyboard': '1.0.8' + 'cordova-plugin-keyboard': '1.1.3' }); Package.onUse(function(api) { From 03d0a333754b3c978f1c71f528d4c5557e7ad189 Mon Sep 17 00:00:00 2001 From: Oliver Klein Date: Tue, 22 Mar 2016 18:25:45 -0700 Subject: [PATCH 2/3] Added Backward Compatibility With Older Keyboard plugin --- components/ionKeyboard/ionKeyboard.js | 181 +++++++++++++++++++------- package.js | 3 +- 2 files changed, 138 insertions(+), 46 deletions(-) diff --git a/components/ionKeyboard/ionKeyboard.js b/components/ionKeyboard/ionKeyboard.js index ee3b2d6..fda92c4 100644 --- a/components/ionKeyboard/ionKeyboard.js +++ b/components/ionKeyboard/ionKeyboard.js @@ -3,67 +3,158 @@ Meteor.startup(function () { IonKeyboard.disableScroll(); } }); +//TODO: Added backward compatibility using an if statement to test for newer keyboard plugin +//... cordova-plugin-keyboard. in the future we should remove ionic-plugin-keyboard +//... and take out the if statement below. +if(Keyboard){ + IonKeyboard = { + close: function () { + if (Meteor.isCordova) { + Keyboard.hide(); + } + }, -IonKeyboard = { - close: function () { - if (Meteor.isCordova) { - Keyboard.hide(); - } - }, + show: function () { + if (Meteor.isCordova) { + Keyboard.show(); + } + }, + + hideKeyboardAccessoryBar: function () { + if (Meteor.isCordova) { + Keyboard.hideFormAccessoryBar(true); + } + }, + + showKeyboardAccessoryBar: function () { + if (Meteor.isCordova) { + Keyboard.hideFormAccessoryBar(false); + } + }, - show: function () { - if (Meteor.isCordova) { - Keyboard.show(); + disableScroll: function () { + if (Meteor.isCordova) { + Keyboard.disableScrollingInShrinkView(true); + } + }, + + enableScroll: function () { + if (Meteor.isCordova) { + Keyboard.disableScrollingInShrinkView(false); + } } - }, + }; - hideKeyboardAccessoryBar: function () { - if (Meteor.isCordova) { - Keyboard.hideFormAccessoryBar(true); + window.addEventListener('keyboardHeightWillChange', function (event) { + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; } - }, - showKeyboardAccessoryBar: function () { - if (Meteor.isCordova) { - Keyboard.hideFormAccessoryBar(false); + $('body').addClass('keyboard-open'); + var keyboardHeight = event.keyboardHeight; + + // Scroll to the focused element + scrollToFocusedElement(null, keyboardHeight); + + }); + + window.addEventListener('keyboardDidHide', function (event) { + + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; } - }, - disableScroll: function () { - if (Meteor.isCordova) { - Keyboard.disableScrollingInShrinkView(true); + // $('input, textarea').blur(); + $('body').removeClass('keyboard-open'); + + }); +} else { + IonKeyboard = { + close: function () { + if (Meteor.isCordova) { + cordova.plugins.Keyboard.close(); + } + }, + + show: function () { + if (Meteor.isCordova) { + cordova.plugins.Keyboard.show(); + } + }, + + hideKeyboardAccessoryBar: function () { + if (Meteor.isCordova) { + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); + } + }, + + showKeyboardAccessoryBar: function () { + if (Meteor.isCordova) { + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); + } + }, + + disableScroll: function () { + if (Meteor.isCordova) { + cordova.plugins.Keyboard.disableScroll(true); + } + }, + + enableScroll: function () { + if (Meteor.isCordova) { + cordova.plugins.Keyboard.disableScroll(false); + } } - }, + }; + + window.addEventListener('native.keyboardshow', function (event) { - enableScroll: function () { - if (Meteor.isCordova) { - Keyboard.disableScrollingInShrinkView(false); + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; } - } -}; -window.addEventListener('keyboardHeightWillChange', function (event) { - // TODO: Android is having problems - if (Platform.isAndroid()) { - return; - } + $('body').addClass('keyboard-open'); + var keyboardHeight = event.keyboardHeight; - $('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}); + }); - // Scroll to the focused element - scrollToFocusedElement(null, 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('keyboardDidHide', function (event) { + }); - // TODO: Android is having problems - if (Platform.isAndroid()) { - return; - } + window.addEventListener('native.keyboardhide', function (event) { - // $('input, textarea').blur(); - $('body').removeClass('keyboard-open'); + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; + } -}); + // $('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')}); + }); + + }); +} diff --git a/package.js b/package.js index b0be862..2046b3e 100644 --- a/package.js +++ b/package.js @@ -6,7 +6,8 @@ Package.describe({ }); Cordova.depends({ - 'cordova-plugin-keyboard': '1.1.3' + 'cordova-plugin-keyboard': '1.1.3', + 'ionic-plugin-keyboard': '1.0.8' }); Package.onUse(function(api) { From 2e4894a0b1f8df4321e42be78aff93554dda56e6 Mon Sep 17 00:00:00 2001 From: Oliver Klein Date: Thu, 24 Mar 2016 10:15:49 -0700 Subject: [PATCH 3/3] Fixed backward compatibility addition --- components/ionKeyboard/ionKeyboard.js | 215 ++++++++++++-------------- 1 file changed, 100 insertions(+), 115 deletions(-) diff --git a/components/ionKeyboard/ionKeyboard.js b/components/ionKeyboard/ionKeyboard.js index fda92c4..cbd21db 100644 --- a/components/ionKeyboard/ionKeyboard.js +++ b/components/ionKeyboard/ionKeyboard.js @@ -3,158 +3,143 @@ Meteor.startup(function () { IonKeyboard.disableScroll(); } }); -//TODO: Added backward compatibility using an if statement to test for newer keyboard plugin +//TODO: Added backward compatibility using if statements to test for newer keyboard plugin //... cordova-plugin-keyboard. in the future we should remove ionic-plugin-keyboard -//... and take out the if statement below. -if(Keyboard){ - IonKeyboard = { - close: function () { - if (Meteor.isCordova) { - Keyboard.hide(); +//... and take out the if statements below. +IonKeyboard = { + close: function () { + if (Meteor.isCordova) { + if(typeof(Keyboard) === "undefined"){ + cordova.plugins.Keyboard.close(); + } else { + Keyboard.hide(); } - }, + } + }, - show: function () { - if (Meteor.isCordova) { - Keyboard.show(); + show: function () { + if (Meteor.isCordova) { + if(typeof(Keyboard) === "undefined"){ + cordova.plugins.Keyboard.show(); + } else { + Keyboard.show(); } - }, + } + }, - hideKeyboardAccessoryBar: function () { - if (Meteor.isCordova) { + hideKeyboardAccessoryBar: function () { + if (Meteor.isCordova) { + if(typeof(Keyboard) === "undefined"){ + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); + } else { Keyboard.hideFormAccessoryBar(true); } - }, + } + }, - showKeyboardAccessoryBar: function () { - if (Meteor.isCordova) { + showKeyboardAccessoryBar: function () { + if (Meteor.isCordova) { + if(typeof(Keyboard) === "undefined"){ + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); + } else { Keyboard.hideFormAccessoryBar(false); } - }, + } + }, - disableScroll: function () { - if (Meteor.isCordova) { + disableScroll: function () { + if (Meteor.isCordova) { + if(typeof(Keyboard) === "undefined"){ + cordova.plugins.Keyboard.disableScroll(true); + } else { Keyboard.disableScrollingInShrinkView(true); } - }, + } + }, - enableScroll: function () { - if (Meteor.isCordova) { + enableScroll: function () { + if (Meteor.isCordova) { + if(typeof(Keyboard) === "undefined"){ + cordova.plugins.Keyboard.disableScroll(false); + } else { Keyboard.disableScrollingInShrinkView(false); } } - }; + } +}; - window.addEventListener('keyboardHeightWillChange', function (event) { - // TODO: Android is having problems - if (Platform.isAndroid()) { - return; - } +window.addEventListener('keyboardHeightWillChange', function (event) { + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; + } - $('body').addClass('keyboard-open'); - var keyboardHeight = event.keyboardHeight; + $('body').addClass('keyboard-open'); + var keyboardHeight = event.keyboardHeight; - // Scroll to the focused element - scrollToFocusedElement(null, keyboardHeight); + // Scroll to the focused element + scrollToFocusedElement(null, keyboardHeight); - }); +}); - window.addEventListener('keyboardDidHide', function (event) { +window.addEventListener('keyboardDidHide', function (event) { - // TODO: Android is having problems - if (Platform.isAndroid()) { - return; - } + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; + } - // $('input, textarea').blur(); - $('body').removeClass('keyboard-open'); + // $('input, textarea').blur(); + $('body').removeClass('keyboard-open'); - }); -} else { - IonKeyboard = { - close: function () { - if (Meteor.isCordova) { - cordova.plugins.Keyboard.close(); - } - }, +}); - show: function () { - if (Meteor.isCordova) { - cordova.plugins.Keyboard.show(); - } - }, - hideKeyboardAccessoryBar: function () { - if (Meteor.isCordova) { - cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); - } - }, +window.addEventListener('native.keyboardshow', function (event) { - showKeyboardAccessoryBar: function () { - if (Meteor.isCordova) { - cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); - } - }, + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; + } - disableScroll: function () { - if (Meteor.isCordova) { - cordova.plugins.Keyboard.disableScroll(true); - } - }, + $('body').addClass('keyboard-open'); + var keyboardHeight = event.keyboardHeight; - enableScroll: function () { - if (Meteor.isCordova) { - cordova.plugins.Keyboard.disableScroll(false); - } - } - }; + // 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}); + }); - window.addEventListener('native.keyboardshow', function (event) { + // 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}); + }); - // TODO: Android is having problems - if (Platform.isAndroid()) { - return; - } + // Scroll to the focused element + scrollToFocusedElement(null, keyboardHeight); - $('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}); - }); +window.addEventListener('native.keyboardhide', function (event) { - // 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}); - }); + // TODO: Android is having problems + if (Platform.isAndroid()) { + return; + } - // Scroll to the focused element - scrollToFocusedElement(null, keyboardHeight); + // $('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')}); }); - window.addEventListener('native.keyboardhide', function (event) { - - // TODO: Android is having problems - if (Platform.isAndroid()) { - return; - } - - // $('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')}); - }); - + // Reset the content area(s) + $('.content.overflow-scroll').each(function (index, el) { + $(el).css({bottom: $(el).data('ionkeyboard.bottom')}); }); -} + +});