From 033364a2a96fcef867c0b97b60da43127b5336f3 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 15 May 2014 17:16:17 -0400 Subject: [PATCH] move code from footer.js into admin.js --- public/src/admin.js | 41 ++++++++++++++++++++++++++++++++ public/src/forum/admin/footer.js | 41 -------------------------------- 2 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 public/src/forum/admin/footer.js diff --git a/public/src/admin.js b/public/src/admin.js index 65a7504208..df5b4d3c7d 100644 --- a/public/src/admin.js +++ b/public/src/admin.js @@ -1,4 +1,5 @@ "use strict"; +/*global app, socket*/ var admin = {}; @@ -20,4 +21,44 @@ var admin = {}; }); }; + $(function() { + var menuEl = $('.sidebar-nav'), + liEls = menuEl.find('li'), + parentEl, + activate = function(li) { + liEls.removeClass('active'); + li.addClass('active'); + }; + + // also on ready, check the pathname, maybe it was a page refresh and no item was clicked + liEls.each(function(i, li){ + li = $(li); + if ((li.find('a').attr('href') || '').indexOf(location.pathname) >= 0) { + activate(li); + } + }); + + // On menu click, change "active" state + menuEl.on('click', function(e) { + parentEl = $(e.target).parent(); + if (parentEl.is('li')) { + activate(parentEl); + } + }); + }); + + socket.emit('admin.config.get', function(err, config) { + if(err) { + return app.alert({ + alert_id: 'config_status', + timeout: 2500, + title: 'Error', + message: 'NodeBB encountered a problem getting config', + type: 'danger' + }); + } + + // move this to admin.config + app.config = config; + }); }()); \ No newline at end of file diff --git a/public/src/forum/admin/footer.js b/public/src/forum/admin/footer.js deleted file mode 100644 index a7a040a0f4..0000000000 --- a/public/src/forum/admin/footer.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -/*global app, socket*/ - -$(function() { - var menuEl = $('.sidebar-nav'), - liEls = menuEl.find('li'), - parentEl, - activate = function(li) { - liEls.removeClass('active'); - li.addClass('active'); - }; - - // also on ready, check the pathname, maybe it was a page refresh and no item was clicked - liEls.each(function(i, li){ - li = $(li); - if ((li.find('a').attr('href') || '').indexOf(location.pathname) >= 0) { - activate(li); - } - }); - - // On menu click, change "active" state - menuEl.on('click', function(e) { - parentEl = $(e.target).parent(); - if (parentEl.is('li')) { - activate(parentEl); - } - }); -}); - -socket.emit('admin.config.get', function(err, config) { - if(err) { - return app.alert({ - alert_id: 'config_status', - timeout: 2500, - title: 'Error', - message: 'NodeBB encountered a problem getting config', - type: 'danger' - }); - } - app.config = config; -});