UNPKG

rx-dom-events

Version:
3 lines 3.26 kB
/* Copyright (c) Microsoft, Inc. All rights reserved. See License.txt in the project root for license information.*/ (function(a){function b(a){return a&&a.Object===Object?a:null}var c={"function":!0,object:!0},d=c[typeof exports]&&exports&&!exports.nodeType?exports:null,e=c[typeof module]&&module&&!module.nodeType?module:null,f=b(d&&e&&"object"==typeof global&&global),g=b(c[typeof self]&&self),h=b(c[typeof window]&&window),i=(e&&e.exports===d?d:null,b(c[typeof this]&&this)),j=f||h!==(i&&i.window)&&h||g||i||Function("return this")();"function"==typeof define&&define.amd?define(["rx"],function(b,c){return a(j,c,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(j,module.exports,require("rx")):j.Rx=a(j,{},j.Rx)}).call(this,function(a,b,c,d){function e(a){return function(){try{return a.apply(this,arguments)}catch(b){return o.e=b,o}}}function f(a){if(!m(a))throw new TypeError("fn must be a function");return e(a)}function g(a,b,c,d){this._e=a,this._n=b,this._fn=c,this._u=d,this._e.addEventListener(this._n,this._fn,this._u),this.isDisposed=!1}function h(a,b,c,d){if(a.addEventListener)return new g(a,b,c,d);throw new Error("No listener found")}function i(a,b,c,d){var e=new k,f=Object.prototype.toString;if("[object NodeList]"===f.call(a)||"[object HTMLCollection]"===f.call(a))for(var g=0,j=a.length;j>g;g++)e.add(i(a.item(g),b,c,d));else a&&e.add(h(a,b,c,d));return e}var j=c.ObservableBase,k=c.CompositeDisposable,l=c.DOM||(c.DOM={}),m=c.helpers.isFunction,n=c.internals.inherits,o={e:{}};g.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this._e.removeEventListener(this._n,this._fn,this._u))};var p=function(a){function b(b,c,d,e){this._e=b,this._n=c,this._fn=d,this._uc=e,a.call(this)}function c(a,b){return function(){var c=arguments[0];return b&&(c=f(b).apply(null,arguments),c===o)?a.onError(c.e):void a.onNext(c)}}return n(b,a),b.prototype.subscribeCore=function(a){return i(this._e,this._n,c(a,this._fn),this._uc)},b}(j),q=l.fromEvent=function(a,b,c,d){var e=m(c)?c:null;return"boolean"==typeof c&&(d=c),"undefined"==typeof d&&(d=!1),new p(a,b,e,d).publish().refCount()};!function(){var b="blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu input";a.PointerEvent&&(b+=" pointerdown pointerup pointermove pointerover pointerout pointerenter pointerleave"),a.TouchEvent&&(b+=" touchstart touchend touchmove touchcancel"),b=b.split(" ");for(var c=0,d=b.length;d>c;c++)!function(a){l[a]=function(b,c,d){return q(b,a,c,d)}}(b[c])}();var r=function(b){function c(){b.call(this)}function d(a){return function(){a.onNext(),a.onCompleted()}}function e(b,c){this._o=b,this._fn=c,this._addedHandlers=!1,this.isDisposed=!1,"complete"===a.document.readyState?setTimeout(this._fn,0):(this._addedHandlers=!0,a.document.addEventListener("DOMContentLoaded",this._fn,!1))}return n(c,b),c.prototype.subscribeCore=function(a){return new e(a,d(a))},e.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,a.document.removeEventListener("DOMContentLoaded",this._fn,!1))},c}(j);return l.ready=function(){return new r},c}); //# sourceMappingURL=rx.dom.events.map