[NTP] Fix comment formatting
Fix formatting of comments and some spacing across the javascript files.
Change-Id: Ia4950ff7edcbb020c7395e71b971b091ec83e2c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1659708
Commit-Queue: Kristi Park <kristipark@chromium.org>
Reviewed-by: Kyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#669403}
diff --git a/chrome/browser/resources/local_ntp/animations.js b/chrome/browser/resources/local_ntp/animations.js
index 92f9b09..04f2b17 100644
--- a/chrome/browser/resources/local_ntp/animations.js
+++ b/chrome/browser/resources/local_ntp/animations.js
@@ -2,13 +2,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
-
/**
* Contains common animations used in the main NTP page and its iframes.
*/
const animations = {};
-
/**
* Enum for classnames.
* @enum {string}
@@ -21,7 +19,6 @@
RIPPLE_EFFECT: 'ripple-effect',
};
-
/**
* The duration of the ripple animation.
* @type {number}
@@ -29,7 +26,6 @@
*/
animations.RIPPLE_DURATION_MS = 800;
-
/**
* The max size of the ripple animation.
* @type {number}
@@ -37,7 +33,6 @@
*/
animations.RIPPLE_MAX_RADIUS_PX = 300;
-
/**
* Enables ripple animations for elements with CLASSES.RIPPLE. The target
* element must have position relative or absolute.
diff --git a/chrome/browser/resources/local_ntp/custom_links_edit.js b/chrome/browser/resources/local_ntp/custom_links_edit.js
index 6e91934..bd6bcf243 100644
--- a/chrome/browser/resources/local_ntp/custom_links_edit.js
+++ b/chrome/browser/resources/local_ntp/custom_links_edit.js
@@ -2,7 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
-
/**
* Enum for ids.
* @enum {string}
@@ -23,7 +22,6 @@
URL_FIELD_NAME: 'url-field-name', // URL input field name.
};
-
/**
* Enum for key codes.
* @enum {number}
@@ -36,7 +34,6 @@
TAB: 9,
};
-
/**
* The origin of this request, i.e. 'https://www.google.TLD' for the remote NTP,
* or 'chrome-search://local-ntp' for the local NTP.
@@ -44,14 +41,12 @@
*/
const DOMAIN_ORIGIN = '{{ORIGIN}}';
-
/**
* List of parameters passed by query args.
* @type {Object}
*/
let queryArgs = {};
-
/**
* The prepopulated data for the form. Includes title, url, and rid.
* @type {Object}
@@ -62,28 +57,24 @@
url: '',
};
-
/**
* The title of the dialog when adding a link.
* @type {string}
*/
let addLinkTitle = '';
-
/**
* The title of the dialog when editing a link.
* @type {string}
*/
let editLinkTitle = '';
-
/**
* The accessibility title of remove link button.
* @type {string}
*/
let deleteLinkTitle = '';
-
/**
* Handler for the 'linkData' message from the host page. Pre-populates the url
* and title fields with link's data obtained using the rid. Called if we are
@@ -111,7 +102,6 @@
$(IDS.DONE).title = editLinkTitle;
}
-
/**
* Shows the invalid URL error message until the URL field is modified.
*/
@@ -124,7 +114,6 @@
$(IDS.URL_FIELD).addEventListener('input', reenable);
}
-
/**
* Send a message to close the edit dialog. Called when the edit flow has been
* completed. If the fields were unchanged, does not update the link data.
@@ -159,7 +148,6 @@
closeDialog();
}
-
/**
* Call the EmbeddedSearchAPI to delete the link. Closes the dialog.
* @param {!Event} event The click event.
@@ -169,7 +157,6 @@
closeDialog();
}
-
/**
* Send a message to close the edit dialog, clears the url and title fields, and
* resets the button statuses. Called when the edit flow has been completed.
@@ -189,7 +176,6 @@
}, 10);
}
-
/**
* Send a message to refocus the edited tile's three dot menu or the add
* shortcut tile after the cancel button is clicked.
@@ -204,7 +190,6 @@
}
}
-
/**
* Handler for the 'updateTheme' message from the host page.
* @param {!Object} info Data received in the message.
@@ -213,7 +198,6 @@
document.documentElement.setAttribute('darkmode', info.isDarkMode);
}
-
/**
* Event handler for messages from the host page.
* @param {Event} event Event received.
@@ -245,7 +229,6 @@
}
}
-
/**
* Does some initialization and shows the dialog window.
*/
@@ -328,8 +311,10 @@
$(IDS.URL_FIELD)
.addEventListener('blur', () => changeColor(IDS.URL_FIELD_NAME));
// Disables the "Done" button when the URL field is empty.
- $(IDS.URL_FIELD).addEventListener('input',
- () => $(IDS.DONE).disabled = ($(IDS.URL_FIELD).value.trim() === ''));
+ $(IDS.URL_FIELD)
+ .addEventListener(
+ 'input',
+ () => $(IDS.DONE).disabled = ($(IDS.URL_FIELD).value.trim() === ''));
utils.setPlatformClass(document.body);
@@ -338,5 +323,4 @@
window.addEventListener('message', handlePostMessage);
}
-
window.addEventListener('DOMContentLoaded', init);
diff --git a/chrome/browser/resources/local_ntp/customize.js b/chrome/browser/resources/local_ntp/customize.js
index 878b4b0..554e497 100644
--- a/chrome/browser/resources/local_ntp/customize.js
+++ b/chrome/browser/resources/local_ntp/customize.js
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
'use strict';
// TODO(crbug.com/937570): After the RP launches this should be renamed to
@@ -175,13 +174,15 @@
customize.delayedHideNotification = -1;
customize.NOTIFICATION_TIMEOUT = 10000;
-/* Were the background tiles already created.
- * @type {bool}
+/**
+ * Were the background tiles already created.
+ * @type {boolean}
*/
customize.builtTiles = false;
-/* Tile that was selected by the user.
- * @type {HTMLElement}
+/**
+ * Tile that was selected by the user.
+ * @type {?Element}
*/
customize.selectedTile = null;
@@ -192,21 +193,21 @@
*/
customize.ROWS_TO_PRELOAD = 3;
-/*
+/**
* Called when the error notification should be shown.
* @type {?Function}
* @private
*/
customize.showErrorNotification = null;
-/*
+/**
* Called when the custom link notification should be hidden.
* @type {?Function}
* @private
*/
customize.hideCustomLinkNotification = null;
-/*
+/**
* The currently selected option in the richer picker.
* @type {?Element}
* @private
@@ -363,15 +364,20 @@
$(customize.IDS.MENU_DONE).tabIndex = -1;
};
-/* Close the collection selection dialog and cleanup the state
- * @param {dialog} menu The dialog to be closed
+/**
+ * Close the collection selection dialog and cleanup the state
+ * @param {?Element} menu The dialog to be closed
*/
customize.closeCollectionDialog = function(menu) {
+ if (!menu) {
+ return;
+ }
menu.close();
customize.resetSelectionDialog();
};
-/* Close and reset the dialog, and set the background.
+/**
+ * Close and reset the dialog, and set the background.
* @param {string} url The url of the selected background.
*/
customize.setBackground = function(
@@ -486,7 +492,8 @@
return null;
};
-/* Get the next tile when the arrow keys are used to navigate the grid.
+/**
+ * Get the next tile when the arrow keys are used to navigate the grid.
* Returns null if the tile doesn't exist.
* @param {number} deltaX Change in the x direction.
* @param {number} deltaY Change in the y direction.
@@ -785,7 +792,7 @@
* loaded into collImg via
* chrome-search://local-ntp/ntp-background-images.js?collection_id=<collection_id>
* @param {string} dialogTitle The title to be displayed at the top of the
- * dialog.
+ * dialog.
*/
customize.showImageSelectionDialog = function(dialogTitle) {
const firstNTile = customize.ROWS_TO_PRELOAD * customize.getTilesWide();
@@ -948,7 +955,7 @@
* @param {!Object} tile the tile that needs to be loaded.
* @param {!Object} imageData the source imageData.
* @param {?Function} countLoad If not null, called after the tile finishes
- * loading.
+ * loading.
*/
customize.loadTile = function(tile, imageData, countLoad) {
if (imageData[tile.dataset.tileNum].collectionId === 'solidcolors') {
@@ -971,7 +978,7 @@
* @param {!Object} tile The tile to add the fade in animation to.
* @param {string} imageUrl the image url for the tile
* @param {?Function} countLoad If not null, called after the tile finishes
- * loading.
+ * loading.
*/
customize.fadeInImageTile = function(tile, imageUrl, countLoad) {
const image = new Image();
@@ -1006,7 +1013,9 @@
document.body.appendChild(collScript);
};
-/* Close dialog when an image is selected via the file picker. */
+/**
+ * Close dialog when an image is selected via the file picker.
+ */
customize.closeCustomizationDialog = function() {
if (configData.richerPicker) {
$(customize.IDS.CUSTOMIZATION_MENU).close();
@@ -1015,7 +1024,7 @@
}
};
-/*
+/**
* Get the next visible option. There are times when various combinations of
* options are hidden.
* @param {number} current_index Index of the option the key press occurred on.
@@ -1046,8 +1055,9 @@
return entries[idx];
};
-/* Hide custom background options based on the network state
- * @param {bool} online The current state of the network
+/**
+ * Hide custom background options based on the network state
+ * @param {boolean} online The current state of the network
*/
customize.networkStateChanged = function(online) {
$(customize.IDS.DEFAULT_WALLPAPERS).hidden = !online;
@@ -1093,10 +1103,10 @@
* Initialize the settings menu, custom backgrounds dialogs, and custom
* links menu items. Set the text and event handlers for the various
* elements.
- * @param {!Function} showErrorNotification Called when the error
- * notification should be displayed.
+ * @param {!Function} showErrorNotification Called when the error notification
+ * should be displayed.
* @param {!Function} hideCustomLinkNotification Called when the custom link
- * notification should be hidden.
+ * notification should be hidden.
*/
customize.init = function(showErrorNotification, hideCustomLinkNotification) {
ntpApiHandle = window.chrome.embeddedSearch.newTabPage;
@@ -1207,7 +1217,7 @@
* Initialize custom link items in the settings menu dialog. Set the text
* and event handlers for the various elements.
* @param {!Function} hideCustomLinkNotification Called when the custom link
- * notification should be hidden.
+ * notification should be hidden.
*/
customize.initCustomLinksItems = function(hideCustomLinkNotification) {
customize.hideCustomLinkNotification = hideCustomLinkNotification;
@@ -1255,7 +1265,7 @@
* Initialize the settings menu and custom backgrounds dialogs. Set the
* text and event handlers for the various elements.
* @param {!Function} showErrorNotification Called when the error notification
- * should be displayed.
+ * should be displayed.
*/
customize.initCustomBackgrounds = function(showErrorNotification) {
customize.showErrorNotification = showErrorNotification;
diff --git a/chrome/browser/resources/local_ntp/doodles.js b/chrome/browser/resources/local_ntp/doodles.js
index 77865a37..7481631 100644
--- a/chrome/browser/resources/local_ntp/doodles.js
+++ b/chrome/browser/resources/local_ntp/doodles.js
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
const doodles = {};
doodles.numDdllogResponsesReceived = 0;
@@ -12,7 +11,6 @@
doodles.ei = null;
-
/**
* Enum for classnames.
* @enum {string}
@@ -23,7 +21,6 @@
SHOW_LOGO: 'show-logo', // Marks logo/doodle that should be shown.
};
-
/**
* Enum for HTML element ids.
* @enum {string}
@@ -49,7 +46,6 @@
LOGO_DOODLE_NOTIFIER: 'logo-doodle-notifier',
};
-
/**
* Counterpart of search_provider_logos::LogoType.
* @enum {string}
@@ -61,7 +57,6 @@
INTERACTIVE: 'INTERACTIVE',
};
-
/**
* Subset of gws.plugins.doodle.SharingLightbox.LogType in
* googledata/html/templates/gws/head/xjs/plugins/doodle/sharing_lightbox.js.
@@ -75,14 +70,12 @@
LINK_COPY: 6,
};
-
/**
* The ID of the doodle app for Facebook. Used to share doodles to Facebook.
* @type {number}
*/
doodles.FACEBOOK_APP_ID = 738026486351791;
-
/**
* The different types of events that are logged from the NTP. This enum is
* used to transfer information from the NTP JavaScript to the renderer and is
@@ -109,7 +102,6 @@
NTP_ANIMATED_LOGO_CLICKED: 36,
};
-
/**
* Handle the resizeDoodle command sent from the fpdoodle page
* when an interactive doodle is clicked.
@@ -133,8 +125,7 @@
document.body.style.setProperty('--logo-iframe-width', width);
};
-
-/*
+/**
* Fetch doodle data and display it if one is present.
*/
doodles.init = function() {
@@ -184,7 +175,6 @@
});
};
-
/**
* Loads the Doodle. On success, the loaded script declares a global variable
* ddl, which onload() receives as its single argument. On failure, onload() is
@@ -209,7 +199,6 @@
document.body.appendChild(ddlScript);
};
-
/**
* Handles the response of a doodle impression ping, i.e. stores the
* appropriate interactionLogUrl or onClickUrlExtraParams. Also stores
@@ -248,7 +237,6 @@
}
};
-
/**
* Logs a doodle impression at the given logUrl, and handles the response via
* doodles.handleDdllogResponse.
@@ -290,7 +278,6 @@
});
};
-
/**
* Logs a doodle sharing event.
* Uses the ct param provided in metadata.onClickUrl to track the doodle.
@@ -315,7 +302,6 @@
}
};
-
/**
* Returns true if the target doodle is currently visible. If |image| is null,
* returns true when the default logo is visible; if non-null, checks that it
@@ -348,7 +334,6 @@
}
};
-
/**
* The image and metadata that should be shown, according to the latest fetch.
* After a logo fades out, doodles.onDoodleFadeOutComplete fades in a logo
@@ -364,7 +349,6 @@
onClickUrlExtraParams: null,
};
-
doodles.getDoodleTargetUrl = function() {
const url = new URL(doodles.targetDoodle.metadata.onClickUrl);
if (doodles.targetDoodle.onClickUrlExtraParams) {
@@ -375,7 +359,6 @@
return url;
};
-
doodles.showLogoOrDoodle = function(fromCache) {
const cachedInteractiveOffline = fromCache &&
doodles.targetDoodle.metadata !== null &&
@@ -418,11 +401,9 @@
}
};
-
/**
* Starts fading out the given element, which should be either the default logo
* or the doodle.
- *
* @param {?Element} element
*/
doodles.startFadeOut = function(element) {
@@ -440,7 +421,6 @@
element.addEventListener('transitionend', doodles.onDoodleFadeOutComplete);
};
-
/**
* Integrates a fresh doodle into the page as appropriate. If the correct logo
* or doodle is already shown, just updates the metadata. Otherwise, initiates
@@ -469,7 +449,6 @@
doodles.startFadeOut($(doodles.IDS.LOGO_DOODLE));
};
-
doodles.onDoodleFadeOutComplete = function(e) {
// Fade-out finished. Start fading in the appropriate logo.
$(doodles.IDS.LOGO_DOODLE).classList.add(doodles.CLASSES.FADE);
@@ -480,7 +459,6 @@
'transitionend', doodles.onDoodleFadeOutComplete);
};
-
doodles.applyDoodleMetadata = function() {
const logoDoodleImage = $(doodles.IDS.LOGO_DOODLE_IMAGE);
const logoDoodleButton = $(doodles.IDS.LOGO_DOODLE_BUTTON);
diff --git a/chrome/browser/resources/local_ntp/local_ntp.js b/chrome/browser/resources/local_ntp/local_ntp.js
index 4d66f79..d15764a7 100644
--- a/chrome/browser/resources/local_ntp/local_ntp.js
+++ b/chrome/browser/resources/local_ntp/local_ntp.js
@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
/**
* @fileoverview The local InstantExtended NTP.
*/
-
/**
* Whether the most visited tiles have finished loading, i.e. we've received the
* 'loaded' postMessage from the iframe. Used by tests to detect that loading
@@ -16,7 +14,6 @@
*/
let tilesAreLoaded = false;
-
/**
* Whether the Most Visited and edit custom link iframes should be created while
* running tests. Currently the SimpleJavascriptTests are flaky due to some
@@ -25,7 +22,6 @@
*/
let iframesAndVoiceSearchDisabledForTesting = false;
-
/**
* Controls rendering the new tab page for InstantExtended.
* @return {Object} A limited interface for testing the local NTP.
@@ -33,7 +29,6 @@
function LocalNTP() {
'use strict';
-
/**
* Called by tests to disable the creation of Most Visited and edit custom link
* iframes.
@@ -42,7 +37,6 @@
iframesAndVoiceSearchDisabledForTesting = true;
}
-
/**
* Specifications for an NTP design (not comprehensive).
*
@@ -75,7 +69,6 @@
titleColorAgainstDark: [248, 249, 250, 255], /** GG050 */
};
-
/**
* Enum for classnames.
* @enum {string}
@@ -119,7 +112,6 @@
USE_NOTIFIER: 'use-notifier',
};
-
/**
* Enum for HTML element ids.
* @enum {string}
@@ -155,7 +147,6 @@
USER_CONTENT: 'user-content',
};
-
/**
* The different types of events that are logged from the NTP. This enum is
* used to transfer information from the NTP JavaScript to the renderer and is
@@ -195,7 +186,6 @@
NTP_MIDDLE_SLOT_PROMO_LINK_CLICKED: 61,
};
-
/**
* The maximum number of tiles to show in the Most Visited section.
* @type {number}
@@ -203,7 +193,6 @@
*/
const MAX_NUM_TILES_MOST_VISITED = 8;
-
/**
* The maximum number of tiles to show in the Most Visited section if custom
* links is enabled.
@@ -212,17 +201,14 @@
*/
const MAX_NUM_TILES_CUSTOM_LINKS = 10;
-
/**
* Background colors considered "white". Used to determine if it is possible to
* display a Google Doodle, or if the notifier should be used instead. Also used
* to determine if a colored or white logo should be used.
- * @type {Array<string>}
* @const
*/
const WHITE_BACKGROUND_COLORS = ['rgba(255,255,255,1)', 'rgba(0,0,0,0)'];
-
/**
* Background color for Chrome dark mode. Used to determine if it is possible to
* display a Google Doodle, or if the notifier should be used instead.
@@ -231,7 +217,6 @@
*/
const DARK_MODE_BACKGROUND_COLOR = 'rgba(50,54,57,1)';
-
/**
* Enum for keycodes.
* @enum {number}
@@ -239,14 +224,12 @@
*/
const KEYCODE = {ENTER: 13, SPACE: 32};
-
/**
* The period of time (ms) before the Most Visited notification is hidden.
* @type {number}
*/
const NOTIFICATION_TIMEOUT = 10000;
-
/**
* The period of time (ms) before transitions can be applied to a toast
* notification after modifying the "display" property.
@@ -254,7 +237,6 @@
*/
const DISPLAY_TIMEOUT = 20;
-
/**
* The last blacklisted tile rid if any, which by definition should not be
* filler.
@@ -262,7 +244,6 @@
*/
let lastBlacklistedTile = null;
-
/**
* The timeout function for automatically hiding the pop-up notification. Only
* set if a notification is visible.
@@ -270,7 +251,6 @@
*/
let delayedHideNotification = null;
-
/**
* The currently visible notification element. Null if no notification is
* present.
@@ -278,21 +258,18 @@
*/
let currNotification = null;
-
/**
* The browser embeddedSearch.newTabPage object.
* @type {Object}
*/
let ntpApiHandle;
-
/**
* True if dark mode is enabled.
* @type {boolean}
*/
let isDarkModeEnabled = false;
-
/**
* True if dark colored chips should be used instead of light mode chips when
* dark mode is enabled.
@@ -300,7 +277,6 @@
*/
let useDarkChips = false;
-
/**
* Returns a timeout that can be executed early. Calls back true if this was
* an early execution, false otherwise.
@@ -323,7 +299,6 @@
};
}
-
/**
* Called by tests to override the executable timeout with a test timeout.
* @param {!Function} timeout The timeout function. Requires a boolean param.
@@ -332,7 +307,6 @@
createExecutableTimeout = timeout;
}
-
/**
* Returns theme background info, first checking for history.state.notheme. If
* the page has notheme set, returns a fallback light-colored theme (or dark-
@@ -364,7 +338,6 @@
return ntpApiHandle.themeBackgroundInfo;
}
-
/**
* Determine whether dark chips should be used if dark mode is enabled. This is
* is the case when dark mode is enabled and a background image (from a custom
@@ -378,7 +351,6 @@
return info.usingDarkMode && !info.imageUrl;
}
-
/**
* Updates the NTP based on the current theme.
* @private
@@ -502,7 +474,6 @@
$(IDS.TILES_IFRAME).contentWindow.postMessage(message, '*');
}
-
/**
* Sends the current theme info to the edit custom link iframe.
* @private
@@ -523,7 +494,6 @@
$(IDS.CUSTOM_LINKS_EDIT_IFRAME).contentWindow.postMessage(message, '*');
}
-
/**
* Updates the OneGoogleBar (if it is loaded) based on the current theme.
* TODO(crbug.com/918582): Add support for OGB dark mode.
@@ -545,7 +515,6 @@
}
}
-
/**
* Callback for embeddedSearch.newTabPage.onthemechange.
* @private
@@ -566,7 +535,6 @@
}
}
-
/**
* Updates the NTP style according to theme.
* @param {Object} themeInfo The information about the theme.
@@ -591,12 +559,11 @@
document.body.style.setProperty('--text-color-link', textColorLight);
}
-
/**
* Renders the attribution if the URL is present, otherwise hides it.
* @param {string} url The URL of the attribution image, if any.
* @param {string} themeBackgroundAlignment The alignment of the theme
- * background image. This is used to compute the attribution's alignment.
+ * background image. This is used to compute the attribution's alignment.
* @private
*/
function updateThemeAttribution(url, themeBackgroundAlignment) {
@@ -615,12 +582,11 @@
// To avoid conflicts, place the attribution on the left for themes that
// right align their background images.
- attribution.classList.toggle(CLASSES.LEFT_ALIGN_ATTRIBUTION,
- themeBackgroundAlignment == 'right');
+ attribution.classList.toggle(
+ CLASSES.LEFT_ALIGN_ATTRIBUTION, themeBackgroundAlignment == 'right');
setAttributionVisibility_(true);
}
-
/**
* Sets the visibility of the theme attribution.
* @param {boolean} show True to show the attribution.
@@ -630,7 +596,6 @@
$(IDS.ATTRIBUTION).style.display = show ? '' : 'none';
}
-
/**
* Converts an Array of color components into RGBA format "rgba(R,G,B,A)".
* @param {Array<number>} color Array of rgba color components.
@@ -639,10 +604,9 @@
*/
function convertToRGBAColor(color) {
return 'rgba(' + color[0] + ',' + color[1] + ',' + color[2] + ',' +
- color[3] / 255 + ')';
+ color[3] / 255 + ')';
}
-
/**
* Callback for embeddedSearch.newTabPage.onmostvisitedchange. Called when the
* NTP tiles are updated.
@@ -651,7 +615,6 @@
reloadTiles();
}
-
/**
* Fetches new data (RIDs) from the embeddedSearch.newTabPage API and passes
* them to the iframe.
@@ -678,7 +641,6 @@
$(IDS.TILES_IFRAME).contentWindow.postMessage(cmds, '*');
}
-
/**
* Callback for embeddedSearch.newTabPage.onaddcustomlinkdone. Called when the
* custom link was successfully added. Shows the "Shortcut added" notification.
@@ -694,7 +656,6 @@
ntpApiHandle.logEvent(LOG_TYPE.NTP_CUSTOMIZE_SHORTCUT_DONE);
}
-
/**
* Callback for embeddedSearch.newTabPage.onupdatecustomlinkdone. Called when
* the custom link was successfully updated. Shows the "Shortcut edited"
@@ -710,7 +671,6 @@
}
}
-
/**
* Callback for embeddedSearch.newTabPage.ondeletecustomlinkdone. Called when
* the custom link was successfully deleted. Shows the "Shortcut deleted"
@@ -726,7 +686,6 @@
}
}
-
/**
* Shows the Most Visited pop-up notification and triggers a delay to hide it.
* The message will be set to |msg|.
@@ -741,7 +700,6 @@
$(IDS.UNDO_LINK).focus();
}
-
/**
* Hides the Most Visited pop-up notification.
*/
@@ -750,7 +708,6 @@
$(IDS.NOTIFICATION), $(IDS.NOTIFICATION_CONTAINER), /*showPromo=*/ true);
}
-
/**
* Shows the error pop-up notification and triggers a delay to hide it. The
* message will be set to |msg|. If |linkName| and |linkOnClick| are present,
@@ -774,7 +731,6 @@
floatUpNotification(notification, $(IDS.ERROR_NOTIFICATION_CONTAINER));
}
-
/**
* Animates the specified notification to float up. Automatically hides any
* pre-existing notification and sets a delayed timer to hide the new
@@ -830,7 +786,6 @@
currNotification = notificationContainer;
}
-
/**
* Animates the pop-up notification to float down, and clears the timeout to
* hide the notification.
@@ -885,7 +840,6 @@
notificationContainer.classList.remove(CLASSES.FLOAT_UP);
}
-
/**
* Return true if custom links are enabled.
* @return {boolean}
@@ -895,7 +849,6 @@
!chrome.embeddedSearch.newTabPage.isUsingMostVisited;
}
-
/**
* Handles a click on the notification undo link by hiding the notification and
* informing Chrome.
@@ -911,7 +864,6 @@
}
}
-
/**
* Handles a click on the restore all notification link by hiding the
* notification and informing Chrome.
@@ -927,7 +879,6 @@
}
}
-
/**
* Callback for embeddedSearch.newTabPage.oninputstart. Handles new input by
* disposing the NTP, according to where the input was entered.
@@ -940,7 +891,6 @@
}
}
-
/**
* Callback for embeddedSearch.newTabPage.oninputcancel. Restores the NTP
* (re-enables the fakebox and unhides the logo.)
@@ -949,7 +899,6 @@
setFakeboxVisibility(true);
}
-
/**
* @param {boolean} focus True to focus the fakebox.
*/
@@ -972,7 +921,6 @@
document.body.classList.contains(CLASSES.FAKEBOX_DRAG_FOCUS);
}
-
/**
* @param {!Event} event The click event.
* @return {boolean} True if the click occurred in an enabled fakebox.
@@ -983,7 +931,6 @@
.contains(/** @type HTMLElement */ (event.target));
}
-
/**
* @param {boolean} show True to show the fakebox and logo.
*/
@@ -991,7 +938,6 @@
document.body.classList.toggle(CLASSES.HIDE_FAKEBOX, !show);
}
-
/**
* @param {!Element} element The element to register the handler for.
* @param {number} keycode The keycode of the key to register.
@@ -1005,7 +951,6 @@
});
}
-
/**
* Event handler for messages from the most visited and edit custom link iframe.
* @param {Event} event Event received.
@@ -1101,7 +1046,6 @@
}
}
-
/**
* Prepares the New Tab Page by adding listeners, the most visited pages
* section, and Google-specific elements for a Google-provided page.
@@ -1267,7 +1211,6 @@
document.body.classList.add(CLASSES.INITED);
}
-
/**
* Create the Most Visited and edit custom links iframes.
*/
@@ -1287,7 +1230,8 @@
args.push(
'title=' +
encodeURIComponent(configData.translatedStrings.mostVisitedTitle));
- args.push('removeTooltip=' +
+ args.push(
+ 'removeTooltip=' +
encodeURIComponent(configData.translatedStrings.removeThumbnailTooltip));
if (configData.isGooglePage) {
@@ -1377,7 +1321,6 @@
window.addEventListener('message', handlePostMessage);
}
-
/**
* Binds event listeners.
*/
@@ -1385,7 +1328,6 @@
document.addEventListener('DOMContentLoaded', init);
}
-
/**
* Injects a middle-slot promo into the page. Called asynchronously, so that it
* doesn't block the main page load.
@@ -1419,7 +1361,6 @@
}
}
-
/**
* Injects search suggestions into the page. Called *synchronously* with cached
* data as not to cause shifting of the most visited tiles.
@@ -1442,7 +1383,6 @@
document.body.appendChild(endOfBodyScript);
}
-
/**
* Injects the One Google Bar into the page. Called asynchronously, so that it
* doesn't block the main page load.
@@ -1482,7 +1422,6 @@
ntpApiHandle.logEvent(LOG_TYPE.NTP_ONE_GOOGLE_BAR_SHOWN);
}
-
return {
init: init, // Exposed for testing.
listen: listen,
diff --git a/chrome/browser/resources/local_ntp/most_visited_single.js b/chrome/browser/resources/local_ntp/most_visited_single.js
index 7af4af40..d415b2f2 100644
--- a/chrome/browser/resources/local_ntp/most_visited_single.js
+++ b/chrome/browser/resources/local_ntp/most_visited_single.js
@@ -11,7 +11,6 @@
function MostVisited() {
'use strict';
-
/**
* Enum for key codes.
* @enum {number}
@@ -40,7 +39,6 @@
MV_TILES: 'mv-tiles', // Most Visited tiles container.
};
-
/**
* Enum for classnames.
* @enum {string}
@@ -71,7 +69,6 @@
NO_INITIAL_FADE: 'no-initial-fade',
};
-
/**
* The different types of events that are logged from the NTP. This enum is
* used to transfer information from the NTP JavaScript to the renderer and is
@@ -91,7 +88,6 @@
NTP_CUSTOMIZE_EDIT_SHORTCUT_CLICKED: 45,
};
-
/**
* The different (visual) types that an NTP tile can have.
* Note: Keep in sync with components/ntp_tiles/tile_visual_type.h
@@ -107,7 +103,6 @@
THUMBNAIL_FAILED: 8,
};
-
/**
* Timeout delay for the window.onresize event throttle. Set to 15 frame per
* second.
@@ -115,28 +110,24 @@
*/
const RESIZE_TIMEOUT_DELAY = 66;
-
/**
* Timeout delay in ms before starting the reorder flow.
* @const {number}
*/
const REORDER_TIMEOUT_DELAY = 1000;
-
/**
* Maximum number of tiles if custom links is enabled.
* @const {number}
*/
const MD_MAX_NUM_CUSTOM_LINK_TILES = 10;
-
/**
* Maximum number of tiles per row for Material Design.
* @const {number}
*/
const MD_MAX_TILES_PER_ROW = 5;
-
/**
* Height of a tile for Material Design. Keep in sync with
* most_visited_single.css.
@@ -144,7 +135,6 @@
*/
const MD_TILE_HEIGHT = 128;
-
/**
* Width of a tile for Material Design. Keep in sync with
* most_visited_single.css.
@@ -152,7 +142,6 @@
*/
const MD_TILE_WIDTH = 112;
-
/**
* Number of tiles that will always be visible for Material Design. Calculated
* by dividing minimum |--content-width| (see local_ntp.css) by |MD_TILE_WIDTH|
@@ -161,7 +150,6 @@
*/
const MD_NUM_TILES_ALWAYS_VISIBLE = 6;
-
/**
* The origin of this request, i.e. 'https://www.google.TLD' for the remote NTP,
* or 'chrome-search://local-ntp' for the local NTP.
@@ -169,7 +157,6 @@
*/
const DOMAIN_ORIGIN = '{{ORIGIN}}';
-
/**
* Counter for DOM elements that we are waiting to finish loading. Starts out
* at 1 because initially we're waiting for the "show" message from the parent.
@@ -177,7 +164,6 @@
*/
let loadedCounter = 1;
-
/**
* DOM element containing the tiles we are going to present next.
* Works as a double-buffer that is shown when we receive a "show" postMessage.
@@ -185,7 +171,6 @@
*/
let tiles = null;
-
/**
* Maximum number of MostVisited tiles to show at any time. If the host page
* doesn't send enough tiles and custom links is not enabled, we fill them blank
@@ -195,21 +180,18 @@
*/
let maxNumTiles = 8;
-
/**
* List of parameters passed by query args.
* @type {Object}
*/
let queryArgs = {};
-
/**
* True if we are currently reordering the tiles.
* @type {boolean}
*/
let reordering = false;
-
/**
* The tile that is being moved during the reorder flow. Null if we are
* currently not reordering.
@@ -217,7 +199,6 @@
*/
let elementToReorder = null;
-
/**
* True if the custom links feature is enabled, i.e. when this is a Google NTP.
* Set when the iframe is initialized.
@@ -225,21 +206,18 @@
*/
let customLinksFeatureEnabled = false;
-
/**
* True if the grid layout is enabled.
* @type {boolean}
*/
let isGridEnabled = false;
-
/**
* The current grid of tiles.
* @type {?Grid}
*/
let currGrid = null;
-
/**
* Called by tests to enable the grid layout.
*/
@@ -248,7 +226,6 @@
document.body.classList.add(CLASSES.GRID_LAYOUT);
}
-
/**
* Additional API for Array. Moves the item at index |from| to index |to|.
* @param {number} from Index of the item to move.
@@ -258,7 +235,6 @@
this.splice(to, 0, this.splice(from, 1)[0]);
};
-
/**
* Class that handles layouts and animations for the tile grid. This includes
* animations for adding, deleting, and reordering.
@@ -314,7 +290,6 @@
this.touchStarted_ = false;
}
-
/**
* Sets up the grid for the new tileset in |container|. The old tileset is
* discarded.
@@ -360,7 +335,6 @@
this.updateLayout();
}
-
/**
* Returns a grid tile wrapper that contains |tile|.
* @param {!Element} tile The tile element.
@@ -380,7 +354,6 @@
return gridTileContainer;
}
-
/**
* Updates the layout of the tiles. This is called for new tilesets and when
* the window is resized or zoomed. Translates each tile's
@@ -419,7 +392,6 @@
}
}
-
/**
* Called when the window is resized/zoomed. Recalculates maximums for the new
* window size and calls |updateLayout| if necessary.
@@ -434,7 +406,6 @@
}
}
-
/**
* Returns the number of tiles per row. This may be balanced in order to make
* even rows.
@@ -456,7 +427,6 @@
}
}
-
/**
* Returns the maximum number of tiles per row allowed by the window size.
* @return {number} The maximum number of tiles per row.
@@ -466,7 +436,6 @@
return Math.floor(window.innerWidth / this.tileWidth_);
}
-
/**
* Returns row 2's x offset from row 1 in px. This will either be 0 or half a
* tile length.
@@ -483,7 +452,6 @@
return 0;
}
-
/**
* Returns true if the browser is in RTL.
* @return {boolean}
@@ -493,7 +461,6 @@
return document.documentElement.dir === 'rtl';
}
-
/**
* Translates the |element| by (x, y).
* @param {?Element} element The element to apply the transform to.
@@ -509,7 +476,6 @@
element.style.transform = 'translate(' + rtlX + 'px, ' + y + 'px)';
}
-
/**
* Sets up event listeners necessary for tile reordering.
* @param {!Element} tile Tile on which to set the event listeners.
@@ -579,7 +545,6 @@
});
}
-
/**
* Starts the reorder flow. Updates the visual style of the held tile to
* indicate that it is being moved and sets up the relevant event listeners.
@@ -627,7 +592,6 @@
}
}
-
/**
* Stops the reorder flow. Resets the held tile's visual style and tells the
* EmbeddedSearchAPI that a tile has been moved.
@@ -652,7 +616,6 @@
this.newIndexOfItemToReorder_ = -1;
}
-
/**
* Executed only when the reorder flow is ongoing. Inserts the currently held
* tile at |index| and shifts tiles accordingly.
@@ -680,7 +643,6 @@
}
}
-
/**
* Translates the |tile|'s |CLASSES.GRID_TILE| from |index| to |newIndex|.
* This is done to prevent interference with event listeners on the |tile|'s
@@ -699,7 +661,6 @@
this.translate_(tile.children[0], x, y);
}
-
/**
* Moves |tile| so that it tracks the cursor's position. This is done by
* translating the |tile|'s |CLASSES.GRID_TILE|, which prevents interference
@@ -740,7 +701,6 @@
}
}
-
/**
* Log an event on the NTP.
* @param {number} eventType Event from LOG_TYPE.
@@ -753,12 +713,12 @@
* Log impression of an NTP tile.
* @param {number} tileIndex Position of the tile, >= 0 and < |maxNumTiles|.
* @param {number} tileTitleSource The source of the tile's title as received
- * from getMostVisitedItemData.
+ * from getMostVisitedItemData.
* @param {number} tileSource The tile's source as received from
- * getMostVisitedItemData.
+ * getMostVisitedItemData.
* @param {number} tileType The tile's visual type from TileVisualType.
* @param {Date} dataGenerationTime Timestamp representing when the tile was
- * produced by a ranking algorithm.
+ * produced by a ranking algorithm.
*/
function logMostVisitedImpression(
tileIndex, tileTitleSource, tileSource, tileType, dataGenerationTime) {
@@ -770,12 +730,12 @@
* Log click on an NTP tile.
* @param {number} tileIndex Position of the tile, >= 0 and < |maxNumTiles|.
* @param {number} tileTitleSource The source of the tile's title as received
- * from getMostVisitedItemData.
+ * from getMostVisitedItemData.
* @param {number} tileSource The tile's source as received from
- * getMostVisitedItemData.
+ * getMostVisitedItemData.
* @param {number} tileType The tile's visual type from TileVisualType.
* @param {Date} dataGenerationTime Timestamp representing when the tile was
- * produced by a ranking algorithm.
+ * produced by a ranking algorithm.
*/
function logMostVisitedNavigation(
tileIndex, tileTitleSource, tileSource, tileType, dataGenerationTime) {
@@ -783,7 +743,6 @@
tileIndex, tileTitleSource, tileSource, tileType, dataGenerationTime);
}
-
/**
* Returns true if custom links are enabled.
*/
@@ -792,7 +751,6 @@
!chrome.embeddedSearch.newTabPage.isUsingMostVisited;
}
-
/**
* Down counts the DOM elements that we are waiting for the page to load.
* When we get to 0, we send a message to the parent window.
@@ -823,7 +781,6 @@
}
}
-
/**
* Handles postMessages coming from the host page to the iframe.
* Mostly, it dispatches every command to handleCommand.
@@ -838,7 +795,6 @@
}
}
-
/**
* Handles a single command coming from the host page to the iframe.
* We try to keep the logic here to a minimum and just dispatch to the relevant
@@ -863,7 +819,6 @@
}
}
-
/**
* Handler for the 'show' message from the host page.
* @param {!Object} info Data received in the message.
@@ -876,7 +831,6 @@
countLoad();
}
-
/**
* Handler for the 'updateTheme' message from the host page.
* @param {!Object} info Data received in the message.
@@ -899,7 +853,6 @@
navigator.userAgent.indexOf('CrOS') > -1));
}
-
/**
* Handler for 'focusMenu' message from the host page. Focuses the edited tile's
* menu or the add shortcut tile after closing the custom link edit dialog
@@ -915,7 +868,6 @@
}
}
-
/**
* Removes all old instances of |IDS.MV_TILES| that are pending for deletion.
*/
@@ -927,7 +879,6 @@
}
}
-
/**
* Called when all tiles have finished loading (successfully or not), including
* their thumbnail images, and we are ready to show the new tiles and drop the
@@ -1001,7 +952,6 @@
tiles = document.createElement('div');
}
-
/**
* Explicitly hide tiles that are not visible in order to prevent keyboard
* navigation.
@@ -1021,7 +971,6 @@
}
}
-
/**
* Handler for the 'show' message from the host page, called when it wants to
* add a suggestion tile.
@@ -1071,7 +1020,6 @@
}
}
-
/**
* Starts edit custom link flow. Tells host page to show the edit custom link
* dialog and pre-populate it with data obtained using the link's id.
@@ -1081,7 +1029,6 @@
window.parent.postMessage({cmd: 'startEditLink', rid: rid}, DOMAIN_ORIGIN);
}
-
/**
* Starts the reorder flow. Updates the visual style of the held tile to
* indicate that it is being moved.
@@ -1100,7 +1047,6 @@
}, {once: true});
}
-
/**
* Stops the reorder flow. Resets the held tile's visual style and tells the
* EmbeddedSearchAPI that a tile has been moved.
@@ -1124,7 +1070,6 @@
Number(tile.getAttribute('data-pos')));
}
-
/**
* Sets up event listeners necessary for tile reordering.
* @param {!Element} tile Tile on which to set the event listeners.
@@ -1188,7 +1133,6 @@
});
}
-
/**
* Renders a MostVisited tile to the DOM.
* @param {?MostVisitedData} data Object containing rid, url, title, favicon,
@@ -1201,7 +1145,6 @@
return renderMaterialDesignTile(data);
}
-
/**
* Renders a MostVisited tile with Material Design styles.
* @param {?MostVisitedData} data Object containing rid, url, title, favicon,
@@ -1324,7 +1267,6 @@
mdTileInner.appendChild(mdIcon);
}
-
const mdTitle = document.createElement('div');
mdTitle.className = CLASSES.MD_TITLE;
mdTitle.style.direction = data.direction || 'ltr';
@@ -1382,7 +1324,6 @@
}
}
-
/**
* Does some initialization and parses the query arguments passed to the iframe.
*/
@@ -1448,7 +1389,6 @@
window.addEventListener('message', handlePostMessage);
}
-
/**
* Binds event listeners.
*/
@@ -1456,7 +1396,6 @@
document.addEventListener('DOMContentLoaded', init);
}
-
return {
Grid: Grid, // Exposed for testing.
init: init, // Exposed for testing.
diff --git a/chrome/browser/resources/local_ntp/most_visited_title.js b/chrome/browser/resources/local_ntp/most_visited_title.js
index f25e46d5..a4264625 100644
--- a/chrome/browser/resources/local_ntp/most_visited_title.js
+++ b/chrome/browser/resources/local_ntp/most_visited_title.js
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
/**
* @fileoverview Rendering for iframed most visited titles.
*/
diff --git a/chrome/browser/resources/local_ntp/most_visited_util.js b/chrome/browser/resources/local_ntp/most_visited_util.js
index db47443..0ee762a 100644
--- a/chrome/browser/resources/local_ntp/most_visited_util.js
+++ b/chrome/browser/resources/local_ntp/most_visited_util.js
@@ -2,19 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
/**
* @fileoverview Utilities for rendering most visited thumbnails and titles.
*/
-
/**
* The origin of this request.
* @const {string}
*/
const MV_DOMAIN_ORIGIN = '{{ORIGIN}}';
-
/**
* Converts an RGB color number to a hex color string if valid.
* @param {number} color A 6-digit hex RGB color code as a number.
@@ -32,7 +29,6 @@
return null;
}
-
/**
* Validates a RGBA color component. It must be a number between 0 and 255.
* @param {number} component An RGBA component.
@@ -42,7 +38,6 @@
return isFinite(component) && component >= 0 && component <= 255;
}
-
/**
* Converts an Array of color components into RGBA format "rgba(R,G,B,A)".
* @param {Array<number>} rgbaColor Array of rgba color components.
@@ -61,7 +56,6 @@
return null;
}
-
/**
* Parses query parameters from Location.
* @param {!Location} location The URL to generate the CSS url for.
@@ -86,7 +80,6 @@
return params;
}
-
/**
* Creates a new most visited link element.
* @param {Object} params URL parameters containing styles for the link.
@@ -156,7 +149,6 @@
return link;
}
-
/**
* Returns the color to display string with, depending on whether title is
* displayed, the current theme, and URL parameters.
@@ -188,7 +180,6 @@
return c;
}
-
/**
* Decodes most visited styles from URL parameters.
* - c: A hexadecimal number interpreted as a hex color code.
@@ -231,7 +222,6 @@
return styles;
}
-
/**
* Returns whether the given URL has a known, safe scheme.
* @param {string} url URL to check.
@@ -241,7 +231,6 @@
url.startsWith('ftp://') || url.startsWith('chrome-extension://');
};
-
/**
* @param {!Location} location A location containing URL parameters.
* @param {function(Object, Object)} fill A function called with styles and
diff --git a/chrome/browser/resources/local_ntp/utils.js b/chrome/browser/resources/local_ntp/utils.js
index 5b6f6b3..fdd0c69 100644
--- a/chrome/browser/resources/local_ntp/utils.js
+++ b/chrome/browser/resources/local_ntp/utils.js
@@ -13,7 +13,6 @@
MOUSE_NAVIGATION: 'mouse-navigation', // Removes blue focus ring.
};
-
/**
* Alias for document.getElementById.
* @param {string} id The ID of the element to find.
@@ -24,13 +23,11 @@
return document.getElementById(id);
}
-
/**
* Contains common functions used in the main NTP page and its iframes.
*/
const utils = {};
-
/**
* Disables the focus outline for |element| on mousedown.
* @param {Element} element The element to remove the focus outline from.
@@ -44,7 +41,6 @@
});
};
-
/**
* Returns whether the given URL has a known, safe scheme.
* @param {string} url URL to check.
@@ -54,7 +50,6 @@
url.startsWith('ftp://') || url.startsWith('chrome-extension://');
};
-
/**
* Sets CSS class for |element| corresponding to the current platform.
* @param {Element} element The element to set the current platform.
diff --git a/chrome/browser/resources/local_ntp/voice.js b/chrome/browser/resources/local_ntp/voice.js
index bb16fc8..46497631 100644
--- a/chrome/browser/resources/local_ntp/voice.js
+++ b/chrome/browser/resources/local_ntp/voice.js
@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
'use strict';
-
/**
* Get the preferred language for UI localization. Represents Chrome's UI
* language, which might not coincide with the user's "preferred" language
@@ -23,7 +21,6 @@
return window.navigator.language;
}
-
/**
* The different types of user action and error events that are logged
* from Voice Search. This enum is used to transfer information to
@@ -60,7 +57,6 @@
ERROR_OTHER: 29
};
-
/**
* Enum for keyboard event codes.
* @enum {!string}
@@ -75,7 +71,6 @@
TAB: 'Tab'
};
-
/**
* The set of possible recognition errors.
* @enum {!number}
@@ -94,7 +89,6 @@
OTHER: 9
};
-
/**
* Provides methods for communicating with the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API">
@@ -102,7 +96,6 @@
*/
const speech = {};
-
/**
* Localized translations for messages used in the Speech UI.
* @type {{
@@ -137,7 +130,6 @@
waiting: ''
};
-
/**
* The set of controller states.
* @enum {number}
@@ -181,7 +173,6 @@
STOPPED: 6
};
-
/**
* Threshold for considering an interim speech transcript result as "confident
* enough". The more confident the API is about a transcript, the higher the
@@ -199,7 +190,6 @@
*/
speech.ERROR_TIMEOUT_SHORT_MS_ = 3000;
-
/**
* Time in milliseconds to wait before closing the UI after an error has
* occured. This is a longer timeout used when there is a click-target is
@@ -209,7 +199,6 @@
*/
speech.ERROR_TIMEOUT_LONG_MS_ = 8000;
-
/**
* Time in milliseconds to wait before closing the UI if no interaction has
* occured.
@@ -218,7 +207,6 @@
*/
speech.IDLE_TIMEOUT_MS_ = 8000;
-
/**
* Maximum number of characters recognized before force-submitting a query.
* Includes characters of non-confident recognition transcripts.
@@ -227,7 +215,6 @@
*/
speech.QUERY_LENGTH_LIMIT_ = 120;
-
/**
* Specifies the current state of the controller.
* Note: Different than the UI state.
@@ -235,14 +222,12 @@
*/
speech.currentState_ = speech.State_.UNINITIALIZED;
-
/**
* The ID for the error timer.
* @private {number}
*/
speech.errorTimer_;
-
/**
* The duration of the timeout for the UI elements during an error state.
* Depending on the error state, we have different durations for the timeout.
@@ -250,7 +235,6 @@
*/
speech.errorTimeoutMs_ = 0;
-
/**
* The last high confidence voice transcript received from the Web Speech API.
* This is the actual query that could potentially be submitted to Search.
@@ -258,42 +242,36 @@
*/
speech.finalResult_;
-
/**
* Base URL for sending queries to Search. Includes trailing forward slash.
* @private {string}
*/
speech.googleBaseUrl_;
-
/**
* The ID for the idle timer.
* @private {number}
*/
speech.idleTimer_;
-
/**
* The last low confidence voice transcript received from the Web Speech API.
* @private {string}
*/
speech.interimResult_;
-
/**
* The Web Speech API object driving the speech recognition transaction.
* @private {!webkitSpeechRecognition}
*/
speech.recognition_;
-
/**
* Indicates if the user is using keyboard navigation (i.e. tab).
* @private {boolean}
*/
speech.usingKeyboardNavigation_ = false;
-
/**
* Log an event from Voice Search.
* @param {number} eventType Event from |LOG_TYPE|.
@@ -302,7 +280,6 @@
window.chrome.embeddedSearch.newTabPage.logEvent(eventType);
};
-
/**
* Initialize the speech module as part of the local NTP. Adds event handlers
* and shows the fakebox microphone icon.
@@ -368,7 +345,6 @@
speech.reset_();
};
-
/**
* Initializes and configures the speech recognition API.
* @private
@@ -386,7 +362,6 @@
speech.recognition_.onspeechstart = speech.handleRecognitionSpeechStart_;
};
-
/**
* Sets up the necessary states for voice search and then starts the
* speech recognition interface.
@@ -421,7 +396,6 @@
}
};
-
/**
* Hides the overlay and resets the speech state.
*/
@@ -432,7 +406,6 @@
speech.reset_();
};
-
/**
* Resets the internal state to the READY state.
* @private
@@ -450,7 +423,6 @@
speech.usingKeyboardNavigation_ = false;
};
-
/**
* Informs the view that the browser is receiving audio input.
* @param {Event=} opt_event Emitted event for audio start.
@@ -462,7 +434,6 @@
view.setReadyForSpeech();
};
-
/**
* Function is called when the user starts speaking.
* @param {Event=} opt_event Emitted event for speech start.
@@ -474,7 +445,6 @@
view.setReceivingSpeech();
};
-
/**
* Processes the recognition results arriving from the Web Speech API.
* @param {SpeechRecognitionEvent} responseEvent Event coming from the API.
@@ -540,7 +510,6 @@
}
};
-
/**
* Convert a |RecognitionError| to a |LOG_TYPE| error constant,
* for UMA logging.
@@ -572,7 +541,6 @@
}
};
-
/**
* Handles state transition for the controller when an error occurs
* during speech recognition.
@@ -592,7 +560,6 @@
}
};
-
/**
* Called when an error from Web Speech API is received.
* @param {SpeechRecognitionError} error The error event.
@@ -602,7 +569,6 @@
speech.onErrorReceived_(speech.getRecognitionError_(error.error));
};
-
/**
* Stops speech recognition when no matches are found.
* @private
@@ -611,7 +577,6 @@
speech.onErrorReceived_(RecognitionError.NO_MATCH);
};
-
/**
* Stops the UI when the Web Speech API reports that it has halted speech
* recognition.
@@ -647,7 +612,6 @@
speech.currentState_ = speech.State_.STOPPED;
};
-
/**
* Determines whether the user's browser is probably running on a Mac.
* @return {boolean} True iff the user's browser is running on a Mac.
@@ -657,7 +621,6 @@
return window.navigator.userAgent.includes('Macintosh');
};
-
/**
* Determines, if the given KeyboardEvent |code| is a space or enter key.
* @param {string} code A KeyboardEvent's |code| property.
@@ -675,7 +638,6 @@
}
};
-
/**
* Determines if the given event's target id is for a button or navigation link.
* @param {string} id An event's target id.
@@ -693,7 +655,6 @@
}
};
-
/**
* Handles the following keyboard actions.
* - <CTRL> + <SHIFT> + <.> starts voice input(<CMD> + <SHIFT> + <.> on mac).
@@ -733,7 +694,6 @@
}
};
-
/**
* Displays the no match error if no interactions occur after some time while
* the interface is active. This is a safety net in case the onend event
@@ -759,7 +719,6 @@
}
};
-
/**
* Aborts the speech recognition interface when the user switches to a new
* tab or window.
@@ -775,7 +734,6 @@
}
};
-
/**
* Aborts the speech session if the UI is showing and omnibox gets focused. Does
* not abort if the user is using keyboard navigation (i.e. tab).
@@ -787,7 +745,6 @@
}
};
-
/**
* Change the location of this tab to the new URL. Used for query submission.
* @param {!URL} url The URL to navigate to.
@@ -797,7 +754,6 @@
window.location.href = url.href;
};
-
/**
* Submits the final spoken speech query to perform a search.
* @private
@@ -824,7 +780,6 @@
speech.navigateToUrl_(queryUrl);
};
-
/**
* Returns the error type based on the error string received from the webkit
* speech recognition API.
@@ -877,7 +832,6 @@
}
};
-
/**
* Resets the idle state timeout.
* @param {number} duration The duration after which to close the UI.
@@ -888,7 +842,6 @@
speech.idleTimer_ = window.setTimeout(speech.onIdleTimeout_, duration);
};
-
/**
* Resets the idle error state timeout.
* @param {number} duration The duration after which to close the UI during an
@@ -900,7 +853,6 @@
speech.errorTimer_ = window.setTimeout(speech.stop, duration);
};
-
/**
* Check to see if the speech recognition interface is running, and has
* received any results.
@@ -911,7 +863,6 @@
return speech.currentState_ == speech.State_.RESULT_RECEIVED;
};
-
/**
* Check to see if the speech recognition interface is running.
* @return {boolean} True, if the speech recognition interface is running.
@@ -927,7 +878,6 @@
return false;
};
-
/**
* Check if the controller is in a state where the UI is definitely hidden.
* Since we show the UI for a few seconds after we receive an error from the
@@ -946,7 +896,6 @@
return false;
};
-
/**
* Handles click events during speech recognition.
* @param {boolean} shouldSubmit True if a query should be submitted.
@@ -970,36 +919,32 @@
}
};
-
/* TEXT VIEW */
+
/**
* Provides methods for styling and animating the text areas
* left of the microphone button.
*/
const text = {};
-
/**
* ID for the "Try Again" link shown in error output.
* @const
*/
text.RETRY_LINK_ID = 'voice-retry-link';
-
/**
* ID for the Voice Search support site link shown in error output.
* @const
*/
text.SUPPORT_LINK_ID = 'voice-support-link';
-
/**
* Class for the links shown in error output.
* @const @private
*/
text.ERROR_LINK_CLASS_ = 'voice-text-link';
-
/**
* Class name for the speech recognition result output area.
* @const @private
@@ -1012,49 +957,42 @@
*/
text.LISTENING_ANIMATION_CLASS_ = 'listening-animation';
-
/**
* ID of the final / high confidence speech recognition results element.
* @const @private
*/
text.FINAL_TEXT_AREA_ID_ = 'voice-text-f';
-
/**
* ID of the interim / low confidence speech recognition results element.
* @const @private
*/
text.INTERIM_TEXT_AREA_ID_ = 'voice-text-i';
-
/**
* The line height of the speech recognition results text.
* @const @private
*/
text.LINE_HEIGHT_ = 1.2;
-
/**
* Font size in the full page view in pixels.
* @const @private
*/
text.FONT_SIZE_ = 32;
-
/**
* Delay in milliseconds before showing the initializing message.
* @const @private
*/
text.INITIALIZING_TIMEOUT_MS_ = 300;
-
/**
* Delay in milliseconds before showing the listening message.
* @const @private
*/
text.LISTENING_TIMEOUT_MS_ = 2000;
-
/**
* Base link target for help regarding voice search. To be appended
* with a locale string for proper target site localization.
@@ -1063,35 +1001,30 @@
text.SUPPORT_LINK_BASE_ =
'https://support.google.com/chrome/?p=ui_voice_search&hl=';
-
/**
* The final / high confidence speech recognition result element.
* @private {Element}
*/
text.final_;
-
/**
* The interim / low confidence speech recognition result element.
* @private {Element}
*/
text.interim_;
-
/**
* Stores the ID of the initializing message timer.
* @private {number}
*/
text.initializingTimer_;
-
/**
* Stores the ID of the listening message timer.
* @private {number}
*/
text.listeningTimer_;
-
/**
* Finds the text view elements.
*/
@@ -1101,7 +1034,6 @@
text.clear();
};
-
/**
* Updates the text elements with new recognition results.
* @param {string} interimText Low confidence speech recognition result text.
@@ -1118,7 +1050,6 @@
text.interim_.className = text.final_.className = text.getTextClassName_();
};
-
/**
* Sets the text view to the initializing state. The initializing message
* shown while waiting for permission is not displayed immediately, but after
@@ -1140,7 +1071,6 @@
window.setTimeout(displayMessage, text.INITIALIZING_TIMEOUT_MS_);
};
-
/**
* Sets the text view to the ready state.
*/
@@ -1151,7 +1081,6 @@
text.startListeningMessageAnimation_();
};
-
/**
* Display an error message in the text area for the given error.
* @param {RecognitionError} error The error that occured.
@@ -1167,7 +1096,6 @@
}
};
-
/**
* Returns an error message based on the error.
* @param {RecognitionError} error The error that occured.
@@ -1193,7 +1121,6 @@
}
};
-
/**
* Returns an error message help link based on the error.
* @param {RecognitionError} error The error that occured.
@@ -1229,7 +1156,6 @@
}
};
-
/**
* Clears the text elements.
*/
@@ -1243,7 +1169,6 @@
text.final_.className = text.TEXT_AREA_CLASS_;
};
-
/**
* Cancels listening message display.
*/
@@ -1251,7 +1176,6 @@
window.clearTimeout(text.listeningTimer_);
};
-
/**
* Determines the class name of the text output Elements.
* @return {string} The class name.
@@ -1279,7 +1203,6 @@
return className;
};
-
/**
* Displays the listening message animation after the ready message has been
* shown for |text.LISTENING_TIMEOUT_MS_| milliseconds without further user
@@ -1298,87 +1221,77 @@
text.listeningTimer_ =
window.setTimeout(animateListeningText, text.LISTENING_TIMEOUT_MS_);
};
+
/* END TEXT VIEW */
-
/* MICROPHONE VIEW */
+
/**
* Provides methods for animating the microphone button and icon
* on the Voice Search full screen overlay.
*/
const microphone = {};
-
/**
* ID for the button Element.
* @const
*/
microphone.RED_BUTTON_ID = 'voice-button';
-
/**
* ID for the level animations Element that indicates input volume.
* @const @private
*/
microphone.LEVEL_ID_ = 'voice-level';
-
/**
* ID for the container of the microphone, red button and level animations.
* @const @private
*/
microphone.CONTAINER_ID_ = 'voice-button-container';
-
/**
* The minimum transform scale for the volume rings.
* @const @private
*/
microphone.LEVEL_SCALE_MINIMUM_ = 0.5;
-
/**
* The range of the transform scale for the volume rings.
* @const @private
*/
microphone.LEVEL_SCALE_RANGE_ = 0.55;
-
/**
* The minimum transition time (in milliseconds) for the volume rings.
* @const @private
*/
microphone.LEVEL_TIME_STEP_MINIMUM_ = 170;
-
/**
* The range of the transition time for the volume rings.
* @const @private
*/
microphone.LEVEL_TIME_STEP_RANGE_ = 10;
-
/**
* The button with the microphone icon.
* @private {Element}
*/
microphone.button_;
-
/**
* The voice level element that is displayed when the user starts speaking.
* @private {Element}
*/
microphone.level_;
-
/**
* Variable to indicate whether level animations are underway.
* @private {boolean}
*/
microphone.isLevelAnimating_ = false;
-
/**
* Creates/finds the output elements for the microphone rendering and animation.
*/
@@ -1390,7 +1303,6 @@
microphone.level_ = $(microphone.LEVEL_ID_);
};
-
/**
* Starts the volume circles animations, if it has not started yet.
*/
@@ -1401,7 +1313,6 @@
}
};
-
/**
* Stops the volume circles animations.
*/
@@ -1409,7 +1320,6 @@
microphone.isLevelAnimating_ = false;
};
-
/**
* Runs the volume level animation.
* @private
@@ -1431,31 +1341,29 @@
microphone.level_.style.setProperty('transform', 'scale(' + scale + ')');
window.setTimeout(microphone.runLevelAnimation_, timeStep);
};
+
/* END MICROPHONE VIEW */
-
/* VIEW */
+
/**
* Provides methods for manipulating and animating the Voice Search
* full screen overlay.
*/
const view = {};
-
/**
* ID for the close button in the speech output container.
* @const
*/
view.CLOSE_BUTTON_ID = 'voice-close-button';
-
/**
* Class name of the speech recognition interface on the homepage.
* @const @private
*/
view.OVERLAY_CLASS_ = 'overlay';
-
/**
* Class name of the speech recognition interface when it is hidden on the
* homepage.
@@ -1463,91 +1371,78 @@
*/
view.OVERLAY_HIDDEN_CLASS_ = 'overlay-hidden';
-
/**
* ID for the dialog that contains the speech recognition interface.
* @const @private
*/
view.DIALOG_ID_ = 'voice-overlay-dialog';
-
/**
* ID for the speech output background.
* @const @private
*/
view.BACKGROUND_ID_ = 'voice-overlay';
-
/**
* ID for the speech output container.
* @const @private
*/
view.CONTAINER_ID_ = 'voice-outer';
-
/**
* Class name used to modify the UI to the 'listening' state.
* @const @private
*/
view.MICROPHONE_LISTENING_CLASS_ = 'outer voice-ml';
-
/**
* Class name used to modify the UI to the 'receiving speech' state.
* @const @private
*/
view.RECEIVING_SPEECH_CLASS_ = 'outer voice-rs';
-
/**
* Class name used to modify the UI to the 'error received' state.
* @const @private
*/
view.ERROR_RECEIVED_CLASS_ = 'outer voice-er';
-
/**
* Class name used to modify the UI to the inactive state.
* @const @private
*/
view.INACTIVE_CLASS_ = 'outer';
-
/**
* Background element and container of all other elements.
* @private {Element}
*/
view.background_;
-
/**
* The container used to position the microphone and text output area.
* @private {Element}
*/
view.container_;
-
/**
* True if the the last error message shown was for the 'no-match' error.
* @private {boolean}
*/
view.isNoMatchShown_ = false;
-
/**
* True if the UI elements are visible.
* @private {boolean}
*/
view.isVisible_ = false;
-
/**
* The function to call when there is a click event.
* @private {Function}
*/
view.onClick_;
-
/**
* Displays the UI.
*/
@@ -1570,7 +1465,6 @@
}
};
-
/**
* Shows the pulsing animation emanating from the microphone. This should only
* be called when the Web Speech API starts receiving speech input (i.e.,
@@ -1586,7 +1480,6 @@
}
};
-
/**
* Updates the speech recognition results output with the latest results.
* @param {string} interimResultText Low confidence recognition text (grey).
@@ -1603,7 +1496,6 @@
}
};
-
/**
* Hides the UI and stops animations.
*/
@@ -1615,7 +1507,6 @@
text.clear();
};
-
/**
* Find the page elements that will be used to render the speech recognition
* interface area.
@@ -1633,7 +1524,6 @@
microphone.init();
};
-
/**
* Sets accessibility titles/labels for the page elements.
* @param {!Object} translatedStrings Dictionary of localized title strings.
@@ -1644,7 +1534,6 @@
closeButton.setAttribute('aria-label', translatedStrings.voiceCloseTooltip);
};
-
/**
* Displays an error message and stops animations.
* @param {RecognitionError} error The error type.
@@ -1656,7 +1545,6 @@
view.isNoMatchShown_ = (error == RecognitionError.NO_MATCH);
};
-
/**
* Makes the view visible.
* @private
@@ -1670,7 +1558,6 @@
}
};
-
/**
* Hides the view.
* @private
@@ -1683,7 +1570,6 @@
view.isVisible_ = false;
};
-
/**
* Stops the animations in the microphone view.
* @private
@@ -1692,7 +1578,6 @@
microphone.stopInputAnimation();
};
-
/**
* Makes sure that a click anywhere closes the UI when it is active.
* @param {!Event} event The click event.
@@ -1726,4 +1611,5 @@
view.onClick_(submitQuery, shouldRetry, navigatingAway);
};
+
/* END VIEW */