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();
|
||||
}
|
||||
});
|
||||
@@ -17,18 +17,19 @@ html lang="en"
|
||||
link href="/images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
|
||||
link href="/favicon.ico" rel="shortcut icon"
|
||||
javascript:
|
||||
var data_host = 'http://data.qwaiter.com';
|
||||
//var data_host = 'http://data.qwaiter.com';
|
||||
//var data_host = 'http://localhost:3000';
|
||||
//var data_host = 'http://192.168.1.240:3000';
|
||||
var data_host = 'http://192.168.1.74:3000';
|
||||
var $locale = '#{I18n.locale}';
|
||||
var $url_vars = null;
|
||||
// Dummy holder when Qmobile object is not supplied by the mobile phone
|
||||
var QMobile, Qwaiter, Quser;
|
||||
QMobile || (QMobile = {
|
||||
scanQr: function(){window.location = '/select_qrcode'},
|
||||
activateRotation: function(){},
|
||||
mobile: function(){return false},
|
||||
authentication_string: function(){return this.authentication_string_storage},
|
||||
authentication_object: function(){return this.authentication_object_storage},
|
||||
authentication_string: function(){return this.authentication_string_storage || ''},
|
||||
authentication_object: function(){return this.authentication_object_storage || '{}'},
|
||||
setAuthToken: function(token){
|
||||
this.authentication_string_storage = 'auth_token='+token;
|
||||
this.authentication_object_storage = '{"auth_token": "'+token+'"}'
|
||||
@@ -55,14 +56,12 @@ html lang="en"
|
||||
.container
|
||||
|
||||
.content
|
||||
- if flash[:alert].present?
|
||||
.alert.alert-error
|
||||
a.close data-dismiss="alert" ×
|
||||
div= flash[:alert]
|
||||
- if flash[:notice].present?
|
||||
.alert.alert-success
|
||||
a.close data-dismiss="alert" ×
|
||||
div= flash[:notice]
|
||||
.alert.alert-error.hide
|
||||
button.close type="button" data-dismiss="alert" ×
|
||||
div= flash[:alert]
|
||||
.alert.alert-success.hide
|
||||
button.close type="button" data-dismiss="alert" ×
|
||||
div
|
||||
.row
|
||||
.span12
|
||||
= yield
|
||||
|
||||
Reference in New Issue
Block a user