PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.3
Elementor Website Builder – more than just a page builder v3.13.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / assets / js / gutenberg.js

gutenberg.js in Elementor Website Builder – more than just a page builder 3.13.3, at assets/js/gutenberg.js

160 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! elementor - v3.13.3 - 22-05-2023 */
2 /******/ (() => { // webpackBootstrap
3 /******/ "use strict";
4 /******/ var __webpack_modules__ = ({
5
6 /***/ "@wordpress/i18n":
7 /*!**************************!*\
8 !*** external "wp.i18n" ***!
9 \**************************/
10 /***/ ((module) => {
11
12 module.exports = wp.i18n;
13
14 /***/ })
15
16 /******/ });
17 /************************************************************************/
18 /******/ // The module cache
19 /******/ var __webpack_module_cache__ = {};
20 /******/
21 /******/ // The require function
22 /******/ function __webpack_require__(moduleId) {
23 /******/ // Check if module is in cache
24 /******/ var cachedModule = __webpack_module_cache__[moduleId];
25 /******/ if (cachedModule !== undefined) {
26 /******/ return cachedModule.exports;
27 /******/ }
28 /******/ // Create a new module (and put it into the cache)
29 /******/ var module = __webpack_module_cache__[moduleId] = {
30 /******/ // no module.id needed
31 /******/ // no module.loaded needed
32 /******/ exports: {}
33 /******/ };
34 /******/
35 /******/ // Execute the module function
36 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
37 /******/
38 /******/ // Return the exports of the module
39 /******/ return module.exports;
40 /******/ }
41 /******/
42 /************************************************************************/
43 var __webpack_exports__ = {};
44 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
45 (() => {
46 /*!*******************************************!*\
47 !*** ../assets/dev/js/admin/gutenberg.js ***!
48 \*******************************************/
49 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
50
51
52 /* global ElementorGutenbergSettings */
53 (function ($) {
54 'use strict';
55
56 var ElementorGutenbergApp = {
57 cacheElements: function cacheElements() {
58 var self = this;
59 self.isElementorMode = ElementorGutenbergSettings.isElementorMode;
60 self.cache = {};
61 self.cache.$gutenberg = $('#editor');
62 self.cache.$switchMode = $($('#elementor-gutenberg-button-switch-mode').html());
63 self.cache.$switchModeButton = self.cache.$switchMode.find('#elementor-switch-mode-button');
64 self.bindEvents();
65 self.toggleStatus();
66 wp.data.subscribe(function () {
67 setTimeout(function () {
68 self.buildPanel();
69 }, 1);
70 });
71 },
72 buildPanel: function buildPanel() {
73 var self = this;
74 if (!self.cache.$gutenberg.find('#elementor-switch-mode').length) {
75 self.cache.$gutenberg.find('.edit-post-header-toolbar').append(self.cache.$switchMode);
76 }
77 if (!$('#elementor-editor').length) {
78 self.cache.$editorPanel = $($('#elementor-gutenberg-panel').html());
79 // TODO: `editor-block-list__layout` class for WP < 5.3 support.
80 self.cache.$gurenbergBlockList = self.cache.$gutenberg.find('.editor-block-list__layout, .editor-post-text-editor, .block-editor-block-list__layout');
81 self.cache.$gurenbergBlockList.after(self.cache.$editorPanel);
82 self.cache.$editorPanelButton = self.cache.$editorPanel.find('#elementor-go-to-edit-page-link');
83 self.cache.$editorPanelButton.on('click', function (event) {
84 event.preventDefault();
85 self.animateLoader();
86
87 // A new post is initialized as an 'auto-draft'.
88 // if the post is not a new post it should not save it to avoid some saving conflict between elementor and gutenberg.
89 var isNewPost = 'auto-draft' === wp.data.select('core/editor').getCurrentPost().status;
90 if (isNewPost) {
91 var documentTitle = wp.data.select('core/editor').getEditedPostAttribute('title');
92 if (!documentTitle) {
93 wp.data.dispatch('core/editor').editPost({
94 title: 'Elementor #' + $('#post_ID').val()
95 });
96 }
97 wp.data.dispatch('core/editor').savePost();
98 }
99 self.redirectWhenSave();
100 });
101 }
102 },
103 bindEvents: function bindEvents() {
104 var self = this;
105 self.cache.$switchModeButton.on('click', function () {
106 if (self.isElementorMode) {
107 elementorCommon.dialogsManager.createWidget('confirm', {
108 message: __('Please note that you are switching to WordPress default editor. Your current layout, design and content might break.', 'elementor'),
109 headerMessage: __('Back to WordPress Editor', 'elementor'),
110 strings: {
111 confirm: __('Continue', 'elementor'),
112 cancel: __('Cancel', 'elementor')
113 },
114 defaultOption: 'confirm',
115 onConfirm: function onConfirm() {
116 var wpEditor = wp.data.dispatch('core/editor');
117 wpEditor.editPost({
118 gutenberg_elementor_mode: false
119 });
120 wpEditor.savePost();
121 self.isElementorMode = !self.isElementorMode;
122 self.toggleStatus();
123 }
124 }).show();
125 } else {
126 self.isElementorMode = !self.isElementorMode;
127 self.toggleStatus();
128 self.cache.$editorPanelButton.trigger('click');
129 }
130 });
131 },
132 redirectWhenSave: function redirectWhenSave() {
133 var self = this;
134 setTimeout(function () {
135 if (wp.data.select('core/editor').isSavingPost()) {
136 self.redirectWhenSave();
137 } else {
138 location.href = ElementorGutenbergSettings.editLink;
139 }
140 }, 300);
141 },
142 animateLoader: function animateLoader() {
143 this.cache.$editorPanelButton.addClass('elementor-animate');
144 },
145 toggleStatus: function toggleStatus() {
146 jQuery('body').toggleClass('elementor-editor-active', this.isElementorMode).toggleClass('elementor-editor-inactive', !this.isElementorMode);
147 },
148 init: function init() {
149 this.cacheElements();
150 }
151 };
152 $(function () {
153 ElementorGutenbergApp.init();
154 });
155 })(jQuery);
156 })();
157
158 /******/ })()
159 ;
160 //# sourceMappingURL=gutenberg.js.map