Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * Copyright (C) 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * | 10 * |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 this._searchInputElement.addEventListener('input', this._onInput.bind(this), false); | 96 this._searchInputElement.addEventListener('input', this._onInput.bind(this), false); |
| 97 | 97 |
| 98 this._replaceInputElement = | 98 this._replaceInputElement = |
| 99 searchInputElements.createChild('input', 'search-replace toolbar-replace -control hidden'); | 99 searchInputElements.createChild('input', 'search-replace toolbar-replace -control hidden'); |
| 100 this._replaceInputElement.addEventListener('keydown', this._onReplaceKeyDown .bind(this), true); | 100 this._replaceInputElement.addEventListener('keydown', this._onReplaceKeyDown .bind(this), true); |
| 101 this._replaceInputElement.placeholder = Common.UIString('Replace'); | 101 this._replaceInputElement.placeholder = Common.UIString('Replace'); |
| 102 | 102 |
| 103 // Build the buttons (Find, Previous, Replace, Replace All). | 103 // Build the buttons (Find, Previous, Replace, Replace All). |
| 104 this._buttonsContainer = this._footerElement.createChild('div', 'toolbar-sea rch-buttons hidden'); | 104 this._buttonsContainer = this._footerElement.createChild('div', 'toolbar-sea rch-buttons hidden'); |
| 105 | 105 |
| 106 var findButtonElement = this._buttonsContainer.createChild('button', 'search -action-button'); | 106 var findButtonElement = |
| 107 findButtonElement.textContent = Common.UIString('Find'); | 107 UI.createTextButton(Common.UIString('Find'), this._onFindClick.bind(this ), 'search-action-button'); |
| 108 findButtonElement.tabIndex = -1; | 108 findButtonElement.tabIndex = -1; |
| 109 findButtonElement.addEventListener('click', this._onFindClick.bind(this), fa lse); | 109 this._buttonsContainer.appendChild(findButtonElement); |
| 110 | 110 |
| 111 var prevButtonElement = this._buttonsContainer.createChild('button', 'search -action-button'); | 111 var prevButtonElement = |
| 112 prevButtonElement.textContent = Common.UIString('Previous'); | 112 UI.createTextButton(Common.UIString('Previous'), this._onPreviousClick.b ind(this), 'search-action-button'); |
| 113 prevButtonElement.tabIndex = -1; | 113 prevButtonElement.tabIndex = -1; |
| 114 prevButtonElement.addEventListener('click', this._onPreviousClick.bind(this) , false); | 114 this._buttonsContainer.appendChild(prevButtonElement); |
| 115 | 115 |
| 116 this._replaceButtonElement = this._buttonsContainer.createChild('button', 's earch-action-button'); | 116 this._replaceButtonElement = |
| 117 this._replaceButtonElement.textContent = Common.UIString('Replace'); | 117 UI.createTextButton(Common.UIString('Replace'), this._replace.bind(this) , 'search-action-button'); |
| 118 this._replaceButtonElement.disabled = true; | 118 this._replaceButtonElement.disabled = true; |
| 119 this._replaceButtonElement.tabIndex = -1; | 119 this._replaceButtonElement.tabIndex = -1; |
| 120 this._replaceButtonElement.addEventListener('click', this._replace.bind(this ), false); | 120 this._buttonsContainer.appendChild(this._replaceButtonElement); |
| 121 | 121 |
| 122 var replaceAllButtonElement = this._buttonsContainer.createChild('button', ' search-action-button'); | 122 var replaceAllButtonElement = |
| 123 replaceAllButtonElement.textContent = Common.UIString('Replace All'); | 123 UI.createTextButton(Common.UIString('Replace All'), this._replaceAll.bin d(this), 'search-action-button'); |
| 124 replaceAllButtonElement.addEventListener('click', this._replaceAll.bind(this ), false); | 124 this._buttonsContainer.appendChild(replaceAllButtonElement); |
| 125 | 125 |
| 126 // Build the replace checkbox and cancel button. | 126 // Build the replace checkbox and cancel button. |
| 127 this._replaceElement = this._footerElement.createChild('div').createChild('s pan', 'toolbar-replace-checkbox'); | 127 this._replaceElement = this._footerElement.createChild('div').createChild('s pan', 'toolbar-replace-checkbox'); |
| 128 | 128 |
| 129 var replaceLabelElement = UI.CheckboxLabel.create(Common.UIString('Replace') ); | 129 var replaceLabelElement = UI.CheckboxLabel.create(Common.UIString('Replace') ); |
| 130 this._replaceCheckboxElement = replaceLabelElement.checkboxElement; | 130 this._replaceCheckboxElement = replaceLabelElement.checkboxElement; |
| 131 var uniqueId = ++UI.SearchableView._lastUniqueId; | |
|
einbinder
2017/05/31 21:20:10
What was this doing? Looks interesting.
luoe
2017/05/31 21:42:49
It looks like there used to be a bug when multiple
| |
| 132 var replaceCheckboxId = 'search-replace-trigger' + uniqueId; | |
| 133 this._replaceCheckboxElement.id = replaceCheckboxId; | |
| 134 this._replaceCheckboxElement.addEventListener('change', this._updateSecondRo wVisibility.bind(this), false); | 131 this._replaceCheckboxElement.addEventListener('change', this._updateSecondRo wVisibility.bind(this), false); |
| 135 | 132 |
| 136 this._replaceElement.appendChild(replaceLabelElement); | 133 this._replaceElement.appendChild(replaceLabelElement); |
| 137 | 134 |
| 138 var cancelButtonElement = this._footerElement.createChild('div').createChild ('button', 'search-action-button'); | 135 var cancelButtonElement = |
| 139 cancelButtonElement.textContent = Common.UIString('Cancel'); | 136 UI.createTextButton(Common.UIString('Cancel'), this.closeSearch.bind(thi s), 'search-action-button'); |
| 140 cancelButtonElement.tabIndex = -1; | 137 cancelButtonElement.tabIndex = -1; |
| 141 cancelButtonElement.addEventListener('click', this.closeSearch.bind(this), f alse); | |
| 142 this._minimalSearchQuerySize = 3; | 138 this._minimalSearchQuerySize = 3; |
| 139 this._footerElement.createChild('div').appendChild(cancelButtonElement); | |
| 143 | 140 |
| 144 this._loadSetting(); | 141 this._loadSetting(); |
| 145 } | 142 } |
| 146 | 143 |
| 147 /** | 144 /** |
| 148 * @param {?Element} element | 145 * @param {?Element} element |
| 149 * @return {?UI.SearchableView} | 146 * @return {?UI.SearchableView} |
| 150 */ | 147 */ |
| 151 static fromElement(element) { | 148 static fromElement(element) { |
| 152 var view = null; | 149 var view = null; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 } | 500 } |
| 504 | 501 |
| 505 _onValueChanged() { | 502 _onValueChanged() { |
| 506 if (!this._searchIsVisible) | 503 if (!this._searchIsVisible) |
| 507 return; | 504 return; |
| 508 delete this._valueChangedTimeoutId; | 505 delete this._valueChangedTimeoutId; |
| 509 this._performSearch(false, true); | 506 this._performSearch(false, true); |
| 510 } | 507 } |
| 511 }; | 508 }; |
| 512 | 509 |
| 513 UI.SearchableView._lastUniqueId = 0; | |
| 514 | 510 |
| 515 UI.SearchableView._symbol = Symbol('searchableView'); | 511 UI.SearchableView._symbol = Symbol('searchableView'); |
| 516 | 512 |
| 517 | 513 |
| 518 /** | 514 /** |
| 519 * @interface | 515 * @interface |
| 520 */ | 516 */ |
| 521 UI.Searchable = function() {}; | 517 UI.Searchable = function() {}; |
| 522 | 518 |
| 523 UI.Searchable.prototype = { | 519 UI.Searchable.prototype = { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 // Silent catch. | 597 // Silent catch. |
| 602 } | 598 } |
| 603 | 599 |
| 604 // Otherwise just do a plain text search. | 600 // Otherwise just do a plain text search. |
| 605 if (!regex) | 601 if (!regex) |
| 606 regex = createPlainTextSearchRegex(query, modifiers); | 602 regex = createPlainTextSearchRegex(query, modifiers); |
| 607 | 603 |
| 608 return regex; | 604 return regex; |
| 609 } | 605 } |
| 610 }; | 606 }; |
| OLD | NEW |