Permalink
Browse files

cleanup for version 2.1.9

  • Loading branch information...
1 parent 29883a7 commit b61db7e50aac3b6528c68960769dc33063159068 @tboetig tboetig committed Jan 18, 2012
Showing with 6 additions and 1 deletion.
  1. +5 −0 jquery.embedly.min.js
  2. +1 −1 tests.html
@@ -1 +1,6 @@
+/*
+ * Embedly JQuery v2.1.9
+ * ==============
+ * This library allows you to easily embed objects on any page.
+ */
(function(a){window.embedlyURLre=/(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/,a.embedly=a.embedly||{};if(a.embedly.version)return;a.extend({embedly:function(b,c,d){var e=[],f="http://api.embed.ly/",g;typeof c!="undefined"?g=a.extend(a.embedly.defaults,c):g=a.embedly.defaults,g.urlRe||(g.urlRe=window.embedlyURLre),typeof b=="string"&&(b=new Array(b)),typeof d!="undefined"&&(g.success=d),g.secure&&(f="https://api.embed.ly/"),g.success||(g.success=function(b,c){var d,e=a(c.node);if(!b)return null;if((d=g.method)==="replace")return e.replaceWith(b.code);if(d==="after")return e.after(b.code);if(d==="afterParent")return e.parent().after(b.code);if(d==="replaceParent")return e.parent().replaceWith(b.code)}),g.error||(g.error=function(a,b){});var h=function(a){return g.urlRe.test(a)},i=function(a){var b="urls="+a;g.maxWidth?b+="&maxwidth="+g.maxWidth:typeof dimensions!="undefined"&&(b+="&maxwidth="+dimensions.width),g.maxHeight&&(b+="&maxheight="+g.maxHeight),g.chars&&(b+="&chars="+g.chars),g.words&&(b+="&words="+g.words),g.secure&&(b+="&secure=true"),g.frame&&(b+="&frame=true"),b+="&wmode="+g.wmode,typeof g.key=="string"&&(b+="&key="+g.key);if(typeof g.autoplay=="string"||typeof g.autoplay=="boolean")b+="&autoplay="+g.autoplay;return g.width&&(b+="&width="+g.width),b},j=function(){if(typeof g.key=="string"){if(g.endpoint.search(/objectify/i)>=0)return f+"2/objectify";if(g.endpoint.search(/preview/i)>=0)return f+"1/preview"}return f+"1/oembed"},k=function(){var a=[];return g.addImageStyles&&(g.maxWidth&&(units=isNaN(parseInt(g.maxWidth,10))?"":"px",a.push("max-width: "+g.maxWidth+units)),g.maxHeight&&(units=isNaN(parseInt(g.maxHeight,10))?"":"px",a.push("max-height: "+g.maxHeight+units))),a.join(";")},l=function(b,c){if(g.endpoint!=="oembed")return g.success(b,c);var d,e,f,h,i,j,l,m;return(d=b.type)==="photo"?(h=b.title||"",e="<a href='"+c.url+"' target='_blank'><img style='"+k()+"' src='"+b.url+"' alt='"+h+"' /></a>"):d==="video"?e=b.html:d==="rich"?e=b.html:(h=b.title||c.url,j=b.thumbnail_url?"<img src='"+b.thumbnail_url+"' class='thumb' style='"+k()+"'/>":"",m=b.description?'<div class="description">'+b.description+"</div>":"",l=b.provider_name?"<a href='"+b.provider_url+"' class='provider'>"+b.provider_name+"</a>":"",e=j+"<a href='"+c.url+"'>"+h+"</a>",e+=l,e+=m),g.wrapElement&&g.wrapElement==="div"&&a.browser.msie&&a.browser.version<9&&(g.wrapElement="span"),g.wrapElement&&(e="<"+g.wrapElement+' class="'+g.className+'">'+e+"</"+g.wrapElement+">"),b.code=e,typeof c.node!="undefined"&&a(c.node).data("oembed",b).trigger("embedly-oembed",[b]),g.success(b,c)},m=function(b){var c,d,e,f,h;e=a.map(b,function(b,c){return c===0&&b.node!==null&&(h=a(b.node),f={width:h.parent().width(),height:h.parent().height()}),encodeURIComponent(b.url)}).join(","),a.ajax({url:j(),dataType:"jsonp",data:i(e),success:function(c){return a.each(c,function(a,c){return c.type!=="error"?l(c,b[a]):g.error(b[a].node,c)})}})};a.each(b,function(b,c){var d=typeof g.elems!="undefined"?g.elems[b]:null;typeof d!="undefined"&&!h(c)&&a(d).data("oembed",!1);var f={url:c,error_code:400,error_message:"HTTP 400: Bad Request",type:"error"};return c&&h(c)?e.push({url:c,node:d}):g.error(d,f)});var n=[],o=e.length;for(var p=0;0<=o?p<o:p>o;p+=20)n=n.concat(m(e.slice(p,p+20)));return g.elems?g.elems:this}}),a.embedly.version="2.1.9",a.embedly.defaults={endpoint:"oembed",secure:!1,frame:!1,wmode:"opaque",method:"replace",addImageStyles:!0,wrapElement:"div",className:"embed",elems:[]},a.fn.embedly=function(b,c){var d=typeof b!="undefined"?b:{};typeof c!="undefined"&&(b.success=c);var e=new Array,f=new Array;this.each(function(){typeof a(this).attr("href")!="undefined"?(e.push(a(this).attr("href")),f.push(a(this))):a(this).find("a").each(function(){e.push(a(this).attr("href")),f.push(a(this))}),d.elems=f});var g=a.embedly(e,d);return this}})(jQuery)
View
@@ -9,7 +9,7 @@
<script type="text/javascript">
// --- Unittest Code goes here ---
$(document).ready(function(){
- $.embedly.defaults['key'] = 'internal';
+ $.embedly.defaults['key'] = 'EMBEDLY_KEY';
QUnit.log = function(result, message)
{
if (window.console && window.console.log)

0 comments on commit b61db7e

Please sign in to comment.