percircle.js 1.2 KB

1234567891011121314151617181920212223242526272829
  1. /*
  2. * 进度条,目前只用于个人成绩页面
  3. * quote by pjh
  4. */
  5. $(document).ready(function () {
  6. var rotationMultiplier = 3.6;
  7. // For each div that its id ends with "circle", do the following.
  8. $( "div[id$='circle']" ).each(function() {
  9. // Save all of its classes in an array.
  10. var classList = $( this ).attr('class').split(/\s+/);
  11. // Iterate over the array
  12. for (var i = 0; i < classList.length; i++) {
  13. /* If there's about a percentage class, take the actual percentage and apply the
  14. css transformations in all occurences of the specified percentage class,
  15. even for the divs without an id ending with "circle" */
  16. if (classList[i].match("^p")) {
  17. var rotationPercentage = classList[i].substring(1, classList[i].length);
  18. var rotationDegrees = rotationMultiplier*rotationPercentage;
  19. $('.c100.p'+rotationPercentage+ ' .bar').css({
  20. '-webkit-transform' : 'rotate(' + rotationDegrees + 'deg)',
  21. '-moz-transform' : 'rotate(' + rotationDegrees + 'deg)',
  22. '-ms-transform' : 'rotate(' + rotationDegrees + 'deg)',
  23. '-o-transform' : 'rotate(' + rotationDegrees + 'deg)',
  24. 'transform' : 'rotate(' + rotationDegrees + 'deg)'
  25. });
  26. }
  27. }
  28. });
  29. });