Support for variuos widgets used in managesieve plugin

pull/5742/merge
Aleksander Machniak 7 years ago
parent 1b08b9de4b
commit c33d458d2a

@ -59,6 +59,9 @@ button.btn {
&.delete:before {
content: @fa-var-trash-o;
}
&.next:before {
content: @fa-var-arrow-right;
}
&.restore:before {
content: @fa-var-undo;
}

@ -171,6 +171,33 @@
}
}
table.compact-table {
font-size: 90%;
margin: 0;
* {
font-size: inherit;
}
td {
padding: .25rem;
border: 0;
}
td:first-child {
padding-left: 0;
}
td:last-child {
padding-right: 0;
}
.form-control {
padding-left: .25rem;
padding-right: .25rem;
}
}
/* Bootstrap's .table style overwrites */
.table {
thead th {

@ -40,8 +40,130 @@ input.smart-upload {
margin-right: .5rem;
}
}
td.datetime {
display: flex;
input:first-child {
margin-right: .5rem;
}
input:last-child {
width: 75%;
}
}
td.rowbuttons {
width: 1%;
white-space: nowrap;
span {
display: none;
}
a {
padding: 0;
line-height: 2.3rem;
font-size: 1rem;
&:before {
&:extend(.font-icon-class);
content: @fa-var-plus;
margin: 0;
}
&.delete:before {
content: @fa-var-trash-o;
}
&.advanced:before {
content: @fa-var-cog;
}
&:not(:last-child) {
margin-right: .25rem;
}
}
}
td.rowactions {
width: 1%;
.form-control {
width: auto;
}
}
td.rowtargets {
.input-group {
margin-bottom: .25rem;
*:first-child.input-group-addon {
text-align: left;
min-width: 7em;
padding: .5rem
}
}
& > .advanced {
margin-top: .25rem;
}
}
td > .flexbox {
display: flex;
& > .multi-input {
width: 100%;
margin-left: .25rem;
}
}
.rulerow {
margin-bottom: .5rem;
}
}
@media screen and (max-width: 576px) {
.propform {
table.compact-table {
overflow-x: initial;
tbody {
display: block;
}
.rowactions > select,
.flexbox > select {
width: 100%;
}
tr {
display: flex;
flex-direction: column;
td {
width: 100%;
padding-right: 0;
padding-left: 0;
&.rowbuttons {
text-align: right;
a {
margin-right: .5rem;
& > span {
display: inline;
}
}
}
}
}
}
}
}
.propform,
.formcontent {
legend {
@ -284,6 +406,52 @@ ul.proplist {
}
}
/*** Smart list (multiple input) field ***/
.multi-input {
max-height: 11.65em;
overflow: hidden;
overflow-y: auto;
border-radius: .25rem;
border: 1px solid @color-input-border;
&.focused {
border: 1px solid @color-input-border-focus;
}
/* TODO: style button focus */
.input-group {
margin: 0 !important;
}
.input-group-addon {
&.reset:before {
&:extend(.font-icon-class);
content: @fa-var-trash-o;
margin: 0;
}
}
input,
input:focus,
.input-group-addon {
border-radius: 0;
border: 0;
border-bottom: 1px solid @color-input-border;
}
.input-group:last-child * {
border: 0;
}
& + .btn {
margin-top: .5rem;
}
}
/*** Files upload widget with list of files, upload form and drop area ***/
.file-upload {

@ -15,7 +15,22 @@
background-color: @color-dialog-overlay-background;
}
.ui-widget {
border: 1px solid @color-datepicker-border;
box-shadow: 3px 3px 5px @color-popover-shadow;
border-radius: .3rem;
}
.ui-menu {
overflow-y: auto;
overflow-x: hidden;
max-height: 400px;
}
.ui-dialog {
border-radius: 0;
box-shadow: none;
.ui-dialog-titlebar {
height: @layout-header-height;
border-bottom: 1px solid @color-dialog-header-border;
@ -135,11 +150,9 @@
/* Datepicker widget */
.ui-datepicker {
border: 1px solid @color-datepicker-border;
box-shadow: 3px 3px 5px @color-popover-shadow;
border-radius: .3rem;
padding: 0;
overflow: hidden;
z-index: 2 !important; /* above Bootstrap form controls that use z-index: 1 */
.ui-datepicker-header,
.ui-datepicker-title {
@ -225,9 +238,13 @@ html.touch {
}
@media screen and (max-width: @screen-width-mini) {
.ui-datepicker {
.ui-widget-content {
border-radius: 0;
width: 100% !important;
left: 0 !important;
}
.ui-autocomplete {
/* TODO: e.g. time input autocompletion on mobile */
}
}

@ -59,6 +59,8 @@ function rcube_elastic_ui()
this.mailtomenu = mailtomenu;
this.show_list = show_list;
this.show_sidebar = show_sidebar;
this.smart_field_init = smart_field_init;
this.smart_field_reset = smart_field_reset;
// Initialize layout
@ -88,7 +90,8 @@ function rcube_elastic_ui()
*/
function setup()
{
var content_buttons = [],
var title,
content_buttons = [],
is_framed = rcmail.is_framed();
// Initialize search forms (in list headers)
@ -116,13 +119,17 @@ function rcube_elastic_ui()
// Set content frame title in parent window (exclude ext-windows and dialog frames)
if (is_framed && !rcmail.env.extwin && !parent.$('.ui-dialog:visible').length) {
var title = $('h1.voice:first').text();
if (title) {
if (title = $('h1.voice:first').text()) {
parent.$('.header > .header-title', layout.content).text(title);
}
}
else {
var title = $('.boxtitle:first', layout.content).detach().text();
title = $('.boxtitle:first', layout.content).detach().text();
if (!title) {
title = $('h1.voice:first').text();
}
if (title) {
$('.header > .header-title', layout.content).text(title);
}
@ -269,9 +276,6 @@ function rcube_elastic_ui()
$('input[type=checkbox]', this).each(function() { pretty_checkbox(this); });
});
// The same for some other checkboxes
$('.propform input[type=checkbox], .form-check > input, .popupmenu.form input[type=checkbox], .toolbarmenu input[type=checkbox]')
.each(function() { pretty_checkbox(this); });
// Assign .formcontainer class to the iframe body, when it
// contains .formcontent and .formbuttons.
@ -410,7 +414,8 @@ function rcube_elastic_ui()
attachmentmenu_append(this);
});
rcmail.addEventListener('fileappended', function(e) { if (e.attachment.complete) attachmentmenu_append(e.item); });
rcmail.addEventListener('fileappended', function(e) { if (e.attachment.complete) attachmentmenu_append(e.item); })
.addEventListener('managesieve.insertrow', function(o) { console.log(o); bootstrap_style(o.obj); });
rcmail.init_pagejumper('.pagenav > input');
@ -458,8 +463,8 @@ function rcube_elastic_ui()
});
// Forms
$('input,select,textarea', $('table.propform', context)).not('[type=checkbox]').addClass('form-control');
$('[type=checkbox]', $('table.propform', context)).addClass('form-check-input');
$('input:not(.button),select,textarea', $('.propform', context)).not('[type=checkbox]').addClass('form-control');
$('[type=checkbox]', $('.propform', context)).addClass('form-check-input');
$('table.propform > tbody > tr', context).each(function() {
var first, last, row = $(this),
row_classes = ['form-group', 'row'],
@ -479,11 +484,21 @@ function rcube_elastic_ui()
else if (!last.find('input,textarea,radio,select').length) {
last.addClass('form-control-plaintext');
}
// style some multi-input fields
if (last.children('.datepicker') && last.children('input').length == 2) {
last.addClass('datetime');
}
}
row.addClass(row_classes.join(' '));
});
// Special input + anything entry
$('td.input-group', context).each(function() {
$(this).children(':not(:first)').addClass('input-group-addon');
});
// Other forms, e.g. Contact advanced search
$('fieldset.propform > .contactfieldgroup', context).each(function() {
$('.row', this).addClass('form-group').each(function() {
@ -502,6 +517,8 @@ function rcube_elastic_ui()
});
});
$('td.rowbuttons > a', context).addClass('btn');
// Testing Bootstrap Tabs on contact info/edit page
// Tabs do not scale nicely on very small screen, so can be used
// only with small number of tabs with short text labels
@ -532,7 +549,7 @@ function rcube_elastic_ui()
});
// Make tables pretier
$('table:not(.propform):not(.listing)')
$('table:not(.propform):not(.listing)', context)
.filter(function() {
// exclude direct propform children and external content
return !$(this).parent().is('.propform') && !$(this).parents('.message-htmlpart').length;
@ -547,6 +564,11 @@ function rcube_elastic_ui()
$('select,textarea,input:not([type="checkbox"],[type="radio"])', context).addClass('form-control');
}
// The same for some other checkboxes
// We do this here, not in setup() because we want to cover dialogs
$('.propform input[type=checkbox], .form-check > input, .popupmenu.form input[type=checkbox], .toolbarmenu input[type=checkbox]', context)
.each(function() { pretty_checkbox(this); });
// Make message-objects alerts pretty (the same as UI alerts)
$('#message-objects', context).children().each(function() {
alert_style(this, $(this).addClass('boxwarning').attr('class').split(/\s/)[0]);
@ -2326,6 +2348,126 @@ function rcube_elastic_ui()
setInterval(function() { $(textarea).trigger('input'); }, 500);
};
// Inititalizes smart list input
function smart_field_init(field)
{
var id = field.id + '_list',
area = $('<div class="multi-input"></div>'),
list = field.value ? field.value.split("\n") : [''];
if ($('#' + id).length) {
return;
}
// add input rows
$.each(list, function(i, v) {
smart_field_row_add(area, v, field.name, i, $(field).data('size'));
});
area.attr('id', id);
field = $(field);
if (field.attr('disabled')) {
area.hide();
}
// disable the original field anyway, we don't want it in POST
else {
field.prop('disabled', true);
}
field.after(area);
if (field.hasClass('error')) {
area.addClass('error');
//TODO rcmail.managesieve_tip_register([[id, field.data('tip')]]);
}
};
function smart_field_row_add(area, value, name, idx, size, after)
{
// build row element content
var input, elem = $('<div class="input-group">'
+ '<input type="text" class="form-control">'
+ '<a class="icon reset input-group-addon" href="#"></a>'
+ '</div>'),
attrs = {value: value, name: name + '[]'};
if (size) {
attrs.size = size;
}
input = $('input', elem).attr(attrs)
.keydown(function(e) {
var input = $(this);
// element creation event (on Enter)
if (e.which == 13) {
var name = input.attr('name').replace(/\[\]$/, ''),
dt = (new Date()).getTime(),
elem = smart_field_row_add(area, '', name, dt, size, input.parent());
$('input', elem).focus();
}
// backspace or delete: remove input, focus previous one
else if ((e.which == 8 || e.which == 46) && input.val() == '') {
var parent = input.parent(),
siblings = area.children();
if (siblings.length > 1) {
if (parent.prev().length) {
parent.prev().children('input').focus();
}
else {
parent.next().children('input').focus();
}
parent.remove();
return false;
}
}
});
// element deletion event
$('a.reset', elem).click(function() {
var record = $(this.parentNode);
if (area.children().length > 1) {
record.remove();
}
else {
$('input', record).val('').focus();
}
});
$(elem).children()
.on('focus', function() { area.addClass('focused'); })
.on('blur', function() { area.removeClass('focused'); });
if (after) {
after.after(elem);
}
else {
elem.appendTo(area);
}
return elem;
};
// Reset and fill the smart list input with new data
function smart_field_reset(field, data)
{
var id = field.id + '_list',
list = data.length ? data : [''],
area = $('#' + id);
area.empty();
// add input rows
$.each(list, function(i, v) {
smart_field_row_add(area, v, field.name, i, $(field).data('size'));
});
};
/**
* Wrapper for rcmail.open_window to intercept window opening
* and display a dialog with an iframe instead of a real window.

Loading…
Cancel
Save