From 5c443dc6d175da96b5d7ee970071ebca2ce2cf4c Mon Sep 17 00:00:00 2001 From: goleon Date: Fri, 4 Nov 2016 00:52:13 +0400 Subject: [PATCH] * Use native mouse event in originalEvent propery * Added DomUtil declaration * Added Class declaration (think about generics) * Evented class inherited from Class --- leaflet/leaflet.d.ts | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 38872edcb1..6b0a8990d8 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -5,7 +5,42 @@ /// +type NativeMouseEvent = MouseEvent; + declare namespace L { + export class Class { + static extend(props:any):any/* how to return constructor of self extended type ? */; + static include(props:any):any /* how to return self extended type ? */; + static mergeOptions(props:any): any /* how to return self extended type ? */; + static addInitHook(initHookFn: ()=> void): any/* how to return self extended type ? */; + } + + export class DomUtil { + static get(id: string|HTMLElement): HTMLElement; + static getStyle(el: HTMLElement, styleAttrib: string): string; + static create(tagName: String, className?: String, container?: HTMLElement): HTMLElement; + static remove(el: HTMLElement):void; + static empty(el: HTMLElement):void; + static toFront(el: HTMLElement):void; + static toBack(el: HTMLElement):void; + static hasClass(el: HTMLElement, name: String): Boolean; + static addClass(el: HTMLElement, name: String):void; + static removeClass(el: HTMLElement, name: String):void; + static setClass(el: HTMLElement, name: String):void; + static getClass(el: HTMLElement): String; + static setOpacity(el: HTMLElement, opacity: Number); + static testProp(props: String[]): String|boolean/*=false*/; + static setTransform(el: HTMLElement, offset: Point, scale?: Number); + static setPosition(el: HTMLElement, position: Point):void; + static getPosition(el: HTMLElement): Point + static disableTextSelection(): void + static enableTextSelection(): void + static disableImageDrag(): void + static enableImageDrag(): void + static preventOutline(el: HTMLElement): void + static restoreOutline(): void + } + export interface CRS { latLngToPoint(latlng: LatLng, zoom: number): Point; latLngToPoint(latlng: LatLngLiteral, zoom: number): Point; @@ -211,7 +246,7 @@ declare namespace L { * with an object (e.g. the user clicks on the map, causing the map to fire * 'click' event). */ - export interface Evented { + export interface Evented extends Class { /** * Adds a listener function (fn) to a particular event type of the object. * You can optionally specify the context of the listener (object the this @@ -1125,7 +1160,7 @@ declare namespace L { latlng: LatLng; layerPoint: Point; containerPoint: Point; - originalEvent: MouseEvent; // how can I reference the global MouseEvent? + originalEvent: NativeMouseEvent; } export interface LocationEvent extends Event {