bitsnote-assets 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/fullcalendar/fullcalendar.js +8369 -0
- data/app/assets/javascripts/fullcalendar/fullcalendar.min.js +8 -0
- data/app/assets/javascripts/moment/moment-with-locales.js +9083 -0
- data/app/assets/javascripts/moment/moment-with-locales.min.js +10 -0
- data/app/assets/javascripts/moment/moment.js +2815 -0
- data/app/assets/javascripts/moment/moment.min.js +6 -0
- data/app/assets/javascripts/pickadate/picker.date.js +1349 -0
- data/app/assets/javascripts/pickadate/picker.date.min.js +5 -0
- data/app/assets/javascripts/pickadate/picker.js +1078 -0
- data/app/assets/javascripts/pickadate/picker.min.js +7 -0
- data/app/assets/javascripts/pickadate/picker.time.js +1014 -0
- data/app/assets/javascripts/pickadate/picker.time.min.js +5 -0
- data/app/assets/javascripts/spin/spin.js +349 -0
- data/app/assets/javascripts/spin/spin.min.js +2 -0
- data/app/assets/stylesheets/fullcalendar/fullcalendar.css +933 -0
- data/app/assets/stylesheets/fullcalendar/fullcalendar.min.css +5 -0
- data/app/assets/stylesheets/fullcalendar/fullcalendar.print.css +201 -0
- data/app/assets/stylesheets/pickadate/classic.css +109 -0
- data/app/assets/stylesheets/pickadate/classic.date.css +301 -0
- data/app/assets/stylesheets/pickadate/classic.date.min.css +1 -0
- data/app/assets/stylesheets/pickadate/classic.min.css +4 -0
- data/app/assets/stylesheets/pickadate/classic.time.css +131 -0
- data/app/assets/stylesheets/pickadate/classic.time.min.css +1 -0
- data/app/assets/stylesheets/pickadate/default.css +175 -0
- data/app/assets/stylesheets/pickadate/default.date.css +301 -0
- data/app/assets/stylesheets/pickadate/default.date.min.css +1 -0
- data/app/assets/stylesheets/pickadate/default.min.css +4 -0
- data/app/assets/stylesheets/pickadate/default.time.css +125 -0
- data/app/assets/stylesheets/pickadate/default.time.min.css +1 -0
- data/app/assets/stylesheets/pickadate/rtl.css +29 -0
- data/app/assets/stylesheets/pickadate/rtl.min.css +3 -0
- data/lib/bitsnote-assets/version.rb +1 -1
- data/lib/bitsnote-assets.rb +92 -33
- data/test/dummy/app/views/layouts/application.html.erb +5 -0
- data/test/dummy/config/initializers/assets.rb +1 -1
- data/test/dummy/config/routes.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +448 -396
- data/test/dummy/tmp/cache/assets/development/sprockets/{91056193051f3741ee35672c43f02cc2 → 04a7d966f3aa1a0f5afdd96eeea4dcc8} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{bf21891f6ce2dc468abfcb9bb75c6a1e → 078a7c15de920196b676c944198be294} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{6d98f39010827cad999334e769f03398 → 20a916d3e45f4d0f19d33a8135f20e3e} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/25fca4643219052b0d5c66cf2c71f72f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/386e9196dd0f9efdce6f92ce93a6d107 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3f9170db678c4e1fdfa51752e5ec8e39 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{d34631840b4592db0d749b96ab27a620 → 43affd68874f8c6cd63f138e85ced50f} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{babe75ab5fc2c1762e161e6eaae5c30b → 4718fe4eff59abcea146c68e87a226a0} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/489af12e680adec109e506328fdc1368 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{64f399e2eee4409012ebcc8ea938419a → 59cdca5342cf01aa6f7243c6dbb51b95} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{50b9a4dd63d203039ce5b560ff2c33d7 → 6e275cec34b7a11680df0b73c4b46740} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/727150a817e8100f4a7f7475c0bdb616 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/861d9659592a81ca16c7c25ad7ceffc7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{ee10c355250f9cd7adb9593445676545 → a984c731d3729a5afd87810c979f93b3} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bbe5f5151cdf105fcaea71a26e3a0955 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d1df176743f01ba00229d3954a670e72 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{eb199fcd85e4107f4eb5d71939ea330c → e352b93f329aa1bd1679fe7be91c6a87} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e36b8fcf5914a3a6bf058abfe7367b19 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ecc916b0e46dd019c226421d5ae880c2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f242e30fcd4aeaf37980aa77bc7de0c3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f6eeb33602682bd6ff6d1f177f6b142d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- metadata +125 -66
- data/test/dummy/db/schema.rb +0 -16
- data/test/dummy/db/test.sqlite3 +0 -0
@@ -0,0 +1,5 @@
|
|
1
|
+
/*!
|
2
|
+
* Time picker for pickadate.js v3.5.3
|
3
|
+
* http://amsul.github.io/pickadate.js/time.htm
|
4
|
+
*/
|
5
|
+
!function(a){"function"==typeof define&&define.amd?define(["picker","jquery"],a):"object"==typeof exports?module.exports=a(require("./picker.js"),require("jquery")):a(Picker,jQuery)}(function(a,b){function c(a,b){var c=this,d=a.$node[0].value,e=a.$node.data("value"),f=e||d,g=e?b.formatSubmit:b.format;c.settings=b,c.$node=a.$node,c.queue={interval:"i",min:"measure create",max:"measure create",now:"now create",select:"parse create validate",highlight:"parse create validate",view:"parse create validate",disable:"deactivate",enable:"activate"},c.item={},c.item.clear=null,c.item.interval=b.interval||30,c.item.disable=(b.disable||[]).slice(0),c.item.enable=-function(a){return a[0]===!0?a.shift():-1}(c.item.disable),c.set("min",b.min).set("max",b.max).set("now"),f?c.set("select",f,{format:g,fromValue:!!d}):c.set("select",null).set("highlight",c.item.now),c.key={40:1,38:-1,39:1,37:-1,go:function(a){c.set("highlight",c.item.highlight.pick+a*c.item.interval,{interval:a*c.item.interval}),this.render()}},a.on("render",function(){var c=a.$root.children(),d=c.find("."+b.klass.viewset),e=function(a){return["webkit","moz","ms","o",""].map(function(b){return(b?"-"+b+"-":"")+a})},f=function(a,b){e("transform").map(function(c){a.css(c,b)}),e("transition").map(function(c){a.css(c,b)})};d.length&&(f(c,"none"),c[0].scrollTop=~~d.position().top-2*d[0].clientHeight,f(c,""))},1).on("open",function(){a.$root.find("button").attr("disabled",!1)},1).on("close",function(){a.$root.find("button").attr("disabled",!0)},1)}var d=24,e=60,f=12,g=d*e,h=a._;c.prototype.set=function(a,b,c){var d=this,e=d.item;return null===b?("clear"==a&&(a="select"),e[a]=b,d):(e["enable"==a?"disable":"flip"==a?"enable":a]=d.queue[a].split(" ").map(function(e){return b=d[e](a,b,c)}).pop(),"select"==a?d.set("highlight",e.select,c):"highlight"==a?d.set("view",e.highlight,c):"interval"==a?d.set("min",e.min,c).set("max",e.max,c):a.match(/^(flip|min|max|disable|enable)$/)&&("min"==a&&d.set("max",e.max,c),e.select&&d.disabled(e.select)&&d.set("select",e.select,c),e.highlight&&d.disabled(e.highlight)&&d.set("highlight",e.highlight,c)),d)},c.prototype.get=function(a){return this.item[a]},c.prototype.create=function(a,c,f){var i=this;return c=void 0===c?a:c,h.isDate(c)&&(c=[c.getHours(),c.getMinutes()]),b.isPlainObject(c)&&h.isInteger(c.pick)?c=c.pick:b.isArray(c)?c=+c[0]*e+ +c[1]:h.isInteger(c)||(c=i.now(a,c,f)),"max"==a&&c<i.item.min.pick&&(c+=g),"min"!=a&&"max"!=a&&(c-i.item.min.pick)%i.item.interval!==0&&(c+=i.item.interval),c=i.normalize(a,c,f),{hour:~~(d+c/e)%d,mins:(e+c%e)%e,time:(g+c)%g,pick:c}},c.prototype.createRange=function(a,c){var d=this,e=function(a){return a===!0||b.isArray(a)||h.isDate(a)?d.create(a):a};return h.isInteger(a)||(a=e(a)),h.isInteger(c)||(c=e(c)),h.isInteger(a)&&b.isPlainObject(c)?a=[c.hour,c.mins+a*d.settings.interval]:h.isInteger(c)&&b.isPlainObject(a)&&(c=[a.hour,a.mins+c*d.settings.interval]),{from:e(a),to:e(c)}},c.prototype.withinRange=function(a,b){return a=this.createRange(a.from,a.to),b.pick>=a.from.pick&&b.pick<=a.to.pick},c.prototype.overlapRanges=function(a,b){var c=this;return a=c.createRange(a.from,a.to),b=c.createRange(b.from,b.to),c.withinRange(a,b.from)||c.withinRange(a,b.to)||c.withinRange(b,a.from)||c.withinRange(b,a.to)},c.prototype.now=function(a,b){var c,d=this.item.interval,f=new Date,g=f.getHours()*e+f.getMinutes(),i=h.isInteger(b);return g-=g%d,c=0>b&&-d>=d*b+g,g+="min"==a&&c?0:d,i&&(g+=d*(c&&"max"!=a?b+1:b)),g},c.prototype.normalize=function(a,b){var c=this.item.interval,d=this.item.min&&this.item.min.pick||0;return b-="min"==a?0:(b-d)%c},c.prototype.measure=function(a,c,f){var g=this;return c||(c="min"==a?[0,0]:[d-1,e-1]),"string"==typeof c?c=g.parse(a,c):c===!0||h.isInteger(c)?c=g.now(a,c,f):b.isPlainObject(c)&&h.isInteger(c.pick)&&(c=g.normalize(a,c.pick,f)),c},c.prototype.validate=function(a,b,c){var d=this,e=c&&c.interval?c.interval:d.item.interval;return d.disabled(b)&&(b=d.shift(b,e)),b=d.scope(b),d.disabled(b)&&(b=d.shift(b,-1*e)),b},c.prototype.disabled=function(a){var c=this,d=c.item.disable.filter(function(d){return h.isInteger(d)?a.hour==d:b.isArray(d)||h.isDate(d)?a.pick==c.create(d).pick:b.isPlainObject(d)?c.withinRange(d,a):void 0});return d=d.length&&!d.filter(function(a){return b.isArray(a)&&"inverted"==a[2]||b.isPlainObject(a)&&a.inverted}).length,-1===c.item.enable?!d:d||a.pick<c.item.min.pick||a.pick>c.item.max.pick},c.prototype.shift=function(a,b){var c=this,d=c.item.min.pick,e=c.item.max.pick;for(b=b||c.item.interval;c.disabled(a)&&(a=c.create(a.pick+=b),!(a.pick<=d||a.pick>=e)););return a},c.prototype.scope=function(a){var b=this.item.min.pick,c=this.item.max.pick;return this.create(a.pick>c?c:a.pick<b?b:a)},c.prototype.parse=function(a,b,c){var d,f,g,i,j,k=this,l={};if(!b||"string"!=typeof b)return b;c&&c.format||(c=c||{},c.format=k.settings.format),k.formats.toArray(c.format).map(function(a){var c,d=k.formats[a],e=d?h.trigger(d,k,[b,l]):a.replace(/^!/,"").length;d&&(c=b.substr(0,e),l[a]=c.match(/^\d+$/)?+c:c),b=b.substr(e)});for(i in l)j=l[i],h.isInteger(j)?i.match(/^(h|hh)$/i)?(d=j,("h"==i||"hh"==i)&&(d%=12)):"i"==i&&(f=j):i.match(/^a$/i)&&j.match(/^p/i)&&("h"in l||"hh"in l)&&(g=!0);return(g?d+12:d)*e+f},c.prototype.formats={h:function(a,b){return a?h.digits(a):b.hour%f||f},hh:function(a,b){return a?2:h.lead(b.hour%f||f)},H:function(a,b){return a?h.digits(a):""+b.hour%24},HH:function(a,b){return a?h.digits(a):h.lead(b.hour%24)},i:function(a,b){return a?2:h.lead(b.mins)},a:function(a,b){return a?4:g/2>b.time%g?"a.m.":"p.m."},A:function(a,b){return a?2:g/2>b.time%g?"AM":"PM"},toArray:function(a){return a.split(/(h{1,2}|H{1,2}|i|a|A|!.)/g)},toString:function(a,b){var c=this;return c.formats.toArray(a).map(function(a){return h.trigger(c.formats[a],c,[0,b])||a.replace(/^!/,"")}).join("")}},c.prototype.isTimeExact=function(a,c){var d=this;return h.isInteger(a)&&h.isInteger(c)||"boolean"==typeof a&&"boolean"==typeof c?a===c:(h.isDate(a)||b.isArray(a))&&(h.isDate(c)||b.isArray(c))?d.create(a).pick===d.create(c).pick:b.isPlainObject(a)&&b.isPlainObject(c)?d.isTimeExact(a.from,c.from)&&d.isTimeExact(a.to,c.to):!1},c.prototype.isTimeOverlap=function(a,c){var d=this;return h.isInteger(a)&&(h.isDate(c)||b.isArray(c))?a===d.create(c).hour:h.isInteger(c)&&(h.isDate(a)||b.isArray(a))?c===d.create(a).hour:b.isPlainObject(a)&&b.isPlainObject(c)?d.overlapRanges(a,c):!1},c.prototype.flipEnable=function(a){var b=this.item;b.enable=a||(-1==b.enable?1:-1)},c.prototype.deactivate=function(a,c){var d=this,e=d.item.disable.slice(0);return"flip"==c?d.flipEnable():c===!1?(d.flipEnable(1),e=[]):c===!0?(d.flipEnable(-1),e=[]):c.map(function(a){for(var c,f=0;f<e.length;f+=1)if(d.isTimeExact(a,e[f])){c=!0;break}c||(h.isInteger(a)||h.isDate(a)||b.isArray(a)||b.isPlainObject(a)&&a.from&&a.to)&&e.push(a)}),e},c.prototype.activate=function(a,c){var d=this,e=d.item.disable,f=e.length;return"flip"==c?d.flipEnable():c===!0?(d.flipEnable(1),e=[]):c===!1?(d.flipEnable(-1),e=[]):c.map(function(a){var c,g,i,j;for(i=0;f>i;i+=1){if(g=e[i],d.isTimeExact(g,a)){c=e[i]=null,j=!0;break}if(d.isTimeOverlap(g,a)){b.isPlainObject(a)?(a.inverted=!0,c=a):b.isArray(a)?(c=a,c[2]||c.push("inverted")):h.isDate(a)&&(c=[a.getFullYear(),a.getMonth(),a.getDate(),"inverted"]);break}}if(c)for(i=0;f>i;i+=1)if(d.isTimeExact(e[i],a)){e[i]=null;break}if(j)for(i=0;f>i;i+=1)if(d.isTimeOverlap(e[i],a)){e[i]=null;break}c&&e.push(c)}),e.filter(function(a){return null!=a})},c.prototype.i=function(a,b){return h.isInteger(b)&&b>0?b:this.item.interval},c.prototype.nodes=function(a){var b=this,c=b.settings,d=b.item.select,e=b.item.highlight,f=b.item.view,g=b.item.disable;return h.node("ul",h.group({min:b.item.min.pick,max:b.item.max.pick,i:b.item.interval,node:"li",item:function(a){a=b.create(a);var i=a.pick,j=d&&d.pick==i,k=e&&e.pick==i,l=g&&b.disabled(a);return[h.trigger(b.formats.toString,b,[h.trigger(c.formatLabel,b,[a])||c.format,a]),function(a){return j&&a.push(c.klass.selected),k&&a.push(c.klass.highlighted),f&&f.pick==i&&a.push(c.klass.viewset),l&&a.push(c.klass.disabled),a.join(" ")}([c.klass.listItem]),"data-pick="+a.pick+" "+h.ariaAttr({role:"option",selected:j&&b.$node.val()===h.trigger(b.formats.toString,b,[c.format,a])?!0:null,activedescendant:k?!0:null,disabled:l?!0:null})]}})+h.node("li",h.node("button",c.clear,c.klass.buttonClear,"type=button data-clear=1"+(a?"":" disabled")+" "+h.ariaAttr({controls:b.$node[0].id})),"",h.ariaAttr({role:"presentation"})),c.klass.list,h.ariaAttr({role:"listbox",controls:b.$node[0].id}))},c.defaults=function(a){return{clear:"Clear",format:"h:i A",interval:30,klass:{picker:a+" "+a+"--time",holder:a+"__holder",list:a+"__list",listItem:a+"__list-item",disabled:a+"__list-item--disabled",selected:a+"__list-item--selected",highlighted:a+"__list-item--highlighted",viewset:a+"__list-item--viewset",now:a+"__list-item--now",buttonClear:a+"__button--clear"}}}(a.klasses().picker),a.extend("pickatime",c)});
|
@@ -0,0 +1,349 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2011-2014 Felix Gnass
|
3
|
+
* Licensed under the MIT license
|
4
|
+
*/
|
5
|
+
(function(root, factory) {
|
6
|
+
|
7
|
+
/* CommonJS */
|
8
|
+
if (typeof exports == 'object') module.exports = factory()
|
9
|
+
|
10
|
+
/* AMD module */
|
11
|
+
else if (typeof define == 'function' && define.amd) define(factory)
|
12
|
+
|
13
|
+
/* Browser global */
|
14
|
+
else root.Spinner = factory()
|
15
|
+
}
|
16
|
+
(this, function() {
|
17
|
+
"use strict";
|
18
|
+
|
19
|
+
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
|
20
|
+
, animations = {} /* Animation rules keyed by their name */
|
21
|
+
, useCssAnimations /* Whether to use CSS animations or setTimeout */
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Utility function to create elements. If no tag name is given,
|
25
|
+
* a DIV is created. Optionally properties can be passed.
|
26
|
+
*/
|
27
|
+
function createEl(tag, prop) {
|
28
|
+
var el = document.createElement(tag || 'div')
|
29
|
+
, n
|
30
|
+
|
31
|
+
for(n in prop) el[n] = prop[n]
|
32
|
+
return el
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Appends children and returns the parent.
|
37
|
+
*/
|
38
|
+
function ins(parent /* child1, child2, ...*/) {
|
39
|
+
for (var i=1, n=arguments.length; i<n; i++)
|
40
|
+
parent.appendChild(arguments[i])
|
41
|
+
|
42
|
+
return parent
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Insert a new stylesheet to hold the @keyframe or VML rules.
|
47
|
+
*/
|
48
|
+
var sheet = (function() {
|
49
|
+
var el = createEl('style', {type : 'text/css'})
|
50
|
+
ins(document.getElementsByTagName('head')[0], el)
|
51
|
+
return el.sheet || el.styleSheet
|
52
|
+
}())
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Creates an opacity keyframe animation rule and returns its name.
|
56
|
+
* Since most mobile Webkits have timing issues with animation-delay,
|
57
|
+
* we create separate rules for each line/segment.
|
58
|
+
*/
|
59
|
+
function addAnimation(alpha, trail, i, lines) {
|
60
|
+
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
|
61
|
+
, start = 0.01 + i/lines * 100
|
62
|
+
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
|
63
|
+
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
|
64
|
+
, pre = prefix && '-' + prefix + '-' || ''
|
65
|
+
|
66
|
+
if (!animations[name]) {
|
67
|
+
sheet.insertRule(
|
68
|
+
'@' + pre + 'keyframes ' + name + '{' +
|
69
|
+
'0%{opacity:' + z + '}' +
|
70
|
+
start + '%{opacity:' + alpha + '}' +
|
71
|
+
(start+0.01) + '%{opacity:1}' +
|
72
|
+
(start+trail) % 100 + '%{opacity:' + alpha + '}' +
|
73
|
+
'100%{opacity:' + z + '}' +
|
74
|
+
'}', sheet.cssRules.length)
|
75
|
+
|
76
|
+
animations[name] = 1
|
77
|
+
}
|
78
|
+
|
79
|
+
return name
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Tries various vendor prefixes and returns the first supported property.
|
84
|
+
*/
|
85
|
+
function vendor(el, prop) {
|
86
|
+
var s = el.style
|
87
|
+
, pp
|
88
|
+
, i
|
89
|
+
|
90
|
+
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
|
91
|
+
for(i=0; i<prefixes.length; i++) {
|
92
|
+
pp = prefixes[i]+prop
|
93
|
+
if(s[pp] !== undefined) return pp
|
94
|
+
}
|
95
|
+
if(s[prop] !== undefined) return prop
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Sets multiple style properties at once.
|
100
|
+
*/
|
101
|
+
function css(el, prop) {
|
102
|
+
for (var n in prop)
|
103
|
+
el.style[vendor(el, n)||n] = prop[n]
|
104
|
+
|
105
|
+
return el
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Fills in default values.
|
110
|
+
*/
|
111
|
+
function merge(obj) {
|
112
|
+
for (var i=1; i < arguments.length; i++) {
|
113
|
+
var def = arguments[i]
|
114
|
+
for (var n in def)
|
115
|
+
if (obj[n] === undefined) obj[n] = def[n]
|
116
|
+
}
|
117
|
+
return obj
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Returns the absolute page-offset of the given element.
|
122
|
+
*/
|
123
|
+
function pos(el) {
|
124
|
+
var o = { x:el.offsetLeft, y:el.offsetTop }
|
125
|
+
while((el = el.offsetParent))
|
126
|
+
o.x+=el.offsetLeft, o.y+=el.offsetTop
|
127
|
+
|
128
|
+
return o
|
129
|
+
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Returns the line color from the given string or array.
|
133
|
+
*/
|
134
|
+
function getColor(color, idx) {
|
135
|
+
return typeof color == 'string' ? color : color[idx % color.length]
|
136
|
+
}
|
137
|
+
|
138
|
+
// Built-in defaults
|
139
|
+
|
140
|
+
var defaults = {
|
141
|
+
lines: 12, // The number of lines to draw
|
142
|
+
length: 7, // The length of each line
|
143
|
+
width: 5, // The line thickness
|
144
|
+
radius: 10, // The radius of the inner circle
|
145
|
+
rotate: 0, // Rotation offset
|
146
|
+
corners: 1, // Roundness (0..1)
|
147
|
+
color: '#000', // #rgb or #rrggbb
|
148
|
+
direction: 1, // 1: clockwise, -1: counterclockwise
|
149
|
+
speed: 1, // Rounds per second
|
150
|
+
trail: 100, // Afterglow percentage
|
151
|
+
opacity: 1/4, // Opacity of the lines
|
152
|
+
fps: 20, // Frames per second when using setTimeout()
|
153
|
+
zIndex: 2e9, // Use a high z-index by default
|
154
|
+
className: 'spinner', // CSS class to assign to the element
|
155
|
+
top: '50%', // center vertically
|
156
|
+
left: '50%', // center horizontally
|
157
|
+
position: 'absolute' // element position
|
158
|
+
}
|
159
|
+
|
160
|
+
/** The constructor */
|
161
|
+
function Spinner(o) {
|
162
|
+
this.opts = merge(o || {}, Spinner.defaults, defaults)
|
163
|
+
}
|
164
|
+
|
165
|
+
// Global defaults that override the built-ins:
|
166
|
+
Spinner.defaults = {}
|
167
|
+
|
168
|
+
merge(Spinner.prototype, {
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Adds the spinner to the given target element. If this instance is already
|
172
|
+
* spinning, it is automatically removed from its previous target b calling
|
173
|
+
* stop() internally.
|
174
|
+
*/
|
175
|
+
spin: function(target) {
|
176
|
+
this.stop()
|
177
|
+
|
178
|
+
var self = this
|
179
|
+
, o = self.opts
|
180
|
+
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
|
181
|
+
, mid = o.radius+o.length+o.width
|
182
|
+
|
183
|
+
css(el, {
|
184
|
+
left: o.left,
|
185
|
+
top: o.top
|
186
|
+
})
|
187
|
+
|
188
|
+
if (target) {
|
189
|
+
target.insertBefore(el, target.firstChild||null)
|
190
|
+
}
|
191
|
+
|
192
|
+
el.setAttribute('role', 'progressbar')
|
193
|
+
self.lines(el, self.opts)
|
194
|
+
|
195
|
+
if (!useCssAnimations) {
|
196
|
+
// No CSS animation support, use setTimeout() instead
|
197
|
+
var i = 0
|
198
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
199
|
+
, alpha
|
200
|
+
, fps = o.fps
|
201
|
+
, f = fps/o.speed
|
202
|
+
, ostep = (1-o.opacity) / (f*o.trail / 100)
|
203
|
+
, astep = f/o.lines
|
204
|
+
|
205
|
+
;(function anim() {
|
206
|
+
i++;
|
207
|
+
for (var j = 0; j < o.lines; j++) {
|
208
|
+
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
|
209
|
+
|
210
|
+
self.opacity(el, j * o.direction + start, alpha, o)
|
211
|
+
}
|
212
|
+
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
|
213
|
+
})()
|
214
|
+
}
|
215
|
+
return self
|
216
|
+
},
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Stops and removes the Spinner.
|
220
|
+
*/
|
221
|
+
stop: function() {
|
222
|
+
var el = this.el
|
223
|
+
if (el) {
|
224
|
+
clearTimeout(this.timeout)
|
225
|
+
if (el.parentNode) el.parentNode.removeChild(el)
|
226
|
+
this.el = undefined
|
227
|
+
}
|
228
|
+
return this
|
229
|
+
},
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Internal method that draws the individual lines. Will be overwritten
|
233
|
+
* in VML fallback mode below.
|
234
|
+
*/
|
235
|
+
lines: function(el, o) {
|
236
|
+
var i = 0
|
237
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
238
|
+
, seg
|
239
|
+
|
240
|
+
function fill(color, shadow) {
|
241
|
+
return css(createEl(), {
|
242
|
+
position: 'absolute',
|
243
|
+
width: (o.length+o.width) + 'px',
|
244
|
+
height: o.width + 'px',
|
245
|
+
background: color,
|
246
|
+
boxShadow: shadow,
|
247
|
+
transformOrigin: 'left',
|
248
|
+
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
|
249
|
+
borderRadius: (o.corners * o.width>>1) + 'px'
|
250
|
+
})
|
251
|
+
}
|
252
|
+
|
253
|
+
for (; i < o.lines; i++) {
|
254
|
+
seg = css(createEl(), {
|
255
|
+
position: 'absolute',
|
256
|
+
top: 1+~(o.width/2) + 'px',
|
257
|
+
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
|
258
|
+
opacity: o.opacity,
|
259
|
+
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
|
260
|
+
})
|
261
|
+
|
262
|
+
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
|
263
|
+
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
|
264
|
+
}
|
265
|
+
return el
|
266
|
+
},
|
267
|
+
|
268
|
+
/**
|
269
|
+
* Internal method that adjusts the opacity of a single line.
|
270
|
+
* Will be overwritten in VML fallback mode below.
|
271
|
+
*/
|
272
|
+
opacity: function(el, i, val) {
|
273
|
+
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
|
274
|
+
}
|
275
|
+
|
276
|
+
})
|
277
|
+
|
278
|
+
|
279
|
+
function initVML() {
|
280
|
+
|
281
|
+
/* Utility function to create a VML tag */
|
282
|
+
function vml(tag, attr) {
|
283
|
+
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
|
284
|
+
}
|
285
|
+
|
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
|
+
}
|
302
|
+
|
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: getColor(o.color, i), opacity: o.opacity}),
|
318
|
+
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
|
319
|
+
)
|
320
|
+
)
|
321
|
+
)
|
322
|
+
}
|
323
|
+
|
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)')
|
327
|
+
|
328
|
+
for (i = 1; i <= o.lines; i++) seg(i)
|
329
|
+
return ins(el, g)
|
330
|
+
}
|
331
|
+
|
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
|
338
|
+
}
|
339
|
+
}
|
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')
|
346
|
+
|
347
|
+
return Spinner
|
348
|
+
|
349
|
+
}));
|
@@ -0,0 +1,2 @@
|
|
1
|
+
//fgnass.github.com/spin.js#v2.0.1
|
2
|
+
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return l[e]||(m.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",m.cssRules.length),l[e]=1),e}function d(a,b){var c,d,e=a.style;for(b=b.charAt(0).toUpperCase()+b.slice(1),d=0;d<k.length;d++)if(c=k[d]+b,void 0!==e[c])return c;return void 0!==e[b]?b:void 0}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}m.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.width,left:d.radius,top:-d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.length+d.width,k=2*j,l=2*-(d.width+d.length)+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k=["webkit","Moz","ms","O"],l={},m=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}(),n={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",position:"absolute"};h.defaults={},f(h.prototype,{spin:function(b){this.stop();{var c=this,d=c.opts,f=c.el=e(a(0,{className:d.className}),{position:d.position,width:0,zIndex:d.zIndex});d.radius+d.length+d.width}if(e(f,{left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.length+f.width+"px",height:f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.radius+"px,0)",borderRadius:(f.corners*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}});var o=e(a("group"),{behavior:"url(#default#VML)"});return!d(o,"transform")&&o.adj?i():j=d(o,"animation"),h});
|