Dodan gumb "odstrani datoteko" pri uploadu

This commit is contained in:
pero1203 2020-09-18 12:12:21 +02:00
parent e95b1c6b35
commit 65c97fa7af
6 changed files with 54 additions and 26 deletions

View File

@ -2026,6 +2026,7 @@ $lang = array (
"srv_alert_show_missing_97" => "Prikaži opcijo \"Neustrezno\" ob opozorilu",
"srv_alert_upload_size" => "Naložena datoteka je prevelika! Največja dovoljena velikost je 16 MB.",
"srv_alert_upload_ext" => "Naložen tip datoteke ni dovoljen!",
"srv_alert_upload_remove" => "Odstrani datoteko",
"srv_dostop" => "Anketo lahko ureja avtor in vsi",
"srv_izpolnjujejo" => "Anketo lahko izpolnjujejo",
"srv_dostop_users" => "Uporabniki, ki lahko urejajo anketo",

View File

@ -2013,6 +2013,7 @@ $lang = array (
"srv_alert_show_missing_97" => "Show option \"Invalid\" on alert",
"srv_alert_upload_size" => "Uploaded file is too large! Maximum file size is 16 MB.",
"srv_alert_upload_ext" => "Uploaded file type is not allowed!",
"srv_alert_upload_remove" => "Remove file",
"srv_dostop" => "Survey can be edited by",
"srv_izpolnjujejo" => "Survey can be answered by",
"srv_dostop_users" => "Users who can edit survey",

View File

@ -780,13 +780,22 @@ class TextController extends Controller
type="file"
id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"
' . (!$missing ? '' : ' disabled') . '
onChange="checkUpload(this);"
class="pointer"
onChange="checkUpload(this, \''.$spremenljivka.'_vrednost_'.$i.'\');"
>';
// Remove file button
echo '<div class="remove_file pointer"
id="remove_file_'.$spremenljivka.'_vrednost_'.$i.'"
style="display:none;"
onClick="removeUpload(\'spremenljivka_'.$spremenljivka.'_vrednost_'.$i.'\')"
>';
echo self::$lang['srv_alert_upload_remove'];
echo '</div>';
}
//Fotografiranje
elseif ($row['upload'] == 2) {
//$imginput = ' <input name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" type="file" accept="image/*" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"> ';
$inpname = 'vrednost_' . $spremenljivka . '_kos_' . $row1['id'];
$inpid = 'spremenljivka_' . $spremenljivka . '_vrednost_' . $i;

View File

@ -1896,7 +1896,7 @@ function gridRepeatHeader(repeat_every, spr_id){
// Preverimo upload file omejitve
function checkUpload(upload){
function checkUpload(upload, id){
// Max file size (mb)
let maxSize = 16;
@ -1908,6 +1908,8 @@ function checkUpload(upload){
if(fileSize > maxSize){
$(upload).val(null);
alert(lang["srv_alert_upload_size"]);
return;
}
@ -1925,5 +1927,15 @@ function checkUpload(upload){
if(!extAllowed.includes(fileExt)){
$(upload).val(null);
alert(lang["srv_alert_upload_ext"]);
return;
}
// Add/remove "remove file" button
$('#remove_file_' + id).show();
}
function removeUpload(id){
$('#' + id).val(null);
}

View File

@ -5257,6 +5257,19 @@ input[type=radio]:checked + span.enka-checkbox-radio:before {
content: "";
}
/* File upload */
.remove_file {
margin: 10px 0 0 0;
width: 150px;
color: #1e88e5;
text-decoration: none;
cursor: pointer;
}
.remove_file:hover {
color: #ffa608;
text-decoration: none;
}
/******* CUSTOM IKONE ZA SLIKOVNI TIP **********/
input[type=radio] + span.enka-custom-radio {
font-size: 20px;
@ -5483,29 +5496,6 @@ span.enka-custom-radio:before,
color: #ffa608;
}
div.qtip-content {
font-size: 9px;
}
.qtip-wrapper, .qtip-contentWrapper {
border: 0 !important;
}
.qtip-borderTop, .qtip-borderBottom {
display: none !important;
}
.qtip-title {
color: #0C377A !important;
background-color: #D8DFEA !important;
}
.qtip-content {
padding: 12px 9px !important;
background-color: #EFF2F7 !important;
border: 1px #D8DFEA solid;
}
#cookie_alert, #test_alert {
display: none;
position: fixed;

View File

@ -95,6 +95,21 @@ input[type="radio"]:checked + span.enka-checkbox-radio:before {
}
/* File upload */
.remove_file{
margin: 10px 0 0 0;
width: 150px;
color: #1e88e5;
text-decoration: none;
cursor: pointer;
&:hover {
color: #ffa608;
text-decoration: none;
}
}
/******* CUSTOM IKONE ZA SLIKOVNI TIP **********/
input[type="radio"] + span.enka-custom-radio{