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

Side by Side Diff: chrome/browser/resources/local_ntp/local_ntp.js

Issue 20501002: Adds paste function to searchbox api and handles paste event on fakebox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test updated Created 7 years, 5 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 5
6 /** 6 /**
7 * @fileoverview The local InstantExtended NTP. 7 * @fileoverview The local InstantExtended NTP.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 /** 48 /**
49 * Enum for HTML element ids. 49 * Enum for HTML element ids.
50 * @enum {string} 50 * @enum {string}
51 * @const 51 * @const
52 */ 52 */
53 var IDS = { 53 var IDS = {
54 ATTRIBUTION: 'attribution', 54 ATTRIBUTION: 'attribution',
55 ATTRIBUTION_TEXT: 'attribution-text', 55 ATTRIBUTION_TEXT: 'attribution-text',
56 CUSTOM_THEME_STYLE: 'ct-style', 56 CUSTOM_THEME_STYLE: 'ct-style',
57 FAKEBOX: 'fakebox', 57 FAKEBOX: 'fakebox',
58 FAKEBOX_INPUT: 'fakebox-input',
58 LOGO: 'logo', 59 LOGO: 'logo',
59 NOTIFICATION: 'mv-notice', 60 NOTIFICATION: 'mv-notice',
60 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x', 61 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x',
61 NOTIFICATION_MESSAGE: 'mv-msg', 62 NOTIFICATION_MESSAGE: 'mv-msg',
62 NTP_CONTENTS: 'ntp-contents', 63 NTP_CONTENTS: 'ntp-contents',
63 RECENT_TABS: 'recent-tabs', 64 RECENT_TABS: 'recent-tabs',
64 RESTORE_ALL_LINK: 'mv-restore', 65 RESTORE_ALL_LINK: 'mv-restore',
65 TILES: 'mv-tiles', 66 TILES: 'mv-tiles',
66 UNDO_LINK: 'mv-undo' 67 UNDO_LINK: 'mv-undo'
67 }; 68 };
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 tilesContainer.appendChild(row); 948 tilesContainer.appendChild(row);
948 } 949 }
949 950
950 if (configData.isGooglePage) { 951 if (configData.isGooglePage) {
951 var logo = document.createElement('div'); 952 var logo = document.createElement('div');
952 logo.id = IDS.LOGO; 953 logo.id = IDS.LOGO;
953 954
954 fakebox = document.createElement('div'); 955 fakebox = document.createElement('div');
955 fakebox.id = IDS.FAKEBOX; 956 fakebox.id = IDS.FAKEBOX;
956 fakebox.innerHTML = 957 fakebox.innerHTML =
957 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' + 958 '<input id="' + IDS.FAKEBOX_INPUT +
959 '" autocomplete="off" tabindex="-1" aria-hidden="true">' +
958 '<div id=cursor></div>'; 960 '<div id=cursor></div>';
959 961
960 ntpContents.insertBefore(fakebox, ntpContents.firstChild); 962 ntpContents.insertBefore(fakebox, ntpContents.firstChild);
961 ntpContents.insertBefore(logo, ntpContents.firstChild); 963 ntpContents.insertBefore(logo, ntpContents.firstChild);
962 } else { 964 } else {
963 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); 965 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE);
964 } 966 }
965 967
966 var recentTabsText = configData.translatedStrings.recentTabs; 968 var recentTabsText = configData.translatedStrings.recentTabs;
967 if (recentTabsText) { 969 if (recentTabsText) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 if (ntpApiHandle.isInputInProgress) 1013 if (ntpApiHandle.isInputInProgress)
1012 onInputStart(); 1014 onInputStart();
1013 1015
1014 onThemeChange(); 1016 onThemeChange();
1015 onMostVisitedChange(); 1017 onMostVisitedChange();
1016 1018
1017 searchboxApiHandle = topLevelHandle.searchBox; 1019 searchboxApiHandle = topLevelHandle.searchBox;
1018 1020
1019 if (fakebox) { 1021 if (fakebox) {
1020 // Listener for updating the key capture state. 1022 // Listener for updating the key capture state.
1021 document.body.onclick = function(event) { 1023 document.body.onmousedown = function(event) {
1022 if (isFakeboxClick(event)) 1024 if (isFakeboxClick(event))
1023 searchboxApiHandle.startCapturingKeyStrokes(); 1025 searchboxApiHandle.startCapturingKeyStrokes();
1024 else if (isFakeboxFocused()) 1026 else if (isFakeboxFocused())
1025 searchboxApiHandle.stopCapturingKeyStrokes(); 1027 searchboxApiHandle.stopCapturingKeyStrokes();
1026 }; 1028 };
1027 searchboxApiHandle.onkeycapturechange = function() { 1029 searchboxApiHandle.onkeycapturechange = function() {
1028 setFakeboxFocus(searchboxApiHandle.isKeyCaptureEnabled); 1030 setFakeboxFocus(searchboxApiHandle.isKeyCaptureEnabled);
1029 }; 1031 };
1032 var inputbox = $(IDS.FAKEBOX_INPUT);
1033 if (inputbox) {
1034 inputbox.onpaste = function(event) {
1035 event.preventDefault();
1036 searchboxApiHandle.paste();
1037 };
1038 }
1030 } 1039 }
1031 1040
1032 if (searchboxApiHandle.rtl) { 1041 if (searchboxApiHandle.rtl) {
1033 $(IDS.NOTIFICATION).dir = 'rtl'; 1042 $(IDS.NOTIFICATION).dir = 'rtl';
1034 // Add class for setting alignments based on language directionality. 1043 // Add class for setting alignments based on language directionality.
1035 document.body.classList.add(CLASSES.RTL); 1044 document.body.classList.add(CLASSES.RTL);
1036 $(IDS.TILES).dir = 'rtl'; 1045 $(IDS.TILES).dir = 'rtl';
1037 } 1046 }
1038 } 1047 }
1039 1048
1040 1049
1041 /** 1050 /**
1042 * Binds event listeners. 1051 * Binds event listeners.
1043 */ 1052 */
1044 function listen() { 1053 function listen() {
1045 document.addEventListener('DOMContentLoaded', init); 1054 document.addEventListener('DOMContentLoaded', init);
1046 } 1055 }
1047 1056
1048 return { 1057 return {
1049 init: init, 1058 init: init,
1050 listen: listen 1059 listen: listen
1051 }; 1060 };
1052 } 1061 }
1053 1062
1054 if (!window.localNTPUnitTest) { 1063 if (!window.localNTPUnitTest) {
1055 LocalNTP().listen(); 1064 LocalNTP().listen();
1056 } 1065 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/browser_instant_controller.h » ('j') | chrome/browser/ui/browser_instant_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698