prefixfree-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3e26b2af21bee02b2dbaa45381141300454ae2d
4
+ data.tar.gz: 300db19303e0274ec942b9bfcce9f0ba6449b80b
5
+ SHA512:
6
+ metadata.gz: bfa1fdf116c5dfc5b877c29030fccb25e546bb2e6155c74eca8c5c53a9907996710d2198fd53705c6541d386c7a79a3f93266231c7dac06e5a579326a04e37be
7
+ data.tar.gz: 9f55d38653215e84d65413e4b70b76d12cd2d80c54e7cfdd4ba2ba5a31f82100b6793658877d6ec71d5dc73f79ae6bb9fff3941f61c74a403933512aa9c88a87
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in prefixfree-rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sijo kg
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.
@@ -0,0 +1,30 @@
1
+ # Prefixfree::Rails
2
+
3
+ Gem for https://github.com/LeaVerou/prefixfree/ for using into rails apps
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'prefixfree-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install prefixfree-rails
18
+
19
+ ## Usage
20
+
21
+ add to application.js
22
+ //= require prefixfree-rails/prefixfree
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,8 @@
1
+ require "prefixfree/rails/version"
2
+
3
+ module Prefixfree
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Prefixfree
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prefixfree/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "prefixfree-rails"
8
+ spec.version = Prefixfree::Rails::VERSION
9
+ spec.authors = ["Sijo K George"]
10
+ spec.email = ["cijokgeorge@yahoo.co.in"]
11
+ spec.summary = %q{wrapper for prefixfree.js javascript library in rails}
12
+ spec.description = %q{wrapper for prefixfree.js(https://github.com/LeaVerou/prefixfree/) javascript library in rails}
13
+ spec.homepage = "https://github.com/sijokg/prefixfree-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", '~> 0'
23
+ end
@@ -0,0 +1,72 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="170px" height="170px" viewBox="0 0 170 170" enable-background="new 0 0 170 170" xml:space="preserve">
6
+ <g>
7
+ <g>
8
+ <ellipse fill-rule="evenodd" clip-rule="evenodd" fill="#EEEEEE" cx="85" cy="85" rx="74.1" ry="74.8"/>
9
+ </g>
10
+ <g>
11
+ <path fill="#FFFFFF" d="M85,85l72.4,9.5c0.4-3.1,0.6-6.3,0.6-9.5H85z"/>
12
+ <path fill="#FFFFFF" d="M85,12v73l9.5-72.4C91.4,12.2,88.2,12,85,12z"/>
13
+ <path fill="#FFFFFF" d="M103.9,14.4L85,85l0,0l28-67.5C110,16.3,107,15.3,103.9,14.4z"/>
14
+ <path fill="#FFFFFF" d="M121.5,21.7L85,85l44.5-58C126.9,25.1,124.3,23.3,121.5,21.7z"/>
15
+ <path fill="#FFFFFF" d="M40.5,27c-2.5,1.9-4.9,4-7.2,6.3L85,85L27,40.5c-1.9,2.5-3.7,5.2-5.3,7.9L85,85l0,0L40.5,27z"/>
16
+ <path fill="#FFFFFF" d="M57,17.5c-3,1.2-5.8,2.6-8.6,4.2L85,85L57,17.5z"/>
17
+ <polygon fill="#FFFFFF" points="85,85 85,85 85,85 "/>
18
+ <path fill="#FFFFFF" d="M66.1,14.4L85,85l-9.5-72.4C72.3,13,69.1,13.6,66.1,14.4z"/>
19
+ <path fill="#FFFFFF" d="M143,40.5c-1.9-2.5-4-4.9-6.3-7.2L85,85L143,40.5z"/>
20
+ <path fill="#FFFFFF" d="M152.5,57c-1.2-3-2.6-5.8-4.2-8.6L85,85L152.5,57z"/>
21
+ <path fill="#FFFFFF" d="M155.6,66.1L85,85l72.4-9.5C157,72.3,156.4,69.1,155.6,66.1z"/>
22
+ <path fill="#FFFFFF" d="M103.9,155.6L85,85l9.5,72.4C97.7,157,100.9,156.4,103.9,155.6z"/>
23
+ <path fill="#FFFFFF" d="M113,152.5c3-1.2,5.8-2.6,8.6-4.2L85,85v0L113,152.5z"/>
24
+ <path fill="#FFFFFF" d="M85,158V85l-9.5,72.4C78.6,157.8,81.8,158,85,158z"/>
25
+ <path fill="#FFFFFF" d="M129.5,143c2.5-1.9,4.9-4,7.2-6.3L85,85L129.5,143z"/>
26
+ <path fill="#FFFFFF" d="M85,85L85,85l67.5,28c1.2-2.9,2.2-5.9,3.1-9.1L85,85L85,85z"/>
27
+ <path fill="#FFFFFF" d="M143,129.5c1.9-2.5,3.7-5.2,5.3-7.9L85,85L143,129.5z"/>
28
+ <path fill="#FFFFFF" d="M33.3,136.7L85,85v0l-58,44.5C29,132,31.1,134.4,33.3,136.7z"/>
29
+ <path fill="#FFFFFF" d="M85,85l-72.4-9.5C12.2,78.6,12,81.8,12,85H85L85,85L85,85z"/>
30
+ <path fill="#FFFFFF" d="M14.4,103.9L85,85l-72.4,9.5C13,97.7,13.6,100.9,14.4,103.9z"/>
31
+ <path fill="#FFFFFF" d="M17.5,57c-1.2,2.9-2.2,5.9-3.1,9L85,85L17.5,57z"/>
32
+ <path fill="#FFFFFF" d="M66.1,155.6L85,85l-28,67.5C60,153.7,63,154.7,66.1,155.6z"/>
33
+ <path fill="#FFFFFF" d="M40.5,143c2.5,1.9,5.2,3.7,7.9,5.3L85,85l0,0L40.5,143z"/>
34
+ <path fill="#FFFFFF" d="M21.7,121.5L85,85l-67.5,28C18.7,115.9,20.1,118.8,21.7,121.5z"/>
35
+ </g>
36
+ <g>
37
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M85.9,65.2c1.7-1.6,7.5-8.8,9.2-11.4c-2.1-2.7-5.3-5.7-8.4-7.9
38
+ c-0.4,0-11.3,11.1-11.5,12.6C77,60.4,83.7,63.9,85.9,65.2z"/>
39
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M95,71c0.2,1.9-1.5,5.4-0.9,6.1c1.3-0.2,9.3-9,11.7-11.5
40
+ c-1.6-2.6-6.6-9.6-8.8-9.9c-1.9,1.8-7.5,8.4-8.6,10.5C90.1,67.7,93,69.5,95,71z"/>
41
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M86.2,115.5c1.2-1.2,3.3-1.1,4-3c-1.4-4.2-10.3-26-11.1-26.7
42
+ c-0.5-0.5-9.2-4.2-8.9-5.4c1.2-0.5,3.3,0.2,4.3-0.5c0.7-2.7-1.6-4.5-0.6-6.5c1.8,2.4,4.2,5.2,5.7,5.7c1.6,0.6,9.7,0.4,11.4,0
43
+ c1.1-1.8,1.5-3.9,1.9-6.6c-2.8-2.6-19.2-13-21.4-13.3c-3.1,3.3-18.6,19.8-18.8,21c-0.1,0.6,14.8,31.6,16.7,35.3
44
+ c0,0.9-8.1,27.8-9.7,36.5c7.6,1.9,14.6,2.5,21.2,2.3c2.4-9.5,6.4-27.6,8.3-37.7C88.6,115.4,86.4,117.2,86.2,115.5z"/>
45
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M97.3,92.5c3.9-3,17.3-14.5,17.4-15.6c0.1-1.5-3.8-7.3-7.2-9.5
46
+ c-2.1,2.2-17.3,17.4-18.4,20.1C89.6,88.6,95.1,92,97.3,92.5z"/>
47
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M116.6,79.2c-2,1.6-15.9,13.8-16.9,15.4c0.6,1.4,3.6,5,4.4,6
48
+ c1.7-0.6,17.9-10,18.8-11.9C121.4,85.3,119.1,81.5,116.6,79.2z"/>
49
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M75.9,80.7c-0.8,0.6,8.5,5.2,9.9,5.6c0.9-0.3,3.9-2.6,4.9-5
50
+ C86.8,81.6,77.1,80.6,75.9,80.7z"/>
51
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M104,103.1c-1.8-1-5.1-5.9-6.4-7.3C96,94,87.8,89,82.5,87.2
52
+ c0.1,2,11.9,27.7,12,30.4c-1.1-0.2-2-1.5-3.1-0.8c-1.5,4.7-7.3,33.1-8.3,37.9c4.1,1,10.1,2.1,13.7,1.6c1.6-7.5,3.2-24.1,4.8-33.6
53
+ c7.7-5.1,12.5-13.7,15.1-25.5C117.7,95,106.1,102.6,104,103.1z"/>
54
+ </g>
55
+ <g>
56
+ <g>
57
+ <g>
58
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M48.8,76.7c0,0.5-0.4,0.9-0.9,0.9H18.2c-0.5,0-0.9-0.4-0.9-0.9v-7.3
59
+ c0-0.5,0.4-0.9,0.9-0.9h29.7c0.5,0,0.9,0.4,0.9,0.9V76.7z"/>
60
+ </g>
61
+ <g>
62
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M152.7,76.7c0,0.5-0.4,0.9-0.9,0.9h-29.7c-0.5,0-0.9-0.4-0.9-0.9v-7.3
63
+ c0-0.5,0.4-0.9,0.9-0.9h29.7c0.5,0,0.9,0.4,0.9,0.9V76.7z"/>
64
+ </g>
65
+ </g>
66
+ </g>
67
+ <g>
68
+ <path fill="#BB2222" d="M85,18.5c36.2,0,65.7,29.8,65.7,66.5s-29.5,66.5-65.7,66.5c-36.2,0-65.7-29.8-65.7-66.5S48.8,18.5,85,18.5
69
+ M85,1C39.1,1,1.9,38.6,1.9,85c0,46.4,37.2,84,83.1,84s83.1-37.6,83.1-84C168.1,38.6,130.9,1,85,1L85,1z"/>
70
+ </g>
71
+ </g>
72
+ </svg>
@@ -0,0 +1,494 @@
1
+ /**
2
+ * StyleFix 1.0.3 & PrefixFree 1.0.7
3
+ * @author Lea Verou
4
+ * MIT license
5
+ */
6
+
7
+ (function(){
8
+
9
+ if(!window.addEventListener) {
10
+ return;
11
+ }
12
+
13
+ var self = window.StyleFix = {
14
+ link: function(link) {
15
+ try {
16
+ // Ignore stylesheets with data-noprefix attribute as well as alternate stylesheets
17
+ if(link.rel !== 'stylesheet' || link.hasAttribute('data-noprefix')) {
18
+ return;
19
+ }
20
+ }
21
+ catch(e) {
22
+ return;
23
+ }
24
+
25
+ var url = link.href || link.getAttribute('data-href'),
26
+ base = url.replace(/[^\/]+$/, ''),
27
+ base_scheme = (/^[a-z]{3,10}:/.exec(base) || [''])[0],
28
+ base_domain = (/^[a-z]{3,10}:\/\/[^\/]+/.exec(base) || [''])[0],
29
+ base_query = /^([^?]*)\??/.exec(url)[1],
30
+ parent = link.parentNode,
31
+ xhr = new XMLHttpRequest(),
32
+ process;
33
+
34
+ xhr.onreadystatechange = function() {
35
+ if(xhr.readyState === 4) {
36
+ process();
37
+ }
38
+ };
39
+
40
+ process = function() {
41
+ var css = xhr.responseText;
42
+
43
+ if(css && link.parentNode && (!xhr.status || xhr.status < 400 || xhr.status > 600)) {
44
+ css = self.fix(css, true, link);
45
+
46
+ // Convert relative URLs to absolute, if needed
47
+ if(base) {
48
+ css = css.replace(/url\(\s*?((?:"|')?)(.+?)\1\s*?\)/gi, function($0, quote, url) {
49
+ if(/^([a-z]{3,10}:|#)/i.test(url)) { // Absolute & or hash-relative
50
+ return $0;
51
+ }
52
+ else if(/^\/\//.test(url)) { // Scheme-relative
53
+ // May contain sequences like /../ and /./ but those DO work
54
+ return 'url("' + base_scheme + url + '")';
55
+ }
56
+ else if(/^\//.test(url)) { // Domain-relative
57
+ return 'url("' + base_domain + url + '")';
58
+ }
59
+ else if(/^\?/.test(url)) { // Query-relative
60
+ return 'url("' + base_query + url + '")';
61
+ }
62
+ else {
63
+ // Path-relative
64
+ return 'url("' + base + url + '")';
65
+ }
66
+ });
67
+
68
+ // behavior URLs shoudn’t be converted (Issue #19)
69
+ // base should be escaped before added to RegExp (Issue #81)
70
+ var escaped_base = base.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1");
71
+ css = css.replace(RegExp('\\b(behavior:\\s*?url\\(\'?"?)' + escaped_base, 'gi'), '$1');
72
+ }
73
+
74
+ var style = document.createElement('style');
75
+ style.textContent = css;
76
+ style.media = link.media;
77
+ style.disabled = link.disabled;
78
+ style.setAttribute('data-href', link.getAttribute('href'));
79
+
80
+ parent.insertBefore(style, link);
81
+ parent.removeChild(link);
82
+
83
+ style.media = link.media; // Duplicate is intentional. See issue #31
84
+ }
85
+ };
86
+
87
+ try {
88
+ xhr.open('GET', url);
89
+ xhr.send(null);
90
+ } catch (e) {
91
+ // Fallback to XDomainRequest if available
92
+ if (typeof XDomainRequest != "undefined") {
93
+ xhr = new XDomainRequest();
94
+ xhr.onerror = xhr.onprogress = function() {};
95
+ xhr.onload = process;
96
+ xhr.open("GET", url);
97
+ xhr.send(null);
98
+ }
99
+ }
100
+
101
+ link.setAttribute('data-inprogress', '');
102
+ },
103
+
104
+ styleElement: function(style) {
105
+ if (style.hasAttribute('data-noprefix')) {
106
+ return;
107
+ }
108
+ var disabled = style.disabled;
109
+
110
+ style.textContent = self.fix(style.textContent, true, style);
111
+
112
+ style.disabled = disabled;
113
+ },
114
+
115
+ styleAttribute: function(element) {
116
+ var css = element.getAttribute('style');
117
+
118
+ css = self.fix(css, false, element);
119
+
120
+ element.setAttribute('style', css);
121
+ },
122
+
123
+ process: function() {
124
+ // Linked stylesheets
125
+ $('link[rel="stylesheet"]:not([data-inprogress])').forEach(StyleFix.link);
126
+
127
+ // Inline stylesheets
128
+ $('style').forEach(StyleFix.styleElement);
129
+
130
+ // Inline styles
131
+ $('[style]').forEach(StyleFix.styleAttribute);
132
+ },
133
+
134
+ register: function(fixer, index) {
135
+ (self.fixers = self.fixers || [])
136
+ .splice(index === undefined? self.fixers.length : index, 0, fixer);
137
+ },
138
+
139
+ fix: function(css, raw, element) {
140
+ for(var i=0; i<self.fixers.length; i++) {
141
+ css = self.fixers[i](css, raw, element) || css;
142
+ }
143
+
144
+ return css;
145
+ },
146
+
147
+ camelCase: function(str) {
148
+ return str.replace(/-([a-z])/g, function($0, $1) { return $1.toUpperCase(); }).replace('-','');
149
+ },
150
+
151
+ deCamelCase: function(str) {
152
+ return str.replace(/[A-Z]/g, function($0) { return '-' + $0.toLowerCase() });
153
+ }
154
+ };
155
+
156
+ /**************************************
157
+ * Process styles
158
+ **************************************/
159
+ (function(){
160
+ setTimeout(function(){
161
+ $('link[rel="stylesheet"]').forEach(StyleFix.link);
162
+ }, 10);
163
+
164
+ document.addEventListener('DOMContentLoaded', StyleFix.process, false);
165
+ })();
166
+
167
+ function $(expr, con) {
168
+ return [].slice.call((con || document).querySelectorAll(expr));
169
+ }
170
+
171
+ })();
172
+
173
+ /**
174
+ * PrefixFree
175
+ */
176
+ (function(root){
177
+
178
+ if(!window.StyleFix || !window.getComputedStyle) {
179
+ return;
180
+ }
181
+
182
+ // Private helper
183
+ function fix(what, before, after, replacement, css) {
184
+ what = self[what];
185
+
186
+ if(what.length) {
187
+ var regex = RegExp(before + '(' + what.join('|') + ')' + after, 'gi');
188
+
189
+ css = css.replace(regex, replacement);
190
+ }
191
+
192
+ return css;
193
+ }
194
+
195
+ var self = window.PrefixFree = {
196
+ prefixCSS: function(css, raw, element) {
197
+ var prefix = self.prefix;
198
+
199
+ // Gradient angles hotfix
200
+ if(self.functions.indexOf('linear-gradient') > -1) {
201
+ // Gradients are supported with a prefix, convert angles to legacy
202
+ css = css.replace(/(\s|:|,)(repeating-)?linear-gradient\(\s*(-?\d*\.?\d*)deg/ig, function ($0, delim, repeating, deg) {
203
+ return delim + (repeating || '') + 'linear-gradient(' + (90-deg) + 'deg';
204
+ });
205
+ }
206
+
207
+ css = fix('functions', '(\\s|:|,)', '\\s*\\(', '$1' + prefix + '$2(', css);
208
+ css = fix('keywords', '(\\s|:)', '(\\s|;|\\}|$)', '$1' + prefix + '$2$3', css);
209
+ css = fix('properties', '(^|\\{|\\s|;)', '\\s*:', '$1' + prefix + '$2:', css);
210
+
211
+ // Prefix properties *inside* values (issue #8)
212
+ if (self.properties.length) {
213
+ var regex = RegExp('\\b(' + self.properties.join('|') + ')(?!:)', 'gi');
214
+
215
+ css = fix('valueProperties', '\\b', ':(.+?);', function($0) {
216
+ return $0.replace(regex, prefix + "$1")
217
+ }, css);
218
+ }
219
+
220
+ if(raw) {
221
+ css = fix('selectors', '', '\\b', self.prefixSelector, css);
222
+ css = fix('atrules', '@', '\\b', '@' + prefix + '$1', css);
223
+ }
224
+
225
+ // Fix double prefixing
226
+ css = css.replace(RegExp('-' + prefix, 'g'), '-');
227
+
228
+ // Prefix wildcard
229
+ css = css.replace(/-\*-(?=[a-z]+)/gi, self.prefix);
230
+
231
+ return css;
232
+ },
233
+
234
+ property: function(property) {
235
+ return (self.properties.indexOf(property) >=0 ? self.prefix : '') + property;
236
+ },
237
+
238
+ value: function(value, property) {
239
+ value = fix('functions', '(^|\\s|,)', '\\s*\\(', '$1' + self.prefix + '$2(', value);
240
+ value = fix('keywords', '(^|\\s)', '(\\s|$)', '$1' + self.prefix + '$2$3', value);
241
+
242
+ if(self.valueProperties.indexOf(property) >= 0) {
243
+ value = fix('properties', '(^|\\s|,)', '($|\\s|,)', '$1'+self.prefix+'$2$3', value);
244
+ }
245
+
246
+ return value;
247
+ },
248
+
249
+ // Warning: Prefixes no matter what, even if the selector is supported prefix-less
250
+ prefixSelector: function(selector) {
251
+ return selector.replace(/^:{1,2}/, function($0) { return $0 + self.prefix })
252
+ },
253
+
254
+ // Warning: Prefixes no matter what, even if the property is supported prefix-less
255
+ prefixProperty: function(property, camelCase) {
256
+ var prefixed = self.prefix + property;
257
+
258
+ return camelCase? StyleFix.camelCase(prefixed) : prefixed;
259
+ }
260
+ };
261
+
262
+ /**************************************
263
+ * Properties
264
+ **************************************/
265
+ (function() {
266
+ var prefixes = {},
267
+ properties = [],
268
+ shorthands = {},
269
+ style = getComputedStyle(document.documentElement, null),
270
+ dummy = document.createElement('div').style;
271
+
272
+ // Why are we doing this instead of iterating over properties in a .style object? Cause Webkit won't iterate over those.
273
+ var iterate = function(property) {
274
+ if(property.charAt(0) === '-') {
275
+ properties.push(property);
276
+
277
+ var parts = property.split('-'),
278
+ prefix = parts[1];
279
+
280
+ // Count prefix uses
281
+ prefixes[prefix] = ++prefixes[prefix] || 1;
282
+
283
+ // This helps determining shorthands
284
+ while(parts.length > 3) {
285
+ parts.pop();
286
+
287
+ var shorthand = parts.join('-');
288
+
289
+ if(supported(shorthand) && properties.indexOf(shorthand) === -1) {
290
+ properties.push(shorthand);
291
+ }
292
+ }
293
+ }
294
+ },
295
+ supported = function(property) {
296
+ return StyleFix.camelCase(property) in dummy;
297
+ }
298
+
299
+ // Some browsers have numerical indices for the properties, some don't
300
+ if(style.length > 0) {
301
+ for(var i=0; i<style.length; i++) {
302
+ iterate(style[i])
303
+ }
304
+ }
305
+ else {
306
+ for(var property in style) {
307
+ iterate(StyleFix.deCamelCase(property));
308
+ }
309
+ }
310
+
311
+ // Find most frequently used prefix
312
+ var highest = {uses:0};
313
+ for(var prefix in prefixes) {
314
+ var uses = prefixes[prefix];
315
+
316
+ if(highest.uses < uses) {
317
+ highest = {prefix: prefix, uses: uses};
318
+ }
319
+ }
320
+
321
+ self.prefix = '-' + highest.prefix + '-';
322
+ self.Prefix = StyleFix.camelCase(self.prefix);
323
+
324
+ self.properties = [];
325
+
326
+ // Get properties ONLY supported with a prefix
327
+ for(var i=0; i<properties.length; i++) {
328
+ var property = properties[i];
329
+
330
+ if(property.indexOf(self.prefix) === 0) { // we might have multiple prefixes, like Opera
331
+ var unprefixed = property.slice(self.prefix.length);
332
+
333
+ if(!supported(unprefixed)) {
334
+ self.properties.push(unprefixed);
335
+ }
336
+ }
337
+ }
338
+
339
+ // IE fix
340
+ if(self.Prefix == 'Ms'
341
+ && !('transform' in dummy)
342
+ && !('MsTransform' in dummy)
343
+ && ('msTransform' in dummy)) {
344
+ self.properties.push('transform', 'transform-origin');
345
+ }
346
+
347
+ self.properties.sort();
348
+ })();
349
+
350
+ /**************************************
351
+ * Values
352
+ **************************************/
353
+ (function() {
354
+ // Values that might need prefixing
355
+ var functions = {
356
+ 'linear-gradient': {
357
+ property: 'backgroundImage',
358
+ params: 'red, teal'
359
+ },
360
+ 'calc': {
361
+ property: 'width',
362
+ params: '1px + 5%'
363
+ },
364
+ 'element': {
365
+ property: 'backgroundImage',
366
+ params: '#foo'
367
+ },
368
+ 'cross-fade': {
369
+ property: 'backgroundImage',
370
+ params: 'url(a.png), url(b.png), 50%'
371
+ }
372
+ };
373
+
374
+
375
+ functions['repeating-linear-gradient'] =
376
+ functions['repeating-radial-gradient'] =
377
+ functions['radial-gradient'] =
378
+ functions['linear-gradient'];
379
+
380
+ // Note: The properties assigned are just to *test* support.
381
+ // The keywords will be prefixed everywhere.
382
+ var keywords = {
383
+ 'initial': 'color',
384
+ 'zoom-in': 'cursor',
385
+ 'zoom-out': 'cursor',
386
+ 'box': 'display',
387
+ 'flexbox': 'display',
388
+ 'inline-flexbox': 'display',
389
+ 'flex': 'display',
390
+ 'inline-flex': 'display',
391
+ 'grid': 'display',
392
+ 'inline-grid': 'display',
393
+ 'min-content': 'width'
394
+ };
395
+
396
+ self.functions = [];
397
+ self.keywords = [];
398
+
399
+ var style = document.createElement('div').style;
400
+
401
+ function supported(value, property) {
402
+ style[property] = '';
403
+ style[property] = value;
404
+
405
+ return !!style[property];
406
+ }
407
+
408
+ for (var func in functions) {
409
+ var test = functions[func],
410
+ property = test.property,
411
+ value = func + '(' + test.params + ')';
412
+
413
+ if (!supported(value, property)
414
+ && supported(self.prefix + value, property)) {
415
+ // It's supported, but with a prefix
416
+ self.functions.push(func);
417
+ }
418
+ }
419
+
420
+ for (var keyword in keywords) {
421
+ var property = keywords[keyword];
422
+
423
+ if (!supported(keyword, property)
424
+ && supported(self.prefix + keyword, property)) {
425
+ // It's supported, but with a prefix
426
+ self.keywords.push(keyword);
427
+ }
428
+ }
429
+
430
+ })();
431
+
432
+ /**************************************
433
+ * Selectors and @-rules
434
+ **************************************/
435
+ (function() {
436
+
437
+ var
438
+ selectors = {
439
+ ':read-only': null,
440
+ ':read-write': null,
441
+ ':any-link': null,
442
+ '::selection': null
443
+ },
444
+
445
+ atrules = {
446
+ 'keyframes': 'name',
447
+ 'viewport': null,
448
+ 'document': 'regexp(".")'
449
+ };
450
+
451
+ self.selectors = [];
452
+ self.atrules = [];
453
+
454
+ var style = root.appendChild(document.createElement('style'));
455
+
456
+ function supported(selector) {
457
+ style.textContent = selector + '{}'; // Safari 4 has issues with style.innerHTML
458
+
459
+ return !!style.sheet.cssRules.length;
460
+ }
461
+
462
+ for(var selector in selectors) {
463
+ var test = selector + (selectors[selector]? '(' + selectors[selector] + ')' : '');
464
+
465
+ if(!supported(test) && supported(self.prefixSelector(test))) {
466
+ self.selectors.push(selector);
467
+ }
468
+ }
469
+
470
+ for(var atrule in atrules) {
471
+ var test = atrule + ' ' + (atrules[atrule] || '');
472
+
473
+ if(!supported('@' + test) && supported('@' + self.prefix + test)) {
474
+ self.atrules.push(atrule);
475
+ }
476
+ }
477
+
478
+ root.removeChild(style);
479
+
480
+ })();
481
+
482
+ // Properties that accept properties as their value
483
+ self.valueProperties = [
484
+ 'transition',
485
+ 'transition-property'
486
+ ]
487
+
488
+ // Add class for current prefix
489
+ root.className += ' ' + self.prefix;
490
+
491
+ StyleFix.register(self.prefixCSS);
492
+
493
+
494
+ })(document.documentElement);