Advertisement
marcelobizarro

17:25 scripts.js

Sep 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.62 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3. $('#ModalOnload').modal('show');
  4.  
  5. // Close all other boxes on start
  6. $("#first-box").hide();
  7. $("#second-box").hide();
  8. $("#third-box").hide();
  9. $("#fourth-box").hide();
  10. $("#fifth-box").hide();
  11. $("#fifth-box-error-exist").hide();
  12. $("#fifth-box-error-expired").hide();
  13. $('.sizes-select').selectize({
  14. onInitialize: function() {
  15. $('.sizes-select').next('.selectize-control').find('input').attr('disabled', 'disabled');
  16. }
  17. });
  18.  
  19. // Toolbox
  20. $("#item1").on('click', function() {
  21. $("#main-box").hide();
  22.  
  23. $("#first-box").fadeIn(300);
  24. if ($(window).scrollTop() > 0) {
  25. $("#first-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  26. } else {
  27. $("#first-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  28. }
  29.  
  30. $("#second-box").hide();
  31. $("#third-box").hide();
  32. $("#fourth-box").hide();
  33. $("#fifth-box").hide();
  34. $('#first-box .btn-back').show();
  35. $('.bdr-icon-toolbox').hide();
  36. if ($(window).width() >= 768) {
  37. $('.site-header .bdr-icon-toolbox').hide();
  38. }
  39. });
  40.  
  41. $("#item2").click(function() {
  42. $("#main-box").hide();
  43. $("#first-box").hide();
  44.  
  45. $("#second-box").fadeIn(300);
  46. if ($(window).scrollTop() > 0) {
  47. $("#second-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  48. } else {
  49. $("#second-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  50. }
  51.  
  52. $("#third-box").hide();
  53. $("#fourth-box").hide();
  54. $("#fifth-box").hide();
  55. $('#second-box .btn-back').show();
  56. $('.bdr-icon-toolbox').hide();
  57. $('.site-header .bdr-icon-toolbox').hide();
  58. });
  59.  
  60. $("#item3").click(function() {
  61. $("#main-box").hide();
  62. $("#first-box").hide();
  63. $("#second-box").hide();
  64.  
  65. $("#third-box").fadeIn(300);
  66. if ($(window).scrollTop() > 0) {
  67. $("#third-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  68. } else {
  69. $("#third-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  70. }
  71.  
  72. $("#fourth-box").hide();
  73. $("#fifth-box").hide();
  74. $('#third-box .btn-back').show();
  75. $('.bdr-icon-toolbox').hide();
  76. $('.site-header .bdr-icon-toolbox').hide();
  77. });
  78.  
  79. $("#item4").click(function() {
  80. $("#main-box").hide();
  81. $("#first-box").hide();
  82. $("#second-box").hide();
  83. $("#third-box").hide();
  84.  
  85. $("#fourth-box").fadeIn(300);
  86. if ($(window).scrollTop() > 0) {
  87. $("#fourth-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  88. } else {
  89. $("#fourth-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  90. }
  91.  
  92. $("#fifth-box").hide();
  93. $('#fourth-box .btn-back').show();
  94. $('.bdr-icon-toolbox').hide();
  95. $('.site-header .bdr-icon-toolbox').hide();
  96. });
  97.  
  98. // // add value on outside object
  99. // $('.fondo-inicio *').on('click', function() {
  100. // var input = $('.search-ot')[0].selectize
  101. // var crushVal = $('input.input-exp').val();
  102. // if (crushVal != '') {
  103. // input.addOption({
  104. // text: crushVal,
  105. // value: crushVal
  106. // });
  107. // input.addItem(crushVal);
  108. // }
  109. // });
  110.  
  111. // close modal
  112. $('.modal-dialog').on('click', function() {
  113. $('.modal').modal('hide');
  114. });
  115.  
  116. // $('.search-ot .item a.remove').focus(function() {
  117. // console.log('remover');
  118. // $(this).parent('item').remove();
  119. // });
  120.  
  121. $("#item5").click(function(e) {
  122. if ($('.search-ot .selectize-input').hasClass('has-options')) {
  123. var crush = '0';
  124. $('.search-ot .selectize-input.has-options .item').each(function() {
  125. var valor = $(this).data('value');
  126. if (valor == 123) {
  127. crush = valor;
  128. } else if (valor == 456) {
  129. crush = valor;
  130. }
  131. })
  132. var input = $('.search-ot')[0].selectize
  133. var crushVal = $('input.input-exp').val();
  134. if (crushVal != '') {
  135. input.addOption({
  136. text: crushVal,
  137. value: crushVal
  138. });
  139. input.addItem(crushVal);
  140. }
  141. $('.error-ot').fadeOut();
  142. $("#main-box").hide();
  143. $("#first-box").hide();
  144. $("#second-box").hide();
  145. $("#third-box").hide();
  146. $("#fourth-box").hide();
  147. if (crush == 123) {
  148. // en caso de OT incorrecta
  149. $("#fifth-box-error-exist").fadeIn(300);
  150. if ($(window).scrollTop() > 0) {
  151. $("#fifth-box-error-exist").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  152. } else {
  153. $("#fifth-box-error-exist").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  154. }
  155. $('#fifth-box-error-exist .btn-back').show();
  156. errorWarning();
  157. } else if (crush == 456) {
  158. //en caso de OT expirada
  159. $("#fifth-box-error-expired").fadeIn(300);
  160. if ($(window).scrollTop() > 0) {
  161. $("#fifth-box-error-expired").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  162. } else {
  163. $("#fifth-box-error-expired").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  164. }
  165. $('#fifth-box-error-expired .btn-back').show();
  166. warningError();
  167. } else if (crush != 123 && crush != 456) {
  168. //en caso de que sea una OT real
  169. $("#fifth-box").fadeIn(300);
  170. if ($(window).scrollTop() > 0) {
  171. $("#fifth-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  172. } else {
  173. $("#fifth-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  174. }
  175. $('#fifth-box .btn-back').show();
  176. }
  177. $('.bdr-icon-toolbox').hide();
  178. $('.site-header .bdr-icon-toolbox').hide();
  179.  
  180. } else if ($('input.input-exp').val() != '') {
  181.  
  182. var input = $('.search-ot')[0].selectize
  183. var crushVal = $('input.input-exp').val();
  184. if (crushVal != '') {
  185. input.addOption({
  186. text: crushVal,
  187. value: crushVal
  188. });
  189. input.addItem(crushVal);
  190. }
  191. var crush = $('input.input-exp').val();
  192. $('.error-ot').fadeOut();
  193. $("#main-box").hide();
  194. $("#first-box").hide();
  195. $("#second-box").hide();
  196. $("#third-box").hide();
  197. $("#fourth-box").hide();
  198. if (crush == 123) {
  199. // en caso de OT incorrecta
  200. $("#fifth-box-error-exist").fadeIn(300);
  201. if ($(window).scrollTop() > 0) {
  202. $("#fifth-box-error-exist").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  203. } else {
  204. $("#fifth-box-error-exist").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  205. }
  206. $('#fifth-box-error-exist .btn-back').show();
  207. errorWarning();
  208. } else if (crush == 456) {
  209. //en caso de OT expirada
  210. $("#fifth-box-error-expired").fadeIn(300);
  211. if ($(window).scrollTop() > 0) {
  212. $("#fifth-box-error-expired").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  213. } else {
  214. $("#fifth-box-error-expired").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  215. }
  216. $('#fifth-box-error-expired .btn-back').show();
  217. errorWarning();
  218. } else if (crush != 123 && crush != 456) {
  219. //en caso de que sea una OT real
  220. $("#fifth-box").fadeIn(300);
  221. if ($(window).scrollTop() > 0) {
  222. $("#fifth-box").delay(100).effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  223. } else {
  224. $("#fifth-box").effect("fadeIn", { times: 2, distance: 10, direction: "left" }, 300); //bounce
  225. }
  226. $('#fifth-box .btn-back').show();
  227. }
  228. // btn.addClass('full-btn');
  229. $('.bdr-icon-toolbox').hide();
  230. $('.site-header .bdr-icon-toolbox').hide();
  231. $('input.input-exp').val('');
  232.  
  233. } else {
  234. $('.error-ot.empty').stop(true).fadeIn().delay(5000).fadeOut();
  235. e.stopPropagation();
  236. }
  237.  
  238. });
  239.  
  240. //mensajes error y warning
  241. function errorWarning() {
  242. $('.input-exp').val('');
  243. $('.error-ot.empty').hide();
  244. $('.error-ot.invalid').fadeIn(300, function() {
  245. $('.error-ot.invalid').parent('.input-group').find('input').css({ 'border': '1px solid #D0021B' });
  246. }).delay(5000).fadeOut(function() {
  247. $('.error-ot.invalid').parent('.input-group').find('input').css({ 'border': '1px solid #CCCCCC' });
  248. });
  249. }
  250.  
  251. function warningError() {
  252. $('.input-exp').val('');
  253. $('.error-ot.empty').hide();
  254. $('.error-ot.expired').fadeIn(300, function() {
  255. $('.error-ot.expired').parent('.input-group').find('input').css({ 'border': '1px solid #FFB002' });
  256. }).delay(5000).fadeOut(function() {
  257. $('.error-ot.expired').parent('.input-group').find('input').css({ 'border': '1px solid #CCCCCC' });
  258. });
  259. }
  260.  
  261.  
  262. // Back
  263. $("#first-box .btn-back").click(function() {
  264. $("#main-box").show();
  265. $("#first-box").hide();
  266. mobileToolboxIcon();
  267. });
  268.  
  269. $("#second-box .btn-back").click(function() {
  270. $("#main-box").show();
  271. $("#second-box").hide();
  272. mobileToolboxIcon();
  273. });
  274.  
  275. $("#third-box .btn-back").click(function() {
  276. $("#main-box").show();
  277. $("#third-box").hide();
  278. mobileToolboxIcon();
  279. });
  280.  
  281. $("#fourth-box .btn-back").click(function() {
  282. $("#main-box").show();
  283. $("#fourth-box").hide();
  284. mobileToolboxIcon();
  285. });
  286.  
  287. $("#fifth-box .btn-back").click(function() {
  288. $("#main-box").show();
  289. $("#fifth-box").hide();
  290. mobileToolboxIcon();
  291. });
  292. $("#fifth-box-error-exist .btn-back, #fifth-box-error-exist .body-footer a").click(function() {
  293. $("#main-box").show();
  294. $("#fifth-box-error-exist").hide();
  295. $('.error-ot.empty, .error-ot.invalid').hide();
  296. mobileToolboxIcon();
  297. });
  298. $("#fifth-box-error-expired .btn-back, #fifth-box-error-expired .body-footer a").click(function() {
  299. $("#main-box").show();
  300. $("#fifth-box-error-expired").hide();
  301. $('.error-ot.empty, .error-ot.invalid').hide();
  302. mobileToolboxIcon();
  303. });
  304.  
  305. // ToolBox Tabs buttons
  306. $('.tool-box .body-box .btn-group .btn').on('click', function() {
  307. $('.tool-box .body-box .btn-group .btn').removeClass('active-tab');
  308. $(this).addClass('active-tab');
  309. });
  310.  
  311. // Chosen touch support.
  312. if ($('.chosen-container').length > 0) {
  313. $('.chosen-container').on('touchstart', function(e) {
  314. e.stopPropagation();
  315. e.preventDefault();
  316. // Trigger the mousedown event.
  317. $(this).trigger('mousedown');
  318. });
  319. }
  320.  
  321. //stick in the fixed 100% height behind the navbar but don't wrap it
  322. $('#slide-nav.navbar-top').after($('<div class="inverse" id="navbar-height-col"></div>'));
  323.  
  324. var selected = '#slidemenu, #page-content, body, .navbar, .navbar-top, .navbar-mobile';
  325.  
  326. $.fn.responsiveTabs = function() {
  327. this.addClass('responsive-tabs');
  328. // this.append($('<span class="glyphicon glyphicon-triangle-bottom"></span>'));
  329. this.append($('<span class="glyphicon glyphicon-menu-down"></span>'));
  330. this.append($('<span class="glyphicon glyphicon-menu-top"></span>'));
  331.  
  332. this.on('click', 'li.active > a, span.glyphicon', function() {
  333. this.toggleClass('open');
  334. }.bind(this));
  335.  
  336. this.on('click', 'li:not(.active) > a', function() {
  337. this.removeClass('open');
  338. }.bind(this));
  339. };
  340.  
  341. $('#nav-tabs-services').responsiveTabs();
  342.  
  343. $(window).scroll(function() {
  344. if ($(this).scrollTop() > 150) {
  345. $('#MenuSticky').fadeIn(500);
  346. } else {
  347. $('#MenuSticky').fadeOut(500);
  348. }
  349. });
  350.  
  351. $(window).on('resize', function() {
  352. if ($(window).width() > 768) {
  353. // do something here
  354.  
  355. }
  356.  
  357. if ($(window).width() >= 768) {
  358. $('#MenuSticky').hide();
  359. }
  360.  
  361. if ($(window).width() <= 768) {
  362. $('.alert-warning').hide();
  363. }
  364. });
  365.  
  366. $('#MenuSticky .subnav').hide();
  367. $('.main-tab-item.active:after').hide();
  368. $('#MenuSticky .main-tab-link').on('click', function() {
  369. $('.subnav').removeClass('move');
  370. setTimeout(function() {
  371. $('#MenuSticky .subnav').addClass("move");
  372. }, 100);
  373.  
  374. // $('#MenuSticky .subnav').addClass('move');
  375. if ($('#MenuSticky .subnav').hide()) {
  376. $('#MenuSticky .subnav').show().fadeIn(500);
  377. } else {
  378. $('#MenuSticky .subnav').hide().fadeIn(500);
  379. }
  380.  
  381. if ($('.main-tab-item').hasClass('active')) {
  382. $('.main-tab-item.active:after').show();
  383. } else {
  384. $('.main-tab-item.active:after').hide();
  385. }
  386. });
  387.  
  388. $(function() {
  389.  
  390. var $win = $(window); // or $box parent container
  391. var $box = $(".menu-sticky .subnav.move", ".menu-sticky .main-tab-item.active:after");
  392. // var $log = $(".log");
  393.  
  394. $win.on("click.Bst", function(event) {
  395. if (
  396. $box.has(event.target).length == 0 //checks if descendants of $box was clicked
  397. &&
  398. !$box.is(event.target) //checks if the $box itself was clicked
  399. ) {
  400. $('.menu-sticky .subnav.move').hide();
  401. $('.menu-sticky .main-tab-item.active:after').hide();
  402. } else {
  403. $('.menu-sticky .subnav.move').show();
  404. $('.menu-sticky .main-tab-item.active:after').show();
  405. }
  406. });
  407.  
  408. });
  409.  
  410. // Active Maker animation to navs main
  411. function moveMarker() {
  412. var activeNav = $('.active a');
  413. var activewidth = $(activeNav).width();
  414. var activePadLeft = parseFloat($(activeNav).css('padding-left'));
  415. var activePadRight = parseFloat($(activeNav).css('padding-right'));
  416. var totalWidth = activewidth + activePadLeft + activePadRight;
  417.  
  418. var precedingAnchorWidth = anchorWidthCounter();
  419.  
  420. // TODO:
  421. // Find the total widths of all of the anchors
  422. // to the left of the active anchor.
  423.  
  424. var activeMarker = $('.active-marker');
  425. $(activeMarker).css('display', 'block');
  426.  
  427. $(activeMarker).css('width', totalWidth);
  428.  
  429. $(activeMarker).css('left', precedingAnchorWidth);
  430.  
  431. // TODO:
  432. // Using the calculated total widths of preceding anchors,
  433. // Set the left: css value to that number.
  434. }
  435.  
  436. $(window).load(function() {
  437. moveMarker();
  438. });
  439.  
  440. function anchorWidthCounter() {
  441. var anchorWidths = 0;
  442. var a;
  443. var aWidth;
  444. var aPadLeft;
  445. var aPadRight;
  446. var aTotalWidth;
  447. $('.nav-menu .nav-main li').each(function(index, elem) {
  448. var activeTest = $(elem).hasClass('active');
  449. if (activeTest) {
  450. // Break out of the each function.
  451. return false;
  452. }
  453.  
  454. a = $(elem).find('a');
  455. aWidth = a.width();
  456. aPadLeft = parseFloat(a.css('padding-left'));
  457. aPadRight = parseFloat(a.css('padding-right'));
  458. aTotalWidth = aWidth + aPadLeft + aPadRight;
  459.  
  460. anchorWidths = anchorWidths + aTotalWidth;
  461. });
  462.  
  463. return anchorWidths;
  464. }
  465.  
  466. $('.nav-menu .nav-main a').click(function(e) {
  467. e.preventDefault();
  468. $('.nav-menu .nav-main li').removeClass('active');
  469. $(this).parents('li').addClass('active');
  470. moveMarker();
  471. });
  472.  
  473. // TabPane
  474. $('#personTab').on('click', function() {
  475. $('#personTabPane').show();
  476. $('#businessTabPane').hide();
  477. $('#entrepreneursTabPane').hide();
  478. $('#ecommerceTabPane').hide();
  479. });
  480.  
  481. $('#businessTab').on('click', function() {
  482. $('#personTabPane').hide();
  483. $('#businessTabPane').show();
  484. $('#entrepreneursTabPane').hide();
  485. $('#ecommerceTabPane').hide();
  486. });
  487.  
  488. $('#entrepreneursTab').on('click', function() {
  489. $('#personTabPane').hide();
  490. $('#businessTabPane').hide();
  491. $('#entrepreneursTabPane').show();
  492. $('#ecommerceTabPane').hide();
  493. });
  494.  
  495. $('#ecommerceTab').on('click', function() {
  496. $('#personTabPane').hide();
  497. $('#businessTabPane').hide();
  498. $('#entrepreneursTabPane').hide();
  499. $('#ecommerceTabPane').show();
  500. });
  501.  
  502. // Nav icon Hamburger
  503. $('#nav-icon-hamburguer, .close-nav-mobile, .pattern-nav').click(function() {
  504. // $(this).toggleClass('cross');
  505. $('body').toggleClass('menu-view');
  506. if ($('body').hasClass('menu-view')) {
  507. $('html').css({ 'overflow': 'hidden' });
  508. $('.pattern-nav').delay('250').show(0);
  509. } else {
  510. $('html').css({ 'overflow': 'auto' });
  511. $('#slidemenu .dropdown-menu').removeClass('view-son');
  512. $('.pattern-nav').hide(0);
  513. }
  514. });
  515. $('#slidemenu .dropdown-toggle').on('click', function() {
  516. var son = $(this).next('.dropdown-menu');
  517. son.addClass('view-son');
  518. });
  519. $('#slidemenu .menu-back').on('click', function() {
  520. var dad = $(this).parent().parent('.dropdown-menu');
  521. dad.removeClass('view-son');
  522. });
  523.  
  524.  
  525. $('#page-content').children().on('click', function(e) {
  526. // e.stopPropagation();
  527. // console.log('lopincho');
  528. // var selectizes = $('.searchtize')[0].selectize;
  529. // selectizes.clear();
  530. // selectizes.clearOptions();
  531.  
  532. if (!$(this).hasClass('is-active')) {
  533. $('.search-container.is-active').each(function() {
  534. onBlurSearch();
  535. });
  536. }
  537. });
  538.  
  539.  
  540. // $('.site-header').on('click', function() {
  541. // if (!$(this).hasClass('is-active')) {
  542. // $('.search-container.is-active').each(function() {
  543. // onBlurSearch();
  544. // });
  545. // }
  546. // })
  547.  
  548. // Search Animated Menu Main
  549. $('.nav-menu .search-icon').on('click', function(e) {
  550. e.stopPropagation();
  551. $('.nav-menu .search-container').toggleClass('is-active');
  552. if ($('.nav-menu .search-container').hasClass('is-active')) {
  553. // console.log('paso 1');
  554. $('.logo').hide();
  555. $('.nav-menu #search-box-desktop').attr('placeholder', '¿Qué estás buscando?');
  556. $('.active-marker.active-triangle-person').fadeOut('fast');
  557. } else {
  558. // console.log('paso 2');
  559. $('.logo').show();
  560. $('.nav-menu #search-box-desktop').attr('placeholder', '');
  561. $('#search-box-sticky').attr('placeholder', '');
  562. $('.nav-menu #search-box-desktop').prop('value', '');
  563. $('.active-marker.active-triangle-person').fadeIn('fast');
  564. }
  565. });
  566.  
  567. // Menu Sticky
  568. $(function() {
  569. var shrinkElement = 10;
  570. $(window).scroll(function() {
  571. var scroll = getCurrentScroll();
  572. if (scroll >= shrinkElement) {
  573. $('.site-header .bdr-icon-toolbox').addClass('shrink-element');
  574. $('.navbar-mobile .logo-image').addClass('shrink-element');
  575. } else {
  576. $('.site-header .bdr-icon-toolbox').removeClass('shrink-element');
  577. $('.navbar-mobile .logo-image').removeClass('shrink-element');
  578. }
  579. });
  580.  
  581. function getCurrentScroll() {
  582. return window.pageYOffset || document.documentElement.scrollTop;
  583. }
  584. });
  585.  
  586. $('#MenuSticky #search-submit, #MenuSticky .search-icon').on('click', function(e) {
  587. e.stopPropagation();
  588. $('#MenuSticky .search-container').toggleClass('is-active');
  589. if ($('#MenuSticky .search-container').hasClass('is-active')) {
  590. // console.log('paso 1');
  591. // $('.logo').hide();
  592. $('#MenuSticky #search-box-sticky').attr('placeholder', '¿Qué estás buscando?');
  593. $('.main-tab-item.active').addClass('active-follow');
  594. $('.main-tab-item.active').removeClass('active');
  595.  
  596. } else {
  597. // console.log('paso 2');
  598. // $('.logo').show();
  599. $('#MenuSticky #search-box-sticky').attr('placeholder', '');
  600. $('.main-tab-item.active-follow').addClass('active');
  601. $('.main-tab-item.active-follow').removeClass('active-follow');
  602. }
  603.  
  604. });
  605.  
  606. // scroll top on click toolbox
  607. $('a[href="#toolBox"]').click(function() {
  608. $('html, body').animate({
  609. scrollTop: $($(this).attr('href')).offset().top - 100
  610. // if($('.alert').length) {
  611. // scrollTop: $($(this).attr('href')).offset().top + alertHeight - 100
  612. // }
  613. }, 400);
  614. return false;
  615. });
  616.  
  617. // Scrolltop any element with class '.back-to-top'
  618. $('.back-to-top').click(function() {
  619. $('.modal').modal('hide');
  620. $('body,html').animate({
  621. scrollTop: $("body").offset().top - 0
  622. }, 400);
  623. return false;
  624. });
  625.  
  626. // tabs services
  627. $('#nav-tabs-services a').click(function(e) {
  628. e.preventDefault();
  629. $(this).tab('show');
  630. });
  631.  
  632. //Guideline scripts
  633. $("#menu-toggle-guideline").click(function(e) {
  634. e.preventDefault();
  635. $("#wrapper-guideline").toggleClass("toggled");
  636. });
  637.  
  638. // Button disabled
  639. // $('.isAccept').click(function() {
  640. // if (!$(this).is(':checked')) {
  641. // $('.enableButton').attr('disabled', false);
  642. // $('.enableButton').removeClass('c-button--secondary');
  643. // } else {
  644. // $('.enableButton').attr('disabled', 'disabled');
  645. // $('.enableButton').addClass('c-button--secondary');
  646. // }
  647. // });
  648.  
  649. // //btn-continue
  650. // $('.btn-continue').on('click', function() {
  651. // $('.isAccept').attr('checked', false);
  652. // $('.enableButton').removeClass('c-button--secondary');
  653. // $('#enableButton').attr('disabled', 'disabled');
  654. // });
  655.  
  656. $('.alert .close').on('click', function() {
  657. $('* .alert-warning').remove();
  658. });
  659. // Alert close
  660. var alertHeight = $('.alert-warning').innerHeight();
  661. var navMobile = $('.navbar-mobile').innerHeight() + 40;
  662. // console.log(navMobile);
  663. if ($(window).width() < 768) {
  664. // console.log($('.alert-warning').length);
  665. if ($('.alert-warning').length > 0) {
  666. console.log('estamos ackiq');
  667. $('#section-slide').css('margin-top', alertHeight + navMobile);
  668. $('.site-header .bdr-icon-toolbox').addClass('bdr-with--alert');
  669. $('.site-header .bdr-icon-toolbox.bdr-with--alert').css('top', alertHeight + navMobile - 36)
  670. if ($('.alert-warning .close').on('click', function() {
  671. $('.site-header .bdr-icon-toolbox').removeClass('bdr-with--alert');
  672. $('.site-header .bdr-icon-toolbox').css('top', navMobile - 38)
  673. $('#section-slide').css('margin-top', navMobile);
  674. }));
  675. } else {
  676. $('.site-header .bdr-icon-toolbox').addClass('bdr-with--alert');
  677. }
  678.  
  679. $('.alert .close').on('click', function() {
  680. $('* .alert-warning').remove();
  681. })
  682. }
  683.  
  684.  
  685. //searchbox
  686. $('.searchtize input').on('focus blur', function() {
  687. // var padre = $(this).parents('.search-wrapper');
  688. // padre.toggleClass('on-focus');
  689. });
  690.  
  691. // $('.searchtize').selectize({
  692. // options: [
  693. // { match: 'Bolsa Grande $400', desc: 'Tamaño: 35X27 cm' },
  694. // { match: 'Bolsa Mediana $369', desc: 'Tamaño: 33X22 cm' },
  695. // { match: 'Fulfillment', desc: 'Recibimos tus productos' }
  696. // ],
  697. // maxItems: 1,
  698. // openOnFocus: false,
  699. // highlight: false,
  700. // labelField: 'match',
  701. // valueField: 'match',
  702. // searchField: 'match'
  703. // });
  704. $('#searchBox').on('submit', function(e) {
  705. e.preventDefault();
  706. e.stopPropagation();
  707. var padre = $(this);
  708. var input = padre.find('.searchtize input');
  709.  
  710. if (input.val() == '' && $('input.searchtize').val() == '') {
  711. padre.find('.error-search').stop(true).fadeIn().delay(5000).fadeOut();
  712.  
  713. // var cant = 0;
  714. // $('#searchBox .selectize-input div[data-value]').each(function(index) {
  715. // cant = index;
  716. // console.log(index);
  717. // })
  718. // if (cant != 0) {
  719. // padre.find('.error-search').stop(true).fadeIn().delay(5000).fadeOut();
  720. // }
  721.  
  722. } else {
  723. console.log('realizando busqueda .....');
  724. return true;
  725. }
  726. });
  727. // $('.search-container *').on('click', function() {
  728. // console.log('hizo click');
  729. // });
  730.  
  731. $('.searchtize').selectize({
  732. maxItems: 1,
  733. valueField: 'match',
  734. // labelField: 'desc',
  735. persist: false,
  736. openOnFocus: false,
  737. searchField: ['match'],
  738. clearOnBlur: false,
  739. highlight: false,
  740.  
  741. onInitialize: function() {
  742.  
  743. var valorBuscado = '';
  744. var dataBuscado = '';
  745. $('#search-box-desktop-selectized').on('keyup', function() {
  746. valorBuscado = $(this).val();
  747. $(this).parents('form').find('input.search-hidden').val(valorBuscado);
  748.  
  749. });
  750. //submit search general
  751. $('#search-submit-desktop, #search-submit').on('click', function(e) {
  752. e.stopImmediatePropagation();
  753. $('.search-container .selectize-input.has-items div[data-value]').each(function() {
  754. if ($(this).data('value') != '') {
  755. dataBuscado = $(this).data('value');
  756. }
  757. })
  758. valorBuscado = $('input.search-hidden').val();
  759. if (dataBuscado != '') {
  760. console.log('enviando form....');
  761. $('#search-submit-desktop').parents('form').submit();
  762. } else {
  763. if (valorBuscado == '') {
  764. console.log('no tiene nada');
  765. $(this).next('.error-search.empty').stop(true).fadeIn().delay(4000).fadeOut();
  766. $('#search-box-desktop-selectized').focus();
  767. } else {
  768. console.log('enviando form....');
  769. $('#search-submit-desktop').parents('form').submit();
  770. }
  771. }
  772. });
  773. $('#search-box-desktop-selectized').focus(function() {
  774. $('.search-container').css({ 'overflow': 'inherit', 'height': 'auto' });
  775. })
  776. $('#search-box-desktop-selectized').blur(function() {
  777. $('.error-search.empty').hide();
  778. $('.search-container').css({ 'overflow': 'hidden', 'height': '42px' });
  779. })
  780. },
  781. onType: function() {
  782. $('#searchBox .error-search').hide();
  783. $('.error-search.empty').hide();
  784. },
  785. onFocus: function(element) {
  786. // var padre = $('.search-wrapper');
  787. // padre.toggleClass('on-focus');
  788. $('.error-search.empty.is-desktop').fadeOut();
  789. },
  790. onBlur: function(element) {
  791. // var padre = $('.search-wrapper');
  792. // padre.toggleClass('on-focus');
  793.  
  794. },
  795. options: [
  796. { match: 'Bolsa Grande $400', desc: 'Tamaño: 35X27 cm' },
  797. { match: 'Bolsa Mediana $369', desc: 'Tamaño: 33X22 cm' },
  798. { match: 'Fulfillment', desc: 'Recibimos tus productos' }
  799. ],
  800. render: {
  801. item: function(item, escape) {
  802. return '<div>' +
  803. (item.match ? '<span class="match">' + escape(item.match) + '</span>' : '') +
  804. // (item.desc ? '<span class="desc">' + escape(item.desc) + '</span>' : '') +
  805. '</div>';
  806. },
  807. option: function(item, escape) {
  808. var label = item.match || item.desc;
  809. var caption = item.match ? item.desc : null;
  810. return '<div>' +
  811. '<span class="label">' + escape(label) + '</span>' +
  812. (caption ? '<span class="caption">' + escape(caption) + '</span>' : '') +
  813. '</div>';
  814. }
  815. },
  816. createFilter: function(input) {},
  817. create: function(input) {}
  818. });
  819.  
  820. // $(window).resize(function() {
  821. // var width = $(window).width();
  822. // if (width < 1200){
  823. // alert('Your screen is too small');
  824. // }
  825. // });
  826.  
  827. if ($(window).width() >= 768) {
  828. if ($(window).width() < 992) {
  829. $(".navbar-controls #btnLoginMobile").click(function() {
  830. $("#mainMenuWrapp").hide();
  831. $("#mainLoginWrapp").fadeIn();
  832. });
  833.  
  834. $("#mainLoginWrapp .close").click(function() {
  835. $("#mainLoginWrapp").hide();
  836. $("#mainMenuWrapp").fadeIn();
  837. });
  838. }
  839. } else {
  840. $("#btnLoginMobile").click(function() {
  841.  
  842. $('.site-header .bdr-icon-toolbox').css('margin-top', 78)
  843. $('#section-slide').css('top', 72);
  844. $("#mainLoginWrappMobile").slideDown(200, function() {});
  845. });
  846. $("#mainLoginWrappMobile .close").click(function() {
  847. $("#mainLoginWrappMobile").slideUp(200);
  848. $('.site-header .bdr-icon-toolbox').css('margin-top', 0)
  849. $('#section-slide').css('top', 0);
  850. });
  851. }
  852. $('.search-container .selectize-control .selectize-dropdown').on('click', function() {
  853. // $('.nav-menu .search-container').addClass('is-active');
  854. })
  855.  
  856. // ocultar el buscador general en version mobile
  857. $('#myNav.overlay .pattern').on('click', function() {
  858. closeNav();
  859. })
  860.  
  861.  
  862. });
  863. //click in other side for search
  864. $(document).click(function(e) {
  865. var elemento = $('.search-container.is-active .selectize-dropdown.searchtize');
  866. var container = $(".search-container");
  867. if (elemento.is(':visible')) {
  868. console.log('buscador visible');
  869. } else {
  870. if (container.hasClass('is-active')) {
  871.  
  872. }
  873. if (!container.is(e.target) && container.has(e.target).length === 0) {
  874. onBlurSearch();
  875. } else {}
  876. }
  877.  
  878. });
  879. document.addEventListener("touchstart", function() {}, true);
  880.  
  881. // function mobile icon-toolbox
  882. function mobileToolboxIcon() {
  883. if ($(window).width() >= 768) {
  884. $('.site-header .bdr-icon-toolbox').hide();
  885. $('.tool-box .bdr-icon-toolbox').show();
  886. } else {
  887. $('.site-header .bdr-icon-toolbox').show();
  888. }
  889. }
  890.  
  891. function openNav() {
  892. $('body').addClass('modal-open');
  893. document.getElementById("myNav").style.width = "100%";
  894. }
  895.  
  896. function closeNav() {
  897. $('body').removeClass('modal-open');
  898. document.getElementById("myNav").style.width = "0%";
  899. var caja = $('#searchBox .searchtize')[0].selectize;
  900. caja.clear();
  901. $('#searchBox .error-search').hide();
  902. }
  903.  
  904. function numberWithDot(x) {
  905. return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
  906. }
  907.  
  908. function onBlurSearch() {
  909. $('.error-search.empty').hide();
  910. $('.logo').show();
  911. $('.search-container').removeClass('is-active');
  912. $('.nav-menu #search-box-desktop, #search-box-sticky').prop('value', '');
  913. $('.nav-menu #search-box-desktop, #search-box-sticky').attr('placeholder', '');
  914. $('.active-marker.active-triangle-person').fadeIn('fast');
  915. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement