Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VTab.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  2. // Mixins
  3. import { factory as GroupableFactory } from '../../mixins/groupable';
  4. import Routable from '../../mixins/routable';
  5. import Themeable from '../../mixins/themeable';
  6. // Utilities
  7. import { getObjectValueByPath } from '../../util/helpers';
  8. /* @vue/component */
  9. export default {
  10. name: 'v-tab',
  11. mixins: [Routable,
  12. // Must be after routable
  13. // to overwrite activeClass
  14. GroupableFactory('tabGroup'), Themeable],
  15. props: {
  16. ripple: {
  17. type: [Boolean, Object],
  18. default: true
  19. }
  20. },
  21. computed: {
  22. classes: function classes() {
  23. return _extends({
  24. 'v-tabs__item': true,
  25. 'v-tabs__item--disabled': this.disabled
  26. }, this.groupClasses);
  27. },
  28. value: function value() {
  29. var to = this.to || this.href || '';
  30. if (this.$router && this.to === Object(this.to)) {
  31. var resolve = this.$router.resolve(this.to, this.$route, this.append);
  32. to = resolve.href;
  33. }
  34. return to.replace('#', '');
  35. }
  36. },
  37. watch: {
  38. $route: 'onRouteChange'
  39. },
  40. mounted: function mounted() {
  41. this.onRouteChange();
  42. },
  43. methods: {
  44. click: function click(e) {
  45. // If user provides an
  46. // actual link, do not
  47. // prevent default
  48. if (this.href && this.href.indexOf('#') > -1) e.preventDefault();
  49. this.$emit('click', e);
  50. this.to || this.toggle();
  51. },
  52. onRouteChange: function onRouteChange() {
  53. var _this = this;
  54. if (!this.to || !this.$refs.link) return;
  55. var path = '_vnode.data.class.' + this.activeClass;
  56. this.$nextTick(function () {
  57. if (getObjectValueByPath(_this.$refs.link, path)) {
  58. _this.toggle();
  59. }
  60. });
  61. }
  62. },
  63. render: function render(h) {
  64. var link = this.generateRouteLink(this.classes);
  65. var data = link.data;
  66. // If disabled, use div as anchor tags do not support
  67. // being disabled
  68. var tag = this.disabled ? 'div' : link.tag;
  69. data.ref = 'link';
  70. return h('div', {
  71. staticClass: 'v-tabs__div'
  72. }, [h(tag, data, this.$slots.default)]);
  73. }
  74. };
  75. //# sourceMappingURL=VTab.js.map