| author | Anthony Ly <anthonyly.com@gmail.com> |
| Mon, 10 Jun 2013 15:58:23 +0200 | |
| changeset 107 | f354d24e08ca |
| parent 105 | 8645721dd9fc |
| child 110 | ebbb23d32748 |
| permissions | -rw-r--r-- |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
1 |
var myMedia = undefined, |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
2 |
currentChapter = undefined, |
| 101 | 3 |
currentAnnotation = undefined, |
| 105 | 4 |
currentSlider = undefined, |
| 101 | 5 |
secMiniChapter = 10; |
| 28 | 6 |
|
| 9 | 7 |
$(function(){ |
| 6 | 8 |
|
| 107 | 9 |
var global = { |
10 |
colorsIndex : 0, |
|
11 |
colors : |
|
12 |
['#1abc9c', '#3498db', '#9b59b6', '#2ecc71', |
|
13 |
'#f1c40f', '#ecf0f1', '#e67e22', '#e74c3c', '#95a5a6', |
|
14 |
'#16a085', '#2980b9', '#8e44ad', '#27ae60', |
|
15 |
'#f39c12', '#c0392b', '#bdc3c7', '#d35400', '#7f8c8d'] |
|
16 |
}; |
|
| 101 | 17 |
|
| 107 | 18 |
function getTemplate(idTpl){ |
19 |
return $('#templates').find(idTpl).html(); |
|
| 84 | 20 |
} |
21 |
||
| 107 | 22 |
myProject.onLoad(function() { |
23 |
myProject.regenerateTags = true; |
|
24 |
||
25 |
$(".project-title").text(myProject.title); |
|
26 |
$('.project-title-nav').text(myProject.title); |
|
27 |
||
28 |
myMedia = myProject.getCurrentMedia(); |
|
| 84 | 29 |
|
| 107 | 30 |
var anntypes = myProject.getAnnotationTypes().searchByTitle("chapitrage"); |
31 |
if (!anntypes.length) { |
|
32 |
chapterAnnType = new IriSP.AnnotationType(false, myProject); |
|
33 |
chapterAnnType.title = "chapitrage"; |
|
34 |
} else { |
|
35 |
chapterAnnType = anntypes[0]; |
|
36 |
} |
|
| 58 | 37 |
|
| 107 | 38 |
//load Chapitre |
39 |
chapters = chapterAnnType.getAnnotations(); |
|
40 |
$.each(chapters, function(k, v){ |
|
41 |
v.color = getRandomColor(); |
|
42 |
}); |
|
43 |
renderChapter(); |
|
| 58 | 44 |
|
| 107 | 45 |
//load Annotations |
46 |
var anntypes = myProject.getAnnotationTypes().searchByTitle("annotations"); |
|
47 |
if (!anntypes.length) { |
|
48 |
annotationsAnnType = new IriSP.AnnotationType(false, myProject); |
|
49 |
annotationsAnnType.title = "annotations"; |
|
50 |
} else { |
|
51 |
annotationsAnnType = anntypes[0]; |
|
52 |
} |
|
53 |
||
54 |
annotations = annotationsAnnType.getAnnotations(); |
|
55 |
$.each(annotations, function(k, v){ |
|
56 |
var type = v.content.mimetype.split('-'); |
|
57 |
type = type[type.length-1] |
|
58 |
v.type = type; |
|
59 |
v.color = getRandomColor(); |
|
60 |
}); |
|
61 |
renderAnnotation(); |
|
| 58 | 62 |
|
|
55
cedadc7d039a
modal delete in html title update
Anthony Ly <anthonyly.com@gmail.com>
parents:
54
diff
changeset
|
63 |
|
| 107 | 64 |
IriSP.htmlPlayer( |
65 |
myMedia, |
|
66 |
$(".main-video"), |
|
67 |
{ |
|
68 |
width: 460, |
|
69 |
height: 345, |
|
70 |
controls: true, |
|
71 |
autostart: true, |
|
72 |
url_transform: function(src) { |
|
73 |
return [{ |
|
74 |
type: "video/mp4", |
|
75 |
src: src.replace(/\.[\d\w]+$/,'.mp4').replace('rtmp://media.iri.centrepompidou.fr/ddc_player', 'http://media.iri.centrepompidou.fr') |
|
76 |
}, { |
|
77 |
type: "video/webm", |
|
78 |
src: src.replace(/\.[\d\w]+$/,'.webm').replace('rtmp://media.iri.centrepompidou.fr/ddc_player', 'http://media.iri.centrepompidou.fr') |
|
79 |
}]; |
|
80 |
} |
|
| 54 | 81 |
} |
| 107 | 82 |
); |
| 16 | 83 |
|
| 107 | 84 |
myMedia.on("timeupdate", function(t) { |
| 16 | 85 |
|
| 107 | 86 |
//curseur chapitre |
87 |
var wContainer = $('.chapitre-cut-wrap').width() - 1, |
|
88 |
pos = wContainer * t / myMedia.duration, |
|
89 |
btnCutChapter = $('.btn-cut-chapter'), |
|
90 |
wBtnCutChapter = btnCutChapter.outerWidth(); |
|
91 |
|
|
92 |
$(".indicateur-chapter, .indicateur-annotation").css("left",pos); |
|
93 |
if(pos+wBtnCutChapter>wContainer){ |
|
94 |
btnCutChapter.css("left",(pos - wBtnCutChapter)); |
|
95 |
}else{ |
|
96 |
btnCutChapter.css("left",pos); |
|
97 |
} |
|
98 |
$('.info-time').text(t) |
|
99 |
//annotations view |
|
100 |
refreshAnnotationDisplay(t); |
|
101 |
||
102 |
});//timeupdate |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
103 |
|
| 107 | 104 |
});//myProject.onLoad |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
105 |
|
| 107 | 106 |
/* Display annotation in timeline */ |
| 16 | 107 |
|
| 107 | 108 |
//survol |
109 |
$(document).on('mouseover', '.timeline-annotations .annotation, #list-annotations-rows tr, .item-display-annotation' , function(){ |
|
110 |
if(!$(this).hasClass('shadow')) { |
|
111 |
var idAnnotation = $(this).attr('data-id'); |
|
112 |
$('#annotation-timeline-'+idAnnotation+', #row-list-annotation-'+idAnnotation+', #item-current-annotation-'+idAnnotation).addClass('shadow'); |
|
113 |
} |
|
114 |
}); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
115 |
|
| 107 | 116 |
$(document).on('mouseover', '.chapter-segment, .row-list-chapter' , function(){ |
117 |
if(!$(this).hasClass('shadow')) { |
|
118 |
var idChapter = $(this).attr('data-id'); |
|
119 |
$('#row-list-chapter-'+idChapter+', #'+idChapter+', #form-chapter-edit-'+idChapter).addClass('shadow'); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
120 |
} |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
121 |
}); |
| 107 | 122 |
|
123 |
$(document).on('mouseout', '.shadow' , function(){ |
|
124 |
$('.shadow').removeClass('shadow'); |
|
125 |
}); |
|
126 |
||
127 |
$(document).on('click', '.annotation, .item-display-annotation', function(e){ |
|
128 |
e.preventDefault(); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
129 |
var idAnnotation = $(this).attr('data-id'), |
| 107 | 130 |
annotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
131 |
myMedia.setCurrentTime(annotation.begin); |
|
132 |
if($('#tab-annotation-'+idAnnotation).length){ |
|
133 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
|
134 |
}else{ |
|
135 |
openTab(annotation.type, annotation); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
136 |
} |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
137 |
}); |
| 107 | 138 |
|
139 |
function refreshAnnotationDisplay(t){ |
|
140 |
var currentAnnotationsDisplay = new Array(); |
|
141 |
$.each(annotations, function(k, v){ |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
142 |
|
| 107 | 143 |
if(v.begin <= t && v.end >= t){ |
144 |
currentAnnotationsDisplay.push(v.id); |
|
145 |
if(!$('#item-current-annotation-'+v.id).length){ |
|
146 |
var itemAnnotation = getTemplate('#tpl-item-annotation-display'); |
|
147 |
v.iconTab = getIcon(v.type); |
|
148 |
itemAnnotation = Mustache.render(itemAnnotation, v); |
|
149 |
$('.list-current-annotations').append(itemAnnotation) |
|
150 |
} |
|
151 |
} |
|
152 |
}); |
|
| 6 | 153 |
|
| 107 | 154 |
$.each($('.list-current-annotations li'), function(k, v){ |
155 |
var idAnnotation = $(this).attr('data-id'), |
|
156 |
annotationDisplayView = $('.annotation-display-view'); |
|
157 |
if($.inArray(idAnnotation, currentAnnotationsDisplay)<0){//il ne doit plus être affiché |
|
158 |
$('#item-current-annotation-'+idAnnotation).remove(); |
|
159 |
if(annotationDisplayView.attr('data-id') == idAnnotation && annotationDisplayView.is(":visible")){ |
|
160 |
annotationDisplayView.hide(); |
|
161 |
} |
|
162 |
} |
|
163 |
}); |
|
164 |
if(currentAnnotation !== undefined){ |
|
165 |
showCurrentAnnotationInTimeline(currentAnnotation.id); |
|
166 |
} |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
167 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
168 |
|
| 107 | 169 |
function showCurrentAnnotationInTimeline(idAnnotation){ |
170 |
$('.annotation').removeClass('editing'); |
|
171 |
$('#annotation-timeline-'+idAnnotation).addClass('editing'); |
|
172 |
} |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
173 |
|
| 107 | 174 |
$('.list-current-annotations').on('click', 'a', function(e){ |
175 |
e.preventDefault(); |
|
| 22 | 176 |
}); |
| 107 | 177 |
|
| 22 | 178 |
|
| 107 | 179 |
/* Modal */ |
| 51 | 180 |
|
| 6 | 181 |
//confirmation suppression |
182 |
$("#modal-confirm").on('click', '#btn-delete-modal', function(e){ |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
183 |
|
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
184 |
var typeDelete = $(this).attr('data-type-delete'), |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
185 |
idAnnotation = $(this).attr('data-id'); |
| 9 | 186 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
187 |
if(typeDelete == 'chapter' || typeDelete == 'annotation'){ |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
188 |
e.preventDefault(); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
189 |
if(typeDelete == 'chapter') deleteChapter(idAnnotation); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
190 |
if(typeDelete == 'annotation') deleteAnnotation(idAnnotation); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
191 |
} |
| 6 | 192 |
}); |
193 |
||
| 107 | 194 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
195 |
|
| 107 | 196 |
/* Title project */ |
197 |
||
| 62 | 198 |
$(document).on('click', '.project-title-editor i, .project-title', function () { |
| 105 | 199 |
|
| 62 | 200 |
var html = $('.project-title').html(); |
201 |
var input = $('<input type="text" />'); |
|
202 |
input.val(html); |
|
203 |
$('.project-title').replaceWith(input); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
204 |
input.focus().keypress(function(e){ |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
205 |
code = (e.keyCode ? e.keyCode : e.which); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
206 |
if (code == 13) $(this).blur(); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
207 |
}); |
| 62 | 208 |
}); |
209 |
$(document).on('blur', '.project-title-editor input', function(){ |
|
210 |
var newTitle = $(this).val(); |
|
211 |
myProject.title = newTitle; |
|
212 |
$(this).replaceWith('<span class="project-title">'+newTitle+'</span></td>'); |
|
213 |
$('.project-title-nav').text(newTitle); |
|
| 107 | 214 |
disabledPreview(); |
| 6 | 215 |
}); |
216 |
||
| 9 | 217 |
|
| 107 | 218 |
/* Chapter */ |
| 22 | 219 |
|
| 107 | 220 |
//edit |
| 22 | 221 |
$('.list-chapter-wrap').on('click', '.btn-edit-chapter', function(e){ |
| 6 | 222 |
e.preventDefault(); |
| 22 | 223 |
var idChapter = $(this).attr('data-chapter-id'); |
224 |
loadFormChapter(idChapter); |
|
225 |
}); |
|
226 |
||
| 23 | 227 |
$('.chapter-segments').on('click', 'li', function(){ |
228 |
var idChapter = $(this).attr('id'); |
|
229 |
loadFormChapter(idChapter); |
|
230 |
}); |
|
| 22 | 231 |
|
232 |
$('.chapter-widget-info').on('keyup', 'input[name=title], textarea', function(e){ |
|
233 |
var name = $(this).attr('name'), |
|
234 |
value = $(this).val(); |
|
235 |
currentChapter[name] = value; |
|
236 |
if(name == 'title'){ |
|
237 |
var idChapter = $(this).parents('form').attr('data-chapter-id'); |
|
238 |
$('.chapter-segments').find('#'+idChapter).text(value); |
|
239 |
$('#row-list-chapter-'+idChapter).find('td:first').text(value); |
|
| 95 | 240 |
$(this).parents('form').find('.btn-delete-chapter').attr('data-title', value); |
| 6 | 241 |
} |
| 107 | 242 |
disabledPreview(); |
| 22 | 243 |
}); |
244 |
||
245 |
function loadFormChapter(idChapter){ |
|
| 28 | 246 |
currentChapter = _.find(chapters, function(c){ return c.id == idChapter; }); |
247 |
var chapterWrap = $('.chapter-widget-info'), |
|
248 |
indexChapter = _.indexOf(chapters, currentChapter), |
|
249 |
beginTangle = (indexChapter>0) ? true : false, |
|
250 |
endTangle = (indexChapter<(chapters.length-1)) ? true : false; |
|
| 22 | 251 |
|
| 28 | 252 |
currentChapter.beginTangle = beginTangle; |
253 |
currentChapter.endTangle = endTangle; |
|
| 22 | 254 |
|
| 62 | 255 |
var tpl = getTemplate('#tpl-chapter-edit'); |
| 28 | 256 |
tpl = Mustache.render(tpl, currentChapter); |
| 22 | 257 |
chapterWrap.empty().append(tpl); |
258 |
chapterWrap.find('.tag-it').tagit(tagitParam); |
|
| 58 | 259 |
|
260 |
myMedia.setCurrentTime(currentChapter.begin); |
|
| 22 | 261 |
} |
262 |
||
| 107 | 263 |
//delete chapter |
264 |
$(document).on('click', '.btn-delete-chapter', function(e){ |
|
265 |
e.preventDefault(); |
|
| 22 | 266 |
|
| 107 | 267 |
if(chapters.length == 1){ |
268 |
$('#modal-alert .alert-message').hide(); |
|
269 |
$('#modal-alert #alert-chapter-number').show(); |
|
270 |
$('#modal-alert').modal('show'); |
|
271 |
return; |
|
272 |
} |
|
273 |
var idChapter = $(this).attr('data-chapter-id'), |
|
274 |
btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
|
275 |
btnDeleteModal.attr('data-type-delete', 'chapter'); |
|
276 |
btnDeleteModal.attr('data-id', idChapter); |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
277 |
|
| 107 | 278 |
var titleMedia = $(this).attr('data-title'), |
279 |
urlDelete = $(this).attr('href'); |
|
280 |
$("#modal-confirm #btn-delete-modal").attr('href', urlDelete).focus(); |
|
281 |
$("#modal-confirm .modal-body").find('.titleMedia').text(titleMedia); |
|
282 |
$("#modal-confirm").modal('show'); |
|
283 |
||
284 |
}); |
|
285 |
$(document).on('click', '.btn-ok-chapter', function(e){ |
|
286 |
e.preventDefault(); |
|
287 |
$('.form-chapter-edit').remove(); |
|
288 |
}); |
|
| 102 | 289 |
|
| 107 | 290 |
function deleteChapter(idChapter){ |
291 |
|
|
292 |
$("#modal-confirm").modal('hide'); |
|
293 |
var chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
|
294 |
indexChapter = _.indexOf(chapters, chapter), |
|
295 |
chapterModify; |
|
296 |
if(indexChapter == 0){ |
|
297 |
chapterModify = chapters[1]; |
|
298 |
chapterModify.setBegin(0); |
|
299 |
}else{ |
|
300 |
chapterModify = chapters[indexChapter-1]; |
|
301 |
//var newEnd = new IriSP.Model.Time(chapter.end) |
|
302 |
chapterModify.setEnd(chapter.end); |
|
303 |
} |
|
304 |
chapters.removeId(idChapter); |
|
305 |
myProject.getAnnotations().removeId(idChapter, true); |
|
306 |
renderChapter(); |
|
307 |
//si le formulaire est visible |
|
308 |
if($('#form-chapter-edit-'+idChapter).length){ |
|
309 |
$('#form-chapter-edit-'+idChapter).remove(); |
|
310 |
} |
|
311 |
disabledPreview(); |
|
312 |
} |
|
| 22 | 313 |
|
| 107 | 314 |
function getRandomColor(){ |
315 |
return global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)]; |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
316 |
} |
| 107 | 317 |
//nouveau chapitre |
|
55
cedadc7d039a
modal delete in html title update
Anthony Ly <anthonyly.com@gmail.com>
parents:
54
diff
changeset
|
318 |
function newChapter(dataChapter, render){ |
| 28 | 319 |
var chapter = new IriSP.Model.Annotation(false, myProject); |
320 |
chapter.setMedia(myMedia.id); |
|
321 |
chapter.setBegin(dataChapter.begin); |
|
322 |
chapter.setEnd(dataChapter.end); |
|
| 84 | 323 |
chapter.setAnnotationType(chapterAnnType.id); |
| 28 | 324 |
chapter.title = dataChapter.title; |
325 |
chapter.description = dataChapter.description; |
|
326 |
chapter.keywords = dataChapter.keywords; |
|
| 58 | 327 |
chapter.color = getRandomColor(); |
| 28 | 328 |
|
329 |
chapters.push(chapter); |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
330 |
myProject.getAnnotations().push(chapter); |
| 58 | 331 |
renderChapter(); |
| 28 | 332 |
loadFormChapter(chapter.id); |
| 107 | 333 |
disabledPreview(); |
334 |
$('#chapter-title').focus(); |
|
| 28 | 335 |
} |
336 |
||
| 6 | 337 |
$('.chapter-widget').on('click', '.btn-cut-chapter', function(e){ |
338 |
e.preventDefault(); |
|
| 101 | 339 |
var begin = myMedia.currentTime, |
340 |
end = organizeNewChapter(myMedia.currentTime); |
|
341 |
if(!end){ |
|
| 102 | 342 |
$('#modal-alert .alert-message').hide(); |
343 |
$('#modal-alert #alert-chapter-duration').show(); |
|
344 |
$('#modal-alert #alert-chapter-duration strong').text(secMiniChapter); |
|
345 |
$('#modal-alert').modal('show'); |
|
| 101 | 346 |
return; |
347 |
} |
|
| 28 | 348 |
var dataChapter = { |
| 107 | 349 |
title : '', |
| 101 | 350 |
begin : begin, |
351 |
end : end, |
|
| 107 | 352 |
description : '', |
353 |
keywords : [] |
|
| 95 | 354 |
}; |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
355 |
|
|
55
cedadc7d039a
modal delete in html title update
Anthony Ly <anthonyly.com@gmail.com>
parents:
54
diff
changeset
|
356 |
newChapter(dataChapter, true); |
| 28 | 357 |
|
| 6 | 358 |
}); |
| 22 | 359 |
|
360 |
function organizeNewChapter(beginNew){ |
|
| 6 | 361 |
|
| 101 | 362 |
var returnEnd = false; |
| 22 | 363 |
$.each(chapters, function(k, v){ |
364 |
var begin = v.begin, |
|
365 |
end = v.end; |
|
| 101 | 366 |
|
367 |
if(beginNew>=begin && beginNew<=end && end-beginNew>secMiniChapter*1000 && beginNew-begin>secMiniChapter*1000){ |
|
| 28 | 368 |
returnEnd = new IriSP.Model.Time(end); |
369 |
v.setEnd(beginNew); |
|
| 22 | 370 |
} |
371 |
}); |
|
| 28 | 372 |
|
| 22 | 373 |
return returnEnd; |
374 |
} |
|
375 |
|
|
376 |
function renderChapter(){ |
|
| 105 | 377 |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
378 |
|
| 22 | 379 |
var chapterSegmentWrap = $('.chapter-segments'), |
380 |
wChapterSegmentWrap = chapterSegmentWrap.width(), |
|
381 |
chapterList = $('.list-chapter-rows-wrap'); |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
382 |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
383 |
chapters = chapters.sortBy(function(c){ |
| 22 | 384 |
return c.begin; |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
385 |
}); |
| 18 | 386 |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
387 |
chapterSegmentWrap.empty(); |
| 22 | 388 |
chapterList.empty(); |
| 62 | 389 |
|
| 58 | 390 |
$.each(chapters, function(k, v){ |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
391 |
|
| 58 | 392 |
//segments |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
393 |
var width = v.getDuration() * wChapterSegmentWrap / myMedia.duration, |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
394 |
left = v.begin * wChapterSegmentWrap / myMedia.duration, |
| 58 | 395 |
segment = $('<li>'+v.title+'</li>').css({ |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
396 |
left : left, |
| 58 | 397 |
width : width, |
398 |
backgroundColor : v.color |
|
| 101 | 399 |
}).attr('id', v.id) |
400 |
.attr('data-id', v.id) |
|
401 |
.addClass('chapter-segment'); |
|
| 58 | 402 |
|
403 |
chapterSegmentWrap.append(segment); |
|
| 28 | 404 |
|
| 58 | 405 |
//liste |
| 62 | 406 |
var tplChapterRow = getTemplate('#tpl-chapter-row'); |
| 22 | 407 |
tplChapterRow = Mustache.render(tplChapterRow, v); |
408 |
chapterList.append(tplChapterRow); |
|
409 |
}); |
|
| 62 | 410 |
|
| 58 | 411 |
}//renderChapter() |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
412 |
|
| 107 | 413 |
/* Annotation */ |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
414 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
415 |
function newAnnotation(dataAnnotation){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
416 |
var annotation = new IriSP.Model.Annotation(false, myProject); |
| 84 | 417 |
annotation.setAnnotationType(annotationsAnnType.id); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
418 |
annotation.setMedia(myMedia.id); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
419 |
annotation.setBegin(dataAnnotation.begin); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
420 |
annotation.setEnd(dataAnnotation.end); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
421 |
annotation.title = dataAnnotation.title; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
422 |
annotation.description = dataAnnotation.description; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
423 |
annotation.type = dataAnnotation.type; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
424 |
annotation.color = global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)]; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
425 |
annotation.keywords = dataAnnotation.keywords; |
| 42 | 426 |
annotation.content = getContentAnnotationByType(dataAnnotation.type); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
427 |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
428 |
myProject.getAnnotations().push(annotation); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
429 |
annotations.push(annotation); |
| 107 | 430 |
disabledPreview(); |
431 |
||
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
432 |
return annotation; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
433 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
434 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
435 |
function renderAnnotation(){ |
| 105 | 436 |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
437 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
438 |
var timeline = $('.timeline-annotations'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
439 |
wTimeline = timeline.width(), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
440 |
annotationList = $('#list-annotations-rows'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
441 |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
442 |
annotations = annotations.sortBy(function(c){ |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
443 |
return c.begin; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
444 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
445 |
|
| 62 | 446 |
timeline.empty().append('<li>'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
447 |
annotationList.empty(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
448 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
449 |
$.each(annotations, function(k, v){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
450 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
451 |
//timeline |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
452 |
var width = Math.floor(v.getDuration() * wTimeline / myMedia.duration), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
453 |
left = Math.floor(v.begin * wTimeline / myMedia.duration), |
| 93 | 454 |
dataAnntim = { |
455 |
left : left, |
|
456 |
width : width, |
|
457 |
color : v.color, |
|
| 95 | 458 |
id : v.id, |
459 |
title : v.title |
|
| 93 | 460 |
}, |
461 |
segment = getTemplate('#tpl-annotation-in-timeline'); |
|
462 |
segment = Mustache.render(segment, dataAnntim); |
|
463 |
||
| 95 | 464 |
|
| 62 | 465 |
var isInTimeline = false; |
466 |
$.each(timeline.find('li'), function(a, b){ |
|
467 |
if(isInTimeline) return; |
|
468 |
var row = $(this); |
|
469 |
if(row.children().length){ |
|
470 |
var canBeInRow = true; |
|
471 |
$.each(row.find('.annotation'), function(c, d){ |
|
472 |
var oAL = parseInt($(d).css('left')), |
|
473 |
oAR = oAL + $(d).width(), |
|
474 |
segmentR = left + width; |
|
475 |
if(oAL<=left && oAR>=left || oAL<=segmentR && oAR>= segmentR){ |
|
476 |
canBeInRow = false; |
|
477 |
} |
|
478 |
}); |
|
479 |
if(canBeInRow){ |
|
480 |
row.append(segment); |
|
481 |
isInTimeline = true; |
|
482 |
} |
|
483 |
}else{ |
|
484 |
row.append(segment); |
|
485 |
isInTimeline = true; |
|
486 |
} |
|
487 |
}); |
|
488 |
||
489 |
if(!isInTimeline){ |
|
490 |
timeline.append('<li>'); |
|
491 |
timeline.find('li:last-child').append(segment); |
|
492 |
} |
|
493 |
|
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
494 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
495 |
//liste |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
496 |
v.iconTab = getIcon(v.type); |
| 62 | 497 |
var tplAnnotationRow = getTemplate('#tpl-list-annotation-row'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
498 |
tplAnnotationRow = Mustache.render(tplAnnotationRow, v); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
499 |
annotationList.append(tplAnnotationRow); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
500 |
|
| 62 | 501 |
}); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
502 |
|
| 62 | 503 |
|
504 |
}//renderAnnotation |
|
| 22 | 505 |
|
| 6 | 506 |
//edit annotation |
507 |
$('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){ |
|
508 |
e.preventDefault(); |
|
| 105 | 509 |
|
| 6 | 510 |
var idAnnotation = $(this).attr('data-id'); |
511 |
//si il est déjà ouvert |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
512 |
if($('#tab-annotation-'+idAnnotation).length){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
513 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
| 6 | 514 |
}else{ |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
515 |
var data = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
516 |
openTab(data.type, data); |
| 6 | 517 |
} |
518 |
}); |
|
519 |
||
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
520 |
$('.tab-content').on('keyup', '.form-info-general-annotation input[name=title], .form-info-general-annotation textarea', function(e){ |
| 105 | 521 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
522 |
var name = $(this).attr('name'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
523 |
value = $(this).val(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
524 |
currentAnnotation[name] = value; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
525 |
if(name == 'title'){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
526 |
var idAnnotation = $(this).parents('form').attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
527 |
$('#onglet-title-'+idAnnotation).text(value); |
|
89
99d281de4f31
disabled sélect on pagination modal bibliothèque
Anthony Ly <anthonyly.com@gmail.com>
parents:
88
diff
changeset
|
528 |
$(this).parents('form').find('.btn-delete-annotation').attr('data-title', value); |
| 101 | 529 |
$('#annotation-timeline-'+ idAnnotation).attr('title', value); |
| 95 | 530 |
$('#annotation-timeline-'+ idAnnotation+' span').text(value); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
531 |
} |
| 107 | 532 |
disabledPreview(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
533 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
534 |
|
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
535 |
//delete annotation |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
536 |
$(document).on('click','.btn-delete-annotation', function(e){ |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
537 |
e.preventDefault(); |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
538 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
539 |
var idAnnotation = $(this).attr('data-id'), |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
540 |
btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
541 |
btnDeleteModal.attr('data-type-delete', 'annotation'); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
542 |
btnDeleteModal.attr('data-id', idAnnotation); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
543 |
}); |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
544 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
545 |
function deleteAnnotation(idAnnotation){ |
| 105 | 546 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
547 |
$("#modal-confirm").modal('hide'); |
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
548 |
annotations.removeId(idAnnotation); |
|
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
549 |
myProject.getAnnotations().removeId(idAnnotation, true); |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
550 |
closeTab(idAnnotation); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
551 |
renderAnnotation(); |
| 107 | 552 |
disabledPreview(); |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
553 |
} |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
554 |
|
| 107 | 555 |
/* Tab */ |
556 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
557 |
$('#onglet-annotations').on('click', 'a', function(e){ |
| 9 | 558 |
e.preventDefault(); |
559 |
$(this).tab('show'); |
|
560 |
}); |
|
561 |
||
562 |
//ouvrir tab |
|
563 |
$(document).on('click', '.open-tab', function(e){ |
|
564 |
e.preventDefault(); |
|
565 |
var type = $(this).attr('data-type'); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
566 |
openTab(type); |
| 9 | 567 |
}); |
568 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
569 |
function openTab(type, data){ |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
570 |
|
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
571 |
var dataView; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
572 |
if(_.isUndefined(data)){//nouveau |
| 95 | 573 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
574 |
var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
575 |
endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
576 |
var dataAnnotation = { |
|
70
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
62
diff
changeset
|
577 |
title : '', |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
578 |
begin : myMedia.currentTime, |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
579 |
end : endAnnotation, |
|
70
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
62
diff
changeset
|
580 |
description : '', |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
581 |
type : type, |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
582 |
keywords : [] |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
583 |
}; |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
584 |
dataView = newAnnotation(dataAnnotation); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
585 |
renderAnnotation(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
586 |
}else{//édition |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
587 |
dataView = data; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
588 |
} |
| 6 | 589 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
590 |
var idAnnotation = dataView.id, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
591 |
tabContent = $('<div class="tab-pane" id="tab-annotation-'+idAnnotation+'"></div>'), |
| 6 | 592 |
iconTab; |
593 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
594 |
currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
595 |
showCurrentAnnotationInTimeline(idAnnotation); |
| 6 | 596 |
//head commun à tous |
| 62 | 597 |
var tplHead = getTemplate('#tpl-head'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
598 |
var output = Mustache.render(tplHead, dataView); |
| 6 | 599 |
$(tabContent).append(output); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
600 |
$(tabContent).find(".slider-duration").slider(configSlider(dataView)); |
| 105 | 601 |
currentSlider = $(tabContent).find(".slider-duration"); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
602 |
$(tabContent).find(".ui-slider-range.ui-widget-header.ui-corner-all").css('background', dataView.color); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
603 |
$(tabContent).find('.tag-it').tagit(tagitParam); |
| 6 | 604 |
//type |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
605 |
var viewType = { |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
606 |
id : idAnnotation, |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
607 |
content : dataView.content |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
608 |
}; |
| 62 | 609 |
var tpl = getTemplate('#tpl-'+type); |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
610 |
|
| 6 | 611 |
tpl = Mustache.render(tpl, viewType); |
612 |
$(tabContent).append(tpl); |
|
613 |
$('.tab-content').append(tabContent); |
|
614 |
||
615 |
//particularité selon type |
|
616 |
switch(type){ |
|
| 48 | 617 |
case 'audio': |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
618 |
break; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
619 |
case 'video': |
| 93 | 620 |
var labelModify = $(tabContent).find('.label-modify-video'), |
621 |
labelAdd = $(tabContent).find('.label-add-video'); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
622 |
if(viewType.content.url != ""){ |
| 62 | 623 |
var videoWrap = $(tabContent).find('.annotation-video-content'); |
| 58 | 624 |
renderVideoInfo(videoWrap, viewType.content); |
| 93 | 625 |
labelModify.show(); |
| 102 | 626 |
|
| 93 | 627 |
}else{ |
628 |
labelAdd.show(); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
629 |
} |
| 6 | 630 |
break; |
631 |
case 'text': |
|
| 38 | 632 |
var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0]; |
| 6 | 633 |
break; |
| 42 | 634 |
case 'links': |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
635 |
var tbody = $(tabContent).find('tbody.links-rows'), |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
636 |
links = viewType.content.links; |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
637 |
if(links.length){ |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
638 |
$.each(links, function(k,v){ |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
639 |
addLinkRow(tbody, v); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
640 |
}); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
641 |
}else{//il n'y a pas de lien on en ajoute 1 |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
642 |
addLinkRow(tbody); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
643 |
} |
| 38 | 644 |
break; |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
645 |
|
| 42 | 646 |
case 'slideshow': |
| 95 | 647 |
console.log(currentAnnotation) |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
648 |
$(tabContent).find('.number-spin').val(dataView.content.slideduration/1000); |
| 6 | 649 |
$(tabContent).find('.number-spin').spin(spinParam); |
650 |
$(tabContent).find('.ui-sortable').sortable({ |
|
| 58 | 651 |
start: function (event, ui) { |
652 |
$(ui.item).data("startindex", ui.item.index()); |
|
653 |
}, |
|
| 6 | 654 |
stop : function(event, ui){ |
655 |
disabledBtnSortable($(this)); |
|
| 58 | 656 |
}, |
657 |
update : function(event, ui){ |
|
658 |
var oldIndex = ui.item.data("startindex"), |
|
659 |
newIndex = ui.item.index(); |
|
660 |
currentAnnotation.content.images.move(oldIndex, newIndex); |
|
661 |
}, |
|
| 6 | 662 |
}); |
| 51 | 663 |
var diaporama = $(tabContent).find('#diaporama-'+idAnnotation), |
664 |
images = viewType.content.images; |
|
665 |
if(images.length){ |
|
666 |
$.each(images, function(k,v){ |
|
667 |
addImageToDiaporama(diaporama, v); |
|
668 |
}); |
|
669 |
} |
|
| 6 | 670 |
break; |
671 |
} |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
672 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
673 |
dataView.iconTab = getIcon(type); |
| 62 | 674 |
var tplOnglet = getTemplate('#tpl-onglet'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
675 |
var onglet = Mustache.render(tplOnglet, dataView); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
676 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
677 |
$(".nav-tabs li:last-child").after(onglet); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
678 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
| 62 | 679 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
680 |
}//openTab() |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
681 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
682 |
function getIcon(type){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
683 |
var icon; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
684 |
switch(type){ |
| 48 | 685 |
case 'audio': icon = 'volume-up'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
686 |
break; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
687 |
case 'video': icon = 'film'; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
688 |
break; |
| 62 | 689 |
case 'text': icon = 'align-left'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
690 |
break; |
| 38 | 691 |
case 'html': icon = 'code'; |
692 |
break; |
|
| 42 | 693 |
case 'links': icon = 'link'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
694 |
break; |
| 42 | 695 |
case 'slideshow': icon = 'picture'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
696 |
break; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
697 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
698 |
return icon; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
699 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
700 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
701 |
//définit currentAnnotation quand la tab s'ouvre |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
702 |
$('#onglet-annotations').on('show', 'a[data-toggle="annotation"]', function (e) { |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
703 |
var idAnnotation = $(e.target).attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
704 |
currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
| 105 | 705 |
currentSlider = $('#tab-annotation-'+idAnnotation).find(".slider-duration"); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
706 |
showCurrentAnnotationInTimeline(idAnnotation); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
707 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
708 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
709 |
//rafraichit annotations au retour sur la liste |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
710 |
$('#onglet-annotations').on('show', 'a[data-toggle="list-annotations"]', function (e) { |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
711 |
currentAnnotation = undefined; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
712 |
renderAnnotation(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
713 |
}); |
| 6 | 714 |
|
| 9 | 715 |
//fermer tab |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
716 |
$('#onglet-annotations').on('click', 'span.close-tab', function(e){ |
| 9 | 717 |
e.preventDefault();e.stopPropagation(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
718 |
var idAnnotation = $(this).parents('a').attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
719 |
closeTab(idAnnotation); |
| 9 | 720 |
}); |
721 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
722 |
$('.tab-content').on('click', '.btn-save-annotation', function(e){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
723 |
e.preventDefault(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
724 |
var idAnnotation = $(this).attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
725 |
closeTab(idAnnotation); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
726 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
727 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
728 |
function closeTab(idAnnotation){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
729 |
$('#onglet-'+idAnnotation).remove(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
730 |
$('.tab-content #tab-annotation-'+idAnnotation).remove(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
731 |
$('#tab-list-annotation').tab('show'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
732 |
} |
| 9 | 733 |
|
| 107 | 734 |
//video |
| 58 | 735 |
function renderVideoInfo(videoWrap, dataVideo){ |
| 62 | 736 |
|
737 |
var tplVideo = getTemplate('#tpl-video-row'); |
|
738 |
tplVideo = Mustache.render(tplVideo, dataVideo); |
|
739 |
|
|
740 |
videoWrap.empty().append(tplVideo); |
|
| 58 | 741 |
|
| 62 | 742 |
videoWrap = videoWrap.find(".video-container"); |
743 |
getVideoPlayer(dataVideo.url, videoWrap); |
|
744 |
|
|
| 58 | 745 |
} |
|
89
99d281de4f31
disabled sélect on pagination modal bibliothèque
Anthony Ly <anthonyly.com@gmail.com>
parents:
88
diff
changeset
|
746 |
$('.popup').on('click', '.bibliotheque-video a:not(.pagination a)', function(e){ |
| 58 | 747 |
e.preventDefault(); |
748 |
||
749 |
var url = $(this).attr('data-url'), |
|
750 |
title = $(this).attr('data-title'), |
|
751 |
description = $(this).attr('data-description'); |
|
752 |
||
753 |
currentAnnotation.content.url = url; |
|
754 |
currentAnnotation.content.title = title; |
|
755 |
currentAnnotation.content.description = description; |
|
756 |
||
757 |
$('.popup').modal('hide'); |
|
758 |
||
759 |
var videoWrap = $('#tab-annotation-'+currentAnnotation.id).find('.annotation-video-content'); |
|
760 |
renderVideoInfo(videoWrap, currentAnnotation.content); |
|
| 93 | 761 |
|
762 |
var labelModify = $('#tab-annotation-'+currentAnnotation.id).find('.label-modify-video'), |
|
763 |
labelAdd = $('#tab-annotation-'+currentAnnotation.id).find('.label-add-video'); |
|
764 |
||
765 |
labelModify.show(); |
|
766 |
labelAdd.hide(); |
|
| 107 | 767 |
|
768 |
disabledPreview(); |
|
| 58 | 769 |
}); |
770 |
||
| 107 | 771 |
/* Slideshow */ |
| 51 | 772 |
|
773 |
//bibliotheque |
|
|
89
99d281de4f31
disabled sélect on pagination modal bibliothèque
Anthony Ly <anthonyly.com@gmail.com>
parents:
88
diff
changeset
|
774 |
$('.popup').on('click', '.bibliotheque-image a:not(.pagination a)', function(e){ |
| 51 | 775 |
e.preventDefault(); |
776 |
||
| 58 | 777 |
var url = $(this).attr('data-url'), |
778 |
title = $(this).attr('data-title'), |
|
779 |
description = $(this).attr('data-description'), |
|
| 51 | 780 |
image = { |
781 |
id : currentAnnotation.id, |
|
782 |
url : url, |
|
| 58 | 783 |
title : title, |
784 |
description : description |
|
| 51 | 785 |
}; |
786 |
currentAnnotation.content.images.push(image); |
|
787 |
||
788 |
var listDiaporama = $('#diaporama-'+currentAnnotation.id); |
|
789 |
addImageToDiaporama(listDiaporama, image); |
|
790 |
$('.popup').modal('hide'); |
|
| 107 | 791 |
disabledPreview(); |
| 51 | 792 |
}); |
793 |
||
794 |
function addImageToDiaporama(diaporama, dataView){ |
|
| 62 | 795 |
|
796 |
var tplDiapo = getTemplate('#tpl-diaporama-row'); |
|
797 |
tplDiapo = Mustache.render(tplDiapo, dataView); |
|
798 |
diaporama.append(tplDiapo); |
|
799 |
disabledBtnSortable(diaporama); |
|
800 |
|
|
| 6 | 801 |
}; |
802 |
||
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
803 |
//edit title / description |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
804 |
$('.tab-content').on('click', '.title-slideshow-row, .description-slideshow-row, .video-title-edit, .video-description-edit', function(){ |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
805 |
if($(this).find('input').length) return; |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
806 |
var html = $(this).find('span').html(), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
807 |
inputType = $(this).attr('data-input'), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
808 |
name = $(this).attr('data-name'), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
809 |
input = $('<'+inputType+'>').attr('name', name); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
810 |
input.val(html); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
811 |
$(this).find('span').replaceWith(input); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
812 |
input.focus().keypress(function(e){ |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
813 |
code = (e.keyCode ? e.keyCode : e.which); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
814 |
if (code == 13) $(this).blur(); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
815 |
}); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
816 |
}); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
817 |
|
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
818 |
$(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){ |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
819 |
var newValue = $(this).val(), |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
820 |
name = $(this).attr('name'), |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
821 |
span = $('<span>').html(newValue), |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
822 |
indexRow = $(this).parents('.row-image-diaporama').index(); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
823 |
$(this).replaceWith(span); |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
824 |
currentAnnotation.content.images[indexRow][name] = newValue; |
| 107 | 825 |
disabledPreview(); |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
826 |
}); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
827 |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
828 |
$(document).on('blur', '.video-title-edit input, .video-description-edit textarea', function(){ |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
829 |
var newValue = $(this).val(), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
830 |
name = $(this).attr('name'), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
831 |
span = $('<span>').html(newValue); |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
832 |
$(this).replaceWith(span); |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
833 |
currentAnnotation.content[name] = newValue; |
| 107 | 834 |
disabledPreview(); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
835 |
}); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
836 |
|
| 9 | 837 |
//bouton up / down |
| 6 | 838 |
$(document).on('click', '.ui-sortable .btn-sort', function(e){ |
839 |
e.preventDefault(); |
|
840 |
var row = $(this).parents('tr.row-image-diaporama'), |
|
| 58 | 841 |
oldIndex = row.index(), |
| 6 | 842 |
listDiaporama = $(this).parents('.list-image-diaporama'); |
843 |
||
844 |
if($(this).hasClass('down')) |
|
845 |
row.insertAfter(row.next()); |
|
846 |
else if($(this).hasClass('up')) |
|
847 |
row.insertBefore(row.prev()); |
|
848 |
||
| 58 | 849 |
var newIndex = row.index(); |
850 |
currentAnnotation.content.images.move(oldIndex, newIndex); |
|
851 |
||
| 6 | 852 |
disabledBtnSortable(listDiaporama); |
| 107 | 853 |
disabledPreview(); |
| 6 | 854 |
}); |
855 |
||
| 58 | 856 |
$('.tab-content').on('click','.btn-delete-image', function(e){ |
857 |
e.preventDefault(); |
|
858 |
var rowImage = $(this).parents('tr.row-image-diaporama'), |
|
859 |
index = rowImage.index(); |
|
860 |
||
861 |
rowImage.remove(); |
|
862 |
currentAnnotation.content.images.splice(index, 1); |
|
| 107 | 863 |
disabledPreview(); |
| 58 | 864 |
}); |
865 |
||
| 6 | 866 |
function disabledBtnSortable(listDiaporama){ |
867 |
listDiaporama.find('.btn-sort.disabled').removeClass('disabled'); |
|
868 |
listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled'); |
|
869 |
listDiaporama.find('tr.row-image-diaporama:last-child').find('.btn-sort.down').addClass('disabled'); |
|
870 |
} |
|
871 |
||
| 107 | 872 |
//links |
873 |
$('.tab-content').on('click', '.add-link', function(e){ |
|
874 |
e.preventDefault(); |
|
875 |
var tbody = $(this).parents('tfoot').siblings('tbody'); |
|
876 |
addLinkRow(tbody); |
|
877 |
}); |
|
878 |
$('.tab-content').on('click', '.delete-link', function(e){ |
|
879 |
e.preventDefault(); |
|
880 |
var row = $(this).parents('tr'), |
|
881 |
tbody = $(this).parents('tbody'); |
|
| 62 | 882 |
|
| 107 | 883 |
row.remove(); |
884 |
updateLinks(tbody); |
|
885 |
}); |
|
886 |
function addLinkRow(tbody, dataView){ |
|
| 62 | 887 |
|
| 107 | 888 |
//head commun à tous |
889 |
var tplLinkRow = getTemplate('#tpl-links-row'); |
|
890 |
var output = Mustache.render(tplLinkRow, dataView); |
|
891 |
tbody.append(output); |
|
| 62 | 892 |
|
| 107 | 893 |
} |
894 |
$('.tab-content').on('keyup', '.links-rows input', function(e){ |
|
895 |
var tbody = $(this).parents('.links-rows'); |
|
896 |
updateLinks(tbody); |
|
| 48 | 897 |
}); |
| 107 | 898 |
function updateLinks(tbody){ |
899 |
links = new Array(); |
|
| 6 | 900 |
|
| 107 | 901 |
$.each(tbody.find('tr'), function(k, v){ |
902 |
var urlLink = $(v).find('.url-link').val(), |
|
903 |
titleLink = $(v).find('.title-link').val(), |
|
904 |
link = { |
|
905 |
url : urlLink, |
|
906 |
title : titleLink |
|
907 |
}; |
|
908 |
links.push(link); |
|
| 51 | 909 |
|
| 107 | 910 |
}); |
911 |
currentAnnotation.content.links = links; |
|
912 |
disabledPreview(); |
|
| 51 | 913 |
} |
914 |
||
| 107 | 915 |
//annotation audio |
916 |
$('.tab-content').on('keyup', '.annotation-audio-content input, .annotation-audio-content textarea', function(){ |
|
917 |
var name = $(this).attr('name'), |
|
918 |
value = $(this).val(); |
|
| 105 | 919 |
|
| 107 | 920 |
currentAnnotation.content[name] = value; |
921 |
disabledPreview(); |
|
922 |
}); |
|
| 95 | 923 |
|
| 107 | 924 |
//annotation slideshow |
925 |
$('.tab-content').on('click', '.btn-autostart', function(){ |
|
926 |
var autostart = $(this).attr('data-autostart'); |
|
927 |
if(autostart == "true"){ autostart = true;} |
|
928 |
else {autostart = false;} |
|
929 |
disabledPreview(); |
|
930 |
currentAnnotation.content.autostart = autostart; |
|
931 |
}); |
|
| 84 | 932 |
|
| 107 | 933 |
$('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){ |
934 |
var value = $(this).val(); |
|
935 |
if(!isNaN(value)){ |
|
936 |
disabledPreview(); |
|
937 |
currentAnnotation.content.slideduration = value * 1000; |
|
| 84 | 938 |
} |
939 |
}); |
|
| 95 | 940 |
|
| 107 | 941 |
|
942 |
//save project |
|
943 |
$('.btn-save-project').bind('click', function(e){ |
|
944 |
e.preventDefault(); |
|
945 |
if($(this).hasClass('disabled')) return; |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
946 |
|
| 107 | 947 |
showAlertByClassName('save-load'); |
948 |
var that = this; |
|
949 |
$(this).addClass('disabled'); |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
950 |
|
| 107 | 951 |
console.log(myProject.serialize()); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
952 |
|
| 107 | 953 |
$.ajax({ |
954 |
type: "POST", |
|
955 |
url: urlSaveProject, |
|
956 |
data: myProject.serialize(), |
|
957 |
contentType: "application/cinelab", |
|
958 |
headers: { |
|
959 |
"X-CSRFToken": tokenSaveProject |
|
960 |
}, |
|
961 |
success: function(data, status, request){ |
|
962 |
showAlertByClassName('save-ok'); |
|
963 |
$('.btn-apercu-projet').removeClass('disabled'); |
|
964 |
console.log('data : ', data); |
|
965 |
console.log('status : ', status); |
|
966 |
console.log('request : ', request); |
|
967 |
||
968 |
}, |
|
969 |
error: function(jqXHR, textStatus, errorThrown){ |
|
970 |
showAlertByClassName('save-error'); |
|
971 |
//alert(gettext("Server error\nYour hashcut couldn't be published")); |
|
972 |
}, |
|
973 |
complete : function(){ |
|
974 |
$(that).removeClass('disabled'); |
|
975 |
} |
|
976 |
}); |
|
977 |
}); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
978 |
|
| 107 | 979 |
//disabled preview |
980 |
function disabledPreview(){ |
|
981 |
if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled'); |
|
982 |
} |
|
983 |
$(document).on('click', '.btn-apercu-projet.disabled', function(e){ |
|
984 |
e.preventDefault(); |
|
985 |
}); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
986 |
|
| 107 | 987 |
//alert |
988 |
$('.alert').bind('close', function (e) { |
|
989 |
e.preventDefault(); |
|
990 |
$(this).hide(); |
|
991 |
}); |
|
992 |
||
993 |
function showAlertByClassName(className){ |
|
994 |
$('.alert').hide(); |
|
995 |
$('.'+className).show(); |
|
| 38 | 996 |
} |
| 107 | 997 |
//################ config |
998 |
//tagit |
|
999 |
function onTagItChange(e, ui) { |
|
1000 |
var tagitType = $(this).attr('data-type'), |
|
1001 |
value = $(this).val(); |
|
1002 |
||
1003 |
disabledPreview(); |
|
1004 |
||
1005 |
if(tagitType == 'chapter'){ |
|
1006 |
var idChapter = $(this).parents('form').attr('data-chapter-id'); |
|
1007 |
currentChapter.keywords = value.split(','); |
|
1008 |
$('#row-list-chapter-'+idChapter).find('.list-chapter-tags').text(value); |
|
1009 |
}else{ |
|
1010 |
currentAnnotation.keywords = value.split(','); |
|
1011 |
} |
|
1012 |
} |
|
| 6 | 1013 |
|
| 107 | 1014 |
var tagitParam = { |
1015 |
allowSpaces: true, |
|
1016 |
afterTagRemoved : onTagItChange, |
|
1017 |
afterTagAdded : onTagItChange |
|
1018 |
} |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1019 |
|
| 107 | 1020 |
//CLEditor annotation > text (wysiwyg) http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters |
1021 |
var wysiwygConfig = { |
|
1022 |
width: 450, |
|
1023 |
height: 250, |
|
1024 |
controls: "bold italic underline strikethrough | font size " + |
|
1025 |
"style | color highlight removeformat | bullets numbering | source", |
|
1026 |
fonts: "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," + |
|
1027 |
"Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana", |
|
1028 |
sizes: "1,2,3,4,5,6,7", |
|
1029 |
styles: [["Paragraph", "<p>"], ["Header 2", "<h2>"], |
|
1030 |
["Header 3", "<h3>"], ["Header 4","<h4>"], ["Header 5","<h5>"], |
|
1031 |
["Header 6","<h6>"]], |
|
1032 |
docType: '<!DOCTYPE HTML>', |
|
1033 |
bodyStyle: "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;", |
|
1034 |
updateTextArea : function(text){ |
|
1035 |
disabledPreview(); |
|
1036 |
currentAnnotation.content.text = text; |
|
1037 |
return text; |
|
|
70
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
62
diff
changeset
|
1038 |
}, |
| 107 | 1039 |
updateFrame: function(text){ |
1040 |
disabledPreview(); |
|
1041 |
currentAnnotation.content.text = text; |
|
1042 |
return text; |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1043 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1044 |
}; |
| 107 | 1045 |
|
1046 |
//slider |
|
1047 |
function configSlider(data){ |
|
1048 |
return { |
|
1049 |
range: true, |
|
1050 |
values: [ data.begin.milliseconds, data.end.milliseconds ], |
|
1051 |
min: 0, |
|
1052 |
max: myMedia.duration.milliseconds, |
|
1053 |
slide: function( event, ui ) { |
|
1054 |
|
|
1055 |
data.setBegin(ui.values[0]); |
|
1056 |
data.setEnd(ui.values[1]); |
|
1057 |
||
1058 |
var idSlider = $(this).attr('data-id'), |
|
1059 |
wTimeline = $('.timeline-annotations').width(), |
|
1060 |
annotationTimeline = $('#annotation-timeline-'+ data.id), |
|
1061 |
width = Math.floor(data.getDuration() * wTimeline / myMedia.duration), |
|
1062 |
left = Math.floor(data.begin * wTimeline / myMedia.duration); |
|
1063 |
||
1064 |
$( '#'+ idSlider +'-begin span' ).html(data.begin.toString()); |
|
1065 |
$( '#'+ idSlider +'-begin span' ).attr('data-milliseconds', data.begin); |
|
1066 |
$( '#'+ idSlider +'-duration' ).html(data.getDuration().toString()); |
|
1067 |
$( '#'+ idSlider +'-end span' ).html(data.end.toString()); |
|
1068 |
$( '#'+ idSlider +'-end span' ).attr('data-milliseconds', data.end); |
|
1069 |
||
1070 |
annotationTimeline.css({ |
|
1071 |
left : left, |
|
1072 |
width :width |
|
1073 |
}); |
|
1074 |
}, |
|
1075 |
start : function(){ |
|
1076 |
var idSlider = $(this).attr('data-id'), |
|
1077 |
annotationTimeline = $('#annotation-timeline-'+ data.id); |
|
1078 |
annotationTimeline.css('z-index',100); |
|
1079 |
disabledPreview(); |
|
1080 |
}, |
|
1081 |
stop : function(){ |
|
1082 |
renderAnnotation(); |
|
1083 |
refreshAnnotationDisplay(myMedia.getCurrentTime()); |
|
1084 |
} |
|
1085 |
}; |
|
1086 |
} |
|
| 9 | 1087 |
|
| 107 | 1088 |
//init annotation content data |
1089 |
function getContentAnnotationByType(type){ |
|
1090 |
var content; |
|
1091 |
switch(type){ |
|
1092 |
case 'audio': |
|
1093 |
content = { |
|
1094 |
mimetype : "application/x-ldt-audio", |
|
1095 |
url : "", |
|
1096 |
embedcode : "" |
|
1097 |
}; |
|
1098 |
break; |
|
1099 |
case 'video': |
|
1100 |
content = { |
|
1101 |
mimetype : "application/x-ldt-video", |
|
1102 |
url : "", |
|
1103 |
embedcode : "" |
|
1104 |
}; |
|
1105 |
break; |
|
1106 |
case 'text': |
|
1107 |
content = { |
|
1108 |
mimetype : "application/x-ldt-text", |
|
1109 |
markup : "html", |
|
1110 |
text : "" |
|
1111 |
}; |
|
1112 |
break; |
|
1113 |
case 'links': |
|
1114 |
content = { |
|
1115 |
mimetype : "application/x-ldt-links", |
|
1116 |
links : [] |
|
1117 |
}; |
|
1118 |
break; |
|
1119 |
case 'slideshow': |
|
1120 |
content = { |
|
1121 |
mimetype : "application/x-ldt-slideshow", |
|
1122 |
slideduration : 1000, |
|
1123 |
autostart : false, |
|
1124 |
images : [] |
|
1125 |
}; |
|
1126 |
break; |
|
1127 |
} |
|
1128 |
return content; |
|
1129 |
}//getContentAnnotationByType |
|
1130 |
||
1131 |
//unload |
|
1132 |
$(window).on("beforeunload", onLeave); |
|
1133 |
function onLeave(){ |
|
1134 |
if($('.btn-apercu-projet').hasClass('disabled')) return "You have unsaved changes"; |
|
| 42 | 1135 |
} |
| 38 | 1136 |
|
| 105 | 1137 |
/* Tangles */ |
1138 |
var tangleMsPerPixel = 100, |
|
1139 |
activeTangle, |
|
1140 |
tangleStartX, |
|
1141 |
tangleStartVal, |
|
1142 |
tangleHasMoved; |
|
1143 |
|
|
1144 |
$('.chapter-widget-info').on('mousedown', '.time-tangle', function(evt){ |
|
1145 |
activeTangle = $(this); |
|
1146 |
activeTangle.addClass("active"); |
|
1147 |
tangleStartVal = +activeTangle.attr("data-milliseconds"); |
|
1148 |
tangleStartX = evt.pageX; |
|
1149 |
tangleHasMoved = false; |
|
1150 |
$(this).parents('td').siblings('td').find(".time-tangle").addClass("deactivate"); |
|
1151 |
return false; |
|
1152 |
}); |
|
| 58 | 1153 |
|
| 105 | 1154 |
$('.tab-content').on('mousedown', '.time-tangle', function(evt){ |
1155 |
activeTangle = $(this); |
|
1156 |
activeTangle.addClass("active"); |
|
1157 |
tangleStartVal = +activeTangle.attr("data-milliseconds"); |
|
1158 |
tangleStartX = evt.pageX; |
|
1159 |
tangleHasMoved = false; |
|
1160 |
$(this).parents('td').siblings('td').find(".time-tangle").addClass("deactivate"); |
|
1161 |
return false; |
|
1162 |
}); |
|
1163 |
||
1164 |
$(document) |
|
1165 |
.mousemove(function(evt) { |
|
1166 |
if (activeTangle) { |
|
1167 |
tangleHasMoved = true; |
|
1168 |
var newval = new IriSP.Model.Time(tangleMsPerPixel * (evt.pageX - tangleStartX) + tangleStartVal); |
|
1169 |
activeTangle.trigger("valuechange", newval); |
|
1170 |
return false; |
|
1171 |
} |
|
1172 |
}) |
|
1173 |
.mouseup(function() { |
|
1174 |
||
1175 |
if (activeTangle) { |
|
1176 |
if(activeTangle.hasClass('slider-tangle')){ |
|
1177 |
renderAnnotation(); |
|
1178 |
refreshAnnotationDisplay(myMedia.getCurrentTime()); |
|
1179 |
} |
|
1180 |
$(".time-tangle").removeClass("active deactivate"); |
|
1181 |
activeTangle = undefined; |
|
1182 |
} |
|
1183 |
}); |
|
1184 |
||
| 107 | 1185 |
//chapters |
| 105 | 1186 |
function updateRenderChapter(chapterData){ |
1187 |
var segment = $('.chapter-segments li#'+chapterData.id), |
|
1188 |
wChapterSegmentWrap = $('.chapter-segments').width(), |
|
1189 |
wSegmentNew = chapterData.getDuration() * wChapterSegmentWrap / myMedia.duration, |
|
1190 |
lSegmentNew = chapterData.begin * wChapterSegmentWrap / myMedia.duration, |
|
1191 |
row = $('#row-list-chapter-'+chapterData.id), |
|
1192 |
form = ($('#form-chapter-edit-'+chapterData.id).length) ? $('#form-chapter-edit-'+chapterData.id) : false; |
|
1193 |
||
1194 |
segment.css({ |
|
1195 |
width : wSegmentNew, |
|
1196 |
left : lSegmentNew |
|
1197 |
}); |
|
1198 |
||
1199 |
row.find('.begin').text(chapterData.begin); |
|
1200 |
console.log(chapterData.getDuration()) |
|
1201 |
row.find('.duration').text(chapterData.getDuration()); |
|
1202 |
row.find('.end').text(chapterData.end); |
|
1203 |
||
1204 |
if(form){ |
|
1205 |
form.find('.begin').text(chapterData.begin); |
|
1206 |
form.find('.begin').attr('data-milliseconds',chapterData.begin); |
|
1207 |
form.find('.duration').text(chapterData.getDuration()); |
|
1208 |
form.find('.end').text(chapterData.end); |
|
1209 |
form.find('.end').attr('data-milliseconds',chapterData.end); |
|
1210 |
} |
|
1211 |
} |
|
1212 |
||
1213 |
function updateChapterDuration(val, chapterBefore, chapterAfter){ |
|
1214 |
||
1215 |
if (val<=chapterAfter.end && val>=chapterBefore.begin && chapterAfter.end-val>secMiniChapter*1000 && val-chapterBefore.begin>secMiniChapter*1000) { |
|
| 107 | 1216 |
disabledPreview(); |
| 105 | 1217 |
chapterAfter.setBegin(val); |
1218 |
chapterBefore.setEnd(val); |
|
1219 |
||
1220 |
updateRenderChapter(chapterAfter); |
|
1221 |
updateRenderChapter(chapterBefore); |
|
1222 |
} |
|
1223 |
} |
|
1224 |
||
1225 |
$('.chapter-widget-info').on('valuechange', '.tangle-start', function(evt, val){ |
|
1226 |
var indexChapter = _.indexOf(chapters, currentChapter); |
|
1227 |
if(indexChapter == 0 || chapters.length<=1) return; |
|
1228 |
|
|
1229 |
var chapterBefore = chapters[indexChapter-1], |
|
1230 |
chapterAfter = currentChapter; |
|
1231 |
||
1232 |
updateChapterDuration(val, chapterBefore, chapterAfter); |
|
1233 |
}); |
|
1234 |
||
1235 |
$('.chapter-widget-info').on('valuechange', '.tangle-end', function(evt, val){ |
|
1236 |
var indexChapter = _.indexOf(chapters, currentChapter); |
|
1237 |
if(indexChapter == chapters.length-1 || chapters.length<=1) return; |
|
1238 |
|
|
1239 |
var chapterAfter = chapters[indexChapter+1], |
|
1240 |
chapterBefore = currentChapter; |
|
1241 |
||
1242 |
updateChapterDuration(val, chapterBefore, chapterAfter); |
|
1243 |
}); |
|
1244 |
||
1245 |
//annotations |
|
1246 |
||
1247 |
$('.tab-content').on('valuechange', '.tangle-start', function(evt, val){ |
|
1248 |
var max = currentSlider.slider('values')[1], |
|
1249 |
min = 0, |
|
1250 |
beginOrEnd = 'begin'; |
|
1251 |
||
1252 |
updateAnnotationDuration(val, min, max, beginOrEnd); |
|
1253 |
}); |
|
1254 |
||
1255 |
$('.tab-content').on('valuechange', '.tangle-end', function(evt, val){ |
|
1256 |
var max = myMedia.duration, |
|
1257 |
min = currentSlider.slider('values')[0], |
|
1258 |
beginOrEnd = 'end'; |
|
1259 |
||
1260 |
updateAnnotationDuration(val, min, max, beginOrEnd); |
|
1261 |
}); |
|
1262 |
||
1263 |
function updateAnnotationDuration(val, min, max, beginOrEnd){ |
|
1264 |
var idAnnotation = currentAnnotation.id, |
|
1265 |
tabAnnotation = $('#tab-annotation-'+idAnnotation), |
|
1266 |
spanTangleStart = tabAnnotation.find('.tangle-start'), |
|
1267 |
spanTangleEnd = tabAnnotation.find('.tangle-end'), |
|
1268 |
spanDuration = tabAnnotation.find('#'+idAnnotation+'-duration'); |
|
1269 |
||
1270 |
if(val<max && val>min){ |
|
| 107 | 1271 |
disabledPreview(); |
| 105 | 1272 |
if(beginOrEnd == 'begin'){currentAnnotation.setBegin(val);} |
1273 |
if(beginOrEnd == 'end'){currentAnnotation.setEnd(val);} |
|
1274 |
||
1275 |
spanTangleStart.html(currentAnnotation.begin.toString()); |
|
1276 |
spanTangleStart.attr('data-milliseconds', currentAnnotation.begin); |
|
1277 |
spanDuration.html(currentAnnotation.getDuration().toString()); |
|
1278 |
spanTangleEnd.html(currentAnnotation.end.toString()); |
|
1279 |
spanTangleEnd.attr('data-milliseconds', currentAnnotation.end); |
|
1280 |
||
1281 |
var wTimeline = $('.timeline-annotations').width(), |
|
1282 |
annotationTimeline = $('#annotation-timeline-'+ idAnnotation), |
|
1283 |
width = Math.floor(currentAnnotation.getDuration() * wTimeline / myMedia.duration), |
|
1284 |
left = Math.floor(currentAnnotation.begin * wTimeline / myMedia.duration); |
|
1285 |
||
1286 |
annotationTimeline.css({ |
|
1287 |
left : left, |
|
1288 |
width :width |
|
1289 |
}); |
|
1290 |
currentSlider.slider('values', [currentAnnotation.begin, currentAnnotation.end]) |
|
1291 |
} |
|
1292 |
} |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
1293 |
|
| 107 | 1294 |
//test |
1295 |
$('.log-annotations').bind('click', function(e){ |
|
1296 |
e.preventDefault(); |
|
1297 |
console.log(annotations.length + ' annotations', annotations); |
|
1298 |
currentSlider.slider( "values", 0, 55 ); |
|
1299 |
}); |
|
| 48 | 1300 |
|
| 107 | 1301 |
$('.log-chapters').bind('click', function(e){ |
1302 |
e.preventDefault(); |
|
1303 |
console.log(chapters.length + ' chapitres',chapters); |
|
1304 |
}); |
|
| 62 | 1305 |
|
| 58 | 1306 |
});//ready |
1307 |
||
| 62 | 1308 |
//Utilitaires |
| 58 | 1309 |
Array.prototype.move = function (old_index, new_index) { |
1310 |
if (new_index >= this.length) { |
|
1311 |
var k = new_index - this.length; |
|
1312 |
while ((k--) + 1) { |
|
1313 |
this.push(undefined); |
|
1314 |
} |
|
1315 |
} |
|
1316 |
this.splice(new_index, 0, this.splice(old_index, 1)[0]); |
|
| 62 | 1317 |
return this; |
| 58 | 1318 |
}; |
1319 |
||
1320 |
function getVideoPlayer(src, videoWrap){ |
|
1321 |
||
1322 |
var youtubeTemplate = _.template( |
|
1323 |
'<iframe width="<%- width %>" height="<%- height %>" src="http://www.youtube.com/embed/<%- ytid %>?rel=0&autoplay=<%- autoplay %>" frameborder="0"></iframe>' |
|
1324 |
); |
|
1325 |
|
|
1326 |
var htmlTemplate = _.template( |
|
1327 |
'<<%- type %> width="<%- width %>" controls="true" autoplay="<%- autoplay %>" src="<%- src %>"/>' |
|
1328 |
); |
|
1329 |
|
|
1330 |
var mediaW = 460, |
|
1331 |
mediaH = 345, |
|
1332 |
autoplay = false; |
|
1333 |
||
1334 |
|
|
1335 |
if (/^(https?:\/\/)?(www\.)?youtu\.?be/.test(src)) { |
|
1336 |
var urlparts = src.split(/[?&]/g), |
|
1337 |
ytid = "", |
|
1338 |
vtest = /^v=/; |
|
1339 |
urlparts.slice(1).forEach(function(p) { |
|
1340 |
if (/^v=/.test(p)) { |
|
1341 |
ytid = p.replace(vtest,""); |
|
1342 |
} |
|
1343 |
}); |
|
1344 |
if (!ytid) { |
|
1345 |
ytid = (urlparts[0].match(/[^\/]+$/) || [""])[0]; |
|
1346 |
} |
|
1347 |
videoWrap.html(youtubeTemplate({ |
|
1348 |
ytid: ytid, |
|
1349 |
width: mediaW, |
|
1350 |
height: mediaH, |
|
1351 |
autoplay: autoplay |
|
1352 |
})); |
|
1353 |
return; |
|
1354 |
} |
|
1355 |
|
|
1356 |
if (/^(https?:\/\/)?(www\.)?vimeo/.test(src)) { |
|
1357 |
$.ajax({ |
|
1358 |
url: "http://vimeo.com/api/oembed.json", |
|
1359 |
dataType: "jsonp", |
|
1360 |
data: { |
|
1361 |
width: mediaW, |
|
1362 |
height: mediaH, |
|
1363 |
url: src, |
|
1364 |
autoplay: autoplay, |
|
1365 |
color: "be4477", |
|
1366 |
portrait: false, |
|
1367 |
title: false, |
|
1368 |
byline: false |
|
1369 |
}, |
|
1370 |
success: function(data) { |
|
1371 |
videoWrap.html(data.html); |
|
1372 |
} |
|
1373 |
}); |
|
1374 |
return; |
|
1375 |
} |
|
1376 |
|
|
1377 |
if (/^(https?:\/\/)?(www\.)?dailymotion/.test(src)) { |
|
1378 |
$.ajax({ |
|
1379 |
url: "http://www.dailymotion.com/services/oembed", |
|
1380 |
dataType: "jsonp", |
|
1381 |
data: { |
|
1382 |
format: "json", |
|
1383 |
maxwidth: mediaW, |
|
1384 |
maxheight: mediaH, |
|
1385 |
url: src |
|
1386 |
}, |
|
1387 |
success: function(data) { |
|
1388 |
videoWrap.html(data.html); |
|
1389 |
} |
|
1390 |
}); |
|
1391 |
return; |
|
1392 |
} |
|
1393 |
|
|
1394 |
if (/^(https?:\/\/)?(www\.)?soundcloud\.com/.test(src)) { |
|
1395 |
$.ajax({ |
|
1396 |
url: "http://soundcloud.com/oembed", |
|
1397 |
dataType: "jsonp", |
|
1398 |
data: { |
|
1399 |
format: "js", |
|
1400 |
show_comments: false, |
|
1401 |
auto_play: autoplay, |
|
1402 |
show_artwork: false, |
|
1403 |
url: src, |
|
1404 |
color: "63be6c" |
|
1405 |
}, |
|
1406 |
success: function(data) { |
|
1407 |
videoWrap.html(data.html); |
|
1408 |
} |
|
1409 |
}); |
|
1410 |
return; |
|
1411 |
} |
|
1412 |
|
|
1413 |
var extension = (src.match(/\.([\d\w]+)$/) || ["",""])[1], |
|
1414 |
mimetype = 'video' + "/" + extension, |
|
1415 |
fallbacks = { "video/webm": "mp4", "video/mp4": "webm" }, |
|
1416 |
canPlay = document.createElement("video").canPlayType(mimetype); |
|
1417 |
|
|
1418 |
if (!canPlay) { |
|
1419 |
src = src.replace(/\.[\d\w]+$/,"." + fallbacks[mimetype]); |
|
1420 |
} |
|
1421 |
|
|
1422 |
console.log(mimetype, canPlay, src); |
|
1423 |
|
|
1424 |
videoWrap.html(htmlTemplate({ |
|
1425 |
type: 'video', |
|
1426 |
src: src, |
|
1427 |
width: mediaW, |
|
1428 |
height: mediaH, |
|
1429 |
autoplay: "" + autoplay |
|
1430 |
})); |
|
1431 |
|
|
| 62 | 1432 |
}//getVideoPlayer |