|
Last change
on this file since 322 was
322,
checked in by gav, 16 years ago
|
|
Move JavascriptService to JsUtilService.
Consolidate similar JsUtilService methods.
Create JsUtilTagLib?.
Disable pulsing of asset tree loading image.
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | |
|---|
| 2 | /** |
|---|
| 3 | * JsUtil tags. |
|---|
| 4 | * Javascript Utility tags. |
|---|
| 5 | */ |
|---|
| 6 | class JsUtilTagLib { |
|---|
| 7 | static namespace = 'jsUtil' |
|---|
| 8 | |
|---|
| 9 | def js = new JsUtilService() |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * Resources. |
|---|
| 13 | * To be included in the page head tag. |
|---|
| 14 | */ |
|---|
| 15 | def resources = { attrs -> |
|---|
| 16 | out << g.javascript(src: "jsUtil.js") |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * Toggle the visibility of an html element and update an image. |
|---|
| 21 | * @param toggleId The html id of the element to toggle. |
|---|
| 22 | * @param imageId The html id to apply to the image. |
|---|
| 23 | * @param openImgUrl The url to apply as the image src when toggled element is visible. |
|---|
| 24 | * @param closedImgUrl The url to apply as the image src when toggled element is hidden. |
|---|
| 25 | * @param text The text, if any, to display. |
|---|
| 26 | */ |
|---|
| 27 | def toggleControl = { attrs -> |
|---|
| 28 | def mkp = new groovy.xml.MarkupBuilder(out) //this line will be unnecessary in versions of Grails after version 1.2 |
|---|
| 29 | |
|---|
| 30 | mkp.div() { |
|---|
| 31 | a( href: js.toggleWithImg(attrs.toggleId, attrs.imageId, attrs.openImgUrl, attrs.closedImgUrl) ) { |
|---|
| 32 | yieldUnescaped(attrs.text) |
|---|
| 33 | img(id: attrs.imageId, src: attrs.closedImgUrl, alt: "Show") |
|---|
| 34 | } |
|---|
| 35 | } // mkp |
|---|
| 36 | |
|---|
| 37 | } // hideShowControl |
|---|
| 38 | |
|---|
| 39 | } // end class |
|---|
Note: See
TracBrowser
for help on using the repository browser.