summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/utils.js
AgeCommit message (Collapse)Author
2021-01-18[FIX] website: prevent navigation during load if new content menu openedBenoit Socias
Before this commit the new content menu only appeared once the page was fully loaded. Because of this users with slow connections could navigate elsewhere before noticing that the new option they enabled had appeared. After this commit a navigation-blocking overlay similar to the background of the menu is temporarily added to the page until the new content menu can be displayed. The div is put inside #wrapwrap in order to be later reused as the theme install loader blocking div which does not exist in 14.0. task-2439775 closes odoo/odoo#64554 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-12-10[IMP] website: improve autocomplete dropdown UISiddarth Gajjar
- Before this commit, Autocomplete dropdown ui is not compatible with existing editor ui. - After this, Autocomplete dropdown UI for url and GMAP imrpoved. closes odoo/odoo#60735 Taskid: 2352870 Closes: https://github.com/odoo/odoo/pull/60735 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-12-08[FIX] website: fix trigger of website_url_chosenBenjamin Vray
Before this commit, website_url_chosen was triggered when the dropdown of the input closed instead of when an item was selected in the list. This caused the following issue: you lost focus in the input every time the list closed while typing. After this commit, website_url_chosen is only triggered when an item is selected in the results list of a urlpicker input. Part of #62971 task-2312878
2020-08-27[FIX] website: restore website menu loading with imagesqsm-odoo
Since the images are now lazy loaded by default, the website menu was not loaded correctly anymore when a mega menu was enabled and that there was an image inside. Indeed, the menu loading waits for all images to be loaded to compute the menu that should be in a dropdown when there are too many. As the ones in the mega menus are hidden when the menu is closed, the new lazy loading feature does not load them... which makes the menu loading wait for something that is not being done. This commit solves the problem by not waiting for images inside mega menus. This could actually be done as a stable fix in stable versions as there is no point waiting for those particular images in any case. This will be only merged in master as it is not strictly a bug though, at least for now. Part of https://github.com/odoo/odoo/pull/56427 task-2264627
2020-05-29[IMP] website: reintroduce a way to post from jsDramixDw
It was deleted in 11.0 as it was not used anymore. Now, it is reintroduce as it is a nice utility function for some external app or fixes. Here, it is use so that /website/add and /website/add/<path> work as a controller POST with a CSRF token. task-2241766
2020-05-01[IMP] website: simplify website menuDramixDw
Some apps, once installed, automatically create a menuitem in website. What complexify the UI and create useless menu withtout plusvalue. It is not because you install livechat to make support online, that you want a link in your menu to show stats e.g. Now we remove the default menu created, and help user to find it when he create a link. The autocomplete suggest most of the main App's controllers task-2189613 closes odoo/odoo#49081 Related: odoo/enterprise#9733 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-10-25[FIX] website, *: restore website js loadingqsm-odoo
* web_editor Commit https://github.com/odoo/odoo/commit/7e2b0ebe7996c9fa35f75949b7fc8cd5a58d7c36 broke the website JS loading as it added a dependency to a lazy loaded JS module which was not even always lazy loaded. A test so that this does not happens anymore will be made in another commit. Related to task-2092386 closes odoo/odoo#39391 X-original-commit: 5ac269d722f9ff8c206215dd1c07b8544cfd5382 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-10-24[FIX] web_editor, *: fix the theme colorpickerfja-odoo
*: website Inherited colorpicker were not used due to the context missing the website_id and the method call being used instead of call_kw. task-2092386 closes odoo/odoo#39357 X-original-commit: 7e2b0ebe7996c9fa35f75949b7fc8cd5a58d7c36 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-10-15[FIX] website_blog: make latest posts snippet multi-website awareqsm-odoo
The snippet was using the posts of all websites and blog post creation was suggesting all blogs. Now: - On blog post creation only suggest the blogs of the current website - In latest posts option, only suggest blogs of the current website - In any case, latest posts only displays posts of the current website Part of https://github.com/odoo/odoo/pull/38510 Related to task-2083198 closes odoo/odoo#38794 X-original-commit: 4be97b48861a6631fe465054c62baea65bfc1524 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-03-15[FIX] website: restore broken promises in websiteqsm-odoo
Since the switch to jQuery 3, Odoo uses native promises in its JS. Some mistakes were made in the website app during conversion from old jQuery deferred to native promises. - `this` -> `self` when wrapping in a promise - `.always(fct)` -> `.then(fct).guardedCatch(fct)` - a function returned sometimes a jQuery deferred, sometimes a native promise. This made the caller fail when using `always` or fail when using `guardedCatch` closes odoo/odoo#31887 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-03-06[REF] website: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-08[IMP] website: improve affix menu to work with all headersqsm-odoo
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
2019-01-09[IMP] website, *: allow creating anchor linksAndrea Ulliana
* portal, web_editor Anchor Link: - Some visual improvements of the link dialog. - New 'Page Anchor' field. - System by default: top and bottom. - Shows existing anchors. Creation of the anchor: - New option 'Anchor Name' to be able to create an anchor. task-1913458 closes odoo/odoo#29150
2018-09-30[REF] website, *: add automatic context for call_kw rpcqsm-odoo
* web_editor, website_blog, website_crm_partner_assign, website_links, website_livechat, website_mail_channel, website_mass_mailing, website_slides Calling a model's method thanks to an RPC will now always send the web_editor context automatically, making sure the method gets the website_id all the time, removing the need to guess the current website (now the get_current_website method uses the context website_id if any). Note: other routes already have the website_id via request.env.context if they correctly set website=True (this commit also adds website=True for scss files customization routes).
2017-10-12[FIX] website: load xml dependencies of website.promptqsm-odoo
The deprecated-but-still-used website.prompt requires some static XML to be loaded to work. In the case of creating a new website page, this XML was implicitely loaded by the "Content" menu... but when the user is on a translated page, this menu is not there. Anyway, this static XML loading should be done by the website.prompt function itself if necessary.
2017-09-25[IMP] website: pageManagement - improvements according to first feedbacksrde
- labelling and screen redesign (update labels, hide labels, hide fields, ...) - make UI more mobile friendly (icon biggest, color using less variables,...) - Page & Redirection menu are for visible only in debug mode - Add meta noindex for website.page not shown in sitemap - Add mechanism to be able to edit in backend a broken view (Needed for - Internal Error 500, css, js file, ...) - website pagemanager dedicated to website_publisher only
2017-09-15[ADD] website: add new page managementrde
website.page = old ir.ui.view with page=True website.redirect is a new mechanism to replace in the futur the ir.attachment mechanism of redirect. From now, we don't have a specific /page controller to serve 'page'. We use a new model website.page which is rendered if none route matches the url and that the field 'url' on website.page matches the request.httprequest.path. The order to serve a path is: - Routes defines in controllers (/shop, /blog, ...) - ir.attachment with name matching the path - website.page with url matching the path - website.redirect with url_from matching the path - 404 To improve: - allow regexp in website.redirect model - allow to edit the view_arch from the page.management via redirect backend (needed when traceback in the page, or when modifying a js/css/less/...)
2017-08-16[REF] web_editor, website, *: complete refactoringqsm-odoo
* mass_mailing, payment, point_of_sale, portal, survey, web, web_tour, website_blog, website_crm_partner_assign, website_event, website_event_questions, website_form, website_forum, website_gengo, website_hr_recruitment, website_links, website_mail, website_mail_channel, website_mass_mailing, website_quote, website_sale, website_sale_options, website_slides, website_twitter This commit reviews the whole "JS side" of the web_editor and website apps. This is a first step to be able to improve them with new and better functionnalities; this commit is not supposed to change any visual behavior. The main goal was to achieve a structure similar to the backend one. Now, the frontend side also has a root widget (like the WebClient) and all other widgets are attached to it one way or another. This allows the benefits of using the 'trigger_up' functionnality for example. As RPC are now mainly done with the `this._rpc` functionnality (being possible thanks to the parent hierarchy), the frontend will also be possible to test thanks to QUnit in a future update (besides the "text" editor side which still requires a refactoring to be able to do that). --- Here are some of the changes: (-) conventions and documentation The code has been updated to follow JS conventions and a lot of code has been commented (around +2000 lines of comment). This also means that lots of functions have been renamed to use camelCase or simply to make their name understandable. See https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines. (-) deprecated: web_editor.base The "web_editor.base" module has been split and does not force the modules which require it to wait for DOM ready anymore. This was indeed slowing loading times, but also prevented to use some modules in some contexts (see the LESS editor use in web_studio which is the subject of another task). Now the "editor context" can be got thanks to the "web_editor.context" JS module with its "get" function. The "web_editor.base" module should probably not be used anymore (see its code and recent updates). (-) new: web.dom_ready If a JS module should wait for the DOM to be ready to be executed, a new JS module has been created: "web.dom_ready". This should always be used in a module which only want to instantiate stuff. Do not extend (or worst, include) classes after DOM ready. (-) website.website The "website.website" module has been split. "website.website" does not return anything useful anymore, it just initialize some miscellaneous stuff, without waiting for the DOM to be ready. You might want to check "website.utils", "website.content.compatibility" or `WebsiteRoot`. Also `website.form` has been deleted (use `this._rpc`), so has been `website.error`. `website.prompt` will be removed in a future update to be replaced by `Dialog.prompt`. (-) widgets are great Many classes which were not widgets are now widgets. This allows them to use the 'events', the 'xmlDependencies' and the 'this._rpc' features for example. Here are some of the main ones: - Snippet options: these were classes with a `$el` for the menu element and `$target` for the customized element. This is still the case but following standard `Widget` structure (one exception: using `this.$(...)` searches in the `$target` as before this update). - Snippet animations: instead of class instances with a `$target` element which can be `start` and `stop`, these are now standard widgets which can be `start` and `destroy`. `this.$target` is an alias to `this.$el` for ease of compatibility. - Snippet editors: instead of class instances in charge of an editor overlay, these are now widgets. Each "child" snippet editor is properly attached as a "child", which allows editors to communicate and to be properly destroyed. (-) root widgets and website navbar The frontend is different of the backend. In the backend, the page has an empty <body/> element and all the components are instantiated from parent to children (i.e. the `WebClient` is instantiated and is in charge of instantiating the `ControlPanel`, etc). The frontend cannot work like that on page loadings as they are way more frequent than in the backend and we do not want them to flicker. A frontend page is loaded as a <body/> element which already contains the website navbar and its menus and the whole content page. JS code has to be "attached" to these existing elements. This is possible thanks to the `RootWidget` instances and the specialized `WebsiteRoot`, `IframeRoot` and `WebsiteNavbar` (see code for details). (-) lazy loading No more (or at least a lot less) XML/JS has to be loaded on page loading, thanks to the use of the `Widget.xmlDependencies` feature. XML which have to be lazy loaded is loaded only on related Widget instantiation if necessary, which allows to execute a lot of JS code before the DOM is ready and to start many widgets on DOM ready (not later). A visual benefit of this is clicking on the 'edit' button as soon as it is possible: before this commit, this was sometimes not doing anything as event handlers were not binded yet. Still a possible exception: loading the session and locales. This may be asynchronous stuff which is still required before widget instantiations but this will be the subject of another task. (-) deprecated code and code location More than reviewing code and organizing it, many apparent dead code was removed. More importantly, mislocated code was put in the right app. This is the case for snippet animations which is a concept for website apps but was defined in the web_editor app, or some translation concepts which were part of website but should have been part of web_editor. --- There are probably more things to say about this commit but I will let the comments speak for those.