# ghostkit/3.7.0/assets/admin/js/reusable-widget.js

Block Animations, Motion &amp; Scroll Effects – Ghost Kit, version 3.7.0. 44 lines.

- Page: https://pluginprobe.com/plugins/ghostkit/3.7.0/code/assets/admin/js/reusable-widget.js
- Raw: https://pluginprobe.com/plugins/ghostkit/3.7.0/raw/assets/admin/js/reusable-widget.js
- Modified: 2024-02-18T18:40:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ghostkit/3.7.0/code/assets/admin/js/reusable-widget.js#L10-L20`.

```javascript
import $ from 'jquery';

function updateReusableBlockLinks($widgets) {
	if (!$widgets) {
		$widgets = $('[id*="ghostkit_reusable_widget"].widget');
	}

	$widgets.each(function () {
		const $widget = $(this);
		const $buttonWrap = $widget.find('.gkt-reusable-block-edit-button');
		const $select = $widget.find('.gkt-reusable-block-select');

		if (!$buttonWrap.length || !$select.length) {
			return;
		}

		const adminURL = $buttonWrap.attr('data-admin-url');
		const selectVal = $select.val();

		if (selectVal) {
			$buttonWrap
				.find('a')
				.attr(
					'href',
					`${adminURL}post.php?post=${selectVal}&action=edit`
				);
			$buttonWrap.show();
		} else {
			$buttonWrap.hide();
		}
	});
}
updateReusableBlockLinks();

$(document).on('widget-added widget-updated', (e, widget) => {
	updateReusableBlockLinks(widget);
});

$(document).on('change', '.gkt-reusable-block-select', function () {
	updateReusableBlockLinks(
		$(this).closest('[id*="ghostkit_reusable_widget"].widget')
	);
});

```
