-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxp-snackbar-behavior.html
92 lines (73 loc) · 2.58 KB
/
xp-snackbar-behavior.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!--
@license
Copyright (c) 2017 The expand.js authors. All rights reserved.
This code may only be used under the BSD style license found at https://expandjs.github.io/LICENSE.txt
The complete set of authors may be found at https://expandjs.github.io/AUTHORS.txt
The complete set of contributors may be found at https://expandjs.github.io/CONTRIBUTORS.txt
-->
<!--
A behavior used to add snackbar capabilities on a web component.
@behavior xp-snackbar-behavior
@since 1.0.0
@category behaviors
@description A behavior used to add snackbar capabilities on a web component
@keywords expandjs, web components
@homepage https://expandjs.com/components/xp-snackbar-behavior
@repository https://github.com/expandjs/xp-elements
@source https://github.com/expandjs/xp-elements/blob/master/xp-snackbar-behavior.html
@behavior xp-toast-behavior /bower_components/xp-elements/xp-toast-behavior.html
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../expandjs/expandjs.html">
<link rel="import" href="xp-toast-behavior.html">
<script>
/**
* @polymerBehavior Polymer.XPSnackbarBehaviorImp
*/
Polymer.XPSnackbarBehaviorImp = {
// CLASSES
classes: ['snackbar'],
/*********************************************************************/
/**
* Fired when the action is clicked.
*
* @event xp-activate
* @param {Element} target
* @param {*} data
* @bubbles
* @cancelable
*/
/*********************************************************************/
// PROPERTIES
properties: {
/**
* The snackbar's button's label.
*
* @attribute button
* @type string
*/
button: {
reflectToAttribute: true,
type: String
}
},
/*********************************************************************/
// HANDLER
__handleAction(event) {
// Checking
if (this.firer(event) === this) { return; }
// Callback
if (XP.isFunction(this.callback)) { this.callback(); }
if (XP.isString(this.callback, true) && this.domHost) { this.domHost[this.callback](); }
// Firing
if (!this.refire(event, event.type).defaultPrevented) { this.hide(); }
}
};
/**
* @polymerBehavior Polymer.XPSnackbarBehavior
*/
Polymer.XPSnackbarBehavior = [
Polymer.XPToastBehavior,
Polymer.XPSnackbarBehaviorImp
];
</script>