Skip to content

Node.js based forum software built for the modern web

move code from footer.js into admin.js

psychobunny033364a2a96f
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;
-});