Changeset 89


Ignore:
Timestamp:
Jan 14, 2010, 5:44:28 PM (8 years ago)
Author:
duh
Message:
  • refactored some wizard code
  • templatizing and standardizing form elements into tag libraries
Location:
trunk
Files:
3 added
4 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}
  • trunk/grails-app/views/common/_topnav.gsp

    r63 r89  
    22    <!-- TOPNAV //-->
    33    <ul class="topnav">
    4       <li><g:link url="/${meta(name: 'app.name')}/">Home</g:link></li>
    5     <li><g:link controller="load" action="index">Loading data</g:link></li>
    6       <li><g:link controller="query" action="index">Query database</g:link></li>
     4     <li><g:link url="/${meta(name: 'app.name')}/">Home</g:link></li>
     5     <li>
     6      <a href="#">Studies</a>
     7      <ul class="subnav">
     8        <li><a href="#">View Studies</a></li>
     9        <li><g:link controller="wizard" action="index">Create Study</g:link></li>
     10      </ul>
     11     </li>
     12     <li><g:link controller="load" action="index">Loading data</g:link></li>
     13     <li><g:link controller="query" action="index">Query database</g:link></li>
    714<n:isLoggedIn>
    8       <li><g:link controller="study" action="list">My studies</g:link></li>
     15     <li><g:link controller="study" action="list">My studies</g:link></li>
    916</n:isLoggedIn>
    10       <li>
    11         <a href="#">Scaffolded controllers</a>
    12         <ul class="subnav"><g:each var="c" in="${grailsApplication.controllerClasses}">
    13           <li><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li></g:each>
    14         </ul>
    15       </li>
     17     <li>
     18          <a href="#">Scaffolded controllers</a>
     19          <ul class="subnav"><g:each var="c" in="${grailsApplication.controllerClasses}">
     20           <li><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li></g:each>
     21          </ul>
     22     </li>
    1623<n:isAdministrator>
    17       <li>
    18         <a href="#">User administation</a>
    19         <ul class="subnav">
    20           <li><g:link controller="admins" action="index" class="icon icon_user_suit">Manage Administrators</g:link></li>
    21           <li><g:link controller="user" action="list" class="icon icon_user">List Users</g:link></li>
    22           <li><g:link controller="user" action="create" class="icon icon_user_add">Create User</g:link></li>
    23           <li><g:link controller="role" action="list" class="icon icon_cog">List Roles</g:link></li>
    24           <li><g:link controller="role" action="create" class="icon icon_cog_add">Create Role</g:link></li>
    25           <li><g:link controller="group" action="list" class="icon icon_group">List Groups</g:link></li>
    26           <li><g:link controller="group" action="create" class="icon icon_group_add">Create Group</g:link></li>
    27           <li><g:link controller="auth" action="logout" class="icon icon_cross">Sign out</g:link></li>
    28         </ul>
    29       </li>
     24     <li>
     25          <a href="#">User administation</a>
     26          <ul class="subnav">
     27            <li><g:link controller="admins" action="index" class="icon icon_user_suit">Manage Administrators</g:link></li>
     28            <li><g:link controller="user" action="list" class="icon icon_user">List Users</g:link></li>
     29            <li><g:link controller="user" action="create" class="icon icon_user_add">Create User</g:link></li>
     30            <li><g:link controller="role" action="list" class="icon icon_cog">List Roles</g:link></li>
     31            <li><g:link controller="role" action="create" class="icon icon_cog_add">Create Role</g:link></li>
     32            <li><g:link controller="group" action="list" class="icon icon_group">List Groups</g:link></li>
     33            <li><g:link controller="group" action="create" class="icon icon_group_add">Create Group</g:link></li>
     34            <li><g:link controller="auth" action="logout" class="icon icon_cross">Sign out</g:link></li>
     35          </ul>
     36     </li>
    3037</n:isAdministrator>
    3138    </ul>
  • trunk/grails-app/views/wizard/pages/_one.gsp

    r88 r89  
    1616%>
    1717<wizard:pageContent>
    18   <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer et elit magna. Maecenas felis tortor, tempus ac condimentum id, cursus ac tellus. Phasellus auctor, ligula vel interdum egestas, tortor justo rutrum ligula, sit amet dictum mi libero a mi. Nam porttitor volutpat nunc in ornare. Cras mi neque, dignissim at vulputate ut, consequat sed eros. Aliquam lobortis lorem nec lorem lobortis in vulputate augue viverra. Nunc mi tellus, elementum id sagittis eu, varius vitae purus. Sed nulla massa, venenatis id tempor nec, consequat suscipit mi. Vivamus erat libero, placerat vitae mollis ut, accumsan vitae augue. Phasellus porta libero quis felis accumsan id congue lectus vestibulum. Etiam aliquam euismod libero, nec feugiat ipsum scelerisque sollicitudin. Duis congue metus quis tellus fermentum cursus. Quisque vel lectus nec felis eleifend blandit. Maecenas sed dolor dolor, eu vulputate quam. Quisque volutpat placerat tortor eget rhoncus.</p>
    19 
    20   <p>Donec non nulla at erat malesuada sollicitudin quis eu arcu. In laoreet placerat justo, quis feugiat purus tempus eu. Sed hendrerit euismod lacinia. Sed fringilla sollicitudin magna nec consectetur. Proin arcu libero, varius ac iaculis in, mattis in arcu. Sed vel odio dui. Nam quis lectus diam, eu dictum urna. Proin molestie, augue ut posuere interdum, orci augue accumsan purus, in aliquet erat tellus nec felis. Vivamus pulvinar, leo in bibendum mattis, libero lacus porttitor nisl, vitae mattis augue sem eget arcu. Sed viverra dui eu eros egestas non malesuada dui venenatis. Sed a neque turpis. Cras vitae erat turpis. Mauris neque nisl, blandit vitae tincidunt in, ultrices sed felis. Quisque interdum urna eu est fringilla id tristique tellus consectetur.</p> 
     18<wizard:textFieldElement name="myZero" value="12" help="some help text" maxlength="4">more than four?</wizard:textFieldElement>
     19<wizard:textFieldElement name="myFirstName" value="my value" help="my help">Please fill in you name bla bla bla</wizard:textFieldElement>
     20<wizard:textFieldElement name="mySecondName" value="1234" size="4">another text field</wizard:textFieldElement>
     21<wizard:textFieldElement name="myThirdName" value="a lotta description" help="so much for help">
     22  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pretium dignissim tellus, id pharetra erat tempus sed. Sed bibendum libero eu lorem pretium nec fermentum ligula faucibus. Morbi gravida interdum ornare. Praesent lectus mi, ullamcorper nec semper nec, vulputate ornare elit. Nam eros metus, egestas a varius eget, facilisis ac purus. Maecenas lectus erat, rutrum id consequat ac, scelerisque ut diam. Donec euismod, tellus facilisis semper elementum, neque lorem volutpat ante, ac consectetur lectus ante sit amet neque. Donec hendrerit, libero quis suscipit iaculis, lacus ligula viverra nibh, eu condimentum diam dui sit amet quam. Praesent turpis orci, laoreet sodales adipiscing eget, ultrices at augue. Nullam sed dolor a velit posuere euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut libero mauris, fermentum id congue sit amet, pharetra in purus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a blandit quam. Cras porta tempus lectus, vel varius lacus vulputate in. Aenean ac nunc lectus, hendrerit tempor elit. Sed ut varius diam.
     23</wizard:textFieldElement>
    2124</wizard:pageContent>
  • trunk/web-app/css/wizard.css

    r88 r89  
    6060    padding-top: 10px;
    6161}
     62
     63.wizard .element {
     64    display: block;
     65}
     66
     67.wizard .element .description {
     68    display: inline-block;
     69    font-size: 11px;
     70    width: 250px;
     71    word-wrap: break-word;
     72}
     73
     74.wizard .element .input {
     75    display: inline;
     76}
     77
     78.wizard .element .input input {
     79    vertical-align: top;
     80    border: 1px solid #CCC;
     81    margin: 2px 0;
     82    padding: 2px 4px;
     83}
     84
     85.wizard .element .input input:focus, select:focus, textarea:focus {
     86    border: 1px solid #B2D1FF;
     87}
     88
     89.wizard .element .help {
     90    vertical-align: top;
     91    display: inline;
     92}
Note: See TracChangeset for help on using the changeset viewer.