UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

966 lines (965 loc) 32.2 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { EventProxy } from "./EventProxy"; import { Point_$type, runOn, markType, PointUtil, String_$type, Delegate_$type } from "./type"; import { Rect } from "./Rect"; import { MouseEventArgs } from "./MouseEventArgs"; import { Dictionary$2 } from "./Dictionary$2"; import { List$1 } from "./List$1"; /** * @hidden */ export let BaseDOMEventProxy = /*@__PURE__*/ (() => { class BaseDOMEventProxy extends EventProxy { constructor() { super(); this.b5 = null; this.bw = false; this.by = false; this.b4 = null; this.bp = false; this.b2 = 0; this.b3 = 0; this.b0 = 0; this.b1 = 0; this.b6 = 0; this.c4 = null; this.c3 = null; this.bo = false; this.b7 = -1; this.bt = false; this.bq = false; this.bn = false; this.ao = 1; } d() { let a = new DOMEventProxy(this.b5, this.b4, this.by); a.ab = this.ab; a.aq = this.aq; return a; } static get bz() { return (BaseDOMEventProxy.bu || BaseDOMEventProxy.bv); } bl(a) { return DOMEventProxy.c5(a); } bs(e_) { let pointerEvent_ = e_.originalEvent; let a = false; if (BaseDOMEventProxy.bv) { a = (pointerEvent_.pointerType == 'touch'); } else { a = (pointerEvent_.pointerType == pointerEvent_.MSPOINTER_TYPE_TOUCH); } return a; } cv(a) { if (!this.ae) { if (this.br(a)) { if (this.as == null || this.as(a)) { a.preventDefault(); } } } } br(e_) { return (e_.originalEvent.cancelable || e_.originalEvent.cancelable == undefined); } cr() { let source_ = this.b5.getNativeElement(); BaseDOMEventProxy.cu(source_); } static cu(source_) { if (BaseDOMEventProxy.bv) { source_.style.touchAction = 'none'; } else { source_.style.msTouchAction = 'none'; } source_.style.msUserSelect = 'none'; source_.style.webkitTouchCallout = 'none'; source_.style.webkitUserSelect = 'none'; source_.style.khtmlUserSelect = 'none'; source_.style.mozUserSelect = 'none'; source_.style.userSelect = 'none'; } static co(source_) { if (BaseDOMEventProxy.bv) { source_.style.touchAction = 'auto'; } else { source_.style.msTouchAction = 'auto'; } source_.style.msUserSelect = 'auto'; source_.style.webkitTouchCallout = 'none'; source_.style.webkitUserSelect = 'auto'; source_.style.khtmlUserSelect = 'auto'; source_.style.mozUserSelect = 'auto'; source_.style.userSelect = 'auto'; } cp() { let source_ = this.b5.getNativeElement(); BaseDOMEventProxy.co(source_); } ax() { super.ax(); if (!this.ae) { this.cr(); } else { this.cp(); } } cc() { let ver_ = -1; let matchIE_ = /Trident\/([\d.]+)/; if ((matchIE_.exec(navigator.userAgent) != null)) { ver_ = (parseFloat(RegExp.$1)); } return ver_; } cb() { let ver_ = -1; let matchIE_ = /Edge\/([\d.]+)/; if ((matchIE_.exec(navigator.userAgent) != null)) { ver_ = (parseFloat(RegExp.$1)); } return ver_; } static ct(e_) { let a = BaseDOMEventProxy.cd >= 6; let oe_ = e_.originalEvent; if ((((typeof e_.pageX == 'undefined')) || a) && oe_.clientX != null) { let od_; if ((e_.target !== undefined)) { od_ = e_.target.ownerDocument; } else { od_ = e_.originalEvent.target.ownerDocument; } let ed_ = od_ ? od_ : document; let doc_ = ed_.documentElement; let body_ = ed_.body; let clientX_ = oe_.clientX; let clientY_ = oe_.clientY; let scrollLeft_ = doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0; let scrollTop_ = doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0; let clientLeft_ = doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0; let clientTop_ = doc_ && doc_.clientTop || body_ && body_.clientTop || 0; e_.pageX = clientX_ + (scrollLeft_ - clientLeft_); e_.pageY = clientY_ + (scrollTop_ - clientTop_); } if ((!e_.pageX)) { e_.pageX = e_.originalEvent.pageX; } if ((!e_.pageY)) { e_.pageY = e_.originalEvent.pageY; } if (((typeof e_.button == 'undefined')) && ((typeof oe_.button != 'undefined'))) { e_.button = oe_.button; } } static c5(a) { let b = BaseDOMEventProxy.cd >= 6; let source_ = a.getNativeElement(); let d_ = source_.ownerDocument; let doc_ = d_ ? d_.documentElement : null; let z_ = doc_ ? doc_.msContentZoomFactor : null; let body_ = doc_.body; if ((z_ && z_ > 1) || b) { let rect_ = source_.getBoundingClientRect(); let x_ = (rect_.left); let y_ = (rect_.top); let scrollLeft_ = (doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0); let scrollTop_ = (doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0); let clientLeft_ = (doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0); let clientTop_ = (doc_ && doc_.clientTop || body_ && body_.clientTop || 0); let c = x_ + scrollLeft_ - clientLeft_; let d = y_ + scrollTop_ - clientTop_; return new Rect(0, c, d, 0, 0); } else { let e = a.getOffset(); return new Rect(0, e.left, e.top, 0, 0); } } get b9() { return this.b6; } set b9(a) { this.b6 = a; } cy(a) { this.at = a; BaseDOMEventProxy.ct(a); let b = BaseDOMEventProxy.c5(this.b5); let c = 0; let d = 0; if (Rect.l_op_Inequality(this.bm, null)) { c = this.bm.left; d = this.bm.top; } this.b2 = (a.pageX - b.left) * this.ao; this.b3 = (a.pageY - b.top) * this.ao; this.b0 = this.b2 - c; this.b1 = this.b3 - d; this.c4 = { $type: Point_$type, x: this.b2, y: this.b3 }; this.c3 = { $type: Point_$type, x: this.b0, y: this.b1 }; } cz(e_) { this.at = e_; BaseDOMEventProxy.ct(e_); if (BaseDOMEventProxy.bz) { let a = e_.pageX; let b = e_.pageY; let c = BaseDOMEventProxy.c5(this.b5); this.b2 = a - c.left; this.b3 = b - c.top; } else { this.b6 = 0; if (!e_.originalEvent.targetTouches || e_.originalEvent.targetTouches.length < 1) { return; } ; this.b6 = (e_.originalEvent.targetTouches.length); let d = (e_.originalEvent.targetTouches[0].pageX); let e = (e_.originalEvent.targetTouches[0].pageY); let f = BaseDOMEventProxy.c5(this.b5); this.b2 = d - f.left; this.b3 = e - f.top; } let g = 0; let h = 0; if (Rect.l_op_Inequality(this.bm, null)) { g = this.bm.left; h = this.bm.top; } this.b0 = this.b2 - g; this.b1 = this.b3 - h; this.c4 = { $type: Point_$type, x: this.b2, y: this.b3 }; this.c3 = { $type: Point_$type, x: this.b0, y: this.b1 }; } cn(e_) { this.cx(e_); if (this.ad(this.c4, false, true)) { let deltaY_ = 0; let ev_ = e_; deltaY_ = (ev_.originalEvent ? ev_.originalEvent.deltaY : ev_.deltaY); let deltaX_ = 0; deltaX_ = (ev_.originalEvent ? ev_.originalEvent.deltaX : ev_.deltaX); let a = (ev_.originalEvent ? (ev_.originalEvent.deltaMode == 1) : (ev_.deltaMode == 1)); if (a) { deltaY_ = deltaY_ * 40; deltaX_ = deltaX_ * 40; } let b = this.aj(this.c3, deltaY_); let c = this.ak(this.c3, deltaX_); if (b || c) { this.cv(e_); } } } cl(e_) { this.cx(e_); this.cy(e_); if (this.ad(this.c4, false, true)) { let ev_ = e_; let delta_ = 0; if (ev_.wheelDelta) { delta_ = ev_.wheelDelta / 120; } ; if (ev_.originalEvent && ev_.originalEvent.wheelDelta) { delta_ = ev_.originalEvent.wheelDelta / 120; } ; if (ev_.detail) { delta_ = -ev_.detail / 3; } ; if (ev_.originalEvent && ev_.originalEvent.detail) { delta_ = -ev_.originalEvent.detail / 3; } ; delta_ = delta_ / 10; let a = this.aj(this.c3, delta_); if (a) { this.cv(e_); } } } cs() { if (this.bo) { if (this.b7 == -1) { this.b7 = this.b4.setTimeout(runOn(this, this.cq), 500); } else { window.clearTimeout(this.b7); this.b7 = -1; this.b7 = this.b4.setTimeout(runOn(this, this.cq), 500); } } } ce() { this.bo = true; if (this.b7 != -1) { window.clearTimeout(this.b7); this.b7 = -1; } } cq() { this.bo = false; } get bx() { return this.bq; } set bx(a) { this.bq = a; } cj(a) { if (this.bq || this.bo) { return; } this.cy(a); if (this.bt) { this.bt = false; this.ba(this.c3); } } ck(a) { if (this.bq || this.bo) { return; } this.cy(a); this.cx(a); let b = new MouseEventArgs(); b.position = this.c4; if (this.ad(this.c4, false, false)) { if (!this.bt) { this.bt = true; this.a9(this.c4); } this.bb(this.c4, true, false); this.az(this.c3, false); } else if (this.bt) { this.cj(a); } } cw(a) { this.b5.focus(this.bw); } ci(a) { if (this.bq || this.bo) { return; } this.cw(a); this.cy(a); this.cx(a); if (this.ad(this.c4, false, false)) { this.bn = true; this.a8(this.c4); this.a0(this.c3, false); this.cv(a); } } c0(a) { if (this.bq || this.bo) { return; } if (this.bn) { this.cm(a); } } cm(a) { if (this.bq || this.bo) { return; } this.cx(a); if (PointUtil.equals(this.c4, null) || PointUtil.equals(this.c3, null)) { this.cy(a); } let b = this.ad(this.c4, false, false) || this.bn || this.bt; this.bn = false; this.bc(this.c4); this.ay(this.c3, false, false); if (b) { this.cv(a); } } cf(a) { this.cg(a, true); } ch(a) { this.cg(a, false); } c2(a) { return BaseDOMEventProxy.c1(a); } static c1(a) { let b; switch (a.which) { case 33: b = 10; break; case 34: b = 11; break; case 36: b = 13; break; case 37: b = 14; break; case 38: b = 15; break; case 39: b = 16; break; case 40: b = 17; break; case 9: b = 2; break; case 32: b = 9; break; case 13: b = 3; break; case 27: b = 8; break; case 16: b = 4; break; case 17: b = 5; break; case 18: b = 6; break; case 8: b = 1; break; case 35: b = 12; break; case 45: b = 18; break; case 46: b = 19; break; case 106: b = 78; break; case 107: b = 79; break; case 109: b = 80; break; case 110: b = 81; break; case 111: b = 82; break; case 220: b = 85; break; case 192: b = 86; break; case 191: b = 84; break; case 186: b = 83; break; case 189: b = 88; break; case 187: b = 87; break; default: if (112 <= a.which && a.which <= 123) { b = (56 + a.which - 112); } else if (65 <= a.which && a.which <= 90) { b = (30 + a.which - 65); } else if (48 <= a.which && a.which <= 57) { b = (20 + a.which - 48); } else if (96 <= a.which && a.which <= 105) { b = (68 + a.which - 96); } else { b = 0; } break; } return b; } cg(a, b) { let c = this.c2(a); let d = c != 0; this.cx(a); if (d) { let e = false; if (b) { e = this.ah(c); } else { e = this.ai(c); } if (e) { this.cv(a); } } } cx(a) { this.at = a; this.bj = 0; if (a.shiftKey) { this.bj = this.bj | 4; } if (a.altKey) { this.bj = this.bj | 1; } if (a.ctrlKey) { this.bj = this.bj | 2; } this.al = a.button == 2; } bk() { let a = BaseDOMEventProxy.c5(this.b5); let b = a.left; let c = a.top; return { $type: Point_$type, x: b, y: c }; } } BaseDOMEventProxy.$t = markType(BaseDOMEventProxy, 'BaseDOMEventProxy', EventProxy.$); BaseDOMEventProxy.bu = false; BaseDOMEventProxy.bv = false; BaseDOMEventProxy.cd = 0; BaseDOMEventProxy.ca = 0; return BaseDOMEventProxy; })(); /** * @hidden */ export let DOMEventProxy = /*@__PURE__*/ (() => { class DOMEventProxy extends BaseDOMEventProxy { constructor(a, b, c) { super(); this.df = 0; this.dh = ""; this.c7 = false; this.dg = null; this.c9 = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0); this.d4 = null; this.dd = -1; this.d5 = null; this.db = 0; this.dc = 0; this.da = 5; this.c6 = false; this.d3 = null; this.by = c; this.b4 = b; this.aq = (d) => true; this.ab = false; DOMEventProxy.de++; this.df = DOMEventProxy.de; this.dh = ".DOMProxy" + this.df.toString(); this.bj = 0; this.b5 = a; BaseDOMEventProxy.bu = false; try { BaseDOMEventProxy.bu = (window.navigator.msPointerEnabled && window.MSGesture !== undefined); } catch (d) { } BaseDOMEventProxy.bv = false; try { BaseDOMEventProxy.bv = (window.PointerEvent !== undefined); } catch (e) { } BaseDOMEventProxy.cd = this.cc(); BaseDOMEventProxy.ca = this.cb(); this.au(this.b5, ""); this.ap = (f) => true; } di(a, b, c) { } au(a, b) { let c = a; let d = this.dh + b; if (!this.b4.supportsDOMEvents()) { return; } let e = new List$1(Delegate_$type, 0); this.c9.addItem(d, e); this.di(a, b, e); if (!BaseDOMEventProxy.bz) { e.add(c.listen("mousemove", runOn(this, this.ck))); e.add(c.listen("mouseleave", runOn(this, this.cj))); e.add(c.listen("mousedown", runOn(this, this.ci))); e.add(c.listen("mouseup", runOn(this, this.cm))); e.add(this.b4.globalListen("window", "mouseup", runOn(this, this.c0))); } e.add(c.listen("keydown", runOn(this, this.cf))); e.add(c.listen("keyup", runOn(this, this.ch))); let source_ = this.b5.getNativeElement(); if (!this.ae) { BaseDOMEventProxy.cu(source_); } if (BaseDOMEventProxy.bz) { let f = this.b5.getNativeElement(); if ((window.MSGesture !== undefined)) { let gesture_ = new window.MSGesture(); let container_ = f; gesture_.target = container_; this.dg = gesture_; e.add(c.listen("MSGestureStart", runOn(this, this.dl))); e.add(c.listen("MSGestureChange", runOn(this, this.dj))); e.add(c.listen("MSGestureEnd", runOn(this, this.dk))); } if (BaseDOMEventProxy.bv) { e.add(c.listen("pointerdown", runOn(this, this.dp))); e.add(c.listen("pointerup", runOn(this, this.ds))); e.add(c.listen("pointercancel", runOn(this, this.dn))); e.add(c.listen("pointermove", runOn(this, this.dq))); e.add(c.listen("pointerout", runOn(this, this.dr))); e.add(c.listen("lostpointercapture", runOn(this, this.dm))); } else { e.add(c.listen("MSPointerDown", runOn(this, this.dp))); e.add(c.listen("MSPointerUp", runOn(this, this.ds))); e.add(c.listen("MSPointerCancel", runOn(this, this.dn))); e.add(c.listen("MSPointerMove", runOn(this, this.dq))); e.add(c.listen("MSPointerOut", runOn(this, this.dr))); e.add(c.listen("MSLostPointerCapture", runOn(this, this.dm))); } } else { e.add(c.listen("gesturestart", runOn(this, this.dl))); e.add(c.listen("gesturechange", runOn(this, this.dj))); e.add(c.listen("gestureend", runOn(this, this.dk))); e.add(c.listen("touchstart", runOn(this, this.dv))); e.add(c.listen("touchmove", runOn(this, this.du))); e.add(c.listen("touchend", runOn(this, this.dt))); } if (this.by) { e.add(c.listen("wheel", runOn(this, this.cn))); } else { e.add(c.listen("DOMMouseScroll", runOn(this, this.cl))); e.add(c.listen("mousewheel", runOn(this, this.cl))); } } ds(e_) { let a = this.bs(e_); if (a) { this.b9 = this.b9 - 1; if (this.b9 < 0) { this.b9 = 0; } } if (this.b9 < 2 && this.c7 && a) { this.c7 = false; let b = (e_.originalEvent.scale); this.a5(this.c3, b); } else { if (a) { this.dt(e_); } else { this.cm(e_); } } } dm(e_) { let a = this.bs(e_); if (a) { this.b9--; if (this.b9 < 0) { this.b9 = 0; } } if (this.b9 < 2 && this.c7 && a) { this.c7 = false; let b = (e_.originalEvent.scale); this.a5(this.c3, b); } } dn(e_) { let a = this.bs(e_); if (a) { this.b9--; if (this.b9 < 0) { this.b9 = 0; } } if (this.b9 < 2 && this.c7 && a) { this.c7 = false; let b = (e_.originalEvent.scale); this.a5(this.c3, b); } } dp(e_) { let a = this.bs(e_); if (this.dg != null && a) { this.b9++; let mGesture_ = this.dg; mGesture_.addPointer(e_.originalEvent.pointerId); } let eventSource_ = this.b5.getNativeElement(); if (BaseDOMEventProxy.bv) { eventSource_.setPointerCapture(e_.originalEvent.pointerId); } else { eventSource_.msSetPointerCapture(e_.originalEvent.pointerId); } if (this.b9 > 1 && !this.c7 && a) { this.c7 = true; this.cz(e_); let b = (e_.originalEvent.scale); this.be(this.c3, b); } else { if (a) { this.dv(e_); } else { this.ci(e_); } } } dq(e_) { let a = this.bs(e_); if (this.c7) { return; } if (a) { this.du(e_); } else { this.ck(e_); } } dr(e_) { let a = this.bs(e_); if (this.c7) { return; } if (a) { } else { this.cj(e_); } } dl(e_) { this.bt = true; this.cx(e_); this.cz(e_); this.dx(); if (this.ad(this.c4, true, false)) { this.cv(e_); if (BaseDOMEventProxy.bz && this.b9 < 2) { return; } let a = (e_.originalEvent.scale); this.be(this.c3, a); } } dj(e_) { this.bt = true; this.cx(e_); this.cz(e_); if (this.ad(this.c4, true, false)) { this.cv(e_); if (BaseDOMEventProxy.bz && this.b9 < 2) { return; } let a = (e_.originalEvent.scale); this.bd(this.c3, a); } } dk(e_) { this.cv(e_); let a = (e_.originalEvent.scale); this.bt = false; this.cx(e_); this.cz(e_); if (!BaseDOMEventProxy.bz || this.c7) { this.a5(this.c3, a); } } dv(e_) { this.bt = true; this.cx(e_); this.cz(e_); this.d4 = this.c3; if (this.ad(this.c4, true, false)) { if (!this.ab) { this.cv(e_); } else { this.bx = true; } this.bb(this.c4, false, true); this.a8(this.c4); this.a0(this.c3, true); this.d0(); } } d0() { if (this.dd == -1) { this.db = this.c4.x; this.dc = this.c4.y; this.dd = this.b4.setTimeout(runOn(this, this.dy), 1500); } } dx() { if (Math.abs(this.db - this.c4.x) > this.da || Math.abs(this.dc - this.c4.y) > this.da) { this.d1(); } } d1() { if (this.dd != -1) { window.clearTimeout(this.dd); this.dd = -1; } } dy() { this.dd = -1; if (this.bx) { this.bx = false; this.ce(); } this.a6(this.c3); } du(a) { this.bt = true; this.cx(a); this.cz(a); if (this.bx) { if (this.ad(this.c4, true, false) && this.c8()) { this.bx = false; this.ce(); } } this.dx(); this.d2(); if (this.ad(this.c4, true, false) && this.b9 == 1 && !this.bx) { this.cv(a); if (!this.c6) { this.c6 = true; this.d3 = this.c3; this.a4(this.d3); } else { this.bb(this.c4, true, true); this.az(this.c3, true); this.a3(this.c3); } } } c8() { let a = { $type: Point_$type, x: this.d4.x - this.c3.x, y: this.d4.y - this.c3.y }; if (Math.abs(a.x) < 2 && Math.abs(a.y) < 2) { return false; } if (Math.abs(a.x) > Math.abs(a.y)) { a.y = 0; } if (Math.abs(a.y) > Math.abs(a.x)) { a.x = 0; } return this.aq(a); } dt(a) { this.bt = false; this.cx(a); this.cz(a); this.d1(); if (this.bx) { this.bx = false; this.ce(); } this.cv(a); this.bb(this.c4, false, true); this.bc(this.c4); if (this.b9 == 0) { this.dz(this.c4); this.cs(); } if (this.c6 && this.b9 == 0) { this.c6 = false; this.d3 = null; this.a2(this.c3); this.cs(); } this.ay(this.c3, true, this.b9 > 0); } dz(a) { if (Rect.l_op_Equality(this.d5, null)) { this.d5 = new Rect(0, a.x - 50, a.y - 50, 100, 100); this.b4.setTimeout(runOn(this, this.d2), 500); } else { if (a.x >= this.d5.x && a.x <= this.d5.right && a.y >= this.d5.y && a.y <= this.d5.bottom) { this.d2(); this.a1(a); } } } d2() { this.d5 = null; } dw(a) { if (this.c9.containsKey(a)) { let b = this.c9.item(a); this.c9.removeItem(a); for (let c = 0; c < b.count; c++) { b._inner[c](); } b.clear(); } } bi(a, b) { if (a == null) { return; } let c = a; let d = this.dh + b; this.dw(d); } aw() { if (this.b5 == null) { return; } this.dw(this.dh); this.b5 = null; } } DOMEventProxy.$t = markType(DOMEventProxy, 'DOMEventProxy', BaseDOMEventProxy.$); DOMEventProxy.de = 0; return DOMEventProxy; })();