2014-05-14 18:46:11 -04:00
|
|
|
"use strict";
|
2014-05-15 17:16:17 -04:00
|
|
|
/*global app, socket*/
|
2014-05-14 18:46:11 -04:00
|
|
|
|
|
|
|
|
var admin = {};
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
admin.enableColorPicker = function(inputEl, callback) {
|
2014-05-14 18:50:50 -04:00
|
|
|
(inputEl instanceof jQuery ? inputEl : $(inputEl)).each(function() {
|
|
|
|
|
var $this = $(this);
|
|
|
|
|
|
|
|
|
|
$this.ColorPicker({
|
|
|
|
|
color: $this.val() || '#000',
|
|
|
|
|
onChange: function(hsb, hex) {
|
|
|
|
|
$this.val('#' + hex);
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
|
callback(hsb, hex);
|
|
|
|
|
}
|
2014-06-13 18:27:03 -04:00
|
|
|
},
|
|
|
|
|
onShow: function(colpkr) {
|
|
|
|
|
$(colpkr).css('z-index', 1051);
|
2014-05-14 18:46:11 -04:00
|
|
|
}
|
2014-05-14 18:50:50 -04:00
|
|
|
});
|
2014-05-15 20:49:47 -04:00
|
|
|
});
|
2014-05-14 18:46:11 -04:00
|
|
|
};
|
|
|
|
|
|
2014-05-15 17:16:17 -04:00
|
|
|
$(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);
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-10-08 17:06:35 -04:00
|
|
|
|
|
|
|
|
setupKeybindings();
|
2014-05-15 17:16:17 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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;
|
2014-10-08 17:06:35 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function setupKeybindings() {
|
|
|
|
|
Mousetrap.bind('ctrl+shift+a r', function() {
|
|
|
|
|
console.log('[admin] Reloading NodeBB...');
|
|
|
|
|
socket.emit('admin.reload');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Mousetrap.bind('ctrl+shift+a R', function() {
|
|
|
|
|
console.log('[admin] Restarting NodeBB...');
|
|
|
|
|
socket.emit('admin.restart');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Mousetrap.bind('/', function(e) {
|
|
|
|
|
$('#acp-search input').focus();
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-05-14 18:46:11 -04:00
|
|
|
}());
|