| author | verrierj |
| Thu, 19 Jan 2012 16:46:06 +0100 | |
| changeset 424 | a2f72b31811b |
| parent 421 | c464acb185d6 |
| child 429 | 8c33427e558b |
| permissions | -rw-r--r-- |
| 348 | 1 |
{% extends "front/front_base.html" %} |
2 |
{% load i18n %} |
|
3 |
{% load thumbnail %} |
|
|
353
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
4 |
{% load front_tags %} |
| 348 | 5 |
|
| 404 | 6 |
{% block title %}Lignes de temps : {% trans 'search' %} "{{search}}" {% endblock %} |
| 348 | 7 |
|
| 355 | 8 |
{% block js_import %} |
9 |
{{block.super}} |
|
10 |
<script src="{{LDT_MEDIA_PREFIX}}js/jquery.min.js" type="text/javascript"/></script> |
|
| 374 | 11 |
<script src="{{LDT_MEDIA_PREFIX}}js/raphael.js" type="text/javascript"/></script> |
| 355 | 12 |
{% endblock %} |
13 |
||
| 348 | 14 |
{% block css_import %} |
15 |
{{block.super}} |
|
16 |
<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/front_search.css" type="text/css"/> |
|
17 |
{% endblock %} |
|
18 |
||
19 |
{% block body %} |
|
20 |
{{block.super}} |
|
| 355 | 21 |
<script type="text/javascript"> |
| 375 | 22 |
var _width = 340, |
23 |
_height = 25; |
|
| 371 | 24 |
var _medias = [ {% for res in results.object_list %} |
25 |
{ |
|
26 |
"iri_id" : '{{ res.content.iri_id }}', |
|
27 |
"duration" : {{ res.content.duration }}, |
|
28 |
"segments" : [ {% for segment in res.list %} |
|
29 |
{ |
|
30 |
"id" : '{{segment.element_id}}', |
|
31 |
"begin" : {{segment.begin}}, |
|
32 |
"duration" : {{segment.duration}}, |
|
33 |
},{% endfor %} |
|
34 |
], |
|
35 |
"stats" : [{{ res.content.stat_annotation }}], |
|
36 |
},{% endfor %} |
|
37 |
]; |
|
38 |
function getRect(_el) { |
|
39 |
var _sid = _el.id.substr(3); |
|
40 |
for (var _i = 0; _i < _medias.length; _i++) { |
|
41 |
for (var _j = 0; _j < _medias[_i].segments.length; _j++) { |
|
42 |
if (_medias[_i].segments[_j].id == _sid) { |
|
43 |
return _medias[_i].segments[_j].rect; |
|
44 |
} |
|
45 |
} |
|
46 |
} |
|
47 |
} |
|
| 355 | 48 |
$(document).ready(function () { |
| 371 | 49 |
$('.graph_annotation').each(function(_i) { |
50 |
var _values = _medias[_i].stats, |
|
51 |
_nb = _values.length, |
|
52 |
_max = _values.reduce(function(_a,_b) { |
|
53 |
return Math.max(_a,_b); |
|
| 376 | 54 |
}, 1), |
| 371 | 55 |
_x = function(_p) { |
| 375 | 56 |
return _p * _width / _nb; |
| 371 | 57 |
}, |
58 |
_y = function(_p) { |
|
| 375 | 59 |
return _height * ( 1 - _p / _max ); |
| 371 | 60 |
}, |
61 |
_d = _values.map(function(_v,_k) { |
|
62 |
return ( _k == 0 ? |
|
63 |
"M" + _x(_k) + " " + _y(_v) : |
|
64 |
"C" + _x(_k-.5) + " " + _y(_values[_k - 1]) |
|
65 |
+ " " + + _x(_k-.5) + " " + _y(_v) |
|
66 |
+ " " + + _x(_k) + " " + _y(_v) |
|
67 |
) ; |
|
| 375 | 68 |
}).join("") + "L" + _width + " " + _height + "L0 " + _height; |
| 371 | 69 |
this.innerHTML = ''; |
| 375 | 70 |
var _paper = new Raphael(this,_width,_height); |
| 371 | 71 |
_paper.path(_d).attr({ |
72 |
"fill" : "#adadad", |
|
73 |
"stroke" : "none" |
|
74 |
}); |
|
75 |
var _x = function(_p) { |
|
76 |
return _p * 340 / _medias[_i].duration; |
|
77 |
}; |
|
78 |
for (var _j = 0; _j < _medias[_i].segments.length; _j++) { |
|
79 |
var _s = _medias[_i].segments[_j]; |
|
80 |
_s.rect = _paper.rect(_x(_s.begin),0,_x(_s.duration),25).attr({ |
|
| 372 | 81 |
"fill" : "rgb(255,120,255)", |
82 |
"opacity" : .5, |
|
| 371 | 83 |
"stroke" : "none" |
84 |
}); |
|
85 |
} |
|
86 |
}); |
|
87 |
$("li.li_segment").mouseover(function() { |
|
| 374 | 88 |
getRect(this).attr("fill","rgb(255,0,255)"); |
| 371 | 89 |
}).mouseout(function() { |
| 374 | 90 |
getRect(this).attr("fill","rgb(255,120,2255)"); |
| 371 | 91 |
}); |
| 355 | 92 |
}); |
|
363
7872b0e9ebc9
update front search template to add annotation graph.
cavaliet
parents:
355
diff
changeset
|
93 |
</script> |
| 355 | 94 |
|
| 348 | 95 |
{% if msg %} |
96 |
{{ msg }} |
|
97 |
{% else %} |
|
98 |
{% ifequal nb_results 0 %} |
|
99 |
{% blocktrans %} No results for <b>{{ search }}</b>.{% endblocktrans %} |
|
100 |
{% else %} |
|
101 |
<!-- TABLE POUR ALIGNER À LA VERTICALE --> |
|
102 |
<table id="tbl_rech"> |
|
103 |
<tr> |
|
104 |
<!-- LISTE DES RÉSULTATS --> |
|
105 |
<td> |
|
106 |
<ul class="floatlist" id="liste_resultats"> |
|
107 |
<!-- titre "Résultats de recherche" et options --> |
|
108 |
<li id="li_haut_resultats"> |
|
109 |
<ul class="floatlist" id="ul_haut_resultats"> |
|
110 |
<li id="title_resultats"> |
|
111 |
<h2>{% trans "Search results for " %} <b> {{ search }}</b></h2> |
|
112 |
</li> |
|
113 |
<li> |
|
114 |
<p id="p_nb_resultats">{{ nb_results }} {% trans "Result" %}{{ nb_results|pluralize }}</p> |
|
115 |
</li> |
|
116 |
<!--li id="resultats_options">options</li--> |
|
117 |
</ul> |
|
118 |
</li> |
|
119 |
<!-- Médias trouvés --> |
|
120 |
||
121 |
<!-- Média --> |
|
122 |
{% autoescape off %} |
|
123 |
{% for res in results.object_list %} |
|
124 |
<li class="li_result_media"> |
|
125 |
<div class="titre_result_media"> |
|
126 |
<div class="h3_result_media"> |
|
| 420 | 127 |
<h3>{% if res.content_title|length > 20 %}{{res.content_title|capfirst|slice:"20"}}...{% else %}{{res.content_title}}{% endif %}</h3> |
| 348 | 128 |
</div> |
129 |
<div class="duree_result_media"> |
|
|
353
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
130 |
<p>{{res.content.duration|str_duration:"::"}}</p> |
| 348 | 131 |
</div> |
132 |
<div class="graphe_result_media"> |
|
| 424 | 133 |
<span id="{{ res.content.iri_id }}" class="graph_annotation" title="{% trans 'annotation distribution' %}"> |
| 355 | 134 |
{{ res.content.stat_annotation }} |
135 |
</span> |
|
| 348 | 136 |
</div> |
137 |
</div> |
|
138 |
||
139 |
<!-- Segments du média --> |
|
140 |
<ul class="floatlist list_segments"> |
|
141 |
{% for segment in res.list %} |
|
| 371 | 142 |
<li class="li_segment" id="li_{{segment.element_id}}"> |
| 348 | 143 |
<div class="left_segment"> |
144 |
<div class="color_zone" style="background: #f49af5;"></div> |
|
| 424 | 145 |
<a href="{% url ldt.ldt_utils.views.front.annot_content segment.iri_id segment.project_id segment.decoupage_id %}#id={{segment.element_id}}"><img src="{{LDT_MEDIA_PREFIX}}img/annot_icon_80x45.png" width="80" height="45" alt="" /></a> |
|
353
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
146 |
<!--p class="duree_segment">{{ segment.duration|str_duration:"::" }}</p--> |
| 348 | 147 |
</div> |
| 424 | 148 |
<h4 class="title_segment"><a class="blue under" href="{% url ldt.ldt_utils.views.front.annot_content segment.iri_id segment.project_id segment.decoupage_id %}#id={{segment.element_id}}" title="{% trans 'view this annotation in the player' %}"> |
| 348 | 149 |
{% if segment.title %}{{ segment.title }}{% else %}{% trans "No title" %}{% endif %}</a></h4> |
|
353
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
150 |
<p class="text_segment">{% if segment.context %}{{ segment.context }}{% endif %}<br/>{% trans "Begin" %} : {{ segment.begin|str_duration:"::" }} - {% trans "duration" %} : {{ segment.duration|str_duration:"::" }}</h4> |
| 348 | 151 |
</li> |
152 |
{% endfor %} |
|
153 |
</ul> |
|
154 |
</li> |
|
155 |
{% endfor %} |
|
156 |
{% endautoescape %} |
|
157 |
<!-- Fin des médias --> |
|
158 |
<!-- Pagination --> |
|
159 |
<li id="result_pagination"> |
|
160 |
<p> |
|
161 |
{% if results.has_previous %} |
|
| 424 | 162 |
<a class="blue under" href="{% url ldt.ldt_utils.views.front.search_listing %}?page={{ results.previous_page_number }}" title="{% trans 'previous' %}">{% trans "previous" %}</a> |
|
353
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
163 |
. |
| 348 | 164 |
{% endif %} |
165 |
{% if results.paginator.num_pages > 1 %} |
|
166 |
<span class="current"> |
|
|
353
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
167 |
{% for i in results.paginator.num_pages|get_range %} |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
168 |
<span class="current"> |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
169 |
{% if i|add:'1' == results.number %} |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
170 |
<span class="pink">{{i|add:'1'}}</span> |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
171 |
{% else %} |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
172 |
<a class="blue under" href="{% url ldt.ldt_utils.views.front.search_listing %}?page={{i|add:'1'}}">{{i|add:'1'}}</a> |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
173 |
{% endif %} |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
174 |
{% if i|add:'1' < results.paginator.num_pages and 1 < results.paginator.num_pages %} |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
175 |
. |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
176 |
{% endif %} |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
177 |
</span> |
|
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
178 |
{% endfor %} |
| 348 | 179 |
</span> |
180 |
{% endif %} |
|
181 |
{% if results.has_next %} |
|
|
353
bf08750b894c
Update search and front search template. Add tag filter for duration presentation.
cavaliet
parents:
349
diff
changeset
|
182 |
. |
| 424 | 183 |
<a class="blue under" href="{% url ldt.ldt_utils.views.front.search_listing %}?page={{ results.next_page_number }}" title="{% trans 'next' %}">{% trans "next" %}</a> |
| 348 | 184 |
{% endif %} |
185 |
</p> |
|
186 |
</li> |
|
187 |
<!-- Fin Pagination --> |
|
188 |
</ul> |
|
189 |
||
190 |
||
191 |
<!-- Right column --> |
|
192 |
<!-- APERÇU DU RÉSULTAT --> |
|
193 |
<td id="result_preview"> |
|
194 |
<h4>ICI PREVIEW ?</h4> |
|
195 |
<p class="bigmargin">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem …</p> |
|
196 |
</td> |
|
197 |
</tr> |
|
198 |
</table> |
|
199 |
||
200 |
{% endifequal %} |
|
201 |
{% endif %} |
|
202 |
||
203 |
{% endblock %} |
|
204 |