This commit is contained in:
Сергей Савельев
2015-03-16 16:47:45 +03:00
135 changed files with 1417 additions and 758 deletions

View File

@@ -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]];
};
};