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

Side by Side Diff: chrome/browser/resources/sync_internals/sync_search.js

Issue 137753002: Changed sync-internals search to a submit instead of incremental (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 | « chrome/browser/resources/sync_internals/sync_search.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // require: cr.js 5 // require: cr.js
6 6
7 cr.define('chrome.sync', function() { 7 cr.define('chrome.sync', function() {
8 var currSearchId = 0; 8 var currSearchId = 0;
9 9
10 /** 10 /**
(...skipping 20 matching lines...) Expand all
31 // be caught and handled here. 31 // be caught and handled here.
32 callback([], err); 32 callback([], err);
33 } 33 }
34 }; 34 };
35 35
36 /** 36 /**
37 * Decorates the various search controls. 37 * Decorates the various search controls.
38 * 38 *
39 * @param {!HTMLInputElement} queryControl The <input> object of 39 * @param {!HTMLInputElement} queryControl The <input> object of
40 * type=search where the user types in his query. 40 * type=search where the user types in his query.
41 * @param {!HTMLButtonElement} submitControl The <button> object of
42 * where the user can click to do his query.
41 * @param {!HTMLElement} statusControl The <span> object display the 43 * @param {!HTMLElement} statusControl The <span> object display the
42 * search status. 44 * search status.
43 * @param {!HTMLElement} listControl The <list> object which holds 45 * @param {!HTMLElement} listControl The <list> object which holds
44 * the list of returned results. 46 * the list of returned results.
45 * @param {!HTMLPreElement} detailsControl The <pre> object which 47 * @param {!HTMLPreElement} detailsControl The <pre> object which
46 * holds the details of the selected result. 48 * holds the details of the selected result.
47 */ 49 */
48 function decorateSearchControls(queryControl, statusControl, 50 function decorateSearchControls(queryControl, submitControl, statusControl,
49 resultsControl, detailsControl) { 51 resultsControl, detailsControl) {
50 var resultsDataModel = new cr.ui.ArrayDataModel([]); 52 var resultsDataModel = new cr.ui.ArrayDataModel([]);
51 53
52 // Decorate search box. 54 var searchFunction = function() {
53 queryControl.onsearch = function() {
54 var query = queryControl.value; 55 var query = queryControl.value;
55 statusControl.textContent = ''; 56 statusControl.textContent = '';
56 resultsDataModel.splice(0, resultsDataModel.length); 57 resultsDataModel.splice(0, resultsDataModel.length);
57 if (!query) { 58 if (!query) {
58 return; 59 return;
59 } 60 }
60 statusControl.textContent = 'Searching for ' + query + '...'; 61 statusControl.textContent = 'Searching for ' + query + '...';
61 queryControl.removeAttribute('error'); 62 queryControl.removeAttribute('error');
62 var timer = chrome.sync.makeTimer(); 63 var timer = chrome.sync.makeTimer();
63 doSearch(query, function(nodes, error) { 64 doSearch(query, function(nodes, error) {
(...skipping 11 matching lines...) Expand all
75 nodes[i].toString = function() { 76 nodes[i].toString = function() {
76 return this.NON_UNIQUE_NAME; 77 return this.NON_UNIQUE_NAME;
77 }; 78 };
78 } 79 }
79 resultsDataModel.push.apply(resultsDataModel, nodes); 80 resultsDataModel.push.apply(resultsDataModel, nodes);
80 // Workaround for http://crbug.com/83452 . 81 // Workaround for http://crbug.com/83452 .
81 resultsControl.redraw(); 82 resultsControl.redraw();
82 } 83 }
83 }); 84 });
84 }; 85 };
86
87 submitControl.addEventListener('click', searchFunction);
88 // Decorate search box.
89 queryControl.onsearch = searchFunction;
85 queryControl.value = ''; 90 queryControl.value = '';
86 91
87 // Decorate results list. 92 // Decorate results list.
88 cr.ui.List.decorate(resultsControl); 93 cr.ui.List.decorate(resultsControl);
89 resultsControl.dataModel = resultsDataModel; 94 resultsControl.dataModel = resultsDataModel;
90 resultsControl.selectionModel.addEventListener('change', function(event) { 95 resultsControl.selectionModel.addEventListener('change', function(event) {
91 detailsControl.textContent = ''; 96 detailsControl.textContent = '';
92 var selected = resultsControl.selectedItem; 97 var selected = resultsControl.selectedItem;
93 if (selected) { 98 if (selected) {
94 detailsControl.textContent = JSON.stringify(selected, null, 2); 99 detailsControl.textContent = JSON.stringify(selected, null, 2);
95 } 100 }
96 }); 101 });
97 } 102 }
98 103
99 return { 104 return {
100 decorateSearchControls: decorateSearchControls 105 decorateSearchControls: decorateSearchControls
101 }; 106 };
102 }); 107 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/sync_internals/sync_search.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698