[IMP] website snippets: get parent container

bzr revid: chm@openerp.com-20130919125854-w9g395r71vbzbjts
This commit is contained in:
Christophe Matthieu
2013-09-19 14:58:54 +02:00
parent bfb9eb5b0a
commit b8086bc9a6
2 changed files with 24 additions and 9 deletions
@@ -198,17 +198,12 @@
if (snipped_event_flag) {
return;
}
var $target = $(event.currentTarget);
if (self.$active_snipped_id) {
if (self.$active_snipped_id[0] === $target[0] || $.contains(self.$active_snipped_id, $target[0])) {
var $parent = self.$active_snipped_id.parents("[data-snippet-id]:first");
if ($parent.length) {
$target = $parent;
}
}
}
snipped_event_flag = true;
setTimeout(function () {snipped_event_flag = false;}, 0);
var $target = $(event.currentTarget);
if (self.$active_snipped_id && self.$active_snipped_id.is($target)) {
return;
}
self.make_active($target);
});
$("body > :not(:has(#website-top-view)):not(#oe_manipulators)").on('click', function (ev) {
@@ -572,6 +567,7 @@
this.snippet_id = this.$target.data("snippet-id");
this._readXMLData();
this.load_style_options();
this.get_parent_block();
this.start();
},
@@ -662,6 +658,7 @@
$('.oe_drop_zone').droppable('destroy').remove();
$(".oe_drop_clone").remove();
self.parent.editor_busy = false;
self.get_parent_block();
setTimeout(function () {self.parent.create_overlay(self.$target);},0);
},
});
@@ -716,6 +713,23 @@
$li.toggleClass("active");
},
get_parent_block: function () {
var self = this;
var $button = this.$overlay.find('.oe_snippet_parent');
var $parent = this.$target.parents("[data-snippet-id]:first");
if ($parent.length) {
$button.show();
$button.off("click").on('click', function (event) {
event.preventDefault();
setTimeout(function () {
self.parent.make_active($parent);
}, 0);
});
} else {
$button.hide();
}
},
/*
* start
* This method is called after init and _readXMLData
@@ -36,6 +36,7 @@
<t t-name="website.snippet_overlay">
<div class="oe_overlay">
<div class="oe_overlay_options">
<a href="#" class="btn btn-default btn-sm oe_snippet_parent" title="Get Container Block"><span class="glyphicon glyphicon-open"/></a>
<div class="dropdown oe_options">
<a href="#" data-toggle="dropdown" class="btn btn-default btn-sm" title="Customize">Customize <span class="glyphicon glyphicon-cog"/></a>
<ul class="dropdown-menu" role="menu"></ul>