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/10/11 23:41:12 UTC

[3/4] git commit: Remove support for the events.document.reflow event

Remove support for the events.document.reflow event


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

Branch: refs/heads/master
Commit: 5140d1b4f9c51ef170c2550b2d3811a7e8f29707
Parents: d279254
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Fri Oct 11 13:41:07 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Fri Oct 11 13:41:07 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/console.coffee     | 88 ++++++++++----------
 .../META-INF/modules/t5/core/events.coffee      |  9 --
 .../org/apache/tapestry5/t5-core-dom.coffee     | 50 -----------
 3 files changed, 43 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5140d1b4/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 ca44573..3962f8a 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
@@ -58,69 +58,67 @@ define ["./dom", "underscore", "./bootstrap"],
     # console as needed.
     display = (className, message) ->
 
-      dom.withReflowEventsDisabled ->
-
-        unless floatingConsole
-          floatingConsole = dom.create
-            class: "tapestry-console",
-            """
-              <div class="message-container"></div>
-              <div class="row">
-                <div class="btn-group btn-group-sm col-md-4">
-                  #{button "clear", "remove", "Clear Console"}
-                  #{button "enable", "play", "Enable Console"}
-                  #{button "disable", "pause", "Disable Console"}
-                </div>
-                <div class="col-md-8">
-                  <input class="form-control" size="40" placeholder="Filter console content">
-                </div>
+      unless floatingConsole
+        floatingConsole = dom.create
+          class: "tapestry-console",
+          """
+            <div class="message-container"></div>
+            <div class="row">
+              <div class="btn-group btn-group-sm col-md-4">
+                #{button "clear", "remove", "Clear Console"}
+                #{button "enable", "play", "Enable Console"}
+                #{button "disable", "pause", "Disable Console"}
               </div>
-              """
+              <div class="col-md-8">
+                <input class="form-control" size="40" placeholder="Filter console content">
+              </div>
+            </div>
+            """
 
-          dom.body.prepend floatingConsole
+        dom.body.prepend floatingConsole
 
-          # Basically, any non-blank value will enable the floating console. In addition, the special
-          # value "invisible" will enable it but then hide it ... this is useful in tests, since
-          # the console output is captured in the markup, but the visible console can have unwanted interactions
-          # (such as obscuring elements that make them unclickable).
-          if consoleAttribute is "invisible"
-            floatingConsole.hide()
+        # Basically, any non-blank value will enable the floating console. In addition, the special
+        # value "invisible" will enable it but then hide it ... this is useful in tests, since
+        # the console output is captured in the markup, but the visible console can have unwanted interactions
+        # (such as obscuring elements that make them unclickable).
+        if consoleAttribute is "invisible"
+          floatingConsole.hide()
 
-          messages = floatingConsole.findFirst ".message-container"
+        messages = floatingConsole.findFirst ".message-container"
 
-          floatingConsole.findFirst("[data-action=enable]").attribute "disabled", true
+        floatingConsole.findFirst("[data-action=enable]").attribute "disabled", true
 
-          floatingConsole.on "click", "[data-action=clear]", ->
-            floatingConsole.hide()
-            messages.update ""
+        floatingConsole.on "click", "[data-action=clear]", ->
+          floatingConsole.hide()
+          messages.update ""
 
-          floatingConsole.on "click", "[data-action=disable]", ->
+        floatingConsole.on "click", "[data-action=disable]", ->
 
-            @attribute "disabled", true
-            floatingConsole.findFirst("[data-action=enable]").attribute "disabled", false
+          @attribute "disabled", true
+          floatingConsole.findFirst("[data-action=enable]").attribute "disabled", false
 
-            messages.hide()
+          messages.hide()
 
-            return false
+          return false
 
-          floatingConsole.on "click", "[data-action=enable]", ->
+        floatingConsole.on "click", "[data-action=enable]", ->
 
-            @attribute "disabled", true
-            floatingConsole.findFirst("[data-action=disable]").attribute "disabled", false
+          @attribute "disabled", true
+          floatingConsole.findFirst("[data-action=disable]").attribute "disabled", false
 
-            messages.show()
+          messages.show()
 
-            return false
+          return false
 
-          floatingConsole.on "change keyup", "input", ->
-            updateFilter @value()
+        floatingConsole.on "change keyup", "input", ->
+          updateFilter @value()
 
-            for e in messages.children()
-              visible = filter e
+          for e in messages.children()
+            visible = filter e
 
-              e[if visible then "show" else "hide"]()
+            e[if visible then "show" else "hide"]()
 
-            return false
+          return false
 
         div = dom.create
           class: className,

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5140d1b4/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
index 5b0092b..e705d0d 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
@@ -19,15 +19,6 @@
 # allow it without issue.
 define
 
-  # Events relating to the document as a whole, triggered on the document object, or elsewhere on the page.
-  document:
-    # Triggered when the page's content has changed and absolutely positioned elements may need to have their
-    # positions adjusted (an example of this is the Bootstrap Popover). Many of the methods on the `t5/core/dom:ElementWrapper`
-    # object automatically trigger this event, as does resizing the window. When that is insufficient, the `dom`
-    # module exports a `triggerReflow()` function. The firing of the event is "debounced" such that it will occur
-    # only every 250ms.
-    reflow: "t5:document:reflow"
-
   # Defines events related to the validation and submission of forms. See module `t5/core/forms` for further details.
   # All events are triggered on a specific HTML `<form>` element, and top-level handlers take it from there.
   form:

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5140d1b4/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
index f5e2db3..7aa3126 100644
--- a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
+++ b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
@@ -37,11 +37,6 @@ define ["underscore", "./utils", "./events", "jquery"],
 (_, utils, events, $) ->
 #endif
 
-  # By default, many DOM-manipulating functions here will trigger a periodic reflow event (this is to allow
-  # adjustment of elements with absolute positioning, such as a Bootstrap Popover). However, this can be
-  # temporarily disabled.
-  reflowEventsEnabled = true
-
 #if prototype
   # Save a local reference to Prototype.$ ... see notes about some challenges using Prototype, jQuery,
   # and RequireJS together, here: https://github.com/jrburke/requirejs/issues/534
@@ -227,8 +222,6 @@ define ["underscore", "./utils", "./events", "jquery"],
       @element.hide()
 #endif
 
-      triggerReflow()
-
       return this
 
     # Displays the wrapped element if hidden.
@@ -238,7 +231,6 @@ define ["underscore", "./utils", "./events", "jquery"],
 #elseif prototype
       @element.show()
 #endif
-      triggerReflow()
 
       return this
 
@@ -277,8 +269,6 @@ define ["underscore", "./utils", "./events", "jquery"],
       @element.remove()
 #endif
 
-      triggerReflow()
-
       return this
 
     # Reads or updates an attribute. With one argument, returns the current value
@@ -366,8 +356,6 @@ define ["underscore", "./utils", "./events", "jquery"],
       @element.update (content and convertContent content)
 #endif
 
-      triggerReflow()
-
       return this
 
     # Appends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
@@ -378,8 +366,6 @@ define ["underscore", "./utils", "./events", "jquery"],
       @element.insert bottom: (convertContent content)
 #endif
 
-      triggerReflow()
-
       return this
 
     # Prepends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
@@ -390,8 +376,6 @@ define ["underscore", "./utils", "./events", "jquery"],
       @element.insert top: (convertContent content)
 #endif
 
-      triggerReflow()
-
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately before
@@ -403,8 +387,6 @@ define ["underscore", "./utils", "./events", "jquery"],
       @element.insert before: (convertContent content)
 #endif
 
-      triggerReflow()
-
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately after
@@ -416,8 +398,6 @@ define ["underscore", "./utils", "./events", "jquery"],
       @element.insert after: (convertContent content)
 #endif
 
-      triggerReflow()
-
       return this
 
     # Finds the first child element that matches the CSS selector, wrapped as an ElementWrapper.
@@ -756,14 +736,6 @@ define ["underscore", "./utils", "./events", "jquery"],
 
     return exports
 
-  triggerReflow = ->
-    return unless reflowEventsEnabled
-#if jquery
-    _.debounce (-> $(document).trigger events.document.reflow), 250
-#elseif prototype
-    _.debounce (-> $(document).fire events.document.reflow), 250
-#endif
-
   # The main export is a function that wraps a DOM element as an ElementWrapper; additional functions are attached as
   # properties.
   #
@@ -822,24 +794,8 @@ define ["underscore", "./utils", "./events", "jquery"],
 
     create: createElement
 
-    triggerReflow: triggerReflow
-
     ajaxRequest: ajaxRequest
 
-    # Executes a block (provided as a function of no parameters) with automatic reflow events
-    # disabled. This is useful when the executed code will not affect the layout of the page in a way
-    # that can affect absolutely positioned elements.
-    withReflowEventsDisabled: (fn) ->
-
-      try
-        stored = reflowEventsEnabled
-
-        reflowEventsEnabled = false
-
-        fn()
-      finally
-        reflowEventsEnabled = stored
-
     # Used to add an event handler to an element (possibly from elements below it in the hierarch).
     #
     # * selector - CSS selector used to select elements to attach handler to; alternately,
@@ -875,10 +831,4 @@ define ["underscore", "./utils", "./events", "jquery"],
     # it is always safe to get the body.
     body: wrapElement document.body
 
-#if jquery
-  $(window).on "resize", exports.triggerReflow
-#elseif prototype
-  Event.observe window, "resize", triggerReflow
-#endif
-
   return exports
\ No newline at end of file