From 6d198182da20a2961240bfb7b8dc9000ade2f1ef Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Thu, 22 Mar 2012 13:19:47 -0400 Subject: [PATCH] added new (android toast like) notification --- app/source/TodoTxt.js | 16 +++++++++++++--- app/source/styles.css | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/source/TodoTxt.js b/app/source/TodoTxt.js index 9c59e42..6155343 100644 --- a/app/source/TodoTxt.js +++ b/app/source/TodoTxt.js @@ -57,6 +57,7 @@ enyo.kind({ onPrefReset: "resetPreferences" } ]}, + {name: "toaster", kind: "HtmlContent"}, {name: "dropbox", kind: "Dropbox", onAuthSuccess: "enableDropbox", onAuthFailure: "disableDropbox", @@ -298,7 +299,7 @@ enyo.kind({ if (inEvent.error) { console.log("error: "+inEvent.error.message); } else { - enyo.windows.addBannerMessage(inEvent.path + " saved", "{}"); + this.showToast(inEvent.path + " saved"); console.log(inEvent.path + " saved..."); console.log(inEvent.bytes + " bytes..."); } @@ -377,7 +378,7 @@ enyo.kind({ } else { console.log("went offline..."); if (this.preferences["offline"] == false) { - enyo.windows.addBannerMessage("offline mode", "{}"); + this.showToast("offline mode"); this.preferences["offline"] = true; this.$.preferenceView.$.offline.setChecked(true); } @@ -387,7 +388,7 @@ enyo.kind({ fail: function(inSender, inResponse, inRequest) { console.log("error"); console.log(JSON.stringify(inResponse)); - enyo.windows.addBannerMessage(inResponse.error, "{}"); + this.showToast(inResponse.error); }, enableDropbox: function() { @@ -413,6 +414,15 @@ enyo.kind({ this.preferences["dboxtoken"] = ""; this.preferences["dboxsecret"] = ""; localStorage.setItem("TodoPreferences", JSON.stringify(this.preferences)); + }, + + showToast: function(message) { + this.$.toaster.setContent("
" + + message + "
"); + window.setTimeout(function () { + var toast = document.getElementById("toast"); + toast.style.opacity = 0; + }, 1000); } }); diff --git a/app/source/styles.css b/app/source/styles.css index 9b89907..245cf9c 100644 --- a/app/source/styles.css +++ b/app/source/styles.css @@ -34,3 +34,17 @@ .ver-history { font-size: 16px; } .version { font-weight: bold;} .enyo-modaldialog > * { height:100%; } +#toast { + position: fixed; + bottom: 20%; + left: 50%; + width: 200px; + margin-left: -100px; + border: 1px solid #666; + background-color: #444; + color: #FFF; + padding: 10px 0 ; + text-align:center; + opacity: .9; + -webkit-transition: opacity 0.5s ease-out; +}