diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-10-10 19:14:30 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-10-10 19:14:30 +0200 |
| commit | 0be264b29eac11a5dec5e6565d23d4ea86bd905a (patch) | |
| tree | 79362f2340c89cb3cf2e8d8a467f357b7c7a8326 /addons/web_editor/static/src | |
| parent | cf753a7fdf1739dcf37d2ad74f4c8efb3d4ff3b3 (diff) | |
| parent | e1104ac344cbc349a46b22339b13dfe9cbab8bcb (diff) | |
[MERGE] forward port branch 11.0 up to e1104ac344c
Diffstat (limited to 'addons/web_editor/static/src')
4 files changed, 47 insertions, 19 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index c08fd39f0db..d192ad00d7d 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -973,7 +973,7 @@ var SnippetsMenu = Widget.extend({ globalSelector.all = function ($from) { var $target = $(); for (var i = 0, len = selectors.length ; i < len ; i++) { - $target.add(selectors[i].all($from)); + $target = $target.add(selectors[i].all($from)); } return $target; }; 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 fbcf364a057..08694882603 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -827,6 +827,7 @@ registry.background = SnippetOption.extend({ start: function () { var res = this._super.apply(this, arguments); this.bindBackgroundEvents(); + this.__customImageSrc = this._getSrcFromCssValue(); return res; }, @@ -840,9 +841,16 @@ registry.background = SnippetOption.extend({ * @see this.selectClass for parameters */ background: function (previewMode, value, $li) { + if (previewMode === 'reset' && value === undefined) { + // No background has been selected and we want to reset back to the + // original custom image + this._setCustomBackground(this.__customImageSrc); + return; + } + if (value && value.length) { this.$target.css('background-image', 'url(\'' + value + '\')'); - this.$target.addClass('oe_img_bg'); + this.$target.removeClass('oe_custom_bg').addClass('oe_img_bg'); } else { this.$target.css('background-image', ''); this.$target.removeClass('oe_img_bg oe_custom_bg'); @@ -868,11 +876,7 @@ registry.background = SnippetOption.extend({ _editor.$('[href="#editor-media-video"], [href="#editor-media-icon"]').addClass('hidden'); _editor.on('save', this, function () { - var value = $image.attr('src'); - this.background(previewMode, value, $li); - this.$target.addClass('oe_custom_bg'); - this._setActive(); - this.$target.trigger('snippet-option-change', [this]); + this._setCustomBackground($image.attr('src')); }); _editor.on('closed', this, function () { $image.remove(); @@ -908,16 +912,26 @@ registry.background = SnippetOption.extend({ //-------------------------------------------------------------------------- /** + * Returns the src value from a css value related to a background image + * (e.g. "url('blabla')" => "blabla" / "none" => ""). + * + * @private + * @param {string} value + * @returns {string} + */ + _getSrcFromCssValue: function (value) { + if (value === undefined) { + value = this.$target.css('background-image'); + } + return value.replace(/url\(['"]*|['"]*\)|^none$/g, ''); + }, + /** * @override */ _setActive: function () { this._super.apply(this, arguments); - var src = this.$target.css('background-image').replace(/url\(['"]*|['"]*\)|^none$/g, ''); - if (this.$target.hasClass('oe_custom_bg')) { - this.$el.find('li[data-choose-image]').data('background', src).attr('data-background', src); - } - + var src = this._getSrcFromCssValue(); this.$el.find('li[data-background]') .removeClass('active') .filter(function () { @@ -925,7 +939,22 @@ registry.background = SnippetOption.extend({ return (bgOption === '' && src === '' || bgOption !== '' && src.indexOf(bgOption) >= 0); }) .addClass('active'); - } + + this.$el.find('li[data-choose-image]').toggleClass('active', this.$target.hasClass('oe_custom_bg')); + }, + /** + * Sets the given value as custom background image. + * + * @private + * @param {string} value + */ + _setCustomBackground: function (value) { + this.__customImageSrc = this._getSrcFromCssValue(value); + this.background(false, this.__customImageSrc); + this.$target.addClass('oe_custom_bg'); + this._setActive(); + this.$target.trigger('snippet-option-change', [this]); + }, }); /** diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js index fa919a5a908..ef102bf081d 100644 --- a/addons/web_editor/static/src/js/editor/summernote.js +++ b/addons/web_editor/static/src/js/editor/summernote.js @@ -1761,6 +1761,7 @@ $.summernote.pluginEvents.outdent = function (event, editor, layoutInfo) { }; $.summernote.pluginEvents.formatBlock = function (event, editor, layoutInfo, sTagName) { + $.summernote.pluginEvents.applyFont(event, editor, layoutInfo, null, null, "Default"); var $editable = layoutInfo.editable(); $editable.data('NoteHistory').recordUndo($editable); event.preventDefault(); diff --git a/addons/web_editor/static/src/xml/editor.xml b/addons/web_editor/static/src/xml/editor.xml index ee3f0cd70e3..104c9b63049 100644 --- a/addons/web_editor/static/src/xml/editor.xml +++ b/addons/web_editor/static/src/xml/editor.xml @@ -62,12 +62,10 @@ </ul> </li> <li class="search"> - <form action="#"> - <div class="form-group"> - <input class="form-control" id="icon-search" type="search"/> - <span class="fa fa-search"/> - </div> - </form> + <div class="form-group"> + <input class="form-control" id="icon-search" type="search"/> + <span class="fa fa-search"/> + </div> </li> </ul> <!-- Tab panes --> |
