added ability to upload category images. closes #638, closes #532

This commit is contained in:
psychobunny
2013-12-08 13:12:52 -05:00
parent 9471fd8e46
commit e76936abfc
5 changed files with 70 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
define(function() {
define(['uploader'], function(uploader) {
var Categories = {};
Categories.init = function() {
@@ -147,7 +147,6 @@ define(function() {
var btn = $(this);
var categoryRow = btn.parents('li');
var cid = categoryRow.attr('data-cid');
console.log(this.getAttribute('data-disabled'));
var disabled = this.getAttribute('data-disabled') === '0' ? '1' : '0';
categoryRow.remove();
@@ -179,6 +178,17 @@ define(function() {
var cid = $(this).parents('li[data-cid]').attr('data-cid');
Categories.launchPermissionsModal(cid);
});
$('.upload-button').on('click', function() {
var inputEl = this;
uploader.open(config.relative_path + '/admin/category/uploadpicture', function(imageUrlOnServer) {
inputEl.value = imageUrlOnServer;
$(inputEl).parents('li[data-cid]').find('.preview-box').css('background', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')');
modified(inputEl);
});
});
});
};