<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">const fx_init = ({ // default component settings
    toast: ({
        position: 'place_top_right',
        css: '',
        timeOut: 10000000,
        delay: 0,
        animateIn: 'fx_animate_slideInRight',
        animateOut: 'fx_animate_slideOutRight',
        placeAfter: false,
        dismiss: true,
        icons: ({
            success: 'icon-check',
            info: 'icon-bullhorn',
            warning: 'icon-exclamation-triangle',
            error: 'icon-exclamation-triangle'
        })

    })
})

//component templates
const fx_tpl = ({
    toast: (type, data,id) =&gt; {
        if(data.title != undefined){ title=data.title}else{title=""}
        if(data.body != undefined){ body=data.body}else{body=""}
        return '&lt;div&gt;\
        &lt;i class="ifa ' + data.settings.icons[type] + '"&gt;&lt;/i&gt;\
        &lt;/div&gt;\
        &lt;div class="content"&gt;\
        &lt;span class="fx_title"&gt;' + title + ' &lt;/span&gt;\
        &lt;span class="fx_msg"&gt;' + body + '&lt;/span&gt;\
        &lt;/div&gt;\
        &lt;div&gt;\
        &lt;i id="'+id+'-end" class="icon-close"&gt;&lt;/i&gt;\
        &lt;/div&gt;\
        '
    }
})


// construction starts here
const fx = ({
    toast: ({
        success: (data) =&gt; {
        // replace default options and pass as prototype specific setting
            data['settings']=fx_init.toast;
            for(i in data.opt){
                data.settings[i] = data.opt[i]
            }
            fx_build.toast('success', data )
        },
        info: (data) =&gt; {
        // replace default options and pass as prototype specific setting
            data['settings']=fx_init.toast;
            for(i in data.opt){
                data.settings[i] = data.opt[i]
            }
            fx_build.toast('info', data )
        },
        warning: (data) =&gt; {
        // replace default options and pass as prototype specific setting
            data['settings']=fx_init.toast;
            for(i in data.opt){
                data.settings[i] = data.opt[i]
            }
            fx_build.toast('warning', data )
        },
        error: (data) =&gt; {
        // replace default options and pass as prototype specific setting
            data['settings']=fx_init.toast;
            for(i in data.opt){
                data.settings[i] = data.opt[i]
            }
            fx_build.toast('error', data )
        },
    })
})


//component Builder
const fx_build = ({
    toast: function(type, data ) {
          
        let itemID = Math.floor(Math.random() * 15000); //create unique id for toast Element
        let template = fx_tpl.toast(type, data, itemID) // get toast template structure
        let placement = data.settings.placeAfter
        const item = document.createElement('div'); // genereate  toast
        item.setAttribute('id', itemID)
        item.setAttribute('class', 'fx  toast ' + data.settings.css +' '+ data.settings.position +' '+data.settings.animateIn + ' ' + type + ' ') //use defined options for toast
        item.innerHTML = template 
        console.log(data.opt.placeAfter)
        itemParent = document.getElementsByTagName('html')[0]
        if (data.opt.placeAfter != undefined) { //if item is to be appended to a specified element
            itemParent = document.getElementById(data.opt.placeAfter); 
            item.classList += ' fix_relative';
        } 

        setTimeout(() =&gt; {
            itemParent.appendChild(item)
            fx_build.end.toast(itemID, data.settings);
            document.getElementById(itemID+'-end').addEventListener("click", ()=&gt;{ data.settings.timeOut = false; fx_build.end.toast(itemID, data.settings)});
        }, data.settings.delay);
    },

    end: ({
        toast: function (id,settings) {
            if(settings.timeOut === false){
                time = 0;
            }else {time = time = settings.timeOut}
            setTimeout(() =&gt; {
                item = document.getElementById(id);
                item.classList += ' ' + settings.animateOut
            }, time);
            setTimeout(() =&gt; {
                item = document.getElementById(id);
                item.remove()
            }, time + 500);

        }
    })
})</pre></body></html>