gamutable/js/gamubox.js

40 lines
1.1 KiB
JavaScript

/*
* Pour parametrer la largeur :
* Indiquer le data-width sur le lien (exmeple data-width= "90")
* Imposer le style sur le premier bloc englobant dans la madiabox (style="width: [(#ENV{largeur})])
*/
jQuery(function () {
modalbox();
function modalbox() {
$('body').on('click', '.modalbox', function (e) {
e.stopPropagation();
e.preventDefault();
let ts = + new Date()
let url = $(this).attr('href');
url += '&var_zajax=content';
url += '&ts=' + ts;
let data = {};
let minHeight = $(this).data('minheight');
let minWidth = $(this).data('minwidth');
if (minHeight !== undefined) {
data.minHeight = minHeight;
}
if (minWidth !== undefined) {
data.minWidth = minWidth;
}
let width = $(this).data('width');
if (width !== undefined) {
data.width = width;
let valeur_reduite = ($(window).width() * width) / 100;
url += '&largeur=' + valeur_reduite + 'px';
}
data.onShow = () => {
if (typeof charger_require !== undefined) {
charger_require();
}
};
$.modalbox(url, data);
});
}
});