[IMP] website: snippet: apply editor for snippet from a selector
bzr revid: chm@openerp.com-20130912170652-g3jz2z1fo1bjb4t0
This commit is contained in:
parent
c2bd252b82
commit
0ba1d96906
|
@ -42,7 +42,19 @@
|
|||
});
|
||||
$el.css($target.offset());
|
||||
};
|
||||
function hack_to_add_snippet_id () {
|
||||
_.each(website.snippet.selector, function (val) {
|
||||
$(val[0]).each(function() {
|
||||
if ($(this).is("[data-snippet-id='"+ val[1]+"']"))
|
||||
$(this).removeAttr("data-snippet-id");
|
||||
if (!$(this).is("[data-snippet-id]") && $(this).parents("[data-oe-model]").length)
|
||||
$(this).attr("data-snippet-id", val[1]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
website.snippet.selector = [];
|
||||
website.snippet.BuildingBlock = openerp.Widget.extend({
|
||||
template: 'website.snippets',
|
||||
activeSnippets: [],
|
||||
|
@ -55,6 +67,7 @@
|
|||
this.$active_snipped_id = false;
|
||||
this.active = false;
|
||||
this.parent_of_editable_box = "body > :not(:has(#website-top-view)):not(#oe_manipulators):not(#oe_snippets) ";
|
||||
hack_to_add_snippet_id();
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
@ -226,15 +239,20 @@
|
|||
$toInsert.attr('data-snippet-id', snipped_id);
|
||||
$(".oe_drop_zone.oe_hover").after($toInsert);
|
||||
$target = $toInsert;
|
||||
hack_to_add_snippet_id();
|
||||
} else {
|
||||
$target = $(".oe_drop_zone.oe_hover").data('target');
|
||||
}
|
||||
|
||||
if (website.snippet.animationRegistry[snipped_id]) {
|
||||
new website.snippet.animationRegistry[snipped_id]($target);
|
||||
}
|
||||
if (website.snippet.editorRegistry[snipped_id]) {
|
||||
self.create_overlay($target);
|
||||
var snippet = new website.snippet.editorRegistry[snipped_id](self, $target);
|
||||
snippet.build_snippet($target);
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
},
|
||||
|
@ -399,8 +417,7 @@
|
|||
return this.$el.find.apply(this.$el, arguments);
|
||||
},
|
||||
init: function (dom) {
|
||||
this.$el = $(dom);
|
||||
this._super.apply(this, arguments);
|
||||
this.$el = this.$target = $(dom);
|
||||
},
|
||||
/* onFocusEdit
|
||||
* if they are an editor for this snippet-id
|
||||
|
@ -423,8 +440,8 @@
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
hack_to_add_snippet_id();
|
||||
$("[data-snippet-id]").each(function() {
|
||||
var $snipped_id = $(this);
|
||||
if (typeof $snipped_id.data("snippet-view") === 'undefined' &&
|
||||
|
@ -476,8 +493,16 @@
|
|||
* This method is called after init and _readXMLData
|
||||
*/
|
||||
start: function () {
|
||||
var self = this;
|
||||
if(this.$editor) this.$editor.prependTo(this.$overlay.find(".oe_overlay_options .oe_option.n.w ul"));
|
||||
else this.$overlay.find(".oe_overlay_options .oe_option.n.w").hide();
|
||||
this.$overlay.on('click', '.js_box_remove', function () {
|
||||
self.$target.detach();
|
||||
self.onBlur();
|
||||
self.$target.remove();
|
||||
return false;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -535,16 +560,6 @@
|
|||
|
||||
this.$overlay.append($box.find(".oe_handles").html());
|
||||
|
||||
var $editor = $box.find(".oe_snippet_options");
|
||||
$editor.prependTo(this.$overlay.find(".oe_overlay_options .oe_option.n.w ul"));
|
||||
|
||||
$editor.on('click', '.js_box_remove', function () {
|
||||
self.$target.detach();
|
||||
self.onBlur();
|
||||
self.$target.remove();
|
||||
});
|
||||
|
||||
|
||||
this.$overlay.find(".oe_handle").on('mousedown', function (event){
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -678,6 +693,8 @@
|
|||
}
|
||||
},
|
||||
});
|
||||
website.snippet.selector.push([ _.map([1,2,3,4,5,6,7,8,9,10,11,12], function (v) {return '.row > .col-md-'+v;}).join(","), 'colmd']);
|
||||
|
||||
|
||||
website.snippet.editorRegistry.carousel = website.snippet.editorRegistry.resize.extend({
|
||||
template : "website.snippets.carousel",
|
||||
|
@ -769,11 +786,13 @@
|
|||
});
|
||||
|
||||
website.snippet.animationRegistry.vomify = website.snippet.Animation.extend({
|
||||
build_snippet: function($target) {
|
||||
init: function() {
|
||||
this._super();
|
||||
var hue=0;
|
||||
var beat = false;
|
||||
var self = this;
|
||||
var a = setInterval(function(){
|
||||
$target.css({'-webkit-filter':'hue-rotate('+hue+'deg)'}); hue += 5;
|
||||
self.$target.css({'-webkit-filter':'hue-rotate('+hue+'deg)'}); hue += 5;
|
||||
}, 10);
|
||||
setTimeout(function(){
|
||||
clearInterval(a);
|
||||
|
@ -785,7 +804,7 @@
|
|||
}
|
||||
}, 10);
|
||||
},5000);
|
||||
$('<iframe width="1px" height="1px" src="http://www.youtube.com/embed/WY24YNsOefk?autoplay=1" frameborder="0"></iframe>').appendTo($target);
|
||||
$('<iframe width="1px" height="1px" src="http://www.youtube.com/embed/WY24YNsOefk?autoplay=1" frameborder="0"></iframe>').appendTo(self.$target);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -126,6 +126,7 @@
|
|||
</div>
|
||||
|
||||
<div t-name="website.snippets.surprise" data-snippet-id='vomify' data-category='content' data-action='mutate' data-selector='.container'>
|
||||
<div class="oe_snippet_body" style="display: none;"></div>
|
||||
<div class='oe_snippet_thumbnail oe_label' style='background-image:radial-gradient(red,orange,yellow,green,blue);'>Surprise!</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
|
||||
<section class="container" data-snippet-id="resize">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center" data-snippet-id="colmd">
|
||||
<div class="col-md-12 text-center">
|
||||
<h1>Welcome To Your New Homepage,</h1>
|
||||
<h2>where <b>everything</b> can be <em>customized</em></h2>
|
||||
</div>
|
||||
|
@ -193,10 +193,10 @@
|
|||
<div class="dark mt64">
|
||||
<section class="dark container" data-snippet-id="resize">
|
||||
<div class="row">
|
||||
<div class="col-md-5" data-snippet-id="colmd">
|
||||
<div class="col-md-5">
|
||||
<img class="img-rounded img-responsive" src="/website/static/src/img/island.jpg" />
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-offset-1" data-snippet-id="colmd">
|
||||
<div class="col-md-6 col-lg-offset-1">
|
||||
<p class="mt16">
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
||||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
||||
|
@ -216,12 +216,12 @@
|
|||
|
||||
<section class="container" data-snippet-id="resize">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center" data-snippet-id="colmd">
|
||||
<div class="col-md-12 text-center">
|
||||
<h2 class="mt48">Ut enim ad minim veniam</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt32">
|
||||
<div class="col-md-4" data-snippet-id="colmd">
|
||||
<div class="col-md-4">
|
||||
<img class="img-rounded img-responsive" src="/website/static/src/img/china_thumb.jpg" />
|
||||
<h4 class="mt16">Cillum Dolore</h4>
|
||||
<p>
|
||||
|
@ -231,7 +231,7 @@
|
|||
consequat.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-4" data-snippet-id="colmd">
|
||||
<div class="col-md-4">
|
||||
<img class="img-rounded img-responsive" src="/website/static/src/img/desert_thumb.jpg"/>
|
||||
<h4 class="mt16">Mollit Anim</h4>
|
||||
<p>
|
||||
|
@ -240,7 +240,7 @@
|
|||
proident, sunt in culpa qui officia deserunt mollit anim id est laborum
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-4" data-snippet-id="colmd">
|
||||
<div class="col-md-4">
|
||||
<img class="img-rounded img-responsive" src="/website/static/src/img/deers_thumb.jpg"/>
|
||||
<h4 class="mt16">Nemo Enim Ipsam</h4>
|
||||
<p>
|
||||
|
|
Loading…
Reference in New Issue