Commit 78b4e3cf authored by estade@chromium.org's avatar estade@chromium.org

Commit inline editable list changes when window loses focus.

BUG=79251
TEST=manual

Review URL: http://codereview.chromium.org/7004058

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86694 0039d316-1c4b-4281-b951-d872f2087c98
parent 32deeda4
...@@ -345,19 +345,6 @@ cr.define('options.contentSettings', function() { ...@@ -345,19 +345,6 @@ cr.define('options.contentSettings', function() {
this.mode = this.getAttribute('mode'); this.mode = this.getAttribute('mode');
var exceptionList = this; var exceptionList = this;
function handleBlur(e) {
// When the blur event happens we do not know who is getting focus so we
// delay this a bit until we know if the new focus node is outside the
// list.
var doc = e.target.ownerDocument;
window.setTimeout(function() {
var activeElement = doc.activeElement;
if (!exceptionList.contains(activeElement))
exceptionList.selectionModel.unselectAll();
}, 50);
}
this.addEventListener('blur', handleBlur, true);
// Whether the exceptions in this list allow an 'Ask every time' option. // Whether the exceptions in this list allow an 'Ask every time' option.
this.enableAskOption = (this.contentType == 'plugins' && this.enableAskOption = (this.contentType == 'plugins' &&
......
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -72,8 +72,8 @@ cr.define('options', function() { ...@@ -72,8 +72,8 @@ cr.define('options', function() {
DeletableItem.prototype.decorate.call(this); DeletableItem.prototype.decorate.call(this);
this.editFields_ = []; this.editFields_ = [];
this.addEventListener('mousedown', this.handleMouseDown_.bind(this)); this.addEventListener('mousedown', this.handleMouseDown_);
this.addEventListener('keydown', this.handleKeyDown_.bind(this)); this.addEventListener('keydown', this.handleKeyDown_);
this.addEventListener('leadChange', this.handleLeadChange_); this.addEventListener('leadChange', this.handleLeadChange_);
}, },
...@@ -328,6 +328,21 @@ cr.define('options', function() { ...@@ -328,6 +328,21 @@ cr.define('options', function() {
}, },
}; };
/**
* Takes care of committing changes to inline editable list items when the
* window loses focus.
*/
function handleWindowBlurs() {
window.addEventListener('blur', function(e) {
var itemAncestor = findAncestor(document.activeElement, function(node) {
return node instanceof InlineEditableItem;
});
if (itemAncestor);
document.activeElement.blur();
});
}
handleWindowBlurs();
var InlineEditableItemList = cr.ui.define('list'); var InlineEditableItemList = cr.ui.define('list');
InlineEditableItemList.prototype = { InlineEditableItemList.prototype = {
......
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