Skip to content

Commit

Permalink
added help block to category purge button, updated iconSelect library…
Browse files Browse the repository at this point in the history
… to use templates in a better way, hooked up iconSelect for category mgmt, #2463
  • Loading branch information
julianlam committed Mar 25, 2015
1 parent 202789f commit d95f5a9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
1 change: 1 addition & 0 deletions public/less/admin/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
}

.category-preview {
.pointer;
width: 100%;
height: 100px;
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion public/src/admin/manage/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

define('admin/manage/category', [
'uploader',
'admin/modules/iconSelect',
'iconSelect',
'admin/modules/colorpicker',
'autocomplete'
], function(uploader, iconSelect, colorpicker, autocomplete) {
Expand Down
53 changes: 31 additions & 22 deletions public/src/modules/iconSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,38 @@ define('iconSelect', function() {
$('#icons .fa-icons .fa.' + selected).addClass('selected');
}

bootbox.confirm('<h2>Select an icon.</h2>' + $('#icons').html(), function(confirm) {
if (confirm) {
var iconClass = $('.bootbox .selected').attr('class');
var categoryIconClass = $('<div/>').addClass(iconClass).removeClass('fa').removeClass('selected').attr('class');
if (categoryIconClass === 'fa-doesnt-exist') {
categoryIconClass = '';
}

el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : '') + categoryIconClass);
el.val(categoryIconClass);
el.attr('value', categoryIconClass);

console.log(el);
onModified(el);
}
});

setTimeout(function() {
$('.bootbox .fa-icons i').on('click', function() {
$('.bootbox .selected').removeClass('selected');
$(this).addClass('selected');
templates.parse('partials/fontawesome', {}, function(html) {
var picker = bootbox.dialog({
message: html,
title: 'Select an Icon',
buttons: {
success: {
label: 'Save',
callback: function(confirm) {
var iconClass = $('.bootbox .selected').attr('class');
var categoryIconClass = $('<div/>').addClass(iconClass).removeClass('fa').removeClass('selected').attr('class');
if (categoryIconClass === 'fa-doesnt-exist') {
categoryIconClass = '';
}

el.attr('class', 'fa ' + (doubleSize ? 'fa-2x ' : '') + categoryIconClass);
el.val(categoryIconClass);
el.attr('value', categoryIconClass);

onModified(el);
}
}
}
});

picker.on('shown.bs.modal', function() {
var modalEl = $(this);
modalEl.find('.icon-container').on('click', 'i', function() {
modalEl.find('.icon-container i').removeClass('selected');
$(this).addClass('selected');
});
});
}, 500);
});
};

return iconSelect;
Expand Down
4 changes: 4 additions & 0 deletions src/views/admin/manage/category.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
</div>
<hr />
<button class="btn btn-danger btn-block btn-xs purge"><i class="fa fa-eraser"></i> Purge Category</button>
<p class="help-block">
Purging a category will remove all topics and posts, and delete the category from the database. If you want to
remove a category <em>temporarily</em>, you'll want to "disable" the category instead.
</p>
</div>
</div>
</div>
Expand Down

0 comments on commit d95f5a9

Please sign in to comment.