2014-03-12 16:18:48 -04:00
|
|
|
"use strict";
|
2014-03-28 13:29:51 -04:00
|
|
|
/*global define, socket, app, bootbox, templates, ajaxify, RELATIVE_PATH*/
|
2014-03-12 16:18:48 -04:00
|
|
|
|
2014-05-29 17:24:38 -04:00
|
|
|
define('forum/admin/categories', ['uploader'], function(uploader) {
|
2013-10-03 15:04:25 -04:00
|
|
|
var Categories = {};
|
2013-06-24 17:25:16 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
Categories.init = function() {
|
|
|
|
|
var modified_categories = {};
|
2013-06-24 17:25:16 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
function modified(el) {
|
|
|
|
|
var cid = $(el).parents('li').attr('data-cid');
|
2013-10-19 23:30:10 -04:00
|
|
|
if(cid) {
|
|
|
|
|
modified_categories[cid] = modified_categories[cid] || {};
|
|
|
|
|
modified_categories[cid][$(el).attr('data-name')] = $(el).val();
|
|
|
|
|
}
|
2013-06-24 17:25:16 -04:00
|
|
|
}
|
|
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
function save() {
|
2014-02-12 12:31:08 -05:00
|
|
|
if(Object.keys(modified_categories).length) {
|
2014-02-28 15:25:50 -05:00
|
|
|
socket.emit('admin.categories.update', modified_categories, function(err, result) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result && result.length) {
|
|
|
|
|
app.alert({
|
|
|
|
|
title: 'Updated Categories',
|
|
|
|
|
message: 'Category IDs ' + result.join(', ') + ' was successfully updated.',
|
|
|
|
|
type: 'success',
|
|
|
|
|
timeout: 2000
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-02-12 12:31:08 -05:00
|
|
|
modified_categories = {};
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2013-10-03 15:04:25 -04:00
|
|
|
}
|
2013-09-11 16:04:34 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
function select_icon(el) {
|
2014-04-12 17:36:48 -04:00
|
|
|
var selected = el.attr('class').replace('fa-2x', '').replace('fa', '').replace(/\s+/g, '');
|
2013-11-27 16:23:30 -05:00
|
|
|
$('#icons .selected').removeClass('selected');
|
2014-04-12 17:36:48 -04:00
|
|
|
|
|
|
|
|
if (selected === '') {
|
|
|
|
|
selected = 'fa-doesnt-exist';
|
|
|
|
|
}
|
2014-03-12 16:18:48 -04:00
|
|
|
if (selected) {
|
2014-04-12 17:36:48 -04:00
|
|
|
$('#icons .fa-icons .fa.' + selected).parent().addClass('selected');
|
2014-03-12 16:18:48 -04:00
|
|
|
}
|
2013-09-11 16:04:34 -04:00
|
|
|
|
2014-04-12 17:36:48 -04:00
|
|
|
bootbox.confirm('<h2>Select an icon.</h2>' + $('#icons').html(), function(confirm) {
|
2013-10-03 15:04:25 -04:00
|
|
|
if (confirm) {
|
2013-11-27 16:23:30 -05:00
|
|
|
var iconClass = $('.bootbox .selected').children(':first').attr('class');
|
2013-11-26 14:25:46 -05:00
|
|
|
|
|
|
|
|
el.attr('class', iconClass + ' fa-2x');
|
|
|
|
|
|
|
|
|
|
// remove the 'fa ' from the class name, just need the icon name itself
|
|
|
|
|
var categoryIconClass = iconClass.replace('fa ', '');
|
2014-04-12 17:36:48 -04:00
|
|
|
if(categoryIconClass === 'fa-doesnt-exist') {
|
|
|
|
|
categoryIconClass = '';
|
|
|
|
|
}
|
2013-11-26 14:25:46 -05:00
|
|
|
el.val(categoryIconClass);
|
|
|
|
|
el.attr('value', categoryIconClass);
|
2013-06-24 17:25:16 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
modified(el);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-06-24 17:25:16 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
setTimeout(function() { //bootbox was rewritten for BS3 and I had to add this timeout for the previous code to work. TODO: to look into
|
2013-11-27 16:23:30 -05:00
|
|
|
$('.bootbox .col-md-3').on('click', function() {
|
|
|
|
|
$('.bootbox .selected').removeClass('selected');
|
|
|
|
|
$(this).addClass('selected');
|
2013-10-03 15:04:25 -04:00
|
|
|
});
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
2013-06-24 17:25:16 -04:00
|
|
|
|
|
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
function update_blockclass(el) {
|
|
|
|
|
el.parentNode.parentNode.className = 'entry-row ' + el.value;
|
|
|
|
|
}
|
2013-06-24 17:25:16 -04:00
|
|
|
|
2013-10-07 17:48:11 -04:00
|
|
|
function updateCategoryOrders() {
|
|
|
|
|
var categories = $('.admin-categories #entry-container').children();
|
2014-02-26 21:55:29 -05:00
|
|
|
for(var i = 0; i<categories.length; ++i) {
|
2013-10-07 17:48:11 -04:00
|
|
|
var input = $(categories[i]).find('input[data-name="order"]');
|
|
|
|
|
|
|
|
|
|
input.val(i+1).attr('data-value', i+1);
|
|
|
|
|
modified(input);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
$('#entry-container').sortable({
|
2014-02-26 21:55:29 -05:00
|
|
|
stop: function(event, ui) {
|
2013-10-07 17:48:11 -04:00
|
|
|
updateCategoryOrders();
|
2014-02-25 17:07:27 -05:00
|
|
|
},
|
|
|
|
|
distance: 10
|
2013-10-07 17:48:11 -04:00
|
|
|
});
|
2014-03-13 18:11:37 -04:00
|
|
|
|
|
|
|
|
$('.blockclass, .admin-categories form select').each(function() {
|
2014-02-26 21:55:29 -05:00
|
|
|
var $this = $(this);
|
|
|
|
|
$this.val($this.attr('data-value'));
|
2013-06-24 17:25:16 -04:00
|
|
|
});
|
2013-08-08 12:49:01 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
function showCreateCategoryModal() {
|
|
|
|
|
$('#new-category-modal').modal();
|
|
|
|
|
}
|
2013-08-08 12:49:01 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
function createNewCategory() {
|
|
|
|
|
var category = {
|
|
|
|
|
name: $('#inputName').val(),
|
|
|
|
|
description: $('#inputDescription').val(),
|
2014-02-19 15:33:59 -05:00
|
|
|
icon: $('#new-category-modal i').attr('value'),
|
2013-11-26 15:14:12 -05:00
|
|
|
bgColor: '#0059b2',
|
2013-12-08 14:15:03 -05:00
|
|
|
color: '#fff',
|
|
|
|
|
order: $('.admin-categories #entry-container').children().length + 1
|
2013-10-03 15:04:25 -04:00
|
|
|
};
|
|
|
|
|
|
2014-01-16 15:10:37 -05:00
|
|
|
socket.emit('admin.categories.create', category, function(err, data) {
|
2014-01-17 12:42:19 -05:00
|
|
|
if(err) {
|
|
|
|
|
return app.alertError(err.message);
|
2013-10-03 15:04:25 -04:00
|
|
|
}
|
2014-01-17 12:42:19 -05:00
|
|
|
|
|
|
|
|
app.alert({
|
|
|
|
|
alert_id: 'category_created',
|
|
|
|
|
title: 'Created',
|
|
|
|
|
message: 'Category successfully created!',
|
|
|
|
|
type: 'success',
|
|
|
|
|
timeout: 2000
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-28 13:29:51 -04:00
|
|
|
ajaxify.loadTemplate('admin/categories', function(adminCategories) {
|
|
|
|
|
var html = $(templates.parse(templates.getBlock(adminCategories, 'categories'), {categories: [data]}));
|
2014-04-12 17:36:48 -04:00
|
|
|
|
2014-03-09 22:35:09 -04:00
|
|
|
html.find('[data-name="bgColor"], [data-name="color"]').each(enableColorPicker);
|
|
|
|
|
|
|
|
|
|
$('#entry-container').append(html);
|
|
|
|
|
$('#new-category-modal').modal('hide');
|
2014-01-17 12:42:19 -05:00
|
|
|
});
|
2014-02-19 15:33:59 -05:00
|
|
|
});
|
|
|
|
|
}
|
2014-01-17 12:42:19 -05:00
|
|
|
|
2014-02-19 15:33:59 -05:00
|
|
|
function enableColorPicker(idx, inputEl) {
|
2014-05-14 18:46:11 -04:00
|
|
|
var $inputEl = $(inputEl),
|
2014-02-26 21:55:29 -05:00
|
|
|
previewEl = $inputEl.parents('[data-cid]').find('.preview-box');
|
2014-02-19 15:33:59 -05:00
|
|
|
|
2014-05-14 18:46:11 -04:00
|
|
|
admin.enableColorPicker($inputEl, function(hsb, hex) {
|
|
|
|
|
if ($inputEl.attr('data-name') === 'bgColor') {
|
|
|
|
|
previewEl.css('background', '#' + hex);
|
|
|
|
|
} else if ($inputEl.attr('data-name') === 'color') {
|
|
|
|
|
previewEl.css('color', '#' + hex);
|
2014-02-19 15:33:59 -05:00
|
|
|
}
|
2014-05-14 18:46:11 -04:00
|
|
|
|
|
|
|
|
modified($inputEl[0]);
|
2013-10-03 15:04:25 -04:00
|
|
|
});
|
|
|
|
|
}
|
2013-08-08 12:49:01 -04:00
|
|
|
|
2014-04-17 14:25:07 -04:00
|
|
|
function setupEditTargets() {
|
|
|
|
|
$('[data-edit-target]').on('click', function() {
|
|
|
|
|
var $this = $(this),
|
|
|
|
|
target = $($this.attr('data-edit-target'));
|
|
|
|
|
|
|
|
|
|
$this.addClass('hide');
|
|
|
|
|
target.removeClass('hide').on('blur', function() {
|
|
|
|
|
$this.removeClass('hide').children('span').html(this.value);
|
|
|
|
|
$(this).addClass('hide');
|
|
|
|
|
}).val($this.children('span').html());
|
|
|
|
|
|
|
|
|
|
target.focus();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-26 21:55:29 -05:00
|
|
|
$(function() {
|
2013-10-03 15:04:25 -04:00
|
|
|
var url = window.location.href,
|
|
|
|
|
parts = url.split('/'),
|
|
|
|
|
active = parts[parts.length - 1];
|
|
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
$('.nav-pills li').removeClass('active');
|
|
|
|
|
$('.nav-pills li a').each(function() {
|
2014-02-26 21:55:29 -05:00
|
|
|
var $this = $(this);
|
|
|
|
|
if ($this.attr('href').match(active)) {
|
|
|
|
|
$this.parent().addClass('active');
|
2013-10-03 15:04:25 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-02-11 19:44:11 -05:00
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
$('#addNew').on('click', showCreateCategoryModal);
|
|
|
|
|
$('#create-category-btn').on('click', createNewCategory);
|
2013-10-03 15:04:25 -04:00
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
$('#entry-container').on('click', '.icon', function(ev) {
|
2013-10-03 15:04:25 -04:00
|
|
|
select_icon($(this).find('i'));
|
|
|
|
|
});
|
|
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
$('#new-category-modal').on('click', '.icon', function(ev) {
|
2013-10-19 23:30:10 -04:00
|
|
|
select_icon($(this).find('i'));
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-13 18:11:37 -04:00
|
|
|
$('.admin-categories form input, .admin-categories form select').on('change', function(ev) {
|
2013-10-03 15:04:25 -04:00
|
|
|
modified(ev.target);
|
|
|
|
|
});
|
|
|
|
|
|
2013-11-29 12:35:36 -05:00
|
|
|
$('.dropdown').on('click', '[data-disabled]', function(ev) {
|
2014-02-26 21:55:29 -05:00
|
|
|
var btn = $(this),
|
|
|
|
|
categoryRow = btn.parents('li'),
|
|
|
|
|
cid = categoryRow.attr('data-cid'),
|
|
|
|
|
disabled = btn.attr('data-disabled') === 'false' ? '1' : '0';
|
2013-10-03 15:04:25 -04:00
|
|
|
|
|
|
|
|
categoryRow.remove();
|
|
|
|
|
modified_categories[cid] = modified_categories[cid] || {};
|
2014-03-12 16:18:48 -04:00
|
|
|
modified_categories[cid].disabled = disabled;
|
2013-10-03 15:04:25 -04:00
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2013-08-08 12:49:01 -04:00
|
|
|
|
2013-11-22 15:48:03 -05:00
|
|
|
// Colour Picker
|
2014-02-19 15:33:59 -05:00
|
|
|
$('[data-name="bgColor"], [data-name="color"]').each(enableColorPicker);
|
2013-11-27 16:23:30 -05:00
|
|
|
|
2014-02-11 19:44:11 -05:00
|
|
|
$('.admin-categories').on('click', '.save', save);
|
|
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
// Permissions modal
|
2014-01-26 17:55:51 -05:00
|
|
|
$('.admin-categories').on('click', '.permissions', function() {
|
2013-11-27 16:23:30 -05:00
|
|
|
var cid = $(this).parents('li[data-cid]').attr('data-cid');
|
|
|
|
|
Categories.launchPermissionsModal(cid);
|
|
|
|
|
});
|
2013-12-08 13:12:52 -05:00
|
|
|
|
|
|
|
|
|
2014-01-26 17:55:51 -05:00
|
|
|
$('.admin-categories').on('click', '.upload-button', function() {
|
2014-02-26 21:55:29 -05:00
|
|
|
var inputEl = $(this),
|
|
|
|
|
cid = inputEl.parents('li[data-cid]').attr('data-cid');
|
|
|
|
|
|
|
|
|
|
uploader.open(RELATIVE_PATH + '/admin/category/uploadpicture', {cid: cid}, 0, function(imageUrlOnServer) {
|
|
|
|
|
inputEl.val(imageUrlOnServer);
|
|
|
|
|
var previewBox = inputEl.parents('li[data-cid]').find('.preview-box');
|
2014-01-05 01:26:23 -05:00
|
|
|
previewBox.css('background', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')')
|
|
|
|
|
.css('background-size', 'cover');
|
2014-02-26 21:55:29 -05:00
|
|
|
modified(inputEl[0]);
|
2013-12-08 13:12:52 -05:00
|
|
|
});
|
|
|
|
|
});
|
2013-12-08 14:37:38 -05:00
|
|
|
|
2014-01-26 17:55:51 -05:00
|
|
|
$('.admin-categories').on('click', '.delete-image', function() {
|
2013-12-08 14:37:38 -05:00
|
|
|
var parent = $(this).parents('li[data-cid]'),
|
|
|
|
|
inputEl = parent.find('.upload-button'),
|
|
|
|
|
preview = parent.find('.preview-box'),
|
|
|
|
|
bgColor = parent.find('.category_bgColor').val();
|
|
|
|
|
|
2014-02-26 21:55:29 -05:00
|
|
|
inputEl.val('');
|
|
|
|
|
modified(inputEl[0]);
|
2013-12-08 14:37:38 -05:00
|
|
|
|
|
|
|
|
preview.css('background', bgColor);
|
|
|
|
|
|
2014-02-26 21:55:29 -05:00
|
|
|
$(this).addClass('hide').hide();
|
2013-12-08 14:37:38 -05:00
|
|
|
});
|
2014-04-17 14:25:07 -04:00
|
|
|
|
2014-04-17 14:39:20 -04:00
|
|
|
$('#revertChanges').on('click', function() {
|
2014-04-18 13:22:07 -04:00
|
|
|
ajaxify.refresh();
|
2014-04-17 14:39:20 -04:00
|
|
|
});
|
|
|
|
|
|
2014-04-17 14:25:07 -04:00
|
|
|
setupEditTargets();
|
2013-11-27 16:23:30 -05:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Categories.launchPermissionsModal = function(cid) {
|
|
|
|
|
var modal = $('#category-permissions-modal'),
|
|
|
|
|
searchEl = modal.find('#permission-search'),
|
2014-05-08 01:40:04 -04:00
|
|
|
resultsEl = modal.find('.search-results.users'),
|
|
|
|
|
groupsResultsEl = modal.find('.search-results.groups'),
|
2013-11-27 16:23:30 -05:00
|
|
|
searchDelay;
|
|
|
|
|
|
2014-03-11 15:56:04 -04:00
|
|
|
// Clear the search field and results
|
|
|
|
|
searchEl.val('');
|
|
|
|
|
resultsEl.html('');
|
|
|
|
|
|
2013-11-28 14:27:19 -05:00
|
|
|
searchEl.off().on('keyup', function() {
|
2013-11-27 16:23:30 -05:00
|
|
|
var searchEl = this,
|
2014-02-26 21:55:29 -05:00
|
|
|
liEl;
|
|
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
clearTimeout(searchDelay);
|
|
|
|
|
|
|
|
|
|
searchDelay = setTimeout(function() {
|
2014-01-16 15:10:37 -05:00
|
|
|
socket.emit('admin.categories.search', {
|
2014-01-16 15:00:49 -05:00
|
|
|
username: searchEl.value,
|
|
|
|
|
cid: cid
|
|
|
|
|
}, function(err, results) {
|
2014-01-17 12:42:19 -05:00
|
|
|
if(err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 01:40:04 -04:00
|
|
|
templates.parse('partials/admin/categories/users', {
|
|
|
|
|
users: results
|
|
|
|
|
}, function(html) {
|
|
|
|
|
resultsEl.html(html);
|
|
|
|
|
});
|
2013-11-27 16:23:30 -05:00
|
|
|
});
|
|
|
|
|
}, 250);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Categories.refreshPrivilegeList(cid);
|
|
|
|
|
|
2013-11-28 14:27:19 -05:00
|
|
|
resultsEl.off().on('click', '[data-priv]', function(e) {
|
2014-05-08 16:51:30 -04:00
|
|
|
var anchorEl = $(this),
|
|
|
|
|
uid = anchorEl.parents('li[data-uid]').attr('data-uid'),
|
|
|
|
|
privilege = anchorEl.attr('data-priv');
|
2013-11-27 16:23:30 -05:00
|
|
|
e.preventDefault();
|
2014-05-11 23:06:40 -04:00
|
|
|
e.stopPropagation();
|
2013-11-27 16:23:30 -05:00
|
|
|
|
2014-01-16 15:10:37 -05:00
|
|
|
socket.emit('admin.categories.setPrivilege', {
|
2014-01-16 15:00:49 -05:00
|
|
|
cid: cid,
|
|
|
|
|
uid: uid,
|
|
|
|
|
privilege: privilege,
|
2014-05-08 16:51:30 -04:00
|
|
|
set: !anchorEl.hasClass('active')
|
2014-05-15 20:49:47 -04:00
|
|
|
}, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
anchorEl.toggleClass('active', !anchorEl.hasClass('active'));
|
2013-11-27 16:23:30 -05:00
|
|
|
Categories.refreshPrivilegeList(cid);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2013-11-28 14:27:19 -05:00
|
|
|
modal.off().on('click', '.members li > img', function() {
|
2014-02-26 21:55:29 -05:00
|
|
|
searchEl.val($(this).attr('title'));
|
2013-11-27 16:23:30 -05:00
|
|
|
searchEl.keyup();
|
|
|
|
|
});
|
|
|
|
|
|
2014-01-08 21:24:43 -05:00
|
|
|
// User Groups and privileges
|
2014-01-16 15:10:37 -05:00
|
|
|
socket.emit('admin.categories.groupsList', cid, function(err, results) {
|
2014-01-17 12:42:19 -05:00
|
|
|
if(err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
2014-05-08 01:40:04 -04:00
|
|
|
|
|
|
|
|
templates.parse('partials/admin/categories/groups', {
|
|
|
|
|
groups: results
|
|
|
|
|
}, function(html) {
|
|
|
|
|
groupsResultsEl.html(html);
|
|
|
|
|
});
|
2013-12-17 20:34:21 +00:00
|
|
|
});
|
2013-12-31 03:14:22 -05:00
|
|
|
|
2014-05-08 16:51:30 -04:00
|
|
|
groupsResultsEl.off().on('click', '[data-priv]', function(e) {
|
|
|
|
|
var anchorEl = $(this),
|
|
|
|
|
name = anchorEl.parents('li[data-name]').attr('data-name'),
|
|
|
|
|
privilege = anchorEl.attr('data-priv');
|
2013-12-17 20:34:21 +00:00
|
|
|
e.preventDefault();
|
2014-05-11 23:06:40 -04:00
|
|
|
e.stopPropagation();
|
2014-02-26 21:55:29 -05:00
|
|
|
|
2014-01-16 15:13:22 -05:00
|
|
|
socket.emit('admin.categories.setGroupPrivilege', {
|
|
|
|
|
cid: cid,
|
2014-03-20 16:26:00 -04:00
|
|
|
name: name,
|
2014-01-16 15:13:22 -05:00
|
|
|
privilege: privilege,
|
2014-05-08 16:51:30 -04:00
|
|
|
set: !anchorEl.hasClass('active')
|
2014-01-16 15:13:22 -05:00
|
|
|
}, function(err) {
|
2014-01-08 21:24:43 -05:00
|
|
|
if (!err) {
|
2014-05-08 16:51:30 -04:00
|
|
|
anchorEl.toggleClass('active');
|
2014-01-08 21:24:43 -05:00
|
|
|
}
|
2013-12-17 20:34:21 +00:00
|
|
|
});
|
2014-02-26 21:55:29 -05:00
|
|
|
});
|
2013-12-17 20:34:21 +00:00
|
|
|
|
2013-11-27 16:23:30 -05:00
|
|
|
modal.modal();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Categories.refreshPrivilegeList = function (cid) {
|
|
|
|
|
var modalEl = $('#category-permissions-modal'),
|
2014-05-12 17:16:29 -04:00
|
|
|
memberList = $('.members');
|
2014-03-04 12:54:25 -05:00
|
|
|
|
2014-01-16 15:10:37 -05:00
|
|
|
socket.emit('admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
|
2014-05-12 17:16:29 -04:00
|
|
|
var membersLength = privilegeList.length,
|
2014-02-26 21:55:29 -05:00
|
|
|
liEl, x, userObj;
|
2013-11-27 16:23:30 -05:00
|
|
|
|
2014-05-12 17:16:29 -04:00
|
|
|
memberList.html('');
|
|
|
|
|
if (membersLength > 0) {
|
|
|
|
|
for(x = 0; x < membersLength; x++) {
|
|
|
|
|
userObj = privilegeList[x];
|
2014-02-26 21:55:29 -05:00
|
|
|
liEl = $('<li/>').attr('data-uid', userObj.uid).html('<img src="' + userObj.picture + '" title="' + userObj.username + '" />');
|
2014-05-12 17:16:29 -04:00
|
|
|
memberList.append(liEl);
|
2013-11-28 17:50:40 -05:00
|
|
|
}
|
|
|
|
|
} else {
|
2014-05-13 17:58:01 -04:00
|
|
|
liEl = $('<li/>').addClass('empty').html('None.');
|
2014-05-12 17:16:29 -04:00
|
|
|
memberList.append(liEl);
|
2014-02-07 12:47:19 -05:00
|
|
|
}
|
2013-08-08 12:49:01 -04:00
|
|
|
});
|
2013-10-03 15:04:25 -04:00
|
|
|
};
|
2013-08-08 12:49:01 -04:00
|
|
|
|
2013-10-03 15:04:25 -04:00
|
|
|
return Categories;
|
2014-04-15 02:48:34 -04:00
|
|
|
});
|