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

Font Awesome support: selectable icon for message #17

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
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,37 @@ bootstrap-notify

Bootstrap alert system made better.

Added [Font Awesome](http://fortawesome.github.io/Font-Awesome/) support.
It's now easy to customize your notifications. For example, you can create success and error messages:

Code:

$('#success-button').click(function(){
$('#id').notify(
{ message:
{ text: 'Great! Operation successful :)' },
type: 'success',
icon: {
symbol: 'icon-ok',
color: '#5A5'
}
}
).show();
});

$('#error-button').click(function(){
$('#id').notify(
{ message:
{ text: 'Uh-oh.. there was an error :(' },
type: 'danger',
icon: {
symbol: 'icon-warning-sign',
color: '#D54'
}
}
).show();
});

# Copyright

Copyright 2013 Nijiko Yonskai @nijikokun
Expand Down
35 changes: 32 additions & 3 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">

<!-- font awesome -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">

<!-- Notify CSS -->
<link href="../css/bootstrap-notify.css" rel="stylesheet">

Expand Down Expand Up @@ -40,8 +43,8 @@
<div class="span12">&nbsp;</div>

<div class="span3">
<iframe src="http://nijikokun.github.com/github-buttons/github-btn.html?user=Nijikokun&repo=bootstrap-notify&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<iframe src="http://nijikokun.github.com/github-buttons/github-btn.html?user=Nijikokun&repo=bootstrap-notify&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=lmarcon&repo=bootstrap-notify&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=lmarcon&repo=bootstrap-notify&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>

<br />

Expand All @@ -51,10 +54,18 @@
<div class="span12">&nbsp;</div>
<div class="span12">&nbsp;</div>

<div class="span12">
<div class="span12" style="margin-bottom: 10px;">
<button class='btn btn-warning show-notification'>Click For A Random Notification</button>
</div>

<div class="span12" style="margin-bottom: 10px;">
<button class='btn btn-success show-success-notification'>Click For A Success Notification</button>
</div>

<div class="span12">
<button class='btn btn-danger show-error-notification'>Click For An Error Notification</button>
</div>

<div class='notifications top-right'></div>
<div class='notifications bottom-right'></div>
<div class='notifications top-left'></div>
Expand Down Expand Up @@ -234,6 +245,16 @@ <h4>Custom Styles Included:</h4>
'You should star this!',
'Holy cow, another alert!'
],
success: [
'Operation successful',
'You\'re the boss',
'All went fine'
],
error: [
'There was an error',
'Something went wrong',
'Uh-oh'
],
positions: [
'bottom-right',
'bottom-left',
Expand Down Expand Up @@ -266,6 +287,14 @@ <h4>Custom Styles Included:</h4>
$('.' + select(example.positions)).notify({ message: { text: select(example.messages) }, type: select(example.styles) }).show();
});

$('.show-success-notification').click(function (e) {
$('.' + select(example.positions)).notify({ message: { text: select(example.success) }, type: 'success', icon: { symbol: 'icon-ok', color: '#5A5' } }).show();
});

$('.show-error-notification').click(function (e) {
$('.' + select(example.positions)).notify({ message: { text: select(example.error) }, type: 'danger', icon: { symbol: 'icon-warning-sign', color: '#D54' } }).show();
});

/* Custom Styles */
var custom = [
'bangTidy',
Expand Down
7 changes: 7 additions & 0 deletions js/bootstrap-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
else if (this.options.message.text)
this.$note.text(this.options.message.text);

if (this.options.message)
this.$note.prepend('<i style="color: ' + this.options.icon.color + ';" class="' + this.options.icon.symbol + '"></i> ');

if (this.options.closable)
this._link = $('<a class="close pull-right">&times;</a>'),
$(this._link).on('click', $.proxy(Notification.onClose, this)),
Expand Down Expand Up @@ -86,6 +89,10 @@
delay: 3000
},
message: null,
icon: {
symbol: null,
color: '#000'
},
onClose: function () {},
onClosed: function () {}
}
Expand Down