Documentation ImageEditor.js

This commit is contained in:
Erik Tiekstra
2017-06-12 10:55:55 +02:00
parent e6e0cd8b7e
commit 2be5f17127
+7 -5
View File
@@ -9,7 +9,7 @@ function ImageEditor(canvasId, args) {
var _settings = $.extend({ var _settings = $.extend({
// Type defaults to wallpaper // Type defaults to wallpaper
type: 'wallpaper', type: 'wallpaper',
// Default texts on the buttons. This van // Default texts on the buttons
buttons: { buttons: {
flat: 'Flat', flat: 'Flat',
threeD: '3d', threeD: '3d',
@@ -24,16 +24,16 @@ function ImageEditor(canvasId, args) {
// Initialize canvas // Initialize canvas
_canvas = new Canvas(canvasId); _canvas = new Canvas(canvasId);
// Let Canvas know which type it is, canvas or wallpaper since it is // Let Canvas know which type it is, canvas or wallpaper since it is
// accessible for all objects contained within. // accessible for all objects contained within.
_canvas.set({ _canvas.set({
__type: _settings.type __type: _settings.type
}); });
/** // Adding buttons to the canvas depending on which type is active.
* @TODO: Refactor this. Since Canvas knows the type of editor it probably // It might be better that this resides somewhere else, either in Canvas or
* better could reside there. // during the initialization of the image editor.
*/
if (_canvas.__type === 'canvas') { if (_canvas.__type === 'canvas') {
_canvas.getButtonMenu() _canvas.getButtonMenu()
.addItem('flat', _settings.buttons.flat, function () { .addItem('flat', _settings.buttons.flat, function () {
@@ -57,6 +57,7 @@ function ImageEditor(canvasId, args) {
.render(); .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(e) {
var isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen; 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 {Number|String} url
* @param {Function} callback * @param {Function} callback
* @return {ImageEditor} * @return {ImageEditor}