{% if is_granted("ROLE_SUPER_ADMIN") %}
<script>
function displayEdit(state) {
$(".edit-spm").each(function(i) {
$(this).css('display',state)
});
$(".edit-spmd").each(function(i) {
$(this).css('display',state)
});
$(".edit-spmc").each(function(i) {
$(this).css('display',state)
});
$(".edit-spmh").each(function(i) {
$(this).css('display',state)
});
}
var isCtrl = false;$(document).keyup(function (e) {
if(e.which == 17) isCtrl=false;
}).keydown(function (e) {
if(e.which == 17) isCtrl=true;
if(e.which == 66 && isCtrl == true) {
var editDisplay = $("#spm").attr('editspm');
if(editDisplay == "1") {
displayEdit("none");
$("#spm").attr('editspm','0');
} else {
displayEdit("block");
$("#spm").attr('editspm','1');
}
return false;
}
});
$('.edit-spm').click(function (data) {
$.get(Routing.generate('bo_pageshasblocks_components_edit_cover',{'page':$(this).attr('page'),'id':$(this).attr('item')})).done(function(data2) {
$("#show_modal").html(data2);
$("#modaldisplay").modal('show');
});
});
$('.edit-spmd').click(function (data) {
$.get(Routing.generate('bo_pageshasblocks_components_edit_classic',{'page':$(this).attr('page'),'id':$(this).attr('item')})).done(function(data2) {
$("#show_modal").html(data2);
$("#modaldisplay").modal('show');
});
});
$('.edit-spmh').click(function (data) {
$.get(Routing.generate('bo_pageshasblocks_components_edit_html',{'page':$(this).attr('page'),'id':$(this).attr('item')})).done(function(data2) {
$("#show_modal").html(data2);
$("#modaldisplay").modal('show');
});
});
document.getElementByClass('edit-spmh').addEventListener('click', function () {
// Display the modal
var modal = document.getElementById('myModal');
modal.style.display = 'block';
// Initialize CodeMirror
setTimeout(function() {
var codeArea = document.getElementById('codeArea');
CodeMirror.fromTextArea(codeArea, {
lineNumbers: true,
mode: "javascript"
});
}, 100);
});
$('.edit-spmc').click(function (data) {
$.get(Routing.generate('bo_pageshasblocks_components_edit_custom',{'page':$(this).attr('page'),'id':$(this).attr('item')})).done(function(data2) {
$("#show_modal").html(data2);
$("#modaldisplay").modal('show');
});
});
</script>
{% endif %}
{{ page.javascript|raw }}