material 0.6.2 → 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 +61 -51
- 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 +160 -161
- package/src/calendar.js +8 -10
- package/src/card.js +4 -6
- package/src/checkbox.js +8 -10
- package/src/component.js +4 -6
- package/src/container.js +4 -6
- package/src/datehour.js +38 -0
- package/src/dialog.js +106 -153
- package/src/divider.js +4 -6
- package/src/drawer.js +11 -13
- package/src/field/email.js +5 -5
- package/src/field/image.js +4 -4
- package/src/{control/file.js → file.js} +18 -48
- package/src/form/build.js +7 -7
- package/src/form/verify.js +2 -2
- package/src/form.js +6 -8
- package/src/icon.js +8 -10
- package/src/image.js +39 -106
- package/src/item.js +7 -9
- package/src/layout.js +10 -10
- package/src/link.js +50 -0
- package/src/list/add.js +1 -1
- package/src/list/build.js +9 -9
- package/src/list/collection.js +1 -1
- package/src/list/display.js +10 -10
- package/src/list/filter.js +2 -2
- package/src/list/request.js +1 -1
- package/src/list/search.js +7 -7
- package/src/list.js +29 -217
- package/src/loading.js +73 -0
- package/src/map/build.js +6 -6
- package/src/map/display.js +8 -8
- package/src/menu.js +60 -116
- package/src/{component → mixin}/control.js +10 -10
- package/src/{component → mixin}/create.js +1 -1
- package/src/{module → mixin}/display.js +9 -22
- package/src/{component → mixin}/events.js +2 -2
- package/src/{component → mixin}/focus.js +2 -3
- package/src/{component → mixin}/insert.js +3 -25
- package/src/{control/module → module}/attributes.js +2 -2
- package/src/module/build.js +11 -7
- package/src/{component → module}/classify.js +0 -13
- package/src/module/dom.js +1 -57
- package/src/module/events.js +4 -2
- package/src/{component → module}/ripple.js +15 -42
- package/src/navigation.js +19 -0
- package/src/progress.js +7 -9
- package/src/search.js +71 -0
- package/src/select.js +58 -273
- package/src/{control/selecter.js → selecter.js} +20 -20
- package/src/selector.js +32 -32
- package/src/skin/material/component/navigation.sass +1 -0
- package/src/skin/material/control/button.sass +10 -0
- package/src/slider.js +32 -34
- package/src/snackbar.js +72 -51
- package/src/switch.js +115 -107
- package/src/{control/switcher.js → switcher.js} +33 -36
- package/src/tabs.js +8 -8
- package/src/tabview.js +8 -8
- package/src/text.js +25 -74
- package/src/textfield.js +97 -234
- package/src/toolbar.js +28 -28
- package/src/tooltip.js +11 -11
- package/src/tree.js +12 -16
- package/src/view/build.js +6 -6
- package/src/view/display.js +16 -16
- package/src/view.js +5 -5
- package/src/banner.js +0 -231
- package/src/component/click.js +0 -17
- package/src/control/button.js +0 -267
- 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/link.js +0 -69
- 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 -89
- package/src/control/switch.js +0 -272
- package/src/control/text.js +0 -70
- package/src/control/textfield.js +0 -177
- /package/src/{component → mixin}/controller.js +0 -0
- /package/src/{component → mixin}/emitter.js +0 -0
- /package/src/{component → mixin}/icon.js +0 -0
- /package/src/{component → mixin}/init.js +0 -0
- /package/src/{component → mixin}/label.js +0 -0
- /package/src/{component → mixin}/settings.js +0 -0
- /package/src/{control/module → module}/addclass.js +0 -0
- /package/src/{tabs/setup.js → module/last.js} +0 -0
package/src/button.js
CHANGED
|
@@ -1,235 +1,234 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
[
|
|
19
|
-
['
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import EventEmitter from './mixin/emitter'
|
|
2
|
+
|
|
3
|
+
import build from './module/build'
|
|
4
|
+
import display from './mixin/display'
|
|
5
|
+
import bindEvents from './module/events'
|
|
6
|
+
|
|
7
|
+
import dataset from './module/dataset'
|
|
8
|
+
import ripple from './module/ripple'
|
|
9
|
+
|
|
10
|
+
class Button extends EventEmitter{
|
|
11
|
+
static isComponent () {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
ripple(this)
|
|
68
|
-
}
|
|
58
|
+
setup () {
|
|
59
|
+
this.styleAttributes()
|
|
69
60
|
|
|
70
|
-
this.
|
|
71
|
-
|
|
61
|
+
this.buildIcon()
|
|
62
|
+
this.buildLabel()
|
|
72
63
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
if (this.options.text) {
|
|
65
|
+
this.element.innerHTML = this.element.innerHTML + this.options.text
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (this.options.data) {
|
|
69
|
+
dataset(this.element, this.options.data)
|
|
70
|
+
}
|
|
80
71
|
|
|
81
|
-
|
|
72
|
+
if (this.options.type) {
|
|
73
|
+
this.element.setAttribute('type', this.options.type)
|
|
74
|
+
} else {
|
|
75
|
+
this.element.setAttribute('type', 'button')
|
|
76
|
+
}
|
|
82
77
|
|
|
83
|
-
|
|
78
|
+
if (this.options.name) {
|
|
79
|
+
this.element.setAttribute('name', this.options.name)
|
|
80
|
+
}
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
if (this.options.value) {
|
|
83
|
+
this.element.setAttribute('value', this.options.value)
|
|
84
|
+
}
|
|
86
85
|
|
|
87
86
|
if (this.options.title) {
|
|
88
|
-
this.
|
|
87
|
+
this.element.setAttribute('title', this.options.title)
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
this.label
|
|
92
|
-
this.icon(this.options.icon)
|
|
90
|
+
this.element.setAttribute('aria-label', this.options.text || this.options.label || this.options.class)
|
|
93
91
|
|
|
94
92
|
if (this.options.tooltip) {
|
|
95
|
-
this.
|
|
93
|
+
this.element.setAttribute('data-tooltip', this.options.tooltip)
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
if (this.options.
|
|
99
|
-
|
|
100
|
-
this.container = this.options.container.root
|
|
101
|
-
} else {
|
|
102
|
-
this.container = this.options.container
|
|
103
|
-
}
|
|
104
|
-
insert(this.root, this.options.container)
|
|
96
|
+
if (this.options.case) {
|
|
97
|
+
this.element.classList.add(this.options.case + '-case')
|
|
105
98
|
}
|
|
106
99
|
|
|
107
|
-
this.
|
|
100
|
+
if (this.options.ripple) ripple(this.element)
|
|
101
|
+
}
|
|
108
102
|
|
|
109
|
-
|
|
103
|
+
append (container) {
|
|
104
|
+
container = container || this.options.container
|
|
105
|
+
if (this.options.container) {
|
|
106
|
+
container.appendChild(this.element)
|
|
107
|
+
}
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
* @param {?} container [description]
|
|
115
|
-
* @param {?} context [description]
|
|
116
|
-
* @return {?} [description]
|
|
117
|
-
*/
|
|
118
|
-
insert (container, context) {
|
|
119
|
-
insert(this.root, container, context)
|
|
110
|
+
buildLabel () {
|
|
111
|
+
if (!this.options.label) return
|
|
120
112
|
|
|
121
|
-
|
|
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
|
+
}
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
* @return {?} [description]
|
|
127
|
-
*/
|
|
128
|
-
setup () {
|
|
129
|
-
this.element.input = this.root
|
|
122
|
+
buildIcon () {
|
|
123
|
+
if (!this.options.icon) return
|
|
130
124
|
|
|
131
|
-
if (this.options.
|
|
132
|
-
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)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
styleAttributes () {
|
|
135
|
+
if (this.options.style) {
|
|
136
|
+
this.element.classList.add('style-' + this.options.style)
|
|
133
137
|
}
|
|
134
138
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
if (this.options.size) {
|
|
140
|
+
this.element.classList.add(this.options.size + '-size')
|
|
141
|
+
}
|
|
138
142
|
|
|
139
|
-
if (this.options.
|
|
140
|
-
this.
|
|
143
|
+
if (this.options.color) {
|
|
144
|
+
this.element.classList.add('color-' + this.options.color)
|
|
141
145
|
}
|
|
142
146
|
|
|
143
|
-
if (this.options.
|
|
144
|
-
this.
|
|
147
|
+
if (this.options.bold) {
|
|
148
|
+
this.element.classList.add('bold')
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
/**
|
|
149
|
-
* Setter
|
|
150
|
-
* @param {string} prop
|
|
151
|
-
* @param {string} value
|
|
152
|
-
* @return {Object} The class instance
|
|
153
|
-
*/
|
|
154
152
|
set (prop, value) {
|
|
153
|
+
// console.log('set', this.element, prop, value)
|
|
155
154
|
switch (prop) {
|
|
156
|
-
case 'disabled':
|
|
157
|
-
this.disable(value)
|
|
158
|
-
break
|
|
159
155
|
case 'value':
|
|
160
|
-
this.
|
|
156
|
+
this.element.value = value
|
|
161
157
|
break
|
|
162
158
|
case 'label':
|
|
163
|
-
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
|
+
}
|
|
164
170
|
break
|
|
165
171
|
default:
|
|
166
|
-
|
|
172
|
+
// console.log('prop', prop)
|
|
173
|
+
this.element.innerHTML = prop
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
return this
|
|
170
177
|
}
|
|
171
178
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
setLabel (label) {
|
|
177
|
-
label = label || this.options.label
|
|
178
|
-
var text = label
|
|
179
|
-
|
|
180
|
-
if (label === null || label === false) {
|
|
181
|
-
text = ''
|
|
182
|
-
} else if (label) {
|
|
183
|
-
text = label
|
|
184
|
-
} else if (this.options.label) {
|
|
185
|
-
text = label
|
|
186
|
-
} else {
|
|
187
|
-
text = this.options.name
|
|
188
|
-
}
|
|
179
|
+
setLabel (value) {
|
|
180
|
+
// console.log('setLabel', value)
|
|
181
|
+
this.label.innerHTML = value
|
|
182
|
+
}
|
|
189
183
|
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
setText (value) {
|
|
185
|
+
// console.log('setText', value)
|
|
186
|
+
if (this.label) {
|
|
187
|
+
this.setLabel(value)
|
|
192
188
|
} else {
|
|
193
|
-
this.element.
|
|
189
|
+
this.element.innerHTML = value
|
|
194
190
|
}
|
|
195
191
|
}
|
|
196
192
|
|
|
197
|
-
destroy () {
|
|
198
|
-
this.container.removeChild(this.root)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
193
|
/**
|
|
202
|
-
*
|
|
203
|
-
* @param
|
|
204
|
-
* @
|
|
194
|
+
* Setter
|
|
195
|
+
* @param {string} prop
|
|
196
|
+
* @param {string} value
|
|
197
|
+
* @return {Object} The class instance
|
|
205
198
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
+
}
|
|
211
209
|
|
|
212
|
-
|
|
213
|
-
this.
|
|
210
|
+
disable () {
|
|
211
|
+
this.element.disabled = true
|
|
212
|
+
}
|
|
214
213
|
|
|
215
|
-
|
|
214
|
+
enable () {
|
|
215
|
+
this.element.disabled = false
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*/
|
|
223
|
-
handleMouseOver (e) {
|
|
224
|
-
e.preventDefault()
|
|
218
|
+
click (ev) {
|
|
219
|
+
if (this.options.stopPropagation === true) {
|
|
220
|
+
ev.stopPropagation()
|
|
221
|
+
}
|
|
225
222
|
|
|
226
|
-
|
|
223
|
+
this.emit('click', ev)
|
|
224
|
+
}
|
|
227
225
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
mousedown (ev) {
|
|
227
|
+
this.element.classList.add('pushed')
|
|
228
|
+
}
|
|
231
229
|
|
|
232
|
-
|
|
230
|
+
mouseup (ev) {
|
|
231
|
+
this.element.classList.remove('pushed')
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
234
|
|
package/src/calendar.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
import create from './element/create'
|
|
4
2
|
import insert from './element/insert'
|
|
5
3
|
import css from './module/css'
|
|
@@ -112,12 +110,12 @@ class Calendar {
|
|
|
112
110
|
// define main tag
|
|
113
111
|
var tag = this.options.tag || 'div'
|
|
114
112
|
|
|
115
|
-
this.
|
|
113
|
+
this.element = create(tag, this.options.prefix + '-' + this.options.class)
|
|
116
114
|
|
|
117
115
|
this.buildWeek()
|
|
118
116
|
|
|
119
117
|
if (this.options.container) {
|
|
120
|
-
insert(this.
|
|
118
|
+
insert(this.element, this.options.container)
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
return this
|
|
@@ -143,7 +141,7 @@ class Calendar {
|
|
|
143
141
|
*/
|
|
144
142
|
buildHeader () {
|
|
145
143
|
this.header = create('header')
|
|
146
|
-
insert(this.header, this.
|
|
144
|
+
insert(this.header, this.element)
|
|
147
145
|
|
|
148
146
|
this.buildHeadline()
|
|
149
147
|
|
|
@@ -266,7 +264,7 @@ class Calendar {
|
|
|
266
264
|
|
|
267
265
|
this.body = create('div')
|
|
268
266
|
css.add(this.body, this.options.class + '-body')
|
|
269
|
-
insert(this.body, this.
|
|
267
|
+
insert(this.body, this.element)
|
|
270
268
|
|
|
271
269
|
var hours = create('div')
|
|
272
270
|
css.add(hours, 'hours')
|
|
@@ -422,7 +420,7 @@ class Calendar {
|
|
|
422
420
|
next () {
|
|
423
421
|
this.firstDay.setDate(this.firstDay.getDate() + this.options.rangedays)
|
|
424
422
|
|
|
425
|
-
this.
|
|
423
|
+
this.element.innerHTML = ''
|
|
426
424
|
|
|
427
425
|
this.buildWeek()
|
|
428
426
|
}
|
|
@@ -434,7 +432,7 @@ class Calendar {
|
|
|
434
432
|
back () {
|
|
435
433
|
this.firstDay.setDate(this.firstDay.getDate() - this.options.rangedays)
|
|
436
434
|
|
|
437
|
-
this.
|
|
435
|
+
this.element.innerHTML = ''
|
|
438
436
|
|
|
439
437
|
this.buildWeek()
|
|
440
438
|
}
|
|
@@ -448,7 +446,7 @@ class Calendar {
|
|
|
448
446
|
date = date || new Date()
|
|
449
447
|
|
|
450
448
|
this.firstDay = this.getFirstDayOfWeek(this.date)
|
|
451
|
-
this.
|
|
449
|
+
this.element.innerHTML = ''
|
|
452
450
|
|
|
453
451
|
this.buildWeek()
|
|
454
452
|
}
|
|
@@ -459,7 +457,7 @@ class Calendar {
|
|
|
459
457
|
|
|
460
458
|
empty () {
|
|
461
459
|
console.log('empty')
|
|
462
|
-
this.
|
|
460
|
+
this.element.innerHTML = ''
|
|
463
461
|
}
|
|
464
462
|
}
|
|
465
463
|
|
package/src/card.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// import modules
|
|
4
|
-
import create from './
|
|
5
|
-
import insert from './
|
|
2
|
+
import create from './mixin/create'
|
|
3
|
+
import insert from './mixin/insert'
|
|
6
4
|
// import components
|
|
7
5
|
import Layout from './layout'
|
|
8
6
|
|
|
@@ -33,10 +31,10 @@ class Card {
|
|
|
33
31
|
* @return {Object} The class instance
|
|
34
32
|
*/
|
|
35
33
|
build () {
|
|
36
|
-
this.
|
|
34
|
+
this.element = create(this.options)
|
|
37
35
|
|
|
38
36
|
if (this.options.layout) {
|
|
39
|
-
this.layout = new Layout(this.options.layout, this.
|
|
37
|
+
this.layout = new Layout(this.options.layout, this.element)
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
}
|
package/src/checkbox.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import control from './component/control'
|
|
5
|
-
import label from './component/label'
|
|
1
|
+
import events from './mixin/events'
|
|
2
|
+
import control from './mixin/control'
|
|
3
|
+
import label from './mixin/label'
|
|
6
4
|
|
|
7
5
|
import insert from './element/insert'
|
|
8
6
|
import build from './element/build'
|
|
@@ -79,13 +77,13 @@ class Checkbox {
|
|
|
79
77
|
*/
|
|
80
78
|
build () {
|
|
81
79
|
this.element = build(this.options.build)
|
|
82
|
-
this.
|
|
80
|
+
this.element = this.element.root
|
|
83
81
|
|
|
84
82
|
this.element.control.innerHTML = icon
|
|
85
83
|
|
|
86
84
|
var text = this.options.text || this.options.label
|
|
87
85
|
|
|
88
|
-
this.element.label = label(this.
|
|
86
|
+
this.element.label = label(this.element, text, this.options)
|
|
89
87
|
|
|
90
88
|
this.element.input.setAttribute('type', 'checkbox')
|
|
91
89
|
this.element.input.setAttribute('name', this.options.name)
|
|
@@ -98,7 +96,7 @@ class Checkbox {
|
|
|
98
96
|
if (this.options.disabled) {
|
|
99
97
|
this.disabled = this.options.disabled
|
|
100
98
|
this.element.input.setAttribute('disabled', 'disabled')
|
|
101
|
-
css.add(this.
|
|
99
|
+
css.add(this.element, 'is-disabled')
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
if (this.options.checked) {
|
|
@@ -111,7 +109,7 @@ class Checkbox {
|
|
|
111
109
|
|
|
112
110
|
// insert if container options is given
|
|
113
111
|
if (this.options.container) {
|
|
114
|
-
insert(this.
|
|
112
|
+
insert(this.element, this.options.container)
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
return this
|
|
@@ -148,7 +146,7 @@ class Checkbox {
|
|
|
148
146
|
* @return {?} [description]
|
|
149
147
|
*/
|
|
150
148
|
insert (container, context) {
|
|
151
|
-
insert(this.
|
|
149
|
+
insert(this.element, container, context)
|
|
152
150
|
|
|
153
151
|
return this
|
|
154
152
|
}
|
package/src/component.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import events from './component/events'
|
|
5
|
-
import insert from './component/insert'
|
|
1
|
+
import create from './mixin/create'
|
|
2
|
+
import events from './mixin/events'
|
|
3
|
+
import insert from './mixin/insert'
|
|
6
4
|
|
|
7
5
|
import emitter from './module/emitter'
|
|
8
6
|
|
|
@@ -59,7 +57,7 @@ class Component {
|
|
|
59
57
|
* @return {Object} This class instance
|
|
60
58
|
*/
|
|
61
59
|
build () {
|
|
62
|
-
this.
|
|
60
|
+
this.element = create(this.options)
|
|
63
61
|
|
|
64
62
|
if (this.options.container) {
|
|
65
63
|
this.insert(this.options.container)
|
package/src/container.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import create from './component/create'
|
|
1
|
+
import create from './mixin/create'
|
|
4
2
|
import insert from './element/insert'
|
|
5
3
|
import emitter from './module/emitter'
|
|
6
4
|
|
|
@@ -50,17 +48,17 @@ class Container {
|
|
|
50
48
|
* @return {Object} This class instance
|
|
51
49
|
*/
|
|
52
50
|
build () {
|
|
53
|
-
this.
|
|
51
|
+
this.element = create(this.options)
|
|
54
52
|
|
|
55
53
|
if (this.options.container) {
|
|
56
|
-
insert(this.
|
|
54
|
+
insert(this.element, this.options.container)
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
return this
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
insert (container, context) {
|
|
63
|
-
insert(this.
|
|
61
|
+
insert(this.element, container, context)
|
|
64
62
|
return this
|
|
65
63
|
}
|
|
66
64
|
}
|
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
|