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