notification system updates

This commit is contained in:
Henrique Dias
2015-09-16 19:34:53 +01:00
parent 52a57d1f79
commit 5ffe125d67
9 changed files with 294 additions and 45 deletions

View File

@@ -1,12 +1,6 @@
$(document).ready(function() {
$('.scroll').perfectScrollbar();
var n = noty({
layout: 'topRight',
type: 'success',
text: 'noty - a jquery notification library!'
});
$("#preview").click(function(e) {
e.preventDefault();
@@ -47,9 +41,21 @@ $(document).ready(function() {
dataType: 'json',
encode: true,
}).done(function(data) {
alert("It was saved and/or published");
if (action == "Save") {
var word = "saved";
} else {
var word = "published";
}
notification({
text: 'The post was ' + word + '.',
type: 'success'
});
}).fail(function(data) {
alert("Something went wrong");
notification({
text: 'Something went wrong.',
type: 'error'
});
});
event.preventDefault();

View File

@@ -0,0 +1,71 @@
$.noty.themes.admin = {
name: 'admin',
helpers: {},
modal: {
css: {
position: 'fixed',
width: '100%',
height: '100%',
backgroundColor: '#000',
zIndex: 10000,
opacity: 0.6,
display: 'none',
left: 0,
top: 0
}
}
};
$.noty.defaults = {
layout: 'topRight',
theme: 'admin',
dismissQueue: true,
animation: {
open: 'animated bounceInRight',
close: 'animated fadeOut',
easing: 'swing',
speed: 500 // opening & closing animation speed
},
timeout: false, // delay for closing event. Set false for sticky notifications
force: false, // adds notification to the beginning of queue when set to true
modal: false,
maxVisible: 5, // you can set max visible notification for dismissQueue true option,
killer: false, // for close all notifications before show
closeWith: ['click'], // ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all notifications
callback: {
onShow: function() {},
afterShow: function() {},
onClose: function() {},
afterClose: function() {},
onCloseClick: function() {},
},
buttons: false // an array of buttons
};
notification = function(options) {
var icon;
switch (options.type) {
case "success":
icon = '<i class="fa fa-check"></i>';
break;
case "error":
icon = '<i class="fa fa-times"></i>';
break;
case "warning":
icon = '<i class="fa fa-exclamation"></i>';
break;
case "information":
icon = '<i class="fa fa-info"></i>';
break;
default:
icon = '<i class="fa fa-bell"></i>';
}
var defaults = {
template: '<div class="noty_message"><span class="noty_icon">' + icon + '</span><span class="noty_text"></span>...<div class="noty_close"></div></div>'
}
options = $.extend({}, defaults, options);
noty(options);
}