Permalink
Browse files

Allow evaling in webview

  • Loading branch information...
1 parent 9481ce0 commit 34c28b95df8fb673b5c148aff497972f6822e0e1 @jakearchibald committed Mar 27, 2013
Showing with 18 additions and 1 deletion.
  1. +8 −0 js/mankini/Builder.js
  2. +10 −1 js/mankini/slide/WebView.js
View
8 js/mankini/Builder.js
@@ -335,6 +335,14 @@
});
};
+ BuilderProto.webViewEval = function(func) {
+ var builder = this;
+
+ return this.action(function( animate, $slide ) {
+ builder._webView.eval(func);
+ });
+ };
+
BuilderProto.supported = function(supportItems, className) {
var builder = this;
View
11 js/mankini/slide/WebView.js
@@ -5,6 +5,7 @@
this.$container = $('<iframe src="about:blank" class="mankini-web-view"></iframe>').addClass( className || '' );
this._$iframe = this.$container;
this.hasUrl = false;
+ this._ready = null;
}
var WebViewProto = WebView.prototype;
@@ -33,7 +34,7 @@
this.hasUrl = true;
this._$iframe[0].src = str;
-
+ this._ready = deferred;
return deferred;
};
@@ -66,5 +67,13 @@
});
};
+ WebViewProto.eval = function(func) {
+ var webView = this;
+
+ webView._ready.done(function() {
+ webView._$iframe[0].contentWindow.eval('a=' + func.toString() + '()');
+ });
+ };
+
mankini.slide.WebView = WebView;
})();

0 comments on commit 34c28b9

Please sign in to comment.