[IMP] Dynamically data with theme.

bzr revid: bth@tinyerp.com-20110913062331-l9uk2gjw4za0mbxd
This commit is contained in:
Bhumi Thakkar (Open ERP) 2011-09-13 11:53:31 +05:30
parent fbd835894f
commit e9fe69d850
2 changed files with 45 additions and 76 deletions

View File

@ -133,8 +133,16 @@ openerp.web_mobile.Shortcuts = openerp.web.Widget.extend({
$shortcut = $(ev.currentTarget);
id = $shortcut.data('menu');
res_id = $shortcut.data('res');
this.listview = new openerp.web_mobile.ListView(this, "oe_list", res_id);
this.listview.start();
if(!$('#oe_list').html().length){
this.listview = new openerp.web_mobile.ListView(this, "oe_list", res_id);
this.listview.start();
}else{
$('#oe_list').remove();
$('<div id="oe_list" data-role="page"> </div>').appendTo('#moe');
this.listview = new openerp.web_mobile.ListView(this, "oe_list", res_id);
this.listview.start();
}
jQuery("#oe_header").find("h1").html($shortcut.data('name'));
}
});
@ -192,37 +200,15 @@ openerp.web_mobile.Menu = openerp.web.Widget.extend({
this.$element
.removeClass("login_valid")
.addClass("secondary_menu");
//.hide();
/*if(!$('#oe_sec_menu').html().length){
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
this.secondary.start();
}else{
//console.log('heree>>>>>>>>>>>>>>>>>>',$('#'+$('.ui-page-active').attr('id')));
var id=$('.ui-page-active').attr('id');
//console.log('heree>>>>>>>>>>>>>>>>>>',$('#'+id).removeClass('ui-page-active'));
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
this.secondary.start();
$('#'+id).removeClass('ui-page-active');
$('#oe_sec_menu').addClass('ui-page-active');
//console.log();
$.mobile.changePage($("#oe_menu"), "slide", true, true);
//if($('.ui-page-active').attr('id').live())
//$.mobile.changePage($("#oe_sec_menu"), "slide", true, true);
// this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
// this.secondary.start();
//$.mobile.loadPage();
//$.mobile.changePage($("#oe_sec_menu"), "slide", true, true);
//this.$element.find("#content").find('a').attr('href','#oe_sec_menu');
}*/
if(!$('#oe_sec_menu').html().length){
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
this.secondary.start();
}else{
$.mobile.changePage($("#oe_sec_menu"), "slide", true, true);
$('#oe_sec_menu').remove();
$('<div id="oe_sec_menu" data-role="page"> </div>').appendTo('#moe');
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
this.secondary.start();
}
}
});
@ -233,20 +219,6 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
},
start: function(ev, id) {
var self = this;
/* if(this.$element.html().length){
self.$element.find('[data-role="listview"]').remove();
_.each(self.data.children,function(i){
var newul = '<ul data-dividertheme="b" class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-theme="c" data-inset="true" data-role="listview"><li data-role="list-divider">'+
i.name+'</li></ul>'; // Create New List Item
self.$element.find('#content').append(newul);
//console.log('in for loop',i.children);
});
console.log('saaasasaaa',self.$element.find('#content'),self.data);
//self.$element.find('[data-role="listview"]').listview('refresh');
}else{*/
var v = { menu : this.data };
this.$element.html(QWeb.render("Menu.secondary", v));
@ -281,8 +253,15 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
var $menu = $(ev.currentTarget);
id = $menu.data('menu');
if (id) {
this.listview = new openerp.web_mobile.ListView(this, "oe_list", id);
this.listview.start();
if(!$('#oe_list').html().length){
this.listview = new openerp.web_mobile.ListView(this, "oe_list", id);
this.listview.start();
}else{
$('#oe_list').remove();
$('<div id="oe_list" data-role="page"> </div>').appendTo('#moe');
this.listview = new openerp.web_mobile.ListView(this, "oe_list", id);
this.listview.start();
}
}
jQuery("#oe_header").find("h1").html($menu.data('name'));
}
@ -301,7 +280,6 @@ openerp.web_mobile.Options = openerp.web.Widget.extend({
}
else{
$.mobile.changePage($("#oe_shortcuts"), "slide", true, true);
//self.$element.find("#footer").find('#shrotcuts').attr('href','#oe_shortcuts');
}
});
this.$element.find("[data-role=header]").find('#home').click(function(){

View File

@ -24,38 +24,29 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
var self = this;
var dataset = new openerp.web.DataSetStatic(this, this.action.res_model, this.action.context);
dataset.name_search('', [], 'ilike',false ,function(result){
if(self.$element.html().length){
self.$element.find('[data-role="listview"]').find('li').remove();
for(var i=0;i<result.length;i++){
var newli = '<li><a id="list-id" data-id='+ result[i][0] +' href="#">' + result[i][1] + '</a></li>'; // Create New List Item
self.$element.find('[data-role="listview"]').append(newli);
self.$element.html(QWeb.render("ListView", {'records' : result}));
self.$element.find("[data-role=header]").find('h1').html(self.action.name);
self.$element.find("[data-role=header]").find('#home').click(function(){
$.mobile.changePage($("#oe_menu"), "slide", true, true);
});
self.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){
if(!$('#oe_shortcuts').html().length){
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
this.shortcuts.start();
}
self.$element.find('[data-role="listview"]').listview('refresh');
}else{
self.$element.html(QWeb.render("ListView", {'records' : result}));
self.$element.find("[data-role=header]").find('h1').html(self.action.name);
self.$element.find("[data-role=header]").find('#home').click(function(){
$.mobile.changePage($("#oe_menu"), "slide", true, true);
});
self.$element.find("[data-role=footer]").find('#shortcuts').click(function(){
if(!$('#oe_shortcuts').html().length){
this.shortcut = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
this.shortcut.start();
}
else{
$.mobile.changePage($("#oe_shortcuts"), "slide", true, true);
}
});
self.$element.find("[data-role=footer]").find('#preference').click(function(){
if(!$('#oe_options').html().length){
this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start();
}
else{
$.mobile.changePage($("#oe_options"), "slide", true, true);
}
});
}
else{
$.mobile.changePage($("#oe_shortcuts"), "slide", true, true);
}
});
self.$element.find("[data-role=footer]").find('#preference').click(function(){
if(!$('#oe_options').html().length){
this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start();
}
else{
$.mobile.changePage($("#oe_options"), "slide", true, true);
}
});
self.$element.find("a#list-id").click(self.on_list_click);
$.mobile.changePage($("#oe_list"), "slide", true, true);
});