move the source files to ./src

This commit is contained in:
Martin
2017-08-04 22:28:54 +02:00
parent 58dd1c66fd
commit f36d6f5915
37 changed files with 5 additions and 5 deletions
+57
View File
@@ -0,0 +1,57 @@
'use strict';
function ImageDataHandler(img) {
/**
* Gets information about how the cropped image is dragged
* @return {Object}
*/
this.getCropData = function () {
return JSON.parse(sessionStorage.getItem('cropData'));
};
this.setCropData = function() {
var viewportBounds = img.canvas.getViewport().getBounds();
var dragAxis = img.canvas.getViewport().getData().axis;
var cropData = {
x: dragAxis === 'x' ? (viewportBounds.left - img.left) / (img.width * img.scaleX) : 0,
y: dragAxis === 'y' ? (viewportBounds.top - img.top) / (img.height * img.scaleY) : 0,
}
sessionStorage.setItem('cropData', JSON.stringify(cropData));
}
this.removeCropData = function() {
sessionStorage.removeItem('cropData');
}
/**
* Gets an object containing applied transformations for the Image and also
* how it is cropped and dragged.
* @return {Object}
*/
this.getData = function () {
var viewportData = img.canvas.getViewport().getData();
var returnValue = $.extend(
{},
{
mirrored: img.canvas.getMirror().getStatus(),
width: viewportData.dim.width,
height: viewportData.dim.height,
},
this.getCropData()
);
if (img.canvas.__type === 'canvas') {
var frameHandler = img.canvas.getViewport().getFrameHandler();
returnValue.edge = frameHandler.getFrameType();
returnValue.framed = returnValue.edge !== 'none';
}
return returnValue;
};
}
module.exports = ImageDataHandler;