{% endif %}
{% set mycategs = [] %}
{% for itemcategory in itemcategorys %}
{% set haveitem=false %}
{% for item in items if item.itemcategory==itemcategory %}
{% if loop.index ==1 %}
{% set mycategs = mycategs|merge({ (loop.index) : itemcategory}) %}
{% endif %}
{% endfor %}
{% endfor %}
{% for itemcategory in mycategs %}
{% set haveitem=false %}
{% for item in items if item.itemcategory==itemcategory %}
{% if loop.index ==1 %}
{% set haveitem=true %}
{% if mycategs|length > 1 or bookmarks is not empty %}
{% endblock %}
{% block localjavascript %}
$('document').ready(function(){
// Ajustement des frames
$(window).resize(function() {
AjustFrame();
});
// Création des grilles d'items
var optiongrid={columnWidth: '.grid-sizer', itemSelector: '.grid-item', gutter: '.grid-gutter-sizer'};
$('body').imagesLoaded(function() {
var grid = $('.grid').masonry(optiongrid);
});
// Preview item de bureau
$( ".grid .item-preview" ).click(function() {
if($(this).parent().children(".grid-item-body").css('display') == 'none') {
$(this).html('');
heightbody=$(this).parent().children(".grid-item-body").height()+30;
heightitem=$(this).parent().parent().height();
$(this).parent().children(".grid-item-body").show();
$(this).parent().parent().css("width","100%");
$(this).parent().parent().css("height",heightitem+heightbody);
$(this).parent().children(".grid-item-content").css("height",heightitem+heightbody);
$(this).parent().children(".item-preview").css("height",heightitem+heightbody);
var grid = $('.grid').masonry(optiongrid);
}
else {
$(this).html('');
$(this).parent().children(".grid-item-body").hide();
$(this).parent().parent().css("width","");
$(this).parent().parent().css("height","");
$(this).parent().children(".grid-item-content").css("height","");
$(this).parent().children(".item-preview").css("height","");
var grid = $('.grid').masonry(optiongrid);
}
});
// Sur click item à sonder
{% if activate_widsonde %}
$( ".linktosonde" ).click(function() {
title=$(this).attr("data-sonde");
//$.getScript( "{{ widsonde_url }}?appli="+title );
});
{% endif %}
});
// Ajout d'un bookmark
function addBookmark(idwidget,touser) {
var url="{{ path('cadoles_portal_user_bookmark_submit',{idpage:0,idwidget:'xx',touser:'yy'})}}";
url=url.replace('xx',idwidget);
url=url.replace('yy',touser);
$(location).attr('href', url);
}
// Modifciation d'un bookmark
function modBookmark(idbookmark) {
var url="{{ path('cadoles_portal_user_bookmark_update',{idpage:0,id:'xx'})}}";
url=url.replace('xx',idbookmark);
$(location).attr('href', url);
}
// Ajouter un item aux bookmark
function heartBookmark(iditem) {
var idbookmark;
$.ajax({
method: "POST",
url: "{{ path('cadoles_portal_user_bookmark_heart') }}",
data: {
iditem:iditem
},
success: function(idbookmark) {
location.reload();
}
});
}
// Supprimer un fichier
function delFile(directory,filename) {
var r = confirm("Confirmez-vous la suppression de ce fichier ?");
if (r == true) {
$.ajax({
method: "POST",
url: "{{ path('cadoles_core_user_file_delete') }}",
data: {
directory:directory,
filename:filename
},
success: function() {
location.reload();
}
});
}
}
// Ajustement des frames
function AjustFrame() {
$('.frameajust').iframeAutoHeight({
minHeight: 500, // Sets the iframe height to this value if the calculated value is less
heightOffset: 0, // Optionally add some buffer to the bottom
callback: function(callbackObject) { $(this).parent().css("height",callbackObject.newFrameHeight) ;}
});
if($(".frameitem").length>0) {
var heightbody = $('html').height();
var heightheader = $('.header').height();
if($('.pagemenu').css("display")=="none")
var heightmenu = 0;
else
var heightmenu = $('.pagemenu').height();
var heightframe = heightbody-heightheader-heightmenu;
$(".frameitem").height(heightframe);
}
}
// Affichage d'un Flux
function showFlux(idwidget, id) {
if(id=="all")
$(".widget[data-id="+idwidget+"]").find(".feed").show();
else {
$(".widget[data-id="+idwidget+"]").find(".feed").hide();
$(".widget[data-id="+idwidget+"]").find(".flux-"+id).show();
}
var optiongrid={columnWidth: '.grid-sizer',itemSelector: '.grid-item'};
var grid = $('.grid').masonry(optiongrid);
}
// Affichage des frames associés aux items de bureau
function resizeFrame() {
var iFrame = document.getElementById('frameContent');
var heightbody = $('html').height();
var heightheader = $('.header').height();
if($('#appmenu').css("display")=="none")
var heightmenu = 0;
else
var heightmenu = $('#appmenu').height();
var heightframe = heightbody-heightheader-heightmenu;
$(".pageframe").each(function( index ) {
$(this).height(heightframe);
});
}
function showFrameitem(id,url,forcereload) {
$(".pageframe").hide();
// Si force le rechargement et frame existante on la détruit
if(forcereload&&$("#frameitem-"+id).length)
$("#frameitem-"+id).remove();
// Si la frame en cours existe déjà on l'affiche
if($("#frameitem-"+id).length)
$("#frameitem-"+id).show();
// Sinon on la génère
else
$("#pagecontainer").append("");
resizeFrame();
}
{% endblock %}