📄 ig_webtab.js
字号:
/*
Infragistics Tab Script
Version 5.1.20051.37
js-version 3.0.20042.1034
Copyright (c) 2002-2005 Infragistics, Inc. All Rights Reserved.
*/
//vs
//==========
// public:
if(typeof(igtab_all) != "object")
var igtab_all = new Object();
// public:
// Get the UltraWebTab object using its html-id
function igtab_getTabById(id)
{
var o = igtab_all[id];
if(o != null) return o;
for(var i in igtab_all) if((o = igtab_all[i]) != null) if(o.ID == id || o.ID_ == id || o.uniqueId == id) return o;
return null;
}
// public:
// Get html child-element of owner by its id(s).
// owner - reference to the html-element that contains requested child element.
// id - the id or list of ids separated by " " starting from the id of requested element.
// Example: "ID_of_element ID_of_userControl ID_of_grandParent"
function igtab_getElementById(id, owner)
{
if(owner == null) owner = window.document;
var e = null, ids = (id.charAt == null) ? id : id.split(" ");
if(ids.length == 1 && owner.forms != null) e = ig_csom.getElementById(id);
else
{
var nodes = owner.childNodes;
var i = nodes.length;
while(i-- > 0)
{
e = nodes[i];
var i0 = 0, j = ids.length;
if((id = e.id) != null) if(id.length > 0)
{
while(j-- > 0)
{
if(ids[j].length < 1) continue;
if((i0 = id.indexOf(ids[j], i0)) < 0) break;
if(i0 > 0) if(id.charAt(i0 - 1) != '_') break;
i0 += ids[j].length;
if(i0 < id.length) if(id.charAt(i0) != '_') break;
}
if(j < 0 && i0 == id.length) i = 0;
}
if((e = igtab_getElementById(ids, e)) != null) i = 0;
}
}
return e;
}
// private: all below
function igtab_init(id, index, seps, prop, evts)
{
var o;
if(id == null)
{
for(id in igtab_all) if((o = igtab_all[id]) != null){o.scrolInit(); o.ensureVisible();}
return;
}
var elem = igtab_getElementById("igtab" + id);
if(elem == null) return;
igtab_all[id] = o = new igtab_new(elem, id, seps, prop, evts);
igtab_selectTab(o, index);
o.fireEvt(o, o.Events.initializeTabs, null);
}
// process events
function igtab_event(e)
{
if(e == null) if((e = window.event) == null) return;
var z, o = null, type = 0;//mouseout
if(e.srcElement != null) o = e.srcElement;
else if(e.target != null) o = e.target;
else o = this;
if(e.type == "focus") if((o = o.indexOwner) != null){o.setState(2, e); return;}
if(e.type == "keydown")
{
z = e.keyCode;
if(z == null || z == 0) z = e.which;
if((o = o.indexOwner) == null) return;
o = o.owner;
if(o.tabIndex < 0 || !o.enabled) return;
var i = o.selected, iL = o.Tabs.length - 1;
switch(z)
{
case 36: i = 0; type = iL; break;
case 35: i = iL; break;
case 37: i--; break;
case 39: i++; type = iL; break;
default: return;
}
while(true)
{
if(i < 0 || i > iL) return;
z = o.Tabs[i];
if(z.visible && z.enabled) break;
if(i == type) return;
if(i < type) i++; else i--;
}
z.setState(2, e);
return;
}
if((o = igtab_getTabFromElement(o)) == null) return;
if(e.type == "mouseover" || e.type == "mousemove") type = 1;
if(e.type == "click"){type = 2; o.owner.fireEvt(o, o.owner.Events.click, e);}
if(e.type == "mousedown") type = 2;
if(e.type == "mouseup") type = 4;
if(type == 2 && (e.button > 1 || e.ctrlKey || e.shiftKey || e.altKey)) return;
if(e.type == "resize") o.scrolInit(e);
if(o.owner == null) return;
if(type == 1) if(o.owner.scrolInit("")) return;
if(!o.owner.enabled) return;
// not tab
if(o.text == null){o.owner.doBut(type, e, o); return;}
if(type > 0){o.setState(type, e); return;}
var w = o.rect(o.element), h = o.rect(o.element, 1);
var x = o.rect(o.element, 2), y = o.rect(o.element, 3);
if(o.elemLeft != null)
{
if((z = o.rect(o.elemLeft, 2)) < x){w += (x - z); x = z;}
if((z = o.rect(o.elemLeft, 3)) < y){h += (y - z); y = z;}
}
if(o.elemRight != null)
{
if(o.rect(o.elemRight, 2) > x) w += o.rect(o.elemRight);
if(o.rect(o.elemRight, 3) > y) h += o.rect(o.elemRight, 1);
}
z = o.element;
while((z = z.offsetParent) != null){x += o.rect(z, 2); y += o.rect(z, 3);}
if(e.clientX < x + 3 || e.clientY < y + 3 || e.clientX + 3 > x + w || e.clientY + 3 > y + h)
o.setState(0, e);
}
//
function igtab_new(elem, id, seps, prop, evts)
{
if(ig_csom.isEmpty(prop)) return;
this.sep1 = (seps.length > 0) ? seps.substring(0, 1) : "\01";
this.sep2 = (seps.length > 1) ? seps.substring(1, 2) : "\02";
this.val = function(o, i){return (o == null || o.length <= i) ? "" : o[i];}
this.vis = function(e, v){if(e != null){e.style.display = (v == null) ? "none" : v; e.style.visibility = (v == null) ? "hidden" : "visible";}}
//
this.addLsnr = function(e, s)
{
if(e == null) return;
ig_csom.addEventListener(e, "select", ig_cancelEvent);
ig_csom.addEventListener(e, "selectstart", ig_cancelEvent);
if(s) return;
ig_csom.addEventListener(e, "mouseout", igtab_event);
ig_csom.addEventListener(e, "mouseover", igtab_event);
ig_csom.addEventListener(e, "mousemove", igtab_event);
ig_csom.addEventListener(e, "click", igtab_event);
if(this.tabIndex < 0) e.unselectable = "on";
}
var prop0 = prop[0].split(this.sep1);
this.ID = id;
if(id.indexOf("x_") == 0) this.ID_ = id.substring(1);
this.element = elem;
this.elemEmpty = igtab_getElementById(id + "_empty");
this.selected = -2;
ig_csom.addEventListener(elem, "resize", igtab_event);
elem.setAttribute("tabID", id);
//
var j, i = -1;
while(++i < 30)
{
if((elem = igtab_getElementById(id + "_r" + i)) == null) break;
if(this.rows == null) this.rows = new Array();
this.rows[i] = elem;
}
if(prop0.length < 6) return;
this.uniqueId = prop0[0];
this.enabled = ig_csom.notEmpty(prop0[1]);
if(!this.enabled) this.element.disabled = true;
this.autoPost = ig_csom.notEmpty(prop0[2]);
this.doPost = this.autoPost;
this.loadAllUrls = ig_csom.notEmpty(prop0[3]);
this.noHov = ig_csom.notEmpty(prop0[6]);
var css, round = 0;
if(ig_csom.notEmpty(prop0[5]))
{
round = parseInt(prop0[5]);
if((round & 1) != 0)
{
this.leftImg = [id + "DefTL", id + "HovTL", id + "SelTL", id + (((round & 4) != 0) ? "DisTL" : "DefTL")];
if(this.noHov) this.leftImg[1] = this.leftImg[0];
}
if((round & 2) != 0)
{
this.rightImg = [id + "DefTR", id + "HovTR", id + "SelTR", id + (((round & 4) != 0) ? "DisTR" : "DefTR")];
if(this.noHov) this.rightImg[1] = this.rightImg[0];
}
}
this.doCss = function(prop)
{
var cs = new Array();
prop = ig_csom.notEmpty(prop) ? prop.split("+") : null;
var j = -1;
if(ig_csom.notEmpty(prop)) while(++j < 4)
if(ig_csom.isEmpty(cs[j] = this.val(prop, j))) cs[j] = cs[0];
return cs;
}
this.dummy = this.val(prop0, 7);
this.tabIndex = this.val(prop0, 8);
if(prop0.length < 12)
{
this.top = this.val(prop0, 9) == 0;
this.back = this.val(prop0, 10);
}
else
{
this.butP = -1;
this.butL = 1;
this.buttons = new Array(4);
for(j = 2; j < 4; j++) if((e = ig_csom.getElementById(id + "more" + j)) != null)
{
ig_csom.addEventListener(e, "mousedown", igtab_event);
e.unselectable = "on";
this.addLsnr(e, true);
e.setAttribute("tabID", id + ",100" + j);
e.owner = this;
this.buttons[j] = e;
}
j = parseInt(this.val(prop0, 9));
this.delay = parseInt(this.val(prop0, 10));
this.scrolHide = ig_csom.notEmpty(prop0[11]);
this.scrolToLast = ig_csom.notEmpty(prop0[12]);
this.css = this.doCss(this.val(prop, 13));
for(i = 0; i < 4; i++)
{
if((o = this.css[i]) == null) o = "";
css = (j < 1) ? "" : (id + "But" + (((j & (1 << i)) != 0) ? i : 0));
if(css.length > 0 && o.length > 0) css += " ";
if((this.css[i] = css + o) == "") this.css[i] = this.css[0];
}
for(j = 0; j < 2; j++) if((e = ig_csom.getElementById(id + "_b" + j)) != null)
{
ig_csom.addEventListener(e, "mousedown", igtab_event);
ig_csom.addEventListener(e, "mouseup", igtab_event);
ig_csom.addEventListener(e, "mousemove", igtab_event);
ig_csom.addEventListener(e, "mouseout", igtab_event);
e.unselectable = "on";
e.setAttribute("tabID", id + ",100" + j);
o = new Object();
o.i = j;
o.elem = e;
o.img = new Array(4);
//images
css = this.val(prop0, 14 + j).split(";");
for(i = 0; i < 4; i++) if((o.img[i] = this.val(css, i)) == "") o.img[i] = o.img[0];
o.state = 0;
o.owner = this;
this.buttons[j] = o;
}
}
css = this.doCss(prop0[4]);
//
this.getUniqueId = function(){return this.uniqueId;}
this.getEnabled = function(){return this.enabled;}//1
this.setEnabled = function(val){this.setEnabled0(this, val);}
this.setEnabled0 = function(o, val)
{
if(o.enabled == (val == true)) return;
o.enabled = (val == true);
var x = -1, owner = o.owner;
if(owner == null) owner = o;
else x = o.index;
owner.update(x, "Enabled", val);
if(++x > 0)
{
o.setState(o.enabled ? 0 : 3);
o.fixSel();
return;
}
while(x < o.Tabs.length) o.Tabs[x++].doState(-1);
o.element.disabled = val != true;
o.scrolW_All = null;
o.scrolInit();
}
this.getAutoPostBack = function(){return this.autoPost;}
this.setAutoPostBack = function(val){this.autoPost = (val == true);}
this.getSelectedIndex = function(){return this.selected;}
this.setSelectedIndex = function(val){igtab_selectTab(this, val);}
this.getSelectedTab = function(){return (this.selected < 0) ? null : this.Tabs[this.selected];}
this.setSelectedTab = function(val){igtab_selectTab(this, (val == null) ? -1 : val.index);}
//
prop0 = ig_csom.notEmpty(evts) ? evts.split(this.sep1) : null;
evts = new Object();
evts.afterSelectedTabChange = this.val(prop0, 0);
evts.beforeSelectedTabChange = this.val(prop0, 1);
evts.initializeTabs = this.val(prop0, 2);
evts.mouseOut = this.val(prop0, 3);
evts.mouseOver = this.val(prop0, 4);
evts.click = this.val(prop0, 5);
this.Events = evts;
this.Tabs = new Array();
this.addLsnr(igtab_getElementById(id + "_tbl"), true);
//
i = -1;
while(++i < prop.length - 1)
{
if((elem = igtab_getElementById(id + "td" + i)) == null) continue;
elem.setAttribute("tabID", id + "," + i);
var tab = new igtab_newT(id, prop[i + 1].split(this.sep1), i, css, this);
tab.element = elem;
tab.tooltip = elem.title;
while(tab.text.indexOf(this.sep2) > 0)
tab.text = tab.text.replace(this.sep2, "\"");
this.addLsnr(elem, false);
if(this.tabIndex != -1) for(j = 0; j < 6; j++)
{
if(elem.tabIndex == -3){ig_csom.addEventListener(elem, "keydown", igtab_event); j = 10;}
if(ig_csom.notEmpty(elem.accessKey)){ig_csom.addEventListener(elem, "focus", igtab_event); j = 10;}
if(j == 10){elem.indexOwner = tab; tab.elemIndex = elem;}
if((elem = elem.parentNode) == null) break;
if(ig_csom.notEmpty(elem.id)) break;
}
this.Tabs[i] = tab;
if(ig_csom.notEmpty(tab.Key)) this.Tabs[tab.Key] = tab;
if((round & 1) != 0) if((elem = igtab_getElementById(id + "td" + i + "L")) != null)
{
elem.setAttribute("tabID", id + "," + i);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -