| author | Anthony Ly <anthonyly.com@gmail.com> |
| Wed, 22 May 2013 17:09:59 +0200 | |
| changeset 28 | a0a048ff33a1 |
| parent 23 | 2a3159ee4ed0 |
| child 34 | e3a17ec94cd8 |
| permissions | -rw-r--r-- |
| 28 | 1 |
var myMedia = null, |
2 |
currentChapter = null, |
|
3 |
chapters = [], |
|
4 |
annotations = []; |
|
5 |
||
| 9 | 6 |
$(function(){ |
| 6 | 7 |
|
8 |
var global = { |
|
9 |
diaporama : null, |
|
|
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 |
||
20 |
||
| 16 | 21 |
|
22 |
myProject.onLoad(function() { |
|
23 |
||
24 |
$(".project-title").text(myProject.title); |
|
25 |
|
|
26 |
myMedia = myProject.getCurrentMedia(); |
|
27 |
|
|
| 28 | 28 |
loadInitChapters(); |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
29 |
|
| 16 | 30 |
IriSP.htmlPlayer( |
31 |
myMedia, |
|
32 |
$(".main-video"), |
|
33 |
{ |
|
34 |
width: 460, |
|
35 |
height: 345, |
|
36 |
controls: true, |
|
37 |
autostart: true |
|
38 |
} |
|
39 |
); |
|
40 |
||
41 |
myMedia.on("timeupdate", function(t) { |
|
42 |
||
43 |
//curseur chapitre |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
44 |
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
|
45 |
pos = wContainer * t / myMedia.duration, |
| 16 | 46 |
btnCutChapter = $('.btn-cut-chapter'), |
47 |
wBtnCutChapter = btnCutChapter.outerWidth(); |
|
48 |
|
|
49 |
$(".indicateur-chapter").css("left",pos); |
|
50 |
if(pos+wBtnCutChapter>wContainer){ |
|
51 |
btnCutChapter.css("left",(pos - wBtnCutChapter)); |
|
52 |
}else{ |
|
53 |
btnCutChapter.css("left",pos); |
|
54 |
} |
|
| 18 | 55 |
});//timeupdate |
| 16 | 56 |
|
57 |
});//myProject.onLoad |
|
58 |
||
| 6 | 59 |
|
60 |
//modal |
|
| 9 | 61 |
$(document).on('click', 'a.open-modal', function(e){ |
62 |
var diaporama = $(this).attr('data-diaporama'), |
|
63 |
idAnnotation = $(this).attr('data-id'); |
|
64 |
||
65 |
if(diaporama !== undefined){ |
|
66 |
global.diaporama = diaporama; |
|
67 |
} |
|
68 |
if(idAnnotation !== undefined){ |
|
69 |
global.idAnnotation = idAnnotation; |
|
70 |
} |
|
| 22 | 71 |
}); |
72 |
||
| 6 | 73 |
//edition image |
74 |
$('.popup').on('change', '#media-type-select', function(e){ |
|
75 |
var typeImage = $(this).val(); |
|
76 |
$('.input-image-url, .input-image-upload').hide(); |
|
77 |
$('.input-image-'+typeImage).show(); |
|
78 |
}); |
|
| 22 | 79 |
|
| 6 | 80 |
//bibliotheque |
81 |
//video |
|
82 |
$('.popup').on('click', '.bibliotheque-video a', function(e){ |
|
83 |
e.preventDefault(); |
|
84 |
$('.popup').modal('hide'); |
|
85 |
$.get('template.html', function(templates){ |
|
86 |
var videoWrap = $('#'+global.idAnnotation).find('.annotation-video-content'), |
|
87 |
tplVideo = $(templates).filter('#tpl-video-row').html(); |
|
88 |
videoWrap.empty().append(tplVideo); |
|
89 |
}); |
|
90 |
|
|
91 |
}); |
|
92 |
//image |
|
93 |
$('.popup').on('click', '.bibliotheque-image a', function(e){ |
|
94 |
e.preventDefault(); |
|
95 |
var listDiaporama = $('#'+global.diaporama); |
|
96 |
addImageToDiaporama(listDiaporama); |
|
97 |
$('.popup').modal('hide'); |
|
98 |
}); |
|
99 |
||
| 22 | 100 |
$(document).on('click','.btn-delete-annotation', function(e){ |
| 6 | 101 |
e.preventDefault(); |
102 |
//si c'est une annotation et que la tab est ouverte, on la ferme |
|
103 |
var type = $(this).attr('data-type'); |
|
| 22 | 104 |
|
105 |
var idAnnotation = $(this).attr('data-id'); |
|
106 |
$('a[href=#annotation-'+idAnnotation+']').closest('li').remove(); |
|
107 |
$('.tab-content #annotation'+idAnnotation).remove(); |
|
108 |
$('#tab-list-annotation').tab('show'); |
|
109 |
|
|
| 6 | 110 |
}); |
111 |
||
112 |
//confirmation suppression |
|
113 |
$("#modal-confirm").on('click', '#btn-delete-modal', function(e){ |
|
| 9 | 114 |
|
| 6 | 115 |
}); |
116 |
||
117 |
//title-editor |
|
118 |
$('.project-title-editor ._popover').bind('click',function(e){e.preventDefault()}); |
|
119 |
$('.project-title-editor ._popover').popover({ |
|
120 |
html : true, |
|
121 |
content : function(){ |
|
122 |
var previousValue = $('.project-title').text(), |
|
123 |
formInput = |
|
124 |
'<form action="#" class="project-title-editor-form">'+ |
|
125 |
'<input type="text" class="project-title-editor-input" value="'+previousValue+'">'+ |
|
126 |
'</form>'; |
|
127 |
return formInput; |
|
128 |
} |
|
129 |
}); |
|
130 |
||
131 |
$('body').on('click', function (e) { |
|
132 |
$('._popover').each(function () { |
|
133 |
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { |
|
134 |
$(this).popover('hide'); |
|
135 |
} |
|
136 |
}); |
|
137 |
}); |
|
138 |
||
139 |
$('body').on('submit', '.project-title-editor-form', function(e){ |
|
140 |
e.preventDefault(); |
|
141 |
$('._popover').popover('hide'); |
|
142 |
}); |
|
143 |
||
144 |
$(document).on('keyup', '.project-title-editor-input', function() { |
|
145 |
$('.project-title').html($(this).val()); |
|
146 |
}); |
|
| 9 | 147 |
|
| 18 | 148 |
//--chapter |
| 22 | 149 |
|
150 |
//edit |
|
151 |
$('.list-chapter-wrap').on('click', '.btn-edit-chapter', function(e){ |
|
| 6 | 152 |
e.preventDefault(); |
| 22 | 153 |
var idChapter = $(this).attr('data-chapter-id'); |
154 |
loadFormChapter(idChapter); |
|
155 |
}); |
|
156 |
||
| 23 | 157 |
$('.chapter-segments').on('click', 'li', function(){ |
158 |
var idChapter = $(this).attr('id'); |
|
159 |
loadFormChapter(idChapter); |
|
160 |
}); |
|
| 22 | 161 |
|
162 |
$('.chapter-widget-info').on('keyup', 'input[name=title], textarea', function(e){ |
|
163 |
var name = $(this).attr('name'), |
|
164 |
value = $(this).val(); |
|
165 |
currentChapter[name] = value; |
|
166 |
if(name == 'title'){ |
|
167 |
var idChapter = $(this).parents('form').attr('data-chapter-id'); |
|
168 |
$('.chapter-segments').find('#'+idChapter).text(value); |
|
169 |
$('#row-list-chapter-'+idChapter).find('td:first').text(value); |
|
| 6 | 170 |
} |
| 22 | 171 |
}); |
172 |
||
173 |
function onTagItChange(e, ui) { |
|
174 |
var idChapter = $(this).parents('form').attr('data-chapter-id'), |
|
| 28 | 175 |
value = $('input[name=keywords]').val(); |
176 |
currentChapter.keywords = value; |
|
| 22 | 177 |
$('#row-list-chapter-'+idChapter).find('.list-chapter-tags').text(value); |
178 |
} |
|
179 |
||
180 |
var tagitParam = { |
|
181 |
afterTagRemoved : onTagItChange, |
|
182 |
afterTagAdded : onTagItChange |
|
183 |
} |
|
184 |
||
185 |
function loadFormChapter(idChapter){ |
|
| 28 | 186 |
currentChapter = _.find(chapters, function(c){ return c.id == idChapter; }); |
187 |
var chapterWrap = $('.chapter-widget-info'), |
|
188 |
indexChapter = _.indexOf(chapters, currentChapter), |
|
189 |
beginTangle = (indexChapter>0) ? true : false, |
|
190 |
endTangle = (indexChapter<(chapters.length-1)) ? true : false; |
|
| 22 | 191 |
|
| 28 | 192 |
currentChapter.beginTangle = beginTangle; |
193 |
currentChapter.endTangle = endTangle; |
|
| 22 | 194 |
|
| 6 | 195 |
$.get('template.html', function(templates){ |
196 |
var tpl = $(templates).filter('#tpl-chapter-edit').html(); |
|
| 28 | 197 |
tpl = Mustache.render(tpl, currentChapter); |
| 22 | 198 |
chapterWrap.empty().append(tpl); |
199 |
chapterWrap.find('.tag-it').tagit(tagitParam); |
|
| 6 | 200 |
}); |
| 22 | 201 |
} |
202 |
||
203 |
||
204 |
//supprimer |
|
205 |
$('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){ |
|
206 |
e.preventDefault(); |
|
207 |
||
208 |
if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;} |
|
| 28 | 209 |
|
| 22 | 210 |
var idChapter = $(this).attr('data-chapter-id'), |
211 |
chapter = _.find(chapters, function(c){ return c.id == idChapter; }), |
|
212 |
indexChapter = _.indexOf(chapters, chapter), |
|
213 |
chapterModify; |
|
214 |
if(indexChapter == 0){ |
|
215 |
chapterModify = chapters[1]; |
|
| 28 | 216 |
chapterModify.setBegin(0); |
| 22 | 217 |
}else{ |
218 |
chapterModify = chapters[indexChapter-1]; |
|
| 28 | 219 |
//var newEnd = new IriSP.Model.Time(chapter.end) |
220 |
chapterModify.setEnd(chapter.end); |
|
| 22 | 221 |
} |
222 |
chapters = _(chapters).reject(function(c) { return c.id == idChapter; }); |
|
223 |
renderChapter(); |
|
224 |
//si le formulaire est visible |
|
225 |
if($('#form-chapter-edit-'+idChapter).length){ |
|
226 |
$('#form-chapter-edit-'+idChapter).remove(); |
|
227 |
} |
|
228 |
}); |
|
229 |
||
230 |
//nouveau chapitre |
|
| 28 | 231 |
function newChapter(dataChapter){ |
232 |
var chapter = new IriSP.Model.Annotation(false, myProject); |
|
233 |
chapter.setMedia(myMedia.id); |
|
234 |
chapter.setBegin(dataChapter.begin); |
|
235 |
chapter.setEnd(dataChapter.end); |
|
236 |
chapter.title = dataChapter.title; |
|
237 |
chapter.description = dataChapter.description; |
|
238 |
chapter.keywords = dataChapter.keywords; |
|
239 |
chapter.color = global.colors[(global.colorsIndex<global.colors.length) ? global.colorsIndex++ : (global.colorsIndex=0)]; |
|
240 |
|
|
241 |
chapters.push(chapter); |
|
242 |
renderChapter(); |
|
243 |
loadFormChapter(chapter.id); |
|
244 |
} |
|
245 |
||
| 6 | 246 |
$('.chapter-widget').on('click', '.btn-cut-chapter', function(e){ |
247 |
e.preventDefault(); |
|
| 16 | 248 |
|
| 28 | 249 |
var dataChapter = { |
250 |
title : 'New', |
|
251 |
begin : myMedia.currentTime, |
|
252 |
end : organizeNewChapter(myMedia.currentTime), |
|
253 |
description : 'description', |
|
254 |
keywords : 'tag1,tag2' |
|
255 |
}; |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
256 |
|
| 28 | 257 |
newChapter(dataChapter); |
258 |
||
| 6 | 259 |
}); |
| 22 | 260 |
|
261 |
function organizeNewChapter(beginNew){ |
|
| 6 | 262 |
|
| 22 | 263 |
var returnEnd; |
264 |
$.each(chapters, function(k, v){ |
|
265 |
var begin = v.begin, |
|
266 |
end = v.end; |
|
267 |
if(beginNew>=begin && beginNew<=end){ |
|
| 28 | 268 |
returnEnd = new IriSP.Model.Time(end); |
269 |
v.setEnd(beginNew); |
|
| 22 | 270 |
} |
271 |
}); |
|
| 28 | 272 |
|
| 22 | 273 |
return returnEnd; |
274 |
} |
|
275 |
|
|
276 |
function renderChapter(){ |
|
277 |
var chapterSegmentWrap = $('.chapter-segments'), |
|
278 |
wChapterSegmentWrap = chapterSegmentWrap.width(), |
|
279 |
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
|
280 |
|
| 22 | 281 |
chapters = _.sortBy(chapters, function(c){ |
282 |
return c.begin; |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
283 |
}); |
| 18 | 284 |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
285 |
chapterSegmentWrap.empty(); |
| 22 | 286 |
chapterList.empty(); |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
287 |
|
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
288 |
$.each(chapters, function(k, v){ |
| 28 | 289 |
//form |
290 |
if($('#form-chapter-edit-'+v.id).length){ |
|
291 |
loadFormChapter(v.id); |
|
292 |
} |
|
| 22 | 293 |
//segments |
| 28 | 294 |
var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration), |
| 22 | 295 |
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
|
296 |
width : width, |
| 22 | 297 |
backgroundColor : v.color |
298 |
}).attr('id', v.id); |
|
299 |
|
|
300 |
chapterSegmentWrap.append(segment); |
|
| 28 | 301 |
|
| 22 | 302 |
//liste |
303 |
$.get('template.html', function(templates){ |
|
304 |
var tplChapterRow = $(templates).filter('#tpl-chapter-row').html(); |
|
305 |
tplChapterRow = Mustache.render(tplChapterRow, v); |
|
306 |
chapterList.append(tplChapterRow); |
|
307 |
||
308 |
}); |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
309 |
}); |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
310 |
} |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
311 |
|
| 22 | 312 |
//init |
| 28 | 313 |
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
|
314 |
var dataChapter = { |
| 28 | 315 |
title : 'New', |
316 |
begin : 0, |
|
317 |
end : myMedia.duration, |
|
318 |
description : 'description', |
|
319 |
keywords : 'tag1,tag2' |
|
320 |
}; |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
321 |
|
| 28 | 322 |
newChapter(dataChapter); |
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
323 |
} |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
324 |
|
| 22 | 325 |
|
326 |
||
327 |
||
| 6 | 328 |
//edit annotation |
329 |
$('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){ |
|
330 |
e.preventDefault(); |
|
331 |
||
332 |
var idAnnotation = $(this).attr('data-id'); |
|
333 |
//si il est déjà ouvert |
|
334 |
if($('#annotation-'+idAnnotation).length){ |
|
335 |
$('a[href=#annotation-'+idAnnotation+']').tab('show'); |
|
336 |
}else{ |
|
337 |
var typeAnnotation = $(this).attr('data-type'), |
|
338 |
data = {id:idAnnotation}; |
|
339 |
openNewTab(typeAnnotation, data); |
|
340 |
} |
|
341 |
}); |
|
342 |
||
| 9 | 343 |
//tab |
344 |
$('#annotation-tab').on('click', 'a', function(e){ |
|
345 |
e.preventDefault(); |
|
346 |
$(this).tab('show'); |
|
347 |
}); |
|
348 |
||
349 |
//ouvrir tab |
|
350 |
$(document).on('click', '.open-tab', function(e){ |
|
351 |
e.preventDefault(); |
|
352 |
var type = $(this).attr('data-type'); |
|
353 |
var data = $(this).attr('data-data'); // à définir |
|
354 |
openNewTab(type); |
|
355 |
}); |
|
356 |
||
| 6 | 357 |
function openNewTab(type, data){ |
358 |
||
359 |
var uniqId = 'id' + (new Date()).getTime(), |
|
360 |
idAnnotation = (data !== undefined) ? data.id : uniqId, |
|
361 |
tabContent = $('<div class="tab-pane" id="annotation-'+idAnnotation+'"></div>'), |
|
362 |
iconTab; |
|
363 |
||
364 |
||
365 |
$.get('template.html', function(templates){ |
|
366 |
//head commun à tous |
|
367 |
var view = { |
|
368 |
titre : "un titre mustache", |
|
369 |
id : uniqId |
|
370 |
}; |
|
371 |
var tplHead = $(templates).filter('#tpl-head').html(); |
|
372 |
var output = Mustache.render(tplHead, view); |
|
373 |
$(tabContent).append(output); |
|
374 |
$(tabContent).find(".slider-duration").slider(configSlider); |
|
375 |
||
376 |
//type |
|
377 |
var viewType = {id : uniqId}; |
|
378 |
var tpl = $(templates).filter('#tpl-'+type).html(); |
|
379 |
tpl = Mustache.render(tpl, viewType); |
|
380 |
$(tabContent).append(tpl); |
|
381 |
$('.tab-content').append(tabContent); |
|
382 |
||
383 |
//particularité selon type |
|
384 |
switch(type){ |
|
385 |
case 'video': iconTab = 'film'; |
|
386 |
break; |
|
387 |
case 'text': |
|
388 |
iconTab = 'align-left'; |
|
389 |
$(tabContent).find('.wysiwyg').cleditor(wysiwygConfig); |
|
390 |
break; |
|
391 |
case 'html': iconTab = 'link'; |
|
392 |
break; |
|
393 |
case 'diaporama': iconTab = 'picture'; |
|
394 |
$(tabContent).find('.number-spin').spin(spinParam); |
|
395 |
$(tabContent).find('.ui-sortable').sortable({ |
|
396 |
stop : function(event, ui){ |
|
397 |
disabledBtnSortable($(this)); |
|
398 |
} |
|
399 |
}); |
|
400 |
break; |
|
401 |
} |
|
402 |
$(".nav-tabs li:last-child").after('<li><a href="#annotation-'+idAnnotation+'"><i class="icon-'+iconTab+'"></i> New <span class="close-tab">×</span></a></li>'); |
|
403 |
$('a[href=#annotation-'+idAnnotation+']').tab('show'); |
|
404 |
}); |
|
405 |
}//openNewTab() |
|
406 |
||
| 9 | 407 |
//fermer tab |
408 |
$('#annotation-tab').on('click', 'span.close-tab', function(e){ |
|
409 |
e.preventDefault();e.stopPropagation(); |
|
410 |
var idTab = $(this).parents('a').attr('href'); |
|
411 |
$(this).closest('li').remove(); |
|
412 |
$('.tab-content '+idTab).remove(); |
|
413 |
$('#tab-list-annotation').tab('show'); |
|
414 |
}); |
|
415 |
||
416 |
||
| 6 | 417 |
//diaporama |
| 9 | 418 |
function addImageToDiaporama(diaporama){ |
| 6 | 419 |
$.get('template.html', function(templates){ |
420 |
var tplDiapo = $(templates).filter('#tpl-diaporama-row').html(), |
|
421 |
uniqId = 'id' + (new Date()).getTime(), |
|
422 |
viewDiapo = { ridid : uniqId}; |
|
423 |
tplDiapo = Mustache.render(tplDiapo, viewDiapo); |
|
424 |
diaporama.append(tplDiapo); |
|
425 |
disabledBtnSortable(diaporama); |
|
426 |
}); |
|
427 |
}; |
|
428 |
||
| 9 | 429 |
//bouton up / down |
| 6 | 430 |
$(document).on('click', '.ui-sortable .btn-sort', function(e){ |
431 |
e.preventDefault(); |
|
432 |
var row = $(this).parents('tr.row-image-diaporama'), |
|
433 |
listDiaporama = $(this).parents('.list-image-diaporama'); |
|
434 |
||
435 |
if($(this).hasClass('down')) |
|
436 |
row.insertAfter(row.next()); |
|
437 |
else if($(this).hasClass('up')) |
|
438 |
row.insertBefore(row.prev()); |
|
439 |
||
440 |
disabledBtnSortable(listDiaporama); |
|
441 |
}); |
|
442 |
||
443 |
function disabledBtnSortable(listDiaporama){ |
|
444 |
listDiaporama.find('.btn-sort.disabled').removeClass('disabled'); |
|
445 |
listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled'); |
|
446 |
listDiaporama.find('tr.row-image-diaporama:last-child').find('.btn-sort.down').addClass('disabled'); |
|
447 |
} |
|
448 |
||
| 9 | 449 |
|
| 6 | 450 |
|
451 |
//sauvegarder annotation |
|
452 |
$('.tab-content').on('click', '.btn-save-annotation', function(e){ |
|
453 |
e.preventDefault(); |
|
454 |
var idAnnotation = $(this).attr('data-id'); |
|
455 |
}); |
|
456 |
||
457 |
//annotation html |
|
458 |
$('.tab-content').on('click', '.btn-html-apercu', function(e){ |
|
459 |
e.preventDefault(); |
|
460 |
||
461 |
var apercuWrap = $(this).parents('.edit-annotation-html').find('.html-apercu'), |
|
462 |
htmlTextarea = $(this).parents('.edit-annotation-html').find('textarea'); |
|
463 |
||
464 |
apercuWrap.empty().html(htmlTextarea.val()); |
|
465 |
}); |
|
466 |
||
467 |
//annotation > diaporama (spin) |
|
| 16 | 468 |
|
| 6 | 469 |
|
470 |
//config |
|
471 |
//CLEditor annotation > text (wysiwyg) |
|
472 |
//http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters |
|
473 |
var wysiwygConfig = { |
|
474 |
width: 456, |
|
475 |
height: 250, |
|
476 |
controls: "bold italic underline strikethrough | font size " + |
|
477 |
"style | color highlight removeformat | bullets numbering | outdent ", |
|
478 |
fonts: "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," + |
|
479 |
"Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana", |
|
480 |
sizes: "1,2,3,4,5,6,7", |
|
481 |
styles: [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"], |
|
482 |
["Header 3", "<h3>"], ["Header 4","<h4>"], ["Header 5","<h5>"], |
|
483 |
["Header 6","<h6>"]], |
|
484 |
docType: '<!DOCTYPE HTML>', |
|
485 |
bodyStyle: "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;" |
|
486 |
}; |
|
487 |
||
488 |
//slider |
|
489 |
var configSlider = { |
|
490 |
range: true, |
|
491 |
values: [ 0, 1*60*1000 ], |
|
492 |
min: 0, |
|
493 |
max: 10*60*1000, |
|
494 |
slide: function( event, ui ) { |
|
495 |
|
|
496 |
var debutString = millisecondsToString(ui.values[0]); |
|
497 |
var endString = millisecondsToString(ui.values[1]); |
|
498 |
var durationString = millisecondsToString(ui.values[1] - ui.values[0]); |
|
499 |
||
500 |
var idSlider = $(this).attr('data-id'); |
|
501 |
|
|
502 |
$( '#'+ idSlider +'-begin' ).html(debutString); |
|
503 |
$( '#'+ idSlider +'-duration' ).html(durationString); |
|
504 |
$( '#'+ idSlider +'-end' ).html(endString); |
|
505 |
|
|
506 |
} |
|
507 |
}; |
|
508 |
||
| 9 | 509 |
//milliseconds To 12h12m12s |
| 6 | 510 |
function millisecondsToString(milliseconds) { |
511 |
var oneHour = 3600000; |
|
512 |
var oneMinute = 60000; |
|
513 |
var oneSecond = 1000; |
|
514 |
var seconds = 0; |
|
515 |
var minutes = 0; |
|
516 |
var hours = 0; |
|
517 |
var result; |
|
518 |
||
519 |
if (milliseconds >= oneHour) { |
|
520 |
hours = Math.floor(milliseconds / oneHour); |
|
521 |
} |
|
522 |
||
523 |
milliseconds = hours > 0 ? (milliseconds - hours * oneHour) : milliseconds; |
|
524 |
||
525 |
if (milliseconds >= oneMinute) { |
|
526 |
minutes = Math.floor(milliseconds / oneMinute); |
|
527 |
} |
|
528 |
||
529 |
milliseconds = minutes > 0 ? (milliseconds - minutes * oneMinute) : milliseconds; |
|
530 |
||
531 |
if (milliseconds >= oneSecond) { |
|
532 |
seconds = Math.floor(milliseconds / oneSecond); |
|
533 |
} |
|
534 |
||
535 |
milliseconds = seconds > 0 ? (milliseconds - seconds * oneSecond) : milliseconds; |
|
536 |
||
537 |
if (hours > 0) { |
|
538 |
result = (hours > 9 ? hours : "0" + hours) + "h"; |
|
539 |
} else { |
|
540 |
result = ""; |
|
541 |
} |
|
542 |
||
543 |
if (minutes > 0) { |
|
544 |
result += (minutes > 9 ? minutes : "0" + minutes) + "m"; |
|
545 |
} else { |
|
546 |
result += "00m"; |
|
547 |
} |
|
548 |
||
549 |
if (seconds > 0) { |
|
550 |
result += (seconds > 9 ? seconds : "0" + seconds) + "s"; |
|
551 |
} else { |
|
552 |
result += "00s"; |
|
553 |
} |
|
554 |
||
555 |
return result; |
|
556 |
} |
|
| 9 | 557 |
|
558 |
//test |
|
559 |
$(".wysiwyg").cleditor(wysiwygConfig); |
|
560 |
||
561 |
$('.number-spin').spin(spinParam); |
|
562 |
||
563 |
disabledBtnSortable($('.ui-sortable')) |
|
564 |
$('.ui-sortable').sortable({ |
|
565 |
stop : function(event, ui){ |
|
566 |
disabledBtnSortable($(this)); |
|
567 |
} |
|
568 |
}); |
|
569 |
||
570 |
$('.slider-duration').slider(configSlider); |
|
571 |
||
572 |
$('#annotation-tab a:last-child').tab('show'); |
|
573 |
||
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
574 |
$(".tag-it").tagit(); |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
18
diff
changeset
|
575 |
|
| 16 | 576 |
});//ready |