nprogress-rails 0.1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6fadfd3d5a790272fb8e6a232460e8c013fc82eb
4
+ data.tar.gz: c10ac326a07bc38dedfabb717c4fcbdb1542a198
5
+ SHA512:
6
+ metadata.gz: 46cce22efb38457504950b20c093208699c15a221d160640de677cd421bec2ae362ce2b95534aed098ae9f8f20a773937b141b40e973d18c0582551d2bfa32a5
7
+ data.tar.gz: 3fe71ef50cd30bd347f3a22e01b85eedd6b028f003f9f6b38bf9f6756053de5a5f49991cde4eaf867abc2e109d78af765a5a269a66ac7ceb84fe587327175ecf
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nprogress-rails.gemspec
4
+ gemspec
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,60 @@
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][rstacruz]' [nprogress][lib] library.
5
+
6
+ - [**Original lib**][lib]
7
+ - [**Demo**][demo]
8
+
9
+
10
+ [rstacruz]: https://github.com/rstacruz
11
+ [lib]: https://github.com/rstacruz/nprogress
12
+ [demo]: http://ricostacruz.com/nprogress/
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'nprogress-rails'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install nprogress-rails
27
+
28
+ ## Usage
29
+
30
+ You basically have to add the requires.
31
+
32
+ In your `application.js.coffee` (or just JS):
33
+
34
+ ```coffeescript
35
+ #= require nprogress
36
+ #= require nprogress-turbolinks
37
+ ```
38
+
39
+ The `nprogress-turbolinks` is required only if you use turbolinks. Otherwise,
40
+ you will have to deal with show/hide the progress by your own.
41
+
42
+ Also, into your `application.css.scss` file:
43
+
44
+ ```scss
45
+ *= require nprogress
46
+ *= require nprogress-bootstrap
47
+ ```
48
+
49
+ The `nprogress-bootstrap` is required if you use bootstrap and have a fixed
50
+ toolbar or anything else. tl;dr: if the console shows no erros, but the
51
+ progress doesn't appear, try this.
52
+
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ module NprogressRails
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -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.1.2"
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.1.}
11
+ spec.summary = %q{Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and Medium.}
12
+ spec.homepage = "https://github.com/caarlos0/nprogress-rails"
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,5 @@
1
+ $(function() {
2
+ $(document).on('page:fetch', function() { NProgress.start(); });
3
+ $(document).on('page:change', function() { NProgress.done(); });
4
+ $(document).on('page:restore', function() { NProgress.remove(); });
5
+ });
@@ -0,0 +1,274 @@
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.1';
16
+
17
+ var Settings = NProgress.settings = {
18
+ minimum: 0.08,
19
+ easing: 'ease',
20
+ positionUsing: '',
21
+ speed: 200,
22
+ trickle: true,
23
+ trickleRate: 0.02,
24
+ trickleSpeed: 800,
25
+ showSpinner: true,
26
+ template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
27
+ };
28
+
29
+ /**
30
+ * Updates configuration.
31
+ *
32
+ * NProgress.configure({
33
+ * minimum: 0.1
34
+ * });
35
+ */
36
+ NProgress.configure = function(options) {
37
+ $.extend(Settings, options);
38
+ return this;
39
+ };
40
+
41
+ /**
42
+ * Last number.
43
+ */
44
+
45
+ NProgress.status = null;
46
+
47
+ /**
48
+ * Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
49
+ *
50
+ * NProgress.set(0.4);
51
+ * NProgress.set(1.0);
52
+ */
53
+
54
+ NProgress.set = function(n) {
55
+ var started = NProgress.isStarted();
56
+
57
+ n = clamp(n, Settings.minimum, 1);
58
+ NProgress.status = (n === 1 ? null : n);
59
+
60
+ var $progress = NProgress.render(!started),
61
+ $bar = $progress.find('[role="bar"]'),
62
+ speed = Settings.speed,
63
+ ease = Settings.easing;
64
+
65
+ $progress[0].offsetWidth; /* Repaint */
66
+
67
+ $progress.queue(function(next) {
68
+ // Set positionUsing if it hasn't already been set
69
+ if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
70
+
71
+ // Add transition
72
+ $bar.css(barPositionCSS(n, speed, ease));
73
+
74
+ if (n === 1) {
75
+ // Fade out
76
+ $progress.css({ transition: 'none', opacity: 1 });
77
+ $progress[0].offsetWidth; /* Repaint */
78
+
79
+ setTimeout(function() {
80
+ $progress.css({ transition: 'all '+speed+'ms linear', opacity: 0 });
81
+ setTimeout(function() {
82
+ NProgress.remove();
83
+ next();
84
+ }, speed);
85
+ }, speed);
86
+ } else {
87
+ setTimeout(next, speed);
88
+ }
89
+ });
90
+
91
+ return this;
92
+ };
93
+
94
+ NProgress.isStarted = function() {
95
+ return typeof NProgress.status === 'number';
96
+ };
97
+
98
+ /**
99
+ * Shows the progress bar.
100
+ * This is the same as setting the status to 0%, except that it doesn't go backwards.
101
+ *
102
+ * NProgress.start();
103
+ *
104
+ */
105
+ NProgress.start = function() {
106
+ if (!NProgress.status) NProgress.set(0);
107
+
108
+ var work = function() {
109
+ setTimeout(function() {
110
+ if (!NProgress.status) return;
111
+ NProgress.trickle();
112
+ work();
113
+ }, Settings.trickleSpeed);
114
+ };
115
+
116
+ if (Settings.trickle) work();
117
+
118
+ return this;
119
+ };
120
+
121
+ /**
122
+ * Hides the progress bar.
123
+ * This is the *sort of* the same as setting the status to 100%, with the
124
+ * difference being `done()` makes some placebo effect of some realistic motion.
125
+ *
126
+ * NProgress.done();
127
+ *
128
+ * If `true` is passed, it will show the progress bar even if its hidden.
129
+ *
130
+ * NProgress.done(true);
131
+ */
132
+
133
+ NProgress.done = function(force) {
134
+ if (!force && !NProgress.status) return this;
135
+
136
+ return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
137
+ };
138
+
139
+ /**
140
+ * Increments by a random amount.
141
+ */
142
+
143
+ NProgress.inc = function(amount) {
144
+ var n = NProgress.status;
145
+
146
+ if (!n) {
147
+ return NProgress.start();
148
+ } else {
149
+ if (typeof amount !== 'number') {
150
+ amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95);
151
+ }
152
+
153
+ n = clamp(n + amount, 0, 0.994);
154
+ return NProgress.set(n);
155
+ }
156
+ };
157
+
158
+ NProgress.trickle = function() {
159
+ return NProgress.inc(Math.random() * Settings.trickleRate);
160
+ };
161
+
162
+ /**
163
+ * (Internal) renders the progress bar markup based on the `template`
164
+ * setting.
165
+ */
166
+
167
+ NProgress.render = function(fromStart) {
168
+ if (NProgress.isRendered()) return $("#nprogress");
169
+ $('html').addClass('nprogress-busy');
170
+
171
+ var $el = $("<div id='nprogress'>")
172
+ .html(Settings.template);
173
+
174
+ var perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0);
175
+
176
+ $el.find('[role="bar"]').css({
177
+ transition: 'all 0 linear',
178
+ transform: 'translate3d('+perc+'%,0,0)'
179
+ });
180
+
181
+ if (!Settings.showSpinner)
182
+ $el.find('[role="spinner"]').remove();
183
+
184
+ $el.appendTo(document.body);
185
+
186
+ return $el;
187
+ };
188
+
189
+ /**
190
+ * Removes the element. Opposite of render().
191
+ */
192
+
193
+ NProgress.remove = function() {
194
+ $('html').removeClass('nprogress-busy');
195
+ $('#nprogress').remove();
196
+ };
197
+
198
+ /**
199
+ * Checks if the progress bar is rendered.
200
+ */
201
+
202
+ NProgress.isRendered = function() {
203
+ return ($("#nprogress").length > 0);
204
+ };
205
+
206
+ /**
207
+ * Determine which positioning CSS rule to use.
208
+ */
209
+
210
+ NProgress.getPositioningCSS = function() {
211
+ // Sniff on document.body.style
212
+ var bodyStyle = document.body.style;
213
+
214
+ // Sniff prefixes
215
+ var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
216
+ ('MozTransform' in bodyStyle) ? 'Moz' :
217
+ ('msTransform' in bodyStyle) ? 'ms' :
218
+ ('OTransform' in bodyStyle) ? 'O' : '';
219
+
220
+ if (vendorPrefix + 'Perspective' in bodyStyle) {
221
+ // Modern browsers with 3D support, e.g. Webkit, IE10
222
+ return 'translate3d';
223
+ } else if (vendorPrefix + 'Transform' in bodyStyle) {
224
+ // Browsers without 3D support, e.g. IE9
225
+ return 'translate';
226
+ } else {
227
+ // Browsers without translate() support, e.g. IE7-8
228
+ return 'margin';
229
+ }
230
+ };
231
+
232
+ /**
233
+ * Helpers
234
+ */
235
+
236
+ function clamp(n, min, max) {
237
+ if (n < min) return min;
238
+ if (n > max) return max;
239
+ return n;
240
+ }
241
+
242
+ /**
243
+ * (Internal) converts a percentage (`0..1`) to a bar translateX
244
+ * percentage (`-100%..0%`).
245
+ */
246
+
247
+ function toBarPerc(n) {
248
+ return (-1 + n) * 100;
249
+ }
250
+
251
+
252
+ /**
253
+ * (Internal) returns the correct CSS for changing the bar's
254
+ * position given an n percentage, and speed and ease from Settings
255
+ */
256
+
257
+ function barPositionCSS(n, speed, ease) {
258
+ var barCSS;
259
+
260
+ if (Settings.positionUsing === 'translate3d') {
261
+ barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
262
+ } else if (Settings.positionUsing === 'translate') {
263
+ barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
264
+ } else {
265
+ barCSS = { 'margin-left': toBarPerc(n)+'%' };
266
+ }
267
+
268
+ barCSS.transition = 'all '+speed+'ms '+ease;
269
+
270
+ return barCSS;
271
+ }
272
+
273
+ return NProgress;
274
+ });
@@ -0,0 +1,4 @@
1
+ #nprogress .bar,
2
+ #nprogress .spinner {
3
+ z-index: 999999;
4
+ }
@@ -0,0 +1,80 @@
1
+ /* Make clicks pass-through */
2
+ #nprogress {
3
+ pointer-events: none;
4
+ -webkit-pointer-events: none;
5
+ }
6
+
7
+ #nprogress .bar {
8
+ background: #29d;
9
+
10
+ position: fixed;
11
+ z-index: 100;
12
+ top: 0;
13
+ left: 0;
14
+
15
+ width: 100%;
16
+ height: 2px;
17
+ }
18
+
19
+ /* Fancy blur effect */
20
+ #nprogress .peg {
21
+ display: block;
22
+ position: absolute;
23
+ right: 0px;
24
+ width: 100px;
25
+ height: 100%;
26
+ box-shadow: 0 0 10px #29d, 0 0 5px #29d;
27
+ opacity: 1.0;
28
+
29
+ -webkit-transform: rotate(3deg) translate(0px, -4px);
30
+ -moz-transform: rotate(3deg) translate(0px, -4px);
31
+ -ms-transform: rotate(3deg) translate(0px, -4px);
32
+ -o-transform: rotate(3deg) translate(0px, -4px);
33
+ transform: rotate(3deg) translate(0px, -4px);
34
+ }
35
+
36
+ /* Remove these to get rid of the spinner */
37
+ #nprogress .spinner {
38
+ display: block;
39
+ position: fixed;
40
+ z-index: 100;
41
+ top: 15px;
42
+ right: 15px;
43
+ }
44
+
45
+ #nprogress .spinner-icon {
46
+ width: 14px;
47
+ height: 14px;
48
+
49
+ border: solid 2px transparent;
50
+ border-top-color: #29d;
51
+ border-left-color: #29d;
52
+ border-radius: 10px;
53
+
54
+ -webkit-animation: nprogress-spinner 400ms linear infinite;
55
+ -moz-animation: nprogress-spinner 400ms linear infinite;
56
+ -ms-animation: nprogress-spinner 400ms linear infinite;
57
+ -o-animation: nprogress-spinner 400ms linear infinite;
58
+ animation: nprogress-spinner 400ms linear infinite;
59
+ }
60
+
61
+ @-webkit-keyframes nprogress-spinner {
62
+ 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
63
+ 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
64
+ }
65
+ @-moz-keyframes nprogress-spinner {
66
+ 0% { -moz-transform: rotate(0deg); transform: rotate(0deg); }
67
+ 100% { -moz-transform: rotate(360deg); transform: rotate(360deg); }
68
+ }
69
+ @-o-keyframes nprogress-spinner {
70
+ 0% { -o-transform: rotate(0deg); transform: rotate(0deg); }
71
+ 100% { -o-transform: rotate(360deg); transform: rotate(360deg); }
72
+ }
73
+ @-ms-keyframes nprogress-spinner {
74
+ 0% { -ms-transform: rotate(0deg); transform: rotate(0deg); }
75
+ 100% { -ms-transform: rotate(360deg); transform: rotate(360deg); }
76
+ }
77
+ @keyframes nprogress-spinner {
78
+ 0% { transform: rotate(0deg); transform: rotate(0deg); }
79
+ 100% { transform: rotate(360deg); transform: rotate(360deg); }
80
+ }
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.1.2
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.1.
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-turbolinks.js
57
+ - vendor/assets/javascripts/nprogress.js
58
+ - vendor/assets/stylesheets/nprogress-bootstrap.css
59
+ - vendor/assets/stylesheets/nprogress.css
60
+ homepage: https://github.com/caarlos0/nprogress-rails
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.3
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: []