pellyadolfo
4 Jan 2012, 6:51 PM
I am having an issue for 2 days and so far no luck. I intend to add/remove a top dockeditem holding iAd adverts to my TabPanel. I want to 'add' when there is connection on the device (iPhone with phonegap) and 'remove' when there is not.
Some code snippets isolating the issue:
The static part, declaring the TabPanel with a test item and its corresponding tabBar.
Ext.setup({
statusBarStyle: 'black',
onReady: function() {
com.vaalbara.App = new com.vaalbara.App({});
}
});
com.vaalbara.App = Ext.extend(Ext.TabPanel, {
fullscreen: true,
layout: 'auto',
scroll: false,
tabBar: {
dock: 'bottom',
layout: { pack: 'center' }
},
cardSwitchAnimation: false,
initComponent: function() {
this.items = [{
html:'test html',
iconMask: true,
iconCls: 'home'
}];
com.vaalbara.App.superclass.initComponent.call(this);
}
});
Ext.reg('App', com.vaalbara.App);
The script in the html page which adds and remove the dockeditem to previous tabpanel.
if (navigator.onLine)
addAdsAndSpace();
else removeAdAndSpace();
function addAdsAndSpace() {
com.vaalbara.App.addDocked({
html: '<iframe src =\"\" width=\"100%\" height=\"50\" frameBorder=\"0\" scrolling=\"no\"></iframe>',
id: 'advertTab',
border: false,
dock: 'top',
scroll: false
});
window.plugins.iAdPlugin.showAd(true);
}
function removeAdAndSpace() {
window.plugins.iAdPlugin.showAd(false);
var advertTab = com.vaalbara.App.getDockedComponent('advertTab');
if(advertTab != null) {
com.vaalbara.App.removeDocked(advertTab, true);
/*com.vaalbara.App.body.setStyle({
top: 0, //top + tb.thisHeight + "px",
height: height + 50 + "px"
);*/
com.vaalbara.App.doComponentLayout(/*width, height*/);
}
}
As shown in the picture below, 'add' works great. The problem basically is that, on 'remove'ing the docked item, I am not able to instruct the TabPanel to resize and get rid of the white space.
30464
I have tried all kind of combinations, setStyle, specifying width and height in doComponentLayout, do Layout, destroy manually.... but nothings seems to work ok.
30465
The setStyle actually moves the center 'test html' item to the space left by the removed advert on top but, in that case there is a blank space between the 'test html' item and the bottom navigation bar.
I have also tried to add the listeners proposed here (http://www.sencha.com/forum/showthread.php?150658)but TabPanel does not seem to call those listeners in any case.
Any help or pointer would be really appreciated as I am really stuck with the issue and I do not think it would be approved in the AppStore leaving the white space as is.
I decided to add the dockeditem to hold the advert after running in the same issue reported here (http://groups.google.com/group/phonegap/browse_thread/thread/2980f33a4d99af09/8a61782c04c50075?lnk=gst&q=iad#8a61782c04c50075) so, I think, this thread, can be a good example of using iAd in Sencha. I have not found any other 'Hello Adverts World' in Sencha. However, I think that, adverts, are not really relevant for the issue.
Thanks.
Some code snippets isolating the issue:
The static part, declaring the TabPanel with a test item and its corresponding tabBar.
Ext.setup({
statusBarStyle: 'black',
onReady: function() {
com.vaalbara.App = new com.vaalbara.App({});
}
});
com.vaalbara.App = Ext.extend(Ext.TabPanel, {
fullscreen: true,
layout: 'auto',
scroll: false,
tabBar: {
dock: 'bottom',
layout: { pack: 'center' }
},
cardSwitchAnimation: false,
initComponent: function() {
this.items = [{
html:'test html',
iconMask: true,
iconCls: 'home'
}];
com.vaalbara.App.superclass.initComponent.call(this);
}
});
Ext.reg('App', com.vaalbara.App);
The script in the html page which adds and remove the dockeditem to previous tabpanel.
if (navigator.onLine)
addAdsAndSpace();
else removeAdAndSpace();
function addAdsAndSpace() {
com.vaalbara.App.addDocked({
html: '<iframe src =\"\" width=\"100%\" height=\"50\" frameBorder=\"0\" scrolling=\"no\"></iframe>',
id: 'advertTab',
border: false,
dock: 'top',
scroll: false
});
window.plugins.iAdPlugin.showAd(true);
}
function removeAdAndSpace() {
window.plugins.iAdPlugin.showAd(false);
var advertTab = com.vaalbara.App.getDockedComponent('advertTab');
if(advertTab != null) {
com.vaalbara.App.removeDocked(advertTab, true);
/*com.vaalbara.App.body.setStyle({
top: 0, //top + tb.thisHeight + "px",
height: height + 50 + "px"
);*/
com.vaalbara.App.doComponentLayout(/*width, height*/);
}
}
As shown in the picture below, 'add' works great. The problem basically is that, on 'remove'ing the docked item, I am not able to instruct the TabPanel to resize and get rid of the white space.
30464
I have tried all kind of combinations, setStyle, specifying width and height in doComponentLayout, do Layout, destroy manually.... but nothings seems to work ok.
30465
The setStyle actually moves the center 'test html' item to the space left by the removed advert on top but, in that case there is a blank space between the 'test html' item and the bottom navigation bar.
I have also tried to add the listeners proposed here (http://www.sencha.com/forum/showthread.php?150658)but TabPanel does not seem to call those listeners in any case.
Any help or pointer would be really appreciated as I am really stuck with the issue and I do not think it would be approved in the AppStore leaving the white space as is.
I decided to add the dockeditem to hold the advert after running in the same issue reported here (http://groups.google.com/group/phonegap/browse_thread/thread/2980f33a4d99af09/8a61782c04c50075?lnk=gst&q=iad#8a61782c04c50075) so, I think, this thread, can be a good example of using iAd in Sencha. I have not found any other 'Hello Adverts World' in Sencha. However, I think that, adverts, are not really relevant for the issue.
Thanks.