forked from alunny/pg-training
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
alunny
committed
Jun 17, 2010
1 parent
37c7ec8
commit b1b83b8
Showing
3 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
storing our JavaScript in a separate file allows us to manage | ||
our app's behaviour separately from the markup and presentation | ||
if you have a larger app, you will want to split your application | ||
code into multiple js files | ||
**/ | ||
|
||
function loadItUp(initializationFunction) { | ||
if (document.readyState == 'loaded' || document.readyState == 'complete') { | ||
initializationFunction(); | ||
} else { | ||
if (navigator.userAgent.indexOf('Browzr') > -1) { | ||
setTimeout(initializationFunction, 250) | ||
} else { | ||
document.addEventListener('deviceready', initializationFunction, false); | ||
} | ||
} | ||
} | ||
|
||
function appInit() { | ||
// there are 4 interaction points in the app: | ||
// "Show My Location" button (welcome view) | ||
document.getElementById('map_button').ontouchend = function () { | ||
displayView('map'); | ||
} | ||
|
||
// "Settings" button (welcome view) | ||
document.getElementById('settings_button').ontouchend = function () { | ||
displayView('settings'); | ||
} | ||
|
||
// "Go Back" button (map view) | ||
document.getElementById('back_button').ontouchend = function () { | ||
displayView('welcome'); | ||
} | ||
|
||
// "Save" button (settings view) | ||
// we want to override the default behaviour, so we return false | ||
document.getElementById('save_button').ontouchend = function () { | ||
displayView('welcome'); | ||
return false; | ||
} | ||
} | ||
|
||
// this function will allow us to hide the current view and | ||
// to display a new one | ||
function displayView(id) { | ||
var views = ["welcome", "map", "settings"]; | ||
var i=0; | ||
|
||
while (i < views.length) { | ||
if (views[i]==id) { | ||
document.getElementById(id).style.display = "block"; | ||
} else { | ||
document.getElementById(views[i]).style.display = "none"; | ||
} | ||
i++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,74 @@ | ||
body { | ||
background: blue; | ||
margin: 0; | ||
font: 18px Helvetica; | ||
text-align: center; | ||
} | ||
|
||
#title_bar { | ||
background: black; | ||
color: white; | ||
height: 25px; | ||
padding: 10px 5%; | ||
width: 90%; | ||
} | ||
|
||
.app_button { | ||
background: gold; | ||
border: khaki; | ||
margin: 15px auto; | ||
padding: 5px; | ||
width: 200px; | ||
-webkit-border-radius: 5px; | ||
} | ||
|
||
#back_button { | ||
background: grey; | ||
} | ||
|
||
/** | ||
* Since all of the views are the same, we'll set them to static widths and heights to match our device. | ||
**/ | ||
|
||
.view { | ||
width: 320px; | ||
height: 480px; | ||
} | ||
/* on the iPhone, we have to account for the 20px status bar at the top */ | ||
/* 480 - 20 = 460 */ | ||
/* then 460 - 40 to account for our title bar */ | ||
height: 420px; | ||
|
||
/* only one view is displayed at a time | ||
so we'll set the views to default to be un-displayed | ||
and then override this based on the element id */ | ||
display: none; | ||
} | ||
/* our three views */ | ||
#welcome { | ||
display: block; | ||
} | ||
#settings { | ||
background: white; | ||
} | ||
#map { | ||
background: black; | ||
color: white; | ||
} | ||
|
||
.map_image { | ||
margin: auto; | ||
height: 250px; | ||
padding-top: 35px; | ||
width: 250px; | ||
} | ||
|
||
#settings_form { | ||
display: block; | ||
padding: 20px; | ||
} | ||
|
||
button { | ||
font: 18px Helvetica; | ||
height: 30px; | ||
width: 100px; | ||
-webkit-appearance:push-button; | ||
} |