integration/js/edition.js
changeset 51 c7ece022eca8
parent 49 06627f23df42
child 54 2a7064b70693
equal deleted inserted replaced
50:494847cf2641 51:c7ece022eca8
     5     annotations = [];
     5     annotations = [];
     6 
     6 
     7 $(function(){
     7 $(function(){
     8 
     8 
     9 var global = {
     9 var global = {
    10     diaporama : null,
       
    11     idAnnotation : null,
    10     idAnnotation : null,
    12     colorsIndex : 0,
    11     colorsIndex : 0,
    13     colors : 
    12     colors : 
    14         ['#f39c12', '#2ecc71', '#3498db', '#9b59b6',  
    13         ['#f39c12', '#2ecc71', '#3498db', '#9b59b6',  
    15         '#f1c40f', '#e67e22', '#e74c3c', '#ecf0f1', 
    14         '#f1c40f', '#e67e22', '#e74c3c', '#ecf0f1', 
    24     
    23     
    25     myMedia = myProject.getCurrentMedia();
    24     myMedia = myProject.getCurrentMedia();
    26     
    25     
    27     //chargement des chapitres et annotations existants
    26     //chargement des chapitres et annotations existants
    28     loadInitChapters();
    27     loadInitChapters();
    29     loadInitAnnotation()
    28     loadInitAnnotation();
    30 
    29 
    31     IriSP.htmlPlayer(
    30     IriSP.htmlPlayer(
    32         myMedia,
    31         myMedia,
    33         $(".main-video"),
    32         $(".main-video"),
    34         {
    33         {
   113 });
   112 });
   114 
   113 
   115 //########### modal
   114 //########### modal
   116 
   115 
   117     $(document).on('click', 'a.open-modal', function(e){
   116     $(document).on('click', 'a.open-modal', function(e){
   118         var diaporama = $(this).attr('data-diaporama'),
   117         var idAnnotation = $(this).attr('data-id');
   119             idAnnotation = $(this).attr('data-id');
   118 
   120 
   119 
   121         if(diaporama !== undefined){
       
   122             global.diaporama = diaporama;
       
   123         }
       
   124         if(idAnnotation !== undefined){
   120         if(idAnnotation !== undefined){
   125             global.idAnnotation = idAnnotation;
   121             global.idAnnotation = idAnnotation;
   126         }
   122         }
   127     });
   123     });
   128 
   124 
   131         var typeImage = $(this).val();
   127         var typeImage = $(this).val();
   132         $('.input-image-url, .input-image-upload').hide();
   128         $('.input-image-url, .input-image-upload').hide();
   133         $('.input-image-'+typeImage).show();
   129         $('.input-image-'+typeImage).show();
   134     });
   130     });
   135 
   131 
   136 //bibliotheque
   132 //select on bibliotheque
       
   133 
   137     //video
   134     //video
   138     $('.popup').on('click', '.bibliotheque-video a', function(e){
   135     $('.popup').on('click', '.bibliotheque-video a', function(e){
   139         e.preventDefault();
   136         e.preventDefault();
   140 
   137 
   141         var url = $(this).attr('href');
   138         var url = $(this).attr('href');
   147                 tplVideo = $(templates).filter('#tpl-video-row').html();
   144                 tplVideo = $(templates).filter('#tpl-video-row').html();
   148             videoWrap.empty().append(tplVideo);
   145             videoWrap.empty().append(tplVideo);
   149         });
   146         });
   150         
   147         
   151     });
   148     });
   152     //image
       
   153     $('.popup').on('click', '.bibliotheque-image a', function(e){
       
   154         e.preventDefault();
       
   155         var listDiaporama = $('#'+global.diaporama);
       
   156         addImageToDiaporama(listDiaporama);
       
   157         $('.popup').modal('hide');
       
   158     });
       
   159 
       
   160     
   149     
   161 
   150 
   162     //confirmation suppression
   151     //confirmation suppression
   163     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   152     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
   164 
   153 
   553                         addLinkRow(tbody);
   542                         addLinkRow(tbody);
   554                     }
   543                     }
   555                     break;
   544                     break;
   556 
   545 
   557                 case 'slideshow': 
   546                 case 'slideshow': 
       
   547 
   558                     $(tabContent).find('.number-spin').spin(spinParam);
   548                     $(tabContent).find('.number-spin').spin(spinParam);
   559                     $(tabContent).find('.ui-sortable').sortable({
   549                     $(tabContent).find('.ui-sortable').sortable({
   560                         stop : function(event, ui){
   550                         stop : function(event, ui){
   561                             disabledBtnSortable($(this));
   551                             disabledBtnSortable($(this));
   562                         }
   552                         }
   563                     });
   553                     });
       
   554                     var diaporama = $(tabContent).find('#diaporama-'+idAnnotation),
       
   555                         images = viewType.content.images;
       
   556                     if(images.length){
       
   557                         $.each(images, function(k,v){
       
   558                             addImageToDiaporama(diaporama, v);
       
   559                         });
       
   560                     }
   564                     break;
   561                     break;
   565             }
   562             }
   566 
   563 
   567             dataView.iconTab = getIcon(type);
   564             dataView.iconTab = getIcon(type);
   568             var tplOnglet = $(templates).filter('#tpl-onglet').html();
   565             var tplOnglet = $(templates).filter('#tpl-onglet').html();
   622         $('.tab-content #tab-annotation-'+idAnnotation).remove();
   619         $('.tab-content #tab-annotation-'+idAnnotation).remove();
   623         $('#tab-list-annotation').tab('show');
   620         $('#tab-list-annotation').tab('show');
   624     }
   621     }
   625 
   622 
   626 //diaporama
   623 //diaporama
   627     function addImageToDiaporama(diaporama){
   624 
       
   625     //bibliotheque
       
   626     $('.popup').on('click', '.bibliotheque-image a', function(e){
       
   627         e.preventDefault();
       
   628 
       
   629         var url = $(this).attr('href'),
       
   630             image = {
       
   631                 id : currentAnnotation.id,
       
   632                 url : url,
       
   633                 title : 'titre image',
       
   634                 description : 'description azerty'
       
   635             };
       
   636         currentAnnotation.content.images.push(image);
       
   637 
       
   638         var listDiaporama = $('#diaporama-'+currentAnnotation.id);
       
   639         addImageToDiaporama(listDiaporama, image);
       
   640         $('.popup').modal('hide'); 
       
   641     });
       
   642 
       
   643     function addImageToDiaporama(diaporama, dataView){
   628         $.get('template.html', function(templates){
   644         $.get('template.html', function(templates){
   629             var tplDiapo = $(templates).filter('#tpl-diaporama-row').html(),
   645             var tplDiapo = $(templates).filter('#tpl-diaporama-row').html();
   630                 uniqId = 'id' + (new Date()).getTime(),
   646             tplDiapo = Mustache.render(tplDiapo, dataView);
   631                 viewDiapo = { ridid : uniqId};
       
   632             tplDiapo = Mustache.render(tplDiapo, viewDiapo);
       
   633             diaporama.append(tplDiapo);
   647             diaporama.append(tplDiapo);
   634             disabledBtnSortable(diaporama);
   648             disabledBtnSortable(diaporama);
   635         });
   649         });
   636     };
   650     };
   637 
   651 
   714         value = $(this).val();
   728         value = $(this).val();
   715 
   729 
   716     currentAnnotation.content[name] = value;
   730     currentAnnotation.content[name] = value;
   717 });
   731 });
   718 
   732 
       
   733 //annotation slideshow
       
   734 $('.tab-content').on('click', '.btn-autostart', function(){
       
   735     var autostart = $(this).attr('data-autostart');
       
   736     if(autostart == "true"){ autostart = true;}
       
   737     else {autostart = false;}
       
   738     currentAnnotation.content.autostart = autostart;
       
   739 });
       
   740 
       
   741 
       
   742 $('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){
       
   743     var value = $(this).val();
       
   744     if(!isNaN(value)){
       
   745         currentAnnotation.content.duration = value;
       
   746     }
       
   747 });
       
   748 
   719 //################ config
   749 //################ config
   720 
       
   721 //tagit
   750 //tagit
   722 function onTagItChange(e, ui) {
   751 function onTagItChange(e, ui) {
   723     var tagitType = $(this).attr('data-type'), 
   752     var tagitType = $(this).attr('data-type'), 
   724         value = $(this).val();
   753         value = $(this).val();
   725 
   754