PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / lib / integrations / divi / modules / QuadMenu / QuadMenu.jsx

QuadMenu.jsx in QuadMenu – Mega Menu 3.3.8, at lib/integrations/divi/modules/QuadMenu/QuadMenu.jsx

72 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // External Dependencies
2 import $ from 'jquery';
3 import React, { Component } from 'react';
4 class QuadMenu extends Component {
5
6 static slug = 'et_pb_quadmenu';
7 constructor(props) {
8 super(props);
9 this.state = {
10 error: false
11 }
12 }
13
14 changeTheme(oldTheme) {
15 this.$el = $(this.el);
16 this.$el.find('nav#quadmenu').removeClass('quadmenu-' + oldTheme).addClass('quadmenu-' + this.props.menu_theme);
17 }
18
19 createQuadMenu() {
20
21 this.$el = $(this.el);
22
23 var body = new FormData();
24 body.append('action', 'ajax_quadmenu_divi_module');
25 body.append('post_id', window.ETBuilderBackend.postId);
26 body.append('menu_id', this.props.menu_id);
27 body.append('menu_theme', this.props.menu_theme);
28
29 fetch(window.et_fb_options.ajaxurl, {body: body, method: 'POST'})
30 .then(res => res.json())
31 .then((response) => {
32 if (response.success) {
33 this.$el.html($(response.data).quadmenu());
34 } else {
35 this.setState({
36 error: response.data
37 });
38 }
39 }, (error) => {
40 this.setState({
41 error: error
42 });
43 });
44 }
45
46 componentDidMount() {
47 this.createQuadMenu(this.props.menu_id);
48 }
49
50 componentDidUpdate(prevProps) {
51 if (prevProps.menu_id !== this.props.menu_id) {
52 this.createQuadMenu(this.props.menu_id);
53 } else if (prevProps.menu_theme !== this.props.menu_theme) {
54 this.changeTheme(prevProps.menu_theme);
55 }
56 }
57
58 render() {
59
60 if (this.state.error) {
61 return (<div>{this.state.error}</div>);
62 }
63
64 return (<div className="et_pb_row et_pb_fullwidth_menu clearfix" ref={(el) => {
65 this.el = el
66 }}></div>);
67
68 }
69
70 }
71
72 export default QuadMenu;