-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (69 loc) · 2.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const path = require("path");
const _ = require("lodash");
const fs = require("fs");
module.exports = {
name : 'shooting-star',
alias : 'shootingStar',
beforeConstruct : function(self,options){
options.star = _.defaults(options.star , {
total : 5,
size: "",
highlightColor: "#FFD700",
hoverColor: "#FFED85",
color: "#ddd",
tooltip : []
})
options.stylesheets = _.defaults(options.stylesheets , {
files : [],
acceptFiles : []
})
options.scripts = _.defaults(options.scripts , {
files : [],
acceptFiles : []
})
var originalTooltip = [
{
rate: "low",
value: "Low - $ Star"
}, {
rate: "medium",
value: "Medium - $ Star"
}, {
rate: "high",
value: "High - $ Star"
}
];
var userTooltip = options.star.tooltip;
options.star.tooltip = _.values(_.merge(_.keyBy(originalTooltip , "rate"), _.keyBy(userTooltip , "rate")));
options.pathLib = __dirname + "/lib";
options.scripts.files = [
{
name : 'user',
when : 'user'
}
].concat(options.scripts.files || []);
options.stylesheets.acceptFiles = [
"css" ,
"min.css" ,
"less"]
.concat(options.stylesheets.acceptFiles || []);
options.scripts.acceptFiles = [
"js" ,
"min.js"]
.concat(options.scripts.acceptFiles || []);
},
afterConstruct : function(self){
self.addFieldRatingType();
self.pushAssets();
self.pushCreateSingleton();
},
construct: function(self, options) {
self.pathLib = options.pathLib;
self.name = options.name;
self.star = options.star;
// Read Lib files
fs.readdirSync(self.pathLib).filter((file)=>{
require(path.resolve(self.pathLib , file))(self,options);
})
}
};