loadcss-rails 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e125130441bd4853f78a4c8010f11f2385d88c4
4
+ data.tar.gz: 6c2c3281b649d8181262e4dbec8351bff5f67f0e
5
+ SHA512:
6
+ metadata.gz: 7c7026ced6d35c915861aa7f95f37d760b769daac3b739e6a8ed3c2e89d1ce567d56e6a88c3d4229a99a94e281c4fc8a5b54b5096b6941166bcffe97d78e5eac
7
+ data.tar.gz: 1772efcd8e1f013a74241cb4382ff414da1a2ae6ab2112ed7a709293f0d3ad7d5034a2879f9695af55e7be58f208968760672c8d37ae43873ca66ac14dbcbadb
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ pkg/*
2
+ tmp
3
+ spec/support/*/Gemfile.lock
4
+ spec/support/*/public/javascripts
5
+ .ruby-version
6
+ .bundle
7
+ imports/*
8
+ Gemfile.lock
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) [2015] [Michael Misshore]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # loadcss-rails
2
+
3
+ loadCSS (and onloadCSS) for Rails!
4
+
5
+ This gem provides:
6
+
7
+ * loadCSS and onloadCSS
8
+
9
+ These pieces of javascript were implemented by [Filament Group](https://github.com/filamentgroup/loadCSS/)
10
+
11
+ ## Versions
12
+
13
+ The loadcss-rails gem follows these version guidelines to provide more control over your app's loadCSS version from your Gemfile:
14
+
15
+ ```
16
+ patch version bump = updates to loadcss-rails and patch-level updates to loadCSS
17
+ minor version bump = minor-level updates to loadCSS
18
+ major version bump = major-level updates to loadCSS and updates to Rails which may be backwards-incompatible
19
+ ```
20
+
21
+ ## Installation
22
+
23
+ The loadCSS and onloadCSS files will be added to the asset pipeline and available for you to use. If they're not already in `app/assets/javascripts/application.js` by default, add these lines:
24
+
25
+ ```js
26
+ //= require loadCSS
27
+ //= require onloadCSS
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ Feel free to open an issue ticket if you find something that could be improved. A couple notes:
33
+
34
+ * If the loadCSS scripts are outdated (i.e. maybe a new version of loadCSS was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated loadCSS scripts.
35
+
36
+ Copyright Michael Misshore, released under the MIT License.
@@ -0,0 +1,6 @@
1
+ module LoadCSS
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module LoadCSS
2
+ module Rails
3
+ VERSION = "0.1.0"
4
+ LOADCSS_VERSION = "0.1.8"
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ require 'loadcss/rails/engine'
2
+ require 'loadcss/rails/version'
3
+
4
+ module LoadCSS
5
+ module Rails
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require 'loadcss/rails'
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/loadcss/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "loadcss-rails"
6
+ s.version = LoadCSS::Rails::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Michael Misshore"]
9
+ s.email = ["mmisshore@gmail.com"]
10
+ s.summary = "Use LoadCSS and OnloadCSS with Rails"
11
+ s.description = "This gem provides LoadCSS and OnloadCSS for your Rails application."
12
+ s.license = "MIT"
13
+
14
+ # s.required_ruby_version = ">= 1.9.3"
15
+ # s.required_rubygems_version = ">= 1.3.6"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
+ s.require_path = 'lib'
20
+ end
@@ -0,0 +1,62 @@
1
+ /*!
2
+ loadCSS: load a CSS file asynchronously.
3
+ [c]2015 @scottjehl, Filament Group, Inc.
4
+ Licensed MIT
5
+ */
6
+ (function(w){
7
+ "use strict";
8
+ /* exported loadCSS */
9
+ w.loadCSS = function( href, before, media ){
10
+ // Arguments explained:
11
+ // `href` [REQUIRED] is the URL for your CSS file.
12
+ // `before` [OPTIONAL] is the element the script should use as a reference for injecting our stylesheet <link> before
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
+ // `media` [OPTIONAL] is the media type or query of the stylesheet. By default it will be 'all'
15
+ var ss = w.document.createElement( "link" );
16
+ var ref;
17
+ if( before ){
18
+ ref = before;
19
+ }
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
+ else {
26
+ ref = w.document.getElementsByTagName( "script" )[ 0 ];
27
+ }
28
+
29
+ var sheets = w.document.styleSheets;
30
+ ss.rel = "stylesheet";
31
+ ss.href = href;
32
+ // temporarily set media to something inapplicable to ensure it'll fetch without blocking render
33
+ ss.media = "only x";
34
+
35
+ // Inject link
36
+ // 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
37
+ // Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/
38
+ ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
39
+ // A method (exposed on return object for external use) that mimics onload by polling until document.styleSheets until it includes the new sheet.
40
+ ss.onloadcssdefined = function( cb ){
41
+ var defined;
42
+ for( var i = 0; i < sheets.length; i++ ){
43
+ if( sheets[ i ].href && sheets[ i ].href === ss.href ){
44
+ defined = true;
45
+ }
46
+ }
47
+ if( defined ){
48
+ cb();
49
+ } else {
50
+ setTimeout(function() {
51
+ ss.onloadcssdefined( cb );
52
+ });
53
+ }
54
+ };
55
+
56
+ // once loaded, set link's media back to `all` so that the stylesheet applies once it loads
57
+ ss.onloadcssdefined(function() {
58
+ ss.media = media || "all";
59
+ });
60
+ return ss;
61
+ };
62
+ }(this));
@@ -0,0 +1,28 @@
1
+ /*!
2
+ onloadCSS: adds onload support for asynchronous stylesheets loaded with loadCSS.
3
+ [c]2014 @zachleat, Filament Group, Inc.
4
+ Licensed MIT
5
+ */
6
+
7
+ /* global navigator */
8
+ /* exported onloadCSS */
9
+ function onloadCSS( ss, callback ) {
10
+ ss.onload = function() {
11
+ ss.onload = null;
12
+ if( callback ) {
13
+ callback.call( ss );
14
+ }
15
+ };
16
+
17
+ // This code is for browsers that don’t support onload, any browser that
18
+ // supports onload should use that instead.
19
+ // No support for onload:
20
+ // * Android 4.3 (Samsung Galaxy S4, Browserstack)
21
+ // * Android 4.2 Browser (Samsung Galaxy SIII Mini GT-I8200L)
22
+ // * Android 2.3 (Pantech Burst P9070)
23
+
24
+ // Weak inference targets Android < 4.4
25
+ if( "isApplicationInstalled" in navigator && "onloadcssdefined" in ss ) {
26
+ ss.onloadcssdefined( callback );
27
+ }
28
+ }
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: loadcss-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Misshore
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem provides LoadCSS and OnloadCSS for your Rails application.
14
+ email:
15
+ - mmisshore@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - LICENSE
22
+ - README.md
23
+ - lib/loadcss-rails.rb
24
+ - lib/loadcss/rails.rb
25
+ - lib/loadcss/rails/engine.rb
26
+ - lib/loadcss/rails/version.rb
27
+ - loadcss-rails.gemspec
28
+ - vendor/assets/javascripts/loadCSS.js
29
+ - vendor/assets/javascripts/onloadCSS.js
30
+ homepage:
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.4.8
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Use LoadCSS and OnloadCSS with Rails
54
+ test_files: []