templates/home/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block css %}
  3.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha512-mSYUmp1HYZDFaVKK//63EcZq4iFWFjxSL+Z3T/aCt4IO9Cejm03q3NKKYN6pFQzY0SBOr8h+eCIAZHPXcpZaNw==" crossorigin="anonymous" />
  4.     <style type="text/css">
  5.         .total-bl{
  6.             color: #000;
  7.             font-weight: 600;
  8.             text-align: center;
  9.         }
  10.         .pswp__caption__center {text-align: center;}
  11.         .pswp{
  12.             z-index: 9999;
  13.         }
  14.         .galerie-item{
  15.             display: flex;
  16.             align-items: flex-start;
  17.             flex-wrap: wrap;
  18.         }
  19.         .galerie-item >*{
  20.             width: 116px;
  21.             margin-right: 8px;
  22.         }
  23.         .thumbnail-galerie i {
  24.             position: absolute;
  25.             right: 7px;
  26.             top: 11px;
  27.             font-size: 15px;
  28.             color: #1ab394;
  29.         }
  30.         .rounded-galerie {
  31.             position: absolute;
  32.             margin-top: -25px;
  33.             margin-left: auto;
  34.             border: 4px solid white;
  35.             height: 46px;
  36.             width: 46px;
  37.             margin-right: auto;
  38.             left: 0;
  39.             right: 0;
  40.             z-index: 1;
  41.         }
  42.         .heure-galerie{
  43.             text-align: center;
  44.             margin-top: 14px;
  45.             font-size: 11px;
  46.         }
  47.         .thumbnail-galerie{
  48.             height: 110px;
  49.         }
  50.         .thumbnail-detail{padding: 12px 20px}
  51.       
  52.           .progress-bar{
  53.               width: 789.01px;
  54.             position: relative;
  55.             height: 21px;
  56.               background: #1ab394;
  57.           }
  58.           .progress-bar .progress-val {
  59.               position: absolute;
  60.             right: 9px;
  61.             font-size: 14px;
  62.             font-weight: bold;
  63.             color: #000;
  64.           }
  65.           .td-name{
  66.               display: block;
  67.             padding-left: 8px;
  68.             padding-right: 20px;
  69.             overflow: hidden;
  70.             text-overflow: ellipsis;
  71.             white-space: nowrap;
  72.           }
  73.           .btn-trash{
  74.               position: absolute;
  75.               display: none;
  76.               text-align: center;
  77.               bottom: -15px;
  78.               left: 0;
  79.               right: 0;
  80.               margin: auto;
  81.           }
  82.           .galerie-item .parent:hover .btn-trash{display: inline-block;}
  83.           .video-wrapper video{
  84.             max-width: 971px!important;
  85.             max-height: 600px!important;
  86.             display: block;
  87.             margin: auto;
  88.             margin-top: 25px;
  89.         }
  90.       
  91.         .row-sum-month {
  92.             display: flex;
  93.             align-items: center;
  94.             justify-content: space-between;
  95.         }
  96.        .row-sum-month > * {
  97.             flex: 1;
  98.             text-align: center;
  99.             font-weight: bold;
  100.             font-size: 15px;
  101.             margin-top: 2px;
  102.         }
  103.       
  104.         .btnShowMore{
  105.             cursor: pointer;
  106.             margin: auto;
  107.             max-width: 110px;
  108.         }
  109.         #section_more_galerie .icon-plus {
  110.           padding-top: 80px;
  111.           position: relative;
  112.           text-align: center;
  113.         }
  114.         #section_more_galerie .icon-plus span {
  115.           position: absolute;
  116.           top: 0;
  117.           left: 50%;
  118.           width: 24px;
  119.           height: 24px;
  120.           margin-left: -12px;
  121.           border-left: 1px solid #000;
  122.           border-bottom: 1px solid #000;
  123.           -webkit-transform: rotate(-45deg);
  124.           transform: rotate(-45deg);
  125.           -webkit-animation: sdb07 2s infinite;
  126.           animation: sdb07 2s infinite;
  127.           opacity: 0;
  128.           box-sizing: border-box;
  129.         }
  130.         #section_more_galerie .icon-plus span:nth-of-type(1) {
  131.           -webkit-animation-delay: 0s;
  132.           animation-delay: 0s;
  133.         }
  134.         #section_more_galerie .icon-plus span:nth-of-type(2) {
  135.           top: 16px;
  136.           -webkit-animation-delay: .15s;
  137.           animation-delay: .15s;
  138.         }
  139.         #section_more_galerie .icon-plus span:nth-of-type(3) {
  140.           top: 32px;
  141.           -webkit-animation-delay: .3s;
  142.           animation-delay: .3s;
  143.         }
  144.         @-webkit-keyframes sdb07 {
  145.           0% {
  146.             opacity: 0;
  147.           }
  148.           50% {
  149.             opacity: 1;
  150.           }
  151.           100% {
  152.             opacity: 0;
  153.           }
  154.         }
  155.         @keyframes sdb07 {
  156.           0% {
  157.             opacity: 0;
  158.           }
  159.           50% {
  160.             opacity: 1;
  161.           }
  162.           100% {
  163.             opacity: 0;
  164.           }
  165.         }
  166.         .caro-nav{
  167.             display: flex;
  168.             align-items: center;
  169.             justify-content: space-between;
  170.             position: absolute;
  171.             top: 45%;
  172.             left: 0;
  173.             right: 0;
  174.             transform: translateY(-50%);
  175.             z-index: 999;
  176.             font-size: 41px;
  177.             background: red;
  178.             height: 0;
  179.         }
  180.         .caro-nav > *{
  181.             color: #1ab394;
  182.             cursor: pointer;
  183.             width: 46px;
  184.             height: 46px;
  185.             display: inline-flex;
  186.             align-items: center;
  187.             justify-content: center;
  188.             border-radius: 50%;
  189.         }
  190.         .galerie-item.active{
  191.             display: flex;
  192.         }
  193.         .galerie-item{display: none;}
  194.         .item-dossier{
  195.             border: 1px solid;
  196.             border-radius: 10px;
  197.             margin-left: 7px;
  198.             padding: 6px 17px;
  199.             color: #676a6c;
  200.         }
  201.     </style>
  202. {% endblock %}
  203. {% block breadcrumb %}
  204.     <div class="row wrapper border-bottom white-bg page-heading">
  205.         <div class="col-lg-10">
  206.             <h1>Accueil</h1>
  207.         </div>
  208.     </div>
  209. {% endblock %}
  210. {% block content %}
  211.     <div class="row">
  212.         <div class="col-lg-12">
  213.             {% include 'flashes.html.twig' %}
  214.             <div class="ibox ">
  215.                 <div class="ibox-title">
  216.                     <h5>Dernières images {{ app.environment }}</h5> 
  217.                 </div>
  218.                 <div class="ibox-content">
  219.                     <div class="carousel-container" style="position: relative;">
  220.                         <div class="row galerie-container">
  221.                             
  222.                         </div>
  223.                         <div class="caro-nav">
  224.                             <span class="nav-left">
  225.                                 <i class="fas fa-chevron-left"></i>
  226.                             </span>
  227.                             <span class="nav-right">
  228.                                 <i class="fas fa-chevron-right"></i>
  229.                             </span>
  230.                         </div>
  231.                     </div>
  232.                     <div class="btnShowMore" style="display: none;">
  233.                         <div id="section_more_galerie" style="height: 51px;">
  234.                           <div class="icon-plus"><span></span><span></div>
  235.                         </div>
  236.                         <div class="text-center" style="font-size: 17px">Voir plus</div>
  237.                     </div>
  238.                 </div>
  239.             </div>
  240.             <div class="ibox">
  241.                 <div class="ibox-content">
  242.                     <h2 style="margin-bottom: 22px">Liste document en attente</h2>
  243.                     <div class="row">
  244.                         {% for item in countDocumentAttente %} 
  245.                             <a class="col-lg-3 item-dossier" href="{{ path('email_document_preview_list', {'dossier':item.entity.dossier}) }}">
  246.                                 <h3 style="text-transform:capitalize;">{{item.dossier}} : <span>{{item.entity.nb}}</span></h3>
  247.                             </a>
  248.                         {% endfor %}
  249.                     </div>
  250.                 </div>
  251.             </div>
  252.             <div class="ibox">
  253.                 <div class="ibox-content">
  254.                     {{ include('home/filter.html.twig') }}
  255.                 </div>
  256.             </div>
  257.             
  258.             <div class="ibox ">
  259.                 <div class="ibox-title">
  260.                     <h5>Achats-Ventes</h5> 
  261.                 </div>
  262.                 <div class="ibox-content">
  263.                     <h2 class="achat-vente-recap" style="font-size: 25px;font-weight: bold;margin-bottom: 17px;text-align: center;"></h2>
  264.                     <div>
  265.                         <canvas id="myChartAchat" height="350"></canvas>
  266.                     </div>
  267.                     <div class="row-sum-month">
  268.                         {% for i in tauxMargin %}
  269.                             <span class="month">{{i}}%</span>
  270.                         {% endfor %}
  271.                     </div>
  272.                 </div>
  273.             </div>
  274.             <div class="ibox ">
  275.                 <div class="ibox-title">
  276.                     <h5>Marge</h5> 
  277.                 </div>
  278.                 <div class="ibox-content">
  279.                     <h2 class="marge-year text-center" style="font-size: 25px;font-weight: bold;margin-bottom: 17px;"></h2>
  280.                     <h5 class="text-center marge-resultat" style="font-size: 17px"></h5>
  281.                     <div style="min-height: 1000px;">
  282.                         <canvas id="chartMarge" height="500"></canvas>
  283.                     </div>
  284.                 </div>
  285.             </div>
  286.             <div class="ibox ">
  287.                 <div class="ibox-title">
  288.                     <h5>Gallery {{currentMonth}}</h5> 
  289.                 </div>
  290.                 <div class="ibox-content">
  291.                     <div class="table-responsive">
  292.                     <table class="table">
  293.                         <thead>
  294.                             <tr>
  295.                                 <th width="175px"></th>
  296.                                 <th></th>
  297.                                 <th width="150px" style="text-align: right;">Photos</th>
  298.                                 <th width="150px" style="text-align: right;">Classement</th>
  299.                             </tr>
  300.                         </thead>
  301.                         <tbody>
  302.                             {% for gal in galleryUser %}
  303.                             <tr>
  304.                                 <td>
  305.                                     <div class="td-name">
  306.                                         <span>
  307.                                             {% if gal.uid in utilisateurs|keys and utilisateurs[gal.uid] %} 
  308.                                                 <img data-file="data:image/jpeg;base64,{{ utilisateurs[gal.uid]}}" src="data:image/jpeg;base64,{{ utilisateurs[gal.uid]}}" 
  309.                                                 class="entreprise-img rounded-img">
  310.                                             {% endif %}
  311.                                         </span>
  312.                                         <span>
  313.                                             {{gal.firstname}} {{gal.lastname}}
  314.                                         </span>
  315.                                     </div>
  316.                                 </td>
  317.                                 <td>
  318.                                     <div class="progress-container" data-nbr-photo="{{gal.nbr_gallery}}">
  319.                                         <div class="progress-bar">
  320.                                             <span class="progress-val">{{gal.nbr_gallery}}</span>
  321.                                         </div>
  322.                                     </div>
  323.                                 </td>
  324.                                 <td style="text-align: right;">{{gal.nbr_gallery}}</td>
  325.                                 <td style="text-align: right;">{{loop.index}}</td>
  326.                             </tr>
  327.                             {% endfor %}
  328.                         </tbody>
  329.                     </table>
  330.                     </div>
  331.                 </div>
  332.             </div>
  333.         </div>
  334.     </div>
  335.     
  336. {% endblock %}
  337. {% block javascript_script %}
  338.     <script type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
  339.     <script type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
  340.     <script type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
  341.     <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"></script>
  342.     <script src="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.3/photoswipe.min.js"></script>
  343.     <script src="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>
  344.     <script type="text/javascript">
  345.         $maxPhotoVal = {{ maxPhotoVal|json_encode()|raw }};
  346.         $('.progress-container').each(function( index ) {
  347.             $barWidth = parseFloat($(this).width()) ;
  348.             $nbrPhoto = parseFloat($(this).data('nbr-photo'));
  349.             $progress = $(this).find('.progress-bar');
  350.             if($maxPhotoVal > 0)
  351.                 $progressWidth = ($nbrPhoto*$barWidth)/$maxPhotoVal;
  352.             else
  353.                 $progressWidth = 0;
  354.             $(this).find('.progress-bar').css('width', $progressWidth);
  355.         })
  356.         var valChart = {{ valChart|json_encode()|raw }};
  357.         var valChartNonLie = {{ valChartNonLie|json_encode()|raw }};
  358.         var valChartFact = {{ valChartFact|json_encode()|raw }};
  359.         var valChartFactClient = {{ valChartFactClient|json_encode()|raw }};
  360.         var valChartAmortMensAssurance = {{ valChartAmortMensAssurance|json_encode()|raw }};
  361.         var valChartCoutGb = {{ valChartCoutGb|json_encode()|raw }};
  362.         var ctxA = document.getElementById('myChartAchat').getContext('2d');
  363.         let datasets = [
  364.                 {
  365.                     label: "BL HT: {{ montant['sum_ht'] ? montant['sum_ht']|number_format(2, ',', '') : "0" }}€",
  366.                     data: valChart,
  367.                     backgroundColor: 'rgb(50 163 243)',
  368.                     hoverBackgroundColor: 'rgb(50 163 243)',
  369.                     hoverBorderColor: 'rgb(50 163 243)',
  370.                     borderColor: 'rgb(50 163 243)',
  371.                     fontColor: "blue",
  372.                     borderWidth: 1
  373.                 },
  374.                 {
  375.                     label: "BL NON LIE: {{ montantBlNonRelie['sum_ht'] ? montantBlNonRelie['sum_ht']|number_format(2, ',', '') : "0" }}€",
  376.                     data: valChartNonLie,
  377.                     backgroundColor: 'rgb(173 255 47)',
  378.                     hoverBackgroundColor: 'rgb(173 255 47)',
  379.                     hoverBorderColor: 'rgb(173 255 47)',
  380.                     borderColor: 'rgb(173 255 47)',
  381.                     fontColor: "greenyellow",
  382.                     borderWidth: 1
  383.                 },
  384.                 {
  385.                     label: "Facturation HT: {{ montantFact['sum_ht'] ? montantFact['sum_ht']|number_format(2, ',', '') : "0" }}€",
  386.                     data: valChartFact,
  387.                     backgroundColor: 'rgb(24 166 137)',
  388.                     hoverBackgroundColor: 'rgb(24 166 137)',
  389.                     hoverBorderColor: 'rgb(24 166 137)',
  390.                     borderColor: 'rgb(24 166 137)',
  391.                     borderWidth: 1
  392.                 },
  393.                 {
  394.                     label: "Cout Global: {{ sumCoutGb ? sumCoutGb|number_format(2, ',', '') : "0" }}€",
  395.                     data: valChartCoutGb,
  396.                     backgroundColor: 'orange',
  397.                     borderColor: 'orange',
  398.                     borderWidth: 1
  399.                 },
  400.                 {
  401.                     label: "Facture client HT: {{ montantFactClient['sum_ht'] ? montantFactClient['sum_ht']|number_format(2, ',', '') : "0" }}€",
  402.                     data: valChartFactClient,
  403.                     backgroundColor: 'pink',
  404.                     borderColor: 'pink',
  405.                     borderWidth: 1
  406.                 }
  407.             ];
  408.         {% if isgestionFinancements == 1 %}
  409.             datasets.push({
  410.                     label: "Mensualité avec assurance: {{ sumMontantAmortMensAssurance['mensualite_avec_assurance'] ? sumMontantAmortMensAssurance['mensualite_avec_assurance']|number_format(2, ',', '') : "0" }}€",
  411.                     data: valChartAmortMensAssurance,
  412.                     backgroundColor: 'rgb(255, 90, 196)',
  413.                     hoverBackgroundColor: 'rgb(255, 90, 196)',
  414.                     hoverBorderColor: 'rgb(255, 90, 196)',
  415.                     borderColor: 'rgb(255, 90, 196)',
  416.                     borderWidth: 1
  417.                 });
  418.         {% endif %}
  419.         var data = {
  420.             labels:  ["jan", "Fév", 'Mars', 'Avr', 'Mais', 'Juin', 'Juil', 'Aout', 'sep', 'Oct', 'Nov', 'Déc'],
  421.             datasets: datasets
  422.         };
  423.         $('.achat-vente-recap').text("{{full_month|capitalize}} - Taux de Marge {{tauxMarginCumulle|number_format(2, ',', '')}}%");
  424.         var myChart = new Chart(ctxA, {
  425.             type: 'bar',
  426.             data: data,
  427.             options: {
  428.                 barValueSpacing: 40,
  429.                 responsive: true,
  430.                 maintainAspectRatio: false,
  431.                 "hover": {
  432.                   "animationDuration": 0
  433.                 },
  434.                 "animation": {
  435.                   "duration": 1,
  436.                   "onComplete": function() {
  437.                     var chartInstance = this.chart,
  438.                       ctx = chartInstance.ctx;
  439.                     ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
  440.                     ctx.textAlign = 'center';
  441.                     ctx.textBaseline = 'bottom';
  442.                     this.data.datasets.forEach(function(dataset, i) {
  443.                       var meta = chartInstance.controller.getDatasetMeta(i);
  444.                       meta.data.forEach(function(bar, index) {
  445.                         var data = dataset.data[index];
  446.                         ctx.fillText(data, bar._model.x, bar._model.y - 5);
  447.                       });
  448.                     });
  449.                   }
  450.                 },
  451.                 tooltips: {
  452.                     "enabled": true,
  453.                     callbacks: {
  454.                         label: function(tooltipItem, data) {
  455.                             var label = data.datasets[tooltipItem.datasetIndex].label || '';
  456.                             if (label) {
  457.                                 label += ': ';
  458.                             }
  459.                             label += Math.round(tooltipItem.yLabel * 100) / 100;
  460.                             return Math.round(tooltipItem.yLabel * 100) / 100;
  461.                         }
  462.                     }
  463.                 },
  464.                 scales: {
  465.                     y: {
  466.                         beginAtZero: true
  467.                     },
  468.                   yAxes: [{
  469.                     display: false,
  470.                     gridLines: {
  471.                       display: false
  472.                     },
  473.                     ticks: {
  474.                       display: false,
  475.                       beginAtZero: true,
  476.                       min:0
  477.                     }
  478.                   }],
  479.                   xAxes: [{
  480.                     gridLines: {
  481.                       display: false
  482.                     },
  483.                     ticks: {
  484.                       beginAtZero: true
  485.                     }
  486.                   }]
  487.                 },
  488.                 title: {
  489.                     display: false,
  490.                     fontSize: '25',
  491.                     text: '{{full_month|capitalize}}'
  492.                 }
  493.             }
  494.         });
  495.         /* CHART MARGE */
  496.         var chartMarge = {{ chartMarge|json_encode()|raw }};
  497.         var chartColor = {{ chartColor|json_encode()|raw }};
  498.         var ctxM = document.getElementById('chartMarge').getContext('2d');
  499.         $('.marge-resultat').text("Marge: {{ sumMarge ? sumMarge|number_format(2, ',', '') : "0" }}€  /  M-1: {{ sumMarge_1 ? sumMarge_1|number_format(2, ',', '') : "0" }}€");
  500.         $('.marge-year').text("{{full_month|capitalize}}");
  501.         var data2 = {
  502.                 labels:  ["jan", "Fév", 'Mars', 'Avr', 'Mais', 'Juin', 'Juil', 'Aout', 'sep', 'Oct', 'Nov', 'Déc'],
  503.                 datasets: [
  504.                     {
  505.                         label: "Marge: {{ sumMarge ? sumMarge|number_format(2, ',', '') : "0" }}€  /  M-1: {{ sumMarge_1 ? sumMarge_1|number_format(2, ',', '') : "0" }}€",
  506.                         data: chartMarge,
  507.                         backgroundColor: chartColor,
  508.                         borderColor: chartColor,
  509.                         borderWidth: 1
  510.                     }
  511.                 ]
  512.             };
  513.         var myChartMarge = new Chart(ctxM, {
  514.             type: 'bar',
  515.             data: data2,
  516.             options: {
  517.                 legend: {
  518.                     display: false,
  519.                     labels: {
  520.                         fontColor: 'rgb(255, 99, 132)'
  521.                     }
  522.                 },
  523.                 barValueSpacing: 40,
  524.                 responsive: true,
  525.                 maintainAspectRatio: false,
  526.                 "hover": {
  527.                   "animationDuration": 0
  528.                 },
  529.                 "animation": {
  530.                   "duration": 1,
  531.                   "onComplete": function() {
  532.                     var chartInstance = this.chart,
  533.                       ctx = chartInstance.ctx;
  534.                     ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
  535.                     ctx.textAlign = 'center';
  536.                     ctx.textBaseline = 'bottom';
  537.                     this.data.datasets.forEach(function(dataset, i) {
  538.                       var meta = chartInstance.controller.getDatasetMeta(i);
  539.                       meta.data.forEach(function(bar, index) {
  540.                         var data2 = dataset.data[index];
  541.                         ctx.fillText(data2, bar._model.x, bar._model.y - 5);
  542.                       });
  543.                     });
  544.                   }
  545.                 },
  546.                 tooltips: {
  547.                     "enabled": true,
  548.                     callbacks: {
  549.                         label: function(tooltipItem, data) {
  550.                             var label = data.datasets[tooltipItem.datasetIndex].label || '';
  551.                             if (label) {
  552.                                 label += ': ';
  553.                             }
  554.                             label += Math.round(tooltipItem.yLabel * 100) / 100;
  555.                             return "";
  556.                         }
  557.                     }
  558.                 },
  559.                 scales: {
  560.                     y: {
  561.                         beginAtZero: true
  562.                     },
  563.                   yAxes: [{
  564.                     display: false,
  565.                     gridLines: {
  566.                       display: false
  567.                     },
  568.                     ticks: {
  569.                       display: false,
  570.                       beginAtZero: true,
  571.                     }
  572.                   }],
  573.                   xAxes: [{
  574.                     gridLines: {
  575.                       display: false
  576.                     },
  577.                     ticks: {
  578.                       beginAtZero: true
  579.                     }
  580.                   }]
  581.                 },
  582.                 title: {
  583.                     display: false,
  584.                     fontSize: '25',
  585.                     text: '{{full_month|capitalize}}'
  586.                 }
  587.             }
  588.         });
  589.         function loadGalerie(page){
  590.             $.ajax({
  591.                 url: "{{path('load_galerie_xhr')}}",
  592.                 type: "GET",
  593.                 async: true,
  594.                 dataType: "json",
  595.                 data: {
  596.                     page:page
  597.                 },
  598.                 success: function(response, status) {
  599.                     if(response.status == 200){
  600.                         $('.galerie-item').removeClass('active');
  601.                         $('.galerie-container').append(response.preview);
  602.                     }
  603.                     else if(response.status == 500){
  604.                         toastr.error(response.message);
  605.                     }
  606.                     else if(response.status == 300){
  607.                         $('.caro-nav .nav-right').css('display', 'none');
  608.                     }
  609.                 },
  610.                 error: function(xhr, textStatus, errorThrown) {
  611.                     toastr.error("Ooops..., Quelque chose s'est mal passée");
  612.                 }
  613.             });
  614.         }
  615.         $page = 0;
  616.         loadGalerie($page);
  617.         $page++;
  618.         $('.caro-nav .nav-left').click(function(){
  619.             var listItem = $( ".galerie-item.active" );
  620.             var idx = $( ".galerie-item" ).index( listItem );
  621.             $prevElt = $('.galerie-item')[idx-1];
  622.             if($prevElt){
  623.                 $('.galerie-item').removeClass('active');
  624.                 $('.galerie-item').eq(idx-1).addClass('active');
  625.                 $stape = $('.galerie-item.active').attr('data-page');
  626.                 reloadInitGalerie($stape);
  627.             }
  628.         });
  629.         $('.caro-nav .nav-right').click(function(){
  630.             loadGalerie($page);
  631.             $page++;
  632.         });
  633.         function reloadInitGalerie(page){
  634.             var container = [];
  635.               // Loop over gallery items and push it to the array
  636.               $('.galerie-item-'+page).find('.parent').each(function() {
  637.                 var $link = $(this).find('.thumbnail-galerie');
  638.                 
  639.                 if ($link.data('type') == 'video') {
  640.                     var item = {
  641.                       html: $link.data('video')
  642.                     };
  643.                     console.log('enter');
  644.                 } else {
  645.                     let img = new Image();
  646.                     img.onload = function() {
  647.                     };
  648.                     img.src = $link.data('url');
  649.                     var item = {
  650.                         src: $link.data('url'),
  651.                         w: $link.data('width'),
  652.                         h: $link.data('height'),
  653.                         title: $link.data('caption')
  654.                     };
  655.                 }
  656.                 container.push(item);
  657.               });
  658.               // Define click event on gallery item
  659.               $('.thumbnail-galerie').click(function(event) {
  660.                 // Prevent location change
  661.                 event.preventDefault();
  662.                 {% verbatim %}
  663.                 // Define object and gallery options
  664.                 var $pswp = $('.pswp')[0],
  665.                   options = {
  666.                     index: $(this).parent('.parent').index(),
  667.                     bgOpacity: 0.85,
  668.                     showHideOpacity: true,
  669.                     shareButtons: [
  670.                         {id:'facebook', label:'Partager sur Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
  671.                         {id:'twitter', label:'Tweeter', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
  672.                         {id:'pinterest', label:'Epingler', url:'http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}'},
  673.                         {id:'download', label:'Télécharger l\'image', url:'{{raw_image_url}}', download:true}
  674.                     ]
  675.                   };
  676.                 {% endverbatim %}
  677.                 // Initialize PhotoSwipe
  678.                 var gallery = new PhotoSwipe($pswp, PhotoSwipeUI_Default, container, options);
  679.                 gallery.init();
  680.                 gallery.listen('beforeChange', function() {
  681.                       var currItem = $(gallery.currItem.container);
  682.                       $('.thumbnail-galerie').removeClass('active');
  683.                       var currItemIframe = currItem.find('.thumbnail-galerie').addClass('active');
  684.                       $('.thumbnail-galerie').each(function() {
  685.                         if (!$(this).hasClass('active')) {
  686.                           $(this).attr('data-url', $(this).attr('data-url'));
  687.                         }
  688.                       });
  689.                 });
  690.                 gallery.listen('close', function() {
  691.                   $('.thumbnail-galerie').each(function() {
  692.                     $(this).attr('data-url', $(this).attr('data-url'));
  693.                   });
  694.                 });
  695.               });
  696.         }
  697. chrome.tabs.onCreated.addListener(function (newTab) {
  698.     chrome.tabs.getAllInWindow(newTab.windowId, function(tabs) {
  699.         var duplicateTab = null;
  700.         tabs.forEach(function(otherTab) {
  701.             // Grab the domain from the otherTab
  702.             var otherDomain = otherTab.url.replace(/(?:(?:http)s?:\/\/)?(.*?\..{2,3}(\..{2})?)(?:.*)/i, '$1');
  703.             // Create a new RegEx pattern with it
  704.             otherDomain = new RegExp(otherDomain, 'i');
  705.             // Then test to see if it matches the newTab.url
  706.             if (otherTab.id !== newTab.id && otherDomain.test(newTab.url)) {
  707.                 duplicateTab = otherTab;
  708.             }
  709.         });
  710.         if (duplicateTab) {
  711.             chrome.tabs.update(duplicateTab.id, {"selected": true});
  712.             chrome.tabs.remove(newTab.id);
  713.         }
  714.     });
  715. });
  716.     </script>
  717. {% endblock %}