material 0.9.13 → 0.9.15
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 +20 -0
- package/src/class/control.js +9 -0
- package/src/list/select.js +6 -1
- package/src/list/update.js +2 -1
- package/src/list.new/request.js +0 -15
- package/src/list.new/virtual.js +1 -1
- package/src/module/mediator.js +12 -0
package/package.json
CHANGED
package/src/class/component.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import build from '../module/build'
|
|
2
|
+
import dom from '../module/dom'
|
|
2
3
|
|
|
3
4
|
class Component {
|
|
4
5
|
static base = 'component'
|
|
@@ -14,6 +15,25 @@ class Component {
|
|
|
14
15
|
|
|
15
16
|
build(this)
|
|
16
17
|
}
|
|
18
|
+
|
|
19
|
+
destroy () {
|
|
20
|
+
console.log('dest5roy')
|
|
21
|
+
if (this.options.transition && this.element) {
|
|
22
|
+
this.element.classList.remove('show')
|
|
23
|
+
|
|
24
|
+
if (this.underlay) {
|
|
25
|
+
this.underlay.classList.remove('show')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
dom.destroy(this.element)
|
|
30
|
+
if (this.underlay) dom.destroy(this.underlay)
|
|
31
|
+
}, this.options.transition)
|
|
32
|
+
} else {
|
|
33
|
+
dom.destroy(this.element)
|
|
34
|
+
if (this.underlay) dom.destroy(this.underlay)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
17
37
|
}
|
|
18
38
|
|
|
19
39
|
export default Component
|
package/src/class/control.js
CHANGED
|
@@ -25,6 +25,15 @@ class Control extends Component {
|
|
|
25
25
|
|
|
26
26
|
return this
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
destroy () {
|
|
30
|
+
// if (this.options.events) {
|
|
31
|
+
// events.detach(this.options.events, this)
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
super.destroy()
|
|
35
|
+
this.emit?.('destroy')
|
|
36
|
+
}
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
export default Control
|
package/src/list/select.js
CHANGED
|
@@ -44,7 +44,12 @@ export default {
|
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
getInfoById (id) {
|
|
47
|
-
|
|
47
|
+
// console.log('getInfoById', this.dataStore)
|
|
48
|
+
let info = null
|
|
49
|
+
|
|
50
|
+
if (this.dataStore) info = clone(this.dataStore[id])
|
|
51
|
+
|
|
52
|
+
return info
|
|
48
53
|
},
|
|
49
54
|
|
|
50
55
|
getSelectedInfo () {
|
package/src/list/update.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { create } from '../module/layout'
|
|
2
|
+
import clone from '../module/clone'
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
update (info) {
|
|
@@ -9,7 +10,7 @@ export default {
|
|
|
9
10
|
|
|
10
11
|
updateInfo (info) {
|
|
11
12
|
// console.log('update', info)
|
|
12
|
-
this.dataStore[info._id] = info
|
|
13
|
+
this.dataStore[info._id] = clone(info)
|
|
13
14
|
|
|
14
15
|
// update item in the list if visible
|
|
15
16
|
const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
|
package/src/list.new/request.js
CHANGED
|
@@ -212,20 +212,5 @@ export default {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
return route
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
storeData (list, more) {
|
|
218
|
-
console.log('storeData', list.length, more)
|
|
219
|
-
if (more !== true) {
|
|
220
|
-
this.dataList = []
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// console.log('storeData', this.dataStore)
|
|
224
|
-
this.dataStore = this.dataStore || {}
|
|
225
|
-
|
|
226
|
-
for (let i = 0; i < list.length; i++) {
|
|
227
|
-
this.dataList.push(list[i][this.dataId])
|
|
228
|
-
this.dataStore[list[i][this.dataId]] = list[i]
|
|
229
|
-
}
|
|
230
215
|
}
|
|
231
216
|
}
|
package/src/list.new/virtual.js
CHANGED
package/src/module/mediator.js
CHANGED
|
@@ -12,6 +12,16 @@ const mediator = ((() => {
|
|
|
12
12
|
return this
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const unsubscribe = function (store, fn) {
|
|
16
|
+
if (!mediator.stores[store]) {
|
|
17
|
+
return this
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
mediator.stores[store] = mediator.stores[store].filter(subscription => subscription.callback !== fn)
|
|
21
|
+
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
const publish = function (store, ...args) {
|
|
16
26
|
// console.log('publish', store, args)
|
|
17
27
|
if (!mediator.stores[store]) {
|
|
@@ -30,10 +40,12 @@ const mediator = ((() => {
|
|
|
30
40
|
stores: {},
|
|
31
41
|
publish,
|
|
32
42
|
subscribe,
|
|
43
|
+
unsubscribe,
|
|
33
44
|
installTo: function (obj) {
|
|
34
45
|
obj.subscribe = subscribe
|
|
35
46
|
obj.publish = publish
|
|
36
47
|
},
|
|
48
|
+
|
|
37
49
|
init: function (obj) {
|
|
38
50
|
obj.subscribe = subscribe
|
|
39
51
|
obj.publish = publish
|