/src/js/partials/basic_scripts.js
https://gitlab.com/sheep-fish-vert/coldAsfAlt · JavaScript · 154 lines · 111 code · 36 blank · 7 comment · 12 complexity · 36544748d93939671e0604a882901cb9 MD5 · raw file
- jQuery.browser = {};
- jQuery.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
- jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
- jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
- jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());
- var scroller=jQuery.browser.webkit ? "body": "html";
- $.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};
- /* scrollUp */
- function scrollUp(block,targetBlock) {
- $(block).click(function(e){
- var target = $(targetBlock).offset().top;
- $(scroller).animate({scrollTop:target},800);
- return false;
- e.preventDefault();
- });
- }
- function oneHeightItems(){
- function oneHeight(block){
- var height=0;
- block.removeAttr('style');
- block.each(function(){
- if($(this).height()>height){
- height=$(this).height();
- }
- });
- block.css('height', height);
- }
- oneHeight($('.oneHeight'));
- oneHeight($('.street-repairds-text'));
- oneHeight($('.top-block-wrap .text'));
- $(window).load(function(){
- oneHeight($('.street-repairds-text'));
- oneHeight($('.top-block-wrap .text'));
- });
- $(window).resize(function(){
- oneHeight($('.street-repairds-text'));
- oneHeight($('.top-block-wrap .text'));
- });
- }
- /*scroll animation*/
- function animationBlock(item){
- $(window).scroll(function(){
- checkForAnimate();
- });
- function checkForAnimate(){
- var bottomCheck = $(window).height()+$(window).scrollTop();
- var windowTop = $(window).scrollTop()+($(window).height()/1.5);
- item.each(function(){
- if(windowTop>$(this).offset().top || bottomCheck > $('body').height()*0.98){
- var itemSect = $(this);
- var point = 0;
- itemSect.find('.animate-it').addClass('animated');
- var timer = setInterval(function(){
- itemSect.find('.animate-delay').eq(point).addClass('animated');
- point++;
- if(itemSect.find('.animate-delay').length == point){
- clearInterval(timer);
- }
- },200);
- }
- });
- }
- checkForAnimate();
- }
- /*GO TO href*/
- function goTo(){
- $('.navigation_menu a').click(function(e){
- e.preventDefault();
- var href = $(this).attr('href');
- var target = $(href).offset().top-65;
- $(scroller).animate({scrollTop:target},500,function(){
- $('.navigation_menu').slideUp(200);
- $('.menu-button').removeClass('active');
- $('.top-main').removeClass('active');
- });
- });
- }
- // cut text script
- function cutText(){
- var filler = '...';
- var filler_length = filler.length;
- $('.cut-text').each(function(){
- var value = $(this).data('cut') - filler_length;
- var text = $.trim($(this).text());
- if(text.length > value && value > 0){
- var newText = text.substring(0,value) + filler;
- $(this).text(newText);
- }
- });
- };
- /*header buter*/
- function headeButer(menuMobile,toggleMenu){
- menuMobile.click(function(event) {
- $(this).toggleClass('active');
- $('.top-main').toggleClass('active');
- toggleMenu.stop().slideToggle(200);
- });
- $(document).on('click',function (event){
- var div = toggleMenu;
- if (!div.is(event.target) && div.has(event.target).length === 0 && !menuMobile.is(event.target) && menuMobile.has(event.target).length === 0)
- {
- toggleMenu.slideUp(200);
- menuMobile.removeClass('active');
- $('.top-main').removeClass('active');
- }
- });
- }
- /* DOCUMENT READY */
- $(document).ready(function() {
- headeButer($('.menu-button'),$('.navigation_menu'));
- $('.footer_placeholder').height($('.footer').outerHeight());
- goTo();
- //animationBlock($('.setion-animate'));
- oneHeightItems();
- });
- $(window).resize(function() {
- $('.footer_placeholder').height($('.footer').outerHeight());
- });