You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2013/01/02 03:15:30 UTC
[6/8] git commit: Rename some of the t5/core/dom module's API: -
container() to parent() - findContainer() to findParent() - ajaxRequest
options "onexception", "onfailure", "onsuccess" to "exception", "failure",
"success"
Rename some of the t5/core/dom module's API:
- container() to parent()
- findContainer() to findParent()
- ajaxRequest options "onexception", "onfailure", "onsuccess" to "exception", "failure", "success"
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/19ce7295
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/19ce7295
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/19ce7295
Branch: refs/heads/master
Commit: 19ce7295f91630aa9ca42041ecc3aac22b37642a
Parents: 246428b
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Jan 1 16:49:58 2013 -0800
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Jan 1 16:49:58 2013 -0800
----------------------------------------------------------------------
.../modules/t5/beanvalidator/validation.coffee | 2 +-
.../META-INF/modules/t5/core/ajax.coffee | 16 +++---
.../META-INF/modules/t5/core/ajaxformloop.coffee | 12 ++--
.../META-INF/modules/t5/core/alert.coffee | 6 +-
.../META-INF/modules/t5/core/autocomplete.coffee | 2 +-
.../META-INF/modules/t5/core/datefield.coffee | 6 +-
.../META-INF/modules/t5/core/fields.coffee | 8 ++--
.../META-INF/modules/t5/core/forms.coffee | 2 +-
.../META-INF/modules/t5/core/grid.coffee | 2 +-
.../META-INF/modules/t5/core/palette.coffee | 2 +-
.../META-INF/modules/t5/core/tree.coffee | 12 ++--
.../META-INF/modules/t5/core/zone.coffee | 4 +-
.../apache/tapestry5/t5-core-dom-prototype.coffee | 40 +++++++-------
13 files changed, 57 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/validation.coffee
----------------------------------------------------------------------
diff --git a/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/validation.coffee b/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/validation.coffee
index daa7726..7f7efa1 100644
--- a/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/validation.coffee
+++ b/tapestry-beanvalidator/src/main/coffeescript/META-INF/modules/t5/beanvalidator/validation.coffee
@@ -29,7 +29,7 @@ define ["_", "t5/core/dom", "t5/core/events", "t5/core/utils", "t5/core/validati
# A select that is used as part of a palette is different; the validation attributes
# are attached to the selected (right side) <select>, and anything there counts as part
# of the selection.
- if e.findContainer ".t-palette"
+ if e.findParent ".t-palette"
e.element.options.length
else
# An ordinary <select> may have multiple options (the clumsy control-click way)
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee
index 1df9506..12238a0 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee
@@ -17,7 +17,7 @@
# Exports a single function, that invokes `t5/core/dom:ajaxRequest()` with the provided `url` and a modified version of the
# `options`.
#
-# It wraps (or provides) `onsuccess`, `onexception`, and `onfailure` handlers, extended to handle a partial page render
+# It wraps (or provides) `success`, `exception`, and `failure` handlers, extended to handle a partial page render
# response (for success), or properly log a server-side failure or client-side exception, including using the
# `t5/core/exceptionframe` module to display a server-side processing exception.
define ["./pageinit", "./dom", "./exceptionframe", "./console", "_"],
@@ -27,15 +27,15 @@ define ["./pageinit", "./dom", "./exceptionframe", "./console", "_"],
# Logs the exception to the console before passing it to the
# provided exception handler or throwing the exception.
- onexception: (exception) ->
+ exception: (exception) ->
console.error "Request to #{url} failed with #{exception}"
- if options.onexception
- options.onexception exception
+ if options.exception
+ options.exception exception
else
throw exception
- onfailure: (response, failureMessage) ->
+ failure: (response, failureMessage) ->
raw = response.header "X-Tapestry-ErrorMessage"
unless _.isEmpty raw
message = window.unescape raw
@@ -50,11 +50,11 @@ define ["./pageinit", "./dom", "./exceptionframe", "./console", "_"],
else
console.error failureMessage
- options.onfailure and options.onfailure(response)
+ options.failure and options.failure(response)
return null
- onsuccess: (response) ->
- pageinit.handlePartialPageRenderResponse response, options.onsuccess
+ success: (response) ->
+ pageinit.handlePartialPageRenderResponse response, options.success
dom.ajaxRequest url, newOptions
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
index 01b8562..45e7552 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
@@ -25,7 +25,7 @@ define ["./dom", "./events", "./console", "./ajax", "./builder"],
dom.onDocument "click", "#{AFL_SELECTOR} [data-afl-behavior=remove]", ->
- afl = this.findContainer AFL_SELECTOR
+ afl = this.findParent AFL_SELECTOR
unless afl
console.error "Enclosing element for AjaxFormLoop remove row link not found."
@@ -36,11 +36,11 @@ define ["./dom", "./events", "./console", "./ajax", "./builder"],
ajax url,
parameters:
"t:rowvalue": this.attribute "data-afl-row-value"
- onsuccess: =>
+ success: =>
# The server has removed the row from persistent storage, lets
# do the same on the UI.
- fragment = this.findContainer "[data-container-type=#{FRAGMENT_TYPE}]"
+ fragment = this.findParent "[data-container-type=#{FRAGMENT_TYPE}]"
# TODO: Fire some before & after events, to allow for animation.
@@ -52,14 +52,14 @@ define ["./dom", "./events", "./console", "./ajax", "./builder"],
dom.onDocument "click", "#{AFL_SELECTOR} [data-afl-behavior=insert-before] [data-afl-trigger=add]", ->
- afl = this.findContainer AFL_SELECTOR
+ afl = this.findParent AFL_SELECTOR
- insertionPoint = this.findContainer "[data-afl-behavior=insert-before]"
+ insertionPoint = this.findParent "[data-afl-behavior=insert-before]"
url = afl.attribute "data-inject-row-url"
ajax url,
- onsuccess: (response) =>
+ success: (response) =>
content = response.json?.content
# Create a new element with the same type (usually "div") and class as this element.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee
index fa992ed..a2810e3 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee
@@ -42,12 +42,12 @@ define ["./dom", "./console", "./messages", "./builder", "./ajax", "_"],
return
ajax (getURL container),
- onsuccess: -> container.update null
+ success: -> container.update null
dismissOne = (container, button) ->
console.debug "dismiss single"
- alert = button.container()
+ alert = button.parent()
id = alert.attribute "data-alert-id"
@@ -57,7 +57,7 @@ define ["./dom", "./console", "./messages", "./builder", "./ajax", "_"],
ajax (getURL container),
parameters: { id }
- onsuccess: -> removeAlert container, alert
+ success: -> removeAlert container, alert
setupUI = (container) ->
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee
index c2ba58c..590a055 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee
@@ -24,7 +24,7 @@ define ["./dom", "./ajax", "jquery", "bootstrap"],
ajax url,
parameters:
"t:input": query
- onsuccess: (response) ->
+ success: (response) ->
$field.removeClass "ajax-wait"
process response.json.matches
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee
index ce3d48b..82ad70d 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee
@@ -89,7 +89,7 @@ define ["./dom", "./events", "./messages", "./builder", "./ajax",
@field.removeClass "ajax-wait"
@fieldError message
- onsuccess: (response) =>
+ success: (response) =>
@field.removeClass "ajax-wait"
reply = response.json
@@ -136,10 +136,10 @@ define ["./dom", "./events", "./messages", "./builder", "./ajax",
ajax (@container.attribute "data-format-url"),
parameters:
input: date.getTime()
- onfailure: (response, message) =>
+ failure: (response, message) =>
@field.removeClass "ajax-wait"
@fieldError message
- onsuccess: (response) =>
+ success: (response) =>
@field.removeClass "ajax-wait"
@clearFieldError()
@field.value response.json.result
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee
index a17c631..943c81f 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/fields.coffee
@@ -50,7 +50,7 @@ define ["_", "./events", "./dom", "./builder", "./utils", "./forms"],
# Not found by id, but see if an empty placeholder was provided within
# the same .controls or .control-group.
- group = field.findContainer ".controls, .control-group"
+ group = field.findParent ".controls, .control-group"
return null unless group
@@ -74,7 +74,7 @@ define ["_", "./events", "./dom", "./builder", "./utils", "./forms"],
# No containing group ... this is a problem, probably an old 5.3 application upgraded to 5.4
# or beyond. Place the block just after the field.
- container = field.container()
+ container = field.parent()
block = builder "p.help-block", "data-error-block-for": fieldId
@@ -154,7 +154,7 @@ define ["_", "./events", "./dom", "./builder", "./utils", "./forms"],
if block
block.hide().update("")
- group = this.findContainer ".control-group"
+ group = this.findParent ".control-group"
group and group.removeClass "error"
@@ -168,7 +168,7 @@ define ["_", "./events", "./dom", "./builder", "./utils", "./forms"],
block.show().update(memo.message)
- group = this.findContainer ".control-group"
+ group = this.findParent ".control-group"
group and group.addClass "error"
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
index ba04774..51616f9 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/forms.coffee
@@ -139,7 +139,7 @@ define ["./events", "./dom", "./builder", "_"],
# Support for link submits. `data-submit-mode` will be non-null, possibly "cancel".
# Update the hidden field, but also cancel the default behavior for the click.
dom.onDocument "click", "a[data-submit-mode]", ->
- form = this.findContainer "form"
+ form = this.findParent "form"
unless form
console.error "Submitting link element not contained inside a form element."
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/grid.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/grid.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/grid.coffee
index 5dd02da..d4ac2de 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/grid.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/grid.coffee
@@ -25,7 +25,7 @@ define ["./dom", "./events", "./console"],
dom.onDocument "[data-inplace-grid-links] a", ->
- zone = this.findContainer "[data-container-type=zone]"
+ zone = this.findParent "[data-container-type=zone]"
unless zone
console.error "Unable to find containing zone for live update of grid."
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
index a4e4174..fbf0722 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/palette.coffee
@@ -21,7 +21,7 @@ define ["./dom", "_"],
constructor: (id) ->
@selected = (dom id)
- @container = @selected.findContainer ".t-palette"
+ @container = @selected.findParent ".t-palette"
@available = @container.findFirst ".t-palette-available select"
@hidden = @container.findFirst "input[type=hidden]"
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee
index 626c6bf..a8d42a2 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee
@@ -26,15 +26,15 @@ define ["./dom", "./ajax", "./zone"],
EXPANDED = "t-tree-expanded"
SELECTED = "t-selected-leaf-node"
- send = (node, action, onsuccess) ->
- container = node.findContainer TREE
+ send = (node, action, success) ->
+ container = node.findParent TREE
url = container.attribute "data-tree-action-url"
ajax url,
parameters:
"t:action": action
"t:nodeid": node.attribute NODE_ID
- onsuccess: onsuccess
+ success: success
loadChildren = (node) ->
@@ -51,7 +51,7 @@ define ["./dom", "./ajax", "./zone"],
# icon instead of a "+" icon)
node.update("").addClass(EXPANDED).removeClass("t-empty-node")
- label = node.findContainer("li").findFirst(".t-tree-label")
+ label = node.findParent("li").findFirst(".t-tree-label")
label.insertAfter response.json.content
@@ -59,7 +59,7 @@ define ["./dom", "./ajax", "./zone"],
node.meta LOADED, true
toggle = (node) ->
- sublist = node.findContainer("li").findFirst("ul")
+ sublist = node.findParent("li").findFirst("ul")
if node.hasClass EXPANDED
node.removeClass EXPANDED
@@ -91,7 +91,7 @@ define ["./dom", "./ajax", "./zone"],
selected = this.hasClass SELECTED
- node = this.findContainer("li").findFirst("[#{NODE_ID}]")
+ node = this.findParent("li").findFirst("[#{NODE_ID}]")
if selected
this.removeClass SELECTED
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/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 770c4a9..088ad6e 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
@@ -35,7 +35,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "_"],
zoneId = element.attribute "data-update-zone"
if zoneId is "^"
- zone = element.findContainer "[data-container-type=zone]"
+ zone = element.findParent "[data-container-type=zone]"
if zone is null
console.error "Unable to locate containing zone for #{element}."
@@ -97,7 +97,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "_"],
ajax event.memo.url,
parameters: _.extend { "t:zoneid": this.element.id }, parameters, event.memo.parameters
- onsuccess: (response) =>
+ success: (response) =>
this.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),
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/19ce7295/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 36bbec2..bad644a 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
@@ -299,22 +299,22 @@ define ["_", "./utils", "prototype"], (_, utils) ->
# Find the first container element that matches the selector (wrapped as an ElementWrapper),
# or returns null.
- findContainer: (selector) ->
- container = @element.up selector
+ findParent: (selector) ->
+ parent = @element.up selector
- if container
- return new ElementWrapper container
- else
- return null
+ return null unless parent
- # Returns an ElementWrapper for this element's containing element.
+ new ElementWrapper parent
+
+ # 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).
- container: ->
- parentNode = @element.parentNode
- return null unless parentNode
+ parent: ->
+ parent = @element.parentNode
+
+ return null unless parent
- new ElementWrapper(parentNode)
+ new ElementWrapper parent
# Returns true if this element is visible, false otherwise. This does not check to see if all containers of the
# element are visible.
@@ -328,7 +328,7 @@ define ["_", "./utils", "prototype"], (_, utils) ->
cursor = this
while cursor
return false unless cursor.visible()
- cursor = cursor.container()
+ cursor = cursor.parent()
return true if cursor and cursor.element is document.body
@@ -440,11 +440,11 @@ define ["_", "./utils", "prototype"], (_, utils) ->
# Adds a "_method" parameter and uses "post" to handle "delete", etc.
# * options.contentType - default "context "application/x-www-form-urlencoded"
# * options.parameters - optional, additional key/value pairs
- # * options.onsuccess - handler to invoke on success, passed the ResponseWrapper
+ # * options.success - handler to invoke on success, passed the ResponseWrapper
# Default does nothing.
- # * options.onfailure - handler to invoke on failure (server responds with a non-2xx code),
+ # * options.failure - handler to invoke on failure (server responds with a non-2xx code),
# Passed the ResponseWrapper and an error message. Defaults throws an Error.
- # * options.onexception - handler to invoke when an exception occurs (often means the server is unavailable).
+ # * options.exception - handler to invoke when an exception occurs (often means the server is unavailable).
# Passed the exception. Default re-throws the underlying exception.
#
# Returns the module's exports
@@ -454,8 +454,8 @@ define ["_", "./utils", "prototype"], (_, utils) ->
contentType: options.contentType or "application/x-www-form-urlencoded"
parameters: options.parameters or {}
onException: (ajaxRequest, exception) ->
- if options.onexception
- options.onexception exception
+ if options.exception
+ options.exception exception
else
throw exception
@@ -468,8 +468,8 @@ define ["_", "./utils", "prototype"], (_, utils) ->
message += " -- #{text}"
message += "."
- if options.onfailure
- options.onfailure (new ResponseWrapper response), message
+ if options.failure
+ options.failure (new ResponseWrapper response), message
else
throw new Error message
@@ -485,7 +485,7 @@ define ["_", "./utils", "prototype"], (_, utils) ->
# Tapestry 5.3 includes lots more exception catching ... that just got in the way
# of identifying the source of problems. That's been stripped out.
- options.onsuccess and options.onsuccess(new ResponseWrapper response)
+ options.success and options.success(new ResponseWrapper response)
return
new Ajax.Request(url, finalOptions)