alchemy-media 0.6.2 → 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 +6 -0
- package/assets/stylesheets/alchemy_icons.scss +5 -61
- package/assets/stylesheets/alchemy_icons_fafree.scss +59 -0
- package/bootstrap.js +8 -1
- package/element/al_ico_element.js +131 -1
- package/helper/media_helper.js +12 -5
- package/package.json +1 -1
- package/view/element/al_file.hwk +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 0.6.3 (2022-07-23)
|
|
2
|
+
|
|
3
|
+
* Fix `al-file` element showing wrong buttons on load
|
|
4
|
+
* Always add `role="presentation"` to images that get a simple placeholder
|
|
5
|
+
* Add support for Fontawesome Pro with the `media.fontawesome_pro` setting
|
|
6
|
+
|
|
1
7
|
## 0.6.2 (2022-07-06)
|
|
2
8
|
|
|
3
9
|
* Upgrade to Fontawesome 6
|
|
@@ -1,66 +1,10 @@
|
|
|
1
|
-
@import "fontawesome6/fontawesome.scss";
|
|
2
|
-
@import "fontawesome6/solid.scss";
|
|
3
|
-
@import "fontawesome6/brands.scss";
|
|
4
|
-
|
|
5
1
|
al-ico {
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
// inline-flex breaks certain (duotone) icons
|
|
3
|
+
//--fa-display: inline-flex;
|
|
8
4
|
flex-flow: column;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
&[type="arrow-left"] {
|
|
14
|
-
@extend .fas, .fa-angle-left;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&[type="arrow-left-double"] {
|
|
18
|
-
@extend .fas, .fa-angle-double-left;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&[type="arrow-right"] {
|
|
22
|
-
@extend .fas, .fa-angle-right;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&[type="arrow-right-double"] {
|
|
26
|
-
@extend .fas, .fa-angle-double-right;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&[type="sorting-arrow"] {
|
|
30
|
-
@extend .fas;
|
|
31
|
-
|
|
32
|
-
&.down {
|
|
33
|
-
@extend .fa-sort-alpha-up;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&.up {
|
|
37
|
-
@extend .fa-sort-alpha-down;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&[type="menu"] {
|
|
42
|
-
@extend .fas, .fa-bars;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&[type="edit"] {
|
|
46
|
-
@extend .fas, .fa-pencil-alt;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&[type="zoom-in"] {
|
|
50
|
-
@extend .fas, .fa-search-plus;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&[type="microphone"] {
|
|
54
|
-
@extend .fas, .fa-microphone-alt;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&[type="video"] {
|
|
58
|
-
@extend .fas, .fa-video;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&[type="plus"] {
|
|
62
|
-
@extend .fas, .fa-plus;
|
|
63
|
-
}
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-content: center;
|
|
7
|
+
text-align: center;
|
|
64
8
|
|
|
65
9
|
&[hidden] {
|
|
66
10
|
display: none !important;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@use "fontawesome6/fontawesome.scss";
|
|
2
|
+
@use "fontawesome6/solid.scss";
|
|
3
|
+
@use "fontawesome6/brands.scss";
|
|
4
|
+
|
|
5
|
+
al-ico {
|
|
6
|
+
@extend %fa-icon;
|
|
7
|
+
|
|
8
|
+
&[type="arrow-left"] {
|
|
9
|
+
@extend .fas, .fa-angle-left;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&[type="arrow-left-double"] {
|
|
13
|
+
@extend .fas, .fa-angle-double-left;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&[type="arrow-right"] {
|
|
17
|
+
@extend .fas, .fa-angle-right;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&[type="arrow-right-double"] {
|
|
21
|
+
@extend .fas, .fa-angle-double-right;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&[type="sorting-arrow"] {
|
|
25
|
+
@extend .fas;
|
|
26
|
+
|
|
27
|
+
&.down {
|
|
28
|
+
@extend .fa-sort-alpha-up;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.up {
|
|
32
|
+
@extend .fa-sort-alpha-down;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&[type="menu"] {
|
|
37
|
+
@extend .fas, .fa-bars;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&[type="edit"] {
|
|
41
|
+
@extend .fas, .fa-pencil-alt;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[type="zoom-in"] {
|
|
45
|
+
@extend .fas, .fa-search-plus;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&[type="microphone"] {
|
|
49
|
+
@extend .fas, .fa-microphone-alt;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&[type="video"] {
|
|
53
|
+
@extend .fas, .fa-video;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&[type="plus"] {
|
|
57
|
+
@extend .fas, .fa-plus;
|
|
58
|
+
}
|
|
59
|
+
}
|
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
|
*
|
|
@@ -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
|
|
@@ -159,6 +159,11 @@ Media.setMethod(function applyDirective(element, image, options) {
|
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
if (options[PLACEHOLDER]) {
|
|
163
|
+
element.setAttribute('alt', '');
|
|
164
|
+
element.setAttribute('role', 'presentation');
|
|
165
|
+
}
|
|
166
|
+
|
|
162
167
|
if (!String(image).isHex()) {
|
|
163
168
|
return;
|
|
164
169
|
}
|
|
@@ -275,9 +280,9 @@ Media.setMethod(function imageUrl(image_id, options) {
|
|
|
275
280
|
/**
|
|
276
281
|
* Create a base placeholder image url
|
|
277
282
|
*
|
|
278
|
-
* @author Jelle De Loecker <jelle@
|
|
283
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
279
284
|
* @since 0.2.0
|
|
280
|
-
* @version 0.2
|
|
285
|
+
* @version 0.6.2
|
|
281
286
|
*
|
|
282
287
|
* @param {Object} options
|
|
283
288
|
*
|
|
@@ -306,6 +311,8 @@ Media.setMethod(function placeholderUrl(options) {
|
|
|
306
311
|
if (options.text) {
|
|
307
312
|
url.addQuery('text', options.text);
|
|
308
313
|
}
|
|
314
|
+
|
|
315
|
+
options[PLACEHOLDER] = true;
|
|
309
316
|
}
|
|
310
317
|
|
|
311
318
|
return url;
|
package/package.json
CHANGED
package/view/element/al_file.hwk
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<label class="al-file-drop-target">
|
|
2
2
|
<div class="al-file-preview"></div>
|
|
3
3
|
<al-ico class="uploading-icon fa-solid fa-spinner fa-spin-pulse"></al-ico>
|
|
4
|
-
<al-ico class="empty-icon fa-solid fa-file-arrow-up" hidden
|
|
4
|
+
<al-ico class="empty-icon fa-solid fa-file-arrow-up"><% if (self.value) $0.hidden = true %></al-ico>
|
|
5
5
|
<input type="file" tabindex="-1" class="al-file-input" hidden>
|
|
6
6
|
</label>
|
|
7
7
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
</button>
|
|
13
13
|
|
|
14
14
|
<button class="al-file-remove">
|
|
15
|
+
<% if (!self.value) $0.hidden = true %>
|
|
15
16
|
<al-ico class="fa-solid fa-trash-can"></al-ico>
|
|
16
17
|
{%t "remove-current-file" %}
|
|
17
18
|
</button>
|