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

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

Issue 2881453003: DevTools: update buttons to new style (Closed)
Patch Set: find replace updated too! Created 3 years, 7 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
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 this.registerRequiredCSS('ui/searchableView.css'); 42 this.registerRequiredCSS('ui/searchableView.css');
43 this.element[UI.SearchableView._symbol] = this; 43 this.element[UI.SearchableView._symbol] = this;
44 44
45 this._searchProvider = searchable; 45 this._searchProvider = searchable;
46 this._setting = settingName ? Common.settings.createSetting(settingName, {}) : null; 46 this._setting = settingName ? Common.settings.createSetting(settingName, {}) : null;
47 47
48 this.contentElement.createChild('content'); 48 this.contentElement.createChild('content');
49 this._footerElementContainer = this.contentElement.createChild('div', 'searc h-bar hidden'); 49 this._footerElementContainer = this.contentElement.createChild('div', 'searc h-bar hidden');
50 this._footerElementContainer.style.order = 100; 50 this._footerElementContainer.style.order = 100;
51 51
52 var toolbar = new UI.Toolbar('search-toolbar', this._footerElementContainer) ; 52 var toolbar = new UI.Toolbar('', this._footerElementContainer);
53 53
54 if (this._searchProvider.supportsCaseSensitiveSearch()) { 54 if (this._searchProvider.supportsCaseSensitiveSearch()) {
55 this._caseSensitiveButton = new UI.ToolbarToggle(Common.UIString('Case sen sitive'), ''); 55 this._caseSensitiveButton = new UI.ToolbarToggle(Common.UIString('Case sen sitive'), '');
56 this._caseSensitiveButton.setText('Aa'); 56 this._caseSensitiveButton.setText('Aa');
57 this._caseSensitiveButton.addEventListener(UI.ToolbarButton.Events.Click, this._toggleCaseSensitiveSearch, this); 57 this._caseSensitiveButton.addEventListener(UI.ToolbarButton.Events.Click, this._toggleCaseSensitiveSearch, this);
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'), '');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 this._replaceButtonElement =
107 findButtonElement.textContent = Common.UIString('Find'); 107 UI.createTextButton(Common.UIString('Replace'), this._replace.bind(this) , 'search-action-button');
108 findButtonElement.tabIndex = -1;
109 findButtonElement.addEventListener('click', this._onFindClick.bind(this), fa lse);
110
111 var prevButtonElement = this._buttonsContainer.createChild('button', 'search -action-button');
dgozman 2017/05/15 21:29:00 Let's remove these in a separate patch.
luoe 2017/05/18 21:29:26 Done.
112 prevButtonElement.textContent = Common.UIString('Previous');
113 prevButtonElement.tabIndex = -1;
114 prevButtonElement.addEventListener('click', this._onPreviousClick.bind(this) , false);
115
116 this._replaceButtonElement = this._buttonsContainer.createChild('button', 's earch-action-button');
117 this._replaceButtonElement.textContent = Common.UIString('Replace');
118 this._replaceButtonElement.disabled = true; 108 this._replaceButtonElement.disabled = true;
119 this._replaceButtonElement.tabIndex = -1; 109 this._replaceButtonElement.tabIndex = -1;
120 this._replaceButtonElement.addEventListener('click', this._replace.bind(this ), false); 110 this._buttonsContainer.appendChild(this._replaceButtonElement);
121 111
122 var replaceAllButtonElement = this._buttonsContainer.createChild('button', ' search-action-button'); 112 var replaceAllButtonElement =
123 replaceAllButtonElement.textContent = Common.UIString('Replace All'); 113 UI.createTextButton(Common.UIString('Replace All'), this._replaceAll.bin d(this), 'search-action-button');
124 replaceAllButtonElement.addEventListener('click', this._replaceAll.bind(this ), false); 114 this._buttonsContainer.appendChild(replaceAllButtonElement);
125 115
126 // Build the replace checkbox and cancel button. 116 // Build the replace checkbox and cancel button.
127 this._replaceElement = this._footerElement.createChild('div').createChild('s pan', 'toolbar-replace-checkbox'); 117 this._replaceElement = this._footerElement.createChild('div').createChild('s pan', 'toolbar-replace-checkbox');
128 118
129 var replaceLabelElement = UI.CheckboxLabel.create(Common.UIString('Replace') ); 119 var replaceLabelElement = UI.CheckboxLabel.create(Common.UIString('Replace') );
130 this._replaceCheckboxElement = replaceLabelElement.checkboxElement; 120 this._replaceCheckboxElement = replaceLabelElement.checkboxElement;
131 var uniqueId = ++UI.SearchableView._lastUniqueId;
132 var replaceCheckboxId = 'search-replace-trigger' + uniqueId;
133 this._replaceCheckboxElement.id = replaceCheckboxId;
134 this._replaceCheckboxElement.addEventListener('change', this._updateSecondRo wVisibility.bind(this), false); 121 this._replaceCheckboxElement.addEventListener('change', this._updateSecondRo wVisibility.bind(this), false);
135 122
136 this._replaceElement.appendChild(replaceLabelElement); 123 this._replaceElement.appendChild(replaceLabelElement);
137 124
138 var cancelButtonElement = this._footerElement.createChild('div').createChild ('button', 'search-action-button'); 125 var cancelButtonElement =
139 cancelButtonElement.textContent = Common.UIString('Cancel'); 126 UI.createTextButton(Common.UIString('Cancel'), this.closeSearch.bind(thi s), 'search-action-button');
140 cancelButtonElement.tabIndex = -1; 127 cancelButtonElement.tabIndex = -1;
141 cancelButtonElement.addEventListener('click', this.closeSearch.bind(this), f alse);
142 this._minimalSearchQuerySize = 3; 128 this._minimalSearchQuerySize = 3;
129 this._footerElement.createChild('div').appendChild(cancelButtonElement);
143 130
144 this._loadSetting(); 131 this._loadSetting();
145 } 132 }
146 133
147 /** 134 /**
148 * @param {?Element} element 135 * @param {?Element} element
149 * @return {?UI.SearchableView} 136 * @return {?UI.SearchableView}
150 */ 137 */
151 static fromElement(element) { 138 static fromElement(element) {
152 var view = null; 139 var view = null;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 490 }
504 491
505 _onValueChanged() { 492 _onValueChanged() {
506 if (!this._searchIsVisible) 493 if (!this._searchIsVisible)
507 return; 494 return;
508 delete this._valueChangedTimeoutId; 495 delete this._valueChangedTimeoutId;
509 this._performSearch(false, true); 496 this._performSearch(false, true);
510 } 497 }
511 }; 498 };
512 499
513 UI.SearchableView._lastUniqueId = 0; 500 UI.SearchableView._lastUniqueId = 0;
dgozman 2017/05/15 21:29:00 Remove this one as well.
514 501
515 UI.SearchableView._symbol = Symbol('searchableView'); 502 UI.SearchableView._symbol = Symbol('searchableView');
516 503
517 504
518 /** 505 /**
519 * @interface 506 * @interface
520 */ 507 */
521 UI.Searchable = function() {}; 508 UI.Searchable = function() {};
522 509
523 UI.Searchable.prototype = { 510 UI.Searchable.prototype = {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // Silent catch. 588 // Silent catch.
602 } 589 }
603 590
604 // Otherwise just do a plain text search. 591 // Otherwise just do a plain text search.
605 if (!regex) 592 if (!regex)
606 regex = createPlainTextSearchRegex(query, modifiers); 593 regex = createPlainTextSearchRegex(query, modifiers);
607 594
608 return regex; 595 return regex;
609 } 596 }
610 }; 597 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698