featurejs_rails 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/featurejs_rails.gemspec +24 -0
- data/lib/featurejs_rails.rb +5 -0
- data/lib/featurejs_rails/version.rb +3 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/featurejs_rails/.DS_Store +0 -0
- data/vendor/assets/javascripts/featurejs_rails/feature.js +221 -0
- data/vendor/assets/javascripts/featurejs_rails/feature.min.js +2 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4f683d83dead0329ab49c686579b2f47c9d989fb
|
4
|
+
data.tar.gz: b3d970b88ac6900ab30f220f0807c4c810f963f8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8e9917c4726163e0fb32159b48b7e99a99e7bd6062a9c3d9c549542da0f9841acd405fa5166cbfb614e46657e79b8502244328ca70a46a2fb5100ef96330d7e
|
7
|
+
data.tar.gz: 69232d3c0703f56c283532652ef56f8af824006c699e603d740c8689e6a520207858f6d137d186aba8132c208d0532919db2305a3d0d87fcfcfd8cd582a358e7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Curt Howard
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# FeaturejsRails
|
2
|
+
|
3
|
+
[Feature.js](http://featurejs.com/) packaged for the Rails Asset Pipeline
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'featurejs_rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install featurejs_rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add this to your JavaScript manifest file:
|
24
|
+
|
25
|
+
```js
|
26
|
+
//= require featurejs_rails/feature
|
27
|
+
```
|
28
|
+
|
29
|
+
or, for the pre-minified version, add:
|
30
|
+
|
31
|
+
```js
|
32
|
+
//= require featurejs_rails/feature.min
|
33
|
+
```
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
This is a Rails Asset Pipeline wrapper gem for the [Feature.js](http://featurejs.com/) library. Any issues found with the library itself should be reported on GitHub at https://github.com/viljamis/feature.js
|
38
|
+
|
39
|
+
For any other specifically pertaining to this wrapper, bug reports and pull requests are welcome on GitHub at https://github.com/meowsus/featurejs_rails.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
44
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "featurejs_rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'featurejs_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'featurejs_rails'
|
8
|
+
spec.version = FeaturejsRails::VERSION
|
9
|
+
spec.authors = ['Curt Howard']
|
10
|
+
spec.email = ['choward@weblinc.com']
|
11
|
+
|
12
|
+
spec.summary = 'Feature.js packaged for the Rails Asset Pipeline'
|
13
|
+
spec.description = 'Feature.js packaged for the Rails Asset Pipeline'
|
14
|
+
spec.homepage = 'https://github.com/meowsus/featurejs_rails'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,221 @@
|
|
1
|
+
/*!
|
2
|
+
* FEATURE.JS 1.0.1, A Fast, simple and lightweight browser feature
|
3
|
+
* detection library in just 1kb.
|
4
|
+
*
|
5
|
+
* http://featurejs.com
|
6
|
+
*
|
7
|
+
* CSS 3D Transform, CSS Transform, CSS Transition, Canvas, SVG,
|
8
|
+
* addEventListener, querySelectorAll, matchMedia, classList API,
|
9
|
+
* placeholder, localStorage, History API, Viewport Units, REM Units,
|
10
|
+
* CORS, WebGL, Service Worker, Context Menu, Geolocation,
|
11
|
+
* Device Motion, Device Orientation, Touch, Async, Defer,
|
12
|
+
* Srcset, Sizes & Picture Element.
|
13
|
+
*
|
14
|
+
*
|
15
|
+
* USAGE EXAMPLE:
|
16
|
+
* if (feature.webGL) {
|
17
|
+
* console.log("webGL supported!");
|
18
|
+
* }
|
19
|
+
*
|
20
|
+
* Author: @viljamis, https://viljamis.com
|
21
|
+
*/
|
22
|
+
|
23
|
+
/* globals DocumentTouch */
|
24
|
+
;(function (window, document, undefined) {
|
25
|
+
"use strict";
|
26
|
+
|
27
|
+
// For minification only
|
28
|
+
var docEl = document.documentElement;
|
29
|
+
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Utilities
|
33
|
+
*/
|
34
|
+
var util = {
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Simple create element method
|
38
|
+
*/
|
39
|
+
create : function(el) {
|
40
|
+
return document.createElement(el);
|
41
|
+
},
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Test if it's an old device that we want to filter out
|
45
|
+
*/
|
46
|
+
old : !!(/(Android\s(1.|2.))|(Silk\/1.)/i.test(navigator.userAgent)),
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Function that takes a standard CSS property name as a parameter and
|
50
|
+
* returns it's prefixed version valid for current browser it runs in
|
51
|
+
*/
|
52
|
+
pfx : (function() {
|
53
|
+
var style = document.createElement("dummy").style;
|
54
|
+
var prefixes = ["Webkit", "Moz", "O", "ms"];
|
55
|
+
var memory = {};
|
56
|
+
return function(prop) {
|
57
|
+
if (typeof memory[prop] === "undefined") {
|
58
|
+
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1),
|
59
|
+
props = (prop + " " + prefixes.join(ucProp + " ") + ucProp).split(" ");
|
60
|
+
memory[prop] = null;
|
61
|
+
for (var i in props) {
|
62
|
+
if (style[props[i]] !== undefined) {
|
63
|
+
memory[prop] = props[i];
|
64
|
+
break;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return memory[prop];
|
69
|
+
};
|
70
|
+
})()
|
71
|
+
|
72
|
+
};
|
73
|
+
|
74
|
+
|
75
|
+
/**
|
76
|
+
* The Feature.js object
|
77
|
+
*/
|
78
|
+
|
79
|
+
var Feature = {
|
80
|
+
// Test if CSS 3D transforms are supported
|
81
|
+
css3Dtransform : (function() {
|
82
|
+
var test = (!util.old && util.pfx("perspective") !== null);
|
83
|
+
return !!test;
|
84
|
+
})(),
|
85
|
+
|
86
|
+
// Test if CSS transforms are supported
|
87
|
+
cssTransform : (function() {
|
88
|
+
var test = (!util.old && util.pfx("transformOrigin") !== null);
|
89
|
+
return !!test;
|
90
|
+
})(),
|
91
|
+
|
92
|
+
// Test if CSS transitions are supported
|
93
|
+
cssTransition : (function() {
|
94
|
+
var test = util.pfx("transition") !== null;
|
95
|
+
return !!test;
|
96
|
+
})(),
|
97
|
+
|
98
|
+
// Test if addEventListener is supported
|
99
|
+
addEventListener : !!window.addEventListener,
|
100
|
+
|
101
|
+
// Test if querySelectorAll is supported
|
102
|
+
querySelectorAll : !!document.querySelectorAll,
|
103
|
+
|
104
|
+
// Test if matchMedia is supported
|
105
|
+
matchMedia : !!window.matchMedia,
|
106
|
+
|
107
|
+
// Test if Device Motion is supported
|
108
|
+
deviceMotion : ("DeviceMotionEvent" in window),
|
109
|
+
|
110
|
+
// Test if Device Orientation is supported
|
111
|
+
deviceOrientation : ("DeviceOrientationEvent" in window),
|
112
|
+
|
113
|
+
// Test if Context Menu is supported
|
114
|
+
contextMenu : ("contextMenu" in docEl && "HTMLMenuItemElement" in window),
|
115
|
+
|
116
|
+
// Test if classList API is supported
|
117
|
+
classList : ("classList" in docEl),
|
118
|
+
|
119
|
+
// Test if placeholder attribute is supported
|
120
|
+
placeholder : ("placeholder" in util.create("input")),
|
121
|
+
|
122
|
+
// Test if localStorage is supported
|
123
|
+
localStorage : (function() {
|
124
|
+
var test = "x";
|
125
|
+
try {
|
126
|
+
localStorage.setItem(test, test);
|
127
|
+
localStorage.removeItem(test);
|
128
|
+
return true;
|
129
|
+
} catch(err) {
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
})(),
|
133
|
+
|
134
|
+
// Test if History API is supported
|
135
|
+
historyAPI : (window.history && "pushState" in window.history),
|
136
|
+
|
137
|
+
// Test if ServiceWorkers are supported
|
138
|
+
serviceWorker : ("serviceWorker" in navigator),
|
139
|
+
|
140
|
+
// Test if viewport units are supported
|
141
|
+
viewportUnit : (function(el) {
|
142
|
+
try {
|
143
|
+
el.style.width = "1vw";
|
144
|
+
var test = el.style.width !== "";
|
145
|
+
return !!test;
|
146
|
+
} catch(err) {
|
147
|
+
return false;
|
148
|
+
}
|
149
|
+
})(util.create("dummy")),
|
150
|
+
|
151
|
+
// Test if REM units are supported
|
152
|
+
remUnit : (function(el) {
|
153
|
+
try {
|
154
|
+
el.style.width = "1rem";
|
155
|
+
var test = el.style.width !== "";
|
156
|
+
return !!test;
|
157
|
+
} catch(err) {
|
158
|
+
return false;
|
159
|
+
}
|
160
|
+
})(util.create("dummy")),
|
161
|
+
|
162
|
+
// Test if Canvas is supported
|
163
|
+
canvas : (function(el) {
|
164
|
+
return !!(el.getContext && el.getContext("2d"));
|
165
|
+
})(util.create("canvas")),
|
166
|
+
|
167
|
+
// Test if SVG is supported
|
168
|
+
svg : !!document.createElementNS && !!document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect,
|
169
|
+
|
170
|
+
// Test if WebGL is supported
|
171
|
+
webGL : (function(el) {
|
172
|
+
try {
|
173
|
+
return !!(window.WebGLRenderingContext && (el.getContext("webgl") || el.getContext("experimental-webgl")));
|
174
|
+
} catch(err) {
|
175
|
+
return false;
|
176
|
+
}
|
177
|
+
})(util.create("canvas")),
|
178
|
+
|
179
|
+
// Test if cors is supported
|
180
|
+
cors : ("XMLHttpRequest" in window && "withCredentials" in new XMLHttpRequest()),
|
181
|
+
|
182
|
+
// Tests if touch events are supported, but doesn't necessarily reflect a touchscreen device
|
183
|
+
touch : !!(("ontouchstart" in window) || window.navigator && window.navigator.msPointerEnabled && window.MSGesture || window.DocumentTouch && document instanceof DocumentTouch),
|
184
|
+
|
185
|
+
// Test if async attribute is supported
|
186
|
+
async : ("async" in util.create("script")),
|
187
|
+
|
188
|
+
// Test if defer attribute is supported
|
189
|
+
defer : ("defer" in util.create("script")),
|
190
|
+
|
191
|
+
// Test if Geolocation is supported
|
192
|
+
geolocation : ("geolocation" in navigator),
|
193
|
+
|
194
|
+
// Test if img srcset attribute is supported
|
195
|
+
srcset : ("srcset" in util.create("img")),
|
196
|
+
|
197
|
+
// Test if img sizes attribute is supported
|
198
|
+
sizes : ("sizes" in util.create("img")),
|
199
|
+
|
200
|
+
// Test if Picture element is supported
|
201
|
+
pictureElement : ("HTMLPictureElement" in window),
|
202
|
+
|
203
|
+
// Run all the tests and add supported classes
|
204
|
+
testAll : function() {
|
205
|
+
var classes = " js";
|
206
|
+
for (var test in this) {
|
207
|
+
if (test !== "testAll" && test !== "constructor" && this[test]) {
|
208
|
+
classes += " " + test;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
docEl.className += classes.toLowerCase();
|
212
|
+
}
|
213
|
+
|
214
|
+
};
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Expose a public-facing API
|
218
|
+
*/
|
219
|
+
window.feature = Feature;
|
220
|
+
|
221
|
+
}(window, document));
|
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! FEATURE.JS 1.0.1, http://featurejs.com */
|
2
|
+
!function(e,t,n){"use strict";var r=t.documentElement,i={create:function(e){return t.createElement(e)},old:!!/(Android\s(1.|2.))|(Silk\/1.)/i.test(navigator.userAgent),pfx:function(){var e=t.createElement("dummy").style,r=["Webkit","Moz","O","ms"],i={};return function(t){if("undefined"==typeof i[t]){var c=t.charAt(0).toUpperCase()+t.substr(1),a=(t+" "+r.join(c+" ")+c).split(" ");i[t]=null;for(var o in a)if(e[a[o]]!==n){i[t]=a[o];break}}return i[t]}}()},c={css3Dtransform:function(){var e=!i.old&&null!==i.pfx("perspective");return!!e}(),cssTransform:function(){var e=!i.old&&null!==i.pfx("transformOrigin");return!!e}(),cssTransition:function(){var e=null!==i.pfx("transition");return!!e}(),addEventListener:!!e.addEventListener,querySelectorAll:!!t.querySelectorAll,matchMedia:!!e.matchMedia,deviceMotion:"DeviceMotionEvent"in e,deviceOrientation:"DeviceOrientationEvent"in e,contextMenu:"contextMenu"in r&&"HTMLMenuItemElement"in e,classList:"classList"in r,placeholder:"placeholder"in i.create("input"),localStorage:function(){var e="x";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(t){return!1}}(),historyAPI:e.history&&"pushState"in e.history,serviceWorker:"serviceWorker"in navigator,viewportUnit:function(e){try{e.style.width="1vw";var t=""!==e.style.width;return!!t}catch(n){return!1}}(i.create("dummy")),remUnit:function(e){try{e.style.width="1rem";var t=""!==e.style.width;return!!t}catch(n){return!1}}(i.create("dummy")),canvas:function(e){return!(!e.getContext||!e.getContext("2d"))}(i.create("canvas")),svg:!!t.createElementNS&&!!t.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,webGL:function(t){try{return!(!e.WebGLRenderingContext||!t.getContext("webgl")&&!t.getContext("experimental-webgl"))}catch(n){return!1}}(i.create("canvas")),cors:"XMLHttpRequest"in e&&"withCredentials"in new XMLHttpRequest,touch:!!("ontouchstart"in e||e.navigator&&e.navigator.msPointerEnabled&&e.MSGesture||e.DocumentTouch&&t instanceof DocumentTouch),async:"async"in i.create("script"),defer:"defer"in i.create("script"),geolocation:"geolocation"in navigator,srcset:"srcset"in i.create("img"),sizes:"sizes"in i.create("img"),pictureElement:"HTMLPictureElement"in e,testAll:function(){var e=" js";for(var t in this)"testAll"!==t&&"constructor"!==t&&this[t]&&(e+=" "+t);r.className+=e.toLowerCase()}};e.feature=c}(window,document);
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: featurejs_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Curt Howard
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Feature.js packaged for the Rails Asset Pipeline
|
42
|
+
email:
|
43
|
+
- choward@weblinc.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- featurejs_rails.gemspec
|
56
|
+
- lib/featurejs_rails.rb
|
57
|
+
- lib/featurejs_rails/version.rb
|
58
|
+
- vendor/assets/.DS_Store
|
59
|
+
- vendor/assets/javascripts/featurejs_rails/.DS_Store
|
60
|
+
- vendor/assets/javascripts/featurejs_rails/feature.js
|
61
|
+
- vendor/assets/javascripts/featurejs_rails/feature.min.js
|
62
|
+
homepage: https://github.com/meowsus/featurejs_rails
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.5.1
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Feature.js packaged for the Rails Asset Pipeline
|
86
|
+
test_files: []
|