UNPKG

743 BJavaScriptView Raw
1
2
3
4var Data = List.extend({
5 //syncMethods: List.prototype.syncMethods.concat("isSubsetFrom"),
6 init: function (name) {
7 var list = this
8 , cache = Data.cached
9
10 for (var otherList in cache) {
11 otherList = cache[otherList]
12 if (list.isSubsetFrom(otherList)) {
13 break
14 }
15 }
16
17 list.load()
18 },
19 load: function() {
20 var list = this
21 , resume = list.wait()
22
23 xhr.get("../test/ui/data/" + list.name + ".json", function(err, result) {
24 list.removeAll()
25 if (!err) result.forEach(list.add, list)
26 resume()
27 list.emit("load")
28 })
29 return list
30 },
31 isSubsetFrom: function ( o/*verlaped*/ ) {
32 return this.name.slice(0, o.name.length) == o.name && this.name.slice(o.name.length).indexOf("/") == -1
33 }
34})
35
36El.data.Data = Data
37