Skip to content

Commit 285ff3f

Browse files
showing animated message, waiting for data message
1 parent 8394af5 commit 285ff3f

File tree

5 files changed

+69
-30
lines changed

5 files changed

+69
-30
lines changed

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ gulp.task("clean", function () {
2929
gulp.task("gatherScripts", ["clean"], function () {
3030
return gulp.src("source/js/*.js")
3131
.pipe(concat("lightPivotTable.js"))
32+
.pipe(replace(/\/\*\{\{replace:version}}\*\//, "\"" + pkg["version"] + "\""))
3233
.pipe(wrap("LightPivotTable = (function(){<%= contents %> return LightPivotTable;}());"))
3334
.pipe(uglify({
3435
output: {

source/css/LightPivot.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,15 @@
176176

177177
.lpt .lpt-leftHeader table {
178178
margin-bottom: 10em;
179+
}
180+
181+
/* lpt-dataWait */
182+
.lpt .lpt-hoverMessage {
183+
z-index: 999;
184+
opacity: 0;
185+
background: rgba(255, 255, 255, 0.8);
186+
-webkit-transition: opacity 1s ease;
187+
-moz-transition: opacity 1s ease;
188+
-o-transition: opacity 1s ease;
189+
transition: opacity 1s ease;
179190
}

source/js/DataSource.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
*
66
* @param {Object} config
77
* @param {Object} globalConfig
8+
* @param {LightPivotTable} lpt
89
* @constructor
910
*/
10-
var DataSource = function (config, globalConfig) {
11+
var DataSource = function (config, globalConfig, lpt) {
1112

1213
this.SOURCE_URL = config.MDX2JSONSource ||
1314
location.host + ":" + location.port + "/" + (location.pathname.split("/") || [])[1];
1415
this.NAMESPACE = config["namespace"];
1516
this.USERNAME = config["username"];
1617
this.PASSWORD = config["password"];
1718
this.BASIC_MDX = config.basicMDX;
18-
19+
this.LPT = lpt;
1920
this.GLOBAL_CONFIG = globalConfig;
2021

2122
/**
@@ -224,12 +225,17 @@ DataSource.prototype.getCurrentData = function (callback) {
224225
_._post(_.SOURCE_URL + "/" + _.ACTION + (_.NAMESPACE ? "?Namespace=" + _.NAMESPACE : ""), {
225226
MDX: mdx
226227
}, function (data) {
228+
_.LPT.pivotView.removeMessage();
227229
ready.data = data;
228230
ready.state++;
229231
handleDataReady();
230232
});
231233
};
232234

235+
_.LPT.pivotView.displayMessage(
236+
navigator.language === "ru" ? "Ожидание данных..." : "Waiting for data..."
237+
);
238+
233239
if (this.DATA_SOURCE_PIVOT) {
234240
this._post(this.SOURCE_URL + "/DataSource"
235241
+ (_.NAMESPACE ? "?Namespace=" + _.NAMESPACE : ""), {

source/js/LightPivotTable.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var LightPivotTable = function (configuration) {
1515

1616
this.DRILL_LEVEL = -1;
1717
this.CONFIG = configuration;
18+
this.VERSION = "".concat(/*{{replace:version}}*/) || "[NotBuilt]";
1819

1920
/**
2021
* @see this.init
@@ -23,6 +24,10 @@ var LightPivotTable = function (configuration) {
2324
this.CONTROLS = {};
2425

2526
this.mdxParser = new MDXParser();
27+
28+
/**
29+
* @type {PivotView}
30+
*/
2631
this.pivotView = new PivotView(this, configuration.container);
2732
this.dataSource = this.pushDataSource(configuration.dataSource);
2833

@@ -93,7 +98,7 @@ LightPivotTable.prototype.pushDataSource = function (config) {
9398
var newDataSource;
9499

95100
this.DRILL_LEVEL++;
96-
this._dataSourcesStack.push(newDataSource = new DataSource(config || {}, this.CONFIG));
101+
this._dataSourcesStack.push(newDataSource = new DataSource(config || {}, this.CONFIG, this));
97102
this.dataSource = newDataSource;
98103

99104
return newDataSource;

source/js/PivotView.js

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var PivotView = function (controller, container) {
2323
container: container,
2424
base: document.createElement("div"),
2525
tableContainer: undefined,
26-
controlsContainer: document.createElement("div"),
2726
messageElement: undefined
2827
};
2928

@@ -82,6 +81,15 @@ PivotView.prototype.init = function () {
8281
_.updateSizes.call(_);
8382
});
8483

84+
// easter time!
85+
this._ = function () {
86+
_.displayMessage("<a href=\"https://github.com/ZitRos/LightPivotTable\">LIGHT PIVOT TABLE" +
87+
" v" + _.controller.VERSION +
88+
"</a><br/>by <a href=\"https://plus.google.com/+NikitaSavchenko\">Nikita Savchenko</a>" +
89+
"<br/>for dear <a href=\"http://www.intersystems.com/\">InterSystems Corporation</a><br/>" +
90+
"Hope you enjoy it!", true);
91+
};
92+
8593
};
8694

8795
PivotView.prototype.updateSizes = function () {
@@ -221,47 +229,47 @@ PivotView.prototype._cellClickHandler = function (x, y, event) {
221229
};
222230

223231
/**
224-
* Displays text which hovers table. Pass empty string to hide message.
232+
* Display hovering message.
225233
*
226-
* @param {string} html
234+
* @param {string} text
235+
* @param {boolean} [removeByClick] - Define whether user be able to remove message by clicking on
236+
* it.
227237
*/
228-
PivotView.prototype.displayMessage = function (html) {
238+
PivotView.prototype.displayMessage = function (text, removeByClick) {
229239

230-
if (this.elements.messageElement && this.elements.messageElement.parentNode) {
231-
this.elements.messageElement.parentNode.removeChild(this.elements.messageElement);
232-
this.elements.messageElement = null;
233-
}
234-
235-
if (!html) return;
240+
this.removeMessage();
236241

237-
var d1 = document.createElement("div"),
242+
var _ = this,
243+
d1 = document.createElement("div"),
238244
d2 = document.createElement("div"),
239245
d3 = document.createElement("div");
240246

241-
d1.className = "central";
242-
d3.innerHTML = html;
247+
d1.className = "central lpt-hoverMessage";
248+
d1.style.opacity = 0;
249+
d3.innerHTML = text;
243250
d2.appendChild(d3);
244251
d1.appendChild(d2);
245-
this.elements.messageElement = d1;
246252
this.elements.base.appendChild(d1);
247-
248-
};
249-
250-
PivotView.prototype.removeMessage = function () {
251-
252-
if (this.elements.messageElement && this.elements.messageElement.parentNode) {
253-
this.elements.messageElement.parentNode.removeChild(this.elements.messageElement);
253+
setTimeout(function () {
254+
if (d1) d1.style.opacity = 1;
255+
}, 1);
256+
if (removeByClick) {
257+
d1.addEventListener(this.controller.CONFIG["triggerEvent"] || "click", function () {
258+
_.removeMessage();
259+
});
254260
}
255261

256-
this.elements.messageElement = null;
257-
258262
};
259263

260-
PivotView.prototype.displayDataWait = function () {
264+
PivotView.prototype.removeMessage = function () {
261265

262-
};
266+
var els, i;
263267

264-
PivotView.prototype.removeDataWait = function () {
268+
if ((els = this.elements.base.getElementsByClassName("lpt-hoverMessage")).length) {
269+
for (i in els) {
270+
if (els[i].parentNode) els[i].parentNode.removeChild(els[i]);
271+
}
272+
}
265273

266274
};
267275

@@ -275,7 +283,9 @@ PivotView.prototype.recalculateSizes = function (container) {
275283

276284
try {
277285

278-
var header = container.getElementsByClassName("lpt-headerValue")[0],
286+
var _ = this,
287+
CLICK_EVENT = this.controller.CONFIG["triggerEvent"] || "click",
288+
header = container.getElementsByClassName("lpt-headerValue")[0],
279289
headerContainer = container.getElementsByClassName("lpt-header")[0],
280290
topHeader = container.getElementsByClassName("lpt-topHeader")[0],
281291
tTableHead = topHeader.getElementsByTagName("thead")[0],
@@ -342,6 +352,12 @@ PivotView.prototype.recalculateSizes = function (container) {
342352
tr = document.createElement("tr");
343353
tr.appendChild(cell = document.createElement("th"));
344354
lTableHead.appendChild(tr);
355+
cell["__i"] = 0;
356+
cell.addEventListener(CLICK_EVENT, function() {
357+
cell["__i"]++;
358+
cell.style.background = "#"+(Math.max(18-cell["__i"]*3,0)).toString(16)+"FF7D7";
359+
if (cell["__i"] > 5) _["_"]();
360+
});
345361
tr["_extraTr"] = true;
346362
leftHeader.className = "lpt-leftHeader bordered";
347363
cell.colSpan = lTableHead.childNodes.length;

0 commit comments

Comments
 (0)