%PDF- %PDF-
Direktori : /home/ugotscom/www/questionnaire/js/ |
Current File : /home/ugotscom/www/questionnaire/js/customscripts.js |
$('.btn,.continue,.ratings li').click(function(){ //$(".form-control").blur(); cur=$(this).closest('.form-group'); next=cur.next(); if(next.length){ if(!cur.hasClass('has-error')){ setTimeout(function(){ cur.addClass('prevq') $('.form-group').removeClass('active'); next.toggleClass('active'); $('label.btn,.ratings li').removeClass('flicker'); }, 400); if($( window ).width()>767){ $('html, body').delay(400).animate({scrollTop:$(cur).offset().top + $(cur).outerHeight()}, '300', function(){ next.find(".form-control").focus(); });} } } }); $('label.btn').click(function(){ $(this).addClass('flicker'); }); $('.ratings li').click(function(){ $(this).addClass('flicker'); $(this).prevAll().addClass('flicker'); }); $('.form-control').focus(function(){ $('.form-group').removeClass('active'); $(this).closest('.form-group').addClass('active'); }); $( function() { $( "#estimate" ).slider({ value:80001, orientation: "horizontal", range: "min", animate: 'false', min: 80001, max: 2000000, step: 20000, slide: function( event, ui ) { $( ".estimate" ).val(ui.value); } }); $( ".estimate" ).val('80001'); /* 1. Visualizing things on Hover - See next part for action on click */ $('.ratings li').on('mouseover', function(){ var onStar = parseInt($(this).data('value'), 10); // The star currently mouse on // Now highlight all the stars that's not after the current hovered star $(this).parent().children('li.star').each(function(e){ if (e < onStar) { $(this).addClass('hover'); } else { $(this).removeClass('hover'); } }); }).on('mouseout', function(){ $(this).parent().children('li.star').each(function(e){ $(this).removeClass('hover'); }); }); /* 2. Action to perform on click */ $('.ratings li').on('click', function(){ var onStar = parseInt($(this).data('value'), 10); // The star currently selected var stars = $(this).parent().children('li.star'); for (i = 0; i < stars.length; i++) { $(stars[i]).removeClass('selected'); } for (i = 0; i < onStar; i++) { $(stars[i]).addClass('selected'); } var ratingValue = parseInt($('.ratings li.selected').last().data('value'), 10); $(this).closest('.rating-stars').find('.ratingval').val(ratingValue); }); }); $('form').validator().on('submit', function (e) { if (e.isDefaultPrevented()) { // handle the invalid form... } else { e.preventDefault(); $('.thanks,.formwrap').fadeToggle(); } }) $(window).scroll( function(){ if($('.frstq').offset().top+70 > $(window).scrollTop()){ console.log('frst'); $('.form-group').removeClass('active'); $('.frstq').addClass('active'); } else{ /* Check the location of each desired element */ $('.form-group').each( function(i){ // var bottom_of_object = $(this).offset().top + $(this).outerHeight(); // var bottom_of_window = $(window).scrollTop() + $(window).height(); /* If the object is completely visible in the window, fade it it */ if( $(this).offset().top+70 <= $(window).scrollTop() ){ $('.form-group').removeClass('active'); $(this).next().addClass('active'); } }); } }); (function() { var supportTouch = $.support.touch, scrollEvent = "touchmove scroll", touchStartEvent = supportTouch ? "touchstart" : "mousedown", touchStopEvent = supportTouch ? "touchend" : "mouseup", touchMoveEvent = supportTouch ? "touchmove" : "mousemove"; $.event.special.swipeupdown = { setup: function() { var thisObject = this; var $this = $(thisObject); $this.bind(touchStartEvent, function(event) { var data = event.originalEvent.touches ? event.originalEvent.touches[ 0 ] : event, start = { time: (new Date).getTime(), coords: [ data.pageX, data.pageY ], origin: $(event.target) }, stop; function moveHandler(event) { if (!start) { return; } var data = event.originalEvent.touches ? event.originalEvent.touches[ 0 ] : event; stop = { time: (new Date).getTime(), coords: [ data.pageX, data.pageY ] }; // prevent scrolling if (Math.abs(start.coords[1] - stop.coords[1]) > 10) { event.preventDefault(); } } $this .bind(touchMoveEvent, moveHandler) .one(touchStopEvent, function(event) { $this.unbind(touchMoveEvent, moveHandler); if (start && stop) { if (stop.time - start.time < 1000 && Math.abs(start.coords[1] - stop.coords[1]) > 30 && Math.abs(start.coords[0] - stop.coords[0]) < 75) { start.origin .trigger("swipeupdown") .trigger(start.coords[1] > stop.coords[1] ? "swipeup" : "swipedown"); } } start = stop = undefined; }); }); } }; $.each({ swipedown: "swipeupdown", swipeup: "swipeupdown" }, function(event, sourceEvent){ $.event.special[event] = { setup: function(){ $(this).bind(sourceEvent, $.noop); } }; }); })(); $('.form-group').on('swipeup',function(){ cur=$('.form-group.active'); next=cur.next(); if(next.length){ if(!cur.hasClass('has-error')){ cur.addClass('prevq'); $('.form-group').removeClass('active'); next.toggleClass('active'); if($( window ).width()>767){ $('html, body').animate({scrollTop:$(cur).offset().top + $(cur).outerHeight()}, '300', function(){ }); } } } } ); $('.form-group').on('swipedown',function(){ cur=$('.form-group.active'); next=cur.prev(); if(next.length){ if(!cur.hasClass('has-error')){ $('.form-group').removeClass('active'); next.toggleClass('prevq'); next.toggleClass('active'); if($( window ).width()>767){ $('html, body').animate({scrollTop:$(next).offset().top }, '300', function(){ }); } } } });