308 lines
8.7 KiB
JavaScript
Vendored
308 lines
8.7 KiB
JavaScript
Vendored
/**
|
|
* First we will load all of this project's JavaScript dependencies which
|
|
* includes Vue and other libraries. It is a great starting point when
|
|
* building robust, powerful web applications using Vue and Laravel.
|
|
*/
|
|
|
|
/*
|
|
require('./bootstrap');
|
|
|
|
window.Vue = require('vue');
|
|
|
|
/**
|
|
* Next, we will create a fresh Vue application instance and attach it to
|
|
* the page. Then, you may begin adding components to this application
|
|
* or customize the JavaScript scaffolding to fit your unique needs.
|
|
*/
|
|
|
|
/*
|
|
Vue.component('example-component', require('./components/ExampleComponent.vue'));
|
|
|
|
const app = new Vue({
|
|
el: '#app'
|
|
});
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
try {
|
|
window.$ = window.jQuery = require('jquery')
|
|
} catch (e) {}
|
|
|
|
const changeIcon = $('.marque')
|
|
const dropDownMarque = $('.marque-select')
|
|
|
|
// FancyBox Communes
|
|
// Confirmation
|
|
$.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>' +
|
|
'<p>' + opts.message + '</p>' +
|
|
'<p class="tright">' +
|
|
'<a data-value="0" data-fancybox-close>' + opts.noButton + '</a>' +
|
|
'<button data-value="1" data-fancybox-close class="btn">' + 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 );
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Informations
|
|
$.fancyInfo = 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 class="info">' + opts.title + '</h3>' +
|
|
'<p>' + opts.message + '</p>' +
|
|
'<p class="tright">' +
|
|
'<a data-value="0" data-fancybox-close>' + opts.noButton + '</a>' +
|
|
'<button data-value="1" data-fancybox-close class="btn">' + 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 );
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
changeIcon.on('click', () => {
|
|
if(dropDownMarque.css('display') == "none"){
|
|
dropDownMarque.slideDown('fast');
|
|
} else {
|
|
dropDownMarque.slideUp('fast');
|
|
}
|
|
});
|
|
|
|
const deleteIcons = document.querySelectorAll('.delete-icon')
|
|
|
|
let confirmDelete = (e) => {
|
|
e.preventDefault()
|
|
let url = e.target.parentElement.href
|
|
let form = document.querySelector('#delete-hidden')
|
|
|
|
$.fancyConfirm({
|
|
title : "<i class='fas fa-times-circle'></i> Suppression",
|
|
message : "Êtes-vous sûr de vouloir effacer cet élément ?",
|
|
okButton : 'Supprimer',
|
|
noButton : 'Annuler',
|
|
callback : function (value) {
|
|
if (value) {
|
|
form.action = url
|
|
form.submit()
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
deleteIcons.forEach((el) => {
|
|
el.addEventListener('click', confirmDelete)
|
|
})
|
|
|
|
|
|
$('.burger').on('click', function(e){
|
|
e.preventDefault();
|
|
$(this).parent('nav').css('left', '0');
|
|
$(this).css('display', 'none');
|
|
$('.close').css('display', 'block');
|
|
})
|
|
|
|
$('.close').on('click', function(e){
|
|
e.preventDefault();
|
|
$(this).parent('nav').css('left', '-75px');
|
|
$(this).css('display', 'none');
|
|
$('.burger').css('display', 'block');
|
|
})
|
|
|
|
$( window ).resize(function() {
|
|
if (window.matchMedia("(min-width: 768px)").matches) {
|
|
$('.burger').css('display', 'none');
|
|
$('.close').css('display', 'none');
|
|
$('nav').css('left', '0');
|
|
} else {
|
|
$('nav').css('left', '-75px');
|
|
$('.burger').css('display', 'block');
|
|
$('.close').css('display', 'none');
|
|
}
|
|
});
|
|
|
|
$('#camp_type').on('change', function(event){
|
|
if($(this).val() == 1 || $(this).val() == 3){
|
|
$('.limitPrinting').css('opacity', '1');
|
|
} else {
|
|
$('.limitPrinting').css('opacity', '0');
|
|
}
|
|
});
|
|
|
|
$('#coupon_enablelimitquantity').on('change', function(event){
|
|
if($(this).is(':checked')){
|
|
$('.enablelimitquantity').css('opacity', '1');
|
|
} else {
|
|
$('.enablelimitquantity').css('opacity', '0');
|
|
}
|
|
});
|
|
|
|
$('#coupon_enablelimitperiod').on('change', function(event){
|
|
if($(this).is(':checked')){
|
|
$('.enablelimitperiod').css('opacity', '1');
|
|
} else {
|
|
$('.enablelimitperiod').css('opacity', '0');
|
|
}
|
|
});
|
|
|
|
$('#coupon_norme').on('change', function(event){
|
|
if($(this).is(':checked')){
|
|
$('.gs1code').css('opacity', '1');
|
|
} else {
|
|
$('.gs1code').css('opacity', '0');
|
|
}
|
|
});
|
|
|
|
$(document).ready(function(){
|
|
if($('#camp_type').val() == 1 || $('#camp_type').val() == 3){
|
|
$('.limitPrinting').css('opacity', '1');
|
|
}
|
|
if($('#coupon_enablelimitquantity').is(':checked')){
|
|
$('.enablelimitquantity').css('opacity', '1');
|
|
}
|
|
if($('#coupon_enablelimitperiod').is(':checked')){
|
|
$('.enablelimitperiod').css('opacity', '1');
|
|
}
|
|
if($('#coupon_norme').is(':checked')){
|
|
$('.gs1code').css('opacity', '1');
|
|
}
|
|
})
|
|
|
|
$('.addcalendar').on('click', function(event){
|
|
event.preventDefault();
|
|
$('.calendar').append('<div class="form-field-calendar"><input type="date" name="startdate[]"><input type="date" name="enddate[]"><i class="fas fa-minus-square removecalendar"></i></div>');
|
|
});
|
|
|
|
$('.calendar').on('click', '.removecalendar', function(event){
|
|
$(this).parent('.form-field-calendar').remove();
|
|
})
|
|
|
|
$('.add-mouvement-btn').on('click', function(event){
|
|
event.preventDefault();
|
|
var element = $(this).parent().parent();
|
|
var mouvementDate = element.find('#add-mouvement-date').val();
|
|
var mouvementNbre = element.find('#add-mouvement-nbre').val();
|
|
var html = "<tr>";
|
|
html += "<th>"+mouvementDate.split('-').reverse().join('/')+"<input type='hidden' name='mouvementDate[]' value='"+mouvementDate+"'></th>";
|
|
html += "<th>"+mouvementNbre+"<input type='hidden' name='mouvementNbre[]' value='"+mouvementNbre+"'></th>";
|
|
html += "<th></th></tr>";
|
|
$('.add-mouvement').before(html);
|
|
})
|
|
|
|
|
|
$('.contactWidgets').on('click', '.copy-url', function(event){
|
|
var animElement = $(this).parent().parent().find('.link-copied');
|
|
var $tempElement = $("<input>");
|
|
$("body").append($tempElement);
|
|
$tempElement.val($(this).text()).select();
|
|
document.execCommand("Copy");
|
|
$tempElement.remove();
|
|
animElement.animate({opacity: 1}, 200, function(){
|
|
setTimeout(function(){
|
|
animElement.animate({opacity: 0}, 1000);
|
|
}, 500);
|
|
})
|
|
})
|
|
|
|
|
|
// ---- DASHBOARD BUTTONS
|
|
|
|
$('.campDetail .fa-angle-down').on('click', function(event){
|
|
var cpDiv = $(this).parent().parent().parent().find('.coupons');
|
|
if(cpDiv.css('display') == 'none'){
|
|
cpDiv.slideDown(500);
|
|
} else {
|
|
cpDiv.slideUp(500);
|
|
}
|
|
})
|
|
|
|
$('.open-all').on('click', function(event){
|
|
event.preventDefault();
|
|
$('.coupons').each(function(){
|
|
$(this).slideDown(500);
|
|
})
|
|
})
|
|
|
|
$('.close-all').on('click', function(event){
|
|
event.preventDefault();
|
|
$('.coupons').each(function(){
|
|
$(this).slideUp(500);
|
|
})
|
|
})
|
|
|
|
// ---- ALERTE sur Campagne
|
|
|
|
$('.couponDetail').each(function(){
|
|
if($(this).attr('data-printable') == 0){
|
|
console.log();
|
|
$(this).parent().parent().parent().parent().find('.fa-exclamation-triangle').show();
|
|
}
|
|
})
|
|
|
|
|
|
$('body').on('click', '.expand', function(event){
|
|
event.preventDefault();
|
|
var contentDiv = $(this).parent().parent().find('.content')
|
|
|
|
if(contentDiv.css('display') == 'none'){
|
|
contentDiv.slideDown();
|
|
} else {
|
|
contentDiv.slideUp();
|
|
}
|
|
})
|