integration/js/edition.js
changeset 62 42919bf5d4e1
parent 58 9e14b6f964fe
child 70 2542e988f80c
equal deleted inserted replaced
58:9e14b6f964fe 62:42919bf5d4e1
     5     annotations = [];
     5     annotations = [];
     6 
     6 
     7 $(function(){
     7 $(function(){
     8 
     8 
     9 var global = {
     9 var global = {
    10     idAnnotation : null,
       
    11     colorsIndex : 0,
    10     colorsIndex : 0,
    12     colors : 
    11     colors : 
    13         ['#f39c12', '#2ecc71', '#3498db', '#9b59b6',  
    12         ['#f39c12', '#2ecc71', '#3498db', '#9b59b6',  
    14         '#f1c40f', '#e67e22', '#e74c3c', '#ecf0f1', 
    13         '#f1c40f', '#e67e22', '#e74c3c', 
    15         '#16a085', '#27ae60', '#2980b9', '#8e44ad', 
    14         '#16a085', '#27ae60', '#2980b9', '#8e44ad', 
    16         '#f39c12', '#d35400', '#c0392b', '#bdc3c7']
    15          '#d35400', '#c0392b', '#bdc3c7']
    17 };
    16 };
    18 
    17 
    19 
    18 
    20 //position de la video setCurrentTime
    19 //position de la video setCurrentTime
    21 $(".indicateur-annotation").draggable({
    20 $(".indicateur-annotation").draggable({
    33 });
    32 });
    34 
    33 
    35 myProject.onLoad(function() {
    34 myProject.onLoad(function() {
    36 
    35 
    37     $(".project-title").text(myProject.title);
    36     $(".project-title").text(myProject.title);
    38     
    37     $('.project-title-nav').text(myProject.title);
       
    38 
    39     myMedia = myProject.getCurrentMedia();
    39     myMedia = myProject.getCurrentMedia();
    40 
    40 
    41 //load Chapitre
    41 //load Chapitre
    42 var _chapters = myProject.getAnnotationsByTypeTitle("chapitrage");
    42 var _chapters = myProject.getAnnotationsByTypeTitle("chapitrage");
    43 if(_chapters.length){
    43 if(_chapters.length){
    65             renderAnnotation();
    65             renderAnnotation();
    66         }
    66         }
    67 
    67 
    68     });
    68     });
    69 }
    69 }
    70 
       
    71 
       
    72     //chargement des chapitres et annotations existants
       
    73   //  loadInitChapters();
       
    74     //loadInitAnnotation();
       
    75 
    70 
    76     IriSP.htmlPlayer(
    71     IriSP.htmlPlayer(
    77         myMedia,
    72         myMedia,
    78         $(".main-video"),
    73         $(".main-video"),
    79         {
    74         {
   167 });
   162 });
   168 
   163 
   169 //########### modal
   164 //########### modal
   170 
   165 
   171     $(document).on('click', 'a.open-modal', function(e){
   166     $(document).on('click', 'a.open-modal', function(e){
   172         var idAnnotation = $(this).attr('data-id');
   167 
   173 
       
   174 
       
   175         if(idAnnotation !== undefined){
       
   176             global.idAnnotation = idAnnotation;
       
   177         }
       
   178     });
   168     });
   179 
   169 
   180 //edition image
   170 //edition image
   181     $('.popup').on('change', '#media-type-select', function(e){
   171     $('.popup').on('change', '#media-type-select', function(e){
   182         var typeImage = $(this).val();
   172         var typeImage = $(this).val();
   193     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   183     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   194 
   184 
   195     });
   185     });
   196 
   186 
   197 //--title-editor
   187 //--title-editor
   198 $('.project-title-editor ._popover').bind('click',function(e){e.preventDefault()});
   188     $(document).on('click', '.project-title-editor i, .project-title', function () {
   199     $('.project-title-editor ._popover').popover({
   189         var html = $('.project-title').html();
   200         html : true,
   190         var input = $('<input type="text" />');
   201         content : function(){
   191         input.val(html);
   202             var previousValue = $('.project-title').text(),
   192         $('.project-title').replaceWith(input);
   203                 formInput = 
   193         input.focus();
   204                     '<form action="#" class="project-title-editor-form">'+
   194     });
   205                         '<input type="text" class="project-title-editor-input" value="'+previousValue+'">'+
   195     $(document).on('blur', '.project-title-editor input', function(){
   206                     '</form>';
   196         var newTitle = $(this).val();
   207             return formInput;
   197         myProject.title = newTitle;
   208         }
   198         $(this).replaceWith('<span class="project-title">'+newTitle+'</span></td>');
   209     });
   199         $('.project-title-nav').text(newTitle);
   210 
   200     });
   211     $('body').on('click', function (e) {
   201 
   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     });
       
   227 
   202 
   228 //######################## chapter
   203 //######################## chapter
   229 
   204 
   230 //edit
   205 //edit
   231     $('.list-chapter-wrap').on('click', '.btn-edit-chapter', function(e){
   206     $('.list-chapter-wrap').on('click', '.btn-edit-chapter', function(e){
   263             endTangle = (indexChapter<(chapters.length-1)) ? true : false;
   238             endTangle = (indexChapter<(chapters.length-1)) ? true : false;
   264 
   239 
   265         currentChapter.beginTangle = beginTangle;
   240         currentChapter.beginTangle = beginTangle;
   266         currentChapter.endTangle = endTangle;
   241         currentChapter.endTangle = endTangle;
   267 
   242 
   268         $.get('template.html', function(templates){
   243         var tpl = getTemplate('#tpl-chapter-edit');
   269             var tpl = $(templates).filter('#tpl-chapter-edit').html();
       
   270             tpl = Mustache.render(tpl, currentChapter);
   244             tpl = Mustache.render(tpl, currentChapter);
   271             chapterWrap.empty().append(tpl);
   245             chapterWrap.empty().append(tpl);
   272             chapterWrap.find('.tag-it').tagit(tagitParam);
   246             chapterWrap.find('.tag-it').tagit(tagitParam);
   273         });
       
   274 
   247 
   275         myMedia.setCurrentTime(currentChapter.begin);
   248         myMedia.setCurrentTime(currentChapter.begin);
   276     }
   249     }
   277 
   250 
   278 
   251     function getTemplate(idTpl){
       
   252         return $('#templates').find(idTpl).html();
       
   253     }
   279 //supprimer
   254 //supprimer
   280 $('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){
   255 $('.list-chapter-wrap').on('click', '.btn-delete-chapter', function(e){
   281     e.preventDefault();
   256     e.preventDefault();
   282 
   257 
   283     if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;}
   258     if(chapters.length == 1){alert('Le projet doit contenir au moins un chapitre.'); return;}
   360             return c.begin;
   335             return c.begin;
   361         });
   336         });
   362 
   337 
   363         chapterSegmentWrap.empty();
   338         chapterSegmentWrap.empty();
   364         chapterList.empty();
   339         chapterList.empty();
   365         $.get('template.html', function(templates){
   340        
   366             $.each(chapters, function(k, v){
   341             $.each(chapters, function(k, v){
   367 
   342 
   368                 //segments
   343                 //segments
   369                 var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration),
   344                 var width = Math.floor(v.getDuration() * wChapterSegmentWrap / myMedia.duration),
   370                     segment = $('<li>'+v.title+'</li>').css({
   345                     segment = $('<li>'+v.title+'</li>').css({
   373                     }).attr('id', v.id);
   348                     }).attr('id', v.id);
   374         
   349         
   375                 chapterSegmentWrap.append(segment);
   350                 chapterSegmentWrap.append(segment);
   376 
   351 
   377                 //liste
   352                 //liste
   378                 var tplChapterRow = $(templates).filter('#tpl-chapter-row').html();
   353                 var tplChapterRow = getTemplate('#tpl-chapter-row');
   379                 tplChapterRow = Mustache.render(tplChapterRow, v);
   354                 tplChapterRow = Mustache.render(tplChapterRow, v);
   380                 chapterList.append(tplChapterRow);
   355                 chapterList.append(tplChapterRow);
   381             });
   356             });
   382         });
   357      
   383     }//renderChapter()
   358     }//renderChapter()
   384 
   359 
   385 //init
       
   386     function loadInitChapters(){//nouveau projet, 1 chapitre
       
   387         var dataChapter = {
       
   388                 title : 'New',
       
   389                 begin : 0,
       
   390                 end : myMedia.duration,
       
   391                 description : 'description',
       
   392                 keywords : ['tag1','tag2']
       
   393             };
       
   394 
       
   395         newChapter(dataChapter);
       
   396     }
       
   397 
   360 
   398 
   361 
   399 //######################## annotation
   362 //######################## annotation
   400     
   363     
   401     function loadInitAnnotation(){//nouveau projet, 1 chapitre
       
   402         var dataAnnotation = {
       
   403                 title : 'Titre azerty',
       
   404                 begin : myMedia.duration/5,
       
   405                 end : myMedia.duration/3,
       
   406                 description : 'description',
       
   407                 type : 'video',
       
   408                 keywords : ['ideal', 'tag']
       
   409             };
       
   410 
       
   411         newAnnotation(dataAnnotation);
       
   412         renderAnnotation();
       
   413     }
       
   414 
   364 
   415     function newAnnotation(dataAnnotation){
   365     function newAnnotation(dataAnnotation){
   416         var annotation = new IriSP.Model.Annotation(false, myProject);
   366         var annotation = new IriSP.Model.Annotation(false, myProject);
   417             annotation.setMedia(myMedia.id);
   367             annotation.setMedia(myMedia.id);
   418             annotation.setBegin(dataAnnotation.begin);
   368             annotation.setBegin(dataAnnotation.begin);
   436 
   386 
   437         annotations = _.sortBy(annotations, function(c){
   387         annotations = _.sortBy(annotations, function(c){
   438             return c.begin;
   388             return c.begin;
   439         });
   389         });
   440 
   390 
   441         timeline.empty();
   391         timeline.empty().append('<li>');
   442         annotationList.empty();
   392         annotationList.empty();
   443 
   393 
   444         $.each(annotations, function(k, v){
   394         $.each(annotations, function(k, v){
   445 
   395 
   446             //timeline
   396             //timeline
   449                 segment = $('<div>').css({
   399                 segment = $('<div>').css({
   450                     left : left,
   400                     left : left,
   451                     width : width,
   401                     width : width,
   452                     backgroundColor : v.color
   402                     backgroundColor : v.color
   453                 }).addClass('annotation').attr('id', 'annotation-timeline-'+v.id);
   403                 }).addClass('annotation').attr('id', 'annotation-timeline-'+v.id);
   454     
   404 
   455             timeline.append(segment);
   405             var isInTimeline = false;
       
   406             $.each(timeline.find('li'), function(a, b){
       
   407                 if(isInTimeline) return;
       
   408                 var row = $(this);
       
   409                 if(row.children().length){
       
   410                     var canBeInRow = true;
       
   411                     $.each(row.find('.annotation'), function(c, d){
       
   412                         var oAL = parseInt($(d).css('left')),
       
   413                             oAR = oAL + $(d).width(),
       
   414                             segmentR = left + width;
       
   415                         if(oAL<=left && oAR>=left || oAL<=segmentR && oAR>= segmentR){
       
   416                             canBeInRow = false;
       
   417                         }
       
   418                     });
       
   419                     if(canBeInRow){
       
   420                         row.append(segment);
       
   421                         isInTimeline = true;
       
   422                     }
       
   423                 }else{
       
   424                     row.append(segment);
       
   425                     isInTimeline = true;
       
   426                 }
       
   427             });
       
   428 
       
   429             if(!isInTimeline){
       
   430                 timeline.append('<li>');
       
   431                 timeline.find('li:last-child').append(segment);
       
   432             }
       
   433             
   456            
   434            
   457             //liste
   435             //liste
   458             $.get('template.html', function(templates){
   436                 var tplAnnotationRow = getTemplate('#tpl-list-annotation-row');
   459                 var tplAnnotationRow = $(templates).filter('#tpl-list-annotation-row').html();
       
   460                 tplAnnotationRow = Mustache.render(tplAnnotationRow, v);
   437                 tplAnnotationRow = Mustache.render(tplAnnotationRow, v);
   461                 annotationList.append(tplAnnotationRow);
   438                 annotationList.append(tplAnnotationRow);
   462 
   439 
   463             });
       
   464 
       
   465         });
   440         });
   466     }
   441 
       
   442 
       
   443     }//renderAnnotation
   467 
   444 
   468     //edit annotation
   445     //edit annotation
   469     $('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){
   446     $('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){
   470         e.preventDefault();
   447         e.preventDefault();
   471 
   448 
   538             tabContent = $('<div class="tab-pane" id="tab-annotation-'+idAnnotation+'"></div>'),
   515             tabContent = $('<div class="tab-pane" id="tab-annotation-'+idAnnotation+'"></div>'),
   539             iconTab;
   516             iconTab;
   540 
   517 
   541         currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
   518         currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
   542 
   519 
   543         $.get('template.html', function(templates){
   520       
   544 
   521 
   545             //head commun à tous
   522             //head commun à tous
   546             var tplHead = $(templates).filter('#tpl-head').html();
   523             var tplHead = getTemplate('#tpl-head');
   547             var output = Mustache.render(tplHead, dataView);
   524             var output = Mustache.render(tplHead, dataView);
   548             $(tabContent).append(output);
   525             $(tabContent).append(output);
   549             $(tabContent).find(".slider-duration").slider(configSlider(dataView));
   526             $(tabContent).find(".slider-duration").slider(configSlider(dataView));
   550             $(tabContent).find('.tag-it').tagit(tagitParam);
   527             $(tabContent).find('.tag-it').tagit(tagitParam);
   551             //type
   528             //type
   552             var viewType = {
   529             var viewType = {
   553                 id : idAnnotation,
   530                 id : idAnnotation,
   554                 content : dataView.content
   531                 content : dataView.content
   555             };
   532             };
   556             var tpl = $(templates).filter('#tpl-'+type).html();
   533             var tpl = getTemplate('#tpl-'+type);
   557 
   534 
   558             tpl = Mustache.render(tpl, viewType);
   535             tpl = Mustache.render(tpl, viewType);
   559             $(tabContent).append(tpl);
   536             $(tabContent).append(tpl);
   560             $('.tab-content').append(tabContent);
   537             $('.tab-content').append(tabContent);
   561 
   538 
   564                 case 'audio':
   541                 case 'audio':
   565                     break;
   542                     break;
   566                 case 'video':
   543                 case 'video':
   567                     
   544                     
   568                     if(viewType.content.url != ""){
   545                     if(viewType.content.url != ""){
   569                    /*
   546 
   570                         var videoWrap = $(tabContent).find('.annotation-video-content'),
   547                         var videoWrap = $(tabContent).find('.annotation-video-content');
   571                             tplVideo = $(templates).filter('#tpl-video-row').html();
       
   572                         tplVideo = Mustache.render(tplVideo, viewType.content);
       
   573                         videoWrap.empty().append(tplVideo);
       
   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);
   548                         renderVideoInfo(videoWrap, viewType.content);
   582    
   549    
   583                     }
   550                     }
   584 
   551 
   585                     
   552                     
   625                     }
   592                     }
   626                     break;
   593                     break;
   627             }
   594             }
   628 
   595 
   629             dataView.iconTab = getIcon(type);
   596             dataView.iconTab = getIcon(type);
   630             var tplOnglet = $(templates).filter('#tpl-onglet').html();
   597             var tplOnglet = getTemplate('#tpl-onglet');
   631             var onglet = Mustache.render(tplOnglet, dataView);
   598             var onglet = Mustache.render(tplOnglet, dataView);
   632 
   599 
   633             $(".nav-tabs li:last-child").after(onglet);
   600             $(".nav-tabs li:last-child").after(onglet);
   634             $('a[href=#tab-annotation-'+idAnnotation+']').tab('show');
   601             $('a[href=#tab-annotation-'+idAnnotation+']').tab('show');
   635         });
   602   
   636     }//openTab()
   603     }//openTab()
   637 
   604 
   638     function getIcon(type){
   605     function getIcon(type){
   639         var icon;
   606         var icon;
   640         switch(type){
   607         switch(type){
   641             case 'audio': icon = 'volume-up';
   608             case 'audio': icon = 'volume-up';
   642                 break;
   609                 break;
   643             case 'video': icon = 'film';
   610             case 'video': icon = 'film';
   644                 break;
   611                 break;
   645             case 'text': 
   612             case 'text': icon = 'align-left';
   646                 icon = 'align-left';
       
   647                 break;
   613                 break;
   648             case 'html': icon = 'code';
   614             case 'html': icon = 'code';
   649                 break;
   615                 break;
   650             case 'links': icon = 'link';
   616             case 'links': icon = 'link';
   651                 break;
   617                 break;
   685         $('#tab-list-annotation').tab('show');
   651         $('#tab-list-annotation').tab('show');
   686     }
   652     }
   687 
   653 
   688 //video
   654 //video
   689     function renderVideoInfo(videoWrap, dataVideo){
   655     function renderVideoInfo(videoWrap, dataVideo){
   690         $.get('template.html', function(templates){
   656     
   691             var tplVideo = $(templates).filter('#tpl-video-row').html();
   657         var tplVideo = getTemplate('#tpl-video-row');
   692             tplVideo = Mustache.render(tplVideo, dataVideo);
   658         tplVideo = Mustache.render(tplVideo, dataVideo);
   693             
   659         
   694             videoWrap.empty().append(tplVideo);
   660         videoWrap.empty().append(tplVideo);
   695 
   661 
   696             videoWrap = videoWrap.find(".video-container");
   662         videoWrap = videoWrap.find(".video-container");
   697             getVideoPlayer(dataVideo.url, videoWrap);
   663         getVideoPlayer(dataVideo.url, videoWrap);
   698         });
   664      
   699     }
   665     }
   700     $('.popup').on('click', '.bibliotheque-video a', function(e){
   666     $('.popup').on('click', '.bibliotheque-video a', function(e){
   701         e.preventDefault();
   667         e.preventDefault();
   702 
   668 
   703         var url = $(this).attr('data-url'),
   669         var url = $(this).attr('data-url'),
   710 
   676 
   711         $('.popup').modal('hide');
   677         $('.popup').modal('hide');
   712 
   678 
   713         var videoWrap = $('#tab-annotation-'+currentAnnotation.id).find('.annotation-video-content');
   679         var videoWrap = $('#tab-annotation-'+currentAnnotation.id).find('.annotation-video-content');
   714         renderVideoInfo(videoWrap, currentAnnotation.content);
   680         renderVideoInfo(videoWrap, currentAnnotation.content);
   715 /*
   681 
   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         
   682         
   728     });
   683     });
   729 
   684 
   730 //diaporama
   685 //diaporama
   731 
   686 
   748         addImageToDiaporama(listDiaporama, image);
   703         addImageToDiaporama(listDiaporama, image);
   749         $('.popup').modal('hide'); 
   704         $('.popup').modal('hide'); 
   750     });
   705     });
   751 
   706 
   752     function addImageToDiaporama(diaporama, dataView){
   707     function addImageToDiaporama(diaporama, dataView){
   753         $.get('template.html', function(templates){
   708    
   754             var tplDiapo = $(templates).filter('#tpl-diaporama-row').html();
   709         var tplDiapo = getTemplate('#tpl-diaporama-row');
   755             tplDiapo = Mustache.render(tplDiapo, dataView);
   710         tplDiapo = Mustache.render(tplDiapo, dataView);
   756             diaporama.append(tplDiapo);
   711         diaporama.append(tplDiapo);
   757             disabledBtnSortable(diaporama);
   712         disabledBtnSortable(diaporama);
   758         });
   713     
   759     };
   714     };
   760 
   715 
   761     //bouton up / down
   716     //bouton up / down
   762     $(document).on('click', '.ui-sortable .btn-sort', function(e){
   717     $(document).on('click', '.ui-sortable .btn-sort', function(e){
   763         e.preventDefault();
   718         e.preventDefault();
   799     addLinkRow(tbody);
   754     addLinkRow(tbody);
   800 });
   755 });
   801 $('.tab-content').on('click', '.delete-link', function(e){
   756 $('.tab-content').on('click', '.delete-link', function(e){
   802     e.preventDefault();
   757     e.preventDefault();
   803     var row = $(this).parents('tr'),
   758     var row = $(this).parents('tr'),
   804         tbody = $(this).find('tbody');
   759         tbody = $(this).parents('tbody');
       
   760 
   805     row.remove();
   761     row.remove();
   806     updateLinks(tbody);
   762     updateLinks(tbody);
   807 });
   763 });
   808 function addLinkRow(tbody, dataView){
   764 function addLinkRow(tbody, dataView){
   809     $.get('template.html', function(templates){
   765 
   810         //head commun à tous
   766         //head commun à tous
   811         var tplLinkRow = $(templates).filter('#tpl-links-row').html();
   767         var tplLinkRow = getTemplate('#tpl-links-row');
   812         var output = Mustache.render(tplLinkRow, dataView);
   768         var output = Mustache.render(tplLinkRow, dataView);
   813         tbody.append(output);
   769         tbody.append(output);
   814     });
   770 
   815 }
   771 }
   816 $('.tab-content').on('keyup', '.links-rows input', function(e){
   772 $('.tab-content').on('keyup', '.links-rows input', function(e){
   817     var tbody = $(this).parents('.links-rows');
   773     var tbody = $(this).parents('.links-rows');
   818     updateLinks(tbody);   
   774     updateLinks(tbody);   
   819 });
   775 });
   820 function updateLinks(tbody){
   776 function updateLinks(tbody){
   821     links = new Array();
   777     links = new Array();
       
   778 
   822     $.each(tbody.find('tr'), function(k, v){
   779     $.each(tbody.find('tr'), function(k, v){
   823         var urlLink = $(v).find('.url-link').val(),
   780         var urlLink = $(v).find('.url-link').val(),
   824             titleLink = $(v).find('.title-link').val(),
   781             titleLink = $(v).find('.title-link').val(),
   825             link = {
   782             link = {
   826                 url : urlLink,
   783                 url : urlLink,
   827                 title : titleLink
   784                 title : titleLink
   828             };
   785             };
   829             links.push(link);
   786             links.push(link);
       
   787 
   830     });
   788     });
   831     currentAnnotation.content.links = links;
   789     currentAnnotation.content.links = links;
   832 }
   790 }
   833 
       
   834 
       
   835 //annotation html
       
   836 /*
       
   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 });
       
   845 */
       
   846 
   791 
   847 //annotation audio
   792 //annotation audio
   848 $('.tab-content').on('keyup', '.annotation-audio-content input, .annotation-audio-content textarea', function(){
   793 $('.tab-content').on('keyup', '.annotation-audio-content input, .annotation-audio-content textarea', function(){
   849     var name = $(this).attr('name'),
   794     var name = $(this).attr('name'),
   850         value = $(this).val();
   795         value = $(this).val();
   857     var autostart = $(this).attr('data-autostart');
   802     var autostart = $(this).attr('data-autostart');
   858     if(autostart == "true"){ autostart = true;}
   803     if(autostart == "true"){ autostart = true;}
   859     else {autostart = false;}
   804     else {autostart = false;}
   860     currentAnnotation.content.autostart = autostart;
   805     currentAnnotation.content.autostart = autostart;
   861 });
   806 });
   862 
       
   863 
   807 
   864 $('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){
   808 $('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){
   865     var value = $(this).val();
   809     var value = $(this).val();
   866     if(!isNaN(value)){
   810     if(!isNaN(value)){
   867         currentAnnotation.content.duration = value;
   811         currentAnnotation.content.duration = value;
   914     }
   858     }
   915 };
   859 };
   916 
   860 
   917 //slider
   861 //slider
   918 function configSlider(data){
   862 function configSlider(data){
   919 
       
   920     return {
   863     return {
   921         range: true,
   864         range: true,
   922         values: [ data.begin.milliseconds, data.end.milliseconds ],
   865         values: [ data.begin.milliseconds, data.end.milliseconds ],
   923         min: 0,
   866         min: 0,
   924         max: myMedia.duration.milliseconds,
   867         max: myMedia.duration.milliseconds,
   940             annotationTimeline.css({
   883             annotationTimeline.css({
   941                 left : left,
   884                 left : left,
   942                 width :width
   885                 width :width
   943             });
   886             });
   944 
   887 
       
   888 
       
   889 
       
   890         },
       
   891         stop : function(){
       
   892             renderAnnotation()
   945         }
   893         }
   946     };
   894     };
   947 
       
   948 }
   895 }
   949 
   896 
       
   897 //init annotation content data
   950 function getContentAnnotationByType(type){
   898 function getContentAnnotationByType(type){
   951     var content;
   899     var content;
   952     switch(type){
   900     switch(type){
   953         case 'audio':
   901         case 'audio':
   954             content = {
   902             content = {
   991 
   939 
   992 
   940 
   993 
   941 
   994 
   942 
   995 //test
   943 //test
   996 //a = $(".wysiwyg").cleditor(wysiwygConfig);
       
   997 
       
   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 
       
  1010 $(".tag-it").tagit();
       
  1011 
   944 
  1012 $('.log-annotations').bind('click', function(e){
   945 $('.log-annotations').bind('click', function(e){
  1013     e.preventDefault();
   946     e.preventDefault();
  1014     console.log(annotations.length + ' annotations', annotations);
   947     console.log(annotations.length + ' annotations', annotations);
  1015 });
   948 });
  1016 
   949 
  1017 $('.log-chapters').bind('click', function(e){
   950 $('.log-chapters').bind('click', function(e){
  1018     e.preventDefault();
   951     e.preventDefault();
  1019     console.log(chapters.length + ' chapitres',chapters);
   952     console.log(chapters.length + ' chapitres',chapters);
  1020 });
   953 });
       
   954 
  1021 });//ready
   955 });//ready
  1022 
   956 
       
   957 //Utilitaires
  1023 Array.prototype.move = function (old_index, new_index) {
   958 Array.prototype.move = function (old_index, new_index) {
  1024     if (new_index >= this.length) {
   959     if (new_index >= this.length) {
  1025         var k = new_index - this.length;
   960         var k = new_index - this.length;
  1026         while ((k--) + 1) {
   961         while ((k--) + 1) {
  1027             this.push(undefined);
   962             this.push(undefined);
  1028         }
   963         }
  1029     }
   964     }
  1030     this.splice(new_index, 0, this.splice(old_index, 1)[0]);
   965     this.splice(new_index, 0, this.splice(old_index, 1)[0]);
  1031     return this; // for testing purposes
   966     return this; 
  1032 };
   967 };
  1033 
   968 
  1034 
   969 
  1035 function getVideoPlayer(src, videoWrap){
   970 function getVideoPlayer(src, videoWrap){
  1036 
   971 
  1142         width: mediaW,
  1077         width: mediaW,
  1143         height: mediaH,
  1078         height: mediaH,
  1144         autoplay: "" + autoplay
  1079         autoplay: "" + autoplay
  1145     }));
  1080     }));
  1146                 
  1081                 
  1147 }
  1082 }//getVideoPlayer