//
// p l o t P o p u p V i e w C o n t r o l l e r . s w i f t
// w k t e s t
//
// C r e a t e d b y h r b r m s t r o n 9 / 9 / 1 9 .
// C o p y r i g h t © 2 0 1 9 B o b R u d i s . A l l r i g h t s r e s e r v e d .
//
import Cocoa
import WebKit
class plotPopupViewController : NSViewController {
var webView : WKWebView !
var urlPath : String = " "
open override func viewDidLoad ( ) {
super . viewDidLoad ( )
}
func setupWebView ( configuration : WKWebViewConfiguration ) {
webView = WKWebView ( frame : view . bounds , configuration : configuration )
webView . autoresizingMask = [ . width , . height ]
webView . uiDelegate = self
webView . navigationDelegate = self
view . addSubview ( webView )
}
func loadWebView ( urlIn : String ) {
urlPath = urlIn
if let url = URL ( string : urlPath ) {
let urlRequest = URLRequest ( url : url )
if ( url . path . starts ( with : " /export " ) ) {
} else {
webView . load ( urlRequest )
}
}
}
override func viewDidAppear ( ) {
super . viewDidAppear ( )
}
}
extension plotPopupViewController : WKUIDelegate {
func webViewDidClose ( _ webView : WKWebView ) {
self . view . window ? . close ( )
}
func webView ( _ webView : WKWebView , runOpenPanelWith parameters : WKOpenPanelParameters , initiatedByFrame frame : WKFrameInfo , completionHandler : @ escaping ( [ URL ] ? ) -> Void ) {
}
}
extension plotPopupViewController : WKNavigationDelegate {
open func webView ( _ webView : WKWebView , didStartProvisionalNavigation navigation : WKNavigation ! ) { }
func webView ( _ webView : WKWebView , didFinish navigation : WKNavigation ! ) { }
}