diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-12-20 13:55:52 +0100 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2017-12-20 17:15:08 +0100 |
| commit | 374fa10272a731b499184e0d06330494990938cc (patch) | |
| tree | 5592066d06338c6527de4250a024065ab745516a /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | cc652c65ecd77a973f6b81e87e071386127e0682 (diff) | |
[IMP] web_editor: allow to define options' target in XML data
Before this commit, defining a snippet option began by choosing an XML
`data-selector` attribute to put on the option's <div/>. This selector
would then be used to find DOM elements on which to attach the option.
A recent refactoring added the `data-exclude` attribute, allowing to
define a selector that a DOM element must not match to receive the
option.
A new kind of need has arrived: allowing an option to be attached on a
DOMElement but making the option's effects be applied on a specific
child of this DOMElement. This can allow to regroup children options on
a main DOMElement.
To that effect, this commit introduces the optional `data-target`
attribute. If defined, its value is used as a selector to find the
option's `$target` inside the element found with previous rules. Note
that the system has been made smart enough to only add the option on
elements which indeed contain such a $target.
E.g. I want an option to appear in the customize menu of my custom
snippet's <section/> but will in fact control the toggling of a class
'super-row' on the `.row` (I don't want the option to be on the `.row`
otherwise it would not be in the main customize menu). All I have to
do is defining a
```
<div data-selector="section" data-target="> .container > .row">
<li data-toggle-class="super-row"><a href="#">Super Row</a></li>
</div>
```
(no JS required)
Note: a similar behavior was already present on the JS side of the
"colorpicker" option.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
0 files changed, 0 insertions, 0 deletions
