Browse Source

ajoute la gestion du presse papier

master
vince vince 3 years ago
parent
commit
6d13bc970b
1 changed files with 55 additions and 39 deletions
  1. +55
    -39
      index.php

+ 55
- 39
index.php View File

@ -18,7 +18,10 @@ if (preg_match(REQUEST_REGEX, $requestUrl, $match)) {
$requestUrl = rtrim(str_replace($requestEvent, '', $requestUrl), '/');
if (!is_null($requestSupplier))
$requestUrl = rtrim(str_replace($requestSupplier, '', $requestUrl), '/');
}
} else {
$requestSupplier = null;
$requestEvent = null;
}
function generateUrl($supplier = null, $event = null) {
global $requestUrl;
@ -81,13 +84,12 @@ $hasSupplier = is_string($supplier) and preg_match('/^' . SUPPLIER_REGEX . '$/',
$excludesFormatter = new \IntlDateFormatter('fr_FR.UTF8', \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, 'Europe/Paris');
$supplierIsNew = false;
if ($hasSupplier) {
if (!isset($config[$supplier])) {
$config[$supplier] = [];
$supplierIsNew = true;
} else {
$supplierIsNew = false;
}
$config[$supplier] = array_merge(
@ -653,50 +655,57 @@ if ($supplierIsNew and !empty($suppliers)) {
<?php endif; ?>
</main>
<div class="modal fade" id="linkModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Lien</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row g-3">
<div class="col-12">
Adresse web
</div>
<div class="col-12">
<tt id="linkURL">
<?php if (!$hasSupplier) : ?>
<?php echo generateUrl(); ?>
<?php else : ?>
<?php if (!$hasEvent) : ?>
<?php echo generateUrl($supplier); ?>
<?php else : ?>
<?php echo generateUrl($supplier, $event); ?>
<?php endif; ?>
<?php endif; ?>
</tt>
</div>
<div class="col-12">
QR Code
</div>
<div class="col-12">
<div id="linkQRCode"></div>
<div class="modal fade" id="linkModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Lien</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row g-3">
<div class="col-12">
Adresse web
</div>
<div class="col-12 text-center">
<tt id="linkURL">
<?php if (!$hasSupplier) : ?>
<?php echo generateUrl(); ?>
<?php else : ?>
<?php if (!$hasEvent) : ?>
<?php echo generateUrl($supplier); ?>
<?php else : ?>
<?php echo generateUrl($supplier, $event); ?>
<?php endif; ?>
<?php endif; ?>
</tt>
<button class="btn btn-outline-dark js-clipboard" type="button" role="button" data-clipboard-target="#linkURL" data-bs-toggle="tooltip" data-bs-trigger="manual">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16">
<path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
<path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>
</svg>
</button>
</div>
<div class="col-12">
QR Code
</div>
<div class="col-12">
<div id="linkQRCode"></div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"></script>
<?php if ($isConfig) : ?>
<script src="https://cdn.ckeditor.com/ckeditor5/31.0.0/classic/ckeditor.js"></script>
<script>
@ -744,6 +753,13 @@ if ($supplierIsNew and !empty($suppliers)) {
correctLevel : QRCode.CorrectLevel.H,
});
document.querySelector('#linkQRCode img').classList.add('img-fluid', 'mx-auto', 'd-block');
var clipboard = new ClipboardJS('.js-clipboard');
clipboard.on('success', function (event) {
var tooltip = new bootstrap.Tooltip(event.trigger, {
title: 'Copié dans le presse-papier'
});
tooltip.show();
});
}, false);
</script>
</body>


Loading…
Cancel
Save