@lemonadejs/cropper 1.3.0 → 1.4.1
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/dist/cropper.js +92 -21
- package/package.json +2 -2
package/dist/cropper.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* (c) LemonadeJS components
|
|
3
3
|
*
|
|
4
4
|
* Website: https://lemonadejs.net
|
|
5
|
-
* Description: Image cropper v1.
|
|
5
|
+
* Description: Image cropper v1.4.0
|
|
6
6
|
*
|
|
7
7
|
* MIT License
|
|
8
8
|
*
|
|
@@ -16,24 +16,37 @@
|
|
|
16
16
|
|
|
17
17
|
'use strict';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (typeof(
|
|
22
|
-
var
|
|
19
|
+
// Load lemonadejs
|
|
20
|
+
if (typeof(lemonade) == 'undefined') {
|
|
21
|
+
if (typeof(require) === 'function') {
|
|
22
|
+
var lemonade = require('lemonadejs');
|
|
23
|
+
} else if (window.lemonade) {
|
|
24
|
+
var lemonade = window.lemonade;
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Load jsuites
|
|
29
|
+
if (typeof(jSuites) == 'undefined') {
|
|
30
|
+
if (typeof(require) === 'function') {
|
|
31
|
+
var jSuites = require('jsuites');
|
|
32
|
+
} else if (window.jSuites) {
|
|
33
|
+
var jSuites = window.jSuites;
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
|
|
37
|
+
// Set the app extensions
|
|
38
|
+
if (typeof(jSuites.crop) == 'undefined' && typeof(require) === 'function') {
|
|
39
|
+
// Loading App Extensions
|
|
40
|
+
jSuites.crop = require('@jsuites/cropper');
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
return (function(photoContainer) {
|
|
32
44
|
var original = photoContainer.getAttribute('data-original') ? 1 : 0;
|
|
33
45
|
var width = photoContainer.getAttribute('width') || 300;
|
|
34
46
|
var height = photoContainer.getAttribute('height') || 240;
|
|
35
47
|
var modal = null;
|
|
36
48
|
var crop = null;
|
|
49
|
+
var menu = null;
|
|
37
50
|
|
|
38
51
|
var self = {};
|
|
39
52
|
self.cropperArea = null;
|
|
@@ -73,6 +86,16 @@
|
|
|
73
86
|
});
|
|
74
87
|
}
|
|
75
88
|
|
|
89
|
+
self.createMenu = function(o) {
|
|
90
|
+
// Start contextmenu component
|
|
91
|
+
menu = jSuites.contextmenu(o, {
|
|
92
|
+
onclick: function(a,b) {
|
|
93
|
+
a.close();
|
|
94
|
+
b.stopPropagation();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
76
99
|
self.updateZoom = function(o) {
|
|
77
100
|
crop.zoom(o.value);
|
|
78
101
|
}
|
|
@@ -192,8 +215,20 @@
|
|
|
192
215
|
}
|
|
193
216
|
|
|
194
217
|
photoContainer.content = [data];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
195
220
|
|
|
196
|
-
|
|
221
|
+
self.open = function() {
|
|
222
|
+
if (! modal.isOpen()) {
|
|
223
|
+
// Open modal
|
|
224
|
+
modal.open();
|
|
225
|
+
// Create controls for the first time only
|
|
226
|
+
if (!photoContainer.classList.contains('controls')) {
|
|
227
|
+
// Create controls
|
|
228
|
+
createControls(self.controls);
|
|
229
|
+
// Flag controls are ready
|
|
230
|
+
photoContainer.classList.add('controls');
|
|
231
|
+
}
|
|
197
232
|
}
|
|
198
233
|
}
|
|
199
234
|
|
|
@@ -233,7 +268,9 @@
|
|
|
233
268
|
</div>
|
|
234
269
|
</div>
|
|
235
270
|
</div>
|
|
236
|
-
</div
|
|
271
|
+
</div>
|
|
272
|
+
<div @ready="self.createMenu(this)"></div>
|
|
273
|
+
`;
|
|
237
274
|
|
|
238
275
|
// Controls
|
|
239
276
|
var createControls = function(o) {
|
|
@@ -256,21 +293,55 @@
|
|
|
256
293
|
tabs.content.style.backgroundColor = '#eee';
|
|
257
294
|
}
|
|
258
295
|
|
|
259
|
-
// Onclick event
|
|
260
296
|
photoContainer.onmousedown = function(e) {
|
|
261
|
-
if (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
297
|
+
if (e.target.tagName == 'IMG') {
|
|
298
|
+
e.target.focus();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Onclick event
|
|
303
|
+
photoContainer.onclick = function(e) {
|
|
304
|
+
e = e || window.event;
|
|
305
|
+
if (e.buttons) {
|
|
306
|
+
var mouseButton = e.buttons;
|
|
307
|
+
} else if (e.button) {
|
|
308
|
+
var mouseButton = e.button;
|
|
309
|
+
} else {
|
|
310
|
+
var mouseButton = e.which;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (mouseButton == 1) {
|
|
314
|
+
self.open();
|
|
315
|
+
} else {
|
|
316
|
+
if (e.target.tagName == 'IMG') {
|
|
317
|
+
e.target.focus();
|
|
270
318
|
}
|
|
271
319
|
}
|
|
272
320
|
}
|
|
273
321
|
|
|
322
|
+
photoContainer.oncontextmenu = function(e) {
|
|
323
|
+
if (e.target.tagName == 'IMG') {
|
|
324
|
+
menu.open(e, [
|
|
325
|
+
{
|
|
326
|
+
title: jSuites.translate('Change image'),
|
|
327
|
+
icon: 'edit',
|
|
328
|
+
onclick: function() {
|
|
329
|
+
self.open();
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
title: jSuites.translate('Delete image'),
|
|
334
|
+
icon: 'delete',
|
|
335
|
+
shortcut: 'DELETE',
|
|
336
|
+
onclick: function() {
|
|
337
|
+
e.target.remove();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
]);
|
|
341
|
+
e.preventDefault();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
274
345
|
// Remove current image
|
|
275
346
|
photoContainer.onkeydown = function(e) {
|
|
276
347
|
if (e.key == 'Delete' && e.target.tagName == 'IMG') {
|