picturefill 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/lib/picturefill.rb +5 -0
- data/lib/picturefill/rails.rb +7 -0
- data/lib/picturefill/rails/engine.rb +6 -0
- data/lib/picturefill/rails/railtie.rb +11 -0
- data/lib/picturefill/version.rb +3 -0
- data/picturefill.gemspec +19 -0
- data/vendor/assets/javascripts/matchmedia.js +34 -0
- data/vendor/assets/javascripts/matchmedia.min.js +1 -0
- data/vendor/assets/javascripts/picturefill.all.js +2 -0
- data/vendor/assets/javascripts/picturefill.all.min.js +2 -0
- data/vendor/assets/javascripts/picturefill.js +61 -0
- data/vendor/assets/javascripts/picturefill.min.js +1 -0
- metadata +62 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Patrick Helm
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Picturefill
|
2
|
+
|
3
|
+
This is a Rails-Wrapper for picturefill.js: https://github.com/scottjehl/picturefill
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'picturefill'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install picturefill
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add this line to your application layout (asset-pipeline enabled)
|
22
|
+
|
23
|
+
= javascript_include_tag 'picturefill.all'
|
24
|
+
|
25
|
+
Or w/o asset-pipeline, add these two lines:
|
26
|
+
|
27
|
+
= javascript_include_tag 'matchmedia.min'
|
28
|
+
= javascript_include_tag 'picturefill.min'
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/picturefill.rb
ADDED
data/picturefill.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'picturefill/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "picturefill"
|
8
|
+
gem.version = Picturefill::VERSION
|
9
|
+
gem.authors = ["Patrick Helm"]
|
10
|
+
gem.email = ["deradon87@gmail.com"]
|
11
|
+
gem.description = %q{Rails-Wrapper for picturefill.js}
|
12
|
+
gem.summary = %q{Wraps the javascript lib picturefill, to work with the rails asset-pipeline }
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
|
2
|
+
|
3
|
+
window.matchMedia = window.matchMedia || (function( doc, undefined ) {
|
4
|
+
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
var bool,
|
8
|
+
docElem = doc.documentElement,
|
9
|
+
refNode = docElem.firstElementChild || docElem.firstChild,
|
10
|
+
// fakeBody required for <FF4 when executed in <head>
|
11
|
+
fakeBody = doc.createElement( "body" ),
|
12
|
+
div = doc.createElement( "div" );
|
13
|
+
|
14
|
+
div.id = "mq-test-1";
|
15
|
+
div.style.cssText = "position:absolute;top:-100em";
|
16
|
+
fakeBody.style.background = "none";
|
17
|
+
fakeBody.appendChild(div);
|
18
|
+
|
19
|
+
return function(q){
|
20
|
+
|
21
|
+
div.innerHTML = "­<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
|
22
|
+
|
23
|
+
docElem.insertBefore( fakeBody, refNode );
|
24
|
+
bool = div.offsetWidth === 42;
|
25
|
+
docElem.removeChild( fakeBody );
|
26
|
+
|
27
|
+
return {
|
28
|
+
matches: bool,
|
29
|
+
media: q
|
30
|
+
};
|
31
|
+
|
32
|
+
};
|
33
|
+
|
34
|
+
}( document ));
|
@@ -0,0 +1 @@
|
|
1
|
+
window.matchMedia=window.matchMedia||function(a){"use strict";var c,d=a.documentElement,e=d.firstElementChild||d.firstChild,f=a.createElement("body"),g=a.createElement("div");return g.id="mq-test-1",g.style.cssText="position:absolute;top:-100em",f.style.background="none",f.appendChild(g),function(a){return g.innerHTML='­<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',d.insertBefore(f,e),c=42===g.offsetWidth,d.removeChild(f),{matches:c,media:a}}}(document);
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*! Picturefill - Responsive Images that work today. (and mimic the proposed Picture element with span elements). Author: Scott Jehl, Filament Group, 2012 | License: MIT/GPLv2 */
|
2
|
+
|
3
|
+
(function( w ){
|
4
|
+
|
5
|
+
// Enable strict mode
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
w.picturefill = function() {
|
9
|
+
var ps = w.document.getElementsByTagName( "span" );
|
10
|
+
|
11
|
+
// Loop the pictures
|
12
|
+
for( var i = 0, il = ps.length; i < il; i++ ){
|
13
|
+
if( ps[ i ].getAttribute( "data-picture" ) !== null ){
|
14
|
+
|
15
|
+
var sources = ps[ i ].getElementsByTagName( "span" ),
|
16
|
+
matches = [];
|
17
|
+
|
18
|
+
// See if which sources match
|
19
|
+
for( var j = 0, jl = sources.length; j < jl; j++ ){
|
20
|
+
var media = sources[ j ].getAttribute( "data-media" );
|
21
|
+
// if there's no media specified, OR w.matchMedia is supported
|
22
|
+
if( !media || ( w.matchMedia && w.matchMedia( media ).matches ) ){
|
23
|
+
matches.push( sources[ j ] );
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
// Find any existing img element in the picture element
|
28
|
+
var picImg = ps[ i ].getElementsByTagName( "img" )[ 0 ];
|
29
|
+
|
30
|
+
if( matches.length ){
|
31
|
+
var matchedEl = matches.pop();
|
32
|
+
if( !picImg ){
|
33
|
+
picImg = w.document.createElement( "img" );
|
34
|
+
picImg.alt = ps[ i ].getAttribute( "data-alt" );
|
35
|
+
}
|
36
|
+
|
37
|
+
picImg.src = matchedEl.getAttribute( "data-src" );
|
38
|
+
matchedEl.appendChild( picImg );
|
39
|
+
}
|
40
|
+
else if( picImg ){
|
41
|
+
picImg.parentNode.removeChild( picImg );
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
// Run on resize and domready (w.load as a fallback)
|
48
|
+
if( w.addEventListener ){
|
49
|
+
w.addEventListener( "resize", w.picturefill, false );
|
50
|
+
w.addEventListener( "DOMContentLoaded", function(){
|
51
|
+
w.picturefill();
|
52
|
+
// Run once only
|
53
|
+
w.removeEventListener( "load", w.picturefill, false );
|
54
|
+
}, false );
|
55
|
+
w.addEventListener( "load", w.picturefill, false );
|
56
|
+
}
|
57
|
+
else if( w.attachEvent ){
|
58
|
+
w.attachEvent( "onload", w.picturefill );
|
59
|
+
}
|
60
|
+
|
61
|
+
}( this ));
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(a){"use strict";a.picturefill=function(){for(var b=a.document.getElementsByTagName("span"),c=0,d=b.length;d>c;c++)if(null!==b[c].getAttribute("data-picture")){for(var e=b[c].getElementsByTagName("span"),f=[],g=0,h=e.length;h>g;g++){var i=e[g].getAttribute("data-media");(!i||a.matchMedia&&a.matchMedia(i).matches)&&f.push(e[g])}var j=b[c].getElementsByTagName("img")[0];if(f.length){var k=f.pop();j||(j=a.document.createElement("img"),j.alt=b[c].getAttribute("data-alt")),j.src=k.getAttribute("data-src"),k.appendChild(j)}else j&&j.parentNode.removeChild(j)}},a.addEventListener?(a.addEventListener("resize",a.picturefill,!1),a.addEventListener("DOMContentLoaded",function(){a.picturefill(),a.removeEventListener("load",a.picturefill,!1)},!1),a.addEventListener("load",a.picturefill,!1)):a.attachEvent&&a.attachEvent("onload",a.picturefill)})(this);
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: picturefill
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Patrick Helm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Rails-Wrapper for picturefill.js
|
15
|
+
email:
|
16
|
+
- deradon87@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/picturefill.rb
|
27
|
+
- lib/picturefill/rails.rb
|
28
|
+
- lib/picturefill/rails/engine.rb
|
29
|
+
- lib/picturefill/rails/railtie.rb
|
30
|
+
- lib/picturefill/version.rb
|
31
|
+
- picturefill.gemspec
|
32
|
+
- vendor/assets/javascripts/matchmedia.js
|
33
|
+
- vendor/assets/javascripts/matchmedia.min.js
|
34
|
+
- vendor/assets/javascripts/picturefill.all.js
|
35
|
+
- vendor/assets/javascripts/picturefill.all.min.js
|
36
|
+
- vendor/assets/javascripts/picturefill.js
|
37
|
+
- vendor/assets/javascripts/picturefill.min.js
|
38
|
+
homepage: ''
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.25
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Wraps the javascript lib picturefill, to work with the rails asset-pipeline
|
62
|
+
test_files: []
|