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