summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/static
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-06-10 10:42:28 +0200
committerChristophe Matthieu <chm@odoo.com>2015-07-10 17:00:15 +0200
commitfd5361c0f7116e951cf9e69e2d97a8ccb07ce1b6 (patch)
tree96d765ac0ddc3738e8b6ca40d7a27ddf84e334cc /addons/mass_mailing/static
parent2868a86401cf34ab28e036c3b359673c8efe324b (diff)
[IMP] mass_mailing: remove depends to website. Create a website_mass_mailing bridge to add subscribe snippet into website builder. Split website_links to have link_tracker to create short and trackable URLs, and website_links to have a website layout for link_tracker and add button to share page.
Diffstat (limited to 'addons/mass_mailing/static')
-rw-r--r--addons/mass_mailing/static/src/js/mass_mailing_editor.js15
-rw-r--r--addons/mass_mailing/static/src/js/website_mass_mailing.editor.js101
-rw-r--r--addons/mass_mailing/static/src/js/website_mass_mailing.js149
3 files changed, 9 insertions, 256 deletions
diff --git a/addons/mass_mailing/static/src/js/mass_mailing_editor.js b/addons/mass_mailing/static/src/js/mass_mailing_editor.js
index 9449af6445f..4974674ba3a 100644
--- a/addons/mass_mailing/static/src/js/mass_mailing_editor.js
+++ b/addons/mass_mailing/static/src/js/mass_mailing_editor.js
@@ -1,4 +1,4 @@
-odoo.define('website_mail.website_mail', function (require) {
+odoo.define('mass_mailing.editor', function (require) {
"use strict";
var Model = require('web.Model');
@@ -36,7 +36,7 @@ options.registry["width-x"] = options.Class.extend({
if ($handle.hasClass(handler)) { compass = handler; }
});
if(self.is_image){ compass = "image"; }
- self.BuildingBlock.editor_busy = true;
+ self.buildingBlock.editor_busy = true;
var $body = $(document.body);
@@ -63,7 +63,7 @@ options.registry["width-x"] = options.Class.extend({
var body_mouseup = function(){
$body.unbind('mousemove', body_mousemove);
$body.unbind('mouseup', body_mouseup);
- self.BuildingBlock.editor_busy = false;
+ self.buildingBlock.editor_busy = false;
self.$target.removeClass("resize_editor_busy");
};
$body.mousemove(body_mousemove);
@@ -78,7 +78,7 @@ options.registry["width-x"] = options.Class.extend({
var width = offset + target_width - event.pageX;
}
target.css("width", width + "px");
- self.BuildingBlock.cover_target(self.$overlay, self.$target);
+ self.buildingBlock.cover_target(self.$overlay, self.$target);
return;
},
get_int_width: function ($el) {
@@ -106,7 +106,7 @@ options.registry["width-x"] = options.Class.extend({
});
}
this._super($clone);
- this.BuildingBlock.cover_target(this.$overlay, this.$target);
+ this.buildingBlock.cover_target(this.$overlay, this.$target);
},
on_remove: function () {
var remove_index = $(this.$target).index();
@@ -118,7 +118,7 @@ options.registry["width-x"] = options.Class.extend({
});
}
this._super();
- this.BuildingBlock.cover_target(this.$overlay, this.$target);
+ this.buildingBlock.cover_target(this.$overlay, this.$target);
},
});
@@ -168,6 +168,9 @@ web_editor.Class.include({
$("#choose_template").children().toggleClass("hidden");
$("body").trigger("resize");
$(window.top).trigger('resize');
+ setTimeout(function () {
+ $(".note-popover").toggleClass("hidden", $("#templates").is(":visible"));
+ },0);
},
on_set_snippet_template: function (event) {
var $editable = $("#editable_area");
diff --git a/addons/mass_mailing/static/src/js/website_mass_mailing.editor.js b/addons/mass_mailing/static/src/js/website_mass_mailing.editor.js
deleted file mode 100644
index eced083d6d0..00000000000
--- a/addons/mass_mailing/static/src/js/website_mass_mailing.editor.js
+++ /dev/null
@@ -1,101 +0,0 @@
-odoo.define('website_mass_mailing.editor', function (require) {
-'use strict';
-
-var Model = require('web.Model');
-var ajax = require('web.ajax');
-var core = require('web.core');
-var base = require('web_editor.base');
-var web_editor = require('web_editor.editor');
-var options = require('web_editor.snippets.options');
-var snippet_editor = require('web_editor.snippet.editor');
-var website = require('website.website');
-var _t = core._t;
-
-
-var mass_mailing_common = options.Class.extend({
- popup_template_id: "editor_new_mailing_list_subscribe_button",
- popup_title: _t("Add a Newsletter Subscribe Button"),
- select_mailing_list: function (type, value) {
- var self = this;
- if (type !== "click") return;
- return website.prompt({
- 'id': this.popup_template_id,
- 'window_title': this.popup_title,
- 'select': _t("Newsletter"),
- 'init': function (field) {
- return new Model('mail.mass_mailing.list').call('name_search', ['', []], { context: base.get_context() });
- },
- }).then(function (mailing_list_id) {
- self.$target.attr("data-list-id", mailing_list_id);
- });
- },
- drop_and_build_snippet: function() {
- var self = this;
- this._super();
- this.select_mailing_list('click').fail(function () {
- self.editor.on_remove($.Event( "click" ));
- });
- },
-});
-
-options.registry.mailing_list_subscribe = mass_mailing_common.extend({
- clean_for_save: function () {
- this.$target.addClass("hidden");
- },
-});
-
-options.registry.newsletter_popup = mass_mailing_common.extend({
- popup_template_id: "editor_new_mailing_list_subscribe_popup",
- popup_title: _t("Add a Newsletter Subscribe Popup"),
- select_mailing_list: function (type, value) {
- return this._super(type, value).then(function (mailing_list_id) {
- ajax.jsonRpc('/web/dataset/call', 'call', {
- model: 'mail.mass_mailing.list',
- method: 'read',
- args: [[parseInt(mailing_list_id)], ['popup_content'], base.get_context()],
- }).then(function (data) {
- self.$target.find(".o_popup_content_dev").empty();
- if (data && data[0].popup_content) {
- $(data[0].popup_content).appendTo(self.$target.find(".o_popup_content_dev"));
- }
- });
- });
- },
-});
-
-web_editor.Class.include({
- edit: function () {
- this._super();
- $('body').on('click','#edit_dialog',_.bind(this.edit_dialog, this.rte.editor));
- },
- save : function() {
- var $target = $('#wrapwrap').find('#o_newsletter_popup');
- if ($target && $target.length) {
- $target.modal('hide');
- $target.css("display", "none");
- $('.o_popup_bounce_small').show();
- if (!$target.find('.o_popup_content_dev').length) {
- $target.find('.o_popup_modal_body').prepend($('<div class="o_popup_content_dev" data-oe-placeholder="' + _t("Type Here ...") + '"></div>'));
- }
- var content = $('#wrapwrap .o_popup_content_dev').html();
- var newsletter_id = $target.parent().attr('data-list-id');
- ajax.jsonRpc('/web/dataset/call', 'call', {
- model: 'mail.mass_mailing.list',
- method: 'write',
- args: [parseInt(newsletter_id),
- {'popup_content':content},
- base.get_context()],
- });
- }
- return this._super();
- },
- edit_dialog : function() {
- $('#wrapwrap').find('#o_newsletter_popup').modal('show');
- $('.o_popup_bounce_small').hide();
- $('.modal-backdrop').css("z-index", "0");
- },
-});
-
-});
-
-
diff --git a/addons/mass_mailing/static/src/js/website_mass_mailing.js b/addons/mass_mailing/static/src/js/website_mass_mailing.js
deleted file mode 100644
index 2d0760a202a..00000000000
--- a/addons/mass_mailing/static/src/js/website_mass_mailing.js
+++ /dev/null
@@ -1,149 +0,0 @@
-odoo.define('mass_mailing.website_integration', function (require) {
-"use strict";
-
-var ajax = require('web.ajax');
-var utils = require('web.utils');
-var animation = require('web_editor.snippets.animation');
-var website = require('website.website');
-
-
-animation.registry.subscribe = animation.Class.extend({
- selector: ".js_subscribe",
- start: function (editable_mode) {
- var self = this;
-
- // set value and display button
- self.$target.find("input").removeClass("hidden");
- ajax.jsonRpc('/website_mass_mailing/is_subscriber', 'call', {
- list_id: this.$target.data('list-id'),
- }).always(function (data) {
- self.$target.find('input.js_subscribe_email')
- .val(data.email ? data.email : "")
- .attr("disabled", data.is_subscriber && data.email.length ? "disabled" : false);
- self.$target.attr("data-subscribe", data.is_subscriber ? 'on' : 'off');
- self.$target.find('a.js_subscribe_btn')
- .attr("disabled", data.is_subscriber && data.email.length ? "disabled" : false);
- self.$target.removeClass("hidden");
- self.$target.find('.js_subscribe_btn').toggleClass('hidden', !!data.is_subscriber);
- self.$target.find('.js_subscribed_btn').toggleClass('hidden', !data.is_subscriber);
- });
-
- // not if editable mode to allow designer to edit alert field
- if (!editable_mode) {
- $('.js_subscribe > .alert').addClass("hidden");
- $('.js_subscribe > .input-group-btn.hidden').removeClass("hidden");
- this.$target.find('.js_subscribe_btn').on('click', function (event) {
- event.preventDefault();
- self.on_click();
- });
- }
- },
- on_click: function () {
- var self = this;
- var $email = this.$target.find(".js_subscribe_email:visible");
-
- if ($email.length && !$email.val().match(/.+@.+/)) {
- this.$target.addClass('has-error');
- return false;
- }
- this.$target.removeClass('has-error');
-
- ajax.jsonRpc('/website_mass_mailing/subscribe', 'call', {
- 'list_id': this.$target.data('list-id'),
- 'email': $email.length ? $email.val() : false,
- }).then(function (subscribe) {
- self.$target.find(".js_subscribe_email, .input-group-btn").addClass("hidden");
- self.$target.find(".alert").removeClass("hidden");
- self.$target.find('input.js_subscribe_email').attr("disabled", subscribe ? "disabled" : false);
- self.$target.attr("data-subscribe", subscribe ? 'on' : 'off');
- });
- },
-});
-
-animation.registry.newsletter_popup = animation.Class.extend({
- selector: ".o_newsletter_popup",
- start: function (editable_mode) {
- var self = this;
- var popupcontent = self.$target.find(".o_popup_content_dev").empty();
-
- ajax.jsonRpc('/website_mass_mailing/get_content', 'call', {
- newsletter_id: self.$target.data('list-id')
- }).then(function (data) {
- if (data.content) {
- $('<div></div>').append(data.content).appendTo(popupcontent);
- }
- self.$target.find('input.popup_subscribe_email').val(data.email || "");
- self.redirect_url = data.redirect_url;
- if (!editable_mode && !data.is_subscriber) {
- $(document).on('mouseleave', _.bind(self.show_banner, self));
-
- self.$target.find('.popup_subscribe_btn').on('click', function (event) {
- event.preventDefault();
- self.on_click_subscribe();
- });
- } else { $(document).off('mouseleave'); }
- });
- },
- on_click_subscribe: function () {
- var self = this;
- var $email = self.$target.find(".popup_subscribe_email:visible");
-
- if ($email.length && !$email.val().match(/.+@.+/)) {
- self.$target.addClass('has-error');
- return false;
- }
- self.$target.removeClass('has-error');
-
- ajax.jsonRpc('/website_mass_mailing/subscribe', 'call', {
- 'list_id': self.$target.data('list-id'),
- 'email': $email.length ? $email.val() : false
- }).then(function (subscribe) {
- self.$target.find('#o_newsletter_popup').modal('hide');
- $(document).off('mouseleave');
- if (self.redirect_url) {
- if (_.contains(self.redirect_url.split('/'), window.location.host) || self.redirect_url.indexOf('/')== 0) {
- window.location.href = self.redirect_url;
- } else { window.open(self.redirect_url, '_blank'); }
- }
- });
- },
- show_banner: function() {
- var self = this;
- if (!utils.get_cookie("newsletter-popup-"+ self.$target.data('list-id')) && self.$target) {
- $('#o_newsletter_popup:first').modal('show').css({
- 'margin-top': '70px',
- 'position': 'fixed'
- });
- document.cookie = "newsletter-popup-"+ self.$target.data('list-id') +"=" + true + ";path=/";
- }
- }
-});
-
-website.if_dom_contains('div.o_unsubscribe_form', function() {
- $('#unsubscribe_form').on('submit', function(e) {
- e.preventDefault();
-
- var email = $("input[name='email']").val();
- var mailing_id = parseInt($("input[name='mailing_id']").val());
-
- var checked_ids = [];
- $("input[type='checkbox']:checked").each(function(i){
- checked_ids[i] = parseInt($(this).val());
- });
-
- var unchecked_ids = [];
- $("input[type='checkbox']:not(:checked)").each(function(i){
- unchecked_ids[i] = parseInt($(this).val());
- });
-
- ajax.jsonRpc('/mail/mailing/unsubscribe', 'call', {'opt_in_ids': checked_ids, 'opt_out_ids': unchecked_ids, 'email': email, 'mailing_id': mailing_id})
- .then(function(result) {
- $('.alert-info').html('Your changes has been saved.').removeClass('alert-info').addClass('alert-success');
- })
- .fail(function() {
- $('.alert-info').html('You changes has not been saved, try again later.').removeClass('alert-info').addClass('alert-warning');
- });
- });
-});
-
-});