Moved CDVWebViewUIDelegate into Classes folder
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/28b44750 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/28b44750 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/28b44750 Branch: refs/heads/4.0.x Commit: 28b4475070cd61587c8e7ac8e7f0102d8101367f Parents: aa5d0e9 Author: Shazron Abdullah <shaz...@apache.org> Authored: Thu Jul 17 16:48:13 2014 -0700 Committer: Shazron Abdullah <shaz...@apache.org> Committed: Thu Jul 17 16:48:13 2014 -0700 ---------------------------------------------------------------------- CordovaLib/CDVWebViewUIDelegate.h | 35 ------ CordovaLib/CDVWebViewUIDelegate.m | 126 ------------------- CordovaLib/Classes/CDVWebViewUIDelegate.h | 35 ++++++ CordovaLib/Classes/CDVWebViewUIDelegate.m | 126 +++++++++++++++++++ CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 4 +- 5 files changed, 163 insertions(+), 163 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/28b44750/CordovaLib/CDVWebViewUIDelegate.h ---------------------------------------------------------------------- diff --git a/CordovaLib/CDVWebViewUIDelegate.h b/CordovaLib/CDVWebViewUIDelegate.h deleted file mode 100644 index 9ff2ac1..0000000 --- a/CordovaLib/CDVWebViewUIDelegate.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - 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 <Foundation/Foundation.h> - -#ifdef __IPHONE_8_0 - #import <WebKit/WebKit.h> -#endif - -@interface CDVWebViewUIDelegate : NSObject -#ifdef __IPHONE_8_0 - <WKUIDelegate> -#endif - -@property (nonatomic, copy) NSString* title; - -- (instancetype)initWithTitle:(NSString*)title; - -@end http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/28b44750/CordovaLib/CDVWebViewUIDelegate.m ---------------------------------------------------------------------- diff --git a/CordovaLib/CDVWebViewUIDelegate.m b/CordovaLib/CDVWebViewUIDelegate.m deleted file mode 100644 index 6f98327..0000000 --- a/CordovaLib/CDVWebViewUIDelegate.m +++ /dev/null @@ -1,126 +0,0 @@ -/* - 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. - */ - -#ifdef __IPHONE_8_0 - -#import "CDVWebViewUIDelegate.h" - - @implementation CDVWebViewUIDelegate - - - (instancetype)initWithTitle:(NSString*)title - { - self = [super init]; - if (self) { - self.title = title; - } - - return self; - } - - - (void) webView:(WKWebView*)webView runJavaScriptAlertPanelWithMessage:(NSString*)message - initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)())completionHandler - { - UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title - message:message - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction* action) - { - completionHandler(); - [alert dismissViewControllerAnimated:YES completion:nil]; - }]; - - [alert addAction:ok]; - - UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController; - - [rootController presentViewController:alert animated:YES completion:nil]; - } - - - (void) webView:(WKWebView*)webView runJavaScriptConfirmPanelWithMessage:(NSString*)message - initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)(BOOL result))completionHandler - { - UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title - message:message - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction* action) - { - completionHandler(YES); - [alert dismissViewControllerAnimated:YES completion:nil]; - }]; - - [alert addAction:ok]; - - UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction* action) - { - completionHandler(NO); - [alert dismissViewControllerAnimated:YES completion:nil]; - }]; - [alert addAction:cancel]; - - UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController; - - [rootController presentViewController:alert animated:YES completion:nil]; - } - - - (void) webView:(WKWebView*)webView runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt - defaultText:(NSString*)defaultText initiatedByFrame:(WKFrameInfo*)frame - completionHandler:(void (^)(NSString* result))completionHandler - { - UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title - message:prompt - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction* action) - { - completionHandler(((UITextField*)alert.textFields[0]).text); - [alert dismissViewControllerAnimated:YES completion:nil]; - }]; - - [alert addAction:ok]; - - UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction* action) - { - completionHandler(nil); - [alert dismissViewControllerAnimated:YES completion:nil]; - }]; - [alert addAction:cancel]; - - [alert addTextFieldWithConfigurationHandler:^(UITextField* textField) { - textField.text = defaultText; - }]; - - UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController; - - [rootController presentViewController:alert animated:YES completion:nil]; - } - - @end -#endif /* ifdef __IPHONE_8_0 */ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/28b44750/CordovaLib/Classes/CDVWebViewUIDelegate.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVWebViewUIDelegate.h b/CordovaLib/Classes/CDVWebViewUIDelegate.h new file mode 100644 index 0000000..9ff2ac1 --- /dev/null +++ b/CordovaLib/Classes/CDVWebViewUIDelegate.h @@ -0,0 +1,35 @@ +/* + 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 <Foundation/Foundation.h> + +#ifdef __IPHONE_8_0 + #import <WebKit/WebKit.h> +#endif + +@interface CDVWebViewUIDelegate : NSObject +#ifdef __IPHONE_8_0 + <WKUIDelegate> +#endif + +@property (nonatomic, copy) NSString* title; + +- (instancetype)initWithTitle:(NSString*)title; + +@end http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/28b44750/CordovaLib/Classes/CDVWebViewUIDelegate.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVWebViewUIDelegate.m b/CordovaLib/Classes/CDVWebViewUIDelegate.m new file mode 100644 index 0000000..6f98327 --- /dev/null +++ b/CordovaLib/Classes/CDVWebViewUIDelegate.m @@ -0,0 +1,126 @@ +/* + 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. + */ + +#ifdef __IPHONE_8_0 + +#import "CDVWebViewUIDelegate.h" + + @implementation CDVWebViewUIDelegate + + - (instancetype)initWithTitle:(NSString*)title + { + self = [super init]; + if (self) { + self.title = title; + } + + return self; + } + + - (void) webView:(WKWebView*)webView runJavaScriptAlertPanelWithMessage:(NSString*)message + initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)())completionHandler + { + UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title + message:message + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction* action) + { + completionHandler(); + [alert dismissViewControllerAnimated:YES completion:nil]; + }]; + + [alert addAction:ok]; + + UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController; + + [rootController presentViewController:alert animated:YES completion:nil]; + } + + - (void) webView:(WKWebView*)webView runJavaScriptConfirmPanelWithMessage:(NSString*)message + initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)(BOOL result))completionHandler + { + UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title + message:message + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction* action) + { + completionHandler(YES); + [alert dismissViewControllerAnimated:YES completion:nil]; + }]; + + [alert addAction:ok]; + + UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction* action) + { + completionHandler(NO); + [alert dismissViewControllerAnimated:YES completion:nil]; + }]; + [alert addAction:cancel]; + + UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController; + + [rootController presentViewController:alert animated:YES completion:nil]; + } + + - (void) webView:(WKWebView*)webView runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt + defaultText:(NSString*)defaultText initiatedByFrame:(WKFrameInfo*)frame + completionHandler:(void (^)(NSString* result))completionHandler + { + UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title + message:prompt + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction* action) + { + completionHandler(((UITextField*)alert.textFields[0]).text); + [alert dismissViewControllerAnimated:YES completion:nil]; + }]; + + [alert addAction:ok]; + + UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction* action) + { + completionHandler(nil); + [alert dismissViewControllerAnimated:YES completion:nil]; + }]; + [alert addAction:cancel]; + + [alert addTextFieldWithConfigurationHandler:^(UITextField* textField) { + textField.text = defaultText; + }]; + + UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController; + + [rootController presentViewController:alert animated:YES completion:nil]; + } + + @end +#endif /* ifdef __IPHONE_8_0 */ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/28b44750/CordovaLib/CordovaLib.xcodeproj/project.pbxproj ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj index a2d5cc4..844db7b 100644 --- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj +++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj @@ -101,8 +101,8 @@ 68A32D7414103017006B237C /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; }; 7E14B5A61705050A0032169E /* CDVTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVTimer.h; path = Classes/CDVTimer.h; sourceTree = "<group>"; }; 7E14B5A71705050A0032169E /* CDVTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVTimer.m; path = Classes/CDVTimer.m; sourceTree = "<group>"; }; - 7E785B98196F508900ABBDC8 /* CDVWebViewUIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVWebViewUIDelegate.h; sourceTree = "<group>"; }; - 7E785B99196F508900ABBDC8 /* CDVWebViewUIDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVWebViewUIDelegate.m; sourceTree = "<group>"; }; + 7E785B98196F508900ABBDC8 /* CDVWebViewUIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWebViewUIDelegate.h; path = Classes/CDVWebViewUIDelegate.h; sourceTree = "<group>"; }; + 7E785B99196F508900ABBDC8 /* CDVWebViewUIDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWebViewUIDelegate.m; path = Classes/CDVWebViewUIDelegate.m; sourceTree = "<group>"; }; 7EE9ECF619525D24004CA6B9 /* CDVWebViewPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWebViewPreferences.h; path = Classes/CDVWebViewPreferences.h; sourceTree = "<group>"; }; 7EE9ECF719525D24004CA6B9 /* CDVWebViewPreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWebViewPreferences.m; path = Classes/CDVWebViewPreferences.m; sourceTree = "<group>"; }; 8220B5C316D5427E00EC3921 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org