Skip to content

Commit

Permalink
js lint error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psandor committed May 20, 2019
1 parent 7eeba93 commit a76c47c
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 56 deletions.
2 changes: 1 addition & 1 deletion compile/minified/ui-cropper.js

Large diffs are not rendered by default.

87 changes: 59 additions & 28 deletions compile/unminified/ui-cropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (c) 2019 Alex Kaul
* License: MIT
*
* Generated at Monday, May 20th, 2019, 4:24:47 PM
* Generated at Monday, May 20th, 2019, 10:17:03 PM
*/
(function() {
angular.module('uiCropper', []);
Expand Down Expand Up @@ -1346,7 +1346,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {

// Draw Filled Polygon
var drawFilledPolygon = function(shape, fillStyle, centerCoords, scale) {
if(disable) return;
if(disable) {
return;
}

ctx.save();
ctx.fillStyle = fillStyle;
Expand All @@ -1370,7 +1372,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
/* Icons */

this.drawIconMove = function(centerCoords, scale) {
if(disable) return;
if(disable) {
return;
}

drawFilledPolygon(shapeArrowN, colors.moveIconFill, centerCoords, scale);
drawFilledPolygon(shapeArrowW, colors.moveIconFill, centerCoords, scale);
Expand All @@ -1379,7 +1383,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
};

this.drawIconResizeCircle = function(centerCoords, circleRadius, scale) {
if(disable) return;
if(disable) {
return;
}

var scaledCircleRadius = circleRadius * scale;
ctx.save();
Expand All @@ -1395,7 +1401,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
};

this.drawIconResizeBoxBase = function(centerCoords, boxSize, scale) {
if(disable) return;
if(disable) {
return;
}

var scaledBoxSize = boxSize * scale;
ctx.save();
Expand All @@ -1407,14 +1415,18 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
ctx.restore();
};
this.drawIconResizeBoxNESW = function(centerCoords, boxSize, scale) {
if(disable) return;
if(disable) {
return;
}

this.drawIconResizeBoxBase(centerCoords, boxSize, scale);
drawFilledPolygon(shapeArrowNE, colors.resizeBoxArrowFill, centerCoords, scale);
drawFilledPolygon(shapeArrowSW, colors.resizeBoxArrowFill, centerCoords, scale);
};
this.drawIconResizeBoxNWSE = function(centerCoords, boxSize, scale) {
if(disable) return;
if(disable) {
return;
}

this.drawIconResizeBoxBase(centerCoords, boxSize, scale);
drawFilledPolygon(shapeArrowNW, colors.resizeBoxArrowFill, centerCoords, scale);
Expand All @@ -1424,7 +1436,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
/* Crop Area */

this.drawCropArea = function(image, centerCoords, size, fnDrawClipPath) {
if(disable) return;
if(disable) {
return;
}

var xRatio = Math.abs(image.width / ctx.canvas.width),
yRatio = Math.abs(image.height / ctx.canvas.height),
Expand Down Expand Up @@ -2332,20 +2346,6 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
forceAspectRatio = false;

/* PRIVATE FUNCTIONS */

this.setInitMax = function (bool) {
initMax = bool;
};

this.setAllowCropResizeOnCorners = function (bool) {
theArea.setAllowCropResizeOnCorners(bool);
};

this.setDisableCrop = function(value){
theArea.setDisableCrop(value);
drawScene();
};

// Draw Scene
function drawScene() {
// clear canvas
Expand All @@ -2369,6 +2369,19 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
}
}

this.setInitMax = function (bool) {
initMax = bool;
};

this.setAllowCropResizeOnCorners = function (bool) {
theArea.setAllowCropResizeOnCorners(bool);
};

this.setDisableCrop = function(value){
theArea.setDisableCrop(value);
drawScene();
};

var focusOnCanvas = function () {
elCanvas[0].focus();
};
Expand Down Expand Up @@ -2518,7 +2531,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var onMouseMove = function (e) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (image !== null) {
var offset = getElementOffset(ctx.canvas),
Expand All @@ -2538,7 +2553,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir

var onMouseDown = function (e) {
e.preventDefault();
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (!opts.allowPropagation) {
e.stopPropagation();
Expand All @@ -2561,7 +2578,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var onMouseUp = function (e) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (image !== null) {
var offset = getElementOffset(ctx.canvas),
Expand All @@ -2585,7 +2604,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var resizeCropAreaByDirection = function (direction) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

var scale;
switch (direction) {
Expand All @@ -2605,7 +2626,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var moveCropArea = function (direction) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

var center = theArea.getCenterPoint();
var step = 5;
Expand Down Expand Up @@ -2636,7 +2659,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var onKeyDown = function (e) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (image !== null && opts.disableKeyboardAccess !== true) {
var key = e.which;
Expand Down Expand Up @@ -3547,6 +3572,12 @@ angular.module('uiCropper').directive('uiCropper', ['$timeout', 'cropHost', 'cro

// Sync CropHost with Directive's options
scope.$watch('image', function (newVal) {
// reset the original size and position to 0
// it's mandatory because if not reset the size of the crop area won't maximise when the image was replaced
var area = cropHost.getArea();
if (area) {
cropHost.getArea()._size = { x: 0, y: 0, w: 0, h: 0 };
}
if (newVal) {
displayLoading();
}
Expand Down
28 changes: 21 additions & 7 deletions source/js/classes/crop-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {

// Draw Filled Polygon
var drawFilledPolygon = function(shape, fillStyle, centerCoords, scale) {
if(disable) return;
if(disable) {
return;
}

ctx.save();
ctx.fillStyle = fillStyle;
Expand All @@ -126,7 +128,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
/* Icons */

this.drawIconMove = function(centerCoords, scale) {
if(disable) return;
if(disable) {
return;
}

drawFilledPolygon(shapeArrowN, colors.moveIconFill, centerCoords, scale);
drawFilledPolygon(shapeArrowW, colors.moveIconFill, centerCoords, scale);
Expand All @@ -135,7 +139,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
};

this.drawIconResizeCircle = function(centerCoords, circleRadius, scale) {
if(disable) return;
if(disable) {
return;
}

var scaledCircleRadius = circleRadius * scale;
ctx.save();
Expand All @@ -151,7 +157,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
};

this.drawIconResizeBoxBase = function(centerCoords, boxSize, scale) {
if(disable) return;
if(disable) {
return;
}

var scaledBoxSize = boxSize * scale;
ctx.save();
Expand All @@ -163,14 +171,18 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
ctx.restore();
};
this.drawIconResizeBoxNESW = function(centerCoords, boxSize, scale) {
if(disable) return;
if(disable) {
return;
}

this.drawIconResizeBoxBase(centerCoords, boxSize, scale);
drawFilledPolygon(shapeArrowNE, colors.resizeBoxArrowFill, centerCoords, scale);
drawFilledPolygon(shapeArrowSW, colors.resizeBoxArrowFill, centerCoords, scale);
};
this.drawIconResizeBoxNWSE = function(centerCoords, boxSize, scale) {
if(disable) return;
if(disable) {
return;
}

this.drawIconResizeBoxBase(centerCoords, boxSize, scale);
drawFilledPolygon(shapeArrowNW, colors.resizeBoxArrowFill, centerCoords, scale);
Expand All @@ -180,7 +192,9 @@ angular.module('uiCropper').factory('cropCanvas', [function() {
/* Crop Area */

this.drawCropArea = function(image, centerCoords, size, fnDrawClipPath) {
if(disable) return;
if(disable) {
return;
}

var xRatio = Math.abs(image.width / ctx.canvas.width),
yRatio = Math.abs(image.height / ctx.canvas.height),
Expand Down
53 changes: 33 additions & 20 deletions source/js/classes/crop-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,6 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
forceAspectRatio = false;

/* PRIVATE FUNCTIONS */

this.setInitMax = function (bool) {
initMax = bool;
};

this.setAllowCropResizeOnCorners = function (bool) {
theArea.setAllowCropResizeOnCorners(bool);
};

this.setDisableCrop = function(value){
theArea.setDisableCrop(value);
drawScene();
};

// Draw Scene
function drawScene() {
// clear canvas
Expand All @@ -104,6 +90,21 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
}
}

this.setInitMax = function (bool) {
initMax = bool;
};

this.setAllowCropResizeOnCorners = function (bool) {
theArea.setAllowCropResizeOnCorners(bool);
};

this.setDisableCrop = function(value){
theArea.setDisableCrop(value);
drawScene();
};



var focusOnCanvas = function () {
elCanvas[0].focus();
};
Expand Down Expand Up @@ -253,7 +254,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var onMouseMove = function (e) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (image !== null) {
var offset = getElementOffset(ctx.canvas),
Expand All @@ -273,7 +276,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir

var onMouseDown = function (e) {
e.preventDefault();
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (!opts.allowPropagation) {
e.stopPropagation();
Expand All @@ -296,7 +301,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var onMouseUp = function (e) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (image !== null) {
var offset = getElementOffset(ctx.canvas),
Expand All @@ -320,7 +327,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var resizeCropAreaByDirection = function (direction) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

var scale;
switch (direction) {
Expand All @@ -340,7 +349,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var moveCropArea = function (direction) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

var center = theArea.getCenterPoint();
var step = 5;
Expand Down Expand Up @@ -371,7 +382,9 @@ angular.module('uiCropper').factory('cropHost', ['$document', '$q', 'cropAreaCir
};

var onKeyDown = function (e) {
if(theArea._disableCrop) return;
if(theArea._disableCrop) {
return;
}

if (image !== null && opts.disableKeyboardAccess !== true) {
var key = e.which;
Expand Down
Loading

0 comments on commit a76c47c

Please sign in to comment.