loadcss-rails 0.2.4 → 1.2.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/loadcss/rails/version.rb +2 -2
- data/vendor/assets/javascripts/loadCSS.js +27 -12
- data/vendor/assets/javascripts/onloadCSS.js +17 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f15dadc331f3fa21aa545605d2d31bb86cce3d2
|
4
|
+
data.tar.gz: f6ae515f801ef7005ee46cc386fd17a238b3cd61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fbdc20d5b191f72ab94faf3c03ecba47e8108eef6980c9df11a1025433ee49d99072c87508b6f2ca319358e05ba736f74d2394bbdf095f9cc72107b8ebd2ef1
|
7
|
+
data.tar.gz: e59d509ed8c94092c63b76bc3cdb15b606444615987e96d84d9f80a1ca03a8ed2d3f8d2c018b346ab6a4528d9e17c9f090684f29d6144613c74dfcb2f201c064
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ These pieces of javascript were implemented by [Filament Group](https://github.c
|
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
```
|
14
|
-
gem 'loadcss-rails', '~>
|
14
|
+
gem 'loadcss-rails', '~> 1.2.0'
|
15
15
|
```
|
16
16
|
|
17
17
|
The loadCSS and onloadCSS files will be added to the asset pipeline and available for you to use. Add the lines that you need to your application's JS manifest (usually `app/assets/javascripts/application.js`).
|
@@ -1,8 +1,4 @@
|
|
1
|
-
/*!
|
2
|
-
loadCSS: load a CSS file asynchronously.
|
3
|
-
[c]2015 @scottjehl, Filament Group, Inc.
|
4
|
-
Licensed MIT
|
5
|
-
*/
|
1
|
+
/*! loadCSS: load a CSS file asynchronously. [c]2016 @scottjehl, Filament Group, Inc. Licensed MIT */
|
6
2
|
(function(w){
|
7
3
|
"use strict";
|
8
4
|
/* exported loadCSS */
|
@@ -29,10 +25,21 @@ Licensed MIT
|
|
29
25
|
// temporarily set media to something inapplicable to ensure it'll fetch without blocking render
|
30
26
|
ss.media = "only x";
|
31
27
|
|
28
|
+
// wait until body is defined before injecting link. This ensures a non-blocking load in IE11.
|
29
|
+
function ready( cb ){
|
30
|
+
if( doc.body ){
|
31
|
+
return cb();
|
32
|
+
}
|
33
|
+
setTimeout(function(){
|
34
|
+
ready( cb );
|
35
|
+
});
|
36
|
+
}
|
32
37
|
// Inject link
|
33
38
|
// Note: the ternary preserves the existing behavior of "before" argument, but we could choose to change the argument to "after" in a later release and standardize on ref.nextSibling for all refs
|
34
39
|
// Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/
|
35
|
-
|
40
|
+
ready( function(){
|
41
|
+
ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
|
42
|
+
});
|
36
43
|
// A method (exposed on return object for external use) that mimics onload by polling until document.styleSheets until it includes the new sheet.
|
37
44
|
var onloadcssdefined = function( cb ){
|
38
45
|
var resolvedHref = ss.href;
|
@@ -47,18 +54,26 @@ Licensed MIT
|
|
47
54
|
});
|
48
55
|
};
|
49
56
|
|
57
|
+
function loadCB(){
|
58
|
+
if( ss.addEventListener ){
|
59
|
+
ss.removeEventListener( "load", loadCB );
|
60
|
+
}
|
61
|
+
ss.media = media || "all";
|
62
|
+
}
|
63
|
+
|
50
64
|
// once loaded, set link's media back to `all` so that the stylesheet applies once it loads
|
65
|
+
if( ss.addEventListener ){
|
66
|
+
ss.addEventListener( "load", loadCB);
|
67
|
+
}
|
51
68
|
ss.onloadcssdefined = onloadcssdefined;
|
52
|
-
onloadcssdefined(
|
53
|
-
ss.media = media || "all";
|
54
|
-
});
|
69
|
+
onloadcssdefined( loadCB );
|
55
70
|
return ss;
|
56
71
|
};
|
57
72
|
// commonjs
|
58
|
-
if( typeof
|
59
|
-
|
73
|
+
if( typeof exports !== "undefined" ){
|
74
|
+
exports.loadCSS = loadCSS;
|
60
75
|
}
|
61
76
|
else {
|
62
77
|
w.loadCSS = loadCSS;
|
63
78
|
}
|
64
|
-
}( typeof global !== "undefined" ? global : this ));
|
79
|
+
}( typeof global !== "undefined" ? global : this ));
|
@@ -1,28 +1,29 @@
|
|
1
|
-
/*!
|
2
|
-
onloadCSS: adds onload support for asynchronous stylesheets loaded with loadCSS.
|
3
|
-
[c]2014 @zachleat, Filament Group, Inc.
|
4
|
-
Licensed MIT
|
5
|
-
*/
|
6
|
-
|
1
|
+
/*! onloadCSS: adds onload support for asynchronous stylesheets loaded with loadCSS. [c]2016 @zachleat, Filament Group, Inc. Licensed MIT */
|
7
2
|
/* global navigator */
|
8
3
|
/* exported onloadCSS */
|
9
4
|
function onloadCSS( ss, callback ) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
var called;
|
6
|
+
function newcb(){
|
7
|
+
if( !called && callback ){
|
8
|
+
called = true;
|
9
|
+
callback.call( ss );
|
10
|
+
}
|
11
|
+
}
|
12
|
+
if( ss.addEventListener ){
|
13
|
+
ss.addEventListener( "load", newcb );
|
14
|
+
}
|
15
|
+
if( ss.attachEvent ){
|
16
|
+
ss.attachEvent( "onload", newcb );
|
17
|
+
}
|
16
18
|
|
17
|
-
// This code is for browsers that don’t support onload
|
18
|
-
//
|
19
|
-
// No support for onload:
|
19
|
+
// This code is for browsers that don’t support onload
|
20
|
+
// No support for onload (it'll bind but never fire):
|
20
21
|
// * Android 4.3 (Samsung Galaxy S4, Browserstack)
|
21
22
|
// * Android 4.2 Browser (Samsung Galaxy SIII Mini GT-I8200L)
|
22
23
|
// * Android 2.3 (Pantech Burst P9070)
|
23
24
|
|
24
25
|
// Weak inference targets Android < 4.4
|
25
26
|
if( "isApplicationInstalled" in navigator && "onloadcssdefined" in ss ) {
|
26
|
-
ss.onloadcssdefined(
|
27
|
+
ss.onloadcssdefined( newcb );
|
27
28
|
}
|
28
29
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loadcss-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Misshore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem provides LoadCSS and OnloadCSS for your Rails application.
|
14
14
|
email:
|