@lemonadejs/cropper 1.3.2 → 1.4.0
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 +73 -12
- 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
|
*
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
var height = photoContainer.getAttribute('height') || 240;
|
|
38
38
|
var modal = null;
|
|
39
39
|
var crop = null;
|
|
40
|
+
var menu = null;
|
|
40
41
|
|
|
41
42
|
var self = {};
|
|
42
43
|
self.cropperArea = null;
|
|
@@ -76,6 +77,16 @@
|
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
self.createMenu = function(o) {
|
|
81
|
+
// Start contextmenu component
|
|
82
|
+
menu = jSuites.contextmenu(o, {
|
|
83
|
+
onclick: function(a,b) {
|
|
84
|
+
a.close();
|
|
85
|
+
b.stopPropagation();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
79
90
|
self.updateZoom = function(o) {
|
|
80
91
|
crop.zoom(o.value);
|
|
81
92
|
}
|
|
@@ -198,6 +209,20 @@
|
|
|
198
209
|
}
|
|
199
210
|
}
|
|
200
211
|
|
|
212
|
+
self.open = function() {
|
|
213
|
+
if (! modal.isOpen()) {
|
|
214
|
+
// Open modal
|
|
215
|
+
modal.open();
|
|
216
|
+
// Create controls for the first time only
|
|
217
|
+
if (!photoContainer.classList.contains('controls')) {
|
|
218
|
+
// Create controls
|
|
219
|
+
createControls(self.controls);
|
|
220
|
+
// Flag controls are ready
|
|
221
|
+
photoContainer.classList.add('controls');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
201
226
|
// Template
|
|
202
227
|
var template = `
|
|
203
228
|
<div @ref='self.image' class="jphoto"></div>
|
|
@@ -234,7 +259,9 @@
|
|
|
234
259
|
</div>
|
|
235
260
|
</div>
|
|
236
261
|
</div>
|
|
237
|
-
</div
|
|
262
|
+
</div>
|
|
263
|
+
<div @ready="self.createMenu(this)"></div>
|
|
264
|
+
`;
|
|
238
265
|
|
|
239
266
|
// Controls
|
|
240
267
|
var createControls = function(o) {
|
|
@@ -257,21 +284,55 @@
|
|
|
257
284
|
tabs.content.style.backgroundColor = '#eee';
|
|
258
285
|
}
|
|
259
286
|
|
|
260
|
-
// Onclick event
|
|
261
287
|
photoContainer.onmousedown = function(e) {
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
288
|
+
if (e.target.tagName == 'IMG') {
|
|
289
|
+
e.target.focus();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Onclick event
|
|
294
|
+
photoContainer.onclick = function(e) {
|
|
295
|
+
e = e || window.event;
|
|
296
|
+
if (e.buttons) {
|
|
297
|
+
var mouseButton = e.buttons;
|
|
298
|
+
} else if (e.button) {
|
|
299
|
+
var mouseButton = e.button;
|
|
300
|
+
} else {
|
|
301
|
+
var mouseButton = e.which;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (mouseButton == 1) {
|
|
305
|
+
self.open();
|
|
306
|
+
} else {
|
|
307
|
+
if (e.target.tagName == 'IMG') {
|
|
308
|
+
e.target.focus();
|
|
271
309
|
}
|
|
272
310
|
}
|
|
273
311
|
}
|
|
274
312
|
|
|
313
|
+
photoContainer.oncontextmenu = function(e) {
|
|
314
|
+
if (e.target.tagName == 'IMG') {
|
|
315
|
+
menu.open(e, [
|
|
316
|
+
{
|
|
317
|
+
title: jSuites.translate('Change image'),
|
|
318
|
+
icon: 'edit',
|
|
319
|
+
onclick: function() {
|
|
320
|
+
self.open();
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
title: jSuites.translate('Delete image'),
|
|
325
|
+
icon: 'delete',
|
|
326
|
+
shortcut: 'DELETE',
|
|
327
|
+
onclick: function() {
|
|
328
|
+
e.target.remove();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
]);
|
|
332
|
+
e.preventDefault();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
275
336
|
// Remove current image
|
|
276
337
|
photoContainer.onkeydown = function(e) {
|
|
277
338
|
if (e.key == 'Delete' && e.target.tagName == 'IMG') {
|