vanilla-snackbar 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +137 -0
- data/lib/vanilla-snackbar.rb +8 -0
- data/lib/vanilla-snackbar/version.rb +5 -0
- data/vendor/assets/javascripts/snackbar.js +1028 -0
- data/vendor/assets/javascripts/snackbar.min.js +1 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e26fc4861855a96d97b37c039d6bcda3201e908
|
4
|
+
data.tar.gz: 2492882495cb27d370e837cdf781817f46e3eb5e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc9d91f77d7f1c05720a7bbbcd4f5dd435385f3e63e9a5b7fa9b68fd3dcf4448e855974221e90ff7187026852392fd05cdaac13bae932935967249d156483413
|
7
|
+
data.tar.gz: d97561f2e07daf864671ac22d1765359fa9316e5df861fa32d5aba1f926d9b22f1ef6c644357f4bd1d9bc491fb7db2ae7c01f987ae3721a83d10f6f63acda004
|
data/README.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# Snackbar.js (Vanilla-Snackbar)
|
2
|
+
|
3
|
+
A simple implementation of a full width snackbar message using "vanilla js".
|
4
|
+
View exmple at http://chrisdimoulis.com/snackbar.js
|
5
|
+
|
6
|
+
[Changelog](https://github.com/cdimoulis/snackbar.js/blob/master/changelog.md)
|
7
|
+
|
8
|
+
[![npm][npm]][npm-url]
|
9
|
+
[![node][node]][node-url]
|
10
|
+
[![deps][deps]][deps-url]
|
11
|
+
[![tests][tests]][tests-url]
|
12
|
+
[![coverage][cover]][cover-url]
|
13
|
+
|
14
|
+
## Production Dependencies
|
15
|
+
**None!** (not even jquery)
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
### Node
|
20
|
+
|
21
|
+
```
|
22
|
+
npm install --save vanilla-snackbar
|
23
|
+
```
|
24
|
+
|
25
|
+
### Ruby Gem for Rails
|
26
|
+
|
27
|
+
```
|
28
|
+
gem install vanilla-snackbar
|
29
|
+
```
|
30
|
+
|
31
|
+
Or simply add to your Gemfile:
|
32
|
+
```ruby
|
33
|
+
gem 'vanilla-snackbar'
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
### Importing/Including
|
40
|
+
|
41
|
+
**Node**
|
42
|
+
|
43
|
+
Import `vanilla-snackbar` into your module:
|
44
|
+
```js
|
45
|
+
import Snackbar from 'vanilla-snackbar';
|
46
|
+
```
|
47
|
+
|
48
|
+
**Rails**
|
49
|
+
|
50
|
+
Add to `app/assets/javascripts/application.js`. Note that you should just require snackbar, not vanilla-snackbar.
|
51
|
+
```js
|
52
|
+
//= require snackbar
|
53
|
+
```
|
54
|
+
|
55
|
+
### Style
|
56
|
+
See `src/snackbar.scss` for default style and reference if you desire to override any styles.
|
57
|
+
|
58
|
+
### Pre DOM ready
|
59
|
+
If you create a snackbar and create a message before the DOM is ready the message will be stored in a queue which which will execute once the DOM is ready.
|
60
|
+
|
61
|
+
### Create Snackbar
|
62
|
+
```javascript
|
63
|
+
// New snackbar with defaults
|
64
|
+
var default_snack = new Snackbar();
|
65
|
+
|
66
|
+
// New snackbar with custom default time
|
67
|
+
var short_snack = new Snackbar({time: 2000});
|
68
|
+
|
69
|
+
// New snackbar where the default behviour is to manually close
|
70
|
+
var manual_snack = new Snackbar({manual_close: true});
|
71
|
+
```
|
72
|
+
|
73
|
+
All options passed when creating the snackbar object are default. Overrides can be passed in each call to display a message.
|
74
|
+
|
75
|
+
#### Available Options
|
76
|
+
* `manual_close`: Boolean. Provide a close X button (true) vs timed close (false). *Default:* false
|
77
|
+
* `time`: ms of time before automatic close. (ignored if `manual_close: true`). *Default:* 5000
|
78
|
+
* `class`: String containing desired classes to add to snackbar. *Default:* empty
|
79
|
+
|
80
|
+
**NOTE: Default Options and Multiple Snackbar Objects**
|
81
|
+
|
82
|
+
A new Snackbar object will not inject new `#snackbar-wrapper` elements. All Snackbar objects use the same wrapper. It simply creates a new object with a different set of default options for displaying a Snackbar message. See below for overriding default options on a message specific basis as opposed to creating multiple Snackbar objects.
|
83
|
+
|
84
|
+
### Displaying Messages
|
85
|
+
|
86
|
+
Displaying a message is as simple as calling the `.message(msg, opts)` function of the Snackbar. There are also four helper methods for common Snackbar usage. All of these functions take 2 parameters:
|
87
|
+
|
88
|
+
* `msg`: the message to be displayed.
|
89
|
+
* `opts`: the options to override default options.
|
90
|
+
|
91
|
+
```javascript
|
92
|
+
// Display a message
|
93
|
+
snack.message('Hello World');
|
94
|
+
|
95
|
+
// Helper functions:
|
96
|
+
// Display a message that must be removed manually ->
|
97
|
+
snack.stickyMessage('Acknowledge me!');
|
98
|
+
// Display a message with a green background (adds class 'success') ->
|
99
|
+
snack.success('You did it!');
|
100
|
+
// Display a message with a red background (adds class 'error') ->
|
101
|
+
snack.error("Something didn't work");
|
102
|
+
// Display a message with a orangish/yellow background (adds class 'warn') ->
|
103
|
+
snack.warn("I'd be careful if I were you...");
|
104
|
+
```
|
105
|
+
|
106
|
+
Creating a Snackbar message will return a Promise object. This promise object will resolve when the Snackbar has finished fading in.
|
107
|
+
|
108
|
+
### Overriding Default Options
|
109
|
+
|
110
|
+
```javascript
|
111
|
+
// New snackbar with defaults
|
112
|
+
var snack = new Snackbar();
|
113
|
+
// Require user to close message just this one time
|
114
|
+
snack.message('Read this', {manual_close: true})
|
115
|
+
|
116
|
+
// New snackbar with custom default time
|
117
|
+
var snack = new Snackbar({time: 2000});
|
118
|
+
// Make this message stick longer than default
|
119
|
+
snack.message("A slightly longer message..."), {time: 7500});
|
120
|
+
// Add your own classes to the snackbar
|
121
|
+
snack.message("My special snackbar", {class: 'my-snackbar your-snackbar'})
|
122
|
+
```
|
123
|
+
|
124
|
+
[npm]: https://img.shields.io/npm/v/vanilla-snackbar.svg
|
125
|
+
[npm-url]: https://npmjs.com/package/vanilla-snackbar
|
126
|
+
|
127
|
+
[node]: https://img.shields.io/node/v/vanilla-snackbar.svg
|
128
|
+
[node-url]: https://nodejs.org
|
129
|
+
|
130
|
+
[deps]: https://img.shields.io/david/cdimoulis/snackbar.js.svg
|
131
|
+
[deps-url]: https://david-dm.org/cdimoulis/snackbar.js
|
132
|
+
|
133
|
+
[tests]: https://img.shields.io/travis/cdimoulis/snackbar.js/master.svg
|
134
|
+
[tests-url]: https://travis-ci.org/cdimoulis/snackbar.js
|
135
|
+
|
136
|
+
[cover]: https://coveralls.io/repos/github/cdimoulis/snackbar.js/badge.svg?branch=master
|
137
|
+
[cover-url]: https://coveralls.io/github/cdimoulis/snackbar.js?branch=master
|
@@ -0,0 +1,1028 @@
|
|
1
|
+
/******/ (function(modules) { // webpackBootstrap
|
2
|
+
/******/ // The module cache
|
3
|
+
/******/ var installedModules = {};
|
4
|
+
/******/
|
5
|
+
/******/ // The require function
|
6
|
+
/******/ function __webpack_require__(moduleId) {
|
7
|
+
/******/
|
8
|
+
/******/ // Check if module is in cache
|
9
|
+
/******/ if(installedModules[moduleId]) {
|
10
|
+
/******/ return installedModules[moduleId].exports;
|
11
|
+
/******/ }
|
12
|
+
/******/ // Create a new module (and put it into the cache)
|
13
|
+
/******/ var module = installedModules[moduleId] = {
|
14
|
+
/******/ i: moduleId,
|
15
|
+
/******/ l: false,
|
16
|
+
/******/ exports: {}
|
17
|
+
/******/ };
|
18
|
+
/******/
|
19
|
+
/******/ // Execute the module function
|
20
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21
|
+
/******/
|
22
|
+
/******/ // Flag the module as loaded
|
23
|
+
/******/ module.l = true;
|
24
|
+
/******/
|
25
|
+
/******/ // Return the exports of the module
|
26
|
+
/******/ return module.exports;
|
27
|
+
/******/ }
|
28
|
+
/******/
|
29
|
+
/******/
|
30
|
+
/******/ // expose the modules object (__webpack_modules__)
|
31
|
+
/******/ __webpack_require__.m = modules;
|
32
|
+
/******/
|
33
|
+
/******/ // expose the module cache
|
34
|
+
/******/ __webpack_require__.c = installedModules;
|
35
|
+
/******/
|
36
|
+
/******/ // define getter function for harmony exports
|
37
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
38
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
39
|
+
/******/ Object.defineProperty(exports, name, {
|
40
|
+
/******/ configurable: false,
|
41
|
+
/******/ enumerable: true,
|
42
|
+
/******/ get: getter
|
43
|
+
/******/ });
|
44
|
+
/******/ }
|
45
|
+
/******/ };
|
46
|
+
/******/
|
47
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
48
|
+
/******/ __webpack_require__.n = function(module) {
|
49
|
+
/******/ var getter = module && module.__esModule ?
|
50
|
+
/******/ function getDefault() { return module['default']; } :
|
51
|
+
/******/ function getModuleExports() { return module; };
|
52
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
53
|
+
/******/ return getter;
|
54
|
+
/******/ };
|
55
|
+
/******/
|
56
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
57
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
58
|
+
/******/
|
59
|
+
/******/ // __webpack_public_path__
|
60
|
+
/******/ __webpack_require__.p = "";
|
61
|
+
/******/
|
62
|
+
/******/ // Load entry module and return exports
|
63
|
+
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
64
|
+
/******/ })
|
65
|
+
/************************************************************************/
|
66
|
+
/******/ ([
|
67
|
+
/* 0 */
|
68
|
+
/***/ (function(module, exports, __webpack_require__) {
|
69
|
+
|
70
|
+
"use strict";
|
71
|
+
|
72
|
+
|
73
|
+
Object.defineProperty(exports, "__esModule", {
|
74
|
+
value: true
|
75
|
+
});
|
76
|
+
|
77
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
78
|
+
|
79
|
+
__webpack_require__(1);
|
80
|
+
|
81
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
82
|
+
|
83
|
+
/***************
|
84
|
+
Snackbar.js
|
85
|
+
https://github.com/cdimoulis/snackbar.js
|
86
|
+
|
87
|
+
A simple implementation of the snackbar message pops up at the bottom of the page.
|
88
|
+
|
89
|
+
view README.md for more in depth documentation
|
90
|
+
|
91
|
+
All options passed when creating the snackbar object are default. Overrides can
|
92
|
+
be passed in each call to display a message.
|
93
|
+
|
94
|
+
Usage:
|
95
|
+
Create a new snackbar ->
|
96
|
+
var snack = new Snackbar();
|
97
|
+
Display a message ->
|
98
|
+
snack.message('Hello World');
|
99
|
+
|
100
|
+
Helper functions:
|
101
|
+
Display a message that must be removed manually ->
|
102
|
+
snack.stickyMessage('Acknowledge me!');
|
103
|
+
Display a message with a green background (adds class 'success') ->
|
104
|
+
snack.success('You did it!');
|
105
|
+
Display a message with a red backbround (adds class 'error') ->
|
106
|
+
snack.error("Something didn't work");
|
107
|
+
Display a message with a orangish/yellow backbround (adds class 'warn') ->
|
108
|
+
snack.warn("I'd be careful if I were you...");
|
109
|
+
|
110
|
+
****************/
|
111
|
+
|
112
|
+
var Snackbar = function () {
|
113
|
+
/************
|
114
|
+
Feature wide options. These options will be set at all time unless
|
115
|
+
overridden by options passed in each call
|
116
|
+
manual_close: Boolean. Provide a close X button (true) vs timed close (false)
|
117
|
+
Default: false
|
118
|
+
time: ms of time before automatic close. (ignored if manual_close: true)
|
119
|
+
Default: 5000
|
120
|
+
class: String containing desired classes.
|
121
|
+
Default: null
|
122
|
+
************/
|
123
|
+
function Snackbar(options) {
|
124
|
+
_classCallCheck(this, Snackbar);
|
125
|
+
|
126
|
+
this.options = options || { manual_close: false, time: 5000 };
|
127
|
+
// If called before DOM is ready then maintain list to execute;
|
128
|
+
this.pre_dom_queue = [];
|
129
|
+
|
130
|
+
// Setup DOM
|
131
|
+
this._setDom();
|
132
|
+
}
|
133
|
+
|
134
|
+
/**********
|
135
|
+
/ PUBLIC FUNCTIONS
|
136
|
+
/**********/
|
137
|
+
|
138
|
+
// Main function to display the snackbar
|
139
|
+
// message: text to display
|
140
|
+
// opt: default override options to send
|
141
|
+
// Returns a promise that will resolve when fully faded in OR
|
142
|
+
// null if it cannot be added yet
|
143
|
+
|
144
|
+
|
145
|
+
_createClass(Snackbar, [{
|
146
|
+
key: 'message',
|
147
|
+
value: function message(_message, opts) {
|
148
|
+
var _this2 = this;
|
149
|
+
|
150
|
+
opts = Object.assign({}, this.options, opts);
|
151
|
+
var _snackbar = this._addSnackbar(_message, opts);
|
152
|
+
// Show if _snackbar Element is created
|
153
|
+
if (_snackbar) {
|
154
|
+
|
155
|
+
// Fade in and when complete set timeout for fade out if not manual close
|
156
|
+
return _fadeIn(_snackbar).then(function () {
|
157
|
+
_this2._setClose(_snackbar, opts);
|
158
|
+
});
|
159
|
+
}
|
160
|
+
// Add to queue to show after DOM is ready
|
161
|
+
else {
|
162
|
+
this.pre_dom_queue.push({ snackbar: this, message: _message, opts: opts });
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
// Helper for message that sticks until manually closed
|
167
|
+
// message: text to display
|
168
|
+
// opt: default override options to send
|
169
|
+
// Returns a promise that will resolve when fully faded in OR
|
170
|
+
// null if it cannot be added yet
|
171
|
+
|
172
|
+
}, {
|
173
|
+
key: 'stickyMessage',
|
174
|
+
value: function stickyMessage(message, opts) {
|
175
|
+
opts = Object.assign({}, this.options, opts);
|
176
|
+
opts.manual_close = true;
|
177
|
+
return this.message(message, opts);
|
178
|
+
}
|
179
|
+
|
180
|
+
// Helper for success snackbar
|
181
|
+
// message: text to display
|
182
|
+
// opt: default override options to send
|
183
|
+
// Returns a promise that will resolve when fully faded in OR
|
184
|
+
// null if it cannot be added yet
|
185
|
+
|
186
|
+
}, {
|
187
|
+
key: 'success',
|
188
|
+
value: function success(message, opts) {
|
189
|
+
opts = Object.assign({}, this.options, opts);
|
190
|
+
opts.class = opts.class || '';
|
191
|
+
opts.class += ' success';
|
192
|
+
return this.message(message, opts);
|
193
|
+
}
|
194
|
+
|
195
|
+
// Helper for error snackbar
|
196
|
+
// message: text to display
|
197
|
+
// opt: default override options to send
|
198
|
+
// Returns a promise that will resolve when fully faded in OR
|
199
|
+
// null if it cannot be added yet
|
200
|
+
|
201
|
+
}, {
|
202
|
+
key: 'error',
|
203
|
+
value: function error(message, opts) {
|
204
|
+
opts = Object.assign({}, this.options, opts);
|
205
|
+
opts.class = opts.class || '';
|
206
|
+
opts.class += ' error';
|
207
|
+
return this.message(message, opts);
|
208
|
+
}
|
209
|
+
|
210
|
+
// Helper for warn snackbar
|
211
|
+
// message: text to display
|
212
|
+
// opt: default override options to send
|
213
|
+
// Returns a promise that will resolve when fully faded in OR
|
214
|
+
// null if it cannot be added yet
|
215
|
+
|
216
|
+
}, {
|
217
|
+
key: 'warn',
|
218
|
+
value: function warn(message, opts) {
|
219
|
+
opts = Object.assign({}, this.options, opts);
|
220
|
+
opts.class = opts.class || '';
|
221
|
+
opts.class += ' warn';
|
222
|
+
return this.message(message, opts);
|
223
|
+
}
|
224
|
+
|
225
|
+
/********
|
226
|
+
/ END PUBLIC FUNCTIONS
|
227
|
+
*********/
|
228
|
+
|
229
|
+
/**********
|
230
|
+
/ PRIVATE FUNCTIONS
|
231
|
+
/**********/
|
232
|
+
|
233
|
+
// Set the timeout for closing the snackbar if not opts.manual_close
|
234
|
+
|
235
|
+
}, {
|
236
|
+
key: '_setClose',
|
237
|
+
value: function _setClose(snackbar, opts) {
|
238
|
+
var _this3 = this;
|
239
|
+
|
240
|
+
// If not manual_close then set timeout for removal
|
241
|
+
return new Promise(function (resolve, reject) {
|
242
|
+
if (!opts.manual_close) {
|
243
|
+
setTimeout(function () {
|
244
|
+
_this3._removeSnackbar(snackbar).then(function () {
|
245
|
+
resolve();
|
246
|
+
});
|
247
|
+
}, opts.time);
|
248
|
+
} else {
|
249
|
+
resolve();
|
250
|
+
}
|
251
|
+
});
|
252
|
+
}
|
253
|
+
|
254
|
+
// Setup the elemends on the DOM
|
255
|
+
|
256
|
+
}, {
|
257
|
+
key: '_setDom',
|
258
|
+
value: function _setDom() {
|
259
|
+
var _this4 = this;
|
260
|
+
|
261
|
+
var _body = document.getElementsByTagName('body')[0];
|
262
|
+
// If the Body exists
|
263
|
+
if (_body) {
|
264
|
+
// Add snackbar if not in DOM already
|
265
|
+
if (!document.getElementById('snackbar-wrapper')) {
|
266
|
+
var _outer_wrapper = document.createElement('div');
|
267
|
+
_outer_wrapper.id = 'snackbar-wrapper';
|
268
|
+
_body.appendChild(_outer_wrapper);
|
269
|
+
}
|
270
|
+
if (this.pre_dom_queue.length > 0) this._flushQueue();
|
271
|
+
}
|
272
|
+
// if body is not available then call when DOM is ready
|
273
|
+
else {
|
274
|
+
_ready(function () {
|
275
|
+
_this4._setDom();
|
276
|
+
});
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}, {
|
280
|
+
key: '_flushQueue',
|
281
|
+
|
282
|
+
|
283
|
+
// Flush out the pre_dom_queue
|
284
|
+
value: function _flushQueue() {
|
285
|
+
for (var i = 0; i < this.pre_dom_queue.length; i++) {
|
286
|
+
var sb = this.pre_dom_queue[i];
|
287
|
+
sb.snackbar.message(sb.message, sb.opts);
|
288
|
+
}
|
289
|
+
this.pre_dom_queue = [];
|
290
|
+
}
|
291
|
+
}, {
|
292
|
+
key: '_addSnackbar',
|
293
|
+
|
294
|
+
|
295
|
+
// Add the snackbar
|
296
|
+
// message: text to display
|
297
|
+
// opt: options to send
|
298
|
+
value: function _addSnackbar(message, opts) {
|
299
|
+
var _this5 = this;
|
300
|
+
|
301
|
+
var _this = this;
|
302
|
+
var _snackbar_wrapper = document.getElementById('snackbar-wrapper');
|
303
|
+
// Only create snackbar if snackbar wrapper is in DOM
|
304
|
+
if (_snackbar_wrapper) {
|
305
|
+
var _snackbar = document.createElement('div');
|
306
|
+
// Class names for snackbar element
|
307
|
+
var snk_bar_class = 'snackbar';
|
308
|
+
// Add option classes to snackbar
|
309
|
+
if (opts.class) {
|
310
|
+
snk_bar_class += ' ' + opts.class;
|
311
|
+
}
|
312
|
+
_snackbar.className = snk_bar_class;
|
313
|
+
|
314
|
+
// Text node
|
315
|
+
var _text_wrapper = document.createElement('span');
|
316
|
+
_text_wrapper.className = 'snackbar-text';
|
317
|
+
_text_wrapper.appendChild(document.createTextNode(message));
|
318
|
+
_snackbar.appendChild(_text_wrapper);
|
319
|
+
// Add X for manual close
|
320
|
+
if (opts.manual_close) {
|
321
|
+
var _close = document.createElement('span');
|
322
|
+
_close.className = 'snackbar-close';
|
323
|
+
var _x = document.createTextNode('X');
|
324
|
+
_close.appendChild(_x);
|
325
|
+
// Apply click event for X
|
326
|
+
_close.onclick = function () {
|
327
|
+
// Returns the promise from removing snackbar
|
328
|
+
return _this5._removeSnackbar(_snackbar);
|
329
|
+
};
|
330
|
+
_snackbar.appendChild(_close);
|
331
|
+
}
|
332
|
+
_snackbar_wrapper.appendChild(_snackbar);
|
333
|
+
return _snackbar;
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}, {
|
337
|
+
key: '_removeSnackbar',
|
338
|
+
|
339
|
+
|
340
|
+
// Remove a snackbar
|
341
|
+
value: function _removeSnackbar(_el) {
|
342
|
+
// _fadeOut returns a promise to use for completion
|
343
|
+
return _fadeOut(_el).then(function () {
|
344
|
+
_el.remove();
|
345
|
+
});
|
346
|
+
}
|
347
|
+
}]);
|
348
|
+
|
349
|
+
return Snackbar;
|
350
|
+
}();
|
351
|
+
|
352
|
+
/**********
|
353
|
+
/ END PRIVATE FUNCTIONS
|
354
|
+
/**********/
|
355
|
+
;
|
356
|
+
|
357
|
+
/*******
|
358
|
+
* Helper FUNCTIONS
|
359
|
+
*******/
|
360
|
+
|
361
|
+
// Fade in individual snackbar
|
362
|
+
// Returns a promise to use for completion
|
363
|
+
function _fadeIn(_el) {
|
364
|
+
// Change opacity returns a promise so we are passing that up
|
365
|
+
return _changeOpacity(_el, 1, 500);
|
366
|
+
};
|
367
|
+
|
368
|
+
// Fade out individual snackbar
|
369
|
+
// Returns a promise to use for completion
|
370
|
+
function _fadeOut(_el) {
|
371
|
+
// Change opacity returns a promise so we are passing that up
|
372
|
+
return _changeOpacity(_el, 0, 500);
|
373
|
+
};
|
374
|
+
|
375
|
+
// Change opacity
|
376
|
+
// _el: element
|
377
|
+
// value: the opacity value
|
378
|
+
// time: the amount of time
|
379
|
+
// Returns a promise to use for completion
|
380
|
+
function _changeOpacity(_el, value, time) {
|
381
|
+
// rate of change
|
382
|
+
var fps = 24;
|
383
|
+
var time_per_frame = time / fps;
|
384
|
+
// current opacity
|
385
|
+
var current_opacity = parseFloat(_el.style.opacity) || 0;
|
386
|
+
// change for opacity
|
387
|
+
var diff = value - current_opacity;
|
388
|
+
var delta = diff / time_per_frame;
|
389
|
+
|
390
|
+
// Return a promise so we know when this is done
|
391
|
+
return new Promise(function (resolve, reject) {
|
392
|
+
var interval = setInterval(change, time_per_frame);
|
393
|
+
function change() {
|
394
|
+
// Set new opacity
|
395
|
+
current_opacity += delta;
|
396
|
+
current_opacity = current_opacity < 0 ? 0 : current_opacity;
|
397
|
+
current_opacity = current_opacity > 1 ? 1 : current_opacity;
|
398
|
+
_el.style.opacity = current_opacity;
|
399
|
+
// Check if done
|
400
|
+
if (current_opacity === 1 || current_opacity === 0) {
|
401
|
+
// End interval and resolve the promise
|
402
|
+
clearInterval(interval);
|
403
|
+
resolve();
|
404
|
+
}
|
405
|
+
}
|
406
|
+
});
|
407
|
+
};
|
408
|
+
|
409
|
+
// Callback when DOM is ready
|
410
|
+
function _ready(cb) {
|
411
|
+
// If add event listener is available
|
412
|
+
if (document.addEventListener) {
|
413
|
+
document.addEventListener('DOMContentLoaded', function () {
|
414
|
+
document.removeEventListener('DOMContentLoaded', this.callee);
|
415
|
+
cb();
|
416
|
+
});
|
417
|
+
}
|
418
|
+
// Otherwise attach the state change event
|
419
|
+
else if (document.attachEvent) {
|
420
|
+
document.attachEvent('onreadystatechange', function () {
|
421
|
+
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
422
|
+
document.detachEvent('onreadystatechange', this.callee);
|
423
|
+
cb();
|
424
|
+
}
|
425
|
+
});
|
426
|
+
}
|
427
|
+
};
|
428
|
+
|
429
|
+
window.Snackbar = Snackbar;
|
430
|
+
|
431
|
+
exports.default = Snackbar;
|
432
|
+
|
433
|
+
/***/ }),
|
434
|
+
/* 1 */
|
435
|
+
/***/ (function(module, exports, __webpack_require__) {
|
436
|
+
|
437
|
+
// style-loader: Adds some css to the DOM by adding a <style> tag
|
438
|
+
|
439
|
+
// load the styles
|
440
|
+
var content = __webpack_require__(2);
|
441
|
+
if(typeof content === 'string') content = [[module.i, content, '']];
|
442
|
+
// Prepare cssTransformation
|
443
|
+
var transform;
|
444
|
+
|
445
|
+
var options = {"hmr":true}
|
446
|
+
options.transform = transform
|
447
|
+
// add the styles to the DOM
|
448
|
+
var update = __webpack_require__(4)(content, options);
|
449
|
+
if(content.locals) module.exports = content.locals;
|
450
|
+
// Hot Module Replacement
|
451
|
+
if(false) {
|
452
|
+
// When the styles change, update the <style> tags
|
453
|
+
if(!content.locals) {
|
454
|
+
module.hot.accept("!!../node_modules/css-loader/index.js!../node_modules/sass-loader/lib/loader.js??ref--1-2!./snackbar.scss", function() {
|
455
|
+
var newContent = require("!!../node_modules/css-loader/index.js!../node_modules/sass-loader/lib/loader.js??ref--1-2!./snackbar.scss");
|
456
|
+
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
|
457
|
+
update(newContent);
|
458
|
+
});
|
459
|
+
}
|
460
|
+
// When the module is disposed, remove the <style> tags
|
461
|
+
module.hot.dispose(function() { update(); });
|
462
|
+
}
|
463
|
+
|
464
|
+
/***/ }),
|
465
|
+
/* 2 */
|
466
|
+
/***/ (function(module, exports, __webpack_require__) {
|
467
|
+
|
468
|
+
exports = module.exports = __webpack_require__(3)(undefined);
|
469
|
+
// imports
|
470
|
+
|
471
|
+
|
472
|
+
// module
|
473
|
+
exports.push([module.i, "#snackbar-wrapper {\n width: 100%;\n position: fixed;\n z-index: 999;\n bottom: 0px;\n display: block; }\n #snackbar-wrapper .snackbar {\n opacity: 0;\n width: 105%;\n margin-left: -2.5%;\n background-color: #333;\n color: #fff;\n text-align: center;\n font-size: 17px;\n padding: 16px; }\n #snackbar-wrapper .snackbar-close {\n width: 12%;\n cursor: pointer;\n display: block;\n top: .1em;\n float: right;\n margin-right: 3%; }\n #snackbar-wrapper .snackbar-text {\n width: 85%;\n display: inline-block; }\n #snackbar-wrapper .success {\n background-color: #228822; }\n #snackbar-wrapper .error {\n background-color: #bb2222; }\n #snackbar-wrapper .warn {\n background-color: #f3b300; }\n #snackbar-wrapper span.snackbar-close {\n font-family: sans-serif;\n font-weight: bolder;\n font-size: inherit;\n text-rendering: auto;\n -webkit-font-smoothing: antialiased; }\n", ""]);
|
474
|
+
|
475
|
+
// exports
|
476
|
+
|
477
|
+
|
478
|
+
/***/ }),
|
479
|
+
/* 3 */
|
480
|
+
/***/ (function(module, exports) {
|
481
|
+
|
482
|
+
/*
|
483
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
484
|
+
Author Tobias Koppers @sokra
|
485
|
+
*/
|
486
|
+
// css base code, injected by the css-loader
|
487
|
+
module.exports = function(useSourceMap) {
|
488
|
+
var list = [];
|
489
|
+
|
490
|
+
// return the list of modules as css string
|
491
|
+
list.toString = function toString() {
|
492
|
+
return this.map(function (item) {
|
493
|
+
var content = cssWithMappingToString(item, useSourceMap);
|
494
|
+
if(item[2]) {
|
495
|
+
return "@media " + item[2] + "{" + content + "}";
|
496
|
+
} else {
|
497
|
+
return content;
|
498
|
+
}
|
499
|
+
}).join("");
|
500
|
+
};
|
501
|
+
|
502
|
+
// import a list of modules into the list
|
503
|
+
list.i = function(modules, mediaQuery) {
|
504
|
+
if(typeof modules === "string")
|
505
|
+
modules = [[null, modules, ""]];
|
506
|
+
var alreadyImportedModules = {};
|
507
|
+
for(var i = 0; i < this.length; i++) {
|
508
|
+
var id = this[i][0];
|
509
|
+
if(typeof id === "number")
|
510
|
+
alreadyImportedModules[id] = true;
|
511
|
+
}
|
512
|
+
for(i = 0; i < modules.length; i++) {
|
513
|
+
var item = modules[i];
|
514
|
+
// skip already imported module
|
515
|
+
// this implementation is not 100% perfect for weird media query combinations
|
516
|
+
// when a module is imported multiple times with different media queries.
|
517
|
+
// I hope this will never occur (Hey this way we have smaller bundles)
|
518
|
+
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
|
519
|
+
if(mediaQuery && !item[2]) {
|
520
|
+
item[2] = mediaQuery;
|
521
|
+
} else if(mediaQuery) {
|
522
|
+
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
|
523
|
+
}
|
524
|
+
list.push(item);
|
525
|
+
}
|
526
|
+
}
|
527
|
+
};
|
528
|
+
return list;
|
529
|
+
};
|
530
|
+
|
531
|
+
function cssWithMappingToString(item, useSourceMap) {
|
532
|
+
var content = item[1] || '';
|
533
|
+
var cssMapping = item[3];
|
534
|
+
if (!cssMapping) {
|
535
|
+
return content;
|
536
|
+
}
|
537
|
+
|
538
|
+
if (useSourceMap && typeof btoa === 'function') {
|
539
|
+
var sourceMapping = toComment(cssMapping);
|
540
|
+
var sourceURLs = cssMapping.sources.map(function (source) {
|
541
|
+
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
|
542
|
+
});
|
543
|
+
|
544
|
+
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
|
545
|
+
}
|
546
|
+
|
547
|
+
return [content].join('\n');
|
548
|
+
}
|
549
|
+
|
550
|
+
// Adapted from convert-source-map (MIT)
|
551
|
+
function toComment(sourceMap) {
|
552
|
+
// eslint-disable-next-line no-undef
|
553
|
+
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
554
|
+
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
|
555
|
+
|
556
|
+
return '/*# ' + data + ' */';
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
/***/ }),
|
561
|
+
/* 4 */
|
562
|
+
/***/ (function(module, exports, __webpack_require__) {
|
563
|
+
|
564
|
+
/*
|
565
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
566
|
+
Author Tobias Koppers @sokra
|
567
|
+
*/
|
568
|
+
|
569
|
+
var stylesInDom = {};
|
570
|
+
|
571
|
+
var memoize = function (fn) {
|
572
|
+
var memo;
|
573
|
+
|
574
|
+
return function () {
|
575
|
+
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
|
576
|
+
return memo;
|
577
|
+
};
|
578
|
+
};
|
579
|
+
|
580
|
+
var isOldIE = memoize(function () {
|
581
|
+
// Test for IE <= 9 as proposed by Browserhacks
|
582
|
+
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
|
583
|
+
// Tests for existence of standard globals is to allow style-loader
|
584
|
+
// to operate correctly into non-standard environments
|
585
|
+
// @see https://github.com/webpack-contrib/style-loader/issues/177
|
586
|
+
return window && document && document.all && !window.atob;
|
587
|
+
});
|
588
|
+
|
589
|
+
var getElement = (function (fn) {
|
590
|
+
var memo = {};
|
591
|
+
|
592
|
+
return function(selector) {
|
593
|
+
if (typeof memo[selector] === "undefined") {
|
594
|
+
var styleTarget = fn.call(this, selector);
|
595
|
+
// Special case to return head of iframe instead of iframe itself
|
596
|
+
if (styleTarget instanceof window.HTMLIFrameElement) {
|
597
|
+
try {
|
598
|
+
// This will throw an exception if access to iframe is blocked
|
599
|
+
// due to cross-origin restrictions
|
600
|
+
styleTarget = styleTarget.contentDocument.head;
|
601
|
+
} catch(e) {
|
602
|
+
styleTarget = null;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
memo[selector] = styleTarget;
|
606
|
+
}
|
607
|
+
return memo[selector]
|
608
|
+
};
|
609
|
+
})(function (target) {
|
610
|
+
return document.querySelector(target)
|
611
|
+
});
|
612
|
+
|
613
|
+
var singleton = null;
|
614
|
+
var singletonCounter = 0;
|
615
|
+
var stylesInsertedAtTop = [];
|
616
|
+
|
617
|
+
var fixUrls = __webpack_require__(5);
|
618
|
+
|
619
|
+
module.exports = function(list, options) {
|
620
|
+
if (typeof DEBUG !== "undefined" && DEBUG) {
|
621
|
+
if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
|
622
|
+
}
|
623
|
+
|
624
|
+
options = options || {};
|
625
|
+
|
626
|
+
options.attrs = typeof options.attrs === "object" ? options.attrs : {};
|
627
|
+
|
628
|
+
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
|
629
|
+
// tags it will allow on a page
|
630
|
+
if (!options.singleton) options.singleton = isOldIE();
|
631
|
+
|
632
|
+
// By default, add <style> tags to the <head> element
|
633
|
+
if (!options.insertInto) options.insertInto = "head";
|
634
|
+
|
635
|
+
// By default, add <style> tags to the bottom of the target
|
636
|
+
if (!options.insertAt) options.insertAt = "bottom";
|
637
|
+
|
638
|
+
var styles = listToStyles(list, options);
|
639
|
+
|
640
|
+
addStylesToDom(styles, options);
|
641
|
+
|
642
|
+
return function update (newList) {
|
643
|
+
var mayRemove = [];
|
644
|
+
|
645
|
+
for (var i = 0; i < styles.length; i++) {
|
646
|
+
var item = styles[i];
|
647
|
+
var domStyle = stylesInDom[item.id];
|
648
|
+
|
649
|
+
domStyle.refs--;
|
650
|
+
mayRemove.push(domStyle);
|
651
|
+
}
|
652
|
+
|
653
|
+
if(newList) {
|
654
|
+
var newStyles = listToStyles(newList, options);
|
655
|
+
addStylesToDom(newStyles, options);
|
656
|
+
}
|
657
|
+
|
658
|
+
for (var i = 0; i < mayRemove.length; i++) {
|
659
|
+
var domStyle = mayRemove[i];
|
660
|
+
|
661
|
+
if(domStyle.refs === 0) {
|
662
|
+
for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
|
663
|
+
|
664
|
+
delete stylesInDom[domStyle.id];
|
665
|
+
}
|
666
|
+
}
|
667
|
+
};
|
668
|
+
};
|
669
|
+
|
670
|
+
function addStylesToDom (styles, options) {
|
671
|
+
for (var i = 0; i < styles.length; i++) {
|
672
|
+
var item = styles[i];
|
673
|
+
var domStyle = stylesInDom[item.id];
|
674
|
+
|
675
|
+
if(domStyle) {
|
676
|
+
domStyle.refs++;
|
677
|
+
|
678
|
+
for(var j = 0; j < domStyle.parts.length; j++) {
|
679
|
+
domStyle.parts[j](item.parts[j]);
|
680
|
+
}
|
681
|
+
|
682
|
+
for(; j < item.parts.length; j++) {
|
683
|
+
domStyle.parts.push(addStyle(item.parts[j], options));
|
684
|
+
}
|
685
|
+
} else {
|
686
|
+
var parts = [];
|
687
|
+
|
688
|
+
for(var j = 0; j < item.parts.length; j++) {
|
689
|
+
parts.push(addStyle(item.parts[j], options));
|
690
|
+
}
|
691
|
+
|
692
|
+
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
|
693
|
+
}
|
694
|
+
}
|
695
|
+
}
|
696
|
+
|
697
|
+
function listToStyles (list, options) {
|
698
|
+
var styles = [];
|
699
|
+
var newStyles = {};
|
700
|
+
|
701
|
+
for (var i = 0; i < list.length; i++) {
|
702
|
+
var item = list[i];
|
703
|
+
var id = options.base ? item[0] + options.base : item[0];
|
704
|
+
var css = item[1];
|
705
|
+
var media = item[2];
|
706
|
+
var sourceMap = item[3];
|
707
|
+
var part = {css: css, media: media, sourceMap: sourceMap};
|
708
|
+
|
709
|
+
if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
|
710
|
+
else newStyles[id].parts.push(part);
|
711
|
+
}
|
712
|
+
|
713
|
+
return styles;
|
714
|
+
}
|
715
|
+
|
716
|
+
function insertStyleElement (options, style) {
|
717
|
+
var target = getElement(options.insertInto)
|
718
|
+
|
719
|
+
if (!target) {
|
720
|
+
throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
|
721
|
+
}
|
722
|
+
|
723
|
+
var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
|
724
|
+
|
725
|
+
if (options.insertAt === "top") {
|
726
|
+
if (!lastStyleElementInsertedAtTop) {
|
727
|
+
target.insertBefore(style, target.firstChild);
|
728
|
+
} else if (lastStyleElementInsertedAtTop.nextSibling) {
|
729
|
+
target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
|
730
|
+
} else {
|
731
|
+
target.appendChild(style);
|
732
|
+
}
|
733
|
+
stylesInsertedAtTop.push(style);
|
734
|
+
} else if (options.insertAt === "bottom") {
|
735
|
+
target.appendChild(style);
|
736
|
+
} else if (typeof options.insertAt === "object" && options.insertAt.before) {
|
737
|
+
var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
|
738
|
+
target.insertBefore(style, nextSibling);
|
739
|
+
} else {
|
740
|
+
throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
|
741
|
+
}
|
742
|
+
}
|
743
|
+
|
744
|
+
function removeStyleElement (style) {
|
745
|
+
if (style.parentNode === null) return false;
|
746
|
+
style.parentNode.removeChild(style);
|
747
|
+
|
748
|
+
var idx = stylesInsertedAtTop.indexOf(style);
|
749
|
+
if(idx >= 0) {
|
750
|
+
stylesInsertedAtTop.splice(idx, 1);
|
751
|
+
}
|
752
|
+
}
|
753
|
+
|
754
|
+
function createStyleElement (options) {
|
755
|
+
var style = document.createElement("style");
|
756
|
+
|
757
|
+
options.attrs.type = "text/css";
|
758
|
+
|
759
|
+
addAttrs(style, options.attrs);
|
760
|
+
insertStyleElement(options, style);
|
761
|
+
|
762
|
+
return style;
|
763
|
+
}
|
764
|
+
|
765
|
+
function createLinkElement (options) {
|
766
|
+
var link = document.createElement("link");
|
767
|
+
|
768
|
+
options.attrs.type = "text/css";
|
769
|
+
options.attrs.rel = "stylesheet";
|
770
|
+
|
771
|
+
addAttrs(link, options.attrs);
|
772
|
+
insertStyleElement(options, link);
|
773
|
+
|
774
|
+
return link;
|
775
|
+
}
|
776
|
+
|
777
|
+
function addAttrs (el, attrs) {
|
778
|
+
Object.keys(attrs).forEach(function (key) {
|
779
|
+
el.setAttribute(key, attrs[key]);
|
780
|
+
});
|
781
|
+
}
|
782
|
+
|
783
|
+
function addStyle (obj, options) {
|
784
|
+
var style, update, remove, result;
|
785
|
+
|
786
|
+
// If a transform function was defined, run it on the css
|
787
|
+
if (options.transform && obj.css) {
|
788
|
+
result = options.transform(obj.css);
|
789
|
+
|
790
|
+
if (result) {
|
791
|
+
// If transform returns a value, use that instead of the original css.
|
792
|
+
// This allows running runtime transformations on the css.
|
793
|
+
obj.css = result;
|
794
|
+
} else {
|
795
|
+
// If the transform function returns a falsy value, don't add this css.
|
796
|
+
// This allows conditional loading of css
|
797
|
+
return function() {
|
798
|
+
// noop
|
799
|
+
};
|
800
|
+
}
|
801
|
+
}
|
802
|
+
|
803
|
+
if (options.singleton) {
|
804
|
+
var styleIndex = singletonCounter++;
|
805
|
+
|
806
|
+
style = singleton || (singleton = createStyleElement(options));
|
807
|
+
|
808
|
+
update = applyToSingletonTag.bind(null, style, styleIndex, false);
|
809
|
+
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
|
810
|
+
|
811
|
+
} else if (
|
812
|
+
obj.sourceMap &&
|
813
|
+
typeof URL === "function" &&
|
814
|
+
typeof URL.createObjectURL === "function" &&
|
815
|
+
typeof URL.revokeObjectURL === "function" &&
|
816
|
+
typeof Blob === "function" &&
|
817
|
+
typeof btoa === "function"
|
818
|
+
) {
|
819
|
+
style = createLinkElement(options);
|
820
|
+
update = updateLink.bind(null, style, options);
|
821
|
+
remove = function () {
|
822
|
+
removeStyleElement(style);
|
823
|
+
|
824
|
+
if(style.href) URL.revokeObjectURL(style.href);
|
825
|
+
};
|
826
|
+
} else {
|
827
|
+
style = createStyleElement(options);
|
828
|
+
update = applyToTag.bind(null, style);
|
829
|
+
remove = function () {
|
830
|
+
removeStyleElement(style);
|
831
|
+
};
|
832
|
+
}
|
833
|
+
|
834
|
+
update(obj);
|
835
|
+
|
836
|
+
return function updateStyle (newObj) {
|
837
|
+
if (newObj) {
|
838
|
+
if (
|
839
|
+
newObj.css === obj.css &&
|
840
|
+
newObj.media === obj.media &&
|
841
|
+
newObj.sourceMap === obj.sourceMap
|
842
|
+
) {
|
843
|
+
return;
|
844
|
+
}
|
845
|
+
|
846
|
+
update(obj = newObj);
|
847
|
+
} else {
|
848
|
+
remove();
|
849
|
+
}
|
850
|
+
};
|
851
|
+
}
|
852
|
+
|
853
|
+
var replaceText = (function () {
|
854
|
+
var textStore = [];
|
855
|
+
|
856
|
+
return function (index, replacement) {
|
857
|
+
textStore[index] = replacement;
|
858
|
+
|
859
|
+
return textStore.filter(Boolean).join('\n');
|
860
|
+
};
|
861
|
+
})();
|
862
|
+
|
863
|
+
function applyToSingletonTag (style, index, remove, obj) {
|
864
|
+
var css = remove ? "" : obj.css;
|
865
|
+
|
866
|
+
if (style.styleSheet) {
|
867
|
+
style.styleSheet.cssText = replaceText(index, css);
|
868
|
+
} else {
|
869
|
+
var cssNode = document.createTextNode(css);
|
870
|
+
var childNodes = style.childNodes;
|
871
|
+
|
872
|
+
if (childNodes[index]) style.removeChild(childNodes[index]);
|
873
|
+
|
874
|
+
if (childNodes.length) {
|
875
|
+
style.insertBefore(cssNode, childNodes[index]);
|
876
|
+
} else {
|
877
|
+
style.appendChild(cssNode);
|
878
|
+
}
|
879
|
+
}
|
880
|
+
}
|
881
|
+
|
882
|
+
function applyToTag (style, obj) {
|
883
|
+
var css = obj.css;
|
884
|
+
var media = obj.media;
|
885
|
+
|
886
|
+
if(media) {
|
887
|
+
style.setAttribute("media", media)
|
888
|
+
}
|
889
|
+
|
890
|
+
if(style.styleSheet) {
|
891
|
+
style.styleSheet.cssText = css;
|
892
|
+
} else {
|
893
|
+
while(style.firstChild) {
|
894
|
+
style.removeChild(style.firstChild);
|
895
|
+
}
|
896
|
+
|
897
|
+
style.appendChild(document.createTextNode(css));
|
898
|
+
}
|
899
|
+
}
|
900
|
+
|
901
|
+
function updateLink (link, options, obj) {
|
902
|
+
var css = obj.css;
|
903
|
+
var sourceMap = obj.sourceMap;
|
904
|
+
|
905
|
+
/*
|
906
|
+
If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
|
907
|
+
and there is no publicPath defined then lets turn convertToAbsoluteUrls
|
908
|
+
on by default. Otherwise default to the convertToAbsoluteUrls option
|
909
|
+
directly
|
910
|
+
*/
|
911
|
+
var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
|
912
|
+
|
913
|
+
if (options.convertToAbsoluteUrls || autoFixUrls) {
|
914
|
+
css = fixUrls(css);
|
915
|
+
}
|
916
|
+
|
917
|
+
if (sourceMap) {
|
918
|
+
// http://stackoverflow.com/a/26603875
|
919
|
+
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
|
920
|
+
}
|
921
|
+
|
922
|
+
var blob = new Blob([css], { type: "text/css" });
|
923
|
+
|
924
|
+
var oldSrc = link.href;
|
925
|
+
|
926
|
+
link.href = URL.createObjectURL(blob);
|
927
|
+
|
928
|
+
if(oldSrc) URL.revokeObjectURL(oldSrc);
|
929
|
+
}
|
930
|
+
|
931
|
+
|
932
|
+
/***/ }),
|
933
|
+
/* 5 */
|
934
|
+
/***/ (function(module, exports) {
|
935
|
+
|
936
|
+
|
937
|
+
/**
|
938
|
+
* When source maps are enabled, `style-loader` uses a link element with a data-uri to
|
939
|
+
* embed the css on the page. This breaks all relative urls because now they are relative to a
|
940
|
+
* bundle instead of the current page.
|
941
|
+
*
|
942
|
+
* One solution is to only use full urls, but that may be impossible.
|
943
|
+
*
|
944
|
+
* Instead, this function "fixes" the relative urls to be absolute according to the current page location.
|
945
|
+
*
|
946
|
+
* A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
|
947
|
+
*
|
948
|
+
*/
|
949
|
+
|
950
|
+
module.exports = function (css) {
|
951
|
+
// get current location
|
952
|
+
var location = typeof window !== "undefined" && window.location;
|
953
|
+
|
954
|
+
if (!location) {
|
955
|
+
throw new Error("fixUrls requires window.location");
|
956
|
+
}
|
957
|
+
|
958
|
+
// blank or null?
|
959
|
+
if (!css || typeof css !== "string") {
|
960
|
+
return css;
|
961
|
+
}
|
962
|
+
|
963
|
+
var baseUrl = location.protocol + "//" + location.host;
|
964
|
+
var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
|
965
|
+
|
966
|
+
// convert each url(...)
|
967
|
+
/*
|
968
|
+
This regular expression is just a way to recursively match brackets within
|
969
|
+
a string.
|
970
|
+
|
971
|
+
/url\s*\( = Match on the word "url" with any whitespace after it and then a parens
|
972
|
+
( = Start a capturing group
|
973
|
+
(?: = Start a non-capturing group
|
974
|
+
[^)(] = Match anything that isn't a parentheses
|
975
|
+
| = OR
|
976
|
+
\( = Match a start parentheses
|
977
|
+
(?: = Start another non-capturing groups
|
978
|
+
[^)(]+ = Match anything that isn't a parentheses
|
979
|
+
| = OR
|
980
|
+
\( = Match a start parentheses
|
981
|
+
[^)(]* = Match anything that isn't a parentheses
|
982
|
+
\) = Match a end parentheses
|
983
|
+
) = End Group
|
984
|
+
*\) = Match anything and then a close parens
|
985
|
+
) = Close non-capturing group
|
986
|
+
* = Match anything
|
987
|
+
) = Close capturing group
|
988
|
+
\) = Match a close parens
|
989
|
+
|
990
|
+
/gi = Get all matches, not the first. Be case insensitive.
|
991
|
+
*/
|
992
|
+
var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
|
993
|
+
// strip quotes (if they exist)
|
994
|
+
var unquotedOrigUrl = origUrl
|
995
|
+
.trim()
|
996
|
+
.replace(/^"(.*)"$/, function(o, $1){ return $1; })
|
997
|
+
.replace(/^'(.*)'$/, function(o, $1){ return $1; });
|
998
|
+
|
999
|
+
// already a full url? no change
|
1000
|
+
if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(unquotedOrigUrl)) {
|
1001
|
+
return fullMatch;
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
// convert the url to a full url
|
1005
|
+
var newUrl;
|
1006
|
+
|
1007
|
+
if (unquotedOrigUrl.indexOf("//") === 0) {
|
1008
|
+
//TODO: should we add protocol?
|
1009
|
+
newUrl = unquotedOrigUrl;
|
1010
|
+
} else if (unquotedOrigUrl.indexOf("/") === 0) {
|
1011
|
+
// path should be relative to the base url
|
1012
|
+
newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
|
1013
|
+
} else {
|
1014
|
+
// path should be relative to current directory
|
1015
|
+
newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
// send back the fixed url(...)
|
1019
|
+
return "url(" + JSON.stringify(newUrl) + ")";
|
1020
|
+
});
|
1021
|
+
|
1022
|
+
// send back the fixed css
|
1023
|
+
return fixedCss;
|
1024
|
+
};
|
1025
|
+
|
1026
|
+
|
1027
|
+
/***/ })
|
1028
|
+
/******/ ]);
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return s(e,1,500)}function a(e){return s(e,0,500)}function s(e,t,n){var r=n/24,o=parseFloat(e.style.opacity)||0,a=t-o,s=a/r;return new Promise(function(t,n){function a(){o+=s,o=o<0?0:o,o=o>1?1:o,e.style.opacity=o,1!==o&&0!==o||(clearInterval(i),t())}var i=setInterval(a,r)})}function i(e){document.addEventListener?document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",this.callee),e()}):document.attachEvent&&document.attachEvent("onreadystatechange",function(){"interactive"!==document.readyState&&"complete"!==document.readyState||(document.detachEvent("onreadystatechange",this.callee),e())})}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();n(1);var u=function(){function e(t){r(this,e),this.options=t||{manual_close:!1,time:5e3},this.pre_dom_queue=[],this._setDom()}return c(e,[{key:"message",value:function(e,t){var n=this;t=Object.assign({},this.options,t);var r=this._addSnackbar(e,t);if(r)return o(r).then(function(){n._setClose(r,t)});this.pre_dom_queue.push({snackbar:this,message:e,opts:t})}},{key:"stickyMessage",value:function(e,t){return t=Object.assign({},this.options,t),t.manual_close=!0,this.message(e,t)}},{key:"success",value:function(e,t){return t=Object.assign({},this.options,t),t.class=t.class||"",t.class+=" success",this.message(e,t)}},{key:"error",value:function(e,t){return t=Object.assign({},this.options,t),t.class=t.class||"",t.class+=" error",this.message(e,t)}},{key:"warn",value:function(e,t){return t=Object.assign({},this.options,t),t.class=t.class||"",t.class+=" warn",this.message(e,t)}},{key:"_setClose",value:function(e,t){var n=this;return new Promise(function(r,o){t.manual_close?r():setTimeout(function(){n._removeSnackbar(e).then(function(){r()})},t.time)})}},{key:"_setDom",value:function(){var e=this,t=document.getElementsByTagName("body")[0];if(t){if(!document.getElementById("snackbar-wrapper")){var n=document.createElement("div");n.id="snackbar-wrapper",t.appendChild(n)}this.pre_dom_queue.length>0&&this._flushQueue()}else i(function(){e._setDom()})}},{key:"_flushQueue",value:function(){for(var e=0;e<this.pre_dom_queue.length;e++){var t=this.pre_dom_queue[e];t.snackbar.message(t.message,t.opts)}this.pre_dom_queue=[]}},{key:"_addSnackbar",value:function(e,t){var n=this,r=document.getElementById("snackbar-wrapper");if(r){var o=document.createElement("div"),a="snackbar";t.class&&(a+=" "+t.class),o.className=a;var s=document.createElement("span");if(s.className="snackbar-text",s.appendChild(document.createTextNode(e)),o.appendChild(s),t.manual_close){var i=document.createElement("span");i.className="snackbar-close";var c=document.createTextNode("X");i.appendChild(c),i.onclick=function(){return n._removeSnackbar(o)},o.appendChild(i)}return r.appendChild(o),o}}},{key:"_removeSnackbar",value:function(e){return a(e).then(function(){e.remove()})}}]),e}();window.Snackbar=u,t.default=u},function(e,t,n){var r=n(2);"string"==typeof r&&(r=[[e.i,r,""]]);var o={hmr:!0};o.transform=void 0;n(4)(r,o);r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(3)(void 0),t.push([e.i,"#snackbar-wrapper {\n width: 100%;\n position: fixed;\n z-index: 999;\n bottom: 0px;\n display: block; }\n #snackbar-wrapper .snackbar {\n opacity: 0;\n width: 105%;\n margin-left: -2.5%;\n background-color: #333;\n color: #fff;\n text-align: center;\n font-size: 17px;\n padding: 16px; }\n #snackbar-wrapper .snackbar-close {\n width: 12%;\n cursor: pointer;\n display: block;\n top: .1em;\n float: right;\n margin-right: 3%; }\n #snackbar-wrapper .snackbar-text {\n width: 85%;\n display: inline-block; }\n #snackbar-wrapper .success {\n background-color: #228822; }\n #snackbar-wrapper .error {\n background-color: #bb2222; }\n #snackbar-wrapper .warn {\n background-color: #f3b300; }\n #snackbar-wrapper span.snackbar-close {\n font-family: sans-serif;\n font-weight: bolder;\n font-size: inherit;\n text-rendering: auto;\n -webkit-font-smoothing: antialiased; }\n",""])},function(e,t){function n(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var a=r(o);return[n].concat(o.sources.map(function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"})).concat([a]).join("\n")}return[n].join("\n")}function r(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r=n(t,e);return t[2]?"@media "+t[2]+"{"+r+"}":r}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;o<this.length;o++){var a=this[o][0];"number"==typeof a&&(r[a]=!0)}for(o=0;o<e.length;o++){var s=e[o];"number"==typeof s[0]&&r[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),t.push(s))}},t}},function(e,t,n){function r(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=h[r.id];if(o){o.refs++;for(var a=0;a<o.parts.length;a++)o.parts[a](r.parts[a]);for(;a<r.parts.length;a++)o.parts.push(l(r.parts[a],t))}else{for(var s=[],a=0;a<r.parts.length;a++)s.push(l(r.parts[a],t));h[r.id]={id:r.id,refs:1,parts:s}}}}function o(e,t){for(var n=[],r={},o=0;o<e.length;o++){var a=e[o],s=t.base?a[0]+t.base:a[0],i=a[1],c=a[2],u=a[3],l={css:i,media:c,sourceMap:u};r[s]?r[s].parts.push(l):n.push(r[s]={id:s,parts:[l]})}return n}function a(e,t){var n=v(e.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var r=g[g.length-1];if("top"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),g.push(t);else if("bottom"===e.insertAt)n.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var o=v(e.insertInto+" "+e.insertAt.before);n.insertBefore(t,o)}}function s(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=g.indexOf(e);t>=0&&g.splice(t,1)}function i(e){var t=document.createElement("style");return e.attrs.type="text/css",u(t,e.attrs),a(e,t),t}function c(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",u(t,e.attrs),a(e,t),t}function u(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function l(e,t){var n,r,o,a;if(t.transform&&e.css){if(!(a=t.transform(e.css)))return function(){};e.css=a}if(t.singleton){var u=y++;n=b||(b=i(t)),r=f.bind(null,n,u,!1),o=f.bind(null,n,u,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=c(t),r=d.bind(null,n,t),o=function(){s(n),n.href&&URL.revokeObjectURL(n.href)}):(n=i(t),r=p.bind(null,n),o=function(){s(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}function f(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=w(t,o);else{var a=document.createTextNode(o),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(a,s[t]):e.appendChild(a)}}function p(e,t){var n=t.css,r=t.media;if(r&&e.setAttribute("media",r),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function d(e,t,n){var r=n.css,o=n.sourceMap,a=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||a)&&(r=k(r)),o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var s=new Blob([r],{type:"text/css"}),i=e.href;e.href=URL.createObjectURL(s),i&&URL.revokeObjectURL(i)}var h={},m=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),v=function(e){var t={};return function(n){if(void 0===t[n]){var r=e.call(this,n);if(r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}t[n]=r}return t[n]}}(function(e){return document.querySelector(e)}),b=null,y=0,g=[],k=n(5);e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");t=t||{},t.attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||(t.singleton=m()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=o(e,t);return r(n,t),function(e){for(var a=[],s=0;s<n.length;s++){var i=n[s],c=h[i.id];c.refs--,a.push(c)}if(e){r(o(e,t),t)}for(var s=0;s<a.length;s++){var c=a[s];if(0===c.refs){for(var u=0;u<c.parts.length;u++)c.parts[u]();delete h[c.id]}}}};var w=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,r=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var o=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});if(/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(o))return e;var a;return a=0===o.indexOf("//")?o:0===o.indexOf("/")?n+o:r+o.replace(/^\.\//,""),"url("+JSON.stringify(a)+")"})}}]);
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vanilla-snackbar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christopher Dimoulis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A full width snackbar using "vanilla js".
|
14
|
+
email: christopherjamesd@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- README.md
|
20
|
+
- lib/vanilla-snackbar.rb
|
21
|
+
- lib/vanilla-snackbar/version.rb
|
22
|
+
- vendor/assets/javascripts/snackbar.js
|
23
|
+
- vendor/assets/javascripts/snackbar.min.js
|
24
|
+
homepage: https://github.com/cdimoulis/snackbar.js
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.4.5.1
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: No dependency snackbar notification.
|
48
|
+
test_files: []
|