forked from h5p/moodle-mod_hvp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataviews.js
43 lines (40 loc) · 1.31 KB
/
dataviews.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
/* global H5PDataView */
(function($) {
/**
* Creates a new dataview.
*
* @private
* @param {object} dataView Structure
* @param {string} dataView.source AJAX URL for data view
* @param {object[]} dataView.headers Header text and props
* @param {boolean[]} dataView.filters Which fields to allow filtering for
* @param {object} dataView.order Default order by and direction
* @param {object} dataView.l10n Translations
* @param {Element} wrapper Where in the DOM should the dataview be appended
* @param {function} loaded Callback for when the dataview is ready
*/
var createDataView = function(dataView, wrapper, loaded) {
new H5PDataView(
wrapper,
dataView.source,
dataView.headers,
dataView.l10n,
undefined,
dataView.filters,
loaded,
dataView.order
);
};
// Create data views when page is done loading.
$(document).ready(function() {
for (var id in H5PIntegration.dataViews) {
if (!H5PIntegration.dataViews.hasOwnProperty(id)) {
continue;
}
var wrapper = $('#' + id).get(0);
if (wrapper !== undefined) {
createDataView(H5PIntegration.dataViews[id], wrapper);
}
}
});
})(H5P.jQuery);