coffeebox 0.2.3 → 0.3.0
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 +4 -4
- data/LICENSE.txt +1 -0
- data/app/assets/javascripts/coffeebox/imgpreload.js +49 -107
- data/app/assets/javascripts/coffeebox/main.js.coffee +1 -1
- data/app/assets/javascripts/coffeebox/spin.js +153 -126
- data/lib/coffeebox/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d7e983d56906bb2e1358e905e4a4cde7852935f
|
4
|
+
data.tar.gz: b144ca98a3cb1bacc84c6e439cd6544e502e5cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57522cb58c1771e7f432837ca00c2657255beee971d0b6a9b53d51c7377a53eae4219ec1d9b9e1374b1560daca3aa9e19552d708fe94d32a3bdd04b9e8bf3168
|
7
|
+
data.tar.gz: afecc09dd8e12dc397fd29c1af2459ddd310f4adcdfd1190f2fc577aa116f0228718e732f84037216740f1750f3d26fff65f6a7bb13361792df803c6ec7a7f53
|
data/LICENSE.txt
CHANGED
@@ -1,128 +1,70 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
http://en.wikipedia.org/wiki/MIT_License
|
1
|
+
/**
|
2
|
+
* jquery.imgpreload 1.6.2 <https://github.com/farinspace/jquery.imgpreload>
|
3
|
+
* Copyright 2009-2014 Dimas Begunoff <http://farinspace.com>
|
4
|
+
* License MIT <http://opensource.org/licenses/MIT>
|
6
5
|
*/
|
7
|
-
|
8
6
|
if ('undefined' != typeof jQuery)
|
9
7
|
{
|
10
|
-
|
11
|
-
|
12
|
-
// extend jquery (because i love jQuery)
|
13
|
-
$.imgpreload = function (imgs,settings)
|
14
|
-
{
|
15
|
-
settings = $.extend({},$.fn.imgpreload.defaults,(settings instanceof Function)?{all:settings}:settings);
|
8
|
+
(function($){
|
9
|
+
'use strict';
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
// extend jquery (because i love jQuery)
|
12
|
+
$.imgpreload = function (imgs,settings)
|
13
|
+
{
|
14
|
+
settings = $.extend({},$.fn.imgpreload.defaults,(settings instanceof Function)?{all:settings}:settings);
|
20
15
|
|
21
|
-
|
16
|
+
// use of typeof required
|
17
|
+
// https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Operators/Special_Operators/Instanceof_Operator#Description
|
18
|
+
if ('string' == typeof imgs) { imgs = [imgs]; }
|
22
19
|
|
23
|
-
|
24
|
-
{
|
25
|
-
var img = new Image();
|
20
|
+
var loaded = [];
|
26
21
|
|
27
|
-
|
22
|
+
$.each(imgs,function(i,elem)
|
23
|
+
{
|
24
|
+
var img = new Image();
|
28
25
|
|
29
|
-
|
26
|
+
var url = elem;
|
30
27
|
|
31
|
-
|
32
|
-
{
|
33
|
-
url = $(elem).attr('src') || $(elem).css('background-image').replace(/^url\((?:"|')?(.*)(?:'|")?\)$/mg, "$1");
|
28
|
+
var img_obj = img;
|
34
29
|
|
35
|
-
|
36
|
-
|
30
|
+
if ('string' != typeof elem)
|
31
|
+
{
|
32
|
+
url = $(elem).attr('src') || $(elem).css('background-image').replace(/^url\((?:"|')?(.*)(?:'|")?\)$/mg, "$1");
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
loaded.push(img_obj);
|
34
|
+
img_obj = elem;
|
35
|
+
}
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
$(img).bind('load error', function(e)
|
38
|
+
{
|
39
|
+
loaded.push(img_obj);
|
45
40
|
|
46
|
-
|
47
|
-
if (loaded.length>=imgs.length && settings.all instanceof Function) { settings.all.call(loaded); }
|
41
|
+
$.data(img_obj, 'loaded', ('error'==e.type)?false:true);
|
48
42
|
|
49
|
-
|
50
|
-
|
43
|
+
// http://msdn.microsoft.com/en-us/library/ie/tkcsy6fe(v=vs.94).aspx
|
44
|
+
if (settings.each instanceof Function) { settings.each.call(img_obj, loaded.slice(0)); }
|
51
45
|
|
52
|
-
|
53
|
-
|
54
|
-
};
|
46
|
+
// http://jsperf.com/length-in-a-variable
|
47
|
+
if (loaded.length>=imgs.length && settings.all instanceof Function) { settings.all.call(loaded); }
|
55
48
|
|
56
|
-
|
57
|
-
|
58
|
-
$.imgpreload(this,settings);
|
49
|
+
$(this).unbind('load error');
|
50
|
+
});
|
59
51
|
|
60
|
-
|
61
|
-
|
52
|
+
img.src = url;
|
53
|
+
});
|
54
|
+
};
|
62
55
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
, all: null // callback invoked when when the entire group of images has loaded
|
67
|
-
};
|
56
|
+
$.fn.imgpreload = function(settings)
|
57
|
+
{
|
58
|
+
$.imgpreload(this,settings);
|
68
59
|
|
69
|
-
|
70
|
-
}
|
60
|
+
return this;
|
61
|
+
};
|
71
62
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
{
|
78
|
-
// this = array of dom image objects
|
79
|
-
// callback executes when all images are loaded
|
80
|
-
});
|
81
|
-
|
82
|
-
$('#content img').imgpreload
|
83
|
-
({
|
84
|
-
each: function()
|
85
|
-
{
|
86
|
-
// this = dom image object
|
87
|
-
// check for success with: $(this).data('loaded')
|
88
|
-
// callback executes when each image loads
|
89
|
-
},
|
90
|
-
all: function()
|
91
|
-
{
|
92
|
-
// this = array of dom image objects
|
93
|
-
// check for success with: $(this[i]).data('loaded')
|
94
|
-
// callback executes when all images are loaded
|
95
|
-
}
|
96
|
-
});
|
97
|
-
|
98
|
-
$.imgpreload('/images/a.gif',function()
|
99
|
-
{
|
100
|
-
// this = array of dom image objects
|
101
|
-
// check for success with: $(this[i]).data('loaded')
|
102
|
-
// callback
|
103
|
-
});
|
104
|
-
|
105
|
-
$.imgpreload(['/images/a.gif','/images/b.gif'],function()
|
106
|
-
{
|
107
|
-
// this = array of dom image objects
|
108
|
-
// check for success with: $(this[i]).data('loaded')
|
109
|
-
// callback executes when all images are loaded
|
110
|
-
});
|
111
|
-
|
112
|
-
$.imgpreload(['/images/a.gif','/images/b.gif'],
|
113
|
-
{
|
114
|
-
each: function()
|
115
|
-
{
|
116
|
-
// this = dom image object
|
117
|
-
// check for success with: $(this).data('loaded')
|
118
|
-
// callback executes on every image load
|
119
|
-
},
|
120
|
-
all: function()
|
121
|
-
{
|
122
|
-
// this = array of dom image objects
|
123
|
-
// check for success with: $(this[i]).data('loaded')
|
124
|
-
// callback executes when all images are loaded
|
125
|
-
}
|
126
|
-
});
|
63
|
+
$.fn.imgpreload.defaults =
|
64
|
+
{
|
65
|
+
each: null, // callback invoked when each image is loaded
|
66
|
+
all: null // callback invoked when all images have loaded
|
67
|
+
};
|
127
68
|
|
128
|
-
|
69
|
+
})(jQuery);
|
70
|
+
}
|
@@ -159,7 +159,7 @@ fillcoffeeboxFromHref = (href, klass) ->
|
|
159
159
|
if href.match(/#/)
|
160
160
|
url = window.location.href.split("#")[0]
|
161
161
|
target = href.replace(url, "")
|
162
|
-
$.coffeebox.reveal $(target).html(), klass
|
162
|
+
$.coffeebox.reveal $(target).html(), klass if target.indexOf("#") != -1
|
163
163
|
|
164
164
|
# image
|
165
165
|
else if href.match($.coffeebox.settings.imageTypesRegexp)
|
@@ -1,64 +1,82 @@
|
|
1
1
|
/**
|
2
|
-
* v 2.0.1
|
3
2
|
* Copyright (c) 2011-2014 Felix Gnass
|
4
3
|
* Licensed under the MIT license
|
4
|
+
* http://spin.js.org/
|
5
|
+
*
|
6
|
+
* Example:
|
7
|
+
var opts = {
|
8
|
+
lines: 12 // The number of lines to draw
|
9
|
+
, length: 7 // The length of each line
|
10
|
+
, width: 5 // The line thickness
|
11
|
+
, radius: 10 // The radius of the inner circle
|
12
|
+
, scale: 1.0 // Scales overall size of the spinner
|
13
|
+
, corners: 1 // Roundness (0..1)
|
14
|
+
, color: '#000' // #rgb or #rrggbb
|
15
|
+
, opacity: 1/4 // Opacity of the lines
|
16
|
+
, rotate: 0 // Rotation offset
|
17
|
+
, direction: 1 // 1: clockwise, -1: counterclockwise
|
18
|
+
, speed: 1 // Rounds per second
|
19
|
+
, trail: 100 // Afterglow percentage
|
20
|
+
, fps: 20 // Frames per second when using setTimeout()
|
21
|
+
, zIndex: 2e9 // Use a high z-index by default
|
22
|
+
, className: 'spinner' // CSS class to assign to the element
|
23
|
+
, top: '50%' // center vertically
|
24
|
+
, left: '50%' // center horizontally
|
25
|
+
, shadow: false // Whether to render a shadow
|
26
|
+
, hwaccel: false // Whether to use hardware acceleration (might be buggy)
|
27
|
+
, position: 'absolute' // Element positioning
|
28
|
+
}
|
29
|
+
var target = document.getElementById('foo')
|
30
|
+
var spinner = new Spinner(opts).spin(target)
|
5
31
|
*/
|
6
|
-
(function(root, factory) {
|
32
|
+
;(function (root, factory) {
|
7
33
|
|
8
34
|
/* CommonJS */
|
9
|
-
if (typeof
|
35
|
+
if (typeof module == 'object' && module.exports) module.exports = factory()
|
10
36
|
|
11
37
|
/* AMD module */
|
12
38
|
else if (typeof define == 'function' && define.amd) define(factory)
|
13
39
|
|
14
40
|
/* Browser global */
|
15
41
|
else root.Spinner = factory()
|
16
|
-
}
|
17
|
-
|
18
|
-
"use strict";
|
42
|
+
}(this, function () {
|
43
|
+
"use strict"
|
19
44
|
|
20
45
|
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
|
21
46
|
, animations = {} /* Animation rules keyed by their name */
|
22
47
|
, useCssAnimations /* Whether to use CSS animations or setTimeout */
|
48
|
+
, sheet /* A stylesheet to hold the @keyframe or VML rules. */
|
23
49
|
|
24
50
|
/**
|
25
51
|
* Utility function to create elements. If no tag name is given,
|
26
52
|
* a DIV is created. Optionally properties can be passed.
|
27
53
|
*/
|
28
|
-
function createEl(tag, prop) {
|
54
|
+
function createEl (tag, prop) {
|
29
55
|
var el = document.createElement(tag || 'div')
|
30
56
|
, n
|
31
57
|
|
32
|
-
for(n in prop) el[n] = prop[n]
|
58
|
+
for (n in prop) el[n] = prop[n]
|
33
59
|
return el
|
34
60
|
}
|
35
61
|
|
36
62
|
/**
|
37
63
|
* Appends children and returns the parent.
|
38
64
|
*/
|
39
|
-
function ins(parent /* child1, child2, ...*/) {
|
40
|
-
for (var i=1, n=arguments.length; i<n; i++)
|
65
|
+
function ins (parent /* child1, child2, ...*/) {
|
66
|
+
for (var i = 1, n = arguments.length; i < n; i++) {
|
41
67
|
parent.appendChild(arguments[i])
|
68
|
+
}
|
42
69
|
|
43
70
|
return parent
|
44
71
|
}
|
45
72
|
|
46
|
-
/**
|
47
|
-
* Insert a new stylesheet to hold the @keyframe or VML rules.
|
48
|
-
*/
|
49
|
-
var sheet = (function() {
|
50
|
-
var el = createEl('style', {type : 'text/css'})
|
51
|
-
ins(document.getElementsByTagName('head')[0], el)
|
52
|
-
return el.sheet || el.styleSheet
|
53
|
-
}())
|
54
|
-
|
55
73
|
/**
|
56
74
|
* Creates an opacity keyframe animation rule and returns its name.
|
57
75
|
* Since most mobile Webkits have timing issues with animation-delay,
|
58
76
|
* we create separate rules for each line/segment.
|
59
77
|
*/
|
60
|
-
function addAnimation(alpha, trail, i, lines) {
|
61
|
-
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
|
78
|
+
function addAnimation (alpha, trail, i, lines) {
|
79
|
+
var name = ['opacity', trail, ~~(alpha * 100), i, lines].join('-')
|
62
80
|
, start = 0.01 + i/lines * 100
|
63
81
|
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
|
64
82
|
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
|
@@ -83,25 +101,26 @@
|
|
83
101
|
/**
|
84
102
|
* Tries various vendor prefixes and returns the first supported property.
|
85
103
|
*/
|
86
|
-
function vendor(el, prop) {
|
104
|
+
function vendor (el, prop) {
|
87
105
|
var s = el.style
|
88
106
|
, pp
|
89
107
|
, i
|
90
108
|
|
91
109
|
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
|
92
|
-
|
110
|
+
if (s[prop] !== undefined) return prop
|
111
|
+
for (i = 0; i < prefixes.length; i++) {
|
93
112
|
pp = prefixes[i]+prop
|
94
|
-
if(s[pp] !== undefined) return pp
|
113
|
+
if (s[pp] !== undefined) return pp
|
95
114
|
}
|
96
|
-
if(s[prop] !== undefined) return prop
|
97
115
|
}
|
98
116
|
|
99
117
|
/**
|
100
118
|
* Sets multiple style properties at once.
|
101
119
|
*/
|
102
|
-
function css(el, prop) {
|
103
|
-
for (var n in prop)
|
104
|
-
el.style[vendor(el, n)||n] = prop[n]
|
120
|
+
function css (el, prop) {
|
121
|
+
for (var n in prop) {
|
122
|
+
el.style[vendor(el, n) || n] = prop[n]
|
123
|
+
}
|
105
124
|
|
106
125
|
return el
|
107
126
|
}
|
@@ -109,57 +128,50 @@
|
|
109
128
|
/**
|
110
129
|
* Fills in default values.
|
111
130
|
*/
|
112
|
-
function merge(obj) {
|
113
|
-
for (var i=1; i < arguments.length; i++) {
|
131
|
+
function merge (obj) {
|
132
|
+
for (var i = 1; i < arguments.length; i++) {
|
114
133
|
var def = arguments[i]
|
115
|
-
for (var n in def)
|
134
|
+
for (var n in def) {
|
116
135
|
if (obj[n] === undefined) obj[n] = def[n]
|
136
|
+
}
|
117
137
|
}
|
118
138
|
return obj
|
119
139
|
}
|
120
140
|
|
121
|
-
/**
|
122
|
-
* Returns the absolute page-offset of the given element.
|
123
|
-
*/
|
124
|
-
function pos(el) {
|
125
|
-
var o = { x:el.offsetLeft, y:el.offsetTop }
|
126
|
-
while((el = el.offsetParent))
|
127
|
-
o.x+=el.offsetLeft, o.y+=el.offsetTop
|
128
|
-
|
129
|
-
return o
|
130
|
-
}
|
131
|
-
|
132
141
|
/**
|
133
142
|
* Returns the line color from the given string or array.
|
134
143
|
*/
|
135
|
-
function getColor(color, idx) {
|
144
|
+
function getColor (color, idx) {
|
136
145
|
return typeof color == 'string' ? color : color[idx % color.length]
|
137
146
|
}
|
138
147
|
|
139
148
|
// Built-in defaults
|
140
149
|
|
141
150
|
var defaults = {
|
142
|
-
lines: 12
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
151
|
+
lines: 12 // The number of lines to draw
|
152
|
+
, length: 7 // The length of each line
|
153
|
+
, width: 5 // The line thickness
|
154
|
+
, radius: 10 // The radius of the inner circle
|
155
|
+
, scale: 1.0 // Scales overall size of the spinner
|
156
|
+
, corners: 1 // Roundness (0..1)
|
157
|
+
, color: '#000' // #rgb or #rrggbb
|
158
|
+
, opacity: 1/4 // Opacity of the lines
|
159
|
+
, rotate: 0 // Rotation offset
|
160
|
+
, direction: 1 // 1: clockwise, -1: counterclockwise
|
161
|
+
, speed: 1 // Rounds per second
|
162
|
+
, trail: 100 // Afterglow percentage
|
163
|
+
, fps: 20 // Frames per second when using setTimeout()
|
164
|
+
, zIndex: 2e9 // Use a high z-index by default
|
165
|
+
, className: 'spinner' // CSS class to assign to the element
|
166
|
+
, top: '50%' // center vertically
|
167
|
+
, left: '50%' // center horizontally
|
168
|
+
, shadow: false // Whether to render a shadow
|
169
|
+
, hwaccel: false // Whether to use hardware acceleration (might be buggy)
|
170
|
+
, position: 'absolute' // Element positioning
|
159
171
|
}
|
160
172
|
|
161
173
|
/** The constructor */
|
162
|
-
function Spinner(o) {
|
174
|
+
function Spinner (o) {
|
163
175
|
this.opts = merge(o || {}, Spinner.defaults, defaults)
|
164
176
|
}
|
165
177
|
|
@@ -167,27 +179,28 @@
|
|
167
179
|
Spinner.defaults = {}
|
168
180
|
|
169
181
|
merge(Spinner.prototype, {
|
170
|
-
|
171
182
|
/**
|
172
183
|
* Adds the spinner to the given target element. If this instance is already
|
173
184
|
* spinning, it is automatically removed from its previous target b calling
|
174
185
|
* stop() internally.
|
175
186
|
*/
|
176
|
-
spin: function(target) {
|
187
|
+
spin: function (target) {
|
177
188
|
this.stop()
|
178
189
|
|
179
190
|
var self = this
|
180
191
|
, o = self.opts
|
181
|
-
, el = self.el =
|
182
|
-
, mid = o.radius+o.length+o.width
|
192
|
+
, el = self.el = createEl(null, {className: o.className})
|
183
193
|
|
184
194
|
css(el, {
|
185
|
-
|
186
|
-
|
195
|
+
position: o.position
|
196
|
+
, width: 0
|
197
|
+
, zIndex: o.zIndex
|
198
|
+
, left: o.left
|
199
|
+
, top: o.top
|
187
200
|
})
|
188
|
-
|
201
|
+
|
189
202
|
if (target) {
|
190
|
-
target.insertBefore(el, target.firstChild||null)
|
203
|
+
target.insertBefore(el, target.firstChild || null)
|
191
204
|
}
|
192
205
|
|
193
206
|
el.setAttribute('role', 'progressbar')
|
@@ -199,27 +212,27 @@
|
|
199
212
|
, start = (o.lines - 1) * (1 - o.direction) / 2
|
200
213
|
, alpha
|
201
214
|
, fps = o.fps
|
202
|
-
, f = fps/o.speed
|
203
|
-
, ostep = (1-o.opacity) / (f*o.trail / 100)
|
204
|
-
, astep = f/o.lines
|
215
|
+
, f = fps / o.speed
|
216
|
+
, ostep = (1 - o.opacity) / (f * o.trail / 100)
|
217
|
+
, astep = f / o.lines
|
205
218
|
|
206
|
-
;(function anim() {
|
207
|
-
i
|
219
|
+
;(function anim () {
|
220
|
+
i++
|
208
221
|
for (var j = 0; j < o.lines; j++) {
|
209
222
|
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
|
210
223
|
|
211
224
|
self.opacity(el, j * o.direction + start, alpha, o)
|
212
225
|
}
|
213
|
-
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
|
226
|
+
self.timeout = self.el && setTimeout(anim, ~~(1000 / fps))
|
214
227
|
})()
|
215
228
|
}
|
216
229
|
return self
|
217
|
-
}
|
230
|
+
}
|
218
231
|
|
219
232
|
/**
|
220
233
|
* Stops and removes the Spinner.
|
221
234
|
*/
|
222
|
-
|
235
|
+
, stop: function () {
|
223
236
|
var el = this.el
|
224
237
|
if (el) {
|
225
238
|
clearTimeout(this.timeout)
|
@@ -227,123 +240,137 @@
|
|
227
240
|
this.el = undefined
|
228
241
|
}
|
229
242
|
return this
|
230
|
-
}
|
243
|
+
}
|
231
244
|
|
232
245
|
/**
|
233
246
|
* Internal method that draws the individual lines. Will be overwritten
|
234
247
|
* in VML fallback mode below.
|
235
248
|
*/
|
236
|
-
|
249
|
+
, lines: function (el, o) {
|
237
250
|
var i = 0
|
238
251
|
, start = (o.lines - 1) * (1 - o.direction) / 2
|
239
252
|
, seg
|
240
253
|
|
241
|
-
function fill(color, shadow) {
|
254
|
+
function fill (color, shadow) {
|
242
255
|
return css(createEl(), {
|
243
|
-
position: 'absolute'
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
256
|
+
position: 'absolute'
|
257
|
+
, width: o.scale * (o.length + o.width) + 'px'
|
258
|
+
, height: o.scale * o.width + 'px'
|
259
|
+
, background: color
|
260
|
+
, boxShadow: shadow
|
261
|
+
, transformOrigin: 'left'
|
262
|
+
, transform: 'rotate(' + ~~(360/o.lines*i + o.rotate) + 'deg) translate(' + o.scale*o.radius + 'px' + ',0)'
|
263
|
+
, borderRadius: (o.corners * o.scale * o.width >> 1) + 'px'
|
251
264
|
})
|
252
265
|
}
|
253
266
|
|
254
267
|
for (; i < o.lines; i++) {
|
255
268
|
seg = css(createEl(), {
|
256
|
-
position: 'absolute'
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
269
|
+
position: 'absolute'
|
270
|
+
, top: 1 + ~(o.scale * o.width / 2) + 'px'
|
271
|
+
, transform: o.hwaccel ? 'translate3d(0,0,0)' : ''
|
272
|
+
, opacity: o.opacity
|
273
|
+
, animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite'
|
261
274
|
})
|
262
275
|
|
263
|
-
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px
|
276
|
+
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px #000'), {top: '2px'}))
|
264
277
|
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
|
265
278
|
}
|
266
279
|
return el
|
267
|
-
}
|
280
|
+
}
|
268
281
|
|
269
282
|
/**
|
270
283
|
* Internal method that adjusts the opacity of a single line.
|
271
284
|
* Will be overwritten in VML fallback mode below.
|
272
285
|
*/
|
273
|
-
|
286
|
+
, opacity: function (el, i, val) {
|
274
287
|
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
|
275
288
|
}
|
276
289
|
|
277
290
|
})
|
278
291
|
|
279
292
|
|
280
|
-
function initVML() {
|
293
|
+
function initVML () {
|
281
294
|
|
282
295
|
/* Utility function to create a VML tag */
|
283
|
-
function vml(tag, attr) {
|
296
|
+
function vml (tag, attr) {
|
284
297
|
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
|
285
298
|
}
|
286
299
|
|
287
300
|
// No CSS transforms but VML support, add a CSS rule for VML elements:
|
288
301
|
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
|
289
302
|
|
290
|
-
Spinner.prototype.lines = function(el, o) {
|
291
|
-
var r = o.length+o.width
|
292
|
-
, s = 2*r
|
303
|
+
Spinner.prototype.lines = function (el, o) {
|
304
|
+
var r = o.scale * (o.length + o.width)
|
305
|
+
, s = o.scale * 2 * r
|
293
306
|
|
294
|
-
function grp() {
|
307
|
+
function grp () {
|
295
308
|
return css(
|
296
309
|
vml('group', {
|
297
|
-
coordsize: s + ' ' + s
|
298
|
-
|
299
|
-
})
|
300
|
-
|
310
|
+
coordsize: s + ' ' + s
|
311
|
+
, coordorigin: -r + ' ' + -r
|
312
|
+
})
|
313
|
+
, { width: s, height: s }
|
301
314
|
)
|
302
315
|
}
|
303
316
|
|
304
|
-
var margin = -(o.width+o.length)*2 + 'px'
|
317
|
+
var margin = -(o.width + o.length) * o.scale * 2 + 'px'
|
305
318
|
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
|
306
319
|
, i
|
307
320
|
|
308
|
-
function seg(i, dx, filter) {
|
309
|
-
ins(
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
321
|
+
function seg (i, dx, filter) {
|
322
|
+
ins(
|
323
|
+
g
|
324
|
+
, ins(
|
325
|
+
css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx})
|
326
|
+
, ins(
|
327
|
+
css(
|
328
|
+
vml('roundrect', {arcsize: o.corners})
|
329
|
+
, { width: r
|
330
|
+
, height: o.scale * o.width
|
331
|
+
, left: o.scale * o.radius
|
332
|
+
, top: -o.scale * o.width >> 1
|
333
|
+
, filter: filter
|
334
|
+
}
|
335
|
+
)
|
336
|
+
, vml('fill', {color: getColor(o.color, i), opacity: o.opacity})
|
337
|
+
, vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
|
320
338
|
)
|
321
339
|
)
|
322
340
|
)
|
323
341
|
}
|
324
342
|
|
325
343
|
if (o.shadow)
|
326
|
-
for (i = 1; i <= o.lines; i++)
|
344
|
+
for (i = 1; i <= o.lines; i++) {
|
327
345
|
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
|
346
|
+
}
|
328
347
|
|
329
348
|
for (i = 1; i <= o.lines; i++) seg(i)
|
330
349
|
return ins(el, g)
|
331
350
|
}
|
332
351
|
|
333
|
-
Spinner.prototype.opacity = function(el, i, val, o) {
|
352
|
+
Spinner.prototype.opacity = function (el, i, val, o) {
|
334
353
|
var c = el.firstChild
|
335
354
|
o = o.shadow && o.lines || 0
|
336
|
-
if (c && i+o < c.childNodes.length) {
|
337
|
-
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
|
355
|
+
if (c && i + o < c.childNodes.length) {
|
356
|
+
c = c.childNodes[i + o]; c = c && c.firstChild; c = c && c.firstChild
|
338
357
|
if (c) c.opacity = val
|
339
358
|
}
|
340
359
|
}
|
341
360
|
}
|
342
361
|
|
343
|
-
|
362
|
+
if (typeof document !== 'undefined') {
|
363
|
+
sheet = (function () {
|
364
|
+
var el = createEl('style', {type : 'text/css'})
|
365
|
+
ins(document.getElementsByTagName('head')[0], el)
|
366
|
+
return el.sheet || el.styleSheet
|
367
|
+
}())
|
344
368
|
|
345
|
-
|
346
|
-
|
369
|
+
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
|
370
|
+
|
371
|
+
if (!vendor(probe, 'transform') && probe.adj) initVML()
|
372
|
+
else useCssAnimations = vendor(probe, 'animation')
|
373
|
+
}
|
347
374
|
|
348
375
|
return Spinner
|
349
376
|
|
data/lib/coffeebox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffeebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.4.5
|
99
|
+
rubygems_version: 2.4.5.1
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: An opinionated rewrite of Facebox in coffescript bundled as a rails gem
|