<commit_before>/**
 * @package assets
 */

(function($) {
	/**
	 * Symphony core interactions
	 */
	$(document).ready(function() {

		/*--------------------------------------------------------------------------
			Core Functions
		--------------------------------------------------------------------------*/

		// Initialize Symphony
		Symphony.init();

		// Catch all javascript errors and write them to the Symphony Log
		window.onerror = function(errorMsg, url, line) {
			$.ajax({
				type: 'POST',
				url: Symphony.Context.get('root') + '/symphony/ajax/log/',
				data: {
					'error': errorMsg,
					'url': url,
					'line': line
				}
			});

			return false;
		};

		/*--------------------------------------------------------------------------
			Plugins - Tags, Pickable and Selectable
		--------------------------------------------------------------------------*/

		// Tags
		$('.tags').symphonyTags();

		// Pickers
		$('select[name="settings[Email][default_gateway]"]').symphonyPickable();

		$('select[name="fields[dynamic_xml][format]"]').symphonyPickable({
			pickables: '#xml'
		});

		// Selectable
		$('table.selectable').symphonySelectable();

		/*--------------------------------------------------------------------------
			Plugins - Orderable
		--------------------------------------------------------------------------*/

		// Orderable list
		$('ul.orderable').symphonyOrderable();

		// Orderable tables
		var old_sorting, orderable = $('table.orderable');
		orderable.symphonyOrderable({
			items: 'tr',
			handles: 'td'
		});

		// Store current sort order
		orderable.on('orderstart.orderable', function() {
			old_sorting = orderable.find('input').map(function(e, i) { return this.name + '=' + (e + 1); }).get().join('&');
		});

		// Process sort order
		orderable.on('orderstop.orderable', function() {
			orderable.addClass('busy');

			// Get new sort order
			var new_sorting = orderable.find('input').map(function(e, i) { return this.name + '=' + (e + 1); }).get().join('&');

			// Store new sort order
			if(new_sorting !== old_sorting) {

				// Update items
				orderable.trigger('orderupdate');

				// Send request
				$.ajax({
					type: 'POST',
					url: Symphony.Context.get('root') + '/symphony/ajax/reorder' + location.href.slice(Symphony.Context.get('root').length + 9),
					data: new_sorting,
					success: function() {
						Symphony.Message.clear('reorder');
					},
					error: function() {
						Symphony.Message.post(Symphony.Language.get('Reordering was unsuccessful.'), 'reorder error');
					},
					complete: function() {
						orderable.removeClass('busy').find('tr').removeClass('selected');
						old_sorting = '';
					}
				});
			}
			else {
				orderable.removeClass('busy');
			}
		});


		/*--------------------------------------------------------------------------
			Plugins - Duplicator and Collapsible
		--------------------------------------------------------------------------*/

		// Duplicators
		$('.filters-duplicator').symphonyDuplicator();

		// Collapsible duplicators
		var duplicator = $('#fields-duplicator');
		duplicator.symphonyDuplicator({
			orderable: true,
			collapsible: true,
			preselect: 'input'
		});

		/*--------------------------------------------------------------------------
			Plugins - System Messages
		--------------------------------------------------------------------------*/
		
		$('header').symphonyNotify();

		/*--------------------------------------------------------------------------
			Components - XSLT Editor
		--------------------------------------------------------------------------*/

		// XSLT utilities
		$('textarea').blur(function() {
			var source = $(this).val(),
				utilities = $('#utilities li');

			// Remove current selection
			utilities.removeClass('selected');

			// Get utitities names
			utilities.find('a').each(function() {
				var utility = $(this),
					expression = new RegExp('href=["\']?(?:\\.{2}/utilities/)?' + utility.text());<commit_msg>When duplicator instances are created, rerun the tag's plugin. Fixes #990<commit_after>/**
 * @package assets
 */

(function($) {
	/**
	 * Symphony core interactions
	 */
	$(document).ready(function() {

		/*--------------------------------------------------------------------------
			Core Functions
		--------------------------------------------------------------------------*/

		// Initialize Symphony
		Symphony.init();

		// Catch all javascript errors and write them to the Symphony Log
		window.onerror = function(errorMsg, url, line) {
			$.ajax({
				type: 'POST',
				url: Symphony.Context.get('root') + '/symphony/ajax/log/',
				data: {
					'error': errorMsg,
					'url': url,
					'line': line
				}
			});

			return false;
		};

		/*--------------------------------------------------------------------------
			Plugins - Tags, Pickable and Selectable
		--------------------------------------------------------------------------*/

		// Tags
		$('.tags').symphonyTags();

		// Pickers
		$('select[name="settings[Email][default_gateway]"]').symphonyPickable();

		$('select[name="fields[dynamic_xml][format]"]').symphonyPickable({
			pickables: '#xml'
		});

		// Selectable
		$('table.selectable').symphonySelectable();

		/*--------------------------------------------------------------------------
			Plugins - Orderable
		--------------------------------------------------------------------------*/

		// Orderable list
		$('ul.orderable').symphonyOrderable();

		// Orderable tables
		var old_sorting, orderable = $('table.orderable');
		orderable.symphonyOrderable({
			items: 'tr',
			handles: 'td'
		});

		// Store current sort order
		orderable.on('orderstart.orderable', function() {
			old_sorting = orderable.find('input').map(function(e, i) { return this.name + '=' + (e + 1); }).get().join('&');
		});

		// Process sort order
		orderable.on('orderstop.orderable', function() {
			orderable.addClass('busy');

			// Get new sort order
			var new_sorting = orderable.find('input').map(function(e, i) { return this.name + '=' + (e + 1); }).get().join('&');

			// Store new sort order
			if(new_sorting !== old_sorting) {

				// Update items
				orderable.trigger('orderupdate');

				// Send request
				$.ajax({
					type: 'POST',
					url: Symphony.Context.get('root') + '/symphony/ajax/reorder' + location.href.slice(Symphony.Context.get('root').length + 9),
					data: new_sorting,
					success: function() {
						Symphony.Message.clear('reorder');
					},
					error: function() {
						Symphony.Message.post(Symphony.Language.get('Reordering was unsuccessful.'), 'reorder error');
					},
					complete: function() {
						orderable.removeClass('busy').find('tr').removeClass('selected');
						old_sorting = '';
					}
				});
			}
			else {
				orderable.removeClass('busy');
			}
		});


		/*--------------------------------------------------------------------------
			Plugins - Duplicator and Collapsible
		--------------------------------------------------------------------------*/

		// Duplicators
		$('.filters-duplicator').symphonyDuplicator();

		// Collapsible duplicators
		var duplicator = $('#fields-duplicator')
			.symphonyDuplicator({
				orderable: true,
				collapsible: true,
				preselect: 'input'
			})
			.on('constructshow.duplicator', function() {
				$('.tags').symphonyTags();
			});

		/*--------------------------------------------------------------------------
			Plugins - System Messages
		--------------------------------------------------------------------------*/

		$('header').symphonyNotify();

		/*--------------------------------------------------------------------------
			Components - XSLT Editor
		--------------------------------------------------------------------------*/

		// XSLT utilities
		$('textarea').blur(function() {
			var source = $(this).val(),
				utilities = $('#utilities li');

			// Remove current selection
			utilities.removeClass('selected');

			// Get utitities names
			utilities.find('a').each(function() {
				var utility = $(this),
					expression = new RegExp('href=["\']?(?:\\.{2}/utilities/)?' + utility.text());
{'fraction_non_alphanumeric': 0.3643305825840621, 'fraction_numerical': 0.0013548466559921172, 'mean_word_length': 1.4195470798569725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5291600', 'n_tokens_mistral': 2608, 'n_tokens_neox': 2072, 'n_words': 396}