material 0.6.2 → 0.7.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/index.js +11 -2
- package/package.json +1 -1
- package/src/appbar.js +28 -28
- package/src/banner.js +20 -20
- package/src/button.js +18 -19
- package/src/calendar.js +8 -8
- package/src/card.js +4 -4
- package/src/checkbox.js +8 -8
- package/src/component.js +4 -4
- package/src/container.js +4 -4
- package/src/control/button.js +64 -92
- package/src/control/button.new.js +25 -25
- package/src/control/datehour.js +4 -4
- package/src/control/dialog.js +10 -10
- package/src/control/file.js +8 -8
- package/src/control/image.js +6 -6
- package/src/control/link.js +9 -9
- package/src/control/list.js +3 -3
- package/src/control/loading.js +10 -10
- package/src/control/menu.js +2 -2
- package/src/control/search.js +9 -9
- package/src/control/select.js +6 -6
- package/src/control/selecter.js +15 -15
- package/src/control/snackbar.js +7 -5
- package/src/control/switch.js +18 -18
- package/src/control/switcher.js +16 -16
- package/src/control/text.js +8 -8
- package/src/control/textfield.js +12 -12
- package/src/dialog.js +19 -19
- package/src/divider.js +4 -4
- package/src/drawer.js +11 -11
- package/src/field/email.js +5 -5
- package/src/field/image.js +4 -4
- package/src/form/build.js +7 -7
- package/src/form.js +6 -6
- package/src/icon.js +8 -8
- package/src/image.js +14 -14
- package/src/item.js +7 -7
- package/src/layout.js +10 -10
- package/src/list/add.js +1 -1
- package/src/list/build.js +7 -7
- package/src/list/display.js +10 -10
- package/src/list/search.js +2 -2
- package/src/list.js +13 -13
- package/src/map/build.js +6 -6
- package/src/map/display.js +8 -8
- package/src/menu.js +15 -15
- package/src/{component → mixin}/control.js +10 -10
- package/src/{component → mixin}/create.js +1 -1
- package/src/{module → mixin}/display.js +10 -22
- package/src/{component → mixin}/events.js +2 -2
- package/src/{component → mixin}/focus.js +2 -3
- package/src/{component → mixin}/insert.js +1 -1
- package/src/module/build.js +4 -3
- package/src/{component → module}/classify.js +0 -13
- package/src/module/dom.js +1 -57
- package/src/module/events.js +4 -2
- package/src/module/last.js +0 -0
- package/src/{component → module}/ripple.js +15 -42
- package/src/progress.js +7 -7
- package/src/select.js +16 -16
- package/src/selector.js +32 -32
- package/src/slider.js +32 -32
- package/src/snackbar.js +8 -8
- package/src/switch.js +9 -9
- package/src/tabs.js +8 -8
- package/src/tabview.js +8 -8
- package/src/text.js +5 -5
- package/src/textfield.js +16 -16
- 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/component/click.js +0 -17
- /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/module/events.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import extract from './extract'
|
|
2
2
|
|
|
3
|
+
function last (str) {}
|
|
4
|
+
|
|
3
5
|
export default {
|
|
4
6
|
bindEvents: function (events) {
|
|
5
|
-
console.log('bindEvents', events)
|
|
7
|
+
// console.log('bindEvents', events)
|
|
6
8
|
events = events || this.options.events
|
|
7
9
|
if (!events) return
|
|
8
10
|
|
|
9
|
-
console.log('attach', events, this)
|
|
11
|
+
// console.log('attach', events, this)
|
|
10
12
|
var instance = this
|
|
11
13
|
events.map((def) => {
|
|
12
14
|
var e = extract.e(instance, def[0])
|
|
File without changes
|
|
@@ -6,40 +6,21 @@ const defaults = {
|
|
|
6
6
|
opacity: ['1', '.3']
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @param {?} container [description]
|
|
12
|
-
* @return {?} [description]
|
|
13
|
-
*/
|
|
14
|
-
function init (instance) {
|
|
15
|
-
instance.on('built', (container) => {
|
|
16
|
-
set(container)
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* this function set the event listener
|
|
22
|
-
* @param {HTMLElement} container [description]
|
|
23
|
-
*/
|
|
24
|
-
function set (container) {
|
|
9
|
+
function init (container) {
|
|
10
|
+
console.log('set', container)
|
|
25
11
|
container.addEventListener('mousedown', (e) => {
|
|
12
|
+
console.log('mousedown')
|
|
26
13
|
show(e)
|
|
27
14
|
})
|
|
28
15
|
}
|
|
29
16
|
|
|
30
|
-
/**
|
|
31
|
-
* show method
|
|
32
|
-
* @param {event} e The event related to the the touch
|
|
33
|
-
* @param {Object} coord
|
|
34
|
-
* @return {void}
|
|
35
|
-
*/
|
|
36
17
|
function show (e) {
|
|
37
|
-
|
|
18
|
+
console.log('show', e)
|
|
38
19
|
var container = e.target
|
|
39
20
|
var offs = offset(container)
|
|
40
21
|
|
|
41
22
|
let ripple = document.createElement('div')
|
|
42
|
-
ripple.classList.add('
|
|
23
|
+
ripple.classList.add('ripple')
|
|
43
24
|
let end = coordinate(offs)
|
|
44
25
|
let initial = {
|
|
45
26
|
left: (e.offsetX || offs.width / 2) + 'px',
|
|
@@ -67,24 +48,6 @@ function show (e) {
|
|
|
67
48
|
}
|
|
68
49
|
}
|
|
69
50
|
|
|
70
|
-
/**
|
|
71
|
-
* this method hides the given ripple
|
|
72
|
-
* @return {Object} Size and position
|
|
73
|
-
*/
|
|
74
|
-
function destroy (ripple) {
|
|
75
|
-
if (ripple.parentNode) { ripple.style.opacity = '0' }
|
|
76
|
-
|
|
77
|
-
document.body.onmouseup = null
|
|
78
|
-
|
|
79
|
-
setTimeout(() => {
|
|
80
|
-
if (ripple.parentNode) { ripple.parentNode.removeChild(ripple) }
|
|
81
|
-
}, 1000)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get ripple final coordinates
|
|
86
|
-
* @return {Object} Size and position
|
|
87
|
-
*/
|
|
88
51
|
function coordinate (o) {
|
|
89
52
|
var size = o.height
|
|
90
53
|
var top = -o.height / 2
|
|
@@ -101,4 +64,14 @@ function coordinate (o) {
|
|
|
101
64
|
}
|
|
102
65
|
}
|
|
103
66
|
|
|
67
|
+
function destroy (ripple) {
|
|
68
|
+
if (ripple.parentNode) { ripple.style.opacity = '0' }
|
|
69
|
+
|
|
70
|
+
document.body.onmouseup = null
|
|
71
|
+
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
if (ripple.parentNode) { ripple.parentNode.removeChild(ripple) }
|
|
74
|
+
}, 1000)
|
|
75
|
+
}
|
|
76
|
+
|
|
104
77
|
export default init
|
package/src/progress.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// import Component from './component';
|
|
4
4
|
import create from './element/create'
|
|
5
|
-
import classify from './
|
|
5
|
+
import classify from './module/classify'
|
|
6
6
|
import css from './module/css'
|
|
7
7
|
import insert from './element/insert'
|
|
8
8
|
|
|
@@ -55,23 +55,23 @@ class Spinner {
|
|
|
55
55
|
* @return {Object} This class instance
|
|
56
56
|
*/
|
|
57
57
|
build (options) {
|
|
58
|
-
this.
|
|
59
|
-
classify(this.
|
|
58
|
+
this.element = create(this.options.tag)
|
|
59
|
+
classify(this.element, this.options)
|
|
60
60
|
|
|
61
61
|
if (this.options.type === 'circular') {
|
|
62
|
-
this.
|
|
62
|
+
this.element.innerHTML = this.options.circular
|
|
63
63
|
} if (this.options.type === 'indeterminate') {
|
|
64
64
|
this.bar = create('div', 'bar')
|
|
65
|
-
insert(this.bar, this.
|
|
65
|
+
insert(this.bar, this.element)
|
|
66
66
|
} else {
|
|
67
67
|
this.bar = create('div', 'bar')
|
|
68
|
-
insert(this.bar, this.
|
|
68
|
+
insert(this.bar, this.element)
|
|
69
69
|
|
|
70
70
|
this.set(this.options.progress)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (this.options.container) {
|
|
74
|
-
insert(this.
|
|
74
|
+
insert(this.element, this.options.container)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return this
|
package/src/select.js
CHANGED
|
@@ -65,28 +65,28 @@ class Select {
|
|
|
65
65
|
build () {
|
|
66
66
|
// create a new div as input element
|
|
67
67
|
var tag = this.options.tag || 'div'
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
68
|
+
this.element = document.createElement(tag)
|
|
69
|
+
this.element.classList.add(this.options.prefix + '-' + this.options.class)
|
|
70
70
|
|
|
71
71
|
this.buildLabel()
|
|
72
72
|
this.buildInput()
|
|
73
73
|
this.buildUnderline()
|
|
74
74
|
|
|
75
75
|
if (this.disabled) {
|
|
76
|
-
css.add(this.
|
|
76
|
+
css.add(this.element, 'is-disabled')
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// insert if container this.options is given
|
|
80
80
|
if (this.options.container) {
|
|
81
81
|
// console.log(this.name, opts.container);
|
|
82
|
-
insert(this.
|
|
82
|
+
insert(this.element, this.options.container)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
buildLabel () {
|
|
87
87
|
this.label = document.createElement('label')
|
|
88
88
|
this.label.classList.add(this.options.class + '-label')
|
|
89
|
-
this.
|
|
89
|
+
this.element.appendChild(this.label)
|
|
90
90
|
|
|
91
91
|
if (this.options.label !== false) {
|
|
92
92
|
this.setLabel()
|
|
@@ -101,14 +101,14 @@ class Select {
|
|
|
101
101
|
this.input = document.createElement('select')
|
|
102
102
|
this.input.classList.add(this.options.class + '-input')
|
|
103
103
|
// this.input.setAttribute('type', 'text')
|
|
104
|
-
this.
|
|
104
|
+
this.element.appendChild(this.input)
|
|
105
105
|
|
|
106
106
|
if (this.options.options) {
|
|
107
107
|
this.setOptions(this.options.options)
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// if (!this.options.value) {
|
|
111
|
-
// this.
|
|
111
|
+
// this.element.classList.add('is-empty')
|
|
112
112
|
// }
|
|
113
113
|
|
|
114
114
|
if (this.readonly) {
|
|
@@ -132,7 +132,7 @@ class Select {
|
|
|
132
132
|
buildUnderline () {
|
|
133
133
|
this.underline = document.createElement('span')
|
|
134
134
|
this.underline.classList.add(this.options.class + '-underline')
|
|
135
|
-
this.
|
|
135
|
+
this.element.appendChild(this.underline)
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -185,7 +185,7 @@ class Select {
|
|
|
185
185
|
this.disabled = true
|
|
186
186
|
|
|
187
187
|
this.input.setAttribute('disabled', 'disabled')
|
|
188
|
-
this.
|
|
188
|
+
this.element.classList.add('is-disabled')
|
|
189
189
|
return this
|
|
190
190
|
}
|
|
191
191
|
|
|
@@ -193,7 +193,7 @@ class Select {
|
|
|
193
193
|
this.disabled = false
|
|
194
194
|
|
|
195
195
|
this.element.input.removeAttribute('disabled')
|
|
196
|
-
this.
|
|
196
|
+
this.element.classList.remove('is-disabled')
|
|
197
197
|
return this
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -237,9 +237,9 @@ class Select {
|
|
|
237
237
|
this.input.value = value
|
|
238
238
|
|
|
239
239
|
if (value) {
|
|
240
|
-
this.
|
|
240
|
+
this.element.classList.remove('is-empty')
|
|
241
241
|
} else {
|
|
242
|
-
this.
|
|
242
|
+
this.element.classList.add('is-empty')
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
this.emit('change', value)
|
|
@@ -272,9 +272,9 @@ class Select {
|
|
|
272
272
|
// console.log('_handleInputKeyPress', e);
|
|
273
273
|
|
|
274
274
|
if (this.get('value') === '') {
|
|
275
|
-
this.
|
|
275
|
+
this.element.classList.add('is-empty')
|
|
276
276
|
} else {
|
|
277
|
-
this.
|
|
277
|
+
this.element.classList.remove('is-empty')
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
this.emit('change', this.getValue())
|
|
@@ -293,7 +293,7 @@ class Select {
|
|
|
293
293
|
focus () {
|
|
294
294
|
if (this.disabled === true) return this
|
|
295
295
|
|
|
296
|
-
this.
|
|
296
|
+
this.element.classList.add('is-focused')
|
|
297
297
|
if (this.input !== document.activeElement) { this.input.focus() }
|
|
298
298
|
return this
|
|
299
299
|
}
|
|
@@ -303,7 +303,7 @@ class Select {
|
|
|
303
303
|
* @return {?} [description]
|
|
304
304
|
*/
|
|
305
305
|
blur () {
|
|
306
|
-
this.
|
|
306
|
+
this.element.classList.remove('is-focused')
|
|
307
307
|
return this
|
|
308
308
|
}
|
|
309
309
|
/**
|
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
|
|
package/src/slider.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import init from './
|
|
3
|
+
import init from './mixin/init'
|
|
4
4
|
import build from './element/build'
|
|
5
|
-
import control from './
|
|
5
|
+
import control from './mixin/control'
|
|
6
6
|
|
|
7
|
-
import events from './
|
|
7
|
+
import events from './mixin/events'
|
|
8
8
|
import insert from './element/insert'
|
|
9
9
|
import offset from './element/offset'
|
|
10
|
-
import classify from './
|
|
10
|
+
import classify from './module/classify'
|
|
11
11
|
// import control from './control';
|
|
12
12
|
import attach from './module/attach'
|
|
13
13
|
import css from './module/css'
|
|
@@ -15,7 +15,7 @@ import emitter from './module/emitter'
|
|
|
15
15
|
|
|
16
16
|
import icon from './skin/material/icon/pin.svg'
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const defaults = {
|
|
19
19
|
prefix: 'material',
|
|
20
20
|
class: 'slider',
|
|
21
21
|
type: 'control',
|
|
@@ -84,19 +84,19 @@ class Slider {
|
|
|
84
84
|
*/
|
|
85
85
|
build () {
|
|
86
86
|
this.element = build(this.options.build)
|
|
87
|
-
this.
|
|
87
|
+
this.element = this.element.root
|
|
88
88
|
|
|
89
|
-
classify(this.
|
|
89
|
+
classify(this.element, this.options)
|
|
90
90
|
|
|
91
91
|
if (this.options.container) {
|
|
92
|
-
insert(this.
|
|
92
|
+
insert(this.element, this.options.container)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
const value = this.element.marker.innerHTML
|
|
96
96
|
this.element.marker.innerHTML = icon + value
|
|
97
97
|
|
|
98
98
|
if (this.options.type) {
|
|
99
|
-
css.add(this.
|
|
99
|
+
css.add(this.element, 'type-' + this.options.type)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// init input
|
|
@@ -105,19 +105,19 @@ class Slider {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// if (this.options.name) {
|
|
108
|
-
// this.
|
|
108
|
+
// this.element.dataset.name = name
|
|
109
109
|
// this.element.input.name = name
|
|
110
110
|
// }
|
|
111
111
|
|
|
112
112
|
// init text
|
|
113
|
-
|
|
113
|
+
const text = this.options.label || this.options.text
|
|
114
114
|
this.element.label.textContent = text
|
|
115
115
|
|
|
116
116
|
this.options.label = this.options.label || this.options.text
|
|
117
117
|
|
|
118
118
|
this.initTrack()
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
const delay = 50
|
|
121
121
|
|
|
122
122
|
setTimeout(() => {
|
|
123
123
|
this.initCanvas()
|
|
@@ -133,13 +133,13 @@ class Slider {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
drawCanvas () {
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
const width = offset(this.element.track, 'width')
|
|
137
|
+
const height = offset(this.element.track, 'height')
|
|
138
138
|
|
|
139
139
|
this.element.canvas.width = width
|
|
140
140
|
this.element.canvas.height = height
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
const context = this.element.canvas.getContext('2d')
|
|
143
143
|
context.lineWidth = 2
|
|
144
144
|
context.beginPath()
|
|
145
145
|
|
|
@@ -157,7 +157,7 @@ class Slider {
|
|
|
157
157
|
this.element.track.addEventListener('mousedown', (ev) => {
|
|
158
158
|
if (this.disabled === true) return
|
|
159
159
|
this.initTrackSize()
|
|
160
|
-
|
|
160
|
+
const position = ev.layerX
|
|
161
161
|
this.update(position)
|
|
162
162
|
})
|
|
163
163
|
|
|
@@ -167,7 +167,7 @@ class Slider {
|
|
|
167
167
|
|
|
168
168
|
this.initDragging()
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
const delay = 100
|
|
171
171
|
|
|
172
172
|
setTimeout(() => {
|
|
173
173
|
this.setValue(this.options.value)
|
|
@@ -195,8 +195,8 @@ class Slider {
|
|
|
195
195
|
|
|
196
196
|
css.add(this.element.control, 'dragging')
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
let start = 0
|
|
199
|
+
let position = 0
|
|
200
200
|
|
|
201
201
|
if (e.pageX) start = e.pageX
|
|
202
202
|
else if (e.clientX) start = e.clientX
|
|
@@ -207,7 +207,7 @@ class Slider {
|
|
|
207
207
|
console.log('mousedown', this.disabled)
|
|
208
208
|
|
|
209
209
|
e = e || window.event
|
|
210
|
-
|
|
210
|
+
let end = 0
|
|
211
211
|
if (e.pageX) end = e.pageX
|
|
212
212
|
else if (e.clientX) end = e.clientX
|
|
213
213
|
|
|
@@ -218,7 +218,7 @@ class Slider {
|
|
|
218
218
|
document.body.onmousemove = document.body.onmouseup = null
|
|
219
219
|
|
|
220
220
|
e = e || window.event
|
|
221
|
-
|
|
221
|
+
let end = 0
|
|
222
222
|
if (e.pageX) end = e.pageX
|
|
223
223
|
else if (e.clientX) end = e.clientX
|
|
224
224
|
|
|
@@ -230,8 +230,8 @@ class Slider {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
update (position) {
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
const size = this._tracksize
|
|
234
|
+
const range = this.options.range[1] - this.options.range[0]
|
|
235
235
|
|
|
236
236
|
if (position > size) {
|
|
237
237
|
position = size
|
|
@@ -241,8 +241,8 @@ class Slider {
|
|
|
241
241
|
position = 0
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
const ratio = (size / position)
|
|
245
|
+
const value = Math.round((range / ratio)) + this.options.range[0]
|
|
246
246
|
|
|
247
247
|
if (position === 0) {
|
|
248
248
|
css.remove(this.element.knob, 'notnull')
|
|
@@ -265,12 +265,12 @@ class Slider {
|
|
|
265
265
|
updateValue (value) {
|
|
266
266
|
this.initTrackSize()
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
let size = offset(this.element.track, 'width')
|
|
269
269
|
size = parseInt(size)
|
|
270
270
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
const range = this.options.range[1] - this.options.range[0]
|
|
272
|
+
const ratio = value * 100 / range
|
|
273
|
+
const position = Math.round(size * ratio / 100)
|
|
274
274
|
|
|
275
275
|
this.update(position)
|
|
276
276
|
|
|
@@ -284,7 +284,7 @@ class Slider {
|
|
|
284
284
|
* @return {?} [description]
|
|
285
285
|
*/
|
|
286
286
|
insert (container, context) {
|
|
287
|
-
insert(this.
|
|
287
|
+
insert(this.element, container, context)
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
/**
|
|
@@ -313,7 +313,7 @@ class Slider {
|
|
|
313
313
|
* @param {string} value
|
|
314
314
|
*/
|
|
315
315
|
get (prop) {
|
|
316
|
-
|
|
316
|
+
let value
|
|
317
317
|
|
|
318
318
|
switch (prop) {
|
|
319
319
|
case 'value':
|
package/src/snackbar.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
// import modules
|
|
4
|
-
import init from './
|
|
4
|
+
import init from './mixin/init'
|
|
5
5
|
import create from './element/create'
|
|
6
|
-
import insert from './
|
|
7
|
-
import classify from './
|
|
6
|
+
import insert from './mixin/insert'
|
|
7
|
+
import classify from './module/classify'
|
|
8
8
|
// import components
|
|
9
9
|
import Layout from './layout'
|
|
10
10
|
|
|
@@ -40,10 +40,10 @@ class Snackbar {
|
|
|
40
40
|
build () {
|
|
41
41
|
var tag = this.options.tag || 'div'
|
|
42
42
|
|
|
43
|
-
this.
|
|
44
|
-
classify(this.
|
|
43
|
+
this.element = create(tag)
|
|
44
|
+
classify(this.element, this.options)
|
|
45
45
|
|
|
46
|
-
this.layout = new Layout(this.options.layout, this.
|
|
46
|
+
this.layout = new Layout(this.options.layout, this.element)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -52,7 +52,7 @@ class Snackbar {
|
|
|
52
52
|
*/
|
|
53
53
|
show () {
|
|
54
54
|
setTimeout(() => {
|
|
55
|
-
this.
|
|
55
|
+
this.element.classList.add('show')
|
|
56
56
|
}, 10)
|
|
57
57
|
|
|
58
58
|
if (this.options.delay) {
|
|
@@ -63,7 +63,7 @@ class Snackbar {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
hide () {
|
|
66
|
-
this.
|
|
66
|
+
this.element.classList.remove('show')
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|