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