PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.6.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.6.0
1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
suredonation / inc / page-builders / elementor / assets / editor.js

editor.js in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 1.6.0, at inc/page-builders/elementor/assets/editor.js

49 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * SureDonation Elementor editor behaviours.
3 *
4 * Backs the Donation Form widget's "Edit Form" button, which opens the selected
5 * form's own editor in a new tab.
6 *
7 * @package SureDonation
8 * @since x.x.x
9 */
10
11 /* global elementor, suredonationElementorData */
12 document.addEventListener( 'DOMContentLoaded', function () {
13 if ( typeof elementor === 'undefined' ) {
14 return;
15 }
16
17 elementor.channels.editor.on( 'suredonation:form:edit', function ( view ) {
18 const settings = view && view.elementSettingsModel;
19
20 if ( ! settings ) {
21 return;
22 }
23
24 // The form selector is split into one control per campaign
25 // (`form_id_{id}`) plus a campaign-less fallback (`form_id`); only the
26 // control matching the current campaign holds the chosen value. Mirrors
27 // Donation_Form_Widget::resolve_form_id().
28 const campaignId = parseInt( settings.get( 'campaign_id' ), 10 ) || 0;
29 const controlKey = campaignId ? 'form_id_' + campaignId : 'form_id';
30 const formId = parseInt( settings.get( controlKey ), 10 ) || 0;
31
32 if ( ! formId ) {
33 return;
34 }
35
36 const editWindow = window.open(
37 suredonationElementorData.adminUrl +
38 'post.php?post=' +
39 formId +
40 '&action=edit',
41 '_blank'
42 );
43
44 if ( editWindow ) {
45 editWindow.focus();
46 }
47 } );
48 } );
49