Merge pull request #180 from HenryGBC/feature/new_digitalglarus

Languages selector
This commit is contained in:
Levi Velázquez 2017-03-24 00:00:14 -04:00 committed by GitHub
commit 9b1c1e5127
5 changed files with 103 additions and 22 deletions

View file

@ -473,7 +473,31 @@ section h3.section-subheading {
.ungleich-gallery-text-carousel .carousel-inner .item, .text-carousel .carousel-inner .item {
padding: 0px 30px;
}
.nav-language .select-language{
padding: 15px 10px;
cursor: pointer;
}
.nav-language .select-language span{
margin-left: 5px;
margin-right: 5px;
}
.nav-language .drop-language{
position: absolute;
top: 50px;
left: 10px;
background: #fff;
width: 111px;
height: 60px;
padding: 10px 25px;
-webkit-box-shadow: -8px 13px 31px -8px rgba(77,77,77,1);
-moz-box-shadow: -8px 13px 31px -8px rgba(77,77,77,1);
box-shadow: -8px 13px 31px -8px rgba(77,77,77,1);
display: none;
}
.nav-language .drop-language a{
cursor: pointer;
}
@media only screen and (max-device-width: 480px) {
.carousel-text {

View file

@ -16,6 +16,7 @@
$( document ).ready(function() {
init_nav();
initBackgroundsHeader();
init_hovers();
});
//Infinite loop for change Background Header
@ -45,4 +46,17 @@
}
function init_hovers(){
$('.select-language').hover(function() {
$('.drop-language').show();
}, function() {
$('.drop-language').hide();
})
$('.drop-language').hover(function() {
$('.drop-language').show();
}, function() {
$('.drop-language').hide();
})
}
})(jQuery);

View file

@ -87,6 +87,15 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="nav-language">
<div class="select-language">
<i class="fa fa-globe" aria-hidden="true"></i>
<span>{{language_activate}}</span>
</div>
<div class="drop-language">
<a class="nav-local" href="/{{list_language.code}}/alplora" >{{list_language.name}}</a>
</div>
</li>
<li>
<a class="nav-local" href="javascript:void(0)" data-href="about">{% trans 'About' %}</a>
</li>

View file

@ -83,6 +83,15 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="nav-language">
<div class="select-language">
<i class="fa fa-globe" aria-hidden="true"></i>
<span>{{language_activate}}</span>
</div>
<div class="drop-language">
<a class="nav-local" href="/{{list_language.code}}/alplora/login" >{{list_language.name}}</a>
</div>
</li>
<li>
<a href="/alplora#about" data>About</a>
</li>

View file

@ -1,5 +1,6 @@
from django.views.generic import TemplateView
from django.utils.translation import get_language
from django.utils.translation import get_language, get_language_info
from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import FormView
from django.contrib import messages
@ -8,30 +9,54 @@ from django.core.urlresolvers import reverse_lazy, reverse
from utils.forms import ContactUsForm
class IndexView(FormView):
template_name = "alplora/index.html"
form_class = ContactUsForm
success_message = _('Message Successfully Sent')
template_name = "alplora/index.html"
form_class = ContactUsForm
success_message = _('Message Successfully Sent')
def get_context_data(self, *args, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
language = get_language()
context.update({
'language': language
})
return context
def get_context_data(self, *args, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
languages = getlanguages()
context.update(languages)
return context
def get_success_url(self):
success_url = reverse('alplora:index')
success_url += "#requestformsuccess"
return success_url
def get_success_url(self):
success_url = reverse('alplora:index')
success_url += "#requestformsuccess"
return success_url
def form_valid(self, form):
form.save()
form.send_email()
messages.add_message(self.request, messages.SUCCESS, self.success_message)
return super(IndexView, self).form_valid(form)
def form_valid(self, form):
form.save()
form.send_email()
messages.add_message(self.request, messages.SUCCESS, self.success_message)
return super(IndexView, self).form_valid(form)
class LoginView(TemplateView):
template_name = "alplora/login.html"
template_name = "alplora/login.html"
def get_context_data(self, *args, **kwargs):
context = super(LoginView, self).get_context_data(**kwargs)
languages = getlanguages()
context.update(languages)
return context
def getlanguages():
language = get_language()
language_activate = get_language_info(language)
if language == 'de':
list_language = {
'name': 'English',
'code': 'en-us'
}
else:
list_language = {
'name': 'Deutsch',
'code': 'de'
}
return {
'language': language,
'list_language': list_language,
'language_activate': language_activate['name_local']
}