PluginProbe
Depicter — Popup & Slider Builder / 1.5.2
Depicter — Popup & Slider Builder v1.5.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / resources / scripts / admin / index.js

index.js in Depicter — Popup & Slider Builder 1.5.2, at resources/scripts/admin/index.js

147 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // eslint-disable-next-line no-unused-vars
2 // import config from '@config';
3 // import '@styles/admin';
4 // Uncomment the following line if needed:
5 // import 'airbnb-browser-shims';
6
7 // Your code goes here ...
8
9 // enable submit and deactivate button while clicking on survey list items
10 (function ($) {
11
12 var publishSliderButtonFunc = function ( view = false ) {
13 $('.depicter-publish-slider:not([disabled])').on('click', function () {
14 var $this = $(this);
15 $this.find('.btn-label').hide();
16 $this.find('.depicter-state-icon').show();
17 var sliderID = $this.parents('tbody,#elementor-controls').find('select').val();
18 var data = {
19 action: 'depicter/document/store',
20 ID: sliderID.replace( '#', ''),
21 status: 'published'
22 };
23
24 $.ajax({
25 url: depicterParams.ajaxUrl,
26 type: 'POST',
27 data: data,
28 headers: {
29 'X-DEPICTER-CSRF': depicterParams.token
30 }
31 }).done(function (response) {
32 if (response.hits) {
33 $this.attr('disabled', true);
34 $this.parents('.depicter-notice-btns').siblings('.depicter-notice-txts').hide();
35 $this.find('.btn-label').html(depicterParams.publishedText);
36 $this.find('.btn-label').show();
37 $this.find('.depicter-state-icon').hide();
38 if (view) {
39 view.$el.find('.depicter-notice-wrapper').remove();
40 } else {
41 $('.fl-module-module').find('.depicter-notice-wrapper').remove();
42 }
43 } else {
44 $this.find('.btn-label').show();
45 $this.find('.depicter-state-icon').hide();
46 }
47 });
48
49 });
50 }
51
52 var editSliderButtonFunc = function () {
53 $('.depicter-edit-slider').on('click', function(){
54 var sliderID = $(this).parents('tbody, #elementor-controls').find('select').val();
55 var editorUrl = depicterParams.editorUrl.replace( 'document=1', 'document=' + sliderID.replace('#', '') );
56 window.open( editorUrl );
57 });
58 }
59
60 $(document).ready(function () {
61
62 var $feedbackContainer = $('.depicter-survey-container');
63 // show the popup survey
64 $('#deactivate-depicter').on('click', function (e) {
65 e.preventDefault();
66 $feedbackContainer.addClass('show');
67 });
68
69 // close the popup survey
70 $feedbackContainer.on('click', function(e) {
71 if ((!$(e.target).parents('.depicter-survey-list').length && !$(e.target).is('.depicter-survey-list')) || $(e.target).is('.depicter-close')) {
72 $feedbackContainer.removeClass('show');
73 }
74 });
75
76 // enable submit button if one reason clicked
77 $feedbackContainer.find('input[name="dep_deactivation_reason"]').each(function () {
78 $(this).on('click', function () {
79 $feedbackContainer.find('.depicter-submit').attr('disabled', false);
80 });
81 });
82
83 var ajaxDeactivationRequest = function (reason, userDescriptionText) {
84 $.ajax({
85 url: depDeactivationParams.ajaxUrl,
86 method: 'POST',
87 data: {
88 _wpnonce: $feedbackContainer.find('#_wpnonce').val(),
89 action: 'depicter/deactivate/feedback',
90 issueRelatesTo: reason,
91 userDescription: userDescriptionText,
92 },
93 }).done(function (res) {
94 location.href = $('#deactivate-depicter').attr('href');
95 });
96 };
97
98 // send deactivation feedback
99 $feedbackContainer.find('.depicter-submit').on('click', function () {
100 var $selectedRadioInput = $feedbackContainer.find('input[name="dep_deactivation_reason"]:checked'),
101 reason = $selectedRadioInput.val(),
102 userDescriptionText = $selectedRadioInput.parent('div').find('input[type="text"').length ? $selectedRadioInput.parent('div').find('input[type="text"').val() : '';
103 ajaxDeactivationRequest(reason, userDescriptionText);
104 $(this).parent('.depicter-button-wrapper').addClass('loading');
105 });
106
107 // deactivate plugin if click on skip
108 $feedbackContainer.find('.depicter-skip').on('click', function() {
109 ajaxDeactivationRequest('skip', '');
110 $(this).parent('.depicter-button-wrapper').addClass('loading skipped');
111 location.href = $('#deactivate-depicter').attr('href');
112 });
113
114 // ─── Beaver Builder Js ───────────────────────────────────────────
115
116 var beaverBuilderControls = function () {
117 var $tbody = $('.fl-field-control-wrapper select[name="document_id"]').parents('tbody');
118
119 $tbody.find(' > tr:not(#fl-field-document_id)').hide();
120 var sliderID = $('.fl-field-control-wrapper select[name="document_id"]').val();
121 $('#fl-field-slider_control_buttons_' + sliderID.replace( '#', '')).show();
122
123 editSliderButtonFunc();
124
125 publishSliderButtonFunc();
126 }
127
128 if (typeof FLBuilder != 'undefined') {
129 $('body').on('fl-builder.settings-form-init', function () {
130 $('.fl-field-control-wrapper select[name="document_id"]').on('change', function () {
131 beaverBuilderControls();
132 });
133 beaverBuilderControls();
134 });
135 }
136
137 });
138
139 if ( window.elementor ) {
140 elementor.hooks.addAction( 'panel/open_editor/widget', function( panel, model, view ) {
141 editSliderButtonFunc();
142 publishSliderButtonFunc(view);
143 });
144 }
145
146 })(jQuery);
147