[ADD/IMP] Added RTL support which depends on language direction(left-to-right/right-to-left), Display language flag icon in User profile

This commit is contained in:
Siddharth Bhalgami 2018-01-22 17:33:43 +05:30
parent b2f2d45dc6
commit 5c5629ae10
5 changed files with 49 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -140,8 +140,10 @@ var UserProfile = Widget.extend({
});
return this._super.apply(this, arguments).then(function () {
var $avatar = self.$('.profile_pic img');
var $lang_logo = self.$('img.profile_lang');
if (!session.uid) {
$avatar.attr('src', $avatar.data('default-src'));
$lang_logo.attr('src', $lang_logo.data('default-src'));
return $.when();
}
self.$('.profile_name').text(session.name);
@ -154,6 +156,37 @@ var UserProfile = Widget.extend({
field: 'image_small',
id: session.uid,
});
self._rpc({
model: 'res.lang',
method: 'search_read',
args: [[["code", "=", session.user_context.lang]], ['name', 'direction']],
}).then(function(lang_data){
var img_src = session.url('/web/image', {
model:'res.lang',
field: 'image',
id: lang_data[0].id,
});
$lang_logo.attr('title', lang_data[0].name).attr('src', img_src).attr('data-lang-dir', lang_data[0].direction);
// Web RTL(Right to Left) Snippet
if (lang_data[0].direction == 'rtl') {
var head = document.getElementsByTagName('head')[0];
// BootStrap RTL CSS
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = '/web/static/lib/rtl/bootstrap-rtl.min.css';
head.appendChild(link);
// Flectra RTL Custom CSS
var link1 = document.createElement('link');
link1.rel = 'stylesheet';
link1.type = 'text/css';
link1.href = '/web/static/lib/rtl/flectra-rtl-custom.css';
head.appendChild(link1);
}
});
$avatar.attr('src', avatar_src);
});
},

View File

@ -51,6 +51,12 @@
max-height: 100%;
}
}
> img {
position: absolute;
margin-top: -8px;
margin-left: -8px;
max-height: 30px;
}
.profile_info {
width: 100%;
text-align: center;

View File

@ -1370,6 +1370,7 @@
<t t-name="UserProfile">
<div class="user_profile close_profile">
<img class="profile_lang" t-att-src="_s + '/web/static/src/img/placeholder.png'"/>
<div class="profile_pic">
<img class="img-circle" t-att-src="_s + '/web/static/src/img/user_menu_avatar.png'"/>
</div>