spinjs-rails 1.3 → 1.4

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: cab3c4707629b7189d91c3f992d57fb01cca8422
4
- data.tar.gz: d72a699a9019fea04ac8754516631f53a344750a
3
+ metadata.gz: 48f5d157bcfa2950dc5827138b5f1d411dbc7c8c
4
+ data.tar.gz: 45efc0f47f81873ff545197709e06ad2826786a0
5
5
  SHA512:
6
- metadata.gz: 341eb4c352e75c21748716c1bb601b34652b806722a4d461485bbfd10ec087d8b2341e1e0e0afb8a5297952e0829580b8931159ba4a53b19f4b3fdf69eecddd3
7
- data.tar.gz: b26f382c243b5944be120c3bf146b6b57c2545eaa845f7f582befe398a45673ea5ce04f4b823635973260a3dd7734cb8e396f25f62bddb89b93b5b49dad871f2
6
+ metadata.gz: 015f470e80dd47b4f3554c0b9b44186ed8581a300f08c54f27b8fba9c8e1136bf9f22f1d58487a5803dbef4b1b8d584164281470240efaa50ebaf66b208dfc50
7
+ data.tar.gz: c985e247b151f67917212401381c4d06252bce380b64c0bfa7c80284dd124e527aec50bc14c4d29da3f05c56f75a4a3cf977c14feedb7e79102eb1056d95dffa
@@ -1,5 +1,5 @@
1
1
  module Spinjs
2
2
  module Rails
3
- VERSION = "1.3"
3
+ VERSION = "1.4"
4
4
  end
5
5
  end
@@ -1,38 +1,80 @@
1
- //= require jquery
2
- //= require spin
3
-
4
- (function($) {
5
- $.fn.spin = function(opts, color) {
6
- var presets = {
7
- "tiny": { lines: 8, length: 2, width: 2, radius: 3 },
8
- "small": { lines: 8, length: 4, width: 3, radius: 5 },
9
- "large": { lines: 10, length: 8, width: 4, radius: 8 }
10
- };
11
- if (Spinner) {
12
- return this.each(function() {
13
- var $this = $(this),
14
- data = $this.data();
15
-
16
- if (data.spinner) {
17
- data.spinner.stop();
18
- delete data.spinner;
19
- }
20
- if (opts !== false) {
21
- if (typeof opts === "string") {
22
- if (opts in presets) {
23
- opts = presets[opts];
24
- } else {
25
- opts = {};
26
- }
27
- if (color) {
28
- opts.color = color;
29
- }
30
- }
31
- data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this);
32
- }
33
- });
34
- } else {
35
- throw "Spinner class not available.";
36
- }
37
- };
38
- })(jQuery);
1
+ /**
2
+ * Copyright (c) 2011-2014 Felix Gnass
3
+ * Licensed under the MIT license
4
+ */
5
+
6
+ /*
7
+
8
+ Basic Usage:
9
+ ============
10
+
11
+ $('#el').spin(); // Creates a default Spinner using the text color of #el.
12
+ $('#el').spin({ ... }); // Creates a Spinner using the provided options.
13
+
14
+ $('#el').spin(false); // Stops and removes the spinner.
15
+
16
+ Using Presets:
17
+ ==============
18
+
19
+ $('#el').spin('small'); // Creates a 'small' Spinner using the text color of #el.
20
+ $('#el').spin('large', '#fff'); // Creates a 'large' white Spinner.
21
+
22
+ Adding a custom preset:
23
+ =======================
24
+
25
+ $.fn.spin.presets.flower = {
26
+ lines: 9
27
+ length: 10
28
+ width: 20
29
+ radius: 0
30
+ }
31
+
32
+ $('#el').spin('flower', 'red');
33
+
34
+ */
35
+
36
+ (function(factory) {
37
+
38
+ if (typeof exports == 'object') {
39
+ // CommonJS
40
+ factory(require('jquery'), require('spin'))
41
+ }
42
+ else if (typeof define == 'function' && define.amd) {
43
+ // AMD, register as anonymous module
44
+ define(['jquery', 'spin'], factory)
45
+ }
46
+ else {
47
+ // Browser globals
48
+ if (!window.Spinner) throw new Error('Spin.js not present')
49
+ factory(window.jQuery, window.Spinner)
50
+ }
51
+
52
+ }(function($, Spinner) {
53
+
54
+ $.fn.spin = function(opts, color) {
55
+
56
+ return this.each(function() {
57
+ var $this = $(this),
58
+ data = $this.data();
59
+
60
+ if (data.spinner) {
61
+ data.spinner.stop();
62
+ delete data.spinner;
63
+ }
64
+ if (opts !== false) {
65
+ opts = $.extend(
66
+ { color: color || $this.css('color') },
67
+ $.fn.spin.presets[opts] || opts
68
+ )
69
+ data.spinner = new Spinner(opts).spin(this)
70
+ }
71
+ })
72
+ }
73
+
74
+ $.fn.spin.presets = {
75
+ tiny: { lines: 8, length: 2, width: 2, radius: 3 },
76
+ small: { lines: 8, length: 4, width: 3, radius: 5 },
77
+ large: { lines: 10, length: 8, width: 4, radius: 8 }
78
+ }
79
+
80
+ }));
@@ -1,7 +1,5 @@
1
- //fgnass.github.com/spin.js#v1.3
2
-
3
1
  /**
4
- * Copyright (c) 2011-2013 Felix Gnass
2
+ * Copyright (c) 2011-2014 Felix Gnass
5
3
  * Licensed under the MIT license
6
4
  */
7
5
  (function(root, factory) {
@@ -89,12 +87,12 @@
89
87
  , pp
90
88
  , i
91
89
 
92
- if(s[prop] !== undefined) return prop
93
90
  prop = prop.charAt(0).toUpperCase() + prop.slice(1)
94
91
  for(i=0; i<prefixes.length; i++) {
95
92
  pp = prefixes[i]+prop
96
93
  if(s[pp] !== undefined) return pp
97
94
  }
95
+ if(s[prop] !== undefined) return prop
98
96
  }
99
97
 
100
98
  /**
@@ -130,6 +128,13 @@
130
128
  return o
131
129
  }
132
130
 
131
+ /**
132
+ * Returns the line color from the given string or array.
133
+ */
134
+ function getColor(color, idx) {
135
+ return typeof color == 'string' ? color : color[idx % color.length]
136
+ }
137
+
133
138
  // Built-in defaults
134
139
 
135
140
  var defaults = {
@@ -147,14 +152,13 @@
147
152
  fps: 20, // Frames per second when using setTimeout()
148
153
  zIndex: 2e9, // Use a high z-index by default
149
154
  className: 'spinner', // CSS class to assign to the element
150
- top: 'auto', // center vertically
151
- left: 'auto', // center horizontally
152
- position: 'relative' // element position
155
+ top: '50%', // center vertically
156
+ left: '50%', // center horizontally
157
+ position: 'absolute' // element position
153
158
  }
154
159
 
155
160
  /** The constructor */
156
161
  function Spinner(o) {
157
- if (typeof this == 'undefined') return new Spinner(o)
158
162
  this.opts = merge(o || {}, Spinner.defaults, defaults)
159
163
  }
160
164
 
@@ -175,17 +179,14 @@
175
179
  , o = self.opts
176
180
  , el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
177
181
  , mid = o.radius+o.length+o.width
178
- , ep // element position
179
- , tp // target position
180
182
 
183
+ css(el, {
184
+ left: o.left,
185
+ top: o.top
186
+ })
187
+
181
188
  if (target) {
182
189
  target.insertBefore(el, target.firstChild||null)
183
- tp = pos(target)
184
- ep = pos(el)
185
- css(el, {
186
- left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : parseInt(o.left, 10) + mid) + 'px',
187
- top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : parseInt(o.top, 10) + mid) + 'px'
188
- })
189
190
  }
190
191
 
191
192
  el.setAttribute('role', 'progressbar')
@@ -259,8 +260,7 @@
259
260
  })
260
261
 
261
262
  if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
262
-
263
- ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)')))
263
+ ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
264
264
  }
265
265
  return el
266
266
  },
@@ -314,7 +314,7 @@
314
314
  top: -o.width>>1,
315
315
  filter: filter
316
316
  }),
317
- vml('fill', {color: o.color, opacity: o.opacity}),
317
+ vml('fill', {color: getColor(o.color, i), opacity: o.opacity}),
318
318
  vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
319
319
  )
320
320
  )
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytrii Nagirniak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-02 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  description: An animated CSS3 loading spinner with VML fallback for IE.
@@ -31,7 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
34
+ - ".gitignore"
35
35
  - Gemfile
36
36
  - LICENSE
37
37
  - README.md
@@ -52,17 +52,17 @@ require_paths:
52
52
  - lib
53
53
  required_ruby_version: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project: spinjs-rails
65
- rubygems_version: 2.0.3
65
+ rubygems_version: 2.2.2
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: A spinning activity indicator for Rails 3 with no images and CSS.