spinjs-rails 1.2.8 → 1.3
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 +7 -0
- data/lib/spinjs-rails/version.rb +1 -1
- data/vendor/assets/javascripts/spin.js +113 -84
- metadata +9 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cab3c4707629b7189d91c3f992d57fb01cca8422
|
4
|
+
data.tar.gz: d72a699a9019fea04ac8754516631f53a344750a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 341eb4c352e75c21748716c1bb601b34652b806722a4d461485bbfd10ec087d8b2341e1e0e0afb8a5297952e0829580b8931159ba4a53b19f4b3fdf69eecddd3
|
7
|
+
data.tar.gz: b26f382c243b5944be120c3bf146b6b57c2545eaa845f7f582befe398a45673ea5ce04f4b823635973260a3dd7734cb8e396f25f62bddb89b93b5b49dad871f2
|
data/lib/spinjs-rails/version.rb
CHANGED
@@ -1,14 +1,26 @@
|
|
1
|
-
//fgnass.github.com/spin.js#v1.
|
2
|
-
!function(window, document, undefined) {
|
1
|
+
//fgnass.github.com/spin.js#v1.3
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
/**
|
4
|
+
* Copyright (c) 2011-2013 Felix Gnass
|
5
|
+
* Licensed under the MIT license
|
6
|
+
*/
|
7
|
+
(function(root, factory) {
|
8
|
+
|
9
|
+
/* CommonJS */
|
10
|
+
if (typeof exports == 'object') module.exports = factory()
|
11
|
+
|
12
|
+
/* AMD module */
|
13
|
+
else if (typeof define == 'function' && define.amd) define(factory)
|
14
|
+
|
15
|
+
/* Browser global */
|
16
|
+
else root.Spinner = factory()
|
17
|
+
}
|
18
|
+
(this, function() {
|
19
|
+
"use strict";
|
8
20
|
|
9
21
|
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
|
10
22
|
, animations = {} /* Animation rules keyed by their name */
|
11
|
-
, useCssAnimations
|
23
|
+
, useCssAnimations /* Whether to use CSS animations or setTimeout */
|
12
24
|
|
13
25
|
/**
|
14
26
|
* Utility function to create elements. If no tag name is given,
|
@@ -35,11 +47,11 @@
|
|
35
47
|
/**
|
36
48
|
* Insert a new stylesheet to hold the @keyframe or VML rules.
|
37
49
|
*/
|
38
|
-
var sheet = function() {
|
50
|
+
var sheet = (function() {
|
39
51
|
var el = createEl('style', {type : 'text/css'})
|
40
52
|
ins(document.getElementsByTagName('head')[0], el)
|
41
53
|
return el.sheet || el.styleSheet
|
42
|
-
}()
|
54
|
+
}())
|
43
55
|
|
44
56
|
/**
|
45
57
|
* Creates an opacity keyframe animation rule and returns its name.
|
@@ -48,10 +60,10 @@
|
|
48
60
|
*/
|
49
61
|
function addAnimation(alpha, trail, i, lines) {
|
50
62
|
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
|
51
|
-
, start = 0.01 + i/lines*100
|
63
|
+
, start = 0.01 + i/lines * 100
|
52
64
|
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
|
53
65
|
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
|
54
|
-
, pre = prefix && '-'+prefix+'-' || ''
|
66
|
+
, pre = prefix && '-' + prefix + '-' || ''
|
55
67
|
|
56
68
|
if (!animations[name]) {
|
57
69
|
sheet.insertRule(
|
@@ -65,12 +77,13 @@
|
|
65
77
|
|
66
78
|
animations[name] = 1
|
67
79
|
}
|
80
|
+
|
68
81
|
return name
|
69
82
|
}
|
70
83
|
|
71
84
|
/**
|
72
85
|
* Tries various vendor prefixes and returns the first supported property.
|
73
|
-
|
86
|
+
*/
|
74
87
|
function vendor(el, prop) {
|
75
88
|
var s = el.style
|
76
89
|
, pp
|
@@ -117,6 +130,8 @@
|
|
117
130
|
return o
|
118
131
|
}
|
119
132
|
|
133
|
+
// Built-in defaults
|
134
|
+
|
120
135
|
var defaults = {
|
121
136
|
lines: 12, // The number of lines to draw
|
122
137
|
length: 7, // The length of each line
|
@@ -125,6 +140,7 @@
|
|
125
140
|
rotate: 0, // Rotation offset
|
126
141
|
corners: 1, // Roundness (0..1)
|
127
142
|
color: '#000', // #rgb or #rrggbb
|
143
|
+
direction: 1, // 1: clockwise, -1: counterclockwise
|
128
144
|
speed: 1, // Rounds per second
|
129
145
|
trail: 100, // Afterglow percentage
|
130
146
|
opacity: 1/4, // Opacity of the lines
|
@@ -138,15 +154,23 @@
|
|
138
154
|
|
139
155
|
/** The constructor */
|
140
156
|
function Spinner(o) {
|
141
|
-
if (
|
157
|
+
if (typeof this == 'undefined') return new Spinner(o)
|
142
158
|
this.opts = merge(o || {}, Spinner.defaults, defaults)
|
143
159
|
}
|
144
160
|
|
161
|
+
// Global defaults that override the built-ins:
|
145
162
|
Spinner.defaults = {}
|
146
163
|
|
147
164
|
merge(Spinner.prototype, {
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Adds the spinner to the given target element. If this instance is already
|
168
|
+
* spinning, it is automatically removed from its previous target b calling
|
169
|
+
* stop() internally.
|
170
|
+
*/
|
148
171
|
spin: function(target) {
|
149
172
|
this.stop()
|
173
|
+
|
150
174
|
var self = this
|
151
175
|
, o = self.opts
|
152
176
|
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
|
@@ -164,12 +188,14 @@
|
|
164
188
|
})
|
165
189
|
}
|
166
190
|
|
167
|
-
el.setAttribute('
|
191
|
+
el.setAttribute('role', 'progressbar')
|
168
192
|
self.lines(el, self.opts)
|
169
193
|
|
170
194
|
if (!useCssAnimations) {
|
171
195
|
// No CSS animation support, use setTimeout() instead
|
172
196
|
var i = 0
|
197
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
198
|
+
, alpha
|
173
199
|
, fps = o.fps
|
174
200
|
, f = fps/o.speed
|
175
201
|
, ostep = (1-o.opacity) / (f*o.trail / 100)
|
@@ -177,9 +203,10 @@
|
|
177
203
|
|
178
204
|
;(function anim() {
|
179
205
|
i++;
|
180
|
-
for (var
|
181
|
-
|
182
|
-
|
206
|
+
for (var j = 0; j < o.lines; j++) {
|
207
|
+
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
|
208
|
+
|
209
|
+
self.opacity(el, j * o.direction + start, alpha, o)
|
183
210
|
}
|
184
211
|
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
|
185
212
|
})()
|
@@ -187,6 +214,9 @@
|
|
187
214
|
return self
|
188
215
|
},
|
189
216
|
|
217
|
+
/**
|
218
|
+
* Stops and removes the Spinner.
|
219
|
+
*/
|
190
220
|
stop: function() {
|
191
221
|
var el = this.el
|
192
222
|
if (el) {
|
@@ -197,8 +227,13 @@
|
|
197
227
|
return this
|
198
228
|
},
|
199
229
|
|
230
|
+
/**
|
231
|
+
* Internal method that draws the individual lines. Will be overwritten
|
232
|
+
* in VML fallback mode below.
|
233
|
+
*/
|
200
234
|
lines: function(el, o) {
|
201
235
|
var i = 0
|
236
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
202
237
|
, seg
|
203
238
|
|
204
239
|
function fill(color, shadow) {
|
@@ -220,7 +255,7 @@
|
|
220
255
|
top: 1+~(o.width/2) + 'px',
|
221
256
|
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
|
222
257
|
opacity: o.opacity,
|
223
|
-
animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite'
|
258
|
+
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
|
224
259
|
})
|
225
260
|
|
226
261
|
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
|
@@ -230,91 +265,85 @@
|
|
230
265
|
return el
|
231
266
|
},
|
232
267
|
|
268
|
+
/**
|
269
|
+
* Internal method that adjusts the opacity of a single line.
|
270
|
+
* Will be overwritten in VML fallback mode below.
|
271
|
+
*/
|
233
272
|
opacity: function(el, i, val) {
|
234
273
|
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
|
235
274
|
}
|
236
275
|
|
237
276
|
})
|
238
277
|
|
239
|
-
/////////////////////////////////////////////////////////////////////////
|
240
|
-
// VML rendering for IE
|
241
|
-
/////////////////////////////////////////////////////////////////////////
|
242
278
|
|
243
|
-
|
244
|
-
* Check and init VML support
|
245
|
-
*/
|
246
|
-
;(function() {
|
279
|
+
function initVML() {
|
247
280
|
|
281
|
+
/* Utility function to create a VML tag */
|
248
282
|
function vml(tag, attr) {
|
249
283
|
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
|
250
284
|
}
|
251
285
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
,
|
286
|
+
// No CSS transforms but VML support, add a CSS rule for VML elements:
|
287
|
+
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
|
288
|
+
|
289
|
+
Spinner.prototype.lines = function(el, o) {
|
290
|
+
var r = o.length+o.width
|
291
|
+
, s = 2*r
|
292
|
+
|
293
|
+
function grp() {
|
294
|
+
return css(
|
295
|
+
vml('group', {
|
296
|
+
coordsize: s + ' ' + s,
|
297
|
+
coordorigin: -r + ' ' + -r
|
298
|
+
}),
|
299
|
+
{ width: s, height: s }
|
300
|
+
)
|
301
|
+
}
|
262
302
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
|
280
|
-
ins(css(vml('roundrect', {arcsize: o.corners}), {
|
281
|
-
width: r,
|
282
|
-
height: o.width,
|
283
|
-
left: o.radius,
|
284
|
-
top: -o.width>>1,
|
285
|
-
filter: filter
|
286
|
-
}),
|
287
|
-
vml('fill', {color: o.color, opacity: o.opacity}),
|
288
|
-
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
|
289
|
-
)
|
303
|
+
var margin = -(o.width+o.length)*2 + 'px'
|
304
|
+
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
|
305
|
+
, i
|
306
|
+
|
307
|
+
function seg(i, dx, filter) {
|
308
|
+
ins(g,
|
309
|
+
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
|
310
|
+
ins(css(vml('roundrect', {arcsize: o.corners}), {
|
311
|
+
width: r,
|
312
|
+
height: o.width,
|
313
|
+
left: o.radius,
|
314
|
+
top: -o.width>>1,
|
315
|
+
filter: filter
|
316
|
+
}),
|
317
|
+
vml('fill', {color: o.color, opacity: o.opacity}),
|
318
|
+
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
|
290
319
|
)
|
291
320
|
)
|
292
|
-
|
321
|
+
)
|
322
|
+
}
|
293
323
|
|
294
|
-
|
295
|
-
|
296
|
-
|
324
|
+
if (o.shadow)
|
325
|
+
for (i = 1; i <= o.lines; i++)
|
326
|
+
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
|
297
327
|
|
298
|
-
|
299
|
-
|
300
|
-
|
328
|
+
for (i = 1; i <= o.lines; i++) seg(i)
|
329
|
+
return ins(el, g)
|
330
|
+
}
|
301
331
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
}
|
332
|
+
Spinner.prototype.opacity = function(el, i, val, o) {
|
333
|
+
var c = el.firstChild
|
334
|
+
o = o.shadow && o.lines || 0
|
335
|
+
if (c && i+o < c.childNodes.length) {
|
336
|
+
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
|
337
|
+
if (c) c.opacity = val
|
309
338
|
}
|
310
339
|
}
|
311
|
-
|
312
|
-
|
313
|
-
|
340
|
+
}
|
341
|
+
|
342
|
+
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
|
343
|
+
|
344
|
+
if (!vendor(probe, 'transform') && probe.adj) initVML()
|
345
|
+
else useCssAnimations = vendor(probe, 'animation')
|
314
346
|
|
315
|
-
|
316
|
-
define(function() { return Spinner })
|
317
|
-
else
|
318
|
-
window.Spinner = Spinner
|
347
|
+
return Spinner
|
319
348
|
|
320
|
-
}
|
349
|
+
}));
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spinjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: '1.3'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Dmytrii Nagirniak
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-02
|
11
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.1'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '3.1'
|
30
27
|
description: An animated CSS3 loading spinner with VML fallback for IE.
|
@@ -48,32 +45,25 @@ files:
|
|
48
45
|
homepage: https://github.com/dnagir/spinjs-rails
|
49
46
|
licenses:
|
50
47
|
- MIT
|
48
|
+
metadata: {}
|
51
49
|
post_install_message:
|
52
50
|
rdoc_options: []
|
53
51
|
require_paths:
|
54
52
|
- lib
|
55
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
54
|
requirements:
|
58
|
-
- -
|
55
|
+
- - '>='
|
59
56
|
- !ruby/object:Gem::Version
|
60
57
|
version: '0'
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
hash: 382156763220495077
|
64
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
59
|
requirements:
|
67
|
-
- -
|
60
|
+
- - '>='
|
68
61
|
- !ruby/object:Gem::Version
|
69
62
|
version: '0'
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
hash: 382156763220495077
|
73
63
|
requirements: []
|
74
64
|
rubyforge_project: spinjs-rails
|
75
|
-
rubygems_version:
|
65
|
+
rubygems_version: 2.0.3
|
76
66
|
signing_key:
|
77
|
-
specification_version:
|
67
|
+
specification_version: 4
|
78
68
|
summary: A spinning activity indicator for Rails 3 with no images and CSS.
|
79
69
|
test_files: []
|