No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

86 líneas
2.3 KiB

  1. <script>
  2. function makeCircles() {
  3. var divsValues = {
  4. <?php if($this->percent_1): ?>'reader-score-circle': 0.<?= $this->percent_1; ?>,<?php endif ?>
  5. <?php if($this->percent_2): ?>'age-score-circle': 0.<?= $this->percent_2; ?>,<?php endif ?>
  6. <?php if($this->percent_3): ?>'netto-score-circle': 0.<?= $this->percent_3; ?>,<?php endif ?>
  7. <?php if($this->percent_4): ?>'education-score-circle': 0.<?= $this->percent_4; ?>,<?php endif ?>
  8. };
  9. for (var i in divsValues) {
  10. if (divsValues.hasOwnProperty(i)) {
  11. bgCircles(i, divsValues[i]);
  12. }
  13. }
  14. }
  15. makeCircles();
  16. function isScrolledIntoView(elem) {
  17. var docViewTop = jQuery(window).scrollTop();
  18. var docViewBottom = docViewTop + jQuery(window).height();
  19. var elemTop = jQuery(elem).offset().top;
  20. var elemBottom = elemTop + jQuery(elem).height();
  21. return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
  22. }
  23. function checkVisibility(elem, bar, countvalue) {
  24. if (isScrolledIntoView(elem)) {
  25. if (!elem.hasClass("circle-visible")) {
  26. bar.animate(countvalue);
  27. elem.addClass("circle-visible");
  28. }
  29. } else {
  30. // bar.animate(0);
  31. }
  32. }
  33. function bgCircles(divid, countvalue) {
  34. var elem = jQuery('#' + divid);
  35. var bar = new ProgressBar.Circle(elem.get(0), {
  36. color: '#0000DC',
  37. strokeWidth: 4,
  38. trailWidth: 4,
  39. easing: 'easeInOut',
  40. duration: 1000,
  41. trailColor: '#B4D7F7',
  42. text: {
  43. autoStyleContainer: false
  44. },
  45. from: {
  46. color: '#0000DC',
  47. width: 4
  48. },
  49. to: {
  50. color: '#0000DC',
  51. width: 4
  52. },
  53. step: function(state, circle) {
  54. circle.path.setAttribute('stroke', state.color);
  55. circle.path.setAttribute('stroke-width', state.width);
  56. var value = Math.round(circle.value() * 100);
  57. if (value === 0) {
  58. circle.setText('');
  59. } else {
  60. circle.setText(value + '%');
  61. }
  62. }
  63. });
  64. bar.text.style.fontFamily = 'futura-pt, sans-serif';
  65. bar.text.style.fontSize = '2.813rem';
  66. bar.trail.setAttribute('stroke-linecap', 'round');
  67. bar.path.setAttribute('stroke-linecap', 'round');
  68. checkVisibility(elem, bar, countvalue);
  69. $(window).scroll(function () {
  70. checkVisibility(elem, bar, countvalue);
  71. });
  72. }
  73. </script>