toggleSwitch.js 1.2 KB

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