-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.alertiny.js
51 lines (36 loc) · 1.24 KB
/
jquery.alertiny.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*!
* Alertiny v1.0.0 (https://github.com/markcell/jQuery-Alertiny)
* Copyright (c) 2015 Celso Marques
* Licensed under MIT (https://github.com/markcell/jQuery-Alertiny/blob/master/LICENSE)
*/
/**
* @description Tiny plugin to show alert from Bootstrap
* @version 1.0.0
* @author Celso Marques
*/
if (typeof jQuery === 'undefined') {
throw new Error('Alertiny requires jQuery library.');
}
(function($) {
'use strict';
$.fn.Alertiny = function(type, message, options) {
var $container = this;
var defaults = {
extraClass: '',
closeButton: true,
fadeEffect: true
};
var settings = $.extend({}, defaults, options);
var closeButton = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
var fadeEffect = 'fade in';
if (!settings.closeButton) {
closeButton = '';
}
if (!settings.fadeEffect) {
fadeEffect = '';
}
var html = '<div class="alert alert-' + type + ' ' + settings.extraClass + ' ' + fadeEffect + '" alert-dismissible">' + closeButton + message + '</div>';
$container.empty().html(html);
return $container;
};
}(jQuery));