|
|
@ -27,7 +27,7 @@ var MAL = function() |
|
|
|
|
|
|
|
|
|
|
|
installPostboardClick(); |
|
|
|
installPostboardClick(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$(".postboard-loading").hide(); |
|
|
|
$(".postboard-loading").hide(); // FIXME need to decide which one we need to hide actually
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,9 +104,15 @@ var MAL = function() |
|
|
|
newTweetsBarMenu.addClass("show"); |
|
|
|
newTweetsBarMenu.addClass("show"); |
|
|
|
|
|
|
|
|
|
|
|
if ($.Options.showDesktopNotifPosts.val === 'enable') { |
|
|
|
if ($.Options.showDesktopNotifPosts.val === 'enable') { |
|
|
|
this.showDesktopNotif(false, polyglot.t('You got')+' '+polyglot.t('new_posts', newPosts)+' '+polyglot.t('in postboard')+'.', false,'twister_notification_new_posts', $.Options.showDesktopNotifPostsTimer.val, (function() { |
|
|
|
this.showDesktopNotification({ |
|
|
|
requestTimelineUpdate('pending',this,followingUsers,promotedPostsOnly); |
|
|
|
body: polyglot.t('You got') + ' ' + polyglot.t('new_posts', newPosts) + ' ' |
|
|
|
}).bind(newPosts), false) |
|
|
|
+ polyglot.t('in postboard') + '.', |
|
|
|
|
|
|
|
tag: 'twister_notification_new_posts', |
|
|
|
|
|
|
|
timeout: $.Options.showDesktopNotifPostsTimer.val, |
|
|
|
|
|
|
|
funcClick: (function() { |
|
|
|
|
|
|
|
requestTimelineUpdate('pending', this.postsCount, followingUsers, promotedPostsOnly); |
|
|
|
|
|
|
|
}).bind({postsCount: newPosts}) |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
newTweetsBar.hide(); |
|
|
|
newTweetsBar.hide(); |
|
|
@ -430,44 +436,36 @@ var MAL = function() |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.showDesktopNotif = function(notifyTitle, notifyBody, notifyIcon, notifyTag, notifyTimer, actionOnClick, actionOnPermDenied) { |
|
|
|
this.showDesktopNotification = function(req) { |
|
|
|
function doNotification() { |
|
|
|
if (Notify.needsPermission) { |
|
|
|
if (!notifyTitle) { |
|
|
|
Notify.requestPermission(false, req.funcPermDenied); |
|
|
|
notifyTitle = polyglot.t('notify_desktop_title'); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!notifyIcon) { |
|
|
|
|
|
|
|
notifyIcon = '../img/twister_mini.png'; |
|
|
|
if (!req.title) |
|
|
|
} |
|
|
|
req.title = polyglot.t('notify_desktop_title'); |
|
|
|
if (!notifyTag) { |
|
|
|
if (!req.icon) |
|
|
|
notifyTag = 'twister_notification'; |
|
|
|
req.icon = '../img/twister_mini.png'; |
|
|
|
} |
|
|
|
if (!req.tag) |
|
|
|
if (!notifyTimer) { |
|
|
|
req.tag = 'twister_notification'; |
|
|
|
notifyTimer = 3600 * 24 * 30; // one month
|
|
|
|
if (!req.timeout) |
|
|
|
} |
|
|
|
req.timeout = 2592000; // 60 * 60 * 24 * 30, one month
|
|
|
|
var doActionOnClick = false; |
|
|
|
|
|
|
|
if (typeof actionOnClick === 'function') { |
|
|
|
if (typeof req.funcClick === 'function') |
|
|
|
doActionOnClick = function() { |
|
|
|
req.funcClick = (function() {window.focus(); this.funcClick();}) |
|
|
|
actionOnClick(); |
|
|
|
.bind({funcClick: req.funcClick}); |
|
|
|
window.focus(); |
|
|
|
else |
|
|
|
} |
|
|
|
req.funcClick = function() {window.focus();} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var desktopNotification = new Notify(req.title, { |
|
|
|
var desktopNotification = new Notify(notifyTitle, { |
|
|
|
body: req.body, |
|
|
|
body: notifyBody, |
|
|
|
icon: req.icon, |
|
|
|
icon: notifyIcon, |
|
|
|
tag: req.tag, |
|
|
|
tag: notifyTag, |
|
|
|
timeout: req.timeout, |
|
|
|
timeout: notifyTimer, |
|
|
|
notifyClick: req.funcClick, |
|
|
|
notifyClick: doActionOnClick, |
|
|
|
notifyError: function() {alert(polyglot.t('notify_desktop_error'));} |
|
|
|
notifyError: function() { alert(polyglot.t('notify_desktop_error')) } |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
desktopNotification.show(); |
|
|
|
desktopNotification.show(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Notify.needsPermission) { |
|
|
|
|
|
|
|
Notify.requestPermission(false, actionOnPermDenied); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
doNotification(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.reqRepAfterCB = function(postLi, postsFromJson) { |
|
|
|
this.reqRepAfterCB = function(postLi, postsFromJson) { |
|
|
|