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

Side by Side Diff: chrome/browser/resources/options2/search_page.js

Issue 9560005: [uber page] Merge advanced options page into browser options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebase again. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 const OptionsPage = options.OptionsPage; 6 const OptionsPage = options.OptionsPage;
7 7
8 /** 8 /**
9 * Encapsulated handling of a search bubble. 9 * Encapsulated handling of a search bubble.
10 * @constructor 10 * @constructor
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // activate it now. 208 // activate it now.
209 if (!this.searchActive_ && !active) 209 if (!this.searchActive_ && !active)
210 return; 210 return;
211 211
212 this.searchActive_ = active; 212 this.searchActive_ = active;
213 213
214 if (active) { 214 if (active) {
215 var hash = location.hash; 215 var hash = location.hash;
216 if (hash) 216 if (hash)
217 this.searchField.value = unescape(hash.slice(1)); 217 this.searchField.value = unescape(hash.slice(1));
218
219 // Move 'advanced' sections into the main settings page to allow
220 // searching.
221 if (!this.advancedSections_) {
222 this.advancedSections_ =
223 $('advanced-settings-container').querySelectorAll('section');
224 for (var i = 0, section; section = this.advancedSections_[i]; i++)
225 $('settings').appendChild(section);
226 }
218 } else { 227 } else {
219 // Just wipe out any active search text since it's no longer relevant. 228 // Just wipe out any active search text since it's no longer relevant.
220 this.searchField.value = ''; 229 this.searchField.value = '';
221 } 230 }
222 231
223 var pagesToSearch = this.getSearchablePages_(); 232 var pagesToSearch = this.getSearchablePages_();
224 for (var key in pagesToSearch) { 233 for (var key in pagesToSearch) {
225 var page = pagesToSearch[key]; 234 var page = pagesToSearch[key];
226 235
227 if (!active) 236 if (!active)
(...skipping 21 matching lines...) Expand all
249 if (active) { 258 if (active) {
250 this.setSearchText_(this.searchField.value); 259 this.setSearchText_(this.searchField.value);
251 $('search-page-search-field-container').appendChild(this.searchField); 260 $('search-page-search-field-container').appendChild(this.searchField);
252 this.searchField.focus(); 261 this.searchField.focus();
253 } else { 262 } else {
254 $('browser-options-search-field-container').appendChild( 263 $('browser-options-search-field-container').appendChild(
255 this.searchField); 264 this.searchField);
256 // After hiding all page content, remove any search results. 265 // After hiding all page content, remove any search results.
257 this.unhighlightMatches_(); 266 this.unhighlightMatches_();
258 this.removeSearchBubbles_(); 267 this.removeSearchBubbles_();
268
269 // Move 'advanced' sections back into their original container.
270 if (this.advancedSections_) {
271 for (var i = 0, section; section = this.advancedSections_[i]; i++)
272 $('advanced-settings-container').appendChild(section);
273 this.advancedSections_ = null;
274 }
259 } 275 }
260 }, 276 },
261 277
262 /** 278 /**
263 * Set the current search criteria. 279 * Set the current search criteria.
264 * @param {string} text Search text. 280 * @param {string} text Search text.
265 * @private 281 * @private
266 */ 282 */
267 setSearchText_: function(text) { 283 setSearchText_: function(text) {
268 // Prevent recursive execution of this method. 284 // Prevent recursive execution of this method.
269 if (this.insideSetSearchText_) return; 285 if (this.insideSetSearchText_) return;
270 this.insideSetSearchText_ = true; 286 this.insideSetSearchText_ = true;
271 287
272 // Cleanup the search query string. 288 // Cleanup the search query string.
273 text = SearchPage.canonicalizeQuery(text); 289 text = SearchPage.canonicalizeQuery(text);
274 290
275 // Notify listeners about the new search query, some pages may wish to
276 // show/hide elements based on the query.
277 var event = new cr.Event('searchChanged');
278 event.searchText = text;
279 this.dispatchEvent(event);
280
281 // Toggle the search page if necessary. 291 // Toggle the search page if necessary.
282 if (text.length) { 292 if (text.length) {
283 if (!this.searchActive_) 293 if (!this.searchActive_)
284 OptionsPage.navigateToPage(this.name); 294 OptionsPage.navigateToPage(this.name);
285 } else { 295 } else {
286 if (this.searchActive_) 296 if (this.searchActive_)
287 OptionsPage.showDefaultPage(); 297 OptionsPage.showDefaultPage();
288 298
289 this.insideSetSearchText_ = false; 299 this.insideSetSearchText_ = false;
290 return; 300 return;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // Trim beginning and ending whitespace. 581 // Trim beginning and ending whitespace.
572 return text.replace(/^\s+|\s+$/g, ''); 582 return text.replace(/^\s+|\s+$/g, '');
573 }; 583 };
574 584
575 // Export 585 // Export
576 return { 586 return {
577 SearchPage: SearchPage 587 SearchPage: SearchPage
578 }; 588 };
579 589
580 }); 590 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options2/password_manager.js ('k') | chrome/browser/resources/uber/uber_shared.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698