Commit ed2e45e0 authored by alekseys@chromium.org's avatar alekseys@chromium.org

Force save changes when Enter is pressed for the controls with buffered updates.

BUG=141426

Review URL: https://codereview.chromium.org/187813007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255558 0039d316-1c4b-4281-b951-d872f2087c98
parent bfd52f94
......@@ -421,7 +421,7 @@ cr.define('print_preview', function() {
clearTimeout(this.textTimeout_);
this.textTimeout_ = null;
}
if (event.keyIdentifier == 'Enter') {
if (event.keyCode == 13 /*enter*/) {
this.preTimeoutValue_ = null;
cr.dispatchSimpleEvent(this, MarginControl.EventType.TEXT_CHANGE);
} else {
......
......@@ -73,6 +73,10 @@ cr.define('print_preview', function() {
enterDocument: function() {
print_preview.Component.prototype.enterDocument.call(this);
fadeOutOption(this.getElement(), true);
this.tracker.add(
this.getChildElement('input.copies'),
'keydown',
this.onTextfieldKeyDown_.bind(this));
this.tracker.add(
this.getChildElement('input.copies'),
'input',
......@@ -168,12 +172,27 @@ cr.define('print_preview', function() {
* @private
*/
onTextfieldTimeout_: function() {
this.textfieldTimeout_ = null;
var copiesVal = this.getChildElement('input.copies').value;
if (copiesVal != '') {
this.copiesTicketItem_.updateValue(copiesVal);
}
},
/**
* Called when a key is pressed on the custom input.
* @param {Event} event Contains the key that was pressed.
* @private
*/
onTextfieldKeyDown_: function(event) {
if (event.keyCode == 13 /*enter*/) {
if (this.textfieldTimeout_) {
clearTimeout(this.textfieldTimeout_);
}
this.onTextfieldTimeout_();
}
},
/**
* Called when a input event occurs on the textfield. Starts an input
* timeout.
......
......@@ -99,6 +99,8 @@ cr.define('print_preview', function() {
this.customInput_, 'blur', this.onCustomInputBlur_.bind(this));
this.tracker.add(
this.customInput_, 'focus', this.onCustomInputFocus_.bind(this));
this.tracker.add(
this.customInput_, 'keydown', this.onCustomInputKeyDown_.bind(this));
this.tracker.add(
this.customInput_, 'keyup', this.onCustomInputKeyUp_.bind(this));
this.tracker.add(
......@@ -183,6 +185,21 @@ cr.define('print_preview', function() {
this.pageRangeTicketItem_.updateValue(this.customInput_.value);
},
/**
* Called when a key is pressed on the custom input.
* @param {Event} event Contains the key that was pressed.
* @private
*/
onCustomInputKeyDown_: function(event) {
if (event.keyCode == 13 /*enter*/) {
if (this.customInputTimeout_) {
clearTimeout(this.customInputTimeout_);
this.customInputTimeout_ = null;
}
this.pageRangeTicketItem_.updateValue(this.customInput_.value);
}
},
/**
* Called when a key is pressed on the custom input.
* @param {Event} event Contains the key that was pressed.
......@@ -191,10 +208,9 @@ cr.define('print_preview', function() {
onCustomInputKeyUp_: function(event) {
if (this.customInputTimeout_) {
clearTimeout(this.customInputTimeout_);
this.customInputTimeout_ = null;
}
if (event.keyIdentifier == 'Enter') {
this.pageRangeTicketItem_.updateValue(this.customInput_.value);
} else {
if (event.keyCode != 13 /*enter*/) {
this.customRadio_.checked = true;
this.customInputTimeout_ = setTimeout(
this.onCustomInputTimeout_.bind(this),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment