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