blob: 6e07fee41eaae028f6fabf447220190f6dd620c3 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<button id="demo-show-snackbar" class="mdl-button mdl-js-button mdl-button--raised" type="button">Show Snackbar</button>
2<div id="demo-snackbar-example" class="mdl-js-snackbar mdl-snackbar">
3 <div class="mdl-snackbar__text"></div>
4 <button class="mdl-snackbar__action" type="button"></button>
5</div>
6<script>
7(function() {
8 'use strict';
9 var snackbarContainer = document.querySelector('#demo-snackbar-example');
10 var showSnackbarButton = document.querySelector('#demo-show-snackbar');
11 var handler = function(event) {
12 showSnackbarButton.style.backgroundColor = '';
13 };
14 showSnackbarButton.addEventListener('click', function() {
15 'use strict';
16 showSnackbarButton.style.backgroundColor = '#' +
17 Math.floor(Math.random() * 0xFFFFFF).toString(16);
18 var data = {
19 message: 'Button color changed.',
20 timeout: 2000,
21 actionHandler: handler,
22 actionText: 'Undo'
23 };
24 snackbarContainer.MaterialSnackbar.showSnackbar(data);
25 });
26}());
27</script>