Rename the few data- attributes to not be simply data-, not data-t5- Document the currently in use data- attributes
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/3673ff66 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/3673ff66 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/3673ff66 Branch: refs/heads/5.4-js-rewrite Commit: 3673ff666f96ca6568301058d7e8fa009a633cf0 Parents: 872d0a5 Author: Howard M. Lewis Ship <[email protected]> Authored: Fri Aug 17 15:22:47 2012 -0700 Committer: Howard M. Lewis Ship <[email protected]> Committed: Fri Aug 17 15:22:47 2012 -0700 ---------------------------------------------------------------------- 54_RELEASE_NOTES.txt | 13 +++++++++++++ .../META-INF/modules/core/events.coffee | 4 ++-- .../META-INF/modules/core/forms.coffee | 8 ++++---- .../resources/org/apache/tapestry5/tapestry.js | 6 +++--- 4 files changed, 22 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3673ff66/54_RELEASE_NOTES.txt ---------------------------------------------------------------------- diff --git a/54_RELEASE_NOTES.txt b/54_RELEASE_NOTES.txt index bbd7ab5..1263802 100644 --- a/54_RELEASE_NOTES.txt +++ b/54_RELEASE_NOTES.txt @@ -38,6 +38,19 @@ have had their values changed (for consistency with the new set of events define that uses literal values (such as "tapestry:formprepareforsubmit") will break; code that correctly used the constants will continue to work, even though the names have changed. +Tapestry is moving away from "magic class names" to a more uniform approach based on the use of HTML 5 compliant "data-" +attributes. + +* data-prevent-submission: Used on a HTML form to indicate that normal submission should be suppressed; typically because + client-side code will be submitting the form's contents via an Ajax request. + +* data-skip-validation: Used on an HTML form; the immediately subsequent form submission will skip all validation. + This is often associated with buttons that cause a form to be canceled or otherwise submitted without client-side + validation. + +* data-validation: Used on form control elements; a non-null value indicates that the field should have the + `events.field.validate` event triggered on it, when the form is validating, prior to submission. + # Breaking Changes: The definition of the symbol 'tapestry.asset-path-prefix' has changed; it no longer includes the leading and trailing http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3673ff66/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee index 0edea76..d773f39 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee @@ -33,13 +33,13 @@ define # Triggered last, when the form is configured to not submit normally (as a standard POST). Under 5.3, this # configuration was achieved by adding the `t-prevent-submission` CSS class; under 5.4 it is preferred to - # set the `data-t5-prevent-submission` attribute. In either case, the submit event is stopped, and this + # set the `data-prevent-submission` attribute. In either case, the submit event is stopped, and this # event fired to replace it; in most cases, a handler will then handle submitting the form's data as part # of an Ajax request. processSubmit: "t5:form:process-submit" field: - # Triggered by the Form on all enclosed elements with the `data-t5-validation` attribute (indicating they are + # Triggered by the Form on all enclosed elements with the `data-validation` attribute (indicating they are # interested in participating with user input validation). The memo object passed to the event has an error property # that can be set to true to indicate a validation error. Individual fields should determine if the field is in # error and remove or add/update decorations for the validation error (decorations will transition from 5.3 style http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3673ff66/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee index 5996dfd..86d4d04 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/forms.coffee @@ -19,11 +19,11 @@ define ["core/events", "core/spi", "core/builder", "core/compat/tapestry"], (events, spi, builder) -> - SKIP_VALIDATION = "data-t5-skip-validation" + SKIP_VALIDATION = "data-skip-validation" isPreventSubmission = (element) -> (element.hasClass Tapestry.PREVENT_SUBMISSION) or - (element.getAttribute "data-t5-prevent-submission") + (element.getAttribute "data-prevent-submission") clearSubmittingHidden = (form) -> hidden = form.find "[name=t:submit]" @@ -47,14 +47,14 @@ define ["core/events", "core/spi", "core/builder", "core/compat/tapestry"], defaultValidateAndSubmit = (event) -> - if ((this.getAttribute "data-t5-validate") is "submit") and + if ((this.getAttribute "data-validate") is "submit") and (not this.getAttribute SKIP_VALIDATION) this.removeAttribute SKIP_VALIDATION memo = error: false - for field in this.findAll "[data-t5-validation]" + for field in this.findAll "[data-validation]" field.trigger events.field.validate, memo # Only do form validation if all individual field validation http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3673ff66/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js index 27211eb..92eeada 100644 --- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js +++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js @@ -106,9 +106,9 @@ define("core/compat/tapestry", [ * CSS Class added to a <form> element that directs Tapestry to * prevent normal (HTTP POST) form submission, in favor of Ajax * (XmlHttpRequest) submission. This is still supported in Tapestry 5.4, but - * replaced with the data-t5-prevent-submission attribute. + * replaced with the data-prevent-submission attribute. * - * @deprecated Use data-t5-prevent-submission="true" instead + * @deprecated Use data-prevent-submission="true" instead */ PREVENT_SUBMISSION: "t-prevent-submission", @@ -1238,7 +1238,7 @@ define("core/compat/tapestry", [ // This marker clues in the Form that validation should be triggered on this // element. - this.field.writeAttribute("data-t5-validation", true); + this.field.writeAttribute("data-validation", true); var _this = this;
