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