├── LICENSE ├── README.md ├── ios7_toolbar_removed.png ├── ios7_with_toolbar.png ├── plugin.xml ├── src └── ios │ ├── KeyboardToolbarRemover.h │ └── KeyboardToolbarRemover.m ├── toolbar_removed.png ├── with_toolbar.png └── www └── keyboard_toolbar_remover.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2012-2013 Chariot Solutions 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **NOTE:** I recommend using the Cordova [Keyboard Plugin](https://github.com/apache/cordova-plugins/tree/master/keyboard) instead of this one. The Cordova Keyboard Plugin has better support for resizing and works with Cordova 3.2+. 2 | 3 | # Keyboard Toolbar Remover Cordova Plugin 4 | 5 | The keyboard in an iOS web view has an InputAccessoryView with Previous, Next and Done buttons. This plugin allows the toolbar to be hidden. 6 | 7 | ![with_toolbar](https://github.com/don/KeyboardToolbarRemover/raw/master/ios7_with_toolbar.png)   ![toolbar_removed](https://github.com/don/KeyboardToolbarRemover/raw/master/ios7_toolbar_removed.png) 8 | 9 | ![with_toolbar](https://github.com/don/KeyboardToolbarRemover/raw/master/with_toolbar.png)   ![toolbar_removed](https://github.com/don/KeyboardToolbarRemover/raw/master/toolbar_removed.png) 10 | 11 | # Installation 12 | 13 | Assuming you're running Cordova 2.9+ and using the command line interface 14 | 15 | $ cd /path/to/project 16 | $ cordova plugin add https://github.com/don/KeyboardToolbarRemover 17 | 18 | # Usage 19 | 20 | The plugin creates a global variable called `toolbar` when it is installed. 21 | 22 | To disable the toolbar 23 | 24 | toolbar.hide() 25 | 26 | To re-enable the toolbar 27 | 28 | toolbar.show() 29 | 30 | ## Troubleshooting 31 | 32 | If you see a bar above the keyboard with iOS7, try adding `height=device-height` to the viewport meta tag. See [Issue 9](https://github.com/don/KeyboardToolbarRemover/issues/9) for more details. 33 | 34 | # Credits 35 | 36 | The original code to hide the toolbar is based on the [Josh Garnham](http://twitter.com/jgarnham)'s code in a [blog post](http://ios-blog.co.uk/tutorials/rich-text-editing-a-simple-start-part-1/). (Scroll down to the Bonus Code section.) 37 | 38 | [Steve Smith](https://github.com/stevenpsmith)'s iOS 7 fix was influenced by [a stack overflow post](http://stackoverflow.com/questions/18837551/remove-keyboard-form-toolbar-on-ios7-leaves-a-blur-behind/19042392#19042392). 39 | 40 | [Michael Scholz](https://github.com/MichaelRando) and [Shinichi Hosokawa](https://github.com/shosokawa) provided patches for Cordova 3.0 compatibility. 41 | 42 | # License 43 | 44 | The MIT License 45 | 46 | Copyright (c) 2012-3 Chariot Solutions 47 | 48 | Permission is hereby granted, free of charge, to any person obtaining a copy 49 | of this software and associated documentation files (the "Software"), to deal 50 | in the Software without restriction, including without limitation the rights 51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 52 | copies of the Software, and to permit persons to whom the Software is 53 | furnished to do so, subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in 56 | all copies or substantial portions of the Software. 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 64 | THE SOFTWARE. 65 | 66 | -------------------------------------------------------------------------------- /ios7_toolbar_removed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/KeyboardToolbarRemover/628074c7c8f1dd24fcc6ce0dbd39773c2e1fdc84/ios7_toolbar_removed.png -------------------------------------------------------------------------------- /ios7_with_toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/don/KeyboardToolbarRemover/628074c7c8f1dd24fcc6ce0dbd39773c2e1fdc84/ios7_with_toolbar.png -------------------------------------------------------------------------------- /plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Keyboard Toolbar Remover 8 | 9 | Allows the Previous, Next and Done buttons in an iOS web view to be hidden 10 | 11 | MIT 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/ios/KeyboardToolbarRemover.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface KeyboardToolbarRemover : CDVPlugin 4 | - (void) hide:(CDVInvokedUrlCommand*)command; 5 | - (void) show:(CDVInvokedUrlCommand*)command; 6 | @end -------------------------------------------------------------------------------- /src/ios/KeyboardToolbarRemover.m: -------------------------------------------------------------------------------- 1 | #import "KeyboardToolbarRemover.h" 2 | #import 3 | 4 | @implementation KeyboardToolbarRemover 5 | 6 | - (void) hide:(CDVInvokedUrlCommand*)command 7 | { 8 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 9 | 10 | CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 11 | 12 | [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; 13 | } 14 | 15 | - (void) show:(CDVInvokedUrlCommand*)command 16 | { 17 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 18 | 19 | CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 20 | 21 | [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; 22 | 23 | } 24 | 25 | // http://ios-blog.co.uk/tutorials/rich-text-editing-a-simple-start-part-1 26 | - (void)keyboardWillShow:(NSNotification *)note { 27 | [self performSelector:@selector(removeBar) withObject:nil afterDelay:0]; 28 | } 29 | 30 | - (void)removeBar { 31 | // Locate non-UIWindow. 32 | UIWindow *keyboardWindow = nil; 33 | for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { 34 | if (![[testWindow class] isEqual:[UIWindow class]]) { 35 | keyboardWindow = testWindow; 36 | break; 37 | } 38 | } 39 | 40 | // Locate UIWebFormView 41 | for (UIView *possibleFormView in [keyboardWindow subviews]) { 42 | if ([[possibleFormView description] hasPrefix:@"= 5.0) { 57 | webScroll = [[self webView] scrollView]; 58 | } else { 59 | webScroll = [[[self webView] subviews] lastObject]; 60 | } 61 | CGRect newFrame = webScroll.frame; 62 | newFrame.size.height += peripheralView.frame.size.height; 63 | webScroll.frame = newFrame; 64 | 65 | // remove the form accessory bar 66 | [peripheralView removeFromSuperview]; 67 | } 68 | // hides the thin grey line used to adorn the bar (iOS 6) 69 | if ([[peripheralView description] hasPrefix:@"