[FIX] website_blog: fix broken change cover wizard
authorMartin Trigaux <mat@openerp.com>
Tue, 13 May 2014 10:31:57 +0000 (12:31 +0200)
committerMartin Trigaux <mat@openerp.com>
Tue, 13 May 2014 10:31:57 +0000 (12:31 +0200)
addons/website_blog/static/src/js/website_blog.editor.js
addons/website_blog/views/website_blog_templates.xml

index 103b2be..4a18b5e 100644 (file)
             },
         }),
         edit: function () {
+            var self = this;
             $('.popover').remove();
             this._super();
             var vHeight = $(window).height();
-            $('body').on('click','#change_cover',_.bind(this.change_bg,{},vHeight));
-            $('body').on('click', '#clear_cover',_.bind(this.clean_bg,{},vHeight));
+            $('body').on('click','#change_cover',_.bind(this.change_bg, self.rte.editor, vHeight));
+            $('body').on('click', '#clear_cover',_.bind(this.clean_bg, self.rte.editor, vHeight));
         },
         save : function() {
             var res = this._super();
         },
         change_bg : function(vHeight) {
             var self  = this;
-            var editor  = new  website.editor.ImageDialog();
-            editor.on('start', self, function (o) {
-                o.url = $('.js_fullheight').length ? $('.js_fullheight').css('background-image').replace(/url\(|\)|"|'/g,'') : ''; 
-            });
-            editor.on('save', self, function (o) {
-                $('.js_fullheight').css({"background-image": o.url && o.url !== "" ? 'url(' + o.url + ')' : "", 'min-height': vHeight})
+            var element = new CKEDITOR.dom.element(self.element.find('.cover-storage').$[0]);
+            var editor  = new website.editor.MediaDialog(self, element);
+            $(document.body).on('media-saved', self, function (o) {
+                var url = $('.cover-storage').attr('src');
+                $('.js_fullheight').css({"background-image": !_.isUndefined(url) ? 'url(' + url + ')' : "", 'min-height': vHeight});
+                $('.cover-storage').remove();
             });
             editor.appendTo('body');
         },
index 7d7bdbf..20d0428 100644 (file)
                     <span class="fa fa-times"/>
                 </a>
             </div>
+            <div class="cover-storage oe_hidden"></div> 
             <t t-call="website.publish_management">
                 <t t-set="object" t-value="blog_post"/>
                 <t t-set="publish_edit" t-value="True"/>