-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjquery.fs.mimeo.min.js
9 lines (8 loc) · 1.35 KB
/
jquery.fs.mimeo.min.js
1
2
3
4
5
6
7
8
9
/*
* Mimeo v3.0.9 - 2014-08-08
* A jQuery plugin for responsive images. Part of the Formstone Library.
* http://formstone.it/mimeo/
*
* Copyright 2014 Ben Plum; MIT Licensed
*/
!function(a,b){"use strict";function c(b){a.extend(g,b||{}),h.update()}function d(){e.each(function(){for(var b=a(this),c=b.find("img"),d=b.find("source, .mimeo-source"),e=!1,f=0,g=d.length;g>f;f++){var h=d.eq(f).data("mimeo-match");h&&h.matches&&(e=f)}e===!1&&(e=d.length-1),c.attr("src",d.eq(e).attr("src")),b.trigger("change.mimeo")})}var e=(a(b),null),f="undefined"!=typeof b.devicePixelRatio?Math.ceil(b.devicePixelRatio):1,g={selector:"picture"},h={update:function(){a("video > "+g.selector).each(function(){var b=a(this),c=b.parent("video");c.before(b).remove()}),e=a(g.selector).each(function(c,e){for(var g=a(e).find("source, .mimeo-source"),h=0,i=g.length;i>h;h++){var j=g.eq(h),k=j.attr("media"),l=j.attr("srcset");if(l){var m={},n=1;l=l.split(",");for(var o in l)if(l.hasOwnProperty(o)){var p=l[o].replace(/^\s+|\s+$/g,"").split(" "),q=parseInt(p[1],10);q>n&&f>=q&&(n=q),m[q]=p[0]}j.data("mimeo-sources",m).attr("src",m[n])}if(k){var r=b.matchMedia(k.replace(1/0,"100000px"));r.addListener(d),j.data("mimeo-match",r)}}}),d()}};a.mimeo=function(a){return h[a]?h[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:c.apply(this,arguments)}}(jQuery,window);