integration/js/edition.js
changeset 116 fedc0d054b55
parent 115 9144b17b390e
child 121 b7ab06d7ec3e
equal deleted inserted replaced
115:9144b17b390e 116:fedc0d054b55
   128 
   128 
   129     //hover
   129     //hover
   130     $(document).on('mouseover', '.timeline-annotations .annotation, #list-annotations-rows tr, .item-display-annotation' , function(){
   130     $(document).on('mouseover', '.timeline-annotations .annotation, #list-annotations-rows tr, .item-display-annotation' , function(){
   131         if(!$(this).hasClass('shadow')) {
   131         if(!$(this).hasClass('shadow')) {
   132             var idAnnotation = $(this).attr('data-id');
   132             var idAnnotation = $(this).attr('data-id');
   133             $('#annotation-timeline-'+idAnnotation+', #row-list-annotation-'+idAnnotation+', #item-current-annotation-'+idAnnotation).addClass('shadow');
   133             $('#tab-annotation-'+idAnnotation+', #annotation-timeline-'+idAnnotation+', #row-list-annotation-'+idAnnotation+', #item-current-annotation-'+idAnnotation).addClass('shadow');
   134         }
   134         }
   135     });
   135     });
   136 
   136 
   137     $(document).on('mouseover', '.chapter-segment, .row-list-chapter' , function(){
   137     $(document).on('mouseover', '.chapter-segment, .row-list-chapter' , function(){
   138         if(!$(this).hasClass('shadow')) {
   138         if(!$(this).hasClass('shadow')) {
   348         chapters.push(chapter);
   348         chapters.push(chapter);
   349         myProject.getAnnotations().push(chapter);
   349         myProject.getAnnotations().push(chapter);
   350         renderChapter();
   350         renderChapter();
   351         loadFormChapter(chapter.id);
   351         loadFormChapter(chapter.id);
   352         disabledPreview();
   352         disabledPreview();
   353         $('#chapter-title').focus();
   353         $('.chapter-title').focus();
   354     }
   354     }
   355 
   355 
   356     $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
   356     $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
   357         e.preventDefault();
   357         e.preventDefault();
   358         var begin = myMedia.currentTime,
   358         var begin = myMedia.currentTime,
   390  
   390  
   391         return returnEnd;
   391         return returnEnd;
   392     }
   392     }
   393     
   393     
   394     function renderChapter(){
   394     function renderChapter(){
   395         
       
   396 
       
   397         var chapterSegmentWrap = $('.chapter-segments'),
   395         var chapterSegmentWrap = $('.chapter-segments'),
   398             wChapterSegmentWrap = chapterSegmentWrap.width(),
   396             wChapterSegmentWrap = chapterSegmentWrap.width(),
   399             chapterList = $('.list-chapter-rows-wrap');
   397             chapterList = $('.list-chapter-rows-wrap');
   400 
   398 
   401         chapters = chapters.sortBy(function(c){
   399         chapters = chapters.sortBy(function(c){
   519                     title : v.title
   517                     title : v.title
   520                 },
   518                 },
   521                 segment = getTemplate('#tpl-annotation-in-timeline');
   519                 segment = getTemplate('#tpl-annotation-in-timeline');
   522                 segment = Mustache.render(segment, dataAnntim);
   520                 segment = Mustache.render(segment, dataAnntim);
   523 
   521 
   524 
       
   525             var isInTimeline = false;
   522             var isInTimeline = false;
   526             $.each(timeline.find('li'), function(a, b){
   523             $.each(timeline.find('li'), function(a, b){
   527                 if(isInTimeline) return;
   524                 if(isInTimeline) return;
   528                 var row = $(this);
   525                 var row = $(this);
   529                 if(row.children().length){
   526                 if(row.children().length){
   714                             var oldIndex = ui.item.data("startindex"),
   711                             var oldIndex = ui.item.data("startindex"),
   715                                 newIndex = ui.item.index();
   712                                 newIndex = ui.item.index();
   716                             currentAnnotation.content.images.move(oldIndex, newIndex);
   713                             currentAnnotation.content.images.move(oldIndex, newIndex);
   717                         },
   714                         },
   718                     });
   715                     });
   719                     var diaporama = $(tabContent).find('#diaporama-'+idAnnotation),
   716                     var slideshow = $(tabContent).find('#slideshow-'+idAnnotation),
   720                         images = viewType.content.images;
   717                         images = viewType.content.images;
   721                     if(images.length){
   718                     if(images.length){
   722                         $.each(images, function(k,v){
   719                         $.each(images, function(k,v){
   723                             addImageToDiaporama(diaporama, v);
   720                             addImageToSlideshow(slideshow, v);
   724                         });
   721                         });
   725                     }
   722                     }
   726                     break;
   723                     break;
   727             }
   724             }
   728 
   725 
   842                 title : title,
   839                 title : title,
   843                 description : description
   840                 description : description
   844             };
   841             };
   845         currentAnnotation.content.images.push(image);
   842         currentAnnotation.content.images.push(image);
   846 
   843 
   847         var listDiaporama = $('#diaporama-'+currentAnnotation.id);
   844         var listSlideshow = $('#slideshow-'+currentAnnotation.id);
   848         addImageToDiaporama(listDiaporama, image);
   845         addImageToSlideshow(listSlideshow, image);
   849         $('.popup').modal('hide'); 
   846         $('.popup').modal('hide'); 
   850         disabledPreview();
   847         disabledPreview();
   851     });
   848     });
   852 
   849 
   853     function addImageToDiaporama(diaporama, dataView){
   850     function addImageToSlideshow(slideshow, dataView){
   854         var tplDiapo = getTemplate('#tpl-diaporama-row');
   851         var tplDiapo = getTemplate('#tpl-slideshow-row');
   855         tplDiapo = Mustache.render(tplDiapo, dataView);
   852         tplDiapo = Mustache.render(tplDiapo, dataView);
   856         diaporama.append(tplDiapo);
   853         slideshow.append(tplDiapo);
   857         disabledBtnSortable(diaporama);
   854         disabledBtnSortable(slideshow);
   858     };
   855     };
   859 
   856 
   860     //edit 
   857     //edit 
   861     $('.tab-content').on('click', '.title-slideshow-row, .description-slideshow-row, .video-title-edit, .video-description-edit', function(){
   858     $('.tab-content').on('click', '.title-slideshow-row, .description-slideshow-row, .video-title-edit, .video-description-edit', function(){
   862         if($(this).find('input').length) return;
   859         if($(this).find('input').length) return;
   874 
   871 
   875     $(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){
   872     $(document).on('blur', '.title-slideshow-row input, .description-slideshow-row textarea', function(){
   876         var newValue = $(this).val(),
   873         var newValue = $(this).val(),
   877             name = $(this).attr('name'),
   874             name = $(this).attr('name'),
   878             span = $('<span>').html(newValue),
   875             span = $('<span>').html(newValue),
   879             indexRow = $(this).parents('.row-image-diaporama').index();
   876             indexRow = $(this).parents('.row-image-slideshow').index();
   880         $(this).replaceWith(span);
   877         $(this).replaceWith(span);
   881         currentAnnotation.content.images[indexRow][name] = newValue;
   878         currentAnnotation.content.images[indexRow][name] = newValue;
   882         disabledPreview();
   879         disabledPreview();
   883     });
   880     });
   884 
   881 
   892     });
   889     });
   893 
   890 
   894     //button up / down
   891     //button up / down
   895     $(document).on('click', '.ui-sortable .btn-sort', function(e){
   892     $(document).on('click', '.ui-sortable .btn-sort', function(e){
   896         e.preventDefault();
   893         e.preventDefault();
   897         var row = $(this).parents('tr.row-image-diaporama'),
   894         var row = $(this).parents('tr.row-image-slideshow'),
   898             oldIndex = row.index(),
   895             oldIndex = row.index(),
   899             listDiaporama = $(this).parents('.list-image-diaporama');
   896             listSlideshow = $(this).parents('.list-image-slideshow');
   900 
   897 
   901         if($(this).hasClass('down'))
   898         if($(this).hasClass('down'))
   902             row.insertAfter(row.next());
   899             row.insertAfter(row.next());
   903         else if($(this).hasClass('up'))
   900         else if($(this).hasClass('up'))
   904             row.insertBefore(row.prev());
   901             row.insertBefore(row.prev());
   905 
   902 
   906         var newIndex = row.index();
   903         var newIndex = row.index();
   907         currentAnnotation.content.images.move(oldIndex, newIndex);
   904         currentAnnotation.content.images.move(oldIndex, newIndex);
   908 
   905 
   909         disabledBtnSortable(listDiaporama);
   906         disabledBtnSortable(listSlideshow);
   910         disabledPreview();
   907         disabledPreview();
   911     });
   908     });
   912 
   909 
   913     function disabledBtnSortable(listDiaporama){
   910     function disabledBtnSortable(listSlideshow){
   914         listDiaporama.find('.btn-sort.disabled').removeClass('disabled');
   911         listSlideshow.find('.btn-sort.disabled').removeClass('disabled');
   915         listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled');
   912         listSlideshow.find('tr.row-image-slideshow:first-child').find('.btn-sort.up').addClass('disabled');
   916         listDiaporama.find('tr.row-image-diaporama:last-child').find('.btn-sort.down').addClass('disabled');
   913         listSlideshow.find('tr.row-image-slideshow:last-child').find('.btn-sort.down').addClass('disabled');
   917     }
   914     }
   918 
   915 
   919     //delete image on slideshow
   916     //delete image on slideshow
   920     $('.tab-content').on('click','.btn-delete-image', function(e){
   917     $('.tab-content').on('click','.btn-delete-image', function(e){
   921         e.preventDefault();
   918         e.preventDefault();
   922         var rowImage = $(this).parents('tr.row-image-diaporama'),
   919         var rowImage = $(this).parents('tr.row-image-slideshow'),
   923             index = rowImage.index();
   920             index = rowImage.index();
   924 
   921 
   925         rowImage.remove();
   922         rowImage.remove();
   926         currentAnnotation.content.images.splice(index, 1);
   923         currentAnnotation.content.images.splice(index, 1);
   927         disabledPreview();
   924         disabledPreview();
  1005         disabledPreview();
  1002         disabledPreview();
  1006         currentAnnotation.content.autostart = autostart;
  1003         currentAnnotation.content.autostart = autostart;
  1007     });
  1004     });
  1008 
  1005 
  1009     //duration
  1006     //duration
  1010     $('.tab-content').on('change keyup', '.config-diaporama input[name=duration]', function(){
  1007     $('.tab-content').on('change keyup', '.config-slideshow input[name=duration]', function(){
  1011         var value = $(this).val();
  1008         var value = $(this).val();
  1012         if(!isNaN(value)){
  1009         if(!isNaN(value)){
  1013             disabledPreview();
  1010             disabledPreview();
  1014             currentAnnotation.content.slideduration = value * 1000;
  1011             currentAnnotation.content.slideduration = value * 1000;
  1015         }
  1012         }
  1336         }
  1333         }
  1337     }
  1334     }
  1338 
  1335 
  1339 });//ready
  1336 });//ready
  1340 
  1337 
  1341 /* Utility */
  1338 /* Utilitys */
  1342 
  1339 
  1343 Array.prototype.move = function (old_index, new_index) {
  1340 Array.prototype.move = function (old_index, new_index) {
  1344     if (new_index >= this.length) {
  1341     if (new_index >= this.length) {
  1345         var k = new_index - this.length;
  1342         var k = new_index - this.length;
  1346         while ((k--) + 1) {
  1343         while ((k--) + 1) {