summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-02-11 14:05:25 +0100
committerChristophe Matthieu <chm@odoo.com>2015-02-12 11:56:15 +0100
commit95fe1b168708fc40bebc7716a2c8a1ffeac71b10 (patch)
tree57610d03c32d549bac4f755bd6f086e17763862f
parent70dd3607ab697354803f9194a5e143705b66beba (diff)
[FIX] website_blog: clone the data-chatter-id attributes when keypress enter and create new p; Include js into if_dom_contains to launch code only on website_blog page
-rw-r--r--addons/website_blog/static/src/js/website_blog.editor.js70
1 files changed, 44 insertions, 26 deletions
diff --git a/addons/website_blog/static/src/js/website_blog.editor.js b/addons/website_blog/static/src/js/website_blog.editor.js
index 4cdb2f8b18d..b173a7fa35a 100644
--- a/addons/website_blog/static/src/js/website_blog.editor.js
+++ b/addons/website_blog/static/src/js/website_blog.editor.js
@@ -19,7 +19,9 @@
});
},
});
- if ($('.website_blog').length) {
+
+ openerp.website.if_dom_contains('.website_blog', function() {
+
website.EditorBar.include({
edit: function () {
var self = this;
@@ -38,7 +40,6 @@
return res;
},
});
-
website.snippet.options.many2one.include({
select_record: function (li) {
var self = this;
@@ -55,30 +56,47 @@
}
}
});
- }
- website.snippet.options.website_blog = website.snippet.Option.extend({
- start : function(type, value, $li) {
- this._super();
- this.src = this.$target.css("background-image").replace(/url\(|\)|"|'/g,'').replace(/.*none$/,'');
- this.$image = $('<image src="'+this.src+'">');
- },
- clear : function(type, value, $li) {
- if (type !== 'click') return;
- this.src = null;
- this.$target.css({"background-image": '', 'min-height': $(window).height()});
- this.$image.removeAttr("src");
- },
- change : function(type, value, $li) {
- if (type !== 'click') return;
- var self = this;
- var editor = new website.editor.MediaDialog(this.$image, this.$image[0], {only_images: true});
- editor.appendTo('body');
- editor.on('saved', self, function (event, img) {
- var url = self.$image.attr('src');
- self.$target.css({"background-image": url ? 'url(' + url + ')' : "", 'min-height': $(window).height()});
- });
- },
+ website.snippet.options.website_blog = website.snippet.Option.extend({
+ start : function(type, value, $li) {
+ this._super();
+ this.src = this.$target.css("background-image").replace(/url\(|\)|"|'/g,'').replace(/.*none$/,'');
+ this.$image = $('<image src="'+this.src+'">');
+ },
+ clear : function(type, value, $li) {
+ if (type !== 'click') return;
+ this.src = null;
+ this.$target.css({"background-image": '', 'min-height': $(window).height()});
+ this.$image.removeAttr("src");
+ },
+ change : function(type, value, $li) {
+ if (type !== 'click') return;
+ var self = this;
+ var editor = new website.editor.MediaDialog(this.$image, this.$image[0], {only_images: true});
+ editor.appendTo('body');
+ editor.on('saved', self, function (event, img) {
+ var url = self.$image.attr('src');
+ self.$target.css({"background-image": url ? 'url(' + url + ')' : "", 'min-height': $(window).height()});
+ });
+ },
+ });
+
+ openerp.define.active();
+ define(['summernote/summernote'], function () {
+ var enter = $.summernote.pluginEvents.enter;
+ $.summernote.pluginEvents.enter = function (event, editor, layoutInfo) {
+ enter.call(this, event, editor, layoutInfo);
+
+ var r = $.summernote.core.range.create();
+ var node = $.summernote.core.dom.node(r.sc);
+ var $nodes = $(node).data('chatter-id') && $("p[data-chatter-id='"+$(node).data('chatter-id')+"']", layoutInfo.editable()) || $();
+ if($nodes.length > 1) {
+ $nodes.last().removeAttr('data-chatter-id');
+ }
+ };
+ });
+ openerp.define.desactive();
+
});
-})();
+})(); \ No newline at end of file