<commit_before><script>
	if(typeof window.FileChosenCallback == 'undefined') {
    	window.FileChosenCallback = [];
	}
	if(typeof window.LinkChosenCallback == 'undefined') {
    	window.LinkChosenCallback = [];
	}
	if(typeof window.SlideChosenCallback == 'undefined') {
    	window.SlideChosenCallback = [];
	}
	if(typeof window.VideoChosenCallback == 'undefined') {
    	window.VideoChosenCallback = [];
	}
	if(typeof PagePartEditor == 'undefined') {
		PagePartEditor = [];
	}
</script>
<div class="pagepartscontainer" data-context="{{pagepartadmin.context}}" data-pageid="{{ pagepartadmin.page.id }}" data-pageclassname="{{ pagepartadmin.getClassName(pagepartadmin.page) }}">
	<div class="new_pagepart first">
	  <select onchange="return PagePartEditor.addPagepart(this)" class="addselect">
	    <option value="">Add a pagepart</option>
	    {% for pagePartType in pagepartadmin.possiblePagePartTypes %}
	      <option value="{{pagePartType.class}}">{{pagePartType.name}}</option>
	    {% endfor %}
	  </select>
	</div>

    <div id="parts_{{pagepartadmin.context}}" class="pageparts_sortable" data-scope="{% spaceless %}
    {% for type in pagepartadmin.possiblePagePartTypes %}
    {{ type.class|replace({'\\':""})~' ' }}
    {% endfor %}
    {% endspaceless %}">
    {% for id, pagepart in pagepartadmin.pagepartmap %}
		{% include 'KunstmaanPagePartBundle:PagePartAdminTwigExtension:pagepart.html.twig' with { 'id': id, 'pagepartadmin': pagepartadmin, 'editmode': false} %}
    {% endfor %}
    </div>
</div>
<div id="pagepartsdeletedcontainer"></div>
<script>
    //TODO: singleton pagepareditor
    PagePartEditor = {
    	propBarMouseDownHandler: function(){
        		PagePartEditor.sortableClicked = true;
                var scope = $(this).closest('section').data('scope');
                $('.pageparts_sortable[data-scope~=' + scope + ']')
                    .addClass('connectedSortable')
                    .sortable('option', 'connectWith', '.connectedSortable');
                $('.pageparts_sortable:not([data-scope~=' + scope + '])')
                    .sortable('disable')
                    .sortable('option', 'connectWith', false)
                    .parent().addClass('region-disabled');
                $('.template-block-content').not('.sortable')
                    .parent().addClass('region-disabled');
            },
    	sortableClicked: false,
	    addPagepart: function (select){
		    pagepartscontainer = jQuery(select).closest('.pagepartscontainer');
	        jQuery.ajax({
	            url: '{{ path('KunstmaanPagePartBundle_admin_newpagepart') }}',
	            data: {
	            	'pageclassname': pagepartscontainer.data('pageclassname'),
	            	'pageid': pagepartscontainer.data('pageid'),
	            	'context': pagepartscontainer.data('context'),
		            'type': jQuery(select).val()
		        },
	            async: true,
	            success: function(data) {
		            var result = null;
		            if(jQuery(select).parent().hasClass('first')) {
		            	result = jQuery('#parts_'+pagepartscontainer.data('context')).prepend(data);
			        } else {
			        	result = jQuery(select).closest('section').after(data);
				    }
				    console.log(result);
				    result.find('.prop_bar').mousedown(PagePartEditor.propBarMouseDownHandler);
				    disableCKEditors();
				    enableCKEditors();
	            }
		    });
	        jQuery(select).val('');
	        return false;
	    },
	    deletePagepart: function (id){
	    	isEdited = true; // enabling the "leave page" popup
	    	document.getElementById(id + '_deleted').checked = 'checked';
	    	var container = jQuery('#' + id + '_container');
	    	container.slideUp(function(){
	        	container.html('');
	        });
	        return true;
	    },
	    editPagepart: function (id){
	    	isEdited = true; // enabling the "leave page" popup
	        document.getElementById(id + '_edit').style.display = '';
	        document.getElementById(id + '_view').style.display = 'none';
	        window.activeEdit = id;
	        return false;
	    }
    }

    function disableCKEditors(){
    	for ( instance in CKEDITOR.instances ){
            CKEDITOR.instances[instance].destroy();
		}
    }

    function enableCKEditors(){
    	jQuery('textarea.rich_editor').each(function(item){
			var config = {};
        	if($(this).attr('height')){
        		config.height = $(this).attr('height');
            }
        	if($(this).attr('noparagraphs')){
        		config.enterMode = CKEDITOR.ENTER_BR;
	         		config.shiftEnterMode = CKEDITOR.ENTER_P;
            }
    		CKEDITOR.replace( $(this).attr('id'), config);
		});
    }

    $(document).ready(function () {

        $('.prop_bar').mousedown(PagePartEditor.propBarMouseDownHandler);
        $('body').mouseup(
            function() {<commit_msg>Only destroy CKEDITOR with class = rich_editor<commit_after><script>
	if(typeof window.FileChosenCallback == 'undefined') {
    	window.FileChosenCallback = [];
	}
	if(typeof window.LinkChosenCallback == 'undefined') {
    	window.LinkChosenCallback = [];
	}
	if(typeof window.SlideChosenCallback == 'undefined') {
    	window.SlideChosenCallback = [];
	}
	if(typeof window.VideoChosenCallback == 'undefined') {
    	window.VideoChosenCallback = [];
	}
	if(typeof PagePartEditor == 'undefined') {
		PagePartEditor = [];
	}
</script>
<div class="pagepartscontainer" data-context="{{pagepartadmin.context}}" data-pageid="{{ pagepartadmin.page.id }}" data-pageclassname="{{ pagepartadmin.getClassName(pagepartadmin.page) }}">
	<div class="new_pagepart first">
	  <select onchange="return PagePartEditor.addPagepart(this)" class="addselect">
	    <option value="">Add a pagepart</option>
	    {% for pagePartType in pagepartadmin.possiblePagePartTypes %}
	      <option value="{{pagePartType.class}}">{{pagePartType.name}}</option>
	    {% endfor %}
	  </select>
	</div>

    <div id="parts_{{pagepartadmin.context}}" class="pageparts_sortable" data-scope="{% spaceless %}
    {% for type in pagepartadmin.possiblePagePartTypes %}
    {{ type.class|replace({'\\':""})~' ' }}
    {% endfor %}
    {% endspaceless %}">
    {% for id, pagepart in pagepartadmin.pagepartmap %}
		{% include 'KunstmaanPagePartBundle:PagePartAdminTwigExtension:pagepart.html.twig' with { 'id': id, 'pagepartadmin': pagepartadmin, 'editmode': false} %}
    {% endfor %}
    </div>
</div>
<div id="pagepartsdeletedcontainer"></div>
<script>
    //TODO: singleton pagepareditor
    PagePartEditor = {
    	propBarMouseDownHandler: function(){
        		PagePartEditor.sortableClicked = true;
                var scope = $(this).closest('section').data('scope');
                $('.pageparts_sortable[data-scope~=' + scope + ']')
                    .addClass('connectedSortable')
                    .sortable('option', 'connectWith', '.connectedSortable');
                $('.pageparts_sortable:not([data-scope~=' + scope + '])')
                    .sortable('disable')
                    .sortable('option', 'connectWith', false)
                    .parent().addClass('region-disabled');
                $('.template-block-content').not('.sortable')
                    .parent().addClass('region-disabled');
            },
    	sortableClicked: false,
	    addPagepart: function (select){
		    pagepartscontainer = jQuery(select).closest('.pagepartscontainer');
	        jQuery.ajax({
	            url: '{{ path('KunstmaanPagePartBundle_admin_newpagepart') }}',
	            data: {
	            	'pageclassname': pagepartscontainer.data('pageclassname'),
	            	'pageid': pagepartscontainer.data('pageid'),
	            	'context': pagepartscontainer.data('context'),
		            'type': jQuery(select).val()
		        },
	            async: true,
	            success: function(data) {
		            var result = null;
		            if(jQuery(select).parent().hasClass('first')) {
		            	result = jQuery('#parts_'+pagepartscontainer.data('context')).prepend(data);
			        } else {
			        	result = jQuery(select).closest('section').after(data);
				    }
				    console.log(result);
				    result.find('.prop_bar').mousedown(PagePartEditor.propBarMouseDownHandler);
				    disableCKEditors();
				    enableCKEditors();
	            }
		    });
	        jQuery(select).val('');
	        return false;
	    },
	    deletePagepart: function (id){
	    	isEdited = true; // enabling the "leave page" popup
	    	document.getElementById(id + '_deleted').checked = 'checked';
	    	var container = jQuery('#' + id + '_container');
	    	container.slideUp(function(){
	        	container.html('');
	        });
	        return true;
	    },
	    editPagepart: function (id){
	    	isEdited = true; // enabling the "leave page" popup
	        document.getElementById(id + '_edit').style.display = '';
	        document.getElementById(id + '_view').style.display = 'none';
	        window.activeEdit = id;
	        return false;
	    }
    }

    function disableCKEditors(){
        for ( instance in CKEDITOR.instances ){
            if ($('#' + CKEDITOR.instances[instance].name).hasClass('rich_editor')) {
                CKEDITOR.instances[instance].destroy();

            }
        }
    }

    function enableCKEditors(){
    	jQuery('textarea.rich_editor').each(function(item){
			var config = {};
        	if($(this).attr('height')){
        		config.height = $(this).attr('height');
            }
        	if($(this).attr('noparagraphs')){
        		config.enterMode = CKEDITOR.ENTER_BR;
	         		config.shiftEnterMode = CKEDITOR.ENTER_P;
            }
    		CKEDITOR.replace( $(this).attr('id'), config);
		});
    }

    $(document).ready(function () {

        $('.prop_bar').mousedown(PagePartEditor.propBarMouseDownHandler);
        $('body').mouseup(
            function() {
{'fraction_non_alphanumeric': 0.15835449466734383, 'fraction_numerical': 0.0, 'mean_word_length': 2.6412721893491122, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2281597', 'n_tokens_mistral': 3050, 'n_tokens_neox': 2798, 'n_words': 435}