incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwbro...@apache.org
Subject [7/10] git commit: Refactor report function.
Date Tue, 17 Jul 2012 05:06:36 GMT
Refactor report function.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/0a1450a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/0a1450a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/0a1450a3

Branch: refs/heads/hello-cordova
Commit: 0a1450a305ea9fcaad6bcb0bc3b981025a1e8228
Parents: 6c162b3
Author: Michael Brooks <michael@michaelbrooks.ca>
Authored: Sat Jul 14 11:39:35 2012 -0700
Committer: Michael Brooks <michael@michaelbrooks.ca>
Committed: Sat Jul 14 11:39:35 2012 -0700

----------------------------------------------------------------------
 www/css/index.css |    4 ++--
 www/index.html    |    6 ++++--
 www/js/index.js   |    3 ++-
 www/spec/index.js |   20 +++++++++++++++++---
 4 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0a1450a3/www/css/index.css
----------------------------------------------------------------------
diff --git a/www/css/index.css b/www/css/index.css
index 972e500..1f5c6a1 100644
--- a/www/css/index.css
+++ b/www/css/index.css
@@ -42,7 +42,7 @@ h1 {
     text-align:center;
 }
 
-.report {
+.status {
     background-color:#333333;
     -webkit-border-radius:4px;
     -moz-border-radius:4px;
@@ -56,7 +56,7 @@ h1 {
     width:200px;
 }
 
-.report-on {
+.status.complete {
     background-color:#4B946A;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0a1450a3/www/index.html
----------------------------------------------------------------------
diff --git a/www/index.html b/www/index.html
index c7c9069..6e035b1 100644
--- a/www/index.html
+++ b/www/index.html
@@ -10,8 +10,10 @@
     <body>
         <div class="logo"></div>
         <h1>Apache Cordova™</h1>
-        <p class="report report-off blink">Establishing Connection</p>
-        <p class="report report-on blink hide">Connection Ready</p>
+        <div id="deviceready">
+            <p class="status pending blink">Connecting to Device</p>
+            <p class="status complete blink hide">Device is Ready</p>
+        </div>
 
         <script type="text/javascript" src="js/index.js"></script>
         <script type="text/javascript">

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0a1450a3/www/js/index.js
----------------------------------------------------------------------
diff --git a/www/js/index.js b/www/js/index.js
index aa84f8c..f3894b8 100644
--- a/www/js/index.js
+++ b/www/js/index.js
@@ -9,6 +9,7 @@ var app = {
         app.report('deviceready');
     },
     report: function(id) {
-        document.getElementById(id).innerHTML= 'ok';
+        document.querySelector('#' + id + ' .pending').classList.add('hide');
+        document.querySelector('#' + id + ' .complete').classList.remove('hide');
     }
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0a1450a3/www/spec/index.js
----------------------------------------------------------------------
diff --git a/www/spec/index.js b/www/spec/index.js
index 74d9062..121cf63 100644
--- a/www/spec/index.js
+++ b/www/spec/index.js
@@ -26,10 +26,24 @@ describe('app', function() {
     });
 
     describe('report', function() {
-        it('should report "ok" for the given ID', function() {
-            document.getElementById('stage').innerHTML = '<span id="deviceready"></span>';
+        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>',
+                            '</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 pending state', function() {
             app.report('deviceready');
-            expect(document.getElementById('deviceready').innerHTML).toEqual('ok');
+            var el = document.querySelector('#deviceready .pending.hide');
+            expect(el).toBeTruthy();
         });
     });
 });


Mime
View raw message