spree_backend 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/admin/admin.js.erb +10 -9
  3. data/app/assets/javascripts/admin/line_items.js.coffee +61 -0
  4. data/app/assets/javascripts/admin/payments/edit.js.coffee +1 -1
  5. data/app/assets/javascripts/admin/product_picker.js +2 -1
  6. data/app/assets/javascripts/admin/progress.coffee +2 -2
  7. data/app/assets/javascripts/admin/shipments.js.erb +242 -0
  8. data/app/assets/javascripts/admin/variant_autocomplete.js.erb +0 -244
  9. data/app/assets/javascripts/admin/variant_management.js.coffee +10 -0
  10. data/app/assets/stylesheets/admin/sections/_log_entries.scss +17 -0
  11. data/app/assets/stylesheets/admin/spree_admin.scss +1 -0
  12. data/app/assets/stylesheets/admin/spree_backend.css +1 -1
  13. data/app/controllers/spree/admin/images_controller.rb +1 -1
  14. data/app/controllers/spree/admin/log_entries_controller.rb +19 -0
  15. data/app/controllers/spree/admin/mail_methods_controller.rb +1 -8
  16. data/app/controllers/spree/admin/orders/customer_details_controller.rb +4 -0
  17. data/app/controllers/spree/admin/orders_controller.rb +9 -14
  18. data/app/controllers/spree/admin/payments_controller.rb +4 -0
  19. data/app/controllers/spree/admin/products_controller.rb +7 -11
  20. data/app/controllers/spree/admin/reports_controller.rb +20 -4
  21. data/app/controllers/spree/admin/resource_controller.rb +6 -3
  22. data/app/controllers/spree/admin/taxons_controller.rb +1 -2
  23. data/app/controllers/spree/admin/variants_including_master_controller.rb +15 -0
  24. data/app/helpers/spree/admin/base_helper.rb +1 -1
  25. data/app/helpers/spree/admin/navigation_helper.rb +5 -2
  26. data/app/helpers/spree/admin/orders_helper.rb +42 -0
  27. data/app/helpers/spree/admin/stock_movements_helper.rb +5 -1
  28. data/app/views/spree/admin/log_entries/_credit_card.html.erb +4 -0
  29. data/app/views/spree/admin/log_entries/index.html.erb +28 -0
  30. data/app/views/spree/admin/mail_methods/_form.html.erb +2 -2
  31. data/app/views/spree/admin/orders/_form.html.erb +9 -1
  32. data/app/views/spree/admin/orders/_line_items.html.erb +46 -0
  33. data/app/views/spree/admin/orders/_risk_analysis.html.erb +47 -0
  34. data/app/views/spree/admin/orders/_shipment.html.erb +11 -3
  35. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +7 -3
  36. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  37. data/app/views/spree/admin/orders/customer_details/edit.html.erb +7 -9
  38. data/app/views/spree/admin/orders/index.html.erb +11 -5
  39. data/app/views/spree/admin/payment_methods/_form.html.erb +0 -2
  40. data/app/views/spree/admin/payments/_list.html.erb +2 -2
  41. data/app/views/spree/admin/payments/show.html.erb +2 -1
  42. data/app/views/spree/admin/products/_add_stock_form.html.erb +1 -1
  43. data/app/views/spree/admin/products/_form.html.erb +0 -1
  44. data/app/views/spree/admin/products/stock.html.erb +10 -1
  45. data/app/views/spree/admin/shared/_destroy.js.erb +5 -14
  46. data/app/views/spree/admin/shared/_head.html.erb +6 -2
  47. data/app/views/spree/admin/shared/_order_tabs.html.erb +4 -4
  48. data/app/views/spree/admin/variants/update.js.erb +1 -0
  49. data/config/routes.rb +3 -0
  50. data/vendor/assets/javascripts/spin.js +356 -296
  51. metadata +29 -19
@@ -1,319 +1,379 @@
1
- //fgnass.github.com/spin.js#v1.2.6
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
- }
137
-
138
- /** The constructor */
139
- var Spinner = function Spinner(o) {
140
- if (!this.spin) return new Spinner(o)
141
- this.opts = merge(o || {}, Spinner.defaults, defaults)
142
- }
143
-
144
- Spinner.defaults = {}
145
-
146
- merge(Spinner.prototype, {
147
- spin: function(target) {
148
- this.stop()
149
- var self = this
150
- , o = self.opts
151
- , el = self.el = css(createEl(0, {className: o.className}), {position: 'relative', width: 0, zIndex: o.zIndex})
152
- , mid = o.radius+o.length+o.width
153
- , ep // element position
154
- , tp // target position
155
-
156
- if (target) {
157
- target.insertBefore(el, target.firstChild||null)
158
- tp = pos(target)
159
- ep = pos(el)
160
- css(el, {
161
- left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : parseInt(o.left, 10) + mid) + 'px',
162
- top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : parseInt(o.top, 10) + mid) + 'px'
163
- })
164
- }
165
-
166
- el.setAttribute('aria-role', 'progressbar')
167
- self.lines(el, self.opts)
168
-
169
- if (!useCssAnimations) {
170
- // No CSS animation support, use setTimeout() instead
171
- var i = 0
172
- , fps = o.fps
173
- , f = fps/o.speed
174
- , ostep = (1-o.opacity) / (f*o.trail / 100)
175
- , astep = f/o.lines
176
-
177
- ;(function anim() {
178
- i++;
179
- for (var s=o.lines; s; s--) {
180
- var alpha = Math.max(1-(i+s*astep)%f * ostep, o.opacity)
181
- self.opacity(el, o.lines-s, alpha, o)
182
- }
183
- self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
184
- })()
185
- }
186
- return self
187
- },
188
-
189
- stop: function() {
190
- var el = this.el
191
- if (el) {
192
- clearTimeout(this.timeout)
193
- if (el.parentNode) el.parentNode.removeChild(el)
194
- this.el = undefined
195
- }
196
- return this
197
- },
198
-
199
- lines: function(el, o) {
200
- var i = 0
201
- , seg
202
-
203
- function fill(color, shadow) {
204
- return css(createEl(), {
205
- position: 'absolute',
206
- width: (o.length+o.width) + 'px',
207
- height: o.width + 'px',
208
- background: color,
209
- boxShadow: shadow,
210
- transformOrigin: 'left',
211
- transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
212
- borderRadius: (o.corners * o.width>>1) + 'px'
213
- })
214
- }
215
-
216
- for (; i < o.lines; i++) {
217
- seg = css(createEl(), {
218
- position: 'absolute',
219
- top: 1+~(o.width/2) + 'px',
220
- transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
221
- opacity: o.opacity,
222
- animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite'
223
- })
224
1
 
225
- if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
2
+ //fgnass.github.com/spin.js#v1.3.2
3
+
4
+ /**
5
+ * Copyright (c) 2011-2013 Felix Gnass
6
+ * Licensed under the MIT license
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";
20
+
21
+ var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
22
+ ,
23
+ animations = {} /* Animation rules keyed by their name */
24
+ ,
25
+ useCssAnimations /* Whether to use CSS animations or setTimeout */
26
+
27
+ /**
28
+ * Utility function to create elements. If no tag name is given,
29
+ * a DIV is created. Optionally properties can be passed.
30
+ */
31
+ function createEl(tag, prop) {
32
+ var el = document.createElement(tag || 'div'),
33
+ n
34
+
35
+ for (n in prop) el[n] = prop[n]
36
+ return el
37
+ }
226
38
 
227
- ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)')))
228
- }
229
- return el
230
- },
39
+ /**
40
+ * Appends children and returns the parent.
41
+ */
42
+ function ins(parent /* child1, child2, ...*/ ) {
43
+ for (var i = 1, n = arguments.length; i < n; i++)
44
+ parent.appendChild(arguments[i])
231
45
 
232
- opacity: function(el, i, val) {
233
- if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
234
- }
46
+ return parent
47
+ }
235
48
 
236
- })
49
+ /**
50
+ * Insert a new stylesheet to hold the @keyframe or VML rules.
51
+ */
52
+ var sheet = (function() {
53
+ var el = createEl('style', {
54
+ type: 'text/css'
55
+ })
56
+ ins(document.getElementsByTagName('head')[0], el)
57
+ return el.sheet || el.styleSheet
58
+ }())
59
+
60
+ /**
61
+ * Creates an opacity keyframe animation rule and returns its name.
62
+ * Since most mobile Webkits have timing issues with animation-delay,
63
+ * we create separate rules for each line/segment.
64
+ */
65
+ function addAnimation(alpha, trail, i, lines) {
66
+ var name = ['opacity', trail, ~~ (alpha * 100), i, lines].join('-'),
67
+ start = 0.01 + i / lines * 100,
68
+ z = Math.max(1 - (1 - alpha) / trail * (100 - start), alpha),
69
+ prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase(),
70
+ pre = prefix && '-' + prefix + '-' || ''
71
+
72
+ if (!animations[name]) {
73
+ sheet.insertRule('@' + pre + 'keyframes ' + name + '{' + '0%{opacity:' + z + '}' + start + '%{opacity:' + alpha + '}' + (start + 0.01) + '%{opacity:1}' + (start + trail) % 100 + '%{opacity:' + alpha + '}' + '100%{opacity:' + z + '}' + '}', sheet.cssRules.length)
74
+
75
+ animations[name] = 1
76
+ }
77
+
78
+ return name
79
+ }
237
80
 
238
- /////////////////////////////////////////////////////////////////////////
239
- // VML rendering for IE
240
- /////////////////////////////////////////////////////////////////////////
81
+ /**
82
+ * Tries various vendor prefixes and returns the first supported property.
83
+ */
84
+ function vendor(el, prop) {
85
+ var s = el.style,
86
+ pp, i
87
+
88
+ prop = prop.charAt(0).toUpperCase() + prop.slice(1)
89
+ for (i = 0; i < prefixes.length; i++) {
90
+ pp = prefixes[i] + prop
91
+ if (s[pp] !== undefined) return pp
92
+ }
93
+ if (s[prop] !== undefined) return prop
94
+ }
241
95
 
242
- /**
243
- * Check and init VML support
244
- */
245
- ;(function() {
96
+ /**
97
+ * Sets multiple style properties at once.
98
+ */
99
+ function css(el, prop) {
100
+ for (var n in prop)
101
+ el.style[vendor(el, n) || n] = prop[n]
246
102
 
247
- function vml(tag, attr) {
248
- return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
249
- }
103
+ return el
104
+ }
250
105
 
251
- var s = css(createEl('group'), {behavior: 'url(#default#VML)'})
106
+ /**
107
+ * Fills in default values.
108
+ */
109
+ function merge(obj) {
110
+ for (var i = 1; i < arguments.length; i++) {
111
+ var def = arguments[i]
112
+ for (var n in def)
113
+ if (obj[n] === undefined) obj[n] = def[n]
114
+ }
115
+ return obj
116
+ }
252
117
 
253
- if (!vendor(s, 'transform') && s.adj) {
118
+ /**
119
+ * Returns the absolute page-offset of the given element.
120
+ */
121
+ function pos(el) {
122
+ var o = {
123
+ x: el.offsetLeft,
124
+ y: el.offsetTop
125
+ }
126
+ while ((el = el.offsetParent))
127
+ o.x += el.offsetLeft, o.y += el.offsetTop
128
+
129
+ return o
130
+ }
254
131
 
255
- // VML support detected. Insert CSS rule ...
256
- sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
132
+ /**
133
+ * Returns the line color from the given string or array.
134
+ */
135
+ function getColor(color, idx) {
136
+ return typeof color == 'string' ? color : color[idx % color.length]
137
+ }
257
138
 
258
- Spinner.prototype.lines = function(el, o) {
259
- var r = o.length+o.width
260
- , s = 2*r
139
+ // Built-in defaults
140
+
141
+ var defaults = {
142
+ lines: 12, // The number of lines to draw
143
+ length: 7, // The length of each line
144
+ width: 5, // The line thickness
145
+ radius: 10, // The radius of the inner circle
146
+ rotate: 0, // Rotation offset
147
+ corners: 1, // Roundness (0..1)
148
+ color: '#000', // #rgb or #rrggbb
149
+ direction: 1, // 1: clockwise, -1: counterclockwise
150
+ speed: 1, // Rounds per second
151
+ trail: 100, // Afterglow percentage
152
+ opacity: 1 / 4, // Opacity of the lines
153
+ fps: 20, // Frames per second when using setTimeout()
154
+ zIndex: 2e9, // Use a high z-index by default
155
+ className: 'spinner', // CSS class to assign to the element
156
+ top: 'auto', // center vertically
157
+ left: 'auto', // center horizontally
158
+ position: 'relative' // element position
159
+ }
261
160
 
262
- function grp() {
263
- return css(
264
- vml('group', {
265
- coordsize: s + ' ' + s,
266
- coordorigin: -r + ' ' + -r
267
- }),
268
- { width: s, height: s }
269
- )
161
+ /** The constructor */
162
+ function Spinner(o) {
163
+ if (typeof this == 'undefined') return new Spinner(o)
164
+ this.opts = merge(o || {}, Spinner.defaults, defaults)
270
165
  }
271
166
 
272
- var margin = -(o.width+o.length)*2 + 'px'
273
- , g = css(grp(), {position: 'absolute', top: margin, left: margin})
274
- , i
275
-
276
- function seg(i, dx, filter) {
277
- ins(g,
278
- ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
279
- ins(css(vml('roundrect', {arcsize: o.corners}), {
280
- width: r,
281
- height: o.width,
282
- left: o.radius,
283
- top: -o.width>>1,
284
- filter: filter
167
+ // Global defaults that override the built-ins:
168
+ Spinner.defaults = {}
169
+
170
+ merge(Spinner.prototype, {
171
+
172
+ /**
173
+ * Adds the spinner to the given target element. If this instance is already
174
+ * spinning, it is automatically removed from its previous target b calling
175
+ * stop() internally.
176
+ */
177
+ spin: function(target) {
178
+ this.stop()
179
+
180
+ var self = this,
181
+ o = self.opts,
182
+ el = self.el = css(createEl(0, {
183
+ className: o.className
184
+ }), {
185
+ position: o.position,
186
+ width: 0,
187
+ zIndex: o.zIndex
285
188
  }),
286
- vml('fill', {color: o.color, opacity: o.opacity}),
287
- vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
288
- )
289
- )
290
- )
189
+ mid = o.radius + o.length + o.width,
190
+ ep // element position
191
+ ,
192
+ tp // target position
193
+
194
+ if (target) {
195
+ target.insertBefore(el, target.firstChild || null)
196
+ tp = pos(target)
197
+ ep = pos(el)
198
+ css(el, {
199
+ left: (o.left == 'auto' ? tp.x - ep.x + (target.offsetWidth >> 1) : parseInt(o.left, 10) + mid) + 'px',
200
+ top: (o.top == 'auto' ? tp.y - ep.y + (target.offsetHeight >> 1) : parseInt(o.top, 10) + mid) + 'px'
201
+ })
202
+ }
203
+
204
+ el.setAttribute('role', 'progressbar')
205
+ self.lines(el, self.opts)
206
+
207
+ if (!useCssAnimations) {
208
+ // No CSS animation support, use setTimeout() instead
209
+ var i = 0,
210
+ start = (o.lines - 1) * (1 - o.direction) / 2,
211
+ alpha, fps = o.fps,
212
+ f = fps / o.speed,
213
+ ostep = (1 - o.opacity) / (f * o.trail / 100),
214
+ astep = f / o.lines
215
+
216
+ ;
217
+ (function anim() {
218
+ i++;
219
+ for (var j = 0; j < o.lines; j++) {
220
+ alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
221
+
222
+ self.opacity(el, j * o.direction + start, alpha, o)
223
+ }
224
+ self.timeout = self.el && setTimeout(anim, ~~ (1000 / fps))
225
+ })()
226
+ }
227
+ return self
228
+ },
229
+
230
+ /**
231
+ * Stops and removes the Spinner.
232
+ */
233
+ stop: function() {
234
+ var el = this.el
235
+ if (el) {
236
+ clearTimeout(this.timeout)
237
+ if (el.parentNode) el.parentNode.removeChild(el)
238
+ this.el = undefined
239
+ }
240
+ return this
241
+ },
242
+
243
+ /**
244
+ * Internal method that draws the individual lines. Will be overwritten
245
+ * in VML fallback mode below.
246
+ */
247
+ lines: function(el, o) {
248
+ var i = 0,
249
+ start = (o.lines - 1) * (1 - o.direction) / 2,
250
+ seg
251
+
252
+ function fill(color, shadow) {
253
+ return css(createEl(), {
254
+ position: 'absolute',
255
+ width: (o.length + o.width) + 'px',
256
+ height: o.width + 'px',
257
+ background: color,
258
+ boxShadow: shadow,
259
+ transformOrigin: 'left',
260
+ transform: 'rotate(' + ~~ (360 / o.lines * i + o.rotate) + 'deg) translate(' + o.radius + 'px' + ',0)',
261
+ borderRadius: (o.corners * o.width >> 1) + 'px'
262
+ })
263
+ }
264
+
265
+ for (; i < o.lines; i++) {
266
+ seg = css(createEl(), {
267
+ position: 'absolute',
268
+ top: 1 + ~ (o.width / 2) + 'px',
269
+ transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
270
+ opacity: o.opacity,
271
+ animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite'
272
+ })
273
+
274
+ if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {
275
+ top: 2 + 'px'
276
+ }))
277
+ ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
278
+ }
279
+ return el
280
+ },
281
+
282
+ /**
283
+ * Internal method that adjusts the opacity of a single line.
284
+ * Will be overwritten in VML fallback mode below.
285
+ */
286
+ opacity: function(el, i, val) {
287
+ if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
291
288
  }
292
289
 
293
- if (o.shadow)
294
- for (i = 1; i <= o.lines; i++)
295
- seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
290
+ })
291
+
296
292
 
297
- for (i = 1; i <= o.lines; i++) seg(i)
298
- return ins(el, g)
299
- }
293
+ function initVML() {
300
294
 
301
- Spinner.prototype.opacity = function(el, i, val, o) {
302
- var c = el.firstChild
303
- o = o.shadow && o.lines || 0
304
- if (c && i+o < c.childNodes.length) {
305
- c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
306
- if (c) c.opacity = val
295
+ /* Utility function to create a VML tag */
296
+ function vml(tag, attr) {
297
+ return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
298
+ }
299
+
300
+ // No CSS transforms but VML support, add a CSS rule for VML elements:
301
+ sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
302
+
303
+ Spinner.prototype.lines = function(el, o) {
304
+ var r = o.length + o.width,
305
+ s = 2 * r
306
+
307
+ function grp() {
308
+ return css(
309
+ vml('group', {
310
+ coordsize: s + ' ' + s,
311
+ coordorigin: -r + ' ' + -r
312
+ }), {
313
+ width: s,
314
+ height: s
315
+ })
316
+ }
317
+
318
+ var margin = -(o.width + o.length) * 2 + 'px',
319
+ g = css(grp(), {
320
+ position: 'absolute',
321
+ top: margin,
322
+ left: margin
323
+ }),
324
+ i
325
+
326
+ function seg(i, dx, filter) {
327
+ ins(g,
328
+ ins(css(grp(), {
329
+ rotation: 360 / o.lines * i + 'deg',
330
+ left: ~~dx
331
+ }),
332
+ ins(css(vml('roundrect', {
333
+ arcsize: o.corners
334
+ }), {
335
+ width: r,
336
+ height: o.width,
337
+ left: o.radius,
338
+ top: -o.width >> 1,
339
+ filter: filter
340
+ }),
341
+ vml('fill', {
342
+ color: getColor(o.color, i),
343
+ opacity: o.opacity
344
+ }),
345
+ vml('stroke', {
346
+ opacity: 0
347
+ }) // transparent stroke to fix color bleeding upon opacity change
348
+ )))
349
+ }
350
+
351
+ if (o.shadow) for (i = 1; i <= o.lines; i++)
352
+ seg(i, - 2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
353
+
354
+ for (i = 1; i <= o.lines; i++) seg(i)
355
+ return ins(el, g)
356
+ }
357
+
358
+ Spinner.prototype.opacity = function(el, i, val, o) {
359
+ var c = el.firstChild
360
+ o = o.shadow && o.lines || 0
361
+ if (c && i + o < c.childNodes.length) {
362
+ c = c.childNodes[i + o];
363
+ c = c && c.firstChild;
364
+ c = c && c.firstChild
365
+ if (c) c.opacity = val
366
+ }
307
367
  }
308
- }
309
368
  }
310
- else
311
- useCssAnimations = vendor(s, 'animation')
312
- })()
313
369
 
314
- if (typeof define == 'function' && define.amd)
315
- define(function() { return Spinner })
316
- else
317
- window.Spinner = Spinner
370
+ var probe = css(createEl('group'), {
371
+ behavior: 'url(#default#VML)'
372
+ })
373
+
374
+ if (!vendor(probe, 'transform') && probe.adj) initVML()
375
+ else useCssAnimations = vendor(probe, 'animation')
376
+
377
+ return Spinner
318
378
 
319
- }(window, document)
379
+ }));