Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function($) {
- if( jQuery('#slick-slider-home-especialidades').length > 0 ){
- jQuery('#slick-slider-home-especialidades').slick({
- dots: false,
- infinite: true,
- slidesToShow: 3,
- slidesPerRow: 1,
- slidesToScroll: 1,
- arrows : true,
- prevArrow : '<a class="slick-prev"><i class="fa fa-chevron-left"></i></a>',
- nextArrow : '<a class="slick-next"><i class="fa fa-chevron-right"></i></a>',
- responsive: [
- {
- breakpoint: 600,
- settings: {
- slidesToShow: 2,
- slidesToScroll: 2,
- infinite: true,
- dots: false
- }
- },
- {
- breakpoint: 480,
- settings: {
- slidesToShow: 1,
- slidesToScroll: 1,
- infinite: true,
- dots: false
- }
- }
- ]
- });
- }
- if( jQuery('.slide-marcas-especialidad-movil').length > 0 ){
- jQuery('.slide-marcas-especialidad-movil').slick({
- //slide : '.contenedor-marca',
- dots: false,
- infinite: true,
- slidesToShow: 1,
- slidesPerRow: 1,
- slidesToScroll: 1,
- arrows : true,
- prevArrow : '<a class="slick-prev"><i class="fa fa-chevron-left"></i></a>',
- nextArrow : '<a class="slick-next"><i class="fa fa-chevron-right"></i></a>'
- });
- }
- if( jQuery('.slider-especialidades-movil').length > 0 ){
- jQuery('.slider-especialidades-movil').slick({
- //slide : '.contenedor-marca',
- dots: false,
- infinite: true,
- slidesToShow: 2,
- slidesPerRow: 1,
- slidesToScroll: 1,
- arrows : true,
- prevArrow : '<a class="especialidades-slick-prev"><i class="fa fa-chevron-left"></i></a>',
- nextArrow : '<a class="especialidades-slick-next"><i class="fa fa-chevron-right"></i></a>'
- });
- }
- jQuery(document).scroll(function () {
- var $nav = jQuery("nav.navbar");
- $nav.toggleClass('scrolled', jQuery(this).scrollTop() > $nav.height());
- });
- if( location.search ){
- jQuery(".product-categories").find('li a').each(function(index, el) {
- jQuery( el ).prop('href', jQuery( el ).prop('href') + location.search );
- });
- jQuery("#main-menu").find('li.activa-filtros a').each(function(index, el) {
- jQuery( el ).prop('href', jQuery( el ).prop('href') + location.search );
- });
- jQuery("select.pwb-dropdown-widget").find('option').each(function(index, el) {
- jQuery( el ).val( jQuery( el ).val() + location.search );
- });
- }
- jQuery('.woocommerce').on('click', "a.button.btn-quote-only", function(event) {
- event.preventDefault();
- jQuery('#modal-cotizacion').modal('show');
- jQuery('#equipo-cotizacion').val( jQuery(this).data('product-name') );
- });
- jQuery('.solo_numeros').keyup(function(e){
- if (/\D/g.test(this.value)){this.value = this.value.replace(/\D/g, '');}
- });
- jQuery.validator.methods.matches = function( value, element, params ) {
- var re = new RegExp(params);
- return this.optional( element ) || re.test( value );
- }
- jQuery('#form-contacto').validate({
- rules: {
- "firstname" : { required : true },
- "lastname" : { required : true },
- "email" : { required : true, email : true },
- "companyname" : { required : true },
- "homephone" : { required : true },
- "pais" : { required : true },
- "mobilephone" : { required : true },
- "state" : { required : true },
- "city" : { required : true },
- "custentity8" : { required : true },
- "selectProduct" : { required : true },
- "custentity9" : { required : true },
- "comments" : { required : true }
- },
- erroClass: "error",
- submitHandler: function(form) {
- var urlForm = $(form).attr('action');
- $.ajax({
- url: medrent_ajax.ajax_url,
- type: 'POST',
- data: new FormData( $(form)[0] ),
- processData: false,
- contentType: false,
- beforeSend: function(){
- $(form).find('.cargando').removeClass('d-none');
- $(form).find('button[type="submit"]').addClass('disabled');
- },
- error: function(){
- $(form).find('.cargando').addClass('d-none');
- $(form).find('.exitoso').addClass('d-none');
- $(form).find('button[type="submit"]').removeClass('disabled');
- $(form)[0].reset();
- },
- success: function(response){
- $(form).find('.cargando').addClass('d-none');
- $(form).find('.exitoso').removeClass('d-none');
- $(form).find('button[type="submit"]').removeClass('disabled');
- $(form)[0].reset();
- }
- });
- }
- });
- jQuery('#newsletter-form, #newsletter-form-eventos').validate({
- rules: {
- 'correo-electronico' : { required : true, email : true }
- },
- erroClass: "error",
- submitHandler: function(form) {
- var formulario = jQuery(form);
- var data = formulario.serialize();
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "newsletter_submit", data },
- success: function(json) {
- if( json.result ){
- jQuery('#newsletter-form').html('<p>Muchas gracias por enviar tu información.</p>');
- }
- }
- });
- }
- });
- jQuery('#newsletter-form-promociones').validate({
- rules: {
- 'correo-electronico' : { required : true, email : true }
- },
- erroClass: "error",
- submitHandler: function(form) {
- var formulario = jQuery(form);
- var data = formulario.serialize();
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "newsletter_submit", data },
- success: function(json) {
- if( json.result ){
- jQuery('#newsletter-form-promociones').html('<p>Muchas gracias por enviar tu información.</p>');
- }
- }
- });
- }
- });
- jQuery( "#form-cotizar" ).validate( {
- rules: {
- 'nombre-completo' : { required : true },
- 'correo-electronico' : { required : true, email : true },
- 'telefono' : { required : true, digits : true, matches: "[0-9]+", minlength:10, maxlength:10 }
- },
- erroClass: "error",
- success: function ( label, element ) {
- },
- submitHandler: function(form) {
- var formulario = jQuery(form);
- var data = formulario.serialize();
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "cotizacion_submit", data },
- beforeSend: function(){
- $(form).find('button[type="submit"]').addClass('disabled').hide();
- },
- success: function(json) {
- var response = $.parseJSON( json );
- console.log(response);
- if( response.result ){
- jQuery('#modal-cotizacion').modal('hide');
- }
- $(form).find('button[type="submit"]').removeClass('disabled').show();
- }
- });
- }
- });
- $('#modal-cotizacion').on('show.bs.modal', function (e) {
- $('#form-cotizar').find('button[type="submit"]').removeClass('disabled').show();
- })
- jQuery.extend(jQuery.validator.messages, {
- required: "Es requerido",
- email: "Debe ser un email válido",
- digits: "Inserta solo dígitos",
- lettersonly: "Inserta solo caracteres",
- minlength: "Ingresa mínimo 10 caracteres",
- maxlength: "Ingresa máximo 10 caracteres"
- });
- // get the country data from the plugin
- var countryData = window.intlTelInputGlobals.getCountryData(),
- input = document.querySelector("#telefono"),
- addressDropdown = document.querySelector("#pais");
- // init plugin
- var iti = window.intlTelInput(input, {
- //separateDialCode: true,
- initialCountry: "auto",
- geoIpLookup: function(callback) {
- $.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) {
- var countryCode = (resp && resp.country) ? resp.country : "";
- callback(countryCode);
- });
- },
- utilsScript: "https://med-rent.com/wp-content/themes/medrent-beta/node_modules/intl-tel-input/build/js/utils.js?1549804213570" // just for formatting/placeholders etc
- });
- // populate the country dropdown
- for (var i = 0; i < countryData.length; i++) {
- var country = countryData[i];
- var optionNode = document.createElement("option");
- optionNode.value = country.iso2;
- var textNode = document.createTextNode(country.name);
- optionNode.appendChild(textNode);
- addressDropdown.appendChild(optionNode);
- }
- // set it's initial value
- addressDropdown.value = iti.getSelectedCountryData().iso2;
- // listen to the telephone input for changes
- input.addEventListener('countrychange', function(e) {
- addressDropdown.value = iti.getSelectedCountryData().iso2;
- });
- // listen to the address dropdown for changes
- addressDropdown.addEventListener('change', function() {
- iti.setCountry(this.value);
- });
- jQuery('#input-search').on('keyup', function(event) {
- event.preventDefault();
- var term = jQuery(this).val();
- var marca = jQuery(this).data('marca');
- if( term == "" ){
- jQuery('div.productos').show();
- jQuery('div.resultados').html("");
- }else{
- if( term.length >= 3 ){
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "buscar_producto_por_marca", "term" : term, "marca" : marca },
- success: function(json) {
- if( json.result ){
- jQuery('div.productos').hide();
- jQuery('div.resultados').html( json.html );
- }
- }
- });
- }
- }
- });
- if( jQuery('select#marca').length > 0 ){
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "combo_marcas" },
- success: function(json) {
- if( json.result ){
- jQuery('select#marca option').each(function(index, el) {
- if( jQuery( el ).val() != "" ){
- jQuery(el).remove();
- }
- });
- jQuery('select#marca').append( json.brands );
- }
- }
- });
- jQuery('select#marca').on('change', function(event) {
- event.preventDefault();
- var slug = jQuery(this).val();
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "combo_productos", "slug" : slug },
- success: function(json) {
- if( json.result ){
- jQuery('select#modelo option').each(function(index, el) {
- if( jQuery( el ).val() != "" ){
- jQuery(el).remove();
- }
- });
- jQuery('select#modelo').append( json.products );
- }
- }
- });
- });
- }
- jQuery('#input-search-especialidad').on('keyup', function(event) {
- event.preventDefault();
- var term = jQuery(this).val();
- var especialidad = jQuery(this).data('especialidad');
- if( term == "" ){
- jQuery('div.productos').show();
- jQuery('div.resultados').html("");
- }else{
- if( term.length >= 3 ){
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "buscar_producto_por_especialidad", "term" : term, "especialidad" : especialidad },
- success: function(json) {
- if( json.result ){
- jQuery('div.productos').hide();
- jQuery('div.resultados').html( json.html );
- }
- }
- });
- }
- }
- });
- jQuery('.checkbox-filter').on('click', 'input[type="checkbox"]', function(event) {
- var estudios = [];
- jQuery('.checkbox-filter input:checked').each(function(index, el) {
- estudios.push( jQuery( el ).val() );
- });
- if( estudios.length > 0 ){
- jQuery('.woocommerce-product').each(function(index, el) {
- jQuery( el ).hide();
- for ( var i = 0; i < estudios.length; i++ ){
- if ( jQuery( el ).hasClass( estudios[i] ) ) {
- jQuery( el ).show();
- break;
- }
- }
- });
- }else{
- jQuery('.woocommerce-product').show();
- }
- });
- if( jQuery('#calendario-eventos').length > 0 ){
- function myDateFunction(id, fromModal) {
- var date = $("#" + id).data("date");
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "data_eventos_fecha", date: date },
- success: function(json) {
- if( json.result ){
- jQuery('.resultados').html( json.html );
- }
- }
- });
- }
- jQuery.ajax({
- type : "POST",
- dataType : "json",
- url: medrent_ajax.ajax_url,
- data : { action: "data_eventos" },
- success: function(json) {
- if( json.result ){
- var eventData = json.eventos;
- jQuery("#calendario-eventos").zabuto_calendar({
- language: "es",
- nav_icon: {
- prev: '<i class="fa fa-chevron-circle-left"></i>',
- next: '<i class="fa fa-chevron-circle-right"></i>'
- },
- cell_border: true,
- today: true,
- data: eventData,
- action: function () {
- console.log( this.id );
- return myDateFunction(this.id, false);
- },
- });
- }
- }
- });
- }
- $('#form-financiamiento').validate({
- rules: {
- nombre: {
- required: true
- },
- apellidos: {
- required: true
- },
- tel: {
- digits: true,
- minlength: 8
- },
- ciudad: {
- required: true
- },
- cp: {
- digits: true,
- maxlength: 5,
- minlength: 5
- }
- },
- messages: {
- aviso: {
- required: 'Acepta los términos'
- },
- cp: {
- maxlength: 'Ingresa un código postal válido',
- minlength: 'Ingresa un código postal válido'
- }
- },
- success: 'valid',
- submitHandler: function(form){
- var valores = $(form).serialize();
- $.ajax({
- url: medrent_ajax.ajax_url,
- type: 'POST',
- data: new FormData( jQuery(form)[0] ),
- processData: false,
- contentType: false,
- beforeSend: function(){
- $(form).find('.cargando').removeClass('hidden-xs-up');
- $(form).find('.exitoso').addClass('hidden-xs-up');
- $(form).find('button[type="submit"]').addClass('disabled');
- },
- error: function(){
- },
- success: function(response){
- $(form).find('.cargando').addClass('hidden-xs-up');
- $(form).find('.exitoso').removeClass('hidden-xs-up');
- $(form).find('button[type="submit"]').removeClass('disabled');
- $(form)[0].reset();
- }
- });
- }
- });
- $('#form-servicio').validate({
- rules: {
- nombre: {
- required : true
- },
- apellidos: {
- required : true
- },
- tel: {
- digits: true,
- minlength: 8
- },
- ciudad: {
- required : true
- },
- cp: {
- digits: true,
- maxlength: 5,
- minlength: 5
- }
- },
- messages: {
- aviso: {
- required: 'Acepta los términos'
- },
- cp: {
- maxlength: 'Ingresa un código postal válido',
- minlength: 'Ingresa un código postal válido'
- }
- },
- success: 'valid',
- submitHandler: function(form){
- var valores = $(form).serialize();
- $.ajax({
- url: medrent_ajax.ajax_url,
- type: 'POST',
- data: new FormData( jQuery(form)[0] ),
- processData: false,
- contentType: false,
- beforeSend: function(){
- $(form).find('.cargando').removeClass('d-none');
- $(form).find('button[type="submit"]').addClass('disabled');
- },
- error: function(){
- },
- success: function(response){
- $(form).find('.cargando').addClass('d-none');
- $(form).find('.exitoso').removeClass('d-none');
- $(form).find('button[type="submit"]').removeClass('disabled');
- $(form)[0].reset();
- }
- });
- }
- });
- jQuery('#form-contacto').on('change', '#tipo_mensaje', function(event) {
- event.preventDefault();
- var tipo = jQuery(this).val();
- console.log( tipo );
- jQuery('.secciones-flotantes').addClass('d-none');
- if( tipo == "soporte-tecnico" ){
- jQuery('#contenedor-form-soporte').removeClass('d-none');
- }else if( tipo == "financiamiento" ){
- jQuery('#contenedor-form-financiamiento').removeClass('d-none');
- }else{
- jQuery('.secciones-flotantes').addClass('d-none');
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement