|
|
@ -58,10 +58,6 @@ var socket,
|
|
|
|
reconnectEl.removeClass('active').addClass("hide");
|
|
|
|
reconnectEl.removeClass('active').addClass("hide");
|
|
|
|
}, 3000);
|
|
|
|
}, 3000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('meta.updateHeader', {
|
|
|
|
|
|
|
|
fields: ['username', 'picture', 'userslug']
|
|
|
|
|
|
|
|
}, app.updateHeader);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onConfigLoad(data) {
|
|
|
|
function onConfigLoad(data) {
|
|
|
@ -98,10 +94,6 @@ var socket,
|
|
|
|
|
|
|
|
|
|
|
|
app.showLoginMessage();
|
|
|
|
app.showLoginMessage();
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('meta.updateHeader', {
|
|
|
|
|
|
|
|
fields: ['username', 'picture', 'userslug']
|
|
|
|
|
|
|
|
}, app.updateHeader);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(window).trigger('action:connected');
|
|
|
|
$(window).trigger('action:connected');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -146,8 +138,6 @@ var socket,
|
|
|
|
setTimeout(app.logout, 1000);
|
|
|
|
setTimeout(app.logout, 1000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('meta.updateHeader', app.updateHeader);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.enterRoom('global');
|
|
|
|
app.enterRoom('global');
|
|
|
|
|
|
|
|
|
|
|
|
if (config.environment === 'development' && console && console.log) {
|
|
|
|
if (config.environment === 'development' && console && console.log) {
|
|
|
@ -289,7 +279,7 @@ var socket,
|
|
|
|
app.replaceSelfLinks = function(selector) {
|
|
|
|
app.replaceSelfLinks = function(selector) {
|
|
|
|
selector = selector || $('a');
|
|
|
|
selector = selector || $('a');
|
|
|
|
selector.each(function() {
|
|
|
|
selector.each(function() {
|
|
|
|
var href = $(this).attr('href')
|
|
|
|
var href = $(this).attr('href');
|
|
|
|
if (href && app.userslug) {
|
|
|
|
if (href && app.userslug) {
|
|
|
|
$(this).attr('href', href.replace(/\[self\]/g, app.userslug));
|
|
|
|
$(this).attr('href', href.replace(/\[self\]/g, app.userslug));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -430,8 +420,37 @@ var socket,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function exposeConfigToTemplates() {
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
templates.setGlobal('relative_path', RELATIVE_PATH);
|
|
|
|
|
|
|
|
for(var key in config) {
|
|
|
|
|
|
|
|
if (config.hasOwnProperty(key)) {
|
|
|
|
|
|
|
|
templates.setGlobal('config.' + key, config[key]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createHeaderTooltips() {
|
|
|
|
|
|
|
|
$('#header-menu li i[title]').each(function() {
|
|
|
|
|
|
|
|
$(this).parents('a').tooltip({
|
|
|
|
|
|
|
|
placement: 'bottom',
|
|
|
|
|
|
|
|
title: $(this).attr('title')
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#search-form').parent().tooltip({
|
|
|
|
|
|
|
|
placement: 'bottom',
|
|
|
|
|
|
|
|
title: $('#search-button i').attr('title')
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
app.updateHeader = function(err, data) {
|
|
|
|
$('#user_dropdown').tooltip({
|
|
|
|
|
|
|
|
placement: 'bottom',
|
|
|
|
|
|
|
|
title: $('#user_dropdown').attr('title')
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleSearch() {
|
|
|
|
var searchButton = $("#search-button"),
|
|
|
|
var searchButton = $("#search-button"),
|
|
|
|
searchFields = $("#search-fields"),
|
|
|
|
searchFields = $("#search-fields"),
|
|
|
|
searchInput = $('#search-fields input');
|
|
|
|
searchInput = $('#search-fields input');
|
|
|
@ -454,51 +473,23 @@ var socket,
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var loggedInMenu = $('#logged-in-menu'),
|
|
|
|
$('#search-form').on('submit', function () {
|
|
|
|
isLoggedIn = data.uid > 0,
|
|
|
|
var input = $(this).find('input');
|
|
|
|
allowGuestSearching = (data.config || {}).allowGuestSearching === '1';
|
|
|
|
ajaxify.go('search/' + input.val().replace(/^[ ?#]*/, ''));
|
|
|
|
|
|
|
|
input.val('');
|
|
|
|
if (isLoggedIn) {
|
|
|
|
return false;
|
|
|
|
$('#logged-out-menu').addClass('hide');
|
|
|
|
});
|
|
|
|
$('#logged-in-menu').removeClass('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
searchButton.removeClass("hide").show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userLabel = loggedInMenu.find('#user_label');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.userslug) {
|
|
|
|
|
|
|
|
userLabel.find('#user-profile-link').attr('href', RELATIVE_PATH + '/user/' + data.userslug);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.picture) {
|
|
|
|
|
|
|
|
userLabel.find('img').attr('src', data.picture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.username) {
|
|
|
|
|
|
|
|
userLabel.find('#user-profile-link>span').html(' ' + data.username);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#logout-link').on('click', app.logout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateOnlineStatus(data.uid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (allowGuestSearching) {
|
|
|
|
|
|
|
|
searchButton.removeClass("hide").show();
|
|
|
|
|
|
|
|
$('#mobile-search-button').removeClass("hide").show();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
searchButton.addClass("hide").hide();
|
|
|
|
|
|
|
|
$('#mobile-search-button').addClass("hide").hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#logged-out-menu').removeClass('hide');
|
|
|
|
|
|
|
|
$('#logged-in-menu').addClass('hide');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function collapseNavigationOnClick() {
|
|
|
|
$('#main-nav a, #user-control-list a, #logged-out-menu li a, #logged-in-menu .visible-xs').off('click').on('click', function() {
|
|
|
|
$('#main-nav a, #user-control-list a, #logged-out-menu li a, #logged-in-menu .visible-xs').off('click').on('click', function() {
|
|
|
|
if($('.navbar .navbar-collapse').hasClass('in')) {
|
|
|
|
if($('.navbar .navbar-collapse').hasClass('in')) {
|
|
|
|
$('.navbar-header button').click();
|
|
|
|
$('.navbar-header button').click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleStatusChange() {
|
|
|
|
$('#user-control-list .user-status').off('click').on('click', function(e) {
|
|
|
|
$('#user-control-list .user-status').off('click').on('click', function(e) {
|
|
|
|
socket.emit('user.setStatus', $(this).attr('data-status'), function(err, data) {
|
|
|
|
socket.emit('user.setStatus', $(this).attr('data-status'), function(err, data) {
|
|
|
|
if(err) {
|
|
|
|
if(err) {
|
|
|
@ -508,39 +499,8 @@ var socket,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function exposeConfigToTemplates() {
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
templates.setGlobal('relative_path', RELATIVE_PATH);
|
|
|
|
|
|
|
|
for(var key in config) {
|
|
|
|
|
|
|
|
if (config.hasOwnProperty(key)) {
|
|
|
|
|
|
|
|
templates.setGlobal('config.' + key, config[key]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createHeaderTooltips() {
|
|
|
|
|
|
|
|
$('#header-menu li i[title]').each(function() {
|
|
|
|
|
|
|
|
$(this).parents('a').tooltip({
|
|
|
|
|
|
|
|
placement: 'bottom',
|
|
|
|
|
|
|
|
title: $(this).attr('title')
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#search-form').parent().tooltip({
|
|
|
|
|
|
|
|
placement: 'bottom',
|
|
|
|
|
|
|
|
title: $('#search-button i').attr('title')
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#user_dropdown').tooltip({
|
|
|
|
|
|
|
|
placement: 'bottom',
|
|
|
|
|
|
|
|
title: $('#user_dropdown').attr('title')
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.load = function() {
|
|
|
|
app.load = function() {
|
|
|
|
$('document').ready(function () {
|
|
|
|
$('document').ready(function () {
|
|
|
|
var url = window.location.pathname.slice(1),
|
|
|
|
var url = window.location.pathname.slice(1),
|
|
|
@ -556,12 +516,13 @@ var socket,
|
|
|
|
url: url
|
|
|
|
url: url
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('#search-form').on('submit', function () {
|
|
|
|
collapseNavigationOnClick();
|
|
|
|
var input = $(this).find('input');
|
|
|
|
|
|
|
|
ajaxify.go("search/" + input.val().replace(/^[ ?#]*/, ''));
|
|
|
|
handleStatusChange();
|
|
|
|
input.val('');
|
|
|
|
|
|
|
|
return false;
|
|
|
|
handleSearch();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('#logout-link').on('click', app.logout);
|
|
|
|
|
|
|
|
|
|
|
|
$(window).blur(function(){
|
|
|
|
$(window).blur(function(){
|
|
|
|
app.isFocused = false;
|
|
|
|
app.isFocused = false;
|
|
|
|