outpost-cms 0.1.1 → 0.1.2

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