moved refreshTitle into app.js, messaging someone now invokes an alternating title, hehe

v1.18.x
Julian Lam 11 years ago
parent 385aa6df92
commit b81737bc0f

@ -119,7 +119,7 @@ var ajaxify = {};
});
}
utils.refreshTitle(url);
app.refreshTitle(url);
}, url, template);

@ -396,7 +396,44 @@ var socket,
$('body,html').animate({
scrollTop: $('html').height() - 100
});
}
};
var titleObj = {
active: false,
interval: undefined,
titles: []
};
app.alternatingTitle = function (title) {
if (typeof title !== 'string') return;
if (title.length > 0) {
titleObj.titles[1] = title;
if (titleObj.interval) {
clearInterval(titleObj.interval);
}
titleObj.interval = setInterval(function() {
window.document.title = titleObj.titles[titleObj.titles.indexOf(window.document.title) ^ 1];
}, 2000);
} else {
if (titleObj.interval) {
clearInterval(titleObj.interval);
}
if (titleObj.titles[0]) window.document.title = titleObj.titles[0];
}
};
app.refreshTitle = function(url) {
if (!url) {
var a = document.createElement('a');
a.href = document.location;
url = a.pathname.slice(1);
}
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
titleObj.titles[0] = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
app.alternatingTitle('');
});
};
jQuery('document').ready(function () {
$('#search-form').on('submit', function () {
@ -410,5 +447,5 @@ var socket,
showWelcomeMessage = location.href.indexOf('loggedin') !== -1;
app.loadConfig();
app.alternatingTitle('');
}());

@ -112,7 +112,7 @@
socket.emit('api:notifications.mark_all_read', null, function() {
notifIcon.toggleClass('active', false);
utils.refreshTitle();
app.refreshTitle();
// Update favicon + local count
Tinycon.setBubble(0);
@ -167,7 +167,7 @@
type: 'warning',
timeout: 2000
});
utils.refreshTitle();
app.refreshTitle();
// Update the favicon + local storage
var savedCount = parseInt(localStorage.getItem('notifications:count'),10) || 0;
@ -209,7 +209,6 @@
});
socket.on('chatMessage', function(data) {
require(['chat'], function(chat) {
var modal = null;
if (chat.modalExists(data.fromuid)) {
@ -220,10 +219,12 @@
chat.load(modal.attr('UUID'));
} else {
chat.toggleNew(modal.attr('UUID'), true);
app.alternatingTitle(data.username + ' has messaged you');
}
} else {
modal = chat.createModal(data.username, data.fromuid);
chat.toggleNew(modal.attr('UUID'), true);
app.alternatingTitle(data.username + ' has messaged you');
}
});
});

@ -26,6 +26,7 @@ define(function() {
taskbar.minimizeAll();
module.load(uuid);
taskbar.toggleNew(uuid, false);
app.alternatingTitle('');
// Highlight the button
$(taskbar.tasklist).removeClass('active');

@ -169,23 +169,6 @@
return tags;
},
refreshTitle: function(url) {
if (!url) {
var a = document.createElement('a');
a.href = document.location;
url = a.pathname.slice(1);
}
var notificationIcon;
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
notificationIcon = notificationIcon || document.querySelector('.notifications a i');
if (numNotifications > 0 && notificationIcon) {
notificationIcon.className = 'fa fa-circle active';
}
});
},
isRelativeUrl: function(url) {
var firstChar = url.slice(0, 1);
return (firstChar === '.' || firstChar === '/');

@ -1158,6 +1158,4 @@ websockets.init = function(io) {
return userSockets;
}
}
})(module.exports);
})(module.exports);
Loading…
Cancel
Save