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

Unified Diff: chrome/browser/resources/components.js

Issue 209313002: Modified components ui to address concern of all the time disabled check update button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified as per code review comments. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/components.js
diff --git a/chrome/browser/resources/components.js b/chrome/browser/resources/components.js
index 8753e3192ab210b51c8f2d1ea813a50ca67c33bd..ef67ec014ccbdccab06c536c5cf32f702d368de5 100644
--- a/chrome/browser/resources/components.js
+++ b/chrome/browser/resources/components.js
@@ -14,8 +14,11 @@
function renderTemplate(componentsData) {
// This is the javascript code that processes the template:
var input = new JsEvalContext(componentsData);
- var output = $('componentTemplate');
+ var output = $('componentTemplate').cloneNode(true);
+ $('componentPlaceholder').innerHTML = '';
+ $('componentPlaceholder').appendChild(output);
jstProcess(input, output);
+ output.style.visibility = 'visible';
}
/**
@@ -72,6 +75,21 @@ function returnComponentsData(componentsData) {
body.className = 'show-tmi-mode-initial';
}
+function returnComponentStatus(component_id, status) {
+ $('status-' + component_id).innerText = status;
+ var node = $(component_id);
+ if (status == 'in-progress') {
+ node.disabled = true;
+ window.setTimeout(function() { updateComponentStatus(node); }, 1000);
+ } else {
+ node.disabled = false;
+ }
+}
+
+function updateComponentStatus(node) {
+ chrome.send('requestComponentStatus', [String(node.id)]);
+}
+
/**
* Handles an 'enable' or 'disable' button getting clicked.
* @param {HTMLElement} node The HTML element representing the component
@@ -79,12 +97,13 @@ function returnComponentsData(componentsData) {
*/
function handleCheckUpdate(node) {
node.disabled = true;
+
+ $('status-' + String(node.id)).innerText = 'Checking for update...';
+
// Tell the C++ ComponentssDOMHandler to check for update.
chrome.send('checkUpdate', [String(node.id)]);
+ window.setTimeout(function() { updateComponentStatus(node); }, 1000);
}
// Get data and have it displayed upon loading.
document.addEventListener('DOMContentLoaded', requestComponentsData);
-
-// Add handlers to static HTML elements.
-$('button-check-update').onclick = handleCheckUpdate;

Powered by Google App Engine
This is Rietveld 408576698