forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.js
More file actions
90 lines (81 loc) · 1.68 KB
/
Copy pathloader.js
File metadata and controls
90 lines (81 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var CropImageManager = {
curCrop: null,
init: function()
{
this.attachCropper();
},
onChange: function(e)
{
var vals = $F(Event.element(e)).split('|');
this.setImage(vals[0], vals[1], vals[2]);
},
setImage: function(imgSrc, w, h)
{
$('testImage').src = imgSrc;
/*$('testImage').width = w;
$('testImage').height = h;*/
this.attachCropper(w, h);
},
attachCropper: function(maxW, maxH)
{
var vals = $F($('imageChoice')).split('|');
if (!maxW)
maxW = vals[1];
if (!maxH)
maxH = vals[2];
if (this.curCrop == null)
this.curCrop = new Cropper.Img('testImage',
{
minWidth: maxW,
minHeight: maxH,
maxWidth: maxW,
maxHeight: maxH,
onEndCrop: onEndCrop
}
);
else
this.curCrop.reset(maxW, maxH, maxW, maxH);
this.curCrop.aeraCoords = 0;
},
removeCropper: function()
{
if (this.curCrop != null)
this.curCrop.remove();
},
resetCropper: function()
{
this.attachCropper();
}
};
function onEndCrop(coords, dimensions)
{
var vals = $F($('imageChoice')).split('|');
var id_image = vals[3];
if (!image)
{
image = id_image;
image_check = id_image;
}
if (image != id_image)
image = id_image;
else
{
if (image != image_check && navigator.appName != "Microsoft Internet Explorer")
image_check = image;
else
{
$(id_image + '_x1').value = coords.x1;
$(id_image + '_y1').value = coords.y1;
$(id_image + '_x2').value = coords.x2;
$(id_image + '_y2').value = coords.y2;
}
}
}
Event.observe(window, 'load',
function() {
CropImageManager.init();
Event.observe($('imageChoice'), 'change', CropImageManager.onChange.bindAsEventListener(CropImageManager), false );
}
);
var image;
var image_check;