responsive.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Copyright © 2015 Magento. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'jquery',
  7. 'matchMedia',
  8. 'mage/tabs',
  9. 'domReady!'
  10. ], function ($, mediaCheck) {
  11. 'use strict';
  12. mediaCheck({
  13. media: '(min-width: 768px)',
  14. // Switch to Desktop Version
  15. entry: function () {
  16. (function () {
  17. var productInfoMain = $('.product-info-main'),
  18. productInfoAdditional = $('#product-info-additional');
  19. if (productInfoAdditional.length) {
  20. productInfoAdditional.addClass('hidden');
  21. productInfoMain.removeClass('responsive');
  22. }
  23. })();
  24. var galleryElement = $('[data-role=media-gallery]');
  25. if (galleryElement.length && galleryElement.data('mageZoom')) {
  26. galleryElement.zoom('enable');
  27. }
  28. if (galleryElement.length && galleryElement.data('mageGallery')) {
  29. galleryElement.gallery('option', 'disableLinks', true);
  30. galleryElement.gallery('option', 'showNav', false);
  31. galleryElement.gallery('option', 'showThumbs', true);
  32. }
  33. setTimeout(function () {
  34. if(!$('.product.info.detailed').hasClass("sticky"))
  35. $('.product.data.items').tabs('option', 'openOnFocus', true);
  36. }, 500);
  37. },
  38. // Switch to Mobile Version
  39. exit: function () {
  40. $('.action.toggle.checkout.progress')
  41. .on('click.gotoCheckoutProgress', function () {
  42. var myWrapper = '#checkout-progress-wrapper';
  43. scrollTo(myWrapper + ' .title');
  44. $(myWrapper + ' .title').addClass('active');
  45. $(myWrapper + ' .content').show();
  46. });
  47. $('body')
  48. .on('click.checkoutProgress', '#checkout-progress-wrapper .title', function () {
  49. $(this).toggleClass('active');
  50. $('#checkout-progress-wrapper .content').toggle();
  51. });
  52. var galleryElement = $('[data-role=media-gallery]');
  53. setTimeout(function () {
  54. if (galleryElement.length && galleryElement.data('mageZoom')) {
  55. galleryElement.zoom('disable');
  56. }
  57. if (galleryElement.length && galleryElement.data('mageGallery')) {
  58. galleryElement.gallery('option', 'disableLinks', false);
  59. galleryElement.gallery('option', 'showNav', true);
  60. galleryElement.gallery('option', 'showThumbs', false);
  61. }
  62. }, 2000);
  63. setTimeout(function () {
  64. if(!$('.product.info.detailed').hasClass("sticky"))
  65. $('.product.data.items').tabs('option', 'openOnFocus', false);
  66. }, 500);
  67. }
  68. });
  69. });