61 a_template['im_' + i] = o_icon; |
61 a_template['im_' + i] = o_icon; |
62 o_icon.src = a_template['icon_' + i]; |
62 o_icon.src = a_template['icon_' + i]; |
63 } |
63 } |
64 |
64 |
65 this.toggle = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened,co); }; |
65 this.toggle = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened,co); }; |
66 this.open = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(false,co); }; |
66 this.open = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(false,co); }; |
67 this.select = function (n_id) { return this.a_index[n_id].select(); }; |
67 this.select = function (n_id) { return this.a_index[n_id].select(); }; |
68 this.mout = function (n_id) { this.a_index[n_id].upstatus(true) }; |
68 this.mout = function (n_id) { this.a_index[n_id].upstatus(true) }; |
69 this.mover = function (n_id) { this.a_index[n_id].upstatus() }; |
69 this.mover = function (n_id) { this.a_index[n_id].upstatus() }; |
70 |
70 |
71 this.a_children = []; |
71 this.a_children = []; |
72 for (var i = 0; i < a_items.length; i++) |
72 for (var i = 0; i < a_items.length; i++) |
73 { |
73 { |
74 new tree_item(this, i); |
74 new tree_item(this, i); |
75 } |
75 } |
76 |
76 |
77 this.n_id = trees.length; |
77 this.n_id = trees.length; |
78 trees[this.n_id] = this; |
78 trees[this.n_id] = this; |
79 |
79 |
80 for (var i = 0; i < this.a_children.length; i++) |
80 for (var i = 0; i < this.a_children.length; i++) |
81 { |
81 { |
82 if ( s_target ) |
82 if ( s_target ) |
83 document.getElementById(s_target).innerHTML += this.a_children[i].init(); |
83 document.getElementById(s_target).innerHTML += this.a_children[i].init(); |
84 else |
84 else |
85 document.write(this.a_children[i].init()); |
85 document.write(this.a_children[i].init()); |
86 this.a_children[i].open(false, true); |
86 this.a_children[i].open(false, true); |
87 } |
87 } |
88 } |
88 } |
89 function tree_item (o_parent, n_order) { |
89 function tree_item (o_parent, n_order) { |
90 |
90 |
101 this.o_root.a_index[this.n_id] = this; |
101 this.o_root.a_index[this.n_id] = this; |
102 o_parent.a_children[n_order] = this; |
102 o_parent.a_children[n_order] = this; |
103 |
103 |
104 this.a_children = []; |
104 this.a_children = []; |
105 for (var i = 0; i < this.a_config.length - 2; i++) |
105 for (var i = 0; i < this.a_config.length - 2; i++) |
106 { |
106 { |
107 new tree_item(this, i); |
107 new tree_item(this, i); |
108 } |
108 } |
109 |
109 |
110 this.get_icon = item_get_icon; |
110 this.get_icon = item_get_icon; |
111 this.open = item_open; |
111 this.open = item_open; |
112 this.select = item_select; |
112 this.select = item_select; |
113 this.init = item_init; |
113 this.init = item_init; |
114 this.upstatus = item_upstatus; |
114 this.upstatus = item_upstatus; |
115 this.is_last = function () { return this.n_order == this.o_parent.a_children.length - 1 }; |
115 this.is_last = function () { return this.n_order == this.o_parent.a_children.length - 1 }; |
116 |
116 |
117 // CODE MODIFICATION |
117 // CODE MODIFICATION |
118 // added: |
118 // added: |
119 // Do we need to open the branch? |
119 // Do we need to open the branch? |
120 n = Math.pow(2, this.n_id); |
120 n = Math.pow(2, this.n_id); |
121 var disp = ( ck & n ) ? true : false; |
121 var disp = ( ck & n ) ? true : false; |
122 s = ( disp ) ? 'open' : 'closed'; |
122 s = ( disp ) ? 'open' : 'closed'; |
123 //if(s=='open') alert(this.n_id + ': ' + s); |
123 //if(s=='open') alert(this.n_id + ': ' + s); |
124 if(disp) setTimeout('trees['+trees.length+'].open('+this.n_id+', true);', 10); |
124 if(disp) setTimeout('trees['+trees.length+'].open('+this.n_id+', true);', 10); |
125 // END MODIFICATIONS |
125 // END MODIFICATIONS |
126 } |
126 } |
127 |
127 |
128 function item_open (b_close, nocookie) { |
128 function item_open (b_close, nocookie) { |
129 //alert('item_open('+this.n_id+');'); |
129 //alert('item_open('+this.n_id+');'); |
130 var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id); |
130 var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id); |
131 if (!o_idiv) return; |
131 if (!o_idiv) return; |
132 |
132 |
133 if (!o_idiv.innerHTML) { |
133 if (!o_idiv.innerHTML) { |
134 var a_children = []; |
134 var a_children = []; |
135 for (var i = 0; i < this.a_children.length; i++) |
135 for (var i = 0; i < this.a_children.length; i++) |
136 { |
136 { |
137 a_children[i]= this.a_children[i].init(); |
137 a_children[i]= this.a_children[i].init(); |
138 } |
138 } |
139 o_idiv.innerHTML = a_children.join(''); |
139 o_idiv.innerHTML = a_children.join(''); |
140 } |
140 } |
141 o_idiv.style.display = (b_close ? 'none' : 'block'); |
141 o_idiv.style.display = (b_close ? 'none' : 'block'); |
142 |
142 |
143 // CODE MODIFICATION |
143 // CODE MODIFICATION |
144 // added: |
144 // added: |
145 if(!nocookie) |
145 if(!nocookie) |
146 { |
146 { |
147 // The idea here is to use a bitwise field. Nice 'n simple, right? Object of the game is to assemble |
147 // The idea here is to use a bitwise field. Nice 'n simple, right? Object of the game is to assemble |
148 // a binary number that depicts the open/closed state of the entire menu in one cookie. |
148 // a binary number that depicts the open/closed state of the entire menu in one cookie. |
149 n = Math.pow(2, this.n_id); |
149 n = Math.pow(2, this.n_id); |
150 ck = ( b_close ) ? ck-n : ck+n; |
150 ck = ( b_close ) ? ck-n : ck+n; |
151 //alert('open(): doing the cookie routine for id '+this.n_id+"\nResult for bitwise op: "+ck); |
151 //alert('open(): doing the cookie routine for id '+this.n_id+"\nResult for bitwise op: "+ck); |
152 createCookie('admin_menu_state', ck, 365); |
152 createCookie('admin_menu_state', ck, 365); |
153 } else { |
153 } else { |
154 //alert('open(): NOT doing the cookie routine for id '+this.n_id); |
154 //alert('open(): NOT doing the cookie routine for id '+this.n_id); |
155 } |
155 } |
156 // END MODIFICATIONS |
156 // END MODIFICATIONS |
157 |
157 |
158 this.b_opened = !b_close; |
158 this.b_opened = !b_close; |
159 var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id], |
159 var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id], |
160 o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id]; |
160 o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id]; |
161 if (o_jicon) o_jicon.src = this.get_icon(true); |
161 if (o_jicon) o_jicon.src = this.get_icon(true); |
189 o_current_item = o_current_item.o_parent; |
189 o_current_item = o_current_item.o_parent; |
190 } |
190 } |
191 return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap="nowrap">' + (this.n_depth ? a_offset.join('') + (this.a_children.length |
191 return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap="nowrap">' + (this.n_depth ? a_offset.join('') + (this.a_children.length |
192 ? '<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>' |
192 ? '<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>' |
193 : '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') |
193 : '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') |
194 // CODE MODIFICATION |
194 // CODE MODIFICATION |
195 // [7/20/08: removed ondblclick property (unneeded)] |
195 // [7/20/08: removed ondblclick property (unneeded)] |
196 // removed: |
196 // removed: |
197 // + '<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>' : ''); |
197 // + '<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>' : ''); |
198 // added: |
198 // added: |
199 + '<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 + ')" 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 + '">' + 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>' : ''); |
199 + '<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 + ')" 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 + '">' + 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>' : ''); |
200 // END MODIFICATIONS |
200 // END MODIFICATIONS |
201 alert('i_div' + this.o_root.n_id + '_' + this.n_id); |
201 alert('i_div' + this.o_root.n_id + '_' + this.n_id); |
202 } |
202 } |
203 |
203 |
204 function item_get_icon (b_junction) { |
204 function item_get_icon (b_junction) { |
205 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))]; |
205 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))]; |
206 } |
206 } |
210 function (s_id) { return document.all[s_id] } : |
210 function (s_id) { return document.all[s_id] } : |
211 function (s_id) { return document.getElementById(s_id) }; |
211 function (s_id) { return document.getElementById(s_id) }; |
212 |
212 |
213 function addslashes(text) |
213 function addslashes(text) |
214 { |
214 { |
215 text = text.replace(/\\/g, '\\\\'); |
215 text = text.replace(/\\/g, '\\\\'); |
216 text = text.replace(/"/g, '\\"'); |
216 text = text.replace(/"/g, '\\"'); |
217 return text; |
217 return text; |
218 } |
218 } |
219 |
219 |
220 // ******************************************* |
220 // ******************************************* |
221 // Table collapsing |
221 // Table collapsing |
222 // ******************************************* |
222 // ******************************************* |
223 |
223 |
224 function admin_table_onload(page) |
224 function admin_table_onload(page) |
225 { |
225 { |
226 if ( page != namespace_list['Admin'] + 'GeneralConfig' ) |
226 if ( page != namespace_list['Admin'] + 'GeneralConfig' ) |
227 { |
227 { |
228 return true; |
228 return true; |
229 } |
229 } |
230 var collapse_state = admin_table_get_cookie(page); |
230 var collapse_state = admin_table_get_cookie(page); |
231 if ( collapse_state == 0 ) |
231 if ( collapse_state == 0 ) |
232 collapse_state = 0xffffffff; |
232 collapse_state = 0xffffffff; |
233 $('#ajaxPageContainer > form > div.tblholder > table').each(function(i, table) |
233 $('#ajaxPageContainer > form > div.tblholder > table').each(function(i, table) |
234 { |
234 { |
235 // skip if this is a one-row table |
235 // skip if this is a one-row table |
236 if ( $('tr:first', table).get(0) == $('tr:last', table).get(0) ) |
236 if ( $('tr:first', table).get(0) == $('tr:last', table).get(0) ) |
237 return; |
237 return; |
238 |
238 |
239 var open = (collapse_state >> i) & 1 > 0 ? true : false; |
239 var open = (collapse_state >> i) & 1 > 0 ? true : false; |
240 |
240 |
241 var ypos = open ? 0 : 12; |
241 var ypos = open ? 0 : 12; |
242 |
242 |
243 var div = document.createElement('div'); |
243 var div = document.createElement('div'); |
244 $(div).html(gen_sprite_html(scriptPath + '/themes/admin/images/thcollapse.png', 12, 12, ypos, 0)); |
244 $(div).html(gen_sprite_html(scriptPath + '/themes/admin/images/thcollapse.png', 12, 12, ypos, 0)); |
245 $(div).click(function() |
245 $(div).click(function() |
246 { |
246 { |
247 admin_table_click(this); |
247 admin_table_click(this); |
248 }).css('cursor', 'pointer').css('float', 'right'); |
248 }).css('cursor', 'pointer').css('float', 'right'); |
249 div.thetable = table; |
249 div.thetable = table; |
250 div.index = i; |
250 div.index = i; |
251 div.thepage = page; |
251 div.thepage = page; |
252 div.openstate = open; |
252 div.openstate = open; |
253 $('tr > th:first', table).prepend(div); |
253 $('tr > th:first', table).prepend(div); |
254 if ( !open ) |
254 if ( !open ) |
255 admin_table_collapse(table, true); |
255 admin_table_collapse(table, true); |
256 }); |
256 }); |
257 } |
257 } |
258 |
258 |
259 function admin_table_click(mydiv) |
259 function admin_table_click(mydiv) |
260 { |
260 { |
261 var table = mydiv.thetable; |
261 var table = mydiv.thetable; |
262 var i = mydiv.index; |
262 var i = mydiv.index; |
263 var page = mydiv.thepage; |
263 var page = mydiv.thepage; |
264 var collapse_state = admin_table_get_cookie(page); |
264 var collapse_state = admin_table_get_cookie(page); |
265 |
265 |
266 if ( mydiv.openstate ) |
266 if ( mydiv.openstate ) |
267 { |
267 { |
268 $('img', mydiv).css('background-position', '0px -12px'); |
268 $('img', mydiv).css('background-position', '0px -12px'); |
269 var new_collapse_state = collapse_state & ~Math.pow(2, i); |
269 var new_collapse_state = collapse_state & ~Math.pow(2, i); |
270 console.debug(new_collapse_state); |
270 console.debug(new_collapse_state); |
271 mydiv.openstate = false; |
271 mydiv.openstate = false; |
272 admin_table_collapse(table); |
272 admin_table_collapse(table); |
273 } |
273 } |
274 else |
274 else |
275 { |
275 { |
276 $('img', mydiv).css('background-position', '0px 0px'); |
276 $('img', mydiv).css('background-position', '0px 0px'); |
277 var new_collapse_state = collapse_state | Math.pow(2, i); |
277 var new_collapse_state = collapse_state | Math.pow(2, i); |
278 console.debug(new_collapse_state); |
278 console.debug(new_collapse_state); |
279 mydiv.openstate = true; |
279 mydiv.openstate = true; |
280 admin_table_expand(table); |
280 admin_table_expand(table); |
281 } |
281 } |
282 createCookie('admin_th:' + page, new_collapse_state, 3650); |
282 createCookie('admin_th:' + page, new_collapse_state, 3650); |
283 } |
283 } |
284 |
284 |
285 function admin_table_get_cookie(page) |
285 function admin_table_get_cookie(page) |
286 { |
286 { |
287 var cookievalue = parseInt(readCookie('admin_th:' + page)); |
287 var cookievalue = parseInt(readCookie('admin_th:' + page)); |
288 if ( isNaN(cookievalue) ) |
288 if ( isNaN(cookievalue) ) |
289 cookievalue = 0; |
289 cookievalue = 0; |
290 return cookievalue; |
290 return cookievalue; |
291 } |
291 } |
292 |
292 |
293 function admin_table_collapse(table, noanim) |
293 function admin_table_collapse(table, noanim) |
294 { |
294 { |
295 var targetheight = $('tr > th:first', table).height(); |
295 var targetheight = $('tr > th:first', table).height(); |
296 $('tr', table).hide(); |
296 $('tr', table).hide(); |
297 $('tr:first', table).show(); |
297 $('tr:first', table).show(); |
298 } |
298 } |
299 |
299 |
300 function admin_table_expand(table) |
300 function admin_table_expand(table) |
301 { |
301 { |
302 $('tr', table).show(); |
302 $('tr', table).show(); |
303 } |
303 } |