diff options
| author | qsm-odoo <qsm@odoo.com> | 2018-12-24 12:10:30 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2019-02-08 14:38:23 +0000 |
| commit | 9f21427cdf41063065ecb60371717599afdfa067 (patch) | |
| tree | 28b8c9c3c69ef09a4e37c1565ba8e6d23f2b445c /addons/website/static/src/js/utils.js | |
| parent | 2d934aee71a7bfb6cf40272e1b38be240c00bc4b (diff) | |
[IMP] website: improve affix menu to work with all headers
Now that the logo can be resized, the affix menu had to be adapted to
handle tall headers.
PR https://github.com/odoo/odoo/pull/29624
task-1904244
Diffstat (limited to 'addons/website/static/src/js/utils.js')
| -rw-r--r-- | addons/website/static/src/js/utils.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/website/static/src/js/utils.js b/addons/website/static/src/js/utils.js index 9cf511fe160..01f0e7797a4 100644 --- a/addons/website/static/src/js/utils.js +++ b/addons/website/static/src/js/utils.js @@ -60,6 +60,24 @@ function autocompleteWithPages(self, $input) { }, }); } + +/** + * @param {jQuery} $element + */ +function onceAllImagesLoaded($element) { + var defs = _.map($element.find('img').addBack('img'), function (img) { + if (img.complete) { + return; // Already loaded + } + var def = $.Deferred(); + $(img).one('load', function () { + def.resolve(); + }); + return def; + }); + return $.when.apply($, defs); +} + /** * @deprecated * @todo create Dialog.prompt instead of this @@ -168,6 +186,7 @@ function prompt(options, _qweb) { return { loadAnchors: loadAnchors, autocompleteWithPages: autocompleteWithPages, + onceAllImagesLoaded: onceAllImagesLoaded, prompt: prompt, }; }); |
