⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 structure.js

📁 实现了基本的oa功能:个人日志。。。
💻 JS
📖 第 1 页 / 共 3 页
字号:
    this.viewNode = aDiv;

    //create the Whole table
    var wholeTable = document.createElement("<table width='100' height='100%' border='0' cellpadding='0' cellspacing='0'>");
    aDiv.appendChild(wholeTable);

       //create the first Row of whole table.
    var curRow = wholeTable.insertRow();
    var curCell = curRow.insertCell();
    curCell.className = "subtableheader";
    curCell.align = "right";
    
    //create the subtable of first row
    var subTable = document.createElement( "<table style='padding-left:2px;padding-right:2px;' width='100' border='0' cellspacing='0' cellpadding='0'>" );
    curCell.appendChild(subTable);
    curRow = subTable.insertRow();
    curRow.align="center";
    
    curCell = curRow.insertCell();
    curCell.width = "33%"
    var clickHandle = "viewUnitInfo(this.viewNode.treeNode.oid);";
    var curImage = document.createElement("<img id='" + idItem + "' onclick='" +clickHandle+ "' src='" +contextPath+ "/images/edit.gif' width='16' height='16' border='0' style='cursor:hand;' >");
    curImage.alt = viewUnitInfoAltLabel;
    curCell.appendChild( curImage );
    curImage.viewNode = aDiv;
    aDiv.editImage = curImage;
    
    curCell = curRow.insertCell();
    curCell.width = "33%"
      

    curCell = curRow.insertCell();
    curCell.width = "33%"
      
    clickHandle = 'viewEmployees(this.viewNode.treeNode.oid);';
    curImage = document.createElement("<img onclick='" +clickHandle + "' src='" +contextPath+ "/images/begro.gif' width='16' height='16' border='0' style='cursor:hand;' >");
    curImage.alt = viewEmployeeAltLabel;
    curCell.appendChild( curImage );
    curImage.viewNode = aDiv;
    aDiv.viewEmployeesImage = curImage;

    //create the second row of whole table
    curRow = wholeTable.insertRow();
    curCell = curRow.insertCell();
    curCell.className = "subalterbar";
    
    //create subtable of second row
    subTable = document.createElement( "<table style='padding-left:2px;padding-right:2px;' width='100' border='0' cellspacing='0' cellpadding='2'>" );
    curCell.appendChild(subTable);

    if( !isCompact ){
        curRow = subTable.insertRow();
        curCell = curRow.insertCell();
        curCell.width = "1%";
        curCell.align = "right";
        curCell.noWrap = true;
        curCell.innerText = codeKeyValue;
        curCell = curRow.insertCell();
        curCell.width = "100%";
        curCell.noWrap = false;
        curCell.innerText = this.code;
    }
    
    curRow = subTable.insertRow();
    if( !isCompact ){
        curCell = curRow.insertCell();
        curCell.width = "1%";
        curCell.align = "right";
        curCell.vAlign = "top";
        curCell.noWrap = true;
        curCell.innerText = nameKeyValue;
    }
    curCell = curRow.insertCell();
    curCell.width = "100%";
    curCell.noWrap = false;
    curCell.innerText = this.name;

    if( !isCompact ){
         curRow = subTable.insertRow();
         curCell = curRow.insertCell();
         curCell.width = "1%";
         curCell.align = "right";
         curCell.vAlign = "top";
         curCell.noWrap = true;         
         curCell = curRow.insertCell();
         curCell.width = "49%";
         curCell.noWrap = false;         
    }

    
    //create the third row of whole table
    curRow = wholeTable.insertRow();
    curCell = curRow.insertCell();
    curCell.className = "subalterbar";

    //create subtable of third row
	subTable = document.createElement( "<table style='padding-left:2px;padding-right:2px;' width='100' border='0' cellspacing='0' cellpadding='2'>" );
    curCell.appendChild(subTable);
    aDiv.chiefJobTable = subTable;
    
    curRow = subTable.insertRow();
    curCell = curRow.insertCell();
    curCell.width = "100%";
    curCell.align = "left";
    curCell.vAlign = "center";
    curCell.noWrap = false;
    
    
    //create the fourth row of whole table
    curRow = wholeTable.insertRow();
    curCell = curRow.insertCell();
    curCell.align = "center";
    curCell.className = "subalterbar";
    if( this.subnode!=null && this.subnode.length>0 ){
        if( this.open )
            curImage = document.createElement("<img onclick='doOpen(this.viewNode);' src='" +contextPath+ "/images/expand.gif' width='18' height='18' style='cursor=hand;' >");
        else
            curImage = document.createElement("<img onclick='doOpen(this.viewNode);' src='" +contextPath+ "/images/shrink.gif' width='18' height='18' style='cursor=hand;' >");
        curImage.viewNode = aDiv;
        aDiv.openImage = curImage;
        curCell.appendChild(curImage);
    }else{
        curCell.height = "18";
    }

    return aDiv;
}


function initLevelViewNode(td,aDiv){
    //deal with level
    var treeNode = aDiv.treeNode;
    var curLevelIndex = treeNode.level-1 ;
    var curNodes,curMax;
    if( levelNodes.length<=curLevelIndex || levelNodes[curLevelIndex]==null )
        levelNodes[curLevelIndex] = new Array();
    curNodes = levelNodes[curLevelIndex];
    curNodes[curNodes.length] = aDiv;

    if( treeNode.parent!=null ){
        for(var i=treeNode.parent.level;i<treeNode.level-1;i++){
            if( levelNodes.length<=i || levelNodes[i]==null )
                levelNodes[i] = new Array();
            curNodes = levelNodes[i];

            var tempDiv = document.createElement("<div align='center'></div>");
            tempDiv.style.height = (isCompact?"100":"120");
            var tempTable = document.createElement("<table width='100' height='100%' ></table>");
            tempTable.insertRow().insertCell();
            tempDiv.appendChild(tempTable);
            tempTable.background = contextPath + "/images/orgvertical.gif";

            curNodes[curNodes.length] = tempDiv ;
            td.appendChild(tempDiv);
            td.appendChild( document.createElement("<img border='0' src='" + contextPath + "/images/orgvertical.gif' >") );
        }
    }
    td.appendChild(aDiv);
}


function adaptLevelViewNode(){
    var adaptedCount,curNodes,curMax;
    var tempMax;
    for(var i=0;i<levelNodes.length;i++){
        if( levelAdaptedCount.length<=i || levelAdaptedCount[i]==null )
            levelAdaptedCount[i] = 0;
        adaptedCount = levelAdaptedCount[i];

        if( levelNodes.length<=i || levelNodes[i]==null )
            levelNodes[i] = new Array();
        curNodes = levelNodes[i];

        if( levelMaxHeight.length<=i || levelMaxHeight[i]==null )
            levelMaxHeight[i] = 0;
        curMax = levelMaxHeight[i];

        if( adaptedCount<curNodes.length ){
            tempMax = curMax;
            for(var j=adaptedCount;j<curNodes.length;j++){
                if( tempMax<curNodes[j].offsetHeight )
                    tempMax = curNodes[j].offsetHeight;
            }

            if( tempMax>curMax ){
                for(var j=0;j<adaptedCount;j++)
                    curNodes[j].style.height = tempMax;
            }
            for( var j=adaptedCount;j<curNodes.length;j++)
                curNodes[j].style.height = tempMax;

            levelMaxHeight[i] = tempMax;
            levelAdaptedCount[i] = curNodes.length;
        }
    }
}

//Global Var
var contextPath = ".";
var codeKeyValue = "code";
var nameKeyValue = "name";
var isCompact=true;
var mode="chart";

var rootNode = null;
var selectedNode = null;

//Global method
function doEditNode(viewNode, idItem){
  if(actionbar.style.display=="none"){
      actionbar.treeNode = viewNode.treeNode;
      showActionbar(viewNode, idItem);
   }else{
      if( actionbar.treeNode != viewNode.treeNode ){
          actionbar.treeNode = viewNode.treeNode;
          showActionbar(viewNode, idItem);
      }
   }
}

function showActionbar(viewNode, idItem){
    
    var actionbarHeight = 150;
    var y = document.body.scrollTop + document.body.clientHeight;
    var currenty = eval( calculateSumOffset(idItem, 'offsetTop') + 16 + actionbarHeight);
    if( currenty > y){
        //yangc change for show the actionbar to up when therer is no space in the end page, 2003.10.16
        actionbar.style.top = y - actionbarHeight;
    }else{
        actionbar.style.top = calculateSumOffset(idItem, 'offsetTop') + 16;
    }
    //shig change for end, 2003.07.26
    actionbar.style.left = calculateSumOffset(idItem, 'offsetLeft');
    actionbar.style.display="block";

    leftX  = document.all["actionbar"].style.posLeft;
    rightX = leftX + document.all["actionbar"].offsetWidth;

    //shig change for show the actionbar to up when therer is no space in the end page, 2003.07.26
    if( currenty > y){
        topY = document.all["actionbar"].style.posTop;
        bottomY = topY + document.all["actionbar"].offsetHeight;
    }else{
        topY = document.all["actionbar"].style.posTop - 18 ;
        bottomY = topY + document.all["actionbar"].offsetHeight + 18 ;
    }

}

function calculateSumOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = idItem;
	do
	{
		totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}

function hideActionbar(){
    actionbar.style.display="none";
}

function doOpen(viewNode){
   if( mode=="chart" )
      doOpenH(viewNode)
   else
      doOpenT(viewNode)

   adaptPosition();   
   hideActionbar();
}

function doOpenH(viewNode){
   var atable=viewNode;
   var i;
   do{
      atable=atable.parentElement;
   }while(atable.tagName!="TABLE");

   if( viewNode.treeNode.open){
       atable.rows[2].style.display="none";
       if (atable.rows[0].cells.length > 1) {
		   atable.rows[0].cells[0].style.display="none";
		   atable.rows[0].cells[2].style.display="none";
		   atable.rows[1].cells[0].style.display="none";
		   atable.rows[1].cells[2].style.display="none";
	   }
       viewNode.treeNode.open=false;
       viewNode.openImage.src = contextPath+"/images/shrink.gif";
   }else{
       var treeNode = viewNode.treeNode;
       var needAdapt = false;
       if( treeNode.getSubnode(0).viewNode==null ){
           var subViewNode;
           needAdapt = true;
           for(i=0;i<treeNode.subnode.length;i++){
              subViewNode = treeNode.getSubnode(i).createAllNode(i,treeNode.subnode.length);
              atable.rows[2].cells[i*2].appendChild(subViewNode);
           }
       }

       atable.rows[2].style.display="block";
       if (atable.rows[0].cells.length > 1) {
		   atable.rows[0].cells[0].style.display="block";
		   atable.rows[0].cells[2].style.display="block";
		   atable.rows[1].cells[0].style.display="block";
		   atable.rows[1].cells[2].style.display="block";
	   }
       viewNode.treeNode.open=true;
       viewNode.openImage.src = contextPath+"/images/expand.gif";
       if( needAdapt )
          adaptLevelViewNode();
   }
}

function doOpenV(viewNode){
   var atable=viewNode;
   var i;
   do{
      atable=atable.parentElement;
   }while(atable.tagName!="TABLE");

   if( viewNode.treeNode.open){
       for(i=0;i<atable.rows.length;i++)
          atable.rows[i].cells[2].style.display = "none";
       viewNode.treeNode.open=false;
       viewNode.openImage.src = contextPath+"/images/shrink.gif";
   }else{
       var treeNode = viewNode.treeNode;
       if( treeNode.getSubnode(0).viewNode==null ){
           var subViewNode;
           for(i=0;i<treeNode.subnode.length;i++){
              subViewNode = treeNode.getSubnode(i).createAllNode(i,treeNode.subnode.length);
              atable.rows[i*2].cells[2].appendChild(subViewNode);
           }
       }

       for(i=0;i<atable.rows.length;i++)
          atable.rows[i].cells[2].style.display = "block";
       viewNode.treeNode.open=true;
       viewNode.openImage.src = contextPath+"/images/expand.gif";
   }
}

function doOpenT(viewNode){
   var atable=viewNode;
   do{
      atable=atable.parentElement;
   }while(atable.tagName!="TABLE");

   viewNode.treeNode.open = !viewNode.treeNode.open;
   atable.rows[1].style.display = viewNode.treeNode.open?"block":"none";
   if( viewNode.treeNode.parent==null )
      viewNode.openImage.src = contextPath + (viewNode.treeNode.open?"/images/orgtreerootopen.gif":"/images/orgtreerootclose.gif");
   else
      viewNode.openImage.src = contextPath + (viewNode.treeNode.open?"/images/orgtreeopen.gif":"/images/orgtreeclose.gif");
}


function hideAll(){
	if (actionbar != null) {hideActionbar();actionbar.left = 0;}
}

function updateIt(e){
	if (ie)
	{
		var x = window.event.clientX + document.body.scrollLeft;
		var y = window.event.clientY + document.body.scrollTop;

		if (x > rightX || x < leftX) {
		    hideAll();
		}
		else if (y > bottomY || y < topY) {
		    hideAll();
		}
	}
	if (n)
	{
		var x = e.pageX+document.body.scrollLeft;
		var y = e.pageY+document.body.scrollTop;

		if (x > rightX || x < leftX) hideAll();
		else if (y > bottomY || y < topY) hideAll();
	}
}

if (document.all){
	if( document.body !=null ){
	   document.body.onclick=hideAll;
	   document.body.onscroll=hideAll;
	   document.body.onmousemove=updateIt;
	}
}
if (document.layers){
	document.onmousedown=hideAll;
	window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove=updateIt;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -