import {Dialog, Helper, ShareManager, ThemeManager, Translator, ViewInflater} from "../../../../../js/lib/pwa-lib";

export class ShareDialog extends Dialog{
    constructor() {
        let viewPromise = ViewInflater.inflate("html/application/dialog/share.html").then(view => {
            view.appendChild(ShareManager.generateDefaultShareElement(window.location.hostname + Helper.basePath("")));
            let closeListener = () => {
                this.close();
            };

            view.querySelectorAll("a").forEach((element) => {
               element.addEventListener("click", closeListener);
            });
            return view;
        });

        super(viewPromise, "share-dialog");
    }
}