forked from huxinghai/ember-adminlte-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
137 lines (124 loc) · 4.25 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* jshint node: true */
'use strict';
var path = require('path'),
Funnel = require('broccoli-funnel'),
BroccoliMergeTrees = require('broccoli-merge-trees'),
util = require('util');
module.exports = {
name: 'ember-adminlte-theme',
getExamplePath: "pub/example",
default_options: {
plugins: ["slimscroll", "fastclick"]
},
treeForPublic: function(tree){
var trees = [tree]
trees.push(new Funnel("public/", {
srcDir: "/",
exclude: ['**/.DS_Store','**/*.md'],
destDir: "/"
}))
if(this.getEnv() == "development"){
trees.push(new Funnel(this.rootPath +"/vendor/", {
srcDir: "example",
destDir: "example"
}))
trees.push(new Funnel(this.rootPath +"/vendor/", {
srcDir: "plugins",
destDir: "plugins"
}))
}
return BroccoliMergeTrees(trees, {overwrite: true });
},
included: function(app){
var self = this;
if (typeof app.import !== 'function' && app.app) {
app = app.app;
}
this.nodeModulePath = app.options.project.nodeModulesPath
this.rootPath = this.nodeModulePath + "/"+ this.name
this.app = app
this.options = this.objMerge({}, this.default_options)
if(app.options.adminLTE){
this.options = this.objMerge(this.options, app.options.adminLTE)
if(app.options.adminLTE.plugins){
this.options.plugins = this.getUnique(this.default_options.plugins.concat(app.options.adminLTE.plugins))
}
}
app.import('vendor/bootstrap/css/bootstrap.css');
app.import('vendor/css/AdminLTE.css');
app.import('vendor/css/_all-skins.min.css');
app.import('vendor/css/font-awesome.css');
app.import('vendor/bootstrap/js/bootstrap.js');
app.import("vendor/bootstrap/fonts/glyphicons-halflings-regular.eot", {destDir: 'fonts'})
app.import("vendor/bootstrap/fonts/glyphicons-halflings-regular.svg", {destDir: 'fonts'})
app.import("vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf", {destDir: 'fonts'})
app.import("vendor/bootstrap/fonts/glyphicons-halflings-regular.woff", {destDir: 'fonts'})
app.import("vendor/bootstrap/fonts/glyphicons-halflings-regular.woff2", {destDir: 'fonts'})
this.options.plugins.forEach(function(plugin){
self.loadCssPath(plugin)
self.loadJSPath(plugin)
})
app.import('vendor/js/app.js');
},
getEnv: function () {
return process.env.EMBER_ENV
},
logger: function(message){
console.log('['+ this.name +' HANDLING] '+ message)
},
cssPluginsPaths: {
"datepicker": "datepicker/datepicker3.css",
"select2": "select2/select2.css",
"icheck": "iCheck/all.css",
"morris": "morris/morris.css",
"bootstrap-wysihtml5": "bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css",
"daterangepicker": "daterangepicker/daterangepicker-bs3.css",
"jvectormap": "jvectormap/jquery-jvectormap-1.2.2.css"
},
jsPluginsPaths: {
"slimscroll": "slimScroll/jquery.slimscroll.min.js",
"fastclick": "fastclick/fastclick.min.js",
"jquery": "jQuery/jQuery-2.1.4.min.js",
"input-mask": "input-mask/jquery.inputmask.js",
"select2": ["select2/select2.full.min.js", "select2/i18n/zh-CN.js"],
"datepicker": ["datepicker/bootstrap-datepicker.js", "datepicker/locales/bootstrap-datepicker.zh-CN.js"],
"icheck": "iCheck/icheck.min.js",
"morris": "morris/morris.min.js",
"bootstrap-wysihtml5": "bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js",
"daterangepicker": "daterangepicker/daterangepicker.js",
"jvectormap": "jvectormap/jquery-jvectormap-1.2.2.min.js"
},
getUnique: function(items){
var u = {}, a = [];
for(var i = 0, l = items.length; i < l; ++i){
if(u.hasOwnProperty(items[i])) {
continue;
}
a.push(items[i]);
u[items[i]] = 1;
}
return a;
},
objMerge: function(data, items){
for(var k in items){
data[k] = items[k]
}
return data;
},
loadJSPath: function(plugin){
var jsPath = this.jsPluginsPaths[plugin]
this.loadFilePath(jsPath)
},
loadCssPath: function(plugin){
var cssPath = this.cssPluginsPaths[plugin]
this.loadFilePath(cssPath)
},
loadFilePath: function(path){
var self = this;
if(path){
[].concat(path).forEach(function(p){
self.app.import("vendor/plugins/"+ p)
})
}
}
};