| author | Anthony Ly <anthonyly.com@gmail.com> |
| Tue, 11 Jun 2013 10:43:19 +0200 | |
| changeset 115 | 9144b17b390e |
| parent 111 | c0e4d761bcb6 |
| child 116 | fedc0d054b55 |
| 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 |
} |
|
| 58 | 49 |
|
| 107 | 50 |
chapters = chapterAnnType.getAnnotations(); |
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
51 |
if(!chapters.length){ |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
52 |
var dataChapter = { |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
53 |
title : '', |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
54 |
begin : 0, |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
55 |
end : myMedia.duration, |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
56 |
description : '', |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
57 |
keywords : [] |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
58 |
}; |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
59 |
newChapter(dataChapter, true); |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
60 |
} |
| 107 | 61 |
$.each(chapters, function(k, v){ |
62 |
v.color = getRandomColor(); |
|
63 |
}); |
|
64 |
renderChapter(); |
|
| 58 | 65 |
|
| 107 | 66 |
//load Annotations |
67 |
var anntypes = myProject.getAnnotationTypes().searchByTitle("annotations"); |
|
68 |
if (!anntypes.length) { |
|
|
110
ebbb23d32748
Corrected creation of annotation types in empty project
veltr
parents:
107
diff
changeset
|
69 |
annotationsAnnType = new IriSP.Model.AnnotationType(false, myProject); |
| 107 | 70 |
annotationsAnnType.title = "annotations"; |
|
110
ebbb23d32748
Corrected creation of annotation types in empty project
veltr
parents:
107
diff
changeset
|
71 |
myProject.getAnnotationTypes().push(annotationsAnnType); |
| 107 | 72 |
} else { |
73 |
annotationsAnnType = anntypes[0]; |
|
74 |
} |
|
75 |
||
76 |
annotations = annotationsAnnType.getAnnotations(); |
|
77 |
$.each(annotations, function(k, v){ |
|
78 |
var type = v.content.mimetype.split('-'); |
|
79 |
type = type[type.length-1] |
|
80 |
v.type = type; |
|
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
81 |
v.color = annotationsColors[type]; |
| 107 | 82 |
}); |
83 |
renderAnnotation(); |
|
| 58 | 84 |
|
| 115 | 85 |
//player |
| 107 | 86 |
IriSP.htmlPlayer( |
87 |
myMedia, |
|
88 |
$(".main-video"), |
|
89 |
{ |
|
90 |
width: 460, |
|
91 |
height: 345, |
|
92 |
controls: true, |
|
93 |
autostart: true, |
|
94 |
url_transform: function(src) { |
|
95 |
return [{ |
|
96 |
type: "video/mp4", |
|
97 |
src: src.replace(/\.[\d\w]+$/,'.mp4').replace('rtmp://media.iri.centrepompidou.fr/ddc_player', 'http://media.iri.centrepompidou.fr') |
|
98 |
}, { |
|
99 |
type: "video/webm", |
|
100 |
src: src.replace(/\.[\d\w]+$/,'.webm').replace('rtmp://media.iri.centrepompidou.fr/ddc_player', 'http://media.iri.centrepompidou.fr') |
|
101 |
}]; |
|
102 |
} |
|
| 54 | 103 |
} |
| 107 | 104 |
); |
| 16 | 105 |
|
| 107 | 106 |
myMedia.on("timeupdate", function(t) { |
107 |
//curseur chapitre |
|
108 |
var wContainer = $('.chapitre-cut-wrap').width() - 1, |
|
109 |
pos = wContainer * t / myMedia.duration, |
|
110 |
btnCutChapter = $('.btn-cut-chapter'), |
|
111 |
wBtnCutChapter = btnCutChapter.outerWidth(); |
|
112 |
|
|
113 |
$(".indicateur-chapter, .indicateur-annotation").css("left",pos); |
|
114 |
if(pos+wBtnCutChapter>wContainer){ |
|
115 |
btnCutChapter.css("left",(pos - wBtnCutChapter)); |
|
116 |
}else{ |
|
117 |
btnCutChapter.css("left",pos); |
|
118 |
} |
|
| 115 | 119 |
$('.info-time').text(t); |
120 |
||
121 |
//display annotations |
|
| 107 | 122 |
refreshAnnotationDisplay(t); |
123 |
});//timeupdate |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
124 |
|
| 107 | 125 |
});//myProject.onLoad |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
126 |
|
| 107 | 127 |
/* Display annotation in timeline */ |
| 16 | 128 |
|
| 115 | 129 |
//hover |
| 107 | 130 |
$(document).on('mouseover', '.timeline-annotations .annotation, #list-annotations-rows tr, .item-display-annotation' , function(){ |
131 |
if(!$(this).hasClass('shadow')) { |
|
132 |
var idAnnotation = $(this).attr('data-id'); |
|
133 |
$('#annotation-timeline-'+idAnnotation+', #row-list-annotation-'+idAnnotation+', #item-current-annotation-'+idAnnotation).addClass('shadow'); |
|
134 |
} |
|
135 |
}); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
136 |
|
| 107 | 137 |
$(document).on('mouseover', '.chapter-segment, .row-list-chapter' , function(){ |
138 |
if(!$(this).hasClass('shadow')) { |
|
139 |
var idChapter = $(this).attr('data-id'); |
|
140 |
$('#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
|
141 |
} |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
142 |
}); |
| 107 | 143 |
|
144 |
$(document).on('mouseout', '.shadow' , function(){ |
|
145 |
$('.shadow').removeClass('shadow'); |
|
146 |
}); |
|
147 |
||
148 |
$(document).on('click', '.annotation, .item-display-annotation', function(e){ |
|
149 |
e.preventDefault(); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
150 |
var idAnnotation = $(this).attr('data-id'), |
| 107 | 151 |
annotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
152 |
myMedia.setCurrentTime(annotation.begin); |
|
153 |
if($('#tab-annotation-'+idAnnotation).length){ |
|
154 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
|
155 |
}else{ |
|
156 |
openTab(annotation.type, annotation); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
157 |
} |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
158 |
}); |
| 107 | 159 |
|
160 |
function refreshAnnotationDisplay(t){ |
|
161 |
var currentAnnotationsDisplay = new Array(); |
|
162 |
$.each(annotations, function(k, v){ |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
163 |
|
| 107 | 164 |
if(v.begin <= t && v.end >= t){ |
165 |
currentAnnotationsDisplay.push(v.id); |
|
166 |
if(!$('#item-current-annotation-'+v.id).length){ |
|
167 |
var itemAnnotation = getTemplate('#tpl-item-annotation-display'); |
|
168 |
v.iconTab = getIcon(v.type); |
|
169 |
itemAnnotation = Mustache.render(itemAnnotation, v); |
|
170 |
$('.list-current-annotations').append(itemAnnotation) |
|
171 |
} |
|
172 |
} |
|
173 |
}); |
|
| 6 | 174 |
|
| 107 | 175 |
$.each($('.list-current-annotations li'), function(k, v){ |
176 |
var idAnnotation = $(this).attr('data-id'), |
|
177 |
annotationDisplayView = $('.annotation-display-view'); |
|
178 |
if($.inArray(idAnnotation, currentAnnotationsDisplay)<0){//il ne doit plus être affiché |
|
179 |
$('#item-current-annotation-'+idAnnotation).remove(); |
|
180 |
if(annotationDisplayView.attr('data-id') == idAnnotation && annotationDisplayView.is(":visible")){ |
|
181 |
annotationDisplayView.hide(); |
|
182 |
} |
|
183 |
} |
|
184 |
}); |
|
185 |
if(currentAnnotation !== undefined){ |
|
186 |
showCurrentAnnotationInTimeline(currentAnnotation.id); |
|
187 |
} |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
188 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
189 |
|
| 107 | 190 |
function showCurrentAnnotationInTimeline(idAnnotation){ |
191 |
$('.annotation').removeClass('editing'); |
|
192 |
$('#annotation-timeline-'+idAnnotation).addClass('editing'); |
|
193 |
} |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
194 |
|
| 107 | 195 |
$('.list-current-annotations').on('click', 'a', function(e){ |
196 |
e.preventDefault(); |
|
| 22 | 197 |
}); |
| 107 | 198 |
|
| 22 | 199 |
|
| 107 | 200 |
/* Modal */ |
| 51 | 201 |
|
| 6 | 202 |
//confirmation suppression |
203 |
$("#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
|
204 |
|
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
205 |
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
|
206 |
idAnnotation = $(this).attr('data-id'); |
| 9 | 207 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
208 |
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
|
209 |
e.preventDefault(); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
210 |
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
|
211 |
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
|
212 |
} |
| 6 | 213 |
}); |
214 |
||
| 107 | 215 |
/* Title project */ |
216 |
||
| 62 | 217 |
$(document).on('click', '.project-title-editor i, .project-title', function () { |
| 105 | 218 |
|
| 62 | 219 |
var html = $('.project-title').html(); |
220 |
var input = $('<input type="text" />'); |
|
221 |
input.val(html); |
|
222 |
$('.project-title').replaceWith(input); |
|
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
223 |
input.focus().keypress(function(e){ |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
224 |
code = (e.keyCode ? e.keyCode : e.which); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
225 |
if (code == 13) $(this).blur(); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
226 |
}); |
| 62 | 227 |
}); |
228 |
$(document).on('blur', '.project-title-editor input', function(){ |
|
229 |
var newTitle = $(this).val(); |
|
230 |
myProject.title = newTitle; |
|
231 |
$(this).replaceWith('<span class="project-title">'+newTitle+'</span></td>'); |
|
232 |
$('.project-title-nav').text(newTitle); |
|
| 107 | 233 |
disabledPreview(); |
| 6 | 234 |
}); |
235 |
||
| 9 | 236 |
|
| 107 | 237 |
/* Chapter */ |
| 22 | 238 |
|
| 107 | 239 |
//edit |
| 22 | 240 |
$('.list-chapter-wrap').on('click', '.btn-edit-chapter', function(e){ |
| 6 | 241 |
e.preventDefault(); |
| 22 | 242 |
var idChapter = $(this).attr('data-chapter-id'); |
243 |
loadFormChapter(idChapter); |
|
244 |
}); |
|
245 |
||
246 |
$('.chapter-widget-info').on('keyup', 'input[name=title], textarea', function(e){ |
|
247 |
var name = $(this).attr('name'), |
|
248 |
value = $(this).val(); |
|
249 |
currentChapter[name] = value; |
|
250 |
if(name == 'title'){ |
|
251 |
var idChapter = $(this).parents('form').attr('data-chapter-id'); |
|
252 |
$('.chapter-segments').find('#'+idChapter).text(value); |
|
253 |
$('#row-list-chapter-'+idChapter).find('td:first').text(value); |
|
| 95 | 254 |
$(this).parents('form').find('.btn-delete-chapter').attr('data-title', value); |
| 6 | 255 |
} |
| 107 | 256 |
disabledPreview(); |
| 22 | 257 |
}); |
258 |
||
| 115 | 259 |
//form chapter |
260 |
$('.chapter-segments').on('click', 'li', function(){ |
|
261 |
var idChapter = $(this).attr('id'); |
|
262 |
loadFormChapter(idChapter); |
|
263 |
}); |
|
264 |
||
| 22 | 265 |
function loadFormChapter(idChapter){ |
| 28 | 266 |
currentChapter = _.find(chapters, function(c){ return c.id == idChapter; }); |
267 |
var chapterWrap = $('.chapter-widget-info'), |
|
268 |
indexChapter = _.indexOf(chapters, currentChapter), |
|
269 |
beginTangle = (indexChapter>0) ? true : false, |
|
270 |
endTangle = (indexChapter<(chapters.length-1)) ? true : false; |
|
| 22 | 271 |
|
| 28 | 272 |
currentChapter.beginTangle = beginTangle; |
273 |
currentChapter.endTangle = endTangle; |
|
| 22 | 274 |
|
| 62 | 275 |
var tpl = getTemplate('#tpl-chapter-edit'); |
| 28 | 276 |
tpl = Mustache.render(tpl, currentChapter); |
| 22 | 277 |
chapterWrap.empty().append(tpl); |
278 |
chapterWrap.find('.tag-it').tagit(tagitParam); |
|
| 58 | 279 |
|
280 |
myMedia.setCurrentTime(currentChapter.begin); |
|
| 22 | 281 |
} |
282 |
||
| 115 | 283 |
//close chapter form |
284 |
$(document).on('click', '.btn-ok-chapter', function(e){ |
|
285 |
e.preventDefault(); |
|
286 |
$('.form-chapter-edit').remove(); |
|
287 |
}); |
|
288 |
||
| 107 | 289 |
//delete chapter |
290 |
$(document).on('click', '.btn-delete-chapter', function(e){ |
|
291 |
e.preventDefault(); |
|
| 22 | 292 |
|
| 107 | 293 |
if(chapters.length == 1){ |
294 |
$('#modal-alert .alert-message').hide(); |
|
295 |
$('#modal-alert #alert-chapter-number').show(); |
|
296 |
$('#modal-alert').modal('show'); |
|
297 |
return; |
|
298 |
} |
|
299 |
var idChapter = $(this).attr('data-chapter-id'), |
|
300 |
btnDeleteModal = $("#modal-confirm #btn-delete-modal"); |
|
301 |
btnDeleteModal.attr('data-type-delete', 'chapter'); |
|
302 |
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
|
303 |
|
| 107 | 304 |
var titleMedia = $(this).attr('data-title'), |
305 |
urlDelete = $(this).attr('href'); |
|
306 |
$("#modal-confirm #btn-delete-modal").attr('href', urlDelete).focus(); |
|
307 |
$("#modal-confirm .modal-body").find('.titleMedia').text(titleMedia); |
|
308 |
$("#modal-confirm").modal('show'); |
|
309 |
||
310 |
}); |
|
| 102 | 311 |
|
| 107 | 312 |
function deleteChapter(idChapter){ |
313 |
|
|
314 |
$("#modal-confirm").modal('hide'); |
|
315 |
var chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
|
316 |
indexChapter = _.indexOf(chapters, chapter), |
|
317 |
chapterModify; |
|
318 |
if(indexChapter == 0){ |
|
319 |
chapterModify = chapters[1]; |
|
320 |
chapterModify.setBegin(0); |
|
321 |
}else{ |
|
322 |
chapterModify = chapters[indexChapter-1]; |
|
323 |
//var newEnd = new IriSP.Model.Time(chapter.end) |
|
324 |
chapterModify.setEnd(chapter.end); |
|
325 |
} |
|
326 |
chapters.removeId(idChapter); |
|
327 |
myProject.getAnnotations().removeId(idChapter, true); |
|
328 |
renderChapter(); |
|
329 |
//si le formulaire est visible |
|
330 |
if($('#form-chapter-edit-'+idChapter).length){ |
|
331 |
$('#form-chapter-edit-'+idChapter).remove(); |
|
332 |
} |
|
333 |
disabledPreview(); |
|
334 |
} |
|
| 22 | 335 |
|
| 115 | 336 |
//new chapter |
|
55
cedadc7d039a
modal delete in html title update
Anthony Ly <anthonyly.com@gmail.com>
parents:
54
diff
changeset
|
337 |
function newChapter(dataChapter, render){ |
| 28 | 338 |
var chapter = new IriSP.Model.Annotation(false, myProject); |
339 |
chapter.setMedia(myMedia.id); |
|
340 |
chapter.setBegin(dataChapter.begin); |
|
341 |
chapter.setEnd(dataChapter.end); |
|
| 84 | 342 |
chapter.setAnnotationType(chapterAnnType.id); |
| 28 | 343 |
chapter.title = dataChapter.title; |
344 |
chapter.description = dataChapter.description; |
|
345 |
chapter.keywords = dataChapter.keywords; |
|
| 58 | 346 |
chapter.color = getRandomColor(); |
| 28 | 347 |
|
348 |
chapters.push(chapter); |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
349 |
myProject.getAnnotations().push(chapter); |
| 58 | 350 |
renderChapter(); |
| 28 | 351 |
loadFormChapter(chapter.id); |
| 107 | 352 |
disabledPreview(); |
353 |
$('#chapter-title').focus(); |
|
| 28 | 354 |
} |
355 |
||
| 6 | 356 |
$('.chapter-widget').on('click', '.btn-cut-chapter', function(e){ |
357 |
e.preventDefault(); |
|
| 101 | 358 |
var begin = myMedia.currentTime, |
359 |
end = organizeNewChapter(myMedia.currentTime); |
|
360 |
if(!end){ |
|
| 102 | 361 |
$('#modal-alert .alert-message').hide(); |
362 |
$('#modal-alert #alert-chapter-duration').show(); |
|
363 |
$('#modal-alert #alert-chapter-duration strong').text(secMiniChapter); |
|
364 |
$('#modal-alert').modal('show'); |
|
| 101 | 365 |
return; |
366 |
} |
|
| 28 | 367 |
var dataChapter = { |
| 107 | 368 |
title : '', |
| 101 | 369 |
begin : begin, |
370 |
end : end, |
|
| 107 | 371 |
description : '', |
372 |
keywords : [] |
|
| 95 | 373 |
}; |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
374 |
|
|
55
cedadc7d039a
modal delete in html title update
Anthony Ly <anthonyly.com@gmail.com>
parents:
54
diff
changeset
|
375 |
newChapter(dataChapter, true); |
| 6 | 376 |
}); |
| 22 | 377 |
|
378 |
function organizeNewChapter(beginNew){ |
|
| 6 | 379 |
|
| 101 | 380 |
var returnEnd = false; |
| 22 | 381 |
$.each(chapters, function(k, v){ |
382 |
var begin = v.begin, |
|
383 |
end = v.end; |
|
| 101 | 384 |
|
385 |
if(beginNew>=begin && beginNew<=end && end-beginNew>secMiniChapter*1000 && beginNew-begin>secMiniChapter*1000){ |
|
| 28 | 386 |
returnEnd = new IriSP.Model.Time(end); |
387 |
v.setEnd(beginNew); |
|
| 22 | 388 |
} |
389 |
}); |
|
| 28 | 390 |
|
| 22 | 391 |
return returnEnd; |
392 |
} |
|
393 |
|
|
394 |
function renderChapter(){ |
|
| 105 | 395 |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
396 |
|
| 22 | 397 |
var chapterSegmentWrap = $('.chapter-segments'), |
398 |
wChapterSegmentWrap = chapterSegmentWrap.width(), |
|
399 |
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
|
400 |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
401 |
chapters = chapters.sortBy(function(c){ |
| 22 | 402 |
return c.begin; |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
403 |
}); |
| 18 | 404 |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
405 |
chapterSegmentWrap.empty(); |
| 22 | 406 |
chapterList.empty(); |
| 62 | 407 |
|
| 58 | 408 |
$.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
|
409 |
|
| 58 | 410 |
//segments |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
411 |
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
|
412 |
left = v.begin * wChapterSegmentWrap / myMedia.duration, |
| 58 | 413 |
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
|
414 |
left : left, |
| 58 | 415 |
width : width, |
416 |
backgroundColor : v.color |
|
| 101 | 417 |
}).attr('id', v.id) |
418 |
.attr('data-id', v.id) |
|
419 |
.addClass('chapter-segment'); |
|
| 58 | 420 |
|
421 |
chapterSegmentWrap.append(segment); |
|
| 28 | 422 |
|
| 58 | 423 |
//liste |
| 62 | 424 |
var tplChapterRow = getTemplate('#tpl-chapter-row'); |
| 22 | 425 |
tplChapterRow = Mustache.render(tplChapterRow, v); |
426 |
chapterList.append(tplChapterRow); |
|
427 |
}); |
|
| 62 | 428 |
|
| 58 | 429 |
}//renderChapter() |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
430 |
|
| 107 | 431 |
/* Annotation */ |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
432 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
433 |
function newAnnotation(dataAnnotation){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
434 |
var annotation = new IriSP.Model.Annotation(false, myProject); |
| 84 | 435 |
annotation.setAnnotationType(annotationsAnnType.id); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
436 |
annotation.setMedia(myMedia.id); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
437 |
annotation.setBegin(dataAnnotation.begin); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
438 |
annotation.setEnd(dataAnnotation.end); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
439 |
annotation.title = dataAnnotation.title; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
440 |
annotation.description = dataAnnotation.description; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
441 |
annotation.type = dataAnnotation.type; |
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
442 |
annotation.color = annotationsColors[dataAnnotation.type]; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
443 |
annotation.keywords = dataAnnotation.keywords; |
| 42 | 444 |
annotation.content = getContentAnnotationByType(dataAnnotation.type); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
445 |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
446 |
myProject.getAnnotations().push(annotation); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
447 |
annotations.push(annotation); |
| 107 | 448 |
disabledPreview(); |
449 |
||
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
450 |
return annotation; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
451 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
452 |
|
| 115 | 453 |
//annotation content data init |
454 |
function getContentAnnotationByType(type){ |
|
455 |
var content; |
|
456 |
switch(type){ |
|
457 |
case 'audio': |
|
458 |
content = { |
|
459 |
mimetype : "application/x-ldt-audio", |
|
460 |
url : "", |
|
461 |
embedcode : "" |
|
462 |
}; |
|
463 |
break; |
|
464 |
case 'video': |
|
465 |
content = { |
|
466 |
mimetype : "application/x-ldt-video", |
|
467 |
url : "", |
|
468 |
embedcode : "" |
|
469 |
}; |
|
470 |
break; |
|
471 |
case 'text': |
|
472 |
content = { |
|
473 |
mimetype : "application/x-ldt-text", |
|
474 |
markup : "html", |
|
475 |
text : "" |
|
476 |
}; |
|
477 |
break; |
|
478 |
case 'links': |
|
479 |
content = { |
|
480 |
mimetype : "application/x-ldt-links", |
|
481 |
links : [] |
|
482 |
}; |
|
483 |
break; |
|
484 |
case 'slideshow': |
|
485 |
content = { |
|
486 |
mimetype : "application/x-ldt-slideshow", |
|
487 |
slideduration : 1000, |
|
488 |
autostart : false, |
|
489 |
images : [] |
|
490 |
}; |
|
491 |
break; |
|
492 |
} |
|
493 |
return content; |
|
494 |
} |
|
495 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
496 |
function renderAnnotation(){ |
| 105 | 497 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
498 |
var timeline = $('.timeline-annotations'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
499 |
wTimeline = timeline.width(), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
500 |
annotationList = $('#list-annotations-rows'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
501 |
|
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
502 |
annotations = annotations.sortBy(function(c){ |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
503 |
return c.begin; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
504 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
505 |
|
| 62 | 506 |
timeline.empty().append('<li>'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
507 |
annotationList.empty(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
508 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
509 |
$.each(annotations, function(k, v){ |
|
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 |
//timeline |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
512 |
var width = Math.floor(v.getDuration() * wTimeline / myMedia.duration), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
513 |
left = Math.floor(v.begin * wTimeline / myMedia.duration), |
| 93 | 514 |
dataAnntim = { |
515 |
left : left, |
|
516 |
width : width, |
|
517 |
color : v.color, |
|
| 95 | 518 |
id : v.id, |
519 |
title : v.title |
|
| 93 | 520 |
}, |
521 |
segment = getTemplate('#tpl-annotation-in-timeline'); |
|
522 |
segment = Mustache.render(segment, dataAnntim); |
|
523 |
||
| 95 | 524 |
|
| 62 | 525 |
var isInTimeline = false; |
526 |
$.each(timeline.find('li'), function(a, b){ |
|
527 |
if(isInTimeline) return; |
|
528 |
var row = $(this); |
|
529 |
if(row.children().length){ |
|
530 |
var canBeInRow = true; |
|
531 |
$.each(row.find('.annotation'), function(c, d){ |
|
532 |
var oAL = parseInt($(d).css('left')), |
|
533 |
oAR = oAL + $(d).width(), |
|
534 |
segmentR = left + width; |
|
535 |
if(oAL<=left && oAR>=left || oAL<=segmentR && oAR>= segmentR){ |
|
536 |
canBeInRow = false; |
|
537 |
} |
|
538 |
}); |
|
539 |
if(canBeInRow){ |
|
540 |
row.append(segment); |
|
541 |
isInTimeline = true; |
|
542 |
} |
|
543 |
}else{ |
|
544 |
row.append(segment); |
|
545 |
isInTimeline = true; |
|
546 |
} |
|
547 |
}); |
|
548 |
||
549 |
if(!isInTimeline){ |
|
550 |
timeline.append('<li>'); |
|
551 |
timeline.find('li:last-child').append(segment); |
|
552 |
} |
|
553 |
|
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
554 |
//liste |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
555 |
v.iconTab = getIcon(v.type); |
| 62 | 556 |
var tplAnnotationRow = getTemplate('#tpl-list-annotation-row'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
557 |
tplAnnotationRow = Mustache.render(tplAnnotationRow, v); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
558 |
annotationList.append(tplAnnotationRow); |
| 62 | 559 |
}); |
560 |
}//renderAnnotation |
|
| 22 | 561 |
|
| 6 | 562 |
//edit annotation |
563 |
$('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){ |
|
564 |
e.preventDefault(); |
|
| 105 | 565 |
|
| 6 | 566 |
var idAnnotation = $(this).attr('data-id'); |
567 |
//si il est déjà ouvert |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
568 |
if($('#tab-annotation-'+idAnnotation).length){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
569 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
| 6 | 570 |
}else{ |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
571 |
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
|
572 |
openTab(data.type, data); |
| 6 | 573 |
} |
574 |
}); |
|
575 |
||
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
576 |
$('.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
|
577 |
var name = $(this).attr('name'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
578 |
value = $(this).val(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
579 |
currentAnnotation[name] = value; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
580 |
if(name == 'title'){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
581 |
var idAnnotation = $(this).parents('form').attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
582 |
$('#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
|
583 |
$(this).parents('form').find('.btn-delete-annotation').attr('data-title', value); |
| 101 | 584 |
$('#annotation-timeline-'+ idAnnotation).attr('title', value); |
| 95 | 585 |
$('#annotation-timeline-'+ idAnnotation+' span').text(value); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
586 |
} |
| 107 | 587 |
disabledPreview(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
588 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
589 |
|
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
590 |
//delete annotation |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
591 |
$(document).on('click','.btn-delete-annotation', function(e){ |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
592 |
e.preventDefault(); |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
593 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
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
|
598 |
}); |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
599 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
600 |
function deleteAnnotation(idAnnotation){ |
| 105 | 601 |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
602 |
$("#modal-confirm").modal('hide'); |
|
88
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
603 |
annotations.removeId(idAnnotation); |
|
c91124908cd1
Modified Edition to add remove annotations to the project
veltr
parents:
86
diff
changeset
|
604 |
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
|
605 |
closeTab(idAnnotation); |
|
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
606 |
renderAnnotation(); |
| 107 | 607 |
disabledPreview(); |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
608 |
} |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
609 |
|
| 107 | 610 |
/* Tab */ |
611 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
612 |
$('#onglet-annotations').on('click', 'a', function(e){ |
| 9 | 613 |
e.preventDefault(); |
614 |
$(this).tab('show'); |
|
615 |
}); |
|
616 |
||
| 115 | 617 |
//open tab |
| 9 | 618 |
$(document).on('click', '.open-tab', function(e){ |
619 |
e.preventDefault(); |
|
620 |
var type = $(this).attr('data-type'); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
621 |
openTab(type); |
| 9 | 622 |
}); |
623 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
624 |
function openTab(type, data){ |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
625 |
|
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
626 |
var dataView, isNew = false; |
| 115 | 627 |
if(_.isUndefined(data)){//new |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
628 |
var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
629 |
endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
630 |
var dataAnnotation = { |
|
70
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
62
diff
changeset
|
631 |
title : '', |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
632 |
begin : myMedia.currentTime, |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
633 |
end : endAnnotation, |
|
70
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
62
diff
changeset
|
634 |
description : '', |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
635 |
type : type, |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
636 |
keywords : [] |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
637 |
}; |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
638 |
dataView = newAnnotation(dataAnnotation); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
639 |
renderAnnotation(); |
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
640 |
isNew = true; |
| 115 | 641 |
}else{//edition |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
642 |
dataView = data; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
643 |
} |
| 6 | 644 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
645 |
var idAnnotation = dataView.id, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
646 |
tabContent = $('<div class="tab-pane" id="tab-annotation-'+idAnnotation+'"></div>'), |
| 6 | 647 |
iconTab; |
648 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
649 |
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
|
650 |
showCurrentAnnotationInTimeline(idAnnotation); |
| 6 | 651 |
//head commun à tous |
| 62 | 652 |
var tplHead = getTemplate('#tpl-head'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
653 |
var output = Mustache.render(tplHead, dataView); |
| 6 | 654 |
$(tabContent).append(output); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
655 |
$(tabContent).find(".slider-duration").slider(configSlider(dataView)); |
| 105 | 656 |
currentSlider = $(tabContent).find(".slider-duration"); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
657 |
$(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
|
658 |
$(tabContent).find('.tag-it').tagit(tagitParam); |
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
659 |
|
| 6 | 660 |
//type |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
661 |
var viewType = { |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
662 |
id : idAnnotation, |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
663 |
content : dataView.content |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
664 |
}; |
| 62 | 665 |
var tpl = getTemplate('#tpl-'+type); |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
666 |
|
| 6 | 667 |
tpl = Mustache.render(tpl, viewType); |
668 |
$(tabContent).append(tpl); |
|
669 |
$('.tab-content').append(tabContent); |
|
670 |
||
| 115 | 671 |
//data by type |
| 6 | 672 |
switch(type){ |
| 48 | 673 |
case 'audio': |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
674 |
break; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
675 |
case 'video': |
| 93 | 676 |
var labelModify = $(tabContent).find('.label-modify-video'), |
677 |
labelAdd = $(tabContent).find('.label-add-video'); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
678 |
if(viewType.content.url != ""){ |
| 62 | 679 |
var videoWrap = $(tabContent).find('.annotation-video-content'); |
| 58 | 680 |
renderVideoInfo(videoWrap, viewType.content); |
| 93 | 681 |
labelModify.show(); |
| 102 | 682 |
|
| 93 | 683 |
}else{ |
684 |
labelAdd.show(); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
685 |
} |
| 6 | 686 |
break; |
687 |
case 'text': |
|
| 38 | 688 |
var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0]; |
| 6 | 689 |
break; |
| 42 | 690 |
case 'links': |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
691 |
var tbody = $(tabContent).find('tbody.links-rows'), |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
692 |
links = viewType.content.links; |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
693 |
if(links.length){ |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
694 |
$.each(links, function(k,v){ |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
695 |
addLinkRow(tbody, v); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
696 |
}); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
697 |
}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
|
698 |
addLinkRow(tbody); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
699 |
} |
| 38 | 700 |
break; |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
701 |
|
| 42 | 702 |
case 'slideshow': |
| 95 | 703 |
console.log(currentAnnotation) |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
704 |
$(tabContent).find('.number-spin').val(dataView.content.slideduration/1000); |
| 6 | 705 |
$(tabContent).find('.number-spin').spin(spinParam); |
706 |
$(tabContent).find('.ui-sortable').sortable({ |
|
| 58 | 707 |
start: function (event, ui) { |
708 |
$(ui.item).data("startindex", ui.item.index()); |
|
709 |
}, |
|
| 6 | 710 |
stop : function(event, ui){ |
711 |
disabledBtnSortable($(this)); |
|
| 58 | 712 |
}, |
713 |
update : function(event, ui){ |
|
714 |
var oldIndex = ui.item.data("startindex"), |
|
715 |
newIndex = ui.item.index(); |
|
716 |
currentAnnotation.content.images.move(oldIndex, newIndex); |
|
717 |
}, |
|
| 6 | 718 |
}); |
| 51 | 719 |
var diaporama = $(tabContent).find('#diaporama-'+idAnnotation), |
720 |
images = viewType.content.images; |
|
721 |
if(images.length){ |
|
722 |
$.each(images, function(k,v){ |
|
723 |
addImageToDiaporama(diaporama, v); |
|
724 |
}); |
|
725 |
} |
|
| 6 | 726 |
break; |
727 |
} |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
728 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
729 |
dataView.iconTab = getIcon(type); |
| 62 | 730 |
var tplOnglet = getTemplate('#tpl-onglet'); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
731 |
var onglet = Mustache.render(tplOnglet, dataView); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
732 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
733 |
$(".nav-tabs li:last-child").after(onglet); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
734 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
735 |
|
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
736 |
if(isNew){$(tabContent).find('.head-title').focus();} |
| 62 | 737 |
|
| 115 | 738 |
}//openTab |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
739 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
740 |
function getIcon(type){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
741 |
var icon; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
742 |
switch(type){ |
| 48 | 743 |
case 'audio': icon = 'volume-up'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
744 |
break; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
745 |
case 'video': icon = 'film'; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
746 |
break; |
| 62 | 747 |
case 'text': icon = 'align-left'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
748 |
break; |
| 38 | 749 |
case 'html': icon = 'code'; |
750 |
break; |
|
| 42 | 751 |
case 'links': icon = 'link'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
752 |
break; |
| 42 | 753 |
case 'slideshow': icon = 'picture'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
754 |
break; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
755 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
756 |
return icon; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
757 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
758 |
|
| 115 | 759 |
//define currentAnnotation by open tab |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
760 |
$('#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
|
761 |
var idAnnotation = $(e.target).attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
762 |
currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
| 105 | 763 |
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
|
764 |
showCurrentAnnotationInTimeline(idAnnotation); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
765 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
766 |
|
| 115 | 767 |
//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
|
768 |
$('#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
|
769 |
currentAnnotation = undefined; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
770 |
renderAnnotation(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
771 |
}); |
| 6 | 772 |
|
| 115 | 773 |
//close tab |
774 |
function closeTab(idAnnotation){ |
|
775 |
$('#onglet-'+idAnnotation).remove(); |
|
776 |
$('.tab-content #tab-annotation-'+idAnnotation).remove(); |
|
777 |
$('#tab-list-annotation').tab('show'); |
|
778 |
} |
|
779 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
780 |
$('#onglet-annotations').on('click', 'span.close-tab', function(e){ |
| 9 | 781 |
e.preventDefault();e.stopPropagation(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
782 |
var idAnnotation = $(this).parents('a').attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
783 |
closeTab(idAnnotation); |
| 9 | 784 |
}); |
785 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
786 |
$('.tab-content').on('click', '.btn-save-annotation', function(e){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
787 |
e.preventDefault(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
788 |
var idAnnotation = $(this).attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
789 |
closeTab(idAnnotation); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
790 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
791 |
|
| 115 | 792 |
/* Video */ |
| 9 | 793 |
|
| 58 | 794 |
function renderVideoInfo(videoWrap, dataVideo){ |
| 62 | 795 |
var tplVideo = getTemplate('#tpl-video-row'); |
796 |
tplVideo = Mustache.render(tplVideo, dataVideo); |
|
797 |
|
|
798 |
videoWrap.empty().append(tplVideo); |
|
| 58 | 799 |
|
| 62 | 800 |
videoWrap = videoWrap.find(".video-container"); |
801 |
getVideoPlayer(dataVideo.url, videoWrap); |
|
| 58 | 802 |
} |
| 115 | 803 |
|
804 |
//select video on modal |
|
|
89
99d281de4f31
disabled sélect on pagination modal bibliothèque
Anthony Ly <anthonyly.com@gmail.com>
parents:
88
diff
changeset
|
805 |
$('.popup').on('click', '.bibliotheque-video a:not(.pagination a)', function(e){ |
| 58 | 806 |
e.preventDefault(); |
807 |
||
808 |
var url = $(this).attr('data-url'), |
|
809 |
title = $(this).attr('data-title'), |
|
810 |
description = $(this).attr('data-description'); |
|
811 |
||
812 |
currentAnnotation.content.url = url; |
|
813 |
currentAnnotation.content.title = title; |
|
814 |
currentAnnotation.content.description = description; |
|
815 |
||
816 |
$('.popup').modal('hide'); |
|
817 |
||
818 |
var videoWrap = $('#tab-annotation-'+currentAnnotation.id).find('.annotation-video-content'); |
|
819 |
renderVideoInfo(videoWrap, currentAnnotation.content); |
|
| 93 | 820 |
|
821 |
var labelModify = $('#tab-annotation-'+currentAnnotation.id).find('.label-modify-video'), |
|
822 |
labelAdd = $('#tab-annotation-'+currentAnnotation.id).find('.label-add-video'); |
|
823 |
||
824 |
labelModify.show(); |
|
825 |
labelAdd.hide(); |
|
| 107 | 826 |
|
827 |
disabledPreview(); |
|
| 58 | 828 |
}); |
829 |
||
| 107 | 830 |
/* Slideshow */ |
| 51 | 831 |
|
| 115 | 832 |
//select image on modal |
|
89
99d281de4f31
disabled sélect on pagination modal bibliothèque
Anthony Ly <anthonyly.com@gmail.com>
parents:
88
diff
changeset
|
833 |
$('.popup').on('click', '.bibliotheque-image a:not(.pagination a)', function(e){ |
| 51 | 834 |
e.preventDefault(); |
835 |
||
| 58 | 836 |
var url = $(this).attr('data-url'), |
837 |
title = $(this).attr('data-title'), |
|
838 |
description = $(this).attr('data-description'), |
|
| 51 | 839 |
image = { |
840 |
id : currentAnnotation.id, |
|
841 |
url : url, |
|
| 58 | 842 |
title : title, |
843 |
description : description |
|
| 51 | 844 |
}; |
845 |
currentAnnotation.content.images.push(image); |
|
846 |
||
847 |
var listDiaporama = $('#diaporama-'+currentAnnotation.id); |
|
848 |
addImageToDiaporama(listDiaporama, image); |
|
849 |
$('.popup').modal('hide'); |
|
| 107 | 850 |
disabledPreview(); |
| 51 | 851 |
}); |
852 |
||
853 |
function addImageToDiaporama(diaporama, dataView){ |
|
| 62 | 854 |
var tplDiapo = getTemplate('#tpl-diaporama-row'); |
855 |
tplDiapo = Mustache.render(tplDiapo, dataView); |
|
856 |
diaporama.append(tplDiapo); |
|
857 |
disabledBtnSortable(diaporama); |
|
| 6 | 858 |
}; |
859 |
||
| 115 | 860 |
//edit |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
861 |
$('.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
|
862 |
if($(this).find('input').length) return; |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
863 |
var html = $(this).find('span').html(), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
864 |
inputType = $(this).attr('data-input'), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
865 |
name = $(this).attr('data-name'), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
866 |
input = $('<'+inputType+'>').attr('name', name); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
867 |
input.val(html); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
868 |
$(this).find('span').replaceWith(input); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
869 |
input.focus().keypress(function(e){ |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
870 |
code = (e.keyCode ? e.keyCode : e.which); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
871 |
if (code == 13) $(this).blur(); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
872 |
}); |
|
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 |
$(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
|
876 |
var newValue = $(this).val(), |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
877 |
name = $(this).attr('name'), |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
878 |
span = $('<span>').html(newValue), |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
879 |
indexRow = $(this).parents('.row-image-diaporama').index(); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
880 |
$(this).replaceWith(span); |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
881 |
currentAnnotation.content.images[indexRow][name] = newValue; |
| 107 | 882 |
disabledPreview(); |
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
883 |
}); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
884 |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
885 |
$(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
|
886 |
var newValue = $(this).val(), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
887 |
name = $(this).attr('name'), |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
888 |
span = $('<span>').html(newValue); |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
889 |
$(this).replaceWith(span); |
|
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
890 |
currentAnnotation.content[name] = newValue; |
| 107 | 891 |
disabledPreview(); |
|
79
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
892 |
}); |
|
5dfa74fcec4b
show current annotation edit in timeline
Anthony Ly <anthonyly.com@gmail.com>
parents:
74
diff
changeset
|
893 |
|
| 115 | 894 |
//button up / down |
| 6 | 895 |
$(document).on('click', '.ui-sortable .btn-sort', function(e){ |
896 |
e.preventDefault(); |
|
897 |
var row = $(this).parents('tr.row-image-diaporama'), |
|
| 58 | 898 |
oldIndex = row.index(), |
| 6 | 899 |
listDiaporama = $(this).parents('.list-image-diaporama'); |
900 |
||
901 |
if($(this).hasClass('down')) |
|
902 |
row.insertAfter(row.next()); |
|
903 |
else if($(this).hasClass('up')) |
|
904 |
row.insertBefore(row.prev()); |
|
905 |
||
| 58 | 906 |
var newIndex = row.index(); |
907 |
currentAnnotation.content.images.move(oldIndex, newIndex); |
|
908 |
||
| 6 | 909 |
disabledBtnSortable(listDiaporama); |
| 107 | 910 |
disabledPreview(); |
| 6 | 911 |
}); |
912 |
||
| 115 | 913 |
function disabledBtnSortable(listDiaporama){ |
914 |
listDiaporama.find('.btn-sort.disabled').removeClass('disabled'); |
|
915 |
listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled'); |
|
916 |
listDiaporama.find('tr.row-image-diaporama:last-child').find('.btn-sort.down').addClass('disabled'); |
|
917 |
} |
|
918 |
||
919 |
//delete image on slideshow |
|
| 58 | 920 |
$('.tab-content').on('click','.btn-delete-image', function(e){ |
921 |
e.preventDefault(); |
|
922 |
var rowImage = $(this).parents('tr.row-image-diaporama'), |
|
923 |
index = rowImage.index(); |
|
924 |
||
925 |
rowImage.remove(); |
|
926 |
currentAnnotation.content.images.splice(index, 1); |
|
| 107 | 927 |
disabledPreview(); |
| 58 | 928 |
}); |
929 |
||
| 115 | 930 |
/* Links */ |
931 |
||
932 |
//add |
|
933 |
function addLinkRow(tbody, dataView){ |
|
934 |
var tplLinkRow = getTemplate('#tpl-links-row'); |
|
935 |
var output = Mustache.render(tplLinkRow, dataView); |
|
936 |
tbody.append(output); |
|
937 |
||
| 6 | 938 |
} |
939 |
||
| 107 | 940 |
$('.tab-content').on('click', '.add-link', function(e){ |
941 |
e.preventDefault(); |
|
942 |
var tbody = $(this).parents('tfoot').siblings('tbody'); |
|
943 |
addLinkRow(tbody); |
|
944 |
}); |
|
| 115 | 945 |
|
946 |
//delete |
|
| 107 | 947 |
$('.tab-content').on('click', '.delete-link', function(e){ |
948 |
e.preventDefault(); |
|
949 |
var row = $(this).parents('tr'), |
|
950 |
tbody = $(this).parents('tbody'); |
|
| 62 | 951 |
|
| 107 | 952 |
row.remove(); |
953 |
updateLinks(tbody); |
|
954 |
}); |
|
| 115 | 955 |
|
956 |
//edit |
|
| 107 | 957 |
$('.tab-content').on('keyup', '.links-rows input', function(e){ |
958 |
var tbody = $(this).parents('.links-rows'); |
|
959 |
updateLinks(tbody); |
|
| 48 | 960 |
}); |
| 115 | 961 |
|
| 107 | 962 |
function updateLinks(tbody){ |
963 |
links = new Array(); |
|
| 6 | 964 |
|
| 107 | 965 |
$.each(tbody.find('tr'), function(k, v){ |
966 |
var urlLink = $(v).find('.url-link').val(), |
|
967 |
titleLink = $(v).find('.title-link').val(), |
|
968 |
link = { |
|
969 |
url : urlLink, |
|
970 |
title : titleLink |
|
971 |
}; |
|
972 |
links.push(link); |
|
| 51 | 973 |
|
| 107 | 974 |
}); |
975 |
currentAnnotation.content.links = links; |
|
976 |
disabledPreview(); |
|
| 51 | 977 |
} |
| 115 | 978 |
|
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
979 |
$('.tab-content').on('focus', '.url-link', function(){ |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
980 |
var td = $(this).parents('td'); |
| 115 | 981 |
if(td.hasClass('error')) { |
982 |
td.removeClass('error'); |
|
983 |
td.find('.help-inline').hide(); |
|
984 |
} |
|
|
111
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
985 |
}); |
|
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 |
$('.tab-content').on('blur', '.url-link', function(){ |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
988 |
var url = $(this).val(), |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
989 |
td = $(this).parents('td'); |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
990 |
if(!isValidLink(url)){ |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
991 |
td.addClass('error'); |
| 115 | 992 |
td.find('.help-inline').show(); |
|
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 |
|
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
996 |
function isValidLink(url){ |
|
c0e4d761bcb6
add chapter if new project
Anthony Ly <anthonyly.com@gmail.com>
parents:
110
diff
changeset
|
997 |
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
|
998 |
} |
| 51 | 999 |
|
| 115 | 1000 |
//autostart |
1001 |
$('.tab-content').on('click', '.btn-autostart', function(){ |
|
1002 |
var autostart = $(this).attr('data-autostart'); |
|
1003 |
if(autostart == "true"){ autostart = true;} |
|
1004 |
else {autostart = false;} |
|
1005 |
disabledPreview(); |
|
1006 |
currentAnnotation.content.autostart = autostart; |
|
1007 |
}); |
|
1008 |
||
1009 |
//duration |
|
1010 |
$('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){ |
|
1011 |
var value = $(this).val(); |
|
1012 |
if(!isNaN(value)){ |
|
1013 |
disabledPreview(); |
|
1014 |
currentAnnotation.content.slideduration = value * 1000; |
|
1015 |
} |
|
1016 |
}); |
|
1017 |
||
1018 |
/* Audio */ |
|
1019 |
||
| 107 | 1020 |
$('.tab-content').on('keyup', '.annotation-audio-content input, .annotation-audio-content textarea', function(){ |
1021 |
var name = $(this).attr('name'), |
|
1022 |
value = $(this).val(); |
|
| 105 | 1023 |
|
| 107 | 1024 |
currentAnnotation.content[name] = value; |
1025 |
disabledPreview(); |
|
1026 |
}); |
|
| 95 | 1027 |
|
| 115 | 1028 |
/* Save project */ |
| 84 | 1029 |
|
| 107 | 1030 |
$('.btn-save-project').bind('click', function(e){ |
1031 |
e.preventDefault(); |
|
1032 |
if($(this).hasClass('disabled')) return; |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
1033 |
|
| 107 | 1034 |
showAlertByClassName('save-load'); |
1035 |
var that = this; |
|
1036 |
$(this).addClass('disabled'); |
|
|
83
8f954a0d6031
edit title and descripttion video
Anthony Ly <anthonyly.com@gmail.com>
parents:
79
diff
changeset
|
1037 |
|
| 107 | 1038 |
console.log(myProject.serialize()); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1039 |
|
| 107 | 1040 |
$.ajax({ |
1041 |
type: "POST", |
|
1042 |
url: urlSaveProject, |
|
1043 |
data: myProject.serialize(), |
|
1044 |
contentType: "application/cinelab", |
|
1045 |
headers: { |
|
1046 |
"X-CSRFToken": tokenSaveProject |
|
1047 |
}, |
|
1048 |
success: function(data, status, request){ |
|
1049 |
showAlertByClassName('save-ok'); |
|
1050 |
$('.btn-apercu-projet').removeClass('disabled'); |
|
1051 |
console.log('data : ', data); |
|
1052 |
console.log('status : ', status); |
|
1053 |
console.log('request : ', request); |
|
1054 |
||
1055 |
}, |
|
1056 |
error: function(jqXHR, textStatus, errorThrown){ |
|
1057 |
showAlertByClassName('save-error'); |
|
1058 |
//alert(gettext("Server error\nYour hashcut couldn't be published")); |
|
1059 |
}, |
|
1060 |
complete : function(){ |
|
1061 |
$(that).removeClass('disabled'); |
|
1062 |
} |
|
1063 |
}); |
|
1064 |
}); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1065 |
|
| 107 | 1066 |
//disabled preview |
1067 |
function disabledPreview(){ |
|
1068 |
if(!$('.btn-apercu-projet').hasClass('disabled'))$('.btn-apercu-projet').addClass('disabled'); |
|
1069 |
} |
|
1070 |
$(document).on('click', '.btn-apercu-projet.disabled', function(e){ |
|
1071 |
e.preventDefault(); |
|
1072 |
}); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1073 |
|
| 115 | 1074 |
//alert save info |
| 107 | 1075 |
$('.alert').bind('close', function (e) { |
1076 |
e.preventDefault(); |
|
1077 |
$(this).hide(); |
|
1078 |
}); |
|
1079 |
||
1080 |
function showAlertByClassName(className){ |
|
1081 |
$('.alert').hide(); |
|
1082 |
$('.'+className).show(); |
|
| 38 | 1083 |
} |
| 115 | 1084 |
|
1085 |
/* Config */ |
|
1086 |
||
| 107 | 1087 |
//tagit |
1088 |
function onTagItChange(e, ui) { |
|
1089 |
var tagitType = $(this).attr('data-type'), |
|
1090 |
value = $(this).val(); |
|
1091 |
||
1092 |
disabledPreview(); |
|
1093 |
||
1094 |
if(tagitType == 'chapter'){ |
|
1095 |
var idChapter = $(this).parents('form').attr('data-chapter-id'); |
|
1096 |
currentChapter.keywords = value.split(','); |
|
1097 |
$('#row-list-chapter-'+idChapter).find('.list-chapter-tags').text(value); |
|
1098 |
}else{ |
|
1099 |
currentAnnotation.keywords = value.split(','); |
|
1100 |
} |
|
1101 |
} |
|
| 6 | 1102 |
|
| 107 | 1103 |
var tagitParam = { |
1104 |
allowSpaces: true, |
|
1105 |
afterTagRemoved : onTagItChange, |
|
1106 |
afterTagAdded : onTagItChange |
|
1107 |
} |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1108 |
|
| 115 | 1109 |
//CLEditor (wysiwyg) http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters |
| 107 | 1110 |
var wysiwygConfig = { |
1111 |
width: 450, |
|
1112 |
height: 250, |
|
1113 |
controls: "bold italic underline strikethrough | font size " + |
|
1114 |
"style | color highlight removeformat | bullets numbering | source", |
|
1115 |
fonts: "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," + |
|
1116 |
"Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana", |
|
1117 |
sizes: "1,2,3,4,5,6,7", |
|
1118 |
styles: [["Paragraph", "<p>"], ["Header 2", "<h2>"], |
|
1119 |
["Header 3", "<h3>"], ["Header 4","<h4>"], ["Header 5","<h5>"], |
|
1120 |
["Header 6","<h6>"]], |
|
1121 |
docType: '<!DOCTYPE HTML>', |
|
1122 |
bodyStyle: "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;", |
|
1123 |
updateTextArea : function(text){ |
|
1124 |
disabledPreview(); |
|
1125 |
currentAnnotation.content.text = text; |
|
1126 |
return text; |
|
|
70
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
62
diff
changeset
|
1127 |
}, |
| 107 | 1128 |
updateFrame: function(text){ |
1129 |
disabledPreview(); |
|
1130 |
currentAnnotation.content.text = text; |
|
1131 |
return text; |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1132 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
1133 |
}; |
| 107 | 1134 |
|
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 |
||
| 115 | 1341 |
/* Utility */ |
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 |