| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A lookup helper function to find the first node that has an id (starting | 9 * A lookup helper function to find the first node that has an id (starting |
| 10 * at |node| and going up the parent chain). | 10 * at |node| and going up the parent chain). |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 var toggleSection = $('dev'); | 52 var toggleSection = $('dev'); |
| 53 if (this.data_.developerMode) { | 53 if (this.data_.developerMode) { |
| 54 toggleSection.classList.add('dev-open'); | 54 toggleSection.classList.add('dev-open'); |
| 55 toggleSection.classList.remove('dev-closed'); | 55 toggleSection.classList.remove('dev-closed'); |
| 56 toggleButton.checked = true; | 56 toggleButton.checked = true; |
| 57 } else { | 57 } else { |
| 58 toggleSection.classList.remove('dev-open'); | 58 toggleSection.classList.remove('dev-open'); |
| 59 toggleSection.classList.add('dev-closed'); | 59 toggleSection.classList.add('dev-closed'); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Install handler for key presses. | 62 // Install handler for search changes. |
| 63 if (!handleInstalled) { | 63 if (!handleInstalled) { |
| 64 this.ownerDocument.addEventListener('keyup', | 64 var searchPage = SearchPage.getInstance(); |
| 65 this.upEventHandler_.bind(this)); | 65 searchPage.addEventListener('searchChanged', |
| 66 this.ownerDocument.addEventListener('mouseup', | 66 this.searchChangedHandler_.bind(this)); |
| 67 this.upEventHandler_.bind(this)); | |
| 68 handleInstalled = true; | 67 handleInstalled = true; |
| 69 } | 68 } |
| 70 }, | 69 }, |
| 71 | 70 |
| 72 /** | 71 /** |
| 73 * Deletes the existing Extension nodes from the page to make room for new | 72 * Deletes the existing Extension nodes from the page to make room for new |
| 74 * ones. It also keeps track of who was showing details so when the | 73 * ones. It also keeps track of who was showing details so when the |
| 75 * extension list gets recreated we can recreate that state. | 74 * extension list gets recreated we can recreate that state. |
| 76 * @param {Array} showingDetails An array that will contain the list of | 75 * @param {Array} showingDetails An array that will contain the list of |
| 77 * id's of extension that had the details section | 76 * id's of extension that had the details section |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 details.classList.add('extension-details-visible'); | 586 details.classList.add('extension-details-visible'); |
| 588 iter.classList.remove('extension-list-item-collaped'); | 587 iter.classList.remove('extension-list-item-collaped'); |
| 589 iter.classList.add('extension-list-item-expanded'); | 588 iter.classList.add('extension-list-item-expanded'); |
| 590 } | 589 } |
| 591 } | 590 } |
| 592 iter = iter.nextSibling; | 591 iter = iter.nextSibling; |
| 593 } | 592 } |
| 594 }, | 593 }, |
| 595 | 594 |
| 596 /** | 595 /** |
| 597 * Handles the mouse-up and keyboard-up events. This is used to limit the | 596 * Handles the 'searchChanged' event. This is used to limit the number of |
| 598 * number of items to show in the list, when the user is searching for items | 597 * items to show in the list, when the user is searching for items with the |
| 599 * with the search box. Otherwise, if one match is found, the whole list of | 598 * search box. Otherwise, if one match is found, the whole list of |
| 600 * extensions would be shown when we only want the matching items to be | 599 * extensions would be shown when we only want the matching items to be |
| 601 * found. | 600 * found. |
| 602 * @param {Event} e Change event. | 601 * @param {Event} e Change event. |
| 603 * @private | 602 * @private |
| 604 */ | 603 */ |
| 605 upEventHandler_: function(e) { | 604 searchChangedHandler_: function(e) { |
| 606 var searchString = $('search-field').value.toLowerCase(); | 605 var searchString = e.searchText; |
| 607 var child = this.firstChild; | 606 var child = this.firstChild; |
| 608 while (child){ | 607 while (child) { |
| 609 var extension = this.getExtensionWithId_(child.id); | 608 var extension = this.getExtensionWithId_(child.id); |
| 610 if (searchString.length == 0) { | 609 if (searchString.length == 0) { |
| 611 // Show all. | 610 // Show all. |
| 612 child.classList.remove('search-suppress'); | 611 child.classList.remove('search-suppress'); |
| 613 } else { | 612 } else { |
| 614 // If the search string does not appear within the text of the | 613 // If the search string does not appear within the text of the |
| 615 // extension, then hide it. | 614 // extension, then hide it. |
| 616 if ((extension.name.toLowerCase().indexOf(searchString) < 0) && | 615 if ((extension.name.toLowerCase().indexOf(searchString) < 0) && |
| 617 (extension.version.toLowerCase().indexOf(searchString) < 0) && | 616 (extension.version.toLowerCase().indexOf(searchString) < 0) && |
| 618 (extension.description.toLowerCase().indexOf(searchString) < 0)) { | 617 (extension.description.toLowerCase().indexOf(searchString) < 0)) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 ]); | 725 ]); |
| 727 } | 726 } |
| 728 } | 727 } |
| 729 }, | 728 }, |
| 730 }; | 729 }; |
| 731 | 730 |
| 732 return { | 731 return { |
| 733 ExtensionsList: ExtensionsList | 732 ExtensionsList: ExtensionsList |
| 734 }; | 733 }; |
| 735 }); | 734 }); |
| OLD | NEW |