1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import onsElements from '../ons/elements.js';
|
19 | import BaseElement from './base/base-element.js';
|
20 | import util from '../ons/util.js';
|
21 | import contentReady from '../ons/content-ready.js';
|
22 |
|
23 | export default class SplitterMaskElement extends BaseElement {
|
24 |
|
25 | constructor() {
|
26 | super();
|
27 |
|
28 | this._boundOnClick = this._onClick.bind(this);
|
29 | contentReady(this, () => {
|
30 | if (this.parentNode._sides.every(side => side.mode === 'split')) {
|
31 | this.setAttribute('style', 'display: none !important');
|
32 | }
|
33 | });
|
34 | }
|
35 |
|
36 | _onClick(event) {
|
37 | if (this.onClick instanceof Function) {
|
38 | this.onClick();
|
39 | } else if (util.match(this.parentNode, 'ons-splitter')) {
|
40 | this.parentNode._sides.forEach(side => side.close('left').catch(() => {}));
|
41 | }
|
42 | event.stopPropagation();
|
43 | }
|
44 |
|
45 | static get observedAttributes() {
|
46 | return [];
|
47 | }
|
48 |
|
49 | attributeChangedCallback(name, last, current) {
|
50 | }
|
51 |
|
52 | connectedCallback() {
|
53 | this.addEventListener('click', this._boundOnClick);
|
54 | }
|
55 |
|
56 | disconnectedCallback() {
|
57 | this.removeEventListener('click', this._boundOnClick);
|
58 | }
|
59 | }
|
60 |
|
61 | onsElements.SplitterMask = SplitterMaskElement;
|
62 | customElements.define('ons-splitter-mask', SplitterMaskElement);
|