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/image.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
// import insert from './
|
|
3
|
+
// import insert from './mixin/insert'
|
|
4
4
|
import css from './module/css'
|
|
5
5
|
import insert from './element/insert'
|
|
6
|
-
import control from './
|
|
6
|
+
import control from './mixin/control'
|
|
7
7
|
|
|
8
8
|
var defaults = {
|
|
9
9
|
prefix: 'material',
|
|
@@ -50,22 +50,22 @@ class Image {
|
|
|
50
50
|
|
|
51
51
|
var tag = options.tag || 'div'
|
|
52
52
|
var text = options.text || options.label
|
|
53
|
-
this.
|
|
53
|
+
this.element = document.createElement(tag)
|
|
54
54
|
|
|
55
55
|
// if (options.src) {
|
|
56
|
-
// this.
|
|
56
|
+
// this.element.setAttribute('style', 'background-image: url(' + options.src + ')')
|
|
57
57
|
|
|
58
58
|
if (options.src) {
|
|
59
59
|
this.image = document.createElement('img')
|
|
60
60
|
this.image.setAttribute('src', options.src)
|
|
61
61
|
css.add(this.image, this.options.class + '-image')
|
|
62
|
-
insert(this.image, this.
|
|
62
|
+
insert(this.image, this.element)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
this.info = document.createElement('span')
|
|
66
66
|
css.add(this.info, this.options.class + '-info')
|
|
67
67
|
|
|
68
|
-
insert(this.info, this.
|
|
68
|
+
insert(this.info, this.element)
|
|
69
69
|
|
|
70
70
|
this.label(text, this.info)
|
|
71
71
|
|
|
@@ -77,13 +77,13 @@ class Image {
|
|
|
77
77
|
// this.label = document.createElement('span')
|
|
78
78
|
// this.label.innerText = text
|
|
79
79
|
// css.add(this.label, this.options.class + '-label')
|
|
80
|
-
// insert(this.label, this.
|
|
80
|
+
// insert(this.label, this.element)
|
|
81
81
|
// }
|
|
82
82
|
|
|
83
|
-
css.add(this.
|
|
83
|
+
css.add(this.element, this.options.prefix + '-' + this.options.class)
|
|
84
84
|
|
|
85
|
-
if (options.css) { css.add(this.
|
|
86
|
-
// css.add(this.
|
|
85
|
+
if (options.css) { css.add(this.element, options.css) }
|
|
86
|
+
// css.add(this.element, this.options.class + '-adjust');
|
|
87
87
|
|
|
88
88
|
if (this.options.container) {
|
|
89
89
|
this.insert(this.options.container)
|
|
@@ -97,7 +97,7 @@ class Image {
|
|
|
97
97
|
* @return {?} [description]
|
|
98
98
|
*/
|
|
99
99
|
insert (container, context) {
|
|
100
|
-
insert(this.
|
|
100
|
+
insert(this.element, container, context)
|
|
101
101
|
|
|
102
102
|
return this
|
|
103
103
|
}
|
|
@@ -109,10 +109,10 @@ class Image {
|
|
|
109
109
|
*/
|
|
110
110
|
set (value) {
|
|
111
111
|
if (value) {
|
|
112
|
-
if (this.
|
|
113
|
-
this.
|
|
112
|
+
if (this.element.innerText) {
|
|
113
|
+
this.element.innerText = value
|
|
114
114
|
} else {
|
|
115
|
-
this.
|
|
115
|
+
this.element.textContent = value
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
return this
|
package/src/item.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import Layout from './layout'
|
|
4
4
|
|
|
5
|
-
import create from './
|
|
6
|
-
import insert from './
|
|
5
|
+
import create from './mixin/create'
|
|
6
|
+
import insert from './mixin/insert'
|
|
7
7
|
|
|
8
8
|
var defaults = {
|
|
9
9
|
prefix: 'material',
|
|
@@ -70,14 +70,14 @@ class Item {
|
|
|
70
70
|
|
|
71
71
|
this.options.tag = this.options.tag
|
|
72
72
|
|
|
73
|
-
this.
|
|
73
|
+
this.element = create(this.options)
|
|
74
74
|
|
|
75
75
|
if (this.options.text) {
|
|
76
76
|
this.set(this.options.text)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (this.options.layout) {
|
|
80
|
-
this.layout = new Layout(this.options.layout, this.
|
|
80
|
+
this.layout = new Layout(this.options.layout, this.element)
|
|
81
81
|
} else {
|
|
82
82
|
if (this.options.container) {
|
|
83
83
|
this.insert(this.options.container)
|
|
@@ -92,10 +92,10 @@ class Item {
|
|
|
92
92
|
*/
|
|
93
93
|
set (value) {
|
|
94
94
|
if (value) {
|
|
95
|
-
if (this.
|
|
96
|
-
this.
|
|
95
|
+
if (this.element.innerText) {
|
|
96
|
+
this.element.innerText = value
|
|
97
97
|
} else {
|
|
98
|
-
this.
|
|
98
|
+
this.element.textContent = value
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
return this
|
package/src/layout.js
CHANGED
|
@@ -37,10 +37,10 @@ class Layout {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
component = new schema[i](options)
|
|
40
|
-
var element = component.
|
|
40
|
+
var element = component.element || component
|
|
41
41
|
|
|
42
42
|
if (level === 1) {
|
|
43
|
-
structure.
|
|
43
|
+
structure.element = element
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (name) {
|
|
@@ -57,7 +57,7 @@ class Layout {
|
|
|
57
57
|
if (component.insert) {
|
|
58
58
|
component.insert(container)
|
|
59
59
|
} else {
|
|
60
|
-
var wrapper = container.
|
|
60
|
+
var wrapper = container.element || container
|
|
61
61
|
|
|
62
62
|
wrapper.appendChild(element)
|
|
63
63
|
|
|
@@ -98,30 +98,30 @@ class Layout {
|
|
|
98
98
|
// console.log('component', component);
|
|
99
99
|
|
|
100
100
|
if (options.flex) {
|
|
101
|
-
css.add(component.
|
|
101
|
+
css.add(component.element, 'flex-' + options.flex)
|
|
102
102
|
} else {
|
|
103
103
|
var size = options.size
|
|
104
104
|
if (options.size && options.width) {
|
|
105
|
-
component.
|
|
105
|
+
component.element.width = size + 'px'
|
|
106
106
|
} else if (options.size && options.height) {
|
|
107
|
-
component.
|
|
107
|
+
component.element.height = size + 'px'
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if (options.position) {
|
|
112
|
-
component.
|
|
112
|
+
component.element.position = options.position
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
if (options.bottom) {
|
|
116
|
-
component.
|
|
116
|
+
component.element.bottom = options.bottom
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
if (options.hide) {
|
|
120
|
-
component.
|
|
120
|
+
component.element.display = 'none'
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
if (options.theme) {
|
|
124
|
-
css.add(component.
|
|
124
|
+
css.add(component.element, 'theme' + '-' + options.theme)
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
package/src/list/add.js
CHANGED
|
@@ -24,7 +24,7 @@ export default {
|
|
|
24
24
|
this.dataStore[info[this.dataId]] = info
|
|
25
25
|
// console.log('data', this.data.length, this.data)
|
|
26
26
|
|
|
27
|
-
if (window.getComputedStyle(this.
|
|
27
|
+
if (window.getComputedStyle(this.element, null).display === 'none') {
|
|
28
28
|
this.virtual.items = this.data
|
|
29
29
|
} else {
|
|
30
30
|
this.virtual.update(this.data)
|
package/src/list/build.js
CHANGED
|
@@ -11,14 +11,14 @@ export default {
|
|
|
11
11
|
|
|
12
12
|
this.dataId = this.options.dataId || '_id'
|
|
13
13
|
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
14
|
+
this.element = document.createElement('div')
|
|
15
|
+
this.element.classList.add('list')
|
|
16
16
|
|
|
17
17
|
if (this.options.class) {
|
|
18
18
|
this.addClass(this.options.class)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
this.
|
|
21
|
+
this.element.addEventListener('click', (e) => {
|
|
22
22
|
e.stopPropagation()
|
|
23
23
|
})
|
|
24
24
|
|
|
@@ -27,17 +27,17 @@ export default {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (this.options.data) {
|
|
30
|
-
dataset(this.
|
|
30
|
+
dataset(this.element, this.options.data)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
this.layout = new Layout(this.options.layout.main, this.
|
|
33
|
+
this.layout = new Layout(this.options.layout.main, this.element)
|
|
34
34
|
this.ui = this.layout.component
|
|
35
35
|
|
|
36
36
|
// prepare loading
|
|
37
37
|
// this.ui.loading = new Loading()
|
|
38
38
|
|
|
39
39
|
if (this.options.container) {
|
|
40
|
-
this.options.container.appendChild(this.
|
|
40
|
+
this.options.container.appendChild(this.element)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
var scrollbarOffset = scrollbar()
|
|
@@ -56,7 +56,7 @@ export default {
|
|
|
56
56
|
var list = c.split(' ')
|
|
57
57
|
|
|
58
58
|
for (var i = 0; i < list.length; i++) {
|
|
59
|
-
this.
|
|
59
|
+
this.element.classList.add(list[i])
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
|
package/src/list/display.js
CHANGED
|
@@ -10,9 +10,9 @@ export default {
|
|
|
10
10
|
show () {
|
|
11
11
|
// console.log('show', this.visible)
|
|
12
12
|
|
|
13
|
-
this.
|
|
13
|
+
this.element.getBoundingClientRect()
|
|
14
14
|
|
|
15
|
-
this.
|
|
15
|
+
this.element.classList.add('show')
|
|
16
16
|
this.visible = true
|
|
17
17
|
|
|
18
18
|
if (this.underlay) {
|
|
@@ -26,11 +26,11 @@ export default {
|
|
|
26
26
|
},
|
|
27
27
|
|
|
28
28
|
hide () {
|
|
29
|
-
// console.log('hide', this.
|
|
29
|
+
// console.log('hide', this.element.style.display)
|
|
30
30
|
|
|
31
|
-
if (!this.
|
|
31
|
+
if (!this.element) return
|
|
32
32
|
|
|
33
|
-
this.
|
|
33
|
+
this.element.classList.remove('show')
|
|
34
34
|
this.visible = false
|
|
35
35
|
|
|
36
36
|
if (this.underlay) {
|
|
@@ -43,8 +43,8 @@ export default {
|
|
|
43
43
|
|
|
44
44
|
destroy () {
|
|
45
45
|
// console.log('destroy', this.options.transition)
|
|
46
|
-
if (this.options.transition && this.
|
|
47
|
-
this.
|
|
46
|
+
if (this.options.transition && this.element) {
|
|
47
|
+
this.element.classList.remove('show')
|
|
48
48
|
|
|
49
49
|
if (this.underlay) {
|
|
50
50
|
this.underlay.classList.remove('show')
|
|
@@ -63,9 +63,9 @@ export default {
|
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
removeChild () {
|
|
66
|
-
if (this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
66
|
+
if (this.element && this.element.parentNode) {
|
|
67
|
+
this.element.parentNode.removeChild(this.element)
|
|
68
|
+
this.element = null
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (this.underlay && this.underlay.parentNode) {
|
package/src/list/search.js
CHANGED
|
@@ -111,7 +111,7 @@ export default {
|
|
|
111
111
|
|
|
112
112
|
// console.log('showSearch')
|
|
113
113
|
this.mode = 'search'
|
|
114
|
-
this.
|
|
114
|
+
this.element.classList.add('search-mode')
|
|
115
115
|
|
|
116
116
|
if (this.ui.search) {
|
|
117
117
|
this.ui.search.root.classList.add('selected')
|
|
@@ -136,7 +136,7 @@ export default {
|
|
|
136
136
|
hideSearch (notfetch) {
|
|
137
137
|
// console.log('hideSearch', notfetch)
|
|
138
138
|
this.mode = 'standard'
|
|
139
|
-
this.
|
|
139
|
+
this.element.classList.remove('search-mode')
|
|
140
140
|
|
|
141
141
|
if (this.ui.search) {
|
|
142
142
|
this.ui.search.root.classList.remove('selected')
|
package/src/list.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import Item from './item'
|
|
4
4
|
import Divider from './divider'
|
|
5
5
|
|
|
6
|
-
// import init from './
|
|
6
|
+
// import init from './mixin/init'
|
|
7
7
|
import emitter from './module/emitter'
|
|
8
8
|
import insert from './element/insert'
|
|
9
9
|
import css from './module/css'
|
|
@@ -86,19 +86,19 @@ class List {
|
|
|
86
86
|
// define main tag
|
|
87
87
|
var tag = this.options.tag || 'ul'
|
|
88
88
|
|
|
89
|
-
this.
|
|
90
|
-
css.add(this.
|
|
89
|
+
this.element = document.createElement(tag)
|
|
90
|
+
css.add(this.element, 'material-' + this.options.class)
|
|
91
91
|
|
|
92
92
|
if (options.name) {
|
|
93
|
-
css.add(this.
|
|
93
|
+
css.add(this.element, options.class + '-' + options.name)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (options.type) {
|
|
97
|
-
css.add(this.
|
|
97
|
+
css.add(this.element, 'type-' + options.type)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
if (options.layout) {
|
|
101
|
-
css.add(this.
|
|
101
|
+
css.add(this.element, 'layout-' + options.layout)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (this.options.list) {
|
|
@@ -106,10 +106,10 @@ class List {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if (this.options.container) {
|
|
109
|
-
insert(this.
|
|
109
|
+
insert(this.element, this.options.container)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
// this.
|
|
112
|
+
// this.element.addEventListener("click", function(e) {
|
|
113
113
|
// // console.log("list", this, e);
|
|
114
114
|
// // e.target was the clicked element
|
|
115
115
|
// });
|
|
@@ -207,7 +207,7 @@ class List {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
scrollToBottom () {
|
|
210
|
-
this.
|
|
210
|
+
this.element.scrollTop = this.element.scrollHeight - this.element.getBoundingClientRect().height
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
/**
|
|
@@ -221,9 +221,9 @@ class List {
|
|
|
221
221
|
|
|
222
222
|
var where = 'bottom'
|
|
223
223
|
if (item.root) {
|
|
224
|
-
insert(item.root, this.
|
|
224
|
+
insert(item.root, this.element, where)
|
|
225
225
|
} else {
|
|
226
|
-
insert(item, this.
|
|
226
|
+
insert(item, this.element, where)
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
this.items.push(item)
|
|
@@ -232,11 +232,11 @@ class List {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
insert (container, context) {
|
|
235
|
-
insert(this.
|
|
235
|
+
insert(this.element, container, context)
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
empty () {
|
|
239
|
-
this.
|
|
239
|
+
this.element.innerHTML = ''
|
|
240
240
|
this.items = []
|
|
241
241
|
this.item = null
|
|
242
242
|
}
|
package/src/map/build.js
CHANGED
|
@@ -13,11 +13,11 @@ export default {
|
|
|
13
13
|
* @return {void} This class instance
|
|
14
14
|
*/
|
|
15
15
|
build () {
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
16
|
+
this.element = document.createElement(this.options.tag)
|
|
17
|
+
this.element.classList.add(this.options.class)
|
|
18
18
|
|
|
19
19
|
if (this.options.container) {
|
|
20
|
-
this.options.container.appendChild(this.
|
|
20
|
+
this.options.container.appendChild(this.element)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
this.label = document.createElement('div')
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
this.buildMap()
|
|
28
28
|
this.screenSize()
|
|
29
29
|
|
|
30
|
-
observer.insert(this.
|
|
30
|
+
observer.insert(this.element, () => {
|
|
31
31
|
// if (touch()) {
|
|
32
32
|
// // console.log('pinchzoom', this.options.pichZoom)
|
|
33
33
|
// this.draggable = new PinchZoom(this.slide, {
|
|
@@ -58,7 +58,7 @@ export default {
|
|
|
58
58
|
})
|
|
59
59
|
// }
|
|
60
60
|
|
|
61
|
-
this.rect = this.
|
|
61
|
+
this.rect = this.element.getBoundingClientRect()
|
|
62
62
|
|
|
63
63
|
this.screen = {
|
|
64
64
|
y: window.pageYOffset,
|
|
@@ -84,7 +84,7 @@ export default {
|
|
|
84
84
|
// console.log('buildmap')
|
|
85
85
|
this.slide = document.createElement('div')
|
|
86
86
|
this.slide.classList.add('slide')
|
|
87
|
-
this.
|
|
87
|
+
this.element.appendChild(this.slide)
|
|
88
88
|
|
|
89
89
|
this.map = document.createElement('div')
|
|
90
90
|
this.map.classList.add('map')
|
package/src/map/display.js
CHANGED
|
@@ -82,24 +82,24 @@ export default {
|
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
updateRoot () {
|
|
85
|
-
this.offsetX = this.screen.width - this.
|
|
86
|
-
this.offsetY = this.screen.height - this.
|
|
85
|
+
this.offsetX = this.screen.width - this.element.offsetWidth
|
|
86
|
+
this.offsetY = this.screen.height - this.element.offsetHeight
|
|
87
87
|
|
|
88
88
|
// console.log('--', this.offsetX / 2 + 'px')
|
|
89
89
|
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
90
|
+
this.element.style.left = (this.offsetX / 2) + 'px'
|
|
91
|
+
this.element.style.top = (this.offsetY / 2) + 'px'
|
|
92
92
|
|
|
93
93
|
// if (isTouchScreen()) {
|
|
94
|
-
// this.
|
|
94
|
+
// this.element.style.top = (this.offsetY / 2) + 70 + 'px'
|
|
95
95
|
// } else {
|
|
96
|
-
// this.
|
|
96
|
+
// this.element.style.top = -1200 + 'px'
|
|
97
97
|
// }
|
|
98
98
|
},
|
|
99
99
|
|
|
100
100
|
updateMap () {
|
|
101
|
-
var offsetX = this.
|
|
102
|
-
// var offsetY = this.
|
|
101
|
+
var offsetX = this.element.offsetWidth - this.map.offsetWidth
|
|
102
|
+
// var offsetY = this.element.height - this.map.offsetHeight
|
|
103
103
|
|
|
104
104
|
// console.log('--', this.offsetX / 2 + 'px')
|
|
105
105
|
|
package/src/menu.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import classify from './
|
|
3
|
+
import classify from './module/classify'
|
|
4
4
|
import css from './module/css'
|
|
5
|
-
import events from './
|
|
5
|
+
import events from './mixin/events'
|
|
6
6
|
import insert from './element/insert'
|
|
7
7
|
import offset from './element/offset'
|
|
8
8
|
|
|
@@ -66,18 +66,18 @@ class Menu {
|
|
|
66
66
|
* @return {Object} This class instance
|
|
67
67
|
*/
|
|
68
68
|
build () {
|
|
69
|
-
this.
|
|
69
|
+
this.element = create(this.options.tag, this.options.css)
|
|
70
70
|
this.mask = create(this.options.tag, this.options.class + '-mask')
|
|
71
71
|
|
|
72
72
|
if (this.options.position) {
|
|
73
|
-
this.
|
|
73
|
+
this.element.style.position = this.options.position
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
classify(this.
|
|
76
|
+
classify(this.element, this.options)
|
|
77
77
|
|
|
78
78
|
if (this.options.list) {
|
|
79
79
|
this.list = new List({
|
|
80
|
-
// root: this.
|
|
80
|
+
// root: this.element,
|
|
81
81
|
list: this.options.list,
|
|
82
82
|
target: '.material-item',
|
|
83
83
|
height: 600,
|
|
@@ -86,17 +86,17 @@ class Menu {
|
|
|
86
86
|
this.selected = item
|
|
87
87
|
this.hide()
|
|
88
88
|
}
|
|
89
|
-
}).insert(this.
|
|
89
|
+
}).insert(this.element)
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
this.emit('built', this.
|
|
92
|
+
this.emit('built', this.element)
|
|
93
93
|
|
|
94
94
|
return this
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
insert () {
|
|
98
98
|
insert(this.mask, document.body)
|
|
99
|
-
insert(this.
|
|
99
|
+
insert(this.element, document.body)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
setup () {
|
|
@@ -113,7 +113,7 @@ class Menu {
|
|
|
113
113
|
|
|
114
114
|
if (e) this.caller = e.target
|
|
115
115
|
|
|
116
|
-
css.add(this.
|
|
116
|
+
css.add(this.element, this.options.class + '-show')
|
|
117
117
|
this.position(this.caller)
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -121,19 +121,19 @@ class Menu {
|
|
|
121
121
|
if (!this.caller) return
|
|
122
122
|
var offs = offset(this.caller)
|
|
123
123
|
|
|
124
|
-
var offsw = this.offset = offset(this.
|
|
124
|
+
var offsw = this.offset = offset(this.element)
|
|
125
125
|
|
|
126
126
|
// console.log('offset')
|
|
127
127
|
// console.log('caller', this.caller, offs, screen.width)
|
|
128
128
|
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
131
|
-
// this.
|
|
129
|
+
this.element.style.top = offs.top + 'px'
|
|
130
|
+
this.element.style.left = offs.left - offsw.width + offs.width + 'px'
|
|
131
|
+
// this.element.style.right = offs.right + offs.width + offsw.width + 'px'
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
hide () {
|
|
135
135
|
// console.log('hide')
|
|
136
|
-
css.remove(this.
|
|
136
|
+
css.remove(this.element, this.options.class + '-show')
|
|
137
137
|
css.remove(this.mask, 'mask-show')
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -32,12 +32,12 @@ var control = {
|
|
|
32
32
|
*/
|
|
33
33
|
check (checked) {
|
|
34
34
|
if (checked === true) {
|
|
35
|
-
css.add(this.
|
|
35
|
+
css.add(this.element, 'is-checked')
|
|
36
36
|
this.element.input.checked = true
|
|
37
37
|
this.checked = true
|
|
38
38
|
this.emit('change', this.checked)
|
|
39
39
|
} else {
|
|
40
|
-
css.remove(this.
|
|
40
|
+
css.remove(this.element, 'is-checked')
|
|
41
41
|
this.element.input.checked = false
|
|
42
42
|
this.checked = false
|
|
43
43
|
this.emit('change', this.checked)
|
|
@@ -60,7 +60,7 @@ var control = {
|
|
|
60
60
|
|
|
61
61
|
this.element.label.textContent = label
|
|
62
62
|
|
|
63
|
-
container = container || this.
|
|
63
|
+
container = container || this.element
|
|
64
64
|
|
|
65
65
|
insert(this.element.label, container)
|
|
66
66
|
},
|
|
@@ -73,7 +73,7 @@ var control = {
|
|
|
73
73
|
icon (icon, container, position) {
|
|
74
74
|
if (!icon) return
|
|
75
75
|
|
|
76
|
-
container = container || this.
|
|
76
|
+
container = container || this.element
|
|
77
77
|
|
|
78
78
|
position = position || 'top'
|
|
79
79
|
if (this.options.type === 'text-icon') {
|
|
@@ -104,14 +104,14 @@ var control = {
|
|
|
104
104
|
this.element.error.textContent = text
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
insert(this.element.error, this.
|
|
107
|
+
insert(this.element.error, this.element, 'bottom')
|
|
108
108
|
},
|
|
109
109
|
|
|
110
110
|
disable () {
|
|
111
111
|
this.disabled = true
|
|
112
112
|
|
|
113
113
|
this.element.input.setAttribute('disabled', 'disabled')
|
|
114
|
-
css.add(this.
|
|
114
|
+
css.add(this.element, 'is-disabled')
|
|
115
115
|
return this
|
|
116
116
|
},
|
|
117
117
|
|
|
@@ -119,7 +119,7 @@ var control = {
|
|
|
119
119
|
this.disabled = false
|
|
120
120
|
|
|
121
121
|
this.element.input.removeAttribute('disabled')
|
|
122
|
-
css.remove(this.
|
|
122
|
+
css.remove(this.element, 'is-disabled')
|
|
123
123
|
return this
|
|
124
124
|
},
|
|
125
125
|
|
|
@@ -162,7 +162,7 @@ var control = {
|
|
|
162
162
|
},
|
|
163
163
|
|
|
164
164
|
getName () {
|
|
165
|
-
return this.
|
|
165
|
+
return this.element.dataset.name
|
|
166
166
|
},
|
|
167
167
|
|
|
168
168
|
/**
|
|
@@ -172,7 +172,7 @@ var control = {
|
|
|
172
172
|
focus () {
|
|
173
173
|
if (this.disabled === true) return this
|
|
174
174
|
|
|
175
|
-
css.add(this.
|
|
175
|
+
css.add(this.element, 'is-focused')
|
|
176
176
|
if (this.element.input !== document.activeElement) { this.element.input.focus() }
|
|
177
177
|
return this
|
|
178
178
|
},
|
|
@@ -182,7 +182,7 @@ var control = {
|
|
|
182
182
|
* @return {?} [description]
|
|
183
183
|
*/
|
|
184
184
|
blur () {
|
|
185
|
-
css.remove(this.
|
|
185
|
+
css.remove(this.element, 'is-focused')
|
|
186
186
|
return this
|
|
187
187
|
}
|
|
188
188
|
}
|