fix message handling for mobile
This commit is contained in:
+22
-4
@@ -14,7 +14,7 @@
|
||||
//= require jquery_ujs
|
||||
// require twitter/bootstrap
|
||||
//= require twitter/bootstrap/bootstrap-transition
|
||||
// require twitter/bootstrap/bootstrap-alert
|
||||
//= require twitter/bootstrap/bootstrap-alert
|
||||
//= require twitter/bootstrap/bootstrap-modal
|
||||
//= require twitter/bootstrap/bootstrap-dropdown
|
||||
//= require twitter/bootstrap/bootstrap-scrollspy
|
||||
@@ -38,8 +38,9 @@ var path_mapping = {
|
||||
history_list: '/user/history_list',
|
||||
obtain_user_token: '/user/obtain_token'
|
||||
}
|
||||
var translations = {
|
||||
var $translations = {
|
||||
en: {
|
||||
messages: <%= I18n.t('messages', locale: :en).to_json %>,
|
||||
confirmations: {
|
||||
},
|
||||
list_needs_help: {
|
||||
@@ -70,6 +71,7 @@ var translations = {
|
||||
}
|
||||
},
|
||||
nl: {
|
||||
messages: <%= I18n.t('messages', locale: :en).to_json %>,
|
||||
confirmations: {
|
||||
},
|
||||
list_needs_help: {
|
||||
@@ -117,7 +119,7 @@ String.prototype.capitalize = function() {
|
||||
function t(path, vars){
|
||||
vars || (vars = {});
|
||||
var parts = path.split('.');
|
||||
var accessor = 'translations["' + parts.join('"]["')+ '"]';
|
||||
var accessor = '$translations.'+$locale+'["' + parts.join('"]["')+ '"]';
|
||||
var result;
|
||||
try{
|
||||
result = eval(accessor);
|
||||
@@ -133,4 +135,20 @@ $.ajaxSetup({
|
||||
window.location = data_host + '/user/obtain_token.html';
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
function getUrlVars() {
|
||||
if($url_vars) return $url_vars;
|
||||
$url_vars = {};
|
||||
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
|
||||
$url_vars[key] = value;
|
||||
});
|
||||
return $url_vars;
|
||||
}
|
||||
$(function(){
|
||||
|
||||
if(getUrlVars().message){
|
||||
var container = $('.alert-success div');
|
||||
container.text($translations[$locale]['messages'][getUrlVars().message] || ('Message ' + getUrlVars().message + ' not found'));
|
||||
container.show();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user