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