diff --git a/README.md b/README.md index 6cecfca..208636b 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ By default, growls use the standard 'alert' Bootstrap style, are 250px wide, rig ```javascript $.bootstrapGrowl("another message, yay!", { ele: 'body', // which element to append to + icon: 'glyphicon glyphicon-info-sign' // Use Bootstrap of FontAwsome icons type: 'info', // (null, 'info', 'error', 'success') offset: {from: 'top', amount: 20}, // 'top', or 'bottom' align: 'right', // ('left', 'right', or 'center') diff --git a/demo.html b/demo.html index bb69378..aeaffa2 100644 --- a/demo.html +++ b/demo.html @@ -21,6 +21,7 @@ setTimeout(function() { $.bootstrapGrowl("Danger, Danger!", { + icon: 'glyphicon glyphicon-info-sign', type: 'danger', align: 'center', width: 'auto', diff --git a/jquery.bootstrap-growl.coffee b/jquery.bootstrap-growl.coffee index 6ea1be1..8b13ed2 100644 --- a/jquery.bootstrap-growl.coffee +++ b/jquery.bootstrap-growl.coffee @@ -8,7 +8,10 @@ $.bootstrapGrowl = (message, options) -> $alert = $("
") $alert.attr "class", "bootstrap-growl alert" $alert.addClass "alert-" + options.type if options.type - $alert.append "×" if options.allow_dismiss + if options.icon + $alert.append " " + if options.allow_dismiss + $alert.append "×" if options.allow_dismiss $alert.append message # Prevent BC breaks @@ -64,7 +67,7 @@ $.bootstrapGrowl.default_options = amount: 20 align: "right" # (left, right, or center) width: 250 - delay: 4000 + delay: -1 allow_dismiss: true stackup_spacing: 10 diff --git a/jquery.bootstrap-growl.js b/jquery.bootstrap-growl.js index edc220f..793246b 100644 --- a/jquery.bootstrap-growl.js +++ b/jquery.bootstrap-growl.js @@ -5,15 +5,15 @@ $.bootstrapGrowl = function(message, options) { var $alert, css, offsetAmount; - options = $.extend({}, $.bootstrapGrowl.default_options, options); $alert = $("
"); $alert.attr("class", "bootstrap-growl alert"); - if (options.type) { - $alert.addClass("alert-" + options.type); - } + if (options.type) $alert.addClass("alert-" + options.type); + if (options.icon) $alert.append(" "); if (options.allow_dismiss) { - $alert.append("×"); + if (options.allow_dismiss) { + $alert.append("×"); + } } $alert.append(message); if (options.top_offset) { @@ -34,9 +34,7 @@ }; css[options.offset.from] = offsetAmount + "px"; $alert.css(css); - if (options.width !== "auto") { - $alert.css("width", options.width + "px"); - } + if (options.width !== "auto") $alert.css("width", options.width + "px"); $(options.ele).append($alert); switch (options.align) { case "center":