/** * == OhSnap!.js == * A simple jQuery/Zepto notification library designed to be used in mobile apps * * author: Justin Domingue * date: september 18, 2015 * version: 1.0.0 * copyright - nice copyright over here */ /* Shows a toast on the page * Params: * text: text to show * options: object that can override the following options * color: alert will have class 'alert-color'. Default null * icon: class of the icon to show before the alert. Default null * duration: duration of the notification in ms. Default 5000ms * container-id: id of the alert container. Default 'ohsnap' * fade-duration: duration of the fade in/out of the alerts. Default 'fast' */ function ohSnap(text, options) { var defaultOptions = { 'color' : null, // color is CSS class `alert-color` 'icon' : null, // class of the icon to show before the alert text 'duration' : '5000', // duration of the notification in ms 'container-id': 'ohsnap', // id of the alert container 'fade-duration': 'fast', // duration of the fade in/out of the alerts. fast, slow or integer in ms } options = (typeof options == 'object') ? $.extend(defaultOptions, options) : defaultOptions; var $container = $('#'+options['container-id']), icon_markup = "", color_markup = ""; if (options.icon) { icon_markup = " "; } if (options.color) { color_markup = 'alert-' + options.color; } // Generate the HTML var html = $('