Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/content/ui/filters-search.js

Issue 29357368: Issue 4525 - Filter Preferences: Move findbar to the top of the filters list (Closed) Base URL: https://hg.adblockplus.org/adblockplus
Patch Set: Created Oct. 14, 2016, 8:09 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 let text = E("findbar-textbox").value.trim(); 87 let text = E("findbar-textbox").value.trim();
88 if (!text) 88 if (!text)
89 return ""; 89 return "";
90 90
91 let caseSensitive = E("findbar-case-sensitive").checked; 91 let caseSensitive = E("findbar-case-sensitive").checked;
92 92
93 if (typeof direction == "undefined") 93 if (typeof direction == "undefined")
94 direction = (text == this.lastSearchString ? 1 : 0); 94 direction = (text == this.lastSearchString ? 1 : 0);
95 this.lastSearchString = text; 95 this.lastSearchString = text;
96 96
97 function normalizeString(string) 97 let normalizeString = (caseSensitive ?
98 { 98 string => string :
99 return caseSensitive ? string : string.toLowerCase(); 99 string => string.toLowerCase());
Wladimir Palant 2016/10/14 08:12:12 Unrelated change but I realized that this can be f
100 }
101 100
102 function findText(startIndex) 101 function findText(startIndex)
103 { 102 {
104 let list = E("filtersTree"); 103 let list = E("filtersTree");
105 let col = list.columns.getNamedColumn("col-filter"); 104 let col = list.columns.getNamedColumn("col-filter");
106 let count = list.view.rowCount; 105 let count = list.view.rowCount;
107 for (let i = startIndex + direction; i >= 0 && i < count; i += (direction || 1)) 106 for (let i = startIndex + direction; i >= 0 && i < count; i += (direction || 1))
108 { 107 {
109 let filter = normalizeString(list.view.getCellText(i, col)); 108 let filter = normalizeString(list.view.getCellText(i, col));
110 if (filter.indexOf(text) >= 0) 109 if (filter.indexOf(text) >= 0)
111 { 110 {
112 FilterView.selectRow(i); 111 FilterView.selectRow(i, true);
113 return true; 112 return true;
114 } 113 }
115 } 114 }
116 return false; 115 return false;
117 } 116 }
118 117
119 text = normalizeString(text); 118 text = normalizeString(text);
120 119
121 // First try to find the entry in the current list 120 // First try to find the entry in the current list
122 if (findText(E("filtersTree").currentIndex)) 121 if (findText(E("filtersTree").currentIndex))
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 search: function(direction) 182 search: function(direction)
184 { 183 {
185 E("findbar").setAttribute("data-status", this._search(direction)); 184 E("findbar").setAttribute("data-status", this._search(direction));
186 } 185 }
187 }; 186 };
188 187
189 window.addEventListener("load", event => 188 window.addEventListener("load", event =>
190 { 189 {
191 E("findbar").setAttribute("data-os", Services.appinfo.OS.toLowerCase()); 190 E("findbar").setAttribute("data-os", Services.appinfo.OS.toLowerCase());
192 }); 191 });
OLDNEW

Powered by Google App Engine
This is Rietveld