avgrund_to 0.0.1 → 0.0.2
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//= require_tree .
|
|
1
2
|
/*!
|
|
2
3
|
* avgrund 0.1
|
|
3
4
|
* http://lab.hakim.se/avgrund
|
|
@@ -13,7 +14,7 @@ jQuery(function(){
|
|
|
13
14
|
currentState = null;
|
|
14
15
|
|
|
15
16
|
//Added draggable popup
|
|
16
|
-
|
|
17
|
+
//$( ".avgrund-popup" ).draggable({ cursor: "move" });
|
|
17
18
|
|
|
18
19
|
container.className = container.className.replace( /\s+$/gi, '' ) + ' avgrund-ready';
|
|
19
20
|
|
|
@@ -53,6 +54,26 @@ jQuery(function(){
|
|
|
53
54
|
document.removeEventListener( 'click', onDocumentClick, false );
|
|
54
55
|
|
|
55
56
|
removeClass( container, 'avgrund-active' );
|
|
57
|
+
jQuery('.modal-body').html('<div id=\"spinner\"><\/div>')
|
|
58
|
+
var opts = {
|
|
59
|
+
lines: 13, // The number of lines to draw
|
|
60
|
+
length: 7, // The length of each line
|
|
61
|
+
width: 4, // The line thickness
|
|
62
|
+
radius: 10, // The radius of the inner circle
|
|
63
|
+
corners: 1, // Corner roundness (0..1)
|
|
64
|
+
rotate: 0, // The rotation offset
|
|
65
|
+
color: '#000', // #rgb or #rrggbb
|
|
66
|
+
speed: 1, // Rounds per second
|
|
67
|
+
trail: 60, // Afterglow percentage
|
|
68
|
+
shadow: false, // Whether to render a shadow
|
|
69
|
+
hwaccel: true, // Whether to use hardware acceleration
|
|
70
|
+
className: 'spinner', // The CSS class to assign to the spinner
|
|
71
|
+
zIndex: 2e9, // The z-index (defaults to 2000000000)
|
|
72
|
+
top: 'auto', // Top position relative to parent in px
|
|
73
|
+
left: 'auto' // Left position relative to parent in px
|
|
74
|
+
};
|
|
75
|
+
var target = document.getElementById('spinner');
|
|
76
|
+
var spinner = new Spinner(opts).spin(target);
|
|
56
77
|
}
|
|
57
78
|
|
|
58
79
|
function disableBlur() {
|
|
@@ -73,4 +94,4 @@ jQuery(function(){
|
|
|
73
94
|
disableBlur: disableBlur
|
|
74
95
|
}
|
|
75
96
|
|
|
76
|
-
})
|
|
97
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
jQuery(function(){
|
|
2
2
|
jQuery('a[data-avgrund-url*=]').prop('href','#');
|
|
3
|
-
jQuery('a[data-avgrund-url
|
|
3
|
+
jQuery('a[data-avgrund-url]').click(function(){
|
|
4
4
|
avgrund.activate('', this);
|
|
5
5
|
jQuery.ajax({url: $(this).data('avgrund-url'),
|
|
6
6
|
success: function(data){
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
//fgnass.github.com/spin.js#v1.2.7
|
|
2
|
+
!function(window, document, undefined) {
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) 2011 Felix Gnass [fgnass at neteye dot de]
|
|
6
|
+
* Licensed under the MIT license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
|
|
10
|
+
, animations = {} /* Animation rules keyed by their name */
|
|
11
|
+
, useCssAnimations
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Utility function to create elements. If no tag name is given,
|
|
15
|
+
* a DIV is created. Optionally properties can be passed.
|
|
16
|
+
*/
|
|
17
|
+
function createEl(tag, prop) {
|
|
18
|
+
var el = document.createElement(tag || 'div')
|
|
19
|
+
, n
|
|
20
|
+
|
|
21
|
+
for(n in prop) el[n] = prop[n]
|
|
22
|
+
return el
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Appends children and returns the parent.
|
|
27
|
+
*/
|
|
28
|
+
function ins(parent /* child1, child2, ...*/) {
|
|
29
|
+
for (var i=1, n=arguments.length; i<n; i++)
|
|
30
|
+
parent.appendChild(arguments[i])
|
|
31
|
+
|
|
32
|
+
return parent
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Insert a new stylesheet to hold the @keyframe or VML rules.
|
|
37
|
+
*/
|
|
38
|
+
var sheet = function() {
|
|
39
|
+
var el = createEl('style', {type : 'text/css'})
|
|
40
|
+
ins(document.getElementsByTagName('head')[0], el)
|
|
41
|
+
return el.sheet || el.styleSheet
|
|
42
|
+
}()
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates an opacity keyframe animation rule and returns its name.
|
|
46
|
+
* Since most mobile Webkits have timing issues with animation-delay,
|
|
47
|
+
* we create separate rules for each line/segment.
|
|
48
|
+
*/
|
|
49
|
+
function addAnimation(alpha, trail, i, lines) {
|
|
50
|
+
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
|
|
51
|
+
, start = 0.01 + i/lines*100
|
|
52
|
+
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
|
|
53
|
+
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
|
|
54
|
+
, pre = prefix && '-'+prefix+'-' || ''
|
|
55
|
+
|
|
56
|
+
if (!animations[name]) {
|
|
57
|
+
sheet.insertRule(
|
|
58
|
+
'@' + pre + 'keyframes ' + name + '{' +
|
|
59
|
+
'0%{opacity:' + z + '}' +
|
|
60
|
+
start + '%{opacity:' + alpha + '}' +
|
|
61
|
+
(start+0.01) + '%{opacity:1}' +
|
|
62
|
+
(start+trail) % 100 + '%{opacity:' + alpha + '}' +
|
|
63
|
+
'100%{opacity:' + z + '}' +
|
|
64
|
+
'}', sheet.cssRules.length)
|
|
65
|
+
|
|
66
|
+
animations[name] = 1
|
|
67
|
+
}
|
|
68
|
+
return name
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Tries various vendor prefixes and returns the first supported property.
|
|
73
|
+
**/
|
|
74
|
+
function vendor(el, prop) {
|
|
75
|
+
var s = el.style
|
|
76
|
+
, pp
|
|
77
|
+
, i
|
|
78
|
+
|
|
79
|
+
if(s[prop] !== undefined) return prop
|
|
80
|
+
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
|
|
81
|
+
for(i=0; i<prefixes.length; i++) {
|
|
82
|
+
pp = prefixes[i]+prop
|
|
83
|
+
if(s[pp] !== undefined) return pp
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Sets multiple style properties at once.
|
|
89
|
+
*/
|
|
90
|
+
function css(el, prop) {
|
|
91
|
+
for (var n in prop)
|
|
92
|
+
el.style[vendor(el, n)||n] = prop[n]
|
|
93
|
+
|
|
94
|
+
return el
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Fills in default values.
|
|
99
|
+
*/
|
|
100
|
+
function merge(obj) {
|
|
101
|
+
for (var i=1; i < arguments.length; i++) {
|
|
102
|
+
var def = arguments[i]
|
|
103
|
+
for (var n in def)
|
|
104
|
+
if (obj[n] === undefined) obj[n] = def[n]
|
|
105
|
+
}
|
|
106
|
+
return obj
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns the absolute page-offset of the given element.
|
|
111
|
+
*/
|
|
112
|
+
function pos(el) {
|
|
113
|
+
var o = { x:el.offsetLeft, y:el.offsetTop }
|
|
114
|
+
while((el = el.offsetParent))
|
|
115
|
+
o.x+=el.offsetLeft, o.y+=el.offsetTop
|
|
116
|
+
|
|
117
|
+
return o
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var defaults = {
|
|
121
|
+
lines: 12, // The number of lines to draw
|
|
122
|
+
length: 7, // The length of each line
|
|
123
|
+
width: 5, // The line thickness
|
|
124
|
+
radius: 10, // The radius of the inner circle
|
|
125
|
+
rotate: 0, // Rotation offset
|
|
126
|
+
corners: 1, // Roundness (0..1)
|
|
127
|
+
color: '#000', // #rgb or #rrggbb
|
|
128
|
+
speed: 1, // Rounds per second
|
|
129
|
+
trail: 100, // Afterglow percentage
|
|
130
|
+
opacity: 1/4, // Opacity of the lines
|
|
131
|
+
fps: 20, // Frames per second when using setTimeout()
|
|
132
|
+
zIndex: 2e9, // Use a high z-index by default
|
|
133
|
+
className: 'spinner', // CSS class to assign to the element
|
|
134
|
+
top: 'auto', // center vertically
|
|
135
|
+
left: 'auto', // center horizontally
|
|
136
|
+
position: 'relative' // element position
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The constructor */
|
|
140
|
+
var Spinner = function Spinner(o) {
|
|
141
|
+
if (!this.spin) return new Spinner(o)
|
|
142
|
+
this.opts = merge(o || {}, Spinner.defaults, defaults)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Spinner.defaults = {}
|
|
146
|
+
|
|
147
|
+
merge(Spinner.prototype, {
|
|
148
|
+
spin: function(target) {
|
|
149
|
+
this.stop()
|
|
150
|
+
var self = this
|
|
151
|
+
, o = self.opts
|
|
152
|
+
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
|
|
153
|
+
, mid = o.radius+o.length+o.width
|
|
154
|
+
, ep // element position
|
|
155
|
+
, tp // target position
|
|
156
|
+
|
|
157
|
+
if (target) {
|
|
158
|
+
target.insertBefore(el, target.firstChild||null)
|
|
159
|
+
tp = pos(target)
|
|
160
|
+
ep = pos(el)
|
|
161
|
+
css(el, {
|
|
162
|
+
left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : parseInt(o.left, 10) + mid) + 'px',
|
|
163
|
+
top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : parseInt(o.top, 10) + mid) + 'px'
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
el.setAttribute('aria-role', 'progressbar')
|
|
168
|
+
self.lines(el, self.opts)
|
|
169
|
+
|
|
170
|
+
if (!useCssAnimations) {
|
|
171
|
+
// No CSS animation support, use setTimeout() instead
|
|
172
|
+
var i = 0
|
|
173
|
+
, fps = o.fps
|
|
174
|
+
, f = fps/o.speed
|
|
175
|
+
, ostep = (1-o.opacity) / (f*o.trail / 100)
|
|
176
|
+
, astep = f/o.lines
|
|
177
|
+
|
|
178
|
+
;(function anim() {
|
|
179
|
+
i++;
|
|
180
|
+
for (var s=o.lines; s; s--) {
|
|
181
|
+
var alpha = Math.max(1-(i+s*astep)%f * ostep, o.opacity)
|
|
182
|
+
self.opacity(el, o.lines-s, alpha, o)
|
|
183
|
+
}
|
|
184
|
+
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
|
|
185
|
+
})()
|
|
186
|
+
}
|
|
187
|
+
return self
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
stop: function() {
|
|
191
|
+
var el = this.el
|
|
192
|
+
if (el) {
|
|
193
|
+
clearTimeout(this.timeout)
|
|
194
|
+
if (el.parentNode) el.parentNode.removeChild(el)
|
|
195
|
+
this.el = undefined
|
|
196
|
+
}
|
|
197
|
+
return this
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
lines: function(el, o) {
|
|
201
|
+
var i = 0
|
|
202
|
+
, seg
|
|
203
|
+
|
|
204
|
+
function fill(color, shadow) {
|
|
205
|
+
return css(createEl(), {
|
|
206
|
+
position: 'absolute',
|
|
207
|
+
width: (o.length+o.width) + 'px',
|
|
208
|
+
height: o.width + 'px',
|
|
209
|
+
background: color,
|
|
210
|
+
boxShadow: shadow,
|
|
211
|
+
transformOrigin: 'left',
|
|
212
|
+
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
|
|
213
|
+
borderRadius: (o.corners * o.width>>1) + 'px'
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
for (; i < o.lines; i++) {
|
|
218
|
+
seg = css(createEl(), {
|
|
219
|
+
position: 'absolute',
|
|
220
|
+
top: 1+~(o.width/2) + 'px',
|
|
221
|
+
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
|
|
222
|
+
opacity: o.opacity,
|
|
223
|
+
animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite'
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
|
|
227
|
+
|
|
228
|
+
ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)')))
|
|
229
|
+
}
|
|
230
|
+
return el
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
opacity: function(el, i, val) {
|
|
234
|
+
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
/////////////////////////////////////////////////////////////////////////
|
|
240
|
+
// VML rendering for IE
|
|
241
|
+
/////////////////////////////////////////////////////////////////////////
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Check and init VML support
|
|
245
|
+
*/
|
|
246
|
+
;(function() {
|
|
247
|
+
|
|
248
|
+
function vml(tag, attr) {
|
|
249
|
+
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
var s = css(createEl('group'), {behavior: 'url(#default#VML)'})
|
|
253
|
+
|
|
254
|
+
if (!vendor(s, 'transform') && s.adj) {
|
|
255
|
+
|
|
256
|
+
// VML support detected. Insert CSS rule ...
|
|
257
|
+
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
|
|
258
|
+
|
|
259
|
+
Spinner.prototype.lines = function(el, o) {
|
|
260
|
+
var r = o.length+o.width
|
|
261
|
+
, s = 2*r
|
|
262
|
+
|
|
263
|
+
function grp() {
|
|
264
|
+
return css(
|
|
265
|
+
vml('group', {
|
|
266
|
+
coordsize: s + ' ' + s,
|
|
267
|
+
coordorigin: -r + ' ' + -r
|
|
268
|
+
}),
|
|
269
|
+
{ width: s, height: s }
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var margin = -(o.width+o.length)*2 + 'px'
|
|
274
|
+
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
|
|
275
|
+
, i
|
|
276
|
+
|
|
277
|
+
function seg(i, dx, filter) {
|
|
278
|
+
ins(g,
|
|
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
|
+
)
|
|
290
|
+
)
|
|
291
|
+
)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (o.shadow)
|
|
295
|
+
for (i = 1; i <= o.lines; i++)
|
|
296
|
+
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
|
|
297
|
+
|
|
298
|
+
for (i = 1; i <= o.lines; i++) seg(i)
|
|
299
|
+
return ins(el, g)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
Spinner.prototype.opacity = function(el, i, val, o) {
|
|
303
|
+
var c = el.firstChild
|
|
304
|
+
o = o.shadow && o.lines || 0
|
|
305
|
+
if (c && i+o < c.childNodes.length) {
|
|
306
|
+
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
|
|
307
|
+
if (c) c.opacity = val
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
else
|
|
312
|
+
useCssAnimations = vendor(s, 'animation')
|
|
313
|
+
})()
|
|
314
|
+
|
|
315
|
+
if (typeof define == 'function' && define.amd)
|
|
316
|
+
define(function() { return Spinner })
|
|
317
|
+
else
|
|
318
|
+
window.Spinner = Spinner
|
|
319
|
+
|
|
320
|
+
}(window, document);
|
data/lib/avgrund_to/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: avgrund_to
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
@@ -53,6 +53,7 @@ extra_rdoc_files: []
|
|
|
53
53
|
files:
|
|
54
54
|
- app/assets/javascripts/avgrund_to/avgrund.js
|
|
55
55
|
- app/assets/javascripts/avgrund_to/modal.js
|
|
56
|
+
- app/assets/javascripts/avgrund_to/spin.js
|
|
56
57
|
- app/assets/stylesheets/avgrund.css
|
|
57
58
|
- app/helpers/avgrund_to_helper.rb
|
|
58
59
|
- app/views/avgrund_to/_modal.html.erb
|
|
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
77
78
|
version: '0'
|
|
78
79
|
segments:
|
|
79
80
|
- 0
|
|
80
|
-
hash:
|
|
81
|
+
hash: 4465249929004866830
|
|
81
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
83
|
none: false
|
|
83
84
|
requirements:
|
|
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
86
87
|
version: '0'
|
|
87
88
|
segments:
|
|
88
89
|
- 0
|
|
89
|
-
hash:
|
|
90
|
+
hash: 4465249929004866830
|
|
90
91
|
requirements: []
|
|
91
92
|
rubyforge_project:
|
|
92
93
|
rubygems_version: 1.8.24
|