This repository has been archived by the owner on Oct 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.js
113 lines (95 loc) · 3.42 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
/* eslint-env node */
'use strict';
const path = require('path');
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const map = require('broccoli-stew').map;
const defaultOptions = {
importTooltipsterDefaultStyles: true,
importTooltipsterBorderless: false,
importTooltipsterLight: false,
importTooltipsterNoir: false,
importTooltipsterPunk: false,
importTooltipsterShadow: false
};
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 = Object.assign(defaultOptions, app.options['ember-cli-tooltipster']);
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(tooltipsterPath, '..', 'css');
var tooltipsterThemePath = path.join(tooltipsterPath, '..', 'css', 'plugins', 'tooltipster', 'sideTip', 'themes');
if (vendorTree) {
trees.push(vendorTree);
}
let tooltipsterTree = new Funnel(tooltipsterPath, {
destDir: 'tooltipster',
files: ['tooltipster.bundle.js']
});
tooltipsterTree = map(tooltipsterTree, content => `if (typeof FastBoot === 'undefined') { ${content} }`);
trees.push(tooltipsterTree);
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);
}
};