diff options
Diffstat (limited to 'addons/web/static/src/js/views/abstract_controller.js')
| -rw-r--r-- | addons/web/static/src/js/views/abstract_controller.js | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index ef95ea72696..aed09c363cc 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -283,22 +283,22 @@ var AbstractController = AbstractAction.extend(ControlPanelMixin, { }); }, /** - * Renders the html provided by the route specified by the - * bannerRoute attribute on the controller (banner_route in the template). - * Renders it before the view output and add a css class 'o_has_banner' to it. - * There can be only one banner displayed at a time. - * - * If the banner contains stylesheet links, they are moved to <head> - * (and will only be fetched once). - * - * Route example: - * @http.route('/module/hello', auth='user', type='json') - * def hello(self): - * return {'html': '<h1>hello, world</h1>'} - * - * @private - * @returns {Deferred} - */ + * Renders the html provided by the route specified by the + * bannerRoute attribute on the controller (banner_route in the template). + * Renders it before the view output and add a css class 'o_has_banner' to it. + * There can be only one banner displayed at a time. + * + * If the banner contains stylesheet links or js files, they are moved to <head> + * (and will only be fetched once). + * + * Route example: + * @http.route('/module/hello', auth='user', type='json') + * def hello(self): + * return {'html': '<h1>hello, world</h1>'} + * + * @private + * @returns {Deferred} + */ _renderBanner: function () { if (this.bannerRoute !== undefined) { var self = this; @@ -315,13 +315,16 @@ var AbstractController = AbstractAction.extend(ControlPanelMixin, { if (self._$banner && self._$banner.remove) { self._$banner.remove(); } - // Stylesheets are moved to <head> and we wait for them to be loaded - // to prevent displaying unstyled content. + // Css and js are moved to <head> var defs = []; $('link[rel="stylesheet"]', $banner).each(function (i, link) { defs.push(ajax.loadCSS(link.href)); link.remove(); }); + $('script[type="text/javascript"]', $banner).each(function (i, js) { + defs.push(ajax.loadJS(js.src)); + js.remove(); + }); return $.when.apply($, defs).then(function () { $banner.prependTo(self.$el); self._$banner = $banner; |
