1 | "use strict";
|
2 | var core_1 = require('@angular/core');
|
3 | var info_window_manager_1 = require('../services/managers/info-window-manager');
|
4 | var infoWindowId = 0;
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | var SebmGoogleMapInfoWindow = (function () {
|
35 | function SebmGoogleMapInfoWindow(_infoWindowManager, _el) {
|
36 | this._infoWindowManager = _infoWindowManager;
|
37 | this._el = _el;
|
38 | |
39 |
|
40 |
|
41 | this.isOpen = false;
|
42 | |
43 |
|
44 |
|
45 | this.infoWindowClose = new core_1.EventEmitter();
|
46 | this._infoWindowAddedToManager = false;
|
47 | this._id = (infoWindowId++).toString();
|
48 | }
|
49 | SebmGoogleMapInfoWindow.prototype.ngOnInit = function () {
|
50 | this.content = this._el.nativeElement.querySelector('.sebm-google-map-info-window-content');
|
51 | this._infoWindowManager.addInfoWindow(this);
|
52 | this._infoWindowAddedToManager = true;
|
53 | this._updateOpenState();
|
54 | this._registerEventListeners();
|
55 | };
|
56 |
|
57 | SebmGoogleMapInfoWindow.prototype.ngOnChanges = function (changes) {
|
58 | if (!this._infoWindowAddedToManager) {
|
59 | return;
|
60 | }
|
61 | if ((changes['latitude'] || changes['longitude']) && typeof this.latitude === 'number' &&
|
62 | typeof this.longitude === 'number') {
|
63 | this._infoWindowManager.setPosition(this);
|
64 | }
|
65 | if (changes['zIndex']) {
|
66 | this._infoWindowManager.setZIndex(this);
|
67 | }
|
68 | if (changes['isOpen']) {
|
69 | this._updateOpenState();
|
70 | }
|
71 | this._setInfoWindowOptions(changes);
|
72 | };
|
73 | SebmGoogleMapInfoWindow.prototype._registerEventListeners = function () {
|
74 | var _this = this;
|
75 | this._infoWindowManager.createEventObservable('closeclick', this).subscribe(function () {
|
76 | _this.isOpen = false;
|
77 | _this.infoWindowClose.emit();
|
78 | });
|
79 | };
|
80 | SebmGoogleMapInfoWindow.prototype._updateOpenState = function () {
|
81 | this.isOpen ? this.open() : this.close();
|
82 | };
|
83 | SebmGoogleMapInfoWindow.prototype._setInfoWindowOptions = function (changes) {
|
84 | var options = {};
|
85 | var optionKeys = Object.keys(changes).filter(function (k) { return SebmGoogleMapInfoWindow._infoWindowOptionsInputs.indexOf(k) !== -1; });
|
86 | optionKeys.forEach(function (k) { options[k] = changes[k].currentValue; });
|
87 | this._infoWindowManager.setOptions(this, options);
|
88 | };
|
89 | |
90 |
|
91 |
|
92 | SebmGoogleMapInfoWindow.prototype.open = function () { return this._infoWindowManager.open(this); };
|
93 | |
94 |
|
95 |
|
96 | SebmGoogleMapInfoWindow.prototype.close = function () {
|
97 | var _this = this;
|
98 | return this._infoWindowManager.close(this).then(function () { _this.infoWindowClose.emit(); });
|
99 | };
|
100 |
|
101 | SebmGoogleMapInfoWindow.prototype.id = function () { return this._id; };
|
102 |
|
103 | SebmGoogleMapInfoWindow.prototype.toString = function () { return 'SebmGoogleMapInfoWindow-' + this._id.toString(); };
|
104 |
|
105 | SebmGoogleMapInfoWindow.prototype.ngOnDestroy = function () { this._infoWindowManager.deleteInfoWindow(this); };
|
106 | SebmGoogleMapInfoWindow._infoWindowOptionsInputs = ['disableAutoPan', 'maxWidth'];
|
107 | SebmGoogleMapInfoWindow.decorators = [
|
108 | { type: core_1.Component, args: [{
|
109 | selector: 'sebm-google-map-info-window',
|
110 | inputs: ['latitude', 'longitude', 'disableAutoPan', 'isOpen', 'zIndex', 'maxWidth'],
|
111 | outputs: ['infoWindowClose'],
|
112 | template: "<div class='sebm-google-map-info-window-content'>\n <ng-content></ng-content>\n </div>\n "
|
113 | },] },
|
114 | ];
|
115 |
|
116 | SebmGoogleMapInfoWindow.ctorParameters = function () { return [
|
117 | { type: info_window_manager_1.InfoWindowManager, },
|
118 | { type: core_1.ElementRef, },
|
119 | ]; };
|
120 | return SebmGoogleMapInfoWindow;
|
121 | }());
|
122 | exports.SebmGoogleMapInfoWindow = SebmGoogleMapInfoWindow;
|
123 |
|
\ | No newline at end of file |