/** * 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 : '
' + '

' + opts.title + '

' + '

' + opts.message + '

' + '

' + '' + opts.noButton + '' + '' + '

' + '
', opts : { animationDuration : 350, animationEffect : 'material', modal : true, baseTpl : '', 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 : '
' + '

' + opts.title + '

' + '

' + opts.message + '

' + '

' + '' + opts.noButton + '' + '' + '

' + '
', opts : { animationDuration : 350, animationEffect : 'material', modal : true, baseTpl : '', 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 : " 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('
'); }); $('.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 = ""; html += ""+mouvementDate.split('-').reverse().join('/')+""; html += ""+mouvementNbre+""; html += ""; $('.add-mouvement').before(html); }) $('.contactWidgets').on('click', '.copy-url', function(event){ var animElement = $(this).parent().parent().find('.link-copied'); var $tempElement = $(""); $("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(); } })