|
37 | 37 |
|
38 | 38 | width: 'auto',
|
39 | 39 |
|
40 |
| - showAction: true, |
| 40 | + showActionButton: true, |
41 | 41 | actionText: 'Dismiss',
|
42 | 42 | actionTextColor: '#4caf50',
|
43 | 43 |
|
|
66 | 66 | }.bind(Snackbar.current), 500);
|
67 | 67 | }
|
68 | 68 |
|
69 |
| - Snackbar.Snackbar = document.createElement('div'); |
70 |
| - Snackbar.Snackbar.className = 'Snackbar-container ' + options.customClass; |
71 |
| - Snackbar.Snackbar.style.width = options.width; |
| 69 | + Snackbar.snackbar = document.createElement('div'); |
| 70 | + Snackbar.snackbar.className = 'snackbar-container ' + options.customClass; |
| 71 | + Snackbar.snackbar.style.width = options.width; |
72 | 72 | var $p = document.createElement('p');
|
73 | 73 | $p.style.margin = 0;
|
74 | 74 | $p.style.padding = 0;
|
|
77 | 77 | $p.style.fontWeight = 300;
|
78 | 78 | $p.style.lineHeight = '1em';
|
79 | 79 | $p.innerHTML = options.text;
|
80 |
| - Snackbar.Snackbar.appendChild($p); |
81 |
| - Snackbar.Snackbar.style.background = options.backgroundColor; |
82 |
| - if (options.showAction) { |
| 80 | + Snackbar.snackbar.appendChild($p); |
| 81 | + Snackbar.snackbar.style.background = options.backgroundColor; |
| 82 | + if (options.showActionButton) { |
83 | 83 | var actionButton = document.createElement('button');
|
84 | 84 | actionButton.className = 'action';
|
85 | 85 | actionButton.innerHTML = options.actionText;
|
86 | 86 | actionButton.style.color = options.actionTextColor;
|
87 | 87 | actionButton.addEventListener('click', function () {
|
88 |
| - options.onActionClick(Snackbar.Snackbar); |
| 88 | + options.onActionClick(Snackbar.snackbar); |
89 | 89 | });
|
90 |
| - Snackbar.Snackbar.appendChild(actionButton); |
| 90 | + Snackbar.snackbar.appendChild(actionButton); |
91 | 91 | }
|
92 | 92 |
|
93 | 93 | setTimeout(function () {
|
94 | 94 | if (Snackbar.current === this) {
|
95 | 95 | Snackbar.current.style.opacity = 0;
|
96 | 96 | }
|
97 | 97 |
|
98 |
| - }.bind(Snackbar.Snackbar), $defaults.duration); |
| 98 | + }.bind(Snackbar.snackbar), $defaults.duration); |
99 | 99 |
|
100 |
| - Snackbar.Snackbar.addEventListener('transitionend', function (event, elapsed) { |
| 100 | + Snackbar.snackbar.addEventListener('transitionend', function (event, elapsed) { |
101 | 101 | if (event.propertyName === 'opacity' && this.style.opacity === 0) {
|
102 | 102 | this.parentElement.removeChild(this);
|
103 | 103 | if (Snackbar.current === this) {
|
104 | 104 | Snackbar.current = null;
|
105 | 105 | }
|
106 | 106 | }
|
107 |
| - }.bind(Snackbar.Snackbar)); |
| 107 | + }.bind(Snackbar.snackbar)); |
108 | 108 |
|
109 |
| - Snackbar.current = Snackbar.Snackbar; |
| 109 | + Snackbar.current = Snackbar.snackbar; |
110 | 110 | document.body.style.overflow = 'hidden';
|
111 | 111 |
|
112 |
| - if (options.pos === 'top-left' || options.pos === 'top-center' || options.pos === 'top-right') |
113 |
| - Snackbar.Snackbar.style.top = '-100px'; |
| 112 | + if (options.pos === 'top-left' || options.pos === 'top-center' || options.pos === 'top' || options.pos === 'top-right') |
| 113 | + Snackbar.snackbar.style.top = '-100px'; |
114 | 114 |
|
115 |
| - document.body.appendChild(Snackbar.Snackbar); |
116 |
| - var $bottom = getComputedStyle(Snackbar.Snackbar).bottom; |
117 |
| - var $top = getComputedStyle(Snackbar.Snackbar).top; |
118 |
| - Snackbar.Snackbar.style.opacity = 1; |
119 |
| - Snackbar.Snackbar.className = 'Snackbar-container ' + options.customClass + ' Snackbar-pos ' + options.pos; |
| 115 | + document.body.appendChild(Snackbar.snackbar); |
| 116 | + var $bottom = getComputedStyle(Snackbar.snackbar).bottom; |
| 117 | + var $top = getComputedStyle(Snackbar.snackbar).top; |
| 118 | + Snackbar.snackbar.style.opacity = 1; |
| 119 | + Snackbar.snackbar.className = 'snackbar-container ' + options.customClass + ' snackbar-pos ' + options.pos; |
120 | 120 | if (options.pos === 'top-left' || options.pos === 'top-right')
|
121 |
| - Snackbar.Snackbar.style.top = 0; |
| 121 | + Snackbar.snackbar.style.top = 0; |
122 | 122 | else if (options.pos === 'top-center' || options.pos === 'top')
|
123 |
| - Snackbar.Snackbar.style.top = '25px'; |
| 123 | + Snackbar.snackbar.style.top = '25px'; |
124 | 124 | else if (options.pos === 'bottom-center' || options.pos === 'bottom')
|
125 |
| - Snackbar.Snackbar.style.bottom = '-25px'; |
| 125 | + Snackbar.snackbar.style.bottom = '-25px'; |
126 | 126 |
|
127 | 127 | setTimeout(function () {
|
128 | 128 | document.body.style.overflow = 'auto';
|
|
0 commit comments