player/js/player.js
changeset 15 01ac2cd2756c
parent 14 f8a0d5d14372
child 16 471bbaa78d0c
equal deleted inserted replaced
14:f8a0d5d14372 15:01ac2cd2756c
   270         annotationDiv.appendTo($(".main-video"));
   270         annotationDiv.appendTo($(".main-video"));
   271         annotationDiv.find(".close-annotation").click(closeAnnotation);
   271         annotationDiv.find(".close-annotation").click(closeAnnotation);
   272         annotationDiv.find(".annotation-title").text(annotationinfo.annotation.title);
   272         annotationDiv.find(".annotation-title").text(annotationinfo.annotation.title);
   273         
   273         
   274                 
   274                 
   275         var positionDiv = function(anim) {
   275         var positionDiv = function() {
   276             var css = {
   276             annotationDiv.css({
   277                 top: Math.floor(($(".main-video").height() - annotationDiv.height())/2)+"px"
   277                 top: Math.floor(($(".main-video").height() - annotationDiv.height())/2)+"px"
   278             };
   278             });
   279             if (anim) {
       
   280                 annotationDiv.animate(css, 800);
       
   281             } else {
       
   282                 annotationDiv.css(css);
       
   283             }
       
   284         }
   279         }
   285         
   280         
   286         switch (annotationinfo.type) {
   281         switch (annotationinfo.type) {
   287             
   282             
   288             case "slideshow":
   283             case "slideshow":
   297                     var imgel = annotationDiv.find(".slideshow-image");
   292                     var imgel = annotationDiv.find(".slideshow-image");
   298                     imgel.css("margin-top","");
   293                     imgel.css("margin-top","");
   299                     var w = imgel.width(),
   294                     var w = imgel.width(),
   300                         h = imgel.height();
   295                         h = imgel.height();
   301                     annotationDiv.find(".annotation-main").css("height","");
   296                     annotationDiv.find(".annotation-main").css("height","");
   302                     annotationDiv.find(".slideshow-description").css("margin-left",w);
       
   303                     var h2 = annotationDiv.find(".annotation-main").height();
   297                     var h2 = annotationDiv.find(".annotation-main").height();
   304                     if (h < h2) {
   298                     if (h < h2) {
   305                         imgel.css("margin-top",Math.floor((h2-h)/2)+"px");
   299                         imgel.css("margin-top",Math.floor((h2-h)/2)+"px");
   306                     }
   300                     }
   307                     if (+imgel.css("opacity") !== 1) {
   301                     if (+imgel.css("opacity") !== 1) {
   436                             title: false,
   430                             title: false,
   437                             byline: false
   431                             byline: false
   438                         },
   432                         },
   439                         success: function(data) {
   433                         success: function(data) {
   440                             annotationDiv.find(".media-frame").html(data.html);
   434                             annotationDiv.find(".media-frame").html(data.html);
   441                             positionDiv(true);
   435                             positionDiv();
   442                         }
   436                         }
   443                     });
   437                     });
   444                     return;
   438                     return;
   445                 }
   439                 }
   446                 
   440                 
   454                             maxheight: 487,
   448                             maxheight: 487,
   455                             url: src
   449                             url: src
   456                         },
   450                         },
   457                         success: function(data) {
   451                         success: function(data) {
   458                             annotationDiv.find(".media-frame").html(data.html);
   452                             annotationDiv.find(".media-frame").html(data.html);
   459                             positionDiv(true);
   453                             positionDiv();
   460                         }
   454                         }
   461                     });
   455                     });
   462                     return;
   456                     return;
   463                 }
   457                 }
   464                 
   458                 
   474                             url: src,
   468                             url: src,
   475                             color: "B8155F"
   469                             color: "B8155F"
   476                         },
   470                         },
   477                         success: function(data) {
   471                         success: function(data) {
   478                             annotationDiv.find(".media-frame").html(data.html);
   472                             annotationDiv.find(".media-frame").html(data.html);
   479                             positionDiv(true);
   473                             positionDiv();
   480                         }
   474                         }
   481                     });
   475                     });
   482                     return;
   476                     return;
   483                 }
   477                 }
   484                 
   478                 
   498                     height: mediaH,
   492                     height: mediaH,
   499                     autoplay: "" + annotationinfo.annotation.content.autostart
   493                     autoplay: "" + annotationinfo.annotation.content.autostart
   500                 }));
   494                 }));
   501                 
   495                 
   502                 media.on("loadedmetadata", function() {
   496                 media.on("loadedmetadata", function() {
   503                     positionDiv(true);
   497                     positionDiv();
   504                 });
   498                 });
   505                 
   499                 
   506                 annotationDiv.find(".media-frame").html(media);
   500                 annotationDiv.find(".media-frame").html(media);
   507                 return;
   501                 return;
   508                 
   502                 
   513                 var text = annotationinfo.annotation.content.text || annotationinfo.annotation.description;
   507                 var text = annotationinfo.annotation.content.text || annotationinfo.annotation.description;
   514                 
   508                 
   515                 switch (annotationinfo.annotation.content.markup) {
   509                 switch (annotationinfo.annotation.content.markup) {
   516                     case "html":
   510                     case "html":
   517                         annotationDiv.find(".text-contents").html(text);
   511                         annotationDiv.find(".text-contents").html(text);
       
   512 /*
       
   513                         var ps = annotationDiv.find(".text-contents>p"),
       
   514                             groups = [],
       
   515                             last, group;
       
   516                         ps.each(function(i, e) {
       
   517                             if (last && group && last.nextElementSibling === e) {
       
   518                                 group.contents.push(e);
       
   519                             } else {
       
   520                                 group = {
       
   521                                     master: e,
       
   522                                     contents: [e.cloneNode(true)]
       
   523                                 }
       
   524                                 groups.push(group);
       
   525                             }
       
   526                             last = e;
       
   527                         });
       
   528                         groups.forEach(function(g) {
       
   529                             $(g.master).replaceWith($('<div class="column-group">').append(g.contents));
       
   530                         });
       
   531 */
   518                     break;
   532                     break;
   519                     default:
   533                     default:
   520                         annotationDiv.find(".text-contents").html(
   534                         annotationDiv.find(".text-contents").html(
   521                             text.split(/\n/gm).map(function(l) {
   535                             text.split(/\n/gm).map(function(l) {
   522                                 return '<p>' + _.escape(l) + '</p>';
   536                                 return '<p>' + _.escape(l) + '</p>';