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/control/list.js
CHANGED
|
@@ -49,10 +49,10 @@ class List {
|
|
|
49
49
|
|
|
50
50
|
var label = this.options.label || ''
|
|
51
51
|
|
|
52
|
-
this.
|
|
52
|
+
this.element.innerHTML = label + text
|
|
53
53
|
|
|
54
54
|
if (this.options.spaceAfter) {
|
|
55
|
-
this.
|
|
55
|
+
this.element.innerHTML = this.element.innerHTML + ' '
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -60,7 +60,7 @@ class List {
|
|
|
60
60
|
|
|
61
61
|
setText (text) {
|
|
62
62
|
// console.log('setText', text)
|
|
63
|
-
this.
|
|
63
|
+
this.element.innerHTML = text
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
package/src/control/loading.js
CHANGED
|
@@ -62,16 +62,16 @@ class Loading {
|
|
|
62
62
|
* @return {Object} This class instance
|
|
63
63
|
*/
|
|
64
64
|
build (options) {
|
|
65
|
-
this.
|
|
65
|
+
this.element = document.createElement(this.options.tag)
|
|
66
66
|
this.classify()
|
|
67
67
|
|
|
68
68
|
if (this.options.type === 'circular') {
|
|
69
|
-
this.
|
|
69
|
+
this.element.innerHTML = this.options.circular
|
|
70
70
|
} if (this.options.type === 'indeterminate') {
|
|
71
71
|
this.bar = document.createElement(this.options.tag)
|
|
72
72
|
this.bar.classList.add('bar')
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
73
|
+
this.element.classList.add('type-indeterminate')
|
|
74
|
+
this.element.appendChild(this.bar)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return this
|
|
@@ -79,16 +79,16 @@ class Loading {
|
|
|
79
79
|
|
|
80
80
|
classify () {
|
|
81
81
|
if (this.options.class !== 'loading') {
|
|
82
|
-
this.
|
|
82
|
+
this.element.setAttribute('class', this.options.class + ' ' + this.options.class)
|
|
83
83
|
} else {
|
|
84
|
-
this.
|
|
84
|
+
this.element.classList.add(this.options.class)
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
append (container) {
|
|
89
89
|
container = container || this.options.container
|
|
90
90
|
if (this.options.container) {
|
|
91
|
-
container.appendChild(this.
|
|
91
|
+
container.appendChild(this.element)
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -101,7 +101,7 @@ class Loading {
|
|
|
101
101
|
|
|
102
102
|
clearTimeout(this.showTimeout)
|
|
103
103
|
this.showTimeout = setTimeout(() => {
|
|
104
|
-
this.
|
|
104
|
+
this.element.classList.add('show')
|
|
105
105
|
}, this.options.delay)
|
|
106
106
|
|
|
107
107
|
this.visible = true
|
|
@@ -110,7 +110,7 @@ class Loading {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
showNow () {
|
|
113
|
-
this.
|
|
113
|
+
this.element.classList.add('show')
|
|
114
114
|
|
|
115
115
|
this.visible
|
|
116
116
|
|
|
@@ -119,7 +119,7 @@ class Loading {
|
|
|
119
119
|
|
|
120
120
|
hide () {
|
|
121
121
|
clearTimeout(this.showTimeout)
|
|
122
|
-
this.
|
|
122
|
+
this.element.classList.remove('show')
|
|
123
123
|
this.visible = false
|
|
124
124
|
return this
|
|
125
125
|
}
|
package/src/control/menu.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import EventEmitter from '../
|
|
1
|
+
import EventEmitter from '../mixin/emitter'
|
|
2
2
|
// menu related modules
|
|
3
3
|
import build from '../module/build'
|
|
4
4
|
import bindEvents from '../module/events'
|
|
5
|
-
import display from '../
|
|
5
|
+
import display from '../mixin/display'
|
|
6
6
|
|
|
7
7
|
import Element from '../element'
|
|
8
8
|
import Button from './button'
|
package/src/control/search.js
CHANGED
|
@@ -40,32 +40,32 @@ class Search {
|
|
|
40
40
|
* @return {Object} This class instance
|
|
41
41
|
*/
|
|
42
42
|
build () {
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
43
|
+
this.element = document.createElement('div')
|
|
44
|
+
this.element.classList.add('search')
|
|
45
45
|
|
|
46
46
|
if (this.options.class !== 'search') {
|
|
47
|
-
this.
|
|
47
|
+
this.element.classList.add(this.options.class)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (this.options.icon) {
|
|
51
51
|
this.icon = document.createElement('i')
|
|
52
52
|
this.icon.classList.add('icon')
|
|
53
53
|
this.icon.innerHTML = this.options.icon
|
|
54
|
-
this.
|
|
54
|
+
this.element.appendChild(this.icon)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
this.input = document.createElement('input')
|
|
58
58
|
this.input.classList.add('input')
|
|
59
|
-
this.
|
|
59
|
+
this.element.appendChild(this.input)
|
|
60
60
|
|
|
61
61
|
this.cancel = new Button({
|
|
62
|
-
container: this.
|
|
62
|
+
container: this.element,
|
|
63
63
|
class: 'clear',
|
|
64
64
|
icon: this.options.iconCancel
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
if (this.options.container) {
|
|
68
|
-
this.options.container.appendChild(this.
|
|
68
|
+
this.options.container.appendChild(this.element)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return this
|
|
@@ -90,8 +90,8 @@ class Search {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
set (email) {
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
93
|
+
this.element.innerHTML = email
|
|
94
|
+
this.element.setAttribute('href', 'mailto:' + email)
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
package/src/control/select.js
CHANGED
|
@@ -32,18 +32,18 @@ class Select {
|
|
|
32
32
|
*/
|
|
33
33
|
build () {
|
|
34
34
|
var tag = this.options.tag || 'span'
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
35
|
+
this.element = document.createElement(tag)
|
|
36
|
+
this.element.classList.add('select')
|
|
37
37
|
|
|
38
38
|
if (this.options.class !== 'select') {
|
|
39
|
-
this.
|
|
39
|
+
this.element.classList.add(this.options.class)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
this.buildLabel()
|
|
43
43
|
this.buildInput()
|
|
44
44
|
|
|
45
45
|
if (this.container) {
|
|
46
|
-
this.container.appendChild(this.
|
|
46
|
+
this.container.appendChild(this.element)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return this
|
|
@@ -54,14 +54,14 @@ class Select {
|
|
|
54
54
|
this.label = document.createElement('span')
|
|
55
55
|
this.label.classList.add('label')
|
|
56
56
|
this.label.innerHTML = this.options.label
|
|
57
|
-
this.
|
|
57
|
+
this.element.appendChild(this.label)
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
buildInput () {
|
|
62
62
|
this.input = document.createElement('select')
|
|
63
63
|
this.input.classList.add('input')
|
|
64
|
-
this.
|
|
64
|
+
this.element.appendChild(this.input)
|
|
65
65
|
|
|
66
66
|
this.input.addEventListener('change', () => {
|
|
67
67
|
// console.log('change', this.input[this.input.selectedIndex].value)
|
package/src/control/selecter.js
CHANGED
|
@@ -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/control/snackbar.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// base class
|
|
2
|
-
import EventEmitter from '../
|
|
2
|
+
import EventEmitter from '../mixin/emitter'
|
|
3
3
|
// related modules
|
|
4
4
|
import build from '../module/build'
|
|
5
5
|
import bindEvents from '../module/events'
|
|
6
|
-
import display from '../
|
|
6
|
+
import display from '../mixin/display'
|
|
7
7
|
// ui element
|
|
8
8
|
import Text from './text'
|
|
9
9
|
import Button from './button'
|
|
@@ -27,7 +27,7 @@ class Snackbar extends EventEmitter {
|
|
|
27
27
|
|
|
28
28
|
constructor (options) {
|
|
29
29
|
super()
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
this.init(options)
|
|
32
32
|
this.build(this.constructor)
|
|
33
33
|
this.render()
|
|
@@ -48,11 +48,11 @@ class Snackbar extends EventEmitter {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
buildSnackbarContainer (container = document.body) {
|
|
51
|
-
console.log('buildSnackbarContainer', container)
|
|
51
|
+
// console.log('buildSnackbarContainer', container)
|
|
52
52
|
|
|
53
53
|
let snackbarContainer = container.querySelector('.snackbars')
|
|
54
54
|
|
|
55
|
-
console.log('snackbarContainer', snackbarContainer)
|
|
55
|
+
// console.log('snackbarContainer', snackbarContainer)
|
|
56
56
|
|
|
57
57
|
if (!snackbarContainer) {
|
|
58
58
|
this.options.container = document.createElement('div')
|
|
@@ -65,6 +65,7 @@ class Snackbar extends EventEmitter {
|
|
|
65
65
|
|
|
66
66
|
render () {
|
|
67
67
|
this.ui.text.set(this.options.text)
|
|
68
|
+
|
|
68
69
|
if (this.options.action) {
|
|
69
70
|
this.ui.action.set(this.options.action)
|
|
70
71
|
this.ui.action.element.classList.add('show')
|
|
@@ -76,6 +77,7 @@ class Snackbar extends EventEmitter {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
action () {
|
|
80
|
+
// console.log('action')
|
|
79
81
|
this.emit('action')
|
|
80
82
|
this.destroy()
|
|
81
83
|
}
|
package/src/control/switch.js
CHANGED
|
@@ -50,14 +50,14 @@ class Switch {
|
|
|
50
50
|
*/
|
|
51
51
|
build () {
|
|
52
52
|
var tag = this.options.tag || 'span'
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
53
|
+
this.element = document.createElement(tag)
|
|
54
|
+
this.element.classList.add('switch')
|
|
55
55
|
|
|
56
56
|
if (this.options.class !== 'switch') {
|
|
57
|
-
addClass(this.
|
|
57
|
+
addClass(this.element, this.options.class)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
this.layout = new Layout(this.options.layout, this.
|
|
60
|
+
this.layout = new Layout(this.options.layout, this.element)
|
|
61
61
|
this.ui = this.layout.component
|
|
62
62
|
|
|
63
63
|
// console.log('ui', this.ui)
|
|
@@ -68,13 +68,13 @@ class Switch {
|
|
|
68
68
|
this.buildLabel()
|
|
69
69
|
|
|
70
70
|
if (this.options.container) {
|
|
71
|
-
this.options.container.appendChild(this.
|
|
71
|
+
this.options.container.appendChild(this.element)
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
setup () {
|
|
76
76
|
if (this.options.data) {
|
|
77
|
-
dataset(this.
|
|
77
|
+
dataset(this.element, this.options.data)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// console.log('attribute', this.ui.input, this.options)
|
|
@@ -89,13 +89,13 @@ class Switch {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
if (this.options.tooltip) {
|
|
92
|
-
this.
|
|
92
|
+
this.element.setAttribute('data-tooltip', this.options.tooltip)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
this.ui.input.setAttribute('aria-label', this.options.name)
|
|
96
96
|
|
|
97
97
|
if (this.options.case) {
|
|
98
|
-
this.
|
|
98
|
+
this.element.classList.add(this.options.case + '-case')
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -111,7 +111,7 @@ class Switch {
|
|
|
111
111
|
this.ui.label.setAttribute('for', this.options.name)
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
this.
|
|
114
|
+
this.element.insertBefore(this.ui.label, this.ui.input)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
buildIcon () {
|
|
@@ -121,24 +121,24 @@ class Switch {
|
|
|
121
121
|
this.ui.icon.classList.add('icon')
|
|
122
122
|
this.ui.icon.innerHTML = this.options.icon
|
|
123
123
|
|
|
124
|
-
this.
|
|
124
|
+
this.element.insertBefore(this.ui.icon, this.ui.input)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
styleAttributes () {
|
|
128
128
|
if (this.options.style) {
|
|
129
|
-
this.
|
|
129
|
+
this.element.classList.add('style-' + this.options.style)
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
if (this.options.size) {
|
|
133
|
-
this.
|
|
133
|
+
this.element.classList.add(this.options.size + '-size')
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
if (this.options.color) {
|
|
137
|
-
this.
|
|
137
|
+
this.element.classList.add('color-' + this.options.color)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
if (this.options.bold) {
|
|
141
|
-
this.
|
|
141
|
+
this.element.classList.add('bold')
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -228,7 +228,7 @@ class Switch {
|
|
|
228
228
|
check (checked, silent) {
|
|
229
229
|
// console.log('check', checked, silent)
|
|
230
230
|
if (checked === true) {
|
|
231
|
-
this.
|
|
231
|
+
this.element.classList.add('is-checked')
|
|
232
232
|
this.ui.input.checked = true
|
|
233
233
|
this.checked = true
|
|
234
234
|
this.value = true
|
|
@@ -236,7 +236,7 @@ class Switch {
|
|
|
236
236
|
this.emit('change', this.checked)
|
|
237
237
|
}
|
|
238
238
|
} else {
|
|
239
|
-
this.
|
|
239
|
+
this.element.classList.remove('is-checked')
|
|
240
240
|
this.ui.input.checked = false
|
|
241
241
|
this.checked = false
|
|
242
242
|
this.value = false
|
|
@@ -254,7 +254,7 @@ class Switch {
|
|
|
254
254
|
focus () {
|
|
255
255
|
if (this.disabled === true) return this
|
|
256
256
|
|
|
257
|
-
this.
|
|
257
|
+
this.element.classList.add('is-focused')
|
|
258
258
|
if (this.ui.input !== document.activeElement) { this.ui.input.focus() }
|
|
259
259
|
return this
|
|
260
260
|
}
|
|
@@ -264,7 +264,7 @@ class Switch {
|
|
|
264
264
|
* @return {?} [description]
|
|
265
265
|
*/
|
|
266
266
|
blur () {
|
|
267
|
-
this.
|
|
267
|
+
this.element.classList.remove('is-focused')
|
|
268
268
|
return this
|
|
269
269
|
}
|
|
270
270
|
}
|
package/src/control/switcher.js
CHANGED
|
@@ -30,26 +30,26 @@ class Switcher {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
build () {
|
|
33
|
-
this.
|
|
33
|
+
this.element = document.createElement(this.options.tag)
|
|
34
34
|
|
|
35
35
|
if (this.options.class !== 'button') {
|
|
36
|
-
this.
|
|
36
|
+
this.element.setAttribute('class', 'switcher ' + this.options.class)
|
|
37
37
|
} else {
|
|
38
|
-
this.
|
|
38
|
+
this.element.classList.add('switcher')
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (this.options.label) {
|
|
42
42
|
this.label = document.createElement('label')
|
|
43
43
|
this.label.innerHTML = this.options.label
|
|
44
|
-
this.
|
|
44
|
+
this.element.appendChild(this.label)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
this.knob = document.createElement('span')
|
|
48
48
|
this.knob.classList.add('knob')
|
|
49
|
-
this.
|
|
49
|
+
this.element.appendChild(this.knob)
|
|
50
50
|
|
|
51
51
|
if (this.options.size) {
|
|
52
|
-
this.
|
|
52
|
+
this.element.classList.add(this.options.size + '-size')
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
this.buildList(this.options.list)
|
|
@@ -59,17 +59,17 @@ class Switcher {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (this.options.container) {
|
|
62
|
-
this.options.container.appendChild(this.
|
|
62
|
+
this.options.container.appendChild(this.element)
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
buildList (list) {
|
|
67
67
|
this.list = document.createElement('ul')
|
|
68
|
-
this.
|
|
68
|
+
this.element.appendChild(this.list)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
attach () {
|
|
72
|
-
this.
|
|
72
|
+
this.element.addEventListener('click', (event) => {
|
|
73
73
|
if (!event.target.dataset.switcher) return
|
|
74
74
|
this.select(event.target)
|
|
75
75
|
})
|
|
@@ -97,7 +97,7 @@ class Switcher {
|
|
|
97
97
|
|
|
98
98
|
selectByName (name) {
|
|
99
99
|
// console.log('selectByName', name)
|
|
100
|
-
var item = this.
|
|
100
|
+
var item = this.element.querySelector('[data-switcher="' + name + '"]')
|
|
101
101
|
// console.log('item', item)
|
|
102
102
|
if (item) {
|
|
103
103
|
this.select(item)
|
|
@@ -106,7 +106,7 @@ class Switcher {
|
|
|
106
106
|
|
|
107
107
|
preSelectByName (name) {
|
|
108
108
|
// console.log('selectByName', name)
|
|
109
|
-
var item = this.
|
|
109
|
+
var item = this.element.querySelector('[data-switcher="' + name + '"]')
|
|
110
110
|
// console.log('item', item)
|
|
111
111
|
this.preselect(item)
|
|
112
112
|
}
|
|
@@ -165,24 +165,24 @@ class Switcher {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
setValue (value) {
|
|
168
|
-
// console.log('value', value, this.options.list, this.
|
|
168
|
+
// console.log('value', value, this.options.list, this.element)
|
|
169
169
|
var list = this.options.list
|
|
170
170
|
if (this.options.mode === 'unique') {
|
|
171
171
|
for (var i = 0; i < list.length; i++) {
|
|
172
|
-
this.
|
|
172
|
+
this.element.querySelector('[data-switcher="' + list[i] + '"]').classList.remove('selected')
|
|
173
173
|
if (list[i] == value) {
|
|
174
174
|
this.selected = [value]
|
|
175
|
-
this.
|
|
175
|
+
this.element.querySelector('[data-switcher="' + list[i] + '"]').classList.add('selected')
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
} else {
|
|
179
179
|
value = value || []
|
|
180
180
|
this.selected = []
|
|
181
181
|
for (var i = 0; i < list.length; i++) {
|
|
182
|
-
this.
|
|
182
|
+
this.element.querySelector('[data-switcher="' + list[i] + '"]').classList.remove('selected')
|
|
183
183
|
if (value.indexOf(list[i]) !== -1) {
|
|
184
184
|
this.selected.push(list[i])
|
|
185
|
-
this.
|
|
185
|
+
this.element.querySelector('[data-switcher="' + list[i] + '"]').classList.add('selected')
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
}
|
package/src/control/text.js
CHANGED
|
@@ -26,11 +26,11 @@ class Text {
|
|
|
26
26
|
* @return {Object} This class instance
|
|
27
27
|
*/
|
|
28
28
|
build () {
|
|
29
|
-
this.
|
|
30
|
-
addClass(this.
|
|
29
|
+
this.element = document.createElement(this.options.tag)
|
|
30
|
+
addClass(this.element, this.options.class)
|
|
31
31
|
|
|
32
32
|
if (this.options.class !== 'text') {
|
|
33
|
-
this.
|
|
33
|
+
this.element.classList.add('text')
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (this.options.text) {
|
|
@@ -38,7 +38,7 @@ class Text {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (this.options.container) {
|
|
41
|
-
this.options.container.appendChild(this.
|
|
41
|
+
this.options.container.appendChild(this.element)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return this
|
|
@@ -51,19 +51,19 @@ class Text {
|
|
|
51
51
|
var label = this.options.label || ''
|
|
52
52
|
|
|
53
53
|
if (this.options.textFirst) {
|
|
54
|
-
this.
|
|
54
|
+
this.element.innerHTML = text + label
|
|
55
55
|
} else {
|
|
56
|
-
this.
|
|
56
|
+
this.element.innerHTML = label + text
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (this.options.spaceAfter) {
|
|
60
|
-
this.
|
|
60
|
+
this.element.innerHTML = this.element.innerHTML + ' '
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
setText (text) {
|
|
65
65
|
// console.log('setText', text)
|
|
66
|
-
this.
|
|
66
|
+
this.element.innerHTML = text
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|