| OLD | NEW |
| 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 Loading... |
| 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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 tilesContainer.appendChild(row); | 941 tilesContainer.appendChild(row); |
| 941 } | 942 } |
| 942 | 943 |
| 943 if (configData.isGooglePage) { | 944 if (configData.isGooglePage) { |
| 944 var logo = document.createElement('div'); | 945 var logo = document.createElement('div'); |
| 945 logo.id = IDS.LOGO; | 946 logo.id = IDS.LOGO; |
| 946 | 947 |
| 947 fakebox = document.createElement('div'); | 948 fakebox = document.createElement('div'); |
| 948 fakebox.id = IDS.FAKEBOX; | 949 fakebox.id = IDS.FAKEBOX; |
| 949 fakebox.innerHTML = | 950 fakebox.innerHTML = |
| 950 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' + | 951 '<input id="' + IDS.FAKEBOX_INPUT + |
| 952 '" autocomplete="off" tabindex="-1" aria-hidden="true">' + |
| 951 '<div id=cursor></div>'; | 953 '<div id=cursor></div>'; |
| 952 | 954 |
| 953 ntpContents.insertBefore(fakebox, ntpContents.firstChild); | 955 ntpContents.insertBefore(fakebox, ntpContents.firstChild); |
| 954 ntpContents.insertBefore(logo, ntpContents.firstChild); | 956 ntpContents.insertBefore(logo, ntpContents.firstChild); |
| 955 } else { | 957 } else { |
| 956 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); | 958 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); |
| 957 } | 959 } |
| 958 | 960 |
| 959 var recentTabsText = configData.translatedStrings.recentTabs; | 961 var recentTabsText = configData.translatedStrings.recentTabs; |
| 960 if (recentTabsText) { | 962 if (recentTabsText) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 if (ntpApiHandle.isInputInProgress) | 1006 if (ntpApiHandle.isInputInProgress) |
| 1005 onInputStart(); | 1007 onInputStart(); |
| 1006 | 1008 |
| 1007 onThemeChange(); | 1009 onThemeChange(); |
| 1008 onMostVisitedChange(); | 1010 onMostVisitedChange(); |
| 1009 | 1011 |
| 1010 searchboxApiHandle = topLevelHandle.searchBox; | 1012 searchboxApiHandle = topLevelHandle.searchBox; |
| 1011 | 1013 |
| 1012 if (fakebox) { | 1014 if (fakebox) { |
| 1013 // Listener for updating the key capture state. | 1015 // Listener for updating the key capture state. |
| 1014 document.body.onclick = function(event) { | 1016 document.body.onmousedown = function(event) { |
| 1015 if (isFakeboxClick(event)) | 1017 if (isFakeboxClick(event)) |
| 1016 searchboxApiHandle.startCapturingKeyStrokes(); | 1018 searchboxApiHandle.startCapturingKeyStrokes(); |
| 1017 else if (isFakeboxFocused()) | 1019 else if (isFakeboxFocused()) |
| 1018 searchboxApiHandle.stopCapturingKeyStrokes(); | 1020 searchboxApiHandle.stopCapturingKeyStrokes(); |
| 1019 }; | 1021 }; |
| 1020 searchboxApiHandle.onkeycapturechange = function() { | 1022 searchboxApiHandle.onkeycapturechange = function() { |
| 1021 setFakeboxFocus(searchboxApiHandle.isKeyCaptureEnabled); | 1023 setFakeboxFocus(searchboxApiHandle.isKeyCaptureEnabled); |
| 1022 }; | 1024 }; |
| 1025 var inputbox = $(IDS.FAKEBOX_INPUT); |
| 1026 if (inputbox) { |
| 1027 inputbox.onpaste = function(event) { |
| 1028 event.preventDefault(); |
| 1029 searchboxApiHandle.paste(); |
| 1030 }; |
| 1031 } |
| 1023 } | 1032 } |
| 1024 | 1033 |
| 1025 if (searchboxApiHandle.rtl) { | 1034 if (searchboxApiHandle.rtl) { |
| 1026 $(IDS.NOTIFICATION).dir = 'rtl'; | 1035 $(IDS.NOTIFICATION).dir = 'rtl'; |
| 1027 // Add class for setting alignments based on language directionality. | 1036 // Add class for setting alignments based on language directionality. |
| 1028 document.body.classList.add(CLASSES.RTL); | 1037 document.body.classList.add(CLASSES.RTL); |
| 1029 $(IDS.TILES).dir = 'rtl'; | 1038 $(IDS.TILES).dir = 'rtl'; |
| 1030 } | 1039 } |
| 1031 } | 1040 } |
| 1032 | 1041 |
| 1033 | 1042 |
| 1034 /** | 1043 /** |
| 1035 * Binds event listeners. | 1044 * Binds event listeners. |
| 1036 */ | 1045 */ |
| 1037 function listen() { | 1046 function listen() { |
| 1038 document.addEventListener('DOMContentLoaded', init); | 1047 document.addEventListener('DOMContentLoaded', init); |
| 1039 } | 1048 } |
| 1040 | 1049 |
| 1041 return { | 1050 return { |
| 1042 init: init, | 1051 init: init, |
| 1043 listen: listen | 1052 listen: listen |
| 1044 }; | 1053 }; |
| 1045 } | 1054 } |
| 1046 | 1055 |
| 1047 if (!window.localNTPUnitTest) { | 1056 if (!window.localNTPUnitTest) { |
| 1048 LocalNTP().listen(); | 1057 LocalNTP().listen(); |
| 1049 } | 1058 } |
| OLD | NEW |