material 0.4.2 → 0.5.0
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/dist/tracks.svg +10 -0
- package/package.json +1 -1
- package/src/appbar.js +1 -2
- package/src/control/button.js +263 -0
- package/src/control/button.new.js +190 -0
- package/src/control/datehour.js +65 -0
- package/src/control/dialog.js +174 -0
- package/src/control/file.js +123 -0
- package/src/control/image.js +92 -0
- package/src/control/link.js +61 -0
- package/src/control/list.js +77 -0
- package/src/control/loading.js +128 -0
- package/src/control/module/addclass.js +16 -0
- package/src/control/module/attributes.js +21 -0
- package/src/control/search.js +98 -0
- package/src/control/select.js +130 -0
- package/src/control/selecter.js +246 -0
- package/src/control/switch.js +272 -0
- package/src/control/switcher.js +245 -0
- package/src/control/text.js +66 -0
- package/src/control/textfield.js +177 -0
- package/src/field/image.js +9 -3
- package/src/form/build.js +60 -6
- package/src/form/cancel.js +7 -3
- package/src/form/controller.js +90 -0
- package/src/form/create.js +12 -6
- package/src/form/data.js +82 -0
- package/src/form/delete.js +2 -1
- package/src/form/fetch.js +30 -0
- package/src/form/render.js +14 -19
- package/src/form/set.js +27 -12
- package/src/form/submit.js +24 -49
- package/src/form/update.js +46 -0
- package/src/layout.js +26 -22
- package/src/list/add.js +34 -0
- package/src/list/build.js +100 -6
- package/src/list/click.js +10 -5
- package/src/list/collection.js +187 -0
- package/src/list/create.js +21 -11
- package/src/list/display.js +78 -0
- package/src/list/empty.js +4 -1
- package/src/list/filter.js +114 -0
- package/src/list/load.js +2 -2
- package/src/list/remove.js +17 -4
- package/src/list/render.js +32 -9
- package/src/list/request.js +182 -0
- package/src/list/search.js +118 -35
- package/src/list/select.js +151 -30
- package/src/list/status.js +10 -3
- package/src/list/update.js +49 -8
- package/src/list/virtual.js +195 -127
- package/src/map/build.js +103 -0
- package/src/map/countries.js +114 -0
- package/src/map/display.js +135 -0
- package/src/map/focus.js +39 -0
- package/src/map/init.js +24 -0
- package/src/map/label.js +0 -0
- package/src/map/mode.js +44 -0
- package/src/map/mouse.js +65 -0
- package/src/map/select.js +68 -0
- package/src/map/set.js +71 -0
- package/src/map/viewport.js +46 -0
- package/src/map.js +71 -0
- package/src/module/attach.js +15 -16
- package/src/module/extract.js +35 -28
- package/src/module/mediator.js +56 -0
- package/src/module/object.js +17 -1
- package/src/module/observer.js +1 -1
- package/src/module/passive.js +17 -0
- package/src/module/remove.js +74 -0
- package/src/module/scrollbar.js +48 -0
- package/src/module/smoothscroll.js +20 -0
- package/src/module/viewport.js +20 -0
- package/src/selector.js +239 -0
- package/src/skin/material/base/body.sass +3 -0
- package/src/skin/material/button/file.sass +1 -1
- package/src/skin/material/container/container.sass +1 -1
- package/src/skin/material/container/dialog.sass +57 -1
- package/src/skin/material/container/drawer.sass +3 -3
- package/src/skin/material/control/button.sass +125 -0
- package/src/skin/material/control/dialog.sass +0 -0
- package/src/skin/material/control/progress.sass +136 -0
- package/src/skin/material/control/search.sass +40 -0
- package/src/skin/material/control/selecter.sass +131 -0
- package/src/skin/material/control/selector.sass +38 -0
- package/src/skin/material/control/slider.sass +2 -2
- package/src/skin/material/control/switch.sass +146 -3
- package/src/skin/material/control/switcher.sass +41 -0
- package/src/skin/material/control/textfield.sass +2 -1
- package/src/skin/material/icon/cancel.svg +1 -0
- package/src/skin/material/material.sass +3 -0
- package/src/skin/material/view/list.sass +81 -188
- package/src/skin/material/view/listview.sass +187 -96
- package/src/skin/material/view/tabview.sass +7 -5
- package/src/skin/material.bak/base/body.sass +52 -0
- package/src/skin/material.bak/base/elevation.sass +50 -0
- package/src/skin/material.bak/base/grid.sass +63 -0
- package/src/skin/material.bak/base/typo.sass +107 -0
- package/src/skin/material.bak/button/action.sass +89 -0
- package/src/skin/material.bak/button/button.sass +183 -0
- package/src/skin/material.bak/button/file.sass +24 -0
- package/src/skin/material.bak/button/floating.sass +113 -0
- package/src/skin/material.bak/button/raised.sass +101 -0
- package/src/skin/material.bak/button/stroked.sass +71 -0
- package/src/skin/material.bak/component/component.sass +7 -0
- package/src/skin/material.bak/component/divider.sass +17 -0
- package/src/skin/material.bak/component/image.sass +6 -0
- package/src/skin/material.bak/component/label.sass +2 -0
- package/src/skin/material.bak/component/progress.sass +138 -0
- package/src/skin/material.bak/component/subheader.sass +3 -0
- package/src/skin/material.bak/component/text.sass +85 -0
- package/src/skin/material.bak/container/appbar.sass +167 -0
- package/src/skin/material.bak/container/banner.sass +38 -0
- package/src/skin/material.bak/container/card.sass +18 -0
- package/src/skin/material.bak/container/container.sass +1 -0
- package/src/skin/material.bak/container/dialog.sass +184 -0
- package/src/skin/material.bak/container/drawer.sass +159 -0
- package/src/skin/material.bak/container/drawernew.sass +159 -0
- package/src/skin/material.bak/container/menu.sass +58 -0
- package/src/skin/material.bak/container/snackbar.sass +18 -0
- package/src/skin/material.bak/container/tabs.sass +75 -0
- package/src/skin/material.bak/container/toolbar.sass +161 -0
- package/src/skin/material.bak/control/button.sass +125 -0
- package/src/skin/material.bak/control/checkbox.sass +105 -0
- package/src/skin/material.bak/control/dialog.sass +0 -0
- package/src/skin/material.bak/control/search.sass +40 -0
- package/src/skin/material.bak/control/selecter.sass +128 -0
- package/src/skin/material.bak/control/slider.sass +181 -0
- package/src/skin/material.bak/control/switch.sass +284 -0
- package/src/skin/material.bak/control/switcher.sass +35 -0
- package/src/skin/material.bak/control/textfield.sass +126 -0
- package/src/skin/material.bak/control/tooltip.sass +36 -0
- package/src/skin/material.bak/icon/back.svg +5 -0
- package/src/skin/material.bak/icon/cancel.svg +1 -0
- package/src/skin/material.bak/icon/checkbox.svg +4 -0
- package/src/skin/material.bak/icon/forward.svg +5 -0
- package/src/skin/material.bak/icon/menu.svg +4 -0
- package/src/skin/material.bak/icon/pin.svg +4 -0
- package/src/skin/material.bak/layout/layout.sass +69 -0
- package/src/skin/material.bak/layout/resizer.sass +69 -0
- package/src/skin/material.bak/material.css +2042 -0
- package/src/skin/material.bak/material.css.map +7 -0
- package/src/skin/material.bak/material.sass +65 -0
- package/src/skin/material.bak/module/ripple.sass +9 -0
- package/src/skin/material.bak/theme/default.sass +50 -0
- package/src/skin/material.bak/theme/ocean.sass +29 -0
- package/src/skin/material.bak/theme/theme.sass +3 -0
- package/src/skin/material.bak/view/calendar.sass +193 -0
- package/src/skin/material.bak/view/form.sass +15 -0
- package/src/skin/material.bak/view/grid.sass +116 -0
- package/src/skin/material.bak/view/list.sass +89 -0
- package/src/skin/material.bak/view/listview.sass +195 -0
- package/src/skin/material.bak/view/map.sass +6 -0
- package/src/skin/material.bak/view/page.sass +4 -0
- package/src/skin/material.bak/view/tabview-bak.sass +40 -0
- package/src/skin/material.bak/view/tabview.sass +55 -0
- package/src/skin/material.bak/view/tree.sass +73 -0
- package/src/skin/material.bak/view/view.sass +7 -0
- package/src/switch.js +1 -1
- package/src/tabs/setup.js +0 -0
- package/src/tabview.js +64 -14
- package/src/tooltip.js +23 -5
- package/src/view/build.js +15 -3
- package/src/view/display.js +79 -7
- package/src/form/clean.js +0 -6
- package/src/form/mode.js +0 -16
- package/src/form/setup.js +0 -30
- package/src/list/fetch.js +0 -66
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import emitter from '../module/emitter'
|
|
2
|
+
|
|
3
|
+
const defaults = {
|
|
4
|
+
class: 'switcher',
|
|
5
|
+
tag: 'div',
|
|
6
|
+
list: [],
|
|
7
|
+
first: false,
|
|
8
|
+
mode: 'unique',
|
|
9
|
+
allowEmpty: false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class Switcher {
|
|
13
|
+
/**
|
|
14
|
+
* Constructor
|
|
15
|
+
* @param {Object} options - Component options
|
|
16
|
+
* @return {Object} Class instance
|
|
17
|
+
*/
|
|
18
|
+
constructor (options) {
|
|
19
|
+
this.options = Object.assign({}, defaults, options || {})
|
|
20
|
+
Object.assign(this, emitter)
|
|
21
|
+
|
|
22
|
+
this.build()
|
|
23
|
+
this.attach()
|
|
24
|
+
|
|
25
|
+
if (this.options.default) {
|
|
26
|
+
this.selectByName(this.options.default, true)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return this
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
build () {
|
|
33
|
+
this.root = document.createElement(this.options.tag)
|
|
34
|
+
|
|
35
|
+
if (this.options.class !== 'button') {
|
|
36
|
+
this.root.setAttribute('class', 'switcher ' + this.options.class)
|
|
37
|
+
} else {
|
|
38
|
+
this.root.classList.add('switcher')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (this.options.label) {
|
|
42
|
+
this.label = document.createElement('label')
|
|
43
|
+
this.label.innerHTML = this.options.label
|
|
44
|
+
this.root.appendChild(this.label)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.knob = document.createElement('span')
|
|
48
|
+
this.knob.classList.add('knob')
|
|
49
|
+
this.root.appendChild(this.knob)
|
|
50
|
+
|
|
51
|
+
if (this.options.size) {
|
|
52
|
+
this.root.classList.add(this.options.size + '-size')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.buildList(this.options.list)
|
|
56
|
+
|
|
57
|
+
if (this.options.list) {
|
|
58
|
+
this.addOptions(this.options.list)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (this.options.container) {
|
|
62
|
+
this.options.container.appendChild(this.root)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
buildList (list) {
|
|
67
|
+
this.list = document.createElement('ul')
|
|
68
|
+
this.root.appendChild(this.list)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
attach () {
|
|
72
|
+
this.root.addEventListener('click', (event) => {
|
|
73
|
+
if (!event.target.dataset.switcher) return
|
|
74
|
+
this.select(event.target)
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
select (option) {
|
|
79
|
+
if (this.options.mode === 'multiple') {
|
|
80
|
+
this.multiple(option)
|
|
81
|
+
} else {
|
|
82
|
+
this.unique(option)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
preselect (item) {
|
|
87
|
+
// console.log('preselect', item)
|
|
88
|
+
if (item) {
|
|
89
|
+
item.classList.add('preselected')
|
|
90
|
+
} else {
|
|
91
|
+
var items = this.list.childNodes
|
|
92
|
+
for (var i = 0; i < items.length; i++) {
|
|
93
|
+
items[i].classList.remove('preselected')
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
selectByName (name) {
|
|
99
|
+
// console.log('selectByName', name)
|
|
100
|
+
var item = this.root.querySelector('[data-switcher="' + name + '"]')
|
|
101
|
+
// console.log('item', item)
|
|
102
|
+
if (item) {
|
|
103
|
+
this.select(item)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
preSelectByName (name) {
|
|
108
|
+
// console.log('selectByName', name)
|
|
109
|
+
var item = this.root.querySelector('[data-switcher="' + name + '"]')
|
|
110
|
+
// console.log('item', item)
|
|
111
|
+
this.preselect(item)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
unique (option) {
|
|
115
|
+
// console.log('option', option)
|
|
116
|
+
if (!option.classList.contains('selected')) {
|
|
117
|
+
var options = this.list.childNodes
|
|
118
|
+
|
|
119
|
+
for (var i = 0; i < options.length; i++) {
|
|
120
|
+
options[i].classList.remove('selected')
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
option.classList.add('selected')
|
|
124
|
+
this.selected = [option.dataset.switcher]
|
|
125
|
+
this.emit('change', this.selected[0])
|
|
126
|
+
} else {
|
|
127
|
+
if (this.options.allowEmpty) {
|
|
128
|
+
option.classList.remove('selected')
|
|
129
|
+
this.selected = []
|
|
130
|
+
this.emit('change', this.selected[0])
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
multiple (option) {
|
|
136
|
+
if (option.classList.contains('selected')) {
|
|
137
|
+
if (this.selected.length === 1) return
|
|
138
|
+
var i = this.selected.indexOf(option.dataset.switcher)
|
|
139
|
+
this.selected.splice(i, 1)
|
|
140
|
+
option.classList.remove('selected')
|
|
141
|
+
} else {
|
|
142
|
+
option.classList.add('selected')
|
|
143
|
+
this.selected.push(option.dataset.switcher)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.emit('change', this.selected)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
set (prop, value) {
|
|
150
|
+
switch (prop) {
|
|
151
|
+
case 'value':
|
|
152
|
+
this.setValue(value)
|
|
153
|
+
break
|
|
154
|
+
case 'options':
|
|
155
|
+
this.setOptions(value)
|
|
156
|
+
break
|
|
157
|
+
case 'option':
|
|
158
|
+
this.addOptions(value)
|
|
159
|
+
break
|
|
160
|
+
default:
|
|
161
|
+
this.setValue(prop)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return this
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setValue (value) {
|
|
168
|
+
// console.log('value', value, this.options.list, this.root)
|
|
169
|
+
var list = this.options.list
|
|
170
|
+
if (this.options.mode === 'unique') {
|
|
171
|
+
for (var i = 0; i < list.length; i++) {
|
|
172
|
+
this.root.querySelector('[data-switcher="' + list[i] + '"]').classList.remove('selected')
|
|
173
|
+
if (list[i] == value) {
|
|
174
|
+
this.selected = [value]
|
|
175
|
+
this.root.querySelector('[data-switcher="' + list[i] + '"]').classList.add('selected')
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
value = value || []
|
|
180
|
+
this.selected = []
|
|
181
|
+
for (var i = 0; i < list.length; i++) {
|
|
182
|
+
this.root.querySelector('[data-switcher="' + list[i] + '"]').classList.remove('selected')
|
|
183
|
+
if (value.indexOf(list[i]) !== -1) {
|
|
184
|
+
this.selected.push(list[i])
|
|
185
|
+
this.root.querySelector('[data-switcher="' + list[i] + '"]').classList.add('selected')
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
addOptions (list) {
|
|
192
|
+
// console.log('setOptions', list, this.options.list)
|
|
193
|
+
|
|
194
|
+
if (!list) return
|
|
195
|
+
|
|
196
|
+
for (var i = 0; i < list.length; i++) {
|
|
197
|
+
this.addOption(list[i])
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
setOptions (list) {
|
|
202
|
+
// console.log('setOptions', list, this.options.list)
|
|
203
|
+
|
|
204
|
+
if (!list) return
|
|
205
|
+
|
|
206
|
+
if (this.options.list.length < 1) this.options.list = list
|
|
207
|
+
|
|
208
|
+
for (var i = 0; i < list.length; i++) {
|
|
209
|
+
this.addOption(list[i])
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
addOption (value) {
|
|
214
|
+
// console.log('addOption', value)
|
|
215
|
+
var item = document.createElement('li')
|
|
216
|
+
item.classList.add('item')
|
|
217
|
+
item.dataset.switcher = value
|
|
218
|
+
item.innerHTML = value
|
|
219
|
+
this.list.appendChild(item)
|
|
220
|
+
// this.options.list.push(list[i])
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
setLabel (value) {
|
|
224
|
+
// console.log('setLabel', value)
|
|
225
|
+
if (this.label) {
|
|
226
|
+
this.label.innerHTML = value
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
setText (value) {
|
|
231
|
+
// console.log('setText', value)
|
|
232
|
+
this.setLabel(value)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
get () {
|
|
236
|
+
// console.log('get', this.selected)
|
|
237
|
+
if (this.options.mode === 'unique') {
|
|
238
|
+
return this.selected[0]
|
|
239
|
+
} else {
|
|
240
|
+
return this.selected
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export default Switcher
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import addClass from './module/addclass'
|
|
2
|
+
|
|
3
|
+
const defaults = {
|
|
4
|
+
class: 'text',
|
|
5
|
+
tag: 'span'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
class Text {
|
|
9
|
+
/**
|
|
10
|
+
* Constructor
|
|
11
|
+
* @param {Object} options - Component options
|
|
12
|
+
* @return {Object} Class instance
|
|
13
|
+
*/
|
|
14
|
+
constructor (options) {
|
|
15
|
+
this.options = Object.assign({}, defaults, options || {})
|
|
16
|
+
|
|
17
|
+
// console.log('options', this.options)
|
|
18
|
+
|
|
19
|
+
this.build()
|
|
20
|
+
|
|
21
|
+
return this
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Build Method
|
|
26
|
+
* @return {Object} This class instance
|
|
27
|
+
*/
|
|
28
|
+
build () {
|
|
29
|
+
this.root = document.createElement(this.options.tag)
|
|
30
|
+
addClass(this.root, this.options.class)
|
|
31
|
+
|
|
32
|
+
if (this.options.class !== 'text') {
|
|
33
|
+
this.root.classList.add('text')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (this.options.text) {
|
|
37
|
+
this.set(this.options.text)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (this.options.container) {
|
|
41
|
+
this.options.container.appendChild(this.root)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return this
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
set (text) {
|
|
48
|
+
// console.log('set', text)
|
|
49
|
+
if (text === undefined) return
|
|
50
|
+
|
|
51
|
+
var label = this.options.label || ''
|
|
52
|
+
|
|
53
|
+
this.root.innerHTML = label + text
|
|
54
|
+
|
|
55
|
+
if (this.options.spaceAfter) {
|
|
56
|
+
this.root.innerHTML = this.root.innerHTML + ' '
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setText (text) {
|
|
61
|
+
// console.log('setText', text)
|
|
62
|
+
this.root.innerHTML = text
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default Text
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
import emitter from '../module/emitter'
|
|
3
|
+
import attach from '../module/attach'
|
|
4
|
+
import dataset from '../view/dataset'
|
|
5
|
+
import attributes from './module/attributes'
|
|
6
|
+
|
|
7
|
+
const defaults = {
|
|
8
|
+
class: 'textfield',
|
|
9
|
+
attributes: ['type', 'name', 'title', 'maxlength', 'pattern', 'min', 'max', 'placeholder', 'readonly', 'autocomplete', 'required', 'disabled'],
|
|
10
|
+
events: [
|
|
11
|
+
['input.input', 'onInput'],
|
|
12
|
+
['input.focus', 'onFocus'],
|
|
13
|
+
['input.blur', 'onBlur'],
|
|
14
|
+
['input.click', 'onClick']
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class Text {
|
|
19
|
+
static isComponent () {
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Constructor
|
|
24
|
+
* @param {Object} options - Component options
|
|
25
|
+
* @return {Object} Class instance
|
|
26
|
+
*/
|
|
27
|
+
constructor (options) {
|
|
28
|
+
this.options = Object.assign({}, defaults, options || {})
|
|
29
|
+
Object.assign(this, emitter, attach, dataset)
|
|
30
|
+
// console.log('options', options)
|
|
31
|
+
|
|
32
|
+
this.build()
|
|
33
|
+
this.attach()
|
|
34
|
+
|
|
35
|
+
return this
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Build Method
|
|
40
|
+
* @return {Object} This class instance
|
|
41
|
+
*/
|
|
42
|
+
build () {
|
|
43
|
+
var tag = this.options.tag || 'div'
|
|
44
|
+
|
|
45
|
+
this.root = document.createElement(tag)
|
|
46
|
+
this.root.classList.add('textfield')
|
|
47
|
+
|
|
48
|
+
if (this.options.class !== 'textfield') {
|
|
49
|
+
this.root.classList.add(this.options.class)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.buildLabel()
|
|
53
|
+
this.buildInput()
|
|
54
|
+
|
|
55
|
+
if (this.options.value) {
|
|
56
|
+
this.set(this.options.value)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (this.options.data) {
|
|
60
|
+
dataset(this.root, this.options.data)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (this.container) {
|
|
64
|
+
this.container.appendChild(this.root)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
buildLabel () {
|
|
71
|
+
if (this.options.label) {
|
|
72
|
+
this.label = document.createElement('label')
|
|
73
|
+
this.label.classList.add('label')
|
|
74
|
+
this.label.innerHTML = this.options.label
|
|
75
|
+
this.root.appendChild(this.label)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
buildInput () {
|
|
80
|
+
let tag = 'input'
|
|
81
|
+
if (this.options.type === 'multiline') {
|
|
82
|
+
tag = 'textarea'
|
|
83
|
+
}
|
|
84
|
+
this.input = document.createElement(tag)
|
|
85
|
+
this.input.classList.add('input')
|
|
86
|
+
this.root.appendChild(this.input)
|
|
87
|
+
|
|
88
|
+
attributes(this.input, this.options)
|
|
89
|
+
|
|
90
|
+
if (this.options.focus) {
|
|
91
|
+
this.input.focus()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
onInput (ev) {
|
|
96
|
+
console.log('onInput', this.value, this.input.value)
|
|
97
|
+
|
|
98
|
+
this.emit('change', ev)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
onFocus (ev) {
|
|
102
|
+
this.root.classList.add('focused')
|
|
103
|
+
this.emit('focus', ev)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onBlur (ev) {
|
|
107
|
+
this.root.classList.remove('focused')
|
|
108
|
+
this.emit('blur', ev)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onClick (ev) {
|
|
112
|
+
console.log('click')
|
|
113
|
+
this.emit('click', ev)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Setter
|
|
118
|
+
* @param {string} prop
|
|
119
|
+
* @param {string} value
|
|
120
|
+
* @return {Object} The class instance
|
|
121
|
+
*/
|
|
122
|
+
set (prop, value) {
|
|
123
|
+
// console.log('set', this.root, prop, value)
|
|
124
|
+
switch (prop) {
|
|
125
|
+
case 'value':
|
|
126
|
+
this.setValue(value)
|
|
127
|
+
break
|
|
128
|
+
case 'label':
|
|
129
|
+
this.setLabel(value)
|
|
130
|
+
break
|
|
131
|
+
default:
|
|
132
|
+
// console.log('prop', prop)
|
|
133
|
+
this.setValue(prop)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return this
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
setValue (value) {
|
|
140
|
+
// console.log('set', typeof value, value)
|
|
141
|
+
if (value && value !== 'undefined') {
|
|
142
|
+
this.value = value
|
|
143
|
+
this.input.value = value
|
|
144
|
+
} else {
|
|
145
|
+
this.input.value = ''
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
setLabel (value) {
|
|
150
|
+
// console.log('setLabel', value)
|
|
151
|
+
if (this.label) {
|
|
152
|
+
this.label.innerHTML = value
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setText (value) {
|
|
157
|
+
this.setLabel(value)
|
|
158
|
+
|
|
159
|
+
if (this.options.placeholder) {
|
|
160
|
+
this.input.placeholder = value
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
hide () {
|
|
165
|
+
this.root.classList.add('hide')
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
show () {
|
|
169
|
+
this.root.classList.remove('hide')
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
get () {
|
|
173
|
+
return this.input.value
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export default Text
|
package/src/field/image.js
CHANGED
|
@@ -20,12 +20,16 @@ const defaults = {
|
|
|
20
20
|
* });
|
|
21
21
|
*/
|
|
22
22
|
class Image {
|
|
23
|
+
static isImage () {
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
23
26
|
/**
|
|
24
27
|
* Constructor
|
|
25
28
|
* @param {Object} options - Component options
|
|
26
29
|
* @return {Object} Class instance
|
|
27
30
|
*/
|
|
28
31
|
constructor (options) {
|
|
32
|
+
// console.log('options', options)
|
|
29
33
|
this.options = Object.assign({}, defaults, options || {})
|
|
30
34
|
|
|
31
35
|
this.build()
|
|
@@ -48,8 +52,10 @@ class Image {
|
|
|
48
52
|
return this
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
set (src) {
|
|
52
|
-
|
|
55
|
+
set (src, asset) {
|
|
56
|
+
console.log('set', src, asset)
|
|
57
|
+
|
|
58
|
+
asset = asset || {}
|
|
53
59
|
|
|
54
60
|
if (!src) return
|
|
55
61
|
|
|
@@ -70,7 +76,7 @@ class Image {
|
|
|
70
76
|
url = url + format
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
this.root.style.backgroundImage = 'url(' + url + src.filename + ')'
|
|
79
|
+
this.root.style.backgroundImage = 'url(' + asset.url + src.path + 'thumb/' + src.filename + ')'
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
sanitize (formats) {
|
package/src/form/build.js
CHANGED
|
@@ -1,15 +1,49 @@
|
|
|
1
|
+
import dataset from '../view/dataset'
|
|
2
|
+
|
|
1
3
|
import Layout from '../layout'
|
|
2
4
|
|
|
3
5
|
export default {
|
|
4
6
|
build () {
|
|
5
7
|
// console.log('build', this.options.layout)
|
|
6
8
|
this.root = document.createElement('div')
|
|
7
|
-
this.root.classList.add('form
|
|
9
|
+
this.root.classList.add('form')
|
|
10
|
+
|
|
11
|
+
if (this.options.class !== 'form') {
|
|
12
|
+
this.root.classList.add(this.options.class)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (this.options.form) {
|
|
16
|
+
this.root.classList.add(this.options.form)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (this.options.data) {
|
|
20
|
+
dataset(this.root, this.options.data)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this.buildForm(this.options.form)
|
|
8
24
|
|
|
25
|
+
this.buildLayout()
|
|
26
|
+
|
|
27
|
+
if (this.options.container) {
|
|
28
|
+
this.options.container.appendChild(this.root)
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
buildForm (form) {
|
|
9
33
|
this.form = document.createElement('form')
|
|
10
34
|
this.root.appendChild(this.form)
|
|
11
35
|
|
|
12
|
-
|
|
36
|
+
if (form && form.method) {
|
|
37
|
+
this.form.setAttribute('method', form.method)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (this.options.autocomplete) {
|
|
41
|
+
this.form.setAttribute('autocomplete', this.options.autocomplete)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (this.options.action) {
|
|
45
|
+
this.form.setAttribute('action', this.options.action)
|
|
46
|
+
}
|
|
13
47
|
},
|
|
14
48
|
|
|
15
49
|
buildLayout () {
|
|
@@ -18,14 +52,20 @@ export default {
|
|
|
18
52
|
this.layout = new Layout(this.options.layout, this.form)
|
|
19
53
|
this.ui = this.layout.component
|
|
20
54
|
|
|
55
|
+
// console.log('ui', this.ui)
|
|
56
|
+
|
|
21
57
|
this.extractInfo(this.ui)
|
|
22
58
|
this.extractFile(this.ui)
|
|
23
59
|
// console.log('file', this.file)
|
|
24
60
|
|
|
25
|
-
this.
|
|
26
|
-
|
|
61
|
+
if (this.disableControl) {
|
|
62
|
+
this.disableControl()
|
|
63
|
+
}
|
|
27
64
|
|
|
28
|
-
|
|
65
|
+
if (this.language) {
|
|
66
|
+
// console.log('translate')
|
|
67
|
+
this.translate()
|
|
68
|
+
}
|
|
29
69
|
},
|
|
30
70
|
|
|
31
71
|
extractFile (object) {
|
|
@@ -47,6 +87,7 @@ export default {
|
|
|
47
87
|
// console.log('extractField', object)
|
|
48
88
|
|
|
49
89
|
this.field = {}
|
|
90
|
+
this.fields = []
|
|
50
91
|
|
|
51
92
|
for (var property in object) {
|
|
52
93
|
if (object.hasOwnProperty(property)) {
|
|
@@ -55,10 +96,23 @@ export default {
|
|
|
55
96
|
if (infos[0] === 'info' && infos[1] !== undefined) {
|
|
56
97
|
var name = property.substr(5, property.length)
|
|
57
98
|
// console.log('field', name, property)
|
|
58
|
-
|
|
99
|
+
this.fields.push(name)
|
|
59
100
|
this.field[name] = object[property]
|
|
60
101
|
}
|
|
61
102
|
}
|
|
62
103
|
}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
clean () {
|
|
107
|
+
// console.log('clean', this.info)
|
|
108
|
+
for (var member in this.info) {
|
|
109
|
+
delete this.info[member]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
this.form.reset()
|
|
113
|
+
|
|
114
|
+
// console.log('cleaned', this.info)
|
|
115
|
+
|
|
116
|
+
this.emit('cleaned')
|
|
63
117
|
}
|
|
64
118
|
}
|
package/src/form/cancel.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
cancel () {
|
|
3
|
-
console.log('cancel', this.info, this.mode)
|
|
2
|
+
cancel (ev) {
|
|
3
|
+
// console.log('cancel', this.info, this.mode)
|
|
4
|
+
ev.preventDefault()
|
|
4
5
|
|
|
5
6
|
this.render(this.info)
|
|
6
7
|
|
|
7
8
|
if (this.mode === 'create') {
|
|
8
|
-
console.log('cancel create')
|
|
9
9
|
this.mode = null
|
|
10
10
|
this.emit('cancel', 'create')
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
this.setMode('read')
|
|
14
|
+
|
|
15
|
+
return false
|
|
12
16
|
}
|
|
13
17
|
}
|