changeset e633b30c75ab in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=e633b30c75ab
description:
        Set the same overflow for datetime picker than completion

        issue9614
        review292581002
diffstat:

 src/common.js    |  47 ++++++++++++++++++++++++++---------------------
 src/sao.js       |  10 ++++++++++
 src/screen.js    |   6 ++++++
 src/view/form.js |   6 ++++++
 4 files changed, 48 insertions(+), 21 deletions(-)

diffs (119 lines):

diff -r b4859872c774 -r e633b30c75ab src/common.js
--- a/src/common.js     Sun Nov 15 18:50:47 2020 +0100
+++ b/src/common.js     Sun Nov 15 19:19:16 2020 +0100
@@ -3303,6 +3303,30 @@
     });
     Sao.common.processing = new Sao.common.Processing();
 
+    Sao.common.set_overflow = function set_overflow(el, state) {
+        // We must set the overflow of the treeview and modal-body
+        // containing the input to visible to prevent vertical scrollbar
+        // inherited from the auto overflow-x
+        // Idem when in navbar collapse for the overflow-y
+        // (see http://www.w3.org/TR/css-overflow-3/#overflow-properties)
+        var overflow, height;
+        if (state == 'hide') {
+            overflow = '';
+            height = '';
+        } else {
+            overflow = 'visible';
+            height = 'none';
+        }
+        el.closest('.treeview')
+            .css('overflow', overflow)
+            .css('max-height', height);
+        el.closest('.modal-body').css('overflow', overflow);
+        el.closest('.navbar-collapse.in').css('overflow-y', overflow);
+        el.closest('.content-box').css('overflow-y', overflow);
+        el.closest('fieldset.form-group_').css('overflow', overflow);
+        Sao.common.scrollIntoViewIfNeeded(el);
+    };
+
     Sao.common.InputCompletion = Sao.class_(Object, {
         init: function(el, source, match_selected, format) {
             if (!el.is('input')) {
@@ -3361,31 +3385,12 @@
                     this.menu.dropdown('toggle');
                 }
             }.bind(this));
-            // We must set the overflow of the treeview and modal-body
-            // containing the input to visible to prevent vertical scrollbar
-            // inherited from the auto overflow-x
-            // Idem when in navbar collapse for the overflow-y
-            // (see http://www.w3.org/TR/css-overflow-3/#overflow-properties)
             this.dropdown.on('hide.bs.dropdown', function() {
                 this.input.focus();
-                this.input.closest('.treeview')
-                    .css('overflow', '')
-                    .css('max-height', '');
-                this.input.closest('.modal-body').css('overflow', '');
-                this.input.closest('.navbar-collapse.in').css('overflow-y', 
'');
-                this.input.closest('.content-box').css('overflow-y', '');
-                this.input.closest('fieldset.form-group_').css('overflow', '');
-                Sao.common.scrollIntoViewIfNeeded(this.input);
+                Sao.common.set_overflow(this.input, 'hide');
             }.bind(this));
             this.dropdown.on('show.bs.dropdown', function() {
-                this.input.closest('.treeview')
-                    .css('overflow', 'visible')
-                    .css('max-height', 'none');
-                this.input.closest('.modal-body').css('overflow', 'visible');
-                this.input.closest('.navbar-collapse.in').css('overflow-y', 
'visible');
-                this.input.closest('.content-box').css('overflow-y', 
'visible');
-                this.input.closest('fieldset.form-group_').css('overflow', 
'visible');
-                Sao.common.scrollIntoViewIfNeeded(this.input);
+                Sao.common.set_overflow(this.input, 'show');
             }.bind(this));
         },
         set_actions: function(actions, action_activated) {
diff -r b4859872c774 -r e633b30c75ab src/sao.js
--- a/src/sao.js        Sun Nov 15 18:50:47 2020 +0100
+++ b/src/sao.js        Sun Nov 15 19:19:16 2020 +0100
@@ -1210,5 +1210,15 @@
             index = index || 0;
             return setValue.call(this, targetMoment, index);
         };
+
+        // XXX: trigger show/hide event without date
+        var notifyEvent = 
$.fn.datetimepicker.prototype.constructor.Constructor.prototype._notifyEvent;
+        
$.fn.datetimepicker.prototype.constructor.Constructor.prototype._notifyEvent = 
function _notifyEvent(e) {
+            if ((e.type === 'datetimepicker.hide') || (e.type === 
'datetimepicker.show')) {
+                this._element.trigger(e);
+            } else {
+                notifyEvent.call(this, e);
+            }
+        };
     }
 }());
diff -r b4859872c774 -r e633b30c75ab src/screen.js
--- a/src/screen.js     Sun Nov 15 18:50:47 2020 +0100
+++ b/src/screen.js     Sun Nov 15 19:19:16 2020 +0100
@@ -675,6 +675,12 @@
                     'keyBinds': null,
                     'useCurrent': false,
                 });
+                entry.on('datetimepicker.hide', function() {
+                    Sao.common.set_overflow(entry, 'hide');
+                });
+                entry.on('datetimepicker.show', function() {
+                    Sao.common.set_overflow(entry, 'show');
+                });
 
                 var mousetrap = new Mousetrap(el[0]);
 
diff -r b4859872c774 -r e633b30c75ab src/view/form.js
--- a/src/view/form.js  Sun Nov 15 18:50:47 2020 +0100
+++ b/src/view/form.js  Sun Nov 15 19:19:16 2020 +0100
@@ -1591,6 +1591,12 @@
             });
             this.date.css('max-width', this._width);
             this.date.on('change.datetimepicker', this.focus_out.bind(this));
+            this.date.on('datetimepicker.hide', function() {
+                Sao.common.set_overflow(this.date, 'hide');
+            }.bind(this));
+            this.date.on('datetimepicker.show', function() {
+                Sao.common.set_overflow(this.date, 'show');
+            }.bind(this));
             var mousetrap = new Mousetrap(this.el[0]);
 
             mousetrap.bind('enter', function(e, combo) {

Reply via email to