[ Index ] |
PHP Cross Reference of Project Glazy import |
[Summary view] [Print] [Text view]
1 // Title: Tigra Tree 2 // Description: See the demo at url 3 // URL: http://www.softcomplex.com/products/tigra_menu_tree/ 4 // Version: 1.1 5 // Date: 11-12-2002 (mm-dd-yyyy) 6 // Contact: feedback@softcomplex.com (specify product title in the subject) 7 // Notes: This script is free. Visit official site for further details. 8 9 // Note by Gareth: Although this script is free, and permission to distribute it 10 // with PHPXref has explicitly been granted, it is not licensed under the GPL. 11 // If you know of a GPLd alternative, please let me know. 12 13 var root = ''; 14 15 // extension by Gareth 16 // locates a node in the tree matching a specified URL, 17 // opens it and scrolls to it. 18 function open_branch(name) { 19 if (!root) 20 return; 21 var name=name.replace(/^.\//,''); 22 var name=name.replace(/\/+$/,''); 23 var nodes=name.split('/'); 24 var current=root; 25 var cid=0; 26 for (var nid=0; nid<nodes.length; nid++) { 27 var matched=false; 28 current=current.a_children[cid]; /* root entry always has a 1 length array */ 29 for (var cid=0; cid<current.a_children.length; cid++) { 30 childpath=current.a_children[cid].a_config[1]; 31 childnodes=childpath.split('/'); 32 if (nodes[nid]==childnodes[nid]) { 33 matched=1; 34 if (!current.a_children[cid].b_opened) 35 current.a_children[cid].open(0); 36 break; 37 } 38 } 39 if (!matched) 40 break; 41 } 42 if (matched) { 43 current.a_children[cid].select(0); 44 var o_itxt = get_element('i_txt' + current.a_children[cid].o_root.n_id + '_' + current.a_children[cid].n_id); 45 o_itxt.scrollIntoView(); 46 } 47 } 48 49 function tree (a_items, a_template) { 50 51 this.a_tpl = a_template; 52 this.a_config = a_items; 53 this.o_root = this; 54 this.a_index = []; 55 this.o_selected = null; 56 this.n_depth = -1; 57 58 var o_icone = new Image(), 59 o_iconl = new Image(); 60 o_icone.src = a_template['icon_e']; 61 o_iconl.src = a_template['icon_l']; 62 a_template['im_e'] = o_icone; 63 a_template['im_l'] = o_iconl; 64 for (var i = 0; i < 64; i++) 65 if (a_template['icon_' + i]) { 66 var o_icon = new Image(); 67 a_template['im_' + i] = o_icon; 68 o_icon.src = a_template['icon_' + i]; 69 } 70 71 this.toggle = function (n_id) { var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) }; 72 this.select = function (n_id) { return this.a_index[n_id].select(); }; 73 this.mout = function (n_id) { this.a_index[n_id].upstatus(true) }; 74 this.mover = function (n_id) { this.a_index[n_id].upstatus() }; 75 76 this.a_children = []; 77 for (var i = 0; i < a_items.length; i++) 78 new tree_item(this, i); 79 80 this.n_id = trees.length; 81 trees[this.n_id] = this; 82 83 for (var i = 0; i < this.a_children.length; i++) { 84 document.write(this.a_children[i].init()); 85 this.a_children[i].open(); 86 } 87 } 88 function tree_item (o_parent, n_order) { 89 90 this.n_depth = o_parent.n_depth + 1; 91 this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)]; 92 if (!this.a_config) return; 93 94 this.o_root = o_parent.o_root; 95 this.o_parent = o_parent; 96 this.n_order = n_order; 97 this.b_opened = !this.n_depth; 98 99 this.n_id = this.o_root.a_index.length; 100 this.o_root.a_index[this.n_id] = this; 101 o_parent.a_children[n_order] = this; 102 103 this.a_children = []; 104 for (var i = 0; i < this.a_config.length - 2; i++) 105 new tree_item(this, i); 106 107 this.get_icon = item_get_icon; 108 this.open = item_open; 109 this.select = item_select; 110 this.init = item_init; 111 this.upstatus = item_upstatus; 112 this.is_last = function () { return this.n_order == this.o_parent.a_children.length - 1 }; 113 } 114 115 function item_open (b_close) { 116 var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id); 117 if (!o_idiv) return; 118 119 if (!o_idiv.innerHTML) { 120 var a_children = []; 121 for (var i = 0; i < this.a_children.length; i++) 122 a_children[i]= this.a_children[i].init(); 123 o_idiv.innerHTML = a_children.join(''); 124 } 125 o_idiv.style.display = (b_close ? 'none' : 'block'); 126 127 this.b_opened = !b_close; 128 var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id], 129 o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id]; 130 if (o_jicon) o_jicon.src = this.get_icon(true); 131 if (o_iicon) o_iicon.src = this.get_icon(); 132 this.upstatus(); 133 } 134 135 function item_select (b_deselect) { 136 if (!b_deselect) { 137 var o_olditem = this.o_root.o_selected; 138 this.o_root.o_selected = this; 139 if (o_olditem) o_olditem.select(true); 140 } 141 var o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id]; 142 if (o_iicon) o_iicon.src = this.get_icon(); 143 get_element('i_txt' + this.o_root.n_id + '_' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'bold'; 144 145 this.upstatus(); 146 return Boolean(this.a_config[1]); 147 } 148 149 function item_upstatus (b_clear) { 150 window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10); 151 } 152 153 function item_init () { 154 var a_offset = [], 155 o_current_item = this.o_parent; 156 for (var i = this.n_depth; i > 1; i--) { 157 a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">'; 158 o_current_item = o_current_item.o_parent; 159 } 160 return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap>' + (this.n_depth ? a_offset.join('') + (this.a_children.length 161 ? '<a href="javascript: trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')"><img src="' + this.get_icon(true) + '" border="0" align="absbottom" name="j_img' + this.o_root.n_id + '_' + this.n_id + '"></a>' 162 : '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') 163 + '<a href="' + this.a_config[1] + '" target="' + this.o_root.a_tpl['target'] + '" onclick="return trees[' + this.o_root.n_id + '].select(' + this.n_id + ')" ondblclick="trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')" class="t' + this.o_root.n_id + 'i" id="i_txt' + this.o_root.n_id + '_' + this.n_id + '"><img src="' + this.get_icon() + '" border="0" align="absbottom" name="i_img' + this.o_root.n_id + '_' + this.n_id + '" class="t' + this.o_root.n_id + 'im">' + this.a_config[0] + '</a></td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.o_root.n_id + '_' + this.n_id + '" style="display:none"></div>' : ''); 164 } 165 166 function item_get_icon (b_junction) { 167 return this.o_root.a_tpl['icon_' + ((this.n_depth ? 0 : 32) + (this.a_children.length ? 16 : 0) + (this.a_children.length && this.b_opened ? 8 : 0) + (!b_junction && this.o_root.o_selected == this ? 4 : 0) + (b_junction ? 2 : 0) + (b_junction && this.is_last() ? 1 : 0))]; 168 } 169 170 var trees = []; 171 get_element = document.all ? 172 function (s_id) { return document.all[s_id] } : 173 function (s_id) { return document.getElementById(s_id) }; 174
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Sep 14 11:31:49 2023 | Cross-referenced by PHPXref 0.7.1 |