[IMP] Improved secondary menu for more than two child on menu tree.
bzr revid: jra@tinyerp.com-20110927061428-loq3ew8fwdhhay6w
This commit is contained in:
@@ -236,7 +236,7 @@ openerp.web_mobile.Menu = openerp.web.Widget.extend({
|
||||
if(!$('[id^="oe_sec_menu_'+id+'"]').html()){
|
||||
$('<div id="oe_sec_menu_'+id+'" data-role="page" data-url="oe_sec_menu_'+id+'"> </div>').appendTo('#moe');
|
||||
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu_"+id, this.children);
|
||||
this.secondary.start();
|
||||
this.secondary.start();
|
||||
}else{
|
||||
$.mobile.changePage('#oe_sec_menu_'+id, "slide", false, true);
|
||||
}
|
||||
@@ -250,9 +250,7 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
|
||||
start: function(ev, id) {
|
||||
var self = this;
|
||||
var v = { menu : this.data };
|
||||
|
||||
this.$element.html(QWeb.render("Menu.secondary", v));
|
||||
|
||||
this.$element.find("[data-role=header]").find("h1").html(this.data.name);
|
||||
this.$element.add(this.$secondary_menu).find('#content').find("a").click(this.on_menu_click);
|
||||
this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){
|
||||
@@ -276,22 +274,50 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
|
||||
this.$element.find("[data-role=header]").find('#home').click(function(){
|
||||
$.mobile.changePage("#oe_menu", "slide", false, true);
|
||||
});
|
||||
|
||||
$.mobile.changePage("#"+this.element_id, "slide", false, true);
|
||||
},
|
||||
on_menu_click: function(ev, id) {
|
||||
var $menu = $(ev.currentTarget);
|
||||
$menu = $(ev.currentTarget);
|
||||
id = $menu.data('menu');
|
||||
name = $menu.data('name');
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
if(!$('[id^="oe_list_'+id+'"]').html()){
|
||||
var child_len = 0;
|
||||
for (var i = 0; i < this.data.children.length; i++) {
|
||||
for (var j=0; j < this.data.children[i].children.length; j++) {
|
||||
if (this.data.children[i].children[j].id == id) {
|
||||
this.children = this.data.children[i].children[j];
|
||||
child_len = this.children.children.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (child_len > 0) {
|
||||
this.$element
|
||||
.addClass("secondary_menu");
|
||||
if(!$('[id^="oe_sec_menu_'+id+'"]').html()){
|
||||
$('<div id="oe_sec_menu_'+id+'" data-role="page" data-url="oe_sec_menu_'+id+'"> </div>').appendTo('#moe');
|
||||
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu_"+id, this.children);
|
||||
this.secondary.start();
|
||||
}else{
|
||||
$.mobile.changePage('#oe_sec_menu_'+id, "slide", false, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!$('[id^="oe_list_'+id+'"]').html()){
|
||||
$('<div id="oe_list_'+id+'" data-role="page" data-url="oe_list_'+id+'"> </div>').appendTo('#moe');
|
||||
this.listview = new openerp.web_mobile.ListView(this, "oe_list_"+id, id);
|
||||
this.listview.start();
|
||||
}else{
|
||||
$.mobile.changePage('#oe_list_'+id, "slide", false, true);
|
||||
}
|
||||
}
|
||||
/* if(!$('[id^="oe_list_'+id+'"]').html()){
|
||||
$('<div id="oe_list_'+id+'" data-role="page" data-url="oe_list_'+id+'"> </div>').appendTo('#moe');
|
||||
this.listview = new openerp.web_mobile.ListView(this, "oe_list_"+id, id);
|
||||
this.listview.start();
|
||||
}else{
|
||||
$.mobile.changePage('#oe_list_'+id, "slide", false, true);
|
||||
}
|
||||
}*/
|
||||
jQuery("#oe_header").find("h1").html($menu.data('name'));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -95,12 +95,19 @@
|
||||
<t t-foreach="menu.children" t-as="menu1" >
|
||||
<ul data-dividertheme="b" data-theme="c" data-inset="true" data-role="listview">
|
||||
<li data-role="list-divider">
|
||||
<t t-esc="menu1.name"/>
|
||||
<t t-if="(menu1.children.length)">
|
||||
<t t-esc="menu1.name"/>
|
||||
</t>
|
||||
<t t-if="!(menu1.children.length)">
|
||||
<a href="#" t-attf-id="menu_#{menu1.id}" t-att-data-menu="menu1.id" t-att-data-name="menu1.name">
|
||||
<t t-esc="menu1.name"/>
|
||||
</a>
|
||||
</t>
|
||||
</li>
|
||||
<t t-if="menu1.children.length">
|
||||
<li data-theme="c" t-foreach="menu1.children" t-as="childmenu" >
|
||||
<a href="#" t-attf-id="menu_#{childmenu.id}" t-att-data-menu="childmenu.id" t-att-data-name="childmenu.name">
|
||||
<t t-esc="childmenu.name" />
|
||||
<t t-esc="childmenu.name" />
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user