1
|
// custom callback
|
2
|
function notify_callback() {
|
3
|
return alert('Notify closed!');
|
4
|
}
|
5
|
|
6
|
function executeCallback(callback) {
|
7
|
window[callback]();
|
8
|
}
|
9
|
|
10
|
function showNotify($element) {
|
11
|
thisNotify = UIkit.notify({
|
12
|
message: $element.data('message') ? $element.data('message') : '',
|
13
|
status: $element.data('status') ? $element.data('status') : '',
|
14
|
timeout: $element.attr('data-timeout') ? $element.data('timeout') : 5000,
|
15
|
group: $element.data('group') ? $element.data('group') : null,
|
16
|
pos: $element.data('pos') ? $element.data('pos') : 'top-center',
|
17
|
onClose: function() {
|
18
|
$body.find('.md-fab-wrapper').css('margin-bottom','');
|
19
|
if($element.data('callback')) {
|
20
|
executeCallback($element.data('callback'));
|
21
|
}
|
22
|
// clear notify timeout (sometimes callback is fired more than once)
|
23
|
clearTimeout(thisNotify.timeout)
|
24
|
}
|
25
|
});
|
26
|
if(
|
27
|
(
|
28
|
($window.width() < 768)
|
29
|
&& (
|
30
|
(thisNotify.options.pos == 'bottom-right')
|
31
|
|| (thisNotify.options.pos == 'bottom-left')
|
32
|
|| (thisNotify.options.pos == 'bottom-center')
|
33
|
)
|
34
|
)
|
35
|
|| (thisNotify.options.pos == 'bottom-right')
|
36
|
) {
|
37
|
var thisNotify_height = $(thisNotify.element).outerHeight();
|
38
|
var spacer = $window.width() < 768 ? -6 : 8;
|
39
|
$body.find('.md-fab-wrapper').css('margin-bottom',thisNotify_height + spacer);
|
40
|
}
|
41
|
}
|
42
|
|
43
|
$(function() {
|
44
|
// notifications
|
45
|
altair_notifications.init();
|
46
|
});
|
47
|
|
48
|
altair_notifications = {
|
49
|
init: function() {
|
50
|
|
51
|
$body.on("click", "[data-message]", function(){
|
52
|
var $this = $(this);
|
53
|
if($body.find('.uk-notify-message').length) {
|
54
|
$body.find('.uk-notify-message').click();
|
55
|
setTimeout(function() {
|
56
|
showNotify($this)
|
57
|
},450)
|
58
|
} else {
|
59
|
showNotify($this)
|
60
|
}
|
61
|
});
|
62
|
|
63
|
}
|
64
|
};
|