PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.4.1
Forumax – AI Powered Advanced Community Forum Plugin v2.4.1
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / assets / admin / js / bbpc-el-editor.js

bbpc-el-editor.js in Forumax – AI Powered Advanced Community Forum Plugin 2.4.1, at assets/admin/js/bbpc-el-editor.js

120 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ;(function ($) {
2
3 'use strict';
4
5 var BbpcEditor = {
6
7 init: function () {
8 elementor.channels.editor.on('section:activated', BbpcEditor.onAnimatedBoxSectionActivated);
9
10 window.elementor.on('preview:loaded', function () {
11 elementor.$preview[0].contentWindow.BbpcEditor = BbpcEditor;
12 BbpcEditor.onPreviewLoaded();
13 });
14 },
15
16
17 onPreviewLoaded: function () {
18 var elementorFrontend = $('#elementor-preview-iframe')[0].contentWindow.elementorFrontend;
19
20 elementorFrontend.hooks.addAction('frontend/element_ready/widget', function ($scope) {
21 });
22 }
23 };
24
25 $(window).on('elementor:init', BbpcEditor.init);
26
27 window.BbpcEditor = BbpcEditor;
28
29
30 elementor.hooks.addFilter("panel/elements/regionViews", function (panel) {
31
32 if (BbpcConfig.pro_installed || BbpcConfig.promotional_widgets <= 0) return panel;
33
34 var promotionalWidgetHandler,
35 promotionalWidgets = BbpcConfig.promotional_widgets,
36 elementsCollection = panel.elements.options.collection,
37 categories = panel.categories.options.collection,
38 categoriesView = panel.categories.view,
39 elementsView = panel.elements.view,
40 freeCategoryIndex, proWidgets = [];
41
42 _.each(promotionalWidgets, function (widget, index) {
43 elementsCollection.add({
44 name: widget.name,
45 title: widget.title,
46 icon: widget.icon,
47 categories: widget.categories,
48 editable: false
49 })
50 });
51
52 elementsCollection.each(function (widget) {
53 "forumax-pro" === widget.get("categories")[0] && proWidgets.push(widget)
54 });
55
56 freeCategoryIndex = categories.findIndex({
57 name: "forumax"
58 });
59
60 freeCategoryIndex && categories.add({
61 name: "forumax-pro",
62 title: "Forumax",
63 defaultActive: !1,
64 items: proWidgets
65 }, {
66 at: freeCategoryIndex + 1
67 });
68
69 promotionalWidgetHandler = {
70
71 getWedgetOption: function (name) {
72 return promotionalWidgets.find(function (item) {
73 return item.name == name;
74 });
75 },
76
77 className: function () {
78 var className = 'elementor-element-wrapper';
79
80 if (!this.isEditable()) {
81 className += ' elementor-element--promotion';
82 }
83 return className;
84 },
85
86 onMouseDown: function () {
87 void this.constructor.__super__.onMouseDown.call(this);
88 var promotion = this.getWedgetOption(this.model.get("name"));
89 elementor.promotion.showDialog({
90 title: sprintf(wp.i18n.__('%s', 'forumax'), this.model.get("title")),
91 content: sprintf(wp.i18n.__('Use %s widget and dozens more pro features to extend your toolbox and build sites faster and better.', 'forumax'), this.model.get("title")),
92 targetElement: this.el,
93 position: {
94 blockStart: '-7'
95 },
96 actionButton: {
97 url: promotion.action_button.url,
98 text: promotion.action_button.text,
99 classes: promotion.action_button.classes || ['elementor-button', 'elementor-button-success']
100 }
101 })
102 }
103 }
104
105 panel.elements.view = elementsView.extend({
106 childView: elementsView.prototype.childView.extend(promotionalWidgetHandler)
107 });
108
109 panel.categories.view = categoriesView.extend({
110 childView: categoriesView.prototype.childView.extend({
111 childView: categoriesView.prototype.childView.prototype.childView.extend(promotionalWidgetHandler)
112 })
113 });
114
115 return panel;
116 })
117
118
119 }(jQuery));
120