PHP 8.2.31
Preview: term-ordering.js Size: 4.62 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/assets/js/admin/term-ordering.js

/*global ajaxurl, woocommerce_term_ordering_params */

/* Modifided script from the simple-page-ordering plugin */
jQuery( function( $ ) {

	var table_selector   = 'table.wp-list-table',
		item_selector    = 'tbody tr:not(.inline-edit-row)',
		term_id_selector = '.column-handle input[name="term_id"]',
		column_handle    = '<td class="column-handle"></td>';

	if ( 0 === $( table_selector ).find( '.column-handle' ).length ) {
		$( table_selector ).find( 'tr:not(.inline-edit-row)' ).append( column_handle );

		term_id_selector = '.check-column input';
	}

	// Stand-in wcTracks.recordEvent in case tracks is not available (for any reason).
	window.wcTracks = window.wcTracks || {};
	window.wcTracks.recordEvent = window.wcTracks.recordEvent  || function() { };

	$( table_selector ).find( '.column-handle' ).show();

	$.wc_add_missing_sort_handles = function() {
		var all_table_rows = $( table_selector ).find('tbody > tr');
		var rows_with_handle = $( table_selector ).find('tbody > tr > td.column-handle').parent();
		if ( all_table_rows.length !== rows_with_handle.length ) {
			all_table_rows.each(function(index, elem){
				if ( ! rows_with_handle.is( elem ) ) {
					$( elem ).append( column_handle );
				}
			});
		}
		$( table_selector ).find( '.column-handle' ).show();
	};

	$( document ).ajaxComplete( function( event, request, options ) {
		if (
			request &&
			4 === request.readyState &&
			200 === request.status &&
			options.data &&
			( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) )
		) {
			$.wc_add_missing_sort_handles();
			$( document.body ).trigger( 'init_tooltips' );
		}
	} );

	$( table_selector ).sortable({
		items: item_selector,
		cursor: 'move',
		handle: '.column-handle',
		axis: 'y',
		forcePlaceholderSize: true,
		helper: 'clone',
		opacity: 0.65,
		placeholder: 'product-cat-placeholder',
		scrollSensitivity: 40,
		start: function( event, ui ) {
			if ( ! ui.item.hasClass( 'alternate' ) ) {
				ui.item.css( 'background-color', '#ffffff' );
			}
			ui.item.children( 'td, th' ).css( 'border-bottom-width', '0' );
			ui.item.css( 'outline', '1px solid #aaa' );
		},
		stop: function( event, ui ) {
			ui.item.removeAttr( 'style' );
			ui.item.children( 'td, th' ).css( 'border-bottom-width', '1px' );
		},
		update: function( event, ui ) {
			var termid     = ui.item.find( term_id_selector ).val(); // this post id
			var termparent = ui.item.find( '.parent' ).html();            // post parent

			var prevtermid = ui.item.prev().find( term_id_selector ).val();
			var nexttermid = ui.item.next().find( term_id_selector ).val();

			// Can only sort in same tree
			var prevtermparent, nexttermparent;
			if ( prevtermid !== undefined ) {
				prevtermparent = ui.item.prev().find( '.parent' ).html();
				if ( prevtermparent !== termparent) {
					prevtermid = undefined;
				}
			}

			if ( nexttermid !== undefined ) {
				nexttermparent = ui.item.next().find( '.parent' ).html();
				if ( nexttermparent !== termparent) {
					nexttermid = undefined;
				}
			}

			// If previous and next not at same tree level, or next not at same tree level and
			// the previous is the parent of the next, or just moved item beneath its own children.
			if (
				( prevtermid === undefined && nexttermid === undefined ) ||
				( nexttermid === undefined && nexttermparent === prevtermid ) ||
				( nexttermid !== undefined && prevtermparent === termid )
			) {
				$( table_selector ).sortable( 'cancel' );
				return;
			}

			window.wcTracks.recordEvent( 'product_attributes_ordering_term', {
				is_category:
					woocommerce_term_ordering_params.taxonomy === 'product_cat'
						? 'yes'
						: 'no',
			} );

			// Show Spinner
			ui.item.find( '.check-column input' ).hide();
			ui.item
				.find( '.check-column' )
				.append( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' );

			// Go do the sorting stuff via ajax.
			$.post(
				ajaxurl,
				{
					action: 'woocommerce_term_ordering',
					security: woocommerce_term_ordering_params.nonce,
					id: termid,
					nextid: nexttermid,
					thetaxonomy: woocommerce_term_ordering_params.taxonomy
				},
				function(response) {
					if ( response === 'children' ) {
						window.location.reload();
					} else {
						ui.item.find( '.check-column input' ).show();
						ui.item.find( '.check-column' ).find( 'img' ).remove();
					}
				}
			);

			// Fix cell colors
			$( 'table.widefat tbody tr' ).each( function() {
				var i = jQuery( 'table.widefat tbody tr' ).index( this );
				if ( i%2 === 0 ) {
					jQuery( this ).addClass( 'alternate' );
				} else {
					jQuery( this ).removeClass( 'alternate' );
				}
			});
		}
	});

});

Directory Contents

Dirs: 0 × Files: 70

Name Size Perms Modified Actions
3.89 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
2.23 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
4.35 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
2.77 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
16.84 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
6.66 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
2.99 KB lrw-r--r-- 2025-04-01 15:51:36
Edit Download
1.61 KB lrw-r--r-- 2025-04-01 15:51:36
Edit Download
54.51 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
33.12 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
42.26 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
22.55 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
37.39 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
19.50 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
4.95 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
3.02 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
2.34 KB lrw-r--r-- 2018-05-23 19:30:10
Edit Download
1.25 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
1.16 KB lrw-r--r-- 2023-12-27 00:45:02
Edit Download
730 B lrw-r--r-- 2023-12-27 00:45:02
Edit Download
696 B lrw-r--r-- 2025-07-29 12:34:58
Edit Download
298 B lrw-r--r-- 2025-07-29 12:34:58
Edit Download
2.60 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
1.66 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
7.06 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
4.58 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
5.39 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
2.70 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
12.04 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
6.08 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
11.95 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
6.25 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
5.38 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.08 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
4.62 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
2.52 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.78 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
1.87 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
4.06 KB lrw-r--r-- 2024-09-23 20:44:04
Edit Download
1.59 KB lrw-r--r-- 2024-09-23 20:44:04
Edit Download
869 B lrw-r--r-- 2021-05-18 21:00:20
Edit Download
336 B lrw-r--r-- 2021-05-18 21:00:20
Edit Download
1.61 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
1.13 KB lrw-r--r-- 2025-09-01 23:44:48
Edit Download
13.58 KB lrw-r--r-- 2023-08-16 00:05:04
Edit Download
7.71 KB lrw-r--r-- 2023-08-16 00:05:04
Edit Download
1.98 KB lrw-r--r-- 2022-10-19 00:34:38
Edit Download
1.17 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
3.79 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
2.09 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
2.92 KB lrw-r--r-- 2023-05-24 03:17:54
Edit Download
1.70 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
1.43 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
638 B lrw-r--r-- 2026-02-23 17:58:34
Edit Download
10.05 KB lrw-r--r-- 2021-05-18 21:00:20
Edit Download
6.35 KB lrw-r--r-- 2023-07-18 23:53:36
Edit Download
6.57 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
3.57 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
7.04 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
3.90 KB lrw-r--r-- 2026-03-30 17:12:24
Edit Download
35.43 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
17.10 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
9.23 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
4.85 KB lrw-r--r-- 2025-03-03 22:28:12
Edit Download
1.33 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
574 B lrw-r--r-- 2026-02-23 17:58:34
Edit Download
1.78 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
1.05 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
22.32 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
11.93 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).