You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2013/07/22 01:49:34 UTC

[5/6] git commit: Turn off reflow logic while manipulating the DOM for the floating console

Turn off reflow logic while manipulating the DOM for the floating console


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/9caac8e5
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/9caac8e5
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/9caac8e5

Branch: refs/heads/master
Commit: 9caac8e576b693f7e87c61dd32b2fe92ee200adc
Parents: 430b1a7
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Sun Jul 21 16:42:25 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Sun Jul 21 16:42:25 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/console.coffee     | 72 +++++++++++---------
 1 file changed, 38 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/9caac8e5/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
index 2a3794c..573a5d3 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/console.coffee
@@ -41,54 +41,58 @@ define ["./dom", "underscore"],
     # _internal_: displays the message inside the floating console, creating the floating
     # console as needed.
     display = (className, message) ->
-      unless floatingConsole
-        floatingConsole = dom.create
-          class: "tapestry-console",
-          """
-            <div class="console-backdrop"></div>
-            <div class="alert-container"></div>
-            <button class="btn btn-mini"><i class="icon-remove"></i> Clear Console</button>
+
+      dom.withReflowEventsDisabled ->
+
+        unless floatingConsole
+          floatingConsole = dom.create
+            class: "tapestry-console",
             """
+              <div class="console-backdrop"></div>
+              <div class="alert-container"></div>
+              <button class="btn btn-mini"><i class="icon-remove"></i> Clear Console</button>
+              """
 
-        dom.body.prepend floatingConsole
+          dom.body.prepend floatingConsole
 
-        alertContainer = floatingConsole.findFirst ".alert-container"
+          alertContainer = floatingConsole.findFirst ".alert-container"
 
-        floatingConsole.on "click", ".btn-mini", ->
-          floatingConsole.hide()
-          alertContainer.update ""
+          floatingConsole.on "click", ".btn-mini", ->
+            floatingConsole.hide()
+            alertContainer.update ""
 
-      div = dom.create
-        class: "alert #{className}"
-        """
-          <button class="close">&times;</button>
-          #{_.escape message}
-        """
+        div = dom.create
+          class: "alert #{className}"
+          """
+            <button class="close">&times;</button>
+            #{_.escape message}
+          """
 
-      floatingConsole.show()
-      alertContainer.append div.hide().fadeIn FADE_DURATION
+        floatingConsole.show()
+        alertContainer.append div.hide().fadeIn FADE_DURATION
 
-      # A slightly clumsy way to ensure that the container is scrolled to the bottom.
-      _.delay -> alertContainer.element.scrollTop = alertContainer.element.scrollHeight
+        # A slightly clumsy way to ensure that the container is scrolled to the bottom.
+        _.delay -> alertContainer.element.scrollTop = alertContainer.element.scrollHeight
 
-      animating = false
-      removed = false
+        animating = false
+        removed = false
 
-      runFadeout = ->
-        return if animating
+        runFadeout = ->
+          return if animating
 
-        animating = true
+          animating = true
 
-        div.fadeOut FADE_DURATION, ->
-          div.remove() unless removed
+          div.fadeOut FADE_DURATION, ->
+            dom.withReflowEventsDisabled ->
+              div.remove() unless removed
 
-          # Hide the console after the last one is removed.
-          unless floatingConsole.findFirst(".alert")
-            floatingConsole.hide()
+              # Hide the console after the last one is removed.
+              unless floatingConsole.findFirst(".alert")
+                floatingConsole.hide()
 
-      window.setTimeout runFadeout, exports.DURATION * 1000
+        window.setTimeout runFadeout, exports.DURATION * 1000
 
-      div.on "click", -> runFadeout()
+        div.on "click", -> runFadeout()
 
     level = (className, consolefn) ->
       (message) ->