//
//  WebBrowseViewController.m
//  kneet
//
//  Created by Jason Lee on 5/13/15.
//  Copyright (c) 2015 ntels. All rights reserved.
//

#import "WebBrowseViewController.h"


@interface WebBrowseViewController () <UIWebViewDelegate> {

}
@end


#pragma mark - Class Definition

@implementation WebBrowseViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self initUI];
    [self prepareViewDidLoad];
}


- (void)initUI {

    self.title = self.titleString;

    
    

    _webView.delegate = self;
}

- (void)prepareViewDidLoad {
    if (_URLString && ![_URLString isEmptyString]) {

        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_URLString]];
        [_webView loadRequest:request];
    }
}

#pragma mark - UIWebView Delegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    if(navigationType == UIWebViewNavigationTypeLinkClicked) {
        [[UIApplication sharedApplication] openURL:request.URL];
        return NO;
    }

    return YES;
}


#pragma mark - UI Events
- (void)btnBackTouched:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - MemoryWarning
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
