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

checkboxXLoadTree.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%\"";
webFXTreeConfig.emptyErrorTextTemplate = "";//"提示信息 \"%1%\" 没有包含任何 tree 条目";
*/

/*
 * WebFXCheckBoxLoadTree class
 */

function WebFXCheckBoxLoadTree(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)
		checkbox_startLoadXmlTree(this.src, this);
	else {

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

}

WebFXCheckBoxLoadTree.prototype = new WebFXTree;

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

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

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

};


/*
 * WebFXLoadCheckBoxTreeItem class
 */

function WebFXLoadCheckBoxTreeItem(sText, sValue, sXmlSrc, eParent, sIcon, sOpenIcon, bChecked, disabled) {

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

    //this.WebFXTreeItem = WebFXCheckBoxTreeItem;
	//this.WebFXTreeItem(sText, sValue, bChecked, eParent, sIcon, sOpenIcon);

	this.base = WebFXCheckBoxTreeItem;
	this.base(sText, sValue, eParent, sIcon, sOpenIcon, bChecked, disabled);

	// 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)
		checkbox_startLoadXmlTree(this.src, this);
	else {

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

	 // luohc add. 2004.11.12
	this.loadChildren = function(){

		checkbox_startLoadXmlTree(this.src, this); 
	
}

}

WebFXLoadCheckBoxTreeItem.prototype = new WebFXCheckBoxTreeItem;

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

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

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

};

// reloads the src file if already loaded
WebFXLoadTree.prototype.reload =
WebFXLoadCheckBoxTreeItem.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)
		checkbox_startLoadXmlTree(this.src, this);

};

/*
 * Helper functions
 */

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

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

		if (xmlHttp.readyState == 4) {

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

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

}

function checkbox_createNode(oNode, parentDisabled){

	// retreive attributes
	var text = oNode.getAttribute("text");
	var value = oNode.getAttribute("value");
	var checked = false;
	if(oNode.getAttribute("checked") == "true"){

       checked = true;
	
}
	var disabled = _getDisabled_A(oNode, parentDisabled);
	var parent = null;
	var icon = oNode.getAttribute("icon");
	var openIcon = oNode.getAttribute("openIcon");
	var src = oNode.getAttribute("src");
	
	// create jsNode
	var jsNode;
	if (src != null && src != "")
		jsNode = new WebFXLoadCheckBoxTreeItem(text, value, src, parent, icon, openIcon, checked, disabled);
	else
		jsNode = new WebFXCheckBoxTreeItem(text, value, parent, icon, openIcon, checked, disabled);
   
    // 将选中的值加入结果集中.
	if(checked){

		checkedValues.put(jsNode.id,  new CheckedObject(jsNode.id, text, value));  // 这里的id是系统自动生成的id,不是oid(业务对象id)。
	
}

	// 调置公共属性。
    _setNodeCommonAttr(jsNode, oNode);

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

}


// Converts an xml tree to a js tree. See article about xml tree format
function checkbox_xmlTreeToJsTree(oNode, parentDisabled) {
	
	// create jsNode
	var jsNode;  
	var type = oNode.getAttribute("type");
	if(type != null && type != ""){

		jsNode = _createNodeByType(type, oNode, parentDisabled);	
	
}else{

		jsNode = checkbox_createNode(oNode, parentDisabled);
	
}

	// go through childNOdes
	var cs = oNode.childNodes;
	var l = cs.length;
	for (var i = 0; i < l; i++) {

		if (cs[i].tagName == "tree"){

			var disabled = _getDisabled_A(oNode, parentDisabled);			
			jsNode.add( checkbox_xmlTreeToJsTree(cs[i], disabled), true );
		
}
	
}

	return jsNode;

}

function _getDisabled_A(oNode, parentDisabled){

	var disabled = false;
	if(oNode.getAttribute("disabled") == "true"){


...
...
(文件超长,未完全显示,请下载后阅读剩余部分)
			
...
展开> <收缩

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

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

checkboxXLoadTree.js (52.66 kB)

需要 1 积分
您持有 积分

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

您的积分不足

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

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

更多付款方式:网银PayPal

上传代码,免费获取

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

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

登录 CodeForge

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

Switch to the English version?

Yes
CodeForge 英文版
No
CodeForge 中文版

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

^_^"呃 ...

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