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