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

Side by Side Diff: chrome/common/extensions/docs/static/js/search.js

Issue 102593005: Clean patch with DCC static content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests for sidenav_data_source Created 7 years 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
(Empty)
1 // Activate the search box:
2 (function() {
3 var form = document.getElementById('chrome-docs-cse-search-form');
4 var searchInput = document.getElementById('chrome-docs-cse-input');
5
6 var cx = '010997258251033819707:7owyldxmpkc';
7
8 var gcse = document.createElement('script');
9 gcse.type = 'text/javascript';
10 gcse.async = true;
11 gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
12 '//www.google.com/cse/cse.js?cx=' + cx;
13 var s = document.getElementsByTagName('script')[0];
14 s.parentNode.insertBefore(gcse, s);
15
16 var executeQuery = function(e) {
17 var element = google.search.cse.element.getElement('results');
18 if (searchInput.value == '') {
19 element.clearAllResults();
20 } else {
21 element.execute(searchInput.value);
22 }
23 e.preventDefault();
24 return true;
25 }
26
27 form.addEventListener('submit', executeQuery);
28
29 // Attach autocomplete to the search box
30 var enableAutoComplete = function() {
31 console.log("running enableAutoComplete");
32 google.search.CustomSearchControl.attachAutoCompletionWithOptions(
33 cx, searchInput, form,
34 // set to true to prevent the search box form from being submitted, sinc e
35 // the search control displaying the results is on the same page.
36 {'preferOnSubmitToSubmit': true}
37 );
38 };
39
40 var myAutocompleteCallback = function() {
41 // Search module is loaded.
42 if (document.readyState == 'complete') {
43 enableAutoComplete();
44 } else {
45 google.setOnLoadCallback(enableAutoComplete, true);
46 }
47 };
48
49 window.__gcse = {
50 callback: myAutocompleteCallback
51 };
52
53 })();
54
55 // End of autocomplete
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/static/js/scroll.js ('k') | chrome/common/extensions/docs/static/js/site.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698