diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 18:10:37 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 18:10:37 +0000 |
commit | a4bb001e1a5a666b10f27d4c2b3c1f24c715306e (patch) | |
tree | 5338c18e75268737c97b8e9a12f98aeba48a4dc6 | |
parent | 060574563cd537d137226d4e73f6211407e1fac1 (diff) | |
download | chromium_src-a4bb001e1a5a666b10f27d4c2b3c1f24c715306e.zip chromium_src-a4bb001e1a5a666b10f27d4c2b3c1f24c715306e.tar.gz chromium_src-a4bb001e1a5a666b10f27d4c2b3c1f24c715306e.tar.bz2 |
tabbed content settings:
- Implement add button
- disable edit/remove buttons when appropriate
BUG=48862
TEST=manual
Review URL: http://codereview.chromium.org/3076028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54931 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/options/content_settings_exceptions_area.js | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.js b/chrome/browser/resources/options/content_settings_exceptions_area.js index 979c0d6..b9becdf 100644 --- a/chrome/browser/resources/options/content_settings_exceptions_area.js +++ b/chrome/browser/resources/options/content_settings_exceptions_area.js @@ -264,6 +264,16 @@ cr.define('options.contentSettings', function() { */ addException: function(entry) { this.dataModel.push(entry); + + // When an empty row is added, put it into editing mode. + if (!entry[0] && !entry[1]) { + var index = this.dataModel.length - 1; + var sm = this.selectionModel; + sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index; + this.scrollIndexIntoView(index); + var li = this.getListItemByIndex(index); + li.editing = true; + } }, /** @@ -303,24 +313,27 @@ cr.define('options.contentSettings', function() { decorate: function() { ExceptionsList.decorate($('imagesExceptionsList')); + this.boundHandleOnSelectionChange_ = + cr.bind(this.handleOnSelectionChange_, this); + imagesExceptionsList.selectionModel.addEventListener( + 'change', this.boundHandleOnSelectionChange_); var addRow = cr.doc.createElement('button'); addRow.textContent = templateData.addExceptionRow; this.appendChild(addRow); - // TODO(estade): disable "Edit" when other than exactly 1 row is - // highlighted. var editRow = cr.doc.createElement('button'); editRow.textContent = templateData.editExceptionRow; this.appendChild(editRow); + this.editRow = editRow; - // TODO(estade): disable "Remove" when no row is highlighted. var removeRow = cr.doc.createElement('button'); removeRow.textContent = templateData.removeExceptionRow; this.appendChild(removeRow); + this.removeRow = removeRow; addRow.onclick = function(event) { - // TODO(estade): implement this. + imagesExceptionsList.addException(['', '']); }; editRow.onclick = function(event) { @@ -330,7 +343,28 @@ cr.define('options.contentSettings', function() { removeRow.onclick = function(event) { imagesExceptionsList.removeSelectedRows(); }; - } + + this.updateButtonSensitivity(); + }, + + /** + * Update the enabled/disabled state of the editing buttons based on which + * rows are selected. + */ + updateButtonSensitivity: function() { + var selectionSize = imagesExceptionsList.selectedItems.length; + this.editRow.disabled = selectionSize != 1; + this.removeRow.disabled = selectionSize == 0; + }, + + /** + * Callback from the selection model. + * @param {!cr.Event} ce Event with change info. + * @private + */ + handleOnSelectionChange_: function(ce) { + this.updateButtonSensitivity(); + }, }; return { |