Commit db512577 authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[NTP] Allow image uploads for custom backgrounds

Make the upload an image option in the richer picker work. Selecting
an image and pressing open will immediately close the dialog. This
is consistent with the orgiinal version of the menu but will change
in the future.

Screencast: http://go/scrcast/NTc1MDQ4OTAzMzQ3NDA0OHw1MTNlMmNmMi02Yw

Bug: 937570
Change-Id: I7fa86164d530cc50c60c29385da14b4ae1921878
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611728
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659742}
parent 7e7a7ff1
......@@ -80,6 +80,7 @@ customBackgrounds.IDS = {
BACKGROUNDS_BUTTON: 'backgrounds-button',
BACKGROUNDS_IMAGE_MENU: 'backgrounds-image-menu',
BACKGROUNDS_MENU: 'backgrounds-menu',
BACKGROUNDS_UPLOAD: 'backgrounds-upload',
CANCEL: 'bg-sel-footer-cancel',
COLORS_BUTTON: 'colors-button',
CUSTOMIZATION_MENU: 'customization-menu',
......@@ -890,7 +891,11 @@ customBackgrounds.loadChromeBackgrounds = function() {
/* Close dialog when an image is selected via the file picker. */
customBackgrounds.closeCustomizationDialog = function() {
$(customBackgrounds.IDS.EDIT_BG_DIALOG).close();
if (configData.richerPicker) {
$(customBackgrounds.IDS.CUSTOMIZATION_MENU).close();
} else {
$(customBackgrounds.IDS.EDIT_BG_DIALOG).close();
}
};
/*
......@@ -1361,6 +1366,14 @@ customBackgrounds.initCustomBackgrounds = function(showErrorNotification) {
}
};
$(customBackgrounds.IDS.BACKGROUNDS_UPLOAD).onclick = uploadImageInteraction;
$(customBackgrounds.IDS.BACKGROUNDS_UPLOAD).onkeydown = function(event) {
if (event.keyCode === customBackgrounds.KEYCODES.ENTER ||
event.keyCode === customBackgrounds.KEYCODES.SPACE) {
uploadImageInteraction();
}
};
$(customBackgrounds.IDS.BACKGROUNDS_DEFAULT).onclick = function() {
const tile = $(customBackgrounds.IDS.BACKGROUNDS_DEFAULT_ICON);
tile.dataset.url = '';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment