Sha256: e95bfb971ab851e041348176ca5ed7e9d97bdd86ec21abfc393a03a2f4bb6546
Contents?: true
Size: 1.04 KB
Versions: 13
Compression:
Stored size: 1.04 KB
Contents
#= require teaspoon/reporters/html/progress_view class Teaspoon.Reporters.HTML.RadialProgressView extends Teaspoon.Reporters.HTML.ProgressView @supported: !!document.createElement("canvas").getContext build: -> @el = @createEl("div", "teaspoon-indicator radial-progress") @el.innerHTML = """ <canvas id="teaspoon-progress-canvas"></canvas> <em id="teaspoon-progress-percent">0%</em> """ appendTo: -> super @size = 80 try canvas = @findEl("progress-canvas") canvas.width = canvas.height = canvas.style.width = canvas.style.height = @size @ctx = canvas.getContext("2d") @ctx.strokeStyle = "#fff" @ctx.lineWidth = 1.5 catch e # intentionally do nothing update: (total, run) -> percent = if total then Math.ceil((run * 100) / total) else 0 @setHtml("progress-percent", "#{percent}%") return unless @ctx half = @size / 2 @ctx.clearRect(0, 0, @size, @size) @ctx.beginPath() @ctx.arc(half, half, half - 1, 0, Math.PI * 2 * (percent / 100), false) @ctx.stroke()
Version data entries
13 entries across 13 versions & 1 rubygems