Changeset 89 for trunk/grails-app/taglib


Ignore:
Timestamp:
Jan 14, 2010, 5:44:28 PM (11 years ago)
Author:
duh
Message:
  • refactored some wizard code
  • templatizing and standardizing form elements into tag libraries
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r88 r89  
    2020  // define the AJAX provider to use
    2121  static ajaxProvider = "jquery"
     22
     23  // define default text field width
     24  static defaultTextFieldSize = 25;
    2225 
    2326  /**
     
    3235   * @todo  perhaps some methods should be moved to a more generic
    3336   *        'webflow' taglib
    34    * @param map     attributes
    35    * @param string body
     37   * @param Map     attributes
     38   * @param Closure body
    3639   */
    3740  def ajaxButton = { attrs, body ->
     
    7679  }
    7780
     81  /**
     82   * render the content of a particular wizard page
     83   * @param Map     attrs
     84   * @param Closure body
     85   */
    7886  def pageContent = { attrs, body ->
    7987    // define AJAX provider
     
    8795    out << render(template:"/wizard/common/navigation")
    8896  }
     97
     98  def textFieldElement = { attrs, body ->
     99    // set default size, or scale to max length if it is less than the default size
     100    if (!attrs.get("size")) {
     101      if (attrs.get("maxlength")) {
     102        attrs.size = ((attrs.get("maxlength") as int) > defaultTextFieldSize) ? defaultTextFieldSize : attrs.get("maxlength")
     103      } else {
     104        attrs.size = defaultTextFieldSize
     105      }
     106    }
     107
     108    // render a text element
     109    out << '<div class="element">'
     110    out << ' <div class="description">'
     111    out << body()
     112    out << ' </div>'
     113    out << ' <div class="input">'
     114    out << textField(attrs)
     115    out << ' </div>'
     116
     117    // add help icon?
     118    if (attrs.get('help')) {
     119      out << ' <div class="help"><img src="../images/icons/famfamfam/help.png"></div>'
     120    }
     121   
     122    out << '</div>'
     123  }
    89124}
Note: See TracChangeset for help on using the changeset viewer.