提交 37937550 编写于 作者: G Gabriele Cirulli

add app notice

上级 b56159b5
...@@ -3,7 +3,7 @@ CACHE MANIFEST ...@@ -3,7 +3,7 @@ CACHE MANIFEST
# Adds the ability to play the game online. # Adds the ability to play the game online.
# The following comment needs to be updated whenever a change is made. # The following comment needs to be updated whenever a change is made.
# Run `rake appcache:update` to do so # Run `rake appcache:update` to do so
# Updated: 2014-03-27T17:09:22+01:00 # Updated: 2014-04-28T12:49:34+02:00
# Main page # Main page
index.html index.html
......
...@@ -35,6 +35,11 @@ ...@@ -35,6 +35,11 @@
<a class="restart-button">New Game</a> <a class="restart-button">New Game</a>
</div> </div>
<div class="app-notice">
<span class="notice-close-button">x</span>
<p><strong class="important">New:</strong> Get the new 2048 app for <a href="https://itunes.apple.com/us/app/2048-by-gabriele-cirulli/id868076805" target="_blank">iOS</a> and <a href="https://play.google.com/store/apps/details?id=com.gabrielecirulli.app2048" target="_blank">Android!</a></p>
</div>
<div class="game-container"> <div class="game-container">
<div class="game-message"> <div class="game-message">
<p></p> <p></p>
......
// Wait till the browser is ready to render the game (avoids glitches) // Wait till the browser is ready to render the game (avoids glitches)
window.requestAnimationFrame(function () { window.requestAnimationFrame(function () {
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager); new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
// TODO: This code is in need of a refactor (along with the rest)
var storage = new LocalStorageManager;
var noticeClose = document.querySelector(".notice-close-button");
var notice = document.querySelector(".app-notice");
if (storage.getNoticeClosed()) {
notice.parentNode.removeChild(notice);
} else {
noticeClose.addEventListener("click", function () {
notice.parentNode.removeChild(notice);
storage.setNoticeClosed(true);
ga("send", "event", "notice", "closed");
});
}
}); });
...@@ -21,6 +21,7 @@ window.fakeStorage = { ...@@ -21,6 +21,7 @@ window.fakeStorage = {
function LocalStorageManager() { function LocalStorageManager() {
this.bestScoreKey = "bestScore"; this.bestScoreKey = "bestScore";
this.gameStateKey = "gameState"; this.gameStateKey = "gameState";
this.noticeClosedKey = "noticeClosed";
var supported = this.localStorageSupported(); var supported = this.localStorageSupported();
this.storage = supported ? window.localStorage : window.fakeStorage; this.storage = supported ? window.localStorage : window.fakeStorage;
...@@ -61,3 +62,11 @@ LocalStorageManager.prototype.setGameState = function (gameState) { ...@@ -61,3 +62,11 @@ LocalStorageManager.prototype.setGameState = function (gameState) {
LocalStorageManager.prototype.clearGameState = function () { LocalStorageManager.prototype.clearGameState = function () {
this.storage.removeItem(this.gameStateKey); this.storage.removeItem(this.gameStateKey);
}; };
LocalStorageManager.prototype.setNoticeClosed = function (noticeClosed) {
this.storage.setItem(this.noticeClosedKey, JSON.stringify(noticeClosed));
};
LocalStorageManager.prototype.getNoticeClosed = function () {
return JSON.parse(this.storage.getItem(this.noticeClosedKey) || "false");
};
...@@ -919,7 +919,7 @@ hr { ...@@ -919,7 +919,7 @@ hr {
opacity: 1; opacity: 1;
top: -45px; top: -45px;
pointer-events: auto; } pointer-events: auto; }
@media screen and (max-width: 480px) { @media screen and (max-width: 520px) {
.btc-donate { .btc-donate {
width: 120px; } width: 120px; }
.btc-donate .address { .btc-donate .address {
...@@ -930,3 +930,123 @@ hr { ...@@ -930,3 +930,123 @@ hr {
.btc-donate .address:after { .btc-donate .address:after {
left: 50%; left: 50%;
bottom: 2px; } } bottom: 2px; } }
@-webkit-keyframes pop-in-big {
0% {
-webkit-transform: scale(0) translateZ(0);
-moz-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
opacity: 0;
margin-top: -56px; }
100% {
-webkit-transform: scale(1) translateZ(0);
-moz-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
opacity: 1;
margin-top: 30px; } }
@-moz-keyframes pop-in-big {
0% {
-webkit-transform: scale(0) translateZ(0);
-moz-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
opacity: 0;
margin-top: -56px; }
100% {
-webkit-transform: scale(1) translateZ(0);
-moz-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
opacity: 1;
margin-top: 30px; } }
@keyframes pop-in-big {
0% {
-webkit-transform: scale(0) translateZ(0);
-moz-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
opacity: 0;
margin-top: -56px; }
100% {
-webkit-transform: scale(1) translateZ(0);
-moz-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
opacity: 1;
margin-top: 30px; } }
@-webkit-keyframes pop-in-small {
0% {
-webkit-transform: scale(0) translateZ(0);
-moz-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
opacity: 0;
margin-top: -76px; }
100% {
-webkit-transform: scale(1) translateZ(0);
-moz-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
opacity: 1;
margin-top: 10px; } }
@-moz-keyframes pop-in-small {
0% {
-webkit-transform: scale(0) translateZ(0);
-moz-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
opacity: 0;
margin-top: -76px; }
100% {
-webkit-transform: scale(1) translateZ(0);
-moz-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
opacity: 1;
margin-top: 10px; } }
@keyframes pop-in-small {
0% {
-webkit-transform: scale(0) translateZ(0);
-moz-transform: scale(0) translateZ(0);
transform: scale(0) translateZ(0);
opacity: 0;
margin-top: -76px; }
100% {
-webkit-transform: scale(1) translateZ(0);
-moz-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
opacity: 1;
margin-top: 10px; } }
.app-notice {
position: relative;
-webkit-animation: pop-in-big 700ms ease 2s both;
-moz-animation: pop-in-big 700ms ease 2s both;
animation: pop-in-big 700ms ease 2s both;
background: #edc53f;
color: white;
padding: 18px;
margin-top: 30px;
height: 56px;
box-sizing: border-box;
border-radius: 3px; }
.app-notice:after {
content: "";
display: block;
clear: both; }
.app-notice .notice-close-button {
float: right;
font-weight: bold;
cursor: pointer;
margin-left: 10px;
opacity: 0.7; }
.app-notice p {
margin-bottom: 0; }
.app-notice, .app-notice p {
line-height: 20px; }
.app-notice a {
color: white; }
@media screen and (max-width: 520px) {
.app-notice {
-webkit-animation: pop-in-small 700ms ease 2s both;
-moz-animation: pop-in-small 700ms ease 2s both;
animation: pop-in-small 700ms ease 2s both;
margin-top: 10px;
height: 76px; } }
...@@ -752,7 +752,7 @@ hr { ...@@ -752,7 +752,7 @@ hr {
} }
// Styles for small screens // Styles for small screens
@include smaller(480px) { @include smaller($mobile-threshold) {
width: 120px; width: 120px;
.address { .address {
...@@ -771,3 +771,76 @@ hr { ...@@ -771,3 +771,76 @@ hr {
} }
} }
} }
@include keyframes(pop-in-big) {
0% {
@include transform(scale(0) translateZ(0));
opacity: 0;
margin-top: -56px;
}
100% {
@include transform(scale(1) translateZ(0));
opacity: 1;
margin-top: 30px;
}
}
@include keyframes(pop-in-small) {
0% {
@include transform(scale(0) translateZ(0));
opacity: 0;
margin-top: -76px;
}
100% {
@include transform(scale(1) translateZ(0));
opacity: 1;
margin-top: 10px;
}
}
.app-notice {
position: relative;
@include animation(pop-in-big 700ms ease 2s both);
background: #edc53f;
color: white;
padding: 18px;
margin-top: 30px;
height: 56px;
box-sizing: border-box;
border-radius: $tile-border-radius;
&:after {
content: "";
display: block;
clear: both;
}
.notice-close-button {
float: right;
font-weight: bold;
cursor: pointer;
margin-left: 10px;
opacity: 0.7;
}
p {
margin-bottom: 0;
// float: left;
}
&, p {
line-height: 20px;
}
a {
color: white;
}
@include smaller($mobile-threshold) {
@include animation(pop-in-small 700ms ease 2s both);
margin-top: 10px;
height: 76px;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册