-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathd2l-button-behavior.js
128 lines (118 loc) · 2.33 KB
/
d2l-button-behavior.js
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import '@polymer/polymer/polymer-legacy.js';
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
window.D2L = window.D2L || {};
window.D2L.PolymerBehaviors = window.D2L.PolymerBehaviors || {};
window.D2L.PolymerBehaviors.Button = window.D2L.PolymerBehaviors.Button || {};
/** @polymerBehavior */
D2L.PolymerBehaviors.Button.Behavior = {
properties: {
/**
* Whether the button is the primary button.
*/
primary: {
type: Boolean,
reflectToAttribute: true
},
/**
* Standard HTML disabled.
*/
disabled: {
type: Boolean,
reflectToAttribute: true
},
/**
* Indicates whether the element, or another grouping element it
* controls, is currently expanded or collapsed.
*/
ariaExpanded: String,
/**
* Indicates the button opens a menu.
*/
ariaHaspopup: String,
/**
* A string to be used as the accessible label, which overrides text content.
*/
ariaLabel: String,
/**
* Standard HTML autofocus.
*/
autofocus: {
type: Boolean,
reflectToAttribute: true
},
/**
* Standard HTML form.
*/
form: {
type: String,
reflectToAttribute: true
},
/**
* Standard HTML formaction.
*/
formaction: {
type: String,
reflectToAttribute: true
},
/**
* Standard HTML formenctype.
*/
formenctype: {
type: String,
reflectToAttribute: true
},
/**
* Standard HTML formmethod.
*/
formmethod: {
type: String,
reflectToAttribute: true
},
/**
* Standard HTML formnovalidate.
*/
formnovalidate: {
type: String,
reflectToAttribute: true
},
/**
* Standard HTML formtarget.
*/
formtarget: {
type: String,
reflectToAttribute: true
},
/**
* Standard HTML name.
*/
name: {
type: String,
reflectToAttribute: true
},
/**
* Standard HTML type.
*/
type: {
type: String,
reflectToAttribute: true,
value: 'button'
}
},
ready: function() {
this._handleClick = this._handleClick.bind(this);
},
attached: function() {
// eslint-disable-next-line prefer-arrow-callback
afterNextRender(this, function() {
this.addEventListener('click', this._handleClick, true);
}.bind(this));
},
detached: function() {
this.removeEventListener('click', this._handleClick, true);
},
_handleClick: function(e) {
if (this.disabled) {
e.stopPropagation();
}
}
};