summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/common/utils.js
AgeCommit message (Collapse)Author
2020-10-07[FIX] web_editor: restore adding bg video in some contextqsm-odoo
Since [1] the feature was broken because of a traceback which occured while trying parse a background image URL of an element which is not in the DOM. [1]: https://github.com/odoo/odoo/commit/7558dcce791f707e3f3470835133f91ec7ff074f closes odoo/odoo#59425 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-10-05[FIX] web_editor: fix background-image urls becoming absolute on dropSamuel Degueldre
With the recent addition of the parallax option on all snippets, background-image urls were being converted from relative to absolute on snippet-drop. This was caused by trying to read the background-image's url and setting it back onto the target, but there is no way to reliably read a background-image url in relative form, so it was returned in absolute form and then written back to the element as is. This commit fixes that by always converting the absolute URL to relative when they are on the same origin as the database. task-2312878 closes odoo/odoo#59098 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-09-16[IMP] web_editor, *: make media-dialog search odoo media-librarySamuel Degueldre
*: website, web_unsplash, website_blog We have recently created an odoo media library that exposes a public API for searching for open-source media, including dynamic SVGs that can be used with the dynamic background-shape system to create illustrations whose colors can be changed by the user. This commit adds the corresponding client-side functionalty: search for the images in the media-library, creating a corresponding attachment when selected, as well as an option to customize the colors of the dynamic SVGs. In the process, adaptations have been made in the web_unsplash module to avoid duplicating code and to adapt code that was making assumptions that are no longer valid. To make new users more aware of this feature, all default images have been hidden from the media-dialog, so that the user is prompted so search for images. Some tests and tours that were relying on having default images in the media-dialog (eg in website_blog) have been adapted to match. task-2316651 Linked to: odoo/iap-apps#235 closes odoo/odoo#56479 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-08-07[IMP] web_editor, website: add background shapes snippet optionSamuel Degueldre
This commit adds a new snippet option allowing the user to choose one of a series of SVG shapes as their background, or to be overlaid over the background image of a snippet and to customize the colors of those shapes. Part of https://github.com/odoo/odoo/pull/53017 task-2210790 closes odoo/odoo#53017 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-08-07[REF] web_editor: move normalizeColor function to we-utils for reuseSamuel Degueldre
Part of https://github.com/odoo/odoo/pull/53017 task-2210790
2020-07-22[FIX] web_editor, *: restore editor UI for selected CSS variablesqsm-odoo
*: website Commit [1] broke the UI for some options related to CSS variables when using Chrome. The commit made sure the string-value CSS variables are printed with quotes, so that the JS representation of the CSS values can distinguish them (strings = strings with surrounding quotes, others like colors, numbers, etc = strings without surrounding quotes). With chrome, the printed surrounding single quotes are read as double quotes for strange reasons though... so the value "a" was not considered equal to the value 'a'. This commit makes sure surrounding quotes are normalized. This is done through a new utility function to read CSS variables. This also makes sure the values are trimmed, and colors normalized. [1]: https://github.com/odoo/odoo/commit/3a34e39caa8544059dfb1888edc29c62c3efde31 closes odoo/odoo#54757 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-06-08[FIX] web_editor: fix color classes for non-background propertiesqsm-odoo
The computed preview for non-background properties (e.g. borders) was wrong in the left panel since the color presets classes were considered by mistake. Part of https://github.com/odoo/odoo/pull/52605 closes odoo/odoo#52605 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-06-02[IMP] web_editor, *: integrate new o_cc${xxx} classes in the colorpickerqsm-odoo
*: website Part of https://github.com/odoo/odoo/pull/45856 task-2197038
2020-05-14[IMP] web_editor, *: make Colorpicker a Widgetfja-odoo
*: website, web Move the colorpicker dialog logic into a colorpicker *widget*, which the colorpicker dialog will now instantiate. Part of https://github.com/odoo/odoo/pull/46088 task-2195313
2020-03-10[FIX] web_editor: allow non-alphabetic unit in data-unitBenjamin Vray
Allow non-alphabetic unit (like percentage) as data-unit value. task-2194309 closes odoo/odoo#47325 X-original-commit: 1f3dd221134b7b5e5b0eac0ab2ffe447771998b9 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-03-04[IMP] web_editor, website: improve border and border radius optionsSamuel Degueldre
Previously, the border radius option was only available when there was a border width, but in some cases you want no border, a background color, and still have rounded corners. This commit makes the option available when there is either a border OR a background color. This commit also adds an option to choose the border style between solid, dashed, dotted and double. The other styles have been left out as they look very different browser to browser and are not very useful. task-2195429 closes odoo/odoo#46625 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-02-05[FIX] web_editor: consider negative values in the left panelqsm-odoo
A negative value, even if legit, was not understood by the editor and induced empty inputs in the left panel. closes odoo/odoo#44683 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-12-01[IMP] web_editor, *: add new user value colorpicker widgetqsm-odoo
* web, mass_mailing, website Introduced a new sub-widget for snippet options: we-colorpicker. This allows to retrieve a color value (either a normalized css color or a theme color name) to be used for a snippet option method. This commit replaces the old 'colorpicker' snippet option whose behavior is now simply achieved by defining an xml option using a we-colorpicker widget in combination with the 'selectStyle' standard method. This commit also adds the possibility to control the border-color of elements alongside their border-width. Again, just a we-colorpicker widget in combination with the 'selectStyle' standard method. Note: this commit reviewed what the colorpalette palette widget notifies. This is not a cssColor and a 'isClass' flag to say if it is a css class or not. The colorpalette always returns a color string which can be the name of a color like 'alpha'. This is up to the caller to check if the color string is a css color or not with isCSSColor. In the case it is not, the related code can read the actual color by reading the related css variable. Part of https://github.com/odoo/odoo/pull/40282 In preparation of task-2122935 and other tasks
2019-12-01[REF] web, web_editor, *: review normalization of colorsqsm-odoo
* website Review colorpicker methods to always allow to use normalized colors. Also factorize some code in the color palette widget. Part of https://github.com/odoo/odoo/pull/40282 In preparation of task-2122935 and other tasks
2019-12-01[REF] web_editor, *: use widgets for left panel componentsqsm-odoo
Before this commit, the rendering of inner content of the left panel options was handled through _buildXXXElement methods in the options widgets. Now they are handled through sub-widgets which also handle the user events. Each sub-widget is notified with the string value it should hold according to the snippet option target and methods. Each sub-widget notifies a string value following user interactions, which snippet options can use to adapt their target through their option methods. The current sub-widgets introduced by this commit are (others will follow): 1) we-button 2) we-checkbox 3) we-input 4) we-select (typically containing multiple we-button widgets) 5) we-multi (typically containing multiple we-input widget) Following this commit only 3 standard option methods remain, which can be used with any meaningful widget: 1) selectClass -> Same as before + handle the old 'toggleClass' method when used with a checkbox-like widget. 2) selectStyle -> Same as old setStyle, introduced recently (simply renamed) 3) selectDataAttribute -> Handle both old selectDataAttribute and setDataAttribute, introduced recently The parameters these methods received are now: - previewMode: same as before - widgetValue: the string value the widget currently holds - params: additional parameters (mainly dataset of the related xml) + params.possibleValues (all the possible values for the method, meaninful for a select or a checkbox) + params.defaultValue (the value that the widget would give if it even holds no value) When defining a method in XML, the given value is the default value. e.g. data-select-style="34px" data-css-property="margin-top" -> if set on any widget, allows to retrieve a value from the user to customize the margin-top, the default value being 34px. -> if used with a we-input, allow to retrieve any value and an empty value will be equal to 34px -> if used on a checkbox, allow to toggle between no value and 34px. -> ... Hopefully, detailed documentation about all of this will follow. Code documentation should already be helpful. Last note: the _updateUI method (replacing the old _setActive) is now async (so does all the functions calling it). In particular, the _select method is now async. Part of https://github.com/odoo/odoo/pull/40282 In preparation of task-2122935 and other tasks