forked from CINERGI/HtmlPivotViewerCustom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
passimagecontroller.js
71 lines (63 loc) · 1.91 KB
/
passimagecontroller.js
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
PASSImageController = PivotViewer.Views.IImageController.subClass({
init: function (baseContentPath) {
this._items = [];
this.TemplateGenerator = new PivotViewer.Views.ItemTemplateGetter(baseContentPath, '');
this.template = null;
var that = this;
$.subscribe("/PivotViewer/Views/Template/Loaded", function (evt) {
if (!evt && !evt.name) {
return;
}
that.template = evt.template;
});
},
Setup: function (basePath) {
this.TemplateGenerator.CreateItemTemplate('pass2012');
$.publish("/PivotViewer/ImageController/Collection/Loaded", null);
},
GetImagesAtLevel: function (item, level) {
if(!this.template)
return null;
if (!this._items[item.Img]) {
if (item.Facets["Category"]) {
var borderColour = '#000';
switch(item.Facets["Category"][0].Value){
case 'Regular Session':
borderColour = '#7E9F41';
break;
case 'Pre-Conference Session':
borderColour = '#F16729';
break;
case 'Spotlight Session':
borderColour = '#D62A28';
break;
case '1/2 Day Session':
borderColour = '#FBB221';
break;
case 'PASS Events':
borderColour = '#7B11C1';
break;
case 'PASS Keynotes':
borderColour = '#23B1E0';
break;
case 'Lightning Talks':
borderColour = '#7F7F7F';
break;
}
$('#pivotviewer').after("<canvas id='" + item.Id + "' class='placeholderPrerender' width='" + this.Width + "' height='" + this.Height + "' style='display:none;' ></canvas>");
var data = {
Category: borderColour,
Title: [ { Text: item.Name, ypos: 190 } ] //TODO: implment word breaker.
};
var databound = Mustache.render(this.template, data);
canvg(item.Id, databound);
var canvas = $('#' + item.Id);
this._items[item.Img] = canvas[0];
canvas.remove();
}
}
return this._items[item.Img];
},
Width: 256,
Height: 256
});