alchemy-media 0.5.2 → 0.6.2

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +11 -4
  2. package/assets/fonts/fontawesome6/fa-brands-400.ttf +0 -0
  3. package/assets/fonts/fontawesome6/fa-brands-400.woff2 +0 -0
  4. package/assets/fonts/fontawesome6/fa-regular-400.ttf +0 -0
  5. package/assets/fonts/fontawesome6/fa-regular-400.woff2 +0 -0
  6. package/assets/fonts/fontawesome6/fa-solid-900.ttf +0 -0
  7. package/assets/fonts/fontawesome6/fa-solid-900.woff2 +0 -0
  8. package/assets/fonts/fontawesome6/fa-v4compatibility.ttf +0 -0
  9. package/assets/fonts/fontawesome6/fa-v4compatibility.woff2 +0 -0
  10. package/assets/stylesheets/alchemy_icons.scss +68 -0
  11. package/assets/stylesheets/alchemy_svg.scss +9 -0
  12. package/assets/stylesheets/chimera/mediafield.less +1 -2
  13. package/assets/stylesheets/element/alchemy_file.scss +95 -0
  14. package/assets/stylesheets/fontawesome6/_animated.scss +153 -0
  15. package/assets/stylesheets/fontawesome6/_bordered-pulled.scss +20 -0
  16. package/assets/stylesheets/fontawesome6/_core.scss +33 -0
  17. package/assets/stylesheets/fontawesome6/_fixed-width.scss +7 -0
  18. package/assets/stylesheets/fontawesome6/_functions.scss +57 -0
  19. package/assets/stylesheets/fontawesome6/_icons.scss +9 -0
  20. package/assets/stylesheets/fontawesome6/_list.scss +18 -0
  21. package/assets/stylesheets/fontawesome6/_mixins.scss +73 -0
  22. package/assets/stylesheets/fontawesome6/_rotated-flipped.scss +31 -0
  23. package/assets/stylesheets/fontawesome6/_screen-reader.scss +14 -0
  24. package/assets/stylesheets/fontawesome6/_shims.scss +2027 -0
  25. package/assets/stylesheets/fontawesome6/_sizing.scss +16 -0
  26. package/assets/stylesheets/fontawesome6/_stacked.scss +32 -0
  27. package/assets/stylesheets/fontawesome6/_variables.scss +4885 -0
  28. package/assets/stylesheets/fontawesome6/brands.scss +30 -0
  29. package/assets/stylesheets/fontawesome6/fontawesome.scss +21 -0
  30. package/assets/stylesheets/fontawesome6/regular.scss +26 -0
  31. package/assets/stylesheets/fontawesome6/solid.scss +26 -0
  32. package/assets/stylesheets/fontawesome6/v4-shims.scss +11 -0
  33. package/bootstrap.js +1 -0
  34. package/controller/media_files_controller.js +20 -0
  35. package/controller/media_gallery_chimera_controller.js +1 -0
  36. package/element/al_file.js +275 -0
  37. package/element/al_ico_element.js +17 -0
  38. package/element/al_svg.js +81 -0
  39. package/helper/media_helper.js +56 -10
  40. package/helper/widgets/image_widget.js +46 -0
  41. package/{lib/field_type → helper_field}/file_field_type.js +5 -3
  42. package/lib/media_types/image_media_type.js +34 -9
  43. package/model/media_file_model.js +9 -3
  44. package/model/media_raw_model.js +529 -529
  45. package/package.json +6 -6
  46. package/view/element/al_file.hwk +18 -0
  47. package/view/form/inputs/edit/file.hwk +8 -0
  48. package/assets/scripts/chimera/mediafield.js +0 -451
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "alchemy-media",
3
3
  "description": "The media plugin for Alchemy",
4
- "version": "0.5.2",
4
+ "version": "0.6.2",
5
5
  "repository": {
6
- "type": "git",
7
- "url": "https://github.com/skerit/alchemy-media.git"
6
+ "type" : "git",
7
+ "url" : "https://github.com/skerit/alchemy-media.git"
8
8
  },
9
9
  "dependencies": {
10
10
  "@11ways/exiv2" : "~0.6.4",
@@ -12,10 +12,10 @@
12
12
  "veronica" : "~0.2.2"
13
13
  },
14
14
  "peerDependencies": {
15
- "alchemymvc": "~1.1.0"
15
+ "alchemymvc" : ">=1.2.0"
16
16
  },
17
17
  "license": "MIT",
18
18
  "engines": {
19
- "node": ">=10.21.0"
19
+ "node" : ">=14.0.0"
20
20
  }
21
- }
21
+ }
@@ -0,0 +1,18 @@
1
+ <label class="al-file-drop-target">
2
+ <div class="al-file-preview"></div>
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></al-ico>
5
+ <input type="file" tabindex="-1" class="al-file-input" hidden>
6
+ </label>
7
+
8
+ <div class="al-file-right">
9
+ <button class="al-file-choose-existing">
10
+ <al-ico class="fa-solid fa-file-image"></al-ico>
11
+ {%t "select-uploaded-file" %}
12
+ </button>
13
+
14
+ <button class="al-file-remove">
15
+ <al-ico class="fa-solid fa-trash-can"></al-ico>
16
+ {%t "remove-current-file" %}
17
+ </button>
18
+ </div>
@@ -0,0 +1,8 @@
1
+ <%
2
+ script('chimera/mediafield');
3
+ style('chimera/mediafield');
4
+ %>
5
+ <al-file
6
+ value=<% value %>
7
+ class="alchemy-field-value"
8
+ ></al-file>
@@ -1,451 +0,0 @@
1
- hawkejs.require([
2
- {name: 'jquery', path: '//code.jquery.com/jquery-1.11.3.min.js'},
3
- 'jqueryui1.10/jquery.ui.widget',
4
- 'fileupload/jquery.fileupload',
5
- 'chimera/chimera'], function onChimeraLoad() {
6
-
7
- var MediaFields = [];
8
-
9
- /**
10
- * The MediaFileInput class
11
- */
12
- function MediaFileField(chimera_field) {
13
-
14
- this.chimera_field = chimera_field;
15
-
16
- // Get the index in the MediaFields array
17
- this.index = (MediaFields.push(this)-1);
18
-
19
- // The original input
20
- this.input = chimera_field.input;
21
-
22
- // The wrapper div
23
- this.wrapper = false;
24
-
25
- // The preview object
26
- this.preview = false;
27
-
28
- // The controls
29
- this.controls = false;
30
-
31
- // Is this part of an array-field?
32
- this.array = false;
33
-
34
- // Init the field
35
- this.init();
36
- }
37
-
38
- /**
39
- * Init the field, add html code
40
- */
41
- MediaFileField.prototype.init = function init() {
42
-
43
- var html,
44
- value;
45
-
46
- // Create the html
47
- html = '<div class="mediafilechooser">';
48
- html += '<div class="preview"></div>';
49
- html += '<div class="controls"></div>';
50
- html += '</div>';
51
-
52
- // Prepare the jquery objects
53
- this.wrapper = $(html);
54
- this.preview = $('.preview', this.wrapper);
55
- this.controls = $('.controls', this.wrapper);
56
-
57
- $(this.input).append(this.wrapper);
58
-
59
- // @todo: implement readOnly
60
- //this.readOnly = this.input.attr('readonly') != null;
61
-
62
- if (this.readOnly) {
63
- this.controls.hide();
64
- }
65
-
66
- // Get the current value
67
- value = this.chimera_field.value;
68
-
69
- // If the value is set, generate the preview
70
- if (value) {
71
- this.setId(value);
72
- } else {
73
- this.setControls();
74
- }
75
- };
76
-
77
- /**
78
- * Set the image id and update the preview
79
- */
80
- MediaFileField.prototype.setId = function setId(id) {
81
-
82
- var that = this,
83
- html;
84
-
85
- // Generate the image html
86
- html = '<img src="/media/thumbnail/' + id + '" srcset="/media/thumbnail/' + id + '?dpr=2 2x" />';
87
-
88
- html += '<div class="image-actions">';
89
-
90
- html += '<a class="download" target="_blank" href="/media/download/' + id + '">';
91
- html += '<span class="icon"><i class="fa fa fa-download"></i></span>';
92
- html += '<span class="message">Download</span>';
93
- html += '</a>';
94
-
95
- html += '<span class="edit">';
96
- html += '<span class="icon"><i class="fa fa fa-edit"></i></span>';
97
- html += '<span class="message">Edit</span>';
98
- html += '</span>';
99
-
100
- // Add the button to remove the image
101
- html += '<span class="remove">';
102
- html += '<span class="icon"><i class="fa fa-times"></i></span>';
103
- html += '<span class="message">Remove</span>';
104
- html += '</span>';
105
-
106
- html += '</div>';
107
-
108
- // See if this is an arrayable field
109
- this.array = this.chimera_field.isArray;
110
- //this.array = !!this.wrapper.parents('.mediafieldgroup').find('button[data-chimera-add-entry]').length;
111
-
112
- this.chimera_field.setValue(id);
113
-
114
- // Set the preview image
115
- this.preview.html(html);
116
-
117
- // Hide the controls
118
- this.controls.hide();
119
-
120
- // Show the preview
121
- this.preview.show();
122
-
123
- if (this.readOnly) {
124
- $('.remove .icon, .remove .message', this.preview).hide();
125
- } else {
126
- // Attach a listener to the remove button
127
- $('.remove .icon, .remove .message', this.preview).click(function() {
128
- that.removeFile();
129
- });
130
- }
131
-
132
- $('.edit', this.preview).on('click', function() {
133
- that.editFile();
134
- });
135
- };
136
-
137
- /**
138
- * Remove the set file
139
- */
140
- MediaFileField.prototype.removeFile = function removeFile() {
141
-
142
- if (this.array) {
143
- // Remove the wrapper element
144
- this.wrapper.remove();
145
-
146
- // Set the only reference to this object to null
147
- MediaFields[this.index] = null;
148
- } else {
149
- this.setControls();
150
- }
151
-
152
- this.chimerafield.setValue(null);
153
- };
154
-
155
- /**
156
- * Edit the set file
157
- */
158
- MediaFileField.prototype.editFile = function editFile() {
159
-
160
- var that = this,
161
- options = {
162
- history: false,
163
- get: {
164
- id: this.chimera_field.value
165
- }
166
- };
167
-
168
- var url = '/chimera/media_gallery/media_files/modify';
169
-
170
- hawkejs.scene.openUrl(url, options, function(err, renderer) {
171
-
172
- $('.action-save-image').on('click', function onClick(e) {
173
-
174
- var save_options,
175
- $fields = $('.chimera-image-edit input.media-edit-field'),
176
- post = {};
177
-
178
- e.preventDefault();
179
-
180
- $fields.each(function eachField() {
181
- var field = this.dataset.field;
182
-
183
- Object.setPath(post, field, this.value);
184
- });
185
-
186
- save_options = {
187
- history: false,
188
- post: post
189
- };
190
-
191
- hawkejs.scene.fetch(url + '?id=' + that.chimera_field.value, save_options, function saved(err, res, b) {
192
-
193
- if (err) {
194
- throw err;
195
- }
196
-
197
- renderer.dialog_element.parentElement.remove();
198
- });
199
- });
200
- });
201
- };
202
-
203
- /**
204
- * Set the controls
205
- */
206
- MediaFileField.prototype.setControls = function setControls() {
207
-
208
- var that = this,
209
- $progress,
210
- $bar,
211
- html;
212
-
213
- if (this.readOnly) {
214
- return;
215
- }
216
-
217
- html = '<span class="btn btn-success fileinput-button">';
218
- html += '<span>Upload file</span>';
219
-
220
- html += '<input class="fileupload" type="file" name="newfile">';
221
- html += '</span>';
222
-
223
- html += '<span class="btn btn-primary fileinput-pick">';
224
- html += '<span>Pick file</span>';
225
- html += '</span>';
226
-
227
- html += '<div class="chimeraMedia-progress progress" hidden>';
228
- html += '<div class="progress-bar progress-bar-success"></div>';
229
- html += '</div>';
230
-
231
- // Remove the current value
232
- this.chimera_field.setValue();
233
-
234
- // Set the html
235
- this.controls.html(html);
236
-
237
- // Get the $progress wrapper
238
- $progress = $('.progress', this.controls);
239
-
240
- // Get the bar self
241
- $bar = $('.progress-bar', $progress);
242
-
243
- // Hide the current preview image
244
- this.preview.hide();
245
-
246
- // Show the controls
247
- this.controls.show();
248
-
249
- // Attach the fileupload code
250
- $('.fileupload', this.controls).fileupload({
251
- url: '/media/upload',
252
- dataType: 'json',
253
- formData: {},
254
- done: function onDone(e, data) {
255
-
256
- var result = JSON.undry(data.result),
257
- file;
258
-
259
- // We only allow 1 file to be uploaded
260
- file = result.files[0];
261
-
262
- that.setId(file._id);
263
-
264
- if ($progress && $progress[0]) {
265
- $progress[0].hidden = true;
266
- }
267
- },
268
- progressall: function (e, data) {
269
- var progress = parseInt(data.loaded / data.total * 100, 10);
270
- $bar.css('width', progress + '%');
271
-
272
- $progress[0].hidden = false;
273
- }
274
- });
275
-
276
- // Attach the media picker
277
- $('.fileinput-pick', this.controls).click(function(e) {
278
-
279
- pickMediaId(function(err, id) {
280
-
281
- if (!id) {
282
- return;
283
- }
284
-
285
- that.setId(id);
286
- });
287
-
288
- e.preventDefault();
289
- });
290
- };
291
-
292
- /**
293
- * The File ChimeraField class
294
- *
295
- * @constructor
296
- *
297
- * @author Jelle De Loecker <jelle@develry.be>
298
- * @since 0.2.0
299
- * @version 0.2.0
300
- *
301
- * @param {DOMElement} container
302
- * @param {Object} variables
303
- */
304
- var FileChimeraField = ChimeraField.extend(function FileChimeraField(parent, value, container, variables, prefix) {
305
- FileChimeraField.super.call(this, parent, value, container, variables, prefix);
306
- });
307
-
308
- /**
309
- * Create the edit input element
310
- *
311
- * @author Jelle De Loecker <jelle@develry.be>
312
- * @since 0.2.0
313
- * @version 0.4.0
314
- */
315
- FileChimeraField.setMethod(function renderEdit(callback) {
316
-
317
- var element;
318
-
319
- if (this._rendered) {
320
- if (callback) callback(null);
321
- return;
322
- }
323
-
324
- this._rendered = true;
325
-
326
- element = Blast.parseHTML('<div class="mediafieldgroup"></div>');
327
-
328
- this.entry = element;
329
- this.input = element;
330
- this.parent.addEntry(this);
331
-
332
- this.mediafile = new MediaFileField(this);
333
- this.mediafile.chimerafield = this;
334
-
335
- if (callback) callback(null);
336
- });
337
-
338
- /**
339
- * Initialize the field in the edit action
340
- *
341
- * @author Jelle De Loecker <jelle@develry.be>
342
- * @since 0.3.0
343
- * @version 0.3.0
344
- *
345
- * @param {Mixed} value Optional value to override
346
- */
347
- FileChimeraField.setMethod(function initEdit(value) {
348
-
349
- var that = this;
350
-
351
- // Override the value if given
352
- if (typeof value == 'undefined') {
353
- value = this.value;
354
- }
355
-
356
- this.renderEdit();
357
- });
358
-
359
- // Intercept filebrowser event emitted in modified ckeditor code
360
- hawkejs.scene.on('filebrowser', function onFilebrowse(input, dialog, filebrowser) {
361
-
362
- pickMediaId(function picked(err, result, element) {
363
-
364
- if (err) {
365
- throw err;
366
- }
367
-
368
- input.setValue('/media/image/' + result);
369
-
370
- // Set the alt text
371
- if (element && element.getAttribute('alt')) {
372
- var alt = $('#' + input.domId).parents('table').find('#cke_158_textInput');
373
- alt.val(element.getAttribute('alt'));
374
- }
375
- });
376
- });
377
-
378
- function pickMediaId(callback) {
379
-
380
- var madeSelection;
381
-
382
- hawkejs.scene.openUrl('/chimera/media_gallery/media_files/gallery_picker', {history: false}, function(err, viewRender) {
383
-
384
- var $fileupload,
385
- $progress,
386
- element,
387
- $bar;
388
-
389
- element = viewRender.dialog_element || document.querySelector('[data-he-template="chimera/editor/gallery_picker"]');
390
- $fileupload = $('.fileupload', element);
391
- $progress = $('.progress', element);
392
- $bar = $('.progress-bar', element);
393
-
394
- $fileupload.fileupload({
395
- url: '/media/upload',
396
- dataType: 'json',
397
- formData: {},
398
- done: function onDone(e, data) {
399
-
400
- var renderer = new __Protoblast.Classes.Hawkejs.Renderer(hawkejs),
401
- result = JSON.undry(data.result),
402
- file,
403
- html;
404
-
405
- // We only allow 1 file to be uploaded
406
- file = result.files[0];
407
-
408
- html = '<figure class="chimeraGallery-thumb" data-id="' + file._id + '" style="';
409
- html += renderer.helpers.Media.imageCssSet(file._id, {profile: 'pickerThumb'});
410
- html += '"><div class="chimeraGallery-thumbInfo"><span>Select</span></div></figure>';
411
-
412
- $('.chimeraGallery-pickup', element).after(html);
413
- $bar.css('width', '');
414
-
415
- if ($progress && $progress[0]) {
416
- $progress[0].hidden = true;
417
- }
418
- },
419
- progressall: function onProgressAll(e, data) {
420
- var progress = parseInt(data.loaded / data.total * 100, 10);
421
- $bar.css('width', progress + '%');
422
-
423
- if ($progress && $progress[0]) {
424
- $progress[0].hidden = false;
425
- }
426
- }
427
- });
428
-
429
- $(element).on('click', '.chimeraGallery-thumb', function onThumbClick(e) {
430
-
431
- var $thumb = $(this),
432
- id = $thumb.data('id');
433
-
434
- madeSelection = true;
435
-
436
- if (callback) {
437
- callback(null, id, this);
438
- }
439
-
440
- element.parentElement.remove();
441
- });
442
-
443
- viewRender.afterOnce('dialog_close', function afterClosed() {
444
- if (!madeSelection && callback) {
445
- callback(null, false);
446
- }
447
- });
448
- });
449
-
450
- }
451
- });