toggleSwitch.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* eslint-disable
  2. max-len,
  3. no-undef,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. define(['base'], App =>
  13. App.directive('toggleSwitch', () => ({
  14. restrict: 'E',
  15. scope: {
  16. description: '@',
  17. labelFalse: '@',
  18. labelTrue: '@',
  19. ngModel: '='
  20. },
  21. template: `\
  22. <fieldset class="toggle-switch">
  23. <legend class="sr-only">{{description}}</legend>
  24. <input
  25. type="radio"
  26. name="toggle-switch-{{$id}}"
  27. class="toggle-switch-input"
  28. id="toggle-switch-false-{{$id}}"
  29. ng-value="false"
  30. ng-model="ngModel"
  31. >
  32. <label for="toggle-switch-false-{{$id}}" class="toggle-switch-label">{{labelFalse}}</label>
  33. <input
  34. type="radio"
  35. class="toggle-switch-input"
  36. name="toggle-switch-{{$id}}"
  37. id="toggle-switch-true-{{$id}}"
  38. ng-value="true"
  39. ng-model="ngModel"
  40. >
  41. <label for="toggle-switch-true-{{$id}}" class="toggle-switch-label">{{labelTrue}}</label>
  42. <span class="toggle-switch-selection" aria-hidden="true"></span>
  43. </fieldset>\
  44. `
  45. })))