Merge pull request #180 from HenryGBC/feature/new_digitalglarus
Languages selector
This commit is contained in:
commit
9b1c1e5127
5 changed files with 103 additions and 22 deletions
|
@ -473,7 +473,31 @@ section h3.section-subheading {
|
||||||
.ungleich-gallery-text-carousel .carousel-inner .item, .text-carousel .carousel-inner .item {
|
.ungleich-gallery-text-carousel .carousel-inner .item, .text-carousel .carousel-inner .item {
|
||||||
padding: 0px 30px;
|
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) {
|
@media only screen and (max-device-width: 480px) {
|
||||||
.carousel-text {
|
.carousel-text {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
init_nav();
|
init_nav();
|
||||||
initBackgroundsHeader();
|
initBackgroundsHeader();
|
||||||
|
init_hovers();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Infinite loop for change Background Header
|
//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);
|
})(jQuery);
|
|
@ -87,6 +87,15 @@
|
||||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<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>
|
<li>
|
||||||
<a class="nav-local" href="javascript:void(0)" data-href="about">{% trans 'About' %}</a>
|
<a class="nav-local" href="javascript:void(0)" data-href="about">{% trans 'About' %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -83,6 +83,15 @@
|
||||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<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>
|
<li>
|
||||||
<a href="/alplora#about" data>About</a>
|
<a href="/alplora#about" data>About</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.views.generic import TemplateView
|
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.utils.translation import ugettext_lazy as _
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
@ -8,30 +9,54 @@ from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
from utils.forms import ContactUsForm
|
from utils.forms import ContactUsForm
|
||||||
|
|
||||||
class IndexView(FormView):
|
class IndexView(FormView):
|
||||||
template_name = "alplora/index.html"
|
template_name = "alplora/index.html"
|
||||||
form_class = ContactUsForm
|
form_class = ContactUsForm
|
||||||
success_message = _('Message Successfully Sent')
|
success_message = _('Message Successfully Sent')
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
def get_context_data(self, *args, **kwargs):
|
context = super(IndexView, self).get_context_data(**kwargs)
|
||||||
context = super(IndexView, self).get_context_data(**kwargs)
|
languages = getlanguages()
|
||||||
language = get_language()
|
context.update(languages)
|
||||||
context.update({
|
return context
|
||||||
'language': language
|
|
||||||
})
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
success_url = reverse('alplora:index')
|
success_url = reverse('alplora:index')
|
||||||
success_url += "#requestformsuccess"
|
success_url += "#requestformsuccess"
|
||||||
return success_url
|
return success_url
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.save()
|
form.save()
|
||||||
form.send_email()
|
form.send_email()
|
||||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||||
return super(IndexView, self).form_valid(form)
|
return super(IndexView, self).form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
class LoginView(TemplateView):
|
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']
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue