<commit_before><script>
    window.ImagegalleryImageChosenCallback = new Array();
</script>
<div class="pagepartscontainer" id="parts_{{pagepartadmin.context}}">
    {% for pagepartref in pagepartadmin.pagepartrefs %}
    	{% set pagepart = pagepartadmin.getPagePart(pagepartref) %}
    	<section class="draggable pagepartcontainer" id="{{pagepartref.id}}_container" >
	        <script>
	            function delete_{{pagepartref.id}}(){
	                document.getElementById('{{pagepartref.id}}_deleted').value = 'true';
	                jQuery('#{{pagepartref.id}}_container').slideUp(function(){
	                    jQuery('#pagepartsdeletedcontainer').append(jQuery('#{{pagepartref.id}}_container'));
	                });
	                return false;
	            }
	            function moveUp_{{pagepartref.id}}(){
	                var $parent = jQuery('#{{pagepartref.id}}_container');
	                var $parentprev = $parent.prev();
	                $parent.swap({
	                    target: $parent.prev().attr('id'),
	                    opacity: "0.5",
	                    speed: 1000,
	                    callback: function() {
	                        $parent.insertBefore($parentprev);
	                        $parent.css("top", "auto").css("left", "auto");
	                        $parentprev.css("top", "auto").css("left", "auto");
	                    }
	                });
	                return false;
	            }
	            function moveDown_{{pagepartref.id}}(){
	                var $parent = jQuery('#{{pagepartref.id}}_container');
	                var $parentnext = $parent.next();
	                $parent.swap({
	                    target: $parent.next().attr('id'),
	                    opacity: "0.5",
	                    speed: 1000,
	                    callback: function() {
	                        $parent.insertAfter($parentnext);
	                        $parent.css("top", "auto").css("left", "auto");
	                        $parentnext.css("top", "auto").css("left", "auto");
	                    }
	                });
	                return false;
	            }
	            function edit_{{pagepartref.id}}(){
	                document.getElementById('{{pagepartref.id}}_view').style.display = 'none';
	                document.getElementById('{{pagepartref.id}}_edit').style.display = '';
                    window.activeEdit = '{{pagepartref.id}}';
	                return false;
	            }
	        </script>
	        <input type="hidden" id="{{pagepartref.id}}_deleted" name="{{pagepartref.id}}_deleted" value="" />
	        <input type="hidden" id="{{pagepartref.context}}_{{pagepartref.pageid}}_{{pagepartref.pageentityname}}_sequence" name="{{pagepartref.context}}_{{pagepartref.pageid}}_{{pagepartref.pageentityname}}_sequence[]" value="{{pagepartref.id}}" />
        
            <div class="pagepart">
            	<div class="prop_bar {% if not form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id].count %}noedit{% endif %}">
            		<h6>{{pagepartadmin.getType(pagepart)}}</h6>
            		{#
            		  <a class="btn small" href="#" onclick="return moveUp_{{pagepartref.id}}()">Up</a>
                      <a class="btn small" href="#" onclick="return moveDown_{{pagepartref.id}}()">Down</a>
            		#}
					<a class="del red" data-controls-modal="delete-pagepart" data-backdrop="true" data-keyboard="true" onclick="return delete_{{pagepartref.id}}()"><span>Del</span></a>
                    {% if form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id].count %}
                        <a href="#" class="bleu" onclick="return edit_{{pagepartref.id}}()">Edit</a>
                    {% endif %}
            	</div>
                {% if form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id].count %}
                    <div class="block" id="{{pagepartref.id}}_view">
                        {% include pagepart.defaultview with {'resource': pagepart, 'pagepartadmin': pagepartadmin, 'pageparts': pagepartadmin.pagepartrefs} %}
                    </div>
                    <div class="block" id="{{pagepartref.id}}_edit" style="display:none">
                        {% set pagepartid %}pagepart{{pagepartref.id}}{%endset%}
                        {{ form_widget(form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id]) }}
                    </div>
                {% endif %}
            </div>
            <div class="new_pagepart">
              <select onchange="return doAddpagepart_{{pagepartadmin.context}}(this)">
	            <option value="">Add a pagepart</option>
	            {% for pagePartType in pagepartadmin.possiblePagePartTypes %}
	              <option value="{{pagePartType.class}}">{{pagePartType.name}}</option>
	            {% endfor %}
              </select>
            </div>
        </section>
    {% else %}
    	<section class="draggable pagepartcontainer">
            <div class="new_pagepart">
              <select onchange="return doAddpagepart_{{pagepartadmin.context}}(this)">
	            <option value="">Add a pagepart</option>
	            {% for pagePartType in pagepartadmin.possiblePagePartTypes %}
	              <option value="{{pagePartType.class}}">{{pagePartType.name}}</option>
	            {% endfor %}
              </select>
            </div>
        </section>
    {% endfor %}
</div>
<input type="hidden" id="{{pagepartadmin.context}}_addposition" name="{{pagepartadmin.context}}_addposition" value="" />
<div class="clearfix">
    <script type="text/javascript">
        function doAddpagepart_{{pagepartadmin.context}}(select){
            var position = jQuery('#parts_{{pagepartadmin.context}} section.draggable').index(jQuery(select).parents("section.draggable"))+1;
            if(position<0){
				position = 0;
            }
            jQuery('#{{pagepartadmin.context}}_addposition').val(position);
            jQuery(select).attr('name', 'addpagepart_{{pagepartadmin.context}}');
            jQuery('form')[0].submit();
            return false;
        }
    </script>
</div>
<div id="pagepartsdeletedcontainer">

</div>
<script type="text/javascript">
	$(document).ready(function () {
		$('#parts_{{pagepartadmin.context}}').sortable({  
		    handle: '.prop_bar',  
		    cursor: 'move',  
		    placeholder: 'placeholder',  
		    forcePlaceholderSize: true, 
			revert: 100,
		    //opacity: 0.4
		    opacity: 1,
			start: function(e, ui) {
				$('.draggable').css('opacity', ".4");
				$('.ui-sortable-helper .new_pagepart').slideUp("fast");
			},
			stop: function(e, ui) {
				$('.draggable').css('opacity', "1");
			}
		    //containment: 'document'
		})  
		.disableSelection();
	});
</script><commit_msg>scroll to added pagepart + edit<commit_after><script>
    window.ImagegalleryImageChosenCallback = new Array();
</script>
<div class="pagepartscontainer" id="parts_{{pagepartadmin.context}}">
	{% if app.request.get('edit') is defined and app.request.get('edit') !="" %}
		{% set editpagepart = app.request.get('edit') + 1 %}
	{% endif %}
    {% for pagepartref in pagepartadmin.pagepartrefs %}
    	{% set pagepart = pagepartadmin.getPagePart(pagepartref) %}
    	<section class="draggable pagepartcontainer" id="{{pagepartref.id}}_container" >
	        <script>
	            function delete_{{pagepartref.id}}(){
	                document.getElementById('{{pagepartref.id}}_deleted').value = 'true';
	                jQuery('#{{pagepartref.id}}_container').slideUp(function(){
	                    jQuery('#pagepartsdeletedcontainer').append(jQuery('#{{pagepartref.id}}_container'));
	                });
	                return false;
	            }
	            function moveUp_{{pagepartref.id}}(){
	                var $parent = jQuery('#{{pagepartref.id}}_container');
	                var $parentprev = $parent.prev();
	                $parent.swap({
	                    target: $parent.prev().attr('id'),
	                    opacity: "0.5",
	                    speed: 1000,
	                    callback: function() {
	                        $parent.insertBefore($parentprev);
	                        $parent.css("top", "auto").css("left", "auto");
	                        $parentprev.css("top", "auto").css("left", "auto");
	                    }
	                });
	                return false;
	            }
	            function moveDown_{{pagepartref.id}}(){
	                var $parent = jQuery('#{{pagepartref.id}}_container');
	                var $parentnext = $parent.next();
	                $parent.swap({
	                    target: $parent.next().attr('id'),
	                    opacity: "0.5",
	                    speed: 1000,
	                    callback: function() {
	                        $parent.insertAfter($parentnext);
	                        $parent.css("top", "auto").css("left", "auto");
	                        $parentnext.css("top", "auto").css("left", "auto");
	                    }
	                });
	                return false;
	            }
	            function edit_{{pagepartref.id}}(){
	                document.getElementById('{{pagepartref.id}}_view').style.display = 'none';
	                document.getElementById('{{pagepartref.id}}_edit').style.display = '';
                    window.activeEdit = '{{pagepartref.id}}';
	                return false;
	            }
	        </script>
	        <input type="hidden" id="{{pagepartref.id}}_deleted" name="{{pagepartref.id}}_deleted" value="" />
	        <input type="hidden" id="{{pagepartref.context}}_{{pagepartref.pageid}}_{{pagepartref.pageentityname}}_sequence" name="{{pagepartref.context}}_{{pagepartref.pageid}}_{{pagepartref.pageentityname}}_sequence[]" value="{{pagepartref.id}}" />
        	
        	<div class="pagepart">
            	<a name="pagepart{{ loop.index }}" ></a>	
            	<div class="prop_bar {% if not form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id].count %}noedit{% endif %}">
            		<h6>{{pagepartadmin.getType(pagepart)}}</h6>
            		{#
            		  <a class="btn small" href="#" onclick="return moveUp_{{pagepartref.id}}()">Up</a>
                      <a class="btn small" href="#" onclick="return moveDown_{{pagepartref.id}}()">Down</a>
            		#}
					<a class="del red" data-controls-modal="delete-pagepart" data-backdrop="true" data-keyboard="true" onclick="return delete_{{pagepartref.id}}()"><span>Del</span></a>
                    {% if form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id].count %}
                        <a href="#" class="bleu" onclick="return edit_{{pagepartref.id}}()">Edit</a>
                    {% endif %}
            	</div>
                {% if form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id].count %}
                    <div class="block" id="{{pagepartref.id}}_view" {% if editpagepart is defined and editpagepart == loop.index %}style="display:none"{% endif %}>
                        {% include pagepart.defaultview with {'resource': pagepart, 'pagepartadmin': pagepartadmin, 'pageparts': pagepartadmin.pagepartrefs} %}
                    </div>
                    <div class="block" id="{{pagepartref.id}}_edit" {% if editpagepart is not defined or editpagepart != loop.index %}style="display:none"{% endif %}>
                        {% set pagepartid %}pagepart{{pagepartref.id}}{%endset%}
                        {{ form_widget(form['pagepartadmin_'~pagepartref.context~'_'~pagepartref.id]) }}
                    </div>
                {% endif %}
            </div>
            <div class="new_pagepart">
              <select onchange="return doAddpagepart_{{pagepartadmin.context}}(this, '{{ loop.index-1 }}')">
	            <option value="">Add a pagepart</option>
	            {% for pagePartType in pagepartadmin.possiblePagePartTypes %}
	              <option value="{{pagePartType.class}}">{{pagePartType.name}}</option>
	            {% endfor %}
              </select>
            </div>
        </section>
    {% else %}
    	<section class="draggable pagepartcontainer">
            <div class="new_pagepart">
              <select onchange="return doAddpagepart_{{pagepartadmin.context}}(this, '{{ loop.index-1 }}')">
	            <option value="">Add a pagepart</option>
	            {% for pagePartType in pagepartadmin.possiblePagePartTypes %}
	              <option value="{{pagePartType.class}}">{{pagePartType.name}}</option>
	            {% endfor %}
              </select>
            </div>
        </section>
    {% endfor %}
</div>
<input type="hidden" id="{{pagepartadmin.context}}_addposition" name="{{pagepartadmin.context}}_addposition" value="" />
<div class="clearfix">
    <script type="text/javascript">
        function doAddpagepart_{{pagepartadmin.context}}(select, id){
            var position = jQuery('#parts_{{pagepartadmin.context}} section.draggable').index(jQuery(select).parents("section.draggable"))+1;
            if(position<0){
				position = 0;
            }
            jQuery('#{{pagepartadmin.context}}_addposition').val(position);
            jQuery(select).attr('name', 'addpagepart_{{pagepartadmin.context}}');
            jQuery('form')[0].action="?edit="+id+"#pagepart"+id;
            jQuery('form')[0].submit();
            return false;
        }
    </script>
</div>
<div id="pagepartsdeletedcontainer">

</div>
<script type="text/javascript">
	$(document).ready(function () {
		$('#parts_{{pagepartadmin.context}}').sortable({  
		    handle: '.prop_bar',  
		    cursor: 'move',  
		    placeholder: 'placeholder',  
		    forcePlaceholderSize: true, 
			revert: 100,
		    //opacity: 0.4
		    opacity: 1,
			start: function(e, ui) {
				$('.draggable').css('opacity', ".4");
				$('.ui-sortable-helper .new_pagepart').slideUp("fast");
			},
			stop: function(e, ui) {
				$('.draggable').css('opacity', "1");
			}
		    //containment: 'document'
		})  
		.disableSelection();
	});
</script>
{'fraction_non_alphanumeric': 0.1699627400401261, 'fraction_numerical': 0.004012611063341932, 'mean_word_length': 2.125167935512763, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 0, '>': 119, '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': '2502053', 'n_tokens_mistral': 4180, 'n_tokens_neox': 3733, 'n_words': 584}