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/dialog.js
CHANGED
|
@@ -1,213 +1,166 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// dialog related modules
|
|
4
|
-
import events from './component/events'
|
|
5
2
|
import emitter from './module/emitter'
|
|
6
|
-
import controller from './component/controller'
|
|
7
3
|
import attach from './module/attach'
|
|
8
|
-
import
|
|
9
|
-
import event from './element/event.js'
|
|
10
|
-
import css from './module/css'
|
|
4
|
+
import display from './view/display'
|
|
11
5
|
|
|
6
|
+
import Element from './element'
|
|
12
7
|
import Text from './text'
|
|
13
8
|
import Button from './button'
|
|
14
|
-
import Toolbar from './toolbar'
|
|
15
9
|
import Layout from './layout'
|
|
16
10
|
|
|
17
|
-
let defaults = {
|
|
18
|
-
prefix: 'material',
|
|
19
|
-
class: 'dialog',
|
|
20
|
-
tag: 'div',
|
|
21
|
-
events: [
|
|
22
|
-
['root.click', 'close']
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
11
|
class Dialog {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
static defaults = {
|
|
13
|
+
class: 'dialog',
|
|
14
|
+
close: true,
|
|
15
|
+
layout: [
|
|
16
|
+
[Element, 'head', { class: 'head' },
|
|
17
|
+
[Text, 'title', { class: 'title' }],
|
|
18
|
+
[Button, 'close', { class: 'close' }]
|
|
19
|
+
],
|
|
20
|
+
[Element, 'body', { class: 'body' },
|
|
21
|
+
[Text, 'content', { class: 'content' }]
|
|
22
|
+
],
|
|
23
|
+
[Element, 'foot', { class: 'foot' },
|
|
24
|
+
[Element, { class: 'divider' }],
|
|
25
|
+
[Button, 'ok', { class: 'ok', text: 'Ok', color: 'primary' }]
|
|
26
|
+
]
|
|
27
|
+
],
|
|
28
|
+
events: [
|
|
29
|
+
['element.click', 'onClickRoot'],
|
|
30
|
+
['surface.click', 'onClick'],
|
|
31
|
+
['ui.ok.click', 'ok'],
|
|
32
|
+
['ui.cancel.click', 'cancel'],
|
|
33
|
+
['ui.close.click', 'close']
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
constructor (options) {
|
|
33
38
|
this.init(options)
|
|
34
39
|
this.build()
|
|
40
|
+
this.render()
|
|
35
41
|
this.attach()
|
|
36
42
|
|
|
37
|
-
this.root.style.display = 'none'
|
|
38
|
-
|
|
39
43
|
return this
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* @return {Object} This class instance
|
|
46
|
-
*/
|
|
47
|
-
init (options) {
|
|
48
|
-
// init options
|
|
49
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
50
|
-
|
|
51
|
-
// implement modules
|
|
52
|
-
Object.assign(this, events, emitter, attach, insert)
|
|
53
|
-
|
|
54
|
-
this.layout = null
|
|
55
|
-
this.content = null
|
|
56
|
-
this.html = null
|
|
57
|
-
|
|
58
|
-
this.controller = controller
|
|
59
|
-
|
|
60
|
-
return this
|
|
46
|
+
init(options) {
|
|
47
|
+
this.options = Object.assign({}, Dialog.defaults, options || {})
|
|
48
|
+
Object.assign(this, emitter, attach, display)
|
|
61
49
|
}
|
|
62
50
|
|
|
63
|
-
/**
|
|
64
|
-
* build the component using the super method
|
|
65
|
-
* @return {Object} The class instance
|
|
66
|
-
*/
|
|
67
51
|
build () {
|
|
68
|
-
this.
|
|
52
|
+
this.element = document.createElement('div')
|
|
53
|
+
this.element.classList.add('dialog')
|
|
69
54
|
|
|
70
|
-
|
|
55
|
+
this.element = this.element
|
|
71
56
|
|
|
72
|
-
if (this.options.
|
|
73
|
-
|
|
57
|
+
if (this.options.class !== 'dialog') {
|
|
58
|
+
this.element.classList.add(this.options.class)
|
|
74
59
|
}
|
|
75
60
|
|
|
76
|
-
if (this.options.
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (this.options.theme) {
|
|
81
|
-
css.add(this.root, this.options.theme + '-theme')
|
|
61
|
+
if (this.options.position) {
|
|
62
|
+
this.element.classList.add('position-' + this.options.position)
|
|
82
63
|
}
|
|
83
64
|
|
|
84
65
|
this.surface = document.createElement('div')
|
|
66
|
+
this.surface.classList.add('surface')
|
|
67
|
+
this.element.appendChild(this.surface)
|
|
85
68
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.insertElement(this.surface, this.root)
|
|
69
|
+
this.layout = new Layout(this.options.layout, this.surface)
|
|
70
|
+
this.ui = this.layout.component
|
|
89
71
|
|
|
90
|
-
if (this.options.
|
|
91
|
-
this.
|
|
72
|
+
if (this.options.container) {
|
|
73
|
+
this.options.container.appendChild(this.element)
|
|
92
74
|
}
|
|
93
75
|
|
|
94
|
-
if (this.options.
|
|
95
|
-
this.
|
|
76
|
+
if (this.options.display === 'show') {
|
|
77
|
+
this.show()
|
|
96
78
|
}
|
|
79
|
+
}
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
render () {
|
|
82
|
+
if (this.options.title && this.ui.title) {
|
|
83
|
+
this.ui.title.set(this.options.title)
|
|
100
84
|
}
|
|
101
85
|
|
|
102
|
-
if (this.options.
|
|
103
|
-
this.
|
|
86
|
+
if (this.options.content && this.ui.content) {
|
|
87
|
+
this.ui.content.set(this.options.content)
|
|
104
88
|
}
|
|
105
89
|
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
ev.stopPropagation()
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
buildTitle () {
|
|
114
|
-
this.title = new Text({
|
|
115
|
-
type: 'title',
|
|
116
|
-
css: 'dialog-title',
|
|
117
|
-
text: this.options.title
|
|
118
|
-
})
|
|
90
|
+
if (this.options.cancel && this.ui.cancel) {
|
|
91
|
+
this.ui.cancel.set('text', this.options.cancel)
|
|
92
|
+
}
|
|
119
93
|
|
|
120
|
-
|
|
94
|
+
if (this.options.ok && this.ui.ok) {
|
|
95
|
+
this.ui.ok.set('text', this.options.ok)
|
|
96
|
+
}
|
|
121
97
|
|
|
122
|
-
|
|
98
|
+
if (this.options.target) {
|
|
99
|
+
this.setPosition()
|
|
100
|
+
}
|
|
123
101
|
}
|
|
124
102
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
103
|
+
setPosition () {
|
|
104
|
+
var coord = this.options.target.getBoundingClientRect()
|
|
105
|
+
var surface_coord = this.surface.getBoundingClientRect()
|
|
129
106
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
107
|
+
if (this.options.position === 'right') {
|
|
108
|
+
this.surface.style.top = coord.top + 'px'
|
|
109
|
+
this.surface.style.left = coord.left + coord.width // surface_coord.width + 'px'
|
|
110
|
+
} else {
|
|
111
|
+
this.surface.style.top = coord.top + 'px'
|
|
112
|
+
this.surface.style.left = coord.left - surface_coord.width + 'px'
|
|
113
|
+
}
|
|
134
114
|
}
|
|
135
115
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
text: this.options.content
|
|
142
|
-
})
|
|
143
|
-
this.insertElement(this.content.root, this.surface)
|
|
116
|
+
ok () {
|
|
117
|
+
this.emit('ok')
|
|
118
|
+
if (this.options.close) {
|
|
119
|
+
this.destroy()
|
|
120
|
+
}
|
|
144
121
|
}
|
|
145
122
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.actions = new Layout(this.options.actions, this.surface)
|
|
123
|
+
cancel () {
|
|
124
|
+
this.emit('cancel')
|
|
149
125
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var actions
|
|
153
|
-
if (this.options.accept || this.options.cancel) {
|
|
154
|
-
actions = new Toolbar({ css: 'dialog-actions' })
|
|
155
|
-
this.insertElement(actions.root, this.surface)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (this.options.cancel) {
|
|
159
|
-
this.cancel = new Button(this.options.cancel)
|
|
160
|
-
.on('click', () => {
|
|
161
|
-
this.emit('canceled')
|
|
162
|
-
this.close()
|
|
163
|
-
})
|
|
164
|
-
this.insertElement(this.cancel.root, actions.root)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (this.options.accept) {
|
|
168
|
-
this.accept = new Button(this.options.accept)
|
|
169
|
-
.on('click', () => {
|
|
170
|
-
this.emit('accepted')
|
|
171
|
-
this.close()
|
|
172
|
-
})
|
|
173
|
-
this.insertElement(this.accept.root, actions.root)
|
|
174
|
-
}
|
|
126
|
+
if (this.options.close) {
|
|
127
|
+
this.destroy()
|
|
175
128
|
}
|
|
176
129
|
}
|
|
177
130
|
|
|
178
131
|
close () {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
var delayMillis = 200 // 1 second
|
|
182
|
-
setTimeout(() => {
|
|
183
|
-
this.root.style.display = 'none'
|
|
184
|
-
css.remove(this.root, 'dialog-closing')
|
|
185
|
-
css.remove(this.root, 'dialog-show')
|
|
186
|
-
}, delayMillis)
|
|
132
|
+
// this.hide()
|
|
187
133
|
|
|
188
|
-
this.
|
|
189
|
-
|
|
190
|
-
|
|
134
|
+
if (this.options.close) {
|
|
135
|
+
this.destroy()
|
|
136
|
+
}
|
|
191
137
|
}
|
|
192
138
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
this.root.style.display = 'flex'
|
|
197
|
-
// css.add(this.root, 'dialog-showing');
|
|
198
|
-
|
|
199
|
-
var delayMillis = 100 // 1 second
|
|
200
|
-
|
|
201
|
-
setTimeout(() => {
|
|
202
|
-
css.add(this.root, 'dialog-show')
|
|
203
|
-
// css.remove(this.root, 'dialog-showing');
|
|
204
|
-
}, delayMillis)
|
|
139
|
+
onClick (e) {
|
|
140
|
+
e.stopPropagation()
|
|
141
|
+
}
|
|
205
142
|
|
|
206
|
-
|
|
143
|
+
onClickRoot (e) {
|
|
144
|
+
// console.log('onClickRoot')
|
|
145
|
+
e.stopPropagation()
|
|
146
|
+
if (!this.options.modal) {
|
|
147
|
+
this.destroy()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
207
150
|
|
|
208
|
-
|
|
151
|
+
emphase () {
|
|
152
|
+
this.element.classList.add('emphase')
|
|
153
|
+
var it
|
|
154
|
+
it = setTimeout(() => {
|
|
155
|
+
clearTimeout(it)
|
|
156
|
+
this.element.classList.remove('emphase')
|
|
157
|
+
}, 100)
|
|
158
|
+
}
|
|
209
159
|
|
|
210
|
-
|
|
160
|
+
set (prop, value) {
|
|
161
|
+
if (this.ui[prop]) {
|
|
162
|
+
this.ui[prop].set(value)
|
|
163
|
+
}
|
|
211
164
|
}
|
|
212
165
|
}
|
|
213
166
|
|
package/src/divider.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import create from './component/create'
|
|
4
|
-
import insert from './component/insert'
|
|
1
|
+
import create from './mixin/create'
|
|
2
|
+
import insert from './mixin/insert'
|
|
5
3
|
|
|
6
4
|
var defaults = {
|
|
7
5
|
prefix: 'material',
|
|
@@ -45,10 +43,10 @@ class Divider {
|
|
|
45
43
|
* @return {Object} This class instance
|
|
46
44
|
*/
|
|
47
45
|
build () {
|
|
48
|
-
this.
|
|
46
|
+
this.element = create(this.options)
|
|
49
47
|
|
|
50
48
|
if (this.options.text) {
|
|
51
|
-
this.
|
|
49
|
+
this.element.textContent = this.options.text
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
if (this.options.container) {
|
package/src/drawer.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import init from './component/init'
|
|
1
|
+
import init from './mixin/init'
|
|
4
2
|
import insert from './element/insert'
|
|
5
|
-
import classify from './
|
|
3
|
+
import classify from './module/classify'
|
|
6
4
|
import css from './module/css'
|
|
7
|
-
import events from './
|
|
5
|
+
import events from './mixin/events'
|
|
8
6
|
import create from './element/create'
|
|
9
7
|
import emitter from './module/emitter'
|
|
10
8
|
|
|
@@ -57,14 +55,14 @@ class Drawer {
|
|
|
57
55
|
|
|
58
56
|
classify(this.wrapper, this.options)
|
|
59
57
|
|
|
60
|
-
this.
|
|
58
|
+
this.element = create('aside')
|
|
61
59
|
|
|
62
|
-
css.add(this.
|
|
60
|
+
css.add(this.element, 'drawer-panel')
|
|
63
61
|
|
|
64
|
-
insert(this.
|
|
62
|
+
insert(this.element, this.wrapper)
|
|
65
63
|
|
|
66
64
|
if (this.options.position) {
|
|
67
|
-
css.add(this.
|
|
65
|
+
css.add(this.element, 'position-' + this.options.position)
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
if (this.options.fixed) {
|
|
@@ -73,9 +71,9 @@ class Drawer {
|
|
|
73
71
|
|
|
74
72
|
if (this.options.size) {
|
|
75
73
|
if (this.options.position === 'top' || this.options.position === 'bottom') {
|
|
76
|
-
this.
|
|
74
|
+
this.element.style = 'height: ' + this.options.size + 'px;'
|
|
77
75
|
} else {
|
|
78
|
-
this.
|
|
76
|
+
this.element.style = 'width: ' + this.options.size + 'px;'
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
|
|
@@ -85,7 +83,7 @@ class Drawer {
|
|
|
85
83
|
|
|
86
84
|
if (this.options.container) { insert(this.wrapper, this.options.container) }
|
|
87
85
|
|
|
88
|
-
this.emit('built', this.
|
|
86
|
+
this.emit('built', this.element)
|
|
89
87
|
|
|
90
88
|
return this
|
|
91
89
|
}
|
|
@@ -109,7 +107,7 @@ class Drawer {
|
|
|
109
107
|
*/
|
|
110
108
|
|
|
111
109
|
toggle () {
|
|
112
|
-
// console.log('toggle', this.
|
|
110
|
+
// console.log('toggle', this.element);
|
|
113
111
|
if (this.wrapper.classList.contains('show')) {
|
|
114
112
|
this.close()
|
|
115
113
|
} else {
|
package/src/field/email.js
CHANGED
|
@@ -40,19 +40,19 @@ class EmailLink {
|
|
|
40
40
|
* @return {Object} This class instance
|
|
41
41
|
*/
|
|
42
42
|
build () {
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
43
|
+
this.element = document.createElement('a')
|
|
44
|
+
this.element.classList.add('email')
|
|
45
45
|
|
|
46
46
|
if (this.options.container) {
|
|
47
|
-
this.options.container.appendChild(this.
|
|
47
|
+
this.options.container.appendChild(this.element)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
return this
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
set (email) {
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
54
|
+
this.element.innerHTML = email
|
|
55
|
+
this.element.setAttribute('href', 'mailto:' + email)
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
package/src/field/image.js
CHANGED
|
@@ -42,11 +42,11 @@ class Image {
|
|
|
42
42
|
* @return {Object} This class instance
|
|
43
43
|
*/
|
|
44
44
|
build () {
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
45
|
+
this.element = document.createElement('div')
|
|
46
|
+
this.element.classList.add(this.options.class)
|
|
47
47
|
|
|
48
48
|
if (this.options.container) {
|
|
49
|
-
this.options.container.appendChild(this.
|
|
49
|
+
this.options.container.appendChild(this.element)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
return this
|
|
@@ -76,7 +76,7 @@ class Image {
|
|
|
76
76
|
url = url + format
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
this.
|
|
79
|
+
this.element.style.backgroundImage = 'url(' + asset.url + src.path + 'thumb/' + src.filename + ')'
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
sanitize (formats) {
|
|
@@ -1,56 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import dataset from '../view/dataset'
|
|
3
|
-
import attributes from './module/attributes'
|
|
1
|
+
import EventEmitter from './mixin/emitter'
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
3
|
+
import build from './module/build'
|
|
4
|
+
import dataset from './module/dataset'
|
|
5
|
+
import attributes from './module/attributes'
|
|
9
6
|
|
|
10
7
|
class File {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @return {Object} Class instance
|
|
15
|
-
*/
|
|
16
|
-
constructor (options) {
|
|
17
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
18
|
-
Object.assign(this, emitter)
|
|
19
|
-
|
|
20
|
-
this.build()
|
|
21
|
-
this.attach()
|
|
22
|
-
|
|
23
|
-
return this
|
|
8
|
+
static defaults = {
|
|
9
|
+
class: 'file',
|
|
10
|
+
attributes: ['name', 'accept', 'required', 'disabled', 'multiple']
|
|
24
11
|
}
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
build () {
|
|
31
|
-
this.root = document.createElement('div')
|
|
32
|
-
this.root.classList.add('file')
|
|
33
|
-
|
|
34
|
-
if (this.options.class !== 'file') {
|
|
35
|
-
this.root.classList.add(this.options.class)
|
|
36
|
-
}
|
|
37
|
-
|
|
13
|
+
constructor (options) {
|
|
14
|
+
this.init(options)
|
|
15
|
+
this.build()
|
|
38
16
|
this.buildLabel()
|
|
39
17
|
this.buildInput()
|
|
18
|
+
this.attach()
|
|
19
|
+
}
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (this.options.focus) {
|
|
46
|
-
this.input.focus()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (this.options.container) {
|
|
50
|
-
this.options.container.appendChild(this.root)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return this
|
|
21
|
+
init (options) {
|
|
22
|
+
this.options = Object.assign({}, File.defaults, options || {})
|
|
23
|
+
Object.assign(this, build)
|
|
54
24
|
}
|
|
55
25
|
|
|
56
26
|
buildLabel () {
|
|
@@ -58,18 +28,18 @@ class File {
|
|
|
58
28
|
this.label = document.createElement('label')
|
|
59
29
|
this.label.classList.add('label')
|
|
60
30
|
this.label.innerHTML = this.options.label
|
|
61
|
-
this.
|
|
31
|
+
this.element.appendChild(this.label)
|
|
62
32
|
}
|
|
63
33
|
}
|
|
64
34
|
|
|
65
35
|
buildInput () {
|
|
66
36
|
this.field = document.createElement('div')
|
|
67
37
|
this.field.classList.add('field')
|
|
68
|
-
this.
|
|
38
|
+
this.element.appendChild(this.field)
|
|
69
39
|
|
|
70
40
|
this.input = document.createElement('input')
|
|
71
41
|
this.input.setAttribute('type', 'file')
|
|
72
|
-
this.
|
|
42
|
+
this.element.appendChild(this.input)
|
|
73
43
|
|
|
74
44
|
attributes(this.input, this.options)
|
|
75
45
|
|
package/src/form/build.js
CHANGED
|
@@ -5,19 +5,19 @@ import Layout from '../layout'
|
|
|
5
5
|
export default {
|
|
6
6
|
build () {
|
|
7
7
|
// console.log('build', this.options.layout)
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
8
|
+
this.element = document.createElement('div')
|
|
9
|
+
this.element.classList.add('form')
|
|
10
10
|
|
|
11
11
|
if (this.options.class !== 'form') {
|
|
12
|
-
this.
|
|
12
|
+
this.element.classList.add(this.options.class)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
if (this.options.form) {
|
|
16
|
-
this.
|
|
16
|
+
this.element.classList.add(this.options.form)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
if (this.options.data) {
|
|
20
|
-
dataset(this.
|
|
20
|
+
dataset(this.element, this.options.data)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
this.buildForm(this.options.form)
|
|
@@ -25,13 +25,13 @@ export default {
|
|
|
25
25
|
this.buildLayout()
|
|
26
26
|
|
|
27
27
|
if (this.options.container) {
|
|
28
|
-
this.options.container.appendChild(this.
|
|
28
|
+
this.options.container.appendChild(this.element)
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
buildForm (form) {
|
|
33
33
|
this.form = document.createElement('form')
|
|
34
|
-
this.
|
|
34
|
+
this.element.appendChild(this.form)
|
|
35
35
|
|
|
36
36
|
if (form && form.method) {
|
|
37
37
|
this.form.setAttribute('method', form.method)
|
package/src/form/verify.js
CHANGED
|
@@ -8,10 +8,10 @@ export default {
|
|
|
8
8
|
var field = this.ui['info.' + list[i]]
|
|
9
9
|
|
|
10
10
|
if (!this.layout.get(list[i]).get()) {
|
|
11
|
-
field.
|
|
11
|
+
field.element.classList.add('textfield-error')
|
|
12
12
|
ok = false
|
|
13
13
|
} else {
|
|
14
|
-
field.
|
|
14
|
+
field.element.classList.remove('textfield-error')
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
package/src/form.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
import insert from './element/insert'
|
|
4
2
|
import css from './module/css'
|
|
5
3
|
import emitter from './module/emitter'
|
|
6
4
|
import attach from './module/attach'
|
|
7
|
-
import controller from './
|
|
5
|
+
import controller from './mixin/controller'
|
|
8
6
|
|
|
9
7
|
// import component
|
|
10
8
|
import Layout from './layout'
|
|
@@ -72,13 +70,13 @@ class Form {
|
|
|
72
70
|
build () {
|
|
73
71
|
var tag = this.options.tag || 'div'
|
|
74
72
|
|
|
75
|
-
this.
|
|
76
|
-
css.add(this.
|
|
73
|
+
this.element = document.createElement(tag)
|
|
74
|
+
css.add(this.element, this.options.prefix + '-' + this.options.class)
|
|
77
75
|
|
|
78
76
|
// complete layout options
|
|
79
|
-
this.options.root = this.
|
|
77
|
+
this.options.root = this.element
|
|
80
78
|
|
|
81
|
-
this.layout = new Layout(this.options.layout, this.
|
|
79
|
+
this.layout = new Layout(this.options.layout, this.element)
|
|
82
80
|
|
|
83
81
|
this._initControls(this.layout.controls)
|
|
84
82
|
|
|
@@ -86,7 +84,7 @@ class Form {
|
|
|
86
84
|
}
|
|
87
85
|
|
|
88
86
|
insert (container, context) {
|
|
89
|
-
insert(this.
|
|
87
|
+
insert(this.element, container, context)
|
|
90
88
|
|
|
91
89
|
return this
|
|
92
90
|
}
|
package/src/icon.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import insert from './component/insert'
|
|
1
|
+
import insert from './mixin/insert'
|
|
4
2
|
import css from './module/css'
|
|
5
3
|
|
|
6
4
|
var defaults = {
|
|
@@ -55,11 +53,11 @@ class Icon {
|
|
|
55
53
|
|
|
56
54
|
this.element = this.element || {}
|
|
57
55
|
|
|
58
|
-
this.
|
|
59
|
-
css.add(this.
|
|
56
|
+
this.element = document.createElement(tag)
|
|
57
|
+
css.add(this.element, this.options.prefix + '-' + this.options.class)
|
|
60
58
|
|
|
61
|
-
if (options.css) { css.add(this.
|
|
62
|
-
// css.add(this.
|
|
59
|
+
if (options.css) { css.add(this.element, options.css) }
|
|
60
|
+
// css.add(this.element, this.options.class + '-adjust');
|
|
63
61
|
|
|
64
62
|
if (this.options.container) {
|
|
65
63
|
this.insert(this.options.container)
|
|
@@ -73,10 +71,10 @@ class Icon {
|
|
|
73
71
|
*/
|
|
74
72
|
set (value) {
|
|
75
73
|
if (value) {
|
|
76
|
-
if (this.
|
|
77
|
-
this.
|
|
74
|
+
if (this.element.innerText) {
|
|
75
|
+
this.element.innerText = value
|
|
78
76
|
} else {
|
|
79
|
-
this.
|
|
77
|
+
this.element.textContent = value
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
return this
|