Permalink
Browse files

Initial commit

  • Loading branch information...
1 parent 6e0f331 commit 153bd2f05e75e3a04c46cc51547ce421d67fcaba @JimBobSquarePants committed Jul 27, 2012
View
@@ -0,0 +1,22 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
View
@@ -0,0 +1,163 @@
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Rr]elease/
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.vspscc
+.builds
+*.dotCover
+
+## TODO: If you have NuGet Package Restore enabled, uncomment this
+#packages/
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+
+# Visual Studio profiler
+*.psess
+*.vsp
+
+# ReSharper is a .NET coding add-in
+_ReSharper*
+
+# Installshield output folder
+[Ee]xpress
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish
+
+# Others
+[Bb]in
+[Oo]bj
+sql
+TestResults
+*.Cache
+ClientBin
+stylecop.*
+~$*
+*.dbmdl
+Generated_Code #added for RIA/Silverlight projects
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+
+
+
+############
+## Windows
+############
+
+# Windows image file caches
+Thumbs.db
+
+# Folder config file
+Desktop.ini
+
+
+#############
+## Python
+#############
+
+*.py[co]
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+
+# Mac crap
+.DS_Store
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+
+<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta charset="utf-8" />
+ <title>Image srcset Polyfill</title>
+ <style type="text/css">
+ img {
+ max-width: 100%; /*make images responsive*/
+ }
+
+ .main {
+ font-family: "Segoe UI",Helvetica,Tahoma,Arial,Verdana,Sans-Serif;
+ max-width: 980px;
+ margin: 0 auto;
+ }
+ </style>
+</head>
+<body>
+ <div class="main">
+ <h1>Srcset Polyfill</h1>
+ <p>Resize the page to load the larger image.</p>
+ <img src="assets/image-480px.jpg" srcset="assets/image-768px.jpg 768w, assets/image-979px.jpg 979w" alt="srcset example" />
+ </div>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
+ <script src="img.srcset.polyfill.js"></script>
+</body>
+</html>
View
@@ -0,0 +1,154 @@
+/*!
+ * A jQuery based image srcset polyfill that provides fallback behaviour for browsers
+ * that do not support the srcset attribute.
+ *
+ * Copyright 2012 James South
+ *
+ * Twitter: http://twitter.com/james_m_south
+ * Github: https://github.com/JimBobSquarePants/srcset-polyfill
+ *
+ * Supports the current syntax as defined below.
+ *
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#attr-img-srcset
+ * http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-May/035746.html
+ */
+
+(function ($) {
+
+ // A little feature detection first
+ var srcsetSupported = "srcset" in document.createElement("img");
+
+ if (!srcsetSupported) {
+
+ // Regexes for matching queries.
+ var rSrc = /[^\s]+/,
+ rHeight = /(\d+)h/,
+ rWidth = /(\d+)w/,
+ rRatio = /(\d+)x/;
+
+ // Detect retina display
+ // http: //www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html
+ var pixelRatio = (window.devicePixelRatio || 1);
+
+ // Get the window
+ var $window = $(window);
+
+ // Cache the images as theres no point querying them twice.
+ var imageList = [];
+
+ // http://lodash.com/docs/#debounce
+ var debounce = function (func, wait, immediate) {
+ var args,
+ result,
+ thisArg,
+ timeoutId;
+
+ function delayed() {
+ timeoutId = null;
+ if (!immediate) {
+ func.apply(thisArg, args);
+ }
+ }
+
+ return function () {
+ var isImmediate = immediate && !timeoutId;
+ args = arguments;
+ thisArg = this;
+
+ clearTimeout(timeoutId);
+ timeoutId = setTimeout(delayed, wait);
+
+ if (isImmediate) {
+ result = func.apply(thisArg, args);
+ }
+ return result;
+ };
+ };
+
+ var getImageSrc = function ($image) {
+
+ var i,
+ imgWidth = 0,
+ imgHeight = 0,
+ imgSrc = null,
+ imgSrcParts = $image.data("srcset");
+ len = imgSrcParts.length,
+ width = $window.width(),
+ height = $window.height();
+
+ for (i = 0; i < len; i += 1) {
+
+ // This is just a rough play on the algorithm.
+ var newImgSrc = imgSrcParts[i].match(rSrc)[0],
+ newImgHeight = rHeight.test(imgSrcParts[i]) ? parseInt(imgSrcParts[i].match(rHeight)[1], 10) : 1,
+ newImgWidth = rWidth.test(imgSrcParts[i]) ? parseInt(imgSrcParts[i].match(rWidth)[1], 10) : 1,
+ newPixelRatio = rRatio.test(imgSrcParts[i]) ? parseInt(imgSrcParts[i].match(rRatio)[1], 10) : 1;
+
+ if ((newImgWidth > imgWidth && width > newImgWidth && newImgHeight > imgHeight && height > newImgHeight && newPixelRatio === pixelRatio)) {
+
+ imgWidth = newImgWidth;
+ imgSrc = newImgSrc;
+ }
+ }
+
+ // Return null
+ return imgSrc;
+ };
+
+ var setImageSrc = function (firstRun) {
+
+ var setSrc = function () {
+
+ // Set the data for recall.
+ this.data("srcset", this.attr("srcset").split(","));
+
+ var src = getImageSrc(this);
+
+ if (src) {
+ this.attr("src", src);
+ }
+
+ };
+
+ // Build the cached list whilst running.
+ if (firstRun) {
+
+ $("img[srcset]").each(function () {
+
+ var $this = $(this);
+
+ setSrc.call($this);
+
+ imageList.push($this);
+
+ });
+
+ return;
+ }
+
+ // Run from our cached list.
+ $.each(imageList, function () {
+
+ var $this = $(this);
+
+ setSrc.call($this);
+
+ });
+
+ };
+
+ // lay implimentation.
+ var lazySetImageSrc = debounce(setImageSrc, 100);
+
+ // Debounce run on resize.
+ $window.resize(function () {
+ lazySetImageSrc();
+ });
+
+ // First run on load.
+ $window.load(function () {
+ setImageSrc(true);
+ });
+ }
+
+}(jQuery));

0 comments on commit 153bd2f

Please sign in to comment.