3 lines
6.1 KiB
JavaScript
3 lines
6.1 KiB
JavaScript
|
/*! @name videojs-playlist-ui @version 3.5.2 @license Apache-2.0 */
|
||
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("global/document"),require("video.js")):"function"==typeof define&&define.amd?define(["global/document","video.js"],e):t.videojsPlaylistUi=e(t.document,t.videojs)}(this,function(t,e){"use strict";function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}t=t&&t.hasOwnProperty("default")?t.default:t;var l,s=(e=e&&e.hasOwnProperty("default")?e.default:e).dom||e,a=e.registerPlugin||e.plugin,n={className:"vjs-playlist",playOnSelect:!1,supportsCssPointerEvents:((l=t.createElement("x")).style.cssText="pointer-events:auto","auto"===l.style.pointerEvents)},r=function(t){t.addClass("vjs-selected")},o=function(t){t.removeClass("vjs-selected"),t.thumbnail&&s.removeClass(t.thumbnail,"vjs-playlist-now-playing")},p=function(t){t.removeClass("vjs-up-next")},d=e.getComponent("Component"),c=function(l){function s(t,e,i){var s;if(!e.item)throw new Error("Cannot construct a PlaylistMenuItem without an item option");return(s=l.call(this,t,e)||this).item=e.item,s.playOnSelect=i.playOnSelect,s.emitTapEvents(),s.on(["click","tap"],s.switchPlaylistItem_),s.on("keydown",s.handleKeyDown_),s}i(s,l);var a=s.prototype;return a.handleKeyDown_=function(t){13!==t.which&&32!==t.which||this.switchPlaylistItem_()},a.switchPlaylistItem_=function(t){this.player_.playlist.currentItem(function(t,e){for(var i=0,l=t.length;i<l;i++)if(t[i]===e)return i;return-1}(this.player_.playlist(),this.item)),this.playOnSelect&&this.player_.play()},a.createEl=function(){var i=t.createElement("li"),l=this.options_.item;"object"==typeof l.data&&Object.keys(l.data).forEach(function(t){var e=l.data[t];i.dataset[t]=e});if(i.className="vjs-playlist-item",i.setAttribute("tabIndex",0),this.thumbnail=function(e){if(!e){var i=t.createElement("div");return i.className="vjs-playlist-thumbnail vjs-playlist-thumbnail-placeholder",i}var l=t.createElement("picture");if(l.className="vjs-playlist-thumbnail","string"==typeof e){var s=t.createElement("img");s.src=e,s.alt="",l.appendChild(s)}else{for(var a=0;a<e.length-1;a++){var n=e[a],r=t.createElement("source");for(var o in n)r[o]=n[o];l.appendChild(r)}var p=e[e.length-1],d=t.createElement("img");for(var c in d.alt="",p)d[c]=p[c];l.appendChild(d)}return l}(l.thumbnail),i.appendChild(this.thumbnail),l.duration){var s=t.createElement("time"),a=e.formatTime(l.duration);s.className="vjs-playlist-duration",s.setAttribute("datetime","PT0H0M"+l.duration+"S"),s.appendChild(t.createTextNode(a)),i.appendChild(s)}var n=t.createElement("span"),r=this.localize("Now Playing");n.className="vjs-playlist-now-playing-text",n.appendChild(t.createTextNode(r)),n.setAttribute("title",r),this.thumbnail.appendChild(n);var o=t.createElement("div");o.className="vjs-playlist-title-container",this.thumbnail.appendChild(o);var p=t.createElement("span"),d=this.localize("Up Next");p.className="vjs-up-next-text",p.appendChild(t.createTextNode(d)),p.setAttribute("title",d),o.appendChild(p);var c=t.createElement("cite"),h=l.name||this.localize("Untitled Video");return c.className="vjs-playlist-name",c.appendChild(t.createTextNode(h)),c.setAttribute("title",h),o.appendChild(c),i},s}(d),h=function(l){function a(t,i){var s;if(!t.playlist)throw new Error("videojs-playlist is required for the playlist component");return(s=l.call(this,t,i)||this).items=[],i.horizontal?s.addClass("vjs-playlist-horizontal"):s.addClass("vjs-playlist-vertical"),i.supportsCssPointerEvents&&s.addClass("vjs-csspointerevents"),s.createPlaylist_(),e.browser.TOUCH_ENABLED||s.addClass("vjs-mouse"),s.on(t,["loadstart","playlistchange","playlistsorted"],function(t){s.update()}),s.on(t,"adstart",function(){s.addClass("vjs-ad-playing")}),s.on(t,"adend",function(){s.removeClass("vjs-ad-playing")}),s.on("dispose",function(){s.empty_(),t.playlistMenu=null}),s.on(t,"dispose",function(){s.dispose()}),s}i(a,l);var n=a.prototype;return n.createEl=function(){return s.createEl("div",{className:this.options_.className})},n.empty_=function(){this.items&&this.items.length&&(this.items.forEach(fun
|