Merge branch 'master' of github.com:chronize/NodeBB into chronize-master

v1.18.x
Julian Lam 11 years ago
commit 05e147b440

@ -7,28 +7,53 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
Groups.init = function() { Groups.init = function() {
var yourid = ajaxify.variables.get('yourid'), var yourid = ajaxify.variables.get('yourid'),
createModal = $('#create-modal'), createModal = $('#create-modal'),
createNameEl = $('#create-group-name'), createGroupName = $('#create-group-name'),
detailsModal = $('#group-details-modal'), create = $('#create'),
detailsSearch = detailsModal.find('#group-details-search'), createModalGo = $('#create-modal-go'),
searchResults = detailsModal.find('#group-details-search-results'), createGroupDesc = $('#create-group-desc'),
groupMembersEl = detailsModal.find('ul.current_members'), createModalError = $('#create-modal-error'),
detailsModalSave = detailsModal.find('.btn-primary'), groupDetailsModal = $('#group-details-modal'),
searchDelay, groupDetailsSearch = $('#group-details-search'),
listEl = $('#groups-list'); groupDetailsSearchResults = $('#group-details-search-results'),
groupMembersEl = $('ul.current_members'),
$('#create').on('click', function() { formEl = groupDetailsModal.find('form'),
detailsModalSave = $('#details-modal-save'),
groupsList = $('#groups-list'),
groupIcon = $('#group-icon'),
changeGroupIcon = $('#change-group-icon'),
changeGroupName = $('#change-group-name'),
changeGroupDesc = $('#change-group-desc'),
changeGroupUserTitle = $('#change-group-user-title'),
changeGroupLabelColor = $('#change-group-label-color'),
groupIcon = $('#group-icon'),
groupLabelPreview = $('#group-label-preview'),
searchDelay;
// Tooltips
$('#groups-list .members li').tooltip();
createModal.on('keypress', function(e) {
switch(e.keyCode) {
case 13:
createModalGo.click();
break;
default:
break;
}
});
create.on('click', function() {
createModal.modal('show'); createModal.modal('show');
setTimeout(function() { setTimeout(function() {
createNameEl.focus(); createGroupName.focus();
}, 250); }, 250);
}); });
$('#create-modal-go').on('click', function() { createModalGo.on('click', function() {
var submitObj = { var submitObj = {
name: createNameEl.val(), name: createGroupName.val(),
description: $('#create-group-desc').val() description: createGroupDesc.val()
}, },
errorEl = $('#create-modal-error'),
errorText; errorText;
socket.emit('admin.groups.create', submitObj, function(err, data) { socket.emit('admin.groups.create', submitObj, function(err, data) {
@ -45,10 +70,10 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
break; break;
} }
errorEl.html(errorText).removeClass('hide'); createModalError.html(errorText).removeClass('hide');
} else { } else {
errorEl.addClass('hide'); createModalError.addClass('hide');
createNameEl.val(''); createGroupName.val('');
createModal.on('hidden.bs.modal', function() { createModal.on('hidden.bs.modal', function() {
ajaxify.go('admin/groups'); ajaxify.go('admin/groups');
}); });
@ -57,7 +82,29 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
}); });
}); });
listEl.on('click', 'button[data-action]', function() { formEl.keypress(function(e) {
switch(e.keyCode) {
case 13:
detailsModalSave.click();
break;
default:
break;
}
});
changeGroupUserTitle.keydown(function() {
setTimeout(function() {
groupLabelPreview.text(changeGroupUserTitle.val());
}, 0);
});
changeGroupLabelColor.keydown(function() {
setTimeout(function() {
groupLabelPreview.css('background', changeGroupLabelColor.val() || '#000000');
}, 0);
});
groupsList.on('click', 'button[data-action]', function() {
var el = $(this), var el = $(this),
action = el.attr('data-action'), action = el.attr('data-action'),
groupName = el.parents('li[data-groupname]').attr('data-groupname'); groupName = el.parents('li[data-groupname]').attr('data-groupname');
@ -78,32 +125,12 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
break; break;
case 'members': case 'members':
socket.emit('admin.groups.get', groupName, function(err, groupObj) { socket.emit('admin.groups.get', groupName, function(err, groupObj) {
var formEl = detailsModal.find('form').keypress(function(e) {
switch(e.keyCode) { changeGroupName.val(groupObj.name).prop('readonly', groupObj.system);
case 13: changeGroupDesc.val(groupObj.description);
detailsModalSave.click(); changeGroupUserTitle.val(groupObj.userTitle);
break; groupIcon.attr('class', 'fa fa-2x ' + groupObj.icon).attr('value', groupObj.icon);
default: changeGroupLabelColor.val(groupObj.labelColor);
break;
}
}),
groupLabelPreview = formEl.find('#group-label-preview'),
changeGroupUserTitle = formEl.find('#change-group-user-title'),
changeGroupLabelColor = formEl.find('#change-group-label-color');
formEl.find('#change-group-name').val(groupObj.name).prop('readonly', groupObj.system);
formEl.find('#change-group-desc').val(groupObj.description);
changeGroupUserTitle.val(groupObj.userTitle).keydown(function() {
setTimeout(function() {
groupLabelPreview.text(changeGroupUserTitle.val());
}, 0);
});
formEl.find('#group-icon').attr('class', 'fa fa-2x ' + groupObj.icon).attr('value', groupObj.icon);
changeGroupLabelColor.val(groupObj.labelColor).keydown(function() {
setTimeout(function() {
groupLabelPreview.css('background', changeGroupLabelColor.val() || '#000000');
}, 0);
});
groupLabelPreview.css('background', groupObj.labelColor || '#000000').text(groupObj.userTitle); groupLabelPreview.css('background', groupObj.labelColor || '#000000').text(groupObj.userTitle);
groupMembersEl.empty(); groupMembersEl.empty();
@ -117,23 +144,21 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
} }
} }
detailsModal.attr('data-groupname', groupObj.name); groupDetailsModal.attr('data-groupname', groupObj.name);
detailsModal.modal('show'); groupDetailsModal.modal('show');
}); });
break; break;
} }
}); });
detailsSearch.on('keyup', function() { groupDetailsSearch.on('keyup', function() {
var searchEl = this;
if (searchDelay) { if (searchDelay) {
clearTimeout(searchDelay); clearTimeout(searchDelay);
} }
searchDelay = setTimeout(function() { searchDelay = setTimeout(function() {
var searchText = searchEl.value, var searchText = groupDetailsSearch.val(),
resultsEl = $('#group-details-search-results'),
foundUser; foundUser;
socket.emit('admin.user.search', searchText, function(err, results) { socket.emit('admin.user.search', searchText, function(err, results) {
@ -143,7 +168,7 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
numResults = 4; numResults = 4;
} }
resultsEl.empty(); groupDetailsSearchResults.empty();
for (x = 0; x < numResults; x++) { for (x = 0; x < numResults; x++) {
foundUser = $('<li />'); foundUser = $('<li />');
foundUser foundUser
@ -151,19 +176,19 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
.append($('<img />').attr('src', results.users[x].picture)) .append($('<img />').attr('src', results.users[x].picture))
.append($('<span />').html(results.users[x].username)); .append($('<span />').html(results.users[x].username));
resultsEl.append(foundUser); groupDetailsSearchResults.append(foundUser);
} }
} else { } else {
resultsEl.html('<li>No Users Found</li>'); groupDetailsSearchResults.html('<li>No Users Found</li>');
} }
}); });
}, 200); }, 200);
}); });
searchResults.on('click', 'li[data-uid]', function() { groupDetailsSearchResults.on('click', 'li[data-uid]', function() {
var userLabel = $(this), var userLabel = $(this),
uid = parseInt(userLabel.attr('data-uid'), 10), uid = parseInt(userLabel.attr('data-uid'), 10),
groupName = detailsModal.attr('data-groupname'), groupName = groupDetailsModal.attr('data-groupname'),
members = []; members = [];
groupMembersEl.find('li[data-uid]').each(function() { groupMembersEl.find('li[data-uid]').each(function() {
@ -184,7 +209,7 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
groupMembersEl.on('click', 'li[data-uid]', function() { groupMembersEl.on('click', 'li[data-uid]', function() {
var uid = $(this).attr('data-uid'), var uid = $(this).attr('data-uid'),
groupName = detailsModal.attr('data-groupname'); groupName = groupDetailsModal.attr('data-groupname');
socket.emit('admin.groups.get', groupName, function(err, groupObj){ socket.emit('admin.groups.get', groupName, function(err, groupObj){
if (!err){ if (!err){
@ -204,38 +229,34 @@ define('forum/admin/groups', ['forum/admin/iconSelect'], function(iconSelect) {
}); });
}); });
$('#change-group-icon').on('click', function() { changeGroupIcon.on('click', function() {
iconSelect.init($('#group-icon')); iconSelect.init(groupIcon);
}); });
admin.enableColorPicker($('#change-group-label-color'), function(hsb, hex) { admin.enableColorPicker(changeGroupLabelColor, function(hsb, hex) {
$('#group-label-preview').css('background-color', '#' + hex); groupLabelPreview.css('background-color', '#' + hex);
}); });
detailsModalSave.on('click', function() { detailsModalSave.on('click', function() {
var formEl = detailsModal.find('form');
socket.emit('admin.groups.update', { socket.emit('admin.groups.update', {
groupName: detailsModal.attr('data-groupname'), groupName: groupDetailsModal.attr('data-groupname'),
values: { values: {
name: formEl.find('#change-group-name').val(), name: changeGroupName.val(),
userTitle: formEl.find('#change-group-user-title').val(), userTitle: changeGroupUserTitle.val(),
description: formEl.find('#change-group-desc').val(), description: changeGroupDesc.val(),
icon: formEl.find('#group-icon').attr('value'), icon: groupIcon.attr('value'),
labelColor: formEl.find('#change-group-label-color').val() labelColor: changeGroupLabelColor.val()
} }
}, function(err) { }, function(err) {
if (!err) { if (!err) {
detailsModal.on('hidden.bs.modal', function() { groupDetailsModal.on('hidden.bs.modal', function() {
ajaxify.go('admin/groups'); ajaxify.go('admin/groups');
}); });
detailsModal.modal('hide'); groupDetailsModal.modal('hide');
} }
}); });
}); });
// Tooltips
$('#groups-list .members li').tooltip();
}; };
return Groups; return Groups;

@ -1,4 +1,4 @@
"use strict"; "use strict";
var db = require('./database'), var db = require('./database'),
async = require('async'), async = require('async'),
@ -75,7 +75,7 @@ Upgrade.upgrade = function(callback) {
{ {
"widget": "html", "widget": "html",
"data": { "data": {
"html": Meta.config['motd'] || "Welcome to NodeBB, if you are an administrator of this forum visit the <a target='_blank' href='/admin/themes'>Themes</a> ACP to modify and add widgets." "html": Meta.config.motd || "Welcome to NodeBB, if you are an administrator of this forum visit the <a target='_blank' href='/admin/themes'>Themes</a> ACP to modify and add widgets."
} }
} }
]), function(err) { ]), function(err) {
@ -171,7 +171,7 @@ Upgrade.upgrade = function(callback) {
{ {
"widget": "html", "widget": "html",
"data": { "data": {
"html": Meta.config['motd'] || "Welcome to NodeBB, if you are an administrator of this forum visit the <a target='_blank' href='/admin/themes'>Themes</a> ACP to modify and add widgets.", "html": Meta.config.motd || "Welcome to NodeBB, if you are an administrator of this forum visit the <a target='_blank' href='/admin/themes'>Themes</a> ACP to modify and add widgets.",
"container": container, "container": container,
"title": "MOTD" "title": "MOTD"
} }

Loading…
Cancel
Save