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