summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.snippets.editor.js
diff options
context:
space:
mode:
authorchm@openerp.com <>2014-03-28 15:16:19 +0100
committerchm@openerp.com <>2014-03-28 15:16:19 +0100
commit31269ba52fafb2238b027b3c42e81acbaacfd9d4 (patch)
tree4a629327799abd288059ceabb355156352f339ee /addons/website/static/src/js/website.snippets.editor.js
parentb0625b1191eaf24a191b8937327809bc0ca0e7d4 (diff)
[IMP] website: media editor doubleclick for video and begin to use snippet builder
bzr revid: chm@openerp.com-20140328141619-x9okgixai2v5dekr
Diffstat (limited to 'addons/website/static/src/js/website.snippets.editor.js')
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js64
1 files changed, 62 insertions, 2 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index 52deeabf5e6..2b7c001b7b6 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -154,6 +154,7 @@
this.on('rte:ready', this, function () {
self.snippets.$button.removeClass("hidden");
website.snippet.stop_animation();
+ website.snippet.start_animation(true, $(".media_iframe_video"));
});
return this._super.apply(this, arguments);
@@ -265,7 +266,8 @@
'$el': $style,
'selector-siblings': $style.data('selector-siblings'),
'selector-children': $style.data('selector-children'),
- 'selector-vertical-children': $style.data('selector-vertical-children')
+ 'selector-vertical-children': $style.data('selector-vertical-children'),
+ 'data': $style.data()
};
selector.push($style.data('selector'));
});
@@ -332,6 +334,7 @@
if (!$target.is(website.snippet.globalSelector)) {
$target = $target.parents(website.snippet.globalSelector).first();
}
+
if (!self.dom_filter($target).length) {
$target = false;
}
@@ -732,7 +735,9 @@
this.$target.data("snippet-option-ids", styles);
this.$overlay = this.$target.data('overlay');
this['snippet-option-id'] = snippet_id;
- this.$el = website.snippet.templateOptions[snippet_id].$el.find(">li").clone();
+ var $option = website.snippet.templateOptions[snippet_id].$el;
+ this.$el = $option.find(">li").clone();
+ this.data = $option.data();
this.required = this.$el.data("required");
@@ -1425,6 +1430,43 @@
}
});
+ website.snippet.options.media = website.snippet.Option.extend({
+ start: function () {
+ var self = this;
+ this._super();
+ website.snippet.start_animation(true, this.$target);
+
+ this.$el.find('[data-toggle="dropdown"]').dropdown();
+ this.$el.find(".hover-edition-button").click(function (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ self.element = new CKEDITOR.dom.element(self.$target[0]);
+ new website.editor.MediaDialog(self, self.element).appendTo(document.body);
+ });
+ this.$el.find(".hover-style-button").click(function (event) {
+ self.transfo(event);
+ });
+ },
+ transfo: function (event) {
+ var self = this;
+ var sel = new CKEDITOR.dom.element(this.$target[0]);
+ var $button = $(event.target);
+ event.preventDefault();
+ event.stopPropagation();
+
+ if (this.$target.data('transfo')) {
+ this.$target.transfo("destroy");
+ $button.addClass("btn-primary").removeClass("btn-default");
+ } else {
+ this.$target.transfo();
+ this.$target.data('transfo').$markup
+ .on("mouseover", function () { self.$target.trigger("mouseover"); })
+ .mouseover()
+ .click(function () { self.$target.transfo("destroy"); });
+ }
+ }
+ });
+
website.snippet.Editor = openerp.Class.extend({
init: function (BuildingBlock, dom) {
@@ -1434,6 +1476,7 @@
this.snippet_id = this.$target.data("snippet-id");
this._readXMLData();
this.load_style_options();
+ this.get_phantom();
this.get_parent_block();
this.start();
},
@@ -1571,6 +1614,23 @@
this.$overlay.find('[data-toggle="dropdown"]').dropdown();
},
+ get_phantom: function () {
+ var self = this;
+ var phantom = false;
+ for (var i in this.styles){
+ if (this.styles[i].data.phantom) {
+ phantom = true;
+ break;
+ }
+ }
+ if (false && phantom) {
+ var $parent = this.$target.parents(website.snippet.globalSelector).first();
+ setTimeout(function () {
+ self.BuildingBlock.make_active($parent);
+ }, 0);
+ }
+ },
+
get_parent_block: function () {
var self = this;
var $button = this.$overlay.find('.oe_snippet_parent');