PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/src/js/partials/basic_scripts.js

https://gitlab.com/sheep-fish-vert/cheeseStudio
JavaScript | 155 lines | 115 code | 31 blank | 9 comment | 16 complexity | afb71bb9355317ef8829b74c20f4e8d8 MD5 | raw file
  1. jQuery.browser = {};
  2. jQuery.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
  3. jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
  4. jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
  5. jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());
  6. var scroller=jQuery.browser.webkit ? "body": "html";
  7. $.scrollbarWidth=function(){var a,b,c;if(c===undefined){a=$('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body');b=a.children();c=b.innerWidth()-b.height(99).innerWidth();a.remove()}return c};
  8. /* scrollUp */
  9. function scrollUp(block,targetBlock) {
  10. $(block).click(function(e){
  11. var target = $(targetBlock).offset().top;
  12. $(scroller).animate({scrollTop:target},800);
  13. return false;
  14. e.preventDefault();
  15. });
  16. }
  17. function oneHeightItems(){
  18. function oneHeight(block){
  19. var height=0;
  20. block.removeAttr('style');
  21. block.each(function(){
  22. if($(this).height()>height){
  23. height=$(this).height();
  24. }
  25. });
  26. block.css('height', height);
  27. }
  28. oneHeight($('.oneHeight'));
  29. }
  30. function oneHeightItems2(){
  31. function oneHeight(block){
  32. var height=0;
  33. block.removeAttr('style');
  34. block.each(function(){
  35. if($(this).height()>height){
  36. height=$(this).height();
  37. }
  38. });
  39. block.css('height', height);
  40. }
  41. oneHeight($('.oneHeight2'));
  42. }
  43. /*scroll animation*/
  44. function animationBlock(item){
  45. $(window).scroll(function(){
  46. checkForAnimate();
  47. });
  48. function checkForAnimate(){
  49. var bottomCheck = $(window).height()+$(window).scrollTop();
  50. var windowTop = $(window).scrollTop()+($(window).height()/1.5);
  51. item.each(function(){
  52. if(windowTop>$(this).offset().top || bottomCheck > $('body').height()*0.98){
  53. var itemSect = $(this);
  54. var point = 0;
  55. itemSect.find('.animate-it').addClass('animated');
  56. var timer = setInterval(function(){
  57. itemSect.find('.animate-delay').eq(point).addClass('animated');
  58. point++;
  59. if(itemSect.find('.animate-delay').length == point){
  60. clearInterval(timer);
  61. }
  62. },200);
  63. }
  64. });
  65. }
  66. checkForAnimate();
  67. }
  68. /*GO TO href*/
  69. function goTo(){
  70. $('.header-nav a').click(function(e){
  71. e.preventDefault();
  72. var href = $(this).attr('href');
  73. var target = $(href).offset().top-99;
  74. $(scroller).animate({scrollTop:target},500);
  75. });
  76. }
  77. // cut text script
  78. function cutText(){
  79. var filler = '...';
  80. var filler_length = filler.length;
  81. $('.cut-text').each(function(){
  82. var value = $(this).data('cut') - filler_length;
  83. var text = $.trim($(this).text());
  84. if(text.length > value && value > 0){
  85. var newText = text.substring(0,value) + filler;
  86. $(this).text(newText);
  87. }
  88. });
  89. };
  90. /*header buter*/
  91. function headeButer(menuMobile,toggleMenu){
  92. if(menuMobile){
  93. menuMobile.click(function(event) {
  94. if($(window).width()<1024-$.scrollbarWidth()){
  95. $(this).toggleClass('active');
  96. toggleMenu.stop().slideToggle();
  97. }
  98. });
  99. $(document).on('click touchstart',function (event){
  100. if($(window).width()<1024-$.scrollbarWidth()){
  101. var div = toggleMenu;
  102. if (!div.is(event.target) && div.has(event.target).length === 0 && !menuMobile.is(event.target) && menuMobile.has(event.target).length === 0)
  103. {
  104. toggleMenu.slideUp();
  105. menuMobile.removeClass('active');
  106. }
  107. }
  108. });
  109. }
  110. }
  111. /* DOCUMENT READY */
  112. $(document).ready(function() {
  113. //oneHeightItems();
  114. oneHeightItems2();
  115. $('.footer_placeholder').height($('.footer').outerHeight());
  116. //goTo();
  117. //animationBlock($('.setion-animate'));
  118. });
  119. $(window).load(function(){
  120. $('.footer_placeholder').height($('.footer').outerHeight());
  121. });
  122. $(window).resize(function() {
  123. $('.footer_placeholder').height($('.footer').outerHeight());
  124. });