player/js/player.js
changeset 78 55b7d94593a1
parent 74 0405878fde82
child 80 c587eca9152e
equal deleted inserted replaced
77:3c47232648d6 78:55b7d94593a1
    83     
    83     
    84     $(".tags-title").mouseenter(function() {
    84     $(".tags-title").mouseenter(function() {
    85         $(".tags-list").stop().slideDown();
    85         $(".tags-list").stop().slideDown();
    86     }).click(function() {
    86     }).click(function() {
    87         if (clickedTag) {
    87         if (clickedTag) {
    88             $(".found").removeClass("found");
       
    89             $(".timelines").removeClass("searching");
       
    90             clickedTag = null;
    88             clickedTag = null;
       
    89             showTag(null);
    91         }
    90         }
    92         return false;
    91         return false;
    93     });
    92     });
    94     $(".tags").mouseleave(function() {
    93     $(".tags").mouseleave(function() {
    95         $(".tags-list").stop().slideUp();
    94         $(".tags-list").stop().slideUp();
    97     
    96     
    98     function showTag(tagId) {
    97     function showTag(tagId) {
    99         $(".found").removeClass("found");
    98         $(".found").removeClass("found");
   100         var tag = myProject.getElement(tagId);
    99         var tag = myProject.getElement(tagId);
   101         if (tag) {
   100         if (tag) {
   102             $(".timelines").addClass("searching");
   101             $("body").addClass("searching");
       
   102             $(".tags-title").text(tag.title);
   103             tag.getRelated("annotation").forEach(function(a) {
   103             tag.getRelated("annotation").forEach(function(a) {
   104                 a.trigger("found-tags");
   104                 a.trigger("found-tags");
   105             });
   105             });
   106             $(".tag[data-tag-id="+tagId+"]").addClass("found");
   106             $(".tag[data-tag-id="+tagId+"]").addClass("found");
   107         } else {
   107         } else {
   108             $(".timelines").removeClass("searching");
   108             $("body").removeClass("searching");
       
   109             $(".tags-title").text("Mots-clés");
   109         }
   110         }
   110         lastTag = tagId;
   111         lastTag = tagId;
   111     }
   112     }
   112     
   113     
   113     $(".tag").hover(function() {
   114     $(".tag").hover(function() {
   114         showTag($(this).attr("data-tag-id"));
   115         showTag($(this).attr("data-tag-id"));
   115     }, function() {
   116     }, function() {
   116         showTag(clickedTag);
   117         showTag(clickedTag);
   117     }).click(function() {
   118     }).click(function() {
   118         if (clickedTag == lastTag) {
   119         var tag = $(this).attr("data-tag-id");
   119             clickedTag = null
   120         if (clickedTag === tag) {
       
   121             clickedTag = null;
   120         } else {
   122         } else {
   121             clickedTag = lastTag;
   123             clickedTag = tag;
   122         }
   124         }
       
   125         showTag(clickedTag);
   123         return false;
   126         return false;
   124     });
   127     });
   125     
   128     
   126     
   129     
   127     var chapters = myProject.getAnnotationsByTypeTitle("chapitrage"),
   130     var chapters = myProject.getAnnotationsByTypeTitle("chapitrage"),
   130             + '<div class="chapter-block"></div><div class="chapter-title"><%- title %></div></li>'
   133             + '<div class="chapter-block"></div><div class="chapter-title"><%- title %></div></li>'
   131         ),
   134         ),
   132         chapterList = $(".chapters-list"),
   135         chapterList = $(".chapters-list"),
   133         hoveredChapter = null,
   136         hoveredChapter = null,
   134         currentChapter = null,
   137         currentChapter = null,
   135         currentChapterI = 0;
   138         currentChapterI = 0,
       
   139         slideInterval;
   136     
   140     
   137     function highlightChapter() {
   141     function highlightChapter() {
   138         $(".chapter").removeClass("active");
   142         $(".chapter").removeClass("active");
   139         if (hoveredChapter || currentChapter) {
   143         if (hoveredChapter || currentChapter) {
   140             (hoveredChapter || currentChapter).addClass("active");
   144             (hoveredChapter || currentChapter).addClass("active");
   325         switch (annotationinfo.type) {
   329         switch (annotationinfo.type) {
   326             
   330             
   327             case "slideshow":
   331             case "slideshow":
   328                 
   332                 
   329                 var currentslide = 0,
   333                 var currentslide = 0,
   330                     slideInterval,
       
   331                     playing = false,
   334                     playing = false,
   332                     loaded = false,
   335                     loaded = false,
   333                     currentSlideLoaded = false,
   336                     currentSlideLoaded = false,
   334                     slides = annotationinfo.annotation.content.images;
   337                     slides = annotationinfo.annotation.content.images;
   335                 
   338                 
   392                     }
   395                     }
   393                     loaded = slides.reduce(function(mem, slide) {
   396                     loaded = slides.reduce(function(mem, slide) {
   394                         return (mem && !!slide.image && !!slide.image.height);
   397                         return (mem && !!slide.image && !!slide.image.height);
   395                     }, true);
   398                     }, true);
   396                     if (loaded) {
   399                     if (loaded) {
   397                         if (annotationinfo.annotation.autostart && slides.length > 1) {
   400                         if (annotationinfo.annotation.content.autostart && slides.length > 1) {
   398                             togglePlay();
   401                             togglePlay();
   399                         }
   402                         }
   400                     }
   403                     }
   401                 }
   404                 }
   402                 
   405                 
   407                 });
   410                 });
   408                 
   411                 
   409                 checkloaded();
   412                 checkloaded();
   410                 
   413                 
   411                 if (slides.length > 1) {
   414                 if (slides.length > 1) {
   412                     annotationDiv.find(".slideshow-next").click(nextImage);
   415                     annotationDiv.find(".slideshow-next").click(function() {
       
   416                         if (playing) {
       
   417                             playing = false;
       
   418                             togglePlay();
       
   419                         }
       
   420                         nextImage();
       
   421                     });
   413                     annotationDiv.find(".slideshow-previous").click(function() {
   422                     annotationDiv.find(".slideshow-previous").click(function() {
       
   423                         if (playing) {
       
   424                             playing = false;
       
   425                             togglePlay();
       
   426                         }
   414                         currentslide = (currentslide ? currentslide : slides.length) - 1;
   427                         currentslide = (currentslide ? currentslide : slides.length) - 1;
   415                         annotationDiv.find(".slideshow-image").fadeTo(400, 0, showCurrentImage);
   428                         annotationDiv.find(".slideshow-image").fadeTo(400, 0, showCurrentImage);
   416                     });
   429                     });
   417                     annotationDiv.find(".slideshow-play-pause").click(togglePlay);
   430                     annotationDiv.find(".slideshow-play-pause").click(togglePlay);
   418                 } else {
   431                 } else {
   592         }
   605         }
   593         return false;
   606         return false;
   594     });
   607     });
   595     
   608     
   596     function fullScreen() {
   609     function fullScreen() {
   597         var isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,
   610         var isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || false,
   598             el = document.querySelector("body"),
   611             el = document.querySelector("body"),
   599             requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
   612             requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
   600             cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"];
   613             cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"];
   601         if (isFull) {
   614         if (isFull) {
   602             for (var i = 0; i < cancelMethods.length; i++) {
   615             for (var i = 0; i < cancelMethods.length; i++) {
   616         return false;
   629         return false;
   617     }
   630     }
   618     
   631     
   619     $(".full-screen").click(fullScreen);
   632     $(".full-screen").click(fullScreen);
   620     $(".top-bar").dblclick(fullScreen);
   633     $(".top-bar").dblclick(fullScreen);
   621     
   634            
   622     var fsel = document.querySelector("body"),
   635     if ( typeof document.fullScreen === "undefined"
   623         fsRequestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
   636         && typeof document.mozFullScreen === "undefined"
   624         fsCapable = false;
   637         && typeof document.webkitIsFullScreen === "undefined") {
   625         
       
   626     for (var i = 0; i < fsRequestMethods.length; i++) {
       
   627         if (typeof fsel[fsRequestMethods[i]] === "function") {
       
   628             fsCapable = true;
       
   629             break;
       
   630         }
       
   631     }
       
   632     
       
   633     if (!fsCapable) {
       
   634         $(".full-screen").remove();
   638         $(".full-screen").remove();
   635     }
   639     }
   636             
   640             
   637     $(".about").click(function() {
   641     $(".about").click(function() {
   638         closeAnnotation();
   642         closeAnnotation();
   640         aboutBox.find(".close-annotation").click(closeAnnotation);
   644         aboutBox.find(".close-annotation").click(closeAnnotation);
   641         aboutBox.css({ top: Math.floor(($(".main-video").height() - aboutBox.height())/2)+"px" });
   645         aboutBox.css({ top: Math.floor(($(".main-video").height() - aboutBox.height())/2)+"px" });
   642     });
   646     });
   643    
   647    
   644     function closeAnnotation(e) {
   648     function closeAnnotation(e) {
       
   649         clearInterval(slideInterval);
   645         currentAnnotation = null;
   650         currentAnnotation = null;
   646         $(".chip, .pictolist li").removeClass("current");
   651         $(".chip, .pictolist li").removeClass("current");
   647         $(".timelines").removeClass("annotation-onscreen");
   652         $(".timelines").removeClass("annotation-onscreen");
   648         $(".annotation audio, .annotation video").each(function() {
   653         $(".annotation audio, .annotation video").each(function() {
   649             try {
   654             try {