| Index: ui/file_manager/gallery/js/image_editor/image_transform.js
|
| diff --git a/ui/file_manager/gallery/js/image_editor/image_transform.js b/ui/file_manager/gallery/js/image_editor/image_transform.js
|
| index dbb96516879ed581a5c6492ba49a69d0a47cf655..91d7a96b73c9221e51c2ab357c08b0817593bb7e 100644
|
| --- a/ui/file_manager/gallery/js/image_editor/image_transform.js
|
| +++ b/ui/file_manager/gallery/js/image_editor/image_transform.js
|
| @@ -77,6 +77,38 @@ ImageEditor.Mode.Crop.prototype.setUp = function() {
|
| };
|
|
|
| /**
|
| + * @override
|
| + */
|
| +ImageEditor.Mode.Crop.prototype.createTools = function(toolbar) {
|
| + var aspects = {
|
| + GALLERY_ASPECT_RATIO_1_1: 1 / 1,
|
| + GALLERY_ASPECT_RATIO_6_4: 6 / 4,
|
| + GALLERY_ASPECT_RATIO_7_5: 7 / 5,
|
| + GALLERY_ASPECT_RATIO_16_9: 16 / 9
|
| + };
|
| + for (name in aspects) {
|
| + toolbar.addButton(
|
| + name,
|
| + name,
|
| + function(aspect, event) {
|
| + var button = event.target;
|
| + if (button.classList.contains('selected')) {
|
| + button.classList.remove('selected');
|
| + this.cropRect_.fixedAspectRatio = null;
|
| + } else {
|
| + var selectedButtons =
|
| + toolbar.element.querySelectorAll('button.selected');
|
| + for (var i = 0; i < selectedButtons.length; i++) {
|
| + selectedButtons[i].classList.remove('selected');
|
| + }
|
| + button.classList.add('selected');
|
| + this.cropRect_.fixedAspectRatio = aspect;
|
| + }
|
| + }.bind(this, aspects[name]));
|
| + }
|
| +};
|
| +
|
| +/**
|
| * Handles resizing of the window and updates the crop rectangle.
|
| * @private
|
| */
|
| @@ -247,6 +279,13 @@ function DraggableRect(rect, viewport) {
|
| */
|
| this.dragMode_ = null;
|
|
|
| + /**
|
| + * Fixed aspect ratio.
|
| + * The aspect ratio is not fixed when null.
|
| + * @type {?number}
|
| + */
|
| + this.fixedAspectRatio = null;
|
| +
|
| Object.seal(this);
|
| }
|
|
|
| @@ -501,7 +540,9 @@ DraggableRect.prototype.getDragHandler = function(
|
| }
|
|
|
| // Update aspect ratio.
|
| - if (shiftKey)
|
| + if (this.fixedAspectRatio)
|
| + this.forceAspectRatio(this.fixedAspectRatio, clipRect);
|
| + else if (shiftKey)
|
| this.forceAspectRatio(initialWidth / initialHeight, clipRect);
|
| }.bind(this);
|
| }
|
|
|