Index: trunk/grails-app/taglib/AssetTreeTagLib.groovy
===================================================================
--- trunk/grails-app/taglib/AssetTreeTagLib.groovy	(revision 286)
+++ trunk/grails-app/taglib/AssetTreeTagLib.groovy	(revision 306)
@@ -4,5 +4,5 @@
 */
 class AssetTreeTagLib {
-    static namespace = 'gnumims'
+    static namespace = 'gnuMims'
 
     def resources = { attrs ->
@@ -10,9 +10,17 @@
     }
 
+    def assetTreeButton = {
+        def mkp = new groovy.xml.MarkupBuilder(out) //this line will be unnecessary in versions of Grails after version 1.2
+
+        mkp.div(class: "tree_button") {
+            a(href: showPane()) {
+                img(src: treeRootImg())
+            }
+        }
+    } // mkp
+
     def assetTree = { attrs ->
 
         def sites = Site.list()
-
-        def assetInstance = Asset.get(1) /// @todo: remove this.
 
         def divIdCount = 0
@@ -27,49 +35,33 @@
 
         /// @todo: use a loop for the subItem levels.
-        mkp.div(class: 'tree') {
-            ul() {
-                img(src: treeRootImg(), alt: 'TreeRoot')
-                for(site in sites.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
-                    li() {
-                        if(site.sections) {
-                            a(href: toggleBranch(nextDivId()) ) {
-                                img( src: bulletTreePlusImg(), id: divId+'img' )
-                            }
-                        }
-                        else
-                            img(src: dashImg())
-                        a( href: siteShowLink(site.id) ) {
-                            yieldUnescaped( site.encodeAsHTML() )
-                        }
-                        a(href: sectionCreateLink(site.id)) {
-                            img(src: addImg(), alt: 'Add', title: 'Add Section')
-                        }
-                    }
-                    if(site.sections) {
-                        div(id: divId,  style: 'display:none;') {
+        mkp.div(class: 'overlayPane', id: 'assetTreePane', style: 'display:none;') {
+            div(class: 'tree') {
+                table() {
+                    tr() {
+                        td( valign: 'top', class: 'value') {
                             ul() {
-                                for(section in site.sections.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
+                                img(src: treeRootImg(), alt: 'TreeRoot')
+                                for(site in sites.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
                                     li() {
-                                        if(section.assets) {
+                                        if(site.sections) {
                                             a(href: toggleBranch(nextDivId()) ) {
-                                                img(src: bulletTreePlusImg(), id: divId+'img' )
+                                                img( src: bulletTreePlusImg(), id: divId+'img' )
                                             }
                                         }
                                         else
                                             img(src: dashImg())
-                                        a( href: sectionShowLink(section.id) ) {
-                                            yieldUnescaped( section.encodeAsHTML() )
+                                        a( href: siteShowLink(site.id) ) {
+                                            yieldUnescaped( site.encodeAsHTML() )
                                         }
-                                        a(href: assetCreateLink(section.id)) {
-                                            img(src: addImg(), alt: 'Add', title: 'Add Asset')
+                                        a(href: sectionCreateLink(site.id)) {
+                                            img(src: addImg(), alt: 'Add', title: 'Add Section')
                                         }
                                     }
-
-                                    if(section.assets) {
-                                        div(id: divId,  style: 'display:none;') {
+                                    if(site.sections) {
+                                        div(id: divId, style: 'display:none;') {
                                             ul() {
-                                                for(asset in section.assets.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
+                                                for(section in site.sections.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
                                                     li() {
-                                                        if(asset.assetSubItems) {
+                                                        if(section.assets) {
                                                             a(href: toggleBranch(nextDivId()) ) {
                                                                 img(src: bulletTreePlusImg(), id: divId+'img' )
@@ -78,21 +70,18 @@
                                                         else
                                                             img(src: dashImg())
-                                                        a( href: assetShowLink(asset.id) ) {
-                                                            yieldUnescaped( asset.encodeAsHTML() )
+                                                        a( href: sectionShowLink(section.id) ) {
+                                                            yieldUnescaped( section.encodeAsHTML() )
                                                         }
-                                                        a(href: assetSubItemCreateLink(asset.id)) {
-                                                            img(src: addImg(), alt: 'Add', title: 'Add Sub Item')
+                                                        a(href: assetCreateLink(section.id)) {
+                                                            img(src: addImg(), alt: 'Add', title: 'Add Asset')
                                                         }
-                                                        a(href: assetCopyLink(asset.id)) {
-                                                            img(src: copyImg(), alt: 'Add', title: 'Copy Asset')
-                                                        }
-                                                    } // li
-
-                                                    if(asset.assetSubItems) {
-                                                        div(id: divId,  style: 'display:none;') {
+                                                    }
+
+                                                    if(section.assets) {
+                                                        div(id: divId, style: 'display:none;') {
                                                             ul() {
-                                                                for(assetSubItemL1 in asset.assetSubItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
+                                                                for(asset in section.assets.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
                                                                     li() {
-                                                                        if(assetSubItemL1.subItems) {
+                                                                        if(asset.assetSubItems) {
                                                                             a(href: toggleBranch(nextDivId()) ) {
                                                                                 img(src: bulletTreePlusImg(), id: divId+'img' )
@@ -101,38 +90,41 @@
                                                                         else
                                                                             img(src: dashImg())
-                                                                        a( href: assetSubItemShowLink(assetSubItemL1.id) ) {
-                                                                            yieldUnescaped( assetSubItemL1.encodeAsHTML() )
+                                                                        a( href: assetShowLink(asset.id) ) {
+                                                                            yieldUnescaped( asset.encodeAsHTML() )
                                                                         }
-                                                                        a(href: assetSubItemCreateWithParentLink(assetSubItemL1.id)) {
+                                                                        a(href: assetSubItemCreateLink(asset.id)) {
                                                                             img(src: addImg(), alt: 'Add', title: 'Add Sub Item')
                                                                         }
+                                                                        a(href: assetCopyLink(asset.id)) {
+                                                                            img(src: copyImg(), alt: 'Add', title: 'Copy Asset')
+                                                                        }
                                                                     } // li
 
-                                                                    if(assetSubItemL1.subItems) {
-                                                                        div(id: divId,  style: 'display:none;') {
+                                                                    if(asset.assetSubItems) {
+                                                                        div(id: divId, style: 'display:none;') {
                                                                             ul() {
-                                                                                for(assetSubItemL2 in assetSubItemL1.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
+                                                                                for(assetSubItemL1 in asset.assetSubItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
                                                                                     li() {
-                                                                                        if(assetSubItemL2.subItems) {
+                                                                                        if(assetSubItemL1.subItems) {
                                                                                             a(href: toggleBranch(nextDivId()) ) {
-                                                                                                img( src: bulletTreePlusImg(), id: divId+'img' )
+                                                                                                img(src: bulletTreePlusImg(), id: divId+'img' )
                                                                                             }
                                                                                         }
                                                                                         else
                                                                                             img(src: dashImg())
-                                                                                        a( href: assetSubItemShowLink(assetSubItemL2.id) ) {
-                                                                                            yieldUnescaped( assetSubItemL2.encodeAsHTML() )
+                                                                                        a( href: assetSubItemShowLink(assetSubItemL1.id) ) {
+                                                                                            yieldUnescaped( assetSubItemL1.encodeAsHTML() )
                                                                                         }
-                                                                                        a(href: assetSubItemCreateWithParentLink(assetSubItemL2.id)) {
+                                                                                        a(href: assetSubItemCreateWithParentLink(assetSubItemL1.id)) {
                                                                                             img(src: addImg(), alt: 'Add', title: 'Add Sub Item')
                                                                                         }
                                                                                     } // li
 
-                                                                                    if(assetSubItemL2.subItems) {
-                                                                                        div(id: divId,  style: 'display:none;') {
+                                                                                    if(assetSubItemL1.subItems) {
+                                                                                        div(id: divId, style: 'display:none;') {
                                                                                             ul() {
-                                                                                                for(assetSubItemL3 in assetSubItemL2.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
+                                                                                                for(assetSubItemL2 in assetSubItemL1.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
                                                                                                     li() {
-                                                                                                        if(assetSubItemL3.subItems) {
+                                                                                                        if(assetSubItemL2.subItems) {
                                                                                                             a(href: toggleBranch(nextDivId()) ) {
                                                                                                                 img( src: bulletTreePlusImg(), id: divId+'img' )
@@ -141,64 +133,95 @@
                                                                                                         else
                                                                                                             img(src: dashImg())
-                                                                                                        a( href: assetSubItemShowLink(assetSubItemL3.id) ) {
-                                                                                                            yieldUnescaped( assetSubItemL3.encodeAsHTML() )
+                                                                                                        a( href: assetSubItemShowLink(assetSubItemL2.id) ) {
+                                                                                                            yieldUnescaped( assetSubItemL2.encodeAsHTML() )
                                                                                                         }
-                                                                                                        a(href: assetSubItemCreateWithParentLink(assetSubItemL3.id)) {
+                                                                                                        a(href: assetSubItemCreateWithParentLink(assetSubItemL2.id)) {
                                                                                                             img(src: addImg(), alt: 'Add', title: 'Add Sub Item')
                                                                                                         }
                                                                                                     } // li
 
-                                                                                                    if(assetSubItemL3.subItems) {
-                                                                                                        div(id: divId,  style: 'display:none;') {
+                                                                                                    if(assetSubItemL2.subItems) {
+                                                                                                        div(id: divId, style: 'display:none;') {
                                                                                                             ul() {
-                                                                                                                for(assetSubItemL4 in assetSubItemL3.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
+                                                                                                                for(assetSubItemL3 in assetSubItemL2.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
                                                                                                                     li() {
-//                                                                                                                         if(assetSubItemL4.subItems) {
-//                                                                                                                             a(href: toggleBranch(nextDivId()) ) {
-//                                                                                                                                 img( src: bulletTreePlusImg(), id: divId+'img' )
-//                                                                                                                             }
-//                                                                                                                         }
-//                                                                                                                         else
-                                                                                                                        img(src: dashImg())
-                                                                                                                        a( href: assetSubItemShowLink(assetSubItemL4.id) ) {
-                                                                                                                            yieldUnescaped( assetSubItemL4.encodeAsHTML() )
+                                                                                                                        if(assetSubItemL3.subItems) {
+                                                                                                                            a(href: toggleBranch(nextDivId()) ) {
+                                                                                                                                img( src: bulletTreePlusImg(), id: divId+'img' )
+                                                                                                                            }
                                                                                                                         }
-//                                                                                                                         a(href: assetSubItemCreateWithParentLink(assetSubItemL4.id)) {
-//                                                                                                                             img(src: addImg(), alt: 'Add', title: 'Add Sub Item')
-//                                                                                                                         }
+                                                                                                                        else
+                                                                                                                            img(src: dashImg())
+                                                                                                                        a( href: assetSubItemShowLink(assetSubItemL3.id) ) {
+                                                                                                                            yieldUnescaped( assetSubItemL3.encodeAsHTML() )
+                                                                                                                        }
+                                                                                                                        a(href: assetSubItemCreateWithParentLink(assetSubItemL3.id)) {
+                                                                                                                            img(src: addImg(), alt: 'Add', title: 'Add Sub Item')
+                                                                                                                        }
                                                                                                                     } // li
 
-                                                                                                                } // assetSubItemL4
+                                                                                                                    if(assetSubItemL3.subItems) {
+                                                                                                                        div(id: divId, style: 'display:none;') {
+                                                                                                                            ul() {
+                                                                                                                                for(assetSubItemL4 in assetSubItemL3.subItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }) {
+                                                                                                                                    li() {
+                //                                                                                                                         if(assetSubItemL4.subItems) {
+                //                                                                                                                             a(href: toggleBranch(nextDivId()) ) {
+                //                                                                                                                                 img( src: bulletTreePlusImg(), id: divId+'img' )
+                //                                                                                                                             }
+                //                                                                                                                         }
+                //                                                                                                                         else
+                                                                                                                                        img(src: dashImg())
+                                                                                                                                        a( href: assetSubItemShowLink(assetSubItemL4.id) ) {
+                                                                                                                                            yieldUnescaped( assetSubItemL4.encodeAsHTML() )
+                                                                                                                                        }
+                //                                                                                                                         a(href: assetSubItemCreateWithParentLink(assetSubItemL4.id)) {
+                //                                                                                                                             img(src: addImg(), alt: 'Add', title: 'Add Sub Item')
+                //                                                                                                                         }
+                                                                                                                                    } // li
+
+                                                                                                                                } // assetSubItemL4
+                                                                                                                            } // ul
+                                                                                                                        } // div
+                                                                                                                    } // if(assetSubItemL3.subItems)
+
+
+                                                                                                                } // assetSubItemL3
                                                                                                             } // ul
                                                                                                         } // div
-                                                                                                    } // if(assetSubItemL3.subItems)
-
-
-                                                                                                } // assetSubItemL3
+                                                                                                    } // if(assetSubItemL2.subItems)
+
+                                                                                                } // assetSubItemL2
                                                                                             } // ul
                                                                                         } // div
-                                                                                    } // if(assetSubItemL2.subItems)
-
-                                                                                } // assetSubItemL2
+                                                                                    } // if(assetSubItemL1.subItems)
+
+                                                                                } // assetSubItemL1
                                                                             } // ul
                                                                         } // div
-                                                                    } // if(assetSubItemL1.subItems)
-
-                                                                } // assetSubItemL1
+                                                                    } // if(asset.assetSubItems)
+
+                                                                } // assets
                                                             } // ul
                                                         } // div
-                                                    } // if(asset.assetSubItems)
-
-                                                } // assets
+                                                    } // if(section.assets)
+
+                                                } //sections
                                             } // ul
                                         } // div
-                                    } // if(section.assets)
-
-                                } //sections
+                                    } // if(site.sections) 
+                                } // sites
                             } // ul
-                        } // div
-                    } // if(site.sections) 
-                } // sites
-            } // ul
+                        } // td
+                    } // tr
+                } // table
+            } // div
+
+            div( class: 'buttons') {
+                span(class: 'button') {
+                    input(type: 'button', value: 'Close', onclick: 'return hideElement("assetTreePane");')
+                }
+            }
+
         } // mkp
 
@@ -231,7 +254,11 @@
     /** js calls */
 
+    def showPane() {
+       'javascript: showDiv(\"assetTreePane\");'
+    }
+
     def toggleBranch(divId) {
         /// @todo: toggleBranch is in overlayPane.js and should be moved to tree.js
-       'javascript: toggleBranch(\"' + divId + '\", \"' + divId + 'img' + '\");'
+       'javascript: toggleBranch(\"' + divId + '\", \"' + divId + 'img' +'\", \"' + bulletTreeMinusImg() +'\", \"' + bulletTreePlusImg() + '\");'
     }
 
