PluginProbe
Ultimate Store Kit / 3.1.3
Ultimate Store Kit v3.1.3
3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 92 releases
ultimate-store-kit / src / js / editor.js

editor.js in Ultimate Store Kit 3.1.3, at src/js/editor.js

147 lines 4.5 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 UltimateStoreKitEditor = {
6 shouldReload: false,
7 init: function () {
8 elementor.channels.editor.on('section:activated', UltimateStoreKitEditor.onAnimatedBoxSectionActivated);
9
10 window.elementor.on('preview:loaded', function () {
11 elementor.$preview[0].contentWindow.UltimateStoreKitEditor = UltimateStoreKitEditor;
12 UltimateStoreKitEditor.onPreviewLoaded();
13 });
14
15 elementor.channels.editor.on('ultimateStoreKitBuilderSetting:applySinglePagePostOnPreview', UltimateStoreKitEditor.ApplyPreviewPostId);
16 elementor.channels.editor.on('saved', UltimateStoreKitEditor.savedBuilder)
17
18 },
19
20
21 savedBuilder: function () {
22 if (UltimateStoreKitEditor.shouldReload) {
23 UltimateStoreKitEditor.shouldReload = false;
24 window.location.href = window.location.href;
25 }
26 },
27 ApplyPreviewPostId: function () {
28 UltimateStoreKitEditor.shouldReload = true;
29 $("#elementor-panel-saver-button-publish").trigger('click');
30 },
31
32 onPreviewLoaded: function () {
33 var elementorFrontend = $('#elementor-preview-iframe')[0].contentWindow.elementorFrontend;
34
35 elementorFrontend.hooks.addAction('frontend/element_ready/widget', function ($scope) {
36 $scope.find('.usk-elementor-template-edit-link').on('click', function (event) {
37 window.open($(this).attr('href'));
38 });
39 });
40 }
41 };
42
43 $(window).on('elementor:init', UltimateStoreKitEditor.init);
44
45 window.UltimateStoreKitEditor = UltimateStoreKitEditor;
46
47
48
49 elementor.hooks.addFilter("panel/elements/regionViews", function (panel) {
50
51 jQuery(document).ready(function () {
52 jQuery('body').append(`<style>.bdt-pro-unlock-icon:after{right: auto !important; left: 5px !important;}</style>`);
53 });
54
55 if (UltimateStoreKitConfigEditor.pro_license_activated || UltimateStoreKitConfigEditor.promotional_widgets <= 0) return panel;
56
57 var promotionalWidgetHandler,
58 promotionalWidgets = UltimateStoreKitConfigEditor.promotional_widgets,
59 elementsCollection = panel.elements.options.collection,
60 categories = panel.categories.options.collection,
61 categoriesView = panel.categories.view,
62 elementsView = panel.elements.view,
63 freeCategoryIndex, proWidgets = [];
64
65 _.each(promotionalWidgets, function (widget, index) {
66 elementsCollection.add({
67 name: widget.name,
68 title: widget.title,
69 icon: widget.icon,
70 categories: widget.categories,
71 editable: false
72 })
73 });
74
75 elementsCollection.each(function (widget) {
76 "ultimate-store-kit-pro" === widget.get("categories")[0] && proWidgets.push(widget)
77 });
78
79 freeCategoryIndex = categories.findIndex({
80 name: "ultimate-store-kit"
81 });
82
83 freeCategoryIndex && categories.add({
84 name: "ultimate-store-kit-pro",
85 title: "Ultimate Store Kit Pro",
86 defaultActive: !1,
87 items: proWidgets
88 }, {
89 at: freeCategoryIndex + 1
90 });
91
92 promotionalWidgetHandler = {
93
94 getWedgetOption: function (name) {
95 return promotionalWidgets.find(function (item) {
96 return item.name == name;
97 });
98 },
99
100 className: function () {
101 var className = 'elementor-element-wrapper';
102
103 if (!this.isEditable()) {
104 className += ' elementor-element--promotion';
105 }
106 return className;
107 },
108
109 onMouseDown: function () {
110 void this.constructor.__super__.onMouseDown.call(this);
111 var promotion = this.getWedgetOption(this.model.get("name"));
112 elementor.promotion.showDialog({
113 title: sprintf(wp.i18n.__('%s', 'elementor'), this.model.get("title")),
114 content: sprintf(wp.i18n.__('Use %s widget and dozens more pro features to extend your toolbox and build sites faster and better.', 'elementor'), this.model.get("title")),
115 targetElement: this.el,
116 position: {
117 blockStart: '-7'
118 },
119 actionButton: {
120 url: promotion.action_button.url,
121 text: promotion.action_button.text,
122 classes: promotion.action_button.classes || ['elementor-button', 'elementor-button-success']
123 }
124 })
125 }
126 }
127
128 panel.elements.view = elementsView.extend({
129 childView: elementsView.prototype.childView.extend(promotionalWidgetHandler)
130 });
131
132 panel.categories.view = categoriesView.extend({
133 childView: categoriesView.prototype.childView.extend({
134 childView: categoriesView.prototype.childView.prototype.childView.extend(promotionalWidgetHandler)
135 })
136 });
137 return panel;
138 });
139
140 $('iframe').on('load', function () {
141 var iframeContents = $(this).contents();
142 if (iframeContents.find(".usk-template-builder-template").length) {
143 iframeContents.find(".usk-template-builder-template").addClass('woocommerce woocommerce-page');
144 }
145 });
146
147 }(jQuery));