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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/SearchableView.js

Issue 2734043002: DevTools: fix stretch layout in search/replace bar (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui/searchableView.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 toolbar.appendToolbarItem(this._caseSensitiveButton); 58 toolbar.appendToolbarItem(this._caseSensitiveButton);
59 } 59 }
60 60
61 if (this._searchProvider.supportsRegexSearch()) { 61 if (this._searchProvider.supportsRegexSearch()) {
62 this._regexButton = new UI.ToolbarToggle(Common.UIString('Regex'), ''); 62 this._regexButton = new UI.ToolbarToggle(Common.UIString('Regex'), '');
63 this._regexButton.setText('.*'); 63 this._regexButton.setText('.*');
64 this._regexButton.addEventListener(UI.ToolbarButton.Events.Click, this._to ggleRegexSearch, this); 64 this._regexButton.addEventListener(UI.ToolbarButton.Events.Click, this._to ggleRegexSearch, this);
65 toolbar.appendToolbarItem(this._regexButton); 65 toolbar.appendToolbarItem(this._regexButton);
66 } 66 }
67 67
68 this._footerElement = this._footerElementContainer.createChild('table', 'too lbar-search'); 68 this._footerElement = this._footerElementContainer.createChild('div', 'toolb ar-search');
69 this._footerElement.cellSpacing = 0;
70 69
71 this._firstRowElement = this._footerElement.createChild('tr'); 70 // Build the text input elements.
72 this._secondRowElement = this._footerElement.createChild('tr', 'hidden'); 71 var searchInputElements = this._footerElement.createChild('div', 'toolbar-se arch-inputs');
73 72 var searchControlElement = searchInputElements.createChild('div', 'toolbar-s earch-control');
74 // Column 1
75 var searchControlElementColumn = this._firstRowElement.createChild('td');
76 this._searchControlElement = searchControlElementColumn.createChild('span', 'toolbar-search-control');
77 73
78 this._searchInputElement = UI.HistoryInput.create(); 74 this._searchInputElement = UI.HistoryInput.create();
79 this._searchInputElement.classList.add('search-replace'); 75 this._searchInputElement.classList.add('search-replace');
80 this._searchControlElement.appendChild(this._searchInputElement);
81
82 this._searchInputElement.id = 'search-input-field'; 76 this._searchInputElement.id = 'search-input-field';
83 this._searchInputElement.placeholder = Common.UIString('Find'); 77 this._searchInputElement.placeholder = Common.UIString('Find');
78 searchControlElement.appendChild(this._searchInputElement);
84 79
85 this._matchesElement = this._searchControlElement.createChild('label', 'sear ch-results-matches'); 80 this._matchesElement = searchControlElement.createChild('label', 'search-res ults-matches');
86 this._matchesElement.setAttribute('for', 'search-input-field'); 81 this._matchesElement.setAttribute('for', 'search-input-field');
87 82
88 this._searchNavigationElement = this._searchControlElement.createChild('div' , 'toolbar-search-navigation-controls'); 83 var searchNavigationElement = searchControlElement.createChild('div', 'toolb ar-search-navigation-controls');
89 84
90 this._searchNavigationPrevElement = 85 this._searchNavigationPrevElement =
91 this._searchNavigationElement.createChild('div', 'toolbar-search-navigat ion toolbar-search-navigation-prev'); 86 searchNavigationElement.createChild('div', 'toolbar-search-navigation to olbar-search-navigation-prev');
92 this._searchNavigationPrevElement.addEventListener('click', this._onPrevButt onSearch.bind(this), false); 87 this._searchNavigationPrevElement.addEventListener('click', this._onPrevButt onSearch.bind(this), false);
93 this._searchNavigationPrevElement.title = Common.UIString('Search Previous') ; 88 this._searchNavigationPrevElement.title = Common.UIString('Search Previous') ;
94 89
95 this._searchNavigationNextElement = 90 this._searchNavigationNextElement =
96 this._searchNavigationElement.createChild('div', 'toolbar-search-navigat ion toolbar-search-navigation-next'); 91 searchNavigationElement.createChild('div', 'toolbar-search-navigation to olbar-search-navigation-next');
97 this._searchNavigationNextElement.addEventListener('click', this._onNextButt onSearch.bind(this), false); 92 this._searchNavigationNextElement.addEventListener('click', this._onNextButt onSearch.bind(this), false);
98 this._searchNavigationNextElement.title = Common.UIString('Search Next'); 93 this._searchNavigationNextElement.title = Common.UIString('Search Next');
99 94
100 this._searchInputElement.addEventListener('keydown', this._onSearchKeyDown.b ind(this), true); 95 this._searchInputElement.addEventListener('keydown', this._onSearchKeyDown.b ind(this), true);
101 this._searchInputElement.addEventListener('input', this._onInput.bind(this), false); 96 this._searchInputElement.addEventListener('input', this._onInput.bind(this), false);
102 97
103 this._replaceInputElement = 98 this._replaceInputElement = searchInputElements.createChild('input', 'search -replace toolbar-replace-control');
104 this._secondRowElement.createChild('td').createChild('input', 'search-re place toolbar-replace-control');
105 this._replaceInputElement.addEventListener('keydown', this._onReplaceKeyDown .bind(this), true); 99 this._replaceInputElement.addEventListener('keydown', this._onReplaceKeyDown .bind(this), true);
106 this._replaceInputElement.placeholder = Common.UIString('Replace'); 100 this._replaceInputElement.placeholder = Common.UIString('Replace');
107 101
108 // Column 2 102 // Build the buttons (Find, Previous, Replace, Replace All).
109 this._findButtonElement = 103 this._nonInputElements = this._footerElement.createChild('div', 'toolbar-sea rch-buttons hidden');
lushnikov 2017/03/07 02:26:01 this._buttonsContainer
luoe 2017/03/07 02:28:55 That's clearer, done!
110 this._firstRowElement.createChild('td').createChild('button', 'search-ac tion-button hidden');
111 this._findButtonElement.textContent = Common.UIString('Find');
112 this._findButtonElement.tabIndex = -1;
113 this._findButtonElement.addEventListener('click', this._onFindClick.bind(thi s), false);
114 104
115 this._replaceButtonElement = this._secondRowElement.createChild('td').create Child('button', 'search-action-button'); 105 var findButtonElement = this._nonInputElements.createChild('button', 'search -action-button');
106 findButtonElement.textContent = Common.UIString('Find');
107 findButtonElement.tabIndex = -1;
108 findButtonElement.addEventListener('click', this._onFindClick.bind(this), fa lse);
109
110 var prevButtonElement = this._nonInputElements.createChild('button', 'search -action-button');
111 prevButtonElement.textContent = Common.UIString('Previous');
112 prevButtonElement.tabIndex = -1;
113 prevButtonElement.addEventListener('click', this._onPreviousClick.bind(this) , false);
114
115 this._replaceButtonElement = this._nonInputElements.createChild('button', 's earch-action-button');
116 this._replaceButtonElement.textContent = Common.UIString('Replace'); 116 this._replaceButtonElement.textContent = Common.UIString('Replace');
117 this._replaceButtonElement.disabled = true; 117 this._replaceButtonElement.disabled = true;
118 this._replaceButtonElement.tabIndex = -1; 118 this._replaceButtonElement.tabIndex = -1;
119 this._replaceButtonElement.addEventListener('click', this._replace.bind(this ), false); 119 this._replaceButtonElement.addEventListener('click', this._replace.bind(this ), false);
120 120
121 // Column 3 121 var replaceAllButtonElement = this._nonInputElements.createChild('button', ' search-action-button');
122 this._prevButtonElement = 122 replaceAllButtonElement.textContent = Common.UIString('Replace All');
123 this._firstRowElement.createChild('td').createChild('button', 'search-ac tion-button hidden'); 123 replaceAllButtonElement.addEventListener('click', this._replaceAll.bind(this ), false);
124 this._prevButtonElement.textContent = Common.UIString('Previous');
125 this._prevButtonElement.tabIndex = -1;
126 this._prevButtonElement.addEventListener('click', this._onPreviousClick.bind (this), false);
127 124
128 this._replaceAllButtonElement = 125 // Build the replace checkbox and cancel button.
129 this._secondRowElement.createChild('td').createChild('button', 'search-a ction-button'); 126 this._replaceElement = this._footerElement.createChild('div').createChild('s pan', 'toolbar-replace-checkbox');
130 this._replaceAllButtonElement.textContent = Common.UIString('Replace All');
131 this._replaceAllButtonElement.addEventListener('click', this._replaceAll.bin d(this), false);
132 127
133 // Column 4 128 var replaceLabelElement = UI.createCheckboxLabel(Common.UIString('Replace')) ;
134 this._replaceElement = this._firstRowElement.createChild('td').createChild(' span'); 129 this._replaceCheckboxElement = replaceLabelElement.checkboxElement;
135 130 var uniqueId = ++UI.SearchableView._lastUniqueId;
136 this._replaceLabelElement = UI.createCheckboxLabel(Common.UIString('Replace' )); 131 var replaceCheckboxId = 'search-replace-trigger' + uniqueId;
137 this._replaceCheckboxElement = this._replaceLabelElement.checkboxElement;
138 this._uniqueId = ++UI.SearchableView._lastUniqueId;
139 var replaceCheckboxId = 'search-replace-trigger' + this._uniqueId;
140 this._replaceCheckboxElement.id = replaceCheckboxId; 132 this._replaceCheckboxElement.id = replaceCheckboxId;
141 this._replaceCheckboxElement.addEventListener('change', this._updateSecondRo wVisibility.bind(this), false); 133 this._replaceCheckboxElement.addEventListener('change', this._updateSecondRo wVisibility.bind(this), false);
142 134
143 this._replaceElement.appendChild(this._replaceLabelElement); 135 this._replaceElement.appendChild(replaceLabelElement);
144 136
145 // Column 5 137 var cancelButtonElement = this._footerElement.createChild('div').createChild ('button', 'search-action-button');
146 var cancelButtonElement = this._firstRowElement.createChild('td').createChil d('button', 'search-action-button');
147 cancelButtonElement.textContent = Common.UIString('Cancel'); 138 cancelButtonElement.textContent = Common.UIString('Cancel');
148 cancelButtonElement.tabIndex = -1; 139 cancelButtonElement.tabIndex = -1;
149 cancelButtonElement.addEventListener('click', this.closeSearch.bind(this), f alse); 140 cancelButtonElement.addEventListener('click', this.closeSearch.bind(this), f alse);
150 this._minimalSearchQuerySize = 3; 141 this._minimalSearchQuerySize = 3;
151 142
152 this._loadSetting(); 143 this._loadSetting();
153 } 144 }
154 145
155 /** 146 /**
156 * @param {?Element} element 147 * @param {?Element} element
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 _currentSearchConfig() { 460 _currentSearchConfig() {
470 var query = this._searchInputElement.value; 461 var query = this._searchInputElement.value;
471 var caseSensitive = this._caseSensitiveButton ? this._caseSensitiveButton.to ggled() : false; 462 var caseSensitive = this._caseSensitiveButton ? this._caseSensitiveButton.to ggled() : false;
472 var isRegex = this._regexButton ? this._regexButton.toggled() : false; 463 var isRegex = this._regexButton ? this._regexButton.toggled() : false;
473 return new UI.SearchableView.SearchConfig(query, caseSensitive, isRegex); 464 return new UI.SearchableView.SearchConfig(query, caseSensitive, isRegex);
474 } 465 }
475 466
476 _updateSecondRowVisibility() { 467 _updateSecondRowVisibility() {
477 var secondRowVisible = this._replaceCheckboxElement.checked; 468 var secondRowVisible = this._replaceCheckboxElement.checked;
478 this._footerElementContainer.classList.toggle('replaceable', secondRowVisibl e); 469 this._footerElementContainer.classList.toggle('replaceable', secondRowVisibl e);
479 this._footerElement.classList.toggle('toolbar-search-replace', secondRowVisi ble); 470 this._nonInputElements.classList.toggle('hidden', !secondRowVisible);
480 this._secondRowElement.classList.toggle('hidden', !secondRowVisible);
481 this._prevButtonElement.classList.toggle('hidden', !secondRowVisible);
482 this._findButtonElement.classList.toggle('hidden', !secondRowVisible);
483 this._replaceCheckboxElement.tabIndex = secondRowVisible ? -1 : 0; 471 this._replaceCheckboxElement.tabIndex = secondRowVisible ? -1 : 0;
484 472
485 if (secondRowVisible) 473 if (secondRowVisible)
486 this._replaceInputElement.focus(); 474 this._replaceInputElement.focus();
487 else 475 else
488 this._searchInputElement.focus(); 476 this._searchInputElement.focus();
489 this.doResize(); 477 this.doResize();
490 } 478 }
491 479
492 _replace() { 480 _replace() {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 // Silent catch. 599 // Silent catch.
612 } 600 }
613 601
614 // Otherwise just do a plain text search. 602 // Otherwise just do a plain text search.
615 if (!regex) 603 if (!regex)
616 regex = createPlainTextSearchRegex(query, modifiers); 604 regex = createPlainTextSearchRegex(query, modifiers);
617 605
618 return regex; 606 return regex;
619 } 607 }
620 }; 608 };
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui/searchableView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698