From: erickson Date: Fri, 29 Sep 2006 23:55:40 +0000 (+0000) Subject: the tree now accepts functions (for onclicks) in addition to JS hrefs for actions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ed12c530606bca60842e228fde8c15ceb31f78ea;p=evergreen%2Fpines.git the tree now accepts functions (for onclicks) in addition to JS hrefs for actions git-svn-id: svn://svn.open-ils.org/ILS/trunk@6274 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/opac/common/js/slimtree.js b/Open-ILS/web/opac/common/js/slimtree.js index 4a922c26b4..77234b73da 100644 --- a/Open-ILS/web/opac/common/js/slimtree.js +++ b/Open-ILS/web/opac/common/js/slimtree.js @@ -55,15 +55,22 @@ SlimTree.prototype.addNode = function( id, pid, name, action, title, cls ) { if(!action) action='javascript:'+this.handle+'.toggle("'+id+'");'; + var actionref; + if( typeof action == 'string' ) + actionref = elem('a',{href:action}, name); + else { + actionref = elem('a',{href:'javascript:void(0);'}, name); + actionref.onclick = action; + } + var div = elem('div',{id:id}); var topdiv = elem('div',{style:'vertical-align:middle'}); var link = elem('a', {id:'stlink_' + id}); - var actionref = elem('a',{href:action}, name); var contdiv = elem('div',{id:'stcont_' + id}); if(cls) addCSSClass(actionref, cls); - actionref.setAttribute('href',action); + //actionref.setAttribute('href',action); if(title) actionref.setAttribute('title',title); else actionref.setAttribute('title',name); @@ -126,6 +133,7 @@ SlimTree.prototype.toggle = function(id) { SlimTree.prototype.open = function(id) { if($(id).getAttribute('ostate') == '2') return; var link = $('stlink_' + id); + if(!link) return; if(id != this.rootid || !this.rootimg) { removeChildren(link); _apc(link,stimgclose.cloneNode(true)); @@ -137,6 +145,7 @@ SlimTree.prototype.open = function(id) { SlimTree.prototype.close = function(id) { var link = $('stlink_' + id); + if(!link) return; if(id != this.rootid || !this.rootimg) { removeChildren(link); _apc(link,stimgopen.cloneNode(true));