alchemy-media 0.6.0 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/assets/fonts/fontawesome6/fa-brands-400.ttf +0 -0
- package/assets/fonts/fontawesome6/fa-brands-400.woff2 +0 -0
- package/assets/fonts/fontawesome6/fa-regular-400.ttf +0 -0
- package/assets/fonts/fontawesome6/fa-regular-400.woff2 +0 -0
- package/assets/fonts/fontawesome6/fa-solid-900.ttf +0 -0
- package/assets/fonts/fontawesome6/fa-solid-900.woff2 +0 -0
- package/assets/fonts/fontawesome6/fa-v4compatibility.ttf +0 -0
- package/assets/fonts/fontawesome6/fa-v4compatibility.woff2 +0 -0
- package/assets/stylesheets/alchemy_icons.scss +9 -57
- package/assets/stylesheets/alchemy_icons_fafree.scss +59 -0
- package/assets/stylesheets/chimera/mediafield.less +0 -0
- package/assets/stylesheets/element/alchemy_file.scss +93 -1
- package/assets/stylesheets/fontawesome6/_animated.scss +153 -0
- package/assets/stylesheets/fontawesome6/_bordered-pulled.scss +20 -0
- package/assets/stylesheets/fontawesome6/_core.scss +33 -0
- package/assets/stylesheets/{fontawesome5.15 → fontawesome6}/_fixed-width.scss +2 -1
- package/assets/stylesheets/fontawesome6/_functions.scss +57 -0
- package/assets/stylesheets/fontawesome6/_icons.scss +9 -0
- package/assets/stylesheets/{fontawesome5.15 → fontawesome6}/_list.scss +4 -4
- package/assets/stylesheets/fontawesome6/_mixins.scss +73 -0
- package/assets/stylesheets/fontawesome6/_rotated-flipped.scss +31 -0
- package/assets/stylesheets/fontawesome6/_screen-reader.scss +14 -0
- package/assets/stylesheets/{fontawesome5.15 → fontawesome6}/_shims.scss +625 -664
- package/assets/stylesheets/fontawesome6/_sizing.scss +16 -0
- package/assets/stylesheets/{fontawesome5.15 → fontawesome6}/_stacked.scss +5 -4
- package/assets/stylesheets/fontawesome6/_variables.scss +4885 -0
- package/assets/stylesheets/fontawesome6/brands.scss +30 -0
- package/assets/stylesheets/{fontawesome5.15 → fontawesome6}/fontawesome.scss +7 -2
- package/assets/stylesheets/fontawesome6/regular.scss +26 -0
- package/assets/stylesheets/fontawesome6/solid.scss +26 -0
- package/assets/stylesheets/fontawesome6/v4-shims.scss +11 -0
- package/bootstrap.js +8 -1
- package/element/al_file.js +104 -24
- package/element/al_ico_element.js +131 -1
- package/helper/media_helper.js +19 -6
- package/lib/media_types/image_media_type.js +6 -3
- package/model/media_raw_model.js +529 -529
- package/package.json +3 -3
- package/view/element/al_file.hwk +17 -5
- package/assets/fonts/fontawesome5.15/fa-brands-400.eot +0 -0
- package/assets/fonts/fontawesome5.15/fa-brands-400.svg +0 -3717
- package/assets/fonts/fontawesome5.15/fa-brands-400.ttf +0 -0
- package/assets/fonts/fontawesome5.15/fa-brands-400.woff +0 -0
- package/assets/fonts/fontawesome5.15/fa-brands-400.woff2 +0 -0
- package/assets/fonts/fontawesome5.15/fa-regular-400.eot +0 -0
- package/assets/fonts/fontawesome5.15/fa-regular-400.svg +0 -801
- package/assets/fonts/fontawesome5.15/fa-regular-400.ttf +0 -0
- package/assets/fonts/fontawesome5.15/fa-regular-400.woff +0 -0
- package/assets/fonts/fontawesome5.15/fa-regular-400.woff2 +0 -0
- package/assets/fonts/fontawesome5.15/fa-solid-900.eot +0 -0
- package/assets/fonts/fontawesome5.15/fa-solid-900.svg +0 -5028
- package/assets/fonts/fontawesome5.15/fa-solid-900.ttf +0 -0
- package/assets/fonts/fontawesome5.15/fa-solid-900.woff +0 -0
- package/assets/fonts/fontawesome5.15/fa-solid-900.woff2 +0 -0
- package/assets/stylesheets/fontawesome5.15/_animated.scss +0 -20
- package/assets/stylesheets/fontawesome5.15/_bordered-pulled.scss +0 -20
- package/assets/stylesheets/fontawesome5.15/_core.scss +0 -21
- package/assets/stylesheets/fontawesome5.15/_icons.scss +0 -1462
- package/assets/stylesheets/fontawesome5.15/_larger.scss +0 -23
- package/assets/stylesheets/fontawesome5.15/_mixins.scss +0 -56
- package/assets/stylesheets/fontawesome5.15/_rotated-flipped.scss +0 -24
- package/assets/stylesheets/fontawesome5.15/_screen-reader.scss +0 -5
- package/assets/stylesheets/fontawesome5.15/_variables.scss +0 -1479
- package/assets/stylesheets/fontawesome5.15/brands.scss +0 -23
- package/assets/stylesheets/fontawesome5.15/regular.scss +0 -23
- package/assets/stylesheets/fontawesome5.15/solid.scss +0 -24
- package/assets/stylesheets/fontawesome5.15/v4-shims.scss +0 -6
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
|
|
3
|
+
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
4
|
+
* Copyright 2022 Fonticons, Inc.
|
|
5
|
+
*/
|
|
6
|
+
@import 'functions';
|
|
7
|
+
@import 'variables';
|
|
8
|
+
|
|
9
|
+
:root, :host {
|
|
10
|
+
--#{$fa-css-prefix}-font-brands: normal 400 1em/1 "Font Awesome 6 Brands";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@font-face {
|
|
14
|
+
font-family: 'Font Awesome 6 Brands';
|
|
15
|
+
font-style: normal;
|
|
16
|
+
font-weight: 400;
|
|
17
|
+
font-display: $fa-font-display;
|
|
18
|
+
src: url('#{$fa-font-path}/fa-brands-400.woff2') format('woff2'),
|
|
19
|
+
url('#{$fa-font-path}/fa-brands-400.ttf') format('truetype');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.fab,
|
|
23
|
+
.#{$fa-css-prefix}-brands {
|
|
24
|
+
font-family: 'Font Awesome 6 Brands';
|
|
25
|
+
font-weight: 400;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@each $name, $icon in $fa-brand-icons {
|
|
29
|
+
.#{$fa-css-prefix}-#{$name}:before { content: unquote("\"#{ $icon }\""); }
|
|
30
|
+
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Font Awesome Free
|
|
2
|
+
* Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
|
|
3
3
|
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
4
|
+
* Copyright 2022 Fonticons, Inc.
|
|
4
5
|
*/
|
|
6
|
+
// Font Awesome core compile (Web Fonts-based)
|
|
7
|
+
// -------------------------
|
|
8
|
+
|
|
9
|
+
@import 'functions';
|
|
5
10
|
@import 'variables';
|
|
6
11
|
@import 'mixins';
|
|
7
12
|
@import 'core';
|
|
8
|
-
@import '
|
|
13
|
+
@import 'sizing';
|
|
9
14
|
@import 'fixed-width';
|
|
10
15
|
@import 'list';
|
|
11
16
|
@import 'bordered-pulled';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
|
|
3
|
+
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
4
|
+
* Copyright 2022 Fonticons, Inc.
|
|
5
|
+
*/
|
|
6
|
+
@import 'functions';
|
|
7
|
+
@import 'variables';
|
|
8
|
+
|
|
9
|
+
:root, :host {
|
|
10
|
+
--#{$fa-css-prefix}-font-regular: normal 400 1em/1 "#{ $fa-style-family }";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@font-face {
|
|
14
|
+
font-family: 'Font Awesome 6 Free';
|
|
15
|
+
font-style: normal;
|
|
16
|
+
font-weight: 400;
|
|
17
|
+
font-display: $fa-font-display;
|
|
18
|
+
src: url('#{$fa-font-path}/fa-regular-400.woff2') format('woff2'),
|
|
19
|
+
url('#{$fa-font-path}/fa-regular-400.ttf') format('truetype');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.far,
|
|
23
|
+
.#{$fa-css-prefix}-regular {
|
|
24
|
+
font-family: 'Font Awesome 6 Free';
|
|
25
|
+
font-weight: 400;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
|
|
3
|
+
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
4
|
+
* Copyright 2022 Fonticons, Inc.
|
|
5
|
+
*/
|
|
6
|
+
@import 'functions';
|
|
7
|
+
@import 'variables';
|
|
8
|
+
|
|
9
|
+
:root, :host {
|
|
10
|
+
--#{$fa-css-prefix}-font-solid: normal 900 1em/1 "#{ $fa-style-family }";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@font-face {
|
|
14
|
+
font-family: 'Font Awesome 6 Free';
|
|
15
|
+
font-style: normal;
|
|
16
|
+
font-weight: 900;
|
|
17
|
+
font-display: $fa-font-display;
|
|
18
|
+
src: url('#{$fa-font-path}/fa-solid-900.woff2') format('woff2'),
|
|
19
|
+
url('#{$fa-font-path}/fa-solid-900.ttf') format('truetype');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.fas,
|
|
23
|
+
.#{$fa-css-prefix}-solid {
|
|
24
|
+
font-family: 'Font Awesome 6 Free';
|
|
25
|
+
font-weight: 900;
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
|
|
3
|
+
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
4
|
+
* Copyright 2022 Fonticons, Inc.
|
|
5
|
+
*/
|
|
6
|
+
// V4 shims compile (Web Fonts-based)
|
|
7
|
+
// -------------------------
|
|
8
|
+
|
|
9
|
+
@import 'functions';
|
|
10
|
+
@import 'variables';
|
|
11
|
+
@import 'shims';
|
package/bootstrap.js
CHANGED
|
@@ -21,7 +21,10 @@ var options = {
|
|
|
21
21
|
scratch: path.resolve(PATH_TEMP, 'scratch'),
|
|
22
22
|
|
|
23
23
|
// The cache map for resized images & thumbnails
|
|
24
|
-
cache: path.resolve(PATH_TEMP, 'imagecache')
|
|
24
|
+
cache: path.resolve(PATH_TEMP, 'imagecache'),
|
|
25
|
+
|
|
26
|
+
// Path to fontawesome pro
|
|
27
|
+
fontawesome_pro: null,
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
// Inject the user-overridden options
|
|
@@ -66,6 +69,10 @@ options.veronica = new Veronica({
|
|
|
66
69
|
|
|
67
70
|
alchemy.hawkejs.addRawHtml(`<script>document.cookie = 'mediaResolution=' + encodeURIComponent(JSON.stringify({width:Math.max(screen.availWidth||0, window.outerWidth||0) || 1024,height:Math.max(screen.availHeight||0, window.outerHeight||0) || 768,dpr:window.devicePixelRatio}))</script>`);
|
|
68
71
|
|
|
72
|
+
if (options.fontawesome_pro) {
|
|
73
|
+
alchemy.exposeStatic('fontawesome_pro', options.fontawesome_pro);
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
/**
|
|
70
77
|
* Register a profile under the given name
|
|
71
78
|
*
|
package/element/al_file.js
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
* @since 0.6.0
|
|
6
6
|
* @version 0.6.0
|
|
7
7
|
*/
|
|
8
|
-
const AlFile = Function.inherits('Alchemy.Element.App',
|
|
9
|
-
return AlFile.super.call(this);
|
|
10
|
-
});
|
|
8
|
+
const AlFile = Function.inherits('Alchemy.Element.App', 'AlFile');
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* The template code
|
|
@@ -28,13 +26,13 @@ AlFile.setTemplateFile('element/al_file');
|
|
|
28
26
|
AlFile.setStylesheetFile('element/alchemy_file');
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
|
-
* Getter for the
|
|
29
|
+
* Getter for the drop target
|
|
32
30
|
*
|
|
33
31
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
34
|
-
* @since 0.2
|
|
35
|
-
* @version 0.2
|
|
32
|
+
* @since 0.6.2
|
|
33
|
+
* @version 0.6.2
|
|
36
34
|
*/
|
|
37
|
-
AlFile.addElementGetter('
|
|
35
|
+
AlFile.addElementGetter('drop_target', '.al-file-drop-target');
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* Getter for the file input
|
|
@@ -54,14 +52,54 @@ AlFile.addElementGetter('file_input', '.al-file-input');
|
|
|
54
52
|
*/
|
|
55
53
|
AlFile.addElementGetter('preview_element', '.al-file-preview');
|
|
56
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Getter for the remove button
|
|
57
|
+
*
|
|
58
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
59
|
+
* @since 0.6.2
|
|
60
|
+
* @version 0.6.2
|
|
61
|
+
*/
|
|
62
|
+
AlFile.addElementGetter('remove_button', '.al-file-remove');
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Getter for the uploading-icon
|
|
66
|
+
*
|
|
67
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
68
|
+
* @since 0.6.2
|
|
69
|
+
* @version 0.6.2
|
|
70
|
+
*/
|
|
71
|
+
AlFile.addElementGetter('icon_uploading', '.uploading-icon');
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Getter for the empty-icon
|
|
75
|
+
*
|
|
76
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
77
|
+
* @since 0.6.2
|
|
78
|
+
* @version 0.6.2
|
|
79
|
+
*/
|
|
80
|
+
AlFile.addElementGetter('icon_empty', '.empty-icon');
|
|
81
|
+
|
|
57
82
|
/**
|
|
58
83
|
* Set the value
|
|
59
84
|
*
|
|
60
85
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
61
86
|
* @since 0.6.0
|
|
62
|
-
* @version 0.6.
|
|
87
|
+
* @version 0.6.2
|
|
63
88
|
*/
|
|
64
89
|
AlFile.setAttribute('value', null, function setValue(value) {
|
|
90
|
+
|
|
91
|
+
if (value == null) {
|
|
92
|
+
value = '';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (this.remove_button) {
|
|
96
|
+
this.remove_button.hidden = !value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.icon_empty) {
|
|
100
|
+
this.icon_empty.hidden = !!value;
|
|
101
|
+
}
|
|
102
|
+
|
|
65
103
|
this.updatePreview(value);
|
|
66
104
|
return value;
|
|
67
105
|
});
|
|
@@ -97,15 +135,15 @@ AlFile.setMethod(function updatePreview(value) {
|
|
|
97
135
|
*
|
|
98
136
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
99
137
|
* @since 0.6.0
|
|
100
|
-
* @version 0.6.
|
|
138
|
+
* @version 0.6.2
|
|
101
139
|
*/
|
|
102
140
|
AlFile.setMethod(async function uploadFile(config) {
|
|
103
141
|
|
|
104
|
-
const that = this;
|
|
105
|
-
|
|
106
142
|
let file = config.file,
|
|
107
143
|
filename = config.filename,
|
|
108
144
|
format = config.format;
|
|
145
|
+
|
|
146
|
+
this.classList.add('uploading');
|
|
109
147
|
|
|
110
148
|
let form_data = new FormData(),
|
|
111
149
|
url = this.dataset.uploadUrl;
|
|
@@ -121,10 +159,18 @@ AlFile.setMethod(async function uploadFile(config) {
|
|
|
121
159
|
form_data.append('format', format);
|
|
122
160
|
}
|
|
123
161
|
|
|
124
|
-
let response
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
162
|
+
let response;
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
response = await Blast.fetch({
|
|
166
|
+
url : url,
|
|
167
|
+
post : form_data,
|
|
168
|
+
});
|
|
169
|
+
} catch (err) {
|
|
170
|
+
console.error('Failed to upload file:', err);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this.classList.remove('uploading');
|
|
128
174
|
|
|
129
175
|
if (!response || !response.files || !response.files[0]) {
|
|
130
176
|
return;
|
|
@@ -139,32 +185,66 @@ AlFile.setMethod(async function uploadFile(config) {
|
|
|
139
185
|
});
|
|
140
186
|
|
|
141
187
|
/**
|
|
142
|
-
*
|
|
188
|
+
* Added to the DOM for the first time
|
|
143
189
|
*
|
|
144
190
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
145
191
|
* @since 0.6.0
|
|
146
|
-
* @version 0.6.
|
|
192
|
+
* @version 0.6.2
|
|
147
193
|
*/
|
|
148
194
|
AlFile.setMethod(function introduced() {
|
|
149
195
|
|
|
150
196
|
const that = this;
|
|
151
197
|
|
|
152
|
-
this.
|
|
198
|
+
this.addEventListener('dragenter', e => {
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
});
|
|
153
201
|
|
|
154
|
-
this.
|
|
202
|
+
this.addEventListener('dragover', e => {
|
|
203
|
+
this.classList.add('dropping');
|
|
155
204
|
e.preventDefault();
|
|
156
|
-
this.file_input.click();
|
|
157
205
|
});
|
|
158
206
|
|
|
159
|
-
this.
|
|
207
|
+
this.addEventListener('dragend', e => {
|
|
208
|
+
this.classList.remove('dropping');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
this.addEventListener('dragleave', e => {
|
|
212
|
+
this.classList.remove('dropping');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
this.addEventListener('drop', e => {
|
|
216
|
+
this.classList.remove('dropping');
|
|
217
|
+
this.classList.add('dropped');
|
|
160
218
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
|
|
221
|
+
let file = e.dataTransfer.files[0];
|
|
222
|
+
|
|
223
|
+
this.uploadFile({
|
|
224
|
+
file : file,
|
|
225
|
+
filename : file.name,
|
|
164
226
|
format : null,
|
|
165
227
|
});
|
|
166
228
|
});
|
|
167
229
|
|
|
230
|
+
this.updatePreview();
|
|
231
|
+
|
|
232
|
+
this.file_input.addEventListener('change', e => {
|
|
233
|
+
|
|
234
|
+
this.classList.remove('dropping');
|
|
235
|
+
this.classList.add('dropped');
|
|
236
|
+
|
|
237
|
+
this.uploadFile({
|
|
238
|
+
file : this.file_input.files[0],
|
|
239
|
+
filename : this.file_input.files[0].name,
|
|
240
|
+
format : null,
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
this.remove_button.addEventListener('click', e => {
|
|
245
|
+
this.value = null;
|
|
246
|
+
});
|
|
247
|
+
|
|
168
248
|
});
|
|
169
249
|
|
|
170
250
|
/**
|
|
@@ -14,4 +14,134 @@ const Icon = Function.inherits('Alchemy.Element', 'AlIco');
|
|
|
14
14
|
* @since 0.6.0
|
|
15
15
|
* @version 0.6.0
|
|
16
16
|
*/
|
|
17
|
-
Icon.setStylesheetFile('alchemy_icons');
|
|
17
|
+
Icon.setStylesheetFile('alchemy_icons');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The source to use
|
|
21
|
+
* (Will default to Fontawesome)
|
|
22
|
+
*
|
|
23
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
24
|
+
* @since 0.6.3
|
|
25
|
+
* @version 0.6.3
|
|
26
|
+
*/
|
|
27
|
+
Icon.setAttribute('source');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The icon-style to use
|
|
31
|
+
* (Will default to regular for fontawesome)
|
|
32
|
+
*
|
|
33
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
34
|
+
* @since 0.6.3
|
|
35
|
+
* @version 0.6.3
|
|
36
|
+
*/
|
|
37
|
+
Icon.setAttribute('icon-style');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The actual icon name to use
|
|
41
|
+
*
|
|
42
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
43
|
+
* @since 0.6.3
|
|
44
|
+
* @version 0.6.3
|
|
45
|
+
*/
|
|
46
|
+
Icon.setAttribute('icon-name');
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The element is being retained
|
|
50
|
+
*
|
|
51
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
52
|
+
* @since 0.6.3
|
|
53
|
+
* @version 0.6.3
|
|
54
|
+
*/
|
|
55
|
+
Icon.setMethod(function retained() {
|
|
56
|
+
this.setCssClasses();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The element has been introduced to the DOM for the first time
|
|
61
|
+
*
|
|
62
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
63
|
+
* @since 0.6.3
|
|
64
|
+
* @version 0.6.3
|
|
65
|
+
*/
|
|
66
|
+
Icon.setMethod(function introduced() {
|
|
67
|
+
this.setCssClasses();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Try to set the correct icon
|
|
72
|
+
*
|
|
73
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
74
|
+
* @since 0.6.3
|
|
75
|
+
* @version 0.6.3
|
|
76
|
+
*/
|
|
77
|
+
Icon.setMethod(function setIcon(info) {
|
|
78
|
+
|
|
79
|
+
if (!info) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (typeof info == 'string') {
|
|
84
|
+
info = info.split(' ');
|
|
85
|
+
|
|
86
|
+
if (info.length == 2) {
|
|
87
|
+
this.icon_style = info[0];
|
|
88
|
+
this.icon_name = info[1];
|
|
89
|
+
} else {
|
|
90
|
+
this.icon_name = info[0];
|
|
91
|
+
}
|
|
92
|
+
} else if (typeof info == 'object') {
|
|
93
|
+
let style = info.style || info.icon_style,
|
|
94
|
+
name = info.name || info.icon_name;
|
|
95
|
+
|
|
96
|
+
if (style) {
|
|
97
|
+
this.icon_style = style;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (name) {
|
|
101
|
+
this.icon_name = name;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!this.icon_style) {
|
|
106
|
+
this.icon_style = 'duotone';
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Set the CSS classes
|
|
112
|
+
*
|
|
113
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
114
|
+
* @since 0.6.3
|
|
115
|
+
* @version 0.6.3
|
|
116
|
+
*/
|
|
117
|
+
Icon.setMethod(function setCssClasses() {
|
|
118
|
+
|
|
119
|
+
if (this.source && this.source != 'fontawesome') {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let fa_pro = this.hawkejs_renderer.expose('fontawesome_pro'),
|
|
124
|
+
style = this.icon_style || 'regular';
|
|
125
|
+
|
|
126
|
+
if (fa_pro) {
|
|
127
|
+
this.hawkejs_renderer.style(fa_pro);
|
|
128
|
+
} else {
|
|
129
|
+
this.hawkejs_renderer.style('alchemy_icons_fafree');
|
|
130
|
+
|
|
131
|
+
if (style == 'duotone' || style == 'light' || style == 'thin' || style == 'regular') {
|
|
132
|
+
style = 'solid';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let existing_classes = Array.cast(this.classList);
|
|
137
|
+
|
|
138
|
+
// Remove existing fontawesome classes
|
|
139
|
+
for (let entry of existing_classes) {
|
|
140
|
+
if (entry.startsWith('fa')) {
|
|
141
|
+
this.classList.remove(entry);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.classList.add('fa-' + (this.icon_style || 'solid'));
|
|
146
|
+
this.classList.add('fa-' + this.icon_name);
|
|
147
|
+
});
|
package/helper/media_helper.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const PLACEHOLDER = Symbol('placeholder');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The Media helper
|
|
3
5
|
*
|
|
@@ -7,9 +9,7 @@
|
|
|
7
9
|
*
|
|
8
10
|
* @param {ViewRender} view
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
|
-
Media.super.call(this, view);
|
|
12
|
-
});
|
|
12
|
+
const Media = Function.inherits('Alchemy.Helper', 'Media');
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Function to execute on the client side, when the scene is made
|
|
@@ -93,7 +93,7 @@ Media.setStatic(function loadImagesBasedOnSize() {
|
|
|
93
93
|
*
|
|
94
94
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
95
95
|
* @since 0.5.0
|
|
96
|
-
* @version 0.
|
|
96
|
+
* @version 0.6.2
|
|
97
97
|
*
|
|
98
98
|
* @param {Element} element The element to apply to
|
|
99
99
|
* @param {String} image The image identifier
|
|
@@ -116,6 +116,12 @@ Media.setMethod(function applyDirective(element, image, options) {
|
|
|
116
116
|
options = {};
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
let variables = element[Hawkejs.VARIABLES];
|
|
120
|
+
|
|
121
|
+
if (!options.route) {
|
|
122
|
+
options.route = variables?.['media-route'];
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
if (width) {
|
|
120
126
|
if (width.indexOf('%') > -1) {
|
|
121
127
|
element.removeAttribute('width');
|
|
@@ -153,6 +159,11 @@ Media.setMethod(function applyDirective(element, image, options) {
|
|
|
153
159
|
return;
|
|
154
160
|
}
|
|
155
161
|
|
|
162
|
+
if (options[PLACEHOLDER]) {
|
|
163
|
+
element.setAttribute('alt', '');
|
|
164
|
+
element.setAttribute('role', 'presentation');
|
|
165
|
+
}
|
|
166
|
+
|
|
156
167
|
if (!String(image).isHex()) {
|
|
157
168
|
return;
|
|
158
169
|
}
|
|
@@ -269,9 +280,9 @@ Media.setMethod(function imageUrl(image_id, options) {
|
|
|
269
280
|
/**
|
|
270
281
|
* Create a base placeholder image url
|
|
271
282
|
*
|
|
272
|
-
* @author Jelle De Loecker <jelle@
|
|
283
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
273
284
|
* @since 0.2.0
|
|
274
|
-
* @version 0.2
|
|
285
|
+
* @version 0.6.2
|
|
275
286
|
*
|
|
276
287
|
* @param {Object} options
|
|
277
288
|
*
|
|
@@ -300,6 +311,8 @@ Media.setMethod(function placeholderUrl(options) {
|
|
|
300
311
|
if (options.text) {
|
|
301
312
|
url.addQuery('text', options.text);
|
|
302
313
|
}
|
|
314
|
+
|
|
315
|
+
options[PLACEHOLDER] = true;
|
|
303
316
|
}
|
|
304
317
|
|
|
305
318
|
return url;
|
|
@@ -84,7 +84,7 @@ ImageMedia.setMethod(function thumbnail(conduit, record) {
|
|
|
84
84
|
*
|
|
85
85
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
86
86
|
* @since 0.0.1
|
|
87
|
-
* @version 0.6.
|
|
87
|
+
* @version 0.6.1
|
|
88
88
|
*
|
|
89
89
|
* @param {Conduit} conduit
|
|
90
90
|
* @param {Object} record
|
|
@@ -227,8 +227,7 @@ ImageMedia.setMethod(function serve(conduit, record, options) {
|
|
|
227
227
|
|
|
228
228
|
if (resizeOptions) {
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
if (this.supportsWebp(conduit)) {
|
|
230
|
+
if (this.supportsWebp(conduit) && alchemy.plugins.media.cwebp) {
|
|
232
231
|
resizeOptions.type = 'webp';
|
|
233
232
|
}
|
|
234
233
|
|
|
@@ -391,6 +390,10 @@ ImageMedia.setMethod(function getSize(conduit, filePath, options, callback) {
|
|
|
391
390
|
|
|
392
391
|
tempPath = PATH_TEMP + '/' + alchemy.ObjectId() + '.webp';
|
|
393
392
|
|
|
393
|
+
if (!alchemy.plugins.media.cwebp) {
|
|
394
|
+
return callback(new Error('Unable to get size: cwebp not found'));
|
|
395
|
+
}
|
|
396
|
+
|
|
394
397
|
child.exec(alchemy.plugins.media.cwebp + ' ' + [resizeOptions, '-q 80', filePath, '-o', tempPath].join(' '), function(err, out) {
|
|
395
398
|
|
|
396
399
|
if (err) {
|