define(['uploader'], function(uploader) {
var Categories = {};
Categories.init = function() {
var modified_categories = {};
function modified(el) {
var cid = $(el).parents('li').attr('data-cid');
if(cid) {
modified_categories[cid] = modified_categories[cid] || {};
modified_categories[cid][$(el).attr('data-name')] = $(el).val();
}
}
function save() {
if(Object.keys(modified_categories).length) {
socket.emit('admin.categories.update', modified_categories);
modified_categories = {};
}
return false;
}
function select_icon(el) {
var selected = el.attr('class').replace(' fa-2x', '');
$('#icons .selected').removeClass('selected');
if (selected)
$('#icons .' + selected).parent().addClass('selected');
bootbox.confirm('
Select an icon.
' + document.getElementById('icons').innerHTML, function(confirm) {
if (confirm) {
var iconClass = $('.bootbox .selected').children(':first').attr('class');
el.attr('class', iconClass + ' fa-2x');
// remove the 'fa ' from the class name, just need the icon name itself
var categoryIconClass = iconClass.replace('fa ', '');
el.val(categoryIconClass);
el.attr('value', categoryIconClass);
modified(el);
}
});
setTimeout(function() { //bootbox was rewritten for BS3 and I had to add this timeout for the previous code to work. TODO: to look into
$('.bootbox .col-md-3').on('click', function() {
$('.bootbox .selected').removeClass('selected');
$(this).addClass('selected');
});
}, 500);
}
function update_blockclass(el) {
el.parentNode.parentNode.className = 'entry-row ' + el.value;
}
function updateCategoryOrders() {
var categories = $('.admin-categories #entry-container').children();
for(var i = 0; i')
.attr('data-uid', resultObj.uid)
.html('