define(function() { 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() { socket.emit('api:admin.categories.update', modified_categories); modified_categories = {}; } function select_icon(el) { var selected = el.attr('class').replace(' icon-2x', ''); jQuery('#icons .selected').removeClass('selected'); if (selected) jQuery('#icons .' + selected).parent().addClass('selected'); bootbox.confirm('

Select an icon.

' + document.getElementById('icons').innerHTML, function(confirm) { if (confirm) { var iconClass = jQuery('.bootbox .selected').children(':first').attr('class'); el.attr('class', iconClass + ' icon-2x'); el.val(iconClass); el.attr('value', iconClass); 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 jQuery('.bootbox .col-md-3').on('click', function() { jQuery('.bootbox .selected').removeClass('selected'); jQuery(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