loadcss-rails 0.1.1 → 0.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/lib/loadcss/rails/version.rb +2 -2
- data/vendor/assets/javascripts/loadCSS.js +16 -21
- 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: bc83079b8a027fcbbb231e86e88ebe42e201bbcb
|
4
|
+
data.tar.gz: 8dc523aedbc7d70b1c7b445caeb0aaf13ff7a959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1eb47d36c6e619d0a71846430ddcb9a131132ca532509e1d834c55c0cfdfd0d7e2483688d8665844b9377bcabf96b355f11a8c789834fa2b24970d545b092d
|
7
|
+
data.tar.gz: 9269799a1acd34349f97e5d559274cacfbb74fd0badae43eb09b0d47e2331b433c08bf64444ae95802b17f79bfef56a8dced980b89abc76704cedf9ab5e651f0
|
@@ -12,21 +12,18 @@ Licensed MIT
|
|
12
12
|
// `before` [OPTIONAL] is the element the script should use as a reference for injecting our stylesheet <link> before
|
13
13
|
// By default, loadCSS attempts to inject the link after the last stylesheet or script in the DOM. However, you might desire a more specific location in your document.
|
14
14
|
// `media` [OPTIONAL] is the media type or query of the stylesheet. By default it will be 'all'
|
15
|
-
var
|
15
|
+
var doc = w.document;
|
16
|
+
var ss = doc.createElement( "link" );
|
16
17
|
var ref;
|
17
18
|
if( before ){
|
18
19
|
ref = before;
|
19
20
|
}
|
20
|
-
else if( w.document.querySelectorAll ){
|
21
|
-
var refs = w.document.querySelectorAll( "style,link[rel=stylesheet],script" );
|
22
|
-
// No need to check length. This script has a parent element, at least
|
23
|
-
ref = refs[ refs.length - 1];
|
24
|
-
}
|
25
21
|
else {
|
26
|
-
|
22
|
+
var refs = ( doc.body || doc.getElementsByTagName( "head" )[ 0 ] ).childNodes;
|
23
|
+
ref = refs[ refs.length - 1];
|
27
24
|
}
|
28
25
|
|
29
|
-
var sheets =
|
26
|
+
var sheets = doc.styleSheets;
|
30
27
|
ss.rel = "stylesheet";
|
31
28
|
ss.href = href;
|
32
29
|
// temporarily set media to something inapplicable to ensure it'll fetch without blocking render
|
@@ -37,24 +34,22 @@ Licensed MIT
|
|
37
34
|
// Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/
|
38
35
|
ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
|
39
36
|
// A method (exposed on return object for external use) that mimics onload by polling until document.styleSheets until it includes the new sheet.
|
40
|
-
|
41
|
-
var
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
var onloadcssdefined = function( cb ){
|
38
|
+
var resolvedHref = ss.href;
|
39
|
+
var i = sheets.length;
|
40
|
+
while( i-- ){
|
41
|
+
if( sheets[ i ].href === resolvedHref ){
|
42
|
+
return cb();
|
45
43
|
}
|
46
44
|
}
|
47
|
-
|
48
|
-
cb
|
49
|
-
}
|
50
|
-
setTimeout(function() {
|
51
|
-
ss.onloadcssdefined( cb );
|
52
|
-
});
|
53
|
-
}
|
45
|
+
setTimeout(function() {
|
46
|
+
onloadcssdefined( cb );
|
47
|
+
});
|
54
48
|
};
|
55
49
|
|
56
50
|
// once loaded, set link's media back to `all` so that the stylesheet applies once it loads
|
57
|
-
ss.onloadcssdefined
|
51
|
+
ss.onloadcssdefined = onloadcssdefined;
|
52
|
+
onloadcssdefined(function() {
|
58
53
|
ss.media = media || "all";
|
59
54
|
});
|
60
55
|
return ss;
|
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: 0.
|
4
|
+
version: 0.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: 2015-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem provides LoadCSS and OnloadCSS for your Rails application.
|
14
14
|
email:
|