You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/10/03 00:07:34 UTC

git commit: CB-4935 iOS Keyboard preferences code into its own plugin

Updated Branches:
  refs/heads/plugins 7e828d996 -> c88ad0cdd


CB-4935 iOS Keyboard preferences code into its own plugin


Project: http://git-wip-us.apache.org/repos/asf/cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-labs/commit/c88ad0cd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-labs/tree/c88ad0cd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-labs/diff/c88ad0cd

Branch: refs/heads/plugins
Commit: c88ad0cdda013d948faa979912e0650e03924dab
Parents: 7e828d9
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Oct 2 15:07:44 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Oct 2 15:07:44 2013 -0700

----------------------------------------------------------------------
 keyboard/plugin.xml            |  6 +++++-
 keyboard/src/ios/CDVKeyboard.h |  6 ++++++
 keyboard/src/ios/CDVKeyboard.m | 39 +++++++++++++++++++++++++++++++++++--
 keyboard/www/keyboard.js       | 10 +++++-----
 4 files changed, 53 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/c88ad0cd/keyboard/plugin.xml
----------------------------------------------------------------------
diff --git a/keyboard/plugin.xml b/keyboard/plugin.xml
index b2ce765..ed0138d 100644
--- a/keyboard/plugin.xml
+++ b/keyboard/plugin.xml
@@ -10,6 +10,10 @@
     <license>Apache 2.0</license>
     <keywords>cordova,keyboard</keywords>
 
+	<engines>
+		<engine name="cordova" version=">=3.2.0" />
+	</engines>
+
     <js-module src="www/keyboard.js" name="keyboard">
     	<clobbers target="window.Keyboard" />
     </js-module>
@@ -18,7 +22,7 @@
     <platform name="ios">
         <config-file target="config.xml" parent="/*">
             <feature name="Keyboard">
-                <param name="ios-package" value="CDVKeyboard"/>
+                <param name="ios-package" value="CDVKeyboard" onload="true" />
             </feature>
         </config-file>
 

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/c88ad0cd/keyboard/src/ios/CDVKeyboard.h
----------------------------------------------------------------------
diff --git a/keyboard/src/ios/CDVKeyboard.h b/keyboard/src/ios/CDVKeyboard.h
index eeea0bb..816fc92 100644
--- a/keyboard/src/ios/CDVKeyboard.h
+++ b/keyboard/src/ios/CDVKeyboard.h
@@ -37,4 +37,10 @@
 @property (readonly, assign)  BOOL hideFormAccessoryBar;
 @property (readonly, assign)  BOOL keyboardIsVisible;
 
+
+- (void) shrinkView:(CDVInvokedUrlCommand*)command;
+- (void) disableScrollingInShrinkView:(CDVInvokedUrlCommand*)command;
+- (void) hideFormAccessoryBar:(CDVInvokedUrlCommand*)command;
+
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/c88ad0cd/keyboard/src/ios/CDVKeyboard.m
----------------------------------------------------------------------
diff --git a/keyboard/src/ios/CDVKeyboard.m b/keyboard/src/ios/CDVKeyboard.m
index 2906e4e..773952c 100644
--- a/keyboard/src/ios/CDVKeyboard.m
+++ b/keyboard/src/ios/CDVKeyboard.m
@@ -65,14 +65,14 @@
                                             object:nil
                                              queue:[NSOperationQueue mainQueue]
                                         usingBlock:^(NSNotification* notification) {
-            // TODO: set Keyboard.isVisible in JavaScript
+            [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = true;"];
             weakSelf.keyboardIsVisible = YES;
         }];
     _keyboardHideObserver = [nc addObserverForName:UIKeyboardDidHideNotification
                                             object:nil
                                              queue:[NSOperationQueue mainQueue]
                                         usingBlock:^(NSNotification* notification) {
-            // TODO: set Keyboard.isVisible in JavaScript
+            [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = false;"];
             weakSelf.keyboardIsVisible = NO;
         }];
 }
@@ -286,4 +286,39 @@ CGFloat gAccessoryBarHeight = 0.0;
     [nc removeObserver:self name:UIKeyboardWillHideNotification object:nil];
 }
 
+// //////////////////////////////////////////////////
+
+#pragma Plugin interface
+
+- (void) shrinkView:(CDVInvokedUrlCommand*)command
+{
+    id value = [command.arguments objectAtIndex:0];
+    if (!([value isKindOfClass:[NSNumber class]])) {
+        value = [NSNumber numberWithBool:NO];
+    }
+    
+    self.shrinkView = [value boolValue];
+}
+
+- (void) disableScrollingInShrinkView:(CDVInvokedUrlCommand*)command
+{
+    id value = [command.arguments objectAtIndex:0];
+    if (!([value isKindOfClass:[NSNumber class]])) {
+        value = [NSNumber numberWithBool:NO];
+    }
+    
+    self.disableScrollingInShrinkView = [value boolValue];
+}
+
+- (void) hideFormAccessoryBar:(CDVInvokedUrlCommand*)command
+{
+    id value = [command.arguments objectAtIndex:0];
+    if (!([value isKindOfClass:[NSNumber class]])) {
+        value = [NSNumber numberWithBool:NO];
+    }
+    
+    self.hideFormAccessoryBar = [value boolValue];
+}
+
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/c88ad0cd/keyboard/www/keyboard.js
----------------------------------------------------------------------
diff --git a/keyboard/www/keyboard.js b/keyboard/www/keyboard.js
index 940752d..c810dce 100644
--- a/keyboard/www/keyboard.js
+++ b/keyboard/www/keyboard.js
@@ -26,18 +26,18 @@ var argscheck = require('cordova/argscheck'),
 var Keyboard = function() {
 };
 
-Keyboard.prototype.keyboardShrinksView = function(shrink) {
-    exec(null, null, "Keyboard", "keyboardShrinksView", [shrink]);
+Keyboard.shrinkView = function(shrink) {
+    exec(null, null, "Keyboard", "shrinkView", [shrink]);
 };
 
-Keyboard.prototype.hideFormAccessoryBar = function(hide) {
+Keyboard.hideFormAccessoryBar = function(hide) {
     exec(null, null, "Keyboard", "hideFormAccessoryBar", [hide]);
 };
 
-Keyboard.prototype.disableScrollingInShrinkView = function(disable) {
+Keyboard.disableScrollingInShrinkView = function(disable) {
     exec(null, null, "Keyboard", "disableScrollingInShrinkView", [disable]);
 };
 
 Keyboard.isVisible = false;
 
-module.exports = Keyboard;
\ No newline at end of file
+module.exports = Keyboard;