WP YouTube Lyte - Version 1.1.2

Version Description

  • bugfix: during development of 1.1.0 the javascript to lazy load the lyte player got lost somehow, readded (now in lyte(-min).js)
  • performance: replaced the external stylesheet (lyte.css) with inline javascript that adds an internal stylesheet to the head of the document (thanks for pushing me Collin!
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 WP YouTube Lyte
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

Files changed (4) hide show
  1. lyte/lyte-min.js +1 -1
  2. lyte/lyte.js +8 -1
  3. readme.txt +5 -1
  4. wp-youtube-lyte.php +4 -5
lyte/lyte-min.js CHANGED
@@ -1 +1 @@
1
- function loadSC(a){scr=d.createElement("script");scr.src=a;scr.type="text/javascript";d.getElementsByTagName("head")[0].appendChild(scr)}function setST(a,b){if(typeof a.setAttribute==="function")a.setAttribute("style",b);else if(typeof a.style.setAttribute==="object")a.style.setAttribute("cssText",b)}function drawT(a,b){p=d.getElementById(a);c=d.createElement("div");c.className="tC";t=d.createElement("div");t.className="tT";c.appendChild(t);t.innerHTML=b;p.appendChild(c)}function parsePL(a){thumb=a.feed.entry[0].media$group.media$thumbnail[1].url;idu=a.feed.id.$t;id="lyte_"+idu.substring(idu.length-16);title="Playlist: "+a.feed.title.$t;pl=d.getElementById(id);pH=pl.style.height;pW=pl.style.width;if(sch=="https"&&thumb.indexOf("https"==-1)){thumb=thumb.replace("http://","https://")}setST(pl,"height:"+pH+";width:"+pW+";background:url('"+thumb+"') no-repeat scroll center -50px rgb(0, 0, 0); background-size:cover;");drawT(id,title)}function parseV(a){tI=a.entry.title.$t;idu=a.entry.id.$t;id="lyte_"+idu.substring(idu.length-11);drawT(id,tI)}function plaYT(){tH=this;tH.onclick="";vid=tH.id.substring(4);hidef=0;if(tH.className.indexOf("hidef")!==-1){hidef=1}if(tH.className.indexOf("playlist")===-1){eU=sch+"://www.youtube.com/embed/"+vid}else{eU=sch+"://www.youtube.com/embed/p/"+vid}qsa=getQ(tH);if(tH.className.indexOf("audio")!==-1){qsa+="&autohide=0"}tH.innerHTML='<iframe id="iF_'+vid+'" width="'+tH.clientWidth+'" height="'+tH.clientHeight+'" src="'+eU+"?autoplay=1&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+'" frameborder="0"></iframe>';if(typeof tH.firstChild.getAttribute("kabl")=="string")tH.innerHTML="Please check Karma Blocker's config."}function getQ(a){qsa="";if(rqs=a.className.match(/qsa_(.*)\s/,"$1"))qsa=rqs[1].replace(/\\([\&\=\?])/g,"$1");return qsa}function lyte(){if(!a){var a=1;lts=getElementsByClassName("lyMe","div");for(var b=0,c=lts.length;b<c;b+=1){p=lts[b];vid=p.id.substring(4);cN=p.className.replace(/lyMe/,"lyte")+" lP";p.className=cN;p.onclick=plaYT;pW=p.style.width.match(/\d+/g)[0];pH=p.style.height.match(/\d+/g)[0];pl=d.createElement("div");pl.id="lyte_"+vid;pl.className="pL";bgA="-60px";if(cN.indexOf("widget")!==-1||pW/pH<1.7)bgA="-10px";qsa=getQ(p);if(cN.indexOf("audio")!==-1){setST(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML='<img src="'+bU+"controls-"+pW+'.png" class="ctrl" alt="" style="max-width:'+pW+'px;"/>'}else if(cN.indexOf("playlist")!==-1){setST(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this playlist" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" class="ctrl" alt="" style="max-width:'+pW+'px;"/>';joU=sch+"://gdata.youtube.com/feeds/api/playlists/"+vid+"?v=2&alt=json-in-script&callback=parsePL&fields=id,title,entry";loadSC(joU)}else{setST(pl,"height:"+pH+"px;width:"+pW+"px;background:url('"+sch+"://img.youtube.com/vi/"+vid+"/0.jpg') no-repeat scroll center "+bgA+" rgb(0, 0, 0);background-size:cover;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this video" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" class="ctrl" alt="" style="max-width:'+pW+'px;"/>';if(cN.indexOf("widget")===-1&&qsa.indexOf("showinfo=0")===-1){joU=sch+"://gdata.youtube.com/feeds/api/videos/"+vid+"?fields=id,title&alt=json-in-script&callback=parseV";loadSC(joU)}}p.appendChild(pl)}}var a=""}var d=document;sch="http";if(bU.indexOf("https")!=-1){sch+="s"}var getElementsByClassName=function(a,b,c){if(d.getElementsByClassName){getElementsByClassName=function(a,b,c){c=c||d;var e=c.getElementsByClassName(a),f=b?new RegExp("\\b"+b+"\\b","i"):null,g=[],h;for(var i=0,j=e.length;i<j;i+=1){h=e[i];if(!f||f.test(h.nodeName)){g.push(h)}}return g}}else if(d.evaluate){getElementsByClassName=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f="",g="http://www.w3.org/1999/xhtml",h=d.documentElement.namespaceURI===g?g:null,i=[],j,k;for(var l=0,m=e.length;l<m;l+=1){f+="[contains(concat(' ', @class, ' '), ' "+e[l]+" ')]"}try{j=d.evaluate(".//"+b+f,c,h,0,null)}catch(n){j=d.evaluate(".//"+b+f,c,null,0,null)}while(k=j.iterateNext()){i.push(k)}return i}}else{getElementsByClassName=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f=[],g=b==="*"&&c.all?c.all:c.getElementsByTagName(b),h,i=[],j;for(var k=0,l=e.length;k<l;k+=1){f.push(new RegExp("(^|\\s)"+e[k]+"(\\s|$)"))}for(var m=0,n=g.length;m<n;m+=1){h=g[m];j=false;for(var o=0,p=f.length;o<p;o+=1){j=f[o].test(h.className);if(!j){break}}if(j){i.push(h)}}return i}}return getElementsByClassName(a,b,c)};lyte()
1
+ function loadSC(a){scr=d.createElement("script");scr.src=a;scr.type="text/javascript";d.getElementsByTagName("head")[0].appendChild(scr)}function setST(a,b){if(typeof a.setAttribute==="function")a.setAttribute("style",b);else if(typeof a.style.setAttribute==="object")a.style.setAttribute("cssText",b)}function drawT(a,b){p=d.getElementById(a);c=d.createElement("div");c.className="tC";t=d.createElement("div");t.className="tT";c.appendChild(t);t.innerHTML=b;p.appendChild(c)}function parsePL(a){thumb=a.feed.entry[0].media$group.media$thumbnail[1].url;idu=a.feed.id.$t;id="lyte_"+idu.substring(idu.length-16);title="Playlist: "+a.feed.title.$t;pl=d.getElementById(id);pH=pl.style.height;pW=pl.style.width;if(sch=="https"&&thumb.indexOf("https"==-1)){thumb=thumb.replace("http://","https://")}setST(pl,"height:"+pH+";width:"+pW+";background:url('"+thumb+"') no-repeat scroll center -50px rgb(0, 0, 0); background-size:cover;");drawT(id,title)}function parseV(a){tI=a.entry.title.$t;idu=a.entry.id.$t;id="lyte_"+idu.substring(idu.length-11);drawT(id,tI)}function plaYT(){tH=this;tH.onclick="";vid=tH.id.substring(4);hidef=0;if(tH.className.indexOf("hidef")!==-1){hidef=1}if(tH.className.indexOf("playlist")===-1){eU=sch+"://www.youtube.com/embed/"+vid}else{eU=sch+"://www.youtube.com/embed/p/"+vid}qsa=getQ(tH);if(tH.className.indexOf("audio")!==-1){qsa+="&autohide=0"}tH.innerHTML='<iframe id="iF_'+vid+'" width="'+tH.clientWidth+'" height="'+tH.clientHeight+'" src="'+eU+"?autoplay=1&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+'" frameborder="0"></iframe>';if(typeof tH.firstChild.getAttribute("kabl")=="string")tH.innerHTML="Please check Karma Blocker's config."}function getQ(a){qsa="";if(rqs=a.className.match(/qsa_(.*)\s/,"$1"))qsa=rqs[1].replace(/\\([\&\=\?])/g,"$1");return qsa}function lyte(){if(!a){var a=1;lts=getElementsByClassName("lyMe","div");for(var b=0,c=lts.length;b<c;b+=1){p=lts[b];vid=p.id.substring(4);cN=p.className.replace(/lyMe/,"lyte")+" lP";p.className=cN;p.onclick=plaYT;pW=p.style.width.match(/\d+/g)[0];pH=p.style.height.match(/\d+/g)[0];pl=d.createElement("div");pl.id="lyte_"+vid;pl.className="pL";bgA="-60px";if(cN.indexOf("widget")!==-1||pW/pH<1.7)bgA="-10px";qsa=getQ(p);if(cN.indexOf("audio")!==-1){setST(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML='<img src="'+bU+"controls-"+pW+'.png" class="ctrl" alt="" style="max-width:'+pW+'px;"/>'}else if(cN.indexOf("playlist")!==-1){setST(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this playlist" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" class="ctrl" alt="" style="max-width:'+pW+'px;"/>';joU=sch+"://gdata.youtube.com/feeds/api/playlists/"+vid+"?v=2&alt=json-in-script&callback=parsePL&fields=id,title,entry";loadSC(joU)}else{setST(pl,"height:"+pH+"px;width:"+pW+"px;background:url('"+sch+"://img.youtube.com/vi/"+vid+"/0.jpg') no-repeat scroll center "+bgA+" rgb(0, 0, 0);background-size:cover;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this video" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" class="ctrl" alt="" style="max-width:'+pW+'px;"/>';if(cN.indexOf("widget")===-1&&qsa.indexOf("showinfo=0")===-1){joU=sch+"://gdata.youtube.com/feeds/api/videos/"+vid+"?fields=id,title&alt=json-in-script&callback=parseV";loadSC(joU)}}p.appendChild(pl)}}var a=""}var d=document;var w=window;sch="http";if(bU.indexOf("https")!=-1){sch+="s"}var getElementsByClassName=function(a,b,c){if(d.getElementsByClassName){getElementsByClassName=function(a,b,c){c=c||d;var e=c.getElementsByClassName(a),f=b?new RegExp("\\b"+b+"\\b","i"):null,g=[],h;for(var i=0,j=e.length;i<j;i+=1){h=e[i];if(!f||f.test(h.nodeName)){g.push(h)}}return g}}else if(d.evaluate){getElementsByClassName=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f="",g="http://www.w3.org/1999/xhtml",h=d.documentElement.namespaceURI===g?g:null,i=[],j,k;for(var l=0,m=e.length;l<m;l+=1){f+="[contains(concat(' ', @class, ' '), ' "+e[l]+" ')]"}try{j=d.evaluate(".//"+b+f,c,h,0,null)}catch(n){j=d.evaluate(".//"+b+f,c,null,0,null)}while(k=j.iterateNext()){i.push(k)}return i}}else{getElementsByClassName=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f=[],g=b==="*"&&c.all?c.all:c.getElementsByTagName(b),h,i=[],j;for(var k=0,l=e.length;k<l;k+=1){f.push(new RegExp("(^|\\s)"+e[k]+"(\\s|$)"))}for(var m=0,n=g.length;m<n;m+=1){h=g[m];j=false;for(var o=0,p=f.length;o<p;o+=1){j=f[o].test(h.className);if(!j){break}}if(j){i.push(h)}}return i}}return getElementsByClassName(a,b,c)};if(w.addEventListener){w.addEventListener("load",lyte,false);d.addEventListener("DomContentLoaded",function(){setTimeout("lyte()",750)},false)}else{w.onload=lyte;setTimeout("lyte()",1000)}
lyte/lyte.js CHANGED
@@ -1,4 +1,5 @@
1
  var d = document;
 
2
 
3
  sch="http";
4
  if (bU.indexOf('https')!=-1) {sch+="s"}
@@ -190,4 +191,10 @@ var getElementsByClassName = function (className, tag, elm) {
190
  return getElementsByClassName(className, tag, elm)
191
  };
192
 
193
- lyte();
 
 
 
 
 
 
1
  var d = document;
2
+ var w = window;
3
 
4
  sch="http";
5
  if (bU.indexOf('https')!=-1) {sch+="s"}
191
  return getElementsByClassName(className, tag, elm)
192
  };
193
 
194
+ if(w.addEventListener) {
195
+ w.addEventListener('load', lyte, false);
196
+ d.addEventListener('DomContentLoaded', function(){setTimeout("lyte()",750)}, false);
197
+ } else {
198
+ w.onload=lyte;
199
+ setTimeout("lyte()",1000);
200
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: futtta
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar, lazy load
4
  Requires at least: 2.9
5
  Tested up to: 3.3
6
- Stable tag: 1.1.1
7
 
8
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
9
 
@@ -78,6 +78,10 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
78
 
79
  == Changelog ==
80
 
 
 
 
 
81
  = 1.1.1 =
82
  * bugfix: lyte css wasn't applied as class was already removed (regression caused by "Infinite Scroll" support), lyMe now is the name of the unprocessed div and becomes lyte after processing
83
  * performance: [minimizing reflows caused by amongst others how styles are applied](http://blog.futtta.be/2012/03/20/going-against-the-reflow/) (kudo's to ["der Tuxman"](http://tuxproject.de/blog) again, buy that man a beer!)
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar, lazy load
4
  Requires at least: 2.9
5
  Tested up to: 3.3
6
+ Stable tag: 1.1.2
7
 
8
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
9
 
78
 
79
  == Changelog ==
80
 
81
+ = 1.1.2 =
82
+ * bugfix: during development of 1.1.0 the javascript to lazy load the lyte player got lost somehow, readded (now in lyte(-min).js)
83
+ * performance: replaced the external stylesheet (lyte.css) with inline javascript that adds an internal stylesheet to the head of the document (thanks for pushing me [Collin](http://www.realsceptic.com/)!
84
+
85
  = 1.1.1 =
86
  * bugfix: lyte css wasn't applied as class was already removed (regression caused by "Infinite Scroll" support), lyMe now is the name of the unprocessed div and becomes lyte after processing
87
  * performance: [minimizing reflows caused by amongst others how styles are applied](http://blog.futtta.be/2012/03/20/going-against-the-reflow/) (kudo's to ["der Tuxman"](http://tuxproject.de/blog) again, buy that man a beer!)
wp-youtube-lyte.php CHANGED
@@ -4,13 +4,13 @@ Plugin Name: WP YouTube Lyte
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
- Version: 1.1.1
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
- $wyl_version="1.1.1";
14
 
15
  $plugin_dir = basename(dirname(__FILE__)).'/languages';
16
  load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
@@ -157,9 +157,8 @@ function lyte_initer() {
157
 
158
  function lyte_init() {
159
  global $lyteSettings;
160
- echo "<link rel=\"stylesheet\" href=\"".$lyteSettings['path']."lyte.css?wylver=".$lyteSettings['version']."\" type=\"text/css\" />";
161
- echo "<script type=\"text/javascript\">var bU='".$lyteSettings['path']."';</script>";
162
- echo "<script type=\"text/javascript\" src=\"".$lyteSettings['path']."lyte-min.js?wylver=".$lyteSettings['version']."\"></script>";
163
  }
164
 
165
  if ( is_admin() ) {
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
+ Version: 1.1.2
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
+ $wyl_version="1.1.2";
14
 
15
  $plugin_dir = basename(dirname(__FILE__)).'/languages';
16
  load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
157
 
158
  function lyte_init() {
159
  global $lyteSettings;
160
+ echo "<script type=\"text/javascript\">var bU='".$lyteSettings['path']."';style = document.createElement('style');style.type = 'text/css';rules = document.createTextNode('.lyte img {border:0px !important;padding:0px;spacing:0px;margin:0px;display:inline;background-color:transparent;} .lL {margin:0px 0px 10px 0px;} .lyte {margin:5px 0px;} .lP {background-color:#fff;} .pL {cursor:pointer;text-align:center;overflow:hidden;position:relative;margin:0px;} .tC {left:0;top:0;position:absolute;width:100%;background-color:rgba(0,0,0,0.6);} .tT {padding:5px 10px;font-size:16px;color:#ffffff;font-family:sans-serif;text-align:left;} .ctrl {position:absolute;left:0px;bottom:0px;}');if(style.styleSheet) { style.styleSheet.cssText = rules.nodeValue;} else {style.appendChild(rules);}document.getElementsByTagName('head')[0].appendChild(style);</script>";
161
+ echo "<script type=\"text/javascript\" async=true src=\"".$lyteSettings['path']."lyte-min.js?wylver=".$lyteSettings['version']."\"></script>";
 
162
  }
163
 
164
  if ( is_admin() ) {