/** * growler-jquery.js - Display 'growl'-like notifications for jQuery Mobile. * * @author Michael Slusarz * @copyright 2014-2015 Horde LLC * @license LGPL-2.1 (http://www.horde.org/licenses/lgpl21) */ (function($) { var closeNotify = function(elt) { $(elt).clearQueue().fadeOut(function() { var $this = $(this), p = $this.parent(); $this.remove(); if (!p.children().size()) { p.hide(); } }); }, methods = { // opts: (object) Options [NONE currently] init: function() { return this.each(function() { $(document).on('vclick.growler', '#' + $(this).attr('id') + ' DIV', function(e) { e.stopPropagation(); closeNotify(e.target); }); }); }, destroy: function() { $(document).off('.growler'); }, // opts: (object) Options: // - delay: (integer) Fadeout delay. // - raw: (boolean) Is msg raw text? // - sticky: (boolean) Make notification sticky? notify: function(msg, type, opts) { return this.each(function() { var div, $this = $(this); opts = $.extend({ delay: 5000, raw: false, sticky: false }, opts); div = $('
').hide(); if (opts.raw) { // TODO: This needs some fixing: div.html(msg.replace('