diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-06-18 12:03:37 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-07-10 17:00:12 +0200 |
| commit | 05daa152dc19b11a3c9094fb48978d1ba27559b0 (patch) | |
| tree | 5772d02c0e2972388392199721a03cd6079a15a6 /addons/website_mail/static/src | |
| parent | 9665882fbadafbaed0fb56f218c9c74696f71815 (diff) | |
[IMP] mass_mailing: move code from website_mail to mass_mailing and use web_editor
Diffstat (limited to 'addons/website_mail/static/src')
36 files changed, 0 insertions, 693 deletions
diff --git a/addons/website_mail/static/src/css/snippets.css b/addons/website_mail/static/src/css/snippets.css deleted file mode 100644 index c6e3ce1716f..00000000000 --- a/addons/website_mail/static/src/css/snippets.css +++ /dev/null @@ -1,85 +0,0 @@ -/* ---- thumbnail ---- */ -.oe_snippet.o_mail_block_header_center_logo .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_header_center_logo.png"); -} -.oe_snippet.o_mail_block_header_center_text .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_header_center_text.png"); -} -.oe_snippet.o_mail_block_header_social .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_header_social.png"); -} -.oe_snippet.o_mail_block_header_text_social .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_header_text_social.png"); -} -.oe_snippet.o_mail_block_text_image .oe_snippet_thumbnail_img { - background-image: url("/website/static/src/img/blocks/block_text_image.png"); -} -.oe_snippet.o_mail_block_footer_copyright .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_footer_copyright.png"); -} -.oe_snippet.o_mail_block_footer_social .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_footer_social.png"); -} -.oe_snippet.o_mail_block_footer_text .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_footer_text.png"); -} -.oe_snippet.o_mail_block_footer_seprator .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_footer_seprator.png"); -} -.oe_snippet.o_mail_block_footer_tag_line .oe_snippet_thumbnail_img { - background-image: url("/website_mail/static/src/img/blocks/block_footer_tag_line.png"); -} -.oe_snippet.o_mail_block_two_cols .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_two-column-img.png"); -} -.oe_snippet.o_mail_block_two_cols_content .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_two-column.png"); -} -.oe_snippet.o_mail_block_title_text .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_title_text.png") -} -.oe_snippet.o_mail_block_title_sub .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_title.png") -} -.oe_snippet.o_mail_block_image_text .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_image-text.png") -} -.oe_snippet.o_mail_block_text_button .oe_snippet_thumbnail_img{ - background-image: url("/website/static/src/img/blocks/block_jumbotron.png") -} -.oe_snippet.o_mail_block_table_content .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_table.png") -} -.oe_snippet.o_mail_block_discount1 .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_discount.png") -} -.oe_snippet.o_mail_block_discount2 .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_discount2.png") -} -.oe_snippet.o_mail_block_event .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_event.png") -} -.oe_snippet.o_mail_block_image .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_image_text.png") -} -.oe_snippet.o_mail_block_profile .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_user.png") -} -.oe_snippet.o_mail_block_four_cols .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_four_columns.png") -} -.oe_snippet.o_mail_block_button .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_button.png") -} -.oe_snippet.o_mail_block_simple_text .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_simple_text.png") -} -.oe_snippet.o_mail_block_three_cols .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_three_columns.png") -} -.oe_snippet.o_mail_block_text_on_img .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_text_on_image.png") -} -.oe_snippet.o_mail_block_steps .oe_snippet_thumbnail_img{ - background-image: url("/website_mail/static/src/img/blocks/block_steps.png") -} diff --git a/addons/website_mail/static/src/css/website_mail_iframe.css b/addons/website_mail/static/src/css/website_mail_iframe.css deleted file mode 100644 index 6e8d6541c95..00000000000 --- a/addons/website_mail/static/src/css/website_mail_iframe.css +++ /dev/null @@ -1,164 +0,0 @@ -body { - background-color: #fff; -} -p { - margin: initial; -} -a { - color: inherit; -} -a:hover { - color: inherit; -} -#wrapwrap .o_editable { - font: initial; - line-height: initial; - color: initial; -} -#oe_snippets ~ #wrapwrap .o_editable { - margin-bottom: 100px; -} - -#wrapwrap > main > div:first-child { - max-width: 600px; - margin-left: auto; - margin-right: auto; - position: relative; -} - -.editor_enable #wrapwrap > main > div:first-child:before, #wrapwrap > main > div:first-child:after { - content: " "; - display: block; - height: 100%; - position: fixed; - top: -4px; - width: 0; - overflow: hidden; -} -.editor_enable #wrapwrap > main > div:first-child:before { - border-right: 1px dashed #ccc; - margin-left: -5px; -} -.editor_enable #wrapwrap > main > div:first-child:after { - border-left: 1px dashed #ccc; - margin-left: 605px; -} - -.note-color-palette .colorpicker { - display: none; -} - -/***************************/ - -#email_theme_list, #email_template_list { - clear: both; - text-align: center; -} - -#email_theme_list > div, #email_template_list > div { - width: 200px; - display: inline-block; - position: relative; -} - -.theme_thumbnail{ - position:inherit; - margin-top:15px; -} -.theme_thumbnail div{ - -webkit-transition: opacity 0.5s; - transition: opacity 0.5s; -} -.theme_thumbnail img.img{ - height: 180px; - width: auto; -} - -.modal-body .theme_thumbnail img.img{ - height: 100px; -} - -.theme_thumbnail div.overlay{ - z-index: 2; - max-height: 135px; - position:absolute; - padding:25% 0; - opacity: 0; - width: 100%; -} -.theme_thumbnail div.overlay p{ - color:#616161; - font-weight:bold; - text-transform: capitalize; -} -.theme_thumbnail:hover>img.img{ - opacity:0.3; -} -.theme_thumbnail:hover>div.overlay{ - opacity: 1; -} - -.email_head { - border-width: 0px 0px 2px 0px; -} -.email_head div{ - font-size:14px; -} -.email_head .popover-title{ - font-weight:bold; -} - -.template_name{ - width: 160px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.email_template *{ - -webkit-transition: opacity 0.5s; - transition: opacity 0.5s; -} -.email_template:hover .template_thumbnail{ - opacity:0.3; -} -.email_template:hover .template_options{ - opacity:1; -} - -/***************************/ - -#templates{ - width: 98%; -} -#choose_template{ - display: none; - margin: 5px; - padding: 1px 5px; - position: fixed; - top: 0; - right: 50px; - z-index: 2000; -} -#templates .template_preview_border{ - overflow: hidden !important; - border: 2px solid grey; - height: 300px; -} -#email_template_list > div{ - overflow: hidden; - height: 300px; -} -#email_template_list .theme_thumbnail div.overlay{ - max-height: 300px; -} -#templates .template_preview{ - -webkit-transform: scale(.33); - -ms-transform: scale(.33); - transform: scale(.33); - -webkit-transform-origin: 0 0; - -ms-transform-origin: 0 0; - transform-origin: 0 0; -} -.theme_thumbnail:hover>.template_preview{ - opacity:0.3; -}
\ No newline at end of file diff --git a/addons/website_mail/static/src/img/blocks/block_button.png b/addons/website_mail/static/src/img/blocks/block_button.png Binary files differdeleted file mode 100644 index 3cc09522e05..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_button.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_discount.png b/addons/website_mail/static/src/img/blocks/block_discount.png Binary files differdeleted file mode 100644 index 2d50e0dc242..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_discount.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_discount2.png b/addons/website_mail/static/src/img/blocks/block_discount2.png Binary files differdeleted file mode 100644 index eec00e52cbc..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_discount2.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_event.png b/addons/website_mail/static/src/img/blocks/block_event.png Binary files differdeleted file mode 100644 index 251d52ddcea..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_event.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_footer_copyright.png b/addons/website_mail/static/src/img/blocks/block_footer_copyright.png Binary files differdeleted file mode 100644 index 3b57fa068be..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_footer_copyright.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_footer_seprator.png b/addons/website_mail/static/src/img/blocks/block_footer_seprator.png Binary files differdeleted file mode 100644 index ea87ad3f176..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_footer_seprator.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_footer_social.png b/addons/website_mail/static/src/img/blocks/block_footer_social.png Binary files differdeleted file mode 100644 index b1ea137b2ae..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_footer_social.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_footer_tag_line.png b/addons/website_mail/static/src/img/blocks/block_footer_tag_line.png Binary files differdeleted file mode 100644 index cf12cc97358..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_footer_tag_line.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_footer_text.png b/addons/website_mail/static/src/img/blocks/block_footer_text.png Binary files differdeleted file mode 100644 index 7f3553cd32d..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_footer_text.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_four_columns.png b/addons/website_mail/static/src/img/blocks/block_four_columns.png Binary files differdeleted file mode 100644 index 6087b078261..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_four_columns.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_header_center_logo.png b/addons/website_mail/static/src/img/blocks/block_header_center_logo.png Binary files differdeleted file mode 100644 index f1c11cfcc3a..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_header_center_logo.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_header_center_text.png b/addons/website_mail/static/src/img/blocks/block_header_center_text.png Binary files differdeleted file mode 100644 index bf61eb36b0b..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_header_center_text.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_header_social.png b/addons/website_mail/static/src/img/blocks/block_header_social.png Binary files differdeleted file mode 100644 index cdd13628997..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_header_social.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_header_text_social.png b/addons/website_mail/static/src/img/blocks/block_header_text_social.png Binary files differdeleted file mode 100644 index c72dc2c0439..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_header_text_social.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_image-text.png b/addons/website_mail/static/src/img/blocks/block_image-text.png Binary files differdeleted file mode 100644 index 8611573f98b..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_image-text.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_image_text.png b/addons/website_mail/static/src/img/blocks/block_image_text.png Binary files differdeleted file mode 100644 index 6a2bcaf6b17..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_image_text.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_simple_text.png b/addons/website_mail/static/src/img/blocks/block_simple_text.png Binary files differdeleted file mode 100644 index 7099744d742..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_simple_text.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_steps.png b/addons/website_mail/static/src/img/blocks/block_steps.png Binary files differdeleted file mode 100644 index 2882bac0f59..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_steps.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_table.png b/addons/website_mail/static/src/img/blocks/block_table.png Binary files differdeleted file mode 100644 index e7f51cbe943..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_table.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_text_on_image.png b/addons/website_mail/static/src/img/blocks/block_text_on_image.png Binary files differdeleted file mode 100644 index d1e6cc1c722..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_text_on_image.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_three_columns.png b/addons/website_mail/static/src/img/blocks/block_three_columns.png Binary files differdeleted file mode 100644 index dd50e0336d3..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_three_columns.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_title.png b/addons/website_mail/static/src/img/blocks/block_title.png Binary files differdeleted file mode 100644 index 8382c843a4b..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_title.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_title_text.png b/addons/website_mail/static/src/img/blocks/block_title_text.png Binary files differdeleted file mode 100644 index cf785444dad..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_title_text.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_two-column-img.png b/addons/website_mail/static/src/img/blocks/block_two-column-img.png Binary files differdeleted file mode 100644 index 3506415d8c2..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_two-column-img.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_two-column.png b/addons/website_mail/static/src/img/blocks/block_two-column.png Binary files differdeleted file mode 100644 index 455ba378f53..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_two-column.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/blocks/block_user.png b/addons/website_mail/static/src/img/blocks/block_user.png Binary files differdeleted file mode 100644 index d822f6f989e..00000000000 --- a/addons/website_mail/static/src/img/blocks/block_user.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/theme_imgs/airmail.png b/addons/website_mail/static/src/img/theme_imgs/airmail.png Binary files differdeleted file mode 100644 index 943d0e4b5ce..00000000000 --- a/addons/website_mail/static/src/img/theme_imgs/airmail.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/theme_imgs/skyline_bg.gif b/addons/website_mail/static/src/img/theme_imgs/skyline_bg.gif Binary files differdeleted file mode 100644 index fa91caa4c72..00000000000 --- a/addons/website_mail/static/src/img/theme_imgs/skyline_bg.gif +++ /dev/null diff --git a/addons/website_mail/static/src/img/theme_imgs/social_facebook.png b/addons/website_mail/static/src/img/theme_imgs/social_facebook.png Binary files differdeleted file mode 100644 index 59eff64afb4..00000000000 --- a/addons/website_mail/static/src/img/theme_imgs/social_facebook.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/theme_imgs/social_googleplus.png b/addons/website_mail/static/src/img/theme_imgs/social_googleplus.png Binary files differdeleted file mode 100644 index 0364cb0b9bb..00000000000 --- a/addons/website_mail/static/src/img/theme_imgs/social_googleplus.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/theme_imgs/social_linkedin.png b/addons/website_mail/static/src/img/theme_imgs/social_linkedin.png Binary files differdeleted file mode 100644 index ff7309e3cf4..00000000000 --- a/addons/website_mail/static/src/img/theme_imgs/social_linkedin.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/theme_imgs/social_rss.png b/addons/website_mail/static/src/img/theme_imgs/social_rss.png Binary files differdeleted file mode 100644 index da352edcfb8..00000000000 --- a/addons/website_mail/static/src/img/theme_imgs/social_rss.png +++ /dev/null diff --git a/addons/website_mail/static/src/img/theme_imgs/social_twitter.png b/addons/website_mail/static/src/img/theme_imgs/social_twitter.png Binary files differdeleted file mode 100644 index 827c85801e6..00000000000 --- a/addons/website_mail/static/src/img/theme_imgs/social_twitter.png +++ /dev/null diff --git a/addons/website_mail/static/src/js/website_email_designer.js b/addons/website_mail/static/src/js/website_email_designer.js deleted file mode 100644 index beafd4a6b5e..00000000000 --- a/addons/website_mail/static/src/js/website_email_designer.js +++ /dev/null @@ -1,444 +0,0 @@ -odoo.define('website_mail.website_mail', function (require) { -"use strict"; - -var Model = require('web.Model'); -var editor = require('website.editor'); -var snippets_editor = require('website.snippets.editor'); - - -// Snippet option for resizing image and column width inline like excel -snippets_editor.options["width-x"] = snippets_editor.Option.extend({ - start: function () { - this.container_width = 600; - var parent = this.$target.closest('[data-max-width]'); - if( parent.length ){ - this.container_width = parseInt(parent.attr('data-max-width')); - } - var self = this; - var offset, sib_offset, target_width, sib_width; - this.is_image = false; - this._super(); - - this.$overlay.find(".oe_handle.e, .oe_handle.w").removeClass("readonly"); - if( this.$target.is('img')){ - this.$overlay.find(".oe_handle.w").addClass("readonly"); - this.$overlay.find(".oe_snippet_remove, .oe_snippet_move, .oe_snippet_clone").addClass("hidden"); - this.is_image=true; - } - - this.$overlay.find(".oe_handle").on('mousedown', function (event){ - event.preventDefault(); - var $handle = $(this); - var compass = false; - - _.each(['n', 's', 'e', 'w' ], function(handler) { - if ($handle.hasClass(handler)) { compass = handler; } - }); - if(self.is_image){ compass = "image"; } - self.BuildingBlock.editor_busy = true; - - var $body = $(document.body); - - var body_mousemove = function (event){ - event.preventDefault(); - offset = self.$target.offset().left; - target_width = self.get_max_width(self.$target); - if (compass === 'e' && self.$target.next().offset()) { - sib_width = self.get_max_width(self.$target.next()); - sib_offset = self.$target.next().offset().left; - self.change_width(event, self.$target, target_width, offset ,'plus'); - self.change_width(event, self.$target.next(), sib_width, sib_offset ,'minus'); - } - if (compass === 'w' && self.$target.prev().offset()) { - sib_width = self.get_max_width(self.$target.prev()); - sib_offset = self.$target.prev().offset().left; - self.change_width(event, self.$target, target_width, offset ,'minus'); - self.change_width(event, self.$target.prev(), sib_width, sib_offset, 'plus'); - } - if (compass === 'image'){ - self.change_width(event, self.$target, target_width, offset ,'plus'); - } - }; - var body_mouseup = function(){ - $body.unbind('mousemove', body_mousemove); - $body.unbind('mouseup', body_mouseup); - self.BuildingBlock.editor_busy = false; - self.$target.removeClass("resize_editor_busy"); - }; - $body.mousemove(body_mousemove); - $body.mouseup(body_mouseup); - }); - }, - change_width:function(event, target ,target_width, offset, type){ - var self = this; - if(type == 'plus'){ - var width = event.pageX-offset; - }else{ - var width = offset + target_width - event.pageX; - } - target.css("width", width + "px"); - self.BuildingBlock.cover_target(self.$overlay, self.$target); - return; - }, - get_int_width: function ($el) { - var el_width = $el.css('width'); - return parseInt(el_width); - }, - get_max_width: function ($el) { - var max_width = 0; - var self = this; - _.each($el.siblings(),function(sib){ - max_width += self.get_int_width($(sib)); - }); - return this.container_width - max_width; - }, - on_clone: function ($clone) { - var clone_index = $(this.$target).index(); - var $table = this.$target.parents('table[data-max-width]'); - if($table.length == 1){ - _.each($table.find('tbody>tr'),function(row){ - var clone_selector = 'td:eq(' + clone_index + ')'; - var $col_to_clone = $(row).find(clone_selector); - if($col_to_clone.length !== 0){ - $col_to_clone.after($col_to_clone.clone()); - } - }); - } - this._super($clone); - this.BuildingBlock.cover_target(this.$overlay, this.$target); - }, - on_remove: function () { - var remove_index = $(this.$target).index(); - var $table = this.$target.parents('table[data-max-width]'); - if($table.length == 1){ - _.each($table.find('tbody>tr'),function(row){ - var remove_selector = 'td:eq(' + remove_index + ')'; - $(row).find(remove_selector).remove(); - }); - } - this._super(); - this.BuildingBlock.cover_target(this.$overlay, this.$target); - }, -}); - - -var fn_popover_update = $.summernote.eventHandler.popover.update; -$.summernote.eventHandler.popover.update = function ($popover, oStyle, isAirMode) { - fn_popover_update.call(this, $popover, oStyle, isAirMode); - $("span.o_table_handler, div.note-table").remove(); -}; - -editor.EditorBar.include({ - start: function () { - var self = this; - if (location.search.indexOf("enable_editor") !== -1) { - this.on('rte:ready', this, function () { - $("#choose_template").off("click").on("click", _.bind(self.on_choose_template, self)); - $(".theme_thumbnail [data-snippet-theme]").off("click").on("click", _.bind(self.on_set_snippet_theme, self)); - $("#wrapwrap").on('click', function (event) { - if ($(event.target).is("#wrapwrap")) { - setTimeout(function () { - var node = $("#wrapwrap .o_editable:first *") - .filter(function () { return this.textContent.match(/\S|\u00A0/); }) - .add($("#wrapwrap .o_editable:first")) - .last()[0]; - $.summernote.core.range.create(node, $.summernote.core.dom.nodeLength(node)).select(); - },0); - } - }); - }); - this.on("snippets:ready", this, _.bind(self.display_theme_from_html, self)); - } - return this._super.apply(this, arguments); - }, - display_theme_from_html: function () { - var theme = $("#wrapwrap .o_editable:first [data-snippet-theme]").data("snippet-theme"); - if (theme) { - $("#choose_template").show(); - this.set_snippet_theme(theme); - } else { - $("#choose_template").hide(); - this.on_choose_template(); - } - var mailing_model = JSON.parse($.deparam(location.search).datarecord).mailing_model; - if (mailing_model) { - this.get_snippet_template( mailing_model ); - } - }, - - on_choose_template: function (event) { - if (event) { - $("#choose_template").show(); - } - var $editable = $("#wrapwrap .o_editable:first"); - $(".o_table_handler").remove(); - $editable.parent().add("#oe_snippets, #templates, .note-popover").toggleClass("hidden"); - $("#choose_template").children().toggleClass("hidden"); - $("body").trigger("resize"); - $(window.top).trigger('resize'); - }, - on_set_snippet_template: function (event) { - var $editable = $("#wrapwrap .o_editable:first"); - this.rte.historyRecordUndo($editable); - $editable.html( $(event.target).closest(".theme_thumbnail").find(".js_content").html() ); - $editable.parent().add("#oe_snippets, #templates, .note-popover").toggleClass("hidden"); - $("#choose_template").children().toggleClass("hidden"); - setTimeout(function () { - $("body").trigger("resize"); - $("body")[0].scrollTop = 0; - },0); - event.preventDefault(); - }, - on_set_snippet_theme: function (event) { - this.set_snippet_theme($(event.target).data("snippet-theme")); - this.on_choose_template(event); - event.preventDefault(); - }, - set_snippet_theme: function (theme) { - $("#o_left_bar .o_panel_body > div").addClass("hidden"); - $("#o_left_bar .o_panel_body > div."+theme).removeClass("hidden"); - }, - get_snippet_template: function (mailing_model) { - var self = this; - var domain = [['model', '=', mailing_model]]; - new Model('mail.template').call('search_read', [domain]).then(function (datas) { - var $template = $("#templates > div:last").addClass("hidden"); - var $tclone = $template.find("> div > div:first"); - $tclone.siblings().remove(); - _.each(datas, function (data) { - if (!data.body_html) { - return; - } - $template.removeClass("hidden"); - var $clone = $tclone.clone().removeClass("hidden"); - $clone.find("p:first").html(data.name); - $clone.find(".template_preview").html(data.body_html); - $tclone.after($clone); - }); - - $(".js_template_set").off("click").on("click", _.bind(self.on_set_snippet_template, self)); - }); - } -}); - -var cache = {}; -var rulesCache = []; -function getMatchedCSSRules(a) { - if(cache[a.tagName + "." +a.className]) { - return cache[a.tagName + "." +a.className]; - } - if (!rulesCache.length) { - var sheets = document.styleSheets; - for(var i = 0; i < sheets.length; i++) { - var rules = sheets[i].rules || sheets[i].cssRules; - if (rules) { - for(var r = 0; r < rules.length; r++) { - var selectorText = rules[r].selectorText; - if (selectorText && - rules[r].cssText && - selectorText.indexOf(".") !== -1 && - selectorText.indexOf(":hover") === -1 && - selectorText.indexOf(":before") === -1 && - selectorText.indexOf(":after") === -1 && - selectorText.indexOf(":active") === -1 && - selectorText.indexOf(":link") === -1 && - selectorText.indexOf("::") === -1) { - var st = selectorText.split(/\s*,\s*/); - for (var k=0; k<st.length; k++) { - rulesCache.push({ - 'selector': st[k], - 'style': rules[r].style, - 'point': st[k].split(/\s+/).length - }); - } - } - } - } - } - - rulesCache.sort(function (a,b) { - return a.point-b.point; - }); - } - - var css = []; - a.matches = a.matches || a.webkitMatchesSelector || a.mozMatchesSelector || a.msMatchesSelector || a.oMatchesSelector; - for(var r = 0; r < rulesCache.length; r++) { - if (a.matches(rulesCache[r].selector)) { - var style = rulesCache[r].style; - if (style.parentRule) { - var style_obj = {}; - for (var k=0, len=style.length; k<len; k++) { - style_obj[style[k]] = style[style[k]]; - } - rulesCache[r].style = style = style_obj; - } - css.push(style); - } - } - - var style = {}; - _.each(css, function (v,k) { - _.each(v, function (v,k) { - if (!style[k] || style[k].indexOf('important') === -1 || v.indexOf('important') !== -1) { - style[k] = v; - } - }); - }); - - return cache[a.tagName + "." +a.className] = style; -} - -$.fn.bindFirst = function(name, fn) { - this.bind(name, fn); - var handlers = $._data($(this).get(0), 'events')[name.split('.')[0]]; - var handler = handlers.pop(); - handlers.splice(0, 0, handler); -}; - -snippets_editor.BuildingBlock.include({ - start: function () { - var self = this; - this._super(); - setTimeout(function () { - self.img_to_font(); - self.style_to_class(); - }); - }, - - _get_snippet_url: function () { - return snippets_url; - }, - clean_for_save: function () { - this._super(); - this.class_to_style(); - this.font_to_img(); - var $editable = $("#wrapwrap .o_editable:first"); - var theme = ($("#o_left_bar .o_panel_body > div:not(.hidden)").attr("class") || "").replace(/^\s*|\s*o_mail_block[^\s]+\s*|\s*oe_snippet\s*|\s*ui-draggable\s*|\s*$/g, ''); - var $theme = $("#wrapwrap .o_editable:first [data-snippet-theme]").removeAttr("data-snippet-theme").removeData("snippet-theme"); - $editable.children().first().attr("data-snippet-theme", theme); - $editable.find(":hidden").remove(); - }, - // convert font awsome into image - font_to_img: function () { - $("#wrapwrap .fa").each(function () { - var $font = $(this); - var content; - _.find(editor.fontIcons, function (font) { - return _.find(editor.getCssSelectors(font.parser), function (css) { - if ($font.is(css[0].replace(/::?before$/, ''))) { - content = css[1].match(/content:\s*['"](.)['"]/)[1]; - return true; - } - }); - }); - if (content) { - var size = parseInt(parseFloat($font.css("font-size"))/parseFloat($font.parent().css("font-size")),10); - var src = _.str.sprintf('/website_mail/font_to_img/%s/%s/'+$font.width(), window.encodeURI(content), window.encodeURI($font.css("color"))); - var $img = $("<img/>").attr("src", src) - .attr("data-class", $font.attr("class")) - .attr("style", $font.attr("style")) - .css({"height": size+"em"}).css("font-size", ""); - $font.replaceWith($img); - } else { - $font.remove(); - } - }); - }, - // convert image into font awsome - img_to_font: function () { - $("#wrapwrap img[src*='/website_mail/font_to_img/']").each(function () { - var $img = $(this); - var $font = $("<span/>").attr("class", $img.data("class")).attr("style", $img.attr("style")).css("height", ""); - $img.replaceWith($font); - }); - }, - - class_to_style: function () { - var $editable = $("#wrapwrap .o_editable:first"); - var selector = _.map(rulesCache, function (a) { return a.selector;}).join(","); - $editable.find(selector).each(function () { - var $target = $(this); - var css = getMatchedCSSRules(this); - var style = $target.attr("style") || ""; - _.each(css, function (v,k) { - if (style.indexOf(k) === -1) { - style = k+":"+v+";"+style; - } - }); - $target.attr("style", style); - }); - }, - - style_to_class: function () { - var $editable = $("#wrapwrap .o_editable:first"); - getMatchedCSSRules($editable[0]); - var selector = _.map(rulesCache, function (a) { return a.selector;}).join(","); - var $c = $('<span/>').appendTo("body"); - $editable.find(selector).each(function () { - var $target = $(this); - var css = getMatchedCSSRules(this); - var style = ""; - _.each(css, function (v,k) { - if (style.indexOf(k) === -1) { - style = k+":"+v+";"+style; - } - }); - css = $c.attr("style", style).attr("style").split(/\s*;\s*/); - style = $target.attr("style") || ""; - _.each(css, function (v) { - style = style.replace(v, ''); - }); - $target.attr("style", style.replace(/;+(\s;)*/g, ';').replace(/^;/g, '')); - }); - $c.remove(); - } -}); - - -window.top.odoo[callback+"_set_value"] = function (value, fields_values, field_name) { - var $editable = $("#wrapwrap .o_editable:first"); - var editor_enable = $('body').hasClass('editor_enable'); - var _val = $editable.prop("innerHTML"); - value = value || ""; - - if(value !== _val) { - if (editor_enable) { - if (value !== fields_values[field_name]) { - editor.editor_bar.rte.historyRecordUndo($editable, true); - } - editor.editor_bar.snippets.make_active(false); - } - - if (value.indexOf('on_change_model_and_list') === -1) { - - $editable.html(value); - - if (editor_enable) { - editor.editor_bar.snippets.img_to_font(); - editor.editor_bar.snippets.style_to_class(); - if (fields_values.mailing_model) { - editor.editor_bar.display_theme_from_html(); - } - - if (value !== fields_values[field_name]) { - $editable.trigger("content_changed"); - } - } - } - } - - if (fields_values.mailing_model) { - editor.editor_bar.get_snippet_template(fields_values.mailing_model); - if (value.indexOf('on_change_model_and_list') !== -1) { - window.top.odoo[callback+"_downup"](_val); - } - } -}; - - -return { - getMatchedCSSRules: getMatchedCSSRules -}; - -}); |
