From 2be5f17127df28245c4cd90c1466ee1685721108 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Mon, 12 Jun 2017 10:55:55 +0200 Subject: [PATCH] Documentation ImageEditor.js --- src/js/includes/ImageEditor.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/js/includes/ImageEditor.js b/src/js/includes/ImageEditor.js index f79d068..468ea1f 100644 --- a/src/js/includes/ImageEditor.js +++ b/src/js/includes/ImageEditor.js @@ -9,7 +9,7 @@ function ImageEditor(canvasId, args) { var _settings = $.extend({ // Type defaults to wallpaper type: 'wallpaper', - // Default texts on the buttons. This van + // Default texts on the buttons buttons: { flat: 'Flat', threeD: '3d', @@ -24,16 +24,16 @@ function ImageEditor(canvasId, args) { // Initialize canvas _canvas = new Canvas(canvasId); + // Let Canvas know which type it is, canvas or wallpaper since it is // accessible for all objects contained within. _canvas.set({ __type: _settings.type }); - /** - * @TODO: Refactor this. Since Canvas knows the type of editor it probably - * better could reside there. - */ + // Adding buttons to the canvas depending on which type is active. + // It might be better that this resides somewhere else, either in Canvas or + // during the initialization of the image editor. if (_canvas.__type === 'canvas') { _canvas.getButtonMenu() .addItem('flat', _settings.buttons.flat, function () { @@ -57,6 +57,7 @@ function ImageEditor(canvasId, args) { .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) { var isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen; @@ -95,6 +96,7 @@ function ImageEditor(canvasId, args) { }; /** + * Loads the image into the canvas. * @param {Number|String} url * @param {Function} callback * @return {ImageEditor}