", {
93 | id: "countdown",
94 | css: {
95 | "font-size": "50px"
96 | },
97 | text: count
98 | });
99 | $(".custom-01").click(function(e) {
100 | showHide(e, "#custom-01", {
101 | background: "brown",
102 | custom: customElement
103 | });
104 | });
105 | let interval = setInterval(function() {
106 | count--;
107 | customElement.text(count);
108 | if (count <= 0) {
109 | clearInterval(interval);
110 | $("#custom-01").busyLoad("hide");
111 | }
112 | }, 1000);
113 | // size
114 | $(".size-01").click(function(e) {
115 | showHide(e, "#size-01", {
116 | maxSize: "150px",
117 | minSize: "150px"
118 | });
119 | });
120 | $(".size-02").click(function(e) {
121 | showHide(e, "#size-02", {
122 | maxSize: "200px",
123 | minSize: "200px",
124 | background: "rgba(0, 51, 101, 0.83)",
125 | image: "./tardis.gif",
126 | });
127 | });
128 | // text
129 | $(".text-01").click(function(e) {
130 | showHide(e, "#text-01", {
131 | text: "LOADING ..."
132 | });
133 | });
134 | $(".text-02").click(function(e) {
135 | showHide(e, "#text-02", {
136 | text: "LOADING ...",
137 | spinner: false
138 | });
139 | });
140 | $(".text-03").click(function(e) {
141 | showHide(e, "#text-03", {
142 | text: "LOADING ...",
143 | textPosition: "left"
144 | });
145 | });
146 | $(".text-04").click(function(e) {
147 | showHide(e, "#text-04", {
148 | text: "LOADING ...",
149 | textPosition: "left"
150 | });
151 | });
152 | $(".text-05").click(function(e) {
153 | showHide(e, "#text-05", {
154 | text: "LOADING ...",
155 | textPosition: "top"
156 | });
157 | });
158 | $(".text-06").click(function(e) {
159 | showHide(e, "#text-06", {
160 | text: "LOADING ...",
161 | textPosition: "bottom"
162 | });
163 | });
164 | $(".text-07").click(function(e) {
165 | showHide(e, "#text-07", {
166 | text: "LOADING ...",
167 | textColor: "white",
168 | color: "red",
169 | background: "brown"
170 | });
171 | });
172 | $(".text-08").click(function(e) {
173 | showHide(e, "#text-08", {
174 | text: "LOADING ...",
175 | textMargin: "3rem"
176 | });
177 | });
178 | $(".text-09").click(function(e) {
179 | showHide(e, "#text-09", {
180 | text: "LOADING ...",
181 | fontSize: "2rem"
182 | });
183 | });
184 | // animation
185 | $(".animation-01").click(function(e) {
186 | showHide(e, "#animation-01", {
187 | animation: false
188 | });
189 | });
190 | $(".animation-02").click(function(e) {
191 | showHide(e, "#animation-02", {
192 | animation: "fade"
193 | });
194 | });
195 | $(".animation-03").click(function(e) {
196 | showHide(e, "#animation-03", {
197 | animation: "slide"
198 | });
199 | });
200 | $(".animation-04").click(function(e) {
201 | showHide(e, "#animation-04", {
202 | animation: "fade",
203 | animationDuration: "slow"
204 | });
205 | });
206 | $(".animation-05").click(function(e) {
207 | showHide(e, "#animation-05", {
208 | animation: "fade",
209 | animationDuration: 4000
210 | });
211 | });
212 | // classes
213 | $(".class-01").click(function(e) {
214 | showHide(e, "#class-01", {
215 | containerClass: "my-own-container-class"
216 | });
217 | });
218 | $(".class-02").click(function(e) {
219 | showHide(e, "#class-02", {
220 | containerItemClass: "my-own-container-item-class"
221 | });
222 | });
223 | $(".class-03").click(function(e) {
224 | showHide(e, "#class-03", {
225 | spinnerClass: "my-own-spinner-class"
226 | });
227 | });
228 | $(".class-04").click(function(e) {
229 | showHide(e, "#class-04", {
230 | text: "LOADING ...",
231 | textClass: "my-own-text-class"
232 | });
233 | });
234 |
235 | // static
236 | $(".static-01").click(function(e) {
237 | showHide(e, "#static-01");
238 | });
239 | });
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
busy-load
21 |
22 |
23 |
24 |
25 |
26 |
27 |
29 |
31 |
33 |
34 |
35 |
36 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
50 |
51 |
52 |
53 |
54 |
Documentation
55 |
See the full documentation on github .
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
Setup
64 |
Use $.busyLoadSetup() to preconfigure busy-load, so you don't have to set your default options all the time.
65 |
66 | $.busyLoadSetup({ animation: "slide", background: "rgba(255, 152, 0, 0.86)" });
67 |
68 |
69 |
70 |
71 |
72 |
Fullscreen
73 |
For a fullscreen-overlay use $.busyLoadFull()
$.busyLoadFull("show");
74 |
$.busyLoadFull("hide");
75 |
76 |
Fullscreen
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
Hint: tardis
85 |
In former versions of busy-load a tardis -image was included. Due to the package-size, the image was now outsourced . If you want to include it, just use this url on the image -option or download it form there.
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
Spinners
95 |
CSS
96 |
Choose one of the built in CSS-spinners.
97 |
98 |
99 |
100 |
101 |
102 |
103 |
spinner:
104 |
pump
105 |
Without any options, the default spinner will be pump
$("#el").busyLoad("show");
106 |
show
107 |
108 |
109 |
110 |
111 |
112 |
113 |
spinner:
114 |
accordion $("#el").busyLoad("show", { spinner: "accordion"
115 | });
116 |
show
117 |
118 |
119 |
120 |
121 |
122 |
123 |
spinner:
124 |
pulsar $("#el").busyLoad("show", { spinner: "pulsar"
125 | });
126 |
show
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
spinner:
136 |
cube $("#el").busyLoad("show", { spinner: "cube"
137 | });
138 |
show
139 |
140 |
141 |
142 |
143 |
144 |
145 |
spinner:
146 |
cubes $("#el").busyLoad("show", { spinner: "cubes"
147 | });
148 |
show
149 |
150 |
151 |
152 |
153 |
154 |
155 |
spinner:
156 |
circle-line $("#el").busyLoad("show", { spinner: "circle-line"
157 | });
158 |
show
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
spinner:
168 |
circles $("#el").busyLoad("show", { spinner: "circles"
169 | });
170 |
show
171 |
172 |
173 |
174 |
175 |
176 |
177 |
spinner:
178 |
cube-grid $("#el").busyLoad("show", { spinner: "cube-grid"
179 | });
180 |
show
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
Images
191 |
Use an image as spinner.
192 |
193 |
194 |
195 |
196 |
197 |
198 |
image:
199 |
base64
200 |
$("#el").busyLoad("show", { background: "rgba(76, 175, 80, 0.73)",
201 | image: "data:image/gif;base64,R0lGODlhQAA..."
202 | });
203 |
show
204 |
205 |
206 |
207 |
208 |
209 |
210 |
image:
211 |
full url
212 |
$("#el").busyLoad("show", {
213 | image: "http://cafe-serendipity.com/wp-content/uploads/2018/01/tardis.gif"
214 | });
show
215 |
216 |
217 |
218 |
219 |
220 |
221 |
image:
222 |
relative url
223 |
$("#el").busyLoad("show", {
224 | image: "./tardis.gif"
225 | });
show
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
Fontawesome
236 |
Include the fontawesome-library and use its icons a spinner.
237 |
238 |
239 |
240 |
241 |
242 |
243 |
fontawesome:
244 |
icon class
245 |
add also fa-spin
$("#el").busyLoad("show", {
246 | fontawesome: "fa fa-spinner fa-spin fa-3x fa-fw" });
247 |
show
248 |
249 |
250 |
251 |
252 |
253 |
254 |
fontawesome:
255 |
icon class
256 |
add also fa-spin
$("#el").busyLoad("show", {
257 | fontawesome: "fa fa-cog fa-spin fa-3x fa-fw" });
258 |
show
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
Custom
269 |
Pass in your own jQuery-Element. Here's a quick example:
270 |
271 |
272 |
273 |
274 | let count = 2121;
275 | let customElement = $("<div>", {
276 | id: "countdown",
277 | css: { "font-size" : "50px" }, text: count
278 | });
279 | $("#el").busyLoad("show", {
280 | background: "brown", custom: customElement
281 | });
282 | let interval = setInterval(function(){
283 | count--;
284 | customElement.text(count);
285 | if (count <= 0) {
286 | clearInterval(interval);
287 | $("#el").busyLoad("hide");
288 | }
289 | }, 1000);
290 |
291 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
Sizing
302 |
Use maxSize & minSize for sizing the spinner. This only works with CSS- & image-spinners.
303 |
304 |
305 |
306 |
307 |
308 |
309 |
max/minSize
310 |
size
311 |
Size a spinner
312 |
$("#el").busyLoad("show", {
313 | maxSize: "150px",
314 | minSize: "150px"
315 | });
316 |
show
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
max/minSize
325 |
size
326 |
Size an image
$("#el").busyLoad("show", {
327 | maxSize: "200px",
328 | minSize: "200px",
329 | background: "rgba(0, 51, 101, 0.83)",
330 | image: "./tardis.gif"
331 | });
332 |
show
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
Text Add text, position & style it.
343 |
344 |
345 |
346 |
347 |
348 |
349 |
text:
350 |
LOADING ...
351 |
$("#el").busyLoad("show", { text: "LOADING ..."
352 | });
353 |
show
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
spinner:
362 |
false
363 |
Explicitly hide the spinner.
$("#el").busyLoad("show", { text: "LOADING ...",
364 | spinner: false
365 | });
366 |
show
367 |
368 |
369 |
370 |
371 |
372 |
373 |
textColor:
374 |
color $("#el").busyLoad("show", {
375 | text: "LOADING ...",
376 | textColor: "white",
377 | color: "red",
378 | background: "brown"
379 | });
380 |
show
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
textPosition:
390 |
top $("#el").busyLoad("show", { text: "LOADING ...",
391 | textPosition: "top"
392 | });
393 |
show
394 |
395 |
396 |
397 |
398 |
399 |
400 |
textPosition:
401 |
bottom $("#el").busyLoad("show", { text: "LOADING ...",
402 | textPosition: "bottom"
403 | });
404 |
show
405 |
406 |
407 |
408 |
409 |
410 |
411 |
textPosition:
412 |
left $("#el").busyLoad("show", { text: "LOADING ...",
413 | textPosition: "left"
414 | });
415 |
show
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
textMargin:
426 |
size $("#el").busyLoad("show", {
427 | text: "LOADING ...",
428 | textMargin: "3rem"
429 | });
430 |
show
431 |
432 |
433 |
434 |
435 |
436 |
437 |
fontSize:
438 |
size $("#el").busyLoad("show", {
439 | text: "LOADING ...",
440 | fontSize: "2rem"
441 | });
442 |
show
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
Animation
453 |
454 |
455 |
456 |
457 |
458 |
459 |
animation:
460 |
false $("#el").busyLoad("show", {
461 | animation: false
462 | });
463 |
show
464 |
465 |
466 |
467 |
468 |
469 |
470 |
animation:
471 |
fade $("#el").busyLoad("show", {
472 | animation: "fade"
473 | });
474 |
show
475 |
476 |
477 |
478 |
479 |
480 |
481 |
animation:
482 |
slide $("#el").busyLoad("show", {
483 | animation: "slide"
484 | });
485 |
show
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
animationDuration:
496 |
slow/fast $("#el").busyLoad("show", {
497 | animation: "fade",
498 | animationDuration: "slow"
499 | });
500 |
show
501 |
502 |
503 |
504 |
505 |
506 |
507 |
animationDuration:
508 |
time $("#el").busyLoad("show", {
509 | animation: "fade",
510 | animationDuration: 4000
511 | });
512 |
show
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
Classes
523 |
Add your own-classes to the components of the overlay.
524 |
525 |
526 |
527 |
528 |
529 |
530 |
containerClass:
531 |
class $("#el").busyLoad("show", {
532 | containerClass: "my-own-container-class"
533 | });
534 |
show
535 |
536 |
537 |
538 |
539 |
540 |
541 |
containerItemClass:
542 |
class $("#el").busyLoad("show", {
543 | containerItemClass: "my-own-container-item-class"
544 | });
545 |
show
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
spinnerClass:
556 |
class $("#el").busyLoad("show", {
557 | spinnerClass: "my-own-spinner-class"
558 | });
559 |
show
560 |
561 |
562 |
563 |
564 |
565 |
566 |
textClass:
567 |
class $("#el").busyLoad("show", {
568 | textClass: "my-own-text-class"
569 | });
570 |
show
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
CSS-position
582 |
583 |
584 |
585 |
586 |
587 |
588 | If the calling element has a position of static , busy-load will turn it into relative , because otherwise the overlay would be positioned to a parent element other than static .
589 |
590 |
591 |
592 |
593 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
594 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
595 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
596 | consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
597 | cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
598 | proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
599 |
600 |
show
601 |
602 |
603 |
604 |
605 |
608 |
609 |
--------------------------------------------------------------------------------
/docs/tardis.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/piccard21/busy-load/33bde6d2740008490e971a538ac6d17d5aa74b6d/docs/tardis.gif
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "busy-load",
3 | "version": "0.1.2",
4 | "description": "A flexible jQuery loading-mask",
5 | "main": "src/index.js",
6 | "scripts": {
7 | "test": "mocha-chrome test/testrunner.html",
8 | "dev": "npm run development",
9 | "development": "cross-env NODE_ENV=DEVELOPMENT webpack --progress --hide-modules",
10 | "watch": "cross-env NODE_ENV=DEVELOPMENT webpack --progress --hide-modules --watch",
11 | "prod": "npm run production",
12 | "production": "npm run development & cross-env NODE_ENV=PRODUCTION webpack --progress --hide-modules",
13 | "start": "cross-env NODE_ENV=DEVELOPMENT-SERVER webpack-dev-server --open",
14 | "prepublish": "npm test"
15 | },
16 | "homepage": "https://github.com/piccard21/busy-load",
17 | "keywords": [
18 | "jQuery-plugin",
19 | "loading-mask",
20 | "overlay",
21 | "mask",
22 | "loader"
23 | ],
24 | "repository": {
25 | "type": "git",
26 | "url": "https://github.com/piccard21/busy-load"
27 | },
28 | "author": "Andreas Stephan
(info@cafe-serendipity.com)",
29 | "license": "MIT",
30 | "devDependencies": {
31 | "babel-core": "^6.26.0",
32 | "babel-loader": "^7.1.2",
33 | "babel-polyfill": "^6.26.0",
34 | "babel-preset-env": "^1.6.1",
35 | "chai": "^4.1.2",
36 | "chai-jquery": "^2.0.0",
37 | "clean-webpack-plugin": "^0.1.17",
38 | "cross-env": "^5.1.1",
39 | "css-loader": "^0.28.7",
40 | "extract-text-webpack-plugin": "^3.0.2",
41 | "html-webpack-plugin": "^2.30.1",
42 | "jquery": "^3.2.1",
43 | "lodash": "^4.17.4",
44 | "mocha": "^4.0.1",
45 | "mocha-chrome": "^2.0.0",
46 | "node-sass": "^4.5.3",
47 | "postcss": "^6.0.14",
48 | "postcss-cssnext": "^3.0.2",
49 | "postcss-import": "^11.0.0",
50 | "postcss-loader": "^2.0.8",
51 | "sass-loader": "^6.0.6",
52 | "sinon": "^4.1.2",
53 | "sinon-chai": "^2.14.0",
54 | "webpack": "^3.8.1",
55 | "webpack-cli": "^3.2.3",
56 | "webpack-dev-server": "^3.0.0"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | 'postcss-import': {},
4 | 'postcss-cssnext': {
5 | browsers: ['last 2 versions', '> 5%'],
6 | },
7 | },
8 | };
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import './sass/sass.scss';
2 | import {
3 | busyLoad,
4 | busyLoadSetup,
5 | busyLoadFull
6 | } from './lib/busy-load.js'
7 | import defaults from './lib/defaults.js';
8 |
9 | let jQuery = require('jquery');
10 |
11 | (function($) {
12 | $.fn.busyLoad = busyLoad;
13 | $.busyLoadSetup = busyLoadSetup;
14 | $.busyLoadFull = busyLoadFull;
15 | $.fn.busyLoad.defaults = defaults;
16 | })(jQuery);
--------------------------------------------------------------------------------
/src/lib/busy-load.js:
--------------------------------------------------------------------------------
1 | import {BusyLoad} from './class.BusyLoad.js';
2 | import defaults from './defaults.js';
3 |
4 |
5 | export function busyLoadSetup(settings) {
6 | $.extend(true, defaults, settings);
7 | }
8 |
9 |
10 | export function busyLoad(action, options) {
11 |
12 | return this.each(function () {
13 | let bl = new BusyLoad($(this), JSON.parse(JSON.stringify(defaults)), options);
14 |
15 | switch (action) {
16 | case "show":
17 | bl.show();
18 | break;
19 | case "hide":
20 | bl.hide();
21 | break;
22 | default:
23 | throw `don't know action '${action}'`
24 | }
25 | });
26 | }
27 |
28 |
29 | export function busyLoadFull(action, options) {
30 |
31 | let $body = $('body');
32 | let bl = new BusyLoad($body, JSON.parse(JSON.stringify(defaults)), options);
33 |
34 |
35 | switch (action.toLowerCase()) {
36 | case "show":
37 | $body.addClass("no-scroll");
38 | bl.caller = $body;
39 | bl.extendSettings({
40 | fullScreen: true
41 | });
42 | bl.show();
43 |
44 | break;
45 |
46 | case "hide":
47 | bl.hide();
48 | $body.removeClass("no-scroll");
49 | break;
50 | }
51 |
52 | return $body;
53 |
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/lib/class.BusyLoad.js:
--------------------------------------------------------------------------------
1 | import {Container} from './components/class.Container.js';
2 | import {ContainerItem} from './components/class.ContainerItem.js';
3 | import {Text} from './components/class.Text.js';
4 | import {Spinner} from './components/class.Spinner.js';
5 | const get = require("lodash/get");
6 |
7 | export class BusyLoad {
8 | constructor(caller, defaults, options) {
9 |
10 | this._settings = defaults;
11 | this._caller= caller;
12 |
13 | this.extendSettings(options);
14 | // this.debugSettings();
15 | }
16 |
17 | get settings() {
18 | return this._settings;
19 | }
20 |
21 | set settings(newOptions) {
22 | this._settings = newOptions;
23 | }
24 |
25 | get caller() {
26 | return this._caller;
27 | }
28 |
29 | set caller(newOptions) {
30 | this._caller = newOptions;
31 | }
32 |
33 | debugSettings() {
34 | console.log(this._settings.fullScreen);
35 | }
36 |
37 | extendSettings(options) {
38 | $.extend(this._settings, options);
39 | }
40 |
41 |
42 | animateShow($tag) {
43 | let callback = () => $tag.trigger("bl.shown", [$tag, $(this.caller)]);
44 |
45 | this.caller.append($tag); // already hidden
46 | $tag.trigger("bl.show", [$tag, $(this.caller)]);
47 |
48 | if (get(this.settings, "animation", false)) {
49 |
50 | switch (get(this.settings, "animation").toLowerCase()) {
51 | case "fade":
52 | $tag = $tag.fadeIn(get(this.settings, "animationDuration", "fast"), callback);
53 | break;
54 | case "slide":
55 | $tag = $tag.slideDown(get(this.settings, "animationDuration", "fast"), callback);
56 | break;
57 | default:
58 | throw "don't know animation: " + get(this.settings, "animation");
59 | }
60 | } else {
61 | $tag.show(0, callback);
62 | }
63 |
64 | return $tag;
65 | }
66 |
67 | animateHide($tag) {
68 | let callback = () => {
69 | $tag.trigger("bl.hidden", [$tag, $(this.caller)]);
70 | $tag.remove();
71 | }
72 |
73 | $tag.trigger("bl.hide", [$tag, $(this.caller)]);
74 |
75 | if (get(this.settings, "animation", false)) {
76 | switch (get(this.settings, "animation").toLowerCase()) {
77 | case "fade":
78 | $tag = $tag.fadeOut(get(this.settings, "animationDuration", "fast"), callback);
79 | break;
80 | case "slide":
81 | $tag = $tag.slideUp(get(this.settings, "animationDuration", "fast"), callback);
82 | break;
83 | default:
84 | throw "don't know animation: " + get(this.settings, "animation");
85 | }
86 | } else {
87 | $tag.hide(0, callback);
88 | }
89 | }
90 |
91 |
92 | getOverlay() {
93 | // already existent?
94 | if(this._caller.data("busy-load-container")) {
95 | return $("#"+this._caller.data("busy-load-container"));
96 | }
97 | // no ... create one
98 | else {
99 | // container & elements
100 | this._container = new Container(this._settings);
101 | this._containerItem = new ContainerItem(this._settings);
102 |
103 |
104 | // append text
105 | if (get(this.settings, "text", false)) {
106 | this._loadingText= new Text(this._settings);
107 | this._containerItem.tag.append(this._loadingText.tag);
108 | }
109 | // append spinner
110 | if (get(this.settings, "spinner", "pump") !== false) {
111 | this._spinner= new Spinner(this._settings);
112 | this._containerItem.tag.append(this._spinner.tag);
113 | }
114 |
115 | // container
116 | this._container.tag.append(this._containerItem.tag).hide();
117 | }
118 |
119 | return this._container.tag;
120 | }
121 |
122 | createRandomString() {
123 | return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
124 | }
125 |
126 | toggle($tag, action) {
127 | // show
128 | if(action == 'show') {
129 | const randomString = this.createRandomString();
130 |
131 | // position static?
132 | if(this.caller.css('position') === 'static') {
133 | this.caller.css('position', 'relative')
134 | }
135 |
136 | this._caller.addClass('busy-load-active');
137 | $tag.attr('id', randomString);
138 | $tag = this.animateShow($tag);
139 |
140 | this._caller.data("busy-load-container", randomString);
141 | }
142 | // hide
143 | else {
144 | this.animateHide($tag);
145 | this._caller.removeData("busy-load-container");
146 | this._caller.removeClass('busy-load-active');
147 | }
148 | }
149 |
150 | show() {
151 | this.toggle( this.getOverlay(), "show")
152 | }
153 |
154 | hide() {
155 | const containerId = this._caller.data('busy-load-container');
156 | this.toggle( $("#"+containerId), "hide" );
157 | }
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/src/lib/components/class.Component.js:
--------------------------------------------------------------------------------
1 | export class Component {
2 | constructor(tag, options, busyLoadOptions) {
3 | this._options = options;
4 | this._busyLoadOptions = busyLoadOptions;
5 |
6 | this.setTag(tag);
7 | // this.debugOptions();
8 | }
9 |
10 | /**
11 | * OPTIONS
12 | */
13 |
14 | get options() {
15 | return this._options;
16 | }
17 |
18 | set options(newOptions) {
19 | this._options = newOptions;
20 | }
21 |
22 | debugOptions() {
23 | console.log(this._options);
24 | }
25 |
26 | extendOptions(options) {
27 | $.extend(this._options, options);
28 | }
29 |
30 |
31 | /**
32 | * TAG
33 | */
34 |
35 | get tag() {
36 | return this._$tag;
37 | }
38 |
39 | set tag($tag) {
40 | this._$tag = $tag;
41 | }
42 |
43 | setTag(tag) {
44 | if (tag instanceof jQuery) {
45 | this._$tag = tag;
46 | } else if (typeof tag === 'string' || tag instanceof String) {
47 | this._$tag = $("<" + tag + "/>", this._options);
48 | } else {
49 | throw "wrong type for creating a tag";
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/lib/components/class.Container.js:
--------------------------------------------------------------------------------
1 | import { Component } from './class.Component.js';
2 | const get = require("lodash/get");
3 |
4 | export class Container extends Component {
5 | constructor(busyLoadOptions) {
6 | super('div', {
7 | "class": get(busyLoadOptions, "containerClass"),
8 | "css": {
9 | "position": get(busyLoadOptions, "fullScreen", false) ? "fixed" : "absolute",
10 | "top": 0,
11 | "left": 0,
12 | "background": get(busyLoadOptions, "background", "#fff"),
13 | "color": get(busyLoadOptions, "color", "#0000001a"),
14 | "display": "flex",
15 | "align-items": "center",
16 | "justify-content": "center",
17 | "width": "100%",
18 | "height": "100%",
19 | "z-index": 9999
20 | }
21 | }, busyLoadOptions);
22 | }
23 | }
--------------------------------------------------------------------------------
/src/lib/components/class.ContainerItem.js:
--------------------------------------------------------------------------------
1 | import {Component} from './class.Component.js';
2 | const get = require("lodash/get");
3 |
4 | export class ContainerItem extends Component {
5 | constructor(busyLoadOptions) {
6 |
7 | let flexDirection = get(busyLoadOptions, "textPosition", "right");
8 |
9 | switch (flexDirection) {
10 | case "top":
11 | flexDirection = "column";
12 | break;
13 | case "bottom":
14 | flexDirection = "column-reverse";
15 | break;
16 | case "right":
17 | flexDirection = "row-reverse";
18 | break;
19 | case "left":
20 | flexDirection = "row";
21 | break;
22 | default:
23 | throw `don't know textPosition: ${flexDirection}`
24 | }
25 |
26 | super('div', {
27 | "class": get(busyLoadOptions, "containerItemClass"),
28 | "css": {
29 | "background": "none",
30 | "display": "flex",
31 | "justify-content": "center",
32 | "align-items": "center",
33 | "flex-direction": flexDirection
34 | }
35 | }, busyLoadOptions);
36 | }
37 | }
--------------------------------------------------------------------------------
/src/lib/components/class.Spinner.js:
--------------------------------------------------------------------------------
1 | import { Component } from './class.Component.js';
2 | import { SpinnerLib } from './class.SpinnerLib.js';
3 | const get = require("lodash/get");
4 |
5 | export class Spinner extends Component {
6 | constructor(busyLoadOptions) {
7 | super("span", {}, busyLoadOptions);
8 |
9 | if (get(this._busyLoadOptions, 'fontawesome')) {
10 | this.createFontAwesomeTag();
11 | }
12 | else if (get(this._busyLoadOptions, 'custom')) {
13 | this.createCustomTag();
14 | }
15 | else if (get(this._busyLoadOptions, 'image')) {
16 | this.createImageTag();
17 | }
18 | else if (get(this._busyLoadOptions, 'spinner')) {
19 | this.createCssTag(get(this._busyLoadOptions, 'spinner'));
20 | }
21 | else {
22 | this.createCssTag("pump");
23 | }
24 |
25 | this.tag.addClass(get(this._busyLoadOptions, "spinnerClass"));
26 | }
27 |
28 |
29 | createCssTag(spinnerType) {
30 | let spinnerLib = new SpinnerLib(spinnerType, this._busyLoadOptions);
31 | this.setTag(spinnerLib.spinner);
32 | this.tag.addClass("busy-load-spinner-css");
33 | this.setMaxMinSize();
34 | }
35 |
36 | createImageTag() {
37 | this.options = {
38 | "class": "loader-image",
39 | "src": this._busyLoadOptions.image
40 | };
41 |
42 | this.setTag('img');
43 | this.setMaxMinSize();
44 | this.tag.addClass("busy-load-spinner-image");
45 | }
46 |
47 | createFontAwesomeTag() {
48 | this.options = {
49 | "class": get(this._busyLoadOptions, 'fontawesome', "fa fa-refresh fa-spin fa-2x fa-fw"),
50 | "css": {
51 | "color": get(this._busyLoadOptions, 'color', "#fff")
52 | }
53 | };
54 |
55 | this.setTag('span');
56 | this.tag.addClass("busy-load-spinner-fontawesome");
57 |
58 | this._$tag.append($(" ", {
59 | "class": "sr-only",
60 | "text": "Loading ..."
61 | }));
62 | }
63 |
64 | createCustomTag() {
65 | let custom = get(this._busyLoadOptions, 'custom');
66 | let isJqueryObject = custom instanceof jQuery
67 |
68 | if (!isJqueryObject) {
69 | throw "wrong type for creating a tag";
70 | }
71 |
72 | this.setTag(custom);
73 | this.tag.addClass("busy-load-spinner-custom");
74 | }
75 |
76 | setMaxMinSize() {
77 | this.tag.css({
78 | "max-height": get(this._busyLoadOptions, 'maxSize'),
79 | "max-width": get(this._busyLoadOptions, 'maxSize'),
80 | "min-height": get(this._busyLoadOptions, 'minSize'),
81 | "min-width": get(this._busyLoadOptions, 'minSize')
82 | });
83 | }
84 |
85 |
86 | // https://projects.lukehaas.me/css-loaders/
87 | }
--------------------------------------------------------------------------------
/src/lib/components/class.SpinnerLib.js:
--------------------------------------------------------------------------------
1 | const get = require("lodash/get");
2 |
3 | export class SpinnerLib {
4 | constructor(spinner, busyLoadOptions={}) {
5 | this._busyLoadOptions = busyLoadOptions;
6 |
7 | switch (spinner.toLowerCase()) {
8 | case "pump":
9 | this.createPump();
10 | break;
11 | case "pulsar":
12 | this.createPulsar();
13 | break;
14 | case "accordion":
15 | this.createAccordion();
16 | break;
17 | case "cube":
18 | this.createCube();
19 | break;
20 | case "cubes":
21 | this.createCubes();
22 | break;
23 | case "circles":
24 | this.createCircles();
25 | break;
26 | case "circle-line":
27 | this.createCircleLine();
28 | break;
29 | case "cube-grid":
30 | this.createCubeGrid();
31 | break;
32 | default:
33 | throw `don't know spinner: ${spinner}`
34 | }
35 | }
36 | get spinner() {
37 | return this._spinner;
38 | }
39 | set spinner(spinner) {
40 | this._spinner = spinner;
41 | }
42 | createCubeGrid() {
43 | this._spinner = $(`
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
`);
54 | this._spinner.find(".sk-cube").css({
55 | "background-color": get(this._busyLoadOptions, "color","#333")
56 | });
57 | }
58 | createCircleLine() {
59 | this._spinner = $(``);
64 | this._spinner.find(".bounce1, .bounce2, .bounce3").css({
65 | "background-color": get(this._busyLoadOptions, "color","#333")
66 | });
67 | }
68 | createCircles() {
69 | this._spinner = $(``);
73 | this._spinner.css({
74 | "margin-right": "0.4rem"
75 | }).find(".dot1, .dot2").css({
76 | "background-color": get(this._busyLoadOptions, "color","#333")
77 | });
78 | }
79 | createPump() {
80 | this._spinner = $(``);
84 |
85 | this._spinner.find(".double-bounce1, .double-bounce2").css({
86 | "background-color": get(this._busyLoadOptions, "color","#333"),
87 | "margin-right": "0.9rem"
88 | });
89 | }
90 | createPulsar() {
91 | this._spinner = $(`
`);
92 | this._spinner.css({
93 | "background-color": get(this._busyLoadOptions, "color","#333")
94 | });
95 | }
96 | createAccordion() {
97 | this._spinner = $(`
98 |
99 |
100 |
101 |
102 |
103 |
`);
104 | this._spinner.find("div").css({
105 | "background-color": get(this._busyLoadOptions, "color","#333")
106 | });
107 | }
108 | createCube() {
109 | this._spinner = $(`
`);
110 | this._spinner.css({
111 | "background-color": get(this._busyLoadOptions, "color","#333")
112 | });
113 | }
114 | createCubes() {
115 | this._spinner = $(``);
119 |
120 | this._spinner.css({
121 | "margin-right": "0.9rem"
122 | }).find(".cube1, .cube2").css({
123 | "background-color": get(this._busyLoadOptions, "color","#333")
124 | });
125 |
126 | }
127 | }
--------------------------------------------------------------------------------
/src/lib/components/class.Text.js:
--------------------------------------------------------------------------------
1 | import {
2 | Component
3 | } from './class.Component.js';
4 | const get = require("lodash/get");
5 |
6 | export class Text extends Component {
7 | constructor(busyLoadOptions) {
8 | super('span', {
9 | "class": get(busyLoadOptions, "textClass"),
10 | "css": {
11 | "color": get(busyLoadOptions, 'textColor', get(busyLoadOptions, 'color', "#fff")),
12 | "font-size": get(busyLoadOptions, 'fontSize', "1rem"),
13 | },
14 | "text": get(busyLoadOptions, "text", "Loading ...")
15 | }, busyLoadOptions);
16 |
17 |
18 | // set margin
19 | let flexDirection = get(busyLoadOptions, "textPosition", "right");
20 | let marginDirection = "margin-left";
21 |
22 | switch (flexDirection) {
23 | case "top":
24 | marginDirection = "margin-bottom";
25 | break;
26 | case "bottom":
27 | marginDirection = "margin-top";
28 | break;
29 | case "left":
30 | marginDirection = "margin-right";
31 | break;
32 | }
33 |
34 | this.tag.css(marginDirection, get(busyLoadOptions, 'textMargin', ".5rem"));
35 | }
36 | }
--------------------------------------------------------------------------------
/src/lib/defaults.js:
--------------------------------------------------------------------------------
1 | export default {
2 | spinner: "pump", // pump, accordion, pulsar, cube, cubes, circle-line, circles, cube-grid
3 | image: false,
4 | fontawesome: false, // "fa fa-refresh fa-spin fa-2x fa-fw"
5 | custom: false, // jQuery Object
6 | color: "#fff",
7 | background: "rgba(0, 0, 0, 0.21)",
8 | maxSize: "50px", // Integer/String only for spinners & images, not fontawesome & custom
9 | minSize: "20px", // Integer/String only for spinners & images, not fontawesome & custom
10 | text: false,
11 | textColor: false, // default is color
12 | textMargin: ".5rem",
13 | textPosition: "right", // left, right, top, bottom
14 | fontSize: "1rem",
15 | fullScreen: false,
16 | animation: false, // fade, slide
17 | animationDuration: "fast", // String, Integer
18 | containerClass: "busy-load-container",
19 | containerItemClass: "busy-load-container-item",
20 | spinnerClass: "busy-load-spinner",
21 | textClass: "busy-load-text",
22 | };
--------------------------------------------------------------------------------
/src/sass/_accordion.scss:
--------------------------------------------------------------------------------
1 | /* Accordion */
2 |
3 | .spinner-accordion {
4 | margin: 100px auto;
5 | width: 50px;
6 | height: 40px;
7 | text-align: center;
8 | font-size: 10px;
9 | }
10 |
11 | .spinner-accordion>div {
12 | background-color: #333;
13 | height: 100%;
14 | width: 6px;
15 | display: inline-block;
16 | -webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
17 | animation: sk-stretchdelay 1.2s infinite ease-in-out;
18 | }
19 |
20 | .spinner-accordion.rect2 {
21 | -webkit-animation-delay: -1.1s;
22 | animation-delay: -1.1s;
23 | }
24 |
25 | .spinner-accordion .rect3 {
26 | -webkit-animation-delay: -1.0s;
27 | animation-delay: -1.0s;
28 | }
29 |
30 | .spinner-accordion .rect4 {
31 | -webkit-animation-delay: -0.9s;
32 | animation-delay: -0.9s;
33 | }
34 |
35 | .spinner-accordion.rect5 {
36 | -webkit-animation-delay: -0.8s;
37 | animation-delay: -0.8s;
38 | }
39 |
40 | @-webkit-keyframes sk-stretchdelay {
41 | 0%, 40%, 100% {
42 | -webkit-transform: scaleY(0.4)
43 | }
44 | 20% {
45 | -webkit-transform: scaleY(1.0)
46 | }
47 | }
48 |
49 | @keyframes sk-stretchdelay {
50 | 0%, 40%, 100% {
51 | transform: scaleY(0.4);
52 | -webkit-transform: scaleY(0.4);
53 | }
54 | 20% {
55 | transform: scaleY(1.0);
56 | -webkit-transform: scaleY(1.0);
57 | }
58 | }
--------------------------------------------------------------------------------
/src/sass/_circle-line.scss:
--------------------------------------------------------------------------------
1 | .spinner-circle-line {
2 | margin: 10px auto 0;
3 | width: 70px;
4 | text-align: center;
5 | }
6 |
7 | .spinner-circle-line > div {
8 | width: 18px;
9 | height: 18px;
10 | background-color: #333;
11 |
12 | border-radius: 100%;
13 | display: inline-block;
14 | -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
15 | animation: sk-bouncedelay 1.4s infinite ease-in-out both;
16 | }
17 |
18 | .spinner-circle-line .bounce1 {
19 | -webkit-animation-delay: -0.32s;
20 | animation-delay: -0.32s;
21 | }
22 |
23 | .spinner-circle-line .bounce2 {
24 | -webkit-animation-delay: -0.16s;
25 | animation-delay: -0.16s;
26 | }
27 |
28 | @-webkit-keyframes sk-bouncedelay {
29 | 0%, 80%, 100% { -webkit-transform: scale(0) }
30 | 40% { -webkit-transform: scale(1.0) }
31 | }
32 |
33 | @keyframes sk-bouncedelay {
34 | 0%, 80%, 100% {
35 | -webkit-transform: scale(0);
36 | transform: scale(0);
37 | } 40% {
38 | -webkit-transform: scale(1.0);
39 | transform: scale(1.0);
40 | }
41 | }
--------------------------------------------------------------------------------
/src/sass/_circles.scss:
--------------------------------------------------------------------------------
1 | .spinner-circles {
2 | width: 40px;
3 | height: 40px;
4 | position: relative;
5 | text-align: center;
6 |
7 | -webkit-animation: sk-rotate 2.0s infinite linear;
8 | animation: sk-rotate 2.0s infinite linear;
9 | }
10 |
11 | .dot1, .dot2 {
12 | width: 60%;
13 | height: 60%;
14 | display: inline-block;
15 | position: absolute;
16 | top: 0;
17 | background-color: #333;
18 | border-radius: 100%;
19 |
20 | -webkit-animation: sk-bounce 2.0s infinite ease-in-out;
21 | animation: sk-bounce 2.0s infinite ease-in-out;
22 | }
23 |
24 | .dot2 {
25 | top: auto;
26 | bottom: 0;
27 | -webkit-animation-delay: -1.0s;
28 | animation-delay: -1.0s;
29 | }
30 |
31 | @-webkit-keyframes sk-rotate { 100% { -webkit-transform: rotate(360deg) }}
32 | @keyframes sk-rotate { 100% { transform: rotate(360deg); -webkit-transform: rotate(360deg) }}
33 |
34 | @-webkit-keyframes sk-bounce {
35 | 0%, 100% { -webkit-transform: scale(0.0) }
36 | 50% { -webkit-transform: scale(1.0) }
37 | }
38 |
39 | @keyframes sk-bounce {
40 | 0%, 100% {
41 | transform: scale(0.0);
42 | -webkit-transform: scale(0.0);
43 | } 50% {
44 | transform: scale(1.0);
45 | -webkit-transform: scale(1.0);
46 | }
47 | }
--------------------------------------------------------------------------------
/src/sass/_cube-grid.scss:
--------------------------------------------------------------------------------
1 | .spinner-cube-grid {
2 | width: 40px;
3 | height: 40px;
4 | }
5 |
6 | .spinner-cube-grid .sk-cube {
7 | width: 33%;
8 | height: 33%;
9 | background-color: #333;
10 | float: left;
11 | -webkit-animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out;
12 | animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out;
13 | }
14 | .spinner-cube-grid .sk-cube1 {
15 | -webkit-animation-delay: 0.2s;
16 | animation-delay: 0.2s; }
17 | .spinner-cube-grid .sk-cube2 {
18 | -webkit-animation-delay: 0.3s;
19 | animation-delay: 0.3s; }
20 | .spinner-cube-grid .sk-cube3 {
21 | -webkit-animation-delay: 0.4s;
22 | animation-delay: 0.4s; }
23 | .spinner-cube-grid .sk-cube4 {
24 | -webkit-animation-delay: 0.1s;
25 | animation-delay: 0.1s; }
26 | .spinner-cube-grid .sk-cube5 {
27 | -webkit-animation-delay: 0.2s;
28 | animation-delay: 0.2s; }
29 | .spinner-cube-grid .sk-cube6 {
30 | -webkit-animation-delay: 0.3s;
31 | animation-delay: 0.3s; }
32 | .spinner-cube-grid .sk-cube7 {
33 | -webkit-animation-delay: 0s;
34 | animation-delay: 0s; }
35 | .spinner-cube-grid .sk-cube8 {
36 | -webkit-animation-delay: 0.1s;
37 | animation-delay: 0.1s; }
38 | .spinner-cube-grid .sk-cube9 {
39 | -webkit-animation-delay: 0.2s;
40 | animation-delay: 0.2s; }
41 |
42 | @-webkit-keyframes sk-cubeGridScaleDelay {
43 | 0%, 70%, 100% {
44 | -webkit-transform: scale3D(1, 1, 1);
45 | transform: scale3D(1, 1, 1);
46 | } 35% {
47 | -webkit-transform: scale3D(0, 0, 1);
48 | transform: scale3D(0, 0, 1);
49 | }
50 | }
51 |
52 | @keyframes sk-cubeGridScaleDelay {
53 | 0%, 70%, 100% {
54 | -webkit-transform: scale3D(1, 1, 1);
55 | transform: scale3D(1, 1, 1);
56 | } 35% {
57 | -webkit-transform: scale3D(0, 0, 1);
58 | transform: scale3D(0, 0, 1);
59 | }
60 | }
--------------------------------------------------------------------------------
/src/sass/_cube.scss:
--------------------------------------------------------------------------------
1 | /* Cube */
2 |
3 | .spinner-cube {
4 | width: 40px;
5 | height: 40px;
6 | background-color: #333;
7 | margin: 100px auto;
8 | -webkit-animation: sk-rotateplane 1.2s infinite ease-in-out;
9 | animation: sk-rotateplane 1.2s infinite ease-in-out;
10 | }
11 |
12 | @-webkit-keyframes sk-rotateplane {
13 | 0% {
14 | -webkit-transform: perspective(120px)
15 | }
16 | 50% {
17 | -webkit-transform: perspective(120px) rotateY(180deg)
18 | }
19 | 100% {
20 | -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg)
21 | }
22 | }
23 |
24 | @keyframes sk-rotateplane {
25 | 0% {
26 | transform: perspective(120px) rotateX(0deg) rotateY(0deg);
27 | -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
28 | }
29 | 50% {
30 | transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
31 | -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
32 | }
33 | 100% {
34 | transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
35 | -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
36 | }
37 | }
--------------------------------------------------------------------------------
/src/sass/_cubes.scss:
--------------------------------------------------------------------------------
1 | .spinner-cubes {
2 | width: 40px;
3 | height: 40px;
4 | position: relative;
5 | }
6 |
7 | .cube1, .cube2 {
8 | background-color: #333;
9 | width: 15px;
10 | height: 15px;
11 | position: absolute;
12 | top: 0;
13 | left: 0;
14 |
15 | -webkit-animation: sk-cubemove 1.8s infinite ease-in-out;
16 | animation: sk-cubemove 1.8s infinite ease-in-out;
17 | }
18 |
19 | .cube2 {
20 | -webkit-animation-delay: -0.9s;
21 | animation-delay: -0.9s;
22 | }
23 |
24 | @-webkit-keyframes sk-cubemove {
25 | 25% { -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5) }
26 | 50% { -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg) }
27 | 75% { -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5) }
28 | 100% { -webkit-transform: rotate(-360deg) }
29 | }
30 |
31 | @keyframes sk-cubemove {
32 | 25% {
33 | transform: translateX(42px) rotate(-90deg) scale(0.5);
34 | -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5);
35 | } 50% {
36 | transform: translateX(42px) translateY(42px) rotate(-179deg);
37 | -webkit-transform: translateX(42px) translateY(42px) rotate(-179deg);
38 | } 50.1% {
39 | transform: translateX(42px) translateY(42px) rotate(-180deg);
40 | -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg);
41 | } 75% {
42 | transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
43 | -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
44 | } 100% {
45 | transform: rotate(-360deg);
46 | -webkit-transform: rotate(-360deg);
47 | }
48 | }
--------------------------------------------------------------------------------
/src/sass/_pulsar.scss:
--------------------------------------------------------------------------------
1 | /* Pulsar */
2 |
3 | .spinner-pulsar {
4 | width: 40px;
5 | height: 40px;
6 | background-color: #333;
7 | border-radius: 100%;
8 | -webkit-animation: sk-scaleout 1.0s infinite ease-in-out;
9 | animation: sk-scaleout 1.0s infinite ease-in-out;
10 | }
11 |
12 | @-webkit-keyframes sk-scaleout {
13 | 0% {
14 | -webkit-transform: scale(0)
15 | }
16 | 100% {
17 | -webkit-transform: scale(1.0);
18 | opacity: 0;
19 | }
20 | }
21 |
22 | @keyframes sk-scaleout {
23 | 0% {
24 | -webkit-transform: scale(0);
25 | transform: scale(0);
26 | }
27 | 100% {
28 | -webkit-transform: scale(1.0);
29 | transform: scale(1.0);
30 | opacity: 0;
31 | }
32 | }
--------------------------------------------------------------------------------
/src/sass/_pump.scss:
--------------------------------------------------------------------------------
1 | .spinner-pump {
2 | width: 40px;
3 | height: 40px;
4 | position: relative;
5 | }
6 |
7 | .double-bounce1, .double-bounce2 {
8 | width: 100%;
9 | height: 100%;
10 | border-radius: 50%;
11 | background-color: #333;
12 | opacity: 0.6;
13 | position: absolute;
14 | top: 0;
15 | left: 0;
16 |
17 | -webkit-animation: sk-bounce 2.0s infinite ease-in-out;
18 | animation: sk-bounce 2.0s infinite ease-in-out;
19 | }
20 |
21 | .double-bounce2 {
22 | -webkit-animation-delay: -1.0s;
23 | animation-delay: -1.0s;
24 | }
25 |
26 | @-webkit-keyframes sk-bounce {
27 | 0%, 100% { -webkit-transform: scale(0.0) }
28 | 50% { -webkit-transform: scale(1.0) }
29 | }
30 |
31 | @keyframes sk-bounce {
32 | 0%, 100% {
33 | transform: scale(0.0);
34 | -webkit-transform: scale(0.0);
35 | } 50% {
36 | transform: scale(1.0);
37 | -webkit-transform: scale(1.0);
38 | }
39 | }
--------------------------------------------------------------------------------
/src/sass/_utils.scss:
--------------------------------------------------------------------------------
1 | .no-scroll {
2 | overflow: hidden;
3 | }
--------------------------------------------------------------------------------
/src/sass/sass.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * Spinners
3 | *
4 | * @see http://tobiasahlin.com/spinkit/
5 | */
6 | @import 'cube-grid';
7 | @import 'circle-line';
8 | @import 'circles';
9 | @import 'cube';
10 | @import 'cubes';
11 | @import 'pump';
12 | @import 'pulsar';
13 | @import 'accordion';
14 | @import 'utils';
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/template/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
19 |
21 |
22 |
23 |
264 |
265 |
330 |
331 |
332 |
333 |
338 |
339 |
340 |
341 |
342 |
Documentation
343 |
See the full documentation on github .
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
Setup
352 |
Use $.busyLoadSetup() to preconfigure busy-load, so you don't have to set your default options all the time.
$.busyLoadSetup({ animation: "slide", background: "rgba(255, 152, 0, 0.86)" });
353 |
354 |
355 |
356 |
357 |
Fullscreen
358 |
For a fullscreen-overlay use $.busyLoadFull()
$.busyLoadFull("show", { background: "rgba(0, 51, 101, 0.83)", image: "tardis", animate: "slide" });
359 |
$.busyLoadFull("hide", { animate: "fade" });
360 |
361 |
Fullscreen
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
Spinners
371 |
CSS
372 |
Choose one of the built in CSS-spinners.
373 |
374 |
375 |
376 |
377 |
378 |
379 |
spinner:
380 |
pump
381 |
Without any options, the default spinner will be pump
$("#el").busyLoad("show");
382 |
show
383 |
384 |
385 |
386 |
387 |
388 |
389 |
spinner:
390 |
accordion $("#el").busyLoad("show", { spinner: "accordion"
391 | });
392 |
show
393 |
394 |
395 |
396 |
397 |
398 |
399 |
spinner:
400 |
pulsar $("#el").busyLoad("show", { spinner: "pulsar"
401 | });
402 |
show
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
spinner:
412 |
cube $("#el").busyLoad("show", { spinner: "cube"
413 | });
414 |
show
415 |
416 |
417 |
418 |
419 |
420 |
421 |
spinner:
422 |
cubes $("#el").busyLoad("show", { spinner: "cubes"
423 | });
424 |
show
425 |
426 |
427 |
428 |
429 |
430 |
431 |
spinner:
432 |
circle-line $("#el").busyLoad("show", { spinner: "circle-line"
433 | });
434 |
show
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
spinner:
444 |
circles $("#el").busyLoad("show", { spinner: "circles"
445 | });
446 |
show
447 |
448 |
449 |
450 |
451 |
452 |
453 |
spinner:
454 |
cube-grid $("#el").busyLoad("show", { spinner: "cube-grid"
455 | });
456 |
show
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
Images
467 |
Use an image as spinner.
468 |
469 |
470 |
471 |
472 |
473 |
474 |
image:
475 |
source $("#el").busyLoad("show", { background: "rgba(76, 175, 80, 0.73)",
476 | image: "data:image/gif;base64,R0lGODlhQAA..."
477 | });
478 |
show
479 |
480 |
481 |
482 |
483 |
484 |
485 |
image:
486 |
tardis
487 |
An image is already included, base64 encoded.
$("#el").busyLoad("show", {
488 | image: "tardis",
489 | background: "rgba(0, 51, 101, 0.83)"
490 | });
show
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
Fontawesome
501 |
Include the fontawesome-library and use its spinners.
502 |
503 |
504 |
505 |
506 |
507 |
508 |
fontawesome:
509 |
icon class
510 |
add also fa-spin
$("#el").busyLoad("show", {
511 | fontawesome: "fa fa-spinner fa-spin fa-3x fa-fw" });
512 |
show
513 |
514 |
515 |
516 |
517 |
518 |
519 |
fontawesome:
520 |
icon class
521 |
add also fa-spin
$("#el").busyLoad("show", {
522 | fontawesome: "fa fa-cog fa-spin fa-3x fa-fw" });
523 |
show
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
Custom
534 |
Pass in your own jQuery-Element. Here's a quick example:
535 |
536 |
537 |
538 |
539 | let count = 2121;
540 | let customElement = $("<div>", {
541 | id: "countdown",
542 | css: { "font-size" : "50px" }, text: count
543 | });
544 | $("#el").busyLoad("show", {
545 | background: "brown", custom: customElement
546 | });
547 | let interval = setInterval(function(){
548 | count--;
549 | customElement.text(count);
550 | if (count <= 0) {
551 | clearInterval(interval);
552 | $("#el").busyLoad("hide");
553 | return;
554 | }
555 | }, 1000);
556 |
557 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
Sizing
568 |
Use maxSize & minSize for sizing the spinner. This only works with CSS- & image-spinners.
569 |
570 |
571 |
572 |
573 |
574 |
575 |
max/minSize
576 |
size
577 |
Size a spinner
578 |
$("#el").busyLoad("show", {
579 | maxSize: "150px",
580 | minSize: "150px"
581 | });
582 |
show
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
max/minSize
591 |
size
592 |
Size an image
$("#el").busyLoad("show", {
593 | maxSize: "200px",
594 | minSize: "200px",
595 | background: "rgba(0, 51, 101, 0.83)",
596 | image: "tardis"
597 | });
598 |
show
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
Text Add text, position & style it.
609 |
610 |
611 |
612 |
613 |
614 |
615 |
text:
616 |
LOADING ...
617 |
$("#el").busyLoad("show", { text: "LOADING ..."
618 | });
619 |
show
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
spinner:
628 |
false
629 |
Explicitly hide the spinner.
$("#el").busyLoad("show", { text: "LOADING ...",
630 | spinner: false
631 | });
632 |
show
633 |
634 |
635 |
636 |
637 |
638 |
639 |
textPosition:
640 |
left $("#el").busyLoad("show", { text: "LOADING ...",
641 | textPosition: "left"
642 | });
643 |
show
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
textPosition:
653 |
right $("#el").busyLoad("show", { text: "LOADING ...",
654 | textPosition: "right"
655 | });
656 |
show
657 |
658 |
659 |
660 |
661 |
662 |
663 |
textPosition:
664 |
top $("#el").busyLoad("show", { text: "LOADING ...",
665 | textPosition: "top"
666 | });
667 |
show
668 |
669 |
670 |
671 |
672 |
673 |
674 |
textPosition:
675 |
bottom $("#el").busyLoad("show", { text: "LOADING ...",
676 | textPosition: "bottom"
677 | });
678 |
show
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
textColor:
689 |
color $("#el").busyLoad("show", {
690 | text: "LOADING ...",
691 | textColor: "white",
692 | color: "red",
693 | background: "brown"
694 | });
695 |
show
696 |
697 |
698 |
699 |
700 |
701 |
702 |
textMargin:
703 |
size $("#el").busyLoad("show", {
704 | text: "LOADING ...",
705 | textMargin: "3rem"
706 | });
707 |
show
708 |
709 |
710 |
711 |
712 |
713 |
714 |
fontSize:
715 |
size $("#el").busyLoad("show", {
716 | text: "LOADING ...",
717 | fontSize: "2rem"
718 | });
719 |
show
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
Animation
730 |
731 |
732 |
733 |
734 |
735 |
736 |
animation:
737 |
false $("#el").busyLoad("show", {
738 | animation: false
739 | });
740 |
show
741 |
742 |
743 |
744 |
745 |
746 |
747 |
animation:
748 |
fade $("#el").busyLoad("show", {
749 | animation: "fade"
750 | });
751 |
show
752 |
753 |
754 |
755 |
756 |
757 |
758 |
animation:
759 |
slide $("#el").busyLoad("show", {
760 | animation: "slide"
761 | });
762 |
show
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
animationDuration:
773 |
slow/fast $("#el").busyLoad("show", {
774 | animation: "fade",
775 | animationDuration: "slow"
776 | });
777 |
show
778 |
779 |
780 |
781 |
782 |
783 |
784 |
animationDuration:
785 |
time $("#el").busyLoad("show", {
786 | animation: "fade",
787 | animationDuration: 4000
788 | });
789 |
show
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
Classes
800 |
Add your own-classes to the components of the overlay.
801 |
802 |
803 |
804 |
805 |
806 |
807 |
containerClass:
808 |
class $("#el").busyLoad("show", {
809 | containerClass: "my-own-container-class"
810 | });
811 |
show
812 |
813 |
814 |
815 |
816 |
817 |
818 |
containerItemClass:
819 |
class $("#el").busyLoad("show", {
820 | containerItemClass: "my-own-container-item-class"
821 | });
822 |
show
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
spinnerClass:
833 |
class $("#el").busyLoad("show", {
834 | spinnerClass: "my-own-spinner-class"
835 | });
836 |
show
837 |
838 |
839 |
840 |
841 |
842 |
843 |
textClass:
844 |
class $("#el").busyLoad("show", {
845 | textClass: "my-own-text-class"
846 | });
847 |
show
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
CSS-position
859 |
860 |
861 |
862 |
863 |
864 |
865 | If a container has a position of static , busy-load will turn it to relative , because otherwise the overlay would be positioned to a parent element other than static .
866 |
867 |
868 |
869 |
870 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
871 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
872 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
873 | consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
874 | cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
875 | proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
876 |
877 |
show
878 |
879 |
880 |
881 |
882 |
885 |
886 |
--------------------------------------------------------------------------------
/test/testrunner.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
31 |
33 |
35 |
39 |
41 |
43 |
45 |
47 |
48 |
49 |
51 |
56 |
57 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./config')
2 |
3 | // console.info(module.exports);
--------------------------------------------------------------------------------