From 90128f42d7ec868ad871d0bab92e3c18cf0035f6 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Thu, 9 Mar 2017 17:55:03 -0800 Subject: [PATCH] update look and feel of demo, add/remove event listeners --- demo/www/css/index.css | 28 ++++++++++++++++------------ demo/www/index.html | 18 +++++++++++++----- demo/www/js/index.js | 26 +++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/demo/www/css/index.css b/demo/www/css/index.css index 51daa79..bb118ff 100644 --- a/demo/www/css/index.css +++ b/demo/www/css/index.css @@ -41,22 +41,13 @@ body { height:100%; margin:0px; padding:0px; - text-transform:uppercase; + padding-top:20px; width:100%; } /* Portrait layout (default) */ .app { - background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */ - position:absolute; /* position in the center of the screen */ - left:50%; - top:50%; - height:50px; /* text area height */ - width:225px; /* text area width */ text-align:center; - padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */ - margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */ - /* offset horizontal: half of text area width */ } /* Landscape layout (with min-width) */ @@ -69,6 +60,19 @@ body { } } +button { + border:solid 1px #946A4b; + background:#666; + color:#fff; + border-radius:4px; + -webkit-border-radius:4px; + font-size:12px; + + margin:8px; + padding:6px; + width:128px; +} + h1 { font-size:24px; font-weight:normal; @@ -102,13 +106,13 @@ h1 { 50% { opacity: 0.4; } to { opacity: 1.0; } } - + @-webkit-keyframes fade { from { opacity: 1.0; } 50% { opacity: 0.4; } to { opacity: 1.0; } } - + .blink { animation:fade 3000ms infinite; -webkit-animation:fade 3000ms infinite; diff --git a/demo/www/index.html b/demo/www/index.html index e4d5114..f88b9cd 100644 --- a/demo/www/index.html +++ b/demo/www/index.html @@ -7,9 +7,9 @@ to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -42,6 +42,7 @@

Connecting to Device

Device is Ready

+

Set screen.orientation.lock();

@@ -50,9 +51,16 @@
- - - +
+ +
+ +

Listen for events

+
+ + +
diff --git a/demo/www/js/index.js b/demo/www/js/index.js index 8512912..1210f48 100644 --- a/demo/www/js/index.js +++ b/demo/www/js/index.js @@ -66,12 +66,32 @@ var app = { btnAny.addEventListener("click", function() { screen.orientation.unlock(); }); - btnOnchange.addEventListener("click", function() { - screen.orientation.onchange = myFunction1(); + var hasOnChange = false; + btnOnchange.addEventListener("click", function() { + if(hasOnChange) { + screen.orientation.onchange = undefined; + btnOnchange.innerText = "assign onchange"; + } + else { + screen.orientation.onchange = myFunction1; + btnOnchange.innerText = "remove onchange"; + } + hasOnChange = !hasOnChange; }); + + var hasListener = false; btnAddEvtListener.addEventListener("click", function() { - screen.orientation.addEventListener('change', myFunction2(), true); + if(hasListener) { + screen.orientation.removeEventListener('change', myFunction2); + btnAddEvtListener.innerText = "addEventListener"; + } + else { + screen.orientation.addEventListener('change', myFunction2); + btnAddEvtListener.innerText = "remEventListener"; + } + hasListener = !hasListener; + });