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.

dependent.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _mixins = require('../util/mixins');
  6. var _mixins2 = _interopRequireDefault(_mixins);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  9. function searchChildren(children) {
  10. var results = [];
  11. for (var index = 0; index < children.length; index++) {
  12. var child = children[index];
  13. if (child.isActive && child.isDependent) {
  14. results.push(child);
  15. } else {
  16. results.push.apply(results, _toConsumableArray(searchChildren(child.$children)));
  17. }
  18. }
  19. return results;
  20. }
  21. /* @vue/component */
  22. exports.default = (0, _mixins2.default)().extend({
  23. name: 'dependent',
  24. data: function data() {
  25. return {
  26. closeDependents: true,
  27. isActive: false,
  28. isDependent: true
  29. };
  30. },
  31. watch: {
  32. isActive: function isActive(val) {
  33. if (val) return;
  34. var openDependents = this.getOpenDependents();
  35. for (var index = 0; index < openDependents.length; index++) {
  36. openDependents[index].isActive = false;
  37. }
  38. }
  39. },
  40. methods: {
  41. getOpenDependents: function getOpenDependents() {
  42. if (this.closeDependents) return searchChildren(this.$children);
  43. return [];
  44. },
  45. getOpenDependentElements: function getOpenDependentElements() {
  46. var result = [];
  47. var openDependents = this.getOpenDependents();
  48. for (var index = 0; index < openDependents.length; index++) {
  49. result.push.apply(result, _toConsumableArray(openDependents[index].getClickableDependentElements()));
  50. }
  51. return result;
  52. },
  53. getClickableDependentElements: function getClickableDependentElements() {
  54. var result = [this.$el];
  55. if (this.$refs.content) result.push(this.$refs.content);
  56. if (this.overlay) result.push(this.overlay);
  57. result.push.apply(result, _toConsumableArray(this.getOpenDependentElements()));
  58. return result;
  59. }
  60. }
  61. });
  62. //# sourceMappingURL=dependent.js.map