diff options
39 files changed, 624 insertions, 581 deletions
@@ -1,12 +1,7 @@ node_modules -*.sublime-project -*.sublime-workspace .DS_Store aws.json *.mp4 !dist/blank.mp4 index-*.html -notes.txt -.idea -.DS_Store npm-debug.log
\ No newline at end of file diff --git a/bundles.json b/bundles.json index 245c1d43..2f8807b1 100644 --- a/bundles.json +++ b/bundles.json @@ -1,22 +1,23 @@ { "plyr": { "less": { - "plyr.css": ["src/less/plyr.less"] + "plyr.css": "src/less/plyr.less" }, "scss": { - "plyr.css": ["src/scss/plyr.scss"] + "plyr.css": "src/scss/plyr.scss" }, "js": { - "plyr.js": ["src/js/plyr.js"] + "plyr.js": "src/js/plyr.js" } }, "demo": { "less": { - "demo.css": ["demo/src/less/demo.less"] + "demo.css": "demo/src/less/bundle.less" }, "js": { "demo.js": [ "demo/src/js/lib/classlist.js", + "demo/src/js/lib/tab-focus.js", "demo/src/js/lib/sprite.js", "demo/src/js/main.js" ] diff --git a/demo/dist/demo.css b/demo/dist/demo.css index e9ae6437..9626746d 100644 --- a/demo/dist/demo.css +++ b/demo/dist/demo.css @@ -1 +1 @@ -/*! normalize.css v2.1.3 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden],template{display:none}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}a{background:0 0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{font-size:2em;margin:.67em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}hr{-webkit-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}button,input{line-height:normal}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=search]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@font-face{font-family:Avenir;src:url(https://cdn.plyr.io/static/fonts/avenir-medium.woff2) format("woff2"),url(https://cdn.plyr.io/static/fonts/avenir-medium.woff) format("woff");font-style:normal;font-weight:500;font-display:swap}@font-face{font-family:Avenir;src:url(https://cdn.plyr.io/static/fonts/avenir-bold.woff2) format("woff2"),url(https://cdn.plyr.io/static/fonts/avenir-bold.woff) format("woff");font-style:normal;font-weight:700;font-display:swap}html{font-size:100%}body{font-family:Avenir,"Helvetica Neue",Helvetica,Arial,sans-serif;line-height:1.5;text-align:center;color:#55646b;font-weight:500;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}h1,h2{letter-spacing:-.025em;color:#3498db;margin:0 0 10px;line-height:1.2;font-weight:700}h1{font-size:64px;font-size:4rem}p,small{margin:0 0 20px}small{display:block;padding:0 10px;font-size:14px;font-size:.875rem}li,ul{list-style:none;margin:0;padding:0}a{text-decoration:none;color:#3498db;border-bottom:1px dotted currentColor;-webkit-transition:background .3s ease,color .3s ease,border .3s ease;transition:background .3s ease,color .3s ease,border .3s ease}a:focus,a:hover{color:#343f4a;border-bottom-color:transparent}a:focus{outline:thin dotted #343f4a;outline-offset:1px}a.logo{border:0}.color--vimeo{color:#19b7ed}.color--youtube{color:#cc181e}*,::after,::before{-webkit-box-sizing:border-box;box-sizing:border-box}[hidden]{display:none}html{height:100%;background:#f2f5f7 fixed}body{margin:0 auto 20px;padding:10px;max-width:1200px}@media (min-width:480px){body{margin-bottom:40px}}header{padding:20px;margin-bottom:20px}header p{font-size:18px;font-size:1.125rem}@media (min-width:480px){header{padding-top:60px;padding-bottom:60px}}.icon{fill:currentColor;width:18px;height:18px;vertical-align:-3px}a svg,button svg,label svg{pointer-events:none}.btn .icon,a .icon{margin-right:10px}.btn:not(.btn-large) .icon{width:16px;height:16px}nav ul{list-style:none;margin:0;padding:0;font-size:0}nav li{display:inline-block;margin-top:10px;font-size:16px;font-size:1rem;white-space:nowrap}nav li+li{margin-left:20px}.btn__bar{position:relative;margin:0 auto 20px;max-width:1200px;white-space:nowrap}.btn__bar::before{content:"";position:absolute;top:50%;left:0;right:0;height:1px;background:#dbe3e8}.btn__bar ul{position:relative;z-index:1;display:inline-block;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.btn__bar li{margin:0}.btn__bar li:first-child .btn{border-radius:4px 0 0 4px}.btn__bar li:last-child .btn{border-radius:0 4px 4px 0}.btn__bar li+li .btn{margin-left:-1px}.btn__bar li.active .btn{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.2);box-shadow:inset 0 1px 1px rgba(0,0,0,.2);position:relative;z-index:1}.btn__bar li.active .btn .icon{color:inherit}.btn__bar li.active+li .btn:hover{z-index:0}.btn__bar .btn{position:relative;display:block;border-radius:0}.btn__bar .btn:focus,.btn__bar .btn:hover{z-index:1}@media (min-width:560px){.btn__bar{margin-bottom:40px}}.btn,.btn__count{display:inline-block;vertical-align:middle;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-weight:700}.btn{padding:10px 12px;background:-webkit-gradient(linear,left top,left bottom,from(#f8fafb),to(#e9eef1));background:linear-gradient(#f8fafb,#e9eef1);border:1px solid #cbd0d3;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05);text-shadow:0 1px 1px #fff;color:#55646b;-webkit-transition:background .1s ease,color .1s ease;transition:background .1s ease,color .1s ease;font-size:14px;font-size:.875rem}.btn:focus,.btn:hover{border-color:#b5bcc0;color:#55646b;outline:0}.btn--large{padding:10px 20px;font-size:16px;font-size:1rem}.btn--primary,.btn__bar li.active .btn{background-image:-webkit-gradient(linear,left top,left bottom,from(#3498db),to(#258cd1));background-image:linear-gradient(#3498db,#258cd1);background-color:#3498db;border-color:#217dbb;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.15);box-shadow:0 1px 1px rgba(0,0,0,.15);text-shadow:0 1px 1px rgba(0,0,0,.1);color:#fff}.btn--primary:focus,.btn--primary:hover{color:#fff;border-color:#196090}.btn--youtube .icon{color:#cc181e}.btn--vimeo .icon{color:#19b7ed}.btn--twitter .icon{color:#4baaf4}.btn__count{position:relative;margin-left:10px;padding:10px 15px;background:#fff;border:1px solid #cbd0d3}.btn__count::before{content:"";position:absolute;display:block;width:8px;height:8px;left:1px;top:50%;margin-top:-4px;background:inherit;border:inherit;border-width:1px 0 0 1px;-webkit-transform:rotate(-45deg) translate(-50%,-50%);transform:rotate(-45deg) translate(-50%,-50%)}.error body,html.error{height:100%}.error body{width:100%;display:table;table-layout:fixed}.error main{display:table-cell;width:100%;vertical-align:middle}video{max-width:100%;vertical-align:middle}.plyr{margin:0 auto;border-radius:6px}.plyr--audio{max-width:520px}.plyr__video-wrapper::after{content:"";pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0;border:1px solid rgba(0,0,0,.15);border-radius:inherit}.plyr__cite{display:none;margin-top:20px}.plyr__cite .icon{margin-right:5px}.plyr--audio~ul .plyr__cite--audio,.plyr--video:not(.plyr--youtube):not(.plyr--vimeo)~ul .plyr__cite--video,.plyr--vimeo~ul .plyr__cite--vimeo,.plyr--youtube~ul .plyr__cite--youtube{display:block}
\ No newline at end of file +@-webkit-keyframes fadein{0%{opacity:0}100%{opacity:1}}@keyframes fadein{0%{opacity:0}100%{opacity:1}}@font-face{font-family:Avenir;src:url(https://cdn.plyr.io/static/fonts/avenir-medium.woff2) format("woff2"),url(https://cdn.plyr.io/static/fonts/avenir-medium.woff) format("woff");font-style:normal;font-weight:500;font-display:swap}@font-face{font-family:Avenir;src:url(https://cdn.plyr.io/static/fonts/avenir-bold.woff2) format("woff2"),url(https://cdn.plyr.io/static/fonts/avenir-bold.woff) format("woff");font-style:normal;font-weight:700;font-display:swap}@font-face{font-family:Avenir;src:url(https://cdn.plyr.io/static/fonts/avenir-black.woff2?v=3) format("woff2"),url(https://cdn.plyr.io/static/fonts/avenir-black.woff?v=3) format("woff");font-style:normal;font-weight:900;font-display:swap}/*! normalize.css v2.1.3 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden],template{display:none}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}a,button.faux-link{background:0 0}a:focus,button.faux-link:focus{outline:thin dotted}a:active,a:hover,button.faux-link:active,button.faux-link:hover{outline:0}h1{font-size:2em;margin:.67em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}hr{-webkit-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}button,input{line-height:normal}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=search]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}html{background:-webkit-gradient(linear,right bottom,left top,from(#67caff),to(#0085cd));background:linear-gradient(to left top,#67caff,#0085cd);background-attachment:fixed}body,html{height:100%}body{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}main{text-align:center}.grid{-webkit-box-flex:1;-ms-flex:1;flex:1}aside{width:100%;padding:15px;background:#fff;text-align:center;color:#55646b;text-shadow:none}aside a,aside button.faux-link{color:#4baaf4}aside a.tab-focus,aside button.faux-link.tab-focus{outline:0;-webkit-box-shadow:0 0 0 3px rgba(75,170,244,.35);box-shadow:0 0 0 3px rgba(75,170,244,.35)}.grid{margin:0 auto;padding:20px}@media only screen and (min-width:768px){.grid{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:100%;max-width:1280px}.grid>*{-webkit-box-flex:1;-ms-flex:1;flex:1}}html{font-size:100%}body{font-family:Avenir,'Helvetica Neue',sans-serif;line-height:1.5;color:#fff;font-weight:500;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;text-shadow:0 1px 1px rgba(0,0,0,.15)}button,input,select,textarea{font:inherit}p,small{margin:0 0 20px}small{display:block;font-size:14px;font-size:.875rem}h1{margin:0 0 10px;font-size:64px;font-size:4rem;font-weight:900;letter-spacing:-.025em}.button,.button__count{position:relative;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:15px;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.1);box-shadow:0 1px 1px rgba(0,0,0,.1);background:#fff;border:0;color:#55646b;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-weight:700;text-shadow:none}.button{padding-left:20px;padding-right:20px;-webkit-transition:all .2s ease;transition:all .2s ease}.button:focus,.button:hover{color:#343f4a;outline:0}.button:focus::after,.button:hover::after{display:none}.button.tab-focus{outline:0;-webkit-box-shadow:0 0 0 3px rgba(255,255,255,.35);box-shadow:0 0 0 3px rgba(255,255,255,.35)}.button__count{margin-left:10px;-webkit-animation:fadein .2s ease;animation:fadein .2s ease}.button__count::before{content:'';position:absolute;display:block;width:8px;height:8px;left:1px;top:50%;margin-top:-4px;background:inherit;border:inherit;border-width:1px 0 0 1px;-webkit-transform:rotate(-45deg) translate(-50%,-50%);transform:rotate(-45deg) translate(-50%,-50%)}header{padding:20px;text-align:center}header p{font-size:18px;font-size:1.125rem;margin-bottom:30px}@media only screen and (min-width:480px){header{padding-top:60px;padding-bottom:60px}}@media only screen and (min-width:768px){header{max-width:400px;margin-right:40px;text-align:left}}.icon{fill:currentColor;width:18px;height:18px}a svg,button svg,button.faux-link svg,label svg{pointer-events:none}.btn .icon,a .icon,button.faux-link .icon{margin-right:10px}button.faux-link{position:relative;margin:0;padding:0;width:auto;border:0;background:0 0;vertical-align:baseline;text-align:inherit;font:inherit;line-height:1.5;cursor:pointer;-moz-user-select:text;text-shadow:inherit;border-radius:0}a,button.faux-link{position:relative;border-bottom:1px dotted currentColor;-webkit-transition:all .2s ease;transition:all .2s ease;text-decoration:none;color:#fff;font-weight:700}a::after,button.faux-link::after{content:'';position:absolute;top:100%;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);width:0;height:1px;-webkit-transition:width .2s ease;transition:width .2s ease;background:currentColor}a:focus,a:hover,button.faux-link:focus,button.faux-link:hover{border-bottom-color:transparent;outline:0}a:focus::after,a:hover::after,button.faux-link:focus::after,button.faux-link:hover::after{width:100%}a.tab-focus,button.faux-link.tab-focus{outline:0;-webkit-box-shadow:0 0 0 3px rgba(255,255,255,.35);box-shadow:0 0 0 3px rgba(255,255,255,.35)}li,ul{list-style:none;margin:0;padding:0}nav{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin-bottom:20px}video{max-width:100%;vertical-align:middle}.plyr{margin:0 auto;border-radius:4px;-webkit-box-shadow:0 2px 5px rgba(0,0,0,.2);box-shadow:0 2px 5px rgba(0,0,0,.2)}.plyr__video-wrapper::after{content:'';pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0;border:1px solid rgba(0,0,0,.15);border-radius:inherit}.plyr__cite{display:none;margin-top:20px}.plyr__cite .icon{margin-right:5px}.plyr--audio~ul .plyr__cite--audio,.plyr--video:not(.plyr--youtube):not(.plyr--vimeo)~ul .plyr__cite--video,.plyr--vimeo~ul .plyr__cite--vimeo,.plyr--youtube~ul .plyr__cite--youtube{display:block}
\ No newline at end of file diff --git a/demo/dist/demo.js b/demo/dist/demo.js index 77408968..df52f680 100644 --- a/demo/dist/demo.js +++ b/demo/dist/demo.js @@ -1 +1 @@ -"document"in self&&("classList"in document.createElement("_")?function(){"use strict";var t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var i,o=arguments.length;for(i=0;i<o;i++)t=arguments[i],e.call(this,t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var i=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:i.call(this,t)}}t=null}():function(t){"use strict";if("Element"in t){var e=t.Element.prototype,i=Object,o=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},n=Array.prototype.indexOf||function(t){for(var e=0,i=this.length;e<i;e++)if(e in this&&this[e]===t)return e;return-1},r=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},s=function(t,e){if(""===e)throw new r("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new r("INVALID_CHARACTER_ERR","String contains an invalid character");return n.call(t,e)},a=function(t){for(var e=o.call(t.getAttribute("class")||""),i=e?e.split(/\s+/):[],n=0,r=i.length;n<r;n++)this.push(i[n]);this._updateClassName=function(){t.setAttribute("class",this.toString())}},c=a.prototype=[],l=function(){return new a(this)};if(r.prototype=Error.prototype,c.item=function(t){return this[t]||null},c.contains=function(t){return t+="",-1!==s(this,t)},c.add=function(){var t,e=arguments,i=0,o=e.length,n=!1;do{t=e[i]+"",-1===s(this,t)&&(this.push(t),n=!0)}while(++i<o);n&&this._updateClassName()},c.remove=function(){var t,e,i=arguments,o=0,n=i.length,r=!1;do{for(t=i[o]+"",e=s(this,t);-1!==e;)this.splice(e,1),r=!0,e=s(this,t)}while(++o<n);r&&this._updateClassName()},c.toggle=function(t,e){t+="";var i=this.contains(t),o=i?!0!==e&&"remove":!1!==e&&"add";return o&&this[o](t),!0===e||!1===e?e:!i},c.toString=function(){return this.join(" ")},i.defineProperty){var u={get:l,enumerable:!0,configurable:!0};try{i.defineProperty(e,"classList",u)}catch(t){-2146823252===t.number&&(u.enumerable=!1,i.defineProperty(e,"classList",u))}}else i.prototype.__defineGetter__&&e.__defineGetter__("classList",l)}}(self)),window.loadSprite=function(t,e){function i(t,e){t.innerHTML=e,o.insertBefore(t,o.childNodes[0])}if("string"==typeof t){var o=document.body,n="string"==typeof e,r=function(){if(!n)return!1;try{return localStorage.setItem("___test","___test"),localStorage.removeItem("___test"),!0}catch(t){return!1}}();if(!n||0===document.querySelectorAll("#"+e).length){var s=document.createElement("div");if(s.setAttribute("hidden",""),n&&s.setAttribute("id",e),r){var a=localStorage.getItem("cache-"+e);if(null!==a){var c=JSON.parse(a);i(s,c.content)}}var l=new XMLHttpRequest;if(!("withCredentials"in l))return;l.open("GET",t,!0),l.onload=function(){r&&localStorage.setItem("cache-"+e,JSON.stringify({content:l.responseText})),i(s,l.responseText)},l.send()}}},function(){function t(t,e,i){if(t)if(t.classList)t.classList[i?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(/\s+/g," ").replace(" "+e+" ","");t.className=o+(i?" "+e:"")}}function e(e,s){if(e in n&&(s||e!==r)&&(r.length||e!==n.video)){switch(e){case n.video:i.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4",type:"video/mp4"}],poster:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg",tracks:[{kind:"captions",label:"English",srclang:"en",src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt",default:!0},{kind:"captions",label:"French",srclang:"fr",src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"}]});break;case n.audio:i.source({type:"audio",title:"Kishi Bashi – “It All Began With A Burst”",sources:[{src:"https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3",type:"audio/mp3"},{src:"https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg",type:"audio/ogg"}]});break;case n.youtube:i.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://www.youtube.com/watch?v=bTqVqk7FSmY",type:"youtube"}]});break;case n.vimeo:i.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://vimeo.com/76979871",type:"vimeo"}]})}r=e;for(var a=o.length-1;a>=0;a--)t(o[a].parentElement,"active",!1);t(document.querySelector('[data-source="'+e+'"]').parentElement,"active",!0),[].forEach.call(document.querySelectorAll(".plyr__cite"),function(t){t.setAttribute("hidden","")}),document.querySelector(".plyr__cite--"+e).removeAttribute("hidden")}}var i=new Plyr("#player",{debug:!0,title:"View From A Blue Moon",iconUrl:"../dist/plyr.svg",tooltips:{controls:!0},captions:{defaultActive:!0},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","fullscreen","pip","airplay"]});window.player=i,window.loadSprite("dist/demo.svg","demo-sprite");var o=document.querySelectorAll("[data-source]"),n={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},r=window.location.hash.replace("#",""),s=window.history&&window.history.pushState;if([].forEach.call(o,function(t){t.addEventListener("click",function(){var t=this.getAttribute("data-source");e(t),s&&history.pushState({type:t},"","#"+t)})}),window.addEventListener("popstate",function(t){t.state&&"type"in t.state&&e(t.state.type)}),s){var a=!r.length;a&&(r=n.video),r in n&&history.replaceState({type:r},"",a?"":"#"+r),r!==n.video&&e(r,!0)}}(),"plyr.io"===window.location.host&&(!function(t,e,i,o,n,r,s){t.GoogleAnalyticsObject=n,t[n]=t[n]||function(){(t[n].q=t[n].q||[]).push(arguments)},t[n].l=1*new Date,r=e.createElement(i),s=e.getElementsByTagName(i)[0],r.async=1,r.src="//www.google-analytics.com/analytics.js",s.parentNode.insertBefore(r,s)}(window,document,"script",0,"ga"),window.ga("create","UA-40881672-11","auto"),window.ga("send","pageview"));
\ No newline at end of file +"document"in self&&("classList"in document.createElement("_")?function(){"use strict";var t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var o,i=arguments.length;for(o=0;o<i;o++)t=arguments[o],e.call(this,t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var o=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:o.call(this,t)}}t=null}():function(t){"use strict";if("Element"in t){var e=t.Element.prototype,o=Object,i=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},n=Array.prototype.indexOf||function(t){for(var e=0,o=this.length;e<o;e++)if(e in this&&this[e]===t)return e;return-1},r=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},s=function(t,e){if(""===e)throw new r("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new r("INVALID_CHARACTER_ERR","String contains an invalid character");return n.call(t,e)},a=function(t){for(var e=i.call(t.getAttribute("class")||""),o=e?e.split(/\s+/):[],n=0,r=o.length;n<r;n++)this.push(o[n]);this._updateClassName=function(){t.setAttribute("class",this.toString())}},c=a.prototype=[],l=function(){return new a(this)};if(r.prototype=Error.prototype,c.item=function(t){return this[t]||null},c.contains=function(t){return t+="",-1!==s(this,t)},c.add=function(){var t,e=arguments,o=0,i=e.length,n=!1;do{t=e[o]+"",-1===s(this,t)&&(this.push(t),n=!0)}while(++o<i);n&&this._updateClassName()},c.remove=function(){var t,e,o=arguments,i=0,n=o.length,r=!1;do{for(t=o[i]+"",e=s(this,t);-1!==e;)this.splice(e,1),r=!0,e=s(this,t)}while(++i<n);r&&this._updateClassName()},c.toggle=function(t,e){t+="";var o=this.contains(t),i=o?!0!==e&&"remove":!1!==e&&"add";return i&&this[i](t),!0===e||!1===e?e:!o},c.toString=function(){return this.join(" ")},o.defineProperty){var u={get:l,enumerable:!0,configurable:!0};try{o.defineProperty(e,"classList",u)}catch(t){-2146823252===t.number&&(u.enumerable=!1,o.defineProperty(e,"classList",u))}}else o.prototype.__defineGetter__&&e.__defineGetter__("classList",l)}}(self)),document.addEventListener("focusout",function(t){t.target.classList.remove("tab-focus")}),document.addEventListener("keydown",function(t){9===t.keyCode&&window.setTimeout(function(){document.activeElement.classList.add("tab-focus")},0)}),window.loadSprite=function(t,e){function o(t,e){t.innerHTML=e,i.insertBefore(t,i.childNodes[0])}if("string"==typeof t){var i=document.body,n="string"==typeof e,r=function(){if(!n)return!1;try{return localStorage.setItem("___test","___test"),localStorage.removeItem("___test"),!0}catch(t){return!1}}();if(!n||0===document.querySelectorAll("#"+e).length){var s=document.createElement("div");if(s.setAttribute("hidden",""),n&&s.setAttribute("id",e),r){var a=localStorage.getItem("cache-"+e);if(null!==a){var c=JSON.parse(a);o(s,c.content)}}var l=new XMLHttpRequest;if(!("withCredentials"in l))return;l.open("GET",t,!0),l.onload=function(){r&&localStorage.setItem("cache-"+e,JSON.stringify({content:l.responseText})),o(s,l.responseText)},l.send()}}},function(){function t(t,e,o){t&&t.classList[o?"add":"remove"](e)}function e(e,s){if(e in n&&(s||e!==r)&&(r.length||e!==n.video)){switch(e){case n.video:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4",type:"video/mp4"}],poster:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg",tracks:[{kind:"captions",label:"English",srclang:"en",src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt",default:!0},{kind:"captions",label:"French",srclang:"fr",src:"https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"}]});break;case n.audio:o.source({type:"audio",title:"Kishi Bashi – “It All Began With A Burst”",sources:[{src:"https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3",type:"audio/mp3"},{src:"https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg",type:"audio/ogg"}]});break;case n.youtube:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://www.youtube.com/watch?v=bTqVqk7FSmY",type:"youtube"}]});break;case n.vimeo:o.source({type:"video",title:"View From A Blue Moon",sources:[{src:"https://vimeo.com/76979871",type:"vimeo"}]})}r=e;for(var a=i.length-1;a>=0;a--)t(i[a].parentElement,"active",!1);t(document.querySelector('[data-source="'+e+'"]'),"active",!0),[].forEach.call(document.querySelectorAll(".plyr__cite"),function(t){t.setAttribute("hidden","")}),document.querySelector(".plyr__cite--"+e).removeAttribute("hidden")}}window.shr&&window.shr.setup({count:{classname:"button__count"}});var o=new Plyr("#player",{debug:!0,title:"View From A Blue Moon",iconUrl:"../dist/plyr.svg",tooltips:{controls:!0},captions:{defaultActive:!0},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","fullscreen","pip","airplay"]});window.player=o,window.loadSprite("dist/demo.svg","demo-sprite");var i=document.querySelectorAll("[data-source]"),n={video:"video",audio:"audio",youtube:"youtube",vimeo:"vimeo"},r=window.location.hash.replace("#",""),s=window.history&&window.history.pushState;if([].forEach.call(i,function(t){t.addEventListener("click",function(){var t=this.getAttribute("data-source");e(t),s&&history.pushState({type:t},"","#"+t)})}),window.addEventListener("popstate",function(t){t.state&&"type"in t.state&&e(t.state.type)}),s){var a=!r.length;a&&(r=n.video),r in n&&history.replaceState({type:r},"",a?"":"#"+r),r!==n.video&&e(r,!0)}}(),"plyr.io"===window.location.host&&(!function(t,e,o,i,n,r,s){t.GoogleAnalyticsObject=n,t[n]=t[n]||function(){(t[n].q=t[n].q||[]).push(arguments)},t[n].l=1*new Date,r=e.createElement(o),s=e.getElementsByTagName(o)[0],r.async=1,r.src="//www.google-analytics.com/analytics.js",s.parentNode.insertBefore(r,s)}(window,document,"script",0,"ga"),window.ga("create","UA-40881672-11","auto"),window.ga("send","pageview"));
\ No newline at end of file diff --git a/demo/index.html b/demo/index.html index 42fb84c1..15112ddd 100644 --- a/demo/index.html +++ b/demo/index.html @@ -17,126 +17,92 @@ <!-- Preload --> <link rel="preload" as="font" crossorigin type="font/woff2" href="https://cdn.plyr.io/static/fonts/avenir-medium.woff2"> <link rel="preload" as="font" crossorigin type="font/woff2" href="https://cdn.plyr.io/static/fonts/avenir-bold.woff2"> + <link rel="preload" as="font" crossorigin type="font/woff2" href="https://cdn.plyr.io/static/fonts/avenir-black.woff2?v=3"> </head> <body> - <header> - <h1>Plyr</h1> - <p>A simple, accessible HTML5 media player by - <a href="https://twitter.com/sam_potts" target="_blank">@sam_potts</a> - </p> - <nav> - <ul> - <li> - <a href="https://github.com/sampotts/plyr" target="_blank" class="btn btn--large btn--primary" data-shr-network="github"> - <svg class="icon"> - <use xlink:href="#icon-github"></use> - </svg>Download on GitHub - </a> - </li> - <li> - <a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts" - target="_blank" class="btn btn--large btn--twitter" data-shr-network="twitter"> - <svg class="icon"> - <use xlink:href="#icon-twitter"></use> - </svg>Tweet - </a> - </li> - </ul> - </nav> - </header> + <div class="grid"> + <header> + <h1>Plyr</h1> + <p>A simple, accessible HTML5 + <button type="button" class="faux-link" data-source="video">Video</button>, + <button type="button" class="faux-link" data-source="audio">Audio</button>, + <button type="button" class="faux-link" data-source="youtube">YouTube</button> and + <button type="button" class="faux-link" data-source="vimeo">Vimeo</button> media player. + </p> + + <a href="https://github.com/sampotts/plyr" target="_blank" class="button" data-shr-network="github"> + <svg class="icon"> + <use xlink:href="#icon-github"></use> + </svg>Download on GitHub + </a> + </header> + + <main> + <video controls crossorigin playsinline loop poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg" + id="player"> + <!-- Video files --> + <source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4" type="video/mp4"> + + <!-- Text track file --> + <track kind="captions" label="English" srclang="en" src="webvtt/View_From_A_Blue_Moon_Trailer-HD.en.vtt" default> + <track kind="captions" label="Français" srclang="fr" src="webvtt/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"> + + <!-- Fallback for browsers that don't support the <video> element --> + <a href="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4" download>Download</a> + </video> - <main role="main" id="main"> - <nav class="btn__bar"> <ul> - <li class="active"> - <button type="button" class="btn" data-source="video">Video</button> + <li class="plyr__cite plyr__cite--video" hidden> + <small> + <a href="http://viewfromabluemoon.com/" target="_blank">View From A Blue Moon</a> © Brainfarm + </small> </li> - <li> - <button type="button" class="btn" data-source="audio">Audio</button> + <li class="plyr__cite plyr__cite--audio" hidden> + <small> + <a href="http://www.kishibashi.com/" target="_blank">Kishi Bashi – “It All Began With A Burst”</a> © Kishi Bashi + </small> </li> - <li> - <button type="button" class="btn btn--youtube" data-source="youtube"> - <svg class="icon"> - <use xlink:href="#icon-youtube"></use> - </svg>YouTube</button> + <li class="plyr__cite plyr__cite--youtube" hidden> + <small> + <a href="https://www.youtube.com/watch?v=bTqVqk7FSmY" target="_blank">View From A Blue Moon</a> on + <span class="color--youtube"> + <svg class="icon"> + <use xlink:href="#icon-youtube"></use> + </svg> YouTube + </span> + </small> </li> - <li> - <button type="button" class="btn btn--vimeo" data-source="vimeo"> - <svg class="icon"> - <use xlink:href="#icon-vimeo"></use> - </svg>Vimeo</button> + <li class="plyr__cite plyr__cite--vimeo" hidden> + <small> + <a href="https://vimeo.com/ondemand/viewfromabluemoon4k" target="_blank">View From A Blue Moon</a> on + <span class="color--vimeo"> + <svg class="icon"> + <use xlink:href="#icon-vimeo"></use> + </svg> Vimeo + </span> + </small> </li> </ul> - </nav> - - <video controls crossorigin playsinline loop poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg" - id="player"> - <!-- Video files --> - <source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4" type="video/mp4"> - - <!-- Text track file --> - <track kind="captions" label="English" srclang="en" src="webvtt/View_From_A_Blue_Moon_Trailer-HD.en.vtt" default> - <track kind="captions" label="Français" srclang="fr" src="webvtt/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"> - - <!-- Fallback for browsers that don't support the <video> element --> - <a href="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4" download>Download</a> - </video> - - <ul> - <li class="plyr__cite plyr__cite--video" hidden> - <small> - <a href="http://viewfromabluemoon.com/" target="_blank">View From A Blue Moon</a> © Brainfarm - </small> - </li> - <li class="plyr__cite plyr__cite--audio" hidden> - <small> - <a href="http://www.kishibashi.com/" target="_blank">Kishi Bashi – “It All Began With A Burst”</a> © Kishi Bashi - </small> - </li> - <li class="plyr__cite plyr__cite--youtube" hidden> - <small> - <a href="https://www.youtube.com/watch?v=bTqVqk7FSmY" target="_blank">View From A Blue Moon</a> on - <span class="color--youtube"> - <svg class="icon"> - <use xlink:href="#icon-youtube"></use> - </svg> YouTube - </span> - </small> - </li> - <li class="plyr__cite plyr__cite--vimeo" hidden> - <small> - <a href="https://vimeo.com/ondemand/viewfromabluemoon4k" target="_blank">View From A Blue Moon</a> on - <span class="color--vimeo"> - <svg class="icon"> - <use xlink:href="#icon-vimeo"></use> - </svg> Vimeo - </span> - </small> - </li> - </ul> - </main> + </main> + </div> + + <aside>If you like Plyr, get the word out and + <a href="https://twitter.com/intent/tweet?text=A+simple+HTML5+media+player+with+custom+controls+and+WebVTT+captions.&url=http%3A%2F%2Fplyr.io&via=Sam_Potts" + target="_blank" data-shr-network="twitter">tweet it</a> + </aside> <!-- Plyr core script --> <script src="../src/js/plyr.js"></script> - <!-- Docs script --> - <script src="dist/demo.js"></script> + <!-- Sharing libary (https://shr.one) --> + <script src="https://cdn.shr.one/1.0.1/shr.js"></script> <!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) --> <script src="https://cdn.rangetouch.com/1.0.1/rangetouch.js" async></script> - <!-- Sharing libary (https://shr.one) --> - <script src="https://cdn.shr.one/1.0.1/shr.js"></script> - <script> - if (window.shr) { - window.shr.setup({ - count: { - classname: 'btn__count' - } - }); - } - </script> + <!-- Docs script --> + <script src="dist/demo.js"></script> </body> </html>
\ No newline at end of file diff --git a/demo/src/js/lib/tab-focus.js b/demo/src/js/lib/tab-focus.js new file mode 100644 index 00000000..06e51203 --- /dev/null +++ b/demo/src/js/lib/tab-focus.js @@ -0,0 +1,26 @@ +// ========================================================================== +// tab-focus.js +// Detect keyboard tabbing +// ========================================================================== + +(function() { + var className = 'tab-focus'; + + // Remove class on blur + document.addEventListener('focusout', function(event) { + event.target.classList.remove(className); + }); + + // Add classname to tabbed elements + document.addEventListener('keydown', function(event) { + if (event.keyCode !== 9) { + return; + } + + // Delay the adding of classname until the focus has changed + // This event fires before the focusin event + window.setTimeout(function() { + document.activeElement.classList.add(className); + }, 0); + }); +})(); diff --git a/demo/src/js/main.js b/demo/src/js/main.js index 2442b01f..16c31f1c 100644 --- a/demo/src/js/main.js +++ b/demo/src/js/main.js @@ -7,6 +7,14 @@ /*global Plyr*/ (function() { + if (window.shr) { + window.shr.setup({ + count: { + classname: 'button__count', + }, + }); + } + /*document.body.addEventListener('ready', function(event) { console.log(event); });*/ @@ -17,10 +25,10 @@ title: 'View From A Blue Moon', iconUrl: '../dist/plyr.svg', tooltips: { - controls: true + controls: true, }, captions: { - defaultActive: true + defaultActive: true, }, controls: [ 'play-large', @@ -33,8 +41,8 @@ 'settings', 'fullscreen', 'pip', - 'airplay' - ] + 'airplay', + ], }); // Expose for testing @@ -49,7 +57,7 @@ video: 'video', audio: 'audio', youtube: 'youtube', - vimeo: 'vimeo' + vimeo: 'vimeo', }; var currentType = window.location.hash.replace('#', ''); var historySupport = window.history && window.history.pushState; @@ -64,7 +72,7 @@ if (historySupport) { history.pushState( { - type: type + type: type, }, '', '#' + type @@ -93,7 +101,7 @@ if (currentType in types) { history.replaceState( { - type: currentType + type: currentType, }, '', video ? '' : '#' + currentType @@ -109,12 +117,7 @@ // Toggle class on an element function toggleClass(element, className, state) { if (element) { - if (element.classList) { - element.classList[state ? 'add' : 'remove'](className); - } else { - var name = (' ' + element.className + ' ').replace(/\s+/g, ' ').replace(' ' + className + ' ', ''); - element.className = name + (state ? ' ' + className : ''); - } + element.classList[state ? 'add' : 'remove'](className); } } @@ -133,8 +136,8 @@ sources: [ { src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4', - type: 'video/mp4' - } + type: 'video/mp4', + }, ], poster: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg', tracks: [ @@ -143,15 +146,15 @@ label: 'English', srclang: 'en', src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt', - default: true + default: true, }, { kind: 'captions', label: 'French', srclang: 'fr', - src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt' - } - ] + src: 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt', + }, + ], }); break; @@ -162,13 +165,13 @@ sources: [ { src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3', - type: 'audio/mp3' + type: 'audio/mp3', }, { src: 'https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg', - type: 'audio/ogg' - } - ] + type: 'audio/ogg', + }, + ], }); break; @@ -179,9 +182,9 @@ sources: [ { src: 'https://www.youtube.com/watch?v=bTqVqk7FSmY', - type: 'youtube' - } - ] + type: 'youtube', + }, + ], }); break; @@ -192,9 +195,9 @@ sources: [ { src: 'https://vimeo.com/76979871', - type: 'vimeo' - } - ] + type: 'vimeo', + }, + ], }); break; } @@ -208,7 +211,7 @@ } // Set active on parent - toggleClass(document.querySelector('[data-source="' + type + '"]').parentElement, 'active', true); + toggleClass(document.querySelector('[data-source="' + type + '"]'), 'active', true); // Show cite [].forEach.call(document.querySelectorAll('.plyr__cite'), function(cite) { diff --git a/demo/src/less/bundle.less b/demo/src/less/bundle.less new file mode 100644 index 00000000..2645d653 --- /dev/null +++ b/demo/src/less/bundle.less @@ -0,0 +1,35 @@ +// ========================================================================== +// Plyr.io Demo Page +// ========================================================================== + +// Libs +@import 'lib/animation'; +@import 'lib/fontface'; +@import 'lib/mixins'; +@import 'lib/normalize'; + +// Settings +@import 'settings/breakpoints'; +@import 'settings/colors'; +@import 'settings/cosmetic'; +@import 'settings/icons'; +@import 'settings/layout'; +@import 'settings/spacing'; +@import 'settings/type'; + +// Layout +@import 'layout/core'; +@import 'layout/grid'; + +// Type +@import 'type/base'; +@import 'type/headings'; + +// Components +@import 'components/buttons'; +@import 'components/header'; +@import 'components/icons'; +@import 'components/links'; +@import 'components/lists'; +@import 'components/navigation'; +@import 'components/players'; diff --git a/demo/src/less/components/base.less b/demo/src/less/components/base.less deleted file mode 100644 index 7e5f97c6..00000000 --- a/demo/src/less/components/base.less +++ /dev/null @@ -1,43 +0,0 @@ -// ========================================================================== -// Base layout -// ========================================================================== - -// BORDER-BOX ALL THE THINGS! -// http://paulirish.com/2012/box-sizing-border-box-ftw/ -*, *::after, *::before { - box-sizing: border-box; -} - -// Hidden -[hidden] { - display: none; -} - -// Base -html { - height: 100%; - background: @body-background fixed; -} -body { - margin: 0 auto @padding-base; - padding: (@padding-base / 2); - max-width: @example-width-video; - - @media (min-width: @screen-sm) { - margin-bottom: (@padding-base * 2); - } -} - -// Header -header { - padding: @padding-base; - margin-bottom: @padding-base; - - p { - .font-size(18); - } - @media (min-width: @screen-sm) { - padding-top: (@padding-base * 3); - padding-bottom: (@padding-base * 3); - } -}
\ No newline at end of file diff --git a/demo/src/less/components/buttons.less b/demo/src/less/components/buttons.less index c99a0836..ed605086 100644 --- a/demo/src/less/components/buttons.less +++ b/demo/src/less/components/buttons.less @@ -2,171 +2,65 @@ // Buttons // ========================================================================== -nav { - ul { - list-style: none; - margin: 0; - padding: 0; - font-size: 0; - } - li { - display: inline-block; - margin-top: (@padding-base / 2); - .font-size(); - white-space: nowrap; - } - li + li { - margin-left: @padding-base; - } -} - -// Tabs -.btn__bar { - position: relative; - margin: 0 auto @padding-base; - max-width: @example-width-video; - white-space: nowrap; - - &::before { - content: ""; - position: absolute; - top: 50%; - left: 0; - right: 0; - height: 1px; - background: @gray-lighter; - } - - ul { - position: relative; - z-index: 1; - display: inline-block; - user-select: none; - } - li { - margin: 0; - - &:first-child .btn { - border-radius: 4px 0 0 4px; - } - &:last-child .btn { - border-radius: 0 4px 4px 0; - } - & + li .btn { - margin-left: -1px; - } - - &.active .btn { - &:extend(.btn--primary); - box-shadow: inset 0 1px 1px rgba(0,0,0, .2); - position: relative; - z-index: 1; - - .icon { - color: inherit; - } - } - &.active + li .btn:hover { - z-index: 0; - } - } - .btn { - position: relative; - display: block; - border-radius: 0; - - &:hover, - &:focus { - z-index: 1; - } - } - - @media (min-width: 560px) { - margin-bottom: (@padding-base * 2); - } -} - // Shared -.btn, -.btn__count { - display: inline-block; - vertical-align: middle; - border-radius: @border-radius-base; - user-select: none; - font-weight: @font-weight-bold; +.button, +.button__count { + position: relative; + display: inline-flex; + vertical-align: middle; + align-items: center; + padding: (@spacing-base * 0.75); + + border-radius: @border-radius-base; + box-shadow: 0 1px 1px fade(#000, 10%); + background: #fff; + border: 0; + + color: @gray; + user-select: none; + font-weight: @font-weight-bold; + text-shadow: none; } // Buttons -.btn { - padding: (@padding-base / 2) ((@padding-base / 2) + 2); - background: linear-gradient(lighten(@off-white, 2%), darken(@off-white, 3%)); - border: 1px solid @gray-light; - box-shadow: 0 1px 1px rgba(0,0,0, .05); - text-shadow: 0 1px 1px #fff; - color: @gray; - transition: background .1s ease, color .1s ease; - .font-size(@font-size-small); - - &:hover, - &:focus { - border-color: darken(@gray-light, 8%); - color: @gray; - outline: 0; - } -} - -// Sizes -.btn--large { - padding: (@padding-base / 2) @padding-base; - .font-size(); -} - -// Styles -.btn--primary { - background-image: linear-gradient(@link-color, darken(@link-color, 5%)); - background-color: @link-color; - border-color: darken(@link-color, 10%); - box-shadow: 0 1px 1px rgba(0,0,0, .15); - text-shadow: 0 1px 1px rgba(0,0,0, .1); - color: #fff; - - &:hover, - &:focus { - color: #fff; - border-color: darken(@link-color, 20%); - } -} -.btn--youtube .icon { - color: @color-youtube; -} -.btn--vimeo .icon { - color: @color-vimeo; -} -.btn--twitter .icon { - color: @color-twitter; +.button { + padding-left: @spacing-base; + padding-right: @spacing-base; + transition: all 0.2s ease; + + &:hover, + &:focus { + color: @gray-dark; + outline: 0; + + &::after { + display: none; + } + } + + &.tab-focus { + .tab-focus(); + } } // Count bubble -.btn__count { - position: relative; - margin-left: (@padding-base / 2); - padding: (@padding-base / 2) (@padding-base * .75); - background: #fff; - border: 1px solid @gray-light; - - &::before { - content: ""; - position: absolute; - display: block; - width: @arrow-size; - height: @arrow-size; - left: 1px; - top: 50%; - margin-top: -(@arrow-size / 2); - - background: inherit; - border: inherit; - border-width: 1px 0 0 1px; - transform: rotate(-45deg) translate(-50%, -50%); - } +.button__count { + margin-left: (@spacing-base / 2); + animation: fadein 0.2s ease; + + &::before { + content: ''; + position: absolute; + display: block; + width: @arrow-size; + height: @arrow-size; + left: 1px; + top: 50%; + margin-top: -(@arrow-size / 2); + + background: inherit; + border: inherit; + border-width: 1px 0 0 1px; + transform: rotate(-45deg) translate(-50%, -50%); + } } diff --git a/demo/src/less/components/header.less b/demo/src/less/components/header.less new file mode 100644 index 00000000..c5f8b1fe --- /dev/null +++ b/demo/src/less/components/header.less @@ -0,0 +1,24 @@ +// ========================================================================== +// Header +// ========================================================================== + +header { + padding: @spacing-base; + text-align: center; + + p { + .font-size(18); + margin-bottom: @spacing-base * 1.5; + } + + @media @mq-sm { + padding-top: (@spacing-base * 3); + padding-bottom: (@spacing-base * 3); + } + + @media @mq-md { + max-width: 400px; + margin-right: (@spacing-base * 2); + text-align: left; + } +} diff --git a/demo/src/less/components/icons.less b/demo/src/less/components/icons.less index 9530b601..29f185bd 100644 --- a/demo/src/less/components/icons.less +++ b/demo/src/less/components/icons.less @@ -4,23 +4,19 @@ // Base size icon styles .icon { - fill: currentColor; - width: @icon-size; - height: @icon-size; - vertical-align: -3px; + fill: currentColor; + width: @icon-size; + height: @icon-size; } // Within elements a svg, button svg, label svg { - pointer-events: none; + pointer-events: none; } + a .icon, .btn .icon { - margin-right: (@padding-base / 2); -} -.btn:not(.btn-large) .icon { - width: (@icon-size - 2); - height: (@icon-size - 2); + margin-right: (@spacing-base / 2); } diff --git a/demo/src/less/components/links.less b/demo/src/less/components/links.less new file mode 100644 index 00000000..7a62ab40 --- /dev/null +++ b/demo/src/less/components/links.less @@ -0,0 +1,46 @@ +// ========================================================================== +// Links +// ========================================================================== + +// Make a <button> look like an <a> +button.faux-link { + .cancel-button-styles(); + + &:extend(a all); +} + +// Links +a { + position: relative; + border-bottom: 1px dotted currentColor; + transition: all 0.2s ease; + text-decoration: none; + color: @color-link; + font-weight: @font-weight-bold; + + &::after { + content: ''; + position: absolute; + top: 100%; + left: 50%; + transform: translateX(-50%); + width: 0; + height: 1px; + transition: width 0.2s ease; + background: currentColor; + } + + &:hover, + &:focus { + border-bottom-color: transparent; + outline: 0; + + &::after { + width: 100%; + } + } + + &.tab-focus { + .tab-focus(); + } +} diff --git a/demo/src/less/components/lists.less b/demo/src/less/components/lists.less new file mode 100644 index 00000000..bae3d11d --- /dev/null +++ b/demo/src/less/components/lists.less @@ -0,0 +1,11 @@ +// ========================================================================== +// Lists +// ========================================================================== + +// Lists +ul, +li { + list-style: none; + margin: 0; + padding: 0; +} diff --git a/demo/src/less/components/navigation.less b/demo/src/less/components/navigation.less new file mode 100644 index 00000000..0b80f7e8 --- /dev/null +++ b/demo/src/less/components/navigation.less @@ -0,0 +1,9 @@ +// ========================================================================== +// Navigation +// ========================================================================== + +nav { + display: flex; + justify-content: center; + margin-bottom: @spacing-base; +} diff --git a/demo/src/less/components/examples.less b/demo/src/less/components/players.less index a9e72d21..c0f3e965 100644 --- a/demo/src/less/components/examples.less +++ b/demo/src/less/components/players.less @@ -11,13 +11,11 @@ video { // Example players .plyr { margin: 0 auto; - border-radius: @border-radius-large; -} -.plyr--audio { - max-width: @example-width-audio; + border-radius: @border-radius-base; + box-shadow: 0 2px 5px fade(#000, 20%); } .plyr__video-wrapper::after { - content: ""; + content: ''; pointer-events: none; position: absolute; top: 0; @@ -31,10 +29,10 @@ video { // Style full supported player .plyr__cite { display: none; - margin-top: @padding-base; + margin-top: @spacing-base; .icon { - margin-right: (@padding-base / 4); + margin-right: (@spacing-base / 4); } } diff --git a/demo/src/less/components/type.less b/demo/src/less/components/type.less deleted file mode 100644 index 8e621700..00000000 --- a/demo/src/less/components/type.less +++ /dev/null @@ -1,75 +0,0 @@ -// ========================================================================== -// Typography -// ========================================================================== - -// Base -html { - font-size: 100%; -} -body { - font-family: "Avenir", "Helvetica Neue", Helvetica, Arial, sans-serif; - line-height: 1.5; - text-align: center; - color: @gray; - font-weight: @font-weight-base; - .font-smoothing(); -} - -// Headings -h1, -h2 { - letter-spacing: -.025em; - color: @brand-primary; - margin: 0 0 (@padding-base / 2); - line-height: 1.2; - font-weight: @font-weight-bold; -} -h1 { - .font-size(@font-size-h1); -} - -// Paragraph and small -p, -small { - margin: 0 0 @padding-base; -} -small { - display: block; - padding: 0 (@padding-base / 2); - .font-size(@font-size-small); -} - -// Lists -ul, -li { - list-style: none; - margin: 0; - padding: 0; -} - -// Links -a { - text-decoration: none; - color: @link-color; - border-bottom: 1px dotted currentColor; - transition: background 0.3s ease, color 0.3s ease, border 0.3s ease; - - &:hover, - &:focus { - color: @gray-dark; - border-bottom-color: rgba(0, 0, 0, 0); - } - &:focus { - .tab-focus(); - } - &.logo { - border: 0; - } -} - -.color--vimeo { - color: @color-vimeo; -} -.color--youtube { - color: @color-youtube; -} diff --git a/demo/src/less/demo.less b/demo/src/less/demo.less deleted file mode 100644 index ac15a3c0..00000000 --- a/demo/src/less/demo.less +++ /dev/null @@ -1,26 +0,0 @@ -// ========================================================================== -// Plyr.io Demo Page -// ========================================================================== - -// CSS Reset -@import "lib/normalize.less"; - -// Mixins -@import "lib/mixins.less"; - -// Variables -@import "variables.less"; - -// Animation -@import "lib/animation.less"; - -// Type -@import "lib/fontface.less"; -@import "components/type.less"; - -// Components -@import "components/base.less"; -@import "components/icons.less"; -@import "components/buttons.less"; -@import "components/error.less"; -@import "components/examples.less"; diff --git a/demo/src/less/layout/core.less b/demo/src/less/layout/core.less new file mode 100644 index 00000000..aca66952 --- /dev/null +++ b/demo/src/less/layout/core.less @@ -0,0 +1,44 @@ +// ========================================================================== +// Core +// ========================================================================== + +html { + background: @page-background; + background-attachment: fixed; +} + +html, +body { + height: 100%; +} + +body { + display: flex; + align-items: center; + flex-direction: column; +} + +main { + text-align: center; +} + +.grid { + flex: 1; +} + +aside { + width: 100%; + padding: (@spacing-base * 0.75); + background: #fff; + text-align: center; + color: @gray; + text-shadow: none; + + a { + color: @color-twitter; + + &.tab-focus { + .tab-focus(@color-twitter); + } + } +} diff --git a/demo/src/less/components/error.less b/demo/src/less/layout/error.less index b1427173..0ed02241 100644 --- a/demo/src/less/components/error.less +++ b/demo/src/less/layout/error.less @@ -7,13 +7,15 @@ html.error, .error body { height: 100%; } + .error body { width: 100%; display: table; table-layout: fixed; } + .error main { display: table-cell; width: 100%; vertical-align: middle; -}
\ No newline at end of file +} diff --git a/demo/src/less/layout/grid.less b/demo/src/less/layout/grid.less new file mode 100644 index 00000000..02ff28c8 --- /dev/null +++ b/demo/src/less/layout/grid.less @@ -0,0 +1,19 @@ +// ========================================================================== +// Super basic grid +// ========================================================================== + +.grid { + margin: 0 auto; + padding: @spacing-base; + + @media @mq-md { + display: flex; + align-items: center; + width: 100%; + max-width: @container-max-width; + + > * { + flex: 1; + } + } +} diff --git a/demo/src/less/lib/animation.less b/demo/src/less/lib/animation.less index 386c6613..3c14b0a7 100644 --- a/demo/src/less/lib/animation.less +++ b/demo/src/less/lib/animation.less @@ -3,7 +3,11 @@ // ========================================================================== // Fade -@keyframes fade-in { - 0% { opacity: 0 } - 100% { opacity: 1 } -}
\ No newline at end of file +@keyframes fadein { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} diff --git a/demo/src/less/lib/fontface.less b/demo/src/less/lib/fontface.less index bd5f9feb..7fa06a63 100644 --- a/demo/src/less/lib/fontface.less +++ b/demo/src/less/lib/fontface.less @@ -19,3 +19,12 @@ font-weight: @font-weight-bold; font-display: swap; } + +@font-face { + font-family: "Avenir"; + src: url("https://cdn.plyr.io/static/fonts/avenir-black.woff2?v=3") format("woff2"), + url("https://cdn.plyr.io/static/fonts/avenir-black.woff?v=3") format("woff"); + font-style: normal; + font-weight: @font-weight-heavy; + font-display: swap; +} diff --git a/demo/src/less/lib/mixins.less b/demo/src/less/lib/mixins.less index 923df1ea..fbf36546 100644 --- a/demo/src/less/lib/mixins.less +++ b/demo/src/less/lib/mixins.less @@ -2,31 +2,39 @@ // Mixins // ========================================================================== -// Contain floats: nicolasgallagher.com/micro-clearfix-hack/ +// Convert a <button> into an <a> // --------------------------------------- -.clearfix() { - zoom: 1; - &:before, - &:after { content: ""; display: table; } - &:after { clear: both; } +.cancel-button-styles() { + position: relative; + margin: 0; + padding: 0; + width: auto; + border: 0; + background: transparent; + vertical-align: baseline; + text-align: inherit; + font: inherit; + line-height: @line-height-base; + cursor: pointer; + -moz-user-select: text; + text-shadow: inherit; + border-radius: 0; } -// Webkit-style focus +// Nicer focus styles // --------------------------------------- -.tab-focus() { - // Default - outline: thin dotted @gray-dark; - // Webkit - outline-offset: 1px; +.tab-focus(@color: @tab-focus-default-color) { + outline: 0; + box-shadow: 0 0 0 3px fade(@color, 35%); } // Use rems for font sizing // Leave <body> at 100%/16px // --------------------------------------- -.font-size(@font-size: 16){ +.font-size(@font-size: 16) { @rem: round((@font-size / 16), 3); font-size: (@font-size * 1px); - font-size: ~"@{rem}rem"; + font-size: ~'@{rem}rem'; } // Font smoothing @@ -38,4 +46,4 @@ .font-smoothing(@mode: on) when (@mode = off) { -moz-osx-font-smoothing: auto; -webkit-font-smoothing: subpixel-antialiased; -}
\ No newline at end of file +} diff --git a/demo/src/less/lib/reset.less b/demo/src/less/lib/reset.less new file mode 100644 index 00000000..50798b10 --- /dev/null +++ b/demo/src/less/lib/reset.less @@ -0,0 +1,11 @@ +// ========================================================================== +// Resets +// ========================================================================== + +// BORDER-BOX ALL THE THINGS! +// http://paulirish.com/2012/box-sizing-border-box-ftw/ +*, +*::after, +*::before { + box-sizing: border-box; +} diff --git a/demo/src/less/settings/breakpoints.less b/demo/src/less/settings/breakpoints.less new file mode 100644 index 00000000..b0ce9896 --- /dev/null +++ b/demo/src/less/settings/breakpoints.less @@ -0,0 +1,9 @@ +// ========================================================================== +// Breakpoints +// ========================================================================== + +@screen-sm: 480px; +@screen-md: 768px; + +@mq-sm: ~"only screen and (min-width: @{screen-sm}) "; +@mq-md: ~"only screen and (min-width: @{screen-md}) "; diff --git a/demo/src/less/settings/colors.less b/demo/src/less/settings/colors.less new file mode 100644 index 00000000..2f77fb14 --- /dev/null +++ b/demo/src/less/settings/colors.less @@ -0,0 +1,27 @@ +// ========================================================================== +// Colors +// ========================================================================== + +// Greyscale +@gray-dark: #343f4a; +@gray: #55646b; +@gray-light: #cbd0d3; +@gray-lighter: #dbe3e8; +@off-white: #f2f5f7; + +// Text +@color-text: #fff; + +// Plyr +@color-brand-primary: #1aafff; + +// Brands +@color-twitter: #4baaf4; +@color-youtube: #cc181e; +@color-vimeo: #19b7ed; + +// Elements +@color-link: #fff; + +// Focus +@tab-focus-default-color: #fff; diff --git a/demo/src/less/settings/cosmetic.less b/demo/src/less/settings/cosmetic.less new file mode 100644 index 00000000..bae2572b --- /dev/null +++ b/demo/src/less/settings/cosmetic.less @@ -0,0 +1,12 @@ +// ========================================================================== +// Misc cosmetic +// ========================================================================== + +// Button count arrow size +@arrow-size: 8px; + +// Radii +@border-radius-base: 4px; + +// Background +@page-background: linear-gradient(to left top, lighten(@color-brand-primary, 15%), darken(@color-brand-primary, 15%)); diff --git a/demo/src/less/settings/icons.less b/demo/src/less/settings/icons.less new file mode 100644 index 00000000..d0b09b0b --- /dev/null +++ b/demo/src/less/settings/icons.less @@ -0,0 +1,5 @@ +// ========================================================================== +// Icons +// ========================================================================== + +@icon-size: 18px; diff --git a/demo/src/less/settings/layout.less b/demo/src/less/settings/layout.less new file mode 100644 index 00000000..810edc03 --- /dev/null +++ b/demo/src/less/settings/layout.less @@ -0,0 +1,5 @@ +// ========================================================================== +// Layout +// ========================================================================== + +@container-max-width: 1280px; diff --git a/demo/src/less/settings/spacing.less b/demo/src/less/settings/spacing.less new file mode 100644 index 00000000..6bd14f58 --- /dev/null +++ b/demo/src/less/settings/spacing.less @@ -0,0 +1,5 @@ +// ========================================================================== +// Colors +// ========================================================================== + +@spacing-base: 20px; diff --git a/demo/src/less/settings/type.less b/demo/src/less/settings/type.less new file mode 100644 index 00000000..b2740018 --- /dev/null +++ b/demo/src/less/settings/type.less @@ -0,0 +1,17 @@ +// ========================================================================== +// Typography +// ========================================================================== + +@font-sans-serif: 'Avenir', 'Helvetica Neue', sans-serif; + +@font-size-base: 16; +@font-size-small: 14; +@font-size-h1: 64; + +@font-weight-base: 500; +@font-weight-bold: 700; +@font-weight-heavy: 900; + +@line-height-base: 1.5; + +@letter-spacing-headings: -0.025em; diff --git a/demo/src/less/type/base.less b/demo/src/less/type/base.less new file mode 100644 index 00000000..4aea149d --- /dev/null +++ b/demo/src/less/type/base.less @@ -0,0 +1,33 @@ +// ========================================================================== +// Base +// ========================================================================== + +// Set to 100% for rem sizing +html { + font-size: 100%; +} + +body { + font-family: @font-sans-serif; + line-height: @line-height-base; + color: @color-text; + font-weight: @font-weight-base; + .font-smoothing(); + text-shadow: 0 1px 1px fade(#000, 15%); +} + +button, +input, +select, +textarea { + font: inherit; +} + +p, +small { + margin: 0 0 @spacing-base; +} +small { + display: block; + .font-size(@font-size-small); +} diff --git a/demo/src/less/type/headings.less b/demo/src/less/type/headings.less new file mode 100644 index 00000000..7dfcfb0a --- /dev/null +++ b/demo/src/less/type/headings.less @@ -0,0 +1,10 @@ +// ========================================================================== +// Headings +// ========================================================================== + +h1 { + margin: 0 0 (@spacing-base / 2); + .font-size(@font-size-h1); + font-weight: @font-weight-heavy; + letter-spacing: @letter-spacing-headings; +} diff --git a/demo/src/less/utilities/color.less b/demo/src/less/utilities/color.less new file mode 100644 index 00000000..923a3f67 --- /dev/null +++ b/demo/src/less/utilities/color.less @@ -0,0 +1,10 @@ +// ========================================================================== +// Color +// ========================================================================== + +.color--vimeo { + color: @color-vimeo; +} +.color--youtube { + color: @color-youtube; +} diff --git a/demo/src/less/utilities/hidden.less b/demo/src/less/utilities/hidden.less new file mode 100644 index 00000000..a48b107a --- /dev/null +++ b/demo/src/less/utilities/hidden.less @@ -0,0 +1,7 @@ +// ========================================================================== +// Hidden +// ========================================================================== + +[hidden] { + display: none; +} diff --git a/demo/src/less/variables.less b/demo/src/less/variables.less deleted file mode 100644 index 939232e5..00000000 --- a/demo/src/less/variables.less +++ /dev/null @@ -1,48 +0,0 @@ -// ========================================================================== -// Variables -// ========================================================================== - -// Colors -@gray-dark: #343f4a; -@gray: #55646b; -@gray-light: #cbd0d3; -@gray-lighter: #dbe3e8; -@off-white: #f2f5f7; - -@brand-primary: #3498db; -@brand-secondary: #02bd9b; - -// Brands -@color-twitter: #4baaf4; -@color-youtube: #cc181e; -@color-vimeo: #19b7ed; - -// Base -@body-background: @off-white; //linear-gradient(to left top, @brand-secondary, @brand-primary); - -// Type -@font-size-base: 16; -@font-size-small: 14; -@font-size-h1: 64; -@font-weight-base: 500; -@font-weight-bold: 700; - -// Elements -@link-color: @brand-primary; -@padding-base: 20px; -@arrow-size: 8px; - -// Icons -@icon-size: 18px; - -// Breakpoints -@screen-sm: 480px; -@screen-md: 768px; - -// Radii -@border-radius-base: 4px; -@border-radius-large: 6px; - -// Examples -@example-width-audio: 520px; -@example-width-video: 1200px; diff --git a/gulpfile.js b/gulpfile.js index 7ae7bf97..3dc62c93 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -77,58 +77,52 @@ function loadJSON(path) { var build = { js: function(files, bundle) { - for (var key in files) { - (function(key) { - var name = 'js-' + key; - tasks.js.push(name); - - gulp.task(name, function() { - return gulp - .src(bundles[bundle].js[key]) - .pipe(concat(key)) - .pipe(uglify()) - .pipe(gulp.dest(paths[bundle].output)); - }); - })(key); - } + Object.keys(files).forEach(function(key) { + var name = 'js-' + key; + tasks.js.push(name); + + gulp.task(name, function() { + return gulp + .src(bundles[bundle].js[key]) + .pipe(concat(key)) + .pipe(uglify()) + .pipe(gulp.dest(paths[bundle].output)); + }); + }); }, less: function(files, bundle) { - for (var key in files) { - (function(key) { - var name = 'less-' + key; - tasks.less.push(name); - - gulp.task(name, function() { - return gulp - .src(bundles[bundle].less[key]) - .pipe(less()) - .on('error', gutil.log) - .pipe(concat(key)) - .pipe(prefix(['last 2 versions'], { cascade: false })) - .pipe(cleanCSS()) - .pipe(gulp.dest(paths[bundle].output)); - }); - })(key); - } + Object.keys(files).forEach(function(key) { + var name = 'less-' + key; + tasks.less.push(name); + + gulp.task(name, function() { + return gulp + .src(bundles[bundle].less[key]) + .pipe(less()) + .on('error', gutil.log) + .pipe(concat(key)) + .pipe(prefix(['last 2 versions'], { cascade: false })) + .pipe(cleanCSS()) + .pipe(gulp.dest(paths[bundle].output)); + }); + }); }, scss: function(files, bundle) { - for (var key in files) { - (function(key) { - var name = 'scss-' + key; - tasks.scss.push(name); - - gulp.task(name, function() { - return gulp - .src(bundles[bundle].scss[key]) - .pipe(sass()) - .on('error', gutil.log) - .pipe(concat(key)) - .pipe(prefix(['last 2 versions'], { cascade: false })) - .pipe(cleanCSS()) - .pipe(gulp.dest(paths[bundle].output)); - }); - })(key); - } + Object.keys(files).forEach(function(key) { + var name = 'scss-' + key; + tasks.scss.push(name); + + gulp.task(name, function() { + return gulp + .src(bundles[bundle].scss[key]) + .pipe(sass()) + .on('error', gutil.log) + .pipe(concat(key)) + .pipe(prefix(['last 2 versions'], { cascade: false })) + .pipe(cleanCSS()) + .pipe(gulp.dest(paths[bundle].output)); + }); + }); }, sprite: function(bundle) { var name = 'sprite-' + bundle; diff --git a/src/js/plyr.js b/src/js/plyr.js index 59e8c8ef..663df980 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -19,7 +19,7 @@ } }.call(this, 'Plyr', this, function() { 'use strict'; - /* global jQuery, console */ + /* global jQuery */ // Globals var scroll = { |