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