From 114294e24a64324281ebcdcab54c9e557705f6e5 Mon Sep 17 00:00:00 2001 From: akhoury Date: Wed, 11 Dec 2013 22:50:36 -0500 Subject: [PATCH] allowGuestSearching config .. second attempt --- public/src/app.js | 4 +- public/src/forum/footer.js | 40 ++++++++++-------- public/templates/admin/settings.tpl | 5 +++ public/templates/header.tpl | 28 +++++++------ src/install.js | 3 ++ src/routes/api.js | 4 +- src/upgrade.js | 64 +++++++++++++++++++++++++++-- src/webserver.js | 4 +- src/websockets.js | 5 ++- 9 files changed, 117 insertions(+), 40 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index 837403d906..25cae1c74b 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -80,7 +80,7 @@ var socket, socket.emit('reconnected'); setTimeout(function() { - reconnectEl.removeClass('active'); + reconnectEl.removeClass('active').addClass("hide"); }, 3000); } @@ -104,7 +104,7 @@ var socket, reconnecting = true; if (!reconnectEl.hasClass('active')) reconnectEl.html(''); - reconnectEl.addClass('active'); + reconnectEl.addClass('active').removeClass("hide"); reconnectEl.tooltip({ placement: 'bottom' diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 34e61d8cf0..a16006f319 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -1,18 +1,19 @@ -(function() { +(function($) { socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] }); socket.on('api:updateHeader', function(data) { - jQuery('#search-button').on('click', function() { - jQuery('#search-fields').removeClass('hide').show(); - jQuery(this).hide(); - jQuery('#search-fields input').focus() - - jQuery('#search-form').on('submit', function() { - jQuery('#search-fields').hide(); - jQuery('#search-button').show(); + + $('#search-button').on('click', function() { + $('#search-fields').removeClass('hide').show(); + $(this).hide(); + $('#search-fields input').focus(); + + $('#search-form').on('submit', function() { + $('#search-fields').hide(); + $('#search-button').show(); }); $('#search-fields input').on('blur', function() { @@ -22,16 +23,17 @@ }); var loggedInMenu = $('#logged-in-menu'), - isLoggedIn = data.uid > 0; + isLoggedIn = data.uid > 0, + allowGuestSearching = (data.config || {}).allowGuestSearching === '1'; if (isLoggedIn) { - jQuery('.nodebb-loggedin').show(); - jQuery('.nodebb-loggedout').hide(); + $('.nodebb-loggedin').show(); + $('.nodebb-loggedout').hide(); $('#logged-out-menu').addClass('hide'); $('#logged-in-menu').removeClass('hide'); - $('#search-button').show(); + $('#search-button').removeClass("hide").show(); var userLabel = loggedInMenu.find('#user_label'); @@ -46,10 +48,14 @@ $('#logout-link').on('click', app.logout); } } else { - $('#search-button').hide(); + if (allowGuestSearching) { + $('#search-button').removeClass("hide").show(); + } else { + $('#search-button').addClass("hide").hide(); + } - jQuery('.nodebb-loggedin').hide(); - jQuery('.nodebb-loggedout').show(); + $('.nodebb-loggedin').hide(); + $('.nodebb-loggedout').show(); $('#logged-out-menu').removeClass('hide'); $('#logged-in-menu').addClass('hide'); @@ -264,4 +270,4 @@ require(['mobileMenu'], function(mobileMenu) { mobileMenu.init(); }); -}()); +}(jQuery)); diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl index 4a72c95fcc..8c7a0d44e6 100644 --- a/public/templates/admin/settings.tpl +++ b/public/templates/admin/settings.tpl @@ -97,6 +97,11 @@ Allow guests to post without logging in +
+ +