HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/epamokos.kaunokolegija.lt/wp-content/plugins/download-attachments/js/admin-attachment.js
( function( $ ) {

    // ready event
	$( function() {
		var container = $( '#attachment-downloads-input-container' );
		var counter = $( '#attachment-downloads-display strong' );
		var editLink = $( '#attachment-downloads .edit-attachment-downloads' );
		var counterInput = $( '#attachment-downloads-input' );

		// attachment downloads input
		editLink.on( 'click', function() {
			if ( container.is( ":hidden" ) ) {
				container.slideDown( 'fast' );

				$( this ).hide();
			}

			return false;
		} );

		// save attachment downloads
		$( '#attachment-downloads .save-attachment-downloads' ).on( 'click', function() {
			// clear downloads
			counter.text();

			// hide container
			container.slideUp( 'fast' );

			// show edit link
			editLink.show();

			// get number of downloads
			var downloads = parseInt( counterInput.val() );

			// reassign value as integer
			counterInput.val( downloads );

			// update number of downloads
			counter.text( downloads );

			return false;
		} );

		// cancel attachment downloads
		$( '#attachment-downloads .cancel-attachment-downloads' ).on( 'click', function() {
			// clear downloads
			counter.text();

			// hide container
			container.slideUp( 'fast' );

			// show edit link
			editLink.show();

			// get number of downloads
			var downloads = parseInt( $( '#attachment-downloads-current' ).val() );

			// update number of downloads
			counter.text( downloads );

			// restore old value
			counterInput.val( downloads );

			return false;
		} );
    } );

} )( jQuery );