216 lines
6.3 KiB
JavaScript
Vendored
216 lines
6.3 KiB
JavaScript
Vendored
|
|
'use strict';
|
|
|
|
try {
|
|
window.$ = window.jQuery = require('jquery')
|
|
} catch (e) {}
|
|
|
|
jQuery.fn.scrollParent = function() {
|
|
var overflowRegex = /(auto|scroll)/,
|
|
position = this.css( "position" ),
|
|
excludeStaticParent = position === "absolute",
|
|
scrollParent = this.parents().filter( function() {
|
|
var parent = $( this );
|
|
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
|
|
return false;
|
|
}
|
|
var overflowState = parent.css(["overflow", "overflowX", "overflowY"]);
|
|
return (overflowRegex).test( overflowState.overflow + overflowState.overflowX + overflowState.overflowY );
|
|
}).eq( 0 );
|
|
|
|
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
|
|
};
|
|
|
|
// ---- Configuration de base des filtres médias
|
|
$(window).data('offset', 0);
|
|
$(window).data('limit', 50);
|
|
$(window).data('currentFolder', 0);
|
|
$(window).data('currentBasket', null);
|
|
$(window).data('filter', {});
|
|
|
|
//confirm popup
|
|
$.fancyConfirm = function( opts ) {
|
|
opts = $.extend( true, {
|
|
title : 'Are you sure?',
|
|
message : '',
|
|
okButton : 'OK',
|
|
noButton : 'Cancel',
|
|
callback : $.noop
|
|
}, opts || {} );
|
|
|
|
$.fancybox.open({
|
|
type : 'html',
|
|
src :
|
|
'<div class="fc-content">' +
|
|
'<h3>' + opts.title + '</h3><hr/>' +
|
|
'<p class="tcenter"><i class="fal fa-question-circle"></i>' +
|
|
opts.message + '</p>' +
|
|
'<hr/><p class="button_bar">' +
|
|
'<a data-value="0" data-fancybox-close class="btn btn-black mr-10 btn-square" >' + opts.noButton + '</a>' +
|
|
'<button data-value="1" data-fancybox-close class="btn btn-square">' + opts.okButton + '</button>' +
|
|
'</p>' +
|
|
'</div>',
|
|
opts : {
|
|
animationDuration : 350,
|
|
animationEffect : 'material',
|
|
modal : true,
|
|
baseTpl :
|
|
'<div class="fancybox-container fc-container" role="dialog" tabindex="-1">' +
|
|
'<div class="fancybox-bg"></div>' +
|
|
'<div class="fancybox-inner">' +
|
|
'<div class="fancybox-stage"></div>' +
|
|
'</div>' +
|
|
'</div>',
|
|
afterClose : function( instance, current, e ) {
|
|
var button = e ? e.target || e.currentTarget : null;
|
|
var value = button ? $(button).data('value') : 0;
|
|
|
|
opts.callback( value );
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
// Message
|
|
$.fancyMessage = function( opts ) {
|
|
opts = $.extend( true, {
|
|
title : 'Are you sure?',
|
|
message : '',
|
|
type : '',
|
|
}, opts || {} );
|
|
|
|
$.fancybox.open({
|
|
type : 'html',
|
|
src :
|
|
'<div class="fc-content '+opts.type+'">' +
|
|
'<h3>' + opts.title + '</h3><hr/>' +
|
|
'<p class="tcenter"><i class="fal fa-info-circle"></i></i><i class="fal fa-exclamation-triangle"></i>' +
|
|
opts.message + '</p>' +
|
|
'<hr/><p class="button_bar">' +
|
|
'<a data-value="0" data-fancybox-close class="btn btn-square '+
|
|
(opts.type == "error" ? 'btn-red':'')+' " >Ok</a>' +
|
|
'</p>' +
|
|
'</div>',
|
|
opts : {
|
|
animationDuration : 350,
|
|
animationEffect : 'material',
|
|
modal : false,
|
|
baseTpl :
|
|
'<div class="fancybox-container fc-container" role="dialog" tabindex="-1">' +
|
|
'<div class="fancybox-bg"></div>' +
|
|
'<div class="fancybox-inner">' +
|
|
'<div class="fancybox-stage"></div>' +
|
|
'</div>' +
|
|
'</div>'
|
|
}
|
|
});
|
|
}
|
|
|
|
// ---- Header : Menu utilisateur
|
|
$(".userbar").on('click',function(event) {
|
|
$(".submenu").toggle();
|
|
});
|
|
|
|
$(document).mouseup(function(e) {
|
|
|
|
// ---- Masque le menu utilisateur
|
|
var container = $(".userbar");
|
|
if (!container.is(e.target) && container.has(e.target).length === 0) {
|
|
$(".submenu").hide();
|
|
}
|
|
|
|
// ---- Masque le menu contextuel des dossiers
|
|
var menuContextuel = $(".folder_container .folder_menu");
|
|
if (!menuContextuel.is(e.target) && menuContextuel.has(e.target).length === 0) {
|
|
menuContextuel.hide();
|
|
}
|
|
|
|
// ---- Masque le menu des paniers
|
|
var cartMenu = $(".panier_side_menu .panier_menu");
|
|
if (!cartMenu.is(e.target) && cartMenu.has(e.target).length === 0 && $("#menu_panier").has(e.target).length === 0) {
|
|
cartMenu.hide();
|
|
}
|
|
|
|
// ---- Masque les filtres de la bar de recherche
|
|
var filter_list = $(".filter_selector");
|
|
if (!filter_list.is(e.target) && filter_list.has(e.target).length === 0) {
|
|
$(".filter_selector .list").hide();
|
|
}
|
|
|
|
|
|
// ---- déselectionne les éléments si on clique en dehors
|
|
var parentOffset = $('.media_container').parent().offset();
|
|
if ( ($(e.target).hasClass('media_container') && event.pageX- parentOffset.left < $('.media_container')[0]['clientWidth'] ) || $(e.target).hasClass('wrapper')) {
|
|
$(".imageItem").attr("aria-grabbed", "false");
|
|
$(".imageItem").removeClass('flip');
|
|
}
|
|
|
|
});
|
|
|
|
// ---- Header : Ouverture formulaire de contact
|
|
$(".contact_btn").on('click',function(event) {
|
|
event.preventDefault();
|
|
var subjectId = 1;
|
|
subjectId = $(this).attr("data-subjectId");
|
|
|
|
$.fancybox.open({
|
|
src : '#form_contact',
|
|
type : 'inline',
|
|
opts : {
|
|
animationDuration : 350,
|
|
animationEffect : 'material',
|
|
beforeShow : function( instance, current ) {
|
|
$(".form_contact_type").val(subjectId);
|
|
$(".form_contact_check_ko").hide();
|
|
$(".form_contact_ok").hide();
|
|
$(".form_contact_ko").hide();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// ---- Header : fermeture de la popup
|
|
$(".close_popup").on('click',function(event) {
|
|
event.preventDefault();
|
|
$.fancybox.close();
|
|
});
|
|
|
|
// ---- Header : envoi formulaire de contact
|
|
$(".form_contact_send").on('click',function(event) {
|
|
event.preventDefault();
|
|
var btn = $(this);
|
|
if($('.form_contact_message').val() == ""){
|
|
$(".form_contact_check_ko").show();
|
|
return false;
|
|
}else{
|
|
$(".form_contact_check_ko").hide();
|
|
}
|
|
btn.addClass('loading');
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
|
|
$.ajax({
|
|
url: '/send-message',
|
|
method: 'POST',
|
|
dataType : 'json',
|
|
data: {
|
|
type: $('.form_contact_type option:selected').text(),
|
|
url: $('.form_contact_url').val(),
|
|
message: $('.form_contact_message').val()
|
|
},
|
|
success: function(result){
|
|
btn.removeClass('loading');
|
|
$(".form_contact_ok").show();
|
|
$('.form_contact_url').val('');
|
|
$('.form_contact_message').val('');
|
|
},
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
btn.removeClass('loading');
|
|
$(".form_contact_ko").show();
|
|
}
|
|
});
|
|
});
|