| author | veltr |
| Tue, 28 May 2013 16:42:55 +0200 | |
| changeset 54 | 2a7064b70693 |
| parent 51 | c7ece022eca8 |
| child 55 | cedadc7d039a |
| permissions | -rw-r--r-- |
| 28 | 1 |
var myMedia = null, |
2 |
currentChapter = null, |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
3 |
currentAnnotation = null, |
| 28 | 4 |
chapters = [], |
5 |
annotations = []; |
|
6 |
||
| 9 | 7 |
$(function(){ |
| 6 | 8 |
|
9 |
var global = { |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
10 |
idAnnotation : null, |
| 28 | 11 |
colorsIndex : 0, |
12 |
colors : |
|
13 |
['#f39c12', '#2ecc71', '#3498db', '#9b59b6', |
|
14 |
'#f1c40f', '#e67e22', '#e74c3c', '#ecf0f1', |
|
15 |
'#16a085', '#27ae60', '#2980b9', '#8e44ad', |
|
16 |
'#f39c12', '#d35400', '#c0392b', '#bdc3c7'] |
|
17 |
}; |
|
18 |
||
19 |
||
| 16 | 20 |
myProject.onLoad(function() { |
21 |
||
22 |
$(".project-title").text(myProject.title); |
|
23 |
|
|
24 |
myMedia = myProject.getCurrentMedia(); |
|
25 |
|
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
26 |
//chargement des chapitres et annotations existants |
| 28 | 27 |
loadInitChapters(); |
| 51 | 28 |
loadInitAnnotation(); |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
29 |
|
| 16 | 30 |
IriSP.htmlPlayer( |
31 |
myMedia, |
|
32 |
$(".main-video"), |
|
33 |
{ |
|
34 |
width: 460, |
|
35 |
height: 345, |
|
36 |
controls: true, |
|
| 54 | 37 |
autostart: true, |
38 |
url_transform: function(src) { |
|
39 |
return [{ |
|
40 |
type: "video/mp4", |
|
41 |
src: src.replace(/\.[\d\w]+$/,'.mp4') |
|
42 |
}, { |
|
43 |
type: "video/webm", |
|
44 |
src: src.replace(/\.[\d\w]+$/,'.webm') |
|
45 |
}]; |
|
46 |
} |
|
| 16 | 47 |
} |
48 |
); |
|
49 |
||
50 |
myMedia.on("timeupdate", function(t) { |
|
51 |
||
52 |
//curseur chapitre |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
53 |
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
|
54 |
pos = wContainer * t / myMedia.duration, |
| 16 | 55 |
btnCutChapter = $('.btn-cut-chapter'), |
56 |
wBtnCutChapter = btnCutChapter.outerWidth(); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
57 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
58 |
$(".indicateur-chapter, .indicateur-annotation").css("left",pos); |
| 16 | 59 |
if(pos+wBtnCutChapter>wContainer){ |
60 |
btnCutChapter.css("left",(pos - wBtnCutChapter)); |
|
61 |
}else{ |
|
62 |
btnCutChapter.css("left",pos); |
|
63 |
} |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
64 |
|
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
65 |
//annotations view |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
66 |
var currentAnnotationsDisplay = new Array(); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
67 |
$.each(annotations, function(k, v){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
68 |
|
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
69 |
if(v.begin <= t && v.end >= t){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
70 |
currentAnnotationsDisplay.push(v.id); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
71 |
if(!$('#item-current-annotation-'+v.id).length){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
72 |
var itemAnnotation = |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
73 |
$('<li>') |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
74 |
.attr('id', 'item-current-annotation-'+v.id) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
75 |
.attr('data-id', v.id) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
76 |
.append( |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
77 |
$('<a>') |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
78 |
.css('backgroundColor', v.color) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
79 |
.attr('data-id', v.id) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
80 |
.attr('href', '#') |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
81 |
.append( |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
82 |
$('<i>').addClass('icon-'+getIcon(v.type)) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
83 |
) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
84 |
); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
85 |
$('.list-current-annotations').append(itemAnnotation) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
86 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
87 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
88 |
}); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
89 |
$.each($('.list-current-annotations li'), function(k, v){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
90 |
var idAnnotation = $(this).attr('data-id'), |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
91 |
annotationDisplayView = $('.annotation-display-view'); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
92 |
if($.inArray(idAnnotation, currentAnnotationsDisplay)<0){//il ne doit plus être affiché |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
93 |
$('#item-current-annotation-'+idAnnotation).remove(); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
94 |
if(annotationDisplayView.attr('data-id') == idAnnotation && annotationDisplayView.is(":visible")){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
95 |
annotationDisplayView.hide(); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
96 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
97 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
98 |
}); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
99 |
|
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
100 |
|
| 18 | 101 |
});//timeupdate |
| 16 | 102 |
|
103 |
});//myProject.onLoad |
|
104 |
||
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
105 |
//display annotation view |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
106 |
$('.list-current-annotations').on('click', 'a', function(e){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
107 |
e.preventDefault(); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
108 |
var annotationDisplayView = $('.annotation-display-view'), |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
109 |
idAnnotation = $(this).attr('data-id'); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
110 |
var annotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
| 6 | 111 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
112 |
if(annotationDisplayView.attr('data-id') == idAnnotation && annotationDisplayView.is(":visible")){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
113 |
annotationDisplayView.hide(); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
114 |
}else{ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
115 |
annotationDisplayView |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
116 |
.attr('data-id', idAnnotation) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
117 |
.css('backgroundColor', annotation.color) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
118 |
.text(annotation.type) |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
119 |
.show(); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
120 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
121 |
}); |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
122 |
|
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
123 |
//########### modal |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
124 |
|
| 9 | 125 |
$(document).on('click', 'a.open-modal', function(e){ |
| 51 | 126 |
var idAnnotation = $(this).attr('data-id'); |
| 9 | 127 |
|
| 51 | 128 |
|
| 9 | 129 |
if(idAnnotation !== undefined){ |
130 |
global.idAnnotation = idAnnotation; |
|
131 |
} |
|
| 22 | 132 |
}); |
133 |
||
| 6 | 134 |
//edition image |
135 |
$('.popup').on('change', '#media-type-select', function(e){ |
|
136 |
var typeImage = $(this).val(); |
|
137 |
$('.input-image-url, .input-image-upload').hide(); |
|
138 |
$('.input-image-'+typeImage).show(); |
|
139 |
}); |
|
| 22 | 140 |
|
| 51 | 141 |
//select on bibliotheque |
142 |
||
| 6 | 143 |
//video |
144 |
$('.popup').on('click', '.bibliotheque-video a', function(e){ |
|
145 |
e.preventDefault(); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
146 |
|
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
147 |
var url = $(this).attr('href'); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
148 |
currentAnnotation.content.url = url; |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
149 |
|
| 6 | 150 |
$('.popup').modal('hide'); |
151 |
$.get('template.html', function(templates){ |
|
| 38 | 152 |
var videoWrap = $('#tab-'+global.idAnnotation).find('.annotation-video-content'), |
| 6 | 153 |
tplVideo = $(templates).filter('#tpl-video-row').html(); |
154 |
videoWrap.empty().append(tplVideo); |
|
155 |
}); |
|
156 |
|
|
157 |
}); |
|
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
158 |
|
| 6 | 159 |
|
160 |
//confirmation suppression |
|
161 |
$("#modal-confirm").on('click', '#btn-delete-modal', function(e){ |
|
| 9 | 162 |
|
| 6 | 163 |
}); |
164 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
165 |
//--title-editor |
| 6 | 166 |
$('.project-title-editor ._popover').bind('click',function(e){e.preventDefault()}); |
167 |
$('.project-title-editor ._popover').popover({ |
|
168 |
html : true, |
|
169 |
content : function(){ |
|
170 |
var previousValue = $('.project-title').text(), |
|
171 |
formInput = |
|
172 |
'<form action="#" class="project-title-editor-form">'+ |
|
173 |
'<input type="text" class="project-title-editor-input" value="'+previousValue+'">'+ |
|
174 |
'</form>'; |
|
175 |
return formInput; |
|
176 |
} |
|
177 |
}); |
|
178 |
||
179 |
$('body').on('click', function (e) { |
|
180 |
$('._popover').each(function () { |
|
181 |
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { |
|
182 |
$(this).popover('hide'); |
|
183 |
} |
|
184 |
}); |
|
185 |
}); |
|
186 |
||
187 |
$('body').on('submit', '.project-title-editor-form', function(e){ |
|
188 |
e.preventDefault(); |
|
189 |
$('._popover').popover('hide'); |
|
190 |
}); |
|
191 |
||
192 |
$(document).on('keyup', '.project-title-editor-input', function() { |
|
193 |
$('.project-title').html($(this).val()); |
|
194 |
}); |
|
| 9 | 195 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
196 |
//######################## chapter |
| 22 | 197 |
|
198 |
//edit |
|
199 |
$('.list-chapter-wrap').on('click', '.btn-edit-chapter', function(e){ |
|
| 6 | 200 |
e.preventDefault(); |
| 22 | 201 |
var idChapter = $(this).attr('data-chapter-id'); |
202 |
loadFormChapter(idChapter); |
|
203 |
}); |
|
204 |
||
| 23 | 205 |
$('.chapter-segments').on('click', 'li', function(){ |
206 |
var idChapter = $(this).attr('id'); |
|
207 |
loadFormChapter(idChapter); |
|
208 |
}); |
|
| 22 | 209 |
|
210 |
$('.chapter-widget-info').on('keyup', 'input[name=title], textarea', function(e){ |
|
211 |
var name = $(this).attr('name'), |
|
212 |
value = $(this).val(); |
|
213 |
currentChapter[name] = value; |
|
214 |
if(name == 'title'){ |
|
215 |
var idChapter = $(this).parents('form').attr('data-chapter-id'); |
|
216 |
$('.chapter-segments').find('#'+idChapter).text(value); |
|
217 |
$('#row-list-chapter-'+idChapter).find('td:first').text(value); |
|
| 6 | 218 |
} |
| 22 | 219 |
}); |
220 |
||
221 |
||
222 |
||
223 |
function loadFormChapter(idChapter){ |
|
| 28 | 224 |
currentChapter = _.find(chapters, function(c){ return c.id == idChapter; }); |
225 |
var chapterWrap = $('.chapter-widget-info'), |
|
226 |
indexChapter = _.indexOf(chapters, currentChapter), |
|
227 |
beginTangle = (indexChapter>0) ? true : false, |
|
228 |
endTangle = (indexChapter<(chapters.length-1)) ? true : false; |
|
| 22 | 229 |
|
| 28 | 230 |
currentChapter.beginTangle = beginTangle; |
231 |
currentChapter.endTangle = endTangle; |
|
| 22 | 232 |
|
| 6 | 233 |
$.get('template.html', function(templates){ |
234 |
var tpl = $(templates).filter('#tpl-chapter-edit').html(); |
|
| 28 | 235 |
tpl = Mustache.render(tpl, currentChapter); |
| 22 | 236 |
chapterWrap.empty().append(tpl); |
237 |
chapterWrap.find('.tag-it').tagit(tagitParam); |
|
| 6 | 238 |
}); |
| 22 | 239 |
} |
240 |
||
241 |
||
242 |
//supprimer |
|
243 |
$('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){ |
|
244 |
e.preventDefault(); |
|
245 |
||
246 |
if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;} |
|
| 28 | 247 |
|
| 22 | 248 |
var idChapter = $(this).attr('data-chapter-id'), |
249 |
chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
|
250 |
indexChapter = _.indexOf(chapters, chapter), |
|
251 |
chapterModify; |
|
252 |
if(indexChapter == 0){ |
|
253 |
chapterModify = chapters[1]; |
|
| 28 | 254 |
chapterModify.setBegin(0); |
| 22 | 255 |
}else{ |
256 |
chapterModify = chapters[indexChapter-1]; |
|
| 28 | 257 |
//var newEnd = new IriSP.Model.Time(chapter.end) |
258 |
chapterModify.setEnd(chapter.end); |
|
| 22 | 259 |
} |
260 |
chapters = _(chapters).reject(function(c) { return c.id == idChapter; }); |
|
261 |
renderChapter(); |
|
262 |
//si le formulaire est visible |
|
263 |
if($('#form-chapter-edit-'+idChapter).length){ |
|
264 |
$('#form-chapter-edit-'+idChapter).remove(); |
|
265 |
} |
|
266 |
}); |
|
267 |
||
268 |
//nouveau chapitre |
|
| 28 | 269 |
function newChapter(dataChapter){ |
270 |
var chapter = new IriSP.Model.Annotation(false, myProject); |
|
271 |
chapter.setMedia(myMedia.id); |
|
272 |
chapter.setBegin(dataChapter.begin); |
|
273 |
chapter.setEnd(dataChapter.end); |
|
274 |
chapter.title = dataChapter.title; |
|
275 |
chapter.description = dataChapter.description; |
|
276 |
chapter.keywords = dataChapter.keywords; |
|
277 |
chapter.color = global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)]; |
|
278 |
|
|
279 |
chapters.push(chapter); |
|
280 |
renderChapter(); |
|
281 |
loadFormChapter(chapter.id); |
|
282 |
} |
|
283 |
||
| 6 | 284 |
$('.chapter-widget').on('click', '.btn-cut-chapter', function(e){ |
285 |
e.preventDefault(); |
|
| 16 | 286 |
|
| 28 | 287 |
var dataChapter = { |
288 |
title : 'New', |
|
289 |
begin : myMedia.currentTime, |
|
290 |
end : organizeNewChapter(myMedia.currentTime), |
|
291 |
description : 'description', |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
292 |
keywords : ['tag1','tag2'] |
| 28 | 293 |
}; |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
294 |
|
| 28 | 295 |
newChapter(dataChapter); |
296 |
||
| 6 | 297 |
}); |
| 22 | 298 |
|
299 |
function organizeNewChapter(beginNew){ |
|
| 6 | 300 |
|
| 22 | 301 |
var returnEnd; |
302 |
$.each(chapters, function(k, v){ |
|
303 |
var begin = v.begin, |
|
304 |
end = v.end; |
|
305 |
if(beginNew>=begin && beginNew<=end){ |
|
| 28 | 306 |
returnEnd = new IriSP.Model.Time(end); |
307 |
v.setEnd(beginNew); |
|
| 22 | 308 |
} |
309 |
}); |
|
| 28 | 310 |
|
| 22 | 311 |
return returnEnd; |
312 |
} |
|
313 |
|
|
314 |
function renderChapter(){ |
|
315 |
var chapterSegmentWrap = $('.chapter-segments'), |
|
316 |
wChapterSegmentWrap = chapterSegmentWrap.width(), |
|
317 |
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
|
318 |
|
| 22 | 319 |
chapters = _.sortBy(chapters, function(c){ |
320 |
return c.begin; |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
321 |
}); |
| 18 | 322 |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
323 |
chapterSegmentWrap.empty(); |
| 22 | 324 |
chapterList.empty(); |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
325 |
|
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
326 |
$.each(chapters, function(k, v){ |
| 28 | 327 |
//form |
328 |
if($('#form-chapter-edit-'+v.id).length){ |
|
329 |
loadFormChapter(v.id); |
|
330 |
} |
|
| 22 | 331 |
//segments |
| 28 | 332 |
var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration), |
| 22 | 333 |
segment = $('<li>'+v.title+'</li>').css({ |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
334 |
width : width, |
| 22 | 335 |
backgroundColor : v.color |
336 |
}).attr('id', v.id); |
|
337 |
|
|
338 |
chapterSegmentWrap.append(segment); |
|
| 28 | 339 |
|
| 22 | 340 |
//liste |
341 |
$.get('template.html', function(templates){ |
|
342 |
var tplChapterRow = $(templates).filter('#tpl-chapter-row').html(); |
|
343 |
tplChapterRow = Mustache.render(tplChapterRow, v); |
|
344 |
chapterList.append(tplChapterRow); |
|
345 |
||
346 |
}); |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
347 |
}); |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
348 |
} |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
349 |
|
| 22 | 350 |
//init |
| 28 | 351 |
function loadInitChapters(){//nouveau projet, 1 chapitre |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
352 |
var dataChapter = { |
| 28 | 353 |
title : 'New', |
354 |
begin : 0, |
|
355 |
end : myMedia.duration, |
|
356 |
description : 'description', |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
357 |
keywords : ['tag1','tag2'] |
| 28 | 358 |
}; |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
359 |
|
| 28 | 360 |
newChapter(dataChapter); |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
361 |
} |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
362 |
|
| 22 | 363 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
364 |
//######################## annotation |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
365 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
366 |
function loadInitAnnotation(){//nouveau projet, 1 chapitre |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
367 |
var dataAnnotation = { |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
368 |
title : 'Titre azerty', |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
369 |
begin : myMedia.duration/5, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
370 |
end : myMedia.duration/3, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
371 |
description : 'description', |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
372 |
type : 'video', |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
373 |
keywords : ['ideal', 'tag'] |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
374 |
}; |
| 22 | 375 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
376 |
newAnnotation(dataAnnotation); |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
377 |
renderAnnotation(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
378 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
379 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
380 |
function newAnnotation(dataAnnotation){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
381 |
var annotation = new IriSP.Model.Annotation(false, myProject); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
382 |
annotation.setMedia(myMedia.id); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
383 |
annotation.setBegin(dataAnnotation.begin); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
384 |
annotation.setEnd(dataAnnotation.end); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
385 |
annotation.title = dataAnnotation.title; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
386 |
annotation.description = dataAnnotation.description; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
387 |
annotation.type = dataAnnotation.type; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
388 |
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
|
389 |
annotation.keywords = dataAnnotation.keywords; |
| 42 | 390 |
annotation.content = getContentAnnotationByType(dataAnnotation.type); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
391 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
392 |
annotations.push(annotation); |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
393 |
|
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
394 |
return annotation; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
395 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
396 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
397 |
function renderAnnotation(){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
398 |
var timeline = $('.timeline-annotations'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
399 |
wTimeline = timeline.width(), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
400 |
annotationList = $('#list-annotations-rows'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
401 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
402 |
annotations = _.sortBy(annotations, function(c){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
403 |
return c.begin; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
404 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
405 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
406 |
timeline.empty(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
407 |
annotationList.empty(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
408 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
409 |
$.each(annotations, function(k, v){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
410 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
411 |
//timeline |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
412 |
var width = Math.floor(v.getDuration() * wTimeline / myMedia.duration), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
413 |
left = Math.floor(v.begin * wTimeline / myMedia.duration), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
414 |
segment = $('<div>').css({ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
415 |
left : left, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
416 |
width : width, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
417 |
backgroundColor : v.color |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
418 |
}).addClass('annotation').attr('id', 'annotation-timeline-'+v.id); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
419 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
420 |
timeline.append(segment); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
421 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
422 |
//liste |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
423 |
$.get('template.html', function(templates){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
424 |
var tplAnnotationRow = $(templates).filter('#tpl-list-annotation-row').html(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
425 |
tplAnnotationRow = Mustache.render(tplAnnotationRow, v); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
426 |
annotationList.append(tplAnnotationRow); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
427 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
428 |
}); |
|
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 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
431 |
} |
| 22 | 432 |
|
| 6 | 433 |
//edit annotation |
434 |
$('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){ |
|
435 |
e.preventDefault(); |
|
436 |
||
437 |
var idAnnotation = $(this).attr('data-id'); |
|
438 |
//si il est déjà ouvert |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
439 |
if($('#tab-annotation-'+idAnnotation).length){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
440 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
| 6 | 441 |
}else{ |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
442 |
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
|
443 |
openTab(data.type, data); |
| 6 | 444 |
} |
445 |
}); |
|
446 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
447 |
$('.tab-content').on('keyup', 'input[name=title], textarea', function(e){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
448 |
var name = $(this).attr('name'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
449 |
value = $(this).val(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
450 |
currentAnnotation[name] = value; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
451 |
if(name == 'title'){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
452 |
var idAnnotation = $(this).parents('form').attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
453 |
$('#onglet-title-'+idAnnotation).text(value); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
454 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
455 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
456 |
|
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
457 |
//delete annotation |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
458 |
$(document).on('click','.btn-delete-annotation', function(e){ |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
459 |
e.preventDefault(); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
460 |
|
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
461 |
var idAnnotation = $(this).attr('data-id'); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
462 |
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
|
463 |
closeTab(idAnnotation); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
464 |
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
|
465 |
renderAnnotation(); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
466 |
|
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
467 |
}); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
468 |
|
| 9 | 469 |
//tab |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
470 |
$('#onglet-annotations').on('click', 'a', function(e){ |
| 9 | 471 |
e.preventDefault(); |
472 |
$(this).tab('show'); |
|
473 |
}); |
|
474 |
||
475 |
//ouvrir tab |
|
476 |
$(document).on('click', '.open-tab', function(e){ |
|
477 |
e.preventDefault(); |
|
478 |
var type = $(this).attr('data-type'); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
479 |
openTab(type); |
| 9 | 480 |
}); |
481 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
482 |
function openTab(type, data){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
483 |
|
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
484 |
var dataView; |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
485 |
if(_.isUndefined(data)){//nouveau |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
486 |
var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
487 |
endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
488 |
var dataAnnotation = { |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
489 |
title : 'Nouveau', |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
490 |
begin : myMedia.currentTime, |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
491 |
end : endAnnotation, |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
492 |
description : 'description', |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
493 |
type : type, |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
494 |
keywords : [] |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
495 |
}; |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
496 |
dataView = newAnnotation(dataAnnotation); |
|
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
497 |
renderAnnotation(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
498 |
}else{//édition |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
499 |
dataView = data; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
500 |
} |
| 6 | 501 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
502 |
var idAnnotation = dataView.id, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
503 |
tabContent = $('<div class="tab-pane" id="tab-annotation-'+idAnnotation+'"></div>'), |
| 6 | 504 |
iconTab; |
505 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
506 |
currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
| 6 | 507 |
|
508 |
$.get('template.html', function(templates){ |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
509 |
|
| 6 | 510 |
//head commun à tous |
511 |
var tplHead = $(templates).filter('#tpl-head').html(); |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
512 |
var output = Mustache.render(tplHead, dataView); |
| 6 | 513 |
$(tabContent).append(output); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
514 |
$(tabContent).find(".slider-duration").slider(configSlider(dataView)); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
515 |
$(tabContent).find('.tag-it').tagit(tagitParam); |
| 6 | 516 |
//type |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
517 |
var viewType = { |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
518 |
id : idAnnotation, |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
519 |
content : dataView.content |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
520 |
}; |
| 6 | 521 |
var tpl = $(templates).filter('#tpl-'+type).html(); |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
522 |
|
| 6 | 523 |
tpl = Mustache.render(tpl, viewType); |
524 |
$(tabContent).append(tpl); |
|
525 |
$('.tab-content').append(tabContent); |
|
526 |
||
527 |
//particularité selon type |
|
528 |
switch(type){ |
|
| 48 | 529 |
case 'audio': |
|
35
6eb0de10e9f8
delete / edit / new annotation head
Anthony Ly <anthonyly.com@gmail.com>
parents:
34
diff
changeset
|
530 |
break; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
531 |
case 'video': |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
532 |
|
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
533 |
if(viewType.content.url != ""){ |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
534 |
var videoWrap = $(tabContent).find('.annotation-video-content'), |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
535 |
tplVideo = $(templates).filter('#tpl-video-row').html(); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
536 |
videoWrap.empty().append(tplVideo); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
537 |
} |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
538 |
|
| 6 | 539 |
break; |
540 |
case 'text': |
|
| 38 | 541 |
var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0]; |
| 6 | 542 |
break; |
| 42 | 543 |
case 'links': |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
544 |
var tbody = $(tabContent).find('tbody.links-rows'), |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
545 |
links = viewType.content.links; |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
546 |
if(links.length){ |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
547 |
$.each(links, function(k,v){ |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
548 |
addLinkRow(tbody, v); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
549 |
}); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
550 |
}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
|
551 |
addLinkRow(tbody); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
552 |
} |
| 38 | 553 |
break; |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
554 |
|
| 42 | 555 |
case 'slideshow': |
| 51 | 556 |
|
| 6 | 557 |
$(tabContent).find('.number-spin').spin(spinParam); |
558 |
$(tabContent).find('.ui-sortable').sortable({ |
|
559 |
stop : function(event, ui){ |
|
560 |
disabledBtnSortable($(this)); |
|
561 |
} |
|
562 |
}); |
|
| 51 | 563 |
var diaporama = $(tabContent).find('#diaporama-'+idAnnotation), |
564 |
images = viewType.content.images; |
|
565 |
if(images.length){ |
|
566 |
$.each(images, function(k,v){ |
|
567 |
addImageToDiaporama(diaporama, v); |
|
568 |
}); |
|
569 |
} |
|
| 6 | 570 |
break; |
571 |
} |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
572 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
573 |
dataView.iconTab = getIcon(type); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
574 |
var tplOnglet = $(templates).filter('#tpl-onglet').html(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
575 |
var onglet = Mustache.render(tplOnglet, dataView); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
576 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
577 |
$(".nav-tabs li:last-child").after(onglet); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
578 |
$('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
| 6 | 579 |
}); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
580 |
}//openTab() |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
581 |
|
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
582 |
function getIcon(type){ |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
583 |
var icon; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
584 |
switch(type){ |
| 48 | 585 |
case 'audio': icon = 'volume-up'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
586 |
break; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
587 |
case 'video': icon = 'film'; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
588 |
break; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
589 |
case 'text': |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
590 |
icon = 'align-left'; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
591 |
break; |
| 38 | 592 |
case 'html': icon = 'code'; |
593 |
break; |
|
| 42 | 594 |
case 'links': icon = 'link'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
595 |
break; |
| 42 | 596 |
case 'slideshow': icon = 'picture'; |
|
36
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
597 |
break; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
598 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
599 |
return icon; |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
600 |
} |
|
4c2428524c22
annotation display view
Anthony Ly <anthonyly.com@gmail.com>
parents:
35
diff
changeset
|
601 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
602 |
//définit currentAnnotation quand la tab s'ouvre |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
603 |
$('#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
|
604 |
var idAnnotation = $(e.target).attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
605 |
currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
606 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
607 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
608 |
//rafraichit annotations au retour sur la liste |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
609 |
$('#onglet-annotations').on('show', 'a[data-toggle="list-annotations"]', function (e) { |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
610 |
renderAnnotation(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
611 |
}); |
| 6 | 612 |
|
| 9 | 613 |
//fermer tab |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
614 |
$('#onglet-annotations').on('click', 'span.close-tab', function(e){ |
| 9 | 615 |
e.preventDefault();e.stopPropagation(); |
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
616 |
var idAnnotation = $(this).parents('a').attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
617 |
closeTab(idAnnotation); |
| 9 | 618 |
}); |
619 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
620 |
$('.tab-content').on('click', '.btn-save-annotation', function(e){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
621 |
e.preventDefault(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
622 |
var idAnnotation = $(this).attr('data-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
623 |
closeTab(idAnnotation); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
624 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
625 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
626 |
function closeTab(idAnnotation){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
627 |
$('#onglet-'+idAnnotation).remove(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
628 |
$('.tab-content #tab-annotation-'+idAnnotation).remove(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
629 |
$('#tab-list-annotation').tab('show'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
630 |
} |
| 9 | 631 |
|
| 6 | 632 |
//diaporama |
| 51 | 633 |
|
634 |
//bibliotheque |
|
635 |
$('.popup').on('click', '.bibliotheque-image a', function(e){ |
|
636 |
e.preventDefault(); |
|
637 |
||
638 |
var url = $(this).attr('href'), |
|
639 |
image = { |
|
640 |
id : currentAnnotation.id, |
|
641 |
url : url, |
|
642 |
title : 'titre image', |
|
643 |
description : 'description azerty' |
|
644 |
}; |
|
645 |
currentAnnotation.content.images.push(image); |
|
646 |
||
647 |
var listDiaporama = $('#diaporama-'+currentAnnotation.id); |
|
648 |
addImageToDiaporama(listDiaporama, image); |
|
649 |
$('.popup').modal('hide'); |
|
650 |
}); |
|
651 |
||
652 |
function addImageToDiaporama(diaporama, dataView){ |
|
| 6 | 653 |
$.get('template.html', function(templates){ |
| 51 | 654 |
var tplDiapo = $(templates).filter('#tpl-diaporama-row').html(); |
655 |
tplDiapo = Mustache.render(tplDiapo, dataView); |
|
| 6 | 656 |
diaporama.append(tplDiapo); |
657 |
disabledBtnSortable(diaporama); |
|
658 |
}); |
|
659 |
}; |
|
660 |
||
| 9 | 661 |
//bouton up / down |
| 6 | 662 |
$(document).on('click', '.ui-sortable .btn-sort', function(e){ |
663 |
e.preventDefault(); |
|
664 |
var row = $(this).parents('tr.row-image-diaporama'), |
|
665 |
listDiaporama = $(this).parents('.list-image-diaporama'); |
|
666 |
||
667 |
if($(this).hasClass('down')) |
|
668 |
row.insertAfter(row.next()); |
|
669 |
else if($(this).hasClass('up')) |
|
670 |
row.insertBefore(row.prev()); |
|
671 |
||
672 |
disabledBtnSortable(listDiaporama); |
|
673 |
}); |
|
674 |
||
675 |
function disabledBtnSortable(listDiaporama){ |
|
676 |
listDiaporama.find('.btn-sort.disabled').removeClass('disabled'); |
|
677 |
listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled'); |
|
678 |
listDiaporama.find('tr.row-image-diaporama:last-child').find('.btn-sort.down').addClass('disabled'); |
|
679 |
} |
|
680 |
||
| 9 | 681 |
|
| 48 | 682 |
//links |
683 |
$('.tab-content').on('click', '.add-link', function(e){ |
|
684 |
e.preventDefault(); |
|
685 |
var tbody = $(this).parents('tfoot').siblings('tbody'); |
|
686 |
addLinkRow(tbody); |
|
687 |
}); |
|
688 |
$('.tab-content').on('click', '.delete-link', function(e){ |
|
689 |
e.preventDefault(); |
|
690 |
var row = $(this).parents('tr'), |
|
691 |
tbody = $(this).find('tbody'); |
|
692 |
row.remove(); |
|
693 |
updateLinks(tbody); |
|
694 |
}); |
|
695 |
function addLinkRow(tbody, dataView){ |
|
696 |
$.get('template.html', function(templates){ |
|
697 |
//head commun à tous |
|
698 |
var tplLinkRow = $(templates).filter('#tpl-links-row').html(); |
|
699 |
var output = Mustache.render(tplLinkRow, dataView); |
|
700 |
tbody.append(output); |
|
701 |
}); |
|
702 |
} |
|
703 |
$('.tab-content').on('keyup', '.links-rows input', function(e){ |
|
704 |
var tbody = $(this).parents('.links-rows'); |
|
705 |
updateLinks(tbody); |
|
706 |
}); |
|
707 |
function updateLinks(tbody){ |
|
708 |
links = new Array(); |
|
709 |
$.each(tbody.find('tr'), function(k, v){ |
|
710 |
var urlLink = $(v).find('.url-link').val(), |
|
711 |
titleLink = $(v).find('.title-link').val(), |
|
712 |
link = { |
|
713 |
uri : urlLink, |
|
714 |
title : titleLink |
|
715 |
}; |
|
716 |
links.push(link); |
|
717 |
}); |
|
718 |
currentAnnotation.content.links = links; |
|
719 |
} |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
720 |
|
| 6 | 721 |
|
722 |
//annotation html |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
723 |
/* |
| 6 | 724 |
$('.tab-content').on('click', '.btn-html-apercu', function(e){ |
725 |
e.preventDefault(); |
|
726 |
||
727 |
var apercuWrap = $(this).parents('.edit-annotation-html').find('.html-apercu'), |
|
728 |
htmlTextarea = $(this).parents('.edit-annotation-html').find('textarea'); |
|
729 |
||
730 |
apercuWrap.empty().html(htmlTextarea.val()); |
|
731 |
}); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
732 |
*/ |
| 38 | 733 |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
734 |
//annotation audio |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
735 |
$('.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
|
736 |
var name = $(this).attr('name'), |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
737 |
value = $(this).val(); |
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
738 |
|
|
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
739 |
currentAnnotation.content[name] = value; |
| 38 | 740 |
}); |
| 6 | 741 |
|
| 51 | 742 |
//annotation slideshow |
743 |
$('.tab-content').on('click', '.btn-autostart', function(){ |
|
744 |
var autostart = $(this).attr('data-autostart'); |
|
745 |
if(autostart == "true"){ autostart = true;} |
|
746 |
else {autostart = false;} |
|
747 |
currentAnnotation.content.autostart = autostart; |
|
748 |
}); |
|
749 |
||
750 |
||
751 |
$('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){ |
|
752 |
var value = $(this).val(); |
|
753 |
if(!isNaN(value)){ |
|
754 |
currentAnnotation.content.duration = value; |
|
755 |
} |
|
756 |
}); |
|
757 |
||
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
758 |
//################ config |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
759 |
//tagit |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
760 |
function onTagItChange(e, ui) { |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
761 |
var tagitType = $(this).attr('data-type'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
762 |
value = $(this).val(); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
763 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
764 |
if(tagitType == 'chapter'){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
765 |
var idChapter = $(this).parents('form').attr('data-chapter-id'); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
766 |
currentChapter.keywords = value.split(','); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
767 |
$('#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
|
768 |
}else{ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
769 |
currentAnnotation.keywords = value.split(','); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
770 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
771 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
772 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
773 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
774 |
var tagitParam = { |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
775 |
afterTagRemoved : onTagItChange, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
776 |
afterTagAdded : onTagItChange |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
777 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
778 |
|
| 6 | 779 |
//CLEditor annotation > text (wysiwyg) |
780 |
//http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters |
|
781 |
var wysiwygConfig = { |
|
782 |
width: 456, |
|
783 |
height: 250, |
|
784 |
controls: "bold italic underline strikethrough | font size " + |
|
| 38 | 785 |
"style | color highlight removeformat | bullets numbering | source", |
| 6 | 786 |
fonts: "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," + |
787 |
"Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana", |
|
788 |
sizes: "1,2,3,4,5,6,7", |
|
789 |
styles: [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"], |
|
790 |
["Header 3", "<h3>"], ["Header 4","<h4>"], ["Header 5","<h5>"], |
|
791 |
["Header 6","<h6>"]], |
|
792 |
docType: '<!DOCTYPE HTML>', |
|
| 38 | 793 |
bodyStyle: "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;", |
794 |
updateTextArea : function(text){ |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
795 |
currentAnnotation.content.text = text; |
| 38 | 796 |
return text; |
797 |
}, |
|
798 |
updateFrame: function(text){ |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
799 |
currentAnnotation.content.text = text; |
| 38 | 800 |
return text; |
801 |
} |
|
| 6 | 802 |
}; |
803 |
||
804 |
//slider |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
805 |
function configSlider(data){ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
806 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
807 |
return { |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
808 |
range: true, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
809 |
values: [ data.begin.milliseconds, data.end.milliseconds ], |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
810 |
min: 0, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
811 |
max: myMedia.duration.milliseconds, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
812 |
slide: function( event, ui ) { |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
813 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
814 |
data.setBegin(ui.values[0]); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
815 |
data.setEnd(ui.values[1]); |
| 6 | 816 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
817 |
var idSlider = $(this).attr('data-id'), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
818 |
wTimeline = $('.timeline-annotations').width(), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
819 |
annotationTimeline = $('#annotation-timeline-'+ data.id), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
820 |
width = Math.floor(data.getDuration() * wTimeline / myMedia.duration), |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
821 |
left = Math.floor(data.begin * wTimeline / myMedia.duration); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
822 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
823 |
$( '#'+ idSlider +'-begin' ).html(data.begin.toString()); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
824 |
$( '#'+ idSlider +'-duration' ).html(data.getDuration().toString()); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
825 |
$( '#'+ idSlider +'-end' ).html(data.end.toString()); |
| 6 | 826 |
|
|
34
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
827 |
annotationTimeline.css({ |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
828 |
left : left, |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
829 |
width :width |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
830 |
}); |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
831 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
832 |
} |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
833 |
}; |
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
834 |
|
|
e3a17ec94cd8
edition annotation first part
Anthony Ly <anthonyly.com@gmail.com>
parents:
28
diff
changeset
|
835 |
} |
| 9 | 836 |
|
| 42 | 837 |
function getContentAnnotationByType(type){ |
838 |
var content; |
|
839 |
switch(type){ |
|
| 48 | 840 |
case 'audio': |
| 42 | 841 |
content = { |
| 48 | 842 |
mimetype : "application/x-ldt-audio", |
| 42 | 843 |
url : "", |
844 |
embedcode : "" |
|
845 |
}; |
|
846 |
break; |
|
847 |
case 'video': |
|
848 |
content = { |
|
849 |
mimetype : "application/x-ldt-video", |
|
850 |
url : "", |
|
851 |
embedcode : "" |
|
852 |
}; |
|
853 |
break; |
|
854 |
case 'text': |
|
855 |
content = { |
|
856 |
mimetype : "application/x-ldt-text", |
|
857 |
markup : "html", |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
858 |
text : "azerty" |
| 42 | 859 |
}; |
860 |
break; |
|
861 |
case 'links': |
|
862 |
content = { |
|
863 |
mimetype : "application/x-ldt-links", |
|
864 |
links : [] |
|
865 |
}; |
|
866 |
break; |
|
867 |
case 'slideshow': |
|
868 |
content = { |
|
869 |
mimetype : "application/x-ldt-slideshow", |
|
870 |
duration : 1, |
|
871 |
autostart : false, |
|
872 |
images : [] |
|
873 |
}; |
|
874 |
break; |
|
875 |
} |
|
876 |
return content; |
|
877 |
}//getContentAnnotationByType |
|
| 38 | 878 |
|
879 |
||
| 9 | 880 |
//test |
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
881 |
//a = $(".wysiwyg").cleditor(wysiwygConfig); |
| 38 | 882 |
|
| 9 | 883 |
|
884 |
$('.number-spin').spin(spinParam); |
|
885 |
||
886 |
disabledBtnSortable($('.ui-sortable')) |
|
887 |
$('.ui-sortable').sortable({ |
|
888 |
stop : function(event, ui){ |
|
889 |
disabledBtnSortable($(this)); |
|
890 |
} |
|
891 |
}); |
|
892 |
||
893 |
$('.slider-duration').slider(configSlider); |
|
894 |
||
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
895 |
$(".tag-it").tagit(); |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
896 |
|
| 48 | 897 |
$('.log-annotations').bind('click', function(e){ |
898 |
e.preventDefault(); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
899 |
console.log(annotations.length + ' annotations', annotations); |
| 48 | 900 |
}); |
901 |
||
902 |
$('.log-chapters').bind('click', function(e){ |
|
903 |
e.preventDefault(); |
|
|
49
06627f23df42
show data annotations on tab open
Anthony Ly <anthonyly.com@gmail.com>
parents:
48
diff
changeset
|
904 |
console.log(chapters.length + ' chapitres',chapters); |
| 48 | 905 |
}); |
| 16 | 906 |
});//ready |