├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── .prettierignore ├── .travis.yml ├── LICENSE ├── README.md ├── demo ├── demo.css └── index.html ├── dist ├── jquery.loading.js └── jquery.loading.min.js ├── package.json ├── src ├── loading.css └── loading.js ├── test └── jquery.loading.test.js ├── webpack.config.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["eslint:recommended"], 3 | "env": { 4 | "browser": true, 5 | "es6": true, 6 | "jest": true, 7 | "node": true 8 | }, 9 | "parserOptions": { 10 | "sourceType": "module" 11 | }, 12 | "rules": {} 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | cache: yarn 3 | node_js: 4 | - "lts/*" 5 | - "node" 6 | script: 7 | - yarn build 8 | - yarn eslint 9 | - yarn test 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) Carlos Bonetti, http://carlosbonetti.github.io 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jquery-loading 2 | 3 | [![Build Status](https://travis-ci.org/CarlosBonetti/jquery-loading.svg)](https://travis-ci.org/CarlosBonetti/jquery-loading) 4 | ![NPM downloads per month](https://img.shields.io/npm/dm/jquery-easy-loading.svg) 5 | 6 | Add and manipulate loading states of any element on the page. 7 | 8 | [Docs and Demos](http://carlosbonetti.github.io/jquery-loading/). 9 | 10 | ## Getting started 11 | 12 | Install it, using [npm](https://www.npmjs.com/): 13 | 14 | ```sh 15 | $ npm install --save jquery-easy-loading 16 | ``` 17 | 18 | Include it: 19 | 20 | ```html 21 | 22 | 23 | ``` 24 | 25 | Use it: 26 | 27 | ```javascript 28 | $("#some-element").loading(); 29 | ``` 30 | 31 | Visit [the website](http://carlosbonetti.github.io/jquery-loading/) for full list of options, methods and customization. 32 | 33 | ## Contributing to this project 34 | 35 | Install dependencies once: 36 | 37 | ``` 38 | $ yarn install 39 | ``` 40 | 41 | Then build the project (generates `dist/` files): 42 | 43 | ``` 44 | $ yarn build 45 | ``` 46 | 47 | Run all tests with: 48 | 49 | ``` 50 | $ yarn test 51 | ``` 52 | -------------------------------------------------------------------------------- /demo/demo.css: -------------------------------------------------------------------------------- 1 | .loading-div { 2 | height: 180px; 3 | padding: 15px 25px; 4 | color: #eee; 5 | } 6 | 7 | .example { 8 | height: 270px; 9 | } 10 | 11 | footer { 12 | padding-bottom: 30px; 13 | } 14 | 15 | #custom-overlay { 16 | background-color: #000; 17 | opacity: 0.7; 18 | } 19 | 20 | /* http://projects.lukehaas.me/css-loaders/ by @lukehaas */ 21 | .loading-spinner { 22 | font-size: 12px; 23 | margin: 25% auto; 24 | width: 1em; 25 | height: 1em; 26 | border-radius: 50%; 27 | position: relative; 28 | text-indent: -9999em; 29 | -webkit-animation: load4 1.3s infinite linear; 30 | animation: load4 1.3s infinite linear; 31 | } 32 | @-webkit-keyframes load4 { 33 | 0%, 34 | 100% { 35 | box-shadow: 0em -3em 0em 0.2em #ffffff, 2em -2em 0 0em #ffffff, 36 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 37 | 0em 3em 0 -0.5em #ffffff, -2em 2em 0 -0.5em #ffffff, 38 | -3em 0em 0 -0.5em #ffffff, -2em -2em 0 0em #ffffff; 39 | } 40 | 12.5% { 41 | box-shadow: 0em -3em 0em 0em #ffffff, 2em -2em 0 0.2em #ffffff, 42 | 3em 0em 0 0em #ffffff, 2em 2em 0 -0.5em #ffffff, 0em 3em 0 -0.5em #ffffff, 43 | -2em 2em 0 -0.5em #ffffff, -3em 0em 0 -0.5em #ffffff, 44 | -2em -2em 0 -0.5em #ffffff; 45 | } 46 | 25% { 47 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 0em #ffffff, 48 | 3em 0em 0 0.2em #ffffff, 2em 2em 0 0em #ffffff, 0em 3em 0 -0.5em #ffffff, 49 | -2em 2em 0 -0.5em #ffffff, -3em 0em 0 -0.5em #ffffff, 50 | -2em -2em 0 -0.5em #ffffff; 51 | } 52 | 37.5% { 53 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 54 | 3em 0em 0 0em #ffffff, 2em 2em 0 0.2em #ffffff, 0em 3em 0 0em #ffffff, 55 | -2em 2em 0 -0.5em #ffffff, -3em 0em 0 -0.5em #ffffff, 56 | -2em -2em 0 -0.5em #ffffff; 57 | } 58 | 50% { 59 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 60 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 0em #ffffff, 0em 3em 0 0.2em #ffffff, 61 | -2em 2em 0 0em #ffffff, -3em 0em 0 -0.5em #ffffff, 62 | -2em -2em 0 -0.5em #ffffff; 63 | } 64 | 62.5% { 65 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 66 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 0em 3em 0 0em #ffffff, 67 | -2em 2em 0 0.2em #ffffff, -3em 0em 0 0em #ffffff, 68 | -2em -2em 0 -0.5em #ffffff; 69 | } 70 | 75% { 71 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 72 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 73 | 0em 3em 0 -0.5em #ffffff, -2em 2em 0 0em #ffffff, -3em 0em 0 0.2em #ffffff, 74 | -2em -2em 0 0em #ffffff; 75 | } 76 | 87.5% { 77 | box-shadow: 0em -3em 0em 0em #ffffff, 2em -2em 0 -0.5em #ffffff, 78 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 79 | 0em 3em 0 -0.5em #ffffff, -2em 2em 0 0em #ffffff, -3em 0em 0 0em #ffffff, 80 | -2em -2em 0 0.2em #ffffff; 81 | } 82 | } 83 | @keyframes load4 { 84 | 0%, 85 | 100% { 86 | box-shadow: 0em -3em 0em 0.2em #ffffff, 2em -2em 0 0em #ffffff, 87 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 88 | 0em 3em 0 -0.5em #ffffff, -2em 2em 0 -0.5em #ffffff, 89 | -3em 0em 0 -0.5em #ffffff, -2em -2em 0 0em #ffffff; 90 | } 91 | 12.5% { 92 | box-shadow: 0em -3em 0em 0em #ffffff, 2em -2em 0 0.2em #ffffff, 93 | 3em 0em 0 0em #ffffff, 2em 2em 0 -0.5em #ffffff, 0em 3em 0 -0.5em #ffffff, 94 | -2em 2em 0 -0.5em #ffffff, -3em 0em 0 -0.5em #ffffff, 95 | -2em -2em 0 -0.5em #ffffff; 96 | } 97 | 25% { 98 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 0em #ffffff, 99 | 3em 0em 0 0.2em #ffffff, 2em 2em 0 0em #ffffff, 0em 3em 0 -0.5em #ffffff, 100 | -2em 2em 0 -0.5em #ffffff, -3em 0em 0 -0.5em #ffffff, 101 | -2em -2em 0 -0.5em #ffffff; 102 | } 103 | 37.5% { 104 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 105 | 3em 0em 0 0em #ffffff, 2em 2em 0 0.2em #ffffff, 0em 3em 0 0em #ffffff, 106 | -2em 2em 0 -0.5em #ffffff, -3em 0em 0 -0.5em #ffffff, 107 | -2em -2em 0 -0.5em #ffffff; 108 | } 109 | 50% { 110 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 111 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 0em #ffffff, 0em 3em 0 0.2em #ffffff, 112 | -2em 2em 0 0em #ffffff, -3em 0em 0 -0.5em #ffffff, 113 | -2em -2em 0 -0.5em #ffffff; 114 | } 115 | 62.5% { 116 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 117 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 0em 3em 0 0em #ffffff, 118 | -2em 2em 0 0.2em #ffffff, -3em 0em 0 0em #ffffff, 119 | -2em -2em 0 -0.5em #ffffff; 120 | } 121 | 75% { 122 | box-shadow: 0em -3em 0em -0.5em #ffffff, 2em -2em 0 -0.5em #ffffff, 123 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 124 | 0em 3em 0 -0.5em #ffffff, -2em 2em 0 0em #ffffff, -3em 0em 0 0.2em #ffffff, 125 | -2em -2em 0 0em #ffffff; 126 | } 127 | 87.5% { 128 | box-shadow: 0em -3em 0em 0em #ffffff, 2em -2em 0 -0.5em #ffffff, 129 | 3em 0em 0 -0.5em #ffffff, 2em 2em 0 -0.5em #ffffff, 130 | 0em 3em 0 -0.5em #ffffff, -2em 2em 0 0em #ffffff, -3em 0em 0 0em #ffffff, 131 | -2em -2em 0 0.2em #ffffff; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | jquery-loading Demo 8 | 9 | 13 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 |
33 |

Basic usage

34 | 35 |
36 | This div is always loading 37 |
38 | 39 | 42 |
43 | 44 |
45 |

Starting

46 | 47 |
48 | This div will start loading if you click it 49 |
50 | 51 | 56 |
57 | 58 |
59 |

Stopping

60 | 61 |
62 | This div will stop loading if you click it 63 |
64 | 65 | 70 |
71 | 72 |
73 |

Toggling

74 | 75 |
76 | This div is toggling the loading state 77 |
78 | 79 | 84 |
85 | 86 |
87 |

Custom animation

88 | 89 | 92 | 93 | 103 |
104 | 105 |
106 |

Themes

107 | 108 |
109 | This div has a different theme (dark) 110 |
111 | 112 | 117 |
118 | 119 |
120 |

Custom message

121 | 122 |
123 | This div has a custom loading method 124 |
125 | 126 | 131 |
132 | 133 |
134 |

Controls with events handling

135 | 136 | 139 | 140 |
141 | This div is button controled, using the events `loading.start` and 142 | `loading.stop` to change the state (text) of the button 143 |
144 | 145 | 158 |
159 | 160 |
161 |

Body loading

162 | 163 |
164 | 167 | 168 | 171 |
172 | 173 | 188 |
189 | 190 |
191 |

:loading selector

192 | 193 |
194 | 197 |
198 | 199 | 204 |
205 | 206 |
207 |

start option

208 | 209 |
210 | This div is not started on initialization 211 |
212 | 213 | 216 | 217 | 228 |
229 | 230 |
231 |
232 | Loading (custom)... 233 |
234 |
235 | 236 |
237 |

Custom overlay

238 | 239 | 242 | 243 | 248 |
249 |
250 | 251 | 254 | 255 | 269 | 270 | 271 | -------------------------------------------------------------------------------- /dist/jquery.loading.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(require("jquery")); 4 | else if(typeof define === 'function' && define.amd) 5 | define(["jquery"], factory); 6 | else { 7 | var a = typeof exports === 'object' ? factory(require("jquery")) : factory(root["jQuery"]); 8 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; 9 | } 10 | })(window, function(__WEBPACK_EXTERNAL_MODULE_jquery__) { 11 | return /******/ (function(modules) { // webpackBootstrap 12 | /******/ // The module cache 13 | /******/ var installedModules = {}; 14 | /******/ 15 | /******/ // The require function 16 | /******/ function __webpack_require__(moduleId) { 17 | /******/ 18 | /******/ // Check if module is in cache 19 | /******/ if(installedModules[moduleId]) { 20 | /******/ return installedModules[moduleId].exports; 21 | /******/ } 22 | /******/ // Create a new module (and put it into the cache) 23 | /******/ var module = installedModules[moduleId] = { 24 | /******/ i: moduleId, 25 | /******/ l: false, 26 | /******/ exports: {} 27 | /******/ }; 28 | /******/ 29 | /******/ // Execute the module function 30 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 31 | /******/ 32 | /******/ // Flag the module as loaded 33 | /******/ module.l = true; 34 | /******/ 35 | /******/ // Return the exports of the module 36 | /******/ return module.exports; 37 | /******/ } 38 | /******/ 39 | /******/ 40 | /******/ // expose the modules object (__webpack_modules__) 41 | /******/ __webpack_require__.m = modules; 42 | /******/ 43 | /******/ // expose the module cache 44 | /******/ __webpack_require__.c = installedModules; 45 | /******/ 46 | /******/ // define getter function for harmony exports 47 | /******/ __webpack_require__.d = function(exports, name, getter) { 48 | /******/ if(!__webpack_require__.o(exports, name)) { 49 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 50 | /******/ } 51 | /******/ }; 52 | /******/ 53 | /******/ // define __esModule on exports 54 | /******/ __webpack_require__.r = function(exports) { 55 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 56 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 57 | /******/ } 58 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 59 | /******/ }; 60 | /******/ 61 | /******/ // create a fake namespace object 62 | /******/ // mode & 1: value is a module id, require it 63 | /******/ // mode & 2: merge all properties of value into the ns 64 | /******/ // mode & 4: return value when already ns object 65 | /******/ // mode & 8|1: behave like require 66 | /******/ __webpack_require__.t = function(value, mode) { 67 | /******/ if(mode & 1) value = __webpack_require__(value); 68 | /******/ if(mode & 8) return value; 69 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 70 | /******/ var ns = Object.create(null); 71 | /******/ __webpack_require__.r(ns); 72 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 73 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 74 | /******/ return ns; 75 | /******/ }; 76 | /******/ 77 | /******/ // getDefaultExport function for compatibility with non-harmony modules 78 | /******/ __webpack_require__.n = function(module) { 79 | /******/ var getter = module && module.__esModule ? 80 | /******/ function getDefault() { return module['default']; } : 81 | /******/ function getModuleExports() { return module; }; 82 | /******/ __webpack_require__.d(getter, 'a', getter); 83 | /******/ return getter; 84 | /******/ }; 85 | /******/ 86 | /******/ // Object.prototype.hasOwnProperty.call 87 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 88 | /******/ 89 | /******/ // __webpack_public_path__ 90 | /******/ __webpack_require__.p = ""; 91 | /******/ 92 | /******/ 93 | /******/ // Load entry module and return exports 94 | /******/ return __webpack_require__(__webpack_require__.s = "./src/loading.js"); 95 | /******/ }) 96 | /************************************************************************/ 97 | /******/ ({ 98 | 99 | /***/ "./node_modules/css-loader/dist/cjs.js!./src/loading.css": 100 | /*!***************************************************************!*\ 101 | !*** ./node_modules/css-loader/dist/cjs.js!./src/loading.css ***! 102 | \***************************************************************/ 103 | /*! no static exports found */ 104 | /***/ (function(module, exports, __webpack_require__) { 105 | 106 | eval("exports = module.exports = __webpack_require__(/*! ../node_modules/css-loader/dist/runtime/api.js */ \"./node_modules/css-loader/dist/runtime/api.js\")(false);\n// Module\nexports.push([module.i, \"/* Default jquery-loading styles */\\r\\n\\r\\n.loading-overlay {\\r\\n display: table;\\r\\n opacity: 0.7;\\r\\n}\\r\\n\\r\\n.loading-overlay-content {\\r\\n text-transform: uppercase;\\r\\n letter-spacing: 0.4em;\\r\\n font-size: 1.15em;\\r\\n font-weight: bold;\\r\\n text-align: center;\\r\\n display: table-cell;\\r\\n vertical-align: middle;\\r\\n}\\r\\n\\r\\n.loading-overlay.loading-theme-light {\\r\\n background-color: #fff;\\r\\n color: #000;\\r\\n}\\r\\n\\r\\n.loading-overlay.loading-theme-dark {\\r\\n background-color: #000;\\r\\n color: #fff;\\r\\n}\\r\\n\", \"\"]);\n\n\n//# sourceURL=webpack:///./src/loading.css?./node_modules/css-loader/dist/cjs.js"); 107 | 108 | /***/ }), 109 | 110 | /***/ "./node_modules/css-loader/dist/runtime/api.js": 111 | /*!*****************************************************!*\ 112 | !*** ./node_modules/css-loader/dist/runtime/api.js ***! 113 | \*****************************************************/ 114 | /*! no static exports found */ 115 | /***/ (function(module, exports, __webpack_require__) { 116 | 117 | "use strict"; 118 | eval("\n\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra\n*/\n// css base code, injected by the css-loader\n// eslint-disable-next-line func-names\nmodule.exports = function (useSourceMap) {\n var list = []; // return the list of modules as css string\n\n list.toString = function toString() {\n return this.map(function (item) {\n var content = cssWithMappingToString(item, useSourceMap);\n\n if (item[2]) {\n return \"@media \".concat(item[2], \"{\").concat(content, \"}\");\n }\n\n return content;\n }).join('');\n }; // import a list of modules into the list\n // eslint-disable-next-line func-names\n\n\n list.i = function (modules, mediaQuery) {\n if (typeof modules === 'string') {\n // eslint-disable-next-line no-param-reassign\n modules = [[null, modules, '']];\n }\n\n var alreadyImportedModules = {};\n\n for (var i = 0; i < this.length; i++) {\n // eslint-disable-next-line prefer-destructuring\n var id = this[i][0];\n\n if (id != null) {\n alreadyImportedModules[id] = true;\n }\n }\n\n for (var _i = 0; _i < modules.length; _i++) {\n var item = modules[_i]; // skip already imported module\n // this implementation is not 100% perfect for weird media query combinations\n // when a module is imported multiple times with different media queries.\n // I hope this will never occur (Hey this way we have smaller bundles)\n\n if (item[0] == null || !alreadyImportedModules[item[0]]) {\n if (mediaQuery && !item[2]) {\n item[2] = mediaQuery;\n } else if (mediaQuery) {\n item[2] = \"(\".concat(item[2], \") and (\").concat(mediaQuery, \")\");\n }\n\n list.push(item);\n }\n }\n };\n\n return list;\n};\n\nfunction cssWithMappingToString(item, useSourceMap) {\n var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring\n\n var cssMapping = item[3];\n\n if (!cssMapping) {\n return content;\n }\n\n if (useSourceMap && typeof btoa === 'function') {\n var sourceMapping = toComment(cssMapping);\n var sourceURLs = cssMapping.sources.map(function (source) {\n return \"/*# sourceURL=\".concat(cssMapping.sourceRoot).concat(source, \" */\");\n });\n return [content].concat(sourceURLs).concat([sourceMapping]).join('\\n');\n }\n\n return [content].join('\\n');\n} // Adapted from convert-source-map (MIT)\n\n\nfunction toComment(sourceMap) {\n // eslint-disable-next-line no-undef\n var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));\n var data = \"sourceMappingURL=data:application/json;charset=utf-8;base64,\".concat(base64);\n return \"/*# \".concat(data, \" */\");\n}\n\n//# sourceURL=webpack:///./node_modules/css-loader/dist/runtime/api.js?"); 119 | 120 | /***/ }), 121 | 122 | /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js": 123 | /*!****************************************************************************!*\ 124 | !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***! 125 | \****************************************************************************/ 126 | /*! no static exports found */ 127 | /***/ (function(module, exports, __webpack_require__) { 128 | 129 | "use strict"; 130 | eval("\n\nvar stylesInDom = {};\n\nvar isOldIE = function isOldIE() {\n var memo;\n return function memorize() {\n if (typeof memo === 'undefined') {\n // Test for IE <= 9 as proposed by Browserhacks\n // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n // Tests for existence of standard globals is to allow style-loader\n // to operate correctly into non-standard environments\n // @see https://github.com/webpack-contrib/style-loader/issues/177\n memo = Boolean(window && document && document.all && !window.atob);\n }\n\n return memo;\n };\n}();\n\nvar getTarget = function getTarget() {\n var memo = {};\n return function memorize(target) {\n if (typeof memo[target] === 'undefined') {\n var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself\n\n if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n try {\n // This will throw an exception if access to iframe is blocked\n // due to cross-origin restrictions\n styleTarget = styleTarget.contentDocument.head;\n } catch (e) {\n // istanbul ignore next\n styleTarget = null;\n }\n }\n\n memo[target] = styleTarget;\n }\n\n return memo[target];\n };\n}();\n\nfunction listToStyles(list, options) {\n var styles = [];\n var newStyles = {};\n\n for (var i = 0; i < list.length; i++) {\n var item = list[i];\n var id = options.base ? item[0] + options.base : item[0];\n var css = item[1];\n var media = item[2];\n var sourceMap = item[3];\n var part = {\n css: css,\n media: media,\n sourceMap: sourceMap\n };\n\n if (!newStyles[id]) {\n styles.push(newStyles[id] = {\n id: id,\n parts: [part]\n });\n } else {\n newStyles[id].parts.push(part);\n }\n }\n\n return styles;\n}\n\nfunction addStylesToDom(styles, options) {\n for (var i = 0; i < styles.length; i++) {\n var item = styles[i];\n var domStyle = stylesInDom[item.id];\n var j = 0;\n\n if (domStyle) {\n domStyle.refs++;\n\n for (; j < domStyle.parts.length; j++) {\n domStyle.parts[j](item.parts[j]);\n }\n\n for (; j < item.parts.length; j++) {\n domStyle.parts.push(addStyle(item.parts[j], options));\n }\n } else {\n var parts = [];\n\n for (; j < item.parts.length; j++) {\n parts.push(addStyle(item.parts[j], options));\n }\n\n stylesInDom[item.id] = {\n id: item.id,\n refs: 1,\n parts: parts\n };\n }\n }\n}\n\nfunction insertStyleElement(options) {\n var style = document.createElement('style');\n\n if (typeof options.attributes.nonce === 'undefined') {\n var nonce = true ? __webpack_require__.nc : undefined;\n\n if (nonce) {\n options.attributes.nonce = nonce;\n }\n }\n\n Object.keys(options.attributes).forEach(function (key) {\n style.setAttribute(key, options.attributes[key]);\n });\n\n if (typeof options.insert === 'function') {\n options.insert(style);\n } else {\n var target = getTarget(options.insert || 'head');\n\n if (!target) {\n throw new Error(\"Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.\");\n }\n\n target.appendChild(style);\n }\n\n return style;\n}\n\nfunction removeStyleElement(style) {\n // istanbul ignore if\n if (style.parentNode === null) {\n return false;\n }\n\n style.parentNode.removeChild(style);\n}\n/* istanbul ignore next */\n\n\nvar replaceText = function replaceText() {\n var textStore = [];\n return function replace(index, replacement) {\n textStore[index] = replacement;\n return textStore.filter(Boolean).join('\\n');\n };\n}();\n\nfunction applyToSingletonTag(style, index, remove, obj) {\n var css = remove ? '' : obj.css; // For old IE\n\n /* istanbul ignore if */\n\n if (style.styleSheet) {\n style.styleSheet.cssText = replaceText(index, css);\n } else {\n var cssNode = document.createTextNode(css);\n var childNodes = style.childNodes;\n\n if (childNodes[index]) {\n style.removeChild(childNodes[index]);\n }\n\n if (childNodes.length) {\n style.insertBefore(cssNode, childNodes[index]);\n } else {\n style.appendChild(cssNode);\n }\n }\n}\n\nfunction applyToTag(style, options, obj) {\n var css = obj.css;\n var media = obj.media;\n var sourceMap = obj.sourceMap;\n\n if (media) {\n style.setAttribute('media', media);\n }\n\n if (sourceMap && btoa) {\n css += \"\\n/*# sourceMappingURL=data:application/json;base64,\".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), \" */\");\n } // For old IE\n\n /* istanbul ignore if */\n\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n while (style.firstChild) {\n style.removeChild(style.firstChild);\n }\n\n style.appendChild(document.createTextNode(css));\n }\n}\n\nvar singleton = null;\nvar singletonCounter = 0;\n\nfunction addStyle(obj, options) {\n var style;\n var update;\n var remove;\n\n if (options.singleton) {\n var styleIndex = singletonCounter++;\n style = singleton || (singleton = insertStyleElement(options));\n update = applyToSingletonTag.bind(null, style, styleIndex, false);\n remove = applyToSingletonTag.bind(null, style, styleIndex, true);\n } else {\n style = insertStyleElement(options);\n update = applyToTag.bind(null, style, options);\n\n remove = function remove() {\n removeStyleElement(style);\n };\n }\n\n update(obj);\n return function updateStyle(newObj) {\n if (newObj) {\n if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {\n return;\n }\n\n update(obj = newObj);\n } else {\n remove();\n }\n };\n}\n\nmodule.exports = function (list, options) {\n options = options || {};\n options.attributes = typeof options.attributes === 'object' ? options.attributes : {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of