Skip to content

Commit 9ba1a87

Browse files
committed
a bit of cleanup
1 parent 4b1fe5b commit 9ba1a87

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

simpletoast.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
fontSize: '15px',
1919
'font-style': 'italic',
2020
},
21-
shared: {
21+
toast: {
2222
maxWidth: '320px',
2323
padding: '5px 8px',
2424
borderRadius: '3px',
@@ -27,8 +27,6 @@
2727
cursor: 'pointer',
2828
color: '#fafeff',
2929
margin: '4px',
30-
},
31-
toast: {
3230
textShadow: '#3498db 1px 2px 1px',
3331
background: '#2980b9',
3432
},
@@ -99,17 +97,15 @@
9997
if (!text) return;
10098
const id = count++;
10199
const el = document.createElement('div');
102-
el.setAttribute('id', `AlertToast-${id}`);
103-
applyCSS(el, style.shared);
104100
applyCSS(el, style.toast);
105101
applyCSS(el, css.toast || css);
106102

107103
// Add title, body
108104
if (title) {
109105
const tel = document.createElement('span');
110106
applyCSS(tel, style.title);
111-
applyCSS(tel, title.css);
112-
tel.textContent = title.text || title;
107+
applyCSS(tel, css.title);
108+
tel.textContent = title;
113109
el.appendChild(tel);
114110
}
115111
const body = document.createElement('span');
@@ -141,14 +137,13 @@
141137
}
142138
let prev = {};
143139
elb.onmouseover = () => {
144-
// Apply default style
145-
const original = applyCSS(elb, style.button.mouseOver);
146-
// Apply CSS style
147-
const custom = applyCSS(elb, css.button && css.button.mouseOver);
148-
// Apply button style
149-
const custom2 = applyCSS(elb, button.css && button.css.mouseOver);
150-
// Remember the original styles, do this in reverse
151-
Object.assign(prev, custom2, custom, original);
140+
const hoverStyle = Object.assign(
141+
{},
142+
style.button.mouseOver,
143+
css.button && css.button.mouseOver,
144+
button.css && button.css.mouseOver
145+
);
146+
prev = applyCSS(hoverStyle);
152147
};
153148
elb.onmouseout = () => {
154149
applyCSS(elb, prev);

0 commit comments

Comments
 (0)