|
|
|
@ -19,14 +19,14 @@ define(function() {
|
|
|
|
|
|
|
|
|
|
function select_icon(el) {
|
|
|
|
|
var selected = el.attr('class').replace(' fa-2x', '');
|
|
|
|
|
jQuery('#icons .selected').removeClass('selected');
|
|
|
|
|
$('#icons .selected').removeClass('selected');
|
|
|
|
|
if (selected)
|
|
|
|
|
jQuery('#icons .' + selected).parent().addClass('selected');
|
|
|
|
|
$('#icons .' + selected).parent().addClass('selected');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bootbox.confirm('<h2>Select an icon.</h2>' + document.getElementById('icons').innerHTML, function(confirm) {
|
|
|
|
|
if (confirm) {
|
|
|
|
|
var iconClass = jQuery('.bootbox .selected').children(':first').attr('class');
|
|
|
|
|
var iconClass = $('.bootbox .selected').children(':first').attr('class');
|
|
|
|
|
|
|
|
|
|
el.attr('class', iconClass + ' fa-2x');
|
|
|
|
|
|
|
|
|
@ -40,9 +40,9 @@ define(function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setTimeout(function() { //bootbox was rewritten for BS3 and I had to add this timeout for the previous code to work. TODO: to look into
|
|
|
|
|
jQuery('.bootbox .col-md-3').on('click', function() {
|
|
|
|
|
jQuery('.bootbox .selected').removeClass('selected');
|
|
|
|
|
jQuery(this).addClass('selected');
|
|
|
|
|
$('.bootbox .col-md-3').on('click', function() {
|
|
|
|
|
$('.bootbox .selected').removeClass('selected');
|
|
|
|
|
$(this).addClass('selected');
|
|
|
|
|
});
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
|
|
|
@ -62,13 +62,13 @@ define(function() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jQuery('#entry-container').sortable({
|
|
|
|
|
$('#entry-container').sortable({
|
|
|
|
|
stop: function( event, ui ) {
|
|
|
|
|
updateCategoryOrders();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
jQuery('.blockclass').each(function() {
|
|
|
|
|
jQuery(this).val(this.getAttribute('data-value'));
|
|
|
|
|
$('.blockclass').each(function() {
|
|
|
|
|
$(this).val(this.getAttribute('data-value'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -105,46 +105,46 @@ define(function() {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jQuery('document').ready(function() {
|
|
|
|
|
$('document').ready(function() {
|
|
|
|
|
var url = window.location.href,
|
|
|
|
|
parts = url.split('/'),
|
|
|
|
|
active = parts[parts.length - 1];
|
|
|
|
|
|
|
|
|
|
jQuery('.nav-pills li').removeClass('active');
|
|
|
|
|
jQuery('.nav-pills li a').each(function() {
|
|
|
|
|
$('.nav-pills li').removeClass('active');
|
|
|
|
|
$('.nav-pills li a').each(function() {
|
|
|
|
|
if (this.getAttribute('href').match(active)) {
|
|
|
|
|
jQuery(this.parentNode).addClass('active');
|
|
|
|
|
$(this.parentNode).addClass('active');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery('#save').on('click', save);
|
|
|
|
|
jQuery('#addNew').on('click', showCreateCategoryModal);
|
|
|
|
|
jQuery('#create-category-btn').on('click', createNewCategory);
|
|
|
|
|
$('#save').on('click', save);
|
|
|
|
|
$('#addNew').on('click', showCreateCategoryModal);
|
|
|
|
|
$('#create-category-btn').on('click', createNewCategory);
|
|
|
|
|
|
|
|
|
|
jQuery('#entry-container').on('click', '.icon', function(ev) {
|
|
|
|
|
$('#entry-container').on('click', '.icon', function(ev) {
|
|
|
|
|
select_icon($(this).find('i'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery('#new-category-modal').on('click', '.icon', function(ev) {
|
|
|
|
|
$('#new-category-modal').on('click', '.icon', function(ev) {
|
|
|
|
|
select_icon($(this).find('i'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery('.admin-categories form input').on('change', function(ev) {
|
|
|
|
|
$('.admin-categories form input').on('change', function(ev) {
|
|
|
|
|
modified(ev.target);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery('.entry-row button').each(function(index, element) {
|
|
|
|
|
$('.entry-row button[data-disabled]').each(function(index, element) {
|
|
|
|
|
var disabled = $(element).attr('data-disabled');
|
|
|
|
|
if (disabled == "0" || disabled == "")
|
|
|
|
|
if (disabled == "0" || disabled == "") {
|
|
|
|
|
$(element).html('Disable');
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
$(element).html('Enable');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery('#entry-container').on('click', '.disable-btn', function(ev) {
|
|
|
|
|
var btn = jQuery(this);
|
|
|
|
|
$('#entry-container').on('click', '.disable-btn', function(ev) {
|
|
|
|
|
var btn = $(this);
|
|
|
|
|
var categoryRow = btn.parents('li');
|
|
|
|
|
var cid = categoryRow.attr('data-cid');
|
|
|
|
|
|
|
|
|
@ -172,6 +172,105 @@ define(function() {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Permissions modal
|
|
|
|
|
$('.permissions').on('click', function() {
|
|
|
|
|
var cid = $(this).parents('li[data-cid]').attr('data-cid');
|
|
|
|
|
Categories.launchPermissionsModal(cid);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Categories.launchPermissionsModal = function(cid) {
|
|
|
|
|
var modal = $('#category-permissions-modal'),
|
|
|
|
|
searchEl = modal.find('#permission-search'),
|
|
|
|
|
resultsEl = modal.find('.search-results'),
|
|
|
|
|
searchDelay;
|
|
|
|
|
|
|
|
|
|
searchEl.off('keyup').on('keyup', function() {
|
|
|
|
|
var searchEl = this,
|
|
|
|
|
resultsFrag = document.createDocumentFragment(),
|
|
|
|
|
liEl = document.createElement('li');
|
|
|
|
|
clearTimeout(searchDelay);
|
|
|
|
|
|
|
|
|
|
searchDelay = setTimeout(function() {
|
|
|
|
|
socket.emit('api:admin.categories.search', searchEl.value, cid, function(err, results) {
|
|
|
|
|
var numResults = results.length,
|
|
|
|
|
resultObj;
|
|
|
|
|
for(var x=0;x<numResults;x++) {
|
|
|
|
|
resultObj = results[x];
|
|
|
|
|
|
|
|
|
|
liEl.setAttribute('data-uid', resultObj.uid);
|
|
|
|
|
liEl.innerHTML = '<div class="pull-right">' +
|
|
|
|
|
'<div class="btn-group">' +
|
|
|
|
|
'<button type="button" data-priv="+r" class="btn btn-default' + (resultObj.privileges['+r'] ? ' active' : '') + '">Read</button>' +
|
|
|
|
|
'<button type="button" data-priv="+w" class="btn btn-default' + (resultObj.privileges['+w'] ? ' active' : '') + '">Write</button>' +
|
|
|
|
|
'</div>' +
|
|
|
|
|
'</div>' +
|
|
|
|
|
'<img src="' + resultObj.picture + '" /> ' + resultObj.username;
|
|
|
|
|
|
|
|
|
|
resultsFrag.appendChild(liEl.cloneNode(true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resultsEl.html(resultsFrag);
|
|
|
|
|
});
|
|
|
|
|
}, 250);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Categories.refreshPrivilegeList(cid);
|
|
|
|
|
|
|
|
|
|
resultsEl.on('click', '[data-priv]', function(e) {
|
|
|
|
|
var btnEl = $(this),
|
|
|
|
|
uid = btnEl.parents('li[data-uid]').attr('data-uid'),
|
|
|
|
|
privilege = this.getAttribute('data-priv');
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
socket.emit('api:admin.categories.setPrivilege', cid, uid, privilege, !btnEl.hasClass('active'), function(err, privileges) {
|
|
|
|
|
btnEl.toggleClass('active', privileges[privilege]);
|
|
|
|
|
|
|
|
|
|
Categories.refreshPrivilegeList(cid);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.on('click', '.members li > img', function() {
|
|
|
|
|
console.log('clicked', this);
|
|
|
|
|
searchEl.val(this.getAttribute('title'));
|
|
|
|
|
searchEl.keyup();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.modal();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Categories.refreshPrivilegeList = function (cid) {
|
|
|
|
|
var modalEl = $('#category-permissions-modal'),
|
|
|
|
|
readMembers = modalEl.find('#category-permissions-read'),
|
|
|
|
|
writeMembers = modalEl.find('#category-permissions-write');
|
|
|
|
|
socket.emit('api:admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
|
|
|
|
|
var readLength = privilegeList['+r'].members.length,
|
|
|
|
|
writeLength = privilegeList['+w'].members.length,
|
|
|
|
|
readFrag = document.createDocumentFragment(),
|
|
|
|
|
writeFrag = document.createDocumentFragment(),
|
|
|
|
|
liEl = document.createElement('li'),
|
|
|
|
|
x, userObj;
|
|
|
|
|
|
|
|
|
|
for(x=0;x<readLength;x++) {
|
|
|
|
|
userObj = privilegeList['+r'].members[x];
|
|
|
|
|
liEl.setAttribute('data-uid', userObj.uid);
|
|
|
|
|
|
|
|
|
|
liEl.innerHTML = '<img src="' + userObj.picture + '" title="' + userObj.username + '" />';
|
|
|
|
|
readFrag.appendChild(liEl.cloneNode(true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(x=0;x<writeLength;x++) {
|
|
|
|
|
userObj = privilegeList['+w'].members[x];
|
|
|
|
|
liEl.setAttribute('data-uid', userObj.uid);
|
|
|
|
|
|
|
|
|
|
liEl.innerHTML = '<img src="' + userObj.picture + '" title="' + userObj.username + '" />';
|
|
|
|
|
writeFrag.appendChild(liEl.cloneNode(true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readMembers.html(readFrag);
|
|
|
|
|
writeMembers.html(writeFrag);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|