is-downloadable-handler.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'Magento_Ui/js/form/element/single-checkbox'
  7. ], function (Element) {
  8. 'use strict';
  9. return Element.extend({
  10. defaults: {
  11. listens: {
  12. disabled: 'changeVisibility'
  13. },
  14. modules: {
  15. samplesFieldset: '${ $.samplesFieldset }',
  16. linksFieldset: '${ $.linksFieldset}'
  17. }
  18. },
  19. /**
  20. * Change visibility for samplesFieldset & linksFieldset based on current statuses of checkbox.
  21. */
  22. changeVisibility: function () {
  23. if (this.samplesFieldset() && this.linksFieldset()) {
  24. if (this.checked() && !this.disabled()) {
  25. this.samplesFieldset().visible(true);
  26. this.linksFieldset().visible(true);
  27. } else {
  28. this.samplesFieldset().visible(false);
  29. this.linksFieldset().visible(false);
  30. }
  31. }
  32. },
  33. /**
  34. * Handle checked state changes for checkbox / radio button.
  35. *
  36. * @param {Boolean} newChecked
  37. */
  38. onCheckedChanged: function (newChecked) {
  39. this.changeVisibility();
  40. this._super(newChecked);
  41. }
  42. });
  43. });