Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#7396 from vingtetun/826291-landing
Browse files Browse the repository at this point in the history
Bug 826291 - Make support info a customizable parameter outside l10n. r=...
  • Loading branch information
vingtetun committed Jan 8, 2013
2 parents cee9756 + 64db58b commit 492c68f
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 48 deletions.
11 changes: 4 additions & 7 deletions apps/settings/index.html
Expand Up @@ -2284,17 +2284,13 @@ <h1 data-l10n-id="help"></h1>
<ul>
<li>
<a data-l10n-id="online-support"> Online Support:
<span class="link-text" data-l10n-id="online-support-link-text"></span>
<a data-l10n-id="online-support" id="online-support-link"> Online Support:
<span class="link-text" id="online-support-text"></span>
</a>
</li>
<li>
<span data-l10n-id="call-support"> Call Support:
<span id="call-support-numbers">
<a class="tel-text" data-l10n-id="call-support-link-1"></a>
<span data-l10n-id="call-support-link-or"></span>
<a class="tel-text" data-l10n-id="call-support-link-2"></a>
</span>
<span class="tel-text" id="call-support-numbers"></span>
</span>
</li>
<li>
Expand All @@ -2303,6 +2299,7 @@ <h1 data-l10n-id="help"></h1>
</label>
</li>
</ul>
<script type="application/javascript" src="js/support.js"></script>
-->
</section>

Expand Down
65 changes: 65 additions & 0 deletions apps/settings/js/support.js
@@ -0,0 +1,65 @@
/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

'use strict';

var Support = {
init: function support_init() {
this.loadSupportInfo();
},

getSupportInfo: function support_getInfo(callback) {
if (this._supportInfo) {
callback(this._supportInfo);
return;
}
var self = this;
var SUPPORT_INFO = 'resources/support.json';
var xhr = new XMLHttpRequest();
xhr.onerror = function() {
console.error('Failed to fetch support.json: ',
xhr.statusText);
};
xhr.onload = function loadSupportInfo() {
if (xhr.status === 0 || xhr.status === 200) {
self._supportInfo = xhr.response;
callback(self._supportInfo);
}
};
xhr.open('GET', SUPPORT_INFO, true); // async
xhr.responseType = 'json';
xhr.send();
},

createLinkNode: function support_createLinkNode(data) {
var link = document.createElement('a');
link.setAttribute('href', data.href);
link.textContent = data.title;
return link;
},

loadSupportInfo: function support_loadSupportInfo() {
var self = this;
this.getSupportInfo(function displaySupportInfo(supportInfo) {
document.getElementById('online-support-link')
.setAttribute('href', supportInfo.onlinesupport.href);
document.getElementById('online-support-text')
.textContent = supportInfo.onlinesupport.title;

var callSupportInfo = supportInfo.callsupport;
var numbers = document.getElementById('call-support-numbers');
if (callSupportInfo.length < 2) {
numbers.appendChild(self.createLinkNode(callSupportInfo[0]));
} else {
var link1 = self.createLinkNode(callSupportInfo[0]);
var link2 = self.createLinkNode(callSupportInfo[1]);
numbers.innerHTML = navigator.mozL10n
.get('call-support-numbers', { 'link1': link1.outerHTML,
'link2': link2.outerHTML });
}
});
}
};

// startup
onLocalized(Support.init.bind(Support));
14 changes: 1 addition & 13 deletions apps/settings/locales/settings.en-US.properties
Expand Up @@ -522,20 +522,8 @@ crash-reports-description-3-end=.

# Device :: Help
online-support=Online support:
# LOCALIZATION NOTE (online-support.href): this is the URL for the online support page.
online-support.href=http://www.vivo.com.br/portalweb/appmanager/env/web?_nfls=false&_nfpb=true&_pageLabel=vcAtendMovelBook&WT.ac=portal.atendimento.movel
# LOCALIZATION NOTE (online-support-link-text): This text will appear as a link.
online-support-link-text=Vivo
call-support=Call support:
# LOCALIZATION NOTE (call-support-link-1): this text will appear as a link.
call-support-link-1=*8486
# LOCALIZATION NOTE (call-support-link-1.href): include the "tel:" protocol before the call support
# number so that it will open in the dialer app.
call-support-link-1.href=tel:*8486
# LOCALIZATION NOTE: if your locale only has one support phone number, leave the next 3 strings empty.
call-support-link-2=1058
call-support-link-2.href=tel:1058
call-support-link-or=or
call-support-numbers={{link1}} or {{link2}}
user-guide=User guide

# Device :: SIM toolkit
Expand Down
14 changes: 1 addition & 13 deletions apps/settings/locales/settings.fr.properties
Expand Up @@ -514,20 +514,8 @@ crash-reports-description-3-end=.

# Device :: Help
online-support=Aide en ligne :
# LOCALIZATION NOTE (online-support.href): This is the URL for the online support page.
online-support.href=http://www.vivo.com.br/portalweb/appmanager/env/web?_nfls=false&_nfpb=true&_pageLabel=vcAtendMovelBook&WT.ac=portal.atendimento.movel
# LOCALIZATION NOTE (online-support-link-text): This text will appear as a link.
online-support-link-text=Vivo
call-support=Aide par téléphone :
# LOCALIZATION NOTE (call-support-link-1): This text will appear as a link.
call-support-link-1=*8486
# LOCALIZATION NOTE (call-support-link-1.href): Include the "tel:" protocol before the call support
# number so that it will open in the dialer app.
call-support-link-1.href=tel:*8486
# LOCALIZATION NOTE: If your locale only has one support phone number, leave the next 3 strings empty.
call-support-link-2=
call-support-link-2.href=
call-support-link-or=
call-support-numbers={{link1}} ou {{link2}}
user-guide=Manuel de l’utilisateur

# Device :: SIM Toolkit
Expand Down
14 changes: 1 addition & 13 deletions apps/settings/locales/settings.zh-TW.properties
Expand Up @@ -485,20 +485,8 @@ crash-reports-description-3-end=所描述的方式處理您的資訊。

# Device :: Help
online-support=線上支援:
# LOCALIZATION NOTE (online-support.href): this is the URL for the online support page.
online-support.href=http://www.vivo.com.br/portalweb/appmanager/env/web?_nfls=false&_nfpb=true&_pageLabel=vcAtendMovelBook&WT.ac=portal.atendimento.movel
# LOCALIZATION NOTE (online-support-link-text): This text will appear as a link.
online-support-link-text=Vivo
call-support=撥打技術支援電話:
# LOCALIZATION NOTE (call-support-link-1): this text will appear as a link.
call-support-link-1=*8486
# LOCALIZATION NOTE (call-support-link-1.href): include the "tel:" protocol before the call support
# number so that it will open in the dialer app.
call-support-link-1.href=tel:*8486
# LOCALIZATION NOTE: if your locale only has one support phone number, leave the next 3 strings empty.
call-support-link-2=1058
call-support-link-2.href=tel:1058
call-support-link-or=
call-support-numbers={{link1}} 或 {{link2}}
user-guide=使用者指南

# Device :: SIM toolkit
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/style/settings.css
Expand Up @@ -85,7 +85,7 @@ section[role="region"]:not(#root) > header:first-child + * {
white-space: normal;
}

.link-text, .tel-text {
.link-text, .tel-text a {
font-size: 1.4rem;
color: #336699;
text-decoration: underline;
Expand Down
20 changes: 20 additions & 0 deletions build/applications-data.js
Expand Up @@ -195,3 +195,23 @@ content = {
}

writeContent(init, JSON.stringify(content));

// Support
init = getFile(GAIA_DIR, 'apps', 'settings', 'resources', 'support.json');
content = {
"onlinesupport": {
"href": "http://www.vivo.com.br/portalweb/appmanager/env/web?_nfls=false&_nfpb=true&_pageLabel=vcAtendMovelBook&WT.ac=portal.atendimento.movel",
"title": "Vivo"
},
"callsupport": [
{
"href": "tel:*8486",
"title": "*8486"
},
{
"href": "tel:1058",
"title": "1058"
}
]
}
writeContent(init, JSON.stringify(content));
2 changes: 1 addition & 1 deletion shared/js/l10n.js
Expand Up @@ -821,7 +821,7 @@

// replace {{arguments}} with their values
function substArguments(str, args, key) {
var reArgs = /\{\{\s*([a-zA-Z\.:-]+)\s*\}\}/;
var reArgs = /\{\{\s*(.+?)\s*\}\}/;
var match = reArgs.exec(str);
while (match) {
if (!match || match.length < 2)
Expand Down

0 comments on commit 492c68f

Please sign in to comment.