Skip to content

Commit

Permalink
Merge pull request #538 from Taracque/patch-1
Browse files Browse the repository at this point in the history
[TIMOB-7849] Moved beforeload event trigger to shouldStartLoadWithRequest
  • Loading branch information
Stephen Tramer committed Mar 6, 2012
2 parents bc9cb0f + 1d56dd5 commit 63c6314
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions iphone/Classes/TiUIWebView.m
Expand Up @@ -608,6 +608,13 @@ -(CGFloat)autoWidthForWidth:(CGFloat)value
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL * newUrl = [request URL];

if ([self.proxy _hasListeners:@"beforeload"])
{
NSDictionary *event = newUrl == nil ? nil : [NSDictionary dictionaryWithObject:[newUrl absoluteString] forKey:@"url"];
[self.proxy fireEvent:@"beforeload" withObject:event];
}

NSString * scheme = [[newUrl scheme] lowercaseString];
if ([scheme hasPrefix:@"http"] || [scheme hasPrefix:@"app"] || [scheme hasPrefix:@"file"] || [scheme hasPrefix:@"ftp"])
{
Expand Down Expand Up @@ -639,11 +646,6 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)

- (void)webViewDidStartLoad:(UIWebView *)webView
{
if ([self.proxy _hasListeners:@"beforeload"])
{
NSDictionary *event = url == nil ? nil : [NSDictionary dictionaryWithObject:[url absoluteString] forKey:@"url"];
[self.proxy fireEvent:@"beforeload" withObject:event];
}
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
Expand Down

0 comments on commit 63c6314

Please sign in to comment.