cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject js commit: [CB-2785] Switch executeScript/injectCSS to call dedicated plugin methods
Date Thu, 04 Apr 2013 18:48:12 GMT
Updated Branches:
  refs/heads/master 10788b94d -> d39c1fee2


[CB-2785] Switch executeScript/injectCSS to call dedicated plugin methods


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/d39c1fee
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d39c1fee
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d39c1fee

Branch: refs/heads/master
Commit: d39c1fee26d527f37d217a61086385063b46e439
Parents: 10788b9
Author: Ian Clelland <iclelland@chromium.org>
Authored: Tue Mar 26 16:08:52 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Apr 4 14:33:18 2013 -0400

----------------------------------------------------------------------
 lib/common/plugin/InAppBrowser.js |   20 ++++++--------------
 1 files changed, 6 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d39c1fee/lib/common/plugin/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/InAppBrowser.js b/lib/common/plugin/InAppBrowser.js
index 4f89bd2..1640a82 100644
--- a/lib/common/plugin/InAppBrowser.js
+++ b/lib/common/plugin/InAppBrowser.js
@@ -51,30 +51,22 @@ InAppBrowser.prototype = {
             this.channels[eventname].unsubscribe(f);
         }
     },
+
     executeScript: function(injectDetails, cb) {
-        var script,
-            sourceString;
         if (injectDetails.code) {
-            exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code]);
+            exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
         } else if (injectDetails.file) {
-            sourceString = JSON.stringify(injectDetails.file);
-            script = "(function(d) { var c = d.createElement('script'); c.src = " + sourceString
+ "; d.body.appendChild(c); })(document)";
-            exec(cb, null, "InAppBrowser", "injectScriptCode", [script]);
+            exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
         } else {
             throw new Error('executeScript requires exactly one of code or file to be specified');
         }
     },
+
     insertCSS: function(injectDetails, cb) {
-        var script,
-            sourceString;
         if (injectDetails.code) {
-            sourceString = JSON.stringify(injectDetails.code);
-            script = "(function(d) { var c = d.createElement('style'); c.innerHTML = " +
sourceString + "; d.body.appendChild(c); })(document)";
-            exec(cb, null, "InAppBrowser", "injectScriptCode", [script]);
+            exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
         } else if (injectDetails.file) {
-            sourceString = JSON.stringify(injectDetails.file);
-            script = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet',
c.type='text/css'; c.href = " + sourceString + "; d.body.appendChild(c); })(document)";
-            exec(cb, null, "InAppBrowser", "injectScriptCode", [script]);
+            exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
         } else {
             throw new Error('insertCSS requires exactly one of code or file to be specified');
         }


Mime
View raw message