1+ import { Popup as LeafletPopup } from "leaflet" ;
12import { Bindable } from "../../bindableInterface" ;
23import { PopupInterface , PopupOptions } from "./popupInterface" ;
34
5+
46export class Popup implements PopupInterface {
5- public bindTo ( bindable : Bindable , content : string | HTMLElement , options : PopupOptions = { } ) : Bindable {
6- bindable . getBindable ( ) . bindPopup ( content , options ) ;
7- return bindable ;
7+ constructor ( private popup : LeafletPopup ) { }
8+
9+ public bindTo ( bindable : Bindable , options : PopupOptions = { } ) : this {
10+ bindable . getBindable ( ) . bindPopup ( this . popup , options ) ;
11+ return this ;
812 }
913
10- public unbindPopup ( bindable : Bindable ) : Bindable {
11- bindable . getBindable ( ) . unbindPopup ( ) ;
12- return bindable ;
14+ public unbind ( ) : this {
15+ this . popup . unbindPopup ( ) ;
16+ return this ;
1317 }
1418
15- public openPopup ( bindable : Bindable ) : Bindable {
16- bindable . getBindable ( ) . openPopup ( ) ;
17- return bindable ;
19+ public getElement ( ) : HTMLElement | null {
20+ return this . popup . getElement ( ) ?? null ;
1821 }
1922
20- public closePopup ( bindable : Bindable ) : Bindable {
21- bindable . getBindable ( ) . closePopup ( ) ;
22- return bindable ;
23+ public open ( ) : this {
24+ this . popup . openPopup ( ) ;
25+ return this ;
2326 }
2427
25- public togglePopup ( bindable : Bindable ) : Bindable {
26- bindable . getBindable ( ) . togglePopup ( ) ;
27- return bindable ;
28+ public close ( ) : this {
29+ this . popup . close ( ) ;
30+ return this ;
2831 }
2932
30- public isPopupOpen ( bindable : Bindable ) : boolean {
31- return bindable . getBindable ( ) . isPopupOpen ( ) ;
33+ public toggle ( ) : this {
34+ this . popup . toggle ( ) ;
35+ return this ;
3236 }
3337
34- public setPopupContent ( bindable : Bindable , content : string | HTMLElement ) : Bindable {
35- bindable . getBindable ( ) . setPopupContent ( content ) ;
36- return bindable ;
38+ public isOpen ( ) : boolean {
39+ return this . popup . isOpen ( ) ;
3740 }
3841
39- public getPopup ( bindable : Bindable ) : this | null {
40- const popup = bindable . getBindable ( ) . getPopup ( ) ;
41- return popup ? this : null ;
42+ public setContent ( content : string | HTMLElement ) : this {
43+ this . popup . setContent ( content ) ;
44+ return this ;
4245 }
4346}
0 commit comments