Browse Source

rectify

master
Jaryl Chng 1 year ago
parent
commit
43495fc955
655 changed files with 115437 additions and 0 deletions
  1. +11
    -0
      .gitlab-ci.yml
  2. +45
    -0
      public/bower_components/PACE/.bower.json
  3. +8
    -0
      public/bower_components/PACE/LICENSE
  4. +27
    -0
      public/bower_components/PACE/README.md
  5. +35
    -0
      public/bower_components/PACE/bower.json
  6. +86
    -0
      public/bower_components/PACE/install.json
  7. +755
    -0
      public/bower_components/PACE/pace.coffee
  8. +935
    -0
      public/bower_components/PACE/pace.js
  9. +2
    -0
      public/bower_components/PACE/pace.min.js
  10. +83
    -0
      public/bower_components/PACE/themes/black/pace-theme-barber-shop.css
  11. +40
    -0
      public/bower_components/PACE/themes/black/pace-theme-big-counter.css
  12. +231
    -0
      public/bower_components/PACE/themes/black/pace-theme-bounce.css
  13. +131
    -0
      public/bower_components/PACE/themes/black/pace-theme-center-atom.css
  14. +90
    -0
      public/bower_components/PACE/themes/black/pace-theme-center-circle.css
  15. +74
    -0
      public/bower_components/PACE/themes/black/pace-theme-center-radar.css
  16. +52
    -0
      public/bower_components/PACE/themes/black/pace-theme-center-simple.css
  17. +73
    -0
      public/bower_components/PACE/themes/black/pace-theme-corner-indicator.css
  18. +22
    -0
      public/bower_components/PACE/themes/black/pace-theme-fill-left.css
  19. +77
    -0
      public/bower_components/PACE/themes/black/pace-theme-flash.css
  20. +41
    -0
      public/bower_components/PACE/themes/black/pace-theme-flat-top.css
  21. +198
    -0
      public/bower_components/PACE/themes/black/pace-theme-loading-bar.css
  22. +87
    -0
      public/bower_components/PACE/themes/black/pace-theme-mac-osx.css
  23. +23
    -0
      public/bower_components/PACE/themes/black/pace-theme-minimal.css
  24. +83
    -0
      public/bower_components/PACE/themes/blue/pace-theme-barber-shop.css
  25. +40
    -0
      public/bower_components/PACE/themes/blue/pace-theme-big-counter.css
  26. +231
    -0
      public/bower_components/PACE/themes/blue/pace-theme-bounce.css
  27. +131
    -0
      public/bower_components/PACE/themes/blue/pace-theme-center-atom.css
  28. +90
    -0
      public/bower_components/PACE/themes/blue/pace-theme-center-circle.css
  29. +74
    -0
      public/bower_components/PACE/themes/blue/pace-theme-center-radar.css
  30. +52
    -0
      public/bower_components/PACE/themes/blue/pace-theme-center-simple.css
  31. +73
    -0
      public/bower_components/PACE/themes/blue/pace-theme-corner-indicator.css
  32. +22
    -0
      public/bower_components/PACE/themes/blue/pace-theme-fill-left.css
  33. +77
    -0
      public/bower_components/PACE/themes/blue/pace-theme-flash.css
  34. +41
    -0
      public/bower_components/PACE/themes/blue/pace-theme-flat-top.css
  35. +198
    -0
      public/bower_components/PACE/themes/blue/pace-theme-loading-bar.css
  36. +87
    -0
      public/bower_components/PACE/themes/blue/pace-theme-mac-osx.css
  37. +23
    -0
      public/bower_components/PACE/themes/blue/pace-theme-minimal.css
  38. +83
    -0
      public/bower_components/PACE/themes/green/pace-theme-barber-shop.css
  39. +40
    -0
      public/bower_components/PACE/themes/green/pace-theme-big-counter.css
  40. +231
    -0
      public/bower_components/PACE/themes/green/pace-theme-bounce.css
  41. +131
    -0
      public/bower_components/PACE/themes/green/pace-theme-center-atom.css
  42. +90
    -0
      public/bower_components/PACE/themes/green/pace-theme-center-circle.css
  43. +74
    -0
      public/bower_components/PACE/themes/green/pace-theme-center-radar.css
  44. +52
    -0
      public/bower_components/PACE/themes/green/pace-theme-center-simple.css
  45. +73
    -0
      public/bower_components/PACE/themes/green/pace-theme-corner-indicator.css
  46. +22
    -0
      public/bower_components/PACE/themes/green/pace-theme-fill-left.css
  47. +77
    -0
      public/bower_components/PACE/themes/green/pace-theme-flash.css
  48. +41
    -0
      public/bower_components/PACE/themes/green/pace-theme-flat-top.css
  49. +198
    -0
      public/bower_components/PACE/themes/green/pace-theme-loading-bar.css
  50. +87
    -0
      public/bower_components/PACE/themes/green/pace-theme-mac-osx.css
  51. +23
    -0
      public/bower_components/PACE/themes/green/pace-theme-minimal.css
  52. +83
    -0
      public/bower_components/PACE/themes/orange/pace-theme-barber-shop.css
  53. +40
    -0
      public/bower_components/PACE/themes/orange/pace-theme-big-counter.css
  54. +231
    -0
      public/bower_components/PACE/themes/orange/pace-theme-bounce.css
  55. +131
    -0
      public/bower_components/PACE/themes/orange/pace-theme-center-atom.css
  56. +90
    -0
      public/bower_components/PACE/themes/orange/pace-theme-center-circle.css
  57. +74
    -0
      public/bower_components/PACE/themes/orange/pace-theme-center-radar.css
  58. +52
    -0
      public/bower_components/PACE/themes/orange/pace-theme-center-simple.css
  59. +73
    -0
      public/bower_components/PACE/themes/orange/pace-theme-corner-indicator.css
  60. +22
    -0
      public/bower_components/PACE/themes/orange/pace-theme-fill-left.css
  61. +77
    -0
      public/bower_components/PACE/themes/orange/pace-theme-flash.css
  62. +41
    -0
      public/bower_components/PACE/themes/orange/pace-theme-flat-top.css
  63. +198
    -0
      public/bower_components/PACE/themes/orange/pace-theme-loading-bar.css
  64. +87
    -0
      public/bower_components/PACE/themes/orange/pace-theme-mac-osx.css
  65. +23
    -0
      public/bower_components/PACE/themes/orange/pace-theme-minimal.css
  66. +83
    -0
      public/bower_components/PACE/themes/pink/pace-theme-barber-shop.css
  67. +40
    -0
      public/bower_components/PACE/themes/pink/pace-theme-big-counter.css
  68. +231
    -0
      public/bower_components/PACE/themes/pink/pace-theme-bounce.css
  69. +131
    -0
      public/bower_components/PACE/themes/pink/pace-theme-center-atom.css
  70. +90
    -0
      public/bower_components/PACE/themes/pink/pace-theme-center-circle.css
  71. +74
    -0
      public/bower_components/PACE/themes/pink/pace-theme-center-radar.css
  72. +52
    -0
      public/bower_components/PACE/themes/pink/pace-theme-center-simple.css
  73. +73
    -0
      public/bower_components/PACE/themes/pink/pace-theme-corner-indicator.css
  74. +22
    -0
      public/bower_components/PACE/themes/pink/pace-theme-fill-left.css
  75. +77
    -0
      public/bower_components/PACE/themes/pink/pace-theme-flash.css
  76. +41
    -0
      public/bower_components/PACE/themes/pink/pace-theme-flat-top.css
  77. +198
    -0
      public/bower_components/PACE/themes/pink/pace-theme-loading-bar.css
  78. +87
    -0
      public/bower_components/PACE/themes/pink/pace-theme-mac-osx.css
  79. +23
    -0
      public/bower_components/PACE/themes/pink/pace-theme-minimal.css
  80. +83
    -0
      public/bower_components/PACE/themes/purple/pace-theme-barber-shop.css
  81. +40
    -0
      public/bower_components/PACE/themes/purple/pace-theme-big-counter.css
  82. +231
    -0
      public/bower_components/PACE/themes/purple/pace-theme-bounce.css
  83. +131
    -0
      public/bower_components/PACE/themes/purple/pace-theme-center-atom.css
  84. +90
    -0
      public/bower_components/PACE/themes/purple/pace-theme-center-circle.css
  85. +74
    -0
      public/bower_components/PACE/themes/purple/pace-theme-center-radar.css
  86. +52
    -0
      public/bower_components/PACE/themes/purple/pace-theme-center-simple.css
  87. +73
    -0
      public/bower_components/PACE/themes/purple/pace-theme-corner-indicator.css
  88. +22
    -0
      public/bower_components/PACE/themes/purple/pace-theme-fill-left.css
  89. +77
    -0
      public/bower_components/PACE/themes/purple/pace-theme-flash.css
  90. +41
    -0
      public/bower_components/PACE/themes/purple/pace-theme-flat-top.css
  91. +198
    -0
      public/bower_components/PACE/themes/purple/pace-theme-loading-bar.css
  92. +87
    -0
      public/bower_components/PACE/themes/purple/pace-theme-mac-osx.css
  93. +23
    -0
      public/bower_components/PACE/themes/purple/pace-theme-minimal.css
  94. +83
    -0
      public/bower_components/PACE/themes/red/pace-theme-barber-shop.css
  95. +40
    -0
      public/bower_components/PACE/themes/red/pace-theme-big-counter.css
  96. +231
    -0
      public/bower_components/PACE/themes/red/pace-theme-bounce.css
  97. +131
    -0
      public/bower_components/PACE/themes/red/pace-theme-center-atom.css
  98. +90
    -0
      public/bower_components/PACE/themes/red/pace-theme-center-circle.css
  99. +74
    -0
      public/bower_components/PACE/themes/red/pace-theme-center-radar.css
  100. +52
    -0
      public/bower_components/PACE/themes/red/pace-theme-center-simple.css

+ 11
- 0
.gitlab-ci.yml View File

@ -0,0 +1,11 @@
image: alpine:latest
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- public
only:
- master

+ 45
- 0
public/bower_components/PACE/.bower.json View File

@ -0,0 +1,45 @@
{
"name": "PACE",
"main": "pace.js",
"version": "1.0.2",
"homepage": "http://github.hubspot.com/pace/docs/welcome",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
"Adam Schwartz <adam.flynn.schwartz@gmail.com>"
],
"description": "Automatic page load progress bar",
"keywords": [
"loading",
"load",
"pageload",
"progress",
"activity",
"ajax",
"spinner",
"progress",
"bar",
"automatic",
"client-side"
],
"license": "MIT",
"ignore": [
".*",
"Gruntfile.coffee",
"bower_components",
"docs",
"node_modules",
"package.json",
"templates",
"tests"
],
"_release": "1.0.2",
"_resolution": {
"type": "version",
"tag": "v1.0.2",
"commit": "c6846cbf6b928e9903b569269fa9fbf32f2554f4"
},
"_source": "https://github.com/HubSpot/pace.git",
"_target": "^1.0.2",
"_originalSource": "pace",
"_direct": true
}

+ 8
- 0
public/bower_components/PACE/LICENSE View File

@ -0,0 +1,8 @@
Copyright (c) 2013 HubSpot, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 27
- 0
public/bower_components/PACE/README.md View File

@ -0,0 +1,27 @@
pace
====
<a href="https://eager.io/app/kYKTiQjoVjQk/install?source=button">
<img src="https://install.eager.io/install-button.png" border="0" width="126">
</a>
An automatic web page progress bar.
Include [pace.js](https://raw.github.com/HubSpot/pace/v1.0.2/pace.min.js) and a [theme](http://github.hubspot.com/pace/docs/welcome/) of your choice to your page and you are done!
Pace will automatically monitor your Ajax requests, event loop lag, document ready state and elements on your page to decide on the progress.
If you use AMD or Browserify, require pace.js and call `pace.start()` as early in the loading process as is possible.
### [Demo](http://github.hubspot.com/pace/docs/welcome/)
### [Documentation](http://github.hubspot.com/pace/)
### Example
```html
<head>
<script src="/pace/pace.js"></script>
<link href="/pace/themes/pace-theme-barber-shop.css" rel="stylesheet" />
</head>
```

+ 35
- 0
public/bower_components/PACE/bower.json View File

@ -0,0 +1,35 @@
{
"name": "PACE",
"main": "pace.js",
"version": "1.0.2",
"homepage": "http://github.hubspot.com/pace/docs/welcome",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
"Adam Schwartz <adam.flynn.schwartz@gmail.com>"
],
"description": "Automatic page load progress bar",
"keywords": [
"loading",
"load",
"pageload",
"progress",
"activity",
"ajax",
"spinner",
"progress",
"bar",
"automatic",
"client-side"
],
"license": "MIT",
"ignore": [
".*",
"Gruntfile.coffee",
"bower_components",
"docs",
"node_modules",
"package.json",
"templates",
"tests"
]
}

+ 86
- 0
public/bower_components/PACE/install.json View File

@ -0,0 +1,86 @@
{
"resources": {
"head": [
{
"type": "script",
"src": "./pace.js",
"moduleType": "global",
"exports": ["Pace"]
},
{
"type": "style",
"src": "./themes/{{ options.color }}/pace-theme-{{ options.theme }}.css"
}
]
},
"options": {
"properties": {
"color": {
"title": "Color",
"type": "string",
"enum": [
"black",
"white",
"silver",
"red",
"orange",
"yellow",
"green",
"blue",
"pink",
"purple"
],
"enumNames": {
"black": "Black",
"white": "White",
"silver": "Silver",
"red": "Red",
"orange": "Orange",
"yellow": "Yellow",
"green": "Green",
"blue": "Blue",
"pink": "Pink",
"purple": "Purple"
},
"default": "blue"
},
"theme": {
"title": "Theme",
"type": "string",
"enum": [
"barber-shop",
"big-counter",
"bounce",
"center-atom",
"center-circle",
"center-radar",
"center-simple",
"corner-indicator",
"fill-left",
"flash",
"flat-top",
"loading-bar",
"mac-osx",
"minimal"
],
"enumNames": {
"barber-shop": "Barber Shop",
"big-counter": "Big Counter",
"bounce": "Bounce",
"center-atom": "Center Atom",
"center-circle": "Center Circle",
"center-radar": "Center Radar",
"center-simple": "Center Simple",
"corner-indicator": "Corner Indicator",
"fill-left": "Fill Left",
"flash": "Flash",
"flat-top": "Flat Top",
"loading-bar": "Loading Bar",
"mac-osx": "Mac OS X",
"minimal": "Minimal"
},
"default": "barber-shop"
}
}
}
}

+ 755
- 0
public/bower_components/PACE/pace.coffee View File

@ -0,0 +1,755 @@
defaultOptions =
# How long should it take for the bar to animate to a new
# point after receiving it
catchupTime: 100
# How quickly should the bar be moving before it has any progress
# info from a new source in %/ms
initialRate: .03
# What is the minimum amount of time the bar should be on the
# screen. Irrespective of this number, the bar will always be on screen for
# 33 * (100 / maxProgressPerFrame) + ghostTime ms.
minTime: 250
# What is the minimum amount of time the bar should sit after the last
# update before disappearing
ghostTime: 100
# Its easy for a bunch of the bar to be eaten in the first few frames
# before we know how much there is to load. This limits how much of
# the bar can be used per frame
maxProgressPerFrame: 20
# This tweaks the animation easing
easeFactor: 1.25
# Should pace automatically start when the page is loaded, or should it wait for `start` to
# be called? Always false if pace is loaded with AMD or CommonJS.
startOnPageLoad: true
# Should we restart the browser when pushState or replaceState is called? (Generally
# means ajax navigation has occured)
restartOnPushState: true
# Should we show the progress bar for every ajax request (not just regular or ajax-y page
# navigation)? Set to false to disable.
#
# If so, how many ms does the request have to be running for before we show the progress?
restartOnRequestAfter: 500
# What element should the pace element be appended to on the page?
target: 'body'
elements:
# How frequently in ms should we check for the elements being tested for
# using the element monitor?
checkInterval: 100
# What elements should we wait for before deciding the page is fully loaded (not required)
selectors: ['body']
eventLag:
# When we first start measuring event lag, not much is going on in the browser yet, so it's
# not uncommon for the numbers to be abnormally low for the first few samples. This configures
# how many samples we need before we consider a low number to mean completion.
minSamples: 10
# How many samples should we average to decide what the current lag is?
sampleCount: 3
# Above how many ms of lag is the CPU considered busy?
lagThreshold: 3
ajax:
# Which HTTP methods should we track?
trackMethods: ['GET']
# Should we track web socket connections?
trackWebSockets: true
# A list of regular expressions or substrings of URLS we should ignore (for both tracking and restarting)
ignoreURLs: []
now = ->
performance?.now?() ? +new Date
requestAnimationFrame = window.requestAnimationFrame or window.mozRequestAnimationFrame or
window.webkitRequestAnimationFrame or window.msRequestAnimationFrame
cancelAnimationFrame = window.cancelAnimationFrame or window.mozCancelAnimationFrame
if not requestAnimationFrame?
requestAnimationFrame = (fn) ->
setTimeout fn, 50
cancelAnimationFrame = (id) ->
clearTimeout id
runAnimation = (fn) ->
last = now()
tick = ->
diff = now() - last
if diff >= 33
# Don't run faster than 30 fps
last = now()
fn diff, ->
requestAnimationFrame tick
else
setTimeout tick, (33 - diff)
tick()
result = (obj, key, args...) ->
if typeof obj[key] is 'function'
obj[key](args...)
else
obj[key]
extend = (out, sources...) ->
for source in sources when source
for own key, val of source
if out[key]? and typeof out[key] is 'object' and val? and typeof val is 'object'
extend(out[key], val)
else
out[key] = val
out
avgAmplitude = (arr) ->
sum = count = 0
for v in arr
sum += Math.abs(v)
count++
sum / count
getFromDOM = (key='options', json=true) ->
el = document.querySelector "[data-pace-#{ key }]"
return unless el
data = el.getAttribute "data-pace-#{ key }"
return data if not json
try
return JSON.parse data
catch e
console?.error "Error parsing inline pace options", e
class Evented
on: (event, handler, ctx, once=false) ->
@bindings ?= {}
@bindings[event] ?= []
@bindings[event].push {handler, ctx, once}
once: (event, handler, ctx) ->
@on(event, handler, ctx, true)
off: (event, handler) ->
return unless @bindings?[event]?
if not handler?
delete @bindings[event]
else
i = 0
while i < @bindings[event].length
if @bindings[event][i].handler is handler
@bindings[event].splice i, 1
else
i++
trigger: (event, args...) ->
if @bindings?[event]
i = 0
while i < @bindings[event].length
{handler, ctx, once} = @bindings[event][i]
handler.apply(ctx ? @, args)
if once
@bindings[event].splice i, 1
else
i++
Pace = window.Pace or {}
window.Pace = Pace
extend Pace, Evented::
options = Pace.options = extend {}, defaultOptions, window.paceOptions, getFromDOM()
for source in ['ajax', 'document', 'eventLag', 'elements']
# true enables them without configuration, so we grab the config from the defaults
if options[source] is true
options[source] = defaultOptions[source]
class NoTargetError extends Error
class Bar
constructor: ->
@progress = 0
getElement: ->
if not @el?
targetElement = document.querySelector options.target
if not targetElement
throw new NoTargetError
@el = document.createElement 'div'
@el.className = "pace pace-active"
document.body.className = document.body.className.replace /pace-done/g, ''
document.body.className += ' pace-running'
@el.innerHTML = '''
<div class="pace-progress">
<div class="pace-progress-inner"></div>
</div>
<div class="pace-activity"></div>
'''
if targetElement.firstChild?
targetElement.insertBefore @el, targetElement.firstChild
else
targetElement.appendChild @el
@el
finish: ->
el = @getElement()
el.className = el.className.replace 'pace-active', ''
el.className += ' pace-inactive'
document.body.className = document.body.className.replace 'pace-running', ''
document.body.className += ' pace-done'
update: (prog) ->
@progress = prog
do @render
destroy: ->
try
@getElement().parentNode.removeChild(@getElement())
catch NoTargetError
@el = undefined
render: ->
if not document.querySelector(options.target)?
return false
el = @getElement()
transform = "translate3d(#{ @progress }%, 0, 0)"
for key in ['webkitTransform', 'msTransform', 'transform']
el.children[0].style[key] = transform
if not @lastRenderedProgress or @lastRenderedProgress|0 != @progress|0
# The whole-part of the number has changed
el.children[0].setAttribute 'data-progress-text', "#{ @progress|0 }%"
if @progress >= 100
# We cap it at 99 so we can use prefix-based attribute selectors
progressStr = '99'
else
progressStr = if @progress < 10 then "0" else ""
progressStr += @progress|0
el.children[0].setAttribute 'data-progress', "#{ progressStr }"
@lastRenderedProgress = @progress
done: ->
@progress >= 100
class Events
constructor: ->
@bindings = {}
trigger: (name, val) ->
if @bindings[name]?
for binding in @bindings[name]
binding.call @, val
on: (name, fn) ->
@bindings[name] ?= []
@bindings[name].push fn
_XMLHttpRequest = window.XMLHttpRequest
_XDomainRequest = window.XDomainRequest
_WebSocket = window.WebSocket
extendNative = (to, from) ->
for key of from::
try
if not to[key]? and typeof from[key] isnt 'function'
if typeof Object.defineProperty is 'function'
Object.defineProperty(to, key, {
get: ->
return from::[key];
,
configurable: true,
enumerable: true })
else
to[key] = from::[key]
catch e
ignoreStack = []
Pace.ignore = (fn, args...) ->
ignoreStack.unshift 'ignore'
ret = fn(args...)
ignoreStack.shift()
ret
Pace.track = (fn, args...) ->
ignoreStack.unshift 'track'
ret = fn(args...)
ignoreStack.shift()
ret
shouldTrack = (method='GET') ->
if ignoreStack[0] is 'track'
return 'force'
if not ignoreStack.length and options.ajax
if method is 'socket' and options.ajax.trackWebSockets
return true
else if method.toUpperCase() in options.ajax.trackMethods
return true
return false
# We should only ever instantiate one of these
class RequestIntercept extends Events
constructor: ->
super
monitorXHR = (req) =>
_open = req.open
req.open = (type, url, async) =>
if shouldTrack(type)
@trigger 'request', {type, url, request: req}
_open.apply req, arguments
window.XMLHttpRequest = (flags) ->
req = new _XMLHttpRequest(flags)
monitorXHR req
req
try
extendNative window.XMLHttpRequest, _XMLHttpRequest
if _XDomainRequest?
window.XDomainRequest = ->
req = new _XDomainRequest
monitorXHR req
req
try
extendNative window.XDomainRequest, _XDomainRequest
if _WebSocket? and options.ajax.trackWebSockets
window.WebSocket = (url, protocols) =>
if protocols?
req = new _WebSocket(url, protocols)
else
req = new _WebSocket(url)
if shouldTrack('socket')
@trigger 'request', {type: 'socket', url, protocols, request: req}
req
try
extendNative window.WebSocket, _WebSocket
_intercept = null
getIntercept = ->
if not _intercept?
_intercept = new RequestIntercept
_intercept
shouldIgnoreURL = (url) ->
for pattern in options.ajax.ignoreURLs
if typeof pattern is 'string'
if url.indexOf(pattern) isnt -1
return true
else
if pattern.test(url)
return true
return false
# If we want to start the progress bar
# on every request, we need to hear the request
# and then inject it into the new ajax monitor
# start will have created.
getIntercept().on 'request', ({type, request, url}) ->
return if shouldIgnoreURL(url)
if not Pace.running and (options.restartOnRequestAfter isnt false or shouldTrack(type) is 'force')
args = arguments
after = options.restartOnRequestAfter or 0
if typeof after is 'boolean'
after = 0
setTimeout ->
if type is 'socket'
stillActive = request.readyState < 2
else
stillActive = 0 < request.readyState < 4
if stillActive
Pace.restart()
for source in Pace.sources
if source instanceof AjaxMonitor
source.watch args...
break
, after
class AjaxMonitor
constructor: ->
@elements = []
getIntercept().on 'request', => @watch arguments...
watch: ({type, request, url}) ->
return if shouldIgnoreURL(url)
if type is 'socket'
tracker = new SocketRequestTracker(request)
else
tracker = new XHRRequestTracker(request)
@elements.push tracker
class XHRRequestTracker
constructor: (request) ->
@progress = 0
if window.ProgressEvent?
# We're dealing with a modern browser with progress event support
size = null
request.addEventListener 'progress', (evt) =>
if evt.lengthComputable
@progress = 100 * evt.loaded / evt.total
else
# If it's chunked encoding, we have no way of knowing the total length of the
# response, all we can do is increment the progress with backoff such that we
# never hit 100% until it's done.
@progress = @progress + (100 - @progress) / 2
, false
for event in ['load', 'abort', 'timeout', 'error']
request.addEventListener event, =>
@progress = 100
, false
else
_onreadystatechange = request.onreadystatechange
request.onreadystatechange = =>
if request.readyState in [0, 4]
@progress = 100
else if request.readyState is 3
@progress = 50
_onreadystatechange?(arguments...)
class SocketRequestTracker
constructor: (request) ->
@progress = 0
for event in ['error', 'open']
request.addEventListener event, =>
@progress = 100
, false
class ElementMonitor
constructor: (options={}) ->
@elements = []
options.selectors ?= []
for selector in options.selectors
@elements.push new ElementTracker selector
class ElementTracker
constructor: (@selector) ->
@progress = 0
@check()
check: ->
if document.querySelector(@selector)
@done()
else
setTimeout (=> @check()),
options.elements.checkInterval
done: ->
@progress = 100
class DocumentMonitor
states:
loading: 0
interactive: 50
complete: 100
constructor: ->
@progress = @states[document.readyState] ? 100
_onreadystatechange = document.onreadystatechange
document.onreadystatechange = =>
if @states[document.readyState]?
@progress = @states[document.readyState]
_onreadystatechange?(arguments...)
class EventLagMonitor
constructor: ->
@progress = 0
avg = 0
samples = []
points = 0
last = now()
interval = setInterval =>
diff = now() - last - 50
last = now()
samples.push diff
if samples.length > options.eventLag.sampleCount
samples.shift()
avg = avgAmplitude samples
if ++points >= options.eventLag.minSamples and avg < options.eventLag.lagThreshold
@progress = 100
clearInterval interval
else
@progress = 100 * (3 / (avg + 3))
, 50
class Scaler
constructor: (@source) ->
@last = @sinceLastUpdate = 0
@rate = options.initialRate
@catchup = 0
@progress = @lastProgress = 0
if @source?
@progress = result(@source, 'progress')
tick: (frameTime, val) ->
val ?= result(@source, 'progress')
if val >= 100
@done = true
if val == @last
@sinceLastUpdate += frameTime
else
if @sinceLastUpdate
@rate = (val - @last) / @sinceLastUpdate
@catchup = (val - @progress) / options.catchupTime
@sinceLastUpdate = 0
@last = val
if val > @progress
# After we've got a datapoint, we have catchupTime to
# get the progress bar to reflect that new data
@progress += @catchup * frameTime
scaling = (1 - Math.pow(@progress / 100, options.easeFactor))
# Based on the rate of the last update, we preemptively update
# the progress bar, scaling it so it can never hit 100% until we
# know it's done.
@progress += scaling * @rate * frameTime
@progress = Math.min(@lastProgress + options.maxProgressPerFrame, @progress)
@progress = Math.max(0, @progress)
@progress = Math.min(100, @progress)
@lastProgress = @progress
@progress
sources = null
scalers = null
bar = null
uniScaler = null
animation = null
cancelAnimation = null
Pace.running = false
handlePushState = ->
if options.restartOnPushState
Pace.restart()
# We reset the bar whenever it looks like an ajax navigation has occured.
if window.history.pushState?
_pushState = window.history.pushState
window.history.pushState = ->
handlePushState()
_pushState.apply window.history, arguments
if window.history.replaceState?
_replaceState = window.history.replaceState
window.history.replaceState = ->
handlePushState()
_replaceState.apply window.history, arguments
SOURCE_KEYS =
ajax: AjaxMonitor
elements: ElementMonitor
document: DocumentMonitor
eventLag: EventLagMonitor
do init = ->
Pace.sources = sources = []
for type in ['ajax', 'elements', 'document', 'eventLag']
if options[type] isnt false
sources.push new SOURCE_KEYS[type](options[type])
for source in options.extraSources ? []
sources.push new source(options)
Pace.bar = bar = new Bar
# Each source of progress data has it's own scaler to smooth its output
scalers = []
# We have an extra scaler for the final output to keep things looking nice as we add and
# remove sources
uniScaler = new Scaler
Pace.stop = ->
Pace.trigger 'stop'
Pace.running = false
bar.destroy()
# Not all browsers support cancelAnimationFrame
cancelAnimation = true
if animation?
cancelAnimationFrame? animation
animation = null
init()
Pace.restart = ->
Pace.trigger 'restart'
Pace.stop()
Pace.start()
Pace.go = ->
Pace.running = true
bar.render()
start = now()
cancelAnimation = false
animation = runAnimation (frameTime, enqueueNextFrame) ->
# Every source gives us a progress number from 0 - 100
# It's up to us to figure out how to turn that into a smoothly moving bar
#
# Their progress numbers can only increment. We try to interpolate
# between the numbers.
remaining = 100 - bar.progress
count = sum = 0
done = true
# A source is composed of a bunch of elements, each with a raw, unscaled progress
for source, i in sources
scalerList = scalers[i] ?= []
elements = source.elements ? [source]
# Each element is given it's own scaler, which turns its value into something
# smoothed for display
for element, j in elements
scaler = scalerList[j] ?= new Scaler element
done &= scaler.done
continue if scaler.done
count++
sum += scaler.tick(frameTime)
avg = sum / count
bar.update uniScaler.tick(frameTime, avg)
if bar.done() or done or cancelAnimation
bar.update 100
Pace.trigger 'done'
setTimeout ->
bar.finish()
Pace.running = false
Pace.trigger 'hide'
, Math.max(options.ghostTime, Math.max(options.minTime - (now() - start), 0))
else
enqueueNextFrame()
Pace.start = (_options) ->
extend options, _options
Pace.running = true
try
bar.render()
catch NoTargetError
# It's usually possible to render a bit before the document declares itself ready
if not document.querySelector('.pace')
setTimeout Pace.start, 50
else
Pace.trigger 'start'
Pace.go()
if typeof define is 'function' and define.amd
# AMD
define ['pace'], -> Pace
else if typeof exports is 'object'
# CommonJS
module.exports = Pace
else
# Global
if options.startOnPageLoad
Pace.start()

+ 935
- 0
public/bower_components/PACE/pace.js View File

@ -0,0 +1,935 @@
(function() {
var AjaxMonitor, Bar, DocumentMonitor, ElementMonitor, ElementTracker, EventLagMonitor, Evented, Events, NoTargetError, Pace, RequestIntercept, SOURCE_KEYS, Scaler, SocketRequestTracker, XHRRequestTracker, animation, avgAmplitude, bar, cancelAnimation, cancelAnimationFrame, defaultOptions, extend, extendNative, getFromDOM, getIntercept, handlePushState, ignoreStack, init, now, options, requestAnimationFrame, result, runAnimation, scalers, shouldIgnoreURL, shouldTrack, source, sources, uniScaler, _WebSocket, _XDomainRequest, _XMLHttpRequest, _i, _intercept, _len, _pushState, _ref, _ref1, _replaceState,
__slice = [].slice,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
defaultOptions = {
catchupTime: 100,
initialRate: .03,
minTime: 250,
ghostTime: 100,
maxProgressPerFrame: 20,
easeFactor: 1.25,
startOnPageLoad: true,
restartOnPushState: true,
restartOnRequestAfter: 500,
target: 'body',
elements: {
checkInterval: 100,
selectors: ['body']
},
eventLag: {
minSamples: 10,
sampleCount: 3,
lagThreshold: 3
},
ajax: {
trackMethods: ['GET'],
trackWebSockets: true,
ignoreURLs: []
}
};
now = function() {
var _ref;
return (_ref = typeof performance !== "undefined" && performance !== null ? typeof performance.now === "function" ? performance.now() : void 0 : void 0) != null ? _ref : +(new Date);
};
requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
if (requestAnimationFrame == null) {
requestAnimationFrame = function(fn) {
return setTimeout(fn, 50);
};
cancelAnimationFrame = function(id) {
return clearTimeout(id);
};
}
runAnimation = function(fn) {
var last, tick;
last = now();
tick = function() {
var diff;
diff = now() - last;
if (diff >= 33) {
last = now();
return fn(diff, function() {
return requestAnimationFrame(tick);
});
} else {
return setTimeout(tick, 33 - diff);
}
};
return tick();
};
result = function() {
var args, key, obj;
obj = arguments[0], key = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
if (typeof obj[key] === 'function') {
return obj[key].apply(obj, args);
} else {
return obj[key];
}
};
extend = function() {
var key, out, source, sources, val, _i, _len;
out = arguments[0], sources = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = sources.length; _i < _len; _i++) {
source = sources[_i];
if (source) {
for (key in source) {
if (!__hasProp.call(source, key)) continue;
val = source[key];
if ((out[key] != null) && typeof out[key] === 'object' && (val != null) && typeof val === 'object') {
extend(out[key], val);
} else {
out[key] = val;
}
}
}
}
return out;
};
avgAmplitude = function(arr) {
var count, sum, v, _i, _len;
sum = count = 0;
for (_i = 0, _len = arr.length; _i < _len; _i++) {
v = arr[_i];
sum += Math.abs(v);
count++;
}
return sum / count;
};
getFromDOM = function(key, json) {
var data, e, el;
if (key == null) {
key = 'options';
}
if (json == null) {
json = true;
}
el = document.querySelector("[data-pace-" + key + "]");
if (!el) {
return;
}
data = el.getAttribute("data-pace-" + key);
if (!json) {
return data;
}
try {
return JSON.parse(data);
} catch (_error) {
e = _error;
return typeof console !== "undefined" && console !== null ? console.error("Error parsing inline pace options", e) : void 0;
}
};
Evented = (function() {
function Evented() {}
Evented.prototype.on = function(event, handler, ctx, once) {
var _base;
if (once == null) {
once = false;
}
if (this.bindings == null) {
this.bindings = {};
}
if ((_base = this.bindings)[event] == null) {
_base[event] = [];
}
return this.bindings[event].push({
handler: handler,
ctx: ctx,
once: once
});
};
Evented.prototype.once = function(event, handler, ctx) {
return this.on(event, handler, ctx, true);
};
Evented.prototype.off = function(event, handler) {
var i, _ref, _results;
if (((_ref = this.bindings) != null ? _ref[event] : void 0) == null) {
return;
}
if (handler == null) {
return delete this.bindings[event];
} else {
i = 0;
_results = [];
while (i < this.bindings[event].length) {
if (this.bindings[event][i].handler === handler) {
_results.push(this.bindings[event].splice(i, 1));
} else {
_results.push(i++);
}
}
return _results;
}
};
Evented.prototype.trigger = function() {
var args, ctx, event, handler, i, once, _ref, _ref1, _results;
event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if ((_ref = this.bindings) != null ? _ref[event] : void 0) {
i = 0;
_results = [];
while (i < this.bindings[event].length) {
_ref1 = this.bindings[event][i], handler = _ref1.handler, ctx = _ref1.ctx, once = _ref1.once;
handler.apply(ctx != null ? ctx : this, args);
if (once) {
_results.push(this.bindings[event].splice(i, 1));
} else {
_results.push(i++);
}
}
return _results;
}
};
return Evented;
})();
Pace = window.Pace || {};
window.Pace = Pace;
extend(Pace, Evented.prototype);
options = Pace.options = extend({}, defaultOptions, window.paceOptions, getFromDOM());
_ref = ['ajax', 'document', 'eventLag', 'elements'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
source = _ref[_i];
if (options[source] === true) {
options[source] = defaultOptions[source];
}
}
NoTargetError = (function(_super) {
__extends(NoTargetError, _super);
function NoTargetError() {
_ref1 = NoTargetError.__super__.constructor.apply(this, arguments);
return _ref1;
}
return NoTargetError;
})(Error);
Bar = (function() {
function Bar() {
this.progress = 0;
}
Bar.prototype.getElement = function() {
var targetElement;
if (this.el == null) {
targetElement = document.querySelector(options.target);
if (!targetElement) {
throw new NoTargetError;
}
this.el = document.createElement('div');
this.el.className = "pace pace-active";
document.body.className = document.body.className.replace(/pace-done/g, '');
document.body.className += ' pace-running';
this.el.innerHTML = '<div class="pace-progress">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>';
if (targetElement.firstChild != null) {
targetElement.insertBefore(this.el, targetElement.firstChild);
} else {
targetElement.appendChild(this.el);
}
}
return this.el;
};
Bar.prototype.finish = function() {
var el;
el = this.getElement();
el.className = el.className.replace('pace-active', '');
el.className += ' pace-inactive';
document.body.className = document.body.className.replace('pace-running', '');
return document.body.className += ' pace-done';
};
Bar.prototype.update = function(prog) {
this.progress = prog;
return this.render();
};
Bar.prototype.destroy = function() {
try {
this.getElement().parentNode.removeChild(this.getElement());
} catch (_error) {
NoTargetError = _error;
}
return this.el = void 0;
};
Bar.prototype.render = function() {
var el, key, progressStr, transform, _j, _len1, _ref2;
if (document.querySelector(options.target) == null) {
return false;
}
el = this.getElement();
transform = "translate3d(" + this.progress + "%, 0, 0)";
_ref2 = ['webkitTransform', 'msTransform', 'transform'];
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
key = _ref2[_j];
el.children[0].style[key] = transform;
}
if (!this.lastRenderedProgress || this.lastRenderedProgress | 0 !== this.progress | 0) {
el.children[0].setAttribute('data-progress-text', "" + (this.progress | 0) + "%");
if (this.progress >= 100) {
progressStr = '99';
} else {
progressStr = this.progress < 10 ? "0" : "";
progressStr += this.progress | 0;
}
el.children[0].setAttribute('data-progress', "" + progressStr);
}
return this.lastRenderedProgress = this.progress;
};
Bar.prototype.done = function() {
return this.progress >= 100;
};
return Bar;
})();
Events = (function() {
function Events() {
this.bindings = {};
}
Events.prototype.trigger = function(name, val) {
var binding, _j, _len1, _ref2, _results;
if (this.bindings[name] != null) {
_ref2 = this.bindings[name];
_results = [];
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
binding = _ref2[_j];
_results.push(binding.call(this, val));
}
return _results;
}
};
Events.prototype.on = function(name, fn) {
var _base;
if ((_base = this.bindings)[name] == null) {
_base[name] = [];
}
return this.bindings[name].push(fn);
};
return Events;
})();
_XMLHttpRequest = window.XMLHttpRequest;
_XDomainRequest = window.XDomainRequest;
_WebSocket = window.WebSocket;
extendNative = function(to, from) {
var e, key, _results;
_results = [];
for (key in from.prototype) {
try {
if ((to[key] == null) && typeof from[key] !== 'function') {
if (typeof Object.defineProperty === 'function') {
_results.push(Object.defineProperty(to, key, {
get: function() {
return from.prototype[key];
},
configurable: true,
enumerable: true
}));
} else {
_results.push(to[key] = from.prototype[key]);
}
} else {
_results.push(void 0);
}
} catch (_error) {
e = _error;
}
}
return _results;
};
ignoreStack = [];
Pace.ignore = function() {
var args, fn, ret;
fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
ignoreStack.unshift('ignore');
ret = fn.apply(null, args);
ignoreStack.shift();
return ret;
};
Pace.track = function() {
var args, fn, ret;
fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
ignoreStack.unshift('track');
ret = fn.apply(null, args);
ignoreStack.shift();
return ret;
};
shouldTrack = function(method) {
var _ref2;
if (method == null) {
method = 'GET';
}
if (ignoreStack[0] === 'track') {
return 'force';
}
if (!ignoreStack.length && options.ajax) {
if (method === 'socket' && options.ajax.trackWebSockets) {
return true;
} else if (_ref2 = method.toUpperCase(), __indexOf.call(options.ajax.trackMethods, _ref2) >= 0) {
return true;
}
}
return false;
};
RequestIntercept = (function(_super) {
__extends(RequestIntercept, _super);
function RequestIntercept() {
var monitorXHR,
_this = this;
RequestIntercept.__super__.constructor.apply(this, arguments);
monitorXHR = function(req) {
var _open;
_open = req.open;
return req.open = function(type, url, async) {
if (shouldTrack(type)) {
_this.trigger('request', {
type: type,
url: url,
request: req
});
}
return _open.apply(req, arguments);
};
};
window.XMLHttpRequest = function(flags) {
var req;
req = new _XMLHttpRequest(flags);
monitorXHR(req);
return req;
};
try {
extendNative(window.XMLHttpRequest, _XMLHttpRequest);
} catch (_error) {}
if (_XDomainRequest != null) {
window.XDomainRequest = function() {
var req;
req = new _XDomainRequest;
monitorXHR(req);
return req;
};
try {
extendNative(window.XDomainRequest, _XDomainRequest);
} catch (_error) {}
}
if ((_WebSocket != null) && options.ajax.trackWebSockets) {
window.WebSocket = function(url, protocols) {
var req;
if (protocols != null) {
req = new _WebSocket(url, protocols);
} else {
req = new _WebSocket(url);
}
if (shouldTrack('socket')) {
_this.trigger('request', {
type: 'socket',
url: url,
protocols: protocols,
request: req
});
}
return req;
};
try {
extendNative(window.WebSocket, _WebSocket);
} catch (_error) {}
}
}
return RequestIntercept;
})(Events);
_intercept = null;
getIntercept = function() {
if (_intercept == null) {
_intercept = new RequestIntercept;
}
return _intercept;
};
shouldIgnoreURL = function(url) {
var pattern, _j, _len1, _ref2;
_ref2 = options.ajax.ignoreURLs;
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
pattern = _ref2[_j];
if (typeof pattern === 'string') {
if (url.indexOf(pattern) !== -1) {
return true;
}
} else {
if (pattern.test(url)) {
return true;
}
}
}
return false;
};
getIntercept().on('request', function(_arg) {
var after, args, request, type, url;
type = _arg.type, request = _arg.request, url = _arg.url;
if (shouldIgnoreURL(url)) {
return;
}
if (!Pace.running && (options.restartOnRequestAfter !== false || shouldTrack(type) === 'force')) {
args = arguments;
after = options.restartOnRequestAfter || 0;
if (typeof after === 'boolean') {
after = 0;
}
return setTimeout(function() {
var stillActive, _j, _len1, _ref2, _ref3, _results;
if (type === 'socket') {
stillActive = request.readyState < 2;
} else {
stillActive = (0 < (_ref2 = request.readyState) && _ref2 < 4);
}
if (stillActive) {
Pace.restart();
_ref3 = Pace.sources;
_results = [];
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
source = _ref3[_j];
if (source instanceof AjaxMonitor) {
source.watch.apply(source, args);
break;
} else {
_results.push(void 0);
}
}
return _results;
}
}, after);
}
});
AjaxMonitor = (function() {
function AjaxMonitor() {
var _this = this;
this.elements = [];
getIntercept().on('request', function() {
return _this.watch.apply(_this, arguments);
});
}
AjaxMonitor.prototype.watch = function(_arg) {
var request, tracker, type, url;
type = _arg.type, request = _arg.request, url = _arg.url;
if (shouldIgnoreURL(url)) {
return;
}
if (type === 'socket') {
tracker = new SocketRequestTracker(request);
} else {
tracker = new XHRRequestTracker(request);
}
return this.elements.push(tracker);
};
return AjaxMonitor;
})();
XHRRequestTracker = (function() {
function XHRRequestTracker(request) {
var event, size, _j, _len1, _onreadystatechange, _ref2,
_this = this;
this.progress = 0;
if (window.ProgressEvent != null) {
size = null;
request.addEventListener('progress', function(evt) {
if (evt.lengthComputable) {
return _this.progress = 100 * evt.loaded / evt.total;
} else {
return _this.progress = _this.progress + (100 - _this.progress) / 2;
}
}, false);
_ref2 = ['load', 'abort', 'timeout', 'error'];
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
event = _ref2[_j];
request.addEventListener(event, function() {
return _this.progress = 100;
}, false);
}
} else {
_onreadystatechange = request.onreadystatechange;
request.onreadystatechange = function() {
var _ref3;
if ((_ref3 = request.readyState) === 0 || _ref3 === 4) {
_this.progress = 100;
} else if (request.readyState === 3) {
_this.progress = 50;
}
return typeof _onreadystatechange === "function" ? _onreadystatechange.apply(null, arguments) : void 0;
};
}
}
return XHRRequestTracker;
})();
SocketRequestTracker = (function() {
function SocketRequestTracker(request) {
var event, _j, _len1, _ref2,
_this = this;
this.progress = 0;
_ref2 = ['error', 'open'];
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
event = _ref2[_j];
request.addEventListener(event, function() {
return _this.progress = 100;