HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/advanced-post-manager/resources/tribe-columns.js
jQuery(document).ready(function($) {
	
	var dropdown = $("#tribe-cols-drop"),
	activeList = $("#tribe-cols-active");
	
	activeList.sortable({
		placeholder: 'ui-sortable-placeholder',
		stop: normalizeActiveInputs
	});
	
	dropdown.change(function() {
		var active = $(this).find(":selected"),
		item = Tribe_Columns.item.replace('%name%', active.text() ),
		input = Tribe_Columns.input.replace('%value%', active.val() );

		if ( active.val() == 0 )
			return false;
		
		$(item).prepend(input).appendTo(activeList);
		active.remove();
		normalizeActiveInputs();
	});
	
	activeList.delegate(".close", "click", function() {
		var active = $(this).parent();
		$(this).remove();
		var value = active.find("input").val();
		var name = active.text();

		if ( value == 'comments' ) {
			name = 'Comments';
		}

		option = $('<option></option>').val(value).text(name);
		
		option.appendTo(dropdown);
	
		active.remove();
		normalizeActiveInputs();
	});
	
	function normalizeActiveInputs() {
		activeList.children().each(function(idx) {
			var i = idx + 1;
			$(this).find("input").attr("name", Tribe_Columns.prefix + i );
		});
	}
});