P5-1922 fix jslint warnings

This commit is contained in:
Ruslan Getmansky
2017-11-03 15:53:11 +02:00
parent 3e04bc68d9
commit 8ff2614047
20 changed files with 193 additions and 157 deletions
+2 -3
View File
@@ -1,10 +1,9 @@
'use strict';
var util = require('./util');
/* globals fabric */
/**
* Handles 3d image of canvas products.
* @param {canvas}
* @param {canvas} canvas
*/
function ThreeDHandler(canvas) {
var _overlay = new fabric.Group();
+3 -2
View File
@@ -1,8 +1,9 @@
'use strict';
/* globals fabric */
/**
* ApertureHandler takes care of the bars around the image to show what area has been/will be cropped.
* @param {canvas}
* @param {canvas} canvas
*/
function ApertureHandler(canvas) {
var _items = {x: [], y: []};
@@ -34,7 +35,7 @@ function ApertureHandler(canvas) {
/**
* Applies configuration to the apertures apertures on the viewport
* @param {string} axis
* @param {viewport}
* @param {viewport} viewport
*/
this.apply = function (axis, viewport) {
this.getApertures(axis).forEach(function (o) {
-2
View File
@@ -1,8 +1,6 @@
'use strict';
var TextButton = require('./TextButton');
var config = require('./config');
var util = require('./util');
/**
* Creates the menu with text-buttons settings provided. Settings will override
+1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $, fabric */
var config = require('./config');
var util = require('./util');
+1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $, fabric */
var config = require('./config');
var util = require('./util');
+1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $, fabric */
var DragHandle = require('./DragHandle');
var config = require('./config');
+1
View File
@@ -13,6 +13,7 @@ function Draggable(img, boundingRect) {
* Triggers when object is moved
*/
function onMove() {
/*jshint validthis: true */
this.__dragged = true;
this.canvas.disableScroll();
+5 -4
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals fabric */
var config = require('./config');
@@ -6,10 +7,6 @@ function FrameHandler(viewport) {
var _frames;
var _frameType = 'image';
function init() {
initFrames();
}
function getFramesAsArray() {
return [
_frames.top, _frames.right, _frames.bottom, _frames.left
@@ -34,6 +31,10 @@ function FrameHandler(viewport) {
});
}
function init() {
initFrames();
}
init();
/**
+2 -1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals fabric */
function GoreHandler(viewport) {
var _enabled = false;
@@ -39,7 +40,7 @@ function GoreHandler(viewport) {
if (!_enabled) {
viewport.canvas.renderAll();
return;
return this;
}
var bounds = viewport.getBounds();
+1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $ */
function ImageDataHandler(img) {
+3 -2
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $, fabric */
var Canvas = require('./Canvas');
var util = require('./util');
@@ -68,7 +69,7 @@ function ImageEditor(canvasId, args) {
_canvas.getButtonMenu().render();
// Binding fullscreen change event to the image-editor wrapper. This way we can set the correct button active.
$(_canvas.getSelectionElement().parentNode).bind('webkitfullscreenchange mozfullscreenchange fullscreenchange', function(e) {
$(_canvas.getSelectionElement().parentNode).bind('webkitfullscreenchange mozfullscreenchange fullscreenchange', function() {
var isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
if (isFullscreen) {
@@ -129,7 +130,7 @@ function ImageEditor(canvasId, args) {
this.loadImage = function (url, callback) {
callback = typeof callback === 'function' ? callback : function () {};
fabric.util.loadImage(this._url = url, function (obj) {
if(obj == null) {
if(obj === null) {
throw new Error('Error loading ' + url);
}
var img = new fabric.Image(obj);
+10 -9
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals fabric */
var util = require('./util');
var TextButton = require('./TextButton');
@@ -9,15 +10,6 @@ function RulerHandler(viewport) {
var _lines = { x: null, y: null };
var _rect = { x: null, y: null };
var Event = {
/**
* Triggers when handlebar is moved
*/
onMove: function () {
updateRulerText(this);
}
};
function updateRulerText(ruler) {
var axis = ruler.axis;
var bounds = viewport.getBounds();
@@ -32,6 +24,15 @@ function RulerHandler(viewport) {
ruler.setText(Math.round(dim * 100) / 100 + ' ' + viewport.getData().dim.units);
}
var Event = {
/**
* Triggers when handlebar is moved
*/
onMove: function () {
updateRulerText(this);
}
};
/**
* @return {fabric.Line}
*/
+14 -7
View File
@@ -1,13 +1,18 @@
'use strict';
/* globals $, fabric */
var config = require('./config');
/**
* Creates a text-button with text/settings provided.
* @param {String} text - text to be shown inside the button
* @param {string} id
* @param {string} text - text to be shown inside the button
* @param {Object} settings
* @param {bool} isActive
*/
function TextButton(id, text, settings, isActive) {
/* jshint unused:false */
fabric.Group.call(this);
var __active = isActive || false;
@@ -65,7 +70,15 @@ function TextButton(id, text, settings, isActive) {
return this.__active;
};
function toggleActiveStyle() {
/*jshint validthis: true */
_rect.setFill(_rectSettings[this.isActive() ? 'activeFill' : 'fill']);
_text.setFill(_textSettings[this.isActive() ? 'activeFill' : 'fill']);
this.setText(_textSettings[this.isActive() ? 'textActive' : 'text']);
}
function handleMouseDown(e) {
/*jshint validthis: true */
toggleActiveStyle.call(this);
_callback.call(this, e);
@@ -74,12 +87,6 @@ function TextButton(id, text, settings, isActive) {
}
}
function toggleActiveStyle() {
_rect.setFill(_rectSettings[this.isActive() ? 'activeFill' : 'fill']);
_text.setFill(_textSettings[this.isActive() ? 'activeFill' : 'fill']);
this.setText(_textSettings[this.isActive() ? 'textActive' : 'text']);
}
this.onClick = function(callback) {
_callback = callback || function() {};
this.on('mousedown', function (e) {
+47 -46
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $, fabric */
var FrameHandler = require('./FrameHandler');
var GoreHandler = require('./GoreHandler');
@@ -12,52 +13,6 @@ function Viewport(canvas) {
var _rect;
var self = this;
/**
* Applies viewport to page
*/
function apply() {
var cropData = canvas.getImageData().getCropData();
canvas.remove(_rect);
_rect = new fabric.Rect({
evented: false,
fill: 'transparent',
width: _data.width,
height: _data.height,
stroke: '#fff',
strokeWidth: canvas.__type === 'canvas' ? 0 : _borderWidth
});
_rect.width += _borderWidth;
_rect.height += _borderWidth;
_rect.addTo(canvas).center().setCoords();
if (cropData) {
// Calculate the new position after screenresize and when the
// image already has been cropped to a certain position.
var left = _rect.left + _rect.strokeWidth - (canvas.getImage().width * canvas.getImage().scaleX * cropData.x);
var top = _rect.top + _rect.strokeWidth - (canvas.getImage().height * canvas.getImage().scaleY * cropData.y);
canvas.getImage().set({ left: left, top: top }).setCoords();
} else {
canvas.getImage().center().setCoords();
}
canvas.getImage().drag.enable(calcMinMaxBoundsForRect(_rect.getInsideBoundingRect(), canvas.getImage()));
canvas.getApertures().apply(_data.axis, _rect.getBoundingRect());
if (canvas.__type !== 'canvas') {
drawBeams();
} else {
self.setFrame(self.getFrameHandler().getFrameType());
}
canvas.getDragbars().apply();
// Apertures sometimes overlaps the viewports bounding rect.
// Solve this by bringing it to the front after apertures are applied.
_rect.bringToFront();
}
/**
* Render the diagonal lines from viewport to edge of the canvas
*/
@@ -108,6 +63,52 @@ function Viewport(canvas) {
};
}
/**
* Applies viewport to page
*/
function apply() {
var cropData = canvas.getImageData().getCropData();
canvas.remove(_rect);
_rect = new fabric.Rect({
evented: false,
fill: 'transparent',
width: _data.width,
height: _data.height,
stroke: '#fff',
strokeWidth: canvas.__type === 'canvas' ? 0 : _borderWidth
});
_rect.width += _borderWidth;
_rect.height += _borderWidth;
_rect.addTo(canvas).center().setCoords();
if (cropData) {
// Calculate the new position after screenresize and when the
// image already has been cropped to a certain position.
var left = _rect.left + _rect.strokeWidth - (canvas.getImage().width * canvas.getImage().scaleX * cropData.x);
var top = _rect.top + _rect.strokeWidth - (canvas.getImage().height * canvas.getImage().scaleY * cropData.y);
canvas.getImage().set({ left: left, top: top }).setCoords();
} else {
canvas.getImage().center().setCoords();
}
canvas.getImage().drag.enable(calcMinMaxBoundsForRect(_rect.getInsideBoundingRect(), canvas.getImage()));
canvas.getApertures().apply(_data.axis, _rect.getBoundingRect());
if (canvas.__type !== 'canvas') {
drawBeams();
} else {
self.setFrame(self.getFrameHandler().getFrameType());
}
canvas.getDragbars().apply();
// Apertures sometimes overlaps the viewports bounding rect.
// Solve this by bringing it to the front after apertures are applied.
_rect.bringToFront();
}
this.canvas = canvas;
this.getBounds = function () {
+1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $, fabric */
var Draggable = require('./Draggable');
var util = require('./util');
+1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals window */
(function() {
+1
View File
@@ -1,4 +1,5 @@
'use strict';
/* globals $, window */
function isMobile() {
return $(window).width() < 768;
+1 -1
View File
@@ -3,7 +3,7 @@
var isFullscreen = require('./is-fullscreen');
/**
* Toggles the full screen state for passed DOM object
* @param {HTMLElement} elm
* @param {HTMLElement} elem
*/
function toggleFullscreen(elem) {
if (isFullscreen()) {