51 if(pos+wBtnCutChapter>wContainer){ |
51 if(pos+wBtnCutChapter>wContainer){ |
52 btnCutChapter.css("left",(pos - wBtnCutChapter)); |
52 btnCutChapter.css("left",(pos - wBtnCutChapter)); |
53 }else{ |
53 }else{ |
54 btnCutChapter.css("left",pos); |
54 btnCutChapter.css("left",pos); |
55 } |
55 } |
|
56 |
|
57 //annotations view |
|
58 var currentAnnotationsDisplay = new Array(); |
|
59 $.each(annotations, function(k, v){ |
|
60 |
|
61 if(v.begin <= t && v.end >= t){ |
|
62 currentAnnotationsDisplay.push(v.id); |
|
63 if(!$('#item-current-annotation-'+v.id).length){ |
|
64 var itemAnnotation = |
|
65 $('<li>') |
|
66 .attr('id', 'item-current-annotation-'+v.id) |
|
67 .attr('data-id', v.id) |
|
68 .append( |
|
69 $('<a>') |
|
70 .css('backgroundColor', v.color) |
|
71 .attr('data-id', v.id) |
|
72 .attr('href', '#') |
|
73 .append( |
|
74 $('<i>').addClass('icon-'+getIcon(v.type)) |
|
75 ) |
|
76 ); |
|
77 $('.list-current-annotations').append(itemAnnotation) |
|
78 } |
|
79 } |
|
80 }); |
|
81 $.each($('.list-current-annotations li'), function(k, v){ |
|
82 var idAnnotation = $(this).attr('data-id'), |
|
83 annotationDisplayView = $('.annotation-display-view'); |
|
84 if($.inArray(idAnnotation, currentAnnotationsDisplay)<0){//il ne doit plus être affiché |
|
85 $('#item-current-annotation-'+idAnnotation).remove(); |
|
86 if(annotationDisplayView.attr('data-id') == idAnnotation && annotationDisplayView.is(":visible")){ |
|
87 annotationDisplayView.hide(); |
|
88 } |
|
89 } |
|
90 }); |
|
91 |
|
92 |
56 });//timeupdate |
93 });//timeupdate |
57 |
94 |
58 });//myProject.onLoad |
95 });//myProject.onLoad |
59 |
96 |
60 |
97 //display annotation view |
61 //--modal |
98 $('.list-current-annotations').on('click', 'a', function(e){ |
|
99 e.preventDefault(); |
|
100 var annotationDisplayView = $('.annotation-display-view'), |
|
101 idAnnotation = $(this).attr('data-id'); |
|
102 var annotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
|
103 |
|
104 if(annotationDisplayView.attr('data-id') == idAnnotation && annotationDisplayView.is(":visible")){ |
|
105 annotationDisplayView.hide(); |
|
106 }else{ |
|
107 annotationDisplayView |
|
108 .attr('data-id', idAnnotation) |
|
109 .css('backgroundColor', annotation.color) |
|
110 .text(annotation.type) |
|
111 .show(); |
|
112 } |
|
113 }); |
|
114 |
|
115 //########### modal |
|
116 |
62 $(document).on('click', 'a.open-modal', function(e){ |
117 $(document).on('click', 'a.open-modal', function(e){ |
63 var diaporama = $(this).attr('data-diaporama'), |
118 var diaporama = $(this).attr('data-diaporama'), |
64 idAnnotation = $(this).attr('data-id'); |
119 idAnnotation = $(this).attr('data-id'); |
65 |
120 |
66 if(diaporama !== undefined){ |
121 if(diaporama !== undefined){ |
423 |
478 |
424 function openTab(type, data){ |
479 function openTab(type, data){ |
425 |
480 |
426 var dataView; |
481 var dataView; |
427 if(_.isUndefined(data)){//nouveau |
482 if(_.isUndefined(data)){//nouveau |
|
483 var currentTimePlusUnMin = 60 * 1000 + myMedia.currentTime, |
|
484 endAnnotation = (currentTimePlusUnMin<myMedia.duration) ? currentTimePlusUnMin : myMedia.duration; |
428 var dataAnnotation = { |
485 var dataAnnotation = { |
429 title : 'Nouveau', |
486 title : 'Nouveau', |
430 begin : 60 * 1000, |
487 begin : myMedia.currentTime, |
431 end : 60 * 1000 * 2, |
488 end : endAnnotation, |
432 description : 'description', |
489 description : 'description', |
433 type : type, |
490 type : type, |
434 keywords : [] |
491 keywords : [] |
435 }; |
492 }; |
436 dataView = newAnnotation(dataAnnotation); |
493 dataView = newAnnotation(dataAnnotation); |
459 $(tabContent).append(tpl); |
516 $(tabContent).append(tpl); |
460 $('.tab-content').append(tabContent); |
517 $('.tab-content').append(tabContent); |
461 |
518 |
462 //particularité selon type |
519 //particularité selon type |
463 switch(type){ |
520 switch(type){ |
464 case 'son': iconTab = 'volume-up'; |
521 case 'son': |
465 break; |
522 break; |
466 case 'video': iconTab = 'film'; |
523 case 'video': |
467 break; |
524 break; |
468 case 'text': |
525 case 'text': |
469 iconTab = 'align-left'; |
|
470 $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig); |
526 $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig); |
471 break; |
527 break; |
472 case 'html': iconTab = 'link'; |
528 case 'html': |
473 break; |
529 break; |
474 case 'diaporama': iconTab = 'picture'; |
530 case 'diaporama': |
475 $(tabContent).find('.number-spin').spin(spinParam); |
531 $(tabContent).find('.number-spin').spin(spinParam); |
476 $(tabContent).find('.ui-sortable').sortable({ |
532 $(tabContent).find('.ui-sortable').sortable({ |
477 stop : function(event, ui){ |
533 stop : function(event, ui){ |
478 disabledBtnSortable($(this)); |
534 disabledBtnSortable($(this)); |
479 } |
535 } |
480 }); |
536 }); |
481 break; |
537 break; |
482 } |
538 } |
483 |
539 |
484 dataView.iconTab = iconTab; |
540 dataView.iconTab = getIcon(type); |
485 var tplOnglet = $(templates).filter('#tpl-onglet').html(); |
541 var tplOnglet = $(templates).filter('#tpl-onglet').html(); |
486 var onglet = Mustache.render(tplOnglet, dataView); |
542 var onglet = Mustache.render(tplOnglet, dataView); |
487 |
543 |
488 $(".nav-tabs li:last-child").after(onglet); |
544 $(".nav-tabs li:last-child").after(onglet); |
489 $('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
545 $('a[href=#tab-annotation-'+idAnnotation+']').tab('show'); |
490 }); |
546 }); |
491 }//openTab() |
547 }//openTab() |
|
548 |
|
549 function getIcon(type){ |
|
550 var icon; |
|
551 switch(type){ |
|
552 case 'son': icon = 'volume-up'; |
|
553 break; |
|
554 case 'video': icon = 'film'; |
|
555 break; |
|
556 case 'text': |
|
557 icon = 'align-left'; |
|
558 break; |
|
559 case 'html': icon = 'link'; |
|
560 break; |
|
561 case 'diaporama': icon = 'picture'; |
|
562 break; |
|
563 } |
|
564 return icon; |
|
565 } |
492 |
566 |
493 //définit currentAnnotation quand la tab s'ouvre |
567 //définit currentAnnotation quand la tab s'ouvre |
494 $('#onglet-annotations').on('show', 'a[data-toggle="annotation"]', function (e) { |
568 $('#onglet-annotations').on('show', 'a[data-toggle="annotation"]', function (e) { |
495 var idAnnotation = $(e.target).attr('data-id'); |
569 var idAnnotation = $(e.target).attr('data-id'); |
496 currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
570 currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); |
638 |
712 |
639 } |
713 } |
640 }; |
714 }; |
641 |
715 |
642 } |
716 } |
643 //milliseconds To 12h12m12s |
|
644 function millisecondsToString(milliseconds) { |
|
645 var oneHour = 3600000; |
|
646 var oneMinute = 60000; |
|
647 var oneSecond = 1000; |
|
648 var seconds = 0; |
|
649 var minutes = 0; |
|
650 var hours = 0; |
|
651 var result; |
|
652 |
|
653 if (milliseconds >= oneHour) { |
|
654 hours = Math.floor(milliseconds / oneHour); |
|
655 } |
|
656 |
|
657 milliseconds = hours > 0 ? (milliseconds - hours * oneHour) : milliseconds; |
|
658 |
|
659 if (milliseconds >= oneMinute) { |
|
660 minutes = Math.floor(milliseconds / oneMinute); |
|
661 } |
|
662 |
|
663 milliseconds = minutes > 0 ? (milliseconds - minutes * oneMinute) : milliseconds; |
|
664 |
|
665 if (milliseconds >= oneSecond) { |
|
666 seconds = Math.floor(milliseconds / oneSecond); |
|
667 } |
|
668 |
|
669 milliseconds = seconds > 0 ? (milliseconds - seconds * oneSecond) : milliseconds; |
|
670 |
|
671 if (hours > 0) { |
|
672 result = (hours > 9 ? hours : "0" + hours) + "h"; |
|
673 } else { |
|
674 result = ""; |
|
675 } |
|
676 |
|
677 if (minutes > 0) { |
|
678 result += (minutes > 9 ? minutes : "0" + minutes) + "m"; |
|
679 } else { |
|
680 result += "00m"; |
|
681 } |
|
682 |
|
683 if (seconds > 0) { |
|
684 result += (seconds > 9 ? seconds : "0" + seconds) + "s"; |
|
685 } else { |
|
686 result += "00s"; |
|
687 } |
|
688 |
|
689 return result; |
|
690 } |
|
691 |
717 |
692 //test |
718 //test |
693 $(".wysiwyg").cleditor(wysiwygConfig); |
719 $(".wysiwyg").cleditor(wysiwygConfig); |
694 |
720 |
695 $('.number-spin').spin(spinParam); |
721 $('.number-spin').spin(spinParam); |