Add links to the icons in the tree menu, just like back in the good ole days. Patch...
authorxzilla <xzilla>
Fri, 23 Jun 2006 00:57:37 +0000 (00:57 +0000)
committerxzilla <xzilla>
Fri, 23 Jun 2006 00:57:37 +0000 (00:57 +0000)
ioguix <ioguix@free.fr>.

classes/Misc.php
tables.php
views.php
xloadtree/xloadtree2.js
xloadtree/xtree2.js

index d66565296c8a159e7866049751f6a0993974f642..65a6a263f9d2387a9c2988b1734f9273bc1f0c84 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.130 2006/06/17 21:50:06 xzilla Exp $
+        * $Id: Misc.php,v 1.131 2006/06/23 00:57:37 xzilla Exp $
         */
         
        class Misc {
                 *        'openIcon' - an alternative icon when the node is expanded
                 *        'toolTip' - tool tip text for the node
                 *        'action' - URL to visit when single clicking the node
+                *        'iconAction' - URL to visit when single clicking the icon node
                 *        'branch' - URL for child nodes (tree XML)
                 *        'expand' - the action to return XML for the subtree
                 *        'nodata' - message to display when node has no children
                                        
                                        $icon = $this->icon(value($attrs['icon'], $rec));
                                        echo value_xml_attr('icon', $icon, $rec);
+                                       echo value_xml_attr('iconAction', $attrs['iconAction'], $rec);
                                        
                                        if (!empty($attrs['openIcon'])) {
                                                $icon = $this->icon(value($attrs['openIcon'], $rec));
index cf4f1890652d7946cd4fc75d05a9903791516ff9..05b2f2b2f50075bfa271fc7bbb0b1e6cf2f18326 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.78 2006/06/21 18:02:51 xzilla Exp $
+        * $Id: tables.php,v 1.79 2006/06/23 00:57:37 xzilla Exp $
         */
 
        // Include application functions
                $attrs = array(
                        'text'   => field('relname'),
                        'icon'   => 'Table',
+                       'iconAction' => url('display.php',
+                                                       $reqvars,
+                                                       array('table' => field('relname'))
+                                               ),
                        'toolTip'=> field('relcomment'),
                        'action' => url('redirect.php',
                                                        $reqvars,
index f763dc9e56bae1db0c0c0af83a42bba5bfc3cb86..74412a6b8e706edcc9c573affa00388565cb3f98 100644 (file)
--- a/views.php
+++ b/views.php
@@ -3,7 +3,7 @@
        /**
         * Manage views in a database
         *
-        * $Id: views.php,v 1.56 2006/06/17 12:57:37 xzilla Exp $
+        * $Id: views.php,v 1.57 2006/06/23 00:57:37 xzilla Exp $
         */
 
        // Include application functions
                $attrs = array(
                        'text'   => field('relname'),
                        'icon'   => 'View',
+                       'iconAction' => url('display.php',
+                                                       $reqvars,
+                                                       array('view' => field('relname'))
+                                               ),
                        'toolTip'=> field('relcomment'),
                        'action' => url('redirect.php',
                                                        $reqvars,
index 78b3e55bd17f76888c5c220cd31485cc4a898f47..1b23353bb8c746bb5165cd5a44d9f16668617dca 100644 (file)
@@ -48,7 +48,9 @@
 |-----------------------------------------------------------------------------|\r
 | Created 2003-??-?? | All changes are in the log above. | Updated 2004-06-06 |\r
 \----------------------------------------------------------------------------*/\r
-\r
+| Note local changes have been made to allow Icons to have different links    |\r
+|  than thier text label counterparts. Thanks to JGuillaume de Rorthais       |\r
+|-----------------------------------------------------------------------------|\r
 \r
 webFXTreeConfig.loadingText = "Loading...";\r
 webFXTreeConfig.loadingIcon = "images/loading.gif";\r
@@ -57,8 +59,8 @@ webFXTreeConfig.errorIcon = "images/exclamation.16.png";
 webFXTreeConfig.reloadText = "Click to reload";\r
 \r
 \r
-function WebFXLoadTree(sText, sXmlSrc, oAction, sBehavior, sIcon, sOpenIcon) {\r
-       WebFXTree.call(this, sText, oAction, sBehavior, sIcon, sOpenIcon);\r
+function WebFXLoadTree(sText, sXmlSrc, oAction, sBehavior, sIcon, oIconAction, sOpenIcon) {\r
+       WebFXTree.call(this, sText, oAction, sBehavior, sIcon, oIconAction, sOpenIcon);\r
 \r
        // setup default property values\r
        this.src = sXmlSrc;\r
@@ -95,8 +97,8 @@ _p.setExpanded = function (b) {
        }\r
 };\r
 \r
-function WebFXLoadTreeItem(sText, sXmlSrc, oAction, eParent, sIcon, sOpenIcon) {\r
-       WebFXTreeItem.call(this, sText, oAction, eParent, sIcon, sOpenIcon);\r
+function WebFXLoadTreeItem(sText, sXmlSrc, oAction, eParent, sIcon, oIconAction, sOpenIcon) {\r
+       WebFXTreeItem.call(this, sText, oAction, eParent, sIcon, oIconAction, sOpenIcon);\r
 \r
 // setup default property values\r
        this.src = sXmlSrc;\r
@@ -302,7 +304,7 @@ WebFXLoadTree.createItemFromElement = function (oNode) {
                action = jsAttrs.action;\r
        }\r
        var jsNode = new WebFXLoadTreeItem(jsAttrs.html || "", jsAttrs.src, action,\r
-                                                                          null, jsAttrs.icon, jsAttrs.openIcon);\r
+                                                                               null, jsAttrs.icon, jsAttrs.iconAction, jsAttrs.openIcon);\r
        if (jsAttrs.text) {\r
                jsNode.setText(jsAttrs.text);\r
        }\r
index 156789b3097113b68d0adce6ed220cea7e3b4e20..9913fa00bc759b491da02dbd0a963b9539ca6c7a 100644 (file)
@@ -285,10 +285,11 @@ var webFXTreeHandler = {
 // WebFXTreeAbstractNode
 ///////////////////////////////////////////////////////////////////////////////
 
-function WebFXTreeAbstractNode(sText, oAction) {
+function WebFXTreeAbstractNode(sText, oAction, oIconAction) {
        this.childNodes = [];
        if (sText) this.text = sText;
        if (oAction) this.action = oAction;
+       if (oIconAction) this.iconAction = oIconAction;
        this.id = webFXTreeHandler.getUniqueId();
        if (webFXTreeConfig.usePersistence) {
                this.open = webFXTreeHandler.persistenceManager.getExpanded(this);
@@ -303,6 +304,7 @@ _p.indentWidth = 19;
 _p.open = false;
 _p.text = webFXTreeConfig.defaultText;
 _p.action = null;
+_p.iconAcion = null;
 _p.target = null;
 _p.toolTip = null;
 _p._focused = false;
@@ -815,6 +817,13 @@ _p._getHref = function () {
                return "#";
 };
 
+_p._getIconHref = function () {
+       if (typeof this.iconAction == "string")
+               return this.iconAction;
+       else
+               return this._getHref();
+}
+
 _p.getEventHandlersHtml = function () {
        return "";
 };
@@ -822,7 +831,8 @@ _p.getEventHandlersHtml = function () {
 _p.getIconHtml = function () {
        // here we are not using textToHtml since the file names rarerly contains
        // HTML...
-       return "<img class=\"webfx-tree-icon\" src=\"" + this.getIconSrc() + "\">";
+       return "<a href=\"" + webFXTreeHandler.textToHtml(this._getIconHref()) +
+               "\"><img class=\"webfx-tree-icon\" src=\"" + this.getIconSrc() + "\"></a>";
 };
 
 _p.getIconSrc = function () {
@@ -1050,6 +1060,20 @@ _p.getAction = function () {
        return this.action;
 };
 
+_p.setIconAction = function (oAction) {
+       this.iconAction = oAction;
+       var el = this.getIconElement();
+       if (el) {
+               el.href = this._getIconHref();
+       }   
+}   
+
+_p.getIconAction = function () {
+       if (this.iconAction)
+               return this.iconAction;
+       return _p.getAction();
+};
+
 // update methods
 
 _p.update = function () {
@@ -1130,10 +1154,17 @@ _p._onclick = function (e) {
                return false;
        }
 
-       if (typeof this.action == "function") {
-               this.action();
-       } else if (this.action != null) {
-               window.open(this.action, this.target || "_self");
+       var doAction = null;
+       if (/webfx-tree-icon/.test(el.className) && this.iconAction) {
+               doAction = this.iconAction; 
+       } else {
+               doAction = this.action;
+       }
+
+       if (typeof doAction == "function") {
+               doAction();
+       } else if (doAction != null) {
+               window.open(doAction, this.target || "_self");
        }
        return false;
 };
@@ -1289,8 +1320,8 @@ _p.getPreviousShownNode = function () {
 // WebFXTree
 ///////////////////////////////////////////////////////////////////////////////
 
-function WebFXTree(sText, oAction, sBehavior, sIcon, sOpenIcon) {
-       WebFXTreeAbstractNode.call(this, sText, oAction);
+function WebFXTree(sText, oAction, sBehavior, sIcon, oIconAction, sOpenIcon) {
+       WebFXTreeAbstractNode.call(this, sText, oAction, oIconAction);
        if (sIcon) this.icon = sIcon;
        if (sOpenIcon) this.openIcon = sOpenIcon;
        if (sBehavior) this.behavior = sBehavior;
@@ -1505,8 +1536,8 @@ _p.getSuspendRedraw = function () {
 // WebFXTreeItem
 ///////////////////////////////////////////////////////////////////////////////
 
-function WebFXTreeItem(sText, oAction, eParent, sIcon, sOpenIcon) {
-       WebFXTreeAbstractNode.call(this, sText, oAction);
+function WebFXTreeItem(sText, oAction, eParent, sIcon, oIconAction, sOpenIcon) {
+       WebFXTreeAbstractNode.call(this, sText, oAction, oIconAction);
        if (sIcon) this.icon = sIcon;
        if (sOpenIcon) this.openIcon = sOpenIcon;
        if (eParent) eParent.add(this);