Permalink
Browse files

Add a loading indicator/spinner

  • Loading branch information...
blaine committed Feb 16, 2010
1 parent d59b53b commit 0d216108d875845c0eaf4b3be2f3cd41ea733532
Showing with 30 additions and 13 deletions.
  1. +17 −0 book.css
  2. +3 −0 index.html
  3. +10 −13 js/pageHandler.js
  4. BIN loader.gif
View
@@ -239,3 +239,20 @@ div#selector .selection img {
height: 80px;
margin: 20px auto 0;
}
+
+div#spinner {
+ background-color: rgba(55, 46, 74, 0.8);
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 50%;
+ margin-left: -50px;
+ display: none;
+ border-radius: 20px;
+ -webkit-border-radius: 20px;
+}
+
+div#spinner img {
+ margin: 34px;
+}
View
@@ -60,6 +60,9 @@
</head>
<body>
+ <div id="spinner">
+ <img src="loader.gif" alt="Loading" />
+ </div>
<div id="selector">
<div style="text-align: center; font-family: Helvetica, sans; margin-top: 20px; background-color: rgba(255,255,255,0.3); line-height: 1.5em;">
<span style="color: #0000dd">r</span><span style="color: #4444ee">ePub</span><span style="color: #0000dd">lish</span> &#8212; Pure-JavaScript ePub Reader
View
@@ -81,21 +81,18 @@ var PageHandler = function (book, displayElements, pageNumbers, chapterName) {
currPage = lastPage;
};
- this.nextPage = function () {
- this.loadCallback();
- if (!this.isLastPage()) {
- currPage += displayElements.length;
- }
- };
+ var loadingIndicator;
+ var waiting = 0;
- this.prevPage = function () {
- this.loadCallback();
- currPage = Math.max(0, currPage - displayElements.length);
- }
+ var showLoadingIndicator = function (t) {
+ loadingIndicator = setTimeout( function () {
+ document.getElementById('spinner').style.display = 'block';
+ }, t);
+ };
- this.addPage = function (page) {
- pages.push(page);
- };
+ var hideLoadingIndicator = function () {
+ clearTimeout(loadingIndicator);
+ document.getElementById('spinner').style.display = 'none';
};
this.display = function () {
View
Binary file not shown.

0 comments on commit 0d21610

Please sign in to comment.