- (void) webView:(WebView *)view runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
id<CYWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:)])
- // XXX: check delegate
- if ([delegate webView:view shouldRunJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame])
+ if (
+ ![delegate respondsToSelector:@selector(webView:shouldRunJavaScriptAlertPanelWithMessage:initiatedByFrame:)] ||
+ [delegate webView:view shouldRunJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame]
+ )
[super webView:view runJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame];
}
// }}}
- (BOOL) webView:(WebView *)view runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
id<CYWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:)])
- // XXX: check delegate
- if ([delegate webView:view shouldRunJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame])
+ if (
+ ![delegate respondsToSelector:@selector(webView:shouldRunJavaScriptConfirmPanelWithMessage:initiatedByFrame:)] ||
+ [delegate webView:view shouldRunJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame]
+ )
return [super webView:view runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame];
return NO;
}
- (NSString *) webView:(WebView *)view runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame {
id<CYWebViewDelegate> delegate([self delegate]);
if ([UIWebView instancesRespondToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:)])
- // XXX: check delegate
- if ([delegate webView:view shouldRunJavaScriptTextInputPanelWithPrompt:prompt defaultText:text initiatedByFrame:frame])
+ if (
+ ![delegate respondsToSelector:@selector(webView:shouldRunJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:)] ||
+ [delegate webView:view shouldRunJavaScriptTextInputPanelWithPrompt:prompt defaultText:text initiatedByFrame:frame]
+ )
return [super webView:view runJavaScriptTextInputPanelWithPrompt:prompt defaultText:text initiatedByFrame:frame];
return nil;
}
if (request_ != nil)
[request_ release];
- //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
-
if (custom_ != nil)
[custom_ release];
if (style_ != nil)
if (title_ != nil)
[title_ release];
+ if ([loading_ count] != 0)
+ [delegate_ releaseNetworkActivityIndicator];
[loading_ release];
[reloaditem_ release];
[[self navigationItem] setTitle:UCLocalize("LOADING")];
}
+- (void) layoutRightButton {
+ [[loadingitem_ view] addSubview:indicator_];
+ [[loadingitem_ view] bringSubviewToFront:indicator_];
+}
+
- (void) applyRightButton {
if ([self isLoading]) {
[[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
- // XXX: why do we do this again here? (if we don't, just remove indicator_)
- [[loadingitem_ view] addSubview:indicator_];
+ [self performSelector:@selector(layoutRightButton) withObject:nil afterDelay:0];
+
+ [indicator_ startAnimating];
[self applyLoadingTitle];
- } else if (custom_ != nil) {
- [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
} else {
- [[self navigationItem] setRightBarButtonItem:[self rightButton] animated:YES];
+ [indicator_ stopAnimating];
+
+ [[self navigationItem] setRightBarButtonItem:(
+ custom_ != nil ? [self customButton] : [self rightButton]
+ ) animated:YES];
}
}
- (void) _didStartLoading {
[self applyRightButton];
+
+ if ([loading_ count] != 1)
+ return;
+ [delegate_ retainNetworkActivityIndicator];
}
- (void) _didFinishLoading {
if ([loading_ count] != 0)
return;
+ [delegate_ releaseNetworkActivityIndicator];
[self applyRightButton];
[document setTileSize:CGSizeMake(320, 500)];
[document setBackgroundColor:[UIColor clearColor]];
+
+ // XXX: this is terribly (too?) expensive
[document setDrawsBackground:NO];
WebView *webview([document webView]);
action:@selector(reloadButtonClicked)
];
- CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
- indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
- [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
- [indicator_ startAnimation];
- [[loadingitem_ view] addSubview:indicator_];
+ indicator_ = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
+ [indicator_ setFrame:CGRectMake(15, 5, [indicator_ frame].size.width, [indicator_ frame].size.height)];
[webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];