|
@@ -810,16 +810,16 @@ static NSDictionary* customCertificatesForHost;
|
810
|
810
|
#pragma mark - WKNavigationDelegate methods
|
811
|
811
|
|
812
|
812
|
/**
|
813
|
|
-* alert
|
814
|
|
-*/
|
|
813
|
+ * alert
|
|
814
|
+ */
|
815
|
815
|
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
|
816
|
816
|
{
|
817
|
817
|
#if !TARGET_OS_OSX
|
818
|
|
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
|
819
|
|
- [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
820
|
|
- completionHandler();
|
821
|
|
- }]];
|
822
|
|
- [[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
|
818
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
819
|
+ [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
820
|
+ completionHandler();
|
|
821
|
+ }]];
|
|
822
|
+ [[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
823
|
823
|
#else
|
824
|
824
|
NSAlert *alert = [[NSAlert alloc] init];
|
825
|
825
|
[alert setMessageText:message];
|
|
@@ -830,18 +830,18 @@ static NSDictionary* customCertificatesForHost;
|
830
|
830
|
}
|
831
|
831
|
|
832
|
832
|
/**
|
833
|
|
-* confirm
|
834
|
|
-*/
|
|
833
|
+ * confirm
|
|
834
|
+ */
|
835
|
835
|
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler{
|
836
|
836
|
#if !TARGET_OS_OSX
|
837
|
|
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
|
838
|
|
- [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
839
|
|
- completionHandler(YES);
|
840
|
|
- }]];
|
841
|
|
- [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
842
|
|
- completionHandler(NO);
|
843
|
|
- }]];
|
844
|
|
- [[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
|
837
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
838
|
+ [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
839
|
+ completionHandler(YES);
|
|
840
|
+ }]];
|
|
841
|
+ [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
842
|
+ completionHandler(NO);
|
|
843
|
+ }]];
|
|
844
|
+ [[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
845
|
845
|
#else
|
846
|
846
|
NSAlert *alert = [[NSAlert alloc] init];
|
847
|
847
|
[alert setMessageText:message];
|
|
@@ -855,28 +855,28 @@ static NSDictionary* customCertificatesForHost;
|
855
|
855
|
}
|
856
|
856
|
|
857
|
857
|
/**
|
858
|
|
-* prompt
|
859
|
|
-*/
|
|
858
|
+ * prompt
|
|
859
|
+ */
|
860
|
860
|
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler{
|
861
|
861
|
#if !TARGET_OS_OSX
|
862
|
|
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:prompt preferredStyle:UIAlertControllerStyleAlert];
|
863
|
|
- [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
|
864
|
|
- textField.text = defaultText;
|
865
|
|
- }];
|
866
|
|
- UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
867
|
|
- completionHandler([[alert.textFields lastObject] text]);
|
868
|
|
- }];
|
869
|
|
- [alert addAction:okAction];
|
870
|
|
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
871
|
|
- completionHandler(nil);
|
872
|
|
- }];
|
873
|
|
- [alert addAction:cancelAction];
|
874
|
|
- alert.preferredAction = okAction;
|
875
|
|
- [[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
|
862
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:prompt preferredStyle:UIAlertControllerStyleAlert];
|
|
863
|
+ [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
|
|
864
|
+ textField.text = defaultText;
|
|
865
|
+ }];
|
|
866
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
867
|
+ completionHandler([[alert.textFields lastObject] text]);
|
|
868
|
+ }];
|
|
869
|
+ [alert addAction:okAction];
|
|
870
|
+ UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
871
|
+ completionHandler(nil);
|
|
872
|
+ }];
|
|
873
|
+ [alert addAction:cancelAction];
|
|
874
|
+ alert.preferredAction = okAction;
|
|
875
|
+ [[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
876
|
876
|
#else
|
877
|
877
|
NSAlert *alert = [[NSAlert alloc] init];
|
878
|
878
|
[alert setMessageText:prompt];
|
879
|
|
-
|
|
879
|
+
|
880
|
880
|
const NSRect RCTSingleTextFieldFrame = NSMakeRect(0.0, 0.0, 275.0, 22.0);
|
881
|
881
|
NSTextField *textField = [[NSTextField alloc] initWithFrame:RCTSingleTextFieldFrame];
|
882
|
882
|
textField.cell.scrollable = YES;
|