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