forked from green-arrow/ember-cli-chosen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
44 lines (36 loc) · 1.33 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
/* jshint node: true */
'use strict';
var pickFiles = require('broccoli-static-compiler');
var merge = require('lodash.merge');
module.exports = {
name: 'ember-cli-chosen',
included: function(app) {
if (typeof FastBoot === 'undefined') {
this._super.included(app);
// Setup default options for ember-cli-chosen
var options = merge({
'jQuery': true,
'importChosenCSS': true
}, app.options['ember-cli-chosen'] || {});
options.chosenJSType = options.jQuery ? 'jquery' : 'proto';
// Update `ember-cli-chosen` options on our `app` with updated hash
app.options['ember-cli-chosen'] = options;
// Import the correct JS for chosen
app.import(app.bowerDirectory + '/chosen/chosen.' + options.chosenJSType + '.js');
// Import Chosen CSS (done by default)
if(options.importChosenCSS) { app.import(app.bowerDirectory + '/chosen/chosen.css'); }
}
},
treeForPublic: function(treeName) {
var tree;
// Only include the Chosen sprites if we're including Chosen CSS in the build
if(typeof FastBoot === 'undefined' && this.app.options['ember-cli-chosen'].importChosenCSS) {
tree = pickFiles(this.app.bowerDirectory + '/chosen', {
srcDir: '/',
files: ['*.png'],
destDir: '/assets'
});
}
return tree;
}
};