|
|
@ -1999,7 +1999,7 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
$scope.isActive = false; |
|
|
|
$scope.isActive = false; |
|
|
|
|
|
|
|
|
|
|
|
// Demo
|
|
|
|
// Demo
|
|
|
|
// $scope.document.progress = {enabled: true, percent: 30};
|
|
|
|
$scope.document.progress = {enabled: true, percent: 30}; |
|
|
|
// $timeout(function () {
|
|
|
|
// $timeout(function () {
|
|
|
|
// $scope.document.progress.percent = 60;
|
|
|
|
// $scope.document.progress.percent = 60;
|
|
|
|
// }, 3000);
|
|
|
|
// }, 3000);
|
|
|
@ -3256,13 +3256,13 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
var html = |
|
|
|
var html = |
|
|
|
'<svg class="progress-arc" viewPort="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">\ |
|
|
|
'<svg class="progress-arc" viewPort="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">\ |
|
|
|
<defs>\ |
|
|
|
<defs>\ |
|
|
|
<linearGradient id="grad-intermediate">\ |
|
|
|
<linearGradient id="grad_intermediate%id%" x1="0%" y1="0%" x2="100%" y2="0%">\ |
|
|
|
<stop offset="60%" class="stop0" />\ |
|
|
|
<stop offset="0%" class="stop0" />\ |
|
|
|
<stop offset="60%" class="stop60" />\ |
|
|
|
<stop offset="60%" class="stop60" />\ |
|
|
|
<stop offset="100%" class="stop100"/>\ |
|
|
|
<stop offset="100%" class="stop100"/>\ |
|
|
|
</linearGradient>\ |
|
|
|
</linearGradient>\ |
|
|
|
</defs>\ |
|
|
|
</defs>\ |
|
|
|
<circle class="progress-arc-bar" fill="transparent" stroke-dashoffset="0"></circle>\ |
|
|
|
<circle class="progress-arc-bar"></circle>\ |
|
|
|
</svg>'; |
|
|
|
</svg>'; |
|
|
|
|
|
|
|
|
|
|
|
function updateProgress (bar, progress, fullLen) { |
|
|
|
function updateProgress (bar, progress, fullLen) { |
|
|
@ -3272,40 +3272,43 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
bar.css({strokeDasharray: (progress * fullLen) + ', ' + ((1 - progress) * fullLen)}); |
|
|
|
bar.css({strokeDasharray: (progress * fullLen) + ', ' + ((1 - progress) * fullLen)}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var num = 0; |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
scope: { |
|
|
|
scope: { |
|
|
|
progress: '=myArcProgress' |
|
|
|
progress: '=myArcProgress' |
|
|
|
}, |
|
|
|
}, |
|
|
|
link: function ($scope, element, attrs) { |
|
|
|
link: function ($scope, element, attrs) { |
|
|
|
element |
|
|
|
var intermediate = !attrs.myArcProgress; |
|
|
|
.html(html) |
|
|
|
var width = attrs.width || element.width() || 40; |
|
|
|
.addClass('progress-arc-wrap'); |
|
|
|
var stroke = attrs.stroke || (width / 2 * 0.14); |
|
|
|
|
|
|
|
var center = width / 2; |
|
|
|
var intermediate = attrs.intermediate && $scope.$eval(attrs.intermediate); |
|
|
|
var radius = center - stroke; |
|
|
|
|
|
|
|
|
|
|
|
if (intermediate) { |
|
|
|
|
|
|
|
element.addClass('progress-arc-intermediate'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var svgEl = element[0].firstChild; |
|
|
|
// Doesn't work without unique id for every gradient
|
|
|
|
var bar = $('.progress-arc-bar', element); |
|
|
|
var curNum = ++num; |
|
|
|
|
|
|
|
|
|
|
|
var width = attrs.width || 40; |
|
|
|
element |
|
|
|
var radius = width / 2 * 0.86; |
|
|
|
.html(html.replace('%id%', curNum)) |
|
|
|
var stroke = width / 2 * 0.14; |
|
|
|
.addClass('progress-arc-wrap') |
|
|
|
var center = width / 2; |
|
|
|
.addClass(intermediate ? 'progress-arc-intermediate' : 'progress-arc-percent') |
|
|
|
|
|
|
|
.css({width: width, height: width}); |
|
|
|
|
|
|
|
|
|
|
|
$(svgEl).attr('width', width); |
|
|
|
$(element[0].firstChild) |
|
|
|
$(svgEl).attr('height', width); |
|
|
|
.attr('width', width) |
|
|
|
|
|
|
|
.attr('height', width); |
|
|
|
|
|
|
|
|
|
|
|
bar.attr('cx', center); |
|
|
|
var bar = $('.progress-arc-bar', element); |
|
|
|
bar.attr('cy', center); |
|
|
|
bar |
|
|
|
bar.attr('r', radius); |
|
|
|
.attr('cx', center) |
|
|
|
bar.css({strokeWidth: stroke}); |
|
|
|
.attr('cy', center) |
|
|
|
|
|
|
|
.attr('r', radius) |
|
|
|
|
|
|
|
.css({strokeWidth: stroke}); |
|
|
|
|
|
|
|
|
|
|
|
var fullLen = 2 * Math.PI * radius; |
|
|
|
var fullLen = 2 * Math.PI * radius; |
|
|
|
if (intermediate) { |
|
|
|
if (intermediate) { |
|
|
|
updateProgress(bar, 0.3, fullLen); |
|
|
|
updateProgress(bar, 0.3, fullLen); |
|
|
|
|
|
|
|
bar.css({stroke: 'url(#grad_intermediate' + curNum + ')'}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$scope.$watch('progress', function (newProgress) { |
|
|
|
$scope.$watch('progress', function (newProgress) { |
|
|
|
updateProgress(bar, newProgress / 100.0, fullLen); |
|
|
|
updateProgress(bar, newProgress / 100.0, fullLen); |
|
|
|