main.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ;(function () {
  2. 'use strict';
  3. var isMobile = {
  4. Android: function() {
  5. return navigator.userAgent.match(/Android/i);
  6. },
  7. BlackBerry: function() {
  8. return navigator.userAgent.match(/BlackBerry/i);
  9. },
  10. iOS: function() {
  11. return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  12. },
  13. Opera: function() {
  14. return navigator.userAgent.match(/Opera Mini/i);
  15. },
  16. Windows: function() {
  17. return navigator.userAgent.match(/IEMobile/i);
  18. },
  19. any: function() {
  20. return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  21. }
  22. };
  23. var getHeight = function() {
  24. var extraHeight = 0;
  25. if ( isMobile.any() ) extraHeight = 50;
  26. setTimeout(function(){
  27. $('#fh5co-main').stop().animate({
  28. 'height': $('.fh5co-tab-content.active').height() + extraHeight
  29. });
  30. }, 200);
  31. };
  32. var pieChart = function() {
  33. $('.chart').easyPieChart({
  34. scaleColor: false,
  35. lineWidth: 10,
  36. lineCap: 'butt',
  37. barColor: '#17e7a4',
  38. trackColor: "#000000",
  39. size: 160,
  40. animate: 1000
  41. });
  42. };
  43. var tabContainer = function() {
  44. getHeight();
  45. $(window).resize(function(){
  46. getHeight();
  47. })
  48. };
  49. var tabClickTrigger = function() {
  50. $('.fh5co-tab-menu a').on('click', function(event) {
  51. event.preventDefault();
  52. var $this = $(this),
  53. data = $this.data('tab'),
  54. pie = $this.data('pie');
  55. // add/remove active class
  56. $('.fh5co-tab-menu li').removeClass('active');
  57. $this.closest('li').addClass('active');
  58. $('.fh5co-tab-content.active').addClass('animated fadeOutDown');
  59. setTimeout(function(){
  60. $('.fh5co-tab-content.active').removeClass('active animated fadeOutDown fadeInUp');
  61. $('.fh5co-tab-content[data-content="'+data+'"]').addClass('animated fadeInUp active');
  62. getHeight();
  63. }, 500);
  64. if ( pie === 'yes' ) {
  65. setTimeout(function(){
  66. pieChart();
  67. }, 800);
  68. }
  69. })
  70. };
  71. // Document on load.
  72. $(function(){
  73. tabContainer();
  74. tabClickTrigger();
  75. });
  76. }());