diff --git a/dist/skyvideo.js b/dist/skyvideo.js index e395090..ec4628d 100644 --- a/dist/skyvideo.js +++ b/dist/skyvideo.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("SkyVideo",[],e):"object"==typeof exports?exports.SkyVideo=e():t.SkyVideo=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){var r;function o(t){function n(){if(n.enabled){var t=n,o=+new Date,i=o-(r||o);t.diff=i,t.prev=r,t.curr=o,r=o;for(var s=new Array(arguments.length),u=0;u"+r.css+""}return e}(i))}})),e=r(t,e),n?function(t,e){for(var n=0;n1024&&(this.autoplayDisabled=!1,!0)}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=u(n(10)),i=u(n(11)),s=u(n(13));function u(t){return t&&t.__esModule?t:{default:t}}var c=void 0;e.default=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],u=(0,o.default)();if(c||(c=(0,i.default)(u)),e.events)throw new Error("Event handlers cannot be overwritten.");if("string"==typeof t&&!document.getElementById(t))throw new Error('Element "'+t+'" does not exist.');e.events=s.default.proxyEvents(u);var a=new Promise(function(n){if("string"==typeof t||t instanceof HTMLElement)c.then(function(r){var o=new r.Player(t,e);return u.on("ready",function(){n(o)}),null});else{if(!("object"===(void 0===t?"undefined":r(t))&&t.playVideo instanceof Function))throw new TypeError("Unexpected state.");n(t)}}),l=s.default.promisifyPlayer(a,n);return l.on=u.on,l.off=u.off,l},t.exports=e.default},function(t,e){function n(){var t={},e={};return t.on=function(t,n){var r={name:t,handler:n};return e[t]=e[t]||[],e[t].unshift(r),r},t.off=function(t){var n=e[t.name].indexOf(t);-1!=n&&e[t.name].splice(n,1)},t.trigger=function(t,n){var r,o=e[t];if(o)for(r=o.length;r--;)o[r].handler(n)},t}global.gajus=global.gajus||{},global.gajus.Sister=n,t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,o=n(12),i=(r=o)&&r.__esModule?r:{default:r};e.default=function(t){var e=new Promise(function(t){if(window.YT&&window.YT.Player&&window.YT.Player instanceof Function)t(window.YT);else{var e=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=function(){e&&e(),t(window.YT)}}}),n="http:"===window.location.protocol?"http:":"https:";return(0,i.default)(n+"//www.youtube.com/iframe_api",function(e){e&&t.trigger("error",e)}),e},t.exports=e.default},function(t,e){function n(t,e){t.onload=function(){this.onerror=this.onload=null,e(null,t)},t.onerror=function(){this.onerror=this.onload=null,e(new Error("Failed to load "+this.src),t)}}function r(t,e){t.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,e(null,t))}}t.exports=function(t,e,o){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("script");"function"==typeof e&&(o=e,e={}),e=e||{},o=o||function(){},s.type=e.type||"text/javascript",s.charset=e.charset||"utf8",s.async=!("async"in e)||!!e.async,s.src=t,e.attrs&&function(t,e){for(var n in e)t.setAttribute(n,e[n])}(s,e.attrs),e.text&&(s.text=""+e.text),("onload"in s?n:r)(s,o),s.onload||n(s,o),i.appendChild(s)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=u(n(14)),o=u(n(22)),i=u(n(23)),s=u(n(24));function u(t){return t&&t.__esModule?t:{default:t}}var c=(0,r.default)("youtube-player"),a={proxyEvents:function(t){var e={},n=function(n){var r="on"+n.slice(0,1).toUpperCase()+n.slice(1);e[r]=function(e){c('event "%s"',r,e),t.trigger(n,e)}},r=!0,o=!1,s=void 0;try{for(var u,a=i.default[Symbol.iterator]();!(r=(u=a.next()).done);r=!0){n(u.value)}}catch(t){o=!0,s=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw s}}return e},promisifyPlayer:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n={},r=function(r){e&&s.default[r]?n[r]=function(){for(var e=arguments.length,n=Array(e),o=0;o=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(r())},function(t,e){var n=1e3,r=60*n,o=60*r,i=24*o,s=365.25*i;function u(t,e,n){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var u=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return u*s;case"days":case"day":case"d":return u*i;case"hours":case"hour":case"hrs":case"hr":case"h":return u*o;case"minutes":case"minute":case"mins":case"min":case"m":return u*r;case"seconds":case"second":case"secs":case"sec":case"s":return u*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}(t);if("number"===a&&!1===isNaN(t))return e.long?u(c=t,i,"day")||u(c,o,"hour")||u(c,r,"minute")||u(c,n,"second")||c+" ms":function(t){if(t>=i)return Math.round(t/i)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=r)return Math.round(t/r)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,n){var r=n(18),o=n(19);(e=t.exports=n(0)).init=function(t){t.inspectOpts={};for(var n=Object.keys(e.inspectOpts),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=e.id,o=e.url,i=r||o;if(!i)throw new Error("An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.");if(t=i,!isNaN(parseFloat(t))&&isFinite(t)&&Math.floor(t)==t)return"https://vimeo.com/"+i;if(n(i))return i.replace("http:","https:");if(r)throw new TypeError("“"+r+"” is not a valid video id.");throw new TypeError("“"+i+"” is not a vimeo.com url.")}var o=void 0!==Array.prototype.indexOf,i="undefined"!=typeof window&&void 0!==window.postMessage;if(!(t||o&&i))throw new Error("Sorry, the Vimeo Player API is not available in this browser.");var s="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(t,e){return t(e={exports:{}},e.exports),e.exports}u(function(t,e){!function(t){var e,n=Object.defineProperty,r=function(t,e){return t===e||t!=t&&e!=e};function o(t,e){function r(t){if(!this||this.constructor!==r)return new r(t);this._keys=[],this._values=[],this._itp=[],this.objectOnly=e,t&&function(t){this.add?t.forEach(this.add,this):t.forEach(function(t){this.set(t[0],t[1])},this)}.call(this,t)}return e||n(t,"size",{get:y}),t.constructor=r,r.prototype=t,r}function i(t){return this.has(t)&&(this._keys.splice(e,1),this._values.splice(e,1),this._itp.forEach(function(t){e0&&s(c,e))}function f(t,e,n,r){for(var o=0;o0&&s(c,r))}catch(t){l.call(new h(r),t)}}}).call(e,t)},function(t){l.call(e,t)})}catch(t){l.call(e,t)}}n=function(){var t,n,r;return{add:function(e,o){r=new function(t,e){this.fn=t,this.self=e,this.next=void 0}(e,o),n?n.next=r:t=r,n=r,r=void 0},drain:function(){var r=t;for(t=n=e=void 0;r;)r.fn.call(r.self),r=r.next}}}();var p=t({},"constructor",d,!1);return d.prototype=p,t(p,"__NPO__",0,!1),t(d,"resolve",function(t){return t&&"object"==(void 0===t?"undefined":o(t))&&1===t.__NPO__?t:new this(function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");e(t)})}),t(d,"reject",function(t){return new this(function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");n(t)})}),t(d,"all",function(t){var e=this;return"[object Array]"!=r.call(t)?e.reject(TypeError("Not an array")):0===t.length?e.resolve([]):new e(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");var o=t.length,i=Array(o),s=0;f(e,t,function(t,e){i[t]=e,++s===o&&n(i)},r)})}),t(d,"race",function(t){var e=this;return"[object Array]"!=r.call(t)?e.reject(TypeError("Not an array")):new e(function(n,r){if("function"!=typeof n||"function"!=typeof r)throw TypeError("Not a function");f(e,t,function(t,e){n(e)},r)})}),d},(n=s)[e="Promise"]=n[e]||r(),t.exports&&(t.exports=n[e])}),a=new WeakMap;function l(t,e,n){var r=a.get(t.element)||{};e in r||(r[e]=[]),r[e].push(n),a.set(t.element,r)}function f(t,e){return(a.get(t.element)||{})[e]||[]}function h(t,e,n){var r=a.get(t.element)||{};if(!r[e])return!0;if(!n)return r[e]=[],a.set(t.element,r),!0;var o=r[e].indexOf(n);return-1!==o&&r[e].splice(o,1),a.set(t.element,r),r[e]&&0===r[e].length}var d=["id","url","width","maxwidth","height","maxheight","portrait","title","byline","color","autoplay","autopause","loop","responsive","speed","background","transparent"];function p(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return d.reduce(function(e,n){var r=t.getAttribute("data-vimeo-"+n);return(r||""===r)&&(e[n]=""===r?1:r),e},e)}function y(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(r,o){if(!n(t))throw new TypeError("“"+t+"” is not a vimeo.com url.");var i="https://vimeo.com/api/oembed.json?url="+encodeURIComponent(t);for(var s in e)e.hasOwnProperty(s)&&(i+="&"+s+"="+encodeURIComponent(e[s]));var u="XDomainRequest"in window?new XDomainRequest:new XMLHttpRequest;u.open("GET",i,!0),u.onload=function(){if(404!==u.status)if(403!==u.status)try{var e=JSON.parse(u.responseText);r(e)}catch(t){o(t)}else o(new Error("“"+t+"” is not embeddable."));else o(new Error("“"+t+"” was not found."))},u.onerror=function(){var t=u.status?" ("+u.status+")":"";o(new Error("There was an error fetching the embed code from Vimeo"+t+"."))},u.send()})}function v(t,e){var n=t.html;if(!e)throw new TypeError("An element must be provided");if(null!==e.getAttribute("data-vimeo-initialized"))return e.querySelector("iframe");var r=document.createElement("div");return r.innerHTML=n,e.appendChild(r.firstChild),e.setAttribute("data-vimeo-initialized","true"),e.querySelector("iframe")}function b(t){return"string"==typeof t&&(t=JSON.parse(t)),t}function m(t,e,n){if(t.element.contentWindow&&t.element.contentWindow.postMessage){var r={method:e};void 0!==n&&(r.value=n);var o=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,"$1"));o>=8&&o<10&&(r=JSON.stringify(r)),t.element.contentWindow.postMessage(r,t.origin)}}function g(t,e){var n=[],r=void 0;if((e=b(e)).event){if("error"===e.event)f(t,e.data.method).forEach(function(n){var r=new Error(e.data.message);r.name=e.data.name,n.reject(r),h(t,e.data.method,n)});n=f(t,"event:"+e.event),r=e.data}else if(e.method){var o=function(t,e){var n=f(t,e);if(n.length<1)return!1;var r=n.shift();return h(t,e,r),r}(t,e.method);o&&(n.push(o),r=e.value)}n.forEach(function(e){try{if("function"==typeof e)return void e.call(t,r);e.resolve(r)}catch(t){}})}var w=function(){function t(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn("A jQuery object with multiple elements was passed, using the first element."),e=e[0]),"string"==typeof e&&(e=document.getElementById(e)),!function(t){return t instanceof window.HTMLElement}(e))throw new TypeError("You must pass either a valid element or a valid id.");if("IFRAME"!==e.nodeName){var s=e.querySelector("iframe");s&&(e=s)}if("IFRAME"===e.nodeName&&!n(e.getAttribute("src")||""))throw new Error("The player element passed isn’t a Vimeo embed.");if(_.has(e))return _.get(e);this.element=e,this.origin="*";var u=new c(function(t,s){var u=function(e){if(n(e.origin)&&o.element.contentWindow===e.source){"*"===o.origin&&(o.origin=e.origin);var r=b(e.data),i="event"in r&&"ready"===r.event,s="method"in r&&"ping"===r.method;if(i||s)return o.element.setAttribute("data-ready","true"),void t();g(o,r)}};if(window.addEventListener?window.addEventListener("message",u,!1):window.attachEvent&&window.attachEvent("onmessage",u),"IFRAME"!==o.element.nodeName){var c=p(e,i);y(r(c),c).then(function(t){var n,r,i,s=v(t,e);return o.element=s,n=e,r=s,i=a.get(n),a.set(r,i),a.delete(n),_.set(o.element,o),t}).catch(function(t){return s(t)})}});return E.set(this,u),_.set(this.element,this),"IFRAME"===this.element.nodeName&&m(this,"ping"),this}return w(t,[{key:"callMethod",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new c(function(r,o){return e.ready().then(function(){l(e,t,{resolve:r,reject:o}),m(e,t,n)})})}},{key:"get",value:function(t){var n=this;return new c(function(r,o){return t=e(t,"get"),n.ready().then(function(){l(n,t,{resolve:r,reject:o}),m(n,t)})})}},{key:"set",value:function(t,n){var r=this;return c.resolve(n).then(function(n){if(t=e(t,"set"),void 0===n||null===n)throw new TypeError("There must be a value to set.");return r.ready().then(function(){return new c(function(e,o){l(r,t,{resolve:e,reject:o}),m(r,t,n)})})})}},{key:"on",value:function(t,e){if(!t)throw new TypeError("You must pass an event name.");if(!e)throw new TypeError("You must pass a callback function.");if("function"!=typeof e)throw new TypeError("The callback must be a function.");0===f(this,"event:"+t).length&&this.callMethod("addEventListener",t).catch(function(){}),l(this,"event:"+t,e)}},{key:"off",value:function(t,e){if(!t)throw new TypeError("You must pass an event name.");if(e&&"function"!=typeof e)throw new TypeError("The callback must be a function.");h(this,"event:"+t,e)&&this.callMethod("removeEventListener",t).catch(function(t){})}},{key:"loadVideo",value:function(t){return this.callMethod("loadVideo",t)}},{key:"ready",value:function(){var t=E.get(this);return c.resolve(t)}},{key:"addCuePoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.callMethod("addCuePoint",{time:t,data:e})}},{key:"removeCuePoint",value:function(t){return this.callMethod("removeCuePoint",t)}},{key:"enableTextTrack",value:function(t,e){if(!t)throw new TypeError("You must pass a language.");return this.callMethod("enableTextTrack",{language:t,kind:e})}},{key:"disableTextTrack",value:function(){return this.callMethod("disableTextTrack")}},{key:"pause",value:function(){return this.callMethod("pause")}},{key:"play",value:function(){return this.callMethod("play")}},{key:"unload",value:function(){return this.callMethod("unload")}},{key:"getAutopause",value:function(){return this.get("autopause")}},{key:"setAutopause",value:function(t){return this.set("autopause",t)}},{key:"getColor",value:function(){return this.get("color")}},{key:"setColor",value:function(t){return this.set("color",t)}},{key:"getCuePoints",value:function(){return this.get("cuePoints")}},{key:"getCurrentTime",value:function(){return this.get("currentTime")}},{key:"setCurrentTime",value:function(t){return this.set("currentTime",t)}},{key:"getDuration",value:function(){return this.get("duration")}},{key:"getEnded",value:function(){return this.get("ended")}},{key:"getLoop",value:function(){return this.get("loop")}},{key:"setLoop",value:function(t){return this.set("loop",t)}},{key:"getPaused",value:function(){return this.get("paused")}},{key:"getPlaybackRate",value:function(){return this.get("playbackRate")}},{key:"setPlaybackRate",value:function(t){return this.set("playbackRate",t)}},{key:"getTextTracks",value:function(){return this.get("textTracks")}},{key:"getVideoEmbedCode",value:function(){return this.get("videoEmbedCode")}},{key:"getVideoId",value:function(){return this.get("videoId")}},{key:"getVideoTitle",value:function(){return this.get("videoTitle")}},{key:"getVideoWidth",value:function(){return this.get("videoWidth")}},{key:"getVideoHeight",value:function(){return this.get("videoHeight")}},{key:"getVideoUrl",value:function(){return this.get("videoUrl")}},{key:"getVolume",value:function(){return this.get("volume")}},{key:"setVolume",value:function(t){return this.set("volume",t)}}]),t}();return t||(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=function(t){"console"in window&&console.error&&console.error("There was an error creating an embed: "+t)};[].slice.call(t.querySelectorAll("[data-vimeo-id], [data-vimeo-url]")).forEach(function(t){try{if(null!==t.getAttribute("data-vimeo-defer"))return;var n=p(t);y(r(n),n).then(function(e){return v(e,t)}).catch(e)}catch(t){e(t)}})}(),function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=function(e){if(n(e.origin)&&e.data&&"spacechange"===e.data.event)for(var r=t.querySelectorAll("iframe"),o=0;o-1?t.split("?")[0]:t.indexOf("/")>-1?t.split("/")[0]:t}t.exports=function(t){if("string"!=typeof t)throw new TypeError("get-video-id expects a string");/