diff --git a/README.md b/README.md index 8b8c764..79f1d34 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ From github latest (may not be stable) Shrink the WebView when the keyboard comes up. - Keyboard.shrinkView(true); + Keyboard.shrinkView(value, successCallback); #### Description @@ -57,12 +57,13 @@ Set to true to shrink the WebView when the keyboard comes up. The WebView shrink Keyboard.shrinkView(true); Keyboard.shrinkView(false); + Keyboard.shrinkView(null, function (currentValue) { console.log(currentValue); }); ## Keyboard.hideFormAccessoryBar Hide the keyboard toolbar. - Keyboard.hideFormAccessoryBar(true); + Keyboard.hideFormAccessoryBar(value, successCallback); #### Description @@ -77,13 +78,13 @@ Set to true to hide the additional toolbar that is on top of the keyboard. This Keyboard.hideFormAccessoryBar(true); Keyboard.hideFormAccessoryBar(false); - + Keyboard.hideFormAccessoryBar(null, function (currentValue) { console.log(currentValue); }); ## Keyboard.disableScrollingInShrinkView Disable scrolling when the the WebView is shrunk. - Keyboard.disableScrollingInShrinkView(true); + Keyboard.disableScrollingInShrinkView(value, successCallback); #### Description @@ -98,6 +99,7 @@ Set to true to disable scrolling when the WebView is shrunk. Keyboard.disableScrollingInShrinkView(true); Keyboard.disableScrollingInShrinkView(false); + Keyboard.disableScrollingInShrinkView(null, function (currentValue) { console.log(currentValue); }); ## Keyboard.hide diff --git a/src/ios/CDVKeyboard.m b/src/ios/CDVKeyboard.m index 3041f57..29a9883 100644 --- a/src/ios/CDVKeyboard.m +++ b/src/ios/CDVKeyboard.m @@ -221,32 +221,47 @@ - (void)scrollViewDidScroll:(UIScrollView*)scrollView - (void)shrinkView:(CDVInvokedUrlCommand*)command { - id value = [command.arguments objectAtIndex:0]; - if (!([value isKindOfClass:[NSNumber class]])) { - value = [NSNumber numberWithBool:NO]; - } + if (command.arguments.count > 0) { + id value = [command.arguments objectAtIndex:0]; + if (!([value isKindOfClass:[NSNumber class]])) { + value = [NSNumber numberWithBool:NO]; + } - self.shrinkView = [value boolValue]; + self.shrinkView = [value boolValue]; + } + + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.shrinkView] + callbackId:command.callbackId]; } - (void)disableScrollingInShrinkView:(CDVInvokedUrlCommand*)command { - id value = [command.arguments objectAtIndex:0]; - if (!([value isKindOfClass:[NSNumber class]])) { - value = [NSNumber numberWithBool:NO]; - } + if (command.arguments.count > 0) { + id value = [command.arguments objectAtIndex:0]; + if (!([value isKindOfClass:[NSNumber class]])) { + value = [NSNumber numberWithBool:NO]; + } - self.disableScrollingInShrinkView = [value boolValue]; + self.disableScrollingInShrinkView = [value boolValue]; + } + + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.disableScrollingInShrinkView] + callbackId:command.callbackId]; } - (void)hideFormAccessoryBar:(CDVInvokedUrlCommand*)command { - id value = [command.arguments objectAtIndex:0]; - if (!([value isKindOfClass:[NSNumber class]])) { - value = [NSNumber numberWithBool:NO]; + if (command.arguments.count > 0) { + id value = [command.arguments objectAtIndex:0]; + if (!([value isKindOfClass:[NSNumber class]])) { + value = [NSNumber numberWithBool:NO]; + } + + self.hideFormAccessoryBar = [value boolValue]; } - - self.hideFormAccessoryBar = [value boolValue]; + + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.hideFormAccessoryBar] + callbackId:command.callbackId]; } - (void)hide:(CDVInvokedUrlCommand*)command diff --git a/www/keyboard.js b/www/keyboard.js index 2f3c9f2..e93ef69 100644 --- a/www/keyboard.js +++ b/www/keyboard.js @@ -26,16 +26,28 @@ var argscheck = require('cordova/argscheck'), var Keyboard = function() { }; -Keyboard.shrinkView = function(shrink) { - exec(null, null, "Keyboard", "shrinkView", [shrink]); +Keyboard.shrinkView = function(shrink, success) { + if (shrink !== null && shrink !== undefined) { + exec(success, null, "Keyboard", "shrinkView", [shrink]); + } else { + exec(success, null, "Keyboard", "shrinkView", []); + } }; -Keyboard.hideFormAccessoryBar = function(hide) { - exec(null, null, "Keyboard", "hideFormAccessoryBar", [hide]); +Keyboard.hideFormAccessoryBar = function(hide, success) { + if (hide !== null && hide !== undefined){ + exec(success, null, "Keyboard", "hideFormAccessoryBar", [hide]); + } else { + exec(success, null, "Keyboard", "hideFormAccessoryBar", []); + } }; -Keyboard.disableScrollingInShrinkView = function(disable) { - exec(null, null, "Keyboard", "disableScrollingInShrinkView", [disable]); +Keyboard.disableScrollingInShrinkView = function(disable, success) { + if (disable !== null && disable !== undefined) { + exec(success, null, "Keyboard", "disableScrollingInShrinkView", [disable]); + } else { + exec(success, null, "Keyboard", "disableScrollingInShrinkView", []); + } }; Keyboard.fireOnShow = function() {