Node.js based forum software built for the modern web
if bgColor and color are not sent in the category creation call, automatic colours are supplied
Julian Lame8167a80a0dc
diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.jsindex a9cf3b60e8..52d13874ab 100644--- a/public/src/admin/manage/categories.js+++ b/public/src/admin/manage/categories.js@@ -75,8 +75,6 @@ define('admin/manage/categories', [name: $('#inputName').val(),description: $('#inputDescription').val(),icon: $('#new-category-modal i').attr('value'),- bgColor: '#0059b2',- color: '#fff',order: $('.admin-categories #entry-container').children().length + 1};diff --git a/src/categories/create.js b/src/categories/create.jsindex a8bfaeb6fc..ce293d1c42 100644--- a/src/categories/create.js+++ b/src/categories/create.js@@ -14,15 +14,16 @@ module.exports = function(Categories) {}var slug = cid + '/' + utils.slugify(data.name),- order = data.order || cid; // If no order provided, place it at the end+ order = data.order || cid, // If no order provided, place it at the end+ colours = Categories.assignColours();var category = {cid: cid,name: data.name,description: data.description,icon: data.icon,- bgColor: data.bgColor,- color: data.color,+ bgColor: data.bgColor || colours[0],+ color: data.color || colours[1],slug: slug,parentCid: 0,topic_count: 0,@@ -52,4 +53,12 @@ module.exports = function(Categories) {});});};++ Categories.assignColours = function() {+ var backgrounds = ['#AB4642', '#DC9656', '#F7CA88', '#A1B56C', '#86C1B9', '#7CAFC2', '#BA8BAF', '#A16946'],+ text = ['#fff', '#fff', '#333', '#fff', '#333', '#fff', '#fff', '#fff'],+ index = Math.floor(Math.random() * backgrounds.length);++ return [backgrounds[index], text[index]];+ };};