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