all files / lib/ scale-control.directive.js

88.52% Statements 108/122
76.6% Branches 36/47
83.33% Functions 25/30
89.47% Lines 102/114
1 2 3 4 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238    17× 17× 41× 17×   23×     23× 23× 23× 23× 23× 23× 23× 23× 23× 23× 23× 23× 23× 23× 23×   23× 23×     23×   23×   23×   23×   23×   23×                                                                                                                                                                                                                                                      
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) Eif (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    Iif (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    Iif (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var core_1 = require("@angular/core");
var leaflet_1 = require("leaflet");
var map_component_1 = require("./map.component");
var ScaleControlDirective = (function (_super) {
    __extends(ScaleControlDirective, _super);
    function ScaleControlDirective(mapComponent) {
        var _this = _super.call(this) || this;
        _this.displayChange = new core_1.EventEmitter();
        _this.zIndexChange = new core_1.EventEmitter();
        _this.positionChange = new core_1.EventEmitter();
        _this.addEvent = new core_1.EventEmitter();
        _this.removeEvent = new core_1.EventEmitter();
        _this.clickEvent = new core_1.EventEmitter();
        _this.dbclickEvent = new core_1.EventEmitter();
        _this.mousedownEvent = new core_1.EventEmitter();
        _this.mouseoverEvent = new core_1.EventEmitter();
        _this.mouseoutEvent = new core_1.EventEmitter();
        mapComponent.addControl(_this);
        var self = _this;
        var originalOnRemove = _this.onRemove;
        _this.onRemove = function (map) {
            originalOnRemove.call(this, map);
            self.displayChange.emit(false);
            self.removeEvent.emit({ type: 'remove', target: self });
            return self;
        };
        var originalOnAdd = _this.onAdd;
        _this.onAdd = function (map) {
            var tmp = originalOnAdd.call(this, map);
            self.displayChange.emit(true);
            self.addEvent.emit({ type: 'add', target: self });
            return tmp;
        };
        // Events
        _this.getContainer().addEventListener('click', function (event) {
            _this.clickEvent.emit(event);
        });
        _this.getContainer().addEventListener('dbclick', function (event) {
            _this.dbclickEvent.emit(event);
        });
        _this.getContainer().addEventListener('mousedown', function (event) {
            _this.mousedownEvent.emit(event);
        });
        _this.getContainer().addEventListener('mouseover', function (event) {
            _this.mouseoverEvent.emit(event);
        });
        _this.getContainer().addEventListener('mouseout', function (event) {
            _this.mouseoutEvent.emit(event);
        });
        return _this;
    }
    ScaleControlDirective.prototype.ngOnDestroy = function () {
        this._map.removeControl(this);
    };
    ScaleControlDirective.prototype.setPosition = function (val) {
        _super.prototype.setPosition.call(this, val);
        this.positionChange.emit(val);
        return this;
    };
    Object.defineProperty(ScaleControlDirective.prototype, "opacity", {
        get: function () {
            return parseFloat(this.getContainer().style.opacity);
        },
        set: function (val) {
            this.getContainer().style.opacity = val.toString();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleControlDirective.prototype, "display", {
        get: function () {
            return this._map && this.getContainer().style.display !== 'none';
        },
        set: function (val) {
            if (!this._map) {
                // No map available...
                return;
            }
            if (val) {
                this.getContainer().style.display = '';
                return;
            }
            this.getContainer().style.display = 'none';
            return;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleControlDirective.prototype, "position", {
        get: function () {
            return this.getPosition();
        },
        set: function (val) {
            this.setPosition(val);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleControlDirective.prototype, "maxWidth", {
        get: function () {
            return this.options.maxWidth;
        },
        set: function (val) {
            this.options.maxWidth = val;
            this._update();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleControlDirective.prototype, "metric", {
        get: function () {
            return this.options.metric;
        },
        set: function (val) {
            while (this.getContainer().hasChildNodes()) {
                this.getContainer().removeChild(this.getContainer().lastChild);
            }
            this.options.metric = val;
            this._addScales(this.options, 'leaflet-control-scale-line', this.getContainer());
            this._update();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScaleControlDirective.prototype, "imperial", {
        get: function () {
            return this.options.imperial;
        },
        set: function (val) {
            while (this.getContainer().hasChildNodes()) {
                this.getContainer().removeChild(this.getContainer().lastChild);
            }
            this.options.imperial = val;
            this._addScales(this.options, 'leaflet-control-scale-line', this.getContainer());
            this._update();
        },
        enumerable: true,
        configurable: true
    });
    return ScaleControlDirective;
}(leaflet_1.Control.Scale));
__decorate([
    core_1.Output(),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "displayChange", void 0);
__decorate([
    core_1.Output(),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "zIndexChange", void 0);
__decorate([
    core_1.Output(),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "positionChange", void 0);
__decorate([
    core_1.Output('add'),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "addEvent", void 0);
__decorate([
    core_1.Output('remove'),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "removeEvent", void 0);
__decorate([
    core_1.Output('click'),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "clickEvent", void 0);
__decorate([
    core_1.Output('dbclick'),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "dbclickEvent", void 0);
__decorate([
    core_1.Output('mousedown'),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "mousedownEvent", void 0);
__decorate([
    core_1.Output('mouseover'),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "mouseoverEvent", void 0);
__decorate([
    core_1.Output('mouseout'),
    __metadata("design:type", core_1.EventEmitter)
], ScaleControlDirective.prototype, "mouseoutEvent", void 0);
__decorate([
    core_1.Input(),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], ScaleControlDirective.prototype, "opacity", null);
__decorate([
    core_1.Input(),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ScaleControlDirective.prototype, "display", null);
__decorate([
    core_1.Input(),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], ScaleControlDirective.prototype, "position", null);
__decorate([
    core_1.Input(),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], ScaleControlDirective.prototype, "maxWidth", null);
__decorate([
    core_1.Input(),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ScaleControlDirective.prototype, "metric", null);
__decorate([
    core_1.Input(),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], ScaleControlDirective.prototype, "imperial", null);
ScaleControlDirective = __decorate([
    core_1.Directive({
        selector: 'yaga-scale-control'
    }),
    __param(0, core_1.Inject(core_1.forwardRef(function () { return map_component_1.MapComponent; }))),
    __metadata("design:paramtypes", [map_component_1.MapComponent])
], ScaleControlDirective);
exports.ScaleControlDirective = ScaleControlDirective;
//# sourceMappingURL=scale-control.directive.js.map