Permalink
Browse files

add amazing dom loading

  • Loading branch information...
defunkt committed Jun 26, 2009
1 parent 4b27131 commit 23e46358932ab28d95e9d39f6eae8956312743b6
Showing with 18 additions and 1 deletion.
  1. +7 −0 lib/lyndon/delegate.rb
  2. +11 −1 lib/lyndon/runtime.rb
View
@@ -0,0 +1,7 @@
+module Lyndon
+ class Delegate
+ def webView(sender, didFinishLoadForFrame:frame)
+ NSApplication.sharedApplication.stop(self)
+ end
+ end
+end
View
@@ -2,10 +2,20 @@
module Lyndon
class Runtime
- def initialize
+ def initialize(dom = nil)
@webView = WebView.new
+ @webView.setFrameLoadDelegate(Delegate.new)
+
@scripter = @webView.windowScriptObject
@scripter.setValue(Ruby.new, forKey:"Ruby")
+
+ load_dom(dom) if dom
+ end
+
+ def load_dom(dom, base_url = nil)
+ dom = File.exists?(dom) ? File.read(dom) : dom
+ @webView.mainFrame.loadHTMLString(dom, baseURL:base_url)
+ NSApplication.sharedApplication.run
end
def eval(js)

0 comments on commit 23e4635

Please sign in to comment.