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