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

Unified Diff: components/dom_distiller/content/resources/dom_distiller_viewer.js

Issue 444143002: Loading Indicator for Distilled Pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inverted to isLastPage Created 6 years, 4 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: components/dom_distiller/content/resources/dom_distiller_viewer.js
diff --git a/components/dom_distiller/content/resources/dom_distiller_viewer.js b/components/dom_distiller/content/resources/dom_distiller_viewer.js
index 94299467ef3df0b6ffa129f1ee149d008e58eec8..4ed1e012bd11dc9fd547e3a1b235c3f9647a9fa5 100644
--- a/components/dom_distiller/content/resources/dom_distiller_viewer.js
+++ b/components/dom_distiller/content/resources/dom_distiller_viewer.js
@@ -9,8 +9,13 @@ function addToPage(html) {
}
function showLoadingIndicator(isLastPage) {
- document.getElementById('loadingIndicator').className =
- isLastPage ? 'hidden' : 'visible';
+ if (isLastPage) {
nyquist 2014/08/11 20:47:05 Could this just be something short like this? d
sunangel 2014/08/12 01:56:08 I think it would be better if it were ordered like
nyquist 2014/08/12 22:04:32 AFAIK the interval only triggers after 600 ms, and
sunangel 2014/08/12 23:17:55 Done.
+ document.getElementById('loadingIndicator').className ='hidden';
+ updateLoadingIndicator(isLastPage);
+ } else {
+ updateLoadingIndicator(isLastPage);
+ document.getElementById('loadingIndicator').className ='visible';
+ }
}
// Maps JS theme to CSS class and then changes body class name.
@@ -26,3 +31,21 @@ function useTheme(theme) {
}
document.body.className = cssClass;
}
+
+var updateLoadingIndicator = function() {
+ var colors = ["red", "yellow", "green", "blue"];
+ return function(isLastPage) {
+ if (!isLastPage && typeof this.colorShuffle == "undefined") {
+ var loader = document.getElementById("loader");
+ if (loader) {
+ var colorIndex = -1;
+ this.colorShuffle = setInterval(function() {
+ colorIndex = (colorIndex + 1) % colors.length;
nyquist 2014/08/12 22:04:32 I think these two lines are missing indentation.
sunangel 2014/08/12 23:17:55 Done.
+ loader.className = colors[colorIndex];
+ }, 600);
+ }
+ } else if (isLastPage && typeof this.colorShuffle != "undefined") {
+ clearInterval(this.colorShuffle);
+ }
+ };
+}();

Powered by Google App Engine
This is Rietveld 408576698