forked from alunny/phonegap-start
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kindergarten.js
44 lines (41 loc) · 1.4 KB
/
kindergarten.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Gora: Added for orientation: Needs XUI
function onOrientationChange() {
if( window.orientation == -90 || window.orientation == 90 ) {
// Switch to landscape
alert( "Landscape" );
x$( "#welcome" ).css( "width", "480px" );
// Change main image
var src = x$( "#main-img,#footer-img" ).attr( "src" );
var idx = src.indexOf( "_portrait.jpg" );
if( idx != -1 ) { // Check should not be neeed
x$( "#main-img" ).attr( "src", src.substring( 0, idx ) + ".jpg" );
}
// Change icons
x$( "a.rotate-img" ).each( function() {
src = x$(this).first().attr( "src" );
idx = src.indexOf( "_portrait.jpg" );
if( idx != -1 ) { // Check should not be neeed
x$(this).first().attr( "src", src.substring( 0, idx ) + ".jpg" );
}
});
} else {
// Switch to portrait
alert( "Portrait" );
x$( "#welcome" ).css( "width", "300px" );
// Change main image
var src = x$( "#main-img" ).attr( "src" );
var idx = src.indexOf( ".jpg" );
if( idx != -1 ) { // Check should not be neeed
x$( "#main-img" ).attr( "src", src.substring( 0, idx ) + "_portrait.jpg" );
}
// Change icons
x$( "a.rotate-img" ).each( function() {
src = x$(this).first().attr( "src" );
idx = src.indexOf( ".jpg" );
if( idx != -1 ) { // Check should not be neeed
x$(this).first().attr( "src", src.substring( 0, idx ) + "_portrait.jpg" );
}
});
}
}
x$(window).on('orientationchange', onOrientationChange);