📄 ext-core-debug.js
字号:
Ext.EventObjectImpl.prototype = {
browserEvent : null,
button : -1,
shiftKey : false,
ctrlKey : false,
altKey : false,
BACKSPACE : 8,
TAB : 9,
RETURN : 13,
ENTER : 13,
SHIFT : 16,
CONTROL : 17,
ESC : 27,
SPACE : 32,
PAGEUP : 33,
PAGEDOWN : 34,
END : 35,
HOME : 36,
LEFT : 37,
UP : 38,
RIGHT : 39,
DOWN : 40,
DELETE : 46,
F5 : 116,
setEvent : function(e){
if(e == this || (e && e.browserEvent)){ return e;
}
this.browserEvent = e;
if(e){
this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
this.shiftKey = e.shiftKey;
this.ctrlKey = e.ctrlKey || e.metaKey;
this.altKey = e.altKey;
this.keyCode = e.keyCode;
this.charCode = e.charCode;
this.target = E.getTarget(e);
this.xy = E.getXY(e);
}else{
this.button = -1;
this.shiftKey = false;
this.ctrlKey = false;
this.altKey = false;
this.keyCode = 0;
this.charCode =0;
this.target = null;
this.xy = [0, 0];
}
return this;
},
stopEvent : function(){
if(this.browserEvent){
if(this.browserEvent.type == 'mousedown'){
Ext.EventManager.stoppedMouseDownEvent.fire(this);
}
E.stopEvent(this.browserEvent);
}
},
preventDefault : function(){
if(this.browserEvent){
E.preventDefault(this.browserEvent);
}
},
isNavKeyPress : function(){
var k = this.keyCode;
k = Ext.isSafari ? (safariKeys[k] || k) : k;
return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
},
isSpecialKey : function(){
var k = this.keyCode;
return k == 9 || k == 13 || k == 40 || k == 27 ||
(k == 16) || (k == 17) ||
(k >= 18 && k <= 20) ||
(k >= 33 && k <= 35) ||
(k >= 36 && k <= 39) ||
(k >= 44 && k <= 45);
},
stopPropagation : function(){
if(this.browserEvent){
if(this.browserEvent.type == 'mousedown'){
Ext.EventManager.stoppedMouseDownEvent.fire(this);
}
E.stopPropagation(this.browserEvent);
}
},
getCharCode : function(){
return this.charCode || this.keyCode;
},
getKey : function(){
var k = this.keyCode || this.charCode;
return Ext.isSafari ? (safariKeys[k] || k) : k;
},
getPageX : function(){
return this.xy[0];
},
getPageY : function(){
return this.xy[1];
},
getTime : function(){
if(this.browserEvent){
return E.getTime(this.browserEvent);
}
return null;
},
getXY : function(){
return this.xy;
},
getTarget : function(selector, maxDepth, returnEl){
return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : this.target;
},
getRelatedTarget : function(){
if(this.browserEvent){
return E.getRelatedTarget(this.browserEvent);
}
return null;
},
getWheelDelta : function(){
var e = this.browserEvent;
var delta = 0;
if(e.wheelDelta){
delta = e.wheelDelta/120;
if(window.opera) delta = -delta;
}else if(e.detail){
delta = -e.detail/3;
}
return delta;
},
hasModifier : function(){
return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
},
within : function(el, related){
var t = this[related ? "getRelatedTarget" : "getTarget"]();
return t && Ext.fly(el).contains(t);
},
getPoint : function(){
return new Ext.lib.Point(this.xy[0], this.xy[1]);
}
};
return new Ext.EventObjectImpl();
}();
(function(){
var D = Ext.lib.Dom;
var E = Ext.lib.Event;
var A = Ext.lib.Anim;
var propCache = {};
var camelRe = /(-[a-z])/gi;
var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
var view = document.defaultView;
Ext.Element = function(element, forceNew){
var dom = typeof element == "string" ?
document.getElementById(element) : element;
if(!dom){ return null;
}
if(!forceNew && Ext.Element.cache[dom.id]){ return Ext.Element.cache[dom.id];
}
this.dom = dom;
this.id = dom.id || Ext.id(dom);
};
var El = Ext.Element;
El.prototype = {
originalDisplay : "",
visibilityMode : 1,
defaultUnit : "px",
setVisibilityMode : function(visMode){
this.visibilityMode = visMode;
return this;
},
enableDisplayMode : function(display){
this.setVisibilityMode(El.DISPLAY);
if(typeof display != "undefined") this.originalDisplay = display;
return this;
},
findParent : function(simpleSelector, maxDepth, returnEl){
var p = this.dom, b = document.body, depth = 0, dq = Ext.DomQuery, stopEl;
maxDepth = maxDepth || 50;
if(typeof maxDepth != "number"){
stopEl = Ext.getDom(maxDepth);
maxDepth = 10;
}
while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
if(dq.is(p, simpleSelector)){
return returnEl ? Ext.get(p) : p;
}
depth++;
p = p.parentNode;
}
return null;
},
findParentNode : function(simpleSelector, maxDepth, returnEl){
var p = Ext.fly(this.dom.parentNode, '_internal');
return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
},
up : function(simpleSelector, maxDepth){
return this.findParentNode(simpleSelector, maxDepth, true);
},
is : function(simpleSelector){
return Ext.DomQuery.is(this.dom, simpleSelector);
},
animate : function(args, duration, onComplete, easing, animType){
this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
return this;
},
anim : function(args, opt, animType, defaultDur, defaultEase, cb){
animType = animType || 'run';
opt = opt || {};
var anim = Ext.lib.Anim[animType](
this.dom, args,
(opt.duration || defaultDur) || .35,
(opt.easing || defaultEase) || 'easeOut',
function(){
Ext.callback(cb, this);
Ext.callback(opt.callback, opt.scope || this, [this, opt]);
},
this
);
opt.anim = anim;
return anim;
},
preanim : function(a, i){
return !a[i] ? false : (typeof a[i] == "object" ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
},
clean : function(forceReclean){
if(this.isCleaned && forceReclean !== true){
return this;
}
var ns = /\S/;
var d = this.dom, n = d.firstChild, ni = -1;
while(n){
var nx = n.nextSibling;
if(n.nodeType == 3 && !ns.test(n.nodeValue)){
d.removeChild(n);
}else{
n.nodeIndex = ++ni;
}
n = nx;
}
this.isCleaned = true;
return this;
},
calcOffsetsTo : function(el){
el = Ext.get(el), d = el.dom;
var restorePos = false;
if(el.getStyle('position') == 'static'){
el.position('relative');
restorePos = true;
}
var x = 0, y =0;
var op = this.dom;
while(op && op != d && op.tagName != 'HTML'){
x+= op.offsetLeft;
y+= op.offsetTop;
op = op.offsetParent;
}
if(restorePos){
el.position('static');
}
return [x, y];
},
scrollIntoView : function(container, hscroll){
var c = Ext.getDom(container) || document.body;
var el = this.dom;
var o = this.calcOffsetsTo(c),
l = o[0],
t = o[1],
b = t+el.offsetHeight,
r = l+el.offsetWidth;
var ch = c.clientHeight;
var ct = parseInt(c.scrollTop, 10);
var cl = parseInt(c.scrollLeft, 10);
var cb = ct + ch;
var cr = cl + c.clientWidth;
if(t < ct){
c.scrollTop = t;
}else if(b > cb){
c.scrollTop = b-ch;
}
if(hscroll !== false){
if(l < cl){
c.scrollLeft = l;
}else if(r > cr){
c.scrollLeft = r-c.clientWidth;
}
}
return this;
},
scrollChildIntoView : function(child){
Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this);
},
autoHeight : function(animate, duration, onComplete, easing){
var oldHeight = this.getHeight();
this.clip();
this.setHeight(1); setTimeout(function(){
var height = parseInt(this.dom.scrollHeight, 10); if(!animate){
this.setHeight(height);
this.unclip();
if(typeof onComplete == "function"){
onComplete();
}
}else{
this.setHeight(oldHeight); this.setHeight(height, animate, duration, function(){
this.unclip();
if(typeof onComplete == "function") onComplete();
}.createDelegate(this), easing);
}
}.createDelegate(this), 0);
return this;
},
contains : function(el){
if(!el){return false;}
return D.isAncestor(this.dom, el.dom ? el.dom : el);
},
isVisible : function(deep) {
var vis = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none");
if(deep !== true || !vis){
return vis;
}
var p = this.dom.parentNode;
while(p && p.tagName.toLowerCas
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -