diff --git a/CHANGELOG b/CHANGELOG index 68008f7854..9c0f1b33d2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Manage icons in input * Support RTL language direction * Apply factor on domain parser * Use tab name in CSV Export/Import diff --git a/src/input-icon.less b/src/input-icon.less new file mode 100644 index 0000000000..575b656383 --- /dev/null +++ b/src/input-icon.less @@ -0,0 +1,97 @@ +/* + * Input icons + */ +@import "variables"; + +.input-icon { + position: relative; + + & .icon-input { + position: absolute; + top: 0; + z-index: 4; // Ensure icon is above input + display: block; + width: @input-height-base; + height: @input-height-base; + line-height: @input-height-base; + text-align: center; + } + [dir="ltr"] & .icon-primary { + left: 0px; + } + [dir="rtl"] & .icon-primary { + right: 0px; + } + [dir="ltr"] & .icon-secondary { + right: 0px; + } + [dir="rtl"] & .icon-secondary { + left: 0px; + } +} +.input-lg .icon-input, +.input-group-lg .icon-input { + width: @input-height-large; + height: @input-height-large; + line-height: @input-height-large; +} +.input-sm .icon-input, +.input-group-sm .icon-input { + width: @input-height-small; + height: @input-height-small; + line-height: @input-height-small; +} + +[dir="ltr"] { + .input-icon-primary > .form-control { + padding-left: @input-height-base; + } + .input-lg.input-icon-primary > .form-control, + .input-group-lg.input-icon-primary > .form-control { + padding-left: @input-height-large; + } + .input-sm.input-icon-primary > .form-control, + .input-group-sm.input-icon-primary > .form-control { + padding-left: @input-height-small; + } +} +[dir="rtl"] { + .input-icon-primary > .form-control { + padding-right: @input-height-base; + } + .input-lg.input-icon-primary > .form-control, + .input-group-lg.input-icon-primary > .form-control { + padding-right: @input-height-large; + } + .input-sm.input-icon-primary > .form-control, + .input-group-sm.input-icon-primary > .form-control { + padding-right: @input-height-small; + } +} + +[dir="ltr"] { + .input-icon-secondary > .form-control { + padding-right: @input-height-base; + } + .input-lg.input-icon-secondary > .form-control, + .input-group-lg.input-icon-secondary > .form-control { + padding-right: @input-height-large; + } + .input-sm.input-icon-secondary > .form-control, + .input-group-sm.input-icon-secondary > .form-control { + padding-right: @input-height-small; + } +} +[dir="rtl"] { + .input-icon-secondary > .form-control { + padding-left: @input-height-base; + } + .input-lg.input-icon-secondary > .form-control, + .input-group-lg.input-icon-secondary > .form-control { + padding-left: @input-height-large; + } + .input-sm.input-icon-secondary > .form-control, + .input-group-sm.input-icon-secondary > .form-control { + padding-left: @input-height-small; + } +} diff --git a/src/view/form.js b/src/view/form.js index 5d12f19ece..08b37ad4a9 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -1353,15 +1353,14 @@ function eval_pyson(value){ this.group.css('width', '100%'); } if (this.attributes.translate) { - var button = jQuery('', { - 'class': 'btn btn-default btn-sm form-control', - 'type': 'button', - 'aria-label': Sao.i18n.gettext('Translate') - }).append(Sao.common.ICONFACTORY.get_icon_img('tryton-translate') - ).appendTo(jQuery('', { - 'class': 'input-group-btn' - }).appendTo(this.group)); - button.click(this.translate.bind(this)); + Sao.common.ICONFACTORY.get_icon_img('tryton-translate') + .appendTo(jQuery('
', { + 'class': 'icon-input icon-secondary', + 'aria-label': Sao.i18n.gettext('Translate'), + 'title': Sao.i18n.gettext('Translate'), + }).appendTo( + this.group.addClass('input-icon input-icon-secondary'))) + .click(this.translate.bind(this)); } }, get_client_value: function(record, field) { @@ -1469,18 +1468,15 @@ function eval_pyson(value){ 'class': this.class_ }); this.date = this.labelled = jQuery('', { - 'class': 'input-group input-group-sm' + 'class': ('input-group input-group-sm ' + + 'input-icon input-icon-primary'), }).appendTo(this.el); - jQuery('', { - 'class': 'input-group-btn' - }).append(jQuery('', { - 'class': 'datepickerbutton btn btn-default', - 'type': 'button', - 'tabindex': -1, - 'aria-label': Sao.i18n.gettext("Open the calendar"), - 'title': Sao.i18n.gettext("Open the calendar"), - }).append(Sao.common.ICONFACTORY.get_icon_img('tryton-date') - )).appendTo(this.date); + Sao.common.ICONFACTORY.get_icon_img('tryton-date') + .appendTo(jQuery('', { + 'class': 'datepickerbutton icon-input icon-primary', + 'aria-label': Sao.i18n.gettext("Open the calendar"), + 'title': Sao.i18n.gettext("Open the calendar"), + }).appendTo(this.date)); this.input = jQuery('', { 'type': 'text', 'class': 'form-control input-sm mousetrap' @@ -2147,12 +2143,25 @@ function eval_pyson(value){ 'class': this.class_ }); var group = jQuery('', { - 'class': 'input-group input-group-sm' + 'class': 'input-group input-group-sm input-icon' }).appendTo(this.el); this.entry = this.labelled = jQuery('', { 'type': 'input', 'class': 'form-control input-sm mousetrap' }).appendTo(group); + this.but_primary = jQuery('