| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Instal global event handlers. | 62 // Instal global event handlers. |
| 63 if (!handlersInstalled) { | 63 if (!handlersInstalled) { |
| 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 | 67 |
| 69 // Support full keyboard accessibility without making things ugly | 68 // Support full keyboard accessibility without making things ugly |
| 70 // for users who click, by hiding some focus outlines when the user | 69 // for users who click, by hiding some focus outlines when the user |
| 71 // clicks anywhere, but showing them when the user presses any key. | 70 // clicks anywhere, but showing them when the user presses any key. |
| 72 this.ownerDocument.body.classList.add('hide-some-focus-outlines'); | 71 this.ownerDocument.body.classList.add('hide-some-focus-outlines'); |
| 73 this.ownerDocument.addEventListener('click', (function(e) { | 72 this.ownerDocument.addEventListener('click', (function(e) { |
| 74 this.ownerDocument.body.classList.add('hide-some-focus-outlines'); | 73 this.ownerDocument.body.classList.add('hide-some-focus-outlines'); |
| 75 return true; | 74 return true; |
| 76 }).bind(this), true); | 75 }).bind(this), true); |
| 77 this.ownerDocument.addEventListener('keydown', (function(e) { | 76 this.ownerDocument.addEventListener('keydown', (function(e) { |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 var detailsControls = details.querySelectorAll('a, input'); | 640 var detailsControls = details.querySelectorAll('a, input'); |
| 642 for (var i = 0; i < detailsControls.length; i++) | 641 for (var i = 0; i < detailsControls.length; i++) |
| 643 detailsControls[i].tabIndex = 0; | 642 detailsControls[i].tabIndex = 0; |
| 644 } | 643 } |
| 645 } | 644 } |
| 646 iter = iter.nextSibling; | 645 iter = iter.nextSibling; |
| 647 } | 646 } |
| 648 }, | 647 }, |
| 649 | 648 |
| 650 /** | 649 /** |
| 651 * Handles the mouse-up and keyboard-up events. This is used to limit the | 650 * Handles the 'searchChanged' event. This is used to limit the number of |
| 652 * number of items to show in the list, when the user is searching for items | 651 * items to show in the list, when the user is searching for items with the |
| 653 * with the search box. Otherwise, if one match is found, the whole list of | 652 * search box. Otherwise, if one match is found, the whole list of |
| 654 * extensions would be shown when we only want the matching items to be | 653 * extensions would be shown when we only want the matching items to be |
| 655 * found. | 654 * found. |
| 656 * @param {Event} e Change event. | 655 * @param {Event} e Change event. |
| 657 * @private | 656 * @private |
| 658 */ | 657 */ |
| 659 upEventHandler_: function(e) { | 658 searchChangedHandler_: function(e) { |
| 660 var searchString = $('search-field').value.toLowerCase(); | 659 var searchString = e.searchText; |
| 661 var child = this.firstChild; | 660 var child = this.firstChild; |
| 662 while (child){ | 661 while (child) { |
| 663 var extension = this.getExtensionWithId_(child.id); | 662 var extension = this.getExtensionWithId_(child.id); |
| 664 if (searchString.length == 0) { | 663 if (searchString.length == 0) { |
| 665 // Show all. | 664 // Show all. |
| 666 child.classList.remove('search-suppress'); | 665 child.classList.remove('search-suppress'); |
| 667 } else { | 666 } else { |
| 668 // If the search string does not appear within the text of the | 667 // If the search string does not appear within the text of the |
| 669 // extension, then hide it. | 668 // extension, then hide it. |
| 670 if ((extension.name.toLowerCase().indexOf(searchString) < 0) && | 669 if ((extension.name.toLowerCase().indexOf(searchString) < 0) && |
| 671 (extension.version.toLowerCase().indexOf(searchString) < 0) && | 670 (extension.version.toLowerCase().indexOf(searchString) < 0) && |
| 672 (extension.description.toLowerCase().indexOf(searchString) < 0)) { | 671 (extension.description.toLowerCase().indexOf(searchString) < 0)) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 ]); | 779 ]); |
| 781 } | 780 } |
| 782 } | 781 } |
| 783 }, | 782 }, |
| 784 }; | 783 }; |
| 785 | 784 |
| 786 return { | 785 return { |
| 787 ExtensionsList: ExtensionsList | 786 ExtensionsList: ExtensionsList |
| 788 }; | 787 }; |
| 789 }); | 788 }); |
| OLD | NEW |