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.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 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); } }
  2. import mixins from '../util/mixins';
  3. function searchChildren(children) {
  4. var results = [];
  5. for (var index = 0; index < children.length; index++) {
  6. var child = children[index];
  7. if (child.isActive && child.isDependent) {
  8. results.push(child);
  9. } else {
  10. results.push.apply(results, _toConsumableArray(searchChildren(child.$children)));
  11. }
  12. }
  13. return results;
  14. }
  15. /* @vue/component */
  16. export default mixins().extend({
  17. name: 'dependent',
  18. data: function data() {
  19. return {
  20. closeDependents: true,
  21. isActive: false,
  22. isDependent: true
  23. };
  24. },
  25. watch: {
  26. isActive: function isActive(val) {
  27. if (val) return;
  28. var openDependents = this.getOpenDependents();
  29. for (var index = 0; index < openDependents.length; index++) {
  30. openDependents[index].isActive = false;
  31. }
  32. }
  33. },
  34. methods: {
  35. getOpenDependents: function getOpenDependents() {
  36. if (this.closeDependents) return searchChildren(this.$children);
  37. return [];
  38. },
  39. getOpenDependentElements: function getOpenDependentElements() {
  40. var result = [];
  41. var openDependents = this.getOpenDependents();
  42. for (var index = 0; index < openDependents.length; index++) {
  43. result.push.apply(result, _toConsumableArray(openDependents[index].getClickableDependentElements()));
  44. }
  45. return result;
  46. },
  47. getClickableDependentElements: function getClickableDependentElements() {
  48. var result = [this.$el];
  49. if (this.$refs.content) result.push(this.$refs.content);
  50. if (this.overlay) result.push(this.overlay);
  51. result.push.apply(result, _toConsumableArray(this.getOpenDependentElements()));
  52. return result;
  53. }
  54. }
  55. });
  56. //# sourceMappingURL=dependent.js.map