1 |
1 |
{% load dashboard thumbnail %}
|
2 |
2 |
{% if not in_dashboard %}
|
3 |
|
{% with actualites=json.data|get:slug %}
|
4 |
3 |
<div class="dashboard-settings">
|
5 |
4 |
<div class="dashboard-meta">
|
6 |
|
<h2>{{actualites.label}}</h2>
|
7 |
|
<div>{{actualites.description}}</div>
|
|
5 |
<h2>{{json.meta.label}}</h2>
|
|
6 |
<div>{{json.meta.description}}</div>
|
8 |
7 |
</div>
|
9 |
8 |
<div class="dashboard-switch">
|
10 |
9 |
{% with tile=cell|as_dashboard_cell:request.user %}
|
11 |
|
<input type="checkbox" id="actualites-id-{{slug}}"
|
|
10 |
<input type="checkbox" id="actualites-id-{{connector}}{{query}}"
|
12 |
11 |
data-add-tile-url="{% url 'combo-dashboard-add-tile' cell_reference=cell.get_reference %}"
|
13 |
12 |
{% if tile %}
|
14 |
13 |
checked
|
15 |
14 |
data-remove-tile-url="{% url 'combo-dashboard-remove-tile' cell_reference=tile.cell.get_reference %}"
|
16 |
15 |
{% endif %}
|
17 |
16 |
>
|
18 |
17 |
{% endwith %}
|
19 |
18 |
<script>
|
20 |
|
$('#actualites-id-{{slug}}').on('change', function() {
|
|
19 |
$('#actualites-id-{{connector}}{{query}}').on('change', function() {
|
21 |
20 |
if ($(this).is(':checked')) {
|
22 |
21 |
var $checkbox = $(this);
|
23 |
22 |
$.ajax({
|
24 |
23 |
url: $(this).data('add-tile-url'),
|
25 |
24 |
success: function(data) {
|
26 |
25 |
$checkbox.data('remove-tile-url', data.cell_data.remove_url);
|
27 |
26 |
$('h1#logo').addClass('dashboard-change').on('animationend', function() { $('h1#logo').removeClass('dashboard-change')});
|
28 |
27 |
}
|
... | ... | |
32 |
31 |
url: $(this).data('remove-tile-url'),
|
33 |
32 |
success: function(data) {}
|
34 |
33 |
});
|
35 |
34 |
}
|
36 |
35 |
});
|
37 |
36 |
</script>
|
38 |
37 |
</div>
|
39 |
38 |
</div>
|
40 |
|
{% endwith %}
|
41 |
39 |
{% else %}
|
42 |
|
{% with actualites=json.data|get:slug %}
|
43 |
|
{% if actus.data %}
|
44 |
|
<button hidden class="newsitem-category" data-slug="{{ slug }}">{{actualites.label}}</button>
|
45 |
|
{% endif %}
|
46 |
|
{% for actu in actus.data %}
|
47 |
|
<div class="newsitem" data-slug="{{ slug }}" data-date="{{ actu.date }}">
|
48 |
|
{% thumbnail actu.image "160x160" crop="50% 25%" as im %}
|
|
40 |
<button hidden class="newsitem-category" data-slug="{{connector}}-{{query}}">{{json.meta.label}}</button>
|
|
41 |
{% for actu in json.data %}
|
|
42 |
<div class="newsitem" data-slug="{{connector}}-{{query}}" data-date="{{ actu.created }}">
|
|
43 |
{% thumbnail actu.image.download "160x160" crop="50% 25%" as im %}
|
49 |
44 |
<img src="{{ im.url }}" alt="" />
|
50 |
45 |
{% endthumbnail %}
|
51 |
46 |
<div>
|
52 |
|
<h3><a href="{{actu.href}}">{{actu.title}}</a></h3>
|
53 |
|
<h4>{{actualites.label}} - {{ actu.date|parse_date|date:"d/m/Y" }}</h4>
|
54 |
|
<p>{{actu.description}}</p>
|
|
47 |
<h3><a href="{{actu.PLONE_id}}">{{actu.title}}</a></h3>
|
|
48 |
<h4>{{json.meta.label}} - {{ actu.created|slice:19|parse_date|date:"d/m/Y" }}</h4>
|
|
49 |
<p>{{actu.description|truncatechars:200|safe|escape}}</p>
|
55 |
50 |
</div>
|
56 |
51 |
</div>
|
57 |
52 |
{% endfor %}
|
58 |
|
{% if actus.data %}
|
|
53 |
{% if json.data %}
|
59 |
54 |
<script>
|
60 |
55 |
jQuery.fn.order = function(asc, fn) { // via https://jsfiddle.net/mindplay/H2mrp/
|
61 |
56 |
fn = fn || function (el) {
|
62 |
57 |
return $(el).text().replace(/^\s+|\s+$/g, '');
|
63 |
58 |
};
|
64 |
59 |
var T = asc !== false ? 1 : -1,
|
65 |
60 |
F = asc !== false ? -1 : 1;
|
66 |
61 |
this.sort(function (a, b) {
|
... | ... | |
81 |
76 |
$newsitems.appendTo($('.dashboard-cell > div'));
|
82 |
77 |
}
|
83 |
78 |
$('.newsitem').detach().appendTo($newsitems);
|
84 |
79 |
$('.newsitem-category').detach().attr('hidden', null).appendTo($newsitems.find('.categories'));
|
85 |
80 |
$('.newsitem-category').order(true);
|
86 |
81 |
$('.newsitem').order(false, function(el) { return $(el).data('date'); });
|
87 |
82 |
</script>
|
88 |
83 |
{% endif %}
|
89 |
|
{% endwith %}
|
90 |
84 |
{% endif %}
|
91 |
|
-
|