pace_rails 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/pace.js +615 -0
- data/lib/pace_rails/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af674020f4b73d908cbc9808b7176ff1f740c007
|
4
|
+
data.tar.gz: 3df997dc5624aefe42a8fbce88e45939a2fe3012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20d1bf536f7e89992c7de245fcf31eb55279c1f826624b084ac7eb10117ad0bb786d9a3c807bb17a736e08a7872e611948c07a8dbb176662c9c53b0db62016cc
|
7
|
+
data.tar.gz: 2df27bce0c5b089826e6d49565ae3ef7e8872af29220c6df48f8736ba094069334f9476153c8fea52ad8a59e12af1234ec64121ceb4a182e46acb488eb63ff31
|
@@ -0,0 +1,615 @@
|
|
1
|
+
(function() {
|
2
|
+
var AjaxMonitor, Bar, DocumentMonitor, ElementMonitor, ElementTracker, EventLagMonitor, Events, RequestIntercept, RequestTracker, SOURCE_KEYS, Scaler, animation, bar, cancelAnimation, cancelAnimationFrame, defaultOptions, extend, getFromDOM, handlePushState, init, intercept, now, options, requestAnimationFrame, result, runAnimation, scalers, sources, uniScaler, _XDomainRequest, _XMLHttpRequest, _pushState, _replaceState,
|
3
|
+
__slice = [].slice,
|
4
|
+
__hasProp = {}.hasOwnProperty,
|
5
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
6
|
+
|
7
|
+
defaultOptions = {
|
8
|
+
catchupTime: 500,
|
9
|
+
initialRate: .03,
|
10
|
+
minTime: 500,
|
11
|
+
ghostTime: 250,
|
12
|
+
maxProgressPerFrame: 10,
|
13
|
+
easeFactor: 1.25,
|
14
|
+
restartOnPushState: true,
|
15
|
+
elements: {
|
16
|
+
checkInterval: 100,
|
17
|
+
selectors: ['body']
|
18
|
+
}
|
19
|
+
};
|
20
|
+
|
21
|
+
now = function() {
|
22
|
+
var _ref;
|
23
|
+
return (_ref = typeof performance !== "undefined" && performance !== null ? typeof performance.now === "function" ? performance.now() : void 0 : void 0) != null ? _ref : +(new Date);
|
24
|
+
};
|
25
|
+
|
26
|
+
requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
|
27
|
+
|
28
|
+
cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
|
29
|
+
|
30
|
+
if (requestAnimationFrame == null) {
|
31
|
+
requestAnimationFrame = function(fn) {
|
32
|
+
return setTimeout(fn, 50);
|
33
|
+
};
|
34
|
+
cancelAnimationFrame = function(id) {
|
35
|
+
return clearTimeout(id);
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
runAnimation = function(fn) {
|
40
|
+
var last, tick;
|
41
|
+
last = now();
|
42
|
+
tick = function() {
|
43
|
+
var diff;
|
44
|
+
diff = now() - last;
|
45
|
+
last = now();
|
46
|
+
return fn(diff, function() {
|
47
|
+
return requestAnimationFrame(tick);
|
48
|
+
});
|
49
|
+
};
|
50
|
+
return tick();
|
51
|
+
};
|
52
|
+
|
53
|
+
result = function() {
|
54
|
+
var args, key, obj;
|
55
|
+
obj = arguments[0], key = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
|
56
|
+
if (typeof obj[key] === 'function') {
|
57
|
+
return obj[key].apply(obj, args);
|
58
|
+
} else {
|
59
|
+
return obj[key];
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
extend = function() {
|
64
|
+
var key, out, source, sources, val, _i, _len;
|
65
|
+
out = arguments[0], sources = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
66
|
+
for (_i = 0, _len = sources.length; _i < _len; _i++) {
|
67
|
+
source = sources[_i];
|
68
|
+
if (source) {
|
69
|
+
for (key in source) {
|
70
|
+
if (!__hasProp.call(source, key)) continue;
|
71
|
+
val = source[key];
|
72
|
+
if ((out[key] != null) && typeof out[key] === 'object' && (val != null) && typeof val === 'object') {
|
73
|
+
extend(out[key], val);
|
74
|
+
} else {
|
75
|
+
out[key] = val;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
return out;
|
81
|
+
};
|
82
|
+
|
83
|
+
getFromDOM = function(key, json) {
|
84
|
+
var data, e, el;
|
85
|
+
if (key == null) {
|
86
|
+
key = 'options';
|
87
|
+
}
|
88
|
+
if (json == null) {
|
89
|
+
json = true;
|
90
|
+
}
|
91
|
+
el = document.querySelector("[data-pace-" + key + "]");
|
92
|
+
if (!el) {
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
data = el.getAttribute("data-pace-" + key);
|
96
|
+
if (!json) {
|
97
|
+
return data;
|
98
|
+
}
|
99
|
+
try {
|
100
|
+
return JSON.parse(data);
|
101
|
+
} catch (_error) {
|
102
|
+
e = _error;
|
103
|
+
return typeof console !== "undefined" && console !== null ? console.error("Error parsing inline pace options", e) : void 0;
|
104
|
+
}
|
105
|
+
};
|
106
|
+
|
107
|
+
if (window.Pace == null) {
|
108
|
+
window.Pace = {};
|
109
|
+
}
|
110
|
+
|
111
|
+
options = Pace.options = extend(defaultOptions, window.paceOptions, getFromDOM());
|
112
|
+
|
113
|
+
Bar = (function() {
|
114
|
+
function Bar() {
|
115
|
+
this.progress = 0;
|
116
|
+
}
|
117
|
+
|
118
|
+
Bar.prototype.getElement = function() {
|
119
|
+
if (this.el == null) {
|
120
|
+
this.el = document.createElement('div');
|
121
|
+
this.el.className = "pace pace-active";
|
122
|
+
this.el.innerHTML = '<div class="pace-progress">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>';
|
123
|
+
if (document.body.firstChild != null) {
|
124
|
+
document.body.insertBefore(this.el, document.body.firstChild);
|
125
|
+
} else {
|
126
|
+
document.body.appendChild(this.el);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
return this.el;
|
130
|
+
};
|
131
|
+
|
132
|
+
Bar.prototype.finish = function() {
|
133
|
+
var el;
|
134
|
+
el = this.getElement();
|
135
|
+
el.className = el.className.replace('pace-active', '');
|
136
|
+
return el.className += ' pace-inactive';
|
137
|
+
};
|
138
|
+
|
139
|
+
Bar.prototype.update = function(prog) {
|
140
|
+
this.progress = prog;
|
141
|
+
return this.render();
|
142
|
+
};
|
143
|
+
|
144
|
+
Bar.prototype.destroy = function() {
|
145
|
+
this.getElement().parentNode.removeChild(this.getElement());
|
146
|
+
return this.el = void 0;
|
147
|
+
};
|
148
|
+
|
149
|
+
Bar.prototype.render = function() {
|
150
|
+
var el, progressStr;
|
151
|
+
if (document.body == null) {
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
el = this.getElement();
|
155
|
+
el.children[0].style.width = "" + this.progress + "%";
|
156
|
+
if (!this.lastRenderedProgress || this.lastRenderedProgress | 0 !== this.progress | 0) {
|
157
|
+
el.setAttribute('data-progress-text', "" + (this.progress | 0) + "%");
|
158
|
+
if (this.progress >= 100) {
|
159
|
+
progressStr = '99';
|
160
|
+
} else {
|
161
|
+
progressStr = this.progress < 10 ? "0" : "";
|
162
|
+
progressStr += this.progress | 0;
|
163
|
+
}
|
164
|
+
el.setAttribute('data-progress', "" + progressStr);
|
165
|
+
}
|
166
|
+
return this.lastRenderedProgress = this.progress;
|
167
|
+
};
|
168
|
+
|
169
|
+
Bar.prototype.done = function() {
|
170
|
+
return this.progress >= 100;
|
171
|
+
};
|
172
|
+
|
173
|
+
return Bar;
|
174
|
+
|
175
|
+
})();
|
176
|
+
|
177
|
+
Events = (function() {
|
178
|
+
function Events() {
|
179
|
+
this.bindings = {};
|
180
|
+
}
|
181
|
+
|
182
|
+
Events.prototype.trigger = function(name, val) {
|
183
|
+
var binding, _i, _len, _ref, _results;
|
184
|
+
if (this.bindings[name] != null) {
|
185
|
+
_ref = this.bindings[name];
|
186
|
+
_results = [];
|
187
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
188
|
+
binding = _ref[_i];
|
189
|
+
_results.push(binding.call(this, val));
|
190
|
+
}
|
191
|
+
return _results;
|
192
|
+
}
|
193
|
+
};
|
194
|
+
|
195
|
+
Events.prototype.on = function(name, fn) {
|
196
|
+
var _base;
|
197
|
+
if ((_base = this.bindings)[name] == null) {
|
198
|
+
_base[name] = [];
|
199
|
+
}
|
200
|
+
return this.bindings[name].push(fn);
|
201
|
+
};
|
202
|
+
|
203
|
+
return Events;
|
204
|
+
|
205
|
+
})();
|
206
|
+
|
207
|
+
_XMLHttpRequest = window.XMLHttpRequest;
|
208
|
+
|
209
|
+
_XDomainRequest = window.XDomainRequest;
|
210
|
+
|
211
|
+
RequestIntercept = (function(_super) {
|
212
|
+
__extends(RequestIntercept, _super);
|
213
|
+
|
214
|
+
function RequestIntercept() {
|
215
|
+
var monitor,
|
216
|
+
_this = this;
|
217
|
+
RequestIntercept.__super__.constructor.apply(this, arguments);
|
218
|
+
monitor = function(req) {
|
219
|
+
var _open;
|
220
|
+
_open = req.open;
|
221
|
+
return req.open = function(type, url, async) {
|
222
|
+
_this.trigger('request', {
|
223
|
+
type: type,
|
224
|
+
url: url,
|
225
|
+
request: req
|
226
|
+
});
|
227
|
+
return _open.apply(req, arguments);
|
228
|
+
};
|
229
|
+
};
|
230
|
+
window.XMLHttpRequest = function() {
|
231
|
+
var req;
|
232
|
+
req = new _XMLHttpRequest;
|
233
|
+
monitor(req);
|
234
|
+
return req;
|
235
|
+
};
|
236
|
+
if (_XDomainRequest != null) {
|
237
|
+
window.XDomainRequest = function() {
|
238
|
+
var req;
|
239
|
+
req = new _XDomainRequest;
|
240
|
+
monitor(req);
|
241
|
+
return req;
|
242
|
+
};
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
return RequestIntercept;
|
247
|
+
|
248
|
+
})(Events);
|
249
|
+
|
250
|
+
intercept = new RequestIntercept;
|
251
|
+
|
252
|
+
AjaxMonitor = (function() {
|
253
|
+
function AjaxMonitor() {
|
254
|
+
var _this = this;
|
255
|
+
this.elements = [];
|
256
|
+
intercept.on('request', function(_arg) {
|
257
|
+
var request;
|
258
|
+
request = _arg.request;
|
259
|
+
return _this.watch(request);
|
260
|
+
});
|
261
|
+
}
|
262
|
+
|
263
|
+
AjaxMonitor.prototype.watch = function(request) {
|
264
|
+
var tracker;
|
265
|
+
tracker = new RequestTracker(request);
|
266
|
+
return this.elements.push(tracker);
|
267
|
+
};
|
268
|
+
|
269
|
+
return AjaxMonitor;
|
270
|
+
|
271
|
+
})();
|
272
|
+
|
273
|
+
RequestTracker = (function() {
|
274
|
+
function RequestTracker(request) {
|
275
|
+
var handler, size, _fn, _i, _len, _onprogress, _onreadystatechange, _ref,
|
276
|
+
_this = this;
|
277
|
+
this.progress = 0;
|
278
|
+
if (request.onprogress !== void 0) {
|
279
|
+
size = null;
|
280
|
+
_onprogress = request.onprogress;
|
281
|
+
request.onprogress = function() {
|
282
|
+
var e, headers, name, val;
|
283
|
+
try {
|
284
|
+
headers = request.getAllResponseHeaders();
|
285
|
+
for (name in headers) {
|
286
|
+
val = headers[name];
|
287
|
+
if (name.toLowerCase() === 'content-length') {
|
288
|
+
size = +val;
|
289
|
+
break;
|
290
|
+
}
|
291
|
+
}
|
292
|
+
} catch (_error) {
|
293
|
+
e = _error;
|
294
|
+
}
|
295
|
+
if (size != null) {
|
296
|
+
try {
|
297
|
+
return _this.progress = request.responseText.length / size;
|
298
|
+
} catch (_error) {
|
299
|
+
e = _error;
|
300
|
+
}
|
301
|
+
} else {
|
302
|
+
return _this.progress = _this.progress + (100 - _this.progress) / 2;
|
303
|
+
}
|
304
|
+
};
|
305
|
+
if (typeof _onprogress === "function") {
|
306
|
+
_onprogress.apply(null, arguments);
|
307
|
+
}
|
308
|
+
_ref = ['onload', 'onabort', 'ontimeout', 'onerror'];
|
309
|
+
_fn = function() {
|
310
|
+
var fn;
|
311
|
+
fn = request[handler];
|
312
|
+
return request[handler] = function() {
|
313
|
+
_this.progress = 100;
|
314
|
+
return typeof fn === "function" ? fn.apply(null, arguments) : void 0;
|
315
|
+
};
|
316
|
+
};
|
317
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
318
|
+
handler = _ref[_i];
|
319
|
+
_fn();
|
320
|
+
}
|
321
|
+
} else {
|
322
|
+
_onreadystatechange = request.onreadystatechange;
|
323
|
+
request.onreadystatechange = function() {
|
324
|
+
var _ref1;
|
325
|
+
if ((_ref1 = request.readyState) === 0 || _ref1 === 4) {
|
326
|
+
_this.progress = 100;
|
327
|
+
} else if (request.readyState === 3) {
|
328
|
+
_this.progress = 50;
|
329
|
+
}
|
330
|
+
return typeof _onreadystatechange === "function" ? _onreadystatechange.apply(null, arguments) : void 0;
|
331
|
+
};
|
332
|
+
}
|
333
|
+
}
|
334
|
+
|
335
|
+
return RequestTracker;
|
336
|
+
|
337
|
+
})();
|
338
|
+
|
339
|
+
ElementMonitor = (function() {
|
340
|
+
function ElementMonitor(options) {
|
341
|
+
var selector, _i, _len, _ref;
|
342
|
+
if (options == null) {
|
343
|
+
options = {};
|
344
|
+
}
|
345
|
+
this.elements = [];
|
346
|
+
if (options.selectors == null) {
|
347
|
+
options.selectors = [];
|
348
|
+
}
|
349
|
+
_ref = options.selectors;
|
350
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
351
|
+
selector = _ref[_i];
|
352
|
+
this.elements.push(new ElementTracker(selector));
|
353
|
+
}
|
354
|
+
}
|
355
|
+
|
356
|
+
return ElementMonitor;
|
357
|
+
|
358
|
+
})();
|
359
|
+
|
360
|
+
ElementTracker = (function() {
|
361
|
+
function ElementTracker(selector) {
|
362
|
+
this.selector = selector;
|
363
|
+
this.progress = 0;
|
364
|
+
this.check();
|
365
|
+
}
|
366
|
+
|
367
|
+
ElementTracker.prototype.check = function() {
|
368
|
+
var _this = this;
|
369
|
+
if (document.querySelector(this.selector)) {
|
370
|
+
return this.done();
|
371
|
+
} else {
|
372
|
+
return setTimeout((function() {
|
373
|
+
return _this.check();
|
374
|
+
}), options.elements.checkInterval);
|
375
|
+
}
|
376
|
+
};
|
377
|
+
|
378
|
+
ElementTracker.prototype.done = function() {
|
379
|
+
return this.progress = 100;
|
380
|
+
};
|
381
|
+
|
382
|
+
return ElementTracker;
|
383
|
+
|
384
|
+
})();
|
385
|
+
|
386
|
+
DocumentMonitor = (function() {
|
387
|
+
DocumentMonitor.prototype.states = {
|
388
|
+
loading: 0,
|
389
|
+
interactive: 50,
|
390
|
+
complete: 100
|
391
|
+
};
|
392
|
+
|
393
|
+
function DocumentMonitor() {
|
394
|
+
var _onreadystatechange,
|
395
|
+
_this = this;
|
396
|
+
this.progress = 0;
|
397
|
+
_onreadystatechange = document.onreadystatechange;
|
398
|
+
document.onreadystatechange = function() {
|
399
|
+
if (_this.states[document.readyState] != null) {
|
400
|
+
_this.progress = _this.states[document.readyState];
|
401
|
+
}
|
402
|
+
return typeof _onreadystatechange === "function" ? _onreadystatechange.apply(null, arguments) : void 0;
|
403
|
+
};
|
404
|
+
}
|
405
|
+
|
406
|
+
return DocumentMonitor;
|
407
|
+
|
408
|
+
})();
|
409
|
+
|
410
|
+
EventLagMonitor = (function() {
|
411
|
+
function EventLagMonitor() {
|
412
|
+
var avg, last, points,
|
413
|
+
_this = this;
|
414
|
+
this.progress = 0;
|
415
|
+
avg = 0;
|
416
|
+
points = 0;
|
417
|
+
last = now();
|
418
|
+
setInterval(function() {
|
419
|
+
var diff;
|
420
|
+
diff = now() - last - 50;
|
421
|
+
last = now();
|
422
|
+
avg = avg + (diff - avg) / 15;
|
423
|
+
if (points++ > 20 && Math.abs(avg) < 3) {
|
424
|
+
avg = 0;
|
425
|
+
}
|
426
|
+
return _this.progress = 100 * (3 / (avg + 3));
|
427
|
+
}, 50);
|
428
|
+
}
|
429
|
+
|
430
|
+
return EventLagMonitor;
|
431
|
+
|
432
|
+
})();
|
433
|
+
|
434
|
+
Scaler = (function() {
|
435
|
+
function Scaler(source) {
|
436
|
+
this.source = source;
|
437
|
+
this.last = this.sinceLastUpdate = 0;
|
438
|
+
this.rate = options.initialRate;
|
439
|
+
this.catchup = 0;
|
440
|
+
this.progress = this.lastProgress = 0;
|
441
|
+
if (this.source != null) {
|
442
|
+
this.progress = result(this.source, 'progress');
|
443
|
+
}
|
444
|
+
}
|
445
|
+
|
446
|
+
Scaler.prototype.tick = function(frameTime, val) {
|
447
|
+
var scaling;
|
448
|
+
if (val == null) {
|
449
|
+
val = result(this.source, 'progress');
|
450
|
+
}
|
451
|
+
if (val >= 100) {
|
452
|
+
this.done = true;
|
453
|
+
}
|
454
|
+
if (val === this.last) {
|
455
|
+
this.sinceLastUpdate += frameTime;
|
456
|
+
} else {
|
457
|
+
if (this.sinceLastUpdate) {
|
458
|
+
this.rate = (val - this.last) / this.sinceLastUpdate;
|
459
|
+
}
|
460
|
+
this.catchup = (val - this.progress) / options.catchupTime;
|
461
|
+
this.sinceLastUpdate = 0;
|
462
|
+
this.last = val;
|
463
|
+
}
|
464
|
+
if (val > this.progress) {
|
465
|
+
this.progress += this.catchup * frameTime;
|
466
|
+
}
|
467
|
+
scaling = 1 - Math.pow(this.progress / 100, options.easeFactor);
|
468
|
+
this.progress += scaling * this.rate * frameTime;
|
469
|
+
this.progress = Math.min(this.lastProgress + options.maxProgressPerFrame, this.progress);
|
470
|
+
this.progress = Math.max(0, this.progress);
|
471
|
+
this.progress = Math.min(100, this.progress);
|
472
|
+
this.lastProgress = this.progress;
|
473
|
+
return this.progress;
|
474
|
+
};
|
475
|
+
|
476
|
+
return Scaler;
|
477
|
+
|
478
|
+
})();
|
479
|
+
|
480
|
+
sources = null;
|
481
|
+
|
482
|
+
scalers = null;
|
483
|
+
|
484
|
+
bar = null;
|
485
|
+
|
486
|
+
uniScaler = null;
|
487
|
+
|
488
|
+
animation = null;
|
489
|
+
|
490
|
+
cancelAnimation = null;
|
491
|
+
|
492
|
+
handlePushState = function() {
|
493
|
+
if (options.restartOnPushState) {
|
494
|
+
return Pace.restart();
|
495
|
+
}
|
496
|
+
};
|
497
|
+
|
498
|
+
if (window.history.pushState != null) {
|
499
|
+
_pushState = window.history.pushState;
|
500
|
+
window.history.pushState = function() {
|
501
|
+
handlePushState();
|
502
|
+
return _pushState.apply(window.history, arguments);
|
503
|
+
};
|
504
|
+
}
|
505
|
+
|
506
|
+
if (window.history.replaceState != null) {
|
507
|
+
_replaceState = window.history.replaceState;
|
508
|
+
window.history.replaceState = function() {
|
509
|
+
handlePushState();
|
510
|
+
return _replaceState.apply(window.history, arguments);
|
511
|
+
};
|
512
|
+
}
|
513
|
+
|
514
|
+
SOURCE_KEYS = {
|
515
|
+
ajax: AjaxMonitor,
|
516
|
+
elements: ElementMonitor,
|
517
|
+
document: DocumentMonitor,
|
518
|
+
eventLag: EventLagMonitor
|
519
|
+
};
|
520
|
+
|
521
|
+
(init = function() {
|
522
|
+
var source, type, _i, _j, _len, _len1, _ref, _ref1, _ref2;
|
523
|
+
sources = [];
|
524
|
+
_ref = ['ajax', 'elements', 'document', 'eventLag'];
|
525
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
526
|
+
type = _ref[_i];
|
527
|
+
if (options[type] !== false) {
|
528
|
+
sources.push(new SOURCE_KEYS[type](options[type]));
|
529
|
+
}
|
530
|
+
}
|
531
|
+
_ref2 = (_ref1 = options.extraSources) != null ? _ref1 : [];
|
532
|
+
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
533
|
+
source = _ref2[_j];
|
534
|
+
sources.push(new source(options));
|
535
|
+
}
|
536
|
+
bar = new Bar;
|
537
|
+
scalers = [];
|
538
|
+
return uniScaler = new Scaler;
|
539
|
+
})();
|
540
|
+
|
541
|
+
Pace.stop = function() {
|
542
|
+
bar.destroy();
|
543
|
+
cancelAnimation = true;
|
544
|
+
if (animation != null) {
|
545
|
+
if (typeof cancelAnimationFrame === "function") {
|
546
|
+
cancelAnimationFrame(animation);
|
547
|
+
}
|
548
|
+
animation = null;
|
549
|
+
}
|
550
|
+
return init();
|
551
|
+
};
|
552
|
+
|
553
|
+
Pace.restart = function() {
|
554
|
+
Pace.stop();
|
555
|
+
return Pace.go();
|
556
|
+
};
|
557
|
+
|
558
|
+
Pace.go = function() {
|
559
|
+
bar.render();
|
560
|
+
cancelAnimation = false;
|
561
|
+
return animation = runAnimation(function(frameTime, enqueueNextFrame) {
|
562
|
+
var avg, count, done, element, elements, i, j, remaining, scaler, scalerList, source, start, sum, _i, _j, _len, _len1, _ref;
|
563
|
+
remaining = 100 - bar.progress;
|
564
|
+
count = sum = 0;
|
565
|
+
done = true;
|
566
|
+
for (i = _i = 0, _len = sources.length; _i < _len; i = ++_i) {
|
567
|
+
source = sources[i];
|
568
|
+
scalerList = scalers[i] != null ? scalers[i] : scalers[i] = [];
|
569
|
+
elements = (_ref = source.elements) != null ? _ref : [source];
|
570
|
+
for (j = _j = 0, _len1 = elements.length; _j < _len1; j = ++_j) {
|
571
|
+
element = elements[j];
|
572
|
+
scaler = scalerList[j] != null ? scalerList[j] : scalerList[j] = new Scaler(element);
|
573
|
+
done &= scaler.done;
|
574
|
+
if (scaler.done) {
|
575
|
+
continue;
|
576
|
+
}
|
577
|
+
count++;
|
578
|
+
sum += scaler.tick(frameTime);
|
579
|
+
}
|
580
|
+
}
|
581
|
+
avg = sum / count;
|
582
|
+
bar.update(uniScaler.tick(frameTime, avg));
|
583
|
+
start = now();
|
584
|
+
if (bar.done() || done || cancelAnimation) {
|
585
|
+
bar.update(100);
|
586
|
+
return setTimeout(function() {
|
587
|
+
return bar.finish();
|
588
|
+
}, Math.max(options.ghostTime, Math.min(options.minTime, now() - start)));
|
589
|
+
} else {
|
590
|
+
return enqueueNextFrame();
|
591
|
+
}
|
592
|
+
});
|
593
|
+
};
|
594
|
+
|
595
|
+
Pace.start = function(_options) {
|
596
|
+
extend(options, _options);
|
597
|
+
bar.render();
|
598
|
+
if (!document.querySelector('.pace')) {
|
599
|
+
return setTimeout(Pace.start, 50);
|
600
|
+
} else {
|
601
|
+
return Pace.go();
|
602
|
+
}
|
603
|
+
};
|
604
|
+
|
605
|
+
if (typeof define === 'function' && define.amd) {
|
606
|
+
define(function() {
|
607
|
+
return Pace;
|
608
|
+
});
|
609
|
+
} else if (typeof exports === 'object') {
|
610
|
+
module.exports = Pace;
|
611
|
+
} else {
|
612
|
+
Pace.start();
|
613
|
+
}
|
614
|
+
|
615
|
+
}).call(this);
|
data/lib/pace_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pace_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arvind-naidu
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
|
+
- app/assets/javascripts/pace.js
|
81
82
|
- lib/pace_rails.rb
|
82
83
|
- lib/pace_rails/version.rb
|
83
84
|
- pace_rails.gemspec
|