flowplayer-files
Version:
Flowplayer js and css files for v2.5.9 after the reboot of flowplayer
2 lines (1 loc) • 17.3 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t=t||self).flowplayer=t.flowplayer||{},t.flowplayer.endscreen=e())}(this,(function(){"use strict";var t=[].slice;function e(t,e,n){for(var r=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);r.length;){if(null==t)return n;var i=r.shift();if("string"!=typeof i)return n;t=t[i]}return null==t?n:t}var n=!!function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}return t}()&&{passive:!0},r=["touchstart","touchmove"];function i(t){return t.emit=function(e,n,r){r=r||{};var i=function(t){var e=document.createEvent("Event");return e.initEvent(t,!1,!0),e}(e);return n&&function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];for(var i in e)t[i]=e[i]}(i,{data:n||{}}),t.dispatchEvent(i),!1===r.return_self?i:t},t.on=function(e,i){return"string"==typeof e&&(e=e.split(" ")),e.forEach((function(e){return function(t){return~r.indexOf(t)}(e)?t.addEventListener(e,i,n):t.addEventListener(e,i)})),t},t.off=function(e,n){return t.removeEventListener(e,n),t},t.one=t.once=function(e,n){return t.on(e,(function r(i){t.off(e,r),n(i)}))},t}var o=Array.isArray,a="undefined"!=typeof window&&i(window),l="undefined"!=typeof document&&i(document),s=["span","a","em","p","i"],u=s.concat(["div","strong","video","img","ol","ul","li","script"]);function c(t,e,n){var r=p(document.createElement(t));if(o(e)&&(n=e,e=!1),o(n)||(n=[n]),r.append(n.filter((function(t){return t}))),"object"!=typeof e)return r;for(var i in e)i in r?r[i]=e[i]:r.setAttribute(i,e[i]);return r}function f(e){var n=e.tagName;e.__flowplayer__=1,e.find=function(t){var n=e.querySelector(t);return n?p(n):n},e.html=function(t){return e.innerHTML=t,e},e.empty=function(){return e.innerHTML="",e},e.offset=function(){var t={top:0,left:0},n=e;do{t.left+=n.offsetLeft||0,t.top+=n.offsetTop||0}while(n=n.offsetParent);return t},e.innerWidth=function(){var t=getComputedStyle(e);return e.clientWidth-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)};var r=e.insert=function(t,n){return o(n)?n.map((function(n){return e.insert(t,n)}))[0]:p(n="string"==typeof n?e.insertAdjacentHTML(t,n):e.insertAdjacentElement?e.insertAdjacentElement(t,n):e.appendChild(n))};return e.append=r.bind(e,"beforeend"),e.prepend=r.bind(e,"afterbegin"),e.css=function(t,n){if("object"==typeof t){for(var r in t)e.css(r,t[r]);return e}return void 0===n?getComputedStyle(e)[t]:(1*n&&(n+="px"),e.style[t]=n,e)},e.show=function(){return e.css({display:~s.indexOf(n)?"inline":"block"})},e.hide=function(){return e.css({display:"none"})},e.remove=function(){var t=e.parentNode;t&&t.removeChild(e)},e.attr=function(t,n){return null==n?e.getAttribute(t):(e.setAttribute(t,n),e)},e.txt=function(t){return e.textContent=t,e},e.fp=function(t){return e.addClass("fp-"+t)},e.addClass=function(t){return t.split(" ").forEach((function(t){e.hasClass(t)||(e.className+=(e.className?" ":"")+t)})),e},e.removeClass=function(t){t=t.split(" ");var n=e.className.split(" ");return e.className=n.filter((function(e){return!~t.indexOf(e)})).join(" "),e},e.toggleClass=function(t,n){return void 0===n&&(n=!e.hasClass(t)),n?e.addClass(t):e.removeClass(t)},e.findAll=function(n){return r=e.querySelectorAll(n),t.call(r);var r},e.hasClass=function(t){return~e.className.split(" ").indexOf(t)},e}function p(t){return void 0===t||function(t){return t&&t.__flowplayer__}(t)?t:f(i(t))}function d(t,e){if("string"==typeof t&&"<"==t[0])return c(t.slice(1,-1),e);if("string"!=typeof t)return p(t);var n=e instanceof HTMLElement&&e.querySelector(".fp-"+t)||document.querySelector(t);return n?p(n):void 0}function y(t,e){if(1!=!!e)throw new Error(t)}function v(t,e){this.mode=e.mode,this.sort=e.sort||v._sort,this.members=this.sort(t.slice(0),e.mode),this.last_idx=this.members.length-1,this.plays=e.plays||0,this.idx=-1}d.window=a,d.document=l,d.el=c,u.forEach((function(t){d[t]=function(e,n){return"string"==typeof e&&(e={class:e}),c(t,e,n)}}));var m=v.modes={SHUFFLE:1,FIFO:2,LOOP:4};v.is_ended=function(t){return t.idx==t.last_idx},v.reduce=function(t,e,n){return t.members.reduce.apply(t.members,[].slice.call(arguments,1,arguments.length))},v.map=function(t,e){return t.members.map.apply(t.members,[].slice.call(arguments,1,arguments.length))},v.next_video=function(t){if(!v.is_ended(t)||0!=(t.mode&m.LOOP))return t.members[v.next_id(t)]},v.prev_video=function(t){if(0!==t.idx||0!=(t.mode&m.LOOP))return t.members[v.prev_id(t)]},v.current_video=function(t){return-1==t.idx?t.members[0]:t.members[t.idx]},v.next_id=function(t){var e=t.idx+1;return e>t.last_idx?0:e},v.prev_id=function(t){var e=t.idx-1;return e<0?t.last_idx:e},v.lpop=function(t){return++t.idx,t.members[t.idx]},v._sort=function(t,e){return(e&m.SHUFFLE)==m.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)},v.reset=function(t){return new v(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})},v.of=function(t,e){var n=e.shuffle?m.SHUFFLE:m.FIFO;return e.loop&&(n|=m.LOOP),new v(t,{mode:n,sort:e.sort})};var h={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_INTERSTITIAL:"playlist:interstitial",PLAYLIST_INTERSTITIAL_END:"playlist:interstitial_end"};function _(t){return"function"==typeof t}function g(){throw new Error("Function was expected as Argument[0]")}var b=[].slice;function w(t){if(!(this instanceof w))return new w(t);var e=this;return e.data=t,e.tap=function(){var t=b.call(arguments),n=t.shift();return n==w.lift?e.data:_(n)?(n.apply(e,[e.data].concat(t)),e):void g()},e.into=e.fmap=function(){var t=b.call(arguments),n=t.shift();return n==w.lift?e.data:_(n)?w(n.apply(e,[e.data].concat(t))):void g()},e.unwrap=function(){return e.data},e}function L(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function x(t,e){w.of(t).fmap(L).fmap(y,e)}function A(t){return void 0!==t}function I(t){return"string"==typeof t}function E(t){return"object"==typeof t}function T(t){try{return t instanceof HTMLElement}catch(e){return E(t)&&E(t.style)&&E(t.ownerDocument)}}function S(t){var e;x("Config must be an Object",A(t)&&E(t)),x("property `playlist` is required",A(t.playlist)),x("property `playlist` was not a String(MediaId)",I(t.playlist)||(e=t.playlist,x("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),x("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){x("item at playlist["+e+"] was not valid",I(t)||E(t))})))),"loop shuffle".split(" ").forEach((function(e){A(t[e])&&x(e+" must be a boolean value if present","boolean"==typeof t[e])})),A(t.delay)&&x("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function P(t,e,n){var r=v.lpop(e),i=e.idx+e.plays<1;return function(t,e,n){"object"==typeof e&&t.setOpts(e);q(t,e,n)}(t,r,n),i&&n.autoplay?t.togglePlay(!0):i?t.setState("is-starting",!0):!i&&n.advance?C(t,n,(function(){t.paused&&(t.setState("is-seamless",!0),t.togglePlay(!0))})):void t.emit(h.PLAYLIST_INTERSTITIAL,{config:n})}function q(t,n,r){if(t.setSrc(I(n)||n.type?n:n.src),t.emit(h.PLAYLIST_NEXT,n),e(r,"should_play",!1))return t.togglePlay(!0)}function k(t,e){e=t.playlist.queue=v.reset(e),t.emit(h.PLAYLIST_READY,{queue:e,should_play:!1})}function C(t,e,n){var r=setTimeout(n,e.delay||0);e.delay>0&&t.emit(h.PLAYLIST_INTERSTITIAL,{timer:r,config:e})}function O(t,e,n){if(e[t])return(n=n||[]).unshift(d.span({innerText:e[t]})),d.div({class:t},n)}w.of=w,w.lift=function(t){return t instanceof w?t.data:t},w._apply=w.apply=function(t,e){if(0==e.length)return t();if(1==e.length)return t(e[0]);if(2==e.length)return t(e[0],e[1]);if(3==e.length)return t(e[0],e[1],e[2]);if(4==e.length)return t(e[0],e[1],e[2],e[3]);if(5==e.length)return t(e[0],e[1],e[2],e[3],e[4]);throw new Error("Pipe._apply() does not support arity > 5")},w.maybe=function(t,e,n){return t?w._apply(e,[t].concat(b.call(arguments,2,arguments.length))):t},w.curry=function(t,e,n){return(e=e||[]).length>t.length-1?t.apply(n,e):function(){var r=e.concat(b.call(arguments));return w.curry(t,r,n)}};var N={coords:"0 0 41 42",link:"#fp-skip-next",translation_key:"core.skip-next",name:"fp-skip-next"},Y={coords:"0 0 41 42",link:"#fp-skip-prev",translation_key:"core.skip-prev",name:"fp-skip-prev"};function j(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function D(t){var e,n,r=j("svg");return r.setAttribute("viewBox",t.coords),t.name&&r.setAttribute("class",t.name),t.title&&r.setAttribute("title",t.title),t.title&&r.setAttribute("aria-label",t.title),r.setAttribute("tabindex","0"),r.setAttribute("focusable","true"),r.appendChild((e=t.link,(n=j("use")).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e),n)),d(r)}function M(t,n,r){d(t),t.addClass("fp-playlist-controls "+(r.theme||"fp-dark")),n.setState("is-playlist",!0);var i=n.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();if(i&&t.addClass(i),n.on([h.PLAYLIST_NEXT,"playing","pause",h.PLAYLIST_READY],(function(r){var i=e(r,"data.queue",e(n,"playlist.queue"));if(i&&(new F(t,i,n),n.root.controls.btns.toggleClass("is-prev-button-disabled",!i.idx),n.root.controls.btns.toggleClass("is-next-button-disabled",i.idx===i.last_idx),n.skip_controls)){var o=i.idx<i.last_idx?v.next_video(i):null,a=i.idx>0?v.prev_video(i):null;n.skip_controls.nextPreview.style.backgroundImage=["url(",o?o.poster:null,")"].join(""),n.skip_controls.prevPreview.style.backgroundImage=["url(",a?a.poster:null,")"].join("")}})),r.skip_controls&&!n.skip_controls){var o=function(t){var e=D(Y).attr("role","button");e.on("click",(function(){t.playlist.prev()}));var n=D(N).attr("role","button");n.on("click",(function(){t.playlist.next()}));var r=d.div("fp-playlist-prev-preview"),i=d.div("fp-playlist-next-preview");return t.root.controls.btns.prepend(e),t.root.controls.btns.append(n),t.root.controls.btns.append(r),t.root.controls.btns.append(i),{prevButton:e,nextButton:n,prevPreview:r,nextPreview:i}}(n);n.reaper.put("skip_controls",o),n.on("reap",(function(){for(var t in o)o[t]=0}))}}function F(t,e,n){t.empty();var r=t.append(d.ol("fp-playlist"));v.map(e,(function(t,i){var o=R(t,e,n,i);o&&r.append(o)}))}function R(t,e,n,r){if(t.title){var i={class:r==e.idx?"is-current "+function(t){return t.paused?"is-paused":"is-playing"}(n):"is-queued",onclick:R.onclick.bind(null,t,e,n,r)};return d.li(i,[d.div("fp-color"),H(t),B(t,n)])}}function H(t){return d.div("video-info",[O("title",t),O("description",t)])}function B(t,e){var n=d.div("video-buttons",e.root.ui.findAll(".fp-switch").map((function(t){return d(t.cloneNode(!0)).removeClass("fp-switch")})));return t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}R.onclick=function(t,e,n,r){return e.idx!=r||n.paused?e.idx==r&&n.paused?n.play():(e.idx=r,void q(n,t,{should_play:!0})):n.pause()};function U(t){return Math.min(100*t,100)+"%"}function X(t,e){var n=d.div("fp-interstitial"),r=t.root.ui.find(".fp-middle");r.append(n),t.on(h.PLAYLIST_INTERSTITIAL,(function(i){var o=i.data;t.setState("is-interstitial",!0);var a=v.current_video(t.playlist.queue);a&&(n.empty().append(X.Innards(t,a,r,o)),e.advance&&X.animate_countdown(t,o,n.querySelector(".countdown")))})),t.on("src playing waiting",(function(){t.emit(h.PLAYLIST_INTERSTITIAL_END)})),t.on(h.PLAYLIST_INTERSTITIAL_END,(function(){t.setState("is-interstitial",!1)}))}X.animate_countdown=function(t,e,n){if(!n)throw new Error("no element to animate was passed");var r=e.config.delay,i=Date.now()+r,o=Date.now(),a=Math.ceil(1e3/60);!function l(){var s=Date.now();if(!(s>i)&&t.paused){if(!e.timer)return n.css({width:U(0)});requestAnimationFrame(l),s-o<a||(o=s,n.css({width:U(1-(i-s)/r)}))}}()},X.Innards=function(t,e,n,r){var i=d.div("left",n.findAll(".fp-switch").map((function(t){return d(t.cloneNode(!0)).removeClass("fp-switch")})));return e.poster&&(i.style.backgroundImage=["url(",e.poster,")"].join("")),[i,d.div("right",[d.div("up-next",[d.span().txt(t._t("playlist.up_next")),d.div("fp-color countdown")]),O("title",e),O("description",e),r.timer&&d.div({class:"cancel",onclick:function(t){return clearTimeout(r.timer),r.timer=0,d(t.target).remove(),t.preventDefault(),!1}},[d.span().txt(t._t("playlist.cancel"))])])]};var V=["playlist","controls","shuffle","loop","advance","delay","player","skip_controls"],W=["src"];function Q(t){S(t)}function z(t,e){var n=this;n.queue=e,n.play=function(e){n.queue.idx=e,q(t,v.current_video(n.queue),{should_play:!0})},n.next=function(){n.queue.idx!==n.queue.last_idx&&n.play(n.queue.idx+1)},n.prev=function(){n.queue.idx&&n.play(n.queue.idx-1)},n.remove=function(e){n.queue.members[e]&&(n.queue.members.splice(e,1),n.queue.plays--,k(t,n.queue))},n.push=function(e){n.queue.members=n.queue.members.concat(e),n.queue.plays--,k(t,n.queue)},n.clear=function(){n.queue.members=[],n.queue.plays--,k(t,n.queue)}}function G(t,e){e.delay="delay"in e?e.delay:1e4,Q(e);const n=function(t){var e={};for(var n in W.forEach((function(e){e in t&&(console.warn(new Error("unsupported attribute: "+e+" found on the top-level config")),delete t[e])})),t)~V.indexOf(n)||(e[n]=t[n]);return e}(e);e=function(t,e){var n={};for(var r in t)V.indexOf(r)<0||(n[r]=t[r]);for(r in e)V.indexOf(r)<0||(n[r]=e[r]);return n}((t=flowplayer(t,n)).opts,e),new X(t,e);var r=G.make_controls(t,e);return G.attach_events(t,r,e),G.fetch(e,(function(e){t.emit(h.PLAYLIST_READY,{queue:e,should_play:0===t.currentSrc.length})})),t}function J(t){return"invalid recommendations configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ playlist: PlaylistId|Array(MediaId|PlayerConfig)"].join("\n\t\t, ")+"\n\t\t}"}function K(t,e){w.of(t).fmap(J).fmap(y,e)}function Z(t){return void 0!==t}function $(t){return"string"==typeof t}function tt(t){return"object"==typeof t}function et(t){var e;K("Config must be an Object",Z(t)&&tt(t)),K("property `playlist` is required",Z(t.playlist)),K("property `playlist` was not an array nor playlist id",(e=t.playlist,K("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),!e.forEach((function(t,e){K("item at playlist["+e+"] was not valid",$(t)||tt(t))}))))}function nt(t,e){var n=function(t,e){var n=d.div({class:"fp-endscreen-cell-thumbnail",onclick:nt.onclick.bind(null,t,e)});t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join(""));return n}(t,e);return n.append(function(t){var e=t.title||"";return d.div("fp-endscreen-cell-title",e)}(t)),n}G.make_controls=function(t,e){var n=G.cast_controls(e);if(n)return d(n),new M(n,t,e),n},G.cast_controls=function(t){var e,n;if(I(n=t.controls)||T(n))return T(t.controls)?e=t.controls:I(t.controls)&&(e=document.querySelector(t.controls)),y("Count not find controls by Selector["+t.controls+"]",T(e)),e},G.fetch=function(t,e){if(Array.isArray(t.playlist))return e(v.of(t.playlist,t));throw new Error("config.playlist must be an Array")},G.attach_events=function(t,e,n){t.on(h.PLAYLIST_READY,(function(e){var r=e.data.queue,i=e.data.should_play;t.reaper.put("playlist",new z(t,r)),i&&P(t,r,n)})),t.on("ended",(function(e){setTimeout((function(){if(!e.defaultPrevented)return v.is_ended(t.playlist.queue)?function(t,e){t.emit(h.PLAYLIST_ENDED),e.loop&&(t.playlist.queue=v.reset(t.playlist.queue),t.emit(h.PLAYLIST_LOOP),C(t,e,(function(){t.emit(h.PLAYLIST_READY,{queue:t.playlist.queue,should_play:!0})})))}(t,n):void(0!=n.advance&&P(t,t.playlist.queue,n))}),0)}))},G.events=h,G.VideoQueue=v,nt.onclick=function(t,n){"object"==typeof t&&n.setOpts(t),function(t,n,r){if(t.setSrc($(n)?n:n.src),e(r,"should_play",!1))t.play()}(n,t,{should_play:!0})};function rt(t,e,n){var r=d.div("fp-endscreen");n.reaper.put("endscreen",r),n.on("mount",(function(){n.root.middle.append(r)})),n.on("recommendationsready",(function(i){var o=i.data;et(o),r.recommendations=o,!n.ended||n.playlist||t.loop||it(e,r,n)})),n.on("ended",(function(t){setTimeout((function(){if(r.recommendations&&!n.playlist){if(t.defaultPrevented)return;it(e,r,n)}}),0)})),n.on(G.events.PLAYLIST_ENDED,(function(){r.recommendations&&!t.loop&&it(e,r,n)})),n.on(["loadstart","playing"],(function(){n.setState("is-endscreen",!1)}))}function it(t,e,n){e.empty();var r=e.recommendations;if(r.playlist&&0!==r.playlist.length){var i=t.hasClass("is-small")||t.hasClass("is-tiny")?6:12,o=[];r.playlist.forEach((function(t,e){o.length!==i&&t.poster&&t.title&&o.push(d.div("fp-endscreen-cell",new nt(t,n,e)))})),0!==o.length&&(e.append(d.div("fp-endscreen-cells",o)),n.setState("is-endscreen",!0))}}return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});var n=t.flowplayer;"function"==typeof n?n(e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e))}(window,rt),rt}));