?? treemenu.js
字號:
//可定制的多級樹型目錄
//author Tommy Lee
function winClick() {
var targetId, srcElement,i=0,childi=0,imgID;
srcElement = window.event.srcElement;
targetId=srcElement.id;
//取得當(dāng)前的targetID
if(targetId.indexOf("line")>=0||targetId.indexOf("img")>=0){
//計(jì)算id
if(targetId.indexOf("line")>=0){
imgID="outline"+targetId.substring(7);
}else if(targetId.indexOf("img")>=0){
imgID=targetId;
targetId="outline"+targetId.substring(3);
}
for(i=0;i<document.all.tags("img").length;i++){
if(document.all.tags("img")(i).id.indexOf("outline")>=0){
if(document.all.tags("img")(i).id==imgID){
document.all.tags("img")(i).src='/framework_ext/framework/public/images/tree_minus.gif';
}else{document.all.tags("img")(i).src='/framework_ext/framework/public/images/tree_plus.gif';}
}
}
//關(guān)閉所有id號小于當(dāng)前點(diǎn)擊的id的tr,并將圖片改為arrowclose
for(i=0;i<document.all.tags("tr").length;i++){
//關(guān)掉所有不包含單擊id的項(xiàng)
if(document.all.tags("tr")(i).id.length>targetId.length&&document.all.tags("tr")(i).id.indexOf(targetId)<0){
document.all.tags("tr")(i).style.display='none';
}
//關(guān)閉所有包含點(diǎn)擊id且非孩子的項(xiàng)(>2)
if (document.all.tags("tr")(i).id.indexOf(targetId)>=0&&document.all.tags("tr")(i).id.length-targetId.length>2){
srcElement.src='/framework_ext/framework/public/images/tree_plus.gif';
document.all.tags("tr")(i).style.display='none';
_lstFocus.src='/framework_ext/framework/public/images/tree_minus.gif';
}
//包含所點(diǎn)擊的id
if(document.all.tags("tr")(i).id.indexOf(targetId)>=0){
//對于包含的孩子,執(zhí)行一下程序
if ((document.all.tags("tr")(i).id.length-targetId.length)==2){
if(document.all.tags("tr")(i).style.display==''){
srcElement.src='/framework_ext/framework/public/images/tree_plus.gif';
document.all.tags("tr")(i).style.display='none';
}else{
srcElement.src='/framework_ext/framework/public/images/tree_minus.gif';
document.all.tags("tr")(i).style.display='';
}
}
}
}
}
}
//設(shè)置路徑
function setPath(pathID){
var strPath="",rootID;
var num=0;
//判斷是否最終節(jié)點(diǎn)
for(i=0;i<document.all.tags("tr").length;i++){
if(document.all.tags("tr")(i).id.indexOf(pathID)>=0){
num++;
}
}
//如果是最終節(jié)點(diǎn),則進(jìn)行路徑顯示
if(num==1){
for(i=1;i<=((pathID.length-7)/2);i++){
rootID=pathID.substring(0,7+2*i);
for(ii=0;ii<document.all.tags("tr").length;ii++){
if(document.all.tags("tr")(ii).id==rootID){
if(i==1)
strPath=document.all.tags("tr")(ii).innerText+":";
else if(i<((pathID.length-7)/2))
strPath+=document.all.tags("tr")(ii).innerText+" >";
else
strPath+=document.all.tags("tr")(ii).innerText;
}
}
}
window.parent.wtop.document.all.tags("span")(0).innerText=strPath;
}
}
document.onclick = winClick;
var _lstFocus = null;
function clickItem1(objTable){
// 定制鏈接背景
var e = window.event.srcElement;
while (e!=null && e.tagName != "TR"){
e = e.parentElement;
}
if(e != null && e.tagName == "TR"){
e.style.background ="#e8eaff" ;
if(e != _lstFocus)
{
if(_lstFocus != null){
_lstFocus.style.background ="F9F9F9";
_lstFocus = e;
}else{
_lstFocus = e;
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -