material 0.7.0 → 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 +59 -58
- 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 +155 -155
- package/src/calendar.js +0 -2
- package/src/card.js +0 -2
- package/src/checkbox.js +0 -2
- package/src/component.js +0 -2
- package/src/container.js +0 -2
- package/src/datehour.js +38 -0
- package/src/dialog.js +105 -152
- package/src/divider.js +0 -2
- package/src/drawer.js +0 -2
- package/src/{control/file.js → file.js} +15 -45
- package/src/form/verify.js +2 -2
- package/src/form.js +0 -2
- package/src/icon.js +0 -2
- package/src/image.js +39 -106
- package/src/item.js +0 -2
- package/src/{control/link.js → link.js} +13 -32
- package/src/list/build.js +2 -2
- package/src/list/collection.js +1 -1
- package/src/list/filter.js +2 -2
- package/src/list/request.js +1 -1
- package/src/list/search.js +5 -5
- package/src/list.js +29 -217
- package/src/loading.js +73 -0
- package/src/menu.js +60 -116
- package/src/mixin/display.js +0 -1
- package/src/mixin/insert.js +2 -24
- package/src/{control/module → module}/attributes.js +2 -2
- package/src/module/build.js +8 -5
- package/src/navigation.js +19 -0
- package/src/progress.js +0 -2
- package/src/search.js +71 -0
- package/src/select.js +57 -272
- package/src/{control/selecter.js → selecter.js} +5 -5
- package/src/skin/material/component/navigation.sass +1 -0
- package/src/skin/material/control/button.sass +10 -0
- package/src/slider.js +0 -2
- package/src/snackbar.js +72 -51
- package/src/switch.js +111 -103
- package/src/{control/switcher.js → switcher.js} +17 -20
- package/src/text.js +25 -74
- package/src/textfield.js +96 -233
- package/src/banner.js +0 -231
- package/src/control/button.js +0 -239
- 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/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 -91
- package/src/control/switch.js +0 -272
- package/src/control/text.js +0 -70
- package/src/control/textfield.js +0 -177
- package/src/tabs/setup.js +0 -0
- /package/src/{control/module → module}/addclass.js +0 -0
package/src/control/image.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const defaults = {
|
|
3
|
-
class: 'image',
|
|
4
|
-
tag: 'div',
|
|
5
|
-
format: 'thumb'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Class representing an image.
|
|
10
|
-
*
|
|
11
|
-
* @extends Image
|
|
12
|
-
* @return {parent} The class instance
|
|
13
|
-
* @example new Image({
|
|
14
|
-
* src: {
|
|
15
|
-
* filename: 'image.png',
|
|
16
|
-
* url: 'exmaple.com/image/'
|
|
17
|
-
* format: ['thumbs/', 'medium/', 'large/'],
|
|
18
|
-
* },
|
|
19
|
-
* container: document.body
|
|
20
|
-
* });
|
|
21
|
-
*/
|
|
22
|
-
class Image {
|
|
23
|
-
/**
|
|
24
|
-
* Constructor
|
|
25
|
-
* @param {Object} options - Component options
|
|
26
|
-
* @return {Object} Class instance
|
|
27
|
-
*/
|
|
28
|
-
constructor (options) {
|
|
29
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
30
|
-
|
|
31
|
-
this.build()
|
|
32
|
-
|
|
33
|
-
return this
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Build Method
|
|
38
|
-
* @return {Object} This class instance
|
|
39
|
-
*/
|
|
40
|
-
build () {
|
|
41
|
-
this.element = document.createElement(this.options.tag)
|
|
42
|
-
this.element.classList.add(this.options.class)
|
|
43
|
-
if (this.options.class !== 'image') {
|
|
44
|
-
this.element.classList.add('image')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (this.options.container) {
|
|
48
|
-
this.options.container.appendChild(this.element)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return this
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
set (src) {
|
|
55
|
-
// console.log('set', src)
|
|
56
|
-
if (!src) {
|
|
57
|
-
this.element.style.backgroundImage = ''
|
|
58
|
-
} else {
|
|
59
|
-
var url = null
|
|
60
|
-
|
|
61
|
-
if (src.format) {
|
|
62
|
-
var format = this.sanitize(src.format)
|
|
63
|
-
|
|
64
|
-
if (format.length > 0) {
|
|
65
|
-
var index = format.indexOf(this.options.format)
|
|
66
|
-
if (index === -1) {
|
|
67
|
-
format = src.format[0] + '/'
|
|
68
|
-
} else {
|
|
69
|
-
format = this.options.format + '/'
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
url = src.url + format
|
|
74
|
-
} else {
|
|
75
|
-
url = src.url
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
this.element.style.backgroundImage = 'url(' + url + src.filename + ')'
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
sanitize (formats) {
|
|
83
|
-
var a = []
|
|
84
|
-
for (var i = 0; i < formats.length; i++) {
|
|
85
|
-
var format = formats[i].replace(/\/$/, '')
|
|
86
|
-
a.push(format)
|
|
87
|
-
}
|
|
88
|
-
return a
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export default Image
|
package/src/control/list.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// menu related modules
|
|
2
|
-
import emitter from '../module/emitter'
|
|
3
|
-
import attach from '../module/attach'
|
|
4
|
-
import build from '../module/build'
|
|
5
|
-
import display from '../module/display'
|
|
6
|
-
|
|
7
|
-
import Layout from '../layout'
|
|
8
|
-
import Element from '../element'
|
|
9
|
-
import Button from './text'
|
|
10
|
-
|
|
11
|
-
const defaults = {
|
|
12
|
-
class: 'list',
|
|
13
|
-
layout: [
|
|
14
|
-
[Element, 'main', { tag: 'ul' }]
|
|
15
|
-
],
|
|
16
|
-
item: [Text, { tag: 'li' }],
|
|
17
|
-
events: [
|
|
18
|
-
['ui.main.click', 'select']
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class List {
|
|
23
|
-
/**
|
|
24
|
-
* Constructor
|
|
25
|
-
* @param {Object} options - Component options
|
|
26
|
-
* @return {Object} Class instance
|
|
27
|
-
*/
|
|
28
|
-
constructor (options) {
|
|
29
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
30
|
-
// implement modules
|
|
31
|
-
Object.assign(this, emitter, build, attach, display)
|
|
32
|
-
|
|
33
|
-
this.build()
|
|
34
|
-
|
|
35
|
-
return this
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
add (items) {
|
|
39
|
-
for (var i = 0; i < list.length; i++) {
|
|
40
|
-
if (i < list.length - 1) {
|
|
41
|
-
text = text + list[i] + this.options.seprator
|
|
42
|
-
} else {
|
|
43
|
-
text = text + list[i]
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// console.log('set', text)
|
|
48
|
-
if (text === undefined) return
|
|
49
|
-
|
|
50
|
-
var label = this.options.label || ''
|
|
51
|
-
|
|
52
|
-
this.element.innerHTML = label + text
|
|
53
|
-
|
|
54
|
-
if (this.options.spaceAfter) {
|
|
55
|
-
this.element.innerHTML = this.element.innerHTML + ' '
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
select()
|
|
60
|
-
|
|
61
|
-
setText (text) {
|
|
62
|
-
// console.log('setText', text)
|
|
63
|
-
this.element.innerHTML = text
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default List
|
package/src/control/loading.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import emitter from '../module/emitter'
|
|
2
|
-
import attach from '../module/attach'
|
|
3
|
-
|
|
4
|
-
import dataset from '../view/dataset'
|
|
5
|
-
|
|
6
|
-
var defaults = {
|
|
7
|
-
class: 'loading',
|
|
8
|
-
tag: 'div',
|
|
9
|
-
delay: 1000,
|
|
10
|
-
type: 'indeterminate',
|
|
11
|
-
circular: `<svg class="progress" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
|
|
12
|
-
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
|
|
13
|
-
</svg>`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The class represents an item ie for list
|
|
18
|
-
*
|
|
19
|
-
* @class
|
|
20
|
-
* @return {Object} The class instance
|
|
21
|
-
* @example new Item(object);
|
|
22
|
-
*/
|
|
23
|
-
class Loading {
|
|
24
|
-
static isComponent () {
|
|
25
|
-
return true
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* init
|
|
30
|
-
* @return {Object} The class options
|
|
31
|
-
*/
|
|
32
|
-
constructor (options) {
|
|
33
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
34
|
-
Object.assign(this, emitter, attach)
|
|
35
|
-
// console.log('options', options)
|
|
36
|
-
|
|
37
|
-
this.init()
|
|
38
|
-
|
|
39
|
-
return this
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Setter
|
|
44
|
-
* @param {string} prop
|
|
45
|
-
* @param {string} value
|
|
46
|
-
* @return {Object} The class instance
|
|
47
|
-
*/
|
|
48
|
-
init () {
|
|
49
|
-
this.build()
|
|
50
|
-
// this.setup()
|
|
51
|
-
// this.attach()
|
|
52
|
-
|
|
53
|
-
if (this.options.container) {
|
|
54
|
-
this.append(this.options.container)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return this
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Build function for item
|
|
62
|
-
* @return {Object} This class instance
|
|
63
|
-
*/
|
|
64
|
-
build (options) {
|
|
65
|
-
this.element = document.createElement(this.options.tag)
|
|
66
|
-
this.classify()
|
|
67
|
-
|
|
68
|
-
if (this.options.type === 'circular') {
|
|
69
|
-
this.element.innerHTML = this.options.circular
|
|
70
|
-
} if (this.options.type === 'indeterminate') {
|
|
71
|
-
this.bar = document.createElement(this.options.tag)
|
|
72
|
-
this.bar.classList.add('bar')
|
|
73
|
-
this.element.classList.add('type-indeterminate')
|
|
74
|
-
this.element.appendChild(this.bar)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return this
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
classify () {
|
|
81
|
-
if (this.options.class !== 'loading') {
|
|
82
|
-
this.element.setAttribute('class', this.options.class + ' ' + this.options.class)
|
|
83
|
-
} else {
|
|
84
|
-
this.element.classList.add(this.options.class)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
append (container) {
|
|
89
|
-
container = container || this.options.container
|
|
90
|
-
if (this.options.container) {
|
|
91
|
-
container.appendChild(this.element)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
set (progress) {
|
|
96
|
-
this.bar.setAttribute('style', 'width: ' + progress)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
show (delay) {
|
|
100
|
-
delay = delay || this.options.delay
|
|
101
|
-
|
|
102
|
-
clearTimeout(this.showTimeout)
|
|
103
|
-
this.showTimeout = setTimeout(() => {
|
|
104
|
-
this.element.classList.add('show')
|
|
105
|
-
}, this.options.delay)
|
|
106
|
-
|
|
107
|
-
this.visible = true
|
|
108
|
-
|
|
109
|
-
return this
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
showNow () {
|
|
113
|
-
this.element.classList.add('show')
|
|
114
|
-
|
|
115
|
-
this.visible
|
|
116
|
-
|
|
117
|
-
return this
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
hide () {
|
|
121
|
-
clearTimeout(this.showTimeout)
|
|
122
|
-
this.element.classList.remove('show')
|
|
123
|
-
this.visible = false
|
|
124
|
-
return this
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export default Loading
|
package/src/control/menu.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import EventEmitter from '../mixin/emitter'
|
|
2
|
-
// menu related modules
|
|
3
|
-
import build from '../module/build'
|
|
4
|
-
import bindEvents from '../module/events'
|
|
5
|
-
import display from '../mixin/display'
|
|
6
|
-
|
|
7
|
-
import Element from '../element'
|
|
8
|
-
import Button from './button'
|
|
9
|
-
|
|
10
|
-
class Menu extends EventEmitter {
|
|
11
|
-
static defaults = {
|
|
12
|
-
class: 'menu',
|
|
13
|
-
transition: 200,
|
|
14
|
-
modal: false,
|
|
15
|
-
layout: [
|
|
16
|
-
[Element, 'surface', { class: 'surface' },
|
|
17
|
-
[Element, 'list', { tag: 'ul', class: 'items' }]
|
|
18
|
-
]
|
|
19
|
-
],
|
|
20
|
-
events: [
|
|
21
|
-
['element.click', 'close']
|
|
22
|
-
]
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
constructor (options) {
|
|
26
|
-
super()
|
|
27
|
-
|
|
28
|
-
this.init(options)
|
|
29
|
-
this.build(this.constructor)
|
|
30
|
-
this.bindEvents()
|
|
31
|
-
|
|
32
|
-
this.render(this.options.items)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
init(options) {
|
|
36
|
-
this.options = Object.assign({}, Menu.defaults, options || {})
|
|
37
|
-
Object.assign(this, build, bindEvents, display)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
render (items) {
|
|
41
|
-
if (items && Array.isArray(items)) {
|
|
42
|
-
for (var i = 0; i < items.length; i++) {
|
|
43
|
-
this.add(items[i])
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return this
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
add (obj) {
|
|
51
|
-
if (typeof obj !== 'object') return this;
|
|
52
|
-
let item;
|
|
53
|
-
if (obj.type === 'divider') {
|
|
54
|
-
item = new Element({ tag: 'li', class: 'divider' })
|
|
55
|
-
} else {
|
|
56
|
-
obj.container = this.ui.list
|
|
57
|
-
obj.class = 'item'
|
|
58
|
-
item = new Button(obj).on('click', (ev) => {
|
|
59
|
-
// console.log('select', ev.target.name)
|
|
60
|
-
this.emit('select', ev.target.name)
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return this
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
position(target) {
|
|
68
|
-
if (!target) return
|
|
69
|
-
var offs = target.getBoundingClientRect()
|
|
70
|
-
|
|
71
|
-
var offsw = this.offset = this.ui.surface.getBoundingClientRect()
|
|
72
|
-
|
|
73
|
-
this.ui.surface.style.top = (offs.top - 4) + 'px'
|
|
74
|
-
this.ui.surface.style.left = offs.left - offsw.width + offs.width + 'px'
|
|
75
|
-
|
|
76
|
-
return this
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
close() {
|
|
80
|
-
// console.log('close')
|
|
81
|
-
this.destroy()
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default Menu
|
package/src/control/search.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// search control
|
|
2
|
-
|
|
3
|
-
import emitter from '../module/emitter'
|
|
4
|
-
import Button from '../control/button'
|
|
5
|
-
import cancel from '../skin/material/icon/cancel.svg'
|
|
6
|
-
|
|
7
|
-
const defaults = {
|
|
8
|
-
class: 'search-input',
|
|
9
|
-
minChar: 4,
|
|
10
|
-
iconCancel: cancel,
|
|
11
|
-
timeout: 200
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Class representing a search input
|
|
16
|
-
*
|
|
17
|
-
* @return {parent} The class instance
|
|
18
|
-
* @example new Search({
|
|
19
|
-
* container: document.body
|
|
20
|
-
* });
|
|
21
|
-
*/
|
|
22
|
-
class Search {
|
|
23
|
-
/**
|
|
24
|
-
* Constructor
|
|
25
|
-
* @param {Object} options - Component options
|
|
26
|
-
* @return {Object} Class instance
|
|
27
|
-
*/
|
|
28
|
-
constructor (options) {
|
|
29
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
30
|
-
Object.assign(this, emitter)
|
|
31
|
-
|
|
32
|
-
this.build()
|
|
33
|
-
this.attach()
|
|
34
|
-
|
|
35
|
-
return this
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Build Method
|
|
40
|
-
* @return {Object} This class instance
|
|
41
|
-
*/
|
|
42
|
-
build () {
|
|
43
|
-
this.element = document.createElement('div')
|
|
44
|
-
this.element.classList.add('search')
|
|
45
|
-
|
|
46
|
-
if (this.options.class !== 'search') {
|
|
47
|
-
this.element.classList.add(this.options.class)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (this.options.icon) {
|
|
51
|
-
this.icon = document.createElement('i')
|
|
52
|
-
this.icon.classList.add('icon')
|
|
53
|
-
this.icon.innerHTML = this.options.icon
|
|
54
|
-
this.element.appendChild(this.icon)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
this.input = document.createElement('input')
|
|
58
|
-
this.input.classList.add('input')
|
|
59
|
-
this.element.appendChild(this.input)
|
|
60
|
-
|
|
61
|
-
this.cancel = new Button({
|
|
62
|
-
container: this.element,
|
|
63
|
-
class: 'clear',
|
|
64
|
-
icon: this.options.iconCancel
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
if (this.options.container) {
|
|
68
|
-
this.options.container.appendChild(this.element)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return this
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
attach () {
|
|
75
|
-
this.input.addEventListener('input', () => {
|
|
76
|
-
if (this.input.value.length < this.options.minChar) return
|
|
77
|
-
|
|
78
|
-
clearTimeout(this.timeout)
|
|
79
|
-
|
|
80
|
-
this.timeout = setTimeout(() => {
|
|
81
|
-
this.emit('change', this.input.value)
|
|
82
|
-
}, this.options.timeout)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
this.cancel.on('click', () => {
|
|
86
|
-
this.input.value = ''
|
|
87
|
-
this.input.focus()
|
|
88
|
-
this.emit('cancel')
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
set (email) {
|
|
93
|
-
this.element.innerHTML = email
|
|
94
|
-
this.element.setAttribute('href', 'mailto:' + email)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export default Search
|
package/src/control/select.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import emitter from '..//module/emitter'
|
|
2
|
-
import attach from '../module/attach'
|
|
3
|
-
import attributes from './module/attributes'
|
|
4
|
-
import dataset from '../view/dataset'
|
|
5
|
-
|
|
6
|
-
const defaults = {
|
|
7
|
-
type: 'list', // native
|
|
8
|
-
class: 'select',
|
|
9
|
-
first: null,
|
|
10
|
-
attributes: ['type', 'name', 'autocomplete', 'required']
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class Select {
|
|
14
|
-
/**
|
|
15
|
-
* Constructor
|
|
16
|
-
* @param {Object} options - Component options
|
|
17
|
-
* @return {Object} Class instance
|
|
18
|
-
*/
|
|
19
|
-
constructor (options) {
|
|
20
|
-
this.options = Object.assign({}, defaults, options || {})
|
|
21
|
-
Object.assign(this, emitter, attach, dataset)
|
|
22
|
-
|
|
23
|
-
this.build()
|
|
24
|
-
this.attach()
|
|
25
|
-
|
|
26
|
-
return this
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Build Method
|
|
31
|
-
* @return {Object} This class instance
|
|
32
|
-
*/
|
|
33
|
-
build () {
|
|
34
|
-
var tag = this.options.tag || 'span'
|
|
35
|
-
this.element = document.createElement(tag)
|
|
36
|
-
this.element.classList.add('select')
|
|
37
|
-
|
|
38
|
-
if (this.options.class !== 'select') {
|
|
39
|
-
this.element.classList.add(this.options.class)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
this.buildLabel()
|
|
43
|
-
this.buildInput()
|
|
44
|
-
|
|
45
|
-
if (this.container) {
|
|
46
|
-
this.container.appendChild(this.element)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return this
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
buildLabel () {
|
|
53
|
-
if (this.options.label) {
|
|
54
|
-
this.label = document.createElement('span')
|
|
55
|
-
this.label.classList.add('label')
|
|
56
|
-
this.label.innerHTML = this.options.label
|
|
57
|
-
this.element.appendChild(this.label)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
buildInput () {
|
|
62
|
-
this.input = document.createElement('select')
|
|
63
|
-
this.input.classList.add('input')
|
|
64
|
-
this.element.appendChild(this.input)
|
|
65
|
-
|
|
66
|
-
this.input.addEventListener('change', () => {
|
|
67
|
-
// console.log('change', this.input[this.input.selectedIndex].value)
|
|
68
|
-
this.emit('change', this.input[this.input.selectedIndex].value)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
if (this.options.data) {
|
|
72
|
-
dataset(this.data, this.options.data)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
attributes(this.input, this.options)
|
|
76
|
-
|
|
77
|
-
if (this.options.options) {
|
|
78
|
-
this.setOptions(this.options.options)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
setOptions (options) {
|
|
83
|
-
// console.log('buildCountry', this.input)
|
|
84
|
-
|
|
85
|
-
var first = this.options.first
|
|
86
|
-
|
|
87
|
-
if (first && first[0] && first[1]) {
|
|
88
|
-
this.input.options[0] = new Option(first[1], first[0])
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
for (var i = 0; i < options.length; i++) {
|
|
92
|
-
this.addOption(options[i][1], options[i][0])
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
addOption (name, value) {
|
|
97
|
-
// console.log('addOption', name, value)
|
|
98
|
-
this.input.options[this.input.options.length] = new Option(name, value)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
set (value) {
|
|
102
|
-
// console.log('set', value)
|
|
103
|
-
this.input.value = value
|
|
104
|
-
|
|
105
|
-
return this
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
setLabel (value) {
|
|
109
|
-
console.log('setLabel', value)
|
|
110
|
-
if (this.label) {
|
|
111
|
-
this.label.innerHTML = value
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
setText (value) {
|
|
116
|
-
this.setLabel(value)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
get () {
|
|
120
|
-
var value = null
|
|
121
|
-
|
|
122
|
-
if (this.input[this.input.selectedIndex]) {
|
|
123
|
-
value = this.input[this.input.selectedIndex].value
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return value
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export default Select
|
package/src/control/snackbar.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// base class
|
|
2
|
-
import EventEmitter from '../mixin/emitter'
|
|
3
|
-
// related modules
|
|
4
|
-
import build from '../module/build'
|
|
5
|
-
import bindEvents from '../module/events'
|
|
6
|
-
import display from '../mixin/display'
|
|
7
|
-
// ui element
|
|
8
|
-
import Text from './text'
|
|
9
|
-
import Button from './button'
|
|
10
|
-
|
|
11
|
-
class Snackbar extends EventEmitter {
|
|
12
|
-
static defaults = {
|
|
13
|
-
class: 'snackbar',
|
|
14
|
-
transition: 225,
|
|
15
|
-
duration: 4000,
|
|
16
|
-
close: false,
|
|
17
|
-
layout: [
|
|
18
|
-
[Text, 'text', { tag: 'span', class: 'text' }],
|
|
19
|
-
[Button, 'action', { class: 'action', type: 'link' }],
|
|
20
|
-
[Button, 'close', { class: 'close', type: 'action' }]
|
|
21
|
-
],
|
|
22
|
-
events: [
|
|
23
|
-
['ui.action.click', 'action'],
|
|
24
|
-
['ui.close.click', 'destroy']
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
constructor (options) {
|
|
29
|
-
super()
|
|
30
|
-
|
|
31
|
-
this.init(options)
|
|
32
|
-
this.build(this.constructor)
|
|
33
|
-
this.render()
|
|
34
|
-
this.bindEvents()
|
|
35
|
-
this.show()
|
|
36
|
-
|
|
37
|
-
if (this.options.duration)
|
|
38
|
-
setTimeout(()=>{
|
|
39
|
-
this.destroy()
|
|
40
|
-
}, this.options.duration)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
init(options) {
|
|
44
|
-
this.options = Object.assign({}, Snackbar.defaults, options || {})
|
|
45
|
-
Object.assign(this, build, bindEvents, display)
|
|
46
|
-
|
|
47
|
-
this.buildSnackbarContainer(this.options.container)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
buildSnackbarContainer (container = document.body) {
|
|
51
|
-
// console.log('buildSnackbarContainer', container)
|
|
52
|
-
|
|
53
|
-
let snackbarContainer = container.querySelector('.snackbars')
|
|
54
|
-
|
|
55
|
-
// console.log('snackbarContainer', snackbarContainer)
|
|
56
|
-
|
|
57
|
-
if (!snackbarContainer) {
|
|
58
|
-
this.options.container = document.createElement('div')
|
|
59
|
-
this.options.container.classList.add('snackbars')
|
|
60
|
-
container.appendChild(this.options.container)
|
|
61
|
-
} else {
|
|
62
|
-
this.options.container = snackbarContainer
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
render () {
|
|
67
|
-
this.ui.text.set(this.options.text)
|
|
68
|
-
|
|
69
|
-
if (this.options.action) {
|
|
70
|
-
this.ui.action.set(this.options.action)
|
|
71
|
-
this.ui.action.element.classList.add('show')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (this.options.close) this.ui.close.element.classList.add('show')
|
|
75
|
-
|
|
76
|
-
return this
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
action () {
|
|
80
|
-
// console.log('action')
|
|
81
|
-
this.emit('action')
|
|
82
|
-
this.destroy()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
close() {
|
|
86
|
-
// console.log('close')
|
|
87
|
-
this.destroy()
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export default Snackbar
|