incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject weinre commit: allow deferred running of body-sensitive code
Date Sat, 03 Mar 2012 00:05:46 GMT
Updated Branches:
  refs/heads/master d0a4694a1 -> 344f76450


allow deferred running of body-sensitive code


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/commit/344f7645
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/tree/344f7645
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/diff/344f7645

Branch: refs/heads/master
Commit: 344f76450e311f4e6a1244d4c017a0ec040d98ab
Parents: d0a4694
Author: Patrick Mueller <pmuellr@apache.org>
Authored: Fri Mar 2 13:23:08 2012 -0500
Committer: Patrick Mueller <pmuellr@apache.org>
Committed: Fri Mar 2 13:23:08 2012 -0500

----------------------------------------------------------------------
 weinre.web/modules/weinre/target/Target.coffee     |   10 ++++++++++
 .../weinre/target/WeinreTargetEventsImpl.coffee    |    9 +++++----
 2 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/344f7645/weinre.web/modules/weinre/target/Target.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Target.coffee b/weinre.web/modules/weinre/target/Target.coffee
index 3d3eed3..460ece1 100644
--- a/weinre.web/modules/weinre/target/Target.coffee
+++ b/weinre.web/modules/weinre/target/Target.coffee
@@ -210,6 +210,16 @@ module.exports = class Target
         nodeData = Weinre.nodeStore.getNodeData(nodeId, 2)
         Weinre.wi.DOMNotify.setDocument nodeData
 
+    #---------------------------------------------------------------------------
+    whenBodyReady: (receiver, args, func) ->
+        if document.body
+            func.apply(receiver, args)
+            return
+        
+        document.addEventListener "DOMContentLoaded", 
+            -> func.apply(receiver, args), 
+            false
+
 #-------------------------------------------------------------------------------
 currentTime = () ->
       (new Date().getMilliseconds()) / 1000.0

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/344f7645/weinre.web/modules/weinre/target/WeinreTargetEventsImpl.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/WeinreTargetEventsImpl.coffee b/weinre.web/modules/weinre/target/WeinreTargetEventsImpl.coffee
index 5f308aa..37dce45 100644
--- a/weinre.web/modules/weinre/target/WeinreTargetEventsImpl.coffee
+++ b/weinre.web/modules/weinre/target/WeinreTargetEventsImpl.coffee
@@ -32,10 +32,11 @@ module.exports = class WeinreTargetEventsImpl
         message = "weinre: target #{targetChannel} connected to client " + clientChannel
         Weinre.logInfo message
 
-        oldValue = Console.useRemote(true)
-        Weinre.target.setDocument()
-        Weinre.wi.TimelineNotify.timelineProfilerWasStopped()
-        Weinre.wi.DOMStorage.initialize()
+        Weinre.target.whenBodyReady @, [], ->
+            oldValue = Console.useRemote(true)
+            Weinre.target.setDocument()
+            Weinre.wi.TimelineNotify.timelineProfilerWasStopped()
+            Weinre.wi.DOMStorage.initialize()
 
     #---------------------------------------------------------------------------
     connectionDestroyed: (clientChannel, targetChannel) ->


Mime
View raw message