-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhead-start-exhibit.OLD
79 lines (66 loc) · 2.27 KB
/
head-start-exhibit.OLD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Start Exhibit Manually
Exhibit.Functions["contains"] = {
f: function(args) {
var result = args[0].size > 0;
var set = args[0].getSet();
args[1].forEachValue(function(v) {
if (!set.contains(v)) {
result = false;
return true;
}
});
return new Exhibit.Expression._Collection([ result ? "true" : "false" ], "boolean");
}
};
SimileAjax.jQuery(document).ready(function() {
window.database = Exhibit.Database.create();
window.database.loadDataLinks(onDataLoaded);
});
function onDataLoaded() {
window.exhibit = Exhibit.create();
createCollections();
window.exhibit.configureFromDOM();
};
function createCollections() {
var auto_union = new Exhibit.Collection.create2("auto_union", {}, window.exhibit.getUIContext());
var collection_all = new Exhibit.Collection("collection_all", window.database);
window.exhibit.setCollection("auto_union", auto_union);
window.exhibit.setCollection("collection_all", collection_all);
/*
* For each type of item, create a collection
*/
var types = window.database._types;
var collections = {};
for (var key in types) {
// if (key != "Item") {
var id = types[key].getID();
collections[id] = Exhibit.Collection.create2(
'collection_'+id,
{
baseCollectionID: 'auto_union',
expression:"filter(value, contains(.type, '" + id + "'))"
},
window.exhibit.getUIContext()
);
window.exhibit.setCollection('collection_' + id, collections[id]);
// }
}
collection_all._update = function() {
var dunnit = false;
for (var key in collections) {
if (!dunnit) {
this._items = new Exhibit.Set(collections[key].getRestrictedItems());
dunnit = true;
}
else {
this._items.addSet(collections[key].getRestrictedItems());
}
}
this._onRootItemsChanged();
};
collection_all._listener = { onItemsChanged: function() { collection_all._update(); } };
for (var key in types) {
collections[id].addListener(collection_all._listener);
}
collection_all._update();
};