summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxzilla2006-06-23 00:57:37 +0000
committerxzilla2006-06-23 00:57:37 +0000
commit64b18c1b63510f32a1b67424908d5d8e58a68a49 (patch)
tree824dca11d9b7be4af24650befb4fd8b080c69d40
parent6ae43577b6728dcedc0068278afd64b887af2c9c (diff)
Add links to the icons in the tree menu, just like back in the good ole days. Patch from
-rw-r--r--classes/Misc.php4
-rw-r--r--tables.php6
-rw-r--r--views.php6
-rw-r--r--xloadtree/xloadtree2.js14
-rw-r--r--xloadtree/xtree2.js51
5 files changed, 62 insertions, 19 deletions
diff --git a/classes/Misc.php b/classes/Misc.php
index d6656529..65a6a263 100644
--- a/classes/Misc.php
+++ b/classes/Misc.php
@@ -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 {
@@ -1571,6 +1571,7 @@
* '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
@@ -1600,6 +1601,7 @@
$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));
diff --git a/tables.php b/tables.php
index cf4f1890..05b2f2b2 100644
--- a/tables.php
+++ b/tables.php
@@ -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
@@ -638,6 +638,10 @@
$attrs = array(
'text' => field('relname'),
'icon' => 'Table',
+ 'iconAction' => url('display.php',
+ $reqvars,
+ array('table' => field('relname'))
+ ),
'toolTip'=> field('relcomment'),
'action' => url('redirect.php',
$reqvars,
diff --git a/views.php b/views.php
index f763dc9e..74412a6b 100644
--- 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
@@ -596,6 +596,10 @@
$attrs = array(
'text' => field('relname'),
'icon' => 'View',
+ 'iconAction' => url('display.php',
+ $reqvars,
+ array('view' => field('relname'))
+ ),
'toolTip'=> field('relcomment'),
'action' => url('redirect.php',
$reqvars,
diff --git a/xloadtree/xloadtree2.js b/xloadtree/xloadtree2.js
index 78b3e55b..1b23353b 100644
--- a/xloadtree/xloadtree2.js
+++ b/xloadtree/xloadtree2.js
@@ -48,7 +48,9 @@
|-----------------------------------------------------------------------------|
| Created 2003-??-?? | All changes are in the log above. | Updated 2004-06-06 |
\----------------------------------------------------------------------------*/
-
+| Note local changes have been made to allow Icons to have different links |
+| than thier text label counterparts. Thanks to JGuillaume de Rorthais |
+|-----------------------------------------------------------------------------|
webFXTreeConfig.loadingText = "Loading...";
webFXTreeConfig.loadingIcon = "images/loading.gif";
@@ -57,8 +59,8 @@ webFXTreeConfig.errorIcon = "images/exclamation.16.png";
webFXTreeConfig.reloadText = "Click to reload";
-function WebFXLoadTree(sText, sXmlSrc, oAction, sBehavior, sIcon, sOpenIcon) {
- WebFXTree.call(this, sText, oAction, sBehavior, sIcon, sOpenIcon);
+function WebFXLoadTree(sText, sXmlSrc, oAction, sBehavior, sIcon, oIconAction, sOpenIcon) {
+ WebFXTree.call(this, sText, oAction, sBehavior, sIcon, oIconAction, sOpenIcon);
// setup default property values
this.src = sXmlSrc;
@@ -95,8 +97,8 @@ _p.setExpanded = function (b) {
}
};
-function WebFXLoadTreeItem(sText, sXmlSrc, oAction, eParent, sIcon, sOpenIcon) {
- WebFXTreeItem.call(this, sText, oAction, eParent, sIcon, sOpenIcon);
+function WebFXLoadTreeItem(sText, sXmlSrc, oAction, eParent, sIcon, oIconAction, sOpenIcon) {
+ WebFXTreeItem.call(this, sText, oAction, eParent, sIcon, oIconAction, sOpenIcon);
// setup default property values
this.src = sXmlSrc;
@@ -302,7 +304,7 @@ WebFXLoadTree.createItemFromElement = function (oNode) {
action = jsAttrs.action;
}
var jsNode = new WebFXLoadTreeItem(jsAttrs.html || "", jsAttrs.src, action,
- null, jsAttrs.icon, jsAttrs.openIcon);
+ null, jsAttrs.icon, jsAttrs.iconAction, jsAttrs.openIcon);
if (jsAttrs.text) {
jsNode.setText(jsAttrs.text);
}
diff --git a/xloadtree/xtree2.js b/xloadtree/xtree2.js
index 156789b3..9913fa00 100644
--- a/xloadtree/xtree2.js
+++ b/xloadtree/xtree2.js
@@ -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);