cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject [7/9] git commit: Don't load the context menu until deviceready fires
Date Tue, 25 Jun 2013 18:58:05 GMT
Don't load the context menu until deviceready fires


Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/9b881f49
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/9b881f49
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/9b881f49

Branch: refs/heads/master
Commit: 9b881f490e8bf2f256bcf98e13435291f1e6fad4
Parents: 34c9a89
Author: Braden Shepherdson <braden.shepherdson@gmail.com>
Authored: Mon Jun 17 13:41:25 2013 -0400
Committer: Braden Shepherdson <braden.shepherdson@gmail.com>
Committed: Thu Jun 20 10:43:56 2013 -0400

----------------------------------------------------------------------
 www/cdvah_js/ContextMenu.js             | 16 ++++++++++------
 www/cdvah_js/ContextMenuInjectScript.js | 16 +++++++++-------
 2 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9b881f49/www/cdvah_js/ContextMenu.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/ContextMenu.js b/www/cdvah_js/ContextMenu.js
index 48d5ac8..12d20ae 100644
--- a/www/cdvah_js/ContextMenu.js
+++ b/www/cdvah_js/ContextMenu.js
@@ -4,7 +4,7 @@
         setupIframe();
         sendAppNameToIframe();
         setupIframeMessaging();
-        loadFirebug(false);
+        //loadFirebug(false);
         attachErrorListener();
     }
 
@@ -85,11 +85,15 @@
     };
     function setupIframeMessaging(){
         window.addEventListener("message", function(e){
+            if (!e || !e.data || typeof e.data !== 'string') {
+                return;
+            }
+
             var messageParts = [ e.data ];
-            var location = e.data.indexOf(":");
-            if(location !== -1){
-                messageParts = [ e.data.substring(0, location),
-                    e.data.substring(location + 1)
+            var loc = e.data.indexOf(":");
+            if(loc !== -1){
+                messageParts = [ e.data.substring(0, loc),
+                    e.data.substring(loc + 1)
                 ];
             }
             if(messageHandler[messageParts[0]]){
@@ -101,7 +105,7 @@
     function loadFirebug(startOpened){
         var el = document.createElement("script");
         el.setAttribute("id", "FirebugLite");
-        el.setAttribute("src", "https://getfirebug.com/firebug-lite.js");
+        el.setAttribute("src", "https://getfirebug.com/firebug-lite-beta.js");
         el.setAttribute("FirebugLite", "4");
         el.innerHTML = el.innerHTML = "{ debug : false, startOpened : "  + startOpened +
", showIconWhenHidden : false, saveCommandLineHistory : true, saveCookies : false }";
         document.head.appendChild(el);

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9b881f49/www/cdvah_js/ContextMenuInjectScript.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/ContextMenuInjectScript.js b/www/cdvah_js/ContextMenuInjectScript.js
index 70c06aa..5a703cc 100644
--- a/www/cdvah_js/ContextMenuInjectScript.js
+++ b/www/cdvah_js/ContextMenuInjectScript.js
@@ -3,12 +3,14 @@
     /* global myApp */
     myApp.factory("ContextMenuInjectScript", [ function () {
         var toInject = function() {
-            console.log("Injecting menu script");
-            var contextScript = document.createElement("script");
-            contextScript.setAttribute("type","text/javascript");
-            contextScript.setAttribute("src", "app-bundle:///cdvah_js/ContextMenu.js");
-            window.__cordovaAppHarnessAppName = "appPlaceHolder";
-            document.getElementsByTagName("head")[0].appendChild(contextScript);
+            document.addEventListener('deviceready', function() {
+                console.log("Injecting menu script");
+                var contextScript = document.createElement("script");
+                contextScript.setAttribute("type","text/javascript");
+                contextScript.setAttribute("src", "app-bundle:///cdvah_js/ContextMenu.js");
+                window.__cordovaAppHarnessAppName = "appPlaceHolder";
+                document.getElementsByTagName("head")[0].appendChild(contextScript);
+            });
         };
 
         return {
@@ -19,4 +21,4 @@
             }
         };
     }]);
-})();
\ No newline at end of file
+})();


Mime
View raw message