2007-09-15 03:08:25 +02:00
|
|
|
/**
|
|
|
|
* @author Mateusz
|
|
|
|
*/
|
|
|
|
var ImageTransformation = {
|
|
|
|
initialize: function() {
|
|
|
|
this.resize = ImageTransformation.resize.bind(this);
|
|
|
|
this.rotate = ImageTransformation.rotate.bind(this);
|
|
|
|
this.crop = ImageTransformation.crop.bind(this);
|
|
|
|
this.save = ImageTransformation.save.bind(this);
|
2007-09-15 03:13:18 +02:00
|
|
|
this.close = ImageTransformation.close.bind(this);
|
2007-09-15 03:08:25 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
resize: function(width,height) {
|
|
|
|
if(imageHistory.modifiedOriginalImage) {
|
|
|
|
fileToResize = $('image').src;
|
|
|
|
} else {
|
|
|
|
fileToResize = imageEditor.originalImageFile;
|
|
|
|
}
|
|
|
|
var options = {
|
|
|
|
method: 'post',
|
|
|
|
postBody: 'command=resize&file=' + fileToResize + '&newImageWidth=' + width + '&newImageHeight=' + height,
|
|
|
|
onSuccess: function(transport) {
|
|
|
|
imageBox.hideIndicator();
|
|
|
|
response = eval('(' + transport.responseText + ')');
|
|
|
|
$('image').src = response.fileName;
|
|
|
|
imageHistory.add('resize',$('image').src);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
imageBox.showIndicator();
|
2007-09-15 03:09:25 +02:00
|
|
|
new Ajax.Request('admin/ImageEditor/manipulate', options);
|
2007-09-15 03:08:25 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
rotate: function(angle) {
|
|
|
|
var options = {
|
|
|
|
method: 'post',
|
|
|
|
postBody: 'command=rotate&file=' + $('image').src + '&angle=' + angle ,
|
|
|
|
onSuccess: function(transport) {
|
|
|
|
imageBox.hideIndicator();
|
|
|
|
response = eval('(' + transport.responseText + ')');
|
|
|
|
$('image').src = response.fileName;
|
|
|
|
$('imageContainer').style.width = response.width + 'px';
|
|
|
|
$('imageContainer').style.height = response.height + 'px';
|
|
|
|
imageHistory.add('rotate',$('image').src);
|
|
|
|
resize.imageContainerResize.placeClickBox();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
imageBox.showIndicator();
|
2007-09-15 03:09:25 +02:00
|
|
|
new Ajax.Request('admin/ImageEditor/manipulate', options);
|
2007-09-15 03:08:25 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
crop: function(top,left,width,height) {
|
|
|
|
var options = {
|
|
|
|
method: 'post',
|
|
|
|
postBody: 'command=crop&file=' + $('image').src + '&top=' + top + '&left=' + left + '&width=' + width + '&height=' + height,
|
|
|
|
onSuccess: function(transport) {
|
|
|
|
imageBox.hideIndicator();
|
|
|
|
response = eval('(' + transport.responseText + ')');
|
|
|
|
$('image').src = response.fileName;
|
|
|
|
$('imageContainer').style.width = response.width + 'px';
|
|
|
|
$('imageContainer').style.height = response.height + 'px';
|
|
|
|
imageHistory.add('crop',$('image').src);
|
|
|
|
crop.setVisible(false);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
imageBox.showIndicator();
|
2007-09-15 03:09:25 +02:00
|
|
|
new Ajax.Request('admin/ImageEditor/manipulate', options);
|
2007-09-15 03:08:25 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
save: function(originalFile,editedFile) {
|
|
|
|
var options = {
|
|
|
|
method: 'post',
|
|
|
|
postBody: 'command=save&editedFile=' + editedFile + '&originalFile=' + originalFile,
|
|
|
|
onSuccess: function(transport) {
|
2007-09-15 03:13:18 +02:00
|
|
|
eval(transport.responseText);
|
2007-09-15 03:08:25 +02:00
|
|
|
imageEditor.onClose();
|
|
|
|
},
|
|
|
|
};
|
2007-09-15 03:13:18 +02:00
|
|
|
new Ajax.Request('admin/ImageEditor/save', options);
|
|
|
|
},
|
|
|
|
|
|
|
|
close: function() {
|
|
|
|
var options = {
|
|
|
|
method: 'post',
|
|
|
|
postBody: '',
|
|
|
|
onSuccess: function(transport) {
|
|
|
|
eval(transport.responseText);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
new Ajax.Request('admin/ImageEditor/close', options);
|
2007-09-15 03:08:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|