Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- $('#ModalOnload').modal('show');
- // Close all other boxes on start
- $("#first-box").hide();
- $("#second-box").hide();
- $("#third-box").hide();
- $("#fourth-box").hide();
- $("#fifth-box").hide();
- $("#fifth-box-error-exist").hide();
- $("#fifth-box-error-expired").hide();
- $('.sizes-select').selectize({
- onInitialize: function() {
- $('.sizes-select').next('.selectize-control').find('input').attr('disabled', 'disabled');
- }
- });
- // Toolbox
- $("#item1").on('click', function() {
- $("#main-box").hide();
- $("#first-box").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#first-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#first-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $("#second-box").hide();
- $("#third-box").hide();
- $("#fourth-box").hide();
- $("#fifth-box").hide();
- $('#first-box .btn-back').show();
- $('.bdr-icon-toolbox').hide();
- if ($(window).width() >= 768) {
- $('.site-header .bdr-icon-toolbox').hide();
- }
- });
- $("#item2").click(function() {
- $("#main-box").hide();
- $("#first-box").hide();
- $("#second-box").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#second-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#second-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $("#third-box").hide();
- $("#fourth-box").hide();
- $("#fifth-box").hide();
- $('#second-box .btn-back').show();
- $('.bdr-icon-toolbox').hide();
- $('.site-header .bdr-icon-toolbox').hide();
- });
- $("#item3").click(function() {
- $("#main-box").hide();
- $("#first-box").hide();
- $("#second-box").hide();
- $("#third-box").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#third-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#third-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $("#fourth-box").hide();
- $("#fifth-box").hide();
- $('#third-box .btn-back').show();
- $('.bdr-icon-toolbox').hide();
- $('.site-header .bdr-icon-toolbox').hide();
- });
- $("#item4").click(function() {
- $("#main-box").hide();
- $("#first-box").hide();
- $("#second-box").hide();
- $("#third-box").hide();
- $("#fourth-box").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#fourth-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#fourth-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $("#fifth-box").hide();
- $('#fourth-box .btn-back').show();
- $('.bdr-icon-toolbox').hide();
- $('.site-header .bdr-icon-toolbox').hide();
- });
- // // add value on outside object
- // $('.fondo-inicio *').on('click', function() {
- // var input = $('.search-ot')[0].selectize
- // var crushVal = $('input.input-exp').val();
- // if (crushVal != '') {
- // input.addOption({
- // text: crushVal,
- // value: crushVal
- // });
- // input.addItem(crushVal);
- // }
- // });
- // close modal
- $('.modal-dialog').on('click', function() {
- $('.modal').modal('hide');
- });
- // $('.search-ot .item a.remove').focus(function() {
- // console.log('remover');
- // $(this).parent('item').remove();
- // });
- $("#item5").click(function(e) {
- if ($('.search-ot .selectize-input').hasClass('has-options')) {
- var crush = '0';
- $('.search-ot .selectize-input.has-options .item').each(function() {
- var valor = $(this).data('value');
- if (valor == 123) {
- crush = valor;
- } else if (valor == 456) {
- crush = valor;
- }
- })
- var input = $('.search-ot')[0].selectize
- var crushVal = $('input.input-exp').val();
- if (crushVal != '') {
- input.addOption({
- text: crushVal,
- value: crushVal
- });
- input.addItem(crushVal);
- }
- $('.error-ot').fadeOut();
- $("#main-box").hide();
- $("#first-box").hide();
- $("#second-box").hide();
- $("#third-box").hide();
- $("#fourth-box").hide();
- if (crush == 123) {
- // en caso de OT incorrecta
- $("#fifth-box-error-exist").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#fifth-box-error-exist").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#fifth-box-error-exist").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $('#fifth-box-error-exist .btn-back').show();
- errorWarning();
- } else if (crush == 456) {
- //en caso de OT expirada
- $("#fifth-box-error-expired").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#fifth-box-error-expired").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#fifth-box-error-expired").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $('#fifth-box-error-expired .btn-back').show();
- warningError();
- } else if (crush != 123 && crush != 456) {
- //en caso de que sea una OT real
- $("#fifth-box").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#fifth-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#fifth-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $('#fifth-box .btn-back').show();
- }
- $('.bdr-icon-toolbox').hide();
- $('.site-header .bdr-icon-toolbox').hide();
- } else if ($('input.input-exp').val() != '') {
- var input = $('.search-ot')[0].selectize
- var crushVal = $('input.input-exp').val();
- if (crushVal != '') {
- input.addOption({
- text: crushVal,
- value: crushVal
- });
- input.addItem(crushVal);
- }
- var crush = $('input.input-exp').val();
- $('.error-ot').fadeOut();
- $("#main-box").hide();
- $("#first-box").hide();
- $("#second-box").hide();
- $("#third-box").hide();
- $("#fourth-box").hide();
- if (crush == 123) {
- // en caso de OT incorrecta
- $("#fifth-box-error-exist").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#fifth-box-error-exist").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#fifth-box-error-exist").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $('#fifth-box-error-exist .btn-back').show();
- errorWarning();
- } else if (crush == 456) {
- //en caso de OT expirada
- $("#fifth-box-error-expired").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#fifth-box-error-expired").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#fifth-box-error-expired").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $('#fifth-box-error-expired .btn-back').show();
- errorWarning();
- } else if (crush != 123 && crush != 456) {
- //en caso de que sea una OT real
- $("#fifth-box").fadeIn(300);
- if ($(window).scrollTop() > 0) {
- $("#fifth-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- } else {
- $("#fifth-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
- }
- $('#fifth-box .btn-back').show();
- }
- // btn.addClass('full-btn');
- $('.bdr-icon-toolbox').hide();
- $('.site-header .bdr-icon-toolbox').hide();
- $('input.input-exp').val('');
- } else {
- $('.error-ot.empty').stop(true).fadeIn().delay(5000).fadeOut();
- e.stopPropagation();
- }
- });
- //mensajes error y warning
- function errorWarning() {
- $('.input-exp').val('');
- $('.error-ot.empty').hide();
- $('.error-ot.invalid').fadeIn(300, function() {
- $('.error-ot.invalid').parent('.input-group').find('input').css({ 'border': '1px solid #D0021B' });
- }).delay(5000).fadeOut(function() {
- $('.error-ot.invalid').parent('.input-group').find('input').css({ 'border': '1px solid #CCCCCC' });
- });
- }
- function warningError() {
- $('.input-exp').val('');
- $('.error-ot.empty').hide();
- $('.error-ot.expired').fadeIn(300, function() {
- $('.error-ot.expired').parent('.input-group').find('input').css({ 'border': '1px solid #FFB002' });
- }).delay(5000).fadeOut(function() {
- $('.error-ot.expired').parent('.input-group').find('input').css({ 'border': '1px solid #CCCCCC' });
- });
- }
- // Back
- $("#first-box .btn-back").click(function() {
- $("#main-box").show();
- $("#first-box").hide();
- mobileToolboxIcon();
- });
- $("#second-box .btn-back").click(function() {
- $("#main-box").show();
- $("#second-box").hide();
- mobileToolboxIcon();
- });
- $("#third-box .btn-back").click(function() {
- $("#main-box").show();
- $("#third-box").hide();
- mobileToolboxIcon();
- });
- $("#fourth-box .btn-back").click(function() {
- $("#main-box").show();
- $("#fourth-box").hide();
- mobileToolboxIcon();
- });
- $("#fifth-box .btn-back").click(function() {
- $("#main-box").show();
- $("#fifth-box").hide();
- mobileToolboxIcon();
- });
- $("#fifth-box-error-exist .btn-back, #fifth-box-error-exist .body-footer a").click(function() {
- $("#main-box").show();
- $("#fifth-box-error-exist").hide();
- $('.error-ot.empty, .error-ot.invalid').hide();
- mobileToolboxIcon();
- });
- $("#fifth-box-error-expired .btn-back, #fifth-box-error-expired .body-footer a").click(function() {
- $("#main-box").show();
- $("#fifth-box-error-expired").hide();
- $('.error-ot.empty, .error-ot.invalid').hide();
- mobileToolboxIcon();
- });
- // ToolBox Tabs buttons
- $('.tool-box .body-box .btn-group .btn').on('click', function() {
- $('.tool-box .body-box .btn-group .btn').removeClass('active-tab');
- $(this).addClass('active-tab');
- });
- // Chosen touch support.
- if ($('.chosen-container').length > 0) {
- $('.chosen-container').on('touchstart', function(e) {
- e.stopPropagation();
- e.preventDefault();
- // Trigger the mousedown event.
- $(this).trigger('mousedown');
- });
- }
- //stick in the fixed 100% height behind the navbar but don't wrap it
- $('#slide-nav.navbar-top').after($('<div class="inverse" id="navbar-height-col"></div>'));
- var selected = '#slidemenu, #page-content, body, .navbar, .navbar-top, .navbar-mobile';
- $.fn.responsiveTabs = function() {
- this.addClass('responsive-tabs');
- // this.append($('<span class="glyphicon glyphicon-triangle-bottom"></span>'));
- this.append($('<span class="glyphicon glyphicon-menu-down"></span>'));
- this.append($('<span class="glyphicon glyphicon-menu-top"></span>'));
- this.on('click', 'li.active > a, span.glyphicon', function() {
- this.toggleClass('open');
- }.bind(this));
- this.on('click', 'li:not(.active) > a', function() {
- this.removeClass('open');
- }.bind(this));
- };
- $('#nav-tabs-services').responsiveTabs();
- $(window).scroll(function() {
- if ($(this).scrollTop() > 150) {
- $('#MenuSticky').fadeIn(500);
- } else {
- $('#MenuSticky').fadeOut(500);
- }
- });
- $(window).on('resize', function() {
- if ($(window).width() > 768) {
- // do something here
- }
- if ($(window).width() >= 768) {
- $('#MenuSticky').hide();
- }
- if ($(window).width() <= 768) {
- $('.alert-warning').hide();
- }
- });
- $('#MenuSticky .subnav').hide();
- $('.main-tab-item.active:after').hide();
- $('#MenuSticky .main-tab-link').on('click', function() {
- $('.subnav').removeClass('move');
- setTimeout(function() {
- $('#MenuSticky .subnav').addClass("move");
- }, 100);
- // $('#MenuSticky .subnav').addClass('move');
- if ($('#MenuSticky .subnav').hide()) {
- $('#MenuSticky .subnav').show().fadeIn(500);
- } else {
- $('#MenuSticky .subnav').hide().fadeIn(500);
- }
- if ($('.main-tab-item').hasClass('active')) {
- $('.main-tab-item.active:after').show();
- } else {
- $('.main-tab-item.active:after').hide();
- }
- });
- $(function() {
- var $win = $(window); // or $box parent container
- var $box = $(".menu-sticky .subnav.move", ".menu-sticky .main-tab-item.active:after");
- // var $log = $(".log");
- $win.on("click.Bst", function(event) {
- if (
- $box.has(event.target).length == 0 //checks if descendants of $box was clicked
- &&
- !$box.is(event.target) //checks if the $box itself was clicked
- ) {
- $('.menu-sticky .subnav.move').hide();
- $('.menu-sticky .main-tab-item.active:after').hide();
- } else {
- $('.menu-sticky .subnav.move').show();
- $('.menu-sticky .main-tab-item.active:after').show();
- }
- });
- });
- // Active Maker animation to navs main
- function moveMarker() {
- var activeNav = $('.active a');
- var activewidth = $(activeNav).width();
- var activePadLeft = parseFloat($(activeNav).css('padding-left'));
- var activePadRight = parseFloat($(activeNav).css('padding-right'));
- var totalWidth = activewidth + activePadLeft + activePadRight;
- var precedingAnchorWidth = anchorWidthCounter();
- // TODO:
- // Find the total widths of all of the anchors
- // to the left of the active anchor.
- var activeMarker = $('.active-marker');
- $(activeMarker).css('display', 'block');
- $(activeMarker).css('width', totalWidth);
- $(activeMarker).css('left', precedingAnchorWidth);
- // TODO:
- // Using the calculated total widths of preceding anchors,
- // Set the left: css value to that number.
- }
- $(window).load(function() {
- moveMarker();
- });
- function anchorWidthCounter() {
- var anchorWidths = 0;
- var a;
- var aWidth;
- var aPadLeft;
- var aPadRight;
- var aTotalWidth;
- $('.nav-menu .nav-main li').each(function(index, elem) {
- var activeTest = $(elem).hasClass('active');
- if (activeTest) {
- // Break out of the each function.
- return false;
- }
- a = $(elem).find('a');
- aWidth = a.width();
- aPadLeft = parseFloat(a.css('padding-left'));
- aPadRight = parseFloat(a.css('padding-right'));
- aTotalWidth = aWidth + aPadLeft + aPadRight;
- anchorWidths = anchorWidths + aTotalWidth;
- });
- return anchorWidths;
- }
- $('.nav-menu .nav-main a').click(function(e) {
- e.preventDefault();
- $('.nav-menu .nav-main li').removeClass('active');
- $(this).parents('li').addClass('active');
- moveMarker();
- });
- // TabPane
- $('#personTab').on('click', function() {
- $('#personTabPane').show();
- $('#businessTabPane').hide();
- $('#entrepreneursTabPane').hide();
- $('#ecommerceTabPane').hide();
- });
- $('#businessTab').on('click', function() {
- $('#personTabPane').hide();
- $('#businessTabPane').show();
- $('#entrepreneursTabPane').hide();
- $('#ecommerceTabPane').hide();
- });
- $('#entrepreneursTab').on('click', function() {
- $('#personTabPane').hide();
- $('#businessTabPane').hide();
- $('#entrepreneursTabPane').show();
- $('#ecommerceTabPane').hide();
- });
- $('#ecommerceTab').on('click', function() {
- $('#personTabPane').hide();
- $('#businessTabPane').hide();
- $('#entrepreneursTabPane').hide();
- $('#ecommerceTabPane').show();
- });
- // Nav icon Hamburger
- $('#nav-icon-hamburguer, .close-nav-mobile, .pattern-nav').click(function() {
- // $(this).toggleClass('cross');
- $('body').toggleClass('menu-view');
- if ($('body').hasClass('menu-view')) {
- $('html').css({ 'overflow': 'hidden' });
- $('.pattern-nav').delay('250').show(0);
- } else {
- $('html').css({ 'overflow': 'auto' });
- $('#slidemenu .dropdown-menu').removeClass('view-son');
- $('.pattern-nav').hide(0);
- }
- });
- $('#slidemenu .dropdown-toggle').on('click', function() {
- var son = $(this).next('.dropdown-menu');
- son.addClass('view-son');
- });
- $('#slidemenu .menu-back').on('click', function() {
- var dad = $(this).parent().parent('.dropdown-menu');
- dad.removeClass('view-son');
- });
- $('#page-content').children().on('click', function(e) {
- // e.stopPropagation();
- // console.log('lopincho');
- // var selectizes = $('.searchtize')[0].selectize;
- // selectizes.clear();
- // selectizes.clearOptions();
- if (!$(this).hasClass('is-active')) {
- $('.search-container.is-active').each(function() {
- onBlurSearch();
- });
- }
- });
- // $('.site-header').on('click', function() {
- // if (!$(this).hasClass('is-active')) {
- // $('.search-container.is-active').each(function() {
- // onBlurSearch();
- // });
- // }
- // })
- // Search Animated Menu Main
- $('.nav-menu .search-icon').on('click', function(e) {
- e.stopPropagation();
- $('.nav-menu .search-container').toggleClass('is-active');
- if ($('.nav-menu .search-container').hasClass('is-active')) {
- // console.log('paso 1');
- $('.logo').hide();
- $('.nav-menu #search-box-desktop').attr('placeholder', '¿Qué estás buscando?');
- $('.active-marker.active-triangle-person').fadeOut('fast');
- } else {
- // console.log('paso 2');
- $('.logo').show();
- $('.nav-menu #search-box-desktop').attr('placeholder', '');
- $('#search-box-sticky').attr('placeholder', '');
- $('.nav-menu #search-box-desktop').prop('value', '');
- $('.active-marker.active-triangle-person').fadeIn('fast');
- }
- });
- // Menu Sticky
- $(function() {
- var shrinkElement = 10;
- $(window).scroll(function() {
- var scroll = getCurrentScroll();
- if (scroll >= shrinkElement) {
- $('.site-header .bdr-icon-toolbox').addClass('shrink-element');
- $('.navbar-mobile .logo-image').addClass('shrink-element');
- } else {
- $('.site-header .bdr-icon-toolbox').removeClass('shrink-element');
- $('.navbar-mobile .logo-image').removeClass('shrink-element');
- }
- });
- function getCurrentScroll() {
- return window.pageYOffset || document.documentElement.scrollTop;
- }
- });
- $('#MenuSticky #search-submit, #MenuSticky .search-icon').on('click', function(e) {
- e.stopPropagation();
- $('#MenuSticky .search-container').toggleClass('is-active');
- if ($('#MenuSticky .search-container').hasClass('is-active')) {
- // console.log('paso 1');
- // $('.logo').hide();
- $('#MenuSticky #search-box-sticky').attr('placeholder', '¿Qué estás buscando?');
- $('.main-tab-item.active').addClass('active-follow');
- $('.main-tab-item.active').removeClass('active');
- } else {
- // console.log('paso 2');
- // $('.logo').show();
- $('#MenuSticky #search-box-sticky').attr('placeholder', '');
- $('.main-tab-item.active-follow').addClass('active');
- $('.main-tab-item.active-follow').removeClass('active-follow');
- }
- });
- // scroll top on click toolbox
- $('a[href="#toolBox"]').click(function() {
- $('html, body').animate({
- scrollTop: $($(this).attr('href')).offset().top - 100
- // if($('.alert').length) {
- // scrollTop: $($(this).attr('href')).offset().top + alertHeight - 100
- // }
- }, 400);
- return false;
- });
- // Scrolltop any element with class '.back-to-top'
- $('.back-to-top').click(function() {
- $('.modal').modal('hide');
- $('body,html').animate({
- scrollTop: $("body").offset().top - 0
- }, 400);
- return false;
- });
- // tabs services
- $('#nav-tabs-services a').click(function(e) {
- e.preventDefault();
- $(this).tab('show');
- });
- //Guideline scripts
- $("#menu-toggle-guideline").click(function(e) {
- e.preventDefault();
- $("#wrapper-guideline").toggleClass("toggled");
- });
- // Button disabled
- // $('.isAccept').click(function() {
- // if (!$(this).is(':checked')) {
- // $('.enableButton').attr('disabled', false);
- // $('.enableButton').removeClass('c-button--secondary');
- // } else {
- // $('.enableButton').attr('disabled', 'disabled');
- // $('.enableButton').addClass('c-button--secondary');
- // }
- // });
- // //btn-continue
- // $('.btn-continue').on('click', function() {
- // $('.isAccept').attr('checked', false);
- // $('.enableButton').removeClass('c-button--secondary');
- // $('#enableButton').attr('disabled', 'disabled');
- // });
- $('.alert .close').on('click', function() {
- $('* .alert-warning').remove();
- });
- // Alert close
- var alertHeight = $('.alert-warning').innerHeight();
- var navMobile = $('.navbar-mobile').innerHeight() + 40;
- // console.log(navMobile);
- if ($(window).width() < 768) {
- // console.log($('.alert-warning').length);
- if ($('.alert-warning').length > 0) {
- console.log('estamos ackiq');
- $('#section-slide').css('margin-top', alertHeight + navMobile);
- $('.site-header .bdr-icon-toolbox').addClass('bdr-with--alert');
- $('.site-header .bdr-icon-toolbox.bdr-with--alert').css('top', alertHeight + navMobile - 36)
- if ($('.alert-warning .close').on('click', function() {
- $('.site-header .bdr-icon-toolbox').removeClass('bdr-with--alert');
- $('.site-header .bdr-icon-toolbox').css('top', navMobile - 38)
- $('#section-slide').css('margin-top', navMobile);
- }));
- } else {
- $('.site-header .bdr-icon-toolbox').addClass('bdr-with--alert');
- }
- $('.alert .close').on('click', function() {
- $('* .alert-warning').remove();
- })
- }
- //searchbox
- $('.searchtize input').on('focus blur', function() {
- // var padre = $(this).parents('.search-wrapper');
- // padre.toggleClass('on-focus');
- });
- // $('.searchtize').selectize({
- // options: [
- // { match: 'Bolsa Grande $400', desc: 'Tamaño: 35X27 cm' },
- // { match: 'Bolsa Mediana $369', desc: 'Tamaño: 33X22 cm' },
- // { match: 'Fulfillment', desc: 'Recibimos tus productos' }
- // ],
- // maxItems: 1,
- // openOnFocus: false,
- // highlight: false,
- // labelField: 'match',
- // valueField: 'match',
- // searchField: 'match'
- // });
- $('#searchBox').on('submit', function(e) {
- e.preventDefault();
- e.stopPropagation();
- var padre = $(this);
- var input = padre.find('.searchtize input');
- if (input.val() == '' && $('input.searchtize').val() == '') {
- padre.find('.error-search').stop(true).fadeIn().delay(5000).fadeOut();
- // var cant = 0;
- // $('#searchBox .selectize-input div[data-value]').each(function(index) {
- // cant = index;
- // console.log(index);
- // })
- // if (cant != 0) {
- // padre.find('.error-search').stop(true).fadeIn().delay(5000).fadeOut();
- // }
- } else {
- console.log('realizando busqueda .....');
- return true;
- }
- });
- // $('.search-container *').on('click', function() {
- // console.log('hizo click');
- // });
- $('.searchtize').selectize({
- maxItems: 1,
- valueField: 'match',
- // labelField: 'desc',
- persist: false,
- openOnFocus: false,
- searchField: ['match'],
- clearOnBlur: false,
- highlight: false,
- onInitialize: function() {
- var valorBuscado = '';
- var dataBuscado = '';
- $('#search-box-desktop-selectized').on('keyup', function() {
- valorBuscado = $(this).val();
- $(this).parents('form').find('input.search-hidden').val(valorBuscado);
- });
- //submit search general
- $('#search-submit-desktop, #search-submit').on('click', function(e) {
- e.stopImmediatePropagation();
- $('.search-container .selectize-input.has-items div[data-value]').each(function() {
- if ($(this).data('value') != '') {
- dataBuscado = $(this).data('value');
- }
- })
- valorBuscado = $('input.search-hidden').val();
- if (dataBuscado != '') {
- console.log('enviando form....');
- $('#search-submit-desktop').parents('form').submit();
- } else {
- if (valorBuscado == '') {
- console.log('no tiene nada');
- $(this).next('.error-search.empty').stop(true).fadeIn().delay(4000).fadeOut();
- $('#search-box-desktop-selectized').focus();
- } else {
- console.log('enviando form....');
- $('#search-submit-desktop').parents('form').submit();
- }
- }
- });
- $('#search-box-desktop-selectized').focus(function() {
- $('.search-container').css({ 'overflow': 'inherit', 'height': 'auto' });
- })
- $('#search-box-desktop-selectized').blur(function() {
- $('.error-search.empty').hide();
- $('.search-container').css({ 'overflow': 'hidden', 'height': '42px' });
- })
- },
- onType: function() {
- $('#searchBox .error-search').hide();
- $('.error-search.empty').hide();
- },
- onFocus: function(element) {
- // var padre = $('.search-wrapper');
- // padre.toggleClass('on-focus');
- $('.error-search.empty.is-desktop').fadeOut();
- },
- onBlur: function(element) {
- // var padre = $('.search-wrapper');
- // padre.toggleClass('on-focus');
- },
- options: [
- { match: 'Bolsa Grande $400', desc: 'Tamaño: 35X27 cm' },
- { match: 'Bolsa Mediana $369', desc: 'Tamaño: 33X22 cm' },
- { match: 'Fulfillment', desc: 'Recibimos tus productos' }
- ],
- render: {
- item: function(item, escape) {
- return '<div>' +
- (item.match ? '<span class="match">' + escape(item.match) + '</span>' : '') +
- // (item.desc ? '<span class="desc">' + escape(item.desc) + '</span>' : '') +
- '</div>';
- },
- option: function(item, escape) {
- var label = item.match || item.desc;
- var caption = item.match ? item.desc : null;
- return '<div>' +
- '<span class="label">' + escape(label) + '</span>' +
- (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +
- '</div>';
- }
- },
- createFilter: function(input) {},
- create: function(input) {}
- });
- // $(window).resize(function() {
- // var width = $(window).width();
- // if (width < 1200){
- // alert('Your screen is too small');
- // }
- // });
- if ($(window).width() >= 768) {
- if ($(window).width() < 992) {
- $(".navbar-controls #btnLoginMobile").click(function() {
- $("#mainMenuWrapp").hide();
- $("#mainLoginWrapp").fadeIn();
- });
- $("#mainLoginWrapp .close").click(function() {
- $("#mainLoginWrapp").hide();
- $("#mainMenuWrapp").fadeIn();
- });
- }
- } else {
- $("#btnLoginMobile").click(function() {
- $('.site-header .bdr-icon-toolbox').css('margin-top', 78)
- $('#section-slide').css('top', 72);
- $("#mainLoginWrappMobile").slideDown(200, function() {});
- });
- $("#mainLoginWrappMobile .close").click(function() {
- $("#mainLoginWrappMobile").slideUp(200);
- $('.site-header .bdr-icon-toolbox').css('margin-top', 0)
- $('#section-slide').css('top', 0);
- });
- }
- $('.search-container .selectize-control .selectize-dropdown').on('click', function() {
- // $('.nav-menu .search-container').addClass('is-active');
- })
- // ocultar el buscador general en version mobile
- $('#myNav.overlay .pattern').on('click', function() {
- closeNav();
- })
- });
- //click in other side for search
- $(document).click(function(e) {
- var elemento = $('.search-container.is-active .selectize-dropdown.searchtize');
- var container = $(".search-container");
- if (elemento.is(':visible')) {
- console.log('buscador visible');
- } else {
- if (container.hasClass('is-active')) {
- }
- if (!container.is(e.target) && container.has(e.target).length === 0) {
- onBlurSearch();
- } else {}
- }
- });
- document.addEventListener("touchstart", function() {}, true);
- // function mobile icon-toolbox
- function mobileToolboxIcon() {
- if ($(window).width() >= 768) {
- $('.site-header .bdr-icon-toolbox').hide();
- $('.tool-box .bdr-icon-toolbox').show();
- } else {
- $('.site-header .bdr-icon-toolbox').show();
- }
- }
- function openNav() {
- $('body').addClass('modal-open');
- document.getElementById("myNav").style.width = "100%";
- }
- function closeNav() {
- $('body').removeClass('modal-open');
- document.getElementById("myNav").style.width = "0%";
- var caja = $('#searchBox .searchtize')[0].selectize;
- caja.clear();
- $('#searchBox .error-search').hide();
- }
- function numberWithDot(x) {
- return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
- }
- function onBlurSearch() {
- $('.error-search.empty').hide();
- $('.logo').show();
- $('.search-container').removeClass('is-active');
- $('.nav-menu #search-box-desktop, #search-box-sticky').prop('value', '');
- $('.nav-menu #search-box-desktop, #search-box-sticky').attr('placeholder', '');
- $('.active-marker.active-triangle-person').fadeIn('fast');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement