Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile
Accepted Solution

Script to modify element using screen orientation not working on Dev Alpha in Portrait mode

[ Edited ]

Ok, so I wanted to update my WebWorks Testing app (https://github.com/SCrid2000/WebWorks-Testing) to make it easier to test webworks apps for the difference in screen resolution between the Dev Alpha and the forthcoming BlackBerry 10.


Basically, rather than opening your html, js, and css files directly in the testing app, the update would open your files in an iframe within the app. The iframe will resize based on the device orientation.

The javascript function looks like this:

 

function displayCurrentOrientation() {
	
	if (window.orientation === 0) {
		document.getElementById("currentOrientation").width = '1280px'; 
		document.getElementById("currentOrientation").height = '720px'; 
		return false;
	}	
	if (window.orientation === 90) {
		document.getElementById("currentOrientation").width = '720px'; 
		document.getElementById("currentOrientation").height = '1280px'; 
		return false;
	}
	if (window.orientation === 180) {
		document.getElementById("currentOrientation").width = '1280px'; 
		document.getElementById("currentOrientation").height = '720px'; 
		return false;
	}
	if (window.orientation === -90) {
		document.getElementById("currentOrientation").width = '720px'; 
		document.getElementById("currentOrientation").height = '1280px'; 
		return false;
	}
}

 

Now it works just perfect on the PlayBook (but obviously that's not much help for testing for BB10)

However, on the Dev Alpha it ONLY works in LANDSCAPE; that is, if the app is  launched in landscape, the iframe rezises and everything is just perfect. If the testing app is launched in portrait, the iframe is still resized to the portrait size.

 

Does anyone have any suggestions for what I'm doing wrong? I'm totally at a loss here (and since it's a free and open source app, I'm not too motivated to spend another couple hours trying to fix it lol).

Thanks.

Shane

-----------------------------------------------------------------------------------------



Please use plain text.
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: Script to modify element using screen orientation not working on Dev Alpha in Portrait mode

Nevermind, turns out this isn't supported yet in BB10.
-----------------------------------------------------------------------------------------



Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 822
Registered: ‎07-15-2008
My Device: Z10
My Carrier: Bell

Re: Script to modify element using screen orientation not working on Dev Alpha in Portrait mode

So did you confirm that the orientation events are not firing in the Dev Alpha Beta OS?

 

There is a small error in your config file:

https://github.com/SCrid2000/WebWorks-Testing/blob/master/Source/BB10/config.xml#L32

 

Tim Windsor
Application Development Advisor II
Please use plain text.
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: Script to modify element using screen orientation not working on Dev Alpha in Portrait mode

Oops!
That line isn't in the config that was used in the nonworking version, but thanks for pointing that out!
-----------------------------------------------------------------------------------------



Please use plain text.