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

radioTreeItem.js ( 文件浏览 )

  • 发布于2010-08-06
  • 浏览次数:7
  • 下载次数:1
  • 下载需 1 积分
  • 侵权举报
			/*
 *	Sub class that adds a check box in front of the tree item icon
 *
 *	Created by Erik Arvidsson (http://webfx.eae.net/contact.html#erik)
 *
 *	Disclaimer:	This is not any official WebFX component. It was created due to
 *				demand and is just a quick and dirty implementation. If you are
 *				interested in this functionality the contact us
 *				http://webfx.eae.net/contact.html
 *
 *	Notice that you'll need to add a css rule the sets the size of the input box.
 *	Something like this will do fairly good in both Moz and IE
 *	
 *	input.tree-check-box {

 *		width:		auto;
 *		margin:		0;
 *		padding:	0;
 *		height:		14px;
 *		vertical-align:	middle;
 *	
}
 *
 */

 var disableColor = webFXTreeConfig.disableColor;

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

	this.base = WebFXTreeItem;
	this.base(sText, null, eParent, sIcon, sOpenIcon);	
	this._checked = bChecked;
	this._disabled = false;
	if(disabled) this._disabled = disabled;

    // luohc 2004-7-30.
	this.value = sValue==null?"":sValue;
	this.getRadio = function(){

		return getRadio(this.value);
	
};
	if(bChecked != null && bChecked == true){

		_setCheckedObject(this.id);
	
}

}

WebFXRadioTreeItem.prototype = new WebFXTreeItem;

WebFXRadioTreeItem.prototype.toString = function (nItem, nItemCount) {

	var foo = this.parentNode;
	var indent = '';
	if (nItem + 1 == nItemCount) {
 this.parentNode._last = true; 
}
	var i = 0;
	while (foo.parentNode) {

		foo = foo.parentNode;
		indent = "<img id=\"" + this.id + "-indent-" + i + "\" src=\"" + ((foo._last)?webFXTreeConfig.blankIcon:webFXTreeConfig.iIcon) + "\">" + indent;
		i++;
	
}
	this._level = i;
	if (this.childNodes.length) {
 this.folder = 1; 
}
	else {
 this.open = false; 
}
	if ((this.folder) || (webFXTreeHandler.behavior != 'classic')) {

		if (!this.icon) {
 this.icon = webFXTreeConfig.folderIcon; 
}
		if (!this.openIcon) {
 this.openIcon = webFXTreeConfig.openFolderIcon; 
}
	
}
	else if (!this.icon) {
 this.icon = webFXTreeConfig.fileIcon; 
}
	var label = "&nbsp;" + this.text.replace(/</g, '&lt;').replace(/>/g, '&gt;');

	var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\">";
	str += indent;
	str += "<img id=\"" + this.id + "-plus\" src=\"" + ((this.folder)?((this.open)?((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon):((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon)):((this.parentNode._last)?webFXTreeConfig.lIcon:webFXTreeConfig.tIcon)) + "\" onclick=\"webFXTreeHandler.toggle(this);\">"
	
	// insert radio
	var tempStr = "<input type=\"radio\"" + " class=\"tree-radio\"" +
		(this._checked ? " checked=\"checked\"" : "") +
		" onclick=\"webFXTreeHandler.all[this.parentNode.id].setChecked(this.checked)\"" +
		" value=\"" + this.value + "\" myId=\"" + this.id + "\" id=\"" + this.value 
		+ "-input\" " + (this._disabled?" disabled ": "") + " name=\"radioButton\">";
	str += tempStr;	
	// end insert checkbox
	
	//str += "<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\"><a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\">" + label + "</a></div>";
	tempStr = "<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\"><span  id=\"" + this.id + "-anchor\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\" style=\"cursor:hand;color:" + this.getColor() + "\">" + label + "</span></div>";
	str += tempStr;
    // if(this._disabled) alert(tempStr);
	str += "<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">";
	for (var i = 0; i < this.childNodes.length; i++) {

		str += this.childNodes[i].toString(i,this.childNodes.length);
	
}
	str += "</div>";
	this.plusIcon = ((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon);
	this.minusIcon = ((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon);
	return str;

}

WebFXRadioTreeItem.prototype.getChecked = function () {

	//var divEl = document.getElementById(this.id);
	//var inputEl = divEl.getElementsByTagName("INPUT")[0];
	var inputEl = getRadio();
	return this._checked = inputEl.checked;

};

WebFXRadioTreeItem.prototype.setChecked = function (bChecked) {

    // 这个方法被罗洪臣修改 2004-7-30.
	/*
	if (bChecked != this.getChecked()) {

		var divEl = document.getElementById(this.id);
		var inputEl = divEl.getElementsByTagName("INPUT")[0];
		this._checked = inputEl.checked = bChecked;
		
		if (typeof this.onchange == "function")
			this.onchange();
	
}*/
	if(getCheckObject() !=null && getCheckObject().id == this.id) return;

	this._checked = bChecked;	
    _setCheckedObject(this.id);
	//doCheck(this, bChecked);
	if (typeof this.onchange == "function"){

		this.onchange(this.text, this.value, bChecked);
	
}else if(this.onchange != null && this.onchange != ""){

		var str = this.onchange + "('" + this.text + "','" + this.value + "'," + bChecked + ");";
		eval(str);
	
}

};

/*****   以下是递归选择CheckBox的方法   罗洪臣   2004-7-30   *******/
function getRadio(id){

	return document.getElementById(id + "-input");

}

var checkedObject  = null;

function _setCheckedObject(id){
	
	var node = webFXTreeHandler.all[id];
    // var span = document.getElementById(radio.myId + "-anchor");
    // if(span) obj.text = span.innerText;
	var obj = {
id: node.id, text: node.text, value: node.value, 
		toString: function(){

		   var str = "\nid = " + this.id + "\ntext = " + this.text + "\nvalue = " + this.value + "\n";
	       return str;
	    
}
	
};
	checkedObject = obj;

}

// 获取选中的节点值和文本.
function getCheckObject(){

	return checkedObject;			

}

// 获取所有的选中radio的值. 
function getCheckValue(){
	
	if(checkedObject != null){

		return checkedObject.value;
	
}
	return null;

}

// 返回选中radio的文本。
function getCheckText(){

	if(checkedObject != null){

		return checkedObject.text;
	
}
	return null;

}

// 设置Radio的选中状态.
function setRadioChecked(value, checked){

	var radio = document.getElementById(value + "-input");
	if(radio){

		radio.checked = checked;		
		_setCheckedObject(radio.myId);
	
}

}

// 设置Radio的可用状态.
function disableRadio(value, disabled, recusive){

	var radio = document.getElementById(value + "-input");
	if(radio){

		radio.disabled = disabled;
        var id = radio.myId;
		var span = document.getElementById(id + "-anchor");
		if(span){

			if(disabled) span.style.color = disableColor;
			else span.style.color = "black";
		
}
		if(recusive){

			var node = webFXTreeHandler.all[id];
			disabledChildren(node, disabled);		
		
}
	
}

}

function disabledChildren(node, disabled){

  for(var i=0; i<node.childNodes.length; i++){

	  var item = node.childNodes[i];
	  var id = item.id;
	  var radio = document.getElementById(item.value + "-input");
	  if(radio)radio.disabled  = disabled;	 
	  var span = document.getElementById(id + "-anchor");
	  if(span){

	    	if(disabled) span.style.color = disableColor;
		    	else span.style.color = "black";
	  
}
	  disabledChildren(item, disabled);
  
}

}

// 隐藏Radio.
function visiableRadio(visiable){

	if(visiable) disp = "";
	else disp = "none";
	var cbxs = document.getElementsByTagName("INPUT");
	if(cbxs && cbxs.length >0){

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

			var cbx = cbxs[i];
			if(cbx.type.toUpperCase() == "RADIO"){

				cbx.style.display = disp;
			
}
		
}
	
}

}

			
...
展开> <收缩

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

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

radioTreeItem.js (52.66 kB)

需要 1 积分
您持有 积分

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

您的积分不足

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

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

更多付款方式:网银PayPal

上传代码,免费获取

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

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

登录 CodeForge

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

Switch to the English version?

Yes
CodeForge 英文版
No
CodeForge 中文版

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

^_^"呃 ...

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