tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [21/35] git commit: Update rules for finding and creating help blocks for Bootstrap 3
Date Fri, 23 Aug 2013 01:20:01 GMT
Update rules for finding and creating help blocks for Bootstrap 3


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

Branch: refs/heads/master
Commit: 58b2ec13481f4924f40079ecb0d390b26b47c9a1
Parents: 51664b4
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Thu Aug 22 17:15:38 2013 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Thu Aug 22 17:15:38 2013 -0700

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/events.coffee      |  6 ++---
 .../META-INF/modules/t5/core/fields.coffee      | 27 ++++++++------------
 2 files changed, 13 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/58b2ec13/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 5c9d9c8..684c51c 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
@@ -110,8 +110,8 @@ define
     # The rules for locating the help block:
     #
     # * Search for element with attribute `data-error-block-for` set to the field's `id`
attribute
-    # * If not found, find the enclosing .controls or .control-group element
-    # * Search enclosing element for an element with attribute `data-presentation="error"`
+    # * If not found, find the enclosing .form-group element
+    # * Search the form group for an element with attribute `data-presentation="error"`
     # * Otherwise, it is not found (but may be created dynamically)
     # * If found, set the `data-error-block-for` attribute to the field's `id` (assigning
a unique id to the field
     #   if not already present)
@@ -121,7 +121,7 @@ define
     # * The element is created as `p.help-block` with `data-error-block-for` attribute set
to the
     #   field's id.  The field will be assigned an id if necesary.
     # * Normally, the block is inserted after the field
-    # * If the field's container has class "input-append" or "input-prepend", then the block
is inserted after the container
+    # * If the field's immediate container has class "input-group", then the block is inserted
after the container
     showValidationError: "t5:field:show-validation-error"
 
   # Events triggered by the Palette component.

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/58b2ec13/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 da60ffa..d89a49c 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
@@ -28,7 +28,7 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"],
 
       return fieldId
 
-    # Finds a `p.help-block` used for presenting errors for the provided field.
+    # Finds a `.help-block` used for presenting errors for the provided field.
     # Returns the found block as an ElementWrapper. May modify attributes of the field
     # or the block to make future
     #
@@ -48,22 +48,15 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"],
         fieldId = ensureFieldId field
 
       # Not found by id, but see if an empty placeholder was provided within
-      # the same .controls or .control-group.
+      # the same .control-group.
 
-      group = field.findParent ".controls, .control-group"
+      group = field.findParent ".form-group"
 
       return null unless group
 
       block = group.findFirst "[data-presentation=error]"
 
       if block
-
-        unless fieldId
-          # Assign a unique (hopefully!) client id for the field, which will be
-          # used to link the field and the label together.
-          fieldId = _.uniqueId "field"
-          field.attribute "id", fieldId
-
         block.attribute "data-error-block-for", fieldId
 
       return block
@@ -80,9 +73,9 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"],
         class: "help-block"
         "data-error-block-for": fieldId
 
-      # The .input-append and .input-prepend are used to attach buttons or markers to the
field.
-      # In which case, the block can go
-      if container.hasClass("input-append") or container.hasClass("input-prepend")
+      # The .input-group selectors are used to attach buttons or markers to the field.
+      # In which case, the help block can go after the group instead.
+      if container.hasClass("input-group")
         container.insertAfter block
       else
         field.insertAfter block
@@ -154,9 +147,9 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"],
       if block
         block.hide().update("")
 
-      group = @findParent ".control-group"
+      group = @findParent ".form-group"
 
-      group and group.removeClass "error"
+      group and group.removeClass "has-error"
 
       return
 
@@ -168,8 +161,8 @@ define ["underscore", "./events", "./dom", "./utils", "./forms"],
 
       block.show().update(memo.message)
 
-      group = @findParent ".control-group"
+      group = @findParent ".form-group"
 
-      group and group.addClass "error"
+      group and group.addClass "has-error"
 
     exports = {findHelpBlock, createHelpBlock, showValidationError}
\ No newline at end of file


Mime
View raw message