Guest User

Untitled

a guest
Nov 19th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. Vue.component('vue-switch', {
  2. template: '<label :class="classObject"><span class="vue-switcher__label" v-if="shouldShowLabel"><span v-if="label" v-text="label"></span><span v-if="!label && value" v-text="textEnabled"></span> <span v-if="!label && !value" v-text="textDisabled"></span> </span> <input type="checkbox" :disabled="disabled" :true-value="trueValue" :false-value="falseValue" @change="trigger" :checked="value"><div></div> </label>',
  3. props: {
  4. typeBold: {
  5. default: false
  6. },
  7.  
  8. value: {
  9. default: false
  10. },
  11.  
  12. disabled: {
  13. default: false
  14. },
  15.  
  16. label: {
  17. default: ''
  18. },
  19.  
  20. textEnabled: {
  21. default: ''
  22. },
  23.  
  24. textDisabled: {
  25. default: ''
  26. },
  27.  
  28. color: {
  29. default: 'default'
  30. },
  31.  
  32. theme: {
  33. default: 'default'
  34. },
  35.  
  36. emitOnMount: {
  37. default: true
  38. },
  39. trueValue: {
  40. default: true
  41. },
  42. falseValue: {
  43. default: false
  44. },
  45. },
  46. mounted: function mounted() {
  47. if (this.emitOnMount) {
  48. this.$emit('input', this.value);
  49. }
  50. },
  51. methods: {
  52. trigger: function trigger(e) {
  53. this.$emit('input', e.target.checked);
  54. }
  55. },
  56. computed: {
  57. classObject: function classObject() {
  58. var _ref;
  59.  
  60. var color = this.color,
  61. value = this.value,
  62. theme = this.theme,
  63. typeBold = this.typeBold,
  64. disabled = this.disabled;
  65.  
  66.  
  67. return _ref = {
  68. 'vue-switcher': true
  69. }, _defineProperty(_ref, 'vue-switcher--unchecked', !value), _defineProperty(_ref, 'vue-switcher--disabled', disabled), _defineProperty(_ref, 'vue-switcher--bold', typeBold), _defineProperty(_ref, 'vue-switcher--bold--unchecked', typeBold && !value), _defineProperty(_ref, 'vue-switcher-theme--' + theme, color), _defineProperty(_ref, 'vue-switcher-color--' + color, color), _ref;
  70. },
  71.  
  72. shouldShowLabel: function shouldShowLabel() {
  73. return this.label !== '' || this.textEnabled !== '' || this.textDisabled !== '';
  74. }
  75. }
  76. });
Add Comment
Please, Sign In to add comment