| Index: ui/file_manager/gallery/js/image_editor/image_editor.js
|
| diff --git a/ui/file_manager/gallery/js/image_editor/image_editor.js b/ui/file_manager/gallery/js/image_editor/image_editor.js
|
| index 9db0b9aaa2483838fbd7ffd5cf00855c8a1439cd..0878978ecfcd5e4ad16683417842b4d4a09afbe0 100644
|
| --- a/ui/file_manager/gallery/js/image_editor/image_editor.js
|
| +++ b/ui/file_manager/gallery/js/image_editor/image_editor.js
|
| @@ -44,6 +44,11 @@ function ImageEditor(
|
| */
|
| this.settingUpNextMode_ = false;
|
|
|
| + /**
|
| + * @private {boolean}
|
| + */
|
| + this.showingAlertDialog_ = false;
|
| +
|
| ImageUtil.removeChildren(this.container_);
|
|
|
| this.viewport_ = viewport;
|
| @@ -679,6 +684,21 @@ ImageEditor.prototype.leaveModeInternal_ = function(commit, leaveToSwitchMode) {
|
| if (!this.currentMode_)
|
| return;
|
|
|
| + // If the current mode is image-resize, and commit is required,
|
| + // leaving mode should be stopped when an input value is not valid.
|
| + if(commit && this.currentMode_.name === 'image-resize') {
|
| + var imageResizeMode = /** @type {!ImageEditor.Mode.ImageResize} */
|
| + (this.currentMode_);
|
| + if(!imageResizeMode.isInputValid()) {
|
| + this.showingAlertDialog_ = true;
|
| +
|
| + imageResizeMode.showAlertDialog(function() {
|
| + this.showingAlertDialog_ = false;
|
| + }.bind(this));
|
| + return;
|
| + }
|
| + }
|
| +
|
| this.modeToolbar_.show(false);
|
|
|
| // If it leaves to switch mode, do not restore screen size since the next mode
|
| @@ -751,6 +771,8 @@ ImageEditor.prototype.onKeyDown = function(event) {
|
| switch (util.getKeyModifiers(event) + event.key) {
|
| case 'Escape':
|
| case 'Enter':
|
| + if (this.showingAlertDialog_)
|
| + return false;
|
| if (this.getMode()) {
|
| this.leaveModeInternal_(event.key === 'Enter',
|
| false /* not to switch mode */);
|
| @@ -1298,6 +1320,73 @@ ImageEditor.Toolbar.prototype.addButton = function(
|
| };
|
|
|
| /**
|
| + * Add a checkbox
|
| + *
|
| + * @param {string} name Checkbox name
|
| + * @param {string} title Checkbox title
|
| + * @param {function(Event)} handler onChange handler
|
| + * @param {boolean} value Default value
|
| + * @return {!HTMLElement} Checkbox Element
|
| + */
|
| +ImageEditor.Toolbar.prototype.addCheckbox = function(
|
| + name, title, handler, value) {
|
| +
|
| + var checkbox = /** @type {!HTMLElement} */
|
| + (document.createElement('paper-checkbox'));
|
| + checkbox.textContent = strf(title);
|
| + checkbox.addEventListener('change', handler, false);
|
| + checkbox.checked = value;
|
| + checkbox.classList.add('checkbox', name);
|
| +
|
| + this.add(checkbox);
|
| +
|
| + return checkbox;
|
| +};
|
| +
|
| +/**
|
| + * Add a input field.
|
| + *
|
| + * @param {string} name Input name
|
| + * @param {string} title Input title
|
| + * @param {function(Event)} handler onInput handler
|
| + * @param {string|number} value Default value
|
| + * @param {string=} opt_unit Unit for an input field
|
| + * @return {!HTMLElement} Input Element
|
| + */
|
| +ImageEditor.Toolbar.prototype.addInput = function(
|
| + name, title, handler, value, opt_unit) {
|
| +
|
| + var input = /** @type {!HTMLElement} */ (document.createElement('div'));
|
| + input.classList.add('input', name);
|
| +
|
| + var text = document.createElement('paper-input');
|
| + text.setAttribute('label', strf(title));
|
| + text.classList.add('text', name);
|
| + text.value = value;
|
| + text.addEventListener('input', handler, false);
|
| + input.appendChild(text);
|
| +
|
| + if(opt_unit) {
|
| + var unit_label = document.createElement('span');
|
| + unit_label.textContent = opt_unit;
|
| + unit_label.classList.add('unit_label');
|
| + input.appendChild(unit_label);
|
| + }
|
| +
|
| + input.name = name;
|
| + input.getValue = function(text) {
|
| + return text.value;
|
| + }.bind(this, text);
|
| + input.setValue = function(text, value) {
|
| + text.value = value;
|
| + }.bind(this, text);
|
| +
|
| + this.add(input);
|
| +
|
| + return input;
|
| +};
|
| +
|
| +/**
|
| * Add a range control (scalar value picker).
|
| *
|
| * @param {string} name An option name.
|
|
|