From d95f5a9ae0006f4eb100d464322456f4d37232ed Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 25 Mar 2015 19:29:24 -0400 Subject: [PATCH] added help block to category purge button, updated iconSelect library to use templates in a better way, hooked up iconSelect for category mgmt, #2463 --- public/less/admin/admin.less | 1 + public/src/admin/manage/category.js | 2 +- public/src/modules/iconSelect.js | 53 +++++++++++++++++------------ src/views/admin/manage/category.tpl | 4 +++ 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/public/less/admin/admin.less b/public/less/admin/admin.less index 61462cef49..6d4dce3e43 100644 --- a/public/less/admin/admin.less +++ b/public/less/admin/admin.less @@ -308,6 +308,7 @@ } .category-preview { + .pointer; width: 100%; height: 100px; text-align: center; diff --git a/public/src/admin/manage/category.js b/public/src/admin/manage/category.js index 81db954432..e969b6e6d2 100644 --- a/public/src/admin/manage/category.js +++ b/public/src/admin/manage/category.js @@ -3,7 +3,7 @@ define('admin/manage/category', [ 'uploader', - 'admin/modules/iconSelect', + 'iconSelect', 'admin/modules/colorpicker', 'autocomplete' ], function(uploader, iconSelect, colorpicker, autocomplete) { diff --git a/public/src/modules/iconSelect.js b/public/src/modules/iconSelect.js index 6871948a6e..5dea30c189 100644 --- a/public/src/modules/iconSelect.js +++ b/public/src/modules/iconSelect.js @@ -19,29 +19,38 @@ define('iconSelect', function() { $('#icons .fa-icons .fa.' + selected).addClass('selected'); } - bootbox.confirm('

Select an icon.

' + $('#icons').html(), function(confirm) { - if (confirm) { - var iconClass = $('.bootbox .selected').attr('class'); - var categoryIconClass = $('
').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 = $('
').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; diff --git a/src/views/admin/manage/category.tpl b/src/views/admin/manage/category.tpl index 4b3b01c66f..3b5cd4df0c 100644 --- a/src/views/admin/manage/category.tpl +++ b/src/views/admin/manage/category.tpl @@ -133,6 +133,10 @@

+

+ Purging a category will remove all topics and posts, and delete the category from the database. If you want to + remove a category temporarily, you'll want to "disable" the category instead. +