diff options
| author | Samuel Degueldre <sad@odoo.com> | 2020-06-22 08:35:45 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2020-08-19 08:32:23 +0000 |
| commit | 42abf8f49639439d992c43ddf40f7f04e8f7e7d5 (patch) | |
| tree | d47fe2f5f4b9ca736c0c07a404df2efd5032b686 /addons/web_editor/static/src/js/editor/snippets.options.js | |
| parent | 4575c188c4e24e07897719b31d124af5c3c30e06 (diff) | |
[IMP] web_editor: add webgl image filters
This commit adds webgl image filter to the existing image options,
including a custom filter that lets the user access color-correction
options (saturation, brightness, contrast, sepia, ...) as well as
blending modes for color filters.
Part of https://github.com/odoo/odoo/pull/53114
task-2279190
closes odoo/odoo#53114
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js/editor/snippets.options.js')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.options.js | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 2aca673d887..7edee505ea1 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -2993,15 +2993,34 @@ const ImageHandlerOption = SnippetOptionWidget.extend({ /** * @see this.selectClass for parameters */ - setFilter(previewMode, widgetValue, params) { - this._getImg().dataset.filter = normalizeColor(widgetValue); + setQuality(previewMode, widgetValue, params) { + this._getImg().dataset.quality = widgetValue; return this._applyOptions(); }, /** * @see this.selectClass for parameters */ - setQuality(previewMode, widgetValue, params) { - this._getImg().dataset.quality = widgetValue; + glFilter(previewMode, widgetValue, params) { + const dataset = this._getImg().dataset; + if (widgetValue) { + dataset.glFilter = widgetValue; + } else { + delete dataset.glFilter; + } + return this._applyOptions(); + }, + /** + * @see this.selectClass for parameters + */ + customFilter(previewMode, widgetValue, params) { + const img = this._getImg(); + const {filterOptions} = img.dataset; + const {filterProperty} = params; + if (filterProperty === 'filterColor') { + widgetValue = normalizeColor(widgetValue); + } + const newOptions = Object.assign(JSON.parse(filterOptions || "{}"), {[filterProperty]: widgetValue}); + img.dataset.filterOptions = JSON.stringify(newOptions); return this._applyOptions(); }, @@ -3026,8 +3045,16 @@ const ImageHandlerOption = SnippetOptionWidget.extend({ return img.naturalWidth; case 'setFilter': return img.dataset.filter; + case 'glFilter': + return img.dataset.glFilter || ""; case 'setQuality': return img.dataset.quality || 95; + case 'customFilter': { + const {filterProperty} = params; + const options = JSON.parse(img.dataset.filterOptions || "{}"); + const defaultValue = filterProperty === 'blend' ? 'normal' : 0; + return options[filterProperty] || defaultValue; + } } return this._super(...arguments); }, |
