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.

stackable.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 Vue from 'vue';
  3. import { getZIndex } from '../util/helpers';
  4. /* @vue/component */
  5. export default Vue.extend().extend({
  6. name: 'stackable',
  7. data: function data() {
  8. return {
  9. stackClass: 'unpecified',
  10. stackElement: null,
  11. stackExclude: null,
  12. stackMinZIndex: 0,
  13. isActive: false
  14. };
  15. },
  16. computed: {
  17. activeZIndex: function activeZIndex() {
  18. if (typeof window === 'undefined') return 0;
  19. var content = this.stackElement || this.$refs.content;
  20. // Return current zindex if not active
  21. var index = !this.isActive ? getZIndex(content) : this.getMaxZIndex(this.stackExclude || [content]) + 2;
  22. if (index == null) return index;
  23. // Return max current z-index (excluding self) + 2
  24. // (2 to leave room for an overlay below, if needed)
  25. return parseInt(index);
  26. }
  27. },
  28. methods: {
  29. getMaxZIndex: function getMaxZIndex() {
  30. var exclude = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  31. var base = this.$el;
  32. // Start with lowest allowed z-index or z-index of
  33. // base component's element, whichever is greater
  34. var zis = [this.stackMinZIndex, getZIndex(base)];
  35. // Convert the NodeList to an array to
  36. // prevent an Edge bug with Symbol.iterator
  37. // https://github.com/vuetifyjs/vuetify/issues/2146
  38. var activeElements = [].concat(_toConsumableArray(document.getElementsByClassName(this.stackClass)));
  39. // Get z-index for all active dialogs
  40. for (var index = 0; index < activeElements.length; index++) {
  41. if (!exclude.includes(activeElements[index])) {
  42. zis.push(getZIndex(activeElements[index]));
  43. }
  44. }
  45. return Math.max.apply(Math, zis);
  46. }
  47. }
  48. });
  49. //# sourceMappingURL=stackable.js.map