[FIX] Sidebar dropdown

bzr revid: fme@openerp.com-20120620102126-nax3dlhuj9ja2x2w
This commit is contained in:
Fabien Meghazi 2012-06-20 12:21:26 +02:00
parent da09aec9ca
commit 135be629b1
4 changed files with 144 additions and 219 deletions

View File

@ -369,7 +369,47 @@
.openerp .oe_cropdown_menu { .openerp .oe_cropdown_menu {
display: none; display: none;
position: absolute; position: absolute;
top: 28px;
z-index: 1; z-index: 1;
border: 1px solid #afafb6;
background: white;
padding: 8px;
min-width: 120px;
text-align: left;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.openerp .oe_cropdown_menu li {
list-style-type: none;
float: none;
display: block;
position: relative;
}
.openerp .oe_cropdown_menu li:hover {
background-color: #f0f0fa;
background-image: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6));
background-image: -webkit-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: -moz-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: -ms-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: -o-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: linear-gradient(to bottom, #f0f0fa, #eeeef6);
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.openerp .oe_cropdown_menu li a {
white-space: nowrap;
display: block;
padding: 3px 6px;
color: #4c4c4c;
text-decoration: none;
}
.openerp .oe_cropdown_menu li a:hover {
text-decoration: none;
} }
.openerp .oe_cropdown_arrow:after { .openerp .oe_cropdown_arrow:after {
width: 0; width: 0;
@ -382,52 +422,26 @@
margin-left: 4px; margin-left: 4px;
border-left: 4px solid transparent; border-left: 4px solid transparent;
border-right: 4px solid transparent; border-right: 4px solid transparent;
border-top-color: #404040; border-top: 4px solid #404040;
filter: alpha(opacity=50); filter: alpha(opacity=50);
opacity: 0.5; opacity: 0.5;
} }
.openerp .oe_dropdown_toggle:after { .openerp .oe_sidebar {
width: 0; white-space: nowrap;
height: 0;
display: inline-block;
content: "&darr";
text-indent: -99999px;
vertical-align: top;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid white;
filter: alpha(opacity=50);
opacity: 0.5;
margin-top: 7px;
margin-left: 6px;
} }
.openerp .oe_dropdown_menu { .openerp .oe_sidebar .oe_cropdown_menu .oe_sidebar_add_attachment {
display: none; height: 20px;
position: absolute; cursor: pointer;
top: 28px; padding-left: 6px;
left: 0px; margin-top: 6px;
padding: 8px;
border: 1px solid #afafb6;
min-width: 120px;
overflow-x: hidden;
z-index: 900;
text-align: left;
background: white;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
} }
.openerp .oe_dropdown_menu li { .openerp .oe_sidebar .oe_cropdown_menu .oe_sidebar_add_attachment span {
position: relative; font-weight: bold;
list-style-type: none;
float: none;
display: block;
background-color: none;
} }
.openerp .oe_dropdown_menu li:hover { .openerp .oe_sidebar .oe_cropdown_menu .oe_sidebar_add_attachment .oe_hidden_input_file {
width: 200px;
}
.openerp .oe_sidebar .oe_cropdown_menu .oe_sidebar_add_attachment:hover {
background-color: #f0f0fa; background-color: #f0f0fa;
background-image: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6)); background-image: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6));
background-image: -webkit-linear-gradient(top, #f0f0fa, #eeeef6); background-image: -webkit-linear-gradient(top, #f0f0fa, #eeeef6);
@ -439,27 +453,13 @@
-webkit-box-shadow: none; -webkit-box-shadow: none;
box-shadow: none; box-shadow: none;
} }
.openerp .oe_dropdown_menu li a { .openerp .oe_sidebar .oe_cropdown_menu li .oe_sidebar_delete_item {
display: block;
padding: 3px 6px;
clear: both;
font-weight: normal;
line-height: 14px;
color: #4c4c4c;
text-decoration: none;
cursor: pointer;
}
.openerp .oe_dropdown_menu li a:hover {
text-decoration: none;
}
.openerp .oe_dropdown_menu li .oe_sidebar_delete_item {
position: absolute; position: absolute;
bottom: 1px; top: 4px;
right: 4px; right: 4px;
display: none; display: none;
width: 12px; width: 12px;
height: 12px; height: 12px;
line-height: 12px;
padding: 1px; padding: 1px;
color: #8786b7; color: #8786b7;
line-height: 8px; line-height: 8px;
@ -467,7 +467,7 @@
font-weight: bold; font-weight: bold;
text-shadow: 0 1px 1px white; text-shadow: 0 1px 1px white;
} }
.openerp .oe_dropdown_menu li .oe_sidebar_delete_item:hover { .openerp .oe_sidebar .oe_cropdown_menu li .oe_sidebar_delete_item:hover {
text-decoration: none; text-decoration: none;
color: white; color: white;
background: #8786b7; background: #8786b7;
@ -476,38 +476,9 @@
-webkit-border-radius: 2px; -webkit-border-radius: 2px;
border-radius: 2px; border-radius: 2px;
} }
.openerp .oe_dropdown_menu li:hover .oe_sidebar_delete_item { .openerp .oe_sidebar .oe_cropdown_menu li:hover .oe_sidebar_delete_item {
display: inline-block; display: inline-block;
} }
.openerp .oe_sidebar {
white-space: nowrap;
}
.openerp .oe_sidebar .oe_dropdown_menu li {
padding-right: 16px;
}
.openerp .oe_sidebar .oe_sidebar_add_attachment {
cursor: pointer;
padding-left: 6px;
margin-top: 6px;
}
.openerp .oe_sidebar .oe_sidebar_add_attachment span {
font-weight: bold;
}
.openerp .oe_sidebar .oe_sidebar_add_attachment .oe_hidden_input_file {
width: 200px;
}
.openerp .oe_sidebar .oe_sidebar_add_attachment:hover {
background-color: #f0f0fa;
background-image: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6));
background-image: -webkit-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: -moz-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: -ms-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: -o-linear-gradient(top, #f0f0fa, #eeeef6);
background-image: linear-gradient(to bottom, #f0f0fa, #eeeef6);
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.openerp .oe_loading { .openerp .oe_loading {
display: none; display: none;
z-index: 100; z-index: 100;
@ -743,13 +714,12 @@
.openerp .oe_topbar .oe_topbar_avatar { .openerp .oe_topbar .oe_topbar_avatar {
vertical-align: top; vertical-align: top;
} }
.openerp .oe_topbar .oe_cropdown_toggle:after { .openerp .oe_topbar .oe_cropdown_arrow:after {
border-top: 4px solid white; border-top: 4px solid white;
} }
.openerp .oe_topbar .oe_cropdown_menu { .openerp .oe_topbar .oe_cropdown_menu {
background: #333333; background: #333333;
background: rgba(37, 37, 37, 0.9); background: rgba(37, 37, 37, 0.9);
padding: 6px 0;
border-color: #999999; border-color: #999999;
border-color: rgba(0, 0, 0, 0.2); border-color: rgba(0, 0, 0, 0.2);
border-style: solid; border-style: solid;
@ -757,21 +727,14 @@
-moz-border-radius: 0 0 6px 6px; -moz-border-radius: 0 0 6px 6px;
-webkit-border-radius: 0 0 6px 6px; -webkit-border-radius: 0 0 6px 6px;
border-radius: 0 0 6px 6px; border-radius: 0 0 6px 6px;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
-webkit-background-clip: padding-box; -webkit-background-clip: padding-box;
-moz-background-clip: padding-box; -moz-background-clip: padding-box;
background-clip: padding-box; background-clip: padding-box;
} }
.openerp .oe_topbar .oe_cropdown_menu li { .openerp .oe_topbar .oe_cropdown_menu li {
float: none; float: none;
display: block;
} }
.openerp .oe_topbar .oe_cropdown_menu li a { .openerp .oe_topbar .oe_cropdown_menu li a {
white-space: nowrap;
display: block;
padding: 4px 15px;
color: #eeeeee; color: #eeeeee;
} }
.openerp .oe_topbar .oe_cropdown_menu li a:hover { .openerp .oe_topbar .oe_cropdown_menu li a:hover {

View File

@ -322,7 +322,31 @@ $colour4: #8a89ba
.oe_cropdown_menu .oe_cropdown_menu
display: none display: none
position: absolute position: absolute
top: 28px
z-index: 1 z-index: 1
border: 1px solid #afafb6
background: white
padding: 8px
min-width: 120px
text-align: left
@include radius(3px)
@include box-shadow(0 1px 4px rgba(0,0,0,0.3))
li
&:hover
@include vertical-gradient(#f0f0fa, #eeeef6)
@include box-shadow(none)
list-style-type: none
float: none
display: block
position: relative
a
white-space: nowrap
display: block
padding: 3px 6px
color: #4c4c4c
text-decoration: none
&:hover
text-decoration: none
.oe_cropdown_arrow:after .oe_cropdown_arrow:after
width: 0 width: 0
height: 0 height: 0
@ -334,65 +358,32 @@ $colour4: #8a89ba
margin-left: 4px margin-left: 4px
border-left: 4px solid transparent border-left: 4px solid transparent
border-right: 4px solid transparent border-right: 4px solid transparent
border-top-color: #404040 border-top: 4px solid#404040
@include opacity(0.5) @include opacity(0.5)
.oe_sidebar
.oe_dropdown_toggle:after white-space: nowrap
width: 0 .oe_cropdown_menu
height: 0 .oe_sidebar_add_attachment
display: inline-block height: 20px
content: "&darr" cursor: pointer
text-indent: -99999px padding-left: 6px
vertical-align: top margin-top: 6px
border-left: 4px solid transparent span
border-right: 4px solid transparent font-weight: bold
border-top: 4px solid white .oe_hidden_input_file
@include opacity(0.5) width: 200px
margin-top: 7px
margin-left: 6px
.oe_dropdown_menu
display: none
position: absolute
top: 28px
left: 0px
padding: 8px
border: 1px solid #afafb6
min-width: 120px
overflow-x: hidden
z-index: 900
text-align: left
background: white
@include radius(3px)
@include box-shadow(0 1px 4px rgba(0,0,0,0.3))
li
&:hover &:hover
@include vertical-gradient(#f0f0fa, #eeeef6) @include vertical-gradient(#f0f0fa, #eeeef6)
@include box-shadow(none) @include box-shadow(none)
position: relative li
list-style-type: none
float: none
display: block
background-color: none
a
display: block
padding: 3px 6px
clear: both
font-weight: normal
line-height: 14px
color: #4c4c4c
text-decoration: none
cursor: pointer
&:hover
text-decoration: none
.oe_sidebar_delete_item .oe_sidebar_delete_item
position: absolute position: absolute
bottom: 1px top: 4px
right: 4px right: 4px
display: none display: none
width: 12px width: 12px
height: 12px height: 12px
line-height: 12px
padding: 1px padding: 1px
color: #8786b7 color: #8786b7
line-height: 8px line-height: 8px
@ -408,21 +399,6 @@ $colour4: #8a89ba
&:hover &:hover
.oe_sidebar_delete_item .oe_sidebar_delete_item
display: inline-block display: inline-block
.oe_sidebar
white-space: nowrap
.oe_dropdown_menu li
padding-right: 16px
.oe_sidebar_add_attachment
cursor: pointer
padding-left: 6px
margin-top: 6px
span
font-weight: bold
.oe_hidden_input_file
width: 200px
&:hover
@include vertical-gradient(#f0f0fa, #eeeef6)
@include box-shadow(none)
// }}} // }}}
// Loading {{{ // Loading {{{
@ -603,26 +579,20 @@ $colour4: #8a89ba
@include radius(3px) @include radius(3px)
.oe_topbar_avatar .oe_topbar_avatar
vertical-align: top vertical-align: top
.oe_cropdown_toggle:after .oe_cropdown_arrow:after
border-top: 4px solid white border-top: 4px solid white
.oe_cropdown_menu .oe_cropdown_menu
background: #333 background: #333
background: rgba(37,37,37,0.9) background: rgba(37,37,37,0.9)
padding: 6px 0
border-color: #999 border-color: #999
border-color: rgba(0, 0, 0, 0.2) border-color: rgba(0, 0, 0, 0.2)
border-style: solid border-style: solid
border-width: 0 1px 1px border-width: 0 1px 1px
@include radius(0 0 6px 6px) @include radius(0 0 6px 6px)
@include box-shadow(0 1px 4px rgba(0,0,0,0.3))
@include background-clip() @include background-clip()
li li
float: none float: none
display: block
a a
white-space: nowrap
display: block
padding: 4px 15px
color: #eee color: #eee
&:hover &:hover
@include vertical-gradient(#292929, #191919) @include vertical-gradient(#292929, #191919)

View File

@ -739,18 +739,9 @@ instance.web.Sidebar = instance.web.Widget.extend({
var self = this; var self = this;
this._super(this); this._super(this);
this.redraw(); this.redraw();
this.$element.on('click','.oe_dropdown_toggle',function(event) { this.$element.on('click','.oe_cropdown_menu li a', function(event) {
self.$('ul').hide();
$(this).parent().find('ul').toggle();
return false;
});
instance.web.bus.on('click', self, function(ev) {
self.$('ul').hide();
});
this.$element.on('click','.oe_dropdown_menu li a', function(event) {
var section = $(this).data('section'); var section = $(this).data('section');
var index = $(this).data('index'); var index = $(this).data('index');
$(this).closest('ul').hide();
var item = self.items[section][index]; var item = self.items[section][index];
if (item.callback) { if (item.callback) {
item.callback.apply(self, [item]); item.callback.apply(self, [item]);
@ -759,13 +750,12 @@ instance.web.Sidebar = instance.web.Widget.extend({
} else if (item.url) { } else if (item.url) {
return true; return true;
} }
return false; event.preventDefault();
}); });
}, },
redraw: function() { redraw: function() {
var self = this; var self = this;
self.$element.html(QWeb.render('Sidebar', {widget: self})); self.$element.html(QWeb.render('Sidebar', {widget: self}));
this.$element.find('ul').hide();
// Hides Sidebar sections when item list is empty // Hides Sidebar sections when item list is empty
this.$('.oe_form_dropdown_section').each(function() { this.$('.oe_form_dropdown_section').each(function() {

View File

@ -508,8 +508,9 @@
<div class="oe_sidebar"> <div class="oe_sidebar">
<t t-foreach="widget.sections" t-as="section"> <t t-foreach="widget.sections" t-as="section">
<div class="oe_form_dropdown_section"> <div class="oe_form_dropdown_section">
<button class="oe_dropdown_toggle"><t t-esc="section.label"/></button> <button class="oe_cropdown_toggle oe_cropdown_arrow">
<ul class="oe_dropdown_menu"> <t t-esc="section.label"/>
<ul class="oe_cropdown_menu">
<li t-foreach="widget.items[section.name]" t-as="item" t-att-class="item.classname"> <li t-foreach="widget.items[section.name]" t-as="item" t-att-class="item.classname">
<a class="oe_sidebar_action_a" t-att-title="item.title" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank"> <a class="oe_sidebar_action_a" t-att-title="item.title" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank">
<t t-raw="item.label"/> <t t-raw="item.label"/>
@ -527,6 +528,7 @@
</t> </t>
</li> </li>
</ul> </ul>
</button>
</div> </div>
</t> </t>
</div> </div>