-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabletop-display.js
38 lines (32 loc) · 979 Bytes
/
tabletop-display.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
(function ($) {
Drupal.tabletop = [];
Drupal.behaviors.tabletopDisplay = {
attach: function(context, settings) {
if (Drupal.settings.tabletop != undefined) {
Drupal.behaviors.tabletopDisplay.loadSheets(Drupal.settings.tabletop.tables);
}
},
loadSheets: function(tables) {
$.each(tables, function(k, sheets) {
// Create a Tabletop object for each spreadsheet key.
Drupal.tabletop[k] = Tabletop.init({
key: k,
wanted: sheets,
callback: Drupal.behaviors.tabletopDisplay.showInfo
});
});
},
showInfo: function() {
var table = this;
$.each(Drupal.settings.tabletop.templates, function(id, val) {
if (val.key == table.key) {
var $el = $('#' + id);
var output = Handlebars.compile($el.html())({
data: table.sheets(val.sheet).all()
});
$el.after(output);
}
});
}
}
})(jQuery);