[FIX] website_blog: display cover and cover options
This commit is contained in:
@@ -47,14 +47,14 @@ odoo.define('website_blog.editor', function (require) {
|
||||
|
||||
rte.Class.include({
|
||||
saveElement: function ($el, context) {
|
||||
if ($el.is('#js_blogcover')) {
|
||||
if ($el.is('.website_blog #title')) {
|
||||
return ajax.jsonRpc("/blog/post_change_background", 'call', {
|
||||
'post_id' : +$('#blog_post_name').data('oe-id'),
|
||||
'post_id' : +$el.find('#blog_post_name').data('oe-id'),
|
||||
'cover_properties' : {
|
||||
"background-image": $el.css("background-image").replace(/"/g, ''),
|
||||
"background-color": $el.attr("class"),
|
||||
"opacity": $el.css("opacity"),
|
||||
"resize_class": $('#title').attr('class'),
|
||||
"background-image": $el.find('#js_blogcover').css("background-image").replace(/"/g, ''),
|
||||
"background-color": $el.find('#js_blogcover').attr("class"),
|
||||
"opacity": $el.find('#js_blogcover').css("opacity"),
|
||||
"resize_class": $el.attr('class'),
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -81,16 +81,18 @@ odoo.define('website_blog.editor', function (require) {
|
||||
});
|
||||
|
||||
options.registry.website_blog = options.Class.extend({
|
||||
start : function(type, value, $li) {
|
||||
this._super();
|
||||
start : function() {
|
||||
this.$cover = this.$target.find('#js_blogcover');
|
||||
this.src = this.$target.css("background-image").replace(/url\(|\)|"|'/g,'').replace(/.*none$/,'');
|
||||
this.$image = $('<image src="'+this.src+'">');
|
||||
this._super();
|
||||
},
|
||||
clear : function(type, value, $li) {
|
||||
if (type !== 'click') return;
|
||||
this.src = null;
|
||||
this.$target.css({"background-image": '', 'min-height': $(window).height()});
|
||||
this.$cover.css({"background-image": '', 'min-height': ''});
|
||||
this.$image.removeAttr("src");
|
||||
this.$target.removeClass('cover cover_full');
|
||||
},
|
||||
change : function(type, value, $li) {
|
||||
if (type !== 'click') return;
|
||||
@@ -99,11 +101,32 @@ odoo.define('website_blog.editor', function (require) {
|
||||
editor.appendTo('body');
|
||||
editor.on('saved', self, function (event, img) {
|
||||
var url = self.$image.attr('src');
|
||||
self.$target.find('#js_blogcover').css({"background-image": url ? 'url(' + url + ')' : "", 'min-height': $(window).height()-$('#js_blogcover').offset().top});
|
||||
self.$target.find('#js_blogcover').addClass('o_dirty');
|
||||
self.buildingBlock.parent.rte_changed();
|
||||
self.$cover.css({"background-image": url ? 'url(' + url + ')' : "", 'min-height': $(window).height()-this.$cover.offset().top});
|
||||
self.$target.addClass('o_dirty cover cover_full');
|
||||
self.set_active();
|
||||
});
|
||||
},
|
||||
cover_class : function(type, value, $li) {
|
||||
this.$target.attr("class", (type === 'over' || type === 'click') ? value : this.class);
|
||||
this.$target.addClass('o_dirty');
|
||||
},
|
||||
opacity : function(type, value, $li) {
|
||||
this.$cover.css("opacity", (type === 'over' || type === 'click') ? value : this.value);
|
||||
this.$target.addClass('o_dirty');
|
||||
},
|
||||
bgcolor : function(type, value, $li) {
|
||||
this.$cover.attr("class", (type === 'over' || type === 'click') ? value : this.background);
|
||||
this.$target.addClass('o_dirty');
|
||||
},
|
||||
set_active: function(){
|
||||
this._super();
|
||||
this.background = this.$cover.attr("class");
|
||||
this.class = this.$target.attr('class');
|
||||
this.value = this.$cover.css('opacity');
|
||||
this.$el.parent().find('.snippet-option-website_blog:not(li[data-change])').toggleClass("hidden", !this.$target.hasClass("cover"));
|
||||
this.$el.find('li[data-bgcolor], li[data-opacity], li[data-cover_class]').removeClass("active");
|
||||
this.$el.find('[data-bgcolor="' + this.background + '"], [data-opacity="' + parseFloat(this.value).toFixed(1) + '"], [data-cover_class*="' + ((this.class||'').indexOf('cover_full') === -1 ? 'container' : 'cover_full') + '"]').addClass("active");
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user