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/select.js
CHANGED
|
@@ -1,323 +1,108 @@
|
|
|
1
|
-
|
|
1
|
+
import EventEmitter from './mixin/emitter'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import build from './module/build'
|
|
4
4
|
import attach from './module/attach'
|
|
5
|
+
import attributes from './module/attributes'
|
|
6
|
+
import dataset from './view/dataset'
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
['input.focus', 'focus'],
|
|
14
|
-
['input.blur', 'blur'],
|
|
15
|
-
// ['input.keypress', '_handleInputKeyPress',
|
|
16
|
-
['input.keyup', '_handleInputKeyPress']
|
|
17
|
-
// ['input.mouseover', 'mouseover']
|
|
18
|
-
// ['input.change', '_onChange']
|
|
19
|
-
// 'input.keydown': '_handleInputKeyPress'
|
|
20
|
-
|
|
21
|
-
]
|
|
22
|
-
}
|
|
8
|
+
class Select extends EventEmitter {
|
|
9
|
+
static defaults = {
|
|
10
|
+
type: 'list',
|
|
11
|
+
class: 'select',
|
|
12
|
+
first: null,
|
|
13
|
+
attributes: ['type', 'name', 'autocomplete', 'required']
|
|
14
|
+
}
|
|
23
15
|
|
|
24
|
-
/**
|
|
25
|
-
* Textfield class
|
|
26
|
-
* @class
|
|
27
|
-
*/
|
|
28
|
-
class Select {
|
|
29
|
-
/**
|
|
30
|
-
* Constructor
|
|
31
|
-
* @param {Object} options - Component options
|
|
32
|
-
* @return {Object} Class instance
|
|
33
|
-
*/
|
|
34
16
|
constructor (options) {
|
|
35
|
-
|
|
17
|
+
super()
|
|
36
18
|
|
|
37
|
-
this.init()
|
|
19
|
+
this.init(options)
|
|
38
20
|
this.build()
|
|
39
|
-
this.attach()
|
|
40
|
-
|
|
41
|
-
return this
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* init
|
|
46
|
-
* @param {Object} options The class options
|
|
47
|
-
* @return {Object} The class instance
|
|
48
|
-
*/
|
|
49
|
-
init () {
|
|
50
|
-
Object.assign(this, emitter, attach)
|
|
51
|
-
|
|
52
|
-
this.value = this.options.value
|
|
53
|
-
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
mouseover () {
|
|
58
|
-
// console.log('mouseover')
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* [build description]
|
|
63
|
-
* @return {Object} The class instance
|
|
64
|
-
*/
|
|
65
|
-
build () {
|
|
66
|
-
// create a new div as input element
|
|
67
|
-
var tag = this.options.tag || 'div'
|
|
68
|
-
this.root = document.createElement(tag)
|
|
69
|
-
this.root.classList.add(this.options.prefix + '-' + this.options.class)
|
|
70
|
-
|
|
71
21
|
this.buildLabel()
|
|
72
22
|
this.buildInput()
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
if (this.disabled) {
|
|
76
|
-
css.add(this.root, 'is-disabled')
|
|
77
|
-
}
|
|
23
|
+
this.attach()
|
|
24
|
+
}
|
|
78
25
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
insert(this.root, this.options.container)
|
|
83
|
-
}
|
|
26
|
+
init(options) {
|
|
27
|
+
this.options = Object.assign({}, Select.defaults, options || {})
|
|
28
|
+
Object.assign(this, build, attach, dataset)
|
|
84
29
|
}
|
|
85
30
|
|
|
86
31
|
buildLabel () {
|
|
87
|
-
this.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.setLabel()
|
|
32
|
+
if (this.options.label) {
|
|
33
|
+
this.label = document.createElement('span')
|
|
34
|
+
this.label.classList.add('label')
|
|
35
|
+
this.label.innerHTML = this.options.label
|
|
36
|
+
this.element.appendChild(this.label)
|
|
93
37
|
}
|
|
94
38
|
}
|
|
95
39
|
|
|
96
|
-
/**
|
|
97
|
-
* [_initInput description]
|
|
98
|
-
* @return {Object} The class instance
|
|
99
|
-
*/
|
|
100
40
|
buildInput () {
|
|
101
41
|
this.input = document.createElement('select')
|
|
102
|
-
this.input.classList.add(
|
|
103
|
-
|
|
104
|
-
this.root.appendChild(this.input)
|
|
42
|
+
this.input.classList.add('input')
|
|
43
|
+
this.element.appendChild(this.input)
|
|
105
44
|
|
|
106
|
-
|
|
107
|
-
|
|
45
|
+
this.input.addEventListener('change', () => {
|
|
46
|
+
// console.log('change', this.input[this.input.selectedIndex].value)
|
|
47
|
+
this.emit('change', this.input[this.input.selectedIndex].value)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
if (this.options.data) {
|
|
51
|
+
dataset(this.data, this.options.data)
|
|
108
52
|
}
|
|
109
53
|
|
|
110
|
-
|
|
111
|
-
// this.root.classList.add('is-empty')
|
|
112
|
-
// }
|
|
54
|
+
attributes(this.input, this.options)
|
|
113
55
|
|
|
114
|
-
if (this.
|
|
115
|
-
this.
|
|
116
|
-
this.input.setAttribute('tabindex', '-1')
|
|
56
|
+
if (this.options.options) {
|
|
57
|
+
this.setOptions(this.options.options)
|
|
117
58
|
}
|
|
118
|
-
|
|
119
|
-
return this.input
|
|
120
59
|
}
|
|
121
60
|
|
|
122
61
|
setOptions (options) {
|
|
123
|
-
|
|
124
|
-
this.add(options[i], options[i])
|
|
125
|
-
}
|
|
126
|
-
}
|
|
62
|
+
// console.log('buildCountry', this.input)
|
|
127
63
|
|
|
128
|
-
|
|
129
|
-
* _initUnderline
|
|
130
|
-
* @return {Object} The class instance
|
|
131
|
-
*/
|
|
132
|
-
buildUnderline () {
|
|
133
|
-
this.underline = document.createElement('span')
|
|
134
|
-
this.underline.classList.add(this.options.class + '-underline')
|
|
135
|
-
this.root.appendChild(this.underline)
|
|
136
|
-
}
|
|
64
|
+
var first = this.options.first
|
|
137
65
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
* @param {string} prop
|
|
141
|
-
* @param {string} value
|
|
142
|
-
*/
|
|
143
|
-
set (prop, value) {
|
|
144
|
-
switch (prop) {
|
|
145
|
-
case 'value':
|
|
146
|
-
this.setValue(value)
|
|
147
|
-
break
|
|
148
|
-
case 'label':
|
|
149
|
-
this.setLabel(value)
|
|
150
|
-
break
|
|
151
|
-
case 'disabled':
|
|
152
|
-
if (value === true) {
|
|
153
|
-
this.disable()
|
|
154
|
-
} else if (value === false) {
|
|
155
|
-
this.enable()
|
|
156
|
-
}
|
|
157
|
-
break
|
|
158
|
-
default:
|
|
159
|
-
this.setValue(prop)
|
|
66
|
+
if (first && first[0] && first[1]) {
|
|
67
|
+
this.input.options[0] = new Option(first[1], first[0])
|
|
160
68
|
}
|
|
161
69
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* [buildLabel description]
|
|
167
|
-
* @return {Object} The class instance
|
|
168
|
-
*/
|
|
169
|
-
setLabel (label) {
|
|
170
|
-
label = label || this.options.label
|
|
171
|
-
var text
|
|
172
|
-
|
|
173
|
-
if (label === null || label === false) {
|
|
174
|
-
text = ''
|
|
175
|
-
} else if (this.options.label) {
|
|
176
|
-
text = label
|
|
177
|
-
} else {
|
|
178
|
-
text = this.options.name
|
|
70
|
+
for (var i = 0; i < options.length; i++) {
|
|
71
|
+
this.addOption(options[i][1], options[i][0])
|
|
179
72
|
}
|
|
180
|
-
|
|
181
|
-
this.label.textContent = text
|
|
182
73
|
}
|
|
183
74
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.input.setAttribute('disabled', 'disabled')
|
|
188
|
-
this.root.classList.add('is-disabled')
|
|
189
|
-
return this
|
|
75
|
+
addOption (name, value) {
|
|
76
|
+
// console.log('addOption', name, value)
|
|
77
|
+
this.input.options[this.input.options.length] = new Option(name, value)
|
|
190
78
|
}
|
|
191
79
|
|
|
192
|
-
|
|
193
|
-
|
|
80
|
+
set (value) {
|
|
81
|
+
// console.log('set', value)
|
|
82
|
+
this.input.value = value
|
|
194
83
|
|
|
195
|
-
this.element.input.removeAttribute('disabled')
|
|
196
|
-
this.root.classList.remove('is-disabled')
|
|
197
84
|
return this
|
|
198
85
|
}
|
|
199
86
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
*/
|
|
205
|
-
get (prop) {
|
|
206
|
-
var value
|
|
207
|
-
|
|
208
|
-
switch (prop) {
|
|
209
|
-
case 'value':
|
|
210
|
-
value = this.getValue()
|
|
211
|
-
break
|
|
212
|
-
case 'name':
|
|
213
|
-
value = this.name
|
|
214
|
-
break
|
|
215
|
-
default:
|
|
216
|
-
return this.getValue()
|
|
87
|
+
setLabel (value) {
|
|
88
|
+
// console.log('setLabel', value)
|
|
89
|
+
if (this.label) {
|
|
90
|
+
this.label.innerHTML = value
|
|
217
91
|
}
|
|
218
|
-
|
|
219
|
-
return value
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* [getValue description]
|
|
224
|
-
* @return {Object} The class instance
|
|
225
|
-
*/
|
|
226
|
-
getValue () {
|
|
227
|
-
// console.log('getValue', this);
|
|
228
|
-
return this.input.value
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* [setValue description]
|
|
233
|
-
* @param {string} value [description]
|
|
234
|
-
*/
|
|
235
|
-
setValue (value) {
|
|
236
|
-
// console.log('setValue', this.options.name, value)
|
|
237
|
-
this.input.value = value
|
|
238
|
-
|
|
239
|
-
if (value) {
|
|
240
|
-
this.root.classList.remove('is-empty')
|
|
241
|
-
} else {
|
|
242
|
-
this.root.classList.add('is-empty')
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
this.emit('change', value)
|
|
246
92
|
}
|
|
247
93
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
this.emit('change', ev.target.value)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* [_initValue description]
|
|
256
|
-
* @return {Object} The class instance
|
|
257
|
-
*/
|
|
258
|
-
_initValue () {
|
|
259
|
-
var opts = this.options
|
|
260
|
-
|
|
261
|
-
// create a new div as input element
|
|
262
|
-
if (opts.value) {
|
|
263
|
-
this.setValue(opts.value)
|
|
264
|
-
}
|
|
94
|
+
setText (value) {
|
|
95
|
+
this.setLabel(value)
|
|
265
96
|
}
|
|
266
97
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
* @return {Object} The class instance
|
|
270
|
-
*/
|
|
271
|
-
_handleInputKeyPress (e) {
|
|
272
|
-
// console.log('_handleInputKeyPress', e);
|
|
98
|
+
get () {
|
|
99
|
+
var value = null
|
|
273
100
|
|
|
274
|
-
if (this.
|
|
275
|
-
this.
|
|
276
|
-
} else {
|
|
277
|
-
this.root.classList.remove('is-empty')
|
|
101
|
+
if (this.input[this.input.selectedIndex]) {
|
|
102
|
+
value = this.input[this.input.selectedIndex].value
|
|
278
103
|
}
|
|
279
104
|
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
add (key, value, selected) {
|
|
284
|
-
selected = selected || false
|
|
285
|
-
var select = this.input
|
|
286
|
-
select.options[select.options.length] = new Option(value, key, selected, selected)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* focus method
|
|
291
|
-
* @return {?} [description]
|
|
292
|
-
*/
|
|
293
|
-
focus () {
|
|
294
|
-
if (this.disabled === true) return this
|
|
295
|
-
|
|
296
|
-
this.root.classList.add('is-focused')
|
|
297
|
-
if (this.input !== document.activeElement) { this.input.focus() }
|
|
298
|
-
return this
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* blur method
|
|
303
|
-
* @return {?} [description]
|
|
304
|
-
*/
|
|
305
|
-
blur () {
|
|
306
|
-
this.root.classList.remove('is-focused')
|
|
307
|
-
return this
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* [setError description]
|
|
311
|
-
* @param {string} error Error description
|
|
312
|
-
*/
|
|
313
|
-
setError (error) {
|
|
314
|
-
if (error) {
|
|
315
|
-
this.addClass('field-error')
|
|
316
|
-
if (this.error) { this.error.set('html', error) }
|
|
317
|
-
} else {
|
|
318
|
-
if (this.error) { this.removeClass('field-error') }
|
|
319
|
-
if (this.error) { this.error.set('html', '') }
|
|
320
|
-
}
|
|
105
|
+
return value
|
|
321
106
|
}
|
|
322
107
|
}
|
|
323
108
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import emitter from '
|
|
2
|
-
import attach from '
|
|
3
|
-
import dataset from '
|
|
1
|
+
import emitter from './module/emitter'
|
|
2
|
+
import attach from './module/attach'
|
|
3
|
+
import dataset from './view/dataset'
|
|
4
4
|
import attributes from './module/attributes'
|
|
5
5
|
import addClass from './module/addclass'
|
|
6
6
|
|
|
7
7
|
// ui
|
|
8
|
-
import Layout from '
|
|
9
|
-
import Element from '
|
|
8
|
+
import Layout from './layout'
|
|
9
|
+
import Element from './element'
|
|
10
10
|
import Button from './button'
|
|
11
11
|
|
|
12
12
|
const defaults = {
|
|
@@ -51,7 +51,7 @@ class Selecter {
|
|
|
51
51
|
|
|
52
52
|
setup () {
|
|
53
53
|
if (this.options.data) {
|
|
54
|
-
dataset(this.
|
|
54
|
+
dataset(this.element, this.options.data)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// console.log('attribute', this.ui.input, this.options)
|
|
@@ -62,7 +62,7 @@ class Selecter {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (this.options.tooltip) {
|
|
65
|
-
this.
|
|
65
|
+
this.element.setAttribute('data-tooltip', this.options.tooltip)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (this.options.label) {
|
|
@@ -72,7 +72,7 @@ class Selecter {
|
|
|
72
72
|
this.ui.input.setAttribute('aria-label', this.options.name)
|
|
73
73
|
|
|
74
74
|
if (this.options.case) {
|
|
75
|
-
this.
|
|
75
|
+
this.element.classList.add(this.options.case + '-case')
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -81,14 +81,14 @@ class Selecter {
|
|
|
81
81
|
*/
|
|
82
82
|
build () {
|
|
83
83
|
var tag = this.options.tag || 'span'
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
84
|
+
this.element = document.createElement(tag)
|
|
85
|
+
this.element.classList.add('selecter')
|
|
86
86
|
|
|
87
87
|
if (this.options.class !== 'selecter') {
|
|
88
|
-
addClass(this.
|
|
88
|
+
addClass(this.element, this.options.class)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
this.layout = new Layout(this.options.layout, this.
|
|
91
|
+
this.layout = new Layout(this.options.layout, this.element)
|
|
92
92
|
this.ui = this.layout.component
|
|
93
93
|
|
|
94
94
|
// console.log('ui', this.ui)
|
|
@@ -99,7 +99,7 @@ class Selecter {
|
|
|
99
99
|
this.setList(this.options.list)
|
|
100
100
|
|
|
101
101
|
if (this.options.container) {
|
|
102
|
-
this.options.container.appendChild(this.
|
|
102
|
+
this.options.container.appendChild(this.element)
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -110,13 +110,13 @@ class Selecter {
|
|
|
110
110
|
this.ui.icon.classList.add('icon')
|
|
111
111
|
this.ui.icon.innerHTML = this.options.icon
|
|
112
112
|
|
|
113
|
-
this.
|
|
113
|
+
this.element.insertBefore(this.ui.icon, this.ui.input)
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
buildInput () {
|
|
117
117
|
this.input = document.createElement('select')
|
|
118
118
|
this.input.classList.add('input')
|
|
119
|
-
this.
|
|
119
|
+
this.element.appendChild(this.input)
|
|
120
120
|
|
|
121
121
|
this.input.addEventListener('change', () => {
|
|
122
122
|
// console.log('change', this.input[this.input.selectedIndex].value)
|
|
@@ -154,19 +154,19 @@ class Selecter {
|
|
|
154
154
|
|
|
155
155
|
styleAttributes () {
|
|
156
156
|
if (this.options.style) {
|
|
157
|
-
this.
|
|
157
|
+
this.element.classList.add('style-' + this.options.style)
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
if (this.options.size) {
|
|
161
|
-
this.
|
|
161
|
+
this.element.classList.add(this.options.size + '-size')
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
if (this.options.color) {
|
|
165
|
-
this.
|
|
165
|
+
this.element.classList.add('color-' + this.options.color)
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
if (this.options.bold) {
|
|
169
|
-
this.
|
|
169
|
+
this.element.classList.add('bold')
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
showList () {
|
|
@@ -216,7 +216,7 @@ class Selecter {
|
|
|
216
216
|
this.ui.value.innerHTML = this.values[value]
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
this.selected = this.
|
|
219
|
+
this.selected = this.element.querySelector('[data-value=' + value + ']')
|
|
220
220
|
|
|
221
221
|
// console.log('item', this.selected)
|
|
222
222
|
if (this.selected) {
|
package/src/selector.js
CHANGED
|
@@ -44,7 +44,7 @@ class Selector {
|
|
|
44
44
|
this.attach()
|
|
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
|
|
|
@@ -53,30 +53,30 @@ class Selector {
|
|
|
53
53
|
* @return {Object} This class instance
|
|
54
54
|
*/
|
|
55
55
|
build () {
|
|
56
|
-
this.
|
|
56
|
+
this.element = document.createElement(this.options.tag)
|
|
57
57
|
|
|
58
|
-
this.
|
|
58
|
+
this.element.classList.add('selector')
|
|
59
59
|
|
|
60
60
|
if (this.options.class !== 'selector') {
|
|
61
|
-
this.
|
|
61
|
+
this.element.setAttribute('class', this.options.class)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (this.options.modules.indexOf('border') > -1) {
|
|
65
65
|
this.border = document.createElement('div')
|
|
66
66
|
this.border.classList.add('border')
|
|
67
|
-
this.
|
|
67
|
+
this.element.appendChild(this.border)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (this.options.modules.indexOf('label') > -1) {
|
|
71
71
|
this.label = document.createElement('div')
|
|
72
72
|
this.label.classList.add('label')
|
|
73
|
-
this.
|
|
73
|
+
this.element.appendChild(this.label)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (this.options.modules.indexOf('resizer') > -1) {
|
|
77
77
|
this.resizer = document.createElement('div')
|
|
78
78
|
this.resizer.classList.add('resizer')
|
|
79
|
-
this.
|
|
79
|
+
this.element.appendChild(this.resizer)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return this
|
|
@@ -95,7 +95,7 @@ class Selector {
|
|
|
95
95
|
* @return {Object} The class instance
|
|
96
96
|
*/
|
|
97
97
|
set (prop, value) {
|
|
98
|
-
// console.log('set', this.
|
|
98
|
+
// console.log('set', this.element, prop, value)
|
|
99
99
|
switch (prop) {
|
|
100
100
|
case 'target':
|
|
101
101
|
this.setTarget(value)
|
|
@@ -113,21 +113,21 @@ class Selector {
|
|
|
113
113
|
|
|
114
114
|
this.update(this.target)
|
|
115
115
|
|
|
116
|
-
this.
|
|
116
|
+
this.element.classList.remove('hide')
|
|
117
117
|
|
|
118
|
-
// console.log('target', this.
|
|
118
|
+
// console.log('target', this.element, this.target)
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
update (target) {
|
|
122
122
|
target = target || this.target
|
|
123
123
|
if (!target) return
|
|
124
124
|
var coords = target.getBoundingClientRect()
|
|
125
|
-
var pcoords = this.
|
|
125
|
+
var pcoords = this.element.parentNode.getBoundingClientRect()
|
|
126
126
|
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
127
|
+
this.element.style.top = coords.top - pcoords.top + 'px'
|
|
128
|
+
this.element.style.left = coords.left - pcoords.left + 'px'
|
|
129
|
+
this.element.style.width = coords.width + 'px'
|
|
130
|
+
this.element.style.height = coords.height + 'px'
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
@@ -139,11 +139,11 @@ class Selector {
|
|
|
139
139
|
get (prop, value) {
|
|
140
140
|
switch (prop) {
|
|
141
141
|
case 'value':
|
|
142
|
-
return this.
|
|
142
|
+
return this.element.value
|
|
143
143
|
case 'label':
|
|
144
144
|
return this.label.innerHTML
|
|
145
145
|
default:
|
|
146
|
-
return this.
|
|
146
|
+
return this.element.value
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -154,11 +154,11 @@ class Selector {
|
|
|
154
154
|
let width = 0
|
|
155
155
|
let height = 0
|
|
156
156
|
|
|
157
|
-
const offsetX = this.
|
|
158
|
-
const offsetY = this.
|
|
157
|
+
const offsetX = this.element.getBoundingClientRect().x
|
|
158
|
+
const offsetY = this.element.getBoundingClientRect().y
|
|
159
159
|
const element = document.body
|
|
160
160
|
|
|
161
|
-
var ratio = parseInt(this.
|
|
161
|
+
var ratio = parseInt(this.element.style.width, 10) / parseInt(this.element.style.height, 10)
|
|
162
162
|
|
|
163
163
|
this.border.setPointerCapture(ev.pointerId)
|
|
164
164
|
|
|
@@ -184,8 +184,8 @@ class Selector {
|
|
|
184
184
|
if (height < this.options.resizer.minHeight) height = this.options.resizer.minHeight
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
this.
|
|
188
|
-
this.
|
|
187
|
+
this.element.style.width = width + 'px'
|
|
188
|
+
this.element.style.height = height + 'px'
|
|
189
189
|
|
|
190
190
|
this.emit('resize', width, height)
|
|
191
191
|
}
|
|
@@ -195,31 +195,31 @@ class Selector {
|
|
|
195
195
|
|
|
196
196
|
element.onpointermove = null
|
|
197
197
|
element.onpointerup = null
|
|
198
|
-
this.
|
|
198
|
+
this.element.releasePointerCapture(e.pointerId)
|
|
199
199
|
|
|
200
|
-
// if (e.target !== this.
|
|
200
|
+
// if (e.target !== this.element) return
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
disable () {
|
|
205
|
-
this.
|
|
205
|
+
this.element.disabled = true
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
enable () {
|
|
209
|
-
this.
|
|
209
|
+
this.element.disabled = false
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
hide () {
|
|
213
|
-
this.
|
|
213
|
+
this.element.classList.add('hide')
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
show () {
|
|
217
|
-
this.
|
|
217
|
+
this.element.classList.remove('hide')
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
destroy () {
|
|
221
|
-
if (this.
|
|
222
|
-
this.
|
|
221
|
+
if (this.element && this.element.parentNode) {
|
|
222
|
+
this.element.parentNode.removeChild(this.element)
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -228,11 +228,11 @@ class Selector {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
mousedown (ev) {
|
|
231
|
-
this.
|
|
231
|
+
this.element.classList.add('pushed')
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
mouseup (ev) {
|
|
235
|
-
this.
|
|
235
|
+
this.element.classList.remove('pushed')
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.navigation
|
|
@@ -123,3 +123,13 @@
|
|
|
123
123
|
background-color: rgba(0, 0, 0, .1)
|
|
124
124
|
&:focus
|
|
125
125
|
background-color: rgba(0, 0, 0, .1)
|
|
126
|
+
|
|
127
|
+
.ripple
|
|
128
|
+
opacity: 1
|
|
129
|
+
pointer-events: none
|
|
130
|
+
z-index: 1
|
|
131
|
+
position: absolute
|
|
132
|
+
background-color: rgba(255, 255, 255, 0.1)
|
|
133
|
+
height: 5px
|
|
134
|
+
width: 5px
|
|
135
|
+
border-radius: 50%
|