@kasko/fe-loading-indicator 1.3.1 → 2.0.0

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.
package/README.md CHANGED
@@ -15,7 +15,7 @@ yarn add @kasko/fe-loading-indicator
15
15
  Requiring `@kasko/fe-loading-indicator` will return string that could be injected in
16
16
  HTML using 'HtmlWebpackPlugin'.
17
17
  ```js
18
- const loader = require('@kasko/fe-loading-indicator')();
18
+ const loader = require('@kasko/fe-loading-indicator').kaskoLoader();
19
19
  ```
20
20
 
21
21
  Module accepts configuration object, where custom CSS loading colors could be provided e.g.
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * This function is used by gulp to replace LESS variables
5
+ * with actual values.
6
+ */
7
+ module.exports = function () {
8
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
+
10
+ var result = '<style title="li-loader">@keyframes spinner-loader{0%{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(360deg)}}.hidden{display:none}#kasko-loader-wrapper{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1500}#kasko-loader-wrapper:not(.li-loaded){background:"@overlaycolor";opacity:1}#kasko-loader{display:block;position:relative;left:50%;top:50%;width:150px;height:150px;margin:-75px 0 0 -75px;border-radius:50%;border:3px solid transparent;border-top-color:"@color1";animation:spin 2s linear infinite;z-index:1501}#kasko-loader::after,#kasko-loader::before{content:"";position:absolute;top:5px;left:5px;right:5px;bottom:5px;border-radius:50%;border:3px solid transparent;border-top-color:"@color2";animation:spin 3s linear infinite}#kasko-loader::after{top:15px;left:15px;right:15px;bottom:15px;border-top-color:"@color3";animation:spin 1.5s linear infinite}#kasko-loader-wrapper .loader-section{position:fixed;top:0;width:50%;height:100%;z-index:1500;transform:translateX(0)}.li-loaded .loader-section{background:"@overlaycolor";opacity:.9}#kasko-loader-wrapper .loader-section.section-left{left:0}#kasko-loader-wrapper .loader-section.section-right{right:0}#kasko-loader-wrapper.li-loaded .loader-section.section-left{transform:translateX(-100%);transition:all .7s .3s cubic-bezier(.645,.045,.355,1)}#kasko-loader-wrapper.li-loaded .loader-section.section-right{transform:translateX(100%);transition:all .7s .3s cubic-bezier(.645,.045,.355,1)}.li-loaded #kasko-loader{opacity:0;transition:all .3s ease-out}#kasko-loader-wrapper.li-loaded{visibility:hidden}.spinner-loader:not(:requigray){animation:spinner-loader 1500ms infinite linear;border-radius:.5em;box-shadow:#025983 1.5em 0 0 0,#025983 1.1em 1.1em 0 0,#025983 0 1.5em 0 0,#025983 -1.1em 1.1em 0 0,#025983 -1.5em 0 0 0,#025983 -1.1em -1.1em 0 0,#025983 0 -1.5em 0 0,#025983 1.1em -1.1em 0 0;display:inline-block;font-size:10px;width:1em;height:1em;margin:1.5em;overflow:hidden;text-indent:100%}</style> <div id="kasko-loader-wrapper" class="hidden"> <div id="kasko-loader"></div> <div class="loader-section section-left"></div> <div class="loader-section section-right"></div> </div> <script>"use strict";function LoadingIndicator(){var o=this,t=null;function r(o){t||function(){for(var o=0;o<document.styleSheets.length;o+=1){var r=document.styleSheets.item(o);if("li-loader"===r.title){t=r;break}}}(),t&&t.insertRule(o)}function e(o){var t=RegExp("[?&]"+o+"=([^&]*)").exec(window.location.search);if(!t)return"";var r=decodeURIComponent(t[1].replace(/[+]/g," "));try{r=JSON.parse(r)}catch(o){}return r}this.init=function(){var t=e("loader_background_color"),r=e("loader_animation_colors"),n=document.getElementById("kasko-loader-wrapper");r&&o.setAnimationColors(r),t&&o.setBackdropColor(t),n&&n.classList.remove("hidden")},this.hide=function(){var o=document.getElementById("kasko-loader-wrapper");o&&o.classList.add("li-loaded")},this.setColors=function(t){o.setAnimationColors(t)},this.setAnimationColors=function(o){r("#kasko-loader{border-top-color:"+o[0]+"!important;}"),r("#kasko-loader::before{border-top-color:"+o[1]+"!important;}"),r("#kasko-loader::after{border-top-color:"+o[2]+"!important;}")},this.setBackdropColor=function(o){r("#kasko-loader-wrapper:not(.li-loaded){background:"+o+"!important;}"),r(".li-loaded .loader-section{background:"+o+"!important;}")}}var loadingIndicator=new LoadingIndicator;window.LoadingIndicator=loadingIndicator,window.LoadingIndicator.init();</script> ';
11
+
12
+ if (!config.colors) {
13
+ config.colors = ['#ebbb2a', '#fff', '#a07c0f'];
14
+ }
15
+
16
+ if (!config.overlayColor) {
17
+ config.overlayColor = '#222';
18
+ }
19
+
20
+ config.colors.forEach(function (color, index) {
21
+ result = result.replace('\"@color' + (index + 1) + '\"', color);
22
+ });
23
+
24
+ result = result.replace(/\"@overlaycolor\"/g, config.overlayColor);
25
+ return result;
26
+ };
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * This function is used by gulp to replace LESS variables
5
+ * with actual values.
6
+ */
7
+ module.exports = function () {
8
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
+
10
+ var result = '<style title="li-loader">@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(360deg)}}.hidden{display:none}#kasko-loader-wrapper{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1500}#kasko-loader-wrapper svg{display:block;position:relative;left:50%;top:50%;width:150px;height:150px;margin:-75px 0 0 -75px;z-index:1501;animation:spin 1s linear infinite}#kasko-loader-wrapper:not(.li-loaded){background:"@overlaycolor";opacity:1}.li-loaded svg{opacity:0;transition:all .3s ease-out}#kasko-loader-wrapper.li-loaded{visibility:hidden}</style> <div id="kasko-loader-wrapper" class="hidden"> <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a"> <stop stop-color="#fff" stop-opacity="0" offset="0%"/> <stop stop-color="#fff" stop-opacity=".631" offset="63.146%"/> <stop stop-color="#fff" offset="100%"/> </linearGradient> </defs> <g fill="none" fill-rule="evenodd"> <g transform="translate(1 1)"> <path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2"></path> <circle fill="#fff" cx="36" cy="18" r="1"></circle> </g> </g> </svg> </div> <script>"use strict";function LoadingIndicator(){var o=this,t=null;function n(o){t||function(){for(var o=0;o<document.styleSheets.length;o+=1){var n=document.styleSheets.item(o);if("li-loader"===n.title){t=n;break}}}(),t&&t.insertRule(o)}function r(o){var t=RegExp("[?&]"+o+"=([^&]*)").exec(window.location.search);if(!t)return"";var n=decodeURIComponent(t[1].replace(/[+]/g," "));try{n=JSON.parse(n)}catch(o){}return n}this.init=function(){var t=r("loader_background_color"),n=r("loader_animation_colors"),a=document.getElementById("kasko-loader-wrapper");if(n){var e="string"==typeof n?n:n[0];o.setAnimationColors(e)}t&&o.setBackdropColor(t),a&&a.classList.remove("hidden")},this.hide=function(){var o=document.getElementById("kasko-loader-wrapper");o&&o.classList.add("li-loaded")},this.setAnimationColors=function(o){n("#kasko-loader-wrapper svg stop{stop-color:"+o+"!important;}"),n("#kasko-loader-wrapper svg circle{fill:"+o+"!important;}")},this.setBackdropColor=function(o){n("#kasko-loader-wrapper:not(.li-loaded){background:"+o+"!important;}")}}var loadingIndicator=new LoadingIndicator;window.LoadingIndicator=loadingIndicator,window.LoadingIndicator.init();</script> ';
11
+
12
+ if (!config.overlayColor) {
13
+ config.overlayColor = '#222';
14
+ }
15
+
16
+ result = result.replace(/\"@overlaycolor\"/g, config.overlayColor);
17
+ return result;
18
+ };
package/index.js CHANGED
@@ -1 +1,4 @@
1
- module.exports = require('./dist/loader.js');
1
+ module.exports = {
2
+ kaskoLoader: require('./dist/kasko-loader/kasko-loader.js'),
3
+ spinner: require('./dist/spinner/spinner.js'),
4
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kasko/fe-loading-indicator",
3
3
  "shortname": "fe-loading-indicator",
4
- "version": "1.3.1",
4
+ "version": "2.0.0",
5
5
  "description": "Kasko frontend loading indicator",
6
6
  "license": "UNLICENSED",
7
7
  "main": "index.js",
@@ -15,8 +15,13 @@
15
15
  },
16
16
  "dependencies": {},
17
17
  "devDependencies": {
18
+ "babel-core": "^6.26.3",
19
+ "babel-preset-env": "^1.7.0",
20
+ "eslint": "^4.19.1",
21
+ "eslint-config-airbnb-base": "^12.1.0",
22
+ "eslint-plugin-import": "^2.12.0",
18
23
  "gulp": "^3.9.1",
19
- "gulp-clean": "^0.4.0",
24
+ "gulp-babel": "^7.0.1",
20
25
  "gulp-csso": "^3.0.0",
21
26
  "gulp-less": "^3.3.2",
22
27
  "gulp-minify": "^2.1.0",
@@ -25,6 +30,7 @@
25
30
  },
26
31
  "scripts": {
27
32
  "build": "gulp",
28
- "test": "echo 'No tests for this project!'"
33
+ "test": "npm run lint",
34
+ "lint": "eslint src/"
29
35
  }
30
36
  }
@@ -0,0 +1,88 @@
1
+ function LoadingIndicator() {
2
+ let styleSheet = null;
3
+
4
+ function loadStyleSheet() {
5
+ for (let i = 0; i < document.styleSheets.length; i += 1) {
6
+ const styleSheetItem = document.styleSheets.item(i);
7
+
8
+ if (styleSheetItem.title === 'li-loader') {
9
+ styleSheet = styleSheetItem;
10
+ break;
11
+ }
12
+ }
13
+ }
14
+
15
+ function insertRule(rule) {
16
+ if (!styleSheet) {
17
+ loadStyleSheet();
18
+ }
19
+
20
+ if (styleSheet) {
21
+ styleSheet.insertRule(rule);
22
+ }
23
+ }
24
+
25
+ function getParameterByName(name) {
26
+ const match = RegExp(`[?&]${name}=([^&]*)`).exec(window.location.search);
27
+
28
+ if (!match) {
29
+ return '';
30
+ }
31
+
32
+ let decoded = decodeURIComponent(match[1].replace(/[+]/g, ' '));
33
+
34
+ // Attempt to json-decode
35
+ try {
36
+ decoded = JSON.parse(decoded);
37
+ } catch (e) {
38
+ // Do nothing..
39
+ }
40
+
41
+ return decoded;
42
+ }
43
+
44
+ this.init = () => {
45
+ const backdropColor = getParameterByName('loader_background_color');
46
+ const animationColors = getParameterByName('loader_animation_colors');
47
+ const elementById = document.getElementById('kasko-loader-wrapper');
48
+
49
+ if (animationColors) {
50
+ this.setAnimationColors(animationColors);
51
+ }
52
+
53
+ if (backdropColor) {
54
+ this.setBackdropColor(backdropColor);
55
+ }
56
+
57
+ if (elementById) {
58
+ elementById.classList.remove('hidden');
59
+ }
60
+ };
61
+
62
+ this.hide = () => {
63
+ const elementById = document.getElementById('kasko-loader-wrapper');
64
+
65
+ if (elementById) {
66
+ elementById.classList.add('li-loaded');
67
+ }
68
+ };
69
+
70
+ this.setColors = (colors) => {
71
+ this.setAnimationColors(colors);
72
+ };
73
+
74
+ this.setAnimationColors = (colors) => {
75
+ insertRule(`#kasko-loader{border-top-color:${colors[0]}!important;}`);
76
+ insertRule(`#kasko-loader::before{border-top-color:${colors[1]}!important;}`);
77
+ insertRule(`#kasko-loader::after{border-top-color:${colors[2]}!important;}`);
78
+ };
79
+
80
+ this.setBackdropColor = (color) => {
81
+ insertRule(`#kasko-loader-wrapper:not(.li-loaded){background:${color}!important;}`);
82
+ insertRule(`.li-loaded .loader-section{background:${color}!important;}`);
83
+ };
84
+ }
85
+
86
+ const loadingIndicator = new LoadingIndicator();
87
+ window.LoadingIndicator = loadingIndicator;
88
+ window.LoadingIndicator.init();
@@ -23,7 +23,7 @@
23
23
 
24
24
  #kasko-loader-wrapper:not(.li-loaded) {
25
25
  background: "@overlaycolor";
26
- opacity: .9;
26
+ opacity: 1;
27
27
  }
28
28
 
29
29
  #kasko-loader {
@@ -0,0 +1,22 @@
1
+ <link rel="stylesheet" href="loader.css">
2
+
3
+ <div id="kasko-loader-wrapper" class="hidden">
4
+ <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL -->
5
+ <svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
6
+ <defs>
7
+ <linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a">
8
+ <stop stop-color="#fff" stop-opacity="0" offset="0%"/>
9
+ <stop stop-color="#fff" stop-opacity=".631" offset="63.146%"/>
10
+ <stop stop-color="#fff" offset="100%"/>
11
+ </linearGradient>
12
+ </defs>
13
+ <g fill="none" fill-rule="evenodd">
14
+ <g transform="translate(1 1)">
15
+ <path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2"></path>
16
+ <circle fill="#fff" cx="36" cy="18" r="1"></circle>
17
+ </g>
18
+ </g>
19
+ </svg>
20
+ </div>
21
+
22
+ <script href="loader.js"></script>
@@ -0,0 +1,83 @@
1
+ function LoadingIndicator() {
2
+ let styleSheet = null;
3
+
4
+ function loadStyleSheet() {
5
+ for (let i = 0; i < document.styleSheets.length; i += 1) {
6
+ const styleSheetItem = document.styleSheets.item(i);
7
+
8
+ if (styleSheetItem.title === 'li-loader') {
9
+ styleSheet = styleSheetItem;
10
+ break;
11
+ }
12
+ }
13
+ }
14
+
15
+ function insertRule(rule) {
16
+ if (!styleSheet) {
17
+ loadStyleSheet();
18
+ }
19
+
20
+ if (styleSheet) {
21
+ styleSheet.insertRule(rule);
22
+ }
23
+ }
24
+
25
+ function getParameterByName(name) {
26
+ const match = RegExp(`[?&]${name}=([^&]*)`).exec(window.location.search);
27
+
28
+ if (!match) {
29
+ return '';
30
+ }
31
+
32
+ let decoded = decodeURIComponent(match[1].replace(/[+]/g, ' '));
33
+
34
+ // Attempt to json-decode
35
+ try {
36
+ decoded = JSON.parse(decoded);
37
+ } catch (e) {
38
+ // Do nothing..
39
+ }
40
+
41
+ return decoded;
42
+ }
43
+
44
+ this.init = () => {
45
+ const backdropColor = getParameterByName('loader_background_color');
46
+ const animationColors = getParameterByName('loader_animation_colors');
47
+ const elementById = document.getElementById('kasko-loader-wrapper');
48
+
49
+ if (animationColors) {
50
+ const color = typeof animationColors === 'string' ? animationColors : animationColors[0];
51
+ this.setAnimationColors(color);
52
+ }
53
+
54
+ if (backdropColor) {
55
+ this.setBackdropColor(backdropColor);
56
+ }
57
+
58
+ if (elementById) {
59
+ elementById.classList.remove('hidden');
60
+ }
61
+ };
62
+
63
+ this.hide = () => {
64
+ const elementById = document.getElementById('kasko-loader-wrapper');
65
+
66
+ if (elementById) {
67
+ elementById.classList.add('li-loaded');
68
+ }
69
+ };
70
+
71
+ this.setAnimationColors = (color) => {
72
+ insertRule(`#kasko-loader-wrapper svg stop{stop-color:${color}!important;}`);
73
+ insertRule(`#kasko-loader-wrapper svg circle{fill:${color}!important;}`);
74
+ };
75
+
76
+ this.setBackdropColor = (color) => {
77
+ insertRule(`#kasko-loader-wrapper:not(.li-loaded){background:${color}!important;}`);
78
+ };
79
+ }
80
+
81
+ const loadingIndicator = new LoadingIndicator();
82
+ window.LoadingIndicator = loadingIndicator;
83
+ window.LoadingIndicator.init();
@@ -0,0 +1,48 @@
1
+ @keyframes spin {
2
+ 0% {
3
+ transform: rotate(0deg);
4
+ }
5
+
6
+ 100% {
7
+ transform: rotate(360deg);
8
+ }
9
+ }
10
+
11
+ .hidden {
12
+ display: none;
13
+ }
14
+
15
+ #kasko-loader-wrapper {
16
+ position: fixed;
17
+ top: 0;
18
+ left: 0;
19
+ width: 100%;
20
+ height: 100%;
21
+ z-index: 1500;
22
+ }
23
+
24
+ #kasko-loader-wrapper svg {
25
+ display: block;
26
+ position: relative;
27
+ left: 50%;
28
+ top: 50%;
29
+ width: 150px;
30
+ height: 150px;
31
+ margin: -75px 0 0 -75px;
32
+ z-index: 1501;
33
+ animation: spin 1s linear infinite;
34
+ }
35
+
36
+ #kasko-loader-wrapper:not(.li-loaded) {
37
+ background: "@overlaycolor";
38
+ opacity: 1;
39
+ }
40
+
41
+ .li-loaded svg {
42
+ opacity: 0;
43
+ transition: all 0.3s ease-out;
44
+ }
45
+
46
+ #kasko-loader-wrapper.li-loaded {
47
+ visibility: hidden;
48
+ }
package/dist/loader.js DELETED
@@ -1,18 +0,0 @@
1
- module.exports = function (config = {}) {
2
- let result = '<style title="li-loader">@keyframes spinner-loader{0%{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(360deg)}}.hidden{display:none}#kasko-loader-wrapper{position:fixed;top:0;left:0;width:100%;height:100%;z-index:1500}#kasko-loader-wrapper:not(.li-loaded){background:"@overlaycolor";opacity:.9}#kasko-loader{display:block;position:relative;left:50%;top:50%;width:150px;height:150px;margin:-75px 0 0 -75px;border-radius:50%;border:3px solid transparent;border-top-color:"@color1";animation:spin 2s linear infinite;z-index:1501}#kasko-loader::after,#kasko-loader::before{content:"";position:absolute;top:5px;left:5px;right:5px;bottom:5px;border-radius:50%;border:3px solid transparent;border-top-color:"@color2";animation:spin 3s linear infinite}#kasko-loader::after{top:15px;left:15px;right:15px;bottom:15px;border-top-color:"@color3";animation:spin 1.5s linear infinite}#kasko-loader-wrapper .loader-section{position:fixed;top:0;width:50%;height:100%;z-index:1500;transform:translateX(0)}.li-loaded .loader-section{background:"@overlaycolor";opacity:.9}#kasko-loader-wrapper .loader-section.section-left{left:0}#kasko-loader-wrapper .loader-section.section-right{right:0}#kasko-loader-wrapper.li-loaded .loader-section.section-left{transform:translateX(-100%);transition:all .7s .3s cubic-bezier(.645,.045,.355,1)}#kasko-loader-wrapper.li-loaded .loader-section.section-right{transform:translateX(100%);transition:all .7s .3s cubic-bezier(.645,.045,.355,1)}.li-loaded #kasko-loader{opacity:0;transition:all .3s ease-out}#kasko-loader-wrapper.li-loaded{visibility:hidden}.spinner-loader:not(:requigray){animation:spinner-loader 1500ms infinite linear;border-radius:.5em;box-shadow:#025983 1.5em 0 0 0,#025983 1.1em 1.1em 0 0,#025983 0 1.5em 0 0,#025983 -1.1em 1.1em 0 0,#025983 -1.5em 0 0 0,#025983 -1.1em -1.1em 0 0,#025983 0 -1.5em 0 0,#025983 1.1em -1.1em 0 0;display:inline-block;font-size:10px;width:1em;height:1em;margin:1.5em;overflow:hidden;text-indent:100%}</style> <div id="kasko-loader-wrapper" class="hidden"> <div id="kasko-loader"></div> <div class="loader-section section-left"></div> <div class="loader-section section-right"></div> </div> <script>function LoadingIndicator(){this.init=function(){var o=document.getElementById("kasko-loader-wrapper");o&&o.classList.remove("hidden")},this.hide=function(){const o=document.getElementById("kasko-loader-wrapper");o&&o.classList.add("li-loaded")},this.setColors=function(o){for(var t,e=0;e<document.styleSheets.length;e++){var n=document.styleSheets.item(e);if("li-loader"===n.title){t=n;break}}t&&(t.insertRule("#loader { border-top-color:"+o[0]+"!important;}"),t.insertRule("#loader::before { border-top-color:"+o[1]+"!important;}"),t.insertRule("#loader::after { border-top-color:"+o[2]+"!important;}"))}}const loadingIndicator=new LoadingIndicator;window.LoadingIndicator=loadingIndicator,window.LoadingIndicator.init();</script> ';
3
-
4
- if (!config.colors) {
5
- config.colors = ['#ebbb2a', '#fff', '#a07c0f'];
6
- }
7
-
8
- if (!config.overlayColor) {
9
- config.overlayColor = '#222';
10
- }
11
-
12
- config.colors.forEach((color, index) => {
13
- result = result.replace('\"@color' + (index + 1) + '\"', color);
14
- });
15
-
16
- result = result.replace(/\"@overlaycolor\"/g, config.overlayColor);
17
- return result;
18
- }
package/gulpfile.js DELETED
@@ -1,57 +0,0 @@
1
- const gulp = require('gulp');
2
- const less = require('gulp-less');
3
- const minifyCSS = require('gulp-csso');
4
- const runSequence = require('run-sequence');
5
- const clean = require('gulp-clean');
6
- const replace = require('gulp-replace');
7
- const fs = require('fs');
8
- const minify = require('gulp-minify');
9
-
10
- gulp.task('clean', function () {
11
- return gulp.src(['.tmp'], { read: false }).pipe(clean());
12
- });
13
-
14
- gulp.task('html', function () {
15
- return gulp.src('src/*.html')
16
- .pipe(gulp.dest('.tmp/html'))
17
- });
18
-
19
- gulp.task('css', function () {
20
- return gulp.src('src/*.less')
21
- .pipe(less())
22
- .pipe(minifyCSS())
23
- .pipe(gulp.dest('.tmp/html'))
24
- });
25
-
26
- gulp.task('inline', function () {
27
- return gulp.src('.tmp/html/*.html')
28
- .pipe(replace(/<script href="loader.js"><\/script>/, function () {
29
- const script = fs.readFileSync('./.tmp/loader-min.js', 'utf8');
30
- return '<script>' + script + '</script>';
31
- }))
32
- .pipe(replace(/<link rel="stylesheet" href="loader.css">/, function () {
33
- const style = fs.readFileSync('.tmp/html/loader.css', 'utf8');
34
- return '<style title="li-loader">' + style + '</style>';
35
- }))
36
- .pipe(gulp.dest('./.tmp'));
37
- });
38
-
39
- gulp.task('compress', function () {
40
- gulp.src('./src/loader.js')
41
- .pipe(minify())
42
- .pipe(gulp.dest('./.tmp'))
43
- });
44
-
45
- gulp.task('compile', function () {
46
- return gulp.src('./conf/loader.js')
47
- .pipe(replace(/\$template/, function () {
48
- const content = fs.readFileSync('./.tmp/loader.html', 'utf8');
49
-
50
- return content.toString().replace(/\n|\t/g, ' ');
51
- }))
52
- .pipe(gulp.dest('./dist'));
53
- });
54
-
55
- gulp.task('default', function (callback) {
56
- runSequence(['clean'], ['html', 'css', 'compress'], ['inline'], ['compile'], ['clean'], callback);
57
- });
package/src/loader.js DELETED
@@ -1,40 +0,0 @@
1
- function LoadingIndicator() {
2
- this.init = function () {
3
- var elementById = document.getElementById('kasko-loader-wrapper');
4
-
5
- if (elementById) {
6
- elementById.classList.remove('hidden');
7
- }
8
- };
9
-
10
- this.hide = function () {
11
- const elementById = document.getElementById('kasko-loader-wrapper');
12
-
13
- if (elementById) {
14
- elementById.classList.add('li-loaded');
15
- }
16
- };
17
-
18
- this.setColors = function (colors) {
19
- var styleSheet;
20
-
21
- for (var i = 0; i < document.styleSheets.length; i++) {
22
- var styleSheetItem = document.styleSheets.item(i);
23
-
24
- if (styleSheetItem.title === 'li-loader') {
25
- styleSheet = styleSheetItem;
26
- break;
27
- }
28
- }
29
-
30
- if (styleSheet) {
31
- styleSheet.insertRule('#loader { border-top-color:' + colors[0] + '!important;}');
32
- styleSheet.insertRule('#loader::before { border-top-color:' + colors[1] + '!important;}');
33
- styleSheet.insertRule('#loader::after { border-top-color:' + colors[2] + '!important;}');
34
- }
35
- };
36
- }
37
-
38
- const loadingIndicator = new LoadingIndicator();
39
- window.LoadingIndicator = loadingIndicator;
40
- window.LoadingIndicator.init();
File without changes