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