nprogress_rails 0.1.0.1 → 0.1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84be57f17dc2341dfa51d86c4dc318d01b005145
4
- data.tar.gz: 3e640f92d36d4f1356a6b344c21bb6c9078c91a0
3
+ metadata.gz: 90012fead4389decea774de668482c6c8d09751d
4
+ data.tar.gz: 34641e2c231a1337c417605d071a4b3dca332f53
5
5
  SHA512:
6
- metadata.gz: 06ed4c714b89cd26049e893f909b58d26d0706bd4b6ec39c458d9f8b256504ab2c5cc586f869cac5e6f0096d14b4d7edddc77d5625381d253418fc067bafdcf6
7
- data.tar.gz: 75875506f989870b898ed220a0452588b55ddc172074f10e40455eecc34992cc07d4e79bd0e7fc012b9ed32ad3de1fb11d3b7d0ba2c6a91d9367c28a7e103777
6
+ metadata.gz: a2fbd3de15e8ab3446352da9cdcbcb4b59ff0522c7f59898c388a37a9316019d5babbb62a38de25a9b3f601f34abfad8f10b196a6383d46d5f8cf36cefbaec42
7
+ data.tar.gz: aeea024a72ecb7ddb8b364645a2c75115ed7f9e9e675ff4453020505becf1cd17629e45469072eb7241c860a376aeb16a0307489f8747a039bcd38f835746796
data/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # nprogress_rails
2
2
 
3
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.
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/
6
13
 
7
14
  ## Installation
8
15
 
@@ -4,12 +4,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "nprogress_rails"
7
- spec.version = "0.1.0.1"
7
+ spec.version = "0.1.1.1"
8
8
  spec.authors = ["Carlos Alexandro Becker"]
9
9
  spec.email = ["caarlos0@gmail.com"]
10
10
  spec.description = %q{This is a gem for the rstacruz' nprogress implementation. It's based on version nprogress 0.1.0.}
11
11
  spec.summary = %q{Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and Medium.}
12
- spec.homepage = "http://carlosbecker.com/about"
12
+ spec.homepage = "https://github.com/caarlos0/nprogress_rails"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
@@ -12,16 +12,18 @@
12
12
  })(function($) {
13
13
  var NProgress = {};
14
14
 
15
- NProgress.version = '0.1.0';
15
+ NProgress.version = '0.1.1';
16
16
 
17
17
  var Settings = NProgress.settings = {
18
18
  minimum: 0.08,
19
19
  easing: 'ease',
20
+ positionUsing: '',
20
21
  speed: 200,
21
22
  trickle: true,
22
23
  trickleRate: 0.02,
23
24
  trickleSpeed: 800,
24
- template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner"><div class="spinner-icon"></div></div>'
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>'
25
27
  };
26
28
 
27
29
  /**
@@ -63,10 +65,11 @@
63
65
  $progress[0].offsetWidth; /* Repaint */
64
66
 
65
67
  $progress.queue(function(next) {
66
- $bar.css({
67
- transition: 'all '+speed+'ms '+ease,
68
- transform: 'translate3d('+toBarPerc(n)+'%,0,0)'
69
- });
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));
70
73
 
71
74
  if (n === 1) {
72
75
  // Fade out
@@ -175,13 +178,16 @@
175
178
  transform: 'translate3d('+perc+'%,0,0)'
176
179
  });
177
180
 
181
+ if (!Settings.showSpinner)
182
+ $el.find('[role="spinner"]').remove();
183
+
178
184
  $el.appendTo(document.body);
179
185
 
180
186
  return $el;
181
187
  };
182
188
 
183
189
  /**
184
- * (Internal) Removes the element. Opposite of render().
190
+ * Removes the element. Opposite of render().
185
191
  */
186
192
 
187
193
  NProgress.remove = function() {
@@ -197,6 +203,32 @@
197
203
  return ($("#nprogress").length > 0);
198
204
  };
199
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
+
200
232
  /**
201
233
  * Helpers
202
234
  */
@@ -216,5 +248,27 @@
216
248
  return (-1 + n) * 100;
217
249
  }
218
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
+
219
273
  return NProgress;
220
274
  });
@@ -1,4 +1,5 @@
1
1
  $(function() {
2
- $(document).on('page:fetch', function() { NProgress.start(); });
3
- $(document).on('page:load', function() { NProgress.done(); });
2
+ $(document).on('page:fetch', function() { NProgress.start(); });
3
+ $(document).on('page:change', function() { NProgress.done(); });
4
+ $(document).on('page:restore', function() { NProgress.remove(); });
4
5
  });
@@ -4,11 +4,6 @@
4
4
  -webkit-pointer-events: none;
5
5
  }
6
6
 
7
- /* Make the entire page show a busy cursor */
8
- .nprogress-busy body {
9
- cursor: wait;
10
- }
11
-
12
7
  #nprogress .bar {
13
8
  background: #29d;
14
9
 
@@ -1,3 +1,4 @@
1
- #nprogress .bar {
1
+ #nprogress .bar,
2
+ #nprogress .spinner {
2
3
  z-index: 999999;
3
4
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nprogress_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.1
4
+ version: 0.1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Alexandro Becker
@@ -57,7 +57,7 @@ files:
57
57
  - vendor/assets/javascripts/nprogress_turbolinks.js
58
58
  - vendor/assets/stylesheets/nprogress.css
59
59
  - vendor/assets/stylesheets/nprogress_bootstrap.css
60
- homepage: http://carlosbecker.com/about
60
+ homepage: https://github.com/caarlos0/nprogress_rails
61
61
  licenses:
62
62
  - MIT
63
63
  metadata: {}
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.0.2
80
+ rubygems_version: 2.0.3
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Slim progress bars for Ajax'y applications. Inspired by Google, YouTube,