mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 09:25:45 +01:00
move code from footer.js into admin.js
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
/*global app, socket*/
|
||||||
|
|
||||||
var admin = {};
|
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;
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
@@ -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;
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user