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/18 02:52:45 UTC
ios commit: Initial commit for cordova-ios/plugins/webview-preferences
Updated Branches:
refs/heads/CB-5026 [created] 975199dfa
Initial commit for cordova-ios/plugins/webview-preferences
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/975199df
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/975199df
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/975199df
Branch: refs/heads/CB-5026
Commit: 975199dfa84a855534154cf20554a8008f8444f6
Parents: 82d16e5
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu Oct 17 17:52:06 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Oct 17 17:52:06 2013 -0700
----------------------------------------------------------------------
plugins/webview-preferences/README.md | 256 +++++++++++++++
plugins/webview-preferences/plugin.xml | 33 ++
.../src/ios/CDVWebViewPreferences.h | 36 +++
.../src/ios/CDVWebViewPreferences.m | 315 +++++++++++++++++++
.../www/webview-preferences.js | 69 ++++
5 files changed, 709 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/975199df/plugins/webview-preferences/README.md
----------------------------------------------------------------------
diff --git a/plugins/webview-preferences/README.md b/plugins/webview-preferences/README.md
new file mode 100644
index 0000000..cb96364
--- /dev/null
+++ b/plugins/webview-preferences/README.md
@@ -0,0 +1,256 @@
+WebView Preferences
+======
+
+> The `WebViewPreferences` object provides some functions to customize the iOS Cordova WebView.
+
+You can also set these preferences through config.xml during startup, see the Preferences section below.
+
+Methods
+-------
+
+- WebViewPreferences.enableViewportScale
+- WebViewPreferences.mediaPlaybackRequiresUserAction
+- WebViewPreferences.mediaPlaybackAllowsAirPlay
+- WebViewPreferences.allowInlineMediaPlayback
+- WebViewPreferences.keyboardDisplayRequiresUserAction
+- WebViewPreferences.suppressesIncrementalRendering
+- WebViewPreferences.disallowOverscroll
+- WebViewPreferences.gapBetweenPages
+- WebViewPreferences.pageLength
+- WebViewPreferences.paginationBreakingMode
+- WebViewPreferences.paginationMode
+
+Permissions
+-----------
+
+#### config.xml
+
+ <feature name="WebViewPreferences">
+ <param name="ios-package" value="CDVWebViewPreferences" onload="true" />
+ </feature>
+
+
+Preferences
+-----------
+
+#### config.xml
+
+ <preference name="EnableViewportScale" value ="true" />
+ <preference name="MediaPlaybackRequiresUserAction" value ="true" />
+ <preference name="MediaPlaybackAllowsAirPlay" value ="true" />
+ <preference name="AllowInlineMediaPlayback" value ="true" />
+ <preference name="KeyboardDisplayRequiresUserAction" value ="false" />
+ <preference name="SuppressesIncrementalRendering" value ="true" />
+ <preference name="GapBetweenPages" value ="0" />
+ <preference name="PageLength" value ="0" />
+ <preference name="PaginationBreakingMode" value ="page" />
+ <preference name="PaginationMode" value ="unpaginated" />
+
+
+WebViewPreferences.enableViewportScale
+=================
+
+EnableViewportScale (boolean, defaults to false): Set to true to use a viewport meta tag to either disable or restrict the range of user scaling.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.enableViewportScale(true);
+ WebViewPreferences.enableViewportScale(false);
+
+WebViewPreferences.enableViewportScale
+=================
+
+EnableViewportScale (boolean, defaults to false): Set to true to use a viewport meta tag to either disable or restrict the range of user scaling.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.enableViewportScale(true);
+ WebViewPreferences.enableViewportScale(false);
+
+WebViewPreferences.mediaPlaybackRequiresUserAction
+=================
+
+MediaPlaybackRequiresUserAction (boolean, defaults to false): Set to true to prevent HTML5 videos from playing automatically with the autoplay attribute. Does not apply when calling play() on a video object.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.mediaPlaybackRequiresUserAction(true);
+ WebViewPreferences.mediaPlaybackRequiresUserAction(false);
+
+WebViewPreferences.mediaPlaybackAllowsAirPlay
+=================
+
+MediaPlaybackRequiresUserAction (boolean, defaults to true): A Boolean value that determines whether Air Play is allowed from this view.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.mediaPlaybackAllowsAirPlay(true);
+ WebViewPreferences.mediaPlaybackAllowsAirPlay(false);
+
+WebViewPreferences.allowInlineMediaPlayback
+=================
+
+AllowInlineMediaPlayback (boolean, defaults to false): Set to true to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls. For this to work, add the **webkit-playsinline** attribute to any <video> elements.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.allowInlineMediaPlayback(true);
+ WebViewPreferences.allowInlineMediaPlayback(false);
+
+WebViewPreferences.keyboardDisplayRequiresUserAction
+=================
+
+KeyboardDisplayRequiresUserAction (boolean, defaults to true): Set to false to allow the keyboard to appear when calling **focus()** on form inputs.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.keyboardDisplayRequiresUserAction(true);
+ WebViewPreferences.keyboardDisplayRequiresUserAction(false);
+
+WebViewPreferences.suppressesIncrementalRendering
+=================
+
+SuppressesIncrementalRendering (boolean, defaults to false): Set to true to wait until all content has been received before it renders to the screen.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.suppressesIncrementalRendering(true);
+ WebViewPreferences.suppressesIncrementalRendering(false);
+
+WebViewPreferences.disallowOverscroll
+=================
+
+DisallowOverscroll (boolean, defaults to false): set to true if you don't want the WebView to rubber-band.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.disallowOverscroll(true);
+ WebViewPreferences.disallowOverscroll(false);
+
+WebViewPreferences.gapBetweenPages
+=================
+
+GapBetweenPages (float, defaults to 0): The size of the gap, in points, between pages.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.gapBetweenPages(0);
+ WebViewPreferences.gapBetweenPages(4);
+
+WebViewPreferences.pageLength
+=================
+
+PageLength (float, defaults to 0): The size of each page, in points, in the direction that the pages flow. When PaginationMode is **rightToLeft** or **leftToRight**, this property represents the width of each page. When PaginationMode is **topToBottom** or **bottomToTop**, this property represents the height of each page. The default value is 0, which means the layout uses the size of the viewport to determine the dimensions of the page.
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.pageLength(0);
+ WebViewPreferences.pageLength(95);
+
+WebViewPreferences.paginationBreakingMode
+=================
+
+PaginationBreakingMode (string, defaults to page): The manner in which column- or page-breaking occurs. This property determines whether certain CSS properties regarding column- and page-breaking are honored or ignored. When this property is set to **column**, the content respects the CSS properties related to column-breaking in place of page-breaking.
+
+Valid values are:
+
+ * page
+ * column
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.paginationBreakingMode('page');
+ WebViewPreferences.paginationBreakingMode('column');
+
+WebViewPreferences.paginationMode
+=================
+
+PaginationMode (string, defaults to unpaginated): This property determines whether content in the web view is broken up into pages that fill the view one screen at a time, or shown as one long scrolling view. If set to a paginated form, this property toggles a paginated layout on the content, causing the web view to use the values of PageLength and GapBetweenPages to relayout its content.
+
+Valid values are:
+
+ * unpaginated
+ * leftToRight
+ * topToBottom
+ * bottomToTop
+ * rightToLeft
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Quick Example
+-------------
+
+ WebViewPreferences.paginationMode('unpaginated');
+ WebViewPreferences.paginationMode('leftToRight');
+ WebViewPreferences.paginationMode('topToBottom');
+ WebViewPreferences.paginationMode('bottomToTop');
+ WebViewPreferences.paginationMode('rightToLeft');
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/975199df/plugins/webview-preferences/plugin.xml
----------------------------------------------------------------------
diff --git a/plugins/webview-preferences/plugin.xml b/plugins/webview-preferences/plugin.xml
new file mode 100644
index 0000000..a26bfe4
--- /dev/null
+++ b/plugins/webview-preferences/plugin.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ id="org.apache.cordova.keyboard"
+ version="0.1.0">
+ <name>WebView Preferences</name>
+ <description>Cordova WebView Preferences Plugin</description>
+ <license>Apache 2.0</license>
+ <keywords>cordova,webview preferences</keywords>
+
+ <engines>
+ <engine name="cordova" version=">=3.0.0" />
+ </engines>
+
+ <js-module src="www/webview-preferences.js" name="webview-preferences">
+ <clobbers target="window.WebViewPreferences" />
+ </js-module>
+
+ <!-- ios -->
+ <platform name="ios">
+ <config-file target="config.xml" parent="/*">
+ <feature name="WebViewPreferences">
+ <param name="ios-package" value="CDVWebViewPreferences" onload="true" />
+ </feature>
+ </config-file>
+
+ <header-file src="src/ios/CDVWebViewPreferences.h" />
+ <source-file src="src/ios/CDVWebViewPreferences.m" />
+ </platform>
+
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/975199df/plugins/webview-preferences/src/ios/CDVWebViewPreferences.h
----------------------------------------------------------------------
diff --git a/plugins/webview-preferences/src/ios/CDVWebViewPreferences.h b/plugins/webview-preferences/src/ios/CDVWebViewPreferences.h
new file mode 100644
index 0000000..4a992e1
--- /dev/null
+++ b/plugins/webview-preferences/src/ios/CDVWebViewPreferences.h
@@ -0,0 +1,36 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <Cordova/CDVPlugin.h>
+
+@interface CDVWebViewPreferences : CDVPlugin {}
+
+- (void)enableViewportScale:(CDVInvokedUrlCommand*)command;
+- (void)mediaPlaybackRequiresUserAction:(CDVInvokedUrlCommand*)command;
+- (void)mediaPlaybackAllowsAirPlay:(CDVInvokedUrlCommand*)command;
+- (void)allowInlineMediaPlayback:(CDVInvokedUrlCommand*)command;
+- (void)keyboardDisplayRequiresUserAction:(CDVInvokedUrlCommand*)command;
+- (void)suppressesIncrementalRendering:(CDVInvokedUrlCommand*)command;
+- (void)disallowOverscroll:(CDVInvokedUrlCommand*)command;
+- (void)gapBetweenPages:(CDVInvokedUrlCommand*)command;
+- (void)pageLength:(CDVInvokedUrlCommand*)command;
+- (void)paginationBreakingMode:(CDVInvokedUrlCommand*)command;
+- (void)paginationMode:(CDVInvokedUrlCommand*)command;
+
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/975199df/plugins/webview-preferences/src/ios/CDVWebViewPreferences.m
----------------------------------------------------------------------
diff --git a/plugins/webview-preferences/src/ios/CDVWebViewPreferences.m b/plugins/webview-preferences/src/ios/CDVWebViewPreferences.m
new file mode 100644
index 0000000..9b50842
--- /dev/null
+++ b/plugins/webview-preferences/src/ios/CDVWebViewPreferences.m
@@ -0,0 +1,315 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CDVWebViewPreferences.h"
+#import <Cordova/CDVAvailability.h>
+
+@implementation CDVWebViewPreferences
+
+- (id)settingForKey:(NSString*)key
+{
+ return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
+}
+
+- (void)pluginInitialize
+{
+ NSString* enableViewportScale = [self settingForKey:@"EnableViewportScale"];
+ NSNumber* allowInlineMediaPlayback = [self settingForKey:@"AllowInlineMediaPlayback"];
+ BOOL mediaPlaybackRequiresUserAction = YES; // default value
+
+ if ([self settingForKey:@"MediaPlaybackRequiresUserAction"]) {
+ mediaPlaybackRequiresUserAction = [(NSNumber*)[self settingForKey:@"MediaPlaybackRequiresUserAction"] boolValue];
+ }
+
+ self.webView.scalesPageToFit = [enableViewportScale boolValue];
+
+ /*
+ * This is for iOS 4.x, where you can allow inline <video> and <audio>, and also autoplay them
+ */
+ if ([allowInlineMediaPlayback boolValue] && [self.webView respondsToSelector:@selector(allowsInlineMediaPlayback)]) {
+ self.webView.allowsInlineMediaPlayback = YES;
+ }
+ if ((mediaPlaybackRequiresUserAction == NO) && [self.webView respondsToSelector:@selector(mediaPlaybackRequiresUserAction)]) {
+ self.webView.mediaPlaybackRequiresUserAction = NO;
+ }
+
+ // By default, overscroll bouncing is allowed.
+ // UIWebViewBounce has been renamed to DisallowOverscroll, but both are checked.
+ BOOL bounceAllowed = YES;
+ NSNumber* disallowOverscroll = [self settingForKey:@"DisallowOverscroll"];
+ if (disallowOverscroll == nil) {
+ NSNumber* bouncePreference = [self settingForKey:@"UIWebViewBounce"];
+ bounceAllowed = (bouncePreference == nil || [bouncePreference boolValue]);
+ } else {
+ bounceAllowed = ![disallowOverscroll boolValue];
+ }
+
+ // prevent webView from bouncing
+ // based on the DisallowOverscroll/UIWebViewBounce key in config.xml
+ if (!bounceAllowed) {
+ if ([self.webView respondsToSelector:@selector(scrollView)]) {
+ ((UIScrollView*)[self.webView scrollView]).bounces = NO;
+ } else {
+ for (id subview in self.webView.subviews) {
+ if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
+ ((UIScrollView*)subview).bounces = NO;
+ }
+ }
+ }
+ }
+
+ /*
+ * iOS 6.0 UIWebView properties
+ */
+ if (IsAtLeastiOSVersion(@"6.0")) {
+ BOOL keyboardDisplayRequiresUserAction = YES; // KeyboardDisplayRequiresUserAction - defaults to YES
+ if ([self settingForKey:@"KeyboardDisplayRequiresUserAction"] != nil) {
+ if ([self settingForKey:@"KeyboardDisplayRequiresUserAction"]) {
+ keyboardDisplayRequiresUserAction = [(NSNumber*)[self settingForKey:@"KeyboardDisplayRequiresUserAction"] boolValue];
+ }
+ }
+
+ // property check for compiling under iOS < 6
+ if ([self.webView respondsToSelector:@selector(setKeyboardDisplayRequiresUserAction:)]) {
+ [self.webView setValue:[NSNumber numberWithBool:keyboardDisplayRequiresUserAction] forKey:@"keyboardDisplayRequiresUserAction"];
+ }
+
+ BOOL suppressesIncrementalRendering = NO; // SuppressesIncrementalRendering - defaults to NO
+ if ([self settingForKey:@"SuppressesIncrementalRendering"] != nil) {
+ if ([self settingForKey:@"SuppressesIncrementalRendering"]) {
+ suppressesIncrementalRendering = [(NSNumber*)[self settingForKey:@"SuppressesIncrementalRendering"] boolValue];
+ }
+ }
+
+ // property check for compiling under iOS < 6
+ if ([self.webView respondsToSelector:@selector(setSuppressesIncrementalRendering:)]) {
+ [self.webView setValue:[NSNumber numberWithBool:suppressesIncrementalRendering] forKey:@"suppressesIncrementalRendering"];
+ }
+ }
+
+ /*
+ * iOS 7.0 UIWebView properties
+ */
+ if (IsAtLeastiOSVersion(@"7.0")) {
+ SEL ios7sel = nil;
+ id prefObj = nil;
+
+ CGFloat gapBetweenPages = 0.0; // default
+ prefObj = [self settingForKey:@"GapBetweenPages"];
+ if (prefObj != nil) {
+ gapBetweenPages = [prefObj floatValue];
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setGapBetweenPages:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithFloat:gapBetweenPages] forKey:@"gapBetweenPages"];
+ }
+
+ CGFloat pageLength = 0.0; // default
+ prefObj = [self settingForKey:@"PageLength"];
+ if (prefObj != nil) {
+ pageLength = [[self settingForKey:@"PageLength"] floatValue];
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setPageLength:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithFloat:pageLength] forKey:@"pageLength"];
+ }
+
+ NSInteger paginationBreakingMode = 0; // default - UIWebPaginationBreakingModePage
+ prefObj = [self settingForKey:@"PaginationBreakingMode"];
+ if (prefObj != nil) {
+ NSArray* validValues = @[@"page", @"column"];
+ NSString* prefValue = [validValues objectAtIndex:0];
+
+ if ([prefObj isKindOfClass:[NSString class]]) {
+ prefValue = prefObj;
+ }
+
+ paginationBreakingMode = [validValues indexOfObject:[prefValue lowercaseString]];
+ if (paginationBreakingMode == NSNotFound) {
+ paginationBreakingMode = 0;
+ }
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setPaginationBreakingMode:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithInteger:paginationBreakingMode] forKey:@"paginationBreakingMode"];
+ }
+
+ NSInteger paginationMode = 0; // default - UIWebPaginationModeUnpaginated
+ prefObj = [self settingForKey:@"PaginationMode"];
+ if (prefObj != nil) {
+ NSArray* validValues = @[@"unpaginated", @"lefttoright", @"toptobottom", @"bottomtotop", @"righttoleft"];
+ NSString* prefValue = [validValues objectAtIndex:0];
+
+ if ([prefObj isKindOfClass:[NSString class]]) {
+ prefValue = prefObj;
+ }
+
+ paginationMode = [validValues indexOfObject:[prefValue lowercaseString]];
+ if (paginationMode == NSNotFound) {
+ paginationMode = 0;
+ }
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setPaginationMode:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithInteger:paginationMode] forKey:@"paginationMode"];
+ }
+ }
+}
+
+// //////////////////////////////////////////////////
+
+- (void)enableViewportScale:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:NO];
+ }
+
+ self.webView.scalesPageToFit = [value boolValue];
+}
+
+- (void)mediaPlaybackRequiresUserAction:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:NO];
+ }
+
+ self.webView.mediaPlaybackRequiresUserAction = [value boolValue];
+}
+
+- (void)mediaPlaybackAllowsAirPlay:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:YES];
+ }
+
+ self.webView.mediaPlaybackAllowsAirPlay = [value boolValue];
+}
+
+- (void)allowInlineMediaPlayback:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:NO];
+ }
+
+ self.webView.allowsInlineMediaPlayback = [value boolValue];
+}
+
+- (void)keyboardDisplayRequiresUserAction:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:YES];
+ }
+
+ // TODO: iOS 6 check
+ self.webView.keyboardDisplayRequiresUserAction = [value boolValue];
+}
+
+- (void)suppressesIncrementalRendering:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:NO];
+ }
+
+ // TODO: iOS 6 check
+ self.webView.suppressesIncrementalRendering = [value boolValue];
+}
+
+- (void)disallowOverscroll:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:NO];
+ }
+
+ if ([self.webView respondsToSelector:@selector(scrollView)]) {
+ ((UIScrollView*)[self.webView scrollView]).bounces = [value boolValue];
+ } else {
+ for (id subview in self.webView.subviews) {
+ if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
+ ((UIScrollView*)subview).bounces = [value boolValue];
+ }
+ }
+ }
+}
+
+- (void)gapBetweenPages:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithFloat:0.0];
+ }
+
+ // TODO: implementation, and iOS 7 check
+}
+
+- (void)pageLength:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithFloat:0.0];
+ }
+
+ // TODO: implementation, and iOS 7 check
+}
+
+- (void)paginationBreakingMode:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+
+ if (!([value isKindOfClass:[NSString class]])) {
+ value = @"page";
+ }
+
+ // TODO: implementation, and iOS 7 check
+}
+
+- (void)paginationMode:(CDVInvokedUrlCommand*)command;
+{
+ id value = [command.arguments objectAtIndex:0];
+ if (!([value isKindOfClass:[NSString class]])) {
+ value = @"unpaginated";
+ }
+
+ // TODO: implementation, and iOS 7 check
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/975199df/plugins/webview-preferences/www/webview-preferences.js
----------------------------------------------------------------------
diff --git a/plugins/webview-preferences/www/webview-preferences.js b/plugins/webview-preferences/www/webview-preferences.js
new file mode 100644
index 0000000..d3df67b
--- /dev/null
+++ b/plugins/webview-preferences/www/webview-preferences.js
@@ -0,0 +1,69 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var argscheck = require('cordova/argscheck'),
+ utils = require('cordova/utils'),
+ exec = require('cordova/exec');
+
+var WebViewPreferences = function() {
+};
+
+WebViewPreferences.enableViewportScale = function(b) {
+ exec(null, null, "WebViewPreferences", "enableViewportScale", [b]);
+};
+
+WebViewPreferences.mediaPlaybackRequiresUserAction = function(b) {
+ exec(null, null, "WebViewPreferences", "mediaPlaybackRequiresUserAction", [b]);
+};
+
+WebViewPreferences.allowInlineMediaPlayback = function(b) {
+ exec(null, null, "WebViewPreferences", "allowInlineMediaPlayback", [b]);
+};
+
+WebViewPreferences.keyboardDisplayRequiresUserAction = function(b) {
+ exec(null, null, "WebViewPreferences", "keyboardDisplayRequiresUserAction", [b]);
+};
+
+WebViewPreferences.suppressesIncrementalRendering = function(b) {
+ exec(null, null, "WebViewPreferences", "suppressesIncrementalRendering", [b]);
+};
+
+WebViewPreferences.disallowOverscroll = function(b) {
+ exec(null, null, "WebViewPreferences", "disallowOverscroll", [b]);
+};
+
+WebViewPreferences.gapBetweenPages = function(f) {
+ exec(null, null, "WebViewPreferences", "gapBetweenPages", [f]);
+};
+
+WebViewPreferences.pageLength = function(f) {
+ exec(null, null, "WebViewPreferences", "pageLength", [f]);
+};
+
+WebViewPreferences.paginationBreakingMode = function(s) {
+ exec(null, null, "WebViewPreferences", "paginationBreakingMode", [s]);
+};
+
+WebViewPreferences.paginationMode = function(s) {
+ exec(null, null, "WebViewPreferences", "paginationMode", [s]);
+};
+
+module.exports = WebViewPreferences;