|
1 |
{% load dashboard static thumbnail %}
|
|
2 |
{% if not in_dashboard %}
|
|
3 |
<div class="dashboard-settings">
|
|
4 |
<div class="dashboard-meta">
|
|
5 |
<h2>{{json.meta.label}}</h2>
|
|
6 |
<div>{{json.meta.description}}</div>
|
|
7 |
</div>
|
|
8 |
<div class="dashboard-switch">
|
|
9 |
{% with tile=cell|as_dashboard_cell:request.user %}
|
|
10 |
<input type="checkbox" id="actualites-id-{{connector}}{{query}}"
|
|
11 |
data-add-tile-url="{% url 'combo-dashboard-add-tile' cell_reference=cell.get_reference %}"
|
|
12 |
{% if tile %}
|
|
13 |
checked
|
|
14 |
data-remove-tile-url="{% url 'combo-dashboard-remove-tile' cell_reference=tile.cell.get_reference %}"
|
|
15 |
{% endif %}
|
|
16 |
>
|
|
17 |
{% endwith %}
|
|
18 |
<script>
|
|
19 |
$('#actualites-id-{{connector}}{{query}}').on('change', function() {
|
|
20 |
if ($(this).is(':checked')) {
|
|
21 |
var $checkbox = $(this);
|
|
22 |
$.ajax({
|
|
23 |
url: $(this).data('add-tile-url'),
|
|
24 |
success: function(data) {
|
|
25 |
$checkbox.data('remove-tile-url', data.cell_data.remove_url);
|
|
26 |
$('h1#logo').addClass('dashboard-change').on('animationend', function() { $('h1#logo').removeClass('dashboard-change')});
|
|
27 |
}
|
|
28 |
});
|
|
29 |
} else {
|
|
30 |
$.ajax({
|
|
31 |
url: $(this).data('remove-tile-url'),
|
|
32 |
success: function(data) {}
|
|
33 |
});
|
|
34 |
}
|
|
35 |
});
|
|
36 |
</script>
|
|
37 |
</div>
|
|
38 |
</div>
|
|
39 |
{% else %}
|
|
40 |
<button hidden class="newsitem-category" data-slug="{{connector}}-{{query}}">{{json.meta.label}}</button>
|
|
41 |
{% for event in json.data %}
|
|
42 |
<div class="newsitem" data-slug="{{connector}}-{{query}}" data-date="{{ event.created }}">
|
|
43 |
{% thumbnail event.image.download "160x160" crop="50% 25%" as im %}
|
|
44 |
<img src="{{ im.url }}" alt="" />
|
|
45 |
{% endthumbnail %}
|
|
46 |
{% if not event.image %}
|
|
47 |
<img src="{{site_base}}{% static "" %}{{css_variant}}/placeholder-logo-bla.jpeg" alt="" height="160" width="160">
|
|
48 |
{% endif %}
|
|
49 |
<div>
|
|
50 |
<h3><a href="{{event.PLONE_id}}">{{event.title}}</a></h3>
|
|
51 |
{% with start_date=event.start|slice:9|parse_date|date:"d/m/Y" start_time=event.start|slice:"11:16" %}
|
|
52 |
<h4>{{json.meta.label}} -
|
|
53 |
{% with end_date=event.end|slice:9|parse_date|date:"d/m/Y" end_time=event.end|slice:"11:16" %}
|
|
54 |
{% if event.end and end_date != start_date %}
|
|
55 |
du {{ start_date }} à {{ start_time }}
|
|
56 |
au {{ end_date }} à {{ end_time }}
|
|
57 |
{% else %}
|
|
58 |
le {{ start_date }}
|
|
59 |
{% if event.end and end_time != start_time %}
|
|
60 |
de {{ start_time }} à {{ end_time }}
|
|
61 |
{% else %}
|
|
62 |
à {{ start_time }}
|
|
63 |
{% endif %}
|
|
64 |
{% endif %}
|
|
65 |
{% endwith %}
|
|
66 |
{% endwith %}
|
|
67 |
</h4>
|
|
68 |
<p>{{event.description|truncatechars:200|safe|escape}}</p>
|
|
69 |
</div>
|
|
70 |
</div>
|
|
71 |
{% endfor %}
|
|
72 |
{% if json.data %}
|
|
73 |
<script>
|
|
74 |
jQuery.fn.order = function(asc, fn) { // via https://jsfiddle.net/mindplay/H2mrp/
|
|
75 |
fn = fn || function (el) {
|
|
76 |
return $(el).text().replace(/^\s+|\s+$/g, '');
|
|
77 |
};
|
|
78 |
var T = asc !== false ? 1 : -1,
|
|
79 |
F = asc !== false ? -1 : 1;
|
|
80 |
this.sort(function (a, b) {
|
|
81 |
a = fn(a), b = fn(b);
|
|
82 |
if (a == b) return 0;
|
|
83 |
return a < b ? F : T;
|
|
84 |
});
|
|
85 |
this.each(function (i) {
|
|
86 |
this.parentNode.appendChild(this);
|
|
87 |
});
|
|
88 |
};
|
|
89 |
// move newsitems in a specific div (.newsitems, created as a child of the
|
|
90 |
// dashboard cell if necessary), and sort all of them (maybe from several
|
|
91 |
// categories on date); also add a toggle button for the category.
|
|
92 |
var $newsitems = $('.dashboard-cell .newsitems');
|
|
93 |
if ($newsitems.length == 0) {
|
|
94 |
var $newsitems = $('<div class="newsitems"><h2>Événements</h2><div class="categories"></div></div>');
|
|
95 |
$newsitems.appendTo($('.dashboard-cell > div'));
|
|
96 |
}
|
|
97 |
$('.newsitem').detach().appendTo($newsitems);
|
|
98 |
$('.newsitem-category').detach().attr('hidden', null).appendTo($newsitems.find('.categories'));
|
|
99 |
$('.newsitem-category').order(true);
|
|
100 |
$('.newsitem').order(false, function(el) { return $(el).data('date'); });
|
|
101 |
</script>
|
|
102 |
{% endif %}
|
|
103 |
{% endif %}
|
0 |
|
-
|