Changeset 145 for trunk/grails-app/taglib
- Timestamp:
- Jan 28, 2010, 5:34:50 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r140 r145 176 176 177 177 /** 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 /** 178 223 * render a textFieldElement 179 224 * @param Map attrs 180 225 * @param Closure body (help text) 181 226 */ 182 def textFieldElement = { attrs, body ->227 def textFieldElement = { attrs, body -> 183 228 // set default size, or scale to max length if it is less than the default size 184 229 if (!attrs.get("size")) { … … 190 235 } 191 236 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 ) 238 243 } 239 244 240 245 /** 241 246 * render a dateElement 247 * NOTE: datepicker is attached through wizard.js! 242 248 * @param Map attrs 243 249 * @param Closure body (help text) … … 255 261 256 262 // 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 ) 268 282 } 269 283 … … 285 299 286 300 /** 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 /** 287 315 * render a template select element 288 316 * @param Map attrs … … 296 324 attrs.name = 'template' 297 325 } 298 326 299 327 out << select(attrs) 300 328 } 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 } 301 347 }
Note: See TracChangeset
for help on using the changeset viewer.