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/06/05 20:04:07 UTC

[1/3] git commit: TAP5-2124: Support triggering zone update/refresh via nested element

Updated Branches:
  refs/heads/master b39079c84 -> c18e1199e


TAP5-2124: Support triggering zone update/refresh via nested element


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

Branch: refs/heads/master
Commit: 52fcb51f170fff5c2144a4dab7bcd3b9aad44af3
Parents: b39079c
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Jun 5 09:30:12 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Jun 5 09:30:12 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/events.coffee         |    6 +++---
 .../META-INF/modules/t5/core/zone.coffee           |   12 ++++++++----
 .../org/apache/tapestry5/t5-core-dom-jquery.coffee |   11 +++++++++++
 .../apache/tapestry5/t5-core-dom-prototype.coffee  |    9 +++++++++
 4 files changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/52fcb51f/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 94e2901..908470b 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
@@ -1,4 +1,4 @@
-# Copyright 2012 The Apache Software Foundation
+# Copyright 2012, 2013 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -128,7 +128,7 @@ define
     # Triggered (by the standard handler) just before the content in a Zone will be updated.
     willUpdate: "t5:zone:will-update"
 
-    # Triggered (by the standard hanndler) just after the content in a Zone has updated. If the zone was not visible, it
+    # Triggered (by the standard handler) just after the content in a Zone has updated. If the zone was not visible, it
     # is made visible after its content is changed, and before this event is triggered. Some number of other components that
     # also perform Ajax updates of the page also trigger this event.
     #
@@ -137,7 +137,7 @@ define
     # (see `t5/core/datefield` module).
     didUpdate: "t5:zone:did-update"
 
-    # Triggered on a zone element, the default handler will peform an Ajax request and, when the response is available,
+    # Triggered on (or within) a zone element, the default handler will peform an Ajax request and, when the response is available,
     # update the zone (via `events.zone.update`). The request should provide a partial page render response. If the
     # response includes a `content` key, its value will be the markup to replace the zone element's body.
     #

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/52fcb51f/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
index 32db8f5..57bbaf6 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
@@ -90,15 +90,19 @@ define ["./dom", "./events", "./ajax", "./console", "./forms",  "underscore"],
 
     dom.onDocument events.zone.refresh, (event) ->
 
+      # This even may be triggered on an element inside the zone, rather than on the zone itself. Scan upwards
+      # to find the actual zone.
+      zone = @closest "[data-container-type=zone]"
+
       # A Zone inside a form will render some additional parameters to coordinate updates with the Form on the server.
-      attr = @attribute "data-zone-parameters"
+      attr = zone.attribute "data-zone-parameters"
 
       parameters = attr and JSON.parse attr
 
       ajax event.memo.url,
-        parameters: _.extend { "t:zoneid": @element.id }, parameters, event.memo.parameters
+        parameters: _.extend { "t:zoneid": zone.element.id }, parameters, event.memo.parameters
         success: (response) =>
-          @trigger events.zone.update, content: response.json?.content
+          zone.trigger events.zone.update, content: response.json?.content
 
     # Locates a zone element by its unique id attribute, and (deferred, to a later event loop cycle),
     # performs a standard refresh of the zone. This is primarily used by the core/ProgressiveDisplay component.
@@ -116,5 +120,5 @@ define ["./dom", "./events", "./ajax", "./console", "./forms",  "underscore"],
 
         zone.trigger events.zone.refresh, { url }
 
-    # Most of this module is document-level event handlers, but there's also some exports.
+    # Most of this module is document-level event handlers, but there's also some exports:
     return { deferredZoneUpdate, findZone }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/52fcb51f/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
index 8e8e078..9f60c92 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
@@ -266,6 +266,17 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
 
       new ElementWrapper parents.eq(0)
 
+    # Returns this ElementWrapper if it matches the selector; otherwise, returns the first container element (as an ElementWrapper)
+    # that matches the selector. Returns null if no container element matches.
+    closest: (selector) ->
+
+      match = @$.closest selector
+
+      switch
+        when match.length is 0 then return null
+        when match[0] is @element then return this
+        else return new ElementWrapper match
+
     # Returns an ElementWrapper for this element's containing element.
     # Returns null if this element has no parent (either because this element is the document object, or
     # because this element is not yet attached to the DOM).

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/52fcb51f/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
index 42fd8ee..ccabd1b 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
@@ -306,6 +306,15 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
 
       new ElementWrapper parent
 
+    # Returns this ElementWrapper if it matches the selector; otherwise, returns the first container element (as an ElementWrapper)
+    # that matches the selector. Returns null if no container element matches.
+    closest: (selector) ->
+
+      if @element.match selector
+        return this
+
+      return @findParent selector
+
     # Returns an ElementWrapper for this element's immediate containing element.
     # Returns null if this element has no parent (either because this element is the document object, or
     # because this element is not yet attached to the DOM).


[2/3] git commit: Advance version number to 5.4-alpha-9

Posted by hl...@apache.org.
Advance version number to 5.4-alpha-9


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

Branch: refs/heads/master
Commit: cfb63ee7e1f49823d7becbeaef33530dd6c1562d
Parents: 52fcb51
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Jun 5 09:30:48 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Jun 5 09:30:48 2013 -0700

----------------------------------------------------------------------
 build.gradle |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cfb63ee7/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 15cdd73..3046315 100755
--- a/build.gradle
+++ b/build.gradle
@@ -34,7 +34,7 @@ project.version = tapestryVersion()
 def tapestryVersion() {
 
     def major = "5.4"
-    def minor = "-alpha-8"
+    def minor = "-alpha-9"
 
     // When building on the CI server, make sure -SNAPSHOT is appended, as it is a nightly build.
     // When building normally, or for a release, no suffix is desired.


[2/3] git commit: Advance version number to 5.4-alpha-9

Posted by hl...@apache.org.
Advance version number to 5.4-alpha-9


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

Branch: refs/heads/master
Commit: cfb63ee7e1f49823d7becbeaef33530dd6c1562d
Parents: 52fcb51
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Jun 5 09:30:48 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Jun 5 09:30:48 2013 -0700

----------------------------------------------------------------------
 build.gradle |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/cfb63ee7/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 15cdd73..3046315 100755
--- a/build.gradle
+++ b/build.gradle
@@ -34,7 +34,7 @@ project.version = tapestryVersion()
 def tapestryVersion() {
 
     def major = "5.4"
-    def minor = "-alpha-8"
+    def minor = "-alpha-9"
 
     // When building on the CI server, make sure -SNAPSHOT is appended, as it is a nightly build.
     // When building normally, or for a release, no suffix is desired.


[3/3] git commit: Add support for a events.document.reflow event, to identify when page layout has changed

Posted by hl...@apache.org.
Add support for a events.document.reflow event, to identify when page layout has changed


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

Branch: refs/heads/master
Commit: c18e1199e8eaa801c6be149e76d077221a685c04
Parents: cfb63ee
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Jun 5 10:27:04 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Jun 5 10:27:04 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/events.coffee         |   10 ++++
 .../org/apache/tapestry5/t5-core-dom-jquery.coffee |   34 +++++++++++++--
 .../apache/tapestry5/t5-core-dom-prototype.coffee  |   28 +++++++++++-
 3 files changed, 66 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c18e1199/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 908470b..bc9ca33 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
@@ -18,6 +18,16 @@
 # trigger or listener for. Prototype requires that all custom events have a namespace prefix; jQuery appears to
 # 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/c18e1199/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
index 9f60c92..86c09b4 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
@@ -31,8 +31,7 @@
 # the abstract layer and gain the valuable benefit of not caring about the infrastructure framework.
 #
 # Changes to this library should be coordinated with the Prototype version.
-define ["underscore", "./utils", "jquery"], (_, utils, $) ->
-
+define ["underscore", "./utils", "jquery", "./events"], (_, utils, $, events) ->
 
   # Converts content (provided to `ElementWrapper.update()` or `append()`) into an appropriate type. This
   # primarily exists to validate the value, and to "unpack" an ElementWrapper into a DOM element.
@@ -123,12 +122,16 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     hide: ->
       @$.hide()
 
+      triggerReflow()
+
       return this
 
     # Displays the wrapped element if hidden.
     show: ->
       @$.show()
 
+      triggerReflow()
+
       return this
 
     # Removes the wrapped element from the DOM.  It can later be re-attached.
@@ -136,6 +139,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
       # jQuery's remove() will remove event handlers which we don't want.
       @$.detach()
 
+      triggerReflow()
+
       return this
 
     # Reads or updates an attribute. With one argument, returns the current value
@@ -189,18 +194,24 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
       if content
         @$.append (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Appends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     append: (content) ->
       @$.append (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Prepends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     prepend: (content) ->
       @$.prepend (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately before
@@ -208,6 +219,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     insertBefore: (content) ->
       @$.before (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately after
@@ -215,6 +228,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     insertAfter: (content) ->
       @$.after (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Runs an animation to fade-in the element over the specified duration.
@@ -222,7 +237,9 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # * duration - animation duration time, in seconds
     # * callback - function invoked after the animation is complete
     fadeIn: (duration, callback) ->
-      @$.fadeIn duration * 1000, callback
+      @$.fadeIn duration * 1000, ->
+        triggerReflow()
+        callback and callback()
 
       return this
 
@@ -232,7 +249,9 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # * duration - animation duration time, in seconds
     # * callback - function invoked after the animation is complete
     fadeOut: (duration, callback) ->
-      @$.fadeOut duration * 1000, callback
+      @$.fadeOut duration * 1000, ->
+        triggerReflow()
+        callback and callback()
 
       return this
 
@@ -437,6 +456,7 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
 
     return exports
 
+  triggerReflow = _.debounce (-> $(document).trigger events.document.reflow), 250
 
   # The main export is a function that wraps a DOM element as an ElementWrapper; additional functions are attached as
   # properties.
@@ -462,6 +482,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # Escape's HTML markup in the string.
     escapeHTML: _.escape
 
+    triggerReflow: triggerReflow
+
     ajaxRequest: ajaxRequest
 
     # Used to add an event handler to an element (possibly from elements below it in the hierarch).
@@ -492,3 +514,7 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # inside a block at the end of the document, inside the `<body`> element, it is assumed that
     # it is always safe to get the body.
     body: -> wrapElement document.body
+
+  $(window).on "resize", exports.triggerReflow
+
+  return exports
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c18e1199/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
index ccabd1b..85d1f97 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
@@ -31,7 +31,7 @@
 # the abstract layer and gain the valuable benefit of not caring about the infrastructure framework.
 #
 # Changes to this library should be coordinated with the jQuery version.
-define ["underscore", "./utils", "prototype"], (_, utils) ->
+define ["underscore", "./utils", "./events", "prototype"], (_, utils, events) ->
 
   # 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
@@ -77,6 +77,7 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
         styles[styleName] = finalValue
         element.setStyle styles
         window.clearInterval timeoutID
+        triggerReflow()
         callbacks.oncomplete and callbacks.oncomplete()
 
       # TODO: Add an easein/easeout function
@@ -164,18 +165,24 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     hide: ->
       @element.hide()
 
+      triggerReflow()
+
       return this
 
     # Displays the wrapped element if hidden.
     show: ->
       @element.show()
 
+      triggerReflow()
+
       return this
 
     # Removes the wrapped element from the DOM.  It can later be re-attached.
     remove: ->
       @element.remove()
 
+      triggerReflow()
+
       return this
 
     # Reads or updates an attribute. With one argument, returns the current value
@@ -227,18 +234,24 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     update: (content) ->
       @element.update (content and convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Appends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     append: (content) ->
       @element.insert bottom: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Prepends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     prepend: (content) ->
       @element.insert top: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately before
@@ -246,6 +259,8 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     insertBefore: (content) ->
       @element.insert before: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately after
@@ -253,6 +268,8 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     insertAfter: (content) ->
       @element.insert after: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Runs an animation to fade-in the element over the specified duration. The element may be hidden (via `hide()`)
@@ -508,7 +525,6 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
 
     return exports
 
-
   # The main export is a function that wraps a DOM element as an ElementWrapper; additional functions are attached as
   # properties.
   #
@@ -526,12 +542,16 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     # Prototype API (especially with respect to events).
     new ElementWrapper element
 
+  triggerReflow = _.debounce (-> $(document).fire events.document.reflow), 250
+
   _.extend exports,
     wrap: wrapElement
 
     # Escape's HTML markup in the string.
     escapeHTML: (str) -> str.escapeHTML()
 
+    triggerReflow: triggerReflow
+
     ajaxRequest: ajaxRequest
 
     # Used to add an event handler to an element (possibly from elements below it in the hierarch).
@@ -564,3 +584,7 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     # inside a block at the end of the document, inside the `<body`> element, it is assumed that
     # it is always safe to get the body.
     body: -> wrapElement document.body
+
+  Event.observe window, "resize", triggerReflow
+
+  return exports
\ No newline at end of file


[3/3] git commit: Add support for a events.document.reflow event, to identify when page layout has changed

Posted by hl...@apache.org.
Add support for a events.document.reflow event, to identify when page layout has changed


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

Branch: refs/heads/master
Commit: c18e1199e8eaa801c6be149e76d077221a685c04
Parents: cfb63ee
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Jun 5 10:27:04 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Jun 5 10:27:04 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/events.coffee         |   10 ++++
 .../org/apache/tapestry5/t5-core-dom-jquery.coffee |   34 +++++++++++++--
 .../apache/tapestry5/t5-core-dom-prototype.coffee  |   28 +++++++++++-
 3 files changed, 66 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c18e1199/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 908470b..bc9ca33 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
@@ -18,6 +18,16 @@
 # trigger or listener for. Prototype requires that all custom events have a namespace prefix; jQuery appears to
 # 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/c18e1199/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
index 9f60c92..86c09b4 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-jquery.coffee
@@ -31,8 +31,7 @@
 # the abstract layer and gain the valuable benefit of not caring about the infrastructure framework.
 #
 # Changes to this library should be coordinated with the Prototype version.
-define ["underscore", "./utils", "jquery"], (_, utils, $) ->
-
+define ["underscore", "./utils", "jquery", "./events"], (_, utils, $, events) ->
 
   # Converts content (provided to `ElementWrapper.update()` or `append()`) into an appropriate type. This
   # primarily exists to validate the value, and to "unpack" an ElementWrapper into a DOM element.
@@ -123,12 +122,16 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     hide: ->
       @$.hide()
 
+      triggerReflow()
+
       return this
 
     # Displays the wrapped element if hidden.
     show: ->
       @$.show()
 
+      triggerReflow()
+
       return this
 
     # Removes the wrapped element from the DOM.  It can later be re-attached.
@@ -136,6 +139,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
       # jQuery's remove() will remove event handlers which we don't want.
       @$.detach()
 
+      triggerReflow()
+
       return this
 
     # Reads or updates an attribute. With one argument, returns the current value
@@ -189,18 +194,24 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
       if content
         @$.append (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Appends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     append: (content) ->
       @$.append (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Prepends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     prepend: (content) ->
       @$.prepend (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately before
@@ -208,6 +219,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     insertBefore: (content) ->
       @$.before (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately after
@@ -215,6 +228,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     insertAfter: (content) ->
       @$.after (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Runs an animation to fade-in the element over the specified duration.
@@ -222,7 +237,9 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # * duration - animation duration time, in seconds
     # * callback - function invoked after the animation is complete
     fadeIn: (duration, callback) ->
-      @$.fadeIn duration * 1000, callback
+      @$.fadeIn duration * 1000, ->
+        triggerReflow()
+        callback and callback()
 
       return this
 
@@ -232,7 +249,9 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # * duration - animation duration time, in seconds
     # * callback - function invoked after the animation is complete
     fadeOut: (duration, callback) ->
-      @$.fadeOut duration * 1000, callback
+      @$.fadeOut duration * 1000, ->
+        triggerReflow()
+        callback and callback()
 
       return this
 
@@ -437,6 +456,7 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
 
     return exports
 
+  triggerReflow = _.debounce (-> $(document).trigger events.document.reflow), 250
 
   # The main export is a function that wraps a DOM element as an ElementWrapper; additional functions are attached as
   # properties.
@@ -462,6 +482,8 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # Escape's HTML markup in the string.
     escapeHTML: _.escape
 
+    triggerReflow: triggerReflow
+
     ajaxRequest: ajaxRequest
 
     # Used to add an event handler to an element (possibly from elements below it in the hierarch).
@@ -492,3 +514,7 @@ define ["underscore", "./utils", "jquery"], (_, utils, $) ->
     # inside a block at the end of the document, inside the `<body`> element, it is assumed that
     # it is always safe to get the body.
     body: -> wrapElement document.body
+
+  $(window).on "resize", exports.triggerReflow
+
+  return exports
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/c18e1199/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
index ccabd1b..85d1f97 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/t5-core-dom-prototype.coffee
@@ -31,7 +31,7 @@
 # the abstract layer and gain the valuable benefit of not caring about the infrastructure framework.
 #
 # Changes to this library should be coordinated with the jQuery version.
-define ["underscore", "./utils", "prototype"], (_, utils) ->
+define ["underscore", "./utils", "./events", "prototype"], (_, utils, events) ->
 
   # 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
@@ -77,6 +77,7 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
         styles[styleName] = finalValue
         element.setStyle styles
         window.clearInterval timeoutID
+        triggerReflow()
         callbacks.oncomplete and callbacks.oncomplete()
 
       # TODO: Add an easein/easeout function
@@ -164,18 +165,24 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     hide: ->
       @element.hide()
 
+      triggerReflow()
+
       return this
 
     # Displays the wrapped element if hidden.
     show: ->
       @element.show()
 
+      triggerReflow()
+
       return this
 
     # Removes the wrapped element from the DOM.  It can later be re-attached.
     remove: ->
       @element.remove()
 
+      triggerReflow()
+
       return this
 
     # Reads or updates an attribute. With one argument, returns the current value
@@ -227,18 +234,24 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     update: (content) ->
       @element.update (content and convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Appends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     append: (content) ->
       @element.insert bottom: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Prepends new content (Element, ElementWrapper, or HTML markup string) to the body of the element.
     prepend: (content) ->
       @element.insert top: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately before
@@ -246,6 +259,8 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     insertBefore: (content) ->
       @element.insert before: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately after
@@ -253,6 +268,8 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     insertAfter: (content) ->
       @element.insert after: (convertContent content)
 
+      triggerReflow()
+
       return this
 
     # Runs an animation to fade-in the element over the specified duration. The element may be hidden (via `hide()`)
@@ -508,7 +525,6 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
 
     return exports
 
-
   # The main export is a function that wraps a DOM element as an ElementWrapper; additional functions are attached as
   # properties.
   #
@@ -526,12 +542,16 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     # Prototype API (especially with respect to events).
     new ElementWrapper element
 
+  triggerReflow = _.debounce (-> $(document).fire events.document.reflow), 250
+
   _.extend exports,
     wrap: wrapElement
 
     # Escape's HTML markup in the string.
     escapeHTML: (str) -> str.escapeHTML()
 
+    triggerReflow: triggerReflow
+
     ajaxRequest: ajaxRequest
 
     # Used to add an event handler to an element (possibly from elements below it in the hierarch).
@@ -564,3 +584,7 @@ define ["underscore", "./utils", "prototype"], (_, utils) ->
     # inside a block at the end of the document, inside the `<body`> element, it is assumed that
     # it is always safe to get the body.
     body: -> wrapElement document.body
+
+  Event.observe window, "resize", triggerReflow
+
+  return exports
\ No newline at end of file