UNPKG

ng2-events

Version:

Supercharge your Angular2+ event handling

59 lines (58 loc) 2.76 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.MultiEventPlugin = void 0; var core_1 = require("@angular/core"); var common_1 = require("@angular/common"); var event_manager_plugin_1 = require("../__util/event-manager-plugin"); var i0 = require("@angular/core"); /** * Register multiple event listeners * * Usage: * <button (multi.focus,select)="foo($event)"></button> * */ var MultiEventPlugin = /** @class */ (function (_super) { __extends(MultiEventPlugin, _super); function MultiEventPlugin(doc) { return _super.call(this, doc) || this; } MultiEventPlugin.prototype.supports = function (eventName) { return eventName.indexOf('multi.') === 0; }; MultiEventPlugin.prototype.addEventListener = function (element, eventName, handler) { var _this = this; var eventNames = eventName.slice(6).split(','); var eventListeners = eventNames.map(function (x) { return _this.manager.addEventListener(element, x, handler); }); return function () { eventListeners.forEach(function (x) { return x(); }); }; }; MultiEventPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.2", ngImport: i0, type: MultiEventPlugin, deps: [{ token: common_1.DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); MultiEventPlugin.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.2", ngImport: i0, type: MultiEventPlugin }); return MultiEventPlugin; }(event_manager_plugin_1.MyEventManagerPlugin)); exports.MultiEventPlugin = MultiEventPlugin; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.2", ngImport: i0, type: MultiEventPlugin, decorators: [{ type: core_1.Injectable }], ctorParameters: function () { return [{ type: undefined, decorators: [{ type: core_1.Inject, args: [common_1.DOCUMENT] }] }]; } });