Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bootstrap/FontAwsem icon support #47

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

setTimeout(function() {
$.bootstrapGrowl("Danger, Danger!", {
icon: 'glyphicon glyphicon-info-sign',
type: 'danger',
align: 'center',
width: 'auto',
Expand Down
7 changes: 5 additions & 2 deletions jquery.bootstrap-growl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ $.bootstrapGrowl = (message, options) ->
$alert = $("<div>")
$alert.attr "class", "bootstrap-growl alert"
$alert.addClass "alert-" + options.type if options.type
$alert.append "<a class=\"close\" data-dismiss=\"alert\" href=\"#\">&times;</a>" if options.allow_dismiss
if options.icon
$alert.append "<i class=\""+options.icon+"\"></i> "
if options.allow_dismiss
$alert.append "<a class=\"close\" data-dismiss=\"alert\" href=\"#\">&times;</a>" if options.allow_dismiss

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "if options.allow_dismiss is duplicated as the if statement above tests for the same value...

$alert.append message

# Prevent BC breaks
Expand Down Expand Up @@ -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

14 changes: 6 additions & 8 deletions jquery.bootstrap-growl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

$.bootstrapGrowl = function(message, options) {
var $alert, css, offsetAmount;

options = $.extend({}, $.bootstrapGrowl.default_options, options);
$alert = $("<div>");
$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("<i class=\"" + options.icon + "\"></i> ");
if (options.allow_dismiss) {
$alert.append("<span class=\"close\" data-dismiss=\"alert\">&times;</span>");
if (options.allow_dismiss) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment above

$alert.append("<a class=\"close\" data-dismiss=\"alert\" href=\"#\">&times;</a>");
}
}
$alert.append(message);
if (options.top_offset) {
Expand All @@ -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":
Expand Down