| 1 |
"use strict"; |
| 2 |
|
| 3 |
var wdk_log_notify = function wdk_log_notify(text, type, popup_place) { |
| 4 |
var $ = jQuery; |
| 5 |
if (!$('.wdk_log_notify-box').length) $('body').append('<div class="wdk_log_notify-box"></div>'); |
| 6 |
if (typeof text == "undefined") var text = 'Undefined text'; |
| 7 |
if (typeof type == "undefined") var type = 'success'; |
| 8 |
if (typeof popup_place == "undefined") var popup_place = $('.wdk_log_notify-box'); |
| 9 |
var el_class = ''; |
| 10 |
var el_timer = 5000; |
| 11 |
|
| 12 |
switch (type) { |
| 13 |
case "success": |
| 14 |
el_class = "success"; |
| 15 |
break; |
| 16 |
|
| 17 |
case "error": |
| 18 |
el_class = "error"; |
| 19 |
break; |
| 20 |
|
| 21 |
case "loading": |
| 22 |
el_class = "loading"; |
| 23 |
el_timer = 2000; |
| 24 |
break; |
| 25 |
|
| 26 |
default: |
| 27 |
el_class = "success"; |
| 28 |
break; |
| 29 |
} |
| 30 |
/* notify */ |
| 31 |
|
| 32 |
|
| 33 |
var html = ''; |
| 34 |
html = '<div class="wdk_log_notify ' + el_class + '">\n\ |
| 35 |
' + text + '\n\ |
| 36 |
</div>'; |
| 37 |
var notification = $(html).appendTo(popup_place).delay(100).queue(function () { |
| 38 |
$(this).addClass('show'); |
| 39 |
setTimeout(function () { |
| 40 |
notification.removeClass('show'); |
| 41 |
setTimeout(function () { |
| 42 |
notification.remove(); |
| 43 |
}, 1000); |
| 44 |
}, el_timer); |
| 45 |
}); |
| 46 |
/* end notify */ |
| 47 |
}; |