nprogress_rails 0.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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +1 -0
- data/lib/nprogress_rails.rb +4 -0
- data/nprogress_rails.gemspec +22 -0
- data/vendor/assets/javascripts/nprogress.js +220 -0
- data/vendor/assets/javascripts/nprogress_turbolinks.js +4 -0
- data/vendor/assets/stylesheets/nprogress.css +85 -0
- data/vendor/assets/stylesheets/nprogress_bootstrap.css +3 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 84be57f17dc2341dfa51d86c4dc318d01b005145
|
4
|
+
data.tar.gz: 3e640f92d36d4f1356a6b344c21bb6c9078c91a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06ed4c714b89cd26049e893f909b58d26d0706bd4b6ec39c458d9f8b256504ab2c5cc586f869cac5e6f0096d14b4d7edddc77d5625381d253418fc067bafdcf6
|
7
|
+
data.tar.gz: 75875506f989870b898ed220a0452588b55ddc172074f10e40455eecc34992cc07d4e79bd0e7fc012b9ed32ad3de1fb11d3b7d0ba2c6a91d9367c28a7e103777
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Carlos Alexandro Becker
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# nprogress_rails
|
2
|
+
|
3
|
+
This is basically a ruby gem for asset pipeline which includes the version
|
4
|
+
0.1.0 of the awesome rstacruz' [nprogress](https://github.com/rstacruz/nprogress)
|
5
|
+
library.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'nprogress_rails'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install nprogress_rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
You basically have to add the requires.
|
24
|
+
|
25
|
+
In your `application.js.coffee` (or just JS):
|
26
|
+
|
27
|
+
```coffeescript
|
28
|
+
#= require nprogress
|
29
|
+
#= require nprogress_turbolinks
|
30
|
+
```
|
31
|
+
|
32
|
+
The `nprogress_turbolinks` is required only if you use turbolinks. Otherwise,
|
33
|
+
you will have to deal with show/hide the progress by your own.
|
34
|
+
|
35
|
+
Also, into your `application.css.scss` file:
|
36
|
+
|
37
|
+
```scss
|
38
|
+
*= require nprogress
|
39
|
+
*= require nprogress_bootstrap
|
40
|
+
```
|
41
|
+
|
42
|
+
The `nprogress_bootstrap` is required if you use bootstrap and have a fixed
|
43
|
+
toolbar or anything else. tl;dr: if the console shows no erros, but the
|
44
|
+
progress doesn't appear, try this.
|
45
|
+
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "nprogress_rails"
|
7
|
+
spec.version = "0.1.0.1"
|
8
|
+
spec.authors = ["Carlos Alexandro Becker"]
|
9
|
+
spec.email = ["caarlos0@gmail.com"]
|
10
|
+
spec.description = %q{This is a gem for the rstacruz' nprogress implementation. It's based on version nprogress 0.1.0.}
|
11
|
+
spec.summary = %q{Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and Medium.}
|
12
|
+
spec.homepage = "http://carlosbecker.com/about"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
end
|
@@ -0,0 +1,220 @@
|
|
1
|
+
/*! NProgress (c) 2013, Rico Sta. Cruz
|
2
|
+
* http://ricostacruz.com/nprogress */
|
3
|
+
|
4
|
+
;(function(factory) {
|
5
|
+
|
6
|
+
if (typeof module === 'object') {
|
7
|
+
module.exports = factory(this.jQuery || require('dom'));
|
8
|
+
} else {
|
9
|
+
this.NProgress = factory(this.jQuery);
|
10
|
+
}
|
11
|
+
|
12
|
+
})(function($) {
|
13
|
+
var NProgress = {};
|
14
|
+
|
15
|
+
NProgress.version = '0.1.0';
|
16
|
+
|
17
|
+
var Settings = NProgress.settings = {
|
18
|
+
minimum: 0.08,
|
19
|
+
easing: 'ease',
|
20
|
+
speed: 200,
|
21
|
+
trickle: true,
|
22
|
+
trickleRate: 0.02,
|
23
|
+
trickleSpeed: 800,
|
24
|
+
template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner"><div class="spinner-icon"></div></div>'
|
25
|
+
};
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Updates configuration.
|
29
|
+
*
|
30
|
+
* NProgress.configure({
|
31
|
+
* minimum: 0.1
|
32
|
+
* });
|
33
|
+
*/
|
34
|
+
NProgress.configure = function(options) {
|
35
|
+
$.extend(Settings, options);
|
36
|
+
return this;
|
37
|
+
};
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Last number.
|
41
|
+
*/
|
42
|
+
|
43
|
+
NProgress.status = null;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
|
47
|
+
*
|
48
|
+
* NProgress.set(0.4);
|
49
|
+
* NProgress.set(1.0);
|
50
|
+
*/
|
51
|
+
|
52
|
+
NProgress.set = function(n) {
|
53
|
+
var started = NProgress.isStarted();
|
54
|
+
|
55
|
+
n = clamp(n, Settings.minimum, 1);
|
56
|
+
NProgress.status = (n === 1 ? null : n);
|
57
|
+
|
58
|
+
var $progress = NProgress.render(!started),
|
59
|
+
$bar = $progress.find('[role="bar"]'),
|
60
|
+
speed = Settings.speed,
|
61
|
+
ease = Settings.easing;
|
62
|
+
|
63
|
+
$progress[0].offsetWidth; /* Repaint */
|
64
|
+
|
65
|
+
$progress.queue(function(next) {
|
66
|
+
$bar.css({
|
67
|
+
transition: 'all '+speed+'ms '+ease,
|
68
|
+
transform: 'translate3d('+toBarPerc(n)+'%,0,0)'
|
69
|
+
});
|
70
|
+
|
71
|
+
if (n === 1) {
|
72
|
+
// Fade out
|
73
|
+
$progress.css({ transition: 'none', opacity: 1 });
|
74
|
+
$progress[0].offsetWidth; /* Repaint */
|
75
|
+
|
76
|
+
setTimeout(function() {
|
77
|
+
$progress.css({ transition: 'all '+speed+'ms linear', opacity: 0 });
|
78
|
+
setTimeout(function() {
|
79
|
+
NProgress.remove();
|
80
|
+
next();
|
81
|
+
}, speed);
|
82
|
+
}, speed);
|
83
|
+
} else {
|
84
|
+
setTimeout(next, speed);
|
85
|
+
}
|
86
|
+
});
|
87
|
+
|
88
|
+
return this;
|
89
|
+
};
|
90
|
+
|
91
|
+
NProgress.isStarted = function() {
|
92
|
+
return typeof NProgress.status === 'number';
|
93
|
+
};
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Shows the progress bar.
|
97
|
+
* This is the same as setting the status to 0%, except that it doesn't go backwards.
|
98
|
+
*
|
99
|
+
* NProgress.start();
|
100
|
+
*
|
101
|
+
*/
|
102
|
+
NProgress.start = function() {
|
103
|
+
if (!NProgress.status) NProgress.set(0);
|
104
|
+
|
105
|
+
var work = function() {
|
106
|
+
setTimeout(function() {
|
107
|
+
if (!NProgress.status) return;
|
108
|
+
NProgress.trickle();
|
109
|
+
work();
|
110
|
+
}, Settings.trickleSpeed);
|
111
|
+
};
|
112
|
+
|
113
|
+
if (Settings.trickle) work();
|
114
|
+
|
115
|
+
return this;
|
116
|
+
};
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Hides the progress bar.
|
120
|
+
* This is the *sort of* the same as setting the status to 100%, with the
|
121
|
+
* difference being `done()` makes some placebo effect of some realistic motion.
|
122
|
+
*
|
123
|
+
* NProgress.done();
|
124
|
+
*
|
125
|
+
* If `true` is passed, it will show the progress bar even if its hidden.
|
126
|
+
*
|
127
|
+
* NProgress.done(true);
|
128
|
+
*/
|
129
|
+
|
130
|
+
NProgress.done = function(force) {
|
131
|
+
if (!force && !NProgress.status) return this;
|
132
|
+
|
133
|
+
return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
|
134
|
+
};
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Increments by a random amount.
|
138
|
+
*/
|
139
|
+
|
140
|
+
NProgress.inc = function(amount) {
|
141
|
+
var n = NProgress.status;
|
142
|
+
|
143
|
+
if (!n) {
|
144
|
+
return NProgress.start();
|
145
|
+
} else {
|
146
|
+
if (typeof amount !== 'number') {
|
147
|
+
amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95);
|
148
|
+
}
|
149
|
+
|
150
|
+
n = clamp(n + amount, 0, 0.994);
|
151
|
+
return NProgress.set(n);
|
152
|
+
}
|
153
|
+
};
|
154
|
+
|
155
|
+
NProgress.trickle = function() {
|
156
|
+
return NProgress.inc(Math.random() * Settings.trickleRate);
|
157
|
+
};
|
158
|
+
|
159
|
+
/**
|
160
|
+
* (Internal) renders the progress bar markup based on the `template`
|
161
|
+
* setting.
|
162
|
+
*/
|
163
|
+
|
164
|
+
NProgress.render = function(fromStart) {
|
165
|
+
if (NProgress.isRendered()) return $("#nprogress");
|
166
|
+
$('html').addClass('nprogress-busy');
|
167
|
+
|
168
|
+
var $el = $("<div id='nprogress'>")
|
169
|
+
.html(Settings.template);
|
170
|
+
|
171
|
+
var perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0);
|
172
|
+
|
173
|
+
$el.find('[role="bar"]').css({
|
174
|
+
transition: 'all 0 linear',
|
175
|
+
transform: 'translate3d('+perc+'%,0,0)'
|
176
|
+
});
|
177
|
+
|
178
|
+
$el.appendTo(document.body);
|
179
|
+
|
180
|
+
return $el;
|
181
|
+
};
|
182
|
+
|
183
|
+
/**
|
184
|
+
* (Internal) Removes the element. Opposite of render().
|
185
|
+
*/
|
186
|
+
|
187
|
+
NProgress.remove = function() {
|
188
|
+
$('html').removeClass('nprogress-busy');
|
189
|
+
$('#nprogress').remove();
|
190
|
+
};
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Checks if the progress bar is rendered.
|
194
|
+
*/
|
195
|
+
|
196
|
+
NProgress.isRendered = function() {
|
197
|
+
return ($("#nprogress").length > 0);
|
198
|
+
};
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Helpers
|
202
|
+
*/
|
203
|
+
|
204
|
+
function clamp(n, min, max) {
|
205
|
+
if (n < min) return min;
|
206
|
+
if (n > max) return max;
|
207
|
+
return n;
|
208
|
+
}
|
209
|
+
|
210
|
+
/**
|
211
|
+
* (Internal) converts a percentage (`0..1`) to a bar translateX
|
212
|
+
* percentage (`-100%..0%`).
|
213
|
+
*/
|
214
|
+
|
215
|
+
function toBarPerc(n) {
|
216
|
+
return (-1 + n) * 100;
|
217
|
+
}
|
218
|
+
|
219
|
+
return NProgress;
|
220
|
+
});
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/* Make clicks pass-through */
|
2
|
+
#nprogress {
|
3
|
+
pointer-events: none;
|
4
|
+
-webkit-pointer-events: none;
|
5
|
+
}
|
6
|
+
|
7
|
+
/* Make the entire page show a busy cursor */
|
8
|
+
.nprogress-busy body {
|
9
|
+
cursor: wait;
|
10
|
+
}
|
11
|
+
|
12
|
+
#nprogress .bar {
|
13
|
+
background: #29d;
|
14
|
+
|
15
|
+
position: fixed;
|
16
|
+
z-index: 100;
|
17
|
+
top: 0;
|
18
|
+
left: 0;
|
19
|
+
|
20
|
+
width: 100%;
|
21
|
+
height: 2px;
|
22
|
+
}
|
23
|
+
|
24
|
+
/* Fancy blur effect */
|
25
|
+
#nprogress .peg {
|
26
|
+
display: block;
|
27
|
+
position: absolute;
|
28
|
+
right: 0px;
|
29
|
+
width: 100px;
|
30
|
+
height: 100%;
|
31
|
+
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
|
32
|
+
opacity: 1.0;
|
33
|
+
|
34
|
+
-webkit-transform: rotate(3deg) translate(0px, -4px);
|
35
|
+
-moz-transform: rotate(3deg) translate(0px, -4px);
|
36
|
+
-ms-transform: rotate(3deg) translate(0px, -4px);
|
37
|
+
-o-transform: rotate(3deg) translate(0px, -4px);
|
38
|
+
transform: rotate(3deg) translate(0px, -4px);
|
39
|
+
}
|
40
|
+
|
41
|
+
/* Remove these to get rid of the spinner */
|
42
|
+
#nprogress .spinner {
|
43
|
+
display: block;
|
44
|
+
position: fixed;
|
45
|
+
z-index: 100;
|
46
|
+
top: 15px;
|
47
|
+
right: 15px;
|
48
|
+
}
|
49
|
+
|
50
|
+
#nprogress .spinner-icon {
|
51
|
+
width: 14px;
|
52
|
+
height: 14px;
|
53
|
+
|
54
|
+
border: solid 2px transparent;
|
55
|
+
border-top-color: #29d;
|
56
|
+
border-left-color: #29d;
|
57
|
+
border-radius: 10px;
|
58
|
+
|
59
|
+
-webkit-animation: nprogress-spinner 400ms linear infinite;
|
60
|
+
-moz-animation: nprogress-spinner 400ms linear infinite;
|
61
|
+
-ms-animation: nprogress-spinner 400ms linear infinite;
|
62
|
+
-o-animation: nprogress-spinner 400ms linear infinite;
|
63
|
+
animation: nprogress-spinner 400ms linear infinite;
|
64
|
+
}
|
65
|
+
|
66
|
+
@-webkit-keyframes nprogress-spinner {
|
67
|
+
0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
|
68
|
+
100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
|
69
|
+
}
|
70
|
+
@-moz-keyframes nprogress-spinner {
|
71
|
+
0% { -moz-transform: rotate(0deg); transform: rotate(0deg); }
|
72
|
+
100% { -moz-transform: rotate(360deg); transform: rotate(360deg); }
|
73
|
+
}
|
74
|
+
@-o-keyframes nprogress-spinner {
|
75
|
+
0% { -o-transform: rotate(0deg); transform: rotate(0deg); }
|
76
|
+
100% { -o-transform: rotate(360deg); transform: rotate(360deg); }
|
77
|
+
}
|
78
|
+
@-ms-keyframes nprogress-spinner {
|
79
|
+
0% { -ms-transform: rotate(0deg); transform: rotate(0deg); }
|
80
|
+
100% { -ms-transform: rotate(360deg); transform: rotate(360deg); }
|
81
|
+
}
|
82
|
+
@keyframes nprogress-spinner {
|
83
|
+
0% { transform: rotate(0deg); transform: rotate(0deg); }
|
84
|
+
100% { transform: rotate(360deg); transform: rotate(360deg); }
|
85
|
+
}
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nprogress_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carlos Alexandro Becker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-21 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: This is a gem for the rstacruz' nprogress implementation. It's based
|
42
|
+
on version nprogress 0.1.0.
|
43
|
+
email:
|
44
|
+
- caarlos0@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/nprogress_rails.rb
|
55
|
+
- nprogress_rails.gemspec
|
56
|
+
- vendor/assets/javascripts/nprogress.js
|
57
|
+
- vendor/assets/javascripts/nprogress_turbolinks.js
|
58
|
+
- vendor/assets/stylesheets/nprogress.css
|
59
|
+
- vendor/assets/stylesheets/nprogress_bootstrap.css
|
60
|
+
homepage: http://carlosbecker.com/about
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.0.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Slim progress bars for Ajax'y applications. Inspired by Google, YouTube,
|
84
|
+
and Medium.
|
85
|
+
test_files: []
|