hunk.code_window:                             </group>
                           </div>
                           <notebook>
                               <page string="Popup Content">
                                   <field name="popup_content" options="{'editor_url': '/website_mass_mailing/field/popup_content'}"/>
                               </page>
                           </notebook>
                       </sheet>
  
hunk.labels: keep keep keep keep replace keep keep keep
hunk.after_edit:                                 <field name="popup_content" options="{'editor_url': '/website_mass_mailing/field/popup_content'}" widget="html_frame"/>
  
hunk.file_path: addons/mass_mailing/views/mass_mailing.xml
hunk.type: replace
file: (function() {
      "use strict";
  
      var website = openerp.website;
      var _t = openerp._t;
  
      website.EditorBarContent.include({
          new_product: function() {
              website.prompt({
                  id: "editor_new_product",
                  window_title: _t("New Product"),
                  input: "Product Name",
              }).then(function (name) {
                  website.form('/shop/add_product', 'POST', {
                      name: name
                  });
              });
          },
      });
  
      website.snippet.options.website_sale = website.snippet.Option.extend({
          start: function () {
              var self = this;
              this.product_tmpl_id = parseInt(this.$target.find('[data-oe-model="product.template"]').data('oe-id'));
  
              var size_x = parseInt(this.$target.attr("colspan") || 1);
              var size_y = parseInt(this.$target.attr("rowspan") || 1);
  
              var $size = this.$el.find('ul[name="size"]');
              var $select = $size.find('tr:eq(0) td:lt('+size_x+')');
              if (size_y >= 2) $select = $select.add($size.find('tr:eq(1) td:lt('+size_x+')'));
              if (size_y >= 3) $select = $select.add($size.find('tr:eq(2) td:lt('+size_x+')'));
              if (size_y >= 4) $select = $select.add($size.find('tr:eq(3) td:lt('+size_x+')'));
              $select.addClass("selected");
  
              website.session.model('product.style')
                  .call('search_read', [[]])
                      .then(function (data) {
                          var $ul = self.$el.find('ul[name="style"]');
                          for (var k in data) {
                              $ul.append(
                                  $('<li data-style="'+data[k]['id']+'" data-toggle_class="'+data[k]['html_class']+'"/>')
                                      .append( $('<a/>').text(data[k]['name']) ));
                          }
                          self.set_active();
                      });
  
              this.bind_resize();
          },
          reload: function () {
              if (location.href.match(/\?enable_editor/)) {
                  location.reload();
              } else {
                  location.href = location.href.replace(/\?(enable_editor=1&)?|#.*|$/, '?enable_editor=1&');
              }
          },
          bind_resize: function () {
              var self = this;
              this.$el.on('mouseenter', 'ul[name="size"] table', function (event) {
                  $(event.currentTarget).addClass("oe_hover");
              });
              this.$el.on('mouseleave', 'ul[name="size"] table', function (event) {
                  $(event.currentTarget).removeClass("oe_hover");
              });
              this.$el.on('mouseover', 'ul[name="size"] td', function (event) {
                  var $td = $(event.currentTarget);
                  var $table = $td.closest("table");
                  var x = $td.index()+1;
                  var y = $td.parent().index()+1;
  
                  var tr = [];
                  for (var yi=0; yi<y; yi++) tr.push("tr:eq("+yi+")");
                  var $select_tr = $table.find(tr.join(","));
                  var td = [];
                  for (var xi=0; xi<x; xi++) td.push("td:eq("+xi+")");
                  var $select_td = $select_tr.find(td.join(","));
  
                  $table.find("td").removeClass("select");
                  $select_td.addClass("select");
              });
              this.$el.on('click', 'ul[name="size"] td', function (event) {
                  var $td = $(event.currentTarget);
                  var $data = $td.closest(".js_options:first");
                  var x = $td.index()+1;
                  var y = $td.parent().index()+1;
                  openerp.jsonRpc('/shop/change_size', 'call', {'id': self.product_tmpl_id, 'x': x, 'y': y})
                      .then(self.reload);
              });
          },
          style: function (type, value, $li) {
              if(type !== "click") return;
              openerp.jsonRpc('/shop/change_styles', 'call', {'id': this.product_tmpl_id, 'style_id': value});
          },
          go_to: function (type, value) {
              if(type !== "click") return;
              openerp.jsonRpc('/shop/change_sequence', 'call', {'id': this.product_tmpl_id, 'sequence': value})
                  .then(this.reload);
          }
      });
  
  })();
  