[IMP] website: name connected user; carousel selection; imp drop zone

bzr revid: chm@openerp.com-20130923125606-b6pcr52dai0yh2ia
This commit is contained in:
Christophe Matthieu 2013-09-23 14:56:06 +02:00
commit 7ed222baf3
8 changed files with 296 additions and 170 deletions

View File

@ -1,3 +1,13 @@
/* add CSS for bootstrap dropdown multi level */
.dropdown-submenu{position:relative;}
.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px;}
.dropdown-submenu:hover>.dropdown-menu{display:block;}
.dropdown-submenu>a:after{display:block;content:" ";float:right;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#cccccc;margin-top:5px;margin-right:-10px;}
.dropdown-submenu:hover>a:after{border-left-color:#ffffff;}
.dropdown-submenu.pull-left{float:none;}
.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px;}
/*
.oe_snippet_demo .oe_page{
margin-top: 50px;
@ -208,14 +218,3 @@
min-width: 10px;
}
/* Custom CSS for snippets */
.carousel.oe_small .carousel-inner {
height: 200px;
}
.carousel.oe_medium .carousel-inner {
height: 300px;
}
.carousel.oe_big .carousel-inner {
height: 450px;
}

View File

@ -246,6 +246,15 @@ footer {
height: 100%;
}
.carousel.oe_small .carousel-inner {
height: 200px;
}
.carousel.oe_medium .carousel-inner {
height: 300px;
}
.carousel.oe_big .carousel-inner {
height: 450px;
}
.carousel .carousel-caption h1, .carousel .carousel-caption h2, .carousel .carousel-caption h3 {
margin-top: 10px;
margin-bottom: 10px;
@ -271,7 +280,7 @@ footer {
background: rgba(0, 0, 0, 0.4);
}
.carousel .item.text_only .carousel-image {
display: none;
display: none !important;
}
.carousel .item.text_only .carousel-caption {
left: 10%;
@ -291,6 +300,20 @@ footer {
right: 50%;
left: 10%;
}
.carousel .carousel-control {
cursor: pointer;
}
.carousel .carousel-control span {
top: 50%;
position: absolute;
margin-top: -8px;
}
.carousel .carousel-control.left span {
left: 10px;
}
.carousel .carousel-control.right span {
right: 10px;
}
/* ---- HOMEPAGE THEME CUSTOMIZATION ---- */
.dark {

View File

@ -177,7 +177,14 @@ footer
.carousel-inner .item
height: 100%
.carousel
&.oe_small .carousel-inner
height: 200px
&.oe_medium .carousel-inner
height: 300px
&.oe_big .carousel-inner
height: 450px
.carousel-caption
h1, h2, h3
margin-top: 10px
@ -202,7 +209,7 @@ footer
background: rgba(0, 0, 0, 0.4)
.item.text_only
.carousel-image
display: none
display: none !important
.carousel-caption
left: 10%
right: 10%
@ -219,6 +226,16 @@ footer
.carousel-image
right: 50%
left: 10%
.carousel-control
cursor: pointer
span
top: 50%
position: absolute
margin-top: -8px
&.left span
left: 10px
&.right span
right: 10px
/* ---- HOMEPAGE THEME CUSTOMIZATION ---- */

View File

@ -28,6 +28,7 @@
return this._super.apply(this, arguments);
},
save: function () {
this.snippets.make_active(false);
remove_added_snippet_id();
this._super();
},
@ -106,9 +107,11 @@
var $ul = this.parent.$("#website-top-edit ul");
var $button = $(openerp.qweb.render('website.snippets_button'))
.click(function () {self.$el.toggleClass("hidden");})
.prependTo($ul);
var $button = $(openerp.qweb.render('website.snippets_button')).prependTo($ul);
$button.find('button').click(function () {
self.make_active(false);
self.$el.toggleClass("hidden");
});
this.fetch_snippet_templates();
@ -568,14 +571,6 @@
* Called after onBlur of snippet editor
*/
onBlurEdit : function () {},
/* getOptions
* Read data saved for your snippet animation.
*/
getOptions: function () {
var options = this.$el.data("snippet-options");
return options ? JSON.parse(options) : undefined;
},
});
@ -626,8 +621,7 @@
// activate drag and drop for the snippets in the snippet toolbar
_drag_and_drop: function(){
var self = this;
var dropped = false;
var $move = this.$overlay.find(".oe_snippet_move");
this.dropped = false;
this.$overlay.draggable({
greedy: true,
appendTo: 'body',
@ -639,49 +633,67 @@
},
helper: function() {
var $clone = $(this).clone().css({width: "24px", height: "24px", border: 0});
$clone.find(".oe_overlay_options >:not(.oe_snippet_move), .oe_handle").remove();
$clone.find(".oe_overlay_options >:not(:contains(.oe_snippet_move)), .oe_handle").remove();
$clone.find(":not(.glyphicon)").css({position: 'absolute', top: 0, left: 0});
return $clone.appendTo("body").removeClass("hidden");
$clone.appendTo("body").removeClass("hidden");
return $clone;
},
start: function(){
self.parent.hide();
self.parent.editor_busy = true;
self.$target.after("<div class='oe_drop_clone' style='display: none;'/>");
start: _.bind(self._drag_and_drop_start, self),
stop: _.bind(self._drag_and_drop_stop, self)
});
},
_drag_and_drop_after_insert_dropzone: function (){},
_drag_and_drop_active_drop_zone: function ($zones){
var self = this;
$zones.droppable({
over: function(){
$(".oe_drop_zone.hide").removeClass("hide");
$(this).addClass("hide").first().after(self.$target);
self.dropped = true;
},
out: function(){
$(this).removeClass("hide");
self.$target.detach();
self.$overlay.addClass("hidden");
self.parent.activate_insertion_zones({
siblings: self.$el ? self.$el.data('selector-siblings') : false,
children: self.$el ? self.$el.data('selector-children') : false,
vertical_children: self.$el ? self.$el.data('selector-vertical-children') : false,
});
$("body").addClass('move-important');
$('.oe_drop_zone').droppable({
over: function(){
$(".oe_drop_zone.hide").removeClass("hide");
$(this).addClass("hide").first().after(self.$target);
dropped = true;
},
out: function(){
$(this).removeClass("hide");
self.$target.detach();
dropped = false;
},
});
},
stop: function(){
if (!dropped) {
$(".oe_drop_clone").after(self.$target);
}
self.$overlay.removeClass("hidden");
$("body").removeClass('move-important');
$('.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);
self.dropped = false;
},
});
},
_drag_and_drop_start: function (){
var self = this;
self.parent.hide();
self.parent.editor_busy = true;
self.size = {
width: self.$target.width(),
height: self.$target.height()
};
self.$target.after("<div class='oe_drop_clone' style='display: none;'/>");
self.$target.detach();
self.$overlay.addClass("hidden");
self.parent.activate_insertion_zones({
siblings: self.$el ? self.$el.data('selector-siblings') : false,
children: self.$el ? self.$el.data('selector-children') : false,
vertical_children: self.$el ? self.$el.data('selector-vertical-children') : false,
});
$("body").addClass('move-important');
self._drag_and_drop_after_insert_dropzone();
self._drag_and_drop_active_drop_zone($('.oe_drop_zone'));
},
_drag_and_drop_stop: function (){
var self = this;
if (!self.dropped) {
$(".oe_drop_clone").after(self.$target);
}
self.$overlay.removeClass("hidden");
$("body").removeClass('move-important');
$('.oe_drop_zone').droppable('destroy').remove();
$(".oe_drop_clone, .oe_drop_to_remove").remove();
self.parent.editor_busy = false;
self.get_parent_block();
setTimeout(function () {self.parent.create_overlay(self.$target);},0);
},
_clone: function () {
var self = this;
@ -785,21 +797,6 @@
onBlur : function () {
this.$overlay.removeClass('oe_active');
},
/* setOptions
* Use this method when you want to save some data for your snippet animation.
*/
setOptions: function (options) {
$target.attr("data-snippet-options", JSON.stringify(options));
},
/* getOptions
* Read data saved for your snippet animation.
*/
getOptions: function () {
var options = this.$target.data("snippet-options");
return options ? JSON.parse(options) : undefined;
},
});
@ -931,6 +928,36 @@
return this.grid;
},
_drag_and_drop_after_insert_dropzone: function(){
var self = this;
var $zones = $(".row:has(> .oe_drop_zone)").each(function () {
var $row = $(this);
var width = $row.innerWidth();
var pos = 0;
while (width > pos + self.size.width) {
var $last = $row.find("> .oe_drop_zone:last");
$last.each(function () {
pos = $(this).position().left;
});
if (width > pos + self.size.width) {
$row.append("<div class='col-md-1 oe_drop_to_remove'/>");
var $add_drop = $last.clone();
$row.append($add_drop);
self._drag_and_drop_active_drop_zone($add_drop);
}
}
});
},
_drag_and_drop_start: function () {
this._super();
this.$target.attr("class",this.$target.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, ''));
},
_drag_and_drop_stop: function () {
this.$target.addClass("col-md-offset-" + this.$target.prevAll(".oe_drop_to_remove").length);
this._super();
},
on_resize: function (compass, beginClass, current) {
if (compass !== 'w')
return;
@ -958,88 +985,150 @@
website.snippet.editorRegistry.carousel = website.snippet.editorRegistry.resize.extend({
build_snippet: function($target) {
var id = "myCarousel" + $("body .carousel").size();
var id = "myCarousel" + $("body .carousel").length;
$target.attr("id", id);
$target.find(".carousel-control").attr("href", "#"+id);
},
start : function () {
this._super();
this.$editor.find(".js_add").on('click', this, this.on_add);
this.$editor.find(".js_remove").on('click', this, this.on_remove);
this.$editor.find(".js_add").on('click', _.bind(this.on_add, this));
this.$editor.find(".js_remove").on('click', _.bind(this.on_remove, this));
this.change_background();
this.change_style();
this.change_size();
// remove cke image seletor
this.$target.on('mousedown mouseup', '.carousel-inner .item > img', function (event) {
event.preventDefault();
return false;
});
},
on_add: function (e) {
e.preventDefault();
var $inner = e.data.$target.find('.carousel-inner');
var cycle = $inner.find('.item').size();
this.$target.find('.carousel-control').removeClass("hidden");
var $inner = this.$target.find('.carousel-inner');
var cycle = $inner.find('.item').length;
$inner.find('.item.active').clone().removeClass('active').appendTo($inner);
e.data.$target.carousel(cycle);
this.$target.carousel(cycle);
this.set_options_background();
this.set_options_style();
},
on_remove: function (e) {
e.preventDefault();
var $inner = e.data.$target.find('.carousel-inner');
if ($inner.find('.item').size() > 1) {
var $inner = this.$target.find('.carousel-inner');
var nb = $inner.find('.item').length;
if (nb > 1) {
$inner
.find('.item.active').remove().end()
.find('.item:first').addClass('active');
e.data.$target.carousel(0);
this.$target.carousel(0);
this.set_options_background();
this.set_options_style();
}
console.log(nb);
if (nb <= 1) {
this.$target.find('.carousel-control').addClass("hidden");
}
},
onFocus: function () {
this.set_options_background();
this.set_options_style();
this._super();
},
set_options_background: function () {
var $image = this.$target.find('.carousel-inner .item.active > img');
var bg = $image.attr('src');
var $ul = this.$editor.find('ul[name="carousel-background"]');
$ul.find("li").removeClass("active");
var selected = $ul.find('[data-value="' + bg + '"], [data-value="' + bg.replace(/.*:\/\/[^\/]+/, '') + '"]')
.addClass('active').length;
this.$editor.find('.oe_custom_bg b').val(selected ? "" : bg);
},
change_background: function () {
var self = this;
var bg = this.$target.find('.carousel-inner .item.active').css('background-image').replace(/url\((.*)\)/g, '$1');
var selected = this.$editor.find('select[name="carousel-background"] option[value="'+bg+'"], select[name="carousel-background"] option[value="'+bg.replace(window.location.protocol+'//'+window.location.host, '')+'"]')
.prop('selected', true).length;
if (!selected) {
this.$editor.find('.carousel-background input').val(bg);
}
var $ul = this.$editor.find('ul[name="carousel-background"]');
var $li = $ul.find("li");
this.$editor.find('select[name="carousel-background"], input')
.on('click', function (event) {event.preventDefault(); return false;})
.on('change', function () {
self.$target.find('.carousel-inner .item.active').css('background-image', 'url(' + $(this).val() + ')');
$(this).next().val("");
$li.on('click', function (event) {
$li.removeClass("active");
$(this).addClass("active");
self.$editor.find('input').val("");
})
.on('mouseover', function (event) {
if ($(this).data("value")) {
self.$target.find('.carousel-inner .item.active > img')
.attr('src', $(this).data("value"));
}
})
.on('mouseout', function (event) {
self.$target.find('.carousel-inner .item.active > img')
.attr('src', $ul.find('li.active').data("value"));
});
},
set_options_style: function () {
var style = false;
var $el = this.$target.find('.carousel-inner .item.active');
var $ul = this.$editor.find('ul[name="carousel-style"]');
var $li = $ul.find("li");
if ($el.hasClass('text_only'))
style = 'text_only';
if ($el.hasClass('image_text'))
style = 'image_text';
if ($el.hasClass('text_image'))
style = 'text_image';
$ul.find('[data-value="' + style + '"]').addClass('active');
},
change_style: function () {
var self = this;
var style = false;
var el = this.$target.find('.carousel-inner .item.active');
if (el.hasClass('text_only'))
style = 'text_only';
if (el.hasClass('image_text'))
style = 'image_text';
if (el.hasClass('text_image'))
style = 'text_image';
var $ul = this.$editor.find('ul[name="carousel-style"]');
var $li = $ul.find("li");
this.$editor.find('select[name="carousel-style"] option[value="'+style+'"]').prop('selected', true);
this.$editor.find('select[name="carousel-style"]').on('change', function(e) {
var $container = self.$target.find('.carousel-inner .item.active');
$container.removeClass('image_text text_image text_only');
$container.addClass($(e.currentTarget).val());
});
$li.on('click', function (event) {
$li.removeClass("active");
$(this).addClass("active");
})
.on('mouseover', function (event) {
var $el = self.$target.find('.carousel-inner .item.active');
$el.removeClass('image_text text_image text_only');
$el.addClass($(event.currentTarget).data("value"));
})
.on('mouseout', function (event) {
var $el = self.$target.find('.carousel-inner .item.active');
$el.removeClass('image_text text_image text_only');
$el.addClass($ul.find('li.active').data("value"));
});
},
change_size: function () {
var self = this;
var $el = this.$target;
var size = 'big';
var size = 'oe_big';
if (this.$target.hasClass('oe_small'))
size = 'small';
size = 'oe_small';
else if (this.$target.hasClass('oe_medium'))
size = 'medium';
size = 'oe_medium';
this.$editor.find('select[name="carousel-size"] option[value="'+size+'"]').prop('selected', true);
var $ul = this.$editor.find('ul[name="carousel-size"]');
var $li = $ul.find("li");
this.$editor.find('select[name="carousel-size"]').on('change', function(e) {
self.$target
.removeClass('oe_big oe_small oe_medium')
.addClass("oe_" + $(e.currentTarget).val());
});
$ul.find('[data-value="' + size + '"]').addClass('active');
$li.on('click', function (event) {
$li.removeClass("active");
$(this).addClass("active");
})
.on('mouseover', function (event) {
$el.removeClass('oe_big oe_small oe_medium');
$el.addClass($(event.currentTarget).data("value"));
})
.on('mouseout', function (event) {
$el.removeClass('oe_big oe_small oe_medium');
$el.addClass($ul.find('li.active').data("value"));
});
}
});

View File

@ -111,55 +111,50 @@
<div t-name="website.snippets.carousel" data-snippet-id='carousel' data-category='structure' data-selector-children='.oe_structure, [data-oe-type=html]'>
<!-- editor bar to display inside the top edit bar -->
<li class='oe_snippet_options'>
<a class="carousel-style">
<select class="form-control" name="carousel-size">
<option value="small">Small</option>
<option value="medium">Medium</option>
<option value="big">Big</option>
</select>
</a>
<li class='oe_snippet_options dropdown-submenu'>
<a tabindex="-1" href="#">Size</a>
<ul class="dropdown-menu" name="carousel-size">
<li data-value="oe_small"><a>Small</a></li>
<li data-value="oe_medium"><a>Medium</a></li>
<li data-value="oe_big"><a>Big</a></li>
</ul>
</li>
<li class="divider"></li>
<li class='oe_snippet_options'>
<a href="#" class="button js_add">Add Slide</a>
</li>
<li class="oe_snippet_options dropdown-submenu">
<a tabindex="-1" href="#">Background</a>
<ul class="dropdown-menu" name="carousel-background">
<li data-value="/website/static/src/img/banner/aqua.jpg"><a>Aqua</a></li>
<li data-value="/website/static/src/img/banner/baby_blue.jpg"><a>Baby Blue</a></li>
<li data-value="/website/static/src/img/banner/black.jpg"><a>Black</a></li>
<li data-value="/website/static/src/img/banner/business_guy.jpg"><a>Business Guy</a></li>
<li data-value="/website/static/src/img/banner/color_splash.jpg"><a>Color Splash</a></li>
<li data-value="/website/static/src/img/banner/flower_field.jpg"><a>Flowers Field</a></li>
<li data-value="/website/static/src/img/banner/greenfields.jpg"><a>Greenfields</a></li>
<li data-value="/website/static/src/img/banner/landscape.jpg"><a>Landscape</a></li>
<li data-value="/website/static/src/img/banner/mango.jpg"><a>Mango</a></li>
<li data-value="/website/static/src/img/banner/mountains.jpg"><a>Mountains</a></li>
<li data-value="/website/static/src/img/banner/orange_red.jpg"><a>Orange Red</a></li>
<li data-value="/website/static/src/img/banner/flower.jpg"><a>Purple</a></li>
<li data-value="/website/static/src/img/banner/velour.jpg"><a>Velour</a></li>
<li data-value="/website/static/src/img/banner/wood.jpg"><a>Wood</a></li>
<li data-value="/website/static/src/img/banner/yellow_green.jpg"><a>Yellow Green</a></li>
<li class="oe_custom_bg"><b></b></li>
</ul>
</li>
<li class='oe_snippet_options dropdown-submenu'>
<a tabindex="-1" href="#">Style</a>
<ul class="dropdown-menu" name="carousel-style">
<li data-value="text_only"><a>Text Only</a></li>
<li data-value="image_text"><a>Image - Text</a></li>
<li data-value="text_image"><a>Text - Image</a></li>
</ul>
</li>
<li class='oe_snippet_options'>
<a href="#" class="button js_remove">Remove Slide</a>
</li>
<li class='oe_snippet_options'>
<a class="carousel-background">
Background
<select class="form-control" name="carousel-background">
<option value="/website/static/src/img/banner/aqua.jpg">Aqua</option>
<option value="/website/static/src/img/banner/baby_blue.jpg">Baby Blue</option>
<option value="/website/static/src/img/banner/black.jpg">Black</option>
<option value="/website/static/src/img/banner/business_guy.jpg">Business Guy</option>
<option value="/website/static/src/img/banner/color_splash.jpg">Color Splash</option>
<option value="/website/static/src/img/banner/flower_field.jpg">Flowers Field</option>
<option value="/website/static/src/img/banner/greenfields.jpg">Greenfields</option>
<option value="/website/static/src/img/banner/landscape.jpg">Landscape</option>
<option value="/website/static/src/img/banner/mango.jpg">Mango</option>
<option value="/website/static/src/img/banner/mountains.jpg">Mountains</option>
<option value="/website/static/src/img/banner/orange_red.jpg">Orange Red</option>
<option value="/website/static/src/img/banner/flower.jpg">Purple</option>
<option value="/website/static/src/img/banner/velour.jpg">Velour</option>
<option value="/website/static/src/img/banner/wood.jpg">Wood</option>
<option value="/website/static/src/img/banner/yellow_green.jpg">Yellow Green</option>
</select>
<input class="form-control input-sm" type="text" placeholder="http://...."/>
</a>
</li>
<li class='oe_snippet_options'>
<a class="carousel-style">
Style
<select class="form-control" name="carousel-style">
<option value="text_only">Text Only</option>
<option value="image_text">Image - Text</option>
<option value="text_image">Text - Image</option>
</select>
</a>
</li>
<!-- thumbnail to display inside the bottom widget list editor -->
<div class='oe_snippet_thumbnail'>
@ -172,7 +167,8 @@
<div id="myCarousel" class="oe_snippet_body carousel slide oe_medium mb32" data-interval="10000">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item image_text active" style="background-image: url(/website/static/src/img/banner/color_splash.jpg); background-size: cover;">
<div class="item image_text active">
<img src="/website/static/src/img/banner/color_splash.jpg" width="100%" height="100%"/>
<div class="container">
<div class="carousel-caption content">
<h1>Set Your Banner Title</h1>
@ -188,8 +184,8 @@
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev" style="width: 10%"></a>
<a class="carousel-control right" href="#myCarousel" data-slide="next" style="width: 10%"></a>
<a class="carousel-control left hidden" href="#myCarousel" data-slide="prev" style="width: 10%"><span class="glyphicon glyphicon-circle-arrow-left"><span class="hidden">.</span></span></a>
<a class="carousel-control right hidden" href="#myCarousel" data-slide="next" style="width: 10%"><span class="glyphicon glyphicon-circle-arrow-right"><span class="hidden">.</span></span></a>
</div>
</div>
@ -773,7 +769,6 @@
<small>John Doe, CEO</small>
</blockquote>
</div>
<div class="clearfix"/>
<div class="col-md-2 col-md-offset-1">
<img src="/website/static/src/img/openerp_logo.png" class="img-responsive img-thumbnail"/>
</div>

View File

@ -72,8 +72,9 @@
</div>
<div class="collapse navbar-collapse navbar-top-collapse">
<ul class="nav navbar-nav navbar-right" id="top_menu">
<li><a href="/page/website.contactus">Contact us</a></li>
<li><a href="/admin">Sign in</a></li>
<li name="contactus"><a href="/page/website.contactus">Contact us</a></li>
<li t-if="user_id.id == website.public_user.id"><a href="/admin">Sign in</a></li>
<li t-if="user_id.id != website.public_user.id"><a href="/admin"><t t-field="user_id.name"/></a></li>
<li t-if="len(website.language_ids) &gt; 1" class="dropdown">
<!-- TODO: use flags for language selection -->
<t t-set="lang_selected" t-value="[lg for lg in website.language_ids if lg.code == lang]"/>

View File

@ -91,6 +91,7 @@ class website(osv.osv):
def render(self, cr, uid, ids, template, values=None):
view = request.registry.get("ir.ui.view")
IMD = request.registry.get("ir.model.data")
user = request.registry.get("res.users")
qweb_context = request.context.copy()
@ -103,6 +104,7 @@ class website(osv.osv):
json=simplejson,
website=request.website,
res_company=request.website.company_id,
user_id=user.browse(cr, openerp.SUPERUSER_ID, uid),
)
qweb_context.update(values)

View File

@ -13,7 +13,7 @@
<!-- Layout add nav and footer -->
<template id="header_footer_custom" inherit_id="website.layout">
<xpath expr="//header//ul[@id='top_menu']/li[last()]" position="before">
<xpath expr="//header//ul[@id='top_menu']/li[@name='contactus']" position="before">
<li><a href="/blog/%(website_mail.website_mail_blog)d/">News</a></li>
</xpath>
<xpath expr="//footer//div[@name='info']/ul" position="inside">