Skip to content

Instantly share code, notes, and snippets.

@dannylloyd
Created November 17, 2015 20:09
Show Gist options
  • Select an option

  • Save dannylloyd/1e6c8613f15b77443d41 to your computer and use it in GitHub Desktop.

Select an option

Save dannylloyd/1e6c8613f15b77443d41 to your computer and use it in GitHub Desktop.
Javascript alerts using bootstrap and jquery
//Name: Alerts
//Author: Danny Lloyd 1.0
var Alerts = (function () {
var internalAlert = function (type, message) {
var li = $('<li class="alert alert-' + type + '">'
+ '<span class="glyphicon glyphicon-' + getIcon(type) + '" style="padding-right:5px;"></span> ' +
message +
'</li>');
$('#alerts').append(li);
};
var getIcon = function (type) {
switch (type) {
case "success":
return "ok";
case "danger":
return "exclamation-sign";
case "info":
return "info-sign";
case "warning":
return "warning-sign";
}
};
return {
Danger: function (message) {
internalAlert('danger', message);
},
Info: function (message) {
internalAlert('info', message);
},
Success: function (message) {
internalAlert('success', message);
},
Warning: function (message) {
internalAlert('warning', message);
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment