Skip to content

Commit 7680db3

Browse files
better loading animation, loadingMessageHTML option
1 parent 1b19d25 commit 7680db3

5 files changed

Lines changed: 125 additions & 14 deletions

File tree

example/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
//, caption: "My table" // if set, table basic caption will be replaced by this text
106106
, showSummary: true // show summary by columns
107107
, enableHeadersScrolling: true // enable scrolling both for table and headers
108+
//, loadingMessageHTML: "LOADING DATA..." // HTML displaying during data load
108109
//, conditionalFormattingOn: true // enable conditional formatting rules
109110
//, drillDownTarget: "<dashboard name>" // undocumented, deepSee only
110111
};

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ var setup = { // Object that contain settings. Any setting may be missed.
5656
[ , caption: "My table" // if set, table basic caption will be replaced by this text ]
5757
[ , showSummary: true // show summary by columns ]
5858
[ , conditionalFormattingOn: true // pass false to turn off conditional formatting ]
59+
[ , loadingMessageHTML: "LOADING DATA..." // HTML displaying during data load ]
5960
[ , enableHeadersScrolling: false // enable scrolling both for table and headers. Useful for mobile devices. ]
6061
[ , drillDownTarget: "<dashboard name>" // deepSee only - dashboard to open ]
6162
},

source/css/LightPivot.css

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,114 @@
202202
}
203203
.lpt-scrollable-y::-webkit-scrollbar {
204204
display: none;
205+
}
206+
207+
/* progress bar */
208+
.lpt-spinner {
209+
margin: 100px auto;
210+
width: 100px;
211+
height: 60px;
212+
text-align: center;
213+
font-size: 10px;
214+
}
215+
216+
.lpt-spinner > div {
217+
background-color: #555;
218+
height: 100%;
219+
width: 9px;
220+
margin: 0 3px 0 0;
221+
display: inline-block;
222+
223+
-webkit-animation: lpt-stretch 0.8s infinite ease-in;
224+
-moz-animation: lpt-stretch 0.8s infinite ease-in;
225+
-o-animation: lpt-stretch 0.8s infinite ease-in;
226+
animation: lpt-stretch 0.8s infinite ease-in;
227+
}
228+
229+
.lpt-spinner > div:nth-child(2) {
230+
-webkit-animation-delay: -0.7s;
231+
-moz-animation-delay: -0.7s;
232+
-o-animation-delay: -0.7s;
233+
animation-delay: -0.7s;
234+
}
235+
236+
.lpt-spinner > div:nth-child(3) {
237+
-webkit-animation-delay: -0.6s;
238+
-moz-animation-delay: -0.6s;
239+
-o-animation-delay: -0.6s;
240+
animation-delay: -0.6s;
241+
}
242+
243+
.lpt-spinner > div:nth-child(4) {
244+
-webkit-animation-delay: -0.5s;
245+
-moz-animation-delay: -0.5s;
246+
-o-animation-delay: -0.5s;
247+
animation-delay: -0.5s;
248+
}
249+
250+
.lpt-spinner > div:nth-child(5) {
251+
-webkit-animation-delay: -0.4s;
252+
-moz-animation-delay: -0.4s;
253+
-o-animation-delay: -0.4s;
254+
animation-delay: -0.4s;
255+
}
256+
257+
@-webkit-keyframes lpt-stretch {
258+
0%, 40%, 100% {
259+
-webkit-transform: scaleY(0.4);
260+
-moz-transform: scaleY(0.4);
261+
-o-transform: scaleY(0.4);
262+
transform: scaleY(0.4);
263+
}
264+
20% {
265+
-webkit-transform: scaleY(1.0);
266+
-moz-transform: scaleY(1.0);
267+
-o-transform: scaleY(1.0);
268+
transform: scaleY(1.0);
269+
}
270+
}
271+
272+
@-moz-keyframes lpt-stretch {
273+
0%, 40%, 100% {
274+
-webkit-transform: scaleY(0.4);
275+
-moz-transform: scaleY(0.4);
276+
-o-transform: scaleY(0.4);
277+
transform: scaleY(0.4);
278+
}
279+
20% {
280+
-webkit-transform: scaleY(1.0);
281+
-moz-transform: scaleY(1.0);
282+
-o-transform: scaleY(1.0);
283+
transform: scaleY(1.0);
284+
}
285+
}
286+
287+
@-o-keyframes lpt-stretch {
288+
0%, 40%, 100% {
289+
-webkit-transform: scaleY(0.4);
290+
-moz-transform: scaleY(0.4);
291+
-o-transform: scaleY(0.4);
292+
transform: scaleY(0.4);
293+
}
294+
20% {
295+
-webkit-transform: scaleY(1.0);
296+
-moz-transform: scaleY(1.0);
297+
-o-transform: scaleY(1.0);
298+
transform: scaleY(1.0);
299+
}
300+
}
301+
302+
@keyframes lpt-stretch {
303+
0%, 40%, 100% {
304+
-webkit-transform: scaleY(0.4);
305+
-moz-transform: scaleY(0.4);
306+
-o-transform: scaleY(0.4);
307+
transform: scaleY(0.4);
308+
}
309+
20% {
310+
-webkit-transform: scaleY(1.0);
311+
-moz-transform: scaleY(1.0);
312+
-o-transform: scaleY(1.0);
313+
transform: scaleY(1.0);
314+
}
205315
}

source/js/DataSource.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ DataSource.prototype.getCurrentData = function (callback) {
232232
});
233233
};
234234

235-
_.LPT.pivotView.displayMessage(
236-
navigator.language === "ru" ? "Ожидание данных..." : "Waiting for data..."
237-
);
235+
_.LPT.pivotView.displayLoading();
238236

239237
if (this.DATA_SOURCE_PIVOT) {
240238
this._post(this.SOURCE_URL + "/DataSource"

source/js/PivotView.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PivotView.prototype.init = function () {
6464

6565
this.pushTable();
6666

67-
this.displayMessage(navigator.language === "ru" ? "Загрузка..." : "Loading...");
67+
this.displayLoading();
6868

6969
window.addEventListener("resize", function () {
7070
_.updateSizes.call(_);
@@ -81,6 +81,17 @@ PivotView.prototype.init = function () {
8181

8282
};
8383

84+
PivotView.prototype.displayLoading = function () {
85+
86+
this.displayMessage(
87+
this.controller.CONFIG["loadingMessageHTML"]
88+
|| "<div class=\"lpt-spinner\">" +
89+
"<div></div><div></div><div></div><div></div><div></div>" +
90+
"</div>"
91+
);
92+
93+
};
94+
8495
PivotView.prototype.updateSizes = function () {
8596

8697
for (var i in this.tablesStack) {
@@ -374,7 +385,6 @@ PivotView.prototype.recalculateSizes = function (container) {
374385
containerHeight = container.offsetHeight,
375386
mainHeaderWidth = headerContainer.offsetWidth,
376387
hasVerticalScrollBar = tableBlock.scrollHeight > containerHeight - headerH,
377-
//addExtraTopHeaderCell = tTableHead.offsetWidth > topHeader.offsetWidth,
378388
addExtraLeftHeaderCell = lTableHead.offsetHeight > containerHeight - headerH
379389
&& this.SCROLLBAR_WIDTH > 0,
380390
cell, tr, cellWidths = [], columnHeights = [], i;
@@ -409,13 +419,6 @@ PivotView.prototype.recalculateSizes = function (container) {
409419
tableBlock.style.height = containerHeight - headerH + "px";
410420
headerContainer.style.height = headerH + "px";
411421

412-
//if (false && addExtraTopHeaderCell) {
413-
// tTableHead.childNodes[0].appendChild(cell = document.createElement("td"));
414-
// cell.rowSpan = tTableHead.childNodes.length;
415-
// cell.style.width = this.SCROLLBAR_WIDTH + "px"; // lucky random
416-
// cell["_extraCell"] = true;
417-
//}
418-
419422
if (addExtraLeftHeaderCell) {
420423
tr = document.createElement("tr");
421424
tr.appendChild(cell = document.createElement("th"));
@@ -431,8 +434,6 @@ PivotView.prototype.recalculateSizes = function (container) {
431434
+ " bordered";
432435
cell.colSpan = lTableHead.childNodes.length;
433436
cell.style.height = this.SCROLLBAR_WIDTH + "px";
434-
//cell.textContent = "_"; // cheating
435-
//cell.style.lineHeight = headerH + "px"; // lucky random
436437
}
437438

438439
for (i in tableTr.childNodes) {

0 commit comments

Comments
 (0)