material 0.9.19 → 0.9.21
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/package.json +1 -1
- package/src/class/component.js +1 -1
- package/src/class/view.js +3 -6
- package/src/datehour.js +17 -12
- package/src/loader.js +3 -1
- package/src/module/dom.js +0 -1
- package/src/module/layout.js +1 -1
- package/src/slider-new.js +341 -0
- package/src/switch.js +5 -7
- package/src/switcher.js +10 -10
- package/src/text.js +1 -1
- package/src/textfield.js +2 -1
- package/src/list.new/build.js +0 -139
- package/src/list.new/click.js +0 -40
- package/src/list.new/collection.js +0 -30
- package/src/list.new/create.js +0 -45
- package/src/list.new/data.js +0 -16
- package/src/list.new/display.js +0 -78
- package/src/list.new/empty.js +0 -9
- package/src/list.new/filter.js +0 -114
- package/src/list.new/image.js +0 -19
- package/src/list.new/init.js +0 -6
- package/src/list.new/load.js +0 -9
- package/src/list.new/remove.js +0 -22
- package/src/list.new/render.js +0 -142
- package/src/list.new/request.js +0 -216
- package/src/list.new/search.js +0 -155
- package/src/list.new/select.js +0 -221
- package/src/list.new/status.js +0 -21
- package/src/list.new/update.js +0 -75
- package/src/list.new/virtual.js +0 -186
- package/src/list.new/virtual.new.js +0 -213
package/src/list.new/click.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export default {
|
|
3
|
-
click (e) {
|
|
4
|
-
// console.log('click', e.target)
|
|
5
|
-
e.stopPropagation()
|
|
6
|
-
|
|
7
|
-
if (e.target === e.currentTarget) {
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const target = '[data-id]'
|
|
12
|
-
let item = e.target
|
|
13
|
-
let i = 0
|
|
14
|
-
|
|
15
|
-
while (item && !item.matches(target)) {
|
|
16
|
-
// console.log('item', item)
|
|
17
|
-
if (i > 10) {
|
|
18
|
-
item = null
|
|
19
|
-
break
|
|
20
|
-
}
|
|
21
|
-
item = item.parentNode
|
|
22
|
-
i++
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (e.target.matches('BUTTON') && e.target.dataset.name && item.dataset.id) {
|
|
26
|
-
// console.log('button', e.target.dataset.name)
|
|
27
|
-
this.emit(e.target.dataset.name, item.dataset.id)
|
|
28
|
-
return this
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (this.select) {
|
|
32
|
-
this.select(item)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// console.log('item', item, e.target.dataset.name)
|
|
36
|
-
|
|
37
|
-
return this
|
|
38
|
-
// console.log(item)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
class Collection {
|
|
2
|
-
constructor () {
|
|
3
|
-
this.items = {}
|
|
4
|
-
this.ids = []
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
add (item) {
|
|
8
|
-
const id = item[this.dataId]
|
|
9
|
-
this.items[id] = item
|
|
10
|
-
this.ids.push(id)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
get (id) {
|
|
14
|
-
return this.items[id] || null
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getIndex (id) {
|
|
18
|
-
return this.ids.indexOf(id)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
getPage (page, pageSize) {
|
|
22
|
-
const start = (page - 1) * pageSize
|
|
23
|
-
const end = start + pageSize
|
|
24
|
-
return this.ids.slice(start, end).map(id => this.items[id])
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getCount () {
|
|
28
|
-
return this.ids.length
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/list.new/create.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
create () {
|
|
3
|
-
// console.log('create', this.mode, this.options.item.new)
|
|
4
|
-
// console.log('selected', this.info, this.item)
|
|
5
|
-
|
|
6
|
-
if (this.mode === 'create') return
|
|
7
|
-
|
|
8
|
-
this.mode = 'create'
|
|
9
|
-
|
|
10
|
-
if (this.options.virtual === true) {
|
|
11
|
-
this.data.unshift(this.options.item.new)
|
|
12
|
-
this.render(this.data)
|
|
13
|
-
} else {
|
|
14
|
-
if (this.options.item) {
|
|
15
|
-
this.newItem = this.renderItem(this.options.item.new, 'create')
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
this.emit('create', this.options.item.new)
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
created (data) {
|
|
23
|
-
// console.log('created', this.data.length, data)
|
|
24
|
-
if (this.options.virtual === true) {
|
|
25
|
-
this.data[0] = data
|
|
26
|
-
this.render(this.data)
|
|
27
|
-
} else {
|
|
28
|
-
this.mode = null
|
|
29
|
-
this.info = data
|
|
30
|
-
this.ui.body.removeChild(this.newItem)
|
|
31
|
-
this.item = this.renderItem(data, 'top')
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
createCancel () {
|
|
36
|
-
// console.log('createCancel', this.newItem)
|
|
37
|
-
// console.log('remove')
|
|
38
|
-
// console.log('prepare reselect', this.info, this.item)
|
|
39
|
-
this.ui.body.removeChild(this.newItem)
|
|
40
|
-
this.mode = null
|
|
41
|
-
if (this.item && this.info) {
|
|
42
|
-
this.select(this.info, this.item)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
package/src/list.new/data.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
storeData (list, more) {
|
|
3
|
-
console.log('storeData', list.length, more)
|
|
4
|
-
if (more !== true) {
|
|
5
|
-
this.dataList = []
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// console.log('storeData', this.dataStore)
|
|
9
|
-
this.dataStore = this.dataStore || {}
|
|
10
|
-
|
|
11
|
-
for (let i = 0; i < list.length; i++) {
|
|
12
|
-
this.dataList.push(list[i][this.dataId])
|
|
13
|
-
this.dataStore[list[i][this.dataId]] = list[i]
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
package/src/list.new/display.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export default {
|
|
3
|
-
toggle () {
|
|
4
|
-
this.visible ? this.hide() : this.show()
|
|
5
|
-
|
|
6
|
-
this.emit('toggle')
|
|
7
|
-
return this
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
show () {
|
|
11
|
-
// console.log('show', this.visible)
|
|
12
|
-
|
|
13
|
-
this.element.getBoundingClientRect()
|
|
14
|
-
|
|
15
|
-
this.element.classList.add('show')
|
|
16
|
-
this.visible = true
|
|
17
|
-
|
|
18
|
-
if (this.underlay) {
|
|
19
|
-
this.underlay.classList.add('show')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
this.virtual.setOffset('onShow')
|
|
23
|
-
|
|
24
|
-
this.emit('show')
|
|
25
|
-
return this
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
hide () {
|
|
29
|
-
// console.log('hide', this.element.style.display)
|
|
30
|
-
|
|
31
|
-
if (!this.element) return
|
|
32
|
-
|
|
33
|
-
this.element.classList.remove('show')
|
|
34
|
-
this.visible = false
|
|
35
|
-
|
|
36
|
-
if (this.underlay) {
|
|
37
|
-
this.underlay.classList.remove('show')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.emit('hide')
|
|
41
|
-
return this
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
destroy () {
|
|
45
|
-
// console.log('destroy', this.options.transition)
|
|
46
|
-
if (this.options.transition && this.element) {
|
|
47
|
-
this.element.classList.remove('show')
|
|
48
|
-
|
|
49
|
-
if (this.underlay) {
|
|
50
|
-
this.underlay.classList.remove('show')
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
this.removeChild()
|
|
55
|
-
}, this.options.transition)
|
|
56
|
-
} else {
|
|
57
|
-
this.removeChild()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
this.emit('destroy')
|
|
61
|
-
|
|
62
|
-
return this
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
removeChild () {
|
|
66
|
-
if (this.element && this.element.parentNode) {
|
|
67
|
-
this.element.parentNode.removeChild(this.element)
|
|
68
|
-
this.element = null
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (this.underlay && this.underlay.parentNode) {
|
|
72
|
-
this.underlay.parentNode.removeChild(this.underlay)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.emit('remove')
|
|
76
|
-
return this
|
|
77
|
-
}
|
|
78
|
-
}
|
package/src/list.new/empty.js
DELETED
package/src/list.new/filter.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export default {
|
|
3
|
-
initFilter () {
|
|
4
|
-
this.filter = this.extractFilter(this.ui)
|
|
5
|
-
|
|
6
|
-
for (const name in this.filter) {
|
|
7
|
-
if (this.filter.hasOwnProperty(name)) {
|
|
8
|
-
this.filter[name].on('change', () => {
|
|
9
|
-
this.request()
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
this.ui['filter-clear'].on('click', () => {
|
|
15
|
-
this.clearFilter()
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
this.ui.filter.on('click', () => {
|
|
19
|
-
this.toggleFilter()
|
|
20
|
-
})
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
getFilter () {
|
|
24
|
-
console.log('getFilter')
|
|
25
|
-
let filter = null
|
|
26
|
-
for (const name in this.filter) {
|
|
27
|
-
if (this.filter.hasOwnProperty(name)) {
|
|
28
|
-
console.log('--', typeof this.filter[name].get(), this.filter[name].get())
|
|
29
|
-
if (this.filter[name].get() !== ''/* && this.filter[name].get() !== [] */) {
|
|
30
|
-
if (filter) {
|
|
31
|
-
filter = filter + '&' + name + '=' + this.filter[name].get()
|
|
32
|
-
} else {
|
|
33
|
-
filter = name + '=' + this.filter[name].get()
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// console.log('filter', filter)
|
|
40
|
-
|
|
41
|
-
return filter
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
toggleFilter () {
|
|
45
|
-
// console.log('toggleFilter', this.ui['filter-input'])
|
|
46
|
-
|
|
47
|
-
if (this.ui['filter-input'].classList.contains('show')) {
|
|
48
|
-
this.hideFilter()
|
|
49
|
-
} else {
|
|
50
|
-
this.showFilter()
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* [showSearch description]
|
|
56
|
-
* @return {[type]} [description]
|
|
57
|
-
*/
|
|
58
|
-
showFilter () {
|
|
59
|
-
if (this.hideSearch) {
|
|
60
|
-
this.hideSearch()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// console.log('showSearch')
|
|
64
|
-
this.ui.filter.element.classList.add('selected')
|
|
65
|
-
this.ui['filter-input'].classList.add('show')
|
|
66
|
-
|
|
67
|
-
// this.ui['search-list'].classList.add('show')
|
|
68
|
-
// this.ui.body.classList.add('hide')
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* [hideSearch description]
|
|
73
|
-
* @return {[type]} [description]
|
|
74
|
-
*/
|
|
75
|
-
hideFilter () {
|
|
76
|
-
// console.log('hideSearch')
|
|
77
|
-
this.ui.filter.element.classList.remove('selected')
|
|
78
|
-
this.ui['filter-input'].classList.remove('show')
|
|
79
|
-
// this.ui['search-list'].classList.remove('show')
|
|
80
|
-
// this.ui.body.classList.remove('hide')
|
|
81
|
-
this.clearFilter()
|
|
82
|
-
this.request()
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
clearFilter () {
|
|
86
|
-
for (const name in this.filter) {
|
|
87
|
-
if (this.filter.hasOwnProperty(name)) {
|
|
88
|
-
this.filter[name].set('')
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
this.request()
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
extractFilter (object) {
|
|
96
|
-
// console.log('extractField', object)
|
|
97
|
-
|
|
98
|
-
const filter = {}
|
|
99
|
-
|
|
100
|
-
for (const property in object) {
|
|
101
|
-
if (object.hasOwnProperty(property)) {
|
|
102
|
-
const str = property.split(/\./)
|
|
103
|
-
|
|
104
|
-
if (str[0] === 'filter' && str[1] !== undefined) {
|
|
105
|
-
const name = property.substr(7, property.length)
|
|
106
|
-
|
|
107
|
-
filter[name] = object[property]
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return filter
|
|
113
|
-
}
|
|
114
|
-
}
|
package/src/list.new/image.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
image (info, layout) {
|
|
3
|
-
if (info.image) {
|
|
4
|
-
let format = 'thumb'
|
|
5
|
-
if (this.options.image && this.options.image.format) {
|
|
6
|
-
format = this.options.image.format || format + '/'
|
|
7
|
-
} else {
|
|
8
|
-
format = ''
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const r = Math.floor(Math.random() * 100000) + 1
|
|
12
|
-
|
|
13
|
-
if (info.image.filename) {
|
|
14
|
-
const image = info.image.url + format + info.image.filename
|
|
15
|
-
layout.get('image').style.backgroundImage = 'url("' + image + '?' + r + '")'
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/list.new/init.js
DELETED
package/src/list.new/load.js
DELETED
package/src/list.new/remove.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
remove (id) {
|
|
3
|
-
// console.log('remove', id, this.dataList)
|
|
4
|
-
// console.log('datalist', this.dataList)
|
|
5
|
-
|
|
6
|
-
if (!id) return
|
|
7
|
-
|
|
8
|
-
if (!this.dataStore[id]) {
|
|
9
|
-
// console.log('not in the list')
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
this.dataList.splice(this.dataList.indexOf(id), 1)
|
|
14
|
-
|
|
15
|
-
// remove id from the list
|
|
16
|
-
this.data = this.data.filter((info) => { return info[this.dataId] !== id })
|
|
17
|
-
|
|
18
|
-
// console.log('data', this.data)
|
|
19
|
-
|
|
20
|
-
this.virtual.update(this.data)
|
|
21
|
-
}
|
|
22
|
-
}
|
package/src/list.new/render.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import Element from '../element'
|
|
2
|
-
import { create } from '../module/layout'
|
|
3
|
-
|
|
4
|
-
import dot from '../module/dot'
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
|
|
8
|
-
render (list, page, size) {
|
|
9
|
-
// console.log('render', list)
|
|
10
|
-
this.virtual.set(list, { page, size })
|
|
11
|
-
|
|
12
|
-
if (this.status && this.options.count !== true) {
|
|
13
|
-
this.status('count', list.length)
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* [add description]
|
|
19
|
-
* @param {[type]} info [description]
|
|
20
|
-
* @param {[type]} context [description]
|
|
21
|
-
*/
|
|
22
|
-
renderItem (info, context) {
|
|
23
|
-
// console.log('renderItem', info)
|
|
24
|
-
info = info || {}
|
|
25
|
-
|
|
26
|
-
const container = this.ui.body
|
|
27
|
-
|
|
28
|
-
if (context === 'create') {
|
|
29
|
-
container.scrolltop = 0
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// if (context === 'search') {
|
|
33
|
-
// container = this.ui['search-list']
|
|
34
|
-
// }
|
|
35
|
-
|
|
36
|
-
const element = new Element({
|
|
37
|
-
tag: 'li',
|
|
38
|
-
class: 'item'
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
if (this.id && this.id === info[this.dataId]) {
|
|
42
|
-
element.classList.add('selected')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
element.dataset.id = info[this.dataId]
|
|
46
|
-
element.dataset.info = this.options.info
|
|
47
|
-
|
|
48
|
-
let layout = null
|
|
49
|
-
|
|
50
|
-
if (this.options.itemSwitch) {
|
|
51
|
-
const item = info[this.options.itemSwitch]
|
|
52
|
-
|
|
53
|
-
if (this.options.layout.item[item]) {
|
|
54
|
-
layout = create(this.options.layout.item[item], element)
|
|
55
|
-
} else {
|
|
56
|
-
layout = create(this.options.layout.item.base, element)
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
const itemName = this.options.itemName || 'item'
|
|
60
|
-
layout = create(this.options.layout[itemName], element)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// console.log('translate', layout)
|
|
64
|
-
|
|
65
|
-
if (this.translate && this.options.item && this.options.item.translate) {
|
|
66
|
-
// console.log('----')
|
|
67
|
-
this.translate(layout)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
this.renderInfo(layout, info)
|
|
71
|
-
|
|
72
|
-
if (context === 'top' || context === 'create') {
|
|
73
|
-
container.insertBefore(element, container.firstChild)
|
|
74
|
-
this.selectCreated(info, element)
|
|
75
|
-
} else {
|
|
76
|
-
container.appendChild(element)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.emit('infoRendered', info, element)
|
|
80
|
-
|
|
81
|
-
return element
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* [renderInfo description]
|
|
86
|
-
* @param {[type]} layout [description]
|
|
87
|
-
* @param {[type]} info [description]
|
|
88
|
-
* @return {[type]} [description]
|
|
89
|
-
*/
|
|
90
|
-
renderInfo (layout, object) {
|
|
91
|
-
// console.log('renderInfo', object)
|
|
92
|
-
const info = dot(object)
|
|
93
|
-
|
|
94
|
-
const f = this.extractInfo(layout.component)
|
|
95
|
-
|
|
96
|
-
for (const field in f) {
|
|
97
|
-
if (f.hasOwnProperty(field)) {
|
|
98
|
-
if (f[field] && f[field].set) {
|
|
99
|
-
f[field].set(this.objectValueByDotKey(object, field))
|
|
100
|
-
} else {
|
|
101
|
-
// console.log('innerHTML', typeof f[field])
|
|
102
|
-
f[field].innerHTML = info[field]
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
objectValueByDotKey (object, dotkey) {
|
|
109
|
-
const keys = dotkey.split(/\./)
|
|
110
|
-
|
|
111
|
-
let value = Object.assign({}, object)
|
|
112
|
-
|
|
113
|
-
for (let i = 0; i < keys.length; i++) {
|
|
114
|
-
if (value !== undefined) {
|
|
115
|
-
value = value[keys[i]]
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return value
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
extractInfo (object) {
|
|
123
|
-
// console.log('extractField', object)
|
|
124
|
-
|
|
125
|
-
const field = {}
|
|
126
|
-
|
|
127
|
-
for (const property in object) {
|
|
128
|
-
if (object.hasOwnProperty(property)) {
|
|
129
|
-
const infos = property.split(/\./)
|
|
130
|
-
|
|
131
|
-
if (infos[0] === 'info' && infos[1] !== undefined) {
|
|
132
|
-
const name = property.substr(5, property.length)
|
|
133
|
-
// console.log('field', name, property)
|
|
134
|
-
|
|
135
|
-
field[name] = object[property]
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return field
|
|
141
|
-
}
|
|
142
|
-
}
|