Changeset 307 for trunk/grails-app/taglib
- Timestamp:
- Feb 1, 2010, 7:56:41 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/taglib/AssetTreeTagLib.groovy
r306 r307 24 24 def sites = Site.list() 25 25 26 def visibleBranches = session.assetTreeVisibleBranches ? session.assetTreeVisibleBranches.tokenize(',') : [] 27 28 def branchStyle = { branchId -> 29 if(visibleBranches.contains(branchId)) 30 '' 31 else 32 'display:none;' 33 } 34 35 def branchImg = { branchId -> 36 if(visibleBranches.contains(branchId)) 37 bulletTreeMinusImg() 38 else 39 bulletTreePlusImg() 40 } 41 26 42 def divIdCount = 0 27 43 def divId = '' … … 36 52 /// @todo: use a loop for the subItem levels. 37 53 mkp.div(class: 'overlayPane', id: 'assetTreePane', style: 'display:none;') { 38 div(class: 'tree' ) {54 div(class: 'tree', id: 'assetTreeTable') { 39 55 table() { 40 56 tr() { … … 46 62 if(site.sections) { 47 63 a(href: toggleBranch(nextDivId()) ) { 48 img( src: b ulletTreePlusImg(), id: divId+'img' )64 img( src: branchImg(divId), id: divId+'img' ) 49 65 } 50 66 } 51 67 else 52 68 img(src: dashImg()) 53 a( href: siteShowLink(site.id) ) {69 a( href: siteShowLink(site.id), onclick: hideAssetTreePane() ) { 54 70 yieldUnescaped( site.encodeAsHTML() ) 55 71 } 56 a(href: sectionCreateLink(site.id) ) {72 a(href: sectionCreateLink(site.id), onclick: hideAssetTreePane()) { 57 73 img(src: addImg(), alt: 'Add', title: 'Add Section') 58 74 } 59 75 } 60 76 if(site.sections) { 61 div( id: divId, style: 'display:none;') {77 div( id: divId, style: branchStyle(divId) ) { 62 78 ul() { 63 79 for(section in site.sections.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) { 64 80 li() { 65 81 if(section.assets) { 66 a( href: toggleBranch(nextDivId()) ) {67 img(src: b ulletTreePlusImg(), id: divId+'img' )82 a( href: toggleBranch(nextDivId()) ) { 83 img(src: branchImg(divId), id: divId+'img' ) 68 84 } 69 85 } 70 86 else 71 87 img(src: dashImg()) 72 a( href: sectionShowLink(section.id) ) {88 a( href: sectionShowLink(section.id), onclick: hideAssetTreePane() ) { 73 89 yieldUnescaped( section.encodeAsHTML() ) 74 90 } 75 a(href: assetCreateLink(section.id) ) {91 a(href: assetCreateLink(section.id), onclick: hideAssetTreePane()) { 76 92 img(src: addImg(), alt: 'Add', title: 'Add Asset') 77 93 } … … 79 95 80 96 if(section.assets) { 81 div( id: divId, style: 'display:none;') {97 div( id: divId, style: branchStyle(divId) ) { 82 98 ul() { 83 99 for(asset in section.assets.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) { 84 100 li() { 85 101 if(asset.assetSubItems) { 86 a( href: toggleBranch(nextDivId()) ) {87 img(src: b ulletTreePlusImg(), id: divId+'img' )102 a( href: toggleBranch(nextDivId()) ) { 103 img(src: branchImg(divId), id: divId+'img' ) 88 104 } 89 105 } 90 106 else 91 107 img(src: dashImg()) 92 a( href: assetShowLink(asset.id) ) {108 a( href: assetShowLink(asset.id), onclick: hideAssetTreePane() ) { 93 109 yieldUnescaped( asset.encodeAsHTML() ) 94 110 } 95 a(href: assetSubItemCreateLink(asset.id) ) {111 a(href: assetSubItemCreateLink(asset.id), onclick: hideAssetTreePane()) { 96 112 img(src: addImg(), alt: 'Add', title: 'Add Sub Item') 97 113 } 98 a(href: assetCopyLink(asset.id) ) {114 a(href: assetCopyLink(asset.id), onclick: hideAssetTreePane()) { 99 115 img(src: copyImg(), alt: 'Add', title: 'Copy Asset') 100 116 } … … 102 118 103 119 if(asset.assetSubItems) { 104 div( id: divId, style: 'display:none;') {120 div( id: divId, style: branchStyle(divId) ) { 105 121 ul() { 106 122 for(assetSubItemL1 in asset.assetSubItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) { 107 123 li() { 108 124 if(assetSubItemL1.subItems) { 109 a( href: toggleBranch(nextDivId()) ) {110 img(src: b ulletTreePlusImg(), id: divId+'img' )125 a( href: toggleBranch(nextDivId()) ) { 126 img(src: branchImg(divId), id: divId+'img' ) 111 127 } 112 128 } 113 129 else 114 130 img(src: dashImg()) 115 a( href: assetSubItemShowLink(assetSubItemL1.id) ) {131 a( href: assetSubItemShowLink(assetSubItemL1.id), onclick: hideAssetTreePane() ) { 116 132 yieldUnescaped( assetSubItemL1.encodeAsHTML() ) 117 133 } 118 a(href: assetSubItemCreateWithParentLink(assetSubItemL1.id) ) {134 a(href: assetSubItemCreateWithParentLink(assetSubItemL1.id), onclick: hideAssetTreePane()) { 119 135 img(src: addImg(), alt: 'Add', title: 'Add Sub Item') 120 136 } … … 122 138 123 139 if(assetSubItemL1.subItems) { 124 div( id: divId, style: 'display:none;') {140 div( id: divId, style: branchStyle(divId) ) { 125 141 ul() { 126 142 for(assetSubItemL2 in assetSubItemL1.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) { 127 143 li() { 128 144 if(assetSubItemL2.subItems) { 129 a( href: toggleBranch(nextDivId()) ) {130 img( src: b ulletTreePlusImg(), id: divId+'img' )145 a( href: toggleBranch(nextDivId()) ) { 146 img( src: branchImg(divId), id: divId+'img' ) 131 147 } 132 148 } 133 149 else 134 150 img(src: dashImg()) 135 a( href: assetSubItemShowLink(assetSubItemL2.id) ) {151 a( href: assetSubItemShowLink(assetSubItemL2.id), onclick: hideAssetTreePane() ) { 136 152 yieldUnescaped( assetSubItemL2.encodeAsHTML() ) 137 153 } 138 a(href: assetSubItemCreateWithParentLink(assetSubItemL2.id) ) {154 a(href: assetSubItemCreateWithParentLink(assetSubItemL2.id), onclick: hideAssetTreePane()) { 139 155 img(src: addImg(), alt: 'Add', title: 'Add Sub Item') 140 156 } … … 142 158 143 159 if(assetSubItemL2.subItems) { 144 div( id: divId, style: 'display:none;') {160 div( id: divId, style: branchStyle(divId) ) { 145 161 ul() { 146 162 for(assetSubItemL3 in assetSubItemL2.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) { 147 163 li() { 148 164 if(assetSubItemL3.subItems) { 149 a( href: toggleBranch(nextDivId()) ) {150 img( src: b ulletTreePlusImg(), id: divId+'img' )165 a( href: toggleBranch(nextDivId()) ) { 166 img( src: branchImg(divId), id: divId+'img' ) 151 167 } 152 168 } 153 169 else 154 170 img(src: dashImg()) 155 a( href: assetSubItemShowLink(assetSubItemL3.id) ) {171 a( href: assetSubItemShowLink(assetSubItemL3.id), onclick: hideAssetTreePane() ) { 156 172 yieldUnescaped( assetSubItemL3.encodeAsHTML() ) 157 173 } 158 a(href: assetSubItemCreateWithParentLink(assetSubItemL3.id) ) {174 a(href: assetSubItemCreateWithParentLink(assetSubItemL3.id), onclick: hideAssetTreePane()) { 159 175 img(src: addImg(), alt: 'Add', title: 'Add Sub Item') 160 176 } … … 162 178 163 179 if(assetSubItemL3.subItems) { 164 div( id: divId, style: 'display:none;') {180 div( id: divId, style: branchStyle(divId) ) { 165 181 ul() { 166 182 for(assetSubItemL4 in assetSubItemL3.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) { 167 183 li() { 168 184 // if(assetSubItemL4.subItems) { 169 // a( href: toggleBranch(nextDivId()) ) {170 // img( src: b ulletTreePlusImg(), id: divId+'img' )185 // a( href: toggleBranch(nextDivId()) ) { 186 // img( src: branchImg(divId), id: divId+'img' ) 171 187 // } 172 188 // } 173 189 // else 174 190 img(src: dashImg()) 175 a( href: assetSubItemShowLink(assetSubItemL4.id) ) {191 a( href: assetSubItemShowLink(assetSubItemL4.id), onclick: hideAssetTreePane() ) { 176 192 yieldUnescaped( assetSubItemL4.encodeAsHTML() ) 177 193 } 178 // a(href: assetSubItemCreateWithParentLink(assetSubItemL4.id) ) {194 // a(href: assetSubItemCreateWithParentLink(assetSubItemL4.id), onclick: hideAssetTreePane()) { 179 195 // img(src: addImg(), alt: 'Add', title: 'Add Sub Item') 180 196 // } … … 220 236 div( class: 'buttons') { 221 237 span(class: 'button') { 222 input( type: 'button', value: 'Close', onclick: 'return hideElement("assetTreePane");')238 input( type: 'button', value: 'Close', onclick: hideAssetTreePane() ) 223 239 } 224 240 } … … 227 243 228 244 } // assetTree 229 230 245 231 246 … … 258 273 } 259 274 275 def hideAssetTreePane() { 276 def saveUrl = createLink(controller: 'appCore', action: 'saveAssetTreeStatus').toString() 277 'return hideAssetTreePane(\"assetTreePane\", \"assetTreeTable' + '\", \"' + saveUrl + '\");' 278 } 279 260 280 def toggleBranch(divId) { 261 281 /// @todo: toggleBranch is in overlayPane.js and should be moved to tree.js
Note: See TracChangeset
for help on using the changeset viewer.