Advertisement
Guest User

Untitled

a guest
Jul 15th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($) {                                          // Compliant with jquery.noConflict()
  2. $.fn.jCarouselLite = function(o) {
  3.     o = $.extend({
  4.         btnPrev: null,
  5.         btnNext: null,
  6.         btnGo: null,
  7.         mouseWheel: false,
  8.         auto: null,
  9.         hoverPause: false,
  10.  
  11.         speed: 3000,
  12.         easing: null,
  13.  
  14.         vertical: false,
  15.         circular: true,
  16.         visible: 3,
  17.         start: 0,
  18.         scroll: 1,
  19.  
  20.         beforeStart: null,
  21.         afterEnd: null
  22.     }, o || {});
  23.  
  24.     return this.each(function() {                           // Returns the element collection. Chainable.
  25.  
  26.         var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
  27.         var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
  28.  
  29.         if(o.circular) {
  30.             ul.prepend(tLi.slice(tl-v+1).clone()) // add last visible part, to the begin of the ul
  31.               .append(tLi.slice(0,o.scroll).clone());  // add first visble part, to the end of the ul
  32.             o.start += v-1; //the script added an item at the front, move the start position with one part
  33.         }
  34.  
  35.         var li = $("li", ul), itemLength = li.size(), curr = o.start;
  36.         div.css("visibility", "visible");
  37.  
  38.         li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});
  39.         ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
  40.         div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});
  41.  
  42.         var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
  43.         var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
  44.         var divSize = liSize * v;                           // size of entire div(total length for just the visible items)
  45.  
  46.         li.css({width: li.width(), height: li.height()});
  47.         ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
  48.  
  49.         div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images
  50.  
  51.         if(o.btnPrev) {
  52.             $(o.btnPrev).click(function() {
  53.                 return go(curr-o.scroll);
  54.             });
  55.             //not needed (scriptbreaker)
  56.             /*
  57.             if(o.hoverPause) {
  58.                 $(o.btnPrev).hover(function(){stopAuto();}, function(){startAuto();});
  59.             }
  60.             */
  61.         }
  62.  
  63.  
  64.         if(o.btnNext) {
  65.             $(o.btnNext).click(function() {
  66.                 return go(curr+o.scroll);
  67.             });
  68.             //not needed (scriptbreaker)
  69.             /*
  70.             if(o.hoverPause) {
  71.                 $(o.btnNext).hover(function(){stopAuto();}, function(){startAuto();});
  72.             }
  73.             */
  74.         }
  75.  
  76.         if(o.btnGo)
  77.             $.each(o.btnGo, function(i, val) {
  78.                 $(val).click(function() {
  79.                     //added by the scriptbreaker extension
  80.                     return go(o.circular ? (o.visible+i-1) : i);
  81.                    
  82.                     //why is that?
  83.                     //return go(o.circular ? o.visible+i : i);
  84.                 });
  85.             });
  86.  
  87.         if(o.mouseWheel && div.mousewheel)
  88.             div.mousewheel(function(e, d) {
  89.                 return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
  90.             });
  91.  
  92.         var autoInterval;
  93.  
  94.         function startAuto() {
  95.           stopAuto();
  96.           autoInterval = setInterval(function() {
  97.                   go(curr+o.scroll);
  98.               }, o.auto+o.speed);
  99.         };
  100.  
  101.         function stopAuto() {
  102.             clearInterval(autoInterval);
  103.         };
  104.  
  105.         if(o.auto) {
  106.             if(o.hoverPause) {
  107.                 //scriptbreaker extention add the hover pause to the children instead of the element itself
  108.                 div.children().hover(function(){stopAuto();}, function(){startAuto();});
  109.             }
  110.             startAuto();
  111.         };
  112.  
  113.         function vis() {
  114.             return li.slice(curr).slice(0,v);
  115.         };
  116.  
  117.         function go(to) {
  118.             if(!running) {
  119.                
  120.                 if(o.beforeStart)
  121.                     o.beforeStart.call(this, vis());
  122.  
  123.                 if(o.circular) {            // If circular we are in first or last, then goto the other end
  124.                     if(to<0) {           // If before range, then go around
  125.                         ul.css(animCss, -( (curr + tl) * liSize)+"px");
  126.                         curr = to + tl;
  127.                     } else if(to>itemLength-v) { // If beyond range, then come around
  128.                         ul.css(animCss, -( (curr - tl) * liSize ) + "px" );
  129.                         curr = to - tl;
  130.                     } else curr = to;
  131.                 } else {                    // If non-circular and to points to first or last, we just return.
  132.                     if(to<0 || to>itemLength-v) return;
  133.                     else curr = to;
  134.                 }                           // If neither overrides it, the curr will still be "to" and we can proceed.
  135.  
  136.                 running = true;
  137.  
  138.                 ul.animate(
  139.                     animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
  140.                     function() {
  141.                         if(o.afterEnd)
  142.                             o.afterEnd.call(this, vis(), curr, o.btnGo);
  143.                         running = false;
  144.                     }
  145.                 );
  146.                 // Disable buttons when the carousel reaches the last/first, and enable when not
  147.                 if(!o.circular) {
  148.                     $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
  149.                     $( (curr-o.scroll<0 && o.btnPrev)
  150.                         ||
  151.                        (curr+o.scroll > itemLength-v && o.btnNext)
  152.                         ||
  153.                        []
  154.                      ).addClass("disabled");
  155.                 }
  156.  
  157.             }
  158.             return false;
  159.         };
  160.     });
  161. };
  162.  
  163. function css(el, prop) {
  164.     return parseInt($.css(el[0], prop)) || 0;
  165. };
  166. function width(el) {
  167.     return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
  168. };
  169. function height(el) {
  170.     return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
  171. };
  172.  
  173. })(jQuery);
  174.  
  175. $(document).ready(function() {
  176.  
  177.     $("#slidebox").jCarouselLite({
  178.         vertical: false,
  179.         hoverPause:true,
  180.         btnPrev: ".previous",
  181.         btnNext: ".next",
  182.         visible: 1,
  183.         start: 0,
  184.         scroll: 1,
  185.         circular: true,
  186.         auto:3000,
  187.         speed:2500,            
  188.         btnGo:
  189.             [".1", ".2",
  190.             ".3", ".4"],
  191.        
  192.         afterEnd: function(a, to, btnGo) {
  193.             if(btnGo.length <= to){
  194.                 to = 0;
  195.             }
  196.             $(".thumbActive").removeClass("thumbActive");
  197.             $(btnGo[to]).addClass("thumbActive");
  198.         }
  199.     });
  200.    
  201.     $('.callmeform').click(function() {
  202.        
  203.         new Messi('', {
  204.             title: 'Оставьте заявку на звонок',
  205.             titleClass: 'info',
  206.             modal: true,
  207.             modalOpacity: .6,
  208.             width: '400px',
  209.             height: '245px'
  210.         });
  211.  
  212.         $('.messi-content').last().append($('#dialog .callme-template').html());
  213.  
  214.         var targetInputPhone = '.messi input.maskPhone';
  215.         //var targetInputEmail = '.messi input[name=email]';
  216.         $(targetInputPhone).mask("+7 (999) 999-9999");
  217.         $('.messi input[type=submit]').click(function() {
  218.  
  219.             var valuePhone = $(targetInputPhone).val();
  220.             if (!valuePhone/* || !valueEmail || !validateEmail(valueEmail)*/) {
  221.                 $(targetInputPhone).css('border', '1px solid #fff');
  222.                 //$(targetInputEmail).css('border', '1px solid #fff');
  223.                 if (!valuePhone) {
  224.                     $(targetInputPhone).css('border', '1px solid #fd0101');
  225.                 }
  226.                 /*if (!valueEmail || !validateEmail(valueEmail)) {
  227.                     $(targetInputEmail).css('border', '1px solid #fd0101');
  228.                 }*/
  229.                 return false;
  230.             }
  231.         });
  232.  
  233.         return false;
  234.  
  235.     });
  236.  
  237.     // Валидация ввода номера телефона в форме в футере
  238.     $('.foot-right input[type=submit]').click(function() {
  239.         var targetInputPhone = '.foot-right input.maskPhone';
  240.  
  241.         var valuePhone = $(targetInputPhone).val();    
  242.         if (!valuePhone) {
  243.             $(targetInputPhone).css('border', '1px solid #fff');
  244.             if (!valuePhone) {
  245.                 $(targetInputPhone).css('border', '1px solid #fd0101');
  246.             }
  247.             return false;
  248.         }
  249.     });
  250.  
  251.     // Валидация ввода номера телефона, имени и сообщения в форме на странице заказа
  252.     $('.content-right input[type=submit]').click(function() {
  253.         var targetInputPhone = '.content-right input.maskPhone';
  254.         var targetInputName = '.content-right  input[name=name]';
  255.         var targetTextarea = '.content-right  textarea';
  256.        
  257.         var valuePhone = $(targetInputPhone).val();
  258.         var valueName = $(targetInputName).val();
  259.         var valueTextarea = $(targetTextarea).val();
  260.        
  261.        
  262.         if (!valuePhone || !valueName  || !valueTextarea) {
  263.             $(targetInputPhone).css('border', '1px solid #a9a9a9');
  264.             $(targetInputName).css('border', '1px solid #a9a9a9');
  265.             $(targetTextarea).css('border', '1px solid #a9a9a9');
  266.            
  267.             if (!valuePhone) {
  268.                 $(targetInputPhone).css('border', '1px solid #fd0101');
  269.             }
  270.            
  271.             if (!valueName) {
  272.                 $(targetInputName).css('border', '1px solid #fd0101');
  273.             }
  274.            
  275.             if (!valueTextarea) {
  276.                 $(targetTextarea).css('border', '1px solid #fd0101');
  277.             }
  278.            
  279.             return false;
  280.         }
  281.     });
  282.    
  283.     $('.maskPhone').mask("+7 (999) 999-9999"); 
  284.    
  285.     $('.qstn').click(function(){
  286.         var answrID = $(this).attr('id');
  287.         $('#answr-' + answrID).slideToggle();
  288.     });
  289.    
  290.     $('.modal').click(function(event){
  291.         event.preventDefault();
  292.         $('#overlay').fadeIn(0);
  293.         $('#modal_form').css('display', 'block');
  294.     });
  295.    
  296.     $('.exit, #overlay').click(function(){
  297.         $('#modal_form').css('display', 'none');
  298.         $('#overlay').fadeOut(0);
  299.     });
  300.    
  301.     var targetInputPhone = '.phone-zv';
  302.     $(targetInputPhone).mask("+7 (999) 999-9999");
  303.     $('#orderForm input[type=submit]').click(function() {
  304.             var valuePhone = $(targetInputPhone).val();
  305.             if (!valuePhone) {
  306.                 $(targetInputPhone).css('border', '1px solid #fff');
  307.                 if (!valuePhone) {
  308.                     $(targetInputPhone).css('border', '1px solid #fd0101');
  309.                 }
  310.                 return false;
  311.             }
  312.         });
  313.            
  314.     $(document).on("submit","#orderForm", function(e){
  315.             e.preventDefault();
  316.             var m_method=$(this).attr('method');
  317.             var m_action=$(this).attr('action');
  318.             var m_data=$(this).serialize();
  319.             $.ajax({
  320.                     type: m_method,
  321.                     url: m_action,
  322.                     data: m_data,
  323.                     resetForm: 'true',
  324.                     success: function(result){
  325.                             var data = $(result).find("#modal-form-content").html();
  326.                             $("#modal-form-content").html(data);
  327.                     }
  328.             });
  329.            
  330.     });
  331.    
  332.     $('.modal2').click(function(event){
  333.         event.preventDefault();
  334.         $('#overlay').fadeIn(0);
  335.         $('#modal_form2').css('display', 'block');
  336.     });
  337.    
  338.     $('.exit2, #overlay').click(function(){
  339.         $('#modal_form2').css('display', 'none');
  340.         $('#overlay').fadeOut(0);
  341.     });
  342.    
  343.     var targetInputPhone2 = '.phone-zv2';
  344.     $(targetInputPhone2).mask("+7 (999) 999-9999");
  345.     $('#orderFormCall input[type=submit]').click(function() {
  346.             var valuePhone2 = $(targetInputPhone2).val();
  347.             if (!valuePhone2) {
  348.                 $(targetInputPhone2).css('border', '1px solid #fff');
  349.                
  350.                 if (!valuePhone2) {
  351.                     $(targetInputPhone2).css('border', '1px solid #fd0101');
  352.                 }
  353.                 return false;
  354.             }
  355.         });
  356.            
  357.     $(document).on("submit","#orderFormCall",function(e){
  358.             e.preventDefault();
  359.             var m_method=$(this).attr('method');
  360.             var m_action=$(this).attr('action');
  361.             var m_data=$(this).serialize();
  362.             $.ajax({
  363.                     type: m_method,
  364.                     url: m_action,
  365.                     data: m_data,
  366.                     resetForm: 'true',
  367.                     success: function(result){
  368.                             var data = $(result).find("#modal-form-content2").html();
  369.                             $("#modal-form-content2").html(data);
  370.                     }
  371.             });
  372.            
  373.     });
  374. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement