1 | import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
2 | import _createClass from "@babel/runtime/helpers/esm/createClass";
|
3 | import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
4 | import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
5 | import _inherits from "@babel/runtime/helpers/esm/inherits";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import { Component } from '@wordpress/element';
|
11 | import { withSelect } from '@wordpress/data';
|
12 | export var FullscreenMode =
|
13 |
|
14 | function (_Component) {
|
15 | _inherits(FullscreenMode, _Component);
|
16 |
|
17 | function FullscreenMode() {
|
18 | _classCallCheck(this, FullscreenMode);
|
19 |
|
20 | return _possibleConstructorReturn(this, _getPrototypeOf(FullscreenMode).apply(this, arguments));
|
21 | }
|
22 |
|
23 | _createClass(FullscreenMode, [{
|
24 | key: "componentDidMount",
|
25 | value: function componentDidMount() {
|
26 | this.isSticky = false;
|
27 | this.sync();
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | if (document.body.classList.contains('sticky-menu')) {
|
33 | this.isSticky = true;
|
34 | document.body.classList.remove('sticky-menu');
|
35 | }
|
36 | }
|
37 | }, {
|
38 | key: "componentWillUnmount",
|
39 | value: function componentWillUnmount() {
|
40 | if (this.isSticky) {
|
41 | document.body.classList.add('sticky-menu');
|
42 | }
|
43 | }
|
44 | }, {
|
45 | key: "componentDidUpdate",
|
46 | value: function componentDidUpdate(prevProps) {
|
47 | if (this.props.isActive !== prevProps.isActive) {
|
48 | this.sync();
|
49 | }
|
50 | }
|
51 | }, {
|
52 | key: "sync",
|
53 | value: function sync() {
|
54 | var isActive = this.props.isActive;
|
55 |
|
56 | if (isActive) {
|
57 | document.body.classList.add('is-fullscreen-mode');
|
58 | } else {
|
59 | document.body.classList.remove('is-fullscreen-mode');
|
60 | }
|
61 | }
|
62 | }, {
|
63 | key: "render",
|
64 | value: function render() {
|
65 | return null;
|
66 | }
|
67 | }]);
|
68 |
|
69 | return FullscreenMode;
|
70 | }(Component);
|
71 | export default withSelect(function (select) {
|
72 | return {
|
73 | isActive: select('core/edit-post').isFeatureActive('fullscreenMode')
|
74 | };
|
75 | })(FullscreenMode);
|
76 |
|
\ | No newline at end of file |