Permalink
Browse files

Update from apache/cordova-app-hello-world

  • Loading branch information...
1 parent b4b149c commit 4484b29eb15f3fff2347bdd480f319c0c47499c7 @mwbrooks mwbrooks committed Apr 23, 2013
View
@@ -17,13 +17,13 @@
* under the License.
*/
* {
- -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
- -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
-webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
- -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
}
body {
+ -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
+ -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
+ -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
background-color:#E4E4E4;
background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
@@ -78,8 +78,7 @@ h1 {
text-align:center;
}
-.status {
- background-color:#333333;
+.event {
border-radius:4px;
-webkit-border-radius:4px;
color:#FFFFFF;
@@ -88,11 +87,13 @@ h1 {
padding:2px 0px;
}
-.status.complete {
- background-color:#4B946A;
+.event.listening {
+ background-color:#333333;
+ display:block;
}
-.hide {
+.event.received {
+ background-color:#4B946A;
display:none;
}
View
@@ -19,7 +19,7 @@
-->
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
@@ -28,9 +28,9 @@
<body>
<div class="app">
<h1>PhoneGap</h1>
- <div id="deviceready">
- <p class="status pending blink">Connecting to Device</p>
- <p class="status complete blink hide">Device is Ready</p>
+ <div id="deviceready" class="blink">
+ <p class="event listening">Connecting to Device</p>
+ <p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="phonegap.js"></script>
View
@@ -17,26 +17,33 @@
* under the License.
*/
var app = {
+ // Application Constructor
initialize: function() {
- this.bind();
+ this.bindEvents();
},
- bind: function() {
- document.addEventListener('deviceready', this.deviceready, false);
+ // Bind Event Listeners
+ //
+ // Bind any events that are required on startup. Common events are:
+ // 'load', 'deviceready', 'offline', and 'online'.
+ bindEvents: function() {
+ document.addEventListener('deviceready', this.onDeviceReady, false);
},
- deviceready: function() {
- // This is an event handler function, which means the scope is the event.
- // So, we must explicitly called `app.report()` instead of `this.report()`.
- app.report('deviceready');
+ // deviceready Event Handler
+ //
+ // The scope of 'this' is the event. In order to call the 'receivedEvent'
+ // function, we must explicity call 'app.receivedEvent(...);'
+ onDeviceReady: function() {
+ app.receivedEvent('deviceready');
},
- report: function(id) {
- // Report the event in the console
- console.log("Report: " + id);
+ // Update DOM on a Received Event
+ receivedEvent: function(id) {
+ var parentElement = document.getElementById(id);
+ var listeningElement = parentElement.querySelector('.listening');
+ var receivedElement = parentElement.querySelector('.received');
- // Toggle the state from "pending" to "complete" for the reported ID.
- // Accomplished by adding .hide to the pending element and removing
- // .hide from the complete element.
- document.querySelector('#' + id + ' .pending').className += ' hide';
- var completeElem = document.querySelector('#' + id + ' .complete');
- completeElem.className = completeElem.className.split('hide').join('');
+ listeningElement.setAttribute('style', 'display:none;');
+ receivedElement.setAttribute('style', 'display:block;');
+
+ console.log('Received Event: ' + id);
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,3 @@
+# Tizen Splash Screen
+
+Splash screens are unsupported on the Tizen platform.
View
@@ -25,5 +25,9 @@ var helper = {
var e = document.createEvent('Event');
e.initEvent(name, true, true);
obj.dispatchEvent(e);
+ },
+ getComputedStyle: function(querySelector, property) {
+ var element = document.querySelector(querySelector);
+ return window.getComputedStyle(element).getPropertyValue(property);
}
};
View
@@ -20,48 +20,48 @@ describe('app', function() {
describe('initialize', function() {
it('should bind deviceready', function() {
runs(function() {
- spyOn(app, 'deviceready');
+ spyOn(app, 'onDeviceReady');
app.initialize();
helper.trigger(window.document, 'deviceready');
});
waitsFor(function() {
- return (app.deviceready.calls.length > 0);
- }, 'deviceready should be called once', 500);
+ return (app.onDeviceReady.calls.length > 0);
+ }, 'onDeviceReady should be called once', 500);
runs(function() {
- expect(app.deviceready).toHaveBeenCalled();
+ expect(app.onDeviceReady).toHaveBeenCalled();
});
});
});
- describe('deviceready', function() {
+ describe('onDeviceReady', function() {
it('should report that it fired', function() {
- spyOn(app, 'report');
- app.deviceready();
- expect(app.report).toHaveBeenCalledWith('deviceready');
+ spyOn(app, 'receivedEvent');
+ app.onDeviceReady();
+ expect(app.receivedEvent).toHaveBeenCalledWith('deviceready');
});
});
- describe('report', function() {
+ describe('receivedEvent', function() {
beforeEach(function() {
var el = document.getElementById('stage');
el.innerHTML = ['<div id="deviceready">',
- ' <p class="status pending">Pending</p>',
- ' <p class="status complete hide">Complete</p>',
+ ' <p class="event listening">Listening</p>',
+ ' <p class="event received">Received</p>',
'</div>'].join('\n');
});
- it('should show the completion state', function() {
- app.report('deviceready');
- var el = document.querySelector('#deviceready .complete:not(.hide)');
- expect(el).toBeTruthy();
+ it('should hide the listening element', function() {
+ app.receivedEvent('deviceready');
+ var displayStyle = helper.getComputedStyle('#deviceready .listening', 'display');
+ expect(displayStyle).toEqual('none');
});
- it('should hide the pending state', function() {
- app.report('deviceready');
- var el = document.querySelector('#deviceready .pending.hide');
- expect(el).toBeTruthy();
+ it('should show the received element', function() {
+ app.receivedEvent('deviceready');
+ var displayStyle = helper.getComputedStyle('#deviceready .received', 'display');
+ expect(displayStyle).toEqual('block');
});
});
});

0 comments on commit 4484b29

Please sign in to comment.