mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 03:01:08 +01:00
save
This commit is contained in:
@@ -13,15 +13,16 @@ module.exports = function(Categories) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var slug = data.slug ? cid + '/' + data.slug : cid + '/' + utils.slugify(data.name),
|
||||
order = data.order || cid; // If no order provided, place it at the end
|
||||
var slug = cid + '/' + utils.slugify(data.name),
|
||||
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 ? data.description : '' ),
|
||||
icon: ( data.icon ? data.icon : '' ),
|
||||
bgColor: data.bgColor,
|
||||
bgColor: data.bgColor || colours[0],
|
||||
color: ( data.color ? data.color : '' ),
|
||||
slug: slug,
|
||||
parentCid: ( data.parentCid ? data.parentCid : 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]];
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user