PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.0
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.0
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / assets / admin / js / reusable-widget.js

reusable-widget.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.7.0, at assets/admin/js/reusable-widget.js

44 lines 999 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import $ from 'jquery';
2
3 function updateReusableBlockLinks($widgets) {
4 if (!$widgets) {
5 $widgets = $('[id*="ghostkit_reusable_widget"].widget');
6 }
7
8 $widgets.each(function () {
9 const $widget = $(this);
10 const $buttonWrap = $widget.find('.gkt-reusable-block-edit-button');
11 const $select = $widget.find('.gkt-reusable-block-select');
12
13 if (!$buttonWrap.length || !$select.length) {
14 return;
15 }
16
17 const adminURL = $buttonWrap.attr('data-admin-url');
18 const selectVal = $select.val();
19
20 if (selectVal) {
21 $buttonWrap
22 .find('a')
23 .attr(
24 'href',
25 `${adminURL}post.php?post=${selectVal}&action=edit`
26 );
27 $buttonWrap.show();
28 } else {
29 $buttonWrap.hide();
30 }
31 });
32 }
33 updateReusableBlockLinks();
34
35 $(document).on('widget-added widget-updated', (e, widget) => {
36 updateReusableBlockLinks(widget);
37 });
38
39 $(document).on('change', '.gkt-reusable-block-select', function () {
40 updateReusableBlockLinks(
41 $(this).closest('[id*="ghostkit_reusable_widget"].widget')
42 );
43 });
44