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

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