forked from altrim/ember-cli-tooltipster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
112 lines (95 loc) · 3.39 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
/* jshint node: true */
'use strict';
var path = require('path');
var util = require('util');
var extend = util._extend;
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var defaultOptions = {
importTooltipsterDefaultStyles: true,
importTooltipsterBorderless: false,
importTooltipsterLight: false,
importTooltipsterNoir: false,
importTooltipsterPunk: false,
importTooltipsterShadow: false
};
function isFastBoot() {
return process.env.EMBER_CLI_FASTBOOT === 'true';
}
module.exports = {
name: 'ember-cli-tooltipster',
included: function (app) {
this._super.included.apply(this, arguments);
// see: https://github.com/ember-cli/ember-cli/issues/3718
while (typeof app.import !== 'function' && app.app) {
app = app.app;
}
this.app = app;
this.tooltipsterOptions = extend(defaultOptions, app.options['ember-cli-tooltipster']);
if (!isFastBoot()) {
this.importDependencies(app);
}
return app;
},
importDependencies(app) {
app.import('vendor/tooltipster/tooltipster.bundle.js');
if (this.tooltipsterOptions.importTooltipsterDefaultStyles) {
app.import('vendor/tooltipster/tooltipster.bundle.css');
}
if (this.tooltipsterOptions.importTooltipsterBorderless) {
app.import('vendor/tooltipster/tooltipster-sideTip-borderless.min.css');
}
if (this.tooltipsterOptions.importTooltipsterLight) {
app.import('vendor/tooltipster/tooltipster-sideTip-light.min.css');
}
if (this.tooltipsterOptions.importTooltipsterNoir) {
app.import('vendor/tooltipster/tooltipster-sideTip-noir.min.css');
}
if (this.tooltipsterOptions.importTooltipsterPunk) {
app.import('vendor/tooltipster/tooltipster-sideTip-punk.min.css');
}
if (this.tooltipsterOptions.importTooltipsterShadow) {
app.import('vendor/tooltipster/tooltipster-sideTip-shadow.min.css');
}
},
treeForVendor(vendorTree) {
var trees = [];
var themes = [];
var tooltipsterPath = path.dirname(require.resolve('tooltipster'));
var tooltipsterCssPath = path.join(this.project.root, 'node_modules', 'tooltipster/dist/css');
var tooltipsterThemePath = path.join(this.project.root, 'node_modules', 'tooltipster/dist/css/plugins/tooltipster/sideTip/themes/');
if (vendorTree) {
trees.push(vendorTree);
}
trees.push(new Funnel(tooltipsterPath, {
destDir: 'tooltipster',
files: ['tooltipster.bundle.js']
}));
if (this.tooltipsterOptions.importTooltipsterDefaultStyles) {
trees.push(new Funnel(tooltipsterCssPath, {
destDir: 'tooltipster',
files: ['tooltipster.bundle.css']
}));
}
if (this.tooltipsterOptions.importTooltipsterBorderless) {
themes.push('tooltipster-sideTip-borderless.min.css');
}
if (this.tooltipsterOptions.importTooltipsterLight) {
themes.push('tooltipster-sideTip-light.min.css');
}
if (this.tooltipsterOptions.importTooltipsterNoir) {
themes.push('tooltipster-sideTip-noir.min.css');
}
if (this.tooltipsterOptions.importTooltipsterPunk) {
themes.push('tooltipster-sideTip-punk.min.css');
}
if (this.tooltipsterOptions.importTooltipsterShadow) {
themes.push('tooltipster-sideTip-shadow.min.css');
}
trees.push(new Funnel(tooltipsterThemePath, {
destDir: 'tooltipster',
files: themes
}));
return mergeTrees(trees);
},
};