CodeForge QQ客服 CodeForge 400电话 客服电话 4006316121

xloadtree.js ( 文件浏览 )

  • 发布于2010-08-06
  • 浏览次数:7
  • 下载次数:1
  • 下载需 1 积分
  • 侵权举报
			/*----------------------------------------------------------------------------\
|                               XLoadTree 1.11                                |
|-----------------------------------------------------------------------------|
|                         Created by Erik Arvidsson                           |
|                  (http://webfx.eae.net/contact.html#erik)                   |
|                      For WebFX (http://webfx.eae.net/)                      |
|-----------------------------------------------------------------------------|
| An extension to xTree that allows sub trees to be loaded at runtime by      |
| reading XML files from the server. Works with IE5+ and Mozilla 1.0+         |
|-----------------------------------------------------------------------------|
|                   Copyright (c) 1999 - 2002 Erik Arvidsson                  |
|-----------------------------------------------------------------------------|
| This software is provided "as is", without warranty of any kind, express or |
| implied, including  but not limited  to the warranties of  merchantability, |
| fitness for a particular purpose and noninfringement. In no event shall the |
| authors or  copyright  holders be  liable for any claim,  damages or  other |
| liability, whether  in an  action of  contract, tort  or otherwise, arising |
| from,  out of  or in  connection with  the software or  the  use  or  other |
| dealings in the software.                                                   |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| This  software is  available under the  three different licenses  mentioned |
| below.  To use this software you must chose, and qualify, for one of those. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| The WebFX Non-Commercial License          http://webfx.eae.net/license.html |
| Permits  anyone the right to use the  software in a  non-commercial context |
| free of charge.                                                             |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| The WebFX Commercial license           http://webfx.eae.net/commercial.html |
| Permits the  license holder the right to use  the software in a  commercial |
| context. Such license must be specifically obtained, however it's valid for |
| any number of  implementations of the licensed software.                    |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| GPL - The GNU General Public License    http://www.gnu.org/licenses/gpl.txt |
| Permits anyone the right to use and modify the software without limitations |
| as long as proper  credits are given  and the original  and modified source |
| code are included. Requires  that the final product, software derivate from |
| the original  source or any  software  utilizing a GPL  component, such  as |
| this, is also licensed under the GPL license.                               |
|-----------------------------------------------------------------------------|
| 2001-09-27 | Original Version Posted.                                       |
| 2002-01-19 | Added some simple error handling and string templates for      |
|            | reporting the errors.                                          |
| 2002-01-28 | Fixed loading issues in IE50 and IE55 that made the tree load  |
|            | twice.                                                         |
| 2002-10-10 | (1.1) Added reload method that reloads the XML file from the   |
|            | server.                                                        |
/ 2003-05-06 | Added support for target attribute                             |
|-----------------------------------------------------------------------------|
| Dependencies: xtree.js - original xtree library                             |
|               xtree.css - simple css styling of xtree                       |
|               xmlextras.js - provides xml http objects and xml document     |
|                              objects                                        |
|-----------------------------------------------------------------------------|
| Created 2001-09-27 | All changes are in the log above. | Updated 2003-05-06 |
\----------------------------------------------------------------------------*/


webFXTreeConfig.loadingText = "正在加载中...";
webFXTreeConfig.loadErrorTextTemplate = "加载出错 [%1%-%2%]";
webFXTreeConfig.emptyErrorTextTemplate = "";//"提示信息 \"%1%\" 没有包含任何 tree 条目";

/*
 * WebFXLoadTree class
 */

function WebFXLoadTree(sText, sXmlSrc, sAction, sBehavior, sIcon, sOpenIcon) {

	// call super
	this.WebFXTree = WebFXTree;
	this.WebFXTree(sText, sAction, sBehavior, sIcon, sOpenIcon);

	// setup default property values
	this.src = sXmlSrc;
	this.loading = false;
	this.loaded = false;
	this.errorText = "";

	// check start state and load if open
	if (this.open)
		_startLoadXmlTree(this.src, this);
	else {

		// and create loading item if not
		this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText);
		this.add(this._loadingItem);
	
}   

}

WebFXLoadTree.prototype = new WebFXTree;

// override the expand method to load the xml file
WebFXLoadTree.prototype._webfxtree_expand = WebFXTree.prototype.expand;
WebFXLoadTree.prototype.expand = function() {

	if (!this.loaded && !this.loading) {

		// load
		_startLoadXmlTree(this.src, this);
	
}
	this._webfxtree_expand();

};

/*
 * WebFXLoadTreeItem class
 */

function WebFXLoadTreeItem(sText, sXmlSrc, sAction, eParent, sIcon, sOpenIcon) {

	// call super
	this.WebFXTreeItem = WebFXTreeItem;
	this.WebFXTreeItem(sText, sAction, eParent, sIcon, sOpenIcon);

	// setup default property values
	this.src = sXmlSrc;
	this.loading = false;
	this.loaded = false;
	this.errorText = "";

	// check start state and load if open
	if (this.open){

		_startLoadXmlTree(this.src, this);	   
	
}else {

		// and create loading item if not
		this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText);
		this.add(this._loadingItem);
	
}

}

WebFXLoadTreeItem.prototype = new WebFXTreeItem;

// override the expand method to load the xml file
WebFXLoadTreeItem.prototype._webfxtreeitem_expand = WebFXTreeItem.prototype.expand;
WebFXLoadTreeItem.prototype.expand = function() {

	if (!this.loaded && !this.loading) {

		// load
		_startLoadXmlTree(this.src, this);		
	
}
	this._webfxtreeitem_expand();

};

// reloads the src file if already loaded
WebFXLoadTree.prototype.reload =
WebFXLoadTreeItem.prototype.reload = function () {

	// if loading do nothing
	if (this.loaded) {

		var open = this.open;
		// remove
		while (this.childNodes.length > 0)
			this.childNodes[this.childNodes.length - 1].remove();

		this.loaded = false;

		this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText);
		this.add(this._loadingItem);

		if (open)
			this.expand();
	
}
	else if (this.open && !this.loading)
		_startLoadXmlTree(this.src, this);

};

/*
 * Helper functions
 */

// creates the xmlhttp object and starts the load of the xml document
function _startLoadXmlTree(sSrc, jsNode) {

	if (jsNode.loading || jsNode.loaded)
		return;
	jsNode.loading = true;
	var xmlHttp = XmlHttp.create();	
	xmlHttp.open("GET", sSrc, true);	// async
	xmlHttp.onreadystatechange = function () {

		if (xmlHttp.readyState == 4) {

			_xmlFileLoaded(xmlHttp.responseXML, jsNode);
		
}
	
};
	// call in new thread to allow ui to update
	window.setTimeout(function () {

		xmlHttp.send(null);
	
}, 10);

}


// 根据类型来创建不同的节点。  luohc  2005-11-30.
function _createNodeByType(type, oNode, parentDisabled){
	
	if(type == "check"){

		jsNode = checkbox_createNode(oNode, parentDisabled);
	
}else if(type == "radio"){

		jsNode = radio_createNode(oNode, parentDisabled);
	
}else if(type == "normal"){

		jsNode = _createNode(oNode);
	
}	
	return jsNode;

}

function _createNode(oNode){
		
	var text = oNode.getAttribute("text");
	var action = oNode.getAttribute("action");
	var icon = oNode.getAttribute("icon");
	var openIcon = oNode.getAttribute("openIcon");
	var src = oNode.getAttribute("src");

	var parent = null;
	// create jsNode
	var jsNode;
	if (src != null && src != "")
		jsNode = new WebFXLoadTreeItem(text, src, action, parent, icon, openIcon);
	else
		jsNode = new WebFXTreeItem(text, action, parent, icon, openIcon);
    
	// 调置公共属性。
    _setNodeCommonAttr(jsNode, oNode);

	// 设置扩展属性。
	_setNodeExtendedAttr(jsNode, oNode);

	return jsNode;

}

// 调置公共属性。
function _setNodeCommonAttr(jsNode, oNode){
	
	var id = oNode.getAttribute("id");
	if(id != null && id != "") jsNode.setId(id);   // luohc  2005-11-30.
	var target = oNode.getAttribute("target");	
	if(target != null && target != "") jsNode.target = target;
	var color = oNode.getAttribute("color");
	if(color != null && color != "") {

		jsNode.setColor(color);
	
}

}

// 设置扩展属性。
function _setNodeExtendedAttr(jsNode, oNode){

	// 系统关键字。
	var keywords = new Array();  
	keywords[keywords.length] = "id";
	keywords[keywords.length] = "text";
	keywords[keywords.length] = "action";
	keywords[keywords.length] = "icon";
	keywords[keywords.length] = "openIcon";
	keywords[keywords.length] = "src";
	keywords[keywords.length] = "target";
	keywords[keywords.length] = "type";	
	keywords[keywords.length] = "value";	
	keywords[keywords.length] = "color";	
    keywords[keywords.length] = "disabled";	
	keywords[keywords.length] = "checked";	

	for(var i=0; i<oNode.attributes.length; i++){

		var attr = oNode.attributes[i];	
		var ext = true;
		for(var k=0; k<keywords.length; k++){

			if(keywords[k] == attr.name) {

				ext = false;
				break;
			
}
		
}
		if(ext){

			eval("jsNode." + attr.name + "='" + attr.value + "';");
		
}
	
}

}

// Converts an xml tree to a js tree. See article about xml tree format
function _xmlTreeToJsTree(oNode) {
		
	// create jsNode
	var 
...
...
(文件超长,未完全显示,请下载后阅读剩余部分)
			
...
展开> <收缩

下载源码到电脑,阅读使用更方便

1 积分

快速下载
还剩0行未阅读,继续阅读
免费下载源码
Sponsored links

源码文件列表

温馨提示: 点击源码文件名可预览文件内容哦 ^_^
...
名称 大小 修改日期
allItemTree.html1.50 kB18-02-05 15:32
checkboxTree_demo.html2.21 kB12-05-06 17:19
checkbox_xloadtree.html2.18 kB12-05-06 10:13
err_item.xml627.00 B12-05-06 10:52
help.html10.16 kB15-05-06 17:04
index.html444.00 B15-05-06 14:51
itemb.xml192.00 B30-11-05 17:05
items.xml883.00 B15-05-06 16:25
checkboxTreeItem.js10.85 kB12-05-06 14:39
checkboxXLoadTree.js11.82 kB12-05-06 08:47
blank.png144.00 B13-06-02 17:51
file.png251.00 B13-06-02 17:51
foldericon.png229.00 B13-06-02 17:51
I.png148.00 B13-06-02 17:51
L.png153.00 B13-06-02 17:51
Lminus.png219.00 B13-06-02 17:51
Lplus.png224.00 B13-06-02 17:51
new.png251.00 B13-06-02 17:51
openfoldericon.png232.00 B13-06-02 17:51
pspbrwse.jbf5.54 kB13-06-02 17:51
T.png152.00 B13-06-02 17:51
Thumbs.db14.50 kB12-05-06 10:23
Tminus.png207.00 B13-06-02 17:51
Tplus.png222.00 B13-06-02 17:51
vssver.scc240.00 B21-09-04 09:40
<images>0.00 B19-06-08 11:38
map.js1.60 kB29-03-06 16:47
radioTreeItem.js7.83 kB13-05-06 17:59
radioXLoadTree.js11.77 kB12-05-06 08:47
xloadtree.js12.05 kB15-05-06 14:51
xmlextras.js3.87 kB05-02-02 20:39
xtree.css1.04 kB01-12-04 17:13
xtree.js29.21 kB15-05-06 17:06
<js>0.00 B19-06-08 11:38
largeCheckBoxTree.html1.78 kB18-02-05 15:33
left.html1.55 kB15-05-06 14:53
map.html1.06 kB05-02-05 10:24
no_item.xml60.00 B12-11-04 09:53
radioTree_demo.html1.83 kB12-05-06 10:04
radio_xloadtree.html1.85 kB12-05-06 10:04
ReadMe.txt5.33 kB15-05-06 17:03
web.xml426.00 B03-12-04 09:01
<WEB-INF>0.00 B19-06-08 11:38
xloadtree.html2.14 kB13-05-06 17:46
<xTree>0.00 B29% 03-12-04
xtree.html2.04 kB15-05-06 15:54
<eXtree>0.00 B19-06-08 11:38
Sponsored links

xloadtree.js (52.66 kB)

需要 1 积分
您持有 积分

CodeForge积分(原CF币)全新升级,功能更强大,使用更便捷,不仅可以用来下载海量源代码马上还可兑换精美小礼品了 了解更多

您的积分不足

支付宝优惠套餐快速获取 30 积分

订单支付完成后,积分将自动加入到您的账号。以下是优惠期的人民币价格,优惠期过后将恢复美元价格。

更多付款方式:网银PayPal

上传代码,免费获取

您本次下载所消耗的积分将转交上传作者。

同一源码,30天内重复下载,只扣除一次积分。

登录 CodeForge

还没有CodeForge账号? 立即注册
关注微博
联系客服

Switch to the English version?

Yes
CodeForge 英文版
No
CodeForge 中文版

完善个人资料,获价值¥30元积分奖励!

^_^"呃 ...

Sorry!这位大神很神秘,未开通博客呢,请浏览一下其他的吧
好的