164 lines
4.4 KiB
JavaScript
Vendored
164 lines
4.4 KiB
JavaScript
Vendored
|
|
'use strict';
|
|
|
|
try {
|
|
window.$ = window.jQuery = require('jquery')
|
|
} catch (e) {}
|
|
|
|
//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) {
|
|
var container = $(".userbar");
|
|
if (!container.is(e.target) && container.has(e.target).length === 0) {
|
|
$(".submenu").hide();
|
|
}
|
|
});
|
|
|
|
// ---- 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 formulaire de contact
|
|
$(".form_contact_close").on('click',function(event) {
|
|
event.preventDefault();
|
|
$.fancybox.getInstance().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();
|
|
}
|
|
});
|
|
});
|