# HG changeset patch # User Dan Fuhry # Date 1363148303 14400 # Node ID 35b0a72083ca0ede2a575e2df15d44d9c92f219e # Parent 95d9e7eacc83782ccc26061a39a87ce2b51060c6 Compatibility band-aids diff -r 95d9e7eacc83 -r 35b0a72083ca includes/clientside/static/admin-menu.js --- a/includes/clientside/static/admin-menu.js Tue Jul 12 22:49:29 2011 -0400 +++ b/includes/clientside/static/admin-menu.js Wed Mar 13 00:18:23 2013 -0400 @@ -7,9 +7,6 @@ * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * Some code found in this script is not licensed under the GNU General Public License; however, it is believed that the license terms shown - * below are GPL-compatible. If you believe that this is not the case, please drop a note to support@enano.homelinux.org. */ /* @@ -20,39 +17,30 @@ * Date: 11-12-2002 (mm-dd-yyyy) * Notes: This script is free. Visit official site for further details. * - * There is no license fee or royalty fee to be paid at any time for using the Tigra Tree Menu v1.x - * You may include the source code or modified source code within your own projects for either personal - * or commercial use but excluding the restrictions outlined below. The following restrictions apply to - * all parts of the component, including all source code, samples and documentation. - * - * - Header block of script file (tree.js) CAN NOT be modified or removed. - * - The above items CAN NOT be sold as are, either individually or together. - * - The above items CAN NOT be modified and then sold as a library component, either individually or together. - * * Due to the unclear licensing conditions on this script, I contacted the author, who said that because Enano - * is not a "competing product" I was allowed to treat the code as GPL. The conversation can be seen in the - * /licenses/tigra-menu.html document in the Enano distribution. + * is not a "competing product" I was allowed release the modified code as GPL. The conversation can be seen in the + * licenses/tigra-menu.html document in the Enano distribution. */ -if ( typeof(readCookie) == 'function' ) +if ( /admin_menu_state=/.test(document.cookie) ) { - var ck = readCookie('admin_menu_state'); - if(ck) - { - ck = parseInt(ck); - } - else - { - ck = 0; - } - ck = ( isNaN(ck) ) ? 0 : ck; + var ck = (String(document.cookie).match(/admin_menu_state=([0-9]+)/))[1]; + if(ck) + { + ck = parseInt(ck); + } + else + { + ck = 0; + } + ck = ( isNaN(ck) ) ? 0 : ck; } else { - var ck = 0; + var ck = 0; } -function tree (a_items, a_template) { +function tree (a_items, a_template, s_target) { this.a_tpl = a_template; this.a_config = a_items; @@ -75,22 +63,26 @@ } this.toggle = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened,co); }; - this.open = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(false,co); }; + this.open = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(false,co); }; this.select = function (n_id) { return this.a_index[n_id].select(); }; this.mout = function (n_id) { this.a_index[n_id].upstatus(true) }; this.mover = function (n_id) { this.a_index[n_id].upstatus() }; this.a_children = []; for (var i = 0; i < a_items.length; i++) - { + { new tree_item(this, i); - } + } this.n_id = trees.length; trees[this.n_id] = this; - for (var i = 0; i < this.a_children.length; i++) { - document.write(this.a_children[i].init()); + for (var i = 0; i < this.a_children.length; i++) + { + if ( s_target ) + document.getElementById(s_target).innerHTML += this.a_children[i].init(); + else + document.write(this.a_children[i].init()); this.a_children[i].open(false, true); } } @@ -111,57 +103,57 @@ this.a_children = []; for (var i = 0; i < this.a_config.length - 2; i++) - { + { new tree_item(this, i); - } - + } + this.get_icon = item_get_icon; this.open = item_open; this.select = item_select; this.init = item_init; this.upstatus = item_upstatus; this.is_last = function () { return this.n_order == this.o_parent.a_children.length - 1 }; - - // CODE MODIFICATION - // added: - // Do we need to open the branch? - n = Math.pow(2, this.n_id); - var disp = ( ck & n ) ? true : false; - s = ( disp ) ? 'open' : 'closed'; - //if(s=='open') alert(this.n_id + ': ' + s); - if(disp) setTimeout('trees['+trees.length+'].open('+this.n_id+', true);', 10); - // END MODIFICATIONS + + // CODE MODIFICATION + // added: + // Do we need to open the branch? + n = Math.pow(2, this.n_id); + var disp = ( ck & n ) ? true : false; + s = ( disp ) ? 'open' : 'closed'; + //if(s=='open') alert(this.n_id + ': ' + s); + if(disp) setTimeout('trees['+trees.length+'].open('+this.n_id+', true);', 10); + // END MODIFICATIONS } function item_open (b_close, nocookie) { - //alert('item_open('+this.n_id+');'); + //alert('item_open('+this.n_id+');'); var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id); if (!o_idiv) return; if (!o_idiv.innerHTML) { var a_children = []; for (var i = 0; i < this.a_children.length; i++) - { + { a_children[i]= this.a_children[i].init(); - } + } o_idiv.innerHTML = a_children.join(''); } o_idiv.style.display = (b_close ? 'none' : 'block'); - - // CODE MODIFICATION - // added: - if(!nocookie) - { - // The idea here is to use a bitwise field. Nice 'n simple, right? Object of the game is to assemble - // a binary number that depicts the open/closed state of the entire menu in one cookie. - n = Math.pow(2, this.n_id); - ck = ( b_close ) ? ck-n : ck+n; - //alert('open(): doing the cookie routine for id '+this.n_id+"\nResult for bitwise op: "+ck); - createCookie('admin_menu_state', ck, 365); - } else { - //alert('open(): NOT doing the cookie routine for id '+this.n_id); - } - // END MODIFICATIONS + + // CODE MODIFICATION + // added: + if(!nocookie) + { + // The idea here is to use a bitwise field. Nice 'n simple, right? Object of the game is to assemble + // a binary number that depicts the open/closed state of the entire menu in one cookie. + n = Math.pow(2, this.n_id); + ck = ( b_close ) ? ck-n : ck+n; + //alert('open(): doing the cookie routine for id '+this.n_id+"\nResult for bitwise op: "+ck); + createCookie('admin_menu_state', ck, 365); + } else { + //alert('open(): NOT doing the cookie routine for id '+this.n_id); + } + // END MODIFICATIONS this.b_opened = !b_close; var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id], @@ -186,7 +178,7 @@ } function item_upstatus (b_clear) { - window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10); + window.setTimeout('window.status="' + addslashes(b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10); } function item_init () { @@ -199,13 +191,14 @@ return '
' + (this.n_depth ? a_offset.join('') + (this.a_children.length ? '' : '') : '') - // CODE MODIFICATION - // removed: + // CODE MODIFICATION + // [7/20/08: removed ondblclick property (unneeded)] + // removed: // + '' + this.a_config[0] + '
' + (this.a_children.length ? '' : ''); - // added: - + '' + this.a_config[0] + '' + (this.a_children.length ? '' : ''); - // END MODIFICATIONS - alert('i_div' + this.o_root.n_id + '_' + this.n_id); + // added: + + '' + this.a_config[0] + '' + (this.a_children.length ? '' : ''); + // END MODIFICATIONS + alert('i_div' + this.o_root.n_id + '_' + this.n_id); } function item_get_icon (b_junction) { @@ -217,4 +210,94 @@ function (s_id) { return document.all[s_id] } : function (s_id) { return document.getElementById(s_id) }; +function addslashes(text) +{ + text = text.replace(/\\/g, '\\\\'); + text = text.replace(/"/g, '\\"'); + return text; +} +// ******************************************* +// Table collapsing +// ******************************************* + +function admin_table_onload(page) +{ + if ( page != namespace_list['Admin'] + 'GeneralConfig' ) + { + return true; + } + var collapse_state = admin_table_get_cookie(page); + if ( collapse_state == 0 ) + collapse_state = 0xffffffff; + $('#ajaxPageContainer > form > div.tblholder > table').each(function(i, table) + { + // skip if this is a one-row table + if ( $('tr:first', table).get(0) == $('tr:last', table).get(0) ) + return; + + var open = (collapse_state >> i) & 1 > 0 ? true : false; + + var ypos = open ? 0 : 12; + + var div = document.createElement('div'); + $(div).html(gen_sprite_html(scriptPath + '/themes/admin/images/thcollapse.png', 12, 12, ypos, 0)); + $(div).click(function() + { + admin_table_click(this); + }).css('cursor', 'pointer').css('float', 'right'); + div.thetable = table; + div.index = i; + div.thepage = page; + div.openstate = open; + $('tr > th:first', table).prepend(div); + if ( !open ) + admin_table_collapse(table, true); + }); +} + +function admin_table_click(mydiv) +{ + var table = mydiv.thetable; + var i = mydiv.index; + var page = mydiv.thepage; + var collapse_state = admin_table_get_cookie(page); + + if ( mydiv.openstate ) + { + $('img', mydiv).css('background-position', '0px -12px'); + var new_collapse_state = collapse_state & ~Math.pow(2, i); + console.debug(new_collapse_state); + mydiv.openstate = false; + admin_table_collapse(table); + } + else + { + $('img', mydiv).css('background-position', '0px 0px'); + var new_collapse_state = collapse_state | Math.pow(2, i); + console.debug(new_collapse_state); + mydiv.openstate = true; + admin_table_expand(table); + } + createCookie('admin_th:' + page, new_collapse_state, 3650); +} + +function admin_table_get_cookie(page) +{ + var cookievalue = parseInt(readCookie('admin_th:' + page)); + if ( isNaN(cookievalue) ) + cookievalue = 0; + return cookievalue; +} + +function admin_table_collapse(table, noanim) +{ + var targetheight = $('tr > th:first', table).height(); + $('tr', table).hide(); + $('tr:first', table).show(); +} + +function admin_table_expand(table) +{ + $('tr', table).show(); +} diff -r 95d9e7eacc83 -r 35b0a72083ca includes/functions.php --- a/includes/functions.php Tue Jul 12 22:49:29 2011 -0400 +++ b/includes/functions.php Wed Mar 13 00:18:23 2013 -0400 @@ -1334,6 +1334,7 @@ * @param text string hexadecimal number * @return string */ +if ( !function_exists("hex2bin") ): function hex2bin($text) { $arr = enano_str_split($text, 2); @@ -1344,6 +1345,7 @@ } return $ret; } +endif; /** * Generates and/or prints a human-readable backtrace diff -r 95d9e7eacc83 -r 35b0a72083ca plugins/SpecialAdmin.php --- a/plugins/SpecialAdmin.php Tue Jul 12 22:49:29 2011 -0400 +++ b/plugins/SpecialAdmin.php Wed Mar 13 00:18:23 2013 -0400 @@ -2402,21 +2402,16 @@ 'icon_26' : '/images/icons/minusbottom.gif',// junction for opened node 'icon_27' : '/images/icons/minus.gif' // junction for last opended node }; - addOnloadHook(keepalive_onload); + if ( typeof(keepalive_onload) == 'function' ) + addOnloadHook(keepalive_onload); parseAdminTree(); // Make a Javascript array that defines the tree - if(!isset($_GET['module'])) { echo 'addOnloadHook(_enanoAdminOnload);'; } ?> + if(!isset($_GET['module'])) { echo 'addOnloadHook(function() { _enanoAdminOnload(); new tree(TREE_ITEMS, TREE_TPL, \'admin_tree\'); } )'; } ?>
-
- +
@@ -3010,4 +3005,4 @@ $template->footer(); } -?> \ No newline at end of file +?>