2013-08-28 23:08:41 +00:00
|
|
|
$(document).ready(function() {
|
2013-10-17 08:00:50 +00:00
|
|
|
var skip = getSkippedPage();
|
|
|
|
$('.noty-notification').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
var type = $this.data('noty-type'),
|
|
|
|
importance = $this.data('noty-importance'),
|
|
|
|
id = $this.data('noty-id'),
|
|
|
|
url = $this.data('noty-url');
|
|
|
|
if (type != skip) {
|
|
|
|
createNoty(type, id, $this.text(), url, importance);
|
2013-08-28 23:08:41 +00:00
|
|
|
}
|
2013-10-17 08:00:50 +00:00
|
|
|
$this.remove();
|
2013-08-28 23:08:41 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-10-17 08:00:50 +00:00
|
|
|
function getSkippedPage() {
|
|
|
|
var skip, url = new URL();
|
2013-08-28 23:08:41 +00:00
|
|
|
switch(url.path) {
|
|
|
|
case "inbox":
|
2013-10-17 08:00:50 +00:00
|
|
|
if (url.query.length == 0 || (url.query.length == 1 && url.query.hasOwnProperty('sort'))) {
|
2013-08-28 23:08:41 +00:00
|
|
|
skip = "Inbox";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "userhistory":
|
|
|
|
if (url.query['action'] == "subscriptions") {
|
|
|
|
skip = "Subscriptions";
|
|
|
|
}
|
|
|
|
if (url.query['action'] == "quote_notifications") {
|
|
|
|
skip = "Quotes";
|
|
|
|
}
|
|
|
|
if (url.query['action'] == "subscribed_collages") {
|
|
|
|
skip = "Collages";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "user":
|
|
|
|
if (url.query['action'] == "notify") {
|
|
|
|
skip = "Torrents";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "blog":
|
|
|
|
if (url.query.length == 0) {
|
|
|
|
skip = "Blog";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "index":
|
|
|
|
if (url.query.length == 0) {
|
|
|
|
skip = "News";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "staffpm":
|
|
|
|
if (url.query.length == 0) {
|
|
|
|
skip = "StaffPM";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createNoty(type, id, message, url, importance) {
|
2013-10-17 08:00:50 +00:00
|
|
|
var hideButtons = !url;
|
2013-08-28 23:08:41 +00:00
|
|
|
noty({
|
|
|
|
text: message,
|
|
|
|
type: importance,
|
|
|
|
layout: 'bottomRight',
|
|
|
|
closeWith: ['click'],
|
|
|
|
animation: {
|
|
|
|
open: {height: 'toggle'},
|
|
|
|
close: {height: 'toggle'},
|
|
|
|
easing: 'swing',
|
|
|
|
speed: 250
|
|
|
|
},
|
|
|
|
buttonElement : 'a',
|
|
|
|
buttons: [
|
|
|
|
{
|
2013-10-17 08:00:50 +00:00
|
|
|
addClass: 'brackets noty_button_view' + (hideButtons ? ' hidden' : ''), text: 'View', href: url
|
2013-08-28 23:08:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
addClass: 'brackets noty_button_clear', text: 'Clear', onClick: function($noty) {
|
|
|
|
$noty.close();
|
|
|
|
clear(type, id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2014-01-18 08:01:25 +00:00
|
|
|
addClass: 'brackets noty_button_close ', text: 'Hide', onClick: function($noty) {
|
2013-08-28 23:08:41 +00:00
|
|
|
$noty.close();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear(type, id) {
|
|
|
|
$.ajax({
|
|
|
|
type : "POST",
|
|
|
|
url: "ajax.php?action=clear_user_notification",
|
|
|
|
dataType: "json",
|
|
|
|
data : {
|
|
|
|
"type" : type,
|
|
|
|
"id" : id
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|