Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Bug 821456] Re-implement system banner in everything.me [r=ranbena, …

…a=vingtetun]
  • Loading branch information...
commit a1e45d17b73966c409b745234ed53340515d338e 1 parent 7fae199
@ranbena ranbena authored
View
24 apps/homescreen/everything.me/js/Brain.js
@@ -574,33 +574,33 @@ Evme.Brain = new function Evme_Brain() {
this.hold = function hold(data) {
var isAppInstalled = Evme.Utils.sendToOS(
Evme.Utils.OSMessages.IS_APP_INSTALLED,
- { "url": data.data.appUrl }
+ { 'url': data.data.appUrl }
);
if (isAppInstalled) {
- var msg = _('app-exists-in-home-screen', {name: data.data.name});
- window.alert(msg);
+ window.alert(Evme.Utils.l10n('alert', 'app-install-exists', {'name': data.data.name}));
return;
}
-
- var msg = _('add-to-home-screen-question', {name: data.data.name})
- var response = window.confirm(msg);
- if (!response) {
+
+ var msg = Evme.Utils.l10n('alert', 'app-install-confirm', {'name': data.data.name});
+ if (!window.confirm(msg)) {
return;
}
-
+
// get icon data
var appIcon = Evme.Utils.formatImageData(data.app.getIcon());
// make it round
Evme.Utils.getRoundIcon(appIcon, function onIconReady(roundedAppIcon) {
// bookmark
Evme.Utils.sendToOS(Evme.Utils.OSMessages.APP_INSTALL, {
- "originUrl": data.app.getFavLink(),
- "title": data.data.name,
- "icon": roundedAppIcon
+ 'originUrl': data.app.getFavLink(),
+ 'title': data.data.name,
+ 'icon': roundedAppIcon
});
// display system banner
- Evme.Banner.show(_('app-added-to-home-screen', {name: data.data.name}));
+ Evme.Banner.show('app-install-success', {
+ 'name': data.data.name
+ });
});
};
View
6 apps/homescreen/everything.me/js/helpers/Utils.js
@@ -49,7 +49,7 @@ Evme.Utils = new function Evme_Utils() {
if (args) {
try {
- attr += ' data-l10n-args="' + JSON.stringify(args) + '"';
+ attr += ' data-l10n-args="' + JSON.stringify(args).replace(/"/g, '"') + '"';
} catch(ex) {
}
@@ -114,7 +114,7 @@ Evme.Utils = new function Evme_Utils() {
};
this.getRoundIcon = function getRoundIcon(imageSrc, callback) {
- var size = Evme.Utils.sendToOS(Evme.Utils.OSMessages.GET_ICON_SIZE) - 2,
+ var size = self.sendToOS(self.OSMessages.GET_ICON_SIZE) - 2,
radius = size/2,
img = new Image();
@@ -155,7 +155,7 @@ Evme.Utils = new function Evme_Utils() {
};
this.getIconGroup = function getIconGroup() {
- return Evme.Utils.cloneObject(Evme.__config.iconsGroupSettings);
+ return self.cloneObject(Evme.__config.iconsGroupSettings);
};
this.getIconsFormat = function getIconsFormat() {
View
12 apps/homescreen/everything.me/modules/Banner/Banner.css
@@ -1,5 +1,5 @@
/* from building blocks, core.css - [role=dialog]*/
-.banner {
+#evmeContainer .banner {
position: absolute;
background: orange;
width: 100%;
@@ -20,26 +20,26 @@
z-index: -1;
opacity: 0;
}
-.banner.visible {
+#evmeContainer .banner.visible {
z-index: 10001;
opacity: 1;
-moz-transition: all 600ms ease;
}
-.banner:before {
+#evmeContainer .banner:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
width: 1px;
}
-.banner:after {
+#evmeContainer .banner:after {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
width: 1px;
}
-.banner > p {
+#evmeContainer .banner > p {
display: inline-block;
font-size: 1.56rem;
line-height: 2.34rem;
@@ -49,7 +49,7 @@
color: #FFFFFF;
font-family: "MozTT",Sans-serif;
}
-.banner > p > strong {
+#evmeContainer .banner > p > strong {
color: #0995B0;
font-weight: normal;
text-transform: uppercase;
View
31 apps/homescreen/everything.me/modules/Banner/Banner.js
@@ -1,34 +1,37 @@
Evme.Banner = new function Evme_Banner() {
var NAME = 'Banner', self = this,
- el = null, timer_id = null, messageContainer = null;
+ el = null, timerId = null;
this.init = function init(options) {
!options && (options = {});
el = options.el;
- messageContainer = el.querySelector('p');
+
Evme.EventHandler.trigger(NAME, 'init');
};
-
- this.show = function show(message, latency) {
- if (timer_id)
- clearTimeout(timer_id);
-
+
+ this.show = function show(property, args, latency) {
+ if (timerId) {
+ window.clearTimeout(timerId);
+ }
+
latency = latency || 4000;
- timer_id = setTimeout((function bannerTimeout() {
- timer_id = null;
- this.hide();
- }).bind(this), latency);
-
- messageContainer.innerHTML = message;
+ timerId = window.setTimeout(self.hide, latency);
+
+ el.innerHTML = '<p ' + Evme.Utils.l10nAttr(NAME, property, args) + '></p>';
el.classList.add('visible');
+
+ Evme.EventHandler.trigger(NAME, 'show');
};
this.hide = function hide() {
+ timerId = null;
el.classList.remove('visible');
+
+ Evme.EventHandler.trigger(NAME, 'hide');
};
this.getElement = function getElement() {
return el;
};
-}
+}
View
4 apps/homescreen/index.html
@@ -109,9 +109,7 @@ <h1 id="search-title"></h1>
</div>
<div id="shortcuts-loading"></div>
</div>
- </div>
- <div id="evmeBanner" class="banner">
- <p></p>
+ <div id="evmeBanner" class="banner"></div>
</div>
</div>
<div id="landing-page" data-current-page="true">
View
10 apps/homescreen/locales/homescreen.en-US.properties
@@ -3,11 +3,6 @@ add-to-home-screen=Add to Home Screen
website-name=Website name
address=Address
-# Add app to homescreen from Ev.me
-add-to-home-screen-question=Add {{name}} to Home Screen?
-app-exists-in-home-screen={{name}} was already added to Home Screen
-app-added-to-home-screen={{name}} added to Home Screen
-
# Wrapper
wrapper-search-name={{topic}} on {{name}}
@@ -30,7 +25,6 @@ download=Download
restart-download-title=Restart Download
restart-download-body=Do you want to download {{name}}?
-
# Evme
loadingEvme2=Loading…
@@ -51,6 +45,10 @@ evme-helper-title-empty=Everything
evme-apps-loading-app=Loading…
evme-appsmore-loading=Loading…
+evme-alert-app-install-confirm=Add {{name}} to Home Screen?
+evme-alert-app-install-exists={{name}} was already added to Home Screen
+evme-banner-app-install-success={{name}} added to Home Screen
+
evme-shortcuts-more=More
evme-shortcutscustomize-loading=Loading…
View
7 apps/homescreen/locales/homescreen.fr.properties
@@ -4,11 +4,6 @@ cancel=Annuler
website-name=Nom du site web
address=Adresse
-# Add app to homescreen from Ev.me
-add-to-home-screen-question=Ajouter {{name}} à l’écran d’accueil ?
-app-exists-in-home-screen={{name}} a déjà été ajouté à l’écran d’accueil
-app-added-to-home-screen={{name}} added to Home Screen
-
# Wrapper
wrapper-search-name={{topic}} sur {{name}}
@@ -31,3 +26,5 @@ restart-download-title=Redémarrer le téléchargement
restart-download-body=Voulez-vous télécharger {{name}} ?
# Evme
+evme-alert-app-install-confirm=Ajouter {{name}} à l’écran d’accueil ?
+evme-alert-app-install-exists={{name}} a déjà été ajouté à l’écran d’accueil
View
8 apps/homescreen/locales/homescreen.zh-TW.properties
@@ -3,11 +3,6 @@ add-to-home-screen=新增至裝置主畫面
website-name=網站名稱
address=網址
-# Add app to homescreen from Ev.me
-add-to-home-screen-question=新增 {{name}} 到裝置主畫面?
-app-exists-in-home-screen={{name}} 已存在於裝置主畫面
-app-added-to-home-screen={{name}} added to Home Screen
-
# Wrapper
wrapper-search-name={{topic}} 於 {{name}}
@@ -25,6 +20,9 @@ remove=移除
# Evme
loadingEvme=Everything.me
+evme-alert-app-install-confirm=新增 {{name}} 到裝置主畫面?
+evme-alert-app-install-exists={{name}} 已存在於裝置主畫面
+
# Landing
longDateFormat=%B %e 日 %A
Please sign in to comment.
Something went wrong with that request. Please try again.