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