mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
closes #1482
removed updateHeader, the header is using template values in from the api, update menu partial in vanilla theme as well
This commit is contained in:
@@ -58,10 +58,6 @@ var socket,
|
||||
reconnectEl.removeClass('active').addClass("hide");
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
socket.emit('meta.updateHeader', {
|
||||
fields: ['username', 'picture', 'userslug']
|
||||
}, app.updateHeader);
|
||||
}
|
||||
|
||||
function onConfigLoad(data) {
|
||||
@@ -98,10 +94,6 @@ var socket,
|
||||
|
||||
app.showLoginMessage();
|
||||
|
||||
socket.emit('meta.updateHeader', {
|
||||
fields: ['username', 'picture', 'userslug']
|
||||
}, app.updateHeader);
|
||||
|
||||
$(window).trigger('action:connected');
|
||||
});
|
||||
|
||||
@@ -146,8 +138,6 @@ var socket,
|
||||
setTimeout(app.logout, 1000);
|
||||
});
|
||||
|
||||
socket.on('meta.updateHeader', app.updateHeader);
|
||||
|
||||
app.enterRoom('global');
|
||||
|
||||
if (config.environment === 'development' && console && console.log) {
|
||||
@@ -289,7 +279,7 @@ var socket,
|
||||
app.replaceSelfLinks = function(selector) {
|
||||
selector = selector || $('a');
|
||||
selector.each(function() {
|
||||
var href = $(this).attr('href')
|
||||
var href = $(this).attr('href');
|
||||
if (href && app.userslug) {
|
||||
$(this).attr('href', href.replace(/\[self\]/g, app.userslug));
|
||||
}
|
||||
@@ -430,86 +420,6 @@ var socket,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
app.updateHeader = function(err, data) {
|
||||
var searchButton = $("#search-button"),
|
||||
searchFields = $("#search-fields"),
|
||||
searchInput = $('#search-fields input');
|
||||
|
||||
function dismissSearch(){
|
||||
searchFields.hide();
|
||||
searchButton.show();
|
||||
}
|
||||
|
||||
searchButton.off().on('click', function(e) {
|
||||
e.stopPropagation();
|
||||
|
||||
searchFields.removeClass('hide').show();
|
||||
$(this).hide();
|
||||
|
||||
searchInput.focus();
|
||||
|
||||
$('#search-form').on('submit', dismissSearch);
|
||||
searchInput.on('blur', dismissSearch);
|
||||
return false;
|
||||
});
|
||||
|
||||
var loggedInMenu = $('#logged-in-menu'),
|
||||
isLoggedIn = data.uid > 0,
|
||||
allowGuestSearching = (data.config || {}).allowGuestSearching === '1';
|
||||
|
||||
if (isLoggedIn) {
|
||||
$('#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');
|
||||
}
|
||||
|
||||
$('#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')) {
|
||||
$('.navbar-header button').click();
|
||||
}
|
||||
});
|
||||
|
||||
$('#user-control-list .user-status').off('click').on('click', function(e) {
|
||||
socket.emit('user.setStatus', $(this).attr('data-status'), function(err, data) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
updateOnlineStatus(data.uid);
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
function exposeConfigToTemplates() {
|
||||
$(document).ready(function() {
|
||||
templates.setGlobal('relative_path', RELATIVE_PATH);
|
||||
@@ -540,6 +450,56 @@ var socket,
|
||||
});
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
var searchButton = $("#search-button"),
|
||||
searchFields = $("#search-fields"),
|
||||
searchInput = $('#search-fields input');
|
||||
|
||||
function dismissSearch(){
|
||||
searchFields.hide();
|
||||
searchButton.show();
|
||||
}
|
||||
|
||||
searchButton.off().on('click', function(e) {
|
||||
e.stopPropagation();
|
||||
|
||||
searchFields.removeClass('hide').show();
|
||||
$(this).hide();
|
||||
|
||||
searchInput.focus();
|
||||
|
||||
$('#search-form').on('submit', dismissSearch);
|
||||
searchInput.on('blur', dismissSearch);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#search-form').on('submit', function () {
|
||||
var input = $(this).find('input');
|
||||
ajaxify.go('search/' + input.val().replace(/^[ ?#]*/, ''));
|
||||
input.val('');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function collapseNavigationOnClick() {
|
||||
$('#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')) {
|
||||
$('.navbar-header button').click();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handleStatusChange() {
|
||||
$('#user-control-list .user-status').off('click').on('click', function(e) {
|
||||
socket.emit('user.setStatus', $(this).attr('data-status'), function(err, data) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
updateOnlineStatus(data.uid);
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
app.load = function() {
|
||||
$('document').ready(function () {
|
||||
@@ -556,12 +516,13 @@ var socket,
|
||||
url: url
|
||||
});
|
||||
|
||||
$('#search-form').on('submit', function () {
|
||||
var input = $(this).find('input');
|
||||
ajaxify.go("search/" + input.val().replace(/^[ ?#]*/, ''));
|
||||
input.val('');
|
||||
return false;
|
||||
});
|
||||
collapseNavigationOnClick();
|
||||
|
||||
handleStatusChange();
|
||||
|
||||
handleSearch();
|
||||
|
||||
$('#logout-link').on('click', app.logout);
|
||||
|
||||
$(window).blur(function(){
|
||||
app.isFocused = false;
|
||||
|
||||
Reference in New Issue
Block a user