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/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
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dom from '../module/dom'
|
|
1
2
|
|
|
2
3
|
export default {
|
|
3
4
|
toggle () {
|
|
@@ -8,7 +9,7 @@ export default {
|
|
|
8
9
|
},
|
|
9
10
|
|
|
10
11
|
show () {
|
|
11
|
-
console.log('show', this.visible)
|
|
12
|
+
// console.log('show', this.visible)
|
|
12
13
|
|
|
13
14
|
// if (this.options.transition) {
|
|
14
15
|
// this.element.style.display = 'initial'
|
|
@@ -28,12 +29,12 @@ export default {
|
|
|
28
29
|
},
|
|
29
30
|
|
|
30
31
|
hide () {
|
|
31
|
-
console.log('hide')
|
|
32
|
+
// console.log('hide')
|
|
32
33
|
// if (this.element.style.display === 'none') return
|
|
33
34
|
// clearTimeout(this.displayTimeout)
|
|
34
|
-
// this._display = getComputedStyle(this.
|
|
35
|
+
// this._display = getComputedStyle(this.element).display
|
|
35
36
|
|
|
36
|
-
if (!this.
|
|
37
|
+
if (!this.element) return
|
|
37
38
|
|
|
38
39
|
this.element.classList.remove('show')
|
|
39
40
|
this.visible = false
|
|
@@ -54,8 +55,8 @@ export default {
|
|
|
54
55
|
},
|
|
55
56
|
|
|
56
57
|
destroy () {
|
|
57
|
-
// console.log('destroy', this.options.transition, this.
|
|
58
|
-
if (this.options.transition && this.
|
|
58
|
+
// console.log('destroy', this.options.transition, this.element)
|
|
59
|
+
if (this.options.transition && this.element) {
|
|
59
60
|
this.element.classList.remove('show')
|
|
60
61
|
|
|
61
62
|
if (this.underlay) {
|
|
@@ -63,26 +64,13 @@ export default {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
setTimeout(() => {
|
|
66
|
-
this.
|
|
67
|
+
dom.destroy(this.element)
|
|
67
68
|
}, this.options.transition)
|
|
68
69
|
} else {
|
|
69
|
-
this.
|
|
70
|
+
dom.destroy(this.element)
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
this.emit?.('destroy')
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
removeChild () {
|
|
76
|
-
if (this.root && this.element.parentNode) {
|
|
77
|
-
this.element.parentNode.removeChild(this.root)
|
|
78
|
-
this.root = null
|
|
79
|
-
}
|
|
80
73
|
|
|
81
|
-
|
|
82
|
-
this.underlay.parentNode.removeChild(this.underlay)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.emit?.('remove')
|
|
86
|
-
return this
|
|
74
|
+
this.emit?.('destroy')
|
|
87
75
|
}
|
|
88
76
|
}
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
* @param {Function} fn [description]
|
|
7
7
|
*/
|
|
8
8
|
addEvent (event, fn) {
|
|
9
|
-
var element = this.
|
|
9
|
+
var element = this.element
|
|
10
10
|
// avoid memory overhead of new anonymous functions for every event handler that's installed
|
|
11
11
|
// by using local functions
|
|
12
12
|
function listenHandler (e) {
|
|
@@ -45,7 +45,7 @@ export default {
|
|
|
45
45
|
* @return {Object} [description]
|
|
46
46
|
*/
|
|
47
47
|
removeEvent (event, fn) {
|
|
48
|
-
var element = this.
|
|
48
|
+
var element = this.element
|
|
49
49
|
|
|
50
50
|
if (element.removeEventListener) {
|
|
51
51
|
element.removeEventListener(event, fn, false)
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
focus () {
|
|
9
9
|
if (this.disabled === true) return this
|
|
10
10
|
|
|
11
|
-
css.add(this.
|
|
11
|
+
css.add(this.element, 'is-focused')
|
|
12
12
|
if (this.element.input !== document.activeElement) { this.element.input.focus() }
|
|
13
13
|
return this
|
|
14
14
|
},
|
|
@@ -18,8 +18,7 @@ export default {
|
|
|
18
18
|
* @return {?} [description]
|
|
19
19
|
*/
|
|
20
20
|
blur () {
|
|
21
|
-
css.remove(this.
|
|
21
|
+
css.remove(this.element, 'is-focused')
|
|
22
22
|
return this
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
|
package/src/module/build.js
CHANGED
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
build () {
|
|
6
6
|
this.element = document.createElement(this.options.tag || 'div')
|
|
7
7
|
// for backward compatibility
|
|
8
|
-
this.
|
|
8
|
+
this.element = this.element
|
|
9
9
|
|
|
10
10
|
const defaults = this.constructor.defaults || {}
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
if (this.options.data) {
|
|
19
|
-
dataset(this.
|
|
19
|
+
dataset(this.element, this.options.data)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
this.container = this.options.container
|
|
@@ -35,7 +35,8 @@ export default {
|
|
|
35
35
|
container.appendChild(this.element)
|
|
36
36
|
},
|
|
37
37
|
|
|
38
|
-
addClass
|
|
38
|
+
addClass (clss) {
|
|
39
|
+
const c = clss.replace(/\s+/g, ' ').trim()
|
|
39
40
|
const list = c.split(' ')
|
|
40
41
|
list.forEach(item => this.element.classList.add(item))
|
|
41
42
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import css from '../module/css'
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Classify component related functions
|
|
5
|
-
* @module component/classify
|
|
6
|
-
* @category component
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Init component class
|
|
11
|
-
* @param {element} element The component root element
|
|
12
|
-
* @param {object} options component class options
|
|
13
|
-
* @return {Instance} The Class instance
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
3
|
function classify (element, options) {
|
|
17
4
|
css.add(element, options.prefix + '-' + options.class)
|
|
18
5
|
|
package/src/module/dom.js
CHANGED
|
@@ -1,98 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
// DOM manipulation function
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Element insertion related methods
|
|
5
|
-
* @module module/dom
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Inserts content specified by the container argument at the end of HTMLElement
|
|
10
|
-
*
|
|
11
|
-
* @param {HTMLElement} container
|
|
12
|
-
* @param {String|HTMLElement} html
|
|
13
|
-
* @return {HTMLElement} inserted element
|
|
14
|
-
*/
|
|
15
3
|
function append (container, element) {
|
|
16
4
|
container.appendChild(element)
|
|
17
5
|
return element
|
|
18
6
|
}
|
|
19
7
|
|
|
20
|
-
/**
|
|
21
|
-
* Inserts content specified by the html argument at the beginning of HTMLElement
|
|
22
|
-
*
|
|
23
|
-
* @param {HTMLElement} container
|
|
24
|
-
* @param {string|HTMLElement} html
|
|
25
|
-
* @returns {HTMLElement} inserted container
|
|
26
|
-
*/
|
|
27
8
|
function prepend (container, element) {
|
|
28
9
|
return container.insertBefore(element, container.firstChild)
|
|
29
10
|
}
|
|
30
11
|
|
|
31
|
-
/**
|
|
32
|
-
* Inserts content specified by the html argument after the HTMLElement
|
|
33
|
-
*
|
|
34
|
-
* @param {HTMLElement} container
|
|
35
|
-
* @returns {HTMLElement} inserted container
|
|
36
|
-
*/
|
|
37
12
|
function after (container, element) {
|
|
38
13
|
return container.parentNode.insertBefore(element, container.nextSibling)
|
|
39
14
|
}
|
|
40
15
|
|
|
41
|
-
/**
|
|
42
|
-
* Inserts content specified by the html argument before the HTMLElement
|
|
43
|
-
*
|
|
44
|
-
* @param {HTMLElement} container
|
|
45
|
-
* @returns {HTMLElement} inserted container
|
|
46
|
-
*/
|
|
47
16
|
function before (container, element) {
|
|
48
17
|
return container.insertBefore(element, container)
|
|
49
18
|
}
|
|
50
19
|
|
|
51
|
-
/**
|
|
52
|
-
* Replaces given html container with content specified in html parameter
|
|
53
|
-
*
|
|
54
|
-
* @param {HTMLElement} container
|
|
55
|
-
* @param {string|HTMLElement} html
|
|
56
|
-
* @returns {HTMLElement} inserted container
|
|
57
|
-
*/
|
|
58
20
|
function replace (container, element) {
|
|
59
21
|
return container.parentNode.replaceChild(element, container)
|
|
60
22
|
}
|
|
61
23
|
|
|
62
|
-
/**
|
|
63
|
-
* Removes HTMLElement from dom tree
|
|
64
|
-
*
|
|
65
|
-
* @param {HTMLElement} container
|
|
66
|
-
* @returns {HTMLElement} removed container
|
|
67
|
-
*/
|
|
68
24
|
function remove (element) {
|
|
69
25
|
var parent = element.parentNode
|
|
70
26
|
return parent.removeChild(element)
|
|
71
27
|
}
|
|
72
28
|
|
|
73
|
-
/**
|
|
74
|
-
* [dispose description]
|
|
75
|
-
* @return {Object} The class instance
|
|
76
|
-
*/
|
|
77
29
|
function dispose (element) {
|
|
78
30
|
var el = element
|
|
79
31
|
return (el.parentNode) ? el.parentNode.removeChild(el) : el
|
|
80
32
|
}
|
|
81
33
|
|
|
82
|
-
/**
|
|
83
|
-
* empty
|
|
84
|
-
* @return {void}
|
|
85
|
-
*/
|
|
86
34
|
function empty (element) {
|
|
87
35
|
while (element.firstChild) {
|
|
88
36
|
element.removeChild(element.firstChild)
|
|
89
37
|
}
|
|
90
38
|
}
|
|
91
39
|
|
|
92
|
-
/**
|
|
93
|
-
* [destroy description]
|
|
94
|
-
* @return {Object} this class
|
|
95
|
-
*/
|
|
96
40
|
function destroy (element) {
|
|
97
41
|
return element.parentNode.removeChild(element)
|
|
98
42
|
}
|