This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.js
52 lines (49 loc) · 1.84 KB
/
template.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
(function ($) {
$(document).ready(function () {
initPage(document);
});
$(document).on("opencontent.change", function (event, element) {
initPage(element);
});
var template = '';
function initPage(element) {
$(".jplist", element).each(function () {
var moduleScope = $(this),
self = moduleScope,
sf = $.ServicesFramework($(this).attr('data-moduleid'));
var $list = $('#oc-photo-album .list')
, template = Handlebars.compile($('#jplist-template').html());
$(this).jplist({
itemsBox: ".list"
, itemPath: ".list-item"
, panelPath: ".jplist-panel"
, deepLinking: true
, dataSource: {
type: 'server'
, server: {
ajax: {
data: {}
, url: sf.getServiceRoot('OpenContent') + "JplistAPI/List"
, dataType: 'json'
, type: 'POST'
, beforeSend: sf.setModuleHeaders
}
}
, render: function (dataItem, statuses) {
$list.html(template(dataItem.content));
}
}
});
});
}
if (typeof Handlebars != 'undefined') {
Handlebars.registerHelper('formatDateTime', function (context, format) {
if (window.moment && context && moment(context).isValid()) {
var f = format || "DD/MM/YYYY";
return moment(context).format(f);
} else {
return context; // moment plugin is not available, context does not have a truthy value, or context is not a valid date
}
});
}
}(jQuery));