|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/klengineers/klwebsite-controller/js/ |
Upload File : |
// JavaScript Document
uploader = {
carry: function(){
// set form
YAHOO.util.Connect.setForm('uploadForm', true);
// upload image
YAHOO.util.Connect.asyncRequest('POST', 'upload.php', {
upload: function(o){
// parse our json data
var jsonData = YAHOO.lang.JSON.parse(o.responseText);
// put image in our image container
YAHOO.util.Dom.get('imageContainer').innerHTML = '<img id="yuiImg" src="' + jsonData.image + '" width="' + jsonData.width + '" height="' + jsonData.height + '" alt="" />';
// init our photoshop
photoshop.init(jsonData.image);
// get first cropped image
photoshop.getCroppedImage();
}
});
}
};
photoshop = {
image: null,
crop: null,
//url: null,
init: function(image){
// set our image
photoshop.image = image;
// our image cropper from the uploaded image
photoshop.crop = new YAHOO.widget.ImageCropper('yuiImg');
photoshop.crop.on('moveEvent', function() {
// get updated coordinates
photoshop.getCroppedImage();
});
},
getCroppedImage: function(){
var coordinates = photoshop.getCoordinates();
var url = 'crop.php?image=' + photoshop.image + '&cropStartX=' + coordinates.left +'&cropStartY=' + coordinates.top +'&cropWidth=' + coordinates.width +'&cropHeight=' + coordinates.height;
YAHOO.util.Dom.get('downloadLink').innerHTML = '<a href="' + url + '">save</a>';
},
getCoordinates: function(){
return photoshop.crop.getCropCoords();
}
};
// add listeners
YAHOO.util.Event.on('uploadButton', 'click', uploader.carry);