Ignore:
Timestamp:
Jan 28, 2010, 5:34:50 PM (14 years ago)
Author:
duh
Message:
  • wizard subjects page now build a table with features, does not work properly yet
  • youtube autoplay help items are possible now
  • development grouping page for selecting subjects and grouping them by dragging and dropping
File:
1 edited

Legend:

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

    r140 r145  
    176176
    177177        /**
     178         * generate a base form element
     179         * @param String        inputElement name
     180         * @param Map           attributes
     181         * @param Closure       help content
     182         */
     183        def baseElement = { inputElement, attrs, help ->
     184                // work variables
     185                def description = attrs.remove('description')
     186                def addExampleElement = attrs.remove('addExampleElement')
     187
     188                // render a form element
     189                out << '<div class="element">'
     190                out << ' <div class="description">'
     191                out << description
     192                out << ' </div>'
     193                out << ' <div class="input">'
     194                out << "$inputElement"(attrs)
     195                if(help()) {
     196                        out << '        <div class="helpIcon"></div>'
     197                }
     198
     199                // add an disabled input box for feedback purposes
     200                // @see dateElement(...)
     201                if (addExampleElement) {
     202                        def exampleAttrs = new LinkedHashMap()
     203                        exampleAttrs.name = attrs.get('name')+'Example'
     204                        exampleAttrs.class  = 'isExample'
     205                        exampleAttrs.disabled = 'disabled'
     206                        exampleAttrs.size = 30
     207                        out << textField(exampleAttrs)
     208                }
     209
     210                out << ' </div>'
     211
     212                // add help content if it is available
     213                if (help()) {
     214                        out << '  <div class="helpContent">'
     215                        out << '    ' + help()
     216                        out << '  </div>'
     217                }
     218
     219                out << '</div>'
     220        }
     221
     222        /**
    178223         * render a textFieldElement
    179224         * @param Map attrs
    180225         * @param Closure body  (help text)
    181226         */
    182         def textFieldElement = {attrs, body ->
     227        def textFieldElement = { attrs, body ->
    183228                // set default size, or scale to max length if it is less than the default size
    184229                if (!attrs.get("size")) {
     
    190235                }
    191236
    192                 // work variables
    193                 def addExampleElement = attrs.remove('addExampleElement')
    194                 //attrs.remove('addExampleElement')
    195 
    196                 // render a text element
    197                 out << '<div class="element">'
    198                 out << ' <div class="description">'
    199                 out << attrs.get('description')
    200                 out << ' </div>'
    201                 out << ' <div class="input">'
    202 
    203                 // add text input field
    204                 out << textField(attrs)
    205 
    206                 // add a help icon if help information is available
    207                 if (body()) {
    208                         out << '        <div class="helpIcon" />'
    209                 }
    210 
    211                 // add an disabled input box for feedback purposes
    212                 // @see dateElement(...)
    213                 if (addExampleElement) {
    214                         def exampleAttrs = new LinkedHashMap()
    215                         exampleAttrs.name = attrs.get('name')+'Example'
    216                         exampleAttrs.class  = 'isExample'
    217                         exampleAttrs.disabled = 'disabled'
    218                         out << textField(exampleAttrs)
    219                 }
    220 
    221                 // end HTML
    222                 out << ' </div>'
    223 
    224                 // add help content if it is available
    225                 if (body()) {
    226                         out << '  <div class="helpContent">'
    227                         out << '    ' + body()
    228                         out << '  </div>'
    229                 }
    230 
    231                 out << '</div>'
    232         }
    233 
    234         //def baseElement
    235 
    236         def templateElement = { attrs, body ->
    237 
     237                // render template element
     238                baseElement.call(
     239                        'textField',
     240                        attrs,
     241                        body
     242                )
    238243        }
    239244
    240245        /**
    241246         * render a dateElement
     247         * NOTE: datepicker is attached through wizard.js!
    242248         * @param Map attrs
    243249         * @param Closure body  (help text)
     
    255261               
    256262                // render a normal text field
    257                 out << textFieldElement(attrs,body)
    258 
    259                 // and attach the jquery-ui datepicker
    260                 out << '<script type="text/javascript">'
    261                 out << '$(document).ready(function() {'
    262                 out << '        $("#' + attrs.get('name') + '").datepicker({'
    263                 out << '                dateFormat: \'dd/mm/yy\','
    264                 out << '                altField: \'#' + attrs.get('name') + 'Example\', altFormat: \'DD, d MM, yy\''
    265                 out << '        });'
    266                 out << '});'
    267                 out << '</script>'
     263                //out << textFieldElement(attrs,body)
     264                textFieldElement.call(
     265                        attrs,
     266                        body
     267                )
     268        }
     269       
     270        /**
     271         * Template form element
     272         * @param Map           attributes
     273         * @param Closure       help content
     274         */
     275        def speciesElement = { attrs, body ->
     276                // render template element
     277                baseElement.call(
     278                        'speciesSelect',
     279                        attrs,
     280                        body
     281                )
    268282        }
    269283
     
    285299
    286300        /**
     301         * Template form element
     302         * @param Map           attributes
     303         * @param Closure       help content
     304         */
     305        def templateElement = { attrs, body ->
     306                // render template element
     307                baseElement.call(
     308                        'templateSelect',
     309                        attrs,
     310                        body
     311                )
     312        }
     313       
     314        /**
    287315         * render a template select element
    288316         * @param Map attrs
     
    296324                        attrs.name = 'template'
    297325                }
    298 
     326               
    299327                out << select(attrs)
    300328        }
     329
     330        def templateColumnHeaders = { attrs, body ->
     331                TemplateSubjectField.findAll().each() {
     332                        out << '<div class="column">' + it + '</div>'
     333                }
     334        }
     335
     336        def templateColumns = { attrs, body ->
     337                def subjectId = attrs.remove('id')
     338               
     339                // for now, fetch them all
     340                // also, this should probably be cached to reduce database load...
     341                TemplateSubjectField.findAll().each() {
     342                        out << '<div class="column">'
     343                        out << '<input type="text">'
     344                        out << '</div>'
     345                }
     346        }
    301347}
Note: See TracChangeset for help on using the changeset viewer.