material 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/form.js +27 -0
- package/index.js +59 -58
- package/list.js +35 -0
- package/package.json +5 -1
- package/src/appbar.js +7 -204
- package/src/badge.js +27 -0
- package/src/button.js +155 -155
- package/src/calendar.js +0 -2
- package/src/card.js +0 -2
- package/src/checkbox.js +0 -2
- package/src/component.js +0 -2
- package/src/container.js +0 -2
- package/src/datehour.js +38 -0
- package/src/dialog.js +105 -152
- package/src/divider.js +0 -2
- package/src/drawer.js +0 -2
- package/src/{control/file.js → file.js} +15 -45
- package/src/form/verify.js +2 -2
- package/src/form.js +0 -2
- package/src/icon.js +0 -2
- package/src/image.js +39 -106
- package/src/item.js +0 -2
- package/src/{control/link.js → link.js} +13 -32
- package/src/list/build.js +2 -2
- package/src/list/collection.js +1 -1
- package/src/list/filter.js +2 -2
- package/src/list/request.js +1 -1
- package/src/list/search.js +5 -5
- package/src/list.js +29 -217
- package/src/loading.js +73 -0
- package/src/menu.js +60 -116
- package/src/mixin/display.js +0 -1
- package/src/mixin/insert.js +2 -24
- package/src/{control/module → module}/attributes.js +2 -2
- package/src/module/build.js +8 -5
- package/src/navigation.js +19 -0
- package/src/progress.js +0 -2
- package/src/search.js +71 -0
- package/src/select.js +57 -272
- package/src/{control/selecter.js → selecter.js} +5 -5
- package/src/skin/material/component/navigation.sass +1 -0
- package/src/skin/material/control/button.sass +10 -0
- package/src/slider.js +0 -2
- package/src/snackbar.js +72 -51
- package/src/switch.js +111 -103
- package/src/{control/switcher.js → switcher.js} +17 -20
- package/src/text.js +25 -74
- package/src/textfield.js +96 -233
- package/src/banner.js +0 -231
- package/src/control/button.js +0 -239
- package/src/control/button.new.js +0 -190
- package/src/control/datehour.js +0 -65
- package/src/control/dialog.js +0 -175
- package/src/control/image.js +0 -92
- package/src/control/list.js +0 -67
- package/src/control/loading.js +0 -128
- package/src/control/menu.js +0 -85
- package/src/control/search.js +0 -98
- package/src/control/select.js +0 -130
- package/src/control/snackbar.js +0 -91
- package/src/control/switch.js +0 -272
- package/src/control/text.js +0 -70
- package/src/control/textfield.js +0 -177
- package/src/tabs/setup.js +0 -0
- /package/src/{control/module → module}/addclass.js +0 -0
package/src/button.js
CHANGED
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
|
|
1
|
+
import EventEmitter from './mixin/emitter'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import build from './module/build'
|
|
4
|
+
import display from './mixin/display'
|
|
5
|
+
import bindEvents from './module/events'
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import dataset from './module/dataset'
|
|
8
|
+
import ripple from './module/ripple'
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
class Button extends EventEmitter{
|
|
11
|
+
static isComponent () {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
static defaults = {
|
|
16
|
+
class: 'button',
|
|
17
|
+
tag: 'button',
|
|
18
|
+
modules: [build, bindEvents],
|
|
19
|
+
styles: ['style', 'color'],
|
|
20
|
+
ripple: true,
|
|
21
|
+
stopPropagation: false,
|
|
22
|
+
events: [
|
|
23
|
+
['element.click', 'click'],
|
|
24
|
+
['element.mousedown', 'mousedown'],
|
|
25
|
+
['element.mouseup', 'mouseup'],
|
|
26
|
+
['element.mouseleave', 'mouseup'],
|
|
27
|
+
['element.touchstart', 'mousedown'],
|
|
28
|
+
['element.touchend', 'mouseup']
|
|
29
|
+
]
|
|
30
|
+
}
|
|
22
31
|
|
|
23
|
-
/**
|
|
24
|
-
* Class that represents a button
|
|
25
|
-
* @class
|
|
26
|
-
* @since 0.0.1
|
|
27
|
-
* @example
|
|
28
|
-
* var button = new Button({
|
|
29
|
-
* label: 'Button raised',
|
|
30
|
-
* type: 'raised',
|
|
31
|
-
* color: 'primary'
|
|
32
|
-
* }).on('click', function(e) {
|
|
33
|
-
* console.log('button click', e);
|
|
34
|
-
* }).insert(document.body);
|
|
35
|
-
*/
|
|
36
|
-
class Button {
|
|
37
32
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} options
|
|
40
|
-
* @
|
|
41
|
-
* @return {Object} The class instance
|
|
33
|
+
* Constructor
|
|
34
|
+
* @param {Object} options - Component options
|
|
35
|
+
* @return {Object} Class instance
|
|
42
36
|
*/
|
|
43
37
|
constructor (options) {
|
|
38
|
+
super()
|
|
39
|
+
|
|
44
40
|
this.init(options)
|
|
45
41
|
this.build()
|
|
46
42
|
this.setup()
|
|
47
|
-
this.
|
|
43
|
+
this.bindEvents()
|
|
48
44
|
|
|
49
|
-
this.
|
|
45
|
+
if (this.options.container) {
|
|
46
|
+
this.append(this.options.container)
|
|
47
|
+
}
|
|
50
48
|
|
|
51
49
|
return this
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
/**
|
|
55
|
-
* [init description]
|
|
56
|
-
* @param {?} options [description]
|
|
57
|
-
* @return {?} [description]
|
|
58
|
-
*/
|
|
59
52
|
init (options) {
|
|
60
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
61
|
-
Object.assign(this,
|
|
53
|
+
this.options = Object.assign({}, Button.defaults, options || {})
|
|
54
|
+
Object.assign(this, build, display, bindEvents)
|
|
62
55
|
|
|
63
|
-
|
|
56
|
+
}
|
|
64
57
|
|
|
65
|
-
|
|
58
|
+
setup () {
|
|
59
|
+
this.styleAttributes()
|
|
66
60
|
|
|
67
|
-
this.
|
|
68
|
-
|
|
61
|
+
this.buildIcon()
|
|
62
|
+
this.buildLabel()
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* @return {void}
|
|
74
|
-
*/
|
|
75
|
-
build () {
|
|
76
|
-
this.element = {}
|
|
64
|
+
if (this.options.text) {
|
|
65
|
+
this.element.innerHTML = this.element.innerHTML + this.options.text
|
|
66
|
+
}
|
|
77
67
|
|
|
78
|
-
|
|
68
|
+
if (this.options.data) {
|
|
69
|
+
dataset(this.element, this.options.data)
|
|
70
|
+
}
|
|
79
71
|
|
|
80
|
-
|
|
72
|
+
if (this.options.type) {
|
|
73
|
+
this.element.setAttribute('type', this.options.type)
|
|
74
|
+
} else {
|
|
75
|
+
this.element.setAttribute('type', 'button')
|
|
76
|
+
}
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
if (this.options.name) {
|
|
79
|
+
this.element.setAttribute('name', this.options.name)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.options.value) {
|
|
83
|
+
this.element.setAttribute('value', this.options.value)
|
|
84
|
+
}
|
|
83
85
|
|
|
84
86
|
if (this.options.title) {
|
|
85
87
|
this.element.setAttribute('title', this.options.title)
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
this.label
|
|
89
|
-
this.icon(this.options.icon)
|
|
90
|
+
this.element.setAttribute('aria-label', this.options.text || this.options.label || this.options.class)
|
|
90
91
|
|
|
91
92
|
if (this.options.tooltip) {
|
|
92
|
-
this.element.
|
|
93
|
+
this.element.setAttribute('data-tooltip', this.options.tooltip)
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
if (this.options.
|
|
96
|
-
|
|
97
|
-
this.container = this.options.container.root
|
|
98
|
-
} else {
|
|
99
|
-
this.container = this.options.container
|
|
100
|
-
}
|
|
101
|
-
insert(this.element, this.options.container)
|
|
96
|
+
if (this.options.case) {
|
|
97
|
+
this.element.classList.add(this.options.case + '-case')
|
|
102
98
|
}
|
|
103
99
|
|
|
104
|
-
if (this.options.ripple)
|
|
105
|
-
|
|
106
|
-
}
|
|
100
|
+
if (this.options.ripple) ripple(this.element)
|
|
101
|
+
}
|
|
107
102
|
|
|
108
|
-
|
|
103
|
+
append (container) {
|
|
104
|
+
container = container || this.options.container
|
|
105
|
+
if (this.options.container) {
|
|
106
|
+
container.appendChild(this.element)
|
|
107
|
+
}
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* @param {?} container [description]
|
|
114
|
-
* @param {?} context [description]
|
|
115
|
-
* @return {?} [description]
|
|
116
|
-
*/
|
|
117
|
-
insert (container, context) {
|
|
118
|
-
insert(this.element, container, context)
|
|
110
|
+
buildLabel () {
|
|
111
|
+
if (!this.options.label) return
|
|
119
112
|
|
|
120
|
-
|
|
113
|
+
if (this.options.label) {
|
|
114
|
+
this.label = document.createElement('label')
|
|
115
|
+
this.label.classList.add('label')
|
|
116
|
+
this.label.innerHTML = this.options.label
|
|
117
|
+
|
|
118
|
+
this.element.appendChild(this.label)
|
|
119
|
+
}
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* @return {?} [description]
|
|
126
|
-
*/
|
|
127
|
-
setup () {
|
|
128
|
-
this.element.input = this.element
|
|
122
|
+
buildIcon () {
|
|
123
|
+
if (!this.options.icon) return
|
|
129
124
|
|
|
130
|
-
if (this.options.
|
|
131
|
-
this.
|
|
125
|
+
if (this.options.icon) {
|
|
126
|
+
this.icon = document.createElement('i')
|
|
127
|
+
this.icon.classList.add('icon')
|
|
128
|
+
this.icon.innerHTML = this.options.icon
|
|
129
|
+
|
|
130
|
+
this.element.appendChild(this.icon)
|
|
132
131
|
}
|
|
132
|
+
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
styleAttributes () {
|
|
135
|
+
if (this.options.style) {
|
|
136
|
+
this.element.classList.add('style-' + this.options.style)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.options.size) {
|
|
140
|
+
this.element.classList.add(this.options.size + '-size')
|
|
141
|
+
}
|
|
137
142
|
|
|
138
|
-
if (this.options.
|
|
139
|
-
this.element.
|
|
143
|
+
if (this.options.color) {
|
|
144
|
+
this.element.classList.add('color-' + this.options.color)
|
|
140
145
|
}
|
|
141
146
|
|
|
142
|
-
if (this.options.
|
|
143
|
-
this.
|
|
147
|
+
if (this.options.bold) {
|
|
148
|
+
this.element.classList.add('bold')
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
|
|
147
|
-
/**
|
|
148
|
-
* Setter
|
|
149
|
-
* @param {string} prop
|
|
150
|
-
* @param {string} value
|
|
151
|
-
* @return {Object} The class instance
|
|
152
|
-
*/
|
|
153
152
|
set (prop, value) {
|
|
153
|
+
// console.log('set', this.element, prop, value)
|
|
154
154
|
switch (prop) {
|
|
155
|
-
case 'disabled':
|
|
156
|
-
this.disable(value)
|
|
157
|
-
break
|
|
158
155
|
case 'value':
|
|
159
|
-
this.
|
|
156
|
+
this.element.value = value
|
|
160
157
|
break
|
|
161
158
|
case 'label':
|
|
162
|
-
this.
|
|
159
|
+
if (this.label) {
|
|
160
|
+
this.label.innerHTML = value
|
|
161
|
+
}
|
|
162
|
+
break
|
|
163
|
+
case 'text':
|
|
164
|
+
this.element.innerHTML = value
|
|
165
|
+
break
|
|
166
|
+
case 'icon':
|
|
167
|
+
if (this.icon) {
|
|
168
|
+
this.icon.innerHTML = value
|
|
169
|
+
}
|
|
163
170
|
break
|
|
164
171
|
default:
|
|
165
|
-
|
|
172
|
+
// console.log('prop', prop)
|
|
173
|
+
this.element.innerHTML = prop
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
return this
|
|
169
177
|
}
|
|
170
178
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
setLabel (label) {
|
|
176
|
-
label = label || this.options.label
|
|
177
|
-
var text = label
|
|
178
|
-
|
|
179
|
-
if (label === null || label === false) {
|
|
180
|
-
text = ''
|
|
181
|
-
} else if (label) {
|
|
182
|
-
text = label
|
|
183
|
-
} else if (this.options.label) {
|
|
184
|
-
text = label
|
|
185
|
-
} else {
|
|
186
|
-
text = this.options.name
|
|
187
|
-
}
|
|
179
|
+
setLabel (value) {
|
|
180
|
+
// console.log('setLabel', value)
|
|
181
|
+
this.label.innerHTML = value
|
|
182
|
+
}
|
|
188
183
|
|
|
189
|
-
|
|
190
|
-
|
|
184
|
+
setText (value) {
|
|
185
|
+
// console.log('setText', value)
|
|
186
|
+
if (this.label) {
|
|
187
|
+
this.setLabel(value)
|
|
191
188
|
} else {
|
|
192
|
-
this.element.
|
|
189
|
+
this.element.innerHTML = value
|
|
193
190
|
}
|
|
194
191
|
}
|
|
195
192
|
|
|
196
|
-
destroy () {
|
|
197
|
-
this.container.removeChild(this.element)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
193
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @param
|
|
203
|
-
* @
|
|
194
|
+
* Setter
|
|
195
|
+
* @param {string} prop
|
|
196
|
+
* @param {string} value
|
|
197
|
+
* @return {Object} The class instance
|
|
204
198
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
get (prop, value) {
|
|
200
|
+
switch (prop) {
|
|
201
|
+
case 'value':
|
|
202
|
+
return this.element.value
|
|
203
|
+
case 'label':
|
|
204
|
+
return this.label.innerHTML
|
|
205
|
+
default:
|
|
206
|
+
return this.element.value
|
|
207
|
+
}
|
|
208
|
+
}
|
|
210
209
|
|
|
211
|
-
|
|
212
|
-
this.
|
|
210
|
+
disable () {
|
|
211
|
+
this.element.disabled = true
|
|
212
|
+
}
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
enable () {
|
|
215
|
+
this.element.disabled = false
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
*/
|
|
222
|
-
handleMouseOver (e) {
|
|
223
|
-
e.preventDefault()
|
|
218
|
+
click (ev) {
|
|
219
|
+
if (this.options.stopPropagation === true) {
|
|
220
|
+
ev.stopPropagation()
|
|
221
|
+
}
|
|
224
222
|
|
|
225
|
-
|
|
223
|
+
this.emit('click', ev)
|
|
224
|
+
}
|
|
226
225
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
mousedown (ev) {
|
|
227
|
+
this.element.classList.add('pushed')
|
|
228
|
+
}
|
|
230
229
|
|
|
231
|
-
|
|
230
|
+
mouseup (ev) {
|
|
231
|
+
this.element.classList.remove('pushed')
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
package/src/calendar.js
CHANGED
package/src/card.js
CHANGED
package/src/checkbox.js
CHANGED
package/src/component.js
CHANGED
package/src/container.js
CHANGED
package/src/datehour.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import build from './module/build'
|
|
2
|
+
|
|
3
|
+
class DateHour {
|
|
4
|
+
static defaults = {
|
|
5
|
+
class: 'date',
|
|
6
|
+
tag: 'span'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
constructor (options) {
|
|
10
|
+
this.init(options)
|
|
11
|
+
this.build()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
init(options) {
|
|
15
|
+
this.options = Object.assign({}, DateHour.defaults, options || {})
|
|
16
|
+
Object.assign(this, build)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
set (date) {
|
|
20
|
+
// console.log('set', src)
|
|
21
|
+
var d = new Date(date)
|
|
22
|
+
var formatted = this.format(d)
|
|
23
|
+
this.element.innerHTML = formatted
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
format (date) {
|
|
27
|
+
var hours = date.getHours()
|
|
28
|
+
var minutes = date.getMinutes()
|
|
29
|
+
var ampm = hours >= 12 ? 'pm' : 'am'
|
|
30
|
+
hours = hours % 12
|
|
31
|
+
hours = hours || 12 // the hour '0' should be '12'
|
|
32
|
+
minutes = minutes < 10 ? '0' + minutes : minutes
|
|
33
|
+
var strTime = hours + ':' + minutes + ' ' + ampm
|
|
34
|
+
return date.getMonth() + 1 + '/' + date.getDate() + '/' + date.getFullYear() + ' ' + strTime
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default DateHour
|