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 20:22:11 UTC
[3/3] git commit: Fix problems with jQuery t5/core/dom implementation
Adjust CSS selectors: some attribute selectors needed more quoting for jQuery
than Prototype
Updated Branches:
refs/heads/master d71c481c3 -> 108db6b77
Fix problems with jQuery t5/core/dom implementation
Adjust CSS selectors: some attribute selectors needed more quoting for jQuery than Prototype
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/108db6b7
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/108db6b7
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/108db6b7
Branch: refs/heads/master
Commit: 108db6b77a3c94506071c134780354363b45fd9b
Parents: ce6fe84
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Wed Jan 2 11:12:15 2013 -0800
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Wed Jan 2 11:12:15 2013 -0800
----------------------------------------------------------------------
.../META-INF/modules/t5/core/ajaxformloop.coffee | 4 +-
.../META-INF/modules/t5/core/builder.coffee | 4 +-
.../META-INF/modules/t5/core/datefield.coffee | 2 +-
.../META-INF/modules/t5/core/fields.coffee | 2 +-
.../META-INF/modules/t5/core/form-fragment.coffee | 6 ++--
.../META-INF/modules/t5/core/forms.coffee | 9 +++---
.../META-INF/modules/t5/core/tree.coffee | 4 +-
.../META-INF/modules/t5/core/utils.coffee | 3 +-
.../org/apache/tapestry5/t5-core-dom-jquery.coffee | 22 +++++++-------
9 files changed, 29 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/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 45e7552..830521a 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
@@ -20,7 +20,7 @@ define ["./dom", "./events", "./console", "./ajax", "./builder"],
(dom, events, console, ajax, builder) ->
# "afl" is short for "AjaxFormLoop".
- AFL_SELECTOR = "[data-container-type=core/AjaxFormLoop]"
+ AFL_SELECTOR = "[data-container-type='core/AjaxFormLoop']"
FRAGMENT_TYPE = "core/ajaxformloop-fragment"
dom.onDocument "click", "#{AFL_SELECTOR} [data-afl-behavior=remove]", ->
@@ -40,7 +40,7 @@ define ["./dom", "./events", "./console", "./ajax", "./builder"],
# The server has removed the row from persistent storage, lets
# do the same on the UI.
- fragment = this.findParent "[data-container-type=#{FRAGMENT_TYPE}]"
+ fragment = this.findParent "[data-container-type='#{FRAGMENT_TYPE}']"
# TODO: Fire some before & after events, to allow for animation.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/builder.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/builder.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/builder.coffee
index 5868751..b50df36 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/builder.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/builder.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.
@@ -75,7 +75,7 @@ define ["_", "./dom", "./utils"], (_, dom, utils) ->
if name is "on"
for eventName, handler of value
wrapper.on eventName, handler
- else if name.startsWith "on"
+ else if (utils.startsWith name, "on")
wrapper.on (name.substring 2), value
else
wrapper.attribute name, value
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/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 82ad70d..44678d5 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
@@ -147,7 +147,7 @@ define ["./dom", "./events", "./messages", "./builder", "./ajax",
scan = (root) ->
- for container in root.find "[data-component-type=core/DateField]"
+ for container in root.find "[data-component-type='core/DateField']"
# Hide it from later scans
container.attribute "data-component-type", null
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/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 943c81f..3892649 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
@@ -39,7 +39,7 @@ define ["_", "./events", "./dom", "./builder", "./utils", "./forms"],
# When the field has an id (the normal case!), search the body for
# the matching help block.
if fieldId
- block = dom.body().findFirst "[data-error-block-for=#{fieldId}]"
+ block = dom.body().findFirst "[data-error-block-for='#{fieldId}']"
return block if block
else
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee
index bc288a0..0110f3d 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/form-fragment.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.
@@ -18,7 +18,7 @@
define ["_", "./dom", "./events", "./forms"],
(_, dom, events) ->
- SELECTOR = '[data-component-type="core/FormFragment"]'
+ SELECTOR = "[data-component-type='core/FormFragment']"
# This is mostly for compatibility with 5.3, which supported
# a DOM event to ask a fragment to remove itself. This makes less sense since
@@ -37,7 +37,7 @@ define ["_", "./dom", "./events", "./forms"],
fragmentId = frag.attribute "id"
- hidden = frag.findFirst "input[type=hidden][data-for-fragment=#{fragmentId}]"
+ hidden = frag.findFirst "input[type=hidden][data-for-fragment='#{fragmentId}']"
# If found (e.g., not alwaysSubmit), then enable/disable the field.
hidden && hidden.attribute "disabled", not frag.deepVisible()
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/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 51616f9..c0aa661 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
@@ -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.
@@ -49,9 +49,10 @@ define ["./events", "./dom", "./builder", "_"],
# TODO: Research why we need id and name and get rid of one if possible.
name = if isCancel then "cancel" else submitter.element.name
- value = Object.toJSON [ submitter.element.id, name ]
-
- hidden.value value
+ # Not going to drag in all of json2 just for this one purpose, but even
+ # so, I'd like to get rid of this. Prototype includes Object.toJSON(), but jQuery
+ # is curiously absent an equivalent.
+ hidden.value "[\"#{submitter.element.id}\",\"#{name}\"]"
return
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/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 a8d42a2..2f58f9e 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
@@ -14,10 +14,10 @@
# ## t5/core/tree
#
-# Handlers to support to the core/Tree Tapestry component
+# Handlers to support to the core/Tree Tapestry component.
define ["./dom", "./ajax", "./zone"],
(dom, ajax) ->
- TREE = "[data-component-type=core/Tree]"
+ TREE = "[data-component-type='core/Tree']"
NODE_ID = "data-node-id"
SELECTOR = "#{TREE} [#{NODE_ID}]"
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee
index 443792d..5f4ab26 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.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.
@@ -24,6 +24,7 @@ define ["_"], (_) ->
input.replace(/^\s+/, '').replace(/\s+$/, '')
exports =
+ startsWith: (string, pattern) -> (string.lastIndexOf pattern) is 0
# Trims leading and trailing whitespace from a string. Delegates to String.prototype.trim if present.
trim: trim
# Determines if the input is a blank string, or null, or an empty array.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/108db6b7/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 a5c66e0..2b346c6 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
@@ -177,17 +177,17 @@ define ["_", "./utils", "jquery"], (_, utils, $) ->
# Adds the class name to the element.
addClass: (name) ->
- @element.addClass name
+ @$.addClass name
return this
# Updates this element with new content, replacing any old content. The new content may be HTML text, or a DOM
- # element, or null (to remove the body of the element).
+ # element, or an ElementWrapper, or null (to remove the body of the element).
update: (content) ->
@$.empty()
if content
- @$.update (convertContent content)
+ @$.append (convertContent content)
return this
@@ -206,14 +206,14 @@ define ["_", "./utils", "jquery"], (_, utils, $) ->
# Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately before
# this ElementWrapper's element.
insertBefore: (content) ->
- @$.insertBefore (convertContent content)
+ @$.before (convertContent content)
return this
# Inserts new content (Element, ElementWrapper, or HTML markup string) into the DOM immediately after
# this ElementWrapper's element.
insertAfter: (content) ->
- @$.insertAfter (convertContent content)
+ @$.after (convertContent content)
return this
@@ -252,13 +252,13 @@ define ["_", "./utils", "jquery"], (_, utils, $) ->
find: (selector) ->
matches = @$.find selector
- for i in [0..matches.length]
+ for i in [0..(matches.length - 1)]
new ElementWrapper matches.eq i
# Find the first container element that matches the selector (wrapped as an ElementWrapper),
# or returns null.
- findContainer: (selector) ->
- parents = @element.parents selector
+ findParent: (selector) ->
+ parents = @$.parents selector
return null unless parents.length
@@ -326,7 +326,7 @@ define ["_", "./utils", "jquery"], (_, utils, $) ->
current = @$.val()
if arguments.length > 0
- @element.val newValue
+ @$.val newValue
return current
@@ -398,13 +398,13 @@ define ["_", "./utils", "jquery"], (_, utils, $) ->
# jQuery doesn't have the equivalent of Protoype's onException
error: (jqXHR, textStatus, errorThrown) ->
message = "Request to #{url} failed with status #{textStatus}"
- text = response.statusText
+ text = jqXHR.statusText
if not _.isEmpty text
message += " -- #{text}"
message += "."
if options.failure
- options.failure (new ResponseWrapper response), message
+ options.failure (new ResponseWrapper jqXHR), message
else
throw new Error message