From 70052e1fd6dad7b82aaf069baafdbf30ad34baf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 27 May 2014 14:21:52 +0200 Subject: [PATCH] [FIX] correct some issues with scrolling area the height of the oe_view_manager_header is variable, and the top can't be positioned correctly with pure css without a lot of work, so this commit adds a touch of javascript to make sure that the view is correctly positioned. --- addons/mail/static/src/css/mail.css | 1 - addons/web/static/src/js/search.js | 33 ++++++++++++++++++----------- addons/web/static/src/js/views.js | 3 ++- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index b97040562d7..d8337c75f13 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -691,7 +691,6 @@ .openerp .oe_mail_wall > div { position: absolute; overflow: auto; - top: 48px; bottom: 0; left: 0; right: 0; diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 02d193a2fbb..79b17ba163d 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -387,6 +387,8 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea this.headless = this.options.hidden && !this.has_defaults; this.input_subviews = []; + this.view_manager = null; + this.$view_manager_header = null; this.ready = $.Deferred(); this.drawer_ready = $.Deferred(); @@ -398,11 +400,14 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea var self = this; var p = this._super(); + this.$view_manager_header = this.$el.parents(".oe_view_manager_header").first(); + this.setup_global_completion(); this.query = new my.SearchQuery() .on('add change reset remove', this.proxy('do_search')) .on('change', this.proxy('renderChangedFacets')) - .on('add reset remove', this.proxy('renderFacets')); + .on('add reset remove', this.proxy('renderFacets')) + .on('add change reset remove', this.proxy('adjust_view_top')); if (this.options.hidden) { this.$el.hide(); @@ -432,21 +437,13 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea } if (view_manager) { + this.view_manager = view_manager; view_manager.on('switch_mode', this, function (e) { self.drawer.toggle(e === 'graph'); }); + $(window).resize(this.proxy("adjust_view_top")); } - $(window).resize(this.adjust_top.bind(this)); - return $.when(p, this.ready).then(this.adjust_top.bind(this)); - }, - - adjust_top: function () { - // hack to adjust the top of the view manager body to the actual header height - var parent = this.getParent(); - if (parent && parent.$) { - var h = parent.$(".oe_view_manager_header").height() + 1; - parent.$(".oe_view_manager_body").css('top', h + 'px'); - } + return $.when(p, this.ready); }, set_drawer: function (drawer) { @@ -645,6 +642,18 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea }); }, + // hack to adjust the top of the view body to the actual header height + // the best way would be to do that with pure css, but this cannot be done + // without giving up IE9 support (flexbox/grid) or without reworking the + // full client structure (switching from tables to a sane responsive layout with + // divs). + adjust_view_top: function () { + if (this.$view_manager_header.length) { + var height = this.$view_manager_header.height() + 1; + this.$view_manager_header.next().css('top', height + 'px'); + } + }, + search_view_loaded: function(data) { var self = this; this.fields_view = data; diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 4cbf036e9f3..5d6fe8b143f 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -607,7 +607,6 @@ instance.web.ViewManager = instance.web.Widget.extend({ // If no default view defined, switch to the first one in sequence var default_view = this.flags.default_view || this.views_src[0].view_type; - return this.switch_mode(default_view, null, this.flags[default_view] && this.flags[default_view].options); @@ -705,6 +704,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ self.trigger("controller_inited",view_type,controller); }); }, + /** * @returns {Number|Boolean} the view id of the given type, false if not found */ @@ -1071,6 +1071,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({ view_manager: self })); self.set_title(); + self.searchview.adjust_view_top(); }); }, do_create_view: function(view_type) {