material 0.6.2 → 0.7.1
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/form.js +27 -0
- package/index.js +61 -51
- package/list.js +35 -0
- package/package.json +5 -1
- package/src/appbar.js +7 -204
- package/src/badge.js +27 -0
- package/src/button.js +160 -161
- package/src/calendar.js +8 -10
- package/src/card.js +4 -6
- package/src/checkbox.js +8 -10
- package/src/component.js +4 -6
- package/src/container.js +4 -6
- package/src/datehour.js +38 -0
- package/src/dialog.js +106 -153
- package/src/divider.js +4 -6
- package/src/drawer.js +11 -13
- package/src/field/email.js +5 -5
- package/src/field/image.js +4 -4
- package/src/{control/file.js → file.js} +18 -48
- package/src/form/build.js +7 -7
- package/src/form/verify.js +2 -2
- package/src/form.js +6 -8
- package/src/icon.js +8 -10
- package/src/image.js +39 -106
- package/src/item.js +7 -9
- package/src/layout.js +10 -10
- package/src/link.js +50 -0
- package/src/list/add.js +1 -1
- package/src/list/build.js +9 -9
- package/src/list/collection.js +1 -1
- package/src/list/display.js +10 -10
- package/src/list/filter.js +2 -2
- package/src/list/request.js +1 -1
- package/src/list/search.js +7 -7
- package/src/list.js +29 -217
- package/src/loading.js +73 -0
- package/src/map/build.js +6 -6
- package/src/map/display.js +8 -8
- package/src/menu.js +60 -116
- package/src/{component → mixin}/control.js +10 -10
- package/src/{component → mixin}/create.js +1 -1
- package/src/{module → mixin}/display.js +9 -22
- package/src/{component → mixin}/events.js +2 -2
- package/src/{component → mixin}/focus.js +2 -3
- package/src/{component → mixin}/insert.js +3 -25
- package/src/{control/module → module}/attributes.js +2 -2
- package/src/module/build.js +11 -7
- package/src/{component → module}/classify.js +0 -13
- package/src/module/dom.js +1 -57
- package/src/module/events.js +4 -2
- package/src/{component → module}/ripple.js +15 -42
- package/src/navigation.js +19 -0
- package/src/progress.js +7 -9
- package/src/search.js +71 -0
- package/src/select.js +58 -273
- package/src/{control/selecter.js → selecter.js} +20 -20
- package/src/selector.js +32 -32
- package/src/skin/material/component/navigation.sass +1 -0
- package/src/skin/material/control/button.sass +10 -0
- package/src/slider.js +32 -34
- package/src/snackbar.js +72 -51
- package/src/switch.js +115 -107
- package/src/{control/switcher.js → switcher.js} +33 -36
- package/src/tabs.js +8 -8
- package/src/tabview.js +8 -8
- package/src/text.js +25 -74
- package/src/textfield.js +97 -234
- 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/banner.js +0 -231
- package/src/component/click.js +0 -17
- package/src/control/button.js +0 -267
- package/src/control/button.new.js +0 -190
- package/src/control/datehour.js +0 -65
- package/src/control/dialog.js +0 -175
- package/src/control/image.js +0 -92
- package/src/control/link.js +0 -69
- package/src/control/list.js +0 -67
- package/src/control/loading.js +0 -128
- package/src/control/menu.js +0 -85
- package/src/control/search.js +0 -98
- package/src/control/select.js +0 -130
- package/src/control/snackbar.js +0 -89
- package/src/control/switch.js +0 -272
- package/src/control/text.js +0 -70
- package/src/control/textfield.js +0 -177
- /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/module → module}/addclass.js +0 -0
- /package/src/{tabs/setup.js → module/last.js} +0 -0
|
@@ -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,12 @@ 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
73
|
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
|
-
|
|
81
|
-
if (this.underlay && this.underlay.parentNode) {
|
|
82
|
-
this.underlay.parentNode.removeChild(this.underlay)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.emit?.('remove')
|
|
86
|
-
return this
|
|
87
74
|
}
|
|
88
75
|
}
|
|
@@ -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
|
-
|
|
@@ -2,41 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import dom from '../module/dom'
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Inject method insert element to the domtree using Dom methods
|
|
7
|
-
* @param {HTMLElement} container [description]
|
|
8
|
-
* @param {string} context - Injection context
|
|
9
|
-
* @return {Object} This class intance
|
|
10
|
-
*/
|
|
11
5
|
export default {
|
|
12
6
|
|
|
13
|
-
/**
|
|
14
|
-
* [insert description]
|
|
15
|
-
* @param {?} container [description]
|
|
16
|
-
* @param {?} context [description]
|
|
17
|
-
* @param {?} debug [description]
|
|
18
|
-
* @return {?} [description]
|
|
19
|
-
*/
|
|
20
7
|
insert (container, context) {
|
|
21
|
-
var element = this.
|
|
8
|
+
var element = this.element
|
|
22
9
|
|
|
23
10
|
this.insertElement(element, container, context)
|
|
24
11
|
|
|
25
12
|
return this
|
|
26
13
|
},
|
|
27
14
|
|
|
28
|
-
/**
|
|
29
|
-
* [insertElement description]
|
|
30
|
-
|
|
31
|
-
* @param {?} element [description]
|
|
32
|
-
* @param {?} container [description]
|
|
33
|
-
* @param {?} context [description]
|
|
34
|
-
* @param {?} debug [description]
|
|
35
|
-
* @return {?} [description]
|
|
36
|
-
*/
|
|
37
15
|
insertElement (element, container, context) {
|
|
38
|
-
if (container && container.
|
|
39
|
-
container = container.
|
|
16
|
+
if (container && container.element) {
|
|
17
|
+
container = container.element
|
|
40
18
|
}
|
|
41
19
|
|
|
42
20
|
this.container = container
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const special = ['required', 'disabled', 'multiple', 'checked']
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function attributes (element, o) {
|
|
4
4
|
// console.log('attributes', o.attributes, element)
|
|
5
5
|
|
|
6
6
|
if (!element) return
|
|
@@ -18,4 +18,4 @@ function setAttributes (element, o) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export default
|
|
21
|
+
export default attributes
|
package/src/module/build.js
CHANGED
|
@@ -4,22 +4,26 @@ import Layout from '../layout'
|
|
|
4
4
|
export default {
|
|
5
5
|
build () {
|
|
6
6
|
this.element = document.createElement(this.options.tag || 'div')
|
|
7
|
-
// for backward compatibility
|
|
8
|
-
this.root = this.element
|
|
9
7
|
|
|
10
8
|
const defaults = this.constructor.defaults || {}
|
|
11
9
|
|
|
12
|
-
this.element.classList.add(defaults.
|
|
10
|
+
if (defaults.base) this.element.classList.add(defaults.base)
|
|
11
|
+
|
|
12
|
+
if (defaults.class) this.element.classList.add(defaults.class)
|
|
13
13
|
|
|
14
14
|
if (this.options.class !== defaults.class) {
|
|
15
15
|
this.addClass(this.options.class)
|
|
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
|
+
if (this.options.base === 'view') {
|
|
23
|
+
this.container = this.options.container || document.body
|
|
24
|
+
} else {
|
|
25
|
+
this.container = this.options.container
|
|
26
|
+
}
|
|
23
27
|
|
|
24
28
|
if (this.container) this.appendTo(this.container)
|
|
25
29
|
|
|
@@ -35,9 +39,9 @@ export default {
|
|
|
35
39
|
container.appendChild(this.element)
|
|
36
40
|
},
|
|
37
41
|
|
|
38
|
-
addClass
|
|
42
|
+
addClass (clss) {
|
|
43
|
+
const c = clss.replace(/\s+/g, ' ').trim()
|
|
39
44
|
const list = c.split(' ')
|
|
40
45
|
list.forEach(item => this.element.classList.add(item))
|
|
41
46
|
}
|
|
42
|
-
|
|
43
47
|
}
|
|
@@ -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
|
}
|
package/src/module/events.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import extract from './extract'
|
|
2
2
|
|
|
3
|
+
function last (str) {}
|
|
4
|
+
|
|
3
5
|
export default {
|
|
4
6
|
bindEvents: function (events) {
|
|
5
|
-
console.log('bindEvents', events)
|
|
7
|
+
// console.log('bindEvents', events)
|
|
6
8
|
events = events || this.options.events
|
|
7
9
|
if (!events) return
|
|
8
10
|
|
|
9
|
-
console.log('attach', events, this)
|
|
11
|
+
// console.log('attach', events, this)
|
|
10
12
|
var instance = this
|
|
11
13
|
events.map((def) => {
|
|
12
14
|
var e = extract.e(instance, def[0])
|
|
@@ -6,40 +6,21 @@ const defaults = {
|
|
|
6
6
|
opacity: ['1', '.3']
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @param {?} container [description]
|
|
12
|
-
* @return {?} [description]
|
|
13
|
-
*/
|
|
14
|
-
function init (instance) {
|
|
15
|
-
instance.on('built', (container) => {
|
|
16
|
-
set(container)
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* this function set the event listener
|
|
22
|
-
* @param {HTMLElement} container [description]
|
|
23
|
-
*/
|
|
24
|
-
function set (container) {
|
|
9
|
+
function init (container) {
|
|
10
|
+
console.log('set', container)
|
|
25
11
|
container.addEventListener('mousedown', (e) => {
|
|
12
|
+
console.log('mousedown')
|
|
26
13
|
show(e)
|
|
27
14
|
})
|
|
28
15
|
}
|
|
29
16
|
|
|
30
|
-
/**
|
|
31
|
-
* show method
|
|
32
|
-
* @param {event} e The event related to the the touch
|
|
33
|
-
* @param {Object} coord
|
|
34
|
-
* @return {void}
|
|
35
|
-
*/
|
|
36
17
|
function show (e) {
|
|
37
|
-
|
|
18
|
+
console.log('show', e)
|
|
38
19
|
var container = e.target
|
|
39
20
|
var offs = offset(container)
|
|
40
21
|
|
|
41
22
|
let ripple = document.createElement('div')
|
|
42
|
-
ripple.classList.add('
|
|
23
|
+
ripple.classList.add('ripple')
|
|
43
24
|
let end = coordinate(offs)
|
|
44
25
|
let initial = {
|
|
45
26
|
left: (e.offsetX || offs.width / 2) + 'px',
|
|
@@ -67,24 +48,6 @@ function show (e) {
|
|
|
67
48
|
}
|
|
68
49
|
}
|
|
69
50
|
|
|
70
|
-
/**
|
|
71
|
-
* this method hides the given ripple
|
|
72
|
-
* @return {Object} Size and position
|
|
73
|
-
*/
|
|
74
|
-
function destroy (ripple) {
|
|
75
|
-
if (ripple.parentNode) { ripple.style.opacity = '0' }
|
|
76
|
-
|
|
77
|
-
document.body.onmouseup = null
|
|
78
|
-
|
|
79
|
-
setTimeout(() => {
|
|
80
|
-
if (ripple.parentNode) { ripple.parentNode.removeChild(ripple) }
|
|
81
|
-
}, 1000)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get ripple final coordinates
|
|
86
|
-
* @return {Object} Size and position
|
|
87
|
-
*/
|
|
88
51
|
function coordinate (o) {
|
|
89
52
|
var size = o.height
|
|
90
53
|
var top = -o.height / 2
|
|
@@ -101,4 +64,14 @@ function coordinate (o) {
|
|
|
101
64
|
}
|
|
102
65
|
}
|
|
103
66
|
|
|
67
|
+
function destroy (ripple) {
|
|
68
|
+
if (ripple.parentNode) { ripple.style.opacity = '0' }
|
|
69
|
+
|
|
70
|
+
document.body.onmouseup = null
|
|
71
|
+
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
if (ripple.parentNode) { ripple.parentNode.removeChild(ripple) }
|
|
74
|
+
}, 1000)
|
|
75
|
+
}
|
|
76
|
+
|
|
104
77
|
export default init
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import build from './module/build'
|
|
2
|
+
|
|
3
|
+
class Navigation {
|
|
4
|
+
static defaults = {
|
|
5
|
+
class: 'navigation'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
constructor (options) {
|
|
9
|
+
this.init(options)
|
|
10
|
+
this.build()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
init (options) {
|
|
14
|
+
this.options = Object.assign({}, Navigation.defaults, options || {})
|
|
15
|
+
Object.assign(this, build)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default Navigation
|
package/src/progress.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// import Component from './component';
|
|
4
2
|
import create from './element/create'
|
|
5
|
-
import classify from './
|
|
3
|
+
import classify from './module/classify'
|
|
6
4
|
import css from './module/css'
|
|
7
5
|
import insert from './element/insert'
|
|
8
6
|
|
|
@@ -55,23 +53,23 @@ class Spinner {
|
|
|
55
53
|
* @return {Object} This class instance
|
|
56
54
|
*/
|
|
57
55
|
build (options) {
|
|
58
|
-
this.
|
|
59
|
-
classify(this.
|
|
56
|
+
this.element = create(this.options.tag)
|
|
57
|
+
classify(this.element, this.options)
|
|
60
58
|
|
|
61
59
|
if (this.options.type === 'circular') {
|
|
62
|
-
this.
|
|
60
|
+
this.element.innerHTML = this.options.circular
|
|
63
61
|
} if (this.options.type === 'indeterminate') {
|
|
64
62
|
this.bar = create('div', 'bar')
|
|
65
|
-
insert(this.bar, this.
|
|
63
|
+
insert(this.bar, this.element)
|
|
66
64
|
} else {
|
|
67
65
|
this.bar = create('div', 'bar')
|
|
68
|
-
insert(this.bar, this.
|
|
66
|
+
insert(this.bar, this.element)
|
|
69
67
|
|
|
70
68
|
this.set(this.options.progress)
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
if (this.options.container) {
|
|
74
|
-
insert(this.
|
|
72
|
+
insert(this.element, this.options.container)
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
return this
|
package/src/search.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import EventEmitter from './mixin/emitter'
|
|
2
|
+
|
|
3
|
+
import build from './module/build'
|
|
4
|
+
import bindEvents from './module/events'
|
|
5
|
+
|
|
6
|
+
import Button from './button'
|
|
7
|
+
import cancel from './skin/material/icon/cancel.svg'
|
|
8
|
+
|
|
9
|
+
class Search extends EventEmitter {
|
|
10
|
+
static defaults = {
|
|
11
|
+
class: 'search-input',
|
|
12
|
+
minChar: 4,
|
|
13
|
+
iconCancel: cancel,
|
|
14
|
+
timeout: 200,
|
|
15
|
+
events: [
|
|
16
|
+
['input.input', 'onInput'],
|
|
17
|
+
['input.cancel', 'onCancel']
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor (options) {
|
|
22
|
+
super()
|
|
23
|
+
|
|
24
|
+
this.init(options)
|
|
25
|
+
this.build()
|
|
26
|
+
this.buildSearch()
|
|
27
|
+
this.bindEvents()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
init(options) {
|
|
31
|
+
this.options = Object.assign({}, Search.defaults, options || {})
|
|
32
|
+
Object.assign(this, build, bindEvents)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
buildSearch () {
|
|
36
|
+
if (this.options.icon) {
|
|
37
|
+
this.icon = document.createElement('i')
|
|
38
|
+
this.icon.classList.add('icon')
|
|
39
|
+
this.icon.innerHTML = this.options.icon
|
|
40
|
+
this.element.appendChild(this.icon)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.input = document.createElement('input')
|
|
44
|
+
this.input.classList.add('input')
|
|
45
|
+
this.element.appendChild(this.input)
|
|
46
|
+
|
|
47
|
+
this.cancel = new Button({
|
|
48
|
+
container: this.element,
|
|
49
|
+
class: 'clear',
|
|
50
|
+
icon: this.options.iconCancel
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
onInput () {
|
|
55
|
+
if (this.input.value.length < this.options.minChar) return
|
|
56
|
+
|
|
57
|
+
clearTimeout(this.timeout)
|
|
58
|
+
|
|
59
|
+
this.timeout = setTimeout(() => {
|
|
60
|
+
this.emit('change', this.input.value)
|
|
61
|
+
}, this.options.timeout)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onCancel () {
|
|
65
|
+
this.input.value = ''
|
|
66
|
+
this.input.focus()
|
|
67
|
+
this.emit('cancel')
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default Search
|