add code to use bootstrap's custom file input (currently not used)

This commit is contained in:
Uwe Steinmann 2021-05-28 12:23:04 +02:00
parent 16e4675d93
commit 07919b0810

View File

@ -1350,6 +1350,14 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
function printFileChooserJs() { /* {{{ */
?>
$(document).ready(function() {
/* do not use bootstrap4 custom form element because it is difficult to localize
$(document).on('change', '.custom-file-input',function(){
//get the file name
var fileName = $(this).val().replace(/\\/g, '/').replace(/.*\//, '');
//replace the "Choose a file" label
$(this).next('.custom-file-label').html(fileName);
})
*/
/* Triggered after the file has been selected */
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
@ -1374,6 +1382,15 @@ $(document).ready(function() {
function getFileChooserHtml($varname='userfile', $multiple=false, $accept='') { /* {{{ */
$id = preg_replace('/[^A-Za-z]/', '', $varname);
/* do not use bootstrap4 custom form element because it is difficult to localize
$html = '
<div class="custom-file">
<input type="file" class="custom-file-input" id="'.$id.'" name="'.$varname.'">
<label class="custom-file-label" for="'.$id.'">'.getMLText("browse").'&hellip;'.'</label>
</div>
';
return $html;
*/
$html = '
<div id="'.$id.'-upload-files">
<div id="'.$id.'-upload-file" class="upload-file">