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

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

Issue 4983005: Tabbed options - disable add/edit buttons in content settings lists (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use doc without ument Created 10 years, 1 month 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 | « no previous file | 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.contentSettings', function() { 5 cr.define('options.contentSettings', function() {
6 const List = cr.ui.List; 6 const List = cr.ui.List;
7 const ListItem = cr.ui.ListItem; 7 const ListItem = cr.ui.ListItem;
8 const ArrayDataModel = cr.ui.ArrayDataModel; 8 const ArrayDataModel = cr.ui.ArrayDataModel;
9 9
10 /** 10 /**
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 input.select(); 274 input.select();
275 return; 275 return;
276 } 276 }
277 277
278 patternLabel.classList.toggle('hidden'); 278 patternLabel.classList.toggle('hidden');
279 settingLabel.classList.toggle('hidden'); 279 settingLabel.classList.toggle('hidden');
280 input.classList.toggle('hidden'); 280 input.classList.toggle('hidden');
281 select.classList.toggle('hidden'); 281 select.classList.toggle('hidden');
282 282
283 var doc = this.ownerDocument; 283 var doc = this.ownerDocument;
284 var area = doc.querySelector('div[contentType=' +
285 listItem.contentType + '][mode=' + listItem.mode + ']');
286 area.enableAddAndEditButtons(!editing);
287
284 if (editing) { 288 if (editing) {
285 this.setAttribute('editing', ''); 289 this.setAttribute('editing', '');
286 cr.ui.limitInputWidth(input, this, 20); 290 cr.ui.limitInputWidth(input, this, 20);
287 input.focus(); 291 input.focus();
288 input.select(); 292 input.select();
289 } else { 293 } else {
290 this.removeAttribute('editing'); 294 this.removeAttribute('editing');
291 295
292 var newPattern = input.value; 296 var newPattern = input.value;
293 297
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 var addRow = cr.doc.createElement('button'); 453 var addRow = cr.doc.createElement('button');
450 addRow.textContent = templateData.addExceptionRow; 454 addRow.textContent = templateData.addExceptionRow;
451 this.appendChild(addRow); 455 this.appendChild(addRow);
452 456
453 addRow.onclick = function(event) { 457 addRow.onclick = function(event) {
454 var emptyException = new Object; 458 var emptyException = new Object;
455 emptyException.displayPattern = ''; 459 emptyException.displayPattern = '';
456 emptyException.setting = ''; 460 emptyException.setting = '';
457 self.exceptionsList.addException(emptyException); 461 self.exceptionsList.addException(emptyException);
458 }; 462 };
463 this.addRow = addRow;
459 464
460 var editRow = cr.doc.createElement('button'); 465 var editRow = cr.doc.createElement('button');
461 editRow.textContent = templateData.editExceptionRow; 466 editRow.textContent = templateData.editExceptionRow;
462 this.appendChild(editRow); 467 this.appendChild(editRow);
463 this.editRow = editRow; 468 this.editRow = editRow;
464 469
465 editRow.onclick = function(event) { 470 editRow.onclick = function(event) {
466 self.exceptionsList.editSelectedRow(); 471 self.exceptionsList.editSelectedRow();
467 }; 472 };
468 } 473 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 set mode(mode) { 507 set mode(mode) {
503 return this.setAttribute('mode', mode); 508 return this.setAttribute('mode', mode);
504 }, 509 },
505 510
506 /** 511 /**
507 * Update the enabled/disabled state of the editing buttons based on which 512 * Update the enabled/disabled state of the editing buttons based on which
508 * rows are selected. 513 * rows are selected.
509 */ 514 */
510 updateButtonSensitivity: function() { 515 updateButtonSensitivity: function() {
511 var selectionSize = this.exceptionsList.selectedItems.length; 516 var selectionSize = this.exceptionsList.selectedItems.length;
512 if (this.editRow) 517 if (this.addRow)
513 this.editRow.disabled = selectionSize != 1; 518 this.addRow.disabled = this.addAndEditButtonsDisabled;
519 if (this.editRow) {
520 this.editRow.disabled = selectionSize != 1 ||
521 this.addAndEditButtonsDisabled;
522 }
514 this.removeRow.disabled = selectionSize == 0; 523 this.removeRow.disabled = selectionSize == 0;
515 }, 524 },
516 525
517 /** 526 /**
527 * Manually toggle the enabled/disabled state for the add and edit buttons.
528 * They'll be disabled while another row is being edited.
529 * @param {boolean}
530 */
531 enableAddAndEditButtons: function(enable) {
532 this.addAndEditButtonsDisabled = !enable;
533 this.updateButtonSensitivity();
534 },
535
536 /**
518 * Callback from the selection model. 537 * Callback from the selection model.
519 * @param {!cr.Event} ce Event with change info. 538 * @param {!cr.Event} ce Event with change info.
520 * @private 539 * @private
521 */ 540 */
522 handleOnSelectionChange_: function(ce) { 541 handleOnSelectionChange_: function(ce) {
523 this.updateButtonSensitivity(); 542 this.updateButtonSensitivity();
524 }, 543 },
525 }; 544 };
526 545
527 return { 546 return {
528 ExceptionsListItem: ExceptionsListItem, 547 ExceptionsListItem: ExceptionsListItem,
529 ExceptionsList: ExceptionsList, 548 ExceptionsList: ExceptionsList,
530 ExceptionsArea: ExceptionsArea 549 ExceptionsArea: ExceptionsArea
531 }; 550 };
532 }); 551 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698