Changeset 322 for trunk/grails-app
- Timestamp:
- Feb 8, 2010, 2:51:23 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/AssetTreeService.groovy
r319 r322 3 3 boolean transactional = false 4 4 5 def js = new J avascriptService()5 def js = new JsUtilService() 6 6 7 7 def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib() … … 84 84 85 85 div(class: paneCloseHtmlClass()) { 86 a( href: js. hrefToggle(paneHtmlId()) ) {86 a( href: js.toggle(paneHtmlId()) ) { 87 87 img(src: closeImg()) 88 88 } … … 106 106 div( class: 'buttons') { 107 107 span(class: 'button') { 108 input( type: 'button', value: g.message(code: 'default.close.text'), onclick: js. onclickToggle(paneHtmlId()) )108 input( type: 'button', value: g.message(code: 'default.close.text'), onclick: js.toggle(paneHtmlId(), "onclick") ) 109 109 } 110 110 } // button div … … 132 132 li() { 133 133 if(site.sections) { 134 a(href: hrefToggleBranch(nextDivId()) ) {134 a(href: toggleBranch(nextDivId()) ) { 135 135 img( src: branchImg(divId), id: divId+'img' ) 136 136 } … … 152 152 li() { 153 153 if(section.assets) { 154 a( href: hrefToggleBranch(nextDivId()) ) {154 a( href: toggleBranch(nextDivId()) ) { 155 155 img(src: branchImg(divId), id: divId+'img' ) 156 156 } … … 173 173 li() { 174 174 if(asset.assetSubItems) { 175 a( href: hrefToggleBranch(nextDivId()) ) {175 a( href: toggleBranch(nextDivId()) ) { 176 176 img(src: branchImg(divId), id: divId+'img' ) 177 177 } … … 197 197 li() { 198 198 if(assetSubItemL1.subItems) { 199 a( href: hrefToggleBranch(nextDivId()) ) {199 a( href: toggleBranch(nextDivId()) ) { 200 200 img(src: branchImg(divId), id: divId+'img' ) 201 201 } … … 218 218 li() { 219 219 if(assetSubItemL2.subItems) { 220 a( href: hrefToggleBranch(nextDivId()) ) {220 a( href: toggleBranch(nextDivId()) ) { 221 221 img( src: branchImg(divId), id: divId+'img' ) 222 222 } … … 239 239 li() { 240 240 if(assetSubItemL3.subItems) { 241 a( href: hrefToggleBranch(nextDivId()) ) {241 a( href: toggleBranch(nextDivId()) ) { 242 242 img( src: branchImg(divId), id: divId+'img' ) 243 243 } … … 260 260 li() { 261 261 // if(assetSubItemL4.subItems) { 262 // a( href: hrefToggleBranch(nextDivId()) ) {262 // a( href: toggleBranch(nextDivId()) ) { 263 263 // img( src: branchImg(divId), id: divId+'img' ) 264 264 // } … … 365 365 } 366 366 367 def hrefToggleBranch(divId) {368 'javascript: toggleBranch(\"' + divId + '\", \"' + divId + 'img' +'\", \"' + bulletTreeMinusImg() +'\", \"' + bulletTreePlusImg() + '\");'367 def toggleBranch(divId) { 368 js.toggleWithImg(divId, divId + 'img', bulletTreeMinusImg(), bulletTreePlusImg()) 369 369 } 370 370 -
trunk/grails-app/services/JsUtilService.groovy
r314 r322 1 1 /** 2 2 * Provides some javascript utility methods. 3 * To use include the following in the gsp head: 4 * <!-- 5 * <g:javascript src="util.js" /> 6 * --> 7 * @todo: util.js could be placed a taglib resources closure. 3 * For use with JsUtilTagLib. 8 4 */ 9 class J avascriptService {5 class JsUtilService { 10 6 11 7 boolean transactional = false … … 16 12 * Toggle the visibility of an html element. 17 13 * @param id The html id of the element. 18 * @returns A javascript string that can be assigned to an onclick action. 14 * @param type The type of html action the javascript will be applied to e.g 'onclick', defaults to 'href'. 15 * @returns A javascript string that can be assigned for example to an anchor href or onclick action. 19 16 */ 20 def onclickToggle(id) { 21 'return toggleUtil(\"' + id + '\");' 17 def toggle(id, type="href") { 18 def s = 'toggleUtil(\"' + id + '\");' 19 if(type == "onclick") 20 s + ' return false;' 21 else 22 'javascript: ' + s 22 23 } 23 24 24 25 /** 25 * Toggle the visibility of an html element. 26 * @param id The html id of the element. 27 * @returns A javascript string that can be assigned to an anchor href. 26 * Toggle the visibility of an html element and update an image. 27 * @param toggleId The html id of the element to toggle. 28 * @param imageid The html id of the image to update. 29 * @param openImgUrl The url to apply as the image src when toggled element is visible. 30 * @param closedImgUrl The url to apply as the image src when toggled element is hidden. 31 * @param type The type of html action the javascript will be applied to e.g 'onclick', defaults to 'href'. 32 * @returns A javascript string that can be assigned for example to an anchor href or onclick action. 28 33 */ 29 def hrefToggle(id) { 30 'javascript: toggleUtil(\"' + id + '\");' 34 def toggleWithImg(toggleId, imageid, openImgUrl, closedImgUrl, type="href") { 35 36 def s = 'toggleWithImgUtil(\"' + toggleId +'\", \"' + imageid +'\", \"' + openImgUrl +'\", \"' + closedImgUrl +'\");' 37 if(type == "onclick") 38 s + ' return false;' 39 else 40 'javascript: ' + s 41 31 42 } 32 43 … … 34 45 * Show an html element by slowly increasing the visibility. 35 46 * @param id The html id of the element. 36 * @returns A javascript string that can be assigned to an onclick action. 47 * @param type The type of html action the javascript will be applied to e.g 'onclick', defaults to 'href'. 48 * @returns A javascript string that can be assigned for example to an anchor href or onclick action. 37 49 */ 38 def onclickShow(id) { 39 'return showUtil(\"' + id + '\");' 40 } 41 42 /** 43 * Show an html element by slowly increasing the visibility. 44 * @param id The html id of the element. 45 * @returns A javascript string that can be assigned to an anchor href. 46 */ 47 def hrefShow(id) { 48 'javascript: showUtil(\"' + id + '\");' 50 def show(id) { 51 def s = 'showUtil(\"' + id + '\");' 52 if(type == "onclick") 53 s + ' return false;' 54 else 55 'javascript: ' + s 49 56 } 50 57 … … 52 59 * Hide an html element by slowly decreasing the visibility. 53 60 * @param id The html id of the element. 54 * @returns A javascript string that can be assigned to an onclick action. 61 * @param type The type of html action the javascript will be applied to e.g 'onclick', defaults to 'href'. 62 * @returns A javascript string that can be assigned for example to an anchor href or onclick action. 55 63 */ 56 def onclickHide(id) { 57 'return hideUtil(\"' + id + '\");' 58 } 59 60 /** 61 * Hide an html element by slowly decreasing the visibility. 62 * @param id The html id of the element. 63 * @returns A javascript string that can be assigned to an anchor href. 64 */ 65 def hrefHide(id) { 66 'javascript: hideUtil(\"' + id + '\");' 64 def hide(id) { 65 def s = 'hideUtil(\"' + id + '\");' 66 if(type == "onclick") 67 s + ' return false;' 68 else 69 'javascript: ' + s 67 70 } 68 71 -
trunk/grails-app/taglib/AssetTreeTagLib.groovy
r312 r322 6 6 static namespace = 'gnuMims' 7 7 8 def js = new J avascriptService()8 def js = new JsUtilService() 9 9 def ts = new AssetTreeService() 10 10 … … 37 37 mkp.div(class: ts.paneHtmlClass(), id: ts.paneHtmlId(), style: 'display:none;') { 38 38 div(class: ts.paneCloseHtmlClass()) { 39 a( href: js. hrefToggle(ts.paneHtmlId()) ) {39 a( href: js.toggle(ts.paneHtmlId()) ) { 40 40 img(src: ts.closeImg()) 41 41 } -
trunk/grails-app/views/layouts/main.gsp
r313 r322 11 11 <g:javascript library="prototype/effects" /> 12 12 <g:javascript src="overlayPane.js" /> 13 < g:javascript src="util.js"/>13 <jsUtil:resources /> 14 14 <gnuMims:resources /> 15 15 </head>
Note: See TracChangeset
for help on using the changeset viewer.