if no icon is selected for a category icon will be empty string

This commit is contained in:
barisusakli
2014-04-12 17:36:48 -04:00
parent 29ec14efa0
commit f8a6ab5cf4
2 changed files with 22 additions and 6 deletions

View File

@@ -37,13 +37,17 @@ define(['uploader'], function(uploader) {
}
function select_icon(el) {
var selected = el.attr('class').replace(' fa-2x', '');
var selected = el.attr('class').replace('fa-2x', '').replace('fa', '').replace(/\s+/g, '');
$('#icons .selected').removeClass('selected');
if (selected === '') {
selected = 'fa-doesnt-exist';
}
if (selected) {
$('#icons .' + selected).parent().addClass('selected');
$('#icons .fa-icons .fa.' + selected).parent().addClass('selected');
}
bootbox.confirm('<h2>Select an icon.</h2>' + document.getElementById('icons').innerHTML, function(confirm) {
bootbox.confirm('<h2>Select an icon.</h2>' + $('#icons').html(), function(confirm) {
if (confirm) {
var iconClass = $('.bootbox .selected').children(':first').attr('class');
@@ -51,6 +55,9 @@ define(['uploader'], function(uploader) {
// remove the 'fa ' from the class name, just need the icon name itself
var categoryIconClass = iconClass.replace('fa ', '');
if(categoryIconClass === 'fa-doesnt-exist') {
categoryIconClass = '';
}
el.val(categoryIconClass);
el.attr('value', categoryIconClass);
@@ -122,7 +129,7 @@ define(['uploader'], function(uploader) {
ajaxify.loadTemplate('admin/categories', function(adminCategories) {
var html = $(templates.parse(templates.getBlock(adminCategories, 'categories'), {categories: [data]}));
html.find('[data-name="bgColor"], [data-name="color"]').each(enableColorPicker);
$('#entry-container').append(html);