Merge pull request #1460 from FlxAlbroscheit/develop

Issue 1163: Feature allowing desktop-notifications
pull/1480/head
Tobias Diekershoff 2015-04-05 11:37:05 +02:00
commit 106b0b5d23
3 changed files with 21 additions and 0 deletions

View File

@ -182,6 +182,18 @@
text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>"); text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen')); html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen'));
nnm.append(html); nnm.append(html);
if(e.text().search('&rarr;') == 0) {
var notification = new Notification(document.title, {
body: e.text().replace('&rarr; ',''),
icon: e.attr('photo')
});
// TODO (yet unsupported by most browsers):
// Implement notification.onclick()
notifyMarkAll();
}
}); });
$("img[data-src]", nnm).each(function(i, el){ $("img[data-src]", nnm).each(function(i, el){

View File

@ -1187,6 +1187,10 @@ function settings_content(&$a) {
'$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''), '$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
'$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''),
'$desktop_notifications' => t('Activate desktop notifications'),
'$desktop_notifications_note' => t('Note: This is an experimental feature, as being not supported by each browser'),
'$desktop_notifications_success_message' => t('You will now receive desktop notifications!'),
'$email_textonly' => array('email_textonly', t('Text-only notification emails'), '$email_textonly' => array('email_textonly', t('Text-only notification emails'),
get_pconfig(local_user(),'system','email_textonly'), get_pconfig(local_user(),'system','email_textonly'),
t('Send text only notification emails, without the html part')), t('Send text only notification emails, without the html part')),

View File

@ -133,6 +133,11 @@
{{include file="field_intcheckbox.tpl" field=$notify8}} {{include file="field_intcheckbox.tpl" field=$notify8}}
</div> </div>
<div class="field">
<button onclick="javascript:Notification.requestPermission(function(perm){if(perm === 'granted')alert('{{$desktop_notifications_success_message}}');});return false;">{{$desktop_notifications}}</button>
<span class="field_help">{{$desktop_notifications_note}}</span>
</div>
{{include file="field_checkbox.tpl" field=$email_textonly}} {{include file="field_checkbox.tpl" field=$email_textonly}}
</div> </div>