Changeset 5743
- Timestamp:
- 04/09/08 13:06:41 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinelz/trunk/compress/javascripts/spinelz/spinelz_for_rubricks.js
r5706 r5743 4737 4737 TreeView.iconId="treeview_icon"; 4738 4738 TreeView.prototype={initialize:function(_1){ 4739 this.options=Object.extend({dirSymbol:"dir",fileSymbol:"file",cssPrefix:"custom_",open:true,c allBackFunctions:false,dirSelect:true,fileSelect:true,noSelectedInsert:true,iconIdPrefix:TreeView.iconId,move:false,unselected:Prototype.emptyFunction,enableUnselected:true,sortOptions:{},openDir:Prototype.emptyFunction,closeDir:Prototype.emptyFunction,emptyImg:false,initialSelected:null,build:true},arguments[1]||{});4739 this.options=Object.extend({dirSymbol:"dir",fileSymbol:"file",cssPrefix:"custom_",open:true,closeIds:[],callBackFunctions:false,dirSelect:true,fileSelect:true,noSelectedInsert:true,iconIdPrefix:TreeView.iconId,move:false,unselected:Prototype.emptyFunction,enableUnselected:true,sortOptions:{},openDir:Prototype.emptyFunction,closeDir:Prototype.emptyFunction,emptyImg:false,initialSelected:null,build:true},arguments[1]||{}); 4740 4740 this.element=$(_1); 4741 4741 this.customCss=CssUtil.appendPrefix(this.options.cssPrefix,TreeView.className); … … 4869 4869 }.bind(this)).join(" "); 4870 4870 var _1e=_1b.id||this.getBaseId(); 4871 var _1f=this.getState(_1b); 4872 var _20=this.options.iconIdPrefix.appendSuffix(_1e); 4873 var _21=_20.appendSuffix("stateImg"); 4874 var _22=_20.appendSuffix("dirBodyText"); 4875 var _23=[this.classNames.joinClassNames("dirIcon"),_1c,this.classNames.joinClassNames("handle")]; 4876 var _24=(this.options.open)?"":" style='display: none;'"; 4877 this.dirIds.push({state:_21,icon:_20,bodyText:_22}); 4878 var _25="<li id='"+_1e+"' class='"+this.classNames.joinClassNames("dir")+"'>"+"<div class='"+this.classNames.joinClassNames("dirBody")+"'>"+"<div id='"+_21+"' class='"+this.classNames.joinClassNames(_1f)+"'></div>"+"<div id='"+_20+"' class='"+_23.join(" ")+"'></div>"+"<span id='"+_22+"'class='"+this.classNames.joinClassNames("dirBodyText")+"'>"+this.getDirectoryText(_1b)+"</span>"+"</div>"+"<ul"+_24+" class='"+this.classNames.joinClassNames("dirContainer")+"'>"+this.buildSubContent(_1b)+"</ul>"+"</li>"; 4879 return _25; 4880 },buildSubContent:function(_26){ 4881 var ul=$A(_26.childNodes).detect(function(_28){ 4882 return Element.hasTagName(_28,"ul"); 4871 var _1f=this.options.closeIds.include(_1e); 4872 var _20=this.getState(_1b,_1f); 4873 var _21=this.options.iconIdPrefix.appendSuffix(_1e); 4874 var _22=_21.appendSuffix("stateImg"); 4875 var _23=_21.appendSuffix("dirBodyText"); 4876 var _24=[this.classNames.joinClassNames("dirIcon"),_1c,this.classNames.joinClassNames("handle")]; 4877 var _25=(this.options.open&&!_1f)?"":" style='display: none;'"; 4878 this.dirIds.push({state:_22,icon:_21,bodyText:_23}); 4879 var _26="<li id='"+_1e+"' class='"+this.classNames.joinClassNames("dir")+"'>"+"<div class='"+this.classNames.joinClassNames("dirBody")+"'>"+"<div id='"+_22+"' class='"+this.classNames.joinClassNames(_20)+"'></div>"+"<div id='"+_21+"' class='"+_24.join(" ")+"'></div>"+"<span id='"+_23+"'class='"+this.classNames.joinClassNames("dirBodyText")+"'>"+this.getDirectoryText(_1b)+"</span>"+"</div>"+"<ul"+_25+" class='"+this.classNames.joinClassNames("dirContainer")+"'>"+this.buildSubContent(_1b)+"</ul>"+"</li>"; 4880 return _26; 4881 },buildSubContent:function(_27){ 4882 var ul=$A(_27.childNodes).detect(function(_29){ 4883 return Element.hasTagName(_29,"ul"); 4883 4884 }); 4884 4885 if(ul){ 4885 return $A(ul.childNodes).inject("",function(_2 9,_2a){4886 return _2 9+this.build(_2a);4886 return $A(ul.childNodes).inject("",function(_2a,_2b){ 4887 return _2a+this.build(_2b); 4887 4888 }.bind(this)); 4888 4889 }else{ 4889 4890 return ""; 4890 4891 } 4891 },getState:function(_2 b){4892 if(!this.hasChildNodes(_2 b)&&!this.options.emptyImg){4892 },getState:function(_2c,_2d){ 4893 if(!this.hasChildNodes(_2c)&&!this.options.emptyImg){ 4893 4894 return "state_empty"; 4894 4895 }else{ 4895 if(this.options.open ){4896 if(this.options.open&&!_2d){ 4896 4897 return "state_open"; 4897 4898 }else{ … … 4899 4900 } 4900 4901 } 4901 },hasChildNodes:function(_2c){ 4902 var ul=$A(_2c.childNodes).detect(function(_2e){ 4903 return Element.hasTagName(_2e,"ul"); 4902 },getClosedIds:function(){ 4903 var _2e=$A($(this.element).getElementsByTagName("li")); 4904 return _2e.select(function(_2f){ 4905 return this.isClosed(_2f); 4906 }.bind(this)); 4907 },hasChildNodes:function(_30){ 4908 var ul=$A(_30.childNodes).detect(function(_32){ 4909 return Element.hasTagName(_32,"ul"); 4904 4910 }); 4905 4911 return ul&&(ul.childNodes.length!=0); 4906 },buildFile:function(_ 2f){4907 var _3 0=new Element.ClassNames(_2f).select(function(_31){4908 return _3 1!=this.options.fileSymbol;4912 },buildFile:function(_33){ 4913 var _34=new Element.ClassNames(_33).select(function(_35){ 4914 return _35!=this.options.fileSymbol; 4909 4915 }.bind(this)).join(" "); 4910 var _3 2=_2f.id||this.getBaseId();4911 var _3 3=this.options.iconIdPrefix.appendSuffix(_32);4912 var _3 4=[this.classNames.joinClassNames("fileIcon"),_30,this.classNames.joinClassNames("handle")];4913 var _3 5=_32.appendSuffix("fileBodyText");4914 this.fileIds.push({icon:_3 3,bodyText:_35});4915 var _3 6=Element.attributeHTML(_2f,"onclick");4916 var _3 7="<li id='"+_32+"' class='"+this.classNames.joinClassNames("file")+"' "+_36+">"+"<div class='"+this.classNames.joinClassNames("fileBody")+"'>"+"<div id='"+_33+"' class='"+_34.join(" ")+"'></div>"+"<span id='"+_35+"'class='"+this.classNames.joinClassNames("fileBodyText")+"'>"+_2f.innerHTML+"</span>"+"</div>"+"</li>";4917 return _3 7;4916 var _36=_33.id||this.getBaseId(); 4917 var _37=this.options.iconIdPrefix.appendSuffix(_36); 4918 var _38=[this.classNames.joinClassNames("fileIcon"),_34,this.classNames.joinClassNames("handle")]; 4919 var _39=_36.appendSuffix("fileBodyText"); 4920 this.fileIds.push({icon:_37,bodyText:_39}); 4921 var _3a=Element.attributeHTML(_33,"onclick"); 4922 var _3b="<li id='"+_36+"' class='"+this.classNames.joinClassNames("file")+"' "+_3a+">"+"<div class='"+this.classNames.joinClassNames("fileBody")+"'>"+"<div id='"+_37+"' class='"+_38.join(" ")+"'></div>"+"<span id='"+_39+"'class='"+this.classNames.joinClassNames("fileBodyText")+"'>"+_33.innerHTML+"</span>"+"</div>"+"</li>"; 4923 return _3b; 4918 4924 },getBaseId:function(){ 4919 4925 return this.element.id.appendSuffix(++this.idCount); … … 4924 4930 } 4925 4931 },observeDirEvent:function(){ 4926 this.dirIds.each(function(_3 8){4927 Event.observe(_3 8.state,"click",this.toggle.bindAsEventListener(this));4932 this.dirIds.each(function(_3c){ 4933 Event.observe(_3c.state,"click",this.toggle.bindAsEventListener(this)); 4928 4934 if(this.options.dirSelect){ 4929 Event.observe(_3 8.icon,"click",this.selectDirItem.bindAsEventListener(this));4930 Event.observe(_3 8.bodyText,"click",this.selectDirItem.bindAsEventListener(this));4935 Event.observe(_3c.icon,"click",this.selectDirItem.bindAsEventListener(this)); 4936 Event.observe(_3c.bodyText,"click",this.selectDirItem.bindAsEventListener(this)); 4931 4937 } 4932 4938 }.bind(this)); 4933 4939 },observeFileEvent:function(){ 4934 this.fileIds.each(function(_3 9){4935 Event.observe(_3 9.icon,"click",this.selectFileItem.bindAsEventListener(this));4936 Event.observe(_3 9.bodyText,"click",this.selectFileItem.bindAsEventListener(this));4940 this.fileIds.each(function(_3d){ 4941 Event.observe(_3d.icon,"click",this.selectFileItem.bindAsEventListener(this)); 4942 Event.observe(_3d.bodyText,"click",this.selectFileItem.bindAsEventListener(this)); 4937 4943 }.bind(this)); 4938 4944 },convertJSON:function(){ 4939 4945 return JSON.stringify(this.parse()); 4940 },getChildBody:function(_3 a){4941 var _3 b=[TreeView.className.fileBody,TreeView.className.dirBody];4942 return Element.getFirstElementByClassNames(_3 a,_3b);4943 },getChildBodyText:function(_ 3c){4944 var _ 3d=[TreeView.className.fileBodyText,TreeView.className.fileBodyTextActive,TreeView.className.dirBodyText,TreeView.className.dirBodyTextActive];4945 return Element.getFirstElementByClassNames(_ 3c,_3d);4946 },getChildBodyTextNode:function(_ 3e){4947 var _ 3f=this.getChildBody(_3e);4948 var _4 0=this.getChildBodyText(_3f);4949 return this.searchTextNode(_4 0);4950 },getChildDir:function(_4 1){4951 return document.getElementsByClassName(TreeView.className.dir,_4 1);4952 },getChildDirBody:function(_4 2){4953 return document.getElementsByClassName(TreeView.className.dirBody,_4 2)[0];4954 },getChildDirContainer:function(_4 3){4955 return document.getElementsByClassName(TreeView.className.dirContainer,_4 3)[0];4956 },getChildStateImg:function(_4 4){4957 var _4 5=this.getChildDirBody(_44);4958 var _4 6=[TreeView.className.state_close,TreeView.className.state_open,TreeView.className.state_empty];4959 return Element.getFirstElementByClassNames(_4 5,_46);4960 },getChildren:function(_4 7,_48,_49){4961 var _4 a;4962 var _4 b=new Array();4963 if(_4 7){4964 _4 a=$(_47).getElementsByTagName("ul")[0];4965 }else{ 4966 _4 a=this.element;4967 } 4968 $A(Element.getTagNodes(_4 a)).each(function(_4c){4969 if(!_4 8&&Element.hasClassName(_4c,TreeView.className.dir)){4970 _4 b.push(_4c);4971 } 4972 if(!_4 9&&Element.hasClassName(_4c,TreeView.className.file)){4973 _4 b.push(_4c);4974 } 4975 }); 4976 return _4 b;4977 },getDirectoryContents:function(_ 4d){4978 return $A(_ 4d.childNodes).findAll(function(_4e){4979 if((_ 4e.nodeType!=1)){4946 },getChildBody:function(_3e){ 4947 var _3f=[TreeView.className.fileBody,TreeView.className.dirBody]; 4948 return Element.getFirstElementByClassNames(_3e,_3f); 4949 },getChildBodyText:function(_40){ 4950 var _41=[TreeView.className.fileBodyText,TreeView.className.fileBodyTextActive,TreeView.className.dirBodyText,TreeView.className.dirBodyTextActive]; 4951 return Element.getFirstElementByClassNames(_40,_41); 4952 },getChildBodyTextNode:function(_42){ 4953 var _43=this.getChildBody(_42); 4954 var _44=this.getChildBodyText(_43); 4955 return this.searchTextNode(_44); 4956 },getChildDir:function(_45){ 4957 return document.getElementsByClassName(TreeView.className.dir,_45); 4958 },getChildDirBody:function(_46){ 4959 return document.getElementsByClassName(TreeView.className.dirBody,_46)[0]; 4960 },getChildDirContainer:function(_47){ 4961 return document.getElementsByClassName(TreeView.className.dirContainer,_47)[0]; 4962 },getChildStateImg:function(_48){ 4963 var _49=this.getChildDirBody(_48); 4964 var _4a=[TreeView.className.state_close,TreeView.className.state_open,TreeView.className.state_empty]; 4965 return Element.getFirstElementByClassNames(_49,_4a); 4966 },getChildren:function(_4b,_4c,_4d){ 4967 var _4e; 4968 var _4f=new Array(); 4969 if(_4b){ 4970 _4e=$(_4b).getElementsByTagName("ul")[0]; 4971 }else{ 4972 _4e=this.element; 4973 } 4974 $A(Element.getTagNodes(_4e)).each(function(_50){ 4975 if(!_4c&&Element.hasClassName(_50,TreeView.className.dir)){ 4976 _4f.push(_50); 4977 } 4978 if(!_4d&&Element.hasClassName(_50,TreeView.className.file)){ 4979 _4f.push(_50); 4980 } 4981 }); 4982 return _4f; 4983 },getDirectoryContents:function(_51){ 4984 return $A(_51.childNodes).findAll(function(_52){ 4985 if((_52.nodeType!=1)){ 4980 4986 return false; 4981 4987 } 4982 if(_ 4e.tagName.toLowerCase()=="li"){4988 if(_52.tagName.toLowerCase()=="li"){ 4983 4989 return true; 4984 4990 } 4985 4991 return false; 4986 4992 }); 4987 },getDirectoryText:function(_ 4f){4988 return $A(_ 4f.childNodes).inject("",function(_50,_51){4989 if(Element.isTextNode(_5 1)){4990 _5 0+=_51.nodeValue;4991 }else{ 4992 if(_5 1.tagName.toLowerCase()!="ul"){4993 _5 0+=Element.outerHTML(_51);4994 } 4995 } 4996 return _5 0;4993 },getDirectoryText:function(_53){ 4994 return $A(_53.childNodes).inject("",function(_54,_55){ 4995 if(Element.isTextNode(_55)){ 4996 _54+=_55.nodeValue; 4997 }else{ 4998 if(_55.tagName.toLowerCase()!="ul"){ 4999 _54+=Element.outerHTML(_55); 5000 } 5001 } 5002 return _54; 4997 5003 }); 4998 5004 },getHierarchyNumber:function(){ … … 5000 5006 return; 5001 5007 } 5002 var _5 2=this.selected;5008 var _56=this.selected; 5003 5009 var i=0; 5004 5010 while(true){ 5005 if(this.element==_5 2){5011 if(this.element==_56){ 5006 5012 return i; 5007 5013 }else{ 5008 _5 2=this.getParentDir(_52,true);5009 if(!_5 2){5014 _56=this.getParentDir(_56,true); 5015 if(!_56){ 5010 5016 return; 5011 5017 } … … 5016 5022 var arr=[]; 5017 5023 if(this.selected){ 5018 var _5 5=this.selected;5019 arr.push(_5 5);5020 while(_5 5){5021 _5 5=this.getParentDir(_55,false);5022 if(_5 5){5023 arr.push(_5 5);5024 var _59=this.selected; 5025 arr.push(_59); 5026 while(_59){ 5027 _59=this.getParentDir(_59,false); 5028 if(_59){ 5029 arr.push(_59); 5024 5030 } 5025 5031 } 5026 5032 } 5027 5033 return arr.reverse(); 5028 },getParentDir:function(_5 6,top){5029 var _5 8=Element.getParentByClassName(TreeView.className.dir,_56);5030 if(!_5 8&&top){5031 _5 8=Element.getParentByClassName(TreeView.className.top,_56);5032 } 5033 return _5 8;5034 },hasContents:function(_5 9){5035 if(_5 9){5036 if(!Element.hasClassName(_5 9,TreeView.className.dirContainer)&&!Element.hasClassName(_59,TreeView.className.top)){5034 },getParentDir:function(_5a,top){ 5035 var _5c=Element.getParentByClassName(TreeView.className.dir,_5a); 5036 if(!_5c&&top){ 5037 _5c=Element.getParentByClassName(TreeView.className.top,_5a); 5038 } 5039 return _5c; 5040 },hasContents:function(_5d){ 5041 if(_5d){ 5042 if(!Element.hasClassName(_5d,TreeView.className.dirContainer)&&!Element.hasClassName(_5d,TreeView.className.top)){ 5037 5043 return false; 5038 5044 } 5039 var _5 a=_59.childNodes;5040 for(var i=0;i<_5 a.length;i++){5041 if(_5 a[i].nodeType==1){5042 if(Element.hasClassName(_5 a[i],TreeView.className.dir)||Element.hasClassName(_5a[i],TreeView.className.file)){5045 var _5e=_5d.childNodes; 5046 for(var i=0;i<_5e.length;i++){ 5047 if(_5e[i].nodeType==1){ 5048 if(Element.hasClassName(_5e[i],TreeView.className.dir)||Element.hasClassName(_5e[i],TreeView.className.file)){ 5043 5049 return true; 5044 5050 } … … 5047 5053 } 5048 5054 return false; 5049 },parse:function(_ 5c){5050 if(!_ 5c){5051 _ 5c=this.element;5052 } 5053 var _ 5d=[];5054 var _ 5e=this.getDirectoryContents(_5c);5055 for(var i=0;i<_ 5e.length;i++){5056 var _6 0=_5e[i];5057 var _6 1=this.getChildBody(_60);5058 var _6 2=this.getChildBodyText(_61);5059 var _6 3={};5060 _6 3.id=_60.id;5061 _6 3.name=Element.collectTextNodes(_62).replace(/\n/,"");5062 if(Element.hasClassName(_6 0,TreeView.className.dir)){5063 _6 3.type=this.options.dirSymbol;5064 _6 3.contents=this.parse(this.getChildDirContainer(_60));5065 }else{ 5066 _6 3.type=this.options.fileSymbol;5067 } 5068 _ 5d.push(_63);5069 } 5070 return _ 5d;5071 },refreshStateImg:function(_6 4){5072 if(!Element.hasClassName(_6 4,TreeView.className.dir)){5073 return; 5074 } 5075 var _6 5=this.getChildDirContainer(_64);5076 var img=this.getChildStateImg(_6 4);5077 if(!this.hasContents(_6 5)&&!this.options.emptyImg){5055 },parse:function(_60){ 5056 if(!_60){ 5057 _60=this.element; 5058 } 5059 var _61=[]; 5060 var _62=this.getDirectoryContents(_60); 5061 for(var i=0;i<_62.length;i++){ 5062 var _64=_62[i]; 5063 var _65=this.getChildBody(_64); 5064 var _66=this.getChildBodyText(_65); 5065 var _67={}; 5066 _67.id=_64.id; 5067 _67.name=Element.collectTextNodes(_66).replace(/\n/,""); 5068 if(Element.hasClassName(_64,TreeView.className.dir)){ 5069 _67.type=this.options.dirSymbol; 5070 _67.contents=this.parse(this.getChildDirContainer(_64)); 5071 }else{ 5072 _67.type=this.options.fileSymbol; 5073 } 5074 _61.push(_67); 5075 } 5076 return _61; 5077 },refreshStateImg:function(_68){ 5078 if(!Element.hasClassName(_68,TreeView.className.dir)){ 5079 return; 5080 } 5081 var _69=this.getChildDirContainer(_68); 5082 var img=this.getChildStateImg(_68); 5083 if(!this.hasContents(_69)&&!this.options.emptyImg){ 5078 5084 this.classNames.refreshClassNames(img,"state_empty"); 5079 5085 }else{ 5080 if(Element.visible(_6 5)){5086 if(Element.visible(_69)){ 5081 5087 this.classNames.refreshClassNames(img,"state_open"); 5082 5088 }else{ … … 5084 5090 } 5085 5091 } 5086 },removeById:function(_6 7){5087 _6 7=$(_67);5088 if(_6 7){5089 var _6 8=_67.parentNode.parentNode;5090 Element.remove(_6 7);5091 this.refreshStateImg(_6 8);5092 } 5093 },removeByPath:function(_6 9){5094 var _6 a=_69.split("/").findAll(function(elm){5092 },removeById:function(_6b){ 5093 _6b=$(_6b); 5094 if(_6b){ 5095 var _6c=_6b.parentNode.parentNode; 5096 Element.remove(_6b); 5097 this.refreshStateImg(_6c); 5098 } 5099 },removeByPath:function(_6d){ 5100 var _6e=_6d.split("/").findAll(function(elm){ 5095 5101 return (elm!=""); 5096 5102 }); 5097 var _ 6c=_6a.pop();5098 var _ 6d=this.search(_6a.join("/"));5099 var _ 6e=this.getDirectoryContents(_6d)[_6c];5100 if(_ 6e){5101 this.removeById(_ 6e);5103 var _70=_6e.pop(); 5104 var _71=this.search(_6e.join("/")); 5105 var _72=this.getDirectoryContents(_71)[_70]; 5106 if(_72){ 5107 this.removeById(_72); 5102 5108 } 5103 5109 },removeBySelected:function(){ … … 5107 5113 this.removeById(this.selected); 5108 5114 this.selected=false; 5109 },renameById:function(_ 6f,_70){5110 _7 0=$(_70);5111 if(!Element.hasClassName(_7 0,TreeView.className.dir)&&!Element.hasClassName(_70,TreeView.className.file)){5112 return; 5113 } 5114 var _7 1=this.getChildBodyTextNode(_70);5115 _7 1.nodeValue=_6f;5116 },renameByPath:function(_7 2,_73){5117 var _7 4=_73.split("/").findAll(function(elm){5115 },renameById:function(_73,_74){ 5116 _74=$(_74); 5117 if(!Element.hasClassName(_74,TreeView.className.dir)&&!Element.hasClassName(_74,TreeView.className.file)){ 5118 return; 5119 } 5120 var _75=this.getChildBodyTextNode(_74); 5121 _75.nodeValue=_73; 5122 },renameByPath:function(_76,_77){ 5123 var _78=_77.split("/").findAll(function(elm){ 5118 5124 return (elm!=""); 5119 5125 }); 5120 var _7 6=_74.pop();5121 var _7 7=this.search(_74.join("/"));5122 var _7 8=this.getDirectoryContents(_77)[_76];5123 if(_7 8){5124 this.renameById(_7 2,_78);5125 } 5126 },renameBySelected:function(_7 9){5126 var _7a=_78.pop(); 5127 var _7b=this.search(_78.join("/")); 5128 var _7c=this.getDirectoryContents(_7b)[_7a]; 5129 if(_7c){ 5130 this.renameById(_76,_7c); 5131 } 5132 },renameBySelected:function(_7d){ 5127 5133 if(!this.selected){ 5128 5134 return; 5129 5135 } 5130 this.renameById(_7 9,this.selected);5131 },search:function(_7 a){5132 var _7 b=_7a.split("/").findAll(function(elm){5136 this.renameById(_7d,this.selected); 5137 },search:function(_7e){ 5138 var _7f=_7e.split("/").findAll(function(elm){ 5133 5139 return (elm!=""); 5134 5140 }); 5135 var _ 7d=this.element;5136 for(var i=0;i<_7 b.length;i++){5137 var num=_7 b[i];5138 var _8 0=this.getDirectoryContents(_7d);5139 if(_8 0[num]&&Element.hasClassName(_80[num],TreeView.className.dir)){5140 _ 7d=this.getChildDirContainer(_80[num]);5141 var _81=this.element; 5142 for(var i=0;i<_7f.length;i++){ 5143 var num=_7f[i]; 5144 var _84=this.getDirectoryContents(_81); 5145 if(_84[num]&&Element.hasClassName(_84[num],TreeView.className.dir)){ 5146 _81=this.getChildDirContainer(_84[num]); 5141 5147 }else{ 5142 5148 return false; 5143 5149 } 5144 5150 } 5145 return _ 7d;5146 },searchTextNode:function(_8 1){5147 var _8 2=null;5148 var _8 3=_81.childNodes;5149 for(var i=0;i<_8 3.length;i++){5150 if(_8 3[i].nodeType==3){5151 _8 2=_83[i];5151 return _81; 5152 },searchTextNode:function(_85){ 5153 var _86=null; 5154 var _87=_85.childNodes; 5155 for(var i=0;i<_87.length;i++){ 5156 if(_87[i].nodeType==3){ 5157 _86=_87[i]; 5152 5158 break; 5153 5159 }else{ 5154 if(_8 3[i].nodeType==1){5155 var tmp=this.searchTextNode(_8 3[i]);5160 if(_87[i].nodeType==1){ 5161 var tmp=this.searchTextNode(_87[i]); 5156 5162 if(tmp){ 5157 _8 2=tmp;5163 _86=tmp; 5158 5164 break; 5159 5165 } … … 5161 5167 } 5162 5168 } 5163 return _8 2;5164 },selectDirItem:function(_8 6){5165 var _8 7=Element.getParentByClassName(TreeView.className.dirBody,Event.element(_86));5166 this.selectItem(_8 7);5167 },selectEffect:function(_8 8,_89){5168 _8 9=Object.extend({enableUnselected:true},(_89||{}));5169 _8 8=$(_88);5170 if(_8 8){5171 var _8 a=$A(_88.childNodes).detect(function(_8b){5172 return Element.isElementNode(_8 b);5173 }); 5174 if(this.selectItemUnselect(_8 a,false)){5175 if(_8 9.enableUnselected){5176 return; 5177 } 5178 } 5179 this.selectItemSelect(_8 a,false);5180 } 5181 },selectFileItem:function(_ 8c){5182 var _ 8d=Element.getParentByClassName(TreeView.className.fileBody,Event.element(_8c));5183 this.selectItem(_ 8d);5184 },selectItem:function(_ 8e){5185 if(this.selectItemUnselect(_ 8e,true)){5186 return; 5187 } 5188 this.selectItemSelect(_ 8e,true);5189 },selectItemSelect:function(_ 8f,_90){5190 this.selected=_ 8f.parentNode;5191 var _9 1=this.getChildBodyText(_8f);5192 if(Element.hasClassName(_9 1,TreeView.className.dirBodyText)){5193 this.classNames.refreshClassNames(_9 1,"dirBodyTextActive");5169 return _86; 5170 },selectDirItem:function(_8a){ 5171 var _8b=Element.getParentByClassName(TreeView.className.dirBody,Event.element(_8a)); 5172 this.selectItem(_8b); 5173 },selectEffect:function(_8c,_8d){ 5174 _8d=Object.extend({enableUnselected:true},(_8d||{})); 5175 _8c=$(_8c); 5176 if(_8c){ 5177 var _8e=$A(_8c.childNodes).detect(function(_8f){ 5178 return Element.isElementNode(_8f); 5179 }); 5180 if(this.selectItemUnselect(_8e,false)){ 5181 if(_8d.enableUnselected){ 5182 return; 5183 } 5184 } 5185 this.selectItemSelect(_8e,false); 5186 } 5187 },selectFileItem:function(_90){ 5188 var _91=Element.getParentByClassName(TreeView.className.fileBody,Event.element(_90)); 5189 this.selectItem(_91); 5190 },selectItem:function(_92){ 5191 if(this.selectItemUnselect(_92,true)){ 5192 return; 5193 } 5194 this.selectItemSelect(_92,true); 5195 },selectItemSelect:function(_93,_94){ 5196 this.selected=_93.parentNode; 5197 var _95=this.getChildBodyText(_93); 5198 if(Element.hasClassName(_95,TreeView.className.dirBodyText)){ 5199 this.classNames.refreshClassNames(_95,"dirBodyTextActive"); 5194 5200 this.defaultCss="dirBodyText"; 5195 5201 }else{ 5196 if(Element.hasClassName(_9 1,TreeView.className.fileBodyText)){5197 this.classNames.refreshClassNames(_9 1,"fileBodyTextActive");5202 if(Element.hasClassName(_95,TreeView.className.fileBodyText)){ 5203 this.classNames.refreshClassNames(_95,"fileBodyTextActive"); 5198 5204 this.defaultCss="fileBodyText"; 5199 5205 } 5200 5206 } 5201 if(_9 0){5207 if(_94){ 5202 5208 if(this.options.callBackFunctions){ 5203 5209 for(var i=0;i<this.options.callBackFunctions.length;i++){ 5204 this.options.callBackFunctions[i](_ 8f.parentNode);5205 } 5206 } 5207 } 5208 },selectItemUnselect:function(_9 3,_94){5210 this.options.callBackFunctions[i](_93.parentNode); 5211 } 5212 } 5213 } 5214 },selectItemUnselect:function(_97,_98){ 5209 5215 if(this.selected){ 5210 var _9 5=this.getChildBody(this.selected);5211 var _9 6=this.getChildBodyText(_95);5212 this.classNames.refreshClassNames(_9 6,this.defaultCss);5213 if(this.selected==_9 3.parentNode&&this.options.enableUnselected){5216 var _99=this.getChildBody(this.selected); 5217 var _9a=this.getChildBodyText(_99); 5218 this.classNames.refreshClassNames(_9a,this.defaultCss); 5219 if(this.selected==_97.parentNode&&this.options.enableUnselected){ 5214 5220 this.selected=false; 5215 5221 this.defaultCss=false; 5216 if(_9 4){5222 if(_98){ 5217 5223 this.options.unselected(); 5218 5224 } … … 5222 5228 return false; 5223 5229 },setSortable:function(){ 5224 var _97=Object.extend({dropOnEmpty:true,tree:true,hoverclass:"treeview_dirContainerHover",scroll:window,ghosting:true},this.options.sortOptions); 5225 Sortable.create(this.element,_97); 5226 },toggle:function(_98){ 5227 Event.stop(_98); 5228 var src=Event.element(_98); 5230 var _9b=Object.extend({dropOnEmpty:true,tree:true,hoverclass:"treeview_dirContainerHover",scroll:window,ghosting:true},this.options.sortOptions); 5231 Sortable.create(this.element,_9b); 5232 },isDirectory:function(_9c){ 5233 return Element.hasClassName(_9c,TreeView.className.dir); 5234 },isClosed:function(_9d){ 5235 return this.isDirectory(_9d)&&!this.getChildDirContainer(_9d).visible(); 5236 },toggle:function(_9e){ 5237 Event.stop(_9e); 5238 var src=Event.element(_9e); 5229 5239 this._toggle(this.getParentDir(src),Element.toggle); 5230 },_toggle:function(_ 9a,_9b){5231 _ 9a=$(_9a);5232 if(_ 9a&&!Element.hasClassName(_9a,TreeView.className.dir)){5233 return; 5234 } 5235 var _ 9c=this.getChildDirContainer(_9a);5236 if(!this.hasContents(_ 9c)&&!this.options.emptyImg){5237 return; 5238 } 5239 _ 9b(_9c);5240 this.refreshStateImg(_ 9a);5241 if(!this.hasContents(_ 9c)&&!this.options.emptyImg){5242 this.options.openDir(_ 9a,_9c);5243 }else{ 5244 if(Element.visible(_ 9c)){5245 this.options.openDir(_ 9a,_9c);5246 }else{ 5247 this.options.closeDir(_ 9a,_9c);5240 },_toggle:function(_a0,_a1){ 5241 _a0=$(_a0); 5242 if(_a0&&!Element.hasClassName(_a0,TreeView.className.dir)){ 5243 return; 5244 } 5245 var _a2=this.getChildDirContainer(_a0); 5246 if(!this.hasContents(_a2)&&!this.options.emptyImg){ 5247 return; 5248 } 5249 _a1(_a2); 5250 this.refreshStateImg(_a0); 5251 if(!this.hasContents(_a2)&&!this.options.emptyImg){ 5252 this.options.openDir(_a0,_a2); 5253 }else{ 5254 if(Element.visible(_a2)){ 5255 this.options.openDir(_a0,_a2); 5256 }else{ 5257 this.options.closeDir(_a0,_a2); 5248 5258 } 5249 5259 } spinelz/trunk/compress/javascripts/spinelz/treeview.js
r5520 r5743 3 3 TreeView.iconId="treeview_icon"; 4 4 TreeView.prototype={initialize:function(_1){ 5 this.options=Object.extend({dirSymbol:"dir",fileSymbol:"file",cssPrefix:"custom_",open:true,c allBackFunctions:false,dirSelect:true,fileSelect:true,noSelectedInsert:true,iconIdPrefix:TreeView.iconId,move:false,unselected:Prototype.emptyFunction,enableUnselected:true,sortOptions:{},openDir:Prototype.emptyFunction,closeDir:Prototype.emptyFunction,emptyImg:false,initialSelected:null,build:true},arguments[1]||{});5 this.options=Object.extend({dirSymbol:"dir",fileSymbol:"file",cssPrefix:"custom_",open:true,closeIds:[],callBackFunctions:false,dirSelect:true,fileSelect:true,noSelectedInsert:true,iconIdPrefix:TreeView.iconId,move:false,unselected:Prototype.emptyFunction,enableUnselected:true,sortOptions:{},openDir:Prototype.emptyFunction,closeDir:Prototype.emptyFunction,emptyImg:false,initialSelected:null,build:true},arguments[1]||{}); 6 6 this.element=$(_1); 7 7 this.customCss=CssUtil.appendPrefix(this.options.cssPrefix,TreeView.className); … … 135 135 }.bind(this)).join(" "); 136 136 var _1e=_1b.id||this.getBaseId(); 137 var _1f=this.getState(_1b); 138 var _20=this.options.iconIdPrefix.appendSuffix(_1e); 139 var _21=_20.appendSuffix("stateImg"); 140 var _22=_20.appendSuffix("dirBodyText"); 141 var _23=[this.classNames.joinClassNames("dirIcon"),_1c,this.classNames.joinClassNames("handle")]; 142 var _24=(this.options.open)?"":" style='display: none;'"; 143 this.dirIds.push({state:_21,icon:_20,bodyText:_22}); 144 var _25="<li id='"+_1e+"' class='"+this.classNames.joinClassNames("dir")+"'>"+"<div class='"+this.classNames.joinClassNames("dirBody")+"'>"+"<div id='"+_21+"' class='"+this.classNames.joinClassNames(_1f)+"'></div>"+"<div id='"+_20+"' class='"+_23.join(" ")+"'></div>"+"<span id='"+_22+"'class='"+this.classNames.joinClassNames("dirBodyText")+"'>"+this.getDirectoryText(_1b)+"</span>"+"</div>"+"<ul"+_24+" class='"+this.classNames.joinClassNames("dirContainer")+"'>"+this.buildSubContent(_1b)+"</ul>"+"</li>"; 145 return _25; 146 },buildSubContent:function(_26){ 147 var ul=$A(_26.childNodes).detect(function(_28){ 148 return Element.hasTagName(_28,"ul"); 137 var _1f=this.options.closeIds.include(_1e); 138 var _20=this.getState(_1b,_1f); 139 var _21=this.options.iconIdPrefix.appendSuffix(_1e); 140 var _22=_21.appendSuffix("stateImg"); 141 var _23=_21.appendSuffix("dirBodyText"); 142 var _24=[this.classNames.joinClassNames("dirIcon"),_1c,this.classNames.joinClassNames("handle")]; 143 var _25=(this.options.open&&!_1f)?"":" style='display: none;'"; 144 this.dirIds.push({state:_22,icon:_21,bodyText:_23}); 145 var _26="<li id='"+_1e+"' class='"+this.classNames.joinClassNames("dir")+"'>"+"<div class='"+this.classNames.joinClassNames("dirBody")+"'>"+"<div id='"+_22+"' class='"+this.classNames.joinClassNames(_20)+"'></div>"+"<div id='"+_21+"' class='"+_24.join(" ")+"'></div>"+"<span id='"+_23+"'class='"+this.classNames.joinClassNames("dirBodyText")+"'>"+this.getDirectoryText(_1b)+"</span>"+"</div>"+"<ul"+_25+" class='"+this.classNames.joinClassNames("dirContainer")+"'>"+this.buildSubContent(_1b)+"</ul>"+"</li>"; 146 return _26; 147 },buildSubContent:function(_27){ 148 var ul=$A(_27.childNodes).detect(function(_29){ 149 return Element.hasTagName(_29,"ul"); 149 150 }); 150 151 if(ul){ 151 return $A(ul.childNodes).inject("",function(_2 9,_2a){152 return _2 9+this.build(_2a);152 return $A(ul.childNodes).inject("",function(_2a,_2b){ 153 return _2a+this.build(_2b); 153 154 }.bind(this)); 154 155 }else{ 155 156 return ""; 156 157 } 157 },getState:function(_2 b){158 if(!this.hasChildNodes(_2 b)&&!this.options.emptyImg){158 },getState:function(_2c,_2d){ 159 if(!this.hasChildNodes(_2c)&&!this.options.emptyImg){ 159 160 return "state_empty"; 160 161 }else{ 161 if(this.options.open ){162 if(this.options.open&&!_2d){ 162 163 return "state_open"; 163 164 }else{ … … 165 166 } 166 167 } 167 },hasChildNodes:function(_2c){ 168 var ul=$A(_2c.childNodes).detect(function(_2e){ 169 return Element.hasTagName(_2e,"ul"); 168 },getClosedIds:function(){ 169 var _2e=$A($(this.element).getElementsByTagName("li")); 170 return _2e.select(function(_2f){ 171 return this.isClosed(_2f); 172 }.bind(this)); 173 },hasChildNodes:function(_30){ 174 var ul=$A(_30.childNodes).detect(function(_32){ 175 return Element.hasTagName(_32,"ul"); 170 176 }); 171 177 return ul&&(ul.childNodes.length!=0); 172 },buildFile:function(_ 2f){173 var _3 0=new Element.ClassNames(_2f).select(function(_31){174 return _3 1!=this.options.fileSymbol;178 },buildFile:function(_33){ 179 var _34=new Element.ClassNames(_33).select(function(_35){ 180 return _35!=this.options.fileSymbol; 175 181 }.bind(this)).join(" "); 176 var _3 2=_2f.id||this.getBaseId();177 var _3 3=this.options.iconIdPrefix.appendSuffix(_32);178 var _3 4=[this.classNames.joinClassNames("fileIcon"),_30,this.classNames.joinClassNames("handle")];179 var _3 5=_32.appendSuffix("fileBodyText");180 this.fileIds.push({icon:_3 3,bodyText:_35});181 var _3 6=Element.attributeHTML(_2f,"onclick");182 var _3 7="<li id='"+_32+"' class='"+this.classNames.joinClassNames("file")+"' "+_36+">"+"<div class='"+this.classNames.joinClassNames("fileBody")+"'>"+"<div id='"+_33+"' class='"+_34.join(" ")+"'></div>"+"<span id='"+_35+"'class='"+this.classNames.joinClassNames("fileBodyText")+"'>"+_2f.innerHTML+"</span>"+"</div>"+"</li>";183 return _3 7;182 var _36=_33.id||this.getBaseId(); 183 var _37=this.options.iconIdPrefix.appendSuffix(_36); 184 var _38=[this.classNames.joinClassNames("fileIcon"),_34,this.classNames.joinClassNames("handle")]; 185 var _39=_36.appendSuffix("fileBodyText"); 186 this.fileIds.push({icon:_37,bodyText:_39}); 187 var _3a=Element.attributeHTML(_33,"onclick"); 188 var _3b="<li id='"+_36+"' class='"+this.classNames.joinClassNames("file")+"' "+_3a+">"+"<div class='"+this.classNames.joinClassNames("fileBody")+"'>"+"<div id='"+_37+"' class='"+_38.join(" ")+"'></div>"+"<span id='"+_39+"'class='"+this.classNames.joinClassNames("fileBodyText")+"'>"+_33.innerHTML+"</span>"+"</div>"+"</li>"; 189 return _3b; 184 190 },getBaseId:function(){ 185 191 return this.element.id.appendSuffix(++this.idCount); … … 190 196 } 191 197 },observeDirEvent:function(){ 192 this.dirIds.each(function(_3 8){193 Event.observe(_3 8.state,"click",this.toggle.bindAsEventListener(this));198 this.dirIds.each(function(_3c){ 199 Event.observe(_3c.state,"click",this.toggle.bindAsEventListener(this)); 194 200 if(this.options.dirSelect){ 195 Event.observe(_3 8.icon,"click",this.selectDirItem.bindAsEventListener(this));196 Event.observe(_3 8.bodyText,"click",this.selectDirItem.bindAsEventListener(this));201 Event.observe(_3c.icon,"click",this.selectDirItem.bindAsEventListener(this)); 202 Event.observe(_3c.bodyText,"click",this.selectDirItem.bindAsEventListener(this)); 197 203 } 198 204 }.bind(this)); 199 205 },observeFileEvent:function(){ 200 this.fileIds.each(function(_3 9){201 Event.observe(_3 9.icon,"click",this.selectFileItem.bindAsEventListener(this));202 Event.observe(_3 9.bodyText,"click",this.selectFileItem.bindAsEventListener(this));206 this.fileIds.each(function(_3d){ 207 Event.observe(_3d.icon,"click",this.selectFileItem.bindAsEventListener(this)); 208 Event.observe(_3d.bodyText,"click",this.selectFileItem.bindAsEventListener(this)); 203 209 }.bind(this)); 204 210 },convertJSON:function(){ 205 211 return JSON.stringify(this.parse()); 206 },getChildBody:function(_3 a){207 var _3 b=[TreeView.className.fileBody,TreeView.className.dirBody];208 return Element.getFirstElementByClassNames(_3 a,_3b);209 },getChildBodyText:function(_ 3c){210 var _ 3d=[TreeView.className.fileBodyText,TreeView.className.fileBodyTextActive,TreeView.className.dirBodyText,TreeView.className.dirBodyTextActive];211 return Element.getFirstElementByClassNames(_ 3c,_3d);212 },getChildBodyTextNode:function(_ 3e){213 var _ 3f=this.getChildBody(_3e);214 var _4 0=this.getChildBodyText(_3f);215 return this.searchTextNode(_4 0);216 },getChildDir:function(_4 1){217 return document.getElementsByClassName(TreeView.className.dir,_4 1);218 },getChildDirBody:function(_4 2){219 return document.getElementsByClassName(TreeView.className.dirBody,_4 2)[0];220 },getChildDirContainer:function(_4 3){221 return document.getElementsByClassName(TreeView.className.dirContainer,_4 3)[0];222 },getChildStateImg:function(_4 4){223 var _4 5=this.getChildDirBody(_44);224 var _4 6=[TreeView.className.state_close,TreeView.className.state_open,TreeView.className.state_empty];225 return Element.getFirstElementByClassNames(_4 5,_46);226 },getChildren:function(_4 7,_48,_49){227 var _4 a;228 var _4 b=new Array();229 if(_4 7){230 _4 a=$(_47).getElementsByTagName("ul")[0];231 }else{ 232 _4 a=this.element;233 } 234 $A(Element.getTagNodes(_4 a)).each(function(_4c){235 if(!_4 8&&Element.hasClassName(_4c,TreeView.className.dir)){236 _4 b.push(_4c);237 } 238 if(!_4 9&&Element.hasClassName(_4c,TreeView.className.file)){239 _4 b.push(_4c);240 } 241 }); 242 return _4 b;243 },getDirectoryContents:function(_ 4d){244 return $A(_ 4d.childNodes).findAll(function(_4e){245 if((_ 4e.nodeType!=1)){212 },getChildBody:function(_3e){ 213 var _3f=[TreeView.className.fileBody,TreeView.className.dirBody]; 214 return Element.getFirstElementByClassNames(_3e,_3f); 215 },getChildBodyText:function(_40){ 216 var _41=[TreeView.className.fileBodyText,TreeView.className.fileBodyTextActive,TreeView.className.dirBodyText,TreeView.className.dirBodyTextActive]; 217 return Element.getFirstElementByClassNames(_40,_41); 218 },getChildBodyTextNode:function(_42){ 219 var _43=this.getChildBody(_42); 220 var _44=this.getChildBodyText(_43); 221 return this.searchTextNode(_44); 222 },getChildDir:function(_45){ 223 return document.getElementsByClassName(TreeView.className.dir,_45); 224 },getChildDirBody:function(_46){ 225 return document.getElementsByClassName(TreeView.className.dirBody,_46)[0]; 226 },getChildDirContainer:function(_47){ 227 return document.getElementsByClassName(TreeView.className.dirContainer,_47)[0]; 228 },getChildStateImg:function(_48){ 229 var _49=this.getChildDirBody(_48); 230 var _4a=[TreeView.className.state_close,TreeView.className.state_open,TreeView.className.state_empty]; 231 return Element.getFirstElementByClassNames(_49,_4a); 232 },getChildren:function(_4b,_4c,_4d){ 233 var _4e; 234 var _4f=new Array(); 235 if(_4b){ 236 _4e=$(_4b).getElementsByTagName("ul")[0]; 237 }else{ 238 _4e=this.element; 239 } 240 $A(Element.getTagNodes(_4e)).each(function(_50){ 241 if(!_4c&&Element.hasClassName(_50,TreeView.className.dir)){ 242 _4f.push(_50); 243 } 244 if(!_4d&&Element.hasClassName(_50,TreeView.className.file)){ 245 _4f.push(_50); 246 } 247 }); 248 return _4f; 249 },getDirectoryContents:function(_51){ 250 return $A(_51.childNodes).findAll(function(_52){ 251 if((_52.nodeType!=1)){ 246 252 return false; 247 253 } 248 if(_ 4e.tagName.toLowerCase()=="li"){254 if(_52.tagName.toLowerCase()=="li"){ 249 255 return true; 250 256 } 251 257 return false; 252 258 }); 253 },getDirectoryText:function(_ 4f){254 return $A(_ 4f.childNodes).inject("",function(_50,_51){255 if(Element.isTextNode(_5 1)){256 _5 0+=_51.nodeValue;257 }else{ 258 if(_5 1.tagName.toLowerCase()!="ul"){259 _5 0+=Element.outerHTML(_51);260 } 261 } 262 return _5 0;259 },getDirectoryText:function(_53){ 260 return $A(_53.childNodes).inject("",function(_54,_55){ 261 if(Element.isTextNode(_55)){ 262 _54+=_55.nodeValue; 263 }else{ 264 if(_55.tagName.toLowerCase()!="ul"){ 265 _54+=Element.outerHTML(_55); 266 } 267 } 268 return _54; 263 269 }); 264 270 },getHierarchyNumber:function(){ … … 266 272 return; 267 273 } 268 var _5 2=this.selected;274 var _56=this.selected; 269 275 var i=0; 270 276 while(true){ 271 if(this.element==_5 2){277 if(this.element==_56){ 272 278 return i; 273 279 }else{ 274 _5 2=this.getParentDir(_52,true);275 if(!_5 2){280 _56=this.getParentDir(_56,true); 281 if(!_56){ 276 282 return; 277 283 } … … 282 288 var arr=[]; 283 289 if(this.selected){ 284 var _5 5=this.selected;285 arr.push(_5 5);286 while(_5 5){287 _5 5=this.getParentDir(_55,false);288 if(_5 5){289 arr.push(_5 5);290 var _59=this.selected; 291 arr.push(_59); 292 while(_59){ 293 _59=this.getParentDir(_59,false); 294 if(_59){ 295 arr.push(_59); 290 296 } 291 297 } 292 298 } 293 299 return arr.reverse(); 294 },getParentDir:function(_5 6,top){295 var _5 8=Element.getParentByClassName(TreeView.className.dir,_56);296 if(!_5 8&&top){297 _5 8=Element.getParentByClassName(TreeView.className.top,_56);298 } 299 return _5 8;300 },hasContents:function(_5 9){301 if(_5 9){302 if(!Element.hasClassName(_5 9,TreeView.className.dirContainer)&&!Element.hasClassName(_59,TreeView.className.top)){300 },getParentDir:function(_5a,top){ 301 var _5c=Element.getParentByClassName(TreeView.className.dir,_5a); 302 if(!_5c&&top){ 303 _5c=Element.getParentByClassName(TreeView.className.top,_5a); 304 } 305 return _5c; 306 },hasContents:function(_5d){ 307 if(_5d){ 308 if(!Element.hasClassName(_5d,TreeView.className.dirContainer)&&!Element.hasClassName(_5d,TreeView.className.top)){ 303 309 return false; 304 310 } 305 var _5 a=_59.childNodes;306 for(var i=0;i<_5 a.length;i++){307 if(_5 a[i].nodeType==1){308 if(Element.hasClassName(_5 a[i],TreeView.className.dir)||Element.hasClassName(_5a[i],TreeView.className.file)){311 var _5e=_5d.childNodes; 312 for(var i=0;i<_5e.length;i++){ 313 if(_5e[i].nodeType==1){ 314 if(Element.hasClassName(_5e[i],TreeView.className.dir)||Element.hasClassName(_5e[i],TreeView.className.file)){ 309 315 return true; 310 316 } … … 313 319 } 314 320 return false; 315 },parse:function(_ 5c){316 if(!_ 5c){317 _ 5c=this.element;318 } 319 var _ 5d=[];320 var _ 5e=this.getDirectoryContents(_5c);321 for(var i=0;i<_ 5e.length;i++){322 var _6 0=_5e[i];323 var _6 1=this.getChildBody(_60);324 var _6 2=this.getChildBodyText(_61);325 var _6 3={};326 _6 3.id=_60.id;327 _6 3.name=Element.collectTextNodes(_62).replace(/\n/,"");328 if(Element.hasClassName(_6 0,TreeView.className.dir)){329 _6 3.type=this.options.dirSymbol;330 _6 3.contents=this.parse(this.getChildDirContainer(_60));331 }else{ 332 _6 3.type=this.options.fileSymbol;333 } 334 _ 5d.push(_63);335 } 336 return _ 5d;337 },refreshStateImg:function(_6 4){338 if(!Element.hasClassName(_6 4,TreeView.className.dir)){339 return; 340 } 341 var _6 5=this.getChildDirContainer(_64);342 var img=this.getChildStateImg(_6 4);343 if(!this.hasContents(_6 5)&&!this.options.emptyImg){321 },parse:function(_60){ 322 if(!_60){ 323 _60=this.element; 324 } 325 var _61=[]; 326 var _62=this.getDirectoryContents(_60); 327 for(var i=0;i<_62.length;i++){ 328 var _64=_62[i]; 329 var _65=this.getChildBody(_64); 330 var _66=this.getChildBodyText(_65); 331 var _67={}; 332 _67.id=_64.id; 333 _67.name=Element.collectTextNodes(_66).replace(/\n/,""); 334 if(Element.hasClassName(_64,TreeView.className.dir)){ 335 _67.type=this.options.dirSymbol; 336 _67.contents=this.parse(this.getChildDirContainer(_64)); 337 }else{ 338 _67.type=this.options.fileSymbol; 339 } 340 _61.push(_67); 341 } 342 return _61; 343 },refreshStateImg:function(_68){ 344 if(!Element.hasClassName(_68,TreeView.className.dir)){ 345 return; 346 } 347 var _69=this.getChildDirContainer(_68); 348 var img=this.getChildStateImg(_68); 349 if(!this.hasContents(_69)&&!this.options.emptyImg){ 344 350 this.classNames.refreshClassNames(img,"state_empty"); 345 351 }else{ 346 if(Element.visible(_6 5)){352 if(Element.visible(_69)){ 347 353 this.classNames.refreshClassNames(img,"state_open"); 348 354 }else{ … … 350 356 } 351 357 } 352 },removeById:function(_6 7){353 _6 7=$(_67);354 if(_6 7){355 var _6 8=_67.parentNode.parentNode;356 Element.remove(_6 7);357 this.refreshStateImg(_6 8);358 } 359 },removeByPath:function(_6 9){360 var _6 a=_69.split("/").findAll(function(elm){358 },removeById:function(_6b){ 359 _6b=$(_6b); 360 if(_6b){ 361 var _6c=_6b.parentNode.parentNode; 362 Element.remove(_6b); 363 this.refreshStateImg(_6c); 364 } 365 },removeByPath:function(_6d){ 366 var _6e=_6d.split("/").findAll(function(elm){ 361 367 return (elm!=""); 362 368 }); 363 var _ 6c=_6a.pop();364 var _ 6d=this.search(_6a.join("/"));365 var _ 6e=this.getDirectoryContents(_6d)[_6c];366 if(_ 6e){367 this.removeById(_ 6e);369 var _70=_6e.pop(); 370 var _71=this.search(_6e.join("/")); 371 var _72=this.getDirectoryContents(_71)[_70]; 372 if(_72){ 373 this.removeById(_72); 368 374 } 369 375 },removeBySelected:function(){ … … 373 379 this.removeById(this.selected); 374 380 this.selected=false; 375 },renameById:function(_ 6f,_70){376 _7 0=$(_70);377 if(!Element.hasClassName(_7 0,TreeView.className.dir)&&!Element.hasClassName(_70,TreeView.className.file)){378 return; 379 } 380 var _7 1=this.getChildBodyTextNode(_70);381 _7 1.nodeValue=_6f;382 },renameByPath:function(_7 2,_73){383 var _7 4=_73.split("/").findAll(function(elm){381 },renameById:function(_73,_74){ 382 _74=$(_74); 383 if(!Element.hasClassName(_74,TreeView.className.dir)&&!Element.hasClassName(_74,TreeView.className.file)){ 384 return; 385 } 386 var _75=this.getChildBodyTextNode(_74); 387 _75.nodeValue=_73; 388 },renameByPath:function(_76,_77){ 389 var _78=_77.split("/").findAll(function(elm){ 384 390 return (elm!=""); 385 391 }); 386 var _7 6=_74.pop();387 var _7 7=this.search(_74.join("/"));388 var _7 8=this.getDirectoryContents(_77)[_76];389 if(_7 8){390 this.renameById(_7 2,_78);391 } 392 },renameBySelected:function(_7 9){392 var _7a=_78.pop(); 393 var _7b=this.search(_78.join("/")); 394 var _7c=this.getDirectoryContents(_7b)[_7a]; 395 if(_7c){ 396 this.renameById(_76,_7c); 397 } 398 },renameBySelected:function(_7d){ 393 399 if(!this.selected){ 394 400 return; 395 401 } 396 this.renameById(_7 9,this.selected);397 },search:function(_7 a){398 var _7 b=_7a.split("/").findAll(function(elm){402 this.renameById(_7d,this.selected); 403 },search:function(_7e){ 404 var _7f=_7e.split("/").findAll(function(elm){ 399 405 return (elm!=""); 400 406 }); 401 var _ 7d=this.element;402 for(var i=0;i<_7 b.length;i++){403 var num=_7 b[i];404 var _8 0=this.getDirectoryContents(_7d);405 if(_8 0[num]&&Element.hasClassName(_80[num],TreeView.className.dir)){406 _ 7d=this.getChildDirContainer(_80[num]);407 var _81=this.element; 408 for(var i=0;i<_7f.length;i++){ 409 var num=_7f[i]; 410 var _84=this.getDirectoryContents(_81); 411 if(_84[num]&&Element.hasClassName(_84[num],TreeView.className.dir)){ 412 _81=this.getChildDirContainer(_84[num]); 407 413 }else{ 408 414 return false; 409 415 } 410 416 } 411 return _ 7d;412 },searchTextNode:function(_8 1){413 var _8 2=null;414 var _8 3=_81.childNodes;415 for(var i=0;i<_8 3.length;i++){416
