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