Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/resources/options/inline_editable_list.js

Issue 7004058: Commit inline editable list changes when window loses focus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: handle blurs statically Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/options/content_settings_exceptions_area.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 const DeletableItem = options.DeletableItem; 6 const DeletableItem = options.DeletableItem;
7 const DeletableItemList = options.DeletableItemList; 7 const DeletableItemList = options.DeletableItemList;
8 8
9 /** 9 /**
10 * Creates a new list item with support for inline editing. 10 * Creates a new list item with support for inline editing.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 * @type {HTMLElement} 65 * @type {HTMLElement}
66 * @private 66 * @private
67 */ 67 */
68 editClickTarget_: null, 68 editClickTarget_: null,
69 69
70 /** @inheritDoc */ 70 /** @inheritDoc */
71 decorate: function() { 71 decorate: function() {
72 DeletableItem.prototype.decorate.call(this); 72 DeletableItem.prototype.decorate.call(this);
73 73
74 this.editFields_ = []; 74 this.editFields_ = [];
75 this.addEventListener('mousedown', this.handleMouseDown_.bind(this)); 75 this.addEventListener('mousedown', this.handleMouseDown_);
76 this.addEventListener('keydown', this.handleKeyDown_.bind(this)); 76 this.addEventListener('keydown', this.handleKeyDown_);
77 this.addEventListener('leadChange', this.handleLeadChange_); 77 this.addEventListener('leadChange', this.handleLeadChange_);
78 }, 78 },
79 79
80 /** @inheritDoc */ 80 /** @inheritDoc */
81 selectionChanged: function() { 81 selectionChanged: function() {
82 this.updateEditState(); 82 this.updateEditState();
83 }, 83 },
84 84
85 /** 85 /**
86 * Called when this element gains or loses 'lead' status. Updates editing 86 * Called when this element gains or loses 'lead' status. Updates editing
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 for (var i = 0; i < editFields.length; i++) { 321 for (var i = 0; i < editFields.length; i++) {
322 if (editFields[i] == clickTarget || 322 if (editFields[i] == clickTarget ||
323 editFields[i].staticVersion == clickTarget) { 323 editFields[i].staticVersion == clickTarget) {
324 this.editClickTarget_ = editFields[i]; 324 this.editClickTarget_ = editFields[i];
325 return; 325 return;
326 } 326 }
327 } 327 }
328 }, 328 },
329 }; 329 };
330 330
331 /**
332 * Takes care of committing changes to inline editable list items when the
333 * window loses focus.
334 */
335 function handleWindowBlurs() {
336 window.addEventListener('blur', function(e) {
337 var itemAncestor = findAncestor(document.activeElement, function(node) {
338 return node instanceof InlineEditableItem;
339 });
340 if (itemAncestor);
341 document.activeElement.blur();
342 });
343 }
344 handleWindowBlurs();
345
331 var InlineEditableItemList = cr.ui.define('list'); 346 var InlineEditableItemList = cr.ui.define('list');
332 347
333 InlineEditableItemList.prototype = { 348 InlineEditableItemList.prototype = {
334 __proto__: DeletableItemList.prototype, 349 __proto__: DeletableItemList.prototype,
335 350
336 /** @inheritDoc */ 351 /** @inheritDoc */
337 decorate: function() { 352 decorate: function() {
338 DeletableItemList.prototype.decorate.call(this); 353 DeletableItemList.prototype.decorate.call(this);
339 this.setAttribute('inlineeditable', ''); 354 this.setAttribute('inlineeditable', '');
340 this.addEventListener('hasElementFocusChange', 355 this.addEventListener('hasElementFocusChange',
(...skipping 16 matching lines...) Expand all
357 } 372 }
358 }, 373 },
359 }; 374 };
360 375
361 // Export 376 // Export
362 return { 377 return {
363 InlineEditableItem: InlineEditableItem, 378 InlineEditableItem: InlineEditableItem,
364 InlineEditableItemList: InlineEditableItemList, 379 InlineEditableItemList: InlineEditableItemList,
365 }; 380 };
366 }); 381 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings_exceptions_area.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698