Elastic: Use Bootstrap's custom file input

... with localization and some js logic to display selected file(s) in the input.
pull/6643/head
Aleksander Machniak 6 years ago
parent ede90c1f8c
commit cc20de329d

@ -2127,8 +2127,7 @@ class rcmail extends rcube
$content = $attrib['prefix'] . $input->show();
if ($attrib['mode'] != 'smart') {
$content = html::div(null, $content);
$content .= $hint;
$content = html::div(null, $content . $hint);
}
if (rcube_utils::get_boolean($attrib['buttons'])) {

@ -445,6 +445,9 @@ $labels['rename'] = 'Rename';
$labels['addphoto'] = 'Add';
$labels['replacephoto'] = 'Replace';
$labels['uploadphoto'] = 'Upload photo';
$labels['choosefile'] = 'Choose file...';
$labels['choosefiles'] = 'Choose files...';
$labels['browse'] = 'Browse';
$labels['newcontact'] = 'Create new contact';
$labels['deletecontact'] = 'Delete selected contacts';
@ -747,5 +750,3 @@ $labels['helplistkeyboardnavmessages'] = "Arrows right/left: expand/collapse mes
Enter: Open the selected/focused message.
Delete: Move selected messages to Trash.";
$labels['helplistkeyboardnavcontacts'] = "Enter: Open the selected/focused contact.";
?>

@ -1199,7 +1199,7 @@ html.ms .propform {
}
/*** Bootstrap style overrides ***/
/*** Bootstrap style overrides and improvements ***/
.form-control {
color: @color-font;
@ -1329,3 +1329,23 @@ html.ms .propform {
}
}
}
.custom-file {
display: block;
.custom-file-label {
white-space: nowrap;
.overflow-ellipsis;
padding-right: 100px;
line-height: 1.5 !important;
}
& + .hint {
margin-top: .25rem;
}
}
.custom-file-input:focus ~ .custom-file-label {
border-color: @color-input-border-focus;
box-shadow: 0 0 0 .2rem @color-input-border-focus-shadow;
}

@ -7,6 +7,9 @@
<roundcube:add_label name="next" />
<roundcube:add_label name="select" />
<roundcube:add_label name="close" />
<roundcube:add_label name="browse" />
<roundcube:add_label name="choosefile" />
<roundcube:add_label name="choosefiles" />
<roundcube:object name="doctype" value="html5" />
<roundcube:if condition="!env:framed || env:extwin" />
<html>

@ -796,7 +796,7 @@ function rcube_elastic_ui()
}
// Forms
var supported_controls = 'input:not(.button,.no-bs,[type=button],[type=file],[type=radio],[type=checkbox]),textarea';
var supported_controls = 'input:not(.button,.no-bs,[type=button],[type=radio],[type=checkbox]),textarea';
$(supported_controls, $('.propform', context)).addClass('form-control');
$('[type=checkbox]', $('.propform', context)).addClass('form-check-input');
@ -956,6 +956,27 @@ function rcube_elastic_ui()
$('a.nav-link:first', nav).click();
});
$('input[type=file]:not(.custom-file-input)', context).each(function() {
var label_text = rcmail.gettext('choosefile' + (this.multiple ? 's' : '')),
label = $('<label>').attr({'class': 'custom-file-label',
'data-browse': rcmail.gettext('browse')}).text(label_text);
$(this).addClass('custom-file-input').wrap('<div class="custom-file">');
$(this).on('change', function() {
var text = label_text;
if (this.files.length) {
text = this.files[0].name;
if (this.files.length > 1) {
text += ', ...';
}
}
// Note: We don't use label variable to allow cloning of the input
$(this).next().text(text);
})
.parent().append(label);
});
// Make tables pretier
$('table:not(.table,.propform,.listing,.ui-datepicker-calendar)', context)
.filter(function() {
@ -2612,7 +2633,7 @@ function rcube_elastic_ui()
}
var content = $('#uploadform'),
dialog = content.clone();
dialog = content.clone(true);
var save_func = function(e) {
return rcmail.command('import-messages', $(dialog.find('form')[0]));

Loading…
Cancel
Save