material 0.6.1 → 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 -88
- package/src/control/button.new.js +25 -25
- package/src/control/datehour.js +4 -4
- package/src/control/dialog.js +12 -11
- 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 +25 -35
- package/src/control/loading.js +10 -10
- package/src/control/menu.js +85 -0
- 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 +91 -0
- package/src/control/switch.js +18 -18
- package/src/control/switcher.js +16 -16
- package/src/control/text.js +11 -7
- 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/element.js +6 -31
- 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/mixin/display.js +76 -0
- package/src/mixin/emitter.js +23 -0
- 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 +44 -0
- package/src/{component → module}/classify.js +0 -13
- package/src/module/dataset.js +12 -0
- package/src/module/dom.js +1 -57
- package/src/module/events.js +57 -0
- package/src/module/jsontohtml.js +20 -0
- 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/skin/material/control/menu.sass +29 -0
- package/src/skin/material/control/snackbar.sass +65 -0
- 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 +7 -7
- 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}/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/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,29 @@
|
|
|
1
|
+
.menu
|
|
2
|
+
//display: none
|
|
3
|
+
&.show
|
|
4
|
+
//display: block
|
|
5
|
+
.surface
|
|
6
|
+
background: rgba(0,0,0,.05)
|
|
7
|
+
.list
|
|
8
|
+
background: white
|
|
9
|
+
.item
|
|
10
|
+
color: rgba(0,0,0,.87)
|
|
11
|
+
|
|
12
|
+
&.floating
|
|
13
|
+
position: fixed
|
|
14
|
+
top: 0
|
|
15
|
+
left: 0
|
|
16
|
+
bottom: 0
|
|
17
|
+
right: 0
|
|
18
|
+
background-color: rgba(0, 0, 0, 0.5)
|
|
19
|
+
display: flex
|
|
20
|
+
align-items: center
|
|
21
|
+
justify-content: center
|
|
22
|
+
overflow: hidden
|
|
23
|
+
opacity: 0
|
|
24
|
+
transition: 0.2s
|
|
25
|
+
.surface
|
|
26
|
+
position: absolute
|
|
27
|
+
background-color: white
|
|
28
|
+
|
|
29
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
$width: 500px
|
|
2
|
+
|
|
3
|
+
.snackbars
|
|
4
|
+
position: absolute
|
|
5
|
+
z-index: 300
|
|
6
|
+
display: flex
|
|
7
|
+
width: $width
|
|
8
|
+
flex-direction: column
|
|
9
|
+
background-color: rgba(0,0,0,.1)
|
|
10
|
+
bottom: 160px
|
|
11
|
+
width: 100%
|
|
12
|
+
.snackbar
|
|
13
|
+
overflow: hidden
|
|
14
|
+
display: flex
|
|
15
|
+
opacity: 0
|
|
16
|
+
height: 2px
|
|
17
|
+
flex-direction: row
|
|
18
|
+
padding: 0
|
|
19
|
+
margin: 2px
|
|
20
|
+
background-color: #322F35
|
|
21
|
+
border-radius: 4px
|
|
22
|
+
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2)
|
|
23
|
+
transition: 225ms opacity cubic-bezier(.4,0,.2,1), 225ms height cubic-bezier(.4,0,.2,1), 225ms padding cubic-bezier(.4,0,.2,1)
|
|
24
|
+
&.show
|
|
25
|
+
opacity: 1
|
|
26
|
+
padding: 8px
|
|
27
|
+
height: initial
|
|
28
|
+
transition: 225ms opacity cubic-bezier(.4,0,.2,1), 225ms height cubic-bezier(.4,0,.2,1), 225ms padding cubic-bezier(.4,0,.2,1)
|
|
29
|
+
.text
|
|
30
|
+
line-height: 2em
|
|
31
|
+
padding-left: 8px
|
|
32
|
+
flex: 1
|
|
33
|
+
color: rgba(255,255,255,.87)
|
|
34
|
+
button.action
|
|
35
|
+
flex:none
|
|
36
|
+
display: none
|
|
37
|
+
color: green
|
|
38
|
+
.show
|
|
39
|
+
display: inline-block
|
|
40
|
+
.close
|
|
41
|
+
flex: none
|
|
42
|
+
display: none
|
|
43
|
+
width: 24px
|
|
44
|
+
height: 24px
|
|
45
|
+
min-width: 24px
|
|
46
|
+
background-image: url('../../theme/common/icon/dark/close.svg')
|
|
47
|
+
background-color: transparent
|
|
48
|
+
&:hover, &:active
|
|
49
|
+
background-color: transparent
|
|
50
|
+
&.show
|
|
51
|
+
display: inline-block
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@media only screen and (min-width: $desktop_switch)
|
|
55
|
+
.snackbars
|
|
56
|
+
left: 50%
|
|
57
|
+
bottom: 200px
|
|
58
|
+
margin-left: -$width / 2
|
|
59
|
+
width: $width
|
|
60
|
+
transition: 195ms bottom cubic-bezier(0.4, 0, 0.2, 1)
|
|
61
|
+
&.up
|
|
62
|
+
bottom: 500px
|
|
63
|
+
transition: 225ms bottom cubic-bezier(0.4, 0, 0.2, 1)
|
|
64
|
+
|
|
65
|
+
|
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
|
|
package/src/switch.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
// import control from '../control';
|
|
4
|
-
// import control from './
|
|
4
|
+
// import control from './mixin/control'
|
|
5
5
|
import build from './element/build'
|
|
6
6
|
import emitter from './module/emitter'
|
|
7
|
-
import insert from './
|
|
7
|
+
import insert from './mixin/insert'
|
|
8
8
|
import attach from './module/attach'
|
|
9
|
-
import classify from './
|
|
9
|
+
import classify from './module/classify'
|
|
10
10
|
|
|
11
11
|
let defaults = {
|
|
12
12
|
prefix: 'material',
|
|
@@ -77,9 +77,9 @@ class Switch {
|
|
|
77
77
|
*/
|
|
78
78
|
build () {
|
|
79
79
|
this.element = build(this.options.build)
|
|
80
|
-
this.
|
|
80
|
+
this.element = this.element.root
|
|
81
81
|
|
|
82
|
-
classify(this.
|
|
82
|
+
classify(this.element, this.options)
|
|
83
83
|
|
|
84
84
|
if (this.options.disabled) {
|
|
85
85
|
this.disable()
|
|
@@ -175,7 +175,7 @@ class Switch {
|
|
|
175
175
|
check (checked, silent) {
|
|
176
176
|
// console.log('check', checked, silent)
|
|
177
177
|
if (checked === true) {
|
|
178
|
-
this.
|
|
178
|
+
this.element.classList.add('is-checked')
|
|
179
179
|
this.element.input.checked = true
|
|
180
180
|
this.checked = true
|
|
181
181
|
this.value = true
|
|
@@ -183,7 +183,7 @@ class Switch {
|
|
|
183
183
|
this.emit('change', this.checked)
|
|
184
184
|
}
|
|
185
185
|
} else {
|
|
186
|
-
this.
|
|
186
|
+
this.element.classList.remove('is-checked')
|
|
187
187
|
this.element.input.checked = false
|
|
188
188
|
this.checked = false
|
|
189
189
|
this.value = false
|
|
@@ -201,7 +201,7 @@ class Switch {
|
|
|
201
201
|
focus () {
|
|
202
202
|
if (this.disabled === true) return this
|
|
203
203
|
|
|
204
|
-
this.
|
|
204
|
+
this.element.classList.add('is-focused')
|
|
205
205
|
if (this.element.input !== document.activeElement) { this.element.input.focus() }
|
|
206
206
|
return this
|
|
207
207
|
}
|
|
@@ -211,7 +211,7 @@ class Switch {
|
|
|
211
211
|
* @return {?} [description]
|
|
212
212
|
*/
|
|
213
213
|
blur () {
|
|
214
|
-
this.
|
|
214
|
+
this.element.classList.remove('is-focused')
|
|
215
215
|
return this
|
|
216
216
|
}
|
|
217
217
|
}
|
package/src/tabs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import create from './
|
|
4
|
-
import insert from './
|
|
3
|
+
import create from './mixin/create'
|
|
4
|
+
import insert from './mixin/insert'
|
|
5
5
|
import emitter from './module/emitter'
|
|
6
6
|
|
|
7
7
|
import offset from './element/offset'
|
|
@@ -44,11 +44,11 @@ class Tabs {
|
|
|
44
44
|
* @return {Object} This class instance
|
|
45
45
|
*/
|
|
46
46
|
build () {
|
|
47
|
-
this.
|
|
47
|
+
this.element = create(this.options)
|
|
48
48
|
this.tab = { }
|
|
49
49
|
if (this.options.list) {
|
|
50
50
|
this.list = new List({
|
|
51
|
-
// root: this.
|
|
51
|
+
// root: this.element,
|
|
52
52
|
tag: 'div',
|
|
53
53
|
list: this.options.list,
|
|
54
54
|
target: '.material-button',
|
|
@@ -75,11 +75,11 @@ class Tabs {
|
|
|
75
75
|
this.selected = item
|
|
76
76
|
this.click(item)
|
|
77
77
|
}
|
|
78
|
-
}).insert(this.
|
|
78
|
+
}).insert(this.element)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
this.indicator = create(this.options.indicator)
|
|
82
|
-
this.insertElement(this.indicator, this.
|
|
82
|
+
this.insertElement(this.indicator, this.element)
|
|
83
83
|
|
|
84
84
|
if (this.options.container) {
|
|
85
85
|
this.insert(this.options.container)
|
|
@@ -95,8 +95,8 @@ class Tabs {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
click (item, silent) {
|
|
98
|
-
// console.log('clickitem', item, this.
|
|
99
|
-
var or = offset(this.
|
|
98
|
+
// console.log('clickitem', item, this.element);
|
|
99
|
+
var or = offset(this.element)
|
|
100
100
|
var o = offset(item)
|
|
101
101
|
this.indicator.setAttribute('style', 'width: ' + o.width + 'px; left: ' + (o.left - or.left) + 'px;')
|
|
102
102
|
|
package/src/tabview.js
CHANGED
|
@@ -31,7 +31,7 @@ class TabView {
|
|
|
31
31
|
|
|
32
32
|
var ready = false
|
|
33
33
|
|
|
34
|
-
observer.insert(this.
|
|
34
|
+
observer.insert(this.element, () => {
|
|
35
35
|
// console.log('!!! inserted')
|
|
36
36
|
if (!ready) {
|
|
37
37
|
ready = true
|
|
@@ -46,13 +46,13 @@ class TabView {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
build () {
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
49
|
+
this.element = document.createElement(this.options.tag || 'div')
|
|
50
|
+
this.element.classList.add('tabview')
|
|
51
51
|
|
|
52
|
-
this.
|
|
52
|
+
this.element.classList.add('view')
|
|
53
53
|
|
|
54
54
|
if (this.options.class !== 'tabview') {
|
|
55
|
-
this.
|
|
55
|
+
this.element.classList.add(this.options.class)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
this.ui = {}
|
|
@@ -63,9 +63,9 @@ class TabView {
|
|
|
63
63
|
this.view = {}
|
|
64
64
|
this.views = []
|
|
65
65
|
|
|
66
|
-
this.ui.tabs = this.
|
|
67
|
-
this.ui.view = this.
|
|
68
|
-
this.ui.indicator = this.
|
|
66
|
+
this.ui.tabs = this.element.querySelector('[class="tabs"]')
|
|
67
|
+
this.ui.view = this.element.querySelector('[class="views"]')
|
|
68
|
+
this.ui.indicator = this.element.querySelector('[class="indicator"]')
|
|
69
69
|
|
|
70
70
|
this.ui.buttons = this.ui.tabs.childNodes
|
|
71
71
|
this.ui.views = this.ui.view.childNodes
|
package/src/text.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import create from './
|
|
4
|
-
import insert from './
|
|
3
|
+
import create from './mixin/create'
|
|
4
|
+
import insert from './mixin/insert'
|
|
5
5
|
|
|
6
6
|
var defaults = {
|
|
7
7
|
prefix: 'material',
|
|
@@ -66,7 +66,7 @@ class Text {
|
|
|
66
66
|
build () {
|
|
67
67
|
this.options.tag = this.options.types[this.options.type]
|
|
68
68
|
|
|
69
|
-
this.
|
|
69
|
+
this.element = create(this.options)
|
|
70
70
|
|
|
71
71
|
if (this.options.text) {
|
|
72
72
|
this.set(this.options.text)
|
|
@@ -85,9 +85,9 @@ class Text {
|
|
|
85
85
|
*/
|
|
86
86
|
set (value) {
|
|
87
87
|
if (value) {
|
|
88
|
-
this.
|
|
88
|
+
this.element.textContent = value
|
|
89
89
|
} else {
|
|
90
|
-
this.
|
|
90
|
+
this.element.textContent = ''
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
return this
|