+ function resizeIframe(obj) {
+ obj.style.height = 0;
+ obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
+ }
function openClose(theID) {
if(document.getElementById(theID).style.display == "block") {
var src = null;
var prev = null;
var livetime = null;
- var msie = false;
+ var force_update = false;
var stopped = false;
var totStopped = false;
var timer = null;
$(function() {
$.ajaxSetup({cache: false});
- msie = $.browser.msie ;
-
/* setup tooltips *//*
$("a,.tt").each(function(){
var e = $(this);
setupFieldRichtext();
/* popup menus */
- function close_last_popup_menu() {
- if(last_popup_menu) {
- last_popup_menu.hide();
- last_popup_button.removeClass("selected");
- last_popup_menu = null;
- last_popup_button = null;
- }
- }
+ function close_last_popup_menu() {
+ if(last_popup_menu) {
+ last_popup_menu.hide();
+ last_popup_button.removeClass("selected");
+ last_popup_menu = null;
+ last_popup_button = null;
+ }
+ }
$('a[rel^=#]').click(function(e){
+ e.preventDefault();
+ var parent = $(this).parent();
+ var isSelected = (last_popup_button && parent.attr('id') == last_popup_button.attr('id'));
close_last_popup_menu();
+ if(isSelected) return false;
menu = $( $(this).attr('rel') );
e.preventDefault();
e.stopPropagation();
if (menu.attr('popup')=="false") return false;
- $(this).parent().toggleClass("selected");
+ parent.toggleClass("selected");
menu.toggle();
if (menu.css("display") == "none") {
last_popup_menu = null;
last_popup_button = null;
} else {
last_popup_menu = menu;
- last_popup_button = $(this).parent();
+ last_popup_button = parent;
}
return false;
});
$('html').click(function() {
- close_last_popup_menu();
+ close_last_popup_menu();
});
// fancyboxes
- /*$("a.popupbox").fancybox({
- 'transitionIn' : 'elastic',
- 'transitionOut' : 'elastic'
- });*/
$("a.popupbox").colorbox({
'inline' : true,
'transition' : 'elastic'
nnm = $("#nav-notifications-menu");
nnm.html(notifications_all + notifications_mark);
//nnm.attr('popup','true');
+
+ var notification_lastitem = localStorage.getItem("notification-lastitem");
+ var notification_first_id = 0;
+
eNotif.children("note").each(function(){
e = $(this);
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'));
nnm.append(html);
+
+ var notification_id = e.attr('href').match(/\d+$/)[0];
+ if (notification_lastitem!== null && notification_id!=notification_lastitem) {
+ if (notification_first_id===0) notification_first_id = notification_id;
+ if (getNotificationPermission()==="granted") {
+ var notification = new Notification(document.title, {
+ body: e.text().replace('→ ','').format(e.attr('name')),
+ icon: e.attr('photo'),
+ });
+ // close notification after 5 secs.
+ // see https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API#Closing_notifications
+ setTimeout(notification.close.bind(notification), 5000);
+
+ notification.addEventListener("click", function(ev){
+ window.location = ev.target.data;
+ });
+ }
+ }
+ if (notification_id == notification_lastitem) {
+ if (notification_first_id===0) notification_first_id = notification_id;
+ notification_lastitem = null;
+ }
+
+
});
+ if (notification_first_id!==0) notification_lastitem = notification_first_id;
+ localStorage.setItem("notification-lastitem", notification_lastitem)
$("img[data-src]", nnm).each(function(i, el){
// Add src attribute for images with a data-src attribute
- $(el).attr('src', $(el).data("src"));
+ // However, don't bother if the data-src attribute is empty, because
+ // an empty "src" tag for an image will cause some browsers
+ // to prefetch the root page of the Friendica hub, which will
+ // unnecessarily load an entire profile/ or network/ page
+ if($(el).data("src") != '') $(el).attr('src', $(el).data("src"));
});
}
});
eSysmsg.children("info").each(function(){
text = $(this).text();
- $.jGrowl(text, { sticky: false, theme: 'info', life: 10000 });
+ $.jGrowl(text, { sticky: false, theme: 'info', life: 5000 });
});
});
if(livetime) {
clearTimeout(livetime);
}
- livetime = setTimeout(liveUpdate, 10000);
+ livetime = setTimeout(liveUpdate, 5000);
return;
}
if(livetime != null)
prev = 'live-' + src;
in_progress = true;
+
+ if ($(document).scrollTop() == 0)
+ force_update = true;
+
var udargs = ((netargs.length) ? '/' + netargs : '');
- var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
+ var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&force=' + ((force_update) ? 1 : 0);
$.get(update_url,function(data) {
in_progress = false;
+ force_update = false;
// $('.collapsed-comments',data).each(function() {
// var ident = $(this).attr('id');
// var is_hidden = $('#' + ident).is(':hidden');
}
/* autocomplete @nicknames */
$(".comment-edit-form textarea").contact_autocomplete(baseurl+"/acl");
+
+ // setup videos, since VideoJS won't take care of any loaded via AJAX
+ if(typeof videojs != 'undefined') videojs.autoSetup();
});
}
$('#like-rotator-' + ident.toString()).show();
$.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
liking = 1;
+ force_update = true;
}
function dosubthread(ident) {
$('#star-' + ident).addClass('hidden');
$('#unstar-' + ident).removeClass('hidden');
}
- else {
+ else {
$('#starred-' + ident).addClass('unstarred');
$('#starred-' + ident).removeClass('starred');
$('#star-' + ident).removeClass('hidden');
$('#unstar-' + ident).addClass('hidden');
}
- $('#like-rotator-' + ident).hide();
+ $('#like-rotator-' + ident).hide();
+ });
+ }
+
+ function doignore(ident) {
+ ident = ident.toString();
+ $('#like-rotator-' + ident).show();
+ $.get('ignored/' + ident, function(data) {
+ if(data.match(/1/)) {
+ $('#ignored-' + ident).addClass('ignored');
+ $('#ignored-' + ident).removeClass('unignored');
+ $('#ignore-' + ident).addClass('hidden');
+ $('#unignore-' + ident).removeClass('hidden');
+ }
+ else {
+ $('#ignored-' + ident).addClass('unignored');
+ $('#ignored-' + ident).removeClass('ignored');
+ $('#ignore-' + ident).removeClass('hidden');
+ $('#unignore-' + ident).addClass('hidden');
+ }
+ $('#like-rotator-' + ident).hide();
});
}
commentClose(tarea,id);
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,10);
+ force_update = true;
}
if(data.reload) {
window.location.href=data.reload;
$.get('notify/mark/all', function(data) {
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,1000);
+ force_update = true;
});
}
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_blockformats : "blockquote,code",
+ theme_advanced_resizing : true,
paste_text_sticky : true,
entity_encoding : "raw",
add_unload_trigger : false,
});
}
+
+// notification permission settings in localstorage
+// set by settings page
+function getNotificationPermission() {
+ if (window["Notification"] === undefined) {
+ return null;
+ }
+ if (Notification.permission === 'granted') {
+ return localStorage.getItem('notification-permissions');
+ } else {
+ return Notification.permission;
+ }
+}