⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ig_webtab.js

📁 研究怎样通过手写代码来完成自动生成代码
💻 JS
📖 第 1 页 / 共 3 页
字号:
	// 3 - customCss: none or "defCss+hovCss+selCss+disCss"
	o = own.val(prop, 2);
	var st = ig_csom.notEmpty(o) ? parseInt(o) : 0;
	var cssT = own.doCss(own.val(prop, 3));
	var defCss = id + "DefT";
	if((st & 1) != 0) defCss += i;
	if(ig_csom.notEmpty(o = own.val(cssT, 0))) defCss += " " + o;
	else if(ig_csom.notEmpty(o = own.val(css0, 0))) defCss += " " + o;
	var hovCss = id + "HovT";
	if((st & 2) != 0) hovCss += i;
	else
	{
		if(own.noHov) hovCss = id + "DefT";
		if((st & 1) != 0) hovCss += i;
	}
	if(ig_csom.notEmpty(o = own.val(cssT, 1))) hovCss += " " + o;
	else if(ig_csom.notEmpty(o = own.val(css0, 1))) hovCss += " " + o;
	var selCss = id + "SelT";
	if((st & 4) != 0) selCss += i;
	if(ig_csom.notEmpty(o = own.val(cssT, 2))) selCss += " " + o;
	else if(ig_csom.notEmpty(o = own.val(css0, 2))) selCss += " " + o;
	var disCss = id + "DisT";
	if((st & 8) != 0) disCss += i;
	if(ig_csom.notEmpty(o = own.val(cssT, 3))) disCss += " " + o;
	else if(ig_csom.notEmpty(o = own.val(css0, 3))) disCss += " " + o;
	this.css = [defCss, hovCss, selCss, disCss];
	this.targetUrl = own.val(prop, 4);
	o = own.val(prop, 5).split(";");
	this.img = [own.val(o, 0), own.val(o, 1), own.val(o, 2), own.val(o, 3)];
	if(ig_csom.isEmpty(this.img[3])) this.img[3] = this.img[0];
	this.text = own.val(prop, 6);
	this.selColor = own.val(prop, 7);
	this.Key = own.val(prop, 8);
	this.imgAlign = own.val(prop, 9);
	//
	this.getIndex = function(){return this.index;}
	this.getElement = function(){return this.element;}
	this.getOwner = function(){return this.owner;}
	this.getTargetUrlDocument = function()
	{
		var d, f = this.elemIframe;
		if(f == null) return null;
		try{if((d = f.contentWindow) != null) if((d = d.document) != null) return d;}catch(ex){}
		try{if((d = f.contentDocument) != null) return d;}catch(ex){}
		return null;
	}
	this.getVisible = function(){return this.visible;}//0
	this.setVisible = function(val)
	{
		if(this.visible == (val == true)) return;
		this.visible = (val == true);
		this.owner.vis(this.element, this.visible ? "" : null);
		this.owner.vis(this.elemLeft, this.visible ? "" : null);
		this.owner.vis(this.elemRight, this.visible ? "" : null);
		this.fixSel();
		this.owner.update(this.index, "Visible", val);
	}
	this.getEnabled = function(){return this.enabled;}//1
	this.setEnabled = function(val){this.owner.setEnabled0(this, val);}
	this.getText = function(){return this.text;}//2
	this.setText = function(v)
	{
		if(this.text == v || !ig_csom.isArray(v)) return;
		var t = this.text = v;
		var e = this.element, n = e.childNodes;
		var i = (n == null) ? 0 : n.length;
		while(i-- > 0)
		{
			if(t == v && n[i].nodeName == "#text"){n[i].nodeValue = v; t = null;}
			else if(n[i].nodeName != "IMG") e.removeChild(n[i]);
		}
		if(t == v) e.innerHTML = " " + v + " ";
		this.fixImg(-1);
		this.owner.update(this.index, "Text", v);
	}
	this.getTooltip = function(){return this.tooltip;}//3
	this.setTooltip = function(val)
	{
		if(ig_csom.isArray(val)) this.element.title = this.tooltip = val;
		this.owner.update(this.index, "Tooltip", val);
	}
	this.getTargetUrl = function(){return this.targetUrl;}//4
	this.setTargetUrl = function(val)
	{
		if(val == null || val == this.owner.dummy) val = "";
		if(this.targetUrl == val || this.elemIframe == null) return;
		this.targetUrl = val;
		this.elemIframe.src = (val.length == 0) ? this.owner.dummy : val;
		if(this.state == 2) if((val.length == 0) != (this.elemIframe.style.display == "none"))
		{
			this.owner.vis(this.elemDiv, (val.length == 0) ? "block" : null);
			this.owner.vis(this.elemIframe, (val.length > 0) ? "block" : null);
		}
		this.owner.update(this.index, "TargetUrl", val);
	}
	this.getDefaultImage = function(){return this.img[0];}//5
	this.setDefaultImage = function(val){this.doImg(val, 0, "Default");}
	this.getHoverImage = function(){return this.img[1];}//6
	this.setHoverImage = function(val){this.doImg(val, 1, "Hover");}
	this.getSelectedImage = function(){return this.img[2];}//7
	this.setSelectedImage = function(val){this.doImg(val, 2, "Selected");}
	this.getDisabledImage = function(){return this.img[3];}//8
	this.setDisabledImage = function(val){this.doImg(val, 3, "Disabled");}
	this.doImg = function(val, st, p)
	{
		if(val == null) val = "";
		if(this.img[st] == val) return;
		this.img[st] = val;
		if(this.state == st) this.fixImg(-2);
		this.owner.update(this.index, p + "Image", val);
	}
	this.fixImg = function(st)
	{
		if(this.state == st || (st >= -1 && ig_csom.isEmpty(this.img[0] + this.img[1] + this.img[2] + this.img[3]))) return;
		var c = this.element;
		var im, imgC = null, nodes = c.childNodes;
		if(nodes == null) return;
		var i = nodes.length;
		while(i-- > 0){im = nodes[i].tagName; if(im == "IMG" || im == "img"){imgC = nodes[i]; break;}}
		if(st < 0 || st > 3) st = this.state;
		if(ig_csom.isEmpty(im = this.img[st])) im = this.img[0];
		if(ig_csom.notEmpty(im))
		{
			if(imgC == null)
			{
				if((imgC = document.createElement("IMG")) != null)
				{
					if((i = c.lastChild) != null) c.removeChild(i);
					imgC = c.appendChild(imgC);
					if(i != null) c.appendChild(i);
				}
				if(imgC != null)
				{
					imgC.border = 0;
					if(ig_csom.notEmpty(this.imgAlign)) imgC.align = this.imgAlign;
				}
			}
			if(imgC != null) imgC.src = im;
		}
		else if(imgC != null) c.removeChild(imgC);
	}
	//
	this.fixSel = function()
	{
		if(this.visible && this.enabled) return;
		if(this.owner.selected != this.index) return;
		if(!this.visible){this.owner.vis(this.elemDiv); this.owner.vis(this.elemIframe);}
		var o, i = this.index;
		while(i-- > 0)
		{
			o = this.owner.Tabs[i];
			if(o.visible && o.enabled){igtab_selectTab(o.owner, o.index, 1); return;}
		}
		i = this.index;
		while(++i < this.owner.Tabs.length)
		{
			o = this.owner.Tabs[i];
			if(o.visible && o.enabled){igtab_selectTab(o.owner, o.index, 1); return;}
		}
		igtab_selectTab(this.owner, -1, 1);
	}
	//
	this.rect = function(o, s)
	{
		if(o == null) s = 0;
		else if(s == 1) s = o.offsetHeight;
		else if(s == 2) s = o.offsetLeft;
		else if(s == 3) s = o.offsetTop;
		else s = o.offsetWidth;
		return (s == null) ? 0 : s;
	}
	//
	this.focus = function(){if(this.elemIndex != null) try{this.elemIndex.focus();}catch(ex){};}
	this.setState = function(st, e)
	{
		if(st < 0 || st > 3 || st == this.state){if(st == 2) this.focus(); return;}
		var o = this.owner;
		if(e != null)
		{
			if(st == 1)
			{
				if(o.hover == this) return;
				if(o.hover != null && o.hover.state == 1) o.hover.setState(0, e);
			}
			o.hover = (st == 1 || st == 2) ? this : null;
			if(this.state == 3 || !o.enabled) return;
		}
		if(st == 2)
		{
			if(e != null)
			{
				o.doPost = o.autoPost;
				if(o.fireEvt(this, o.Events.beforeSelectedTabChange, e)) return;
				if(o.doPost){o.update(-1, "SelectedTab", this.index, 1); return;}
			}
			igtab_selectTab(o, this.index);
			if(e != null){o.fireEvt(this, o.Events.afterSelectedTabChange, e); this.focus();}
			return;
		}
		if(e != null && st < 2)
		{
			o.fireEvt(this, (st == 0) ? o.Events.mouseOut : o.Events.mouseOver, e);
			if(o.selected == this.index) return;
		}
		this.doState(st);
		this.state = st;
	}
	this.doState = function(st)
	{
		if(st < 0) st = (this.owner.enabled || this.state == 2) ? this.state : 3;
		this.fixImg(st);
		if(this.element.className != this.css[st]) this.element.className = this.css[st];
		if(this.elemLeft != null && this.elemLeft.className != this.owner.leftImg[st]) this.elemLeft.className = this.owner.leftImg[st];
		if(this.elemRight != null && this.elemRight.className != this.owner.rightImg[st]) this.elemRight.className = this.owner.rightImg[st];
	}
	this.findControl = function(id)
	{
		var c = ig_csom.findControl(this.elemDiv, id);
		if(c == null) if((c = this.getTargetUrlDocument()) != null) c = ig_csom.findControl(c, id);
		return c;
	}
	this.isMy = function(n)
	{
		var e = this.element;
		if(e == n || this.elemLeft == n || this.elemRight == n) return true;
		for(var i = 0; i < 6; i++)
		{
			if((e = e.parentNode) == null) break;
			if(e == n) return true;
		}
		return false;
	}
}
//
function igtab_selectTab(owner, index, fix)
{
	if(owner == null) return;
	var o, e, i = owner.selected;
	if(i == null)
	{
		if((owner = igtab_getTabById(owner)) == null) return;
		if((i = owner.selected) == null) return;
	}
	if(index == i || index < -1 || owner.Tabs.length <= index) return;
	// unselect old
	var obj = owner.elemEmpty;
	if(i >= 0)
	{
		o = owner.Tabs[i];
		owner.vis(o.elemDiv);
		if((e = o.elemIframe) != null)
		{
			owner.vis(e);
			if(!owner.loadAllUrls) e.src = owner.dummy;
		}
		o.setState(o.enabled ? 0 : 3);
		if((e = o.elemIndex) != null) e.tabIndex = -1;
	}
	else owner.vis(obj);
	// select new
	if(index >= 0) if((obj = owner.Tabs[index]) == null) index = -1;
	if(fix != 1) owner.previousSelectedTab = owner.Tabs[(owner.selected == -2) ? index : owner.selected];
	owner.selected = index;
	owner.update(-1, "SelectedTab", index);
	if(index < 0){owner.vis(obj, "block"); return;}
	if(!obj.enabled) obj.setEnabled(true);
	if(!obj.visible) obj.setVisible(true);
	obj.fixImg(2);
	obj.element.className = obj.css[2];
	if((e = obj.elemLeft) != null) e.className = owner.leftImg[2];
	if((e = obj.elemRight) != null) e.className = owner.rightImg[2];
	obj.state = 2;
	if((e = obj.elemIndex) != null) e.tabIndex = owner.tabIndex;
	if(owner.rows != null)
	{
		e = obj.element;
		i = owner.rows.length;
		while(true)
		{
			if((e = e.parentNode) == null) break;
			if((o = e.nodeName) != null) if(o.toUpperCase() == "TD" && ig_csom.notEmpty(e.id))
			{
				while(--i > 0) if(e == owner.rows[i]){owner.moveRow(i); break;}
				break;
			}
		}
	}
	o = obj.targetUrl;
	if(o.length > 2 && (e = obj.elemIframe) != null)
	{
		if(e.src != o) e.src = o;
		owner.vis(e, "block");
	}
	else owner.vis(obj.elemDiv, "block");
	// backcolor
	if((o = igtab_getElementById(owner.ID + "_cp")) != null)
	{
		i = obj.element.className.indexOf(" ");
		o.className = (i > 2) ? obj.element.className.substring(i + 1) : "";
		o.bgColor = obj.selColor;
		if(o.style != null) o.style.backgroundColor = obj.selColor;
	}
	owner.ensureVisible();
}
function igtab_getTabFromElement(e)
{
	var ids = null, i = 0;
	while(true)
	{
		if(e == null) return null;
		try{if(e.getAttribute != null) ids = e.getAttribute("tabID");}catch(ex){}
		if(ig_csom.notEmpty(ids)) break;
		if(++i > 1) return null;
		e = e.parentNode;
	}
	ids = ids.split(",");
	var t = igtab_getTabById(ids[0]);
	if(t != null && ids.length > 1)
	{
		if((i = parseInt(ids[1])) < 1000) t = ig_csom.notEmpty(t.Tabs) ? t.Tabs[i] : null;
		else t = t.buttons[i - 1000];
	}
	return t;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -