diff options
| author | Jiten (OpenERP) <jra@tinyerp.com> | 2011-09-27 11:44:28 +0530 |
|---|---|---|
| committer | Jiten (OpenERP) <jra@tinyerp.com> | 2011-09-27 11:44:28 +0530 |
| commit | 0f83246331158ca5f63ee237f2d8affdfc4b089e (patch) | |
| tree | b8b4089447cf6ed81947be62c0e4ef3efaa040ef /addons/web_mobile/static | |
| parent | d51feac91a138d6ba43f973ded6288fd010ed7b9 (diff) | |
[IMP] Improved secondary menu for more than two child on menu tree.
bzr revid: jra@tinyerp.com-20110927061428-loq3ew8fwdhhay6w
Diffstat (limited to 'addons/web_mobile/static')
| -rw-r--r-- | addons/web_mobile/static/src/js/chrome_mobile.js | 42 | ||||
| -rw-r--r-- | addons/web_mobile/static/src/xml/web_mobile.xml | 11 |
2 files changed, 43 insertions, 10 deletions
diff --git a/addons/web_mobile/static/src/js/chrome_mobile.js b/addons/web_mobile/static/src/js/chrome_mobile.js index bcf13b5c7d7..e8260739161 100644 --- a/addons/web_mobile/static/src/js/chrome_mobile.js +++ b/addons/web_mobile/static/src/js/chrome_mobile.js @@ -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')); } }); diff --git a/addons/web_mobile/static/src/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml index f5825861813..d2df9a1fed9 100644 --- a/addons/web_mobile/static/src/xml/web_mobile.xml +++ b/addons/web_mobile/static/src/xml/web_mobile.xml @@ -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> |
