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

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: 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
285 var area = document.querySelector('div[contentType=' +
Mike Mammarella 2010/11/16 00:00:01 You should use the doc variable declared just abov
Evan Stade 2010/11/16 01:31:25 Done.
286 listItem.contentType + '][mode=' + listItem.mode + ']');
287 area.enableAddAndEditButtons(!editing);
288
284 if (editing) { 289 if (editing) {
285 this.setAttribute('editing', ''); 290 this.setAttribute('editing', '');
286 cr.ui.limitInputWidth(input, this, 20); 291 cr.ui.limitInputWidth(input, this, 20);
287 input.focus(); 292 input.focus();
288 input.select(); 293 input.select();
289 } else { 294 } else {
290 this.removeAttribute('editing'); 295 this.removeAttribute('editing');
291 296
292 var newPattern = input.value; 297 var newPattern = input.value;
293 298
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 var addRow = cr.doc.createElement('button'); 454 var addRow = cr.doc.createElement('button');
450 addRow.textContent = templateData.addExceptionRow; 455 addRow.textContent = templateData.addExceptionRow;
451 this.appendChild(addRow); 456 this.appendChild(addRow);
452 457
453 addRow.onclick = function(event) { 458 addRow.onclick = function(event) {
454 var emptyException = new Object; 459 var emptyException = new Object;
455 emptyException.displayPattern = ''; 460 emptyException.displayPattern = '';
456 emptyException.setting = ''; 461 emptyException.setting = '';
457 self.exceptionsList.addException(emptyException); 462 self.exceptionsList.addException(emptyException);
458 }; 463 };
464 this.addRow = addRow;
459 465
460 var editRow = cr.doc.createElement('button'); 466 var editRow = cr.doc.createElement('button');
461 editRow.textContent = templateData.editExceptionRow; 467 editRow.textContent = templateData.editExceptionRow;
462 this.appendChild(editRow); 468 this.appendChild(editRow);
463 this.editRow = editRow; 469 this.editRow = editRow;
464 470
465 editRow.onclick = function(event) { 471 editRow.onclick = function(event) {
466 self.exceptionsList.editSelectedRow(); 472 self.exceptionsList.editSelectedRow();
467 }; 473 };
468 } 474 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 set mode(mode) { 508 set mode(mode) {
503 return this.setAttribute('mode', mode); 509 return this.setAttribute('mode', mode);
504 }, 510 },
505 511
506 /** 512 /**
507 * Update the enabled/disabled state of the editing buttons based on which 513 * Update the enabled/disabled state of the editing buttons based on which
508 * rows are selected. 514 * rows are selected.
509 */ 515 */
510 updateButtonSensitivity: function() { 516 updateButtonSensitivity: function() {
511 var selectionSize = this.exceptionsList.selectedItems.length; 517 var selectionSize = this.exceptionsList.selectedItems.length;
512 if (this.editRow) 518 if (this.addRow)
513 this.editRow.disabled = selectionSize != 1; 519 this.addRow.disabled = this.addAndEditButtonsDisabled;
520 if (this.editRow) {
521 this.editRow.disabled = selectionSize != 1 ||
522 this.addAndEditButtonsDisabled;
523 }
514 this.removeRow.disabled = selectionSize == 0; 524 this.removeRow.disabled = selectionSize == 0;
515 }, 525 },
516 526
517 /** 527 /**
528 * Manually toggle the enabled/disabled state for the add and edit buttons.
529 * They'll be disabled while another row is being edited.
530 * @param {boolean}
531 */
532 enableAddAndEditButtons: function(enable) {
533 this.addAndEditButtonsDisabled = !enable;
534 this.updateButtonSensitivity();
535 },
536
537 /**
518 * Callback from the selection model. 538 * Callback from the selection model.
519 * @param {!cr.Event} ce Event with change info. 539 * @param {!cr.Event} ce Event with change info.
520 * @private 540 * @private
521 */ 541 */
522 handleOnSelectionChange_: function(ce) { 542 handleOnSelectionChange_: function(ce) {
523 this.updateButtonSensitivity(); 543 this.updateButtonSensitivity();
524 }, 544 },
525 }; 545 };
526 546
527 return { 547 return {
528 ExceptionsListItem: ExceptionsListItem, 548 ExceptionsListItem: ExceptionsListItem,
529 ExceptionsList: ExceptionsList, 549 ExceptionsList: ExceptionsList,
530 ExceptionsArea: ExceptionsArea 550 ExceptionsArea: ExceptionsArea
531 }; 551 };
532 }); 552 });
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