diff --git a/addons/website_mail/static/src/js/website_email_designer.js b/addons/website_mail/static/src/js/website_email_designer.js index 1ea39ae657c..264fe33288e 100644 --- a/addons/website_mail/static/src/js/website_email_designer.js +++ b/addons/website_mail/static/src/js/website_email_designer.js @@ -1,26 +1,25 @@ -(function () { +$(function () { 'use strict'; - var website = openerp.website; - - website.snippet.BuildingBlock.include({ - _get_snippet_url: function () { - return '/website_mail/snippets'; - } - }); - - // Copy the template to the body of the email - $(document).ready(function () { - $('.js_template_set').click(function(ev) { - $('#email_designer').show(); - $('#email_template').hide(); - $(".js_content", $(this).parent()).children().clone().appendTo('#email_body'); - $(".js_content", $(this).parent()).children().clone().appendTo('#email_body_html'); - $('#email_body').addClass('oe_dirty'); - $('#email_body_html').addClass('oe_dirty'); - - openerp.website.editor_bar.edit(); - event.preventDefault(); + if ($("#email_designer").length) { + openerp.website.snippet.BuildingBlock.include({ + _get_snippet_url: function () { + return '/website_mail/snippets'; + } }); - }); -})(); + // Copy the template to the body of the email + $(document).ready(function () { + $('.js_template_set').click(function(ev) { + $('#email_designer').show(); + $('#email_template').hide(); + $(".js_content", $(this).parent()).children().clone().appendTo('#email_body'); + $(".js_content", $(this).parent()).children().clone().appendTo('#email_body_html'); + $('#email_body').addClass('oe_dirty'); + $('#email_body_html').addClass('oe_dirty'); + + openerp.website.editor_bar.edit(); + event.preventDefault(); + }); + }); + } +}); diff --git a/addons/website_mail/views/snippets.xml b/addons/website_mail/views/snippets.xml index 12892f50434..c8b51930e42 100644 --- a/addons/website_mail/views/snippets.xml +++ b/addons/website_mail/views/snippets.xml @@ -10,7 +10,7 @@