Location: PHPKode > projects > Wexplorer > weXplorer/treeview.php
<?php if (!isset($ROOT_URL))$ROOT_URL ="";?>

	<link rel="stylesheet" href="<?php echo $ROOT_URL;?>css/tree.css" type="text/css">
	<script src="<?php echo $ROOT_URL;?>js/xmlextras.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/core.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/expcol.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/tools.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/rename.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/xmltools.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/ondemand.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/select.js" type="text/javascript"></script>
	<script src="<?php echo $ROOT_URL;?>js/move.js" type="text/javascript"></script>

	<script src="<?php echo $ROOT_URL;?>js/dragndrop.js" type="text/javascript"></script>
  

<script type="text/javascript">

var rootUrl = "<?php echo $ROOT_URL;?>";

var treeConfig = {
	loadIcon		: rootUrl+'tree/loading.gif',
	errorIcon		: rootUrl+'tree/error.gif',
	defaultIcon		: rootUrl+'tree/folder.gif',
	defaultIconOpen	: rootUrl+'tree/folderopen.gif',
	iIcon           : rootUrl+'tree/i.gif',
	lIcon           : rootUrl+'tree/l.gif',
	lMinusIcon      : rootUrl+'tree/lminus.gif',
	lPlusIcon       : rootUrl+'tree/lplus.gif',
	tIcon           : rootUrl+'tree/t.gif',
	tMinusIcon      : rootUrl+'tree/tminus.gif',
	tPlusIcon       : rootUrl+'tree/tplus.gif',
	blankIcon		: rootUrl+'tree/blank.gif',
	checkboxIcon	: rootUrl+'tree/check_disabled.gif',
	checkboxCheckedFullIcon : rootUrl+'tree/check_full.gif',
	checkboxCheckedPartialIcon : rootUrl+'tree/check_partial.gif',
	defaultLabel    : 'new node',
	defaultAction   : 'javascript:void(0);',
	defaultOnNodeSelectEventHandler : function(){void(0)},
	defaultOnNodeDragStartHandler : function(){return true},
	defaultOnNodeDragEndHandler : function(){void(0)},
	selectOnReload : false
};




function hidecmenu(){
	document.getElementById('rmenu').style.visibility='hidden';
}



function addVoidFunction(name,func){
  eval('var sum = '+name);
  if(sum==null){
    ftext = "";
  } else  {
    var a = " " +sum;
    while(/\n/.test(a))
      a= a.replace(/\n/, ";")
    while(/\r/.test(a))
      a=a.replace(/\r/, "");
    a.match(/{(.*)}/);
    ftext = RegExp.$1;
    
  }
  a = " "+ func;
  while(/\n/.test(a))
   a= a.replace(/\n/, ";")
  while(/\r/.test(a))
    a=a.replace(/\r/, "");
  a.match(/{(.*)}/);
  stext = RegExp.$1;
  ftext = ftext+stext;
  ftext2 ="";
  for(i=0;i<ftext.length-1;i++){
      if(ftext.charAt(i)=="\"")
        ftext2 += "\\\"";
      else if(ftext.charAt(i)=="\\")
        ftext2+= "\\\\";       
      else 
        ftext2+=ftext.charAt(i);
  }
  eval (name+' = new Function("", "'+ftext2+'");');
}

addVoidFunction("document.onclick",hidecmenu);


function selectPath(path){
	if(path.charAt(0)=='/')
		path = path.substr(1, 500);
	path = path.replace(/\//g, ",");
	document.mytreeview.selectByLabelPath(path);
}


function selectChildByLabel(l){
	mytreeview.selectedNode.selectByLabel(l);
}

function onNodeDragStart(draggingNode){
	return false;
}
function onNodeDragEnd(targetNode){
	//instance,oldparent,newparent
	var instance = draggingNode.getXMLAttribute('instanceid');
	var oldparent = draggingNode.getXMLAttribute('parentid');
	var newparent = targetNode.getXMLAttribute('instanceid');
	
	/*
	if(targetNode.getXMLAttribute('objectname').toLowerCase() == 'article'){
		alert('An article cannot contain subitems');
		return;
	}
	
	if(newparent == instance){
		alert('object cannot be moved to itself');	
		return;
	}
	*/
	
	// we set the true parameter here, because if we wouldn't do this, the parentNode of the selectedNode 
	// would be selected, and thus the targetNode would be overwritten with the parentNode
	
	draggingNode.remove(true);
	//moveInstance(instance,oldparent,newparent);
}
function selectPath(path){
	if(path.charAt(0)=='/')
		path = path.substr(1, 500);
	path = path.replace(/\//g, ",");
	document.mytreeview.selectByLabelPath(path);
}


var mytreeview; 

function newtreeview (treecontainer,treeRootService){
	mytreeview = new treeview('a new treeview',treecontainer,treeRootService);
	return  mytreeview;
//mytreeview.onNodeSelectEventHandler = onNodeSelect;
mytreeview.onNodeDragStartHandler = onNodeDragStart;
mytreeview.onNodeDragEndHandler = onNodeDragEnd;
	
}

function onNodeContextMenu(el,x,y){
	if(isNaN(document.body.scrollTop)){
		var xscroll = document.body.pageXOffset;
		var yscroll = document.body.pageYOffset;		
	} else {
		var xscroll = document.body.scrollLeft ;
		var yscroll = document.body.scrollTop;
	}	
	var menu = document.getElementById('rmenu');
	menu.style.top = yscroll+y-2;
	menu.style.left = xscroll+x-2;
	menu.style.visibility = "visible";
	
}
document.oncontextmenu = function(){};
</script>
<div id='rmenu' style="position:absolute; top:100px; left:100px; z-index:100; visibility:hidden; font-family:Verdana, Helvetica, Arial, Sans-Serif; ">
<table style="border:1px Solid buttonshadow; background: ButtonFace; color:black;">
  <tr>
    <td style="cursor:pointer; font-size:0.9em;"
	onMouseOver="this.style.background='highlight';this.style.color='white';"
	onMouseOut="this.style.background='ButtonFace';this.style.color='black';"
	onclick="mytreeview.selectedNode.collapseAll();"
	><span style="font-size:xx-small;">Collpase</span></td>
  </tr>
  <tr>
    <td style="cursor:pointer;"
	onMouseOver="this.style.background='highlight';this.style.color='white';"
	onMouseOut="this.style.background='ButtonFace';this.style.color='black';"
	onclick="mytreeview.selectedNode.expandAll();"
	><span style="font-size:xx-small;">Expand</span></td>
  </tr>
   <tr>
    <td style="cursor:pointer; font-size:0.9em;"
	onMouseOver="this.style.background='highlight';this.style.color='white';"
	onMouseOut="this.style.background='ButtonFace';this.style.color='black';"
	onclick="document.getElementById('rmenu').style.visibility='hidden';"
	><span style="font-size:xx-small;">Close Menu</span></td>
  </tr>
</table>
</div>
Return current item: Wexplorer