navbar link hash fixed, footer links fixed

This commit is contained in:
Arvind Tiwari 2017-09-01 01:27:44 +05:30
parent 3ed2399337
commit 5550867870
6 changed files with 80 additions and 59 deletions

View file

@ -86,6 +86,20 @@
} }
function _initNavUrl() { function _initNavUrl() {
$('.url-init').each(function(idx, el) {
var $this = $(el);
var currentPath = window.location.pathname;
var thisPaths = $this.attr('href').split('#')
if ($this.hasClass('dropdown-toggle') && window.matchMedia("(max-width: 767px)").matches) {
$this.removeClass('url-init');
$this.attr('href', '');
} else if ($('#'+thisPaths[1]).length) {
$this.removeClass('url-init').addClass('url');
$this.attr('href', '#' + thisPaths[1]);
} else {
$this.removeClass('url-init');
}
});
$('.url').click(function(event) { $('.url').click(function(event) {
event.preventDefault(); event.preventDefault();
var href = $(this).attr('href'); var href = $(this).attr('href');
@ -95,8 +109,6 @@
$('html, body').animate({ $('html, body').animate({
scrollTop: $(href).offset().top scrollTop: $(href).offset().top
}, 1000); }, 1000);
} else {
window.location.href = '/datacenterlight' + href;
} }
}); });
} }

View file

@ -2,52 +2,37 @@
{% get_current_language as LANGUAGE_CODE %} {% get_current_language as LANGUAGE_CODE %}
<footer> <footer>
<div class="container"> <div class="container">
<div class="row"> <ul class="list-inline">
<div class="col-lg-12"> {% if request.resolver_match.url_name != "index" %}
<li>
<a href="{% url 'datacenterlight:index' %}">{% trans "Home" %}</a>
</li>
<li class="footer-menu-divider">&sdot;</li>
{% endif %}
<li>
<a class="url-init" href="{% url 'datacenterlight:index' %}#how">{% trans "Highlights" %}</a>
</li>
<li>
<a class="url-init" href="{% url 'datacenterlight:index' %}#your">{% trans "Scale out" %}</a>
</li>
<li>
<a class="url-init" href="{% url 'datacenterlight:index' %}#our">{% trans "Reliable and light" %}</a>
</li>
{% if request.resolver_match.url_name != "index" %}
<li>
<a class="url-init" href="{% url 'datacenterlight:index' %}#price">{% trans "Pricing" %}</a>
</li>
<li class="footer-menu-divider">&sdot;</li>
{% else %}
<li>
<a class="url-init" href="{% url 'datacenterlight:index' %}#price">{% trans "Order VM" %}</a>
</li>
{% endif %}
<li>
<a class="url-init" href="{% url 'datacenterlight:index' %}#contact">{% trans "Contact" %}</a>
</li>
</ul>
<ul class="list-inline"> <p class="copyright text-muted small">Copyright &copy; ungleich GmbH {% now "Y" %}. {% trans "All Rights Reserved" %}</p>
{% if request.resolver_match.url_name == "index" %}
<li>
<a class="url" href="javascript:void(0)" data-url="#how" >{% trans "Highlights" %}</a>
</li>
<li>
<a class="url" href="javascript:void(0)" data-url="#your" >{% trans "Scale out" %}</a>
</li>
<li>
<a class="url" href="javascript:void(0)" data-url="#our">{% trans "Reliable and light" %}</a>
</li>
<li>
<a class="url" href="javascript:void(0)" data-url="#price" >{% trans "Order VM" %}</a>
</li>
<li>
<a class="url" href="javascript:void(0)" data-url="#contact" >{% trans "Contact" %}</a>
</li>
{% else %}
<li>
<a href="{% url 'datacenterlight:index' %}">{% trans "Home" %}</a>
</li>
<li class="footer-menu-divider">&sdot;</li>
<li>
<a href="{% url 'datacenterlight:index' %}#how">{% trans "Highlights" %}</a></li>
<li class="footer-menu-divider">&sdot;</li>
<li>
<a href="{% url 'datacenterlight:index' %}#your">{% trans "Scale out" %}</a></li>
<li>&sdot;</li>
<li>
<a href="{% url 'datacenterlight:index' %}#our">{% trans "Reliable and light" %}</a></li>
<li class="footer-menu-divider">&sdot;</li>
<li>
<a href="{% url 'datacenterlight:index' %}#price">{% trans "Pricing" %}</a>
</li>
<li class="footer-menu-divider">&sdot;</li>
<li>
<a href="{% url 'datacenterlight:index' %}#contact">{% trans "Contact" %}</a>
</li>
{% endif %}
</ul>
<p class="copyright text-muted small">Copyright &copy; ungleich GmbH {% now "Y" %}. {% trans "All Rights Reserved" %}</p>
</div>
</div>
</div> </div>
</footer> </footer>

View file

@ -16,12 +16,11 @@
<!-- Start Navbar collapse--> <!-- Start Navbar collapse-->
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="dropdown highlights-dropdown"> <li class="dropdown highlights-dropdown">
<a class="dropdown-toggle url visible-desktop" href="#how" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Highlights" %}&nbsp;<span class="caret"></span></a> <a class="dropdown-toggle url-init" href="{% url 'datacenterlight:index' %}#how" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Highlights" %}&nbsp;<span class="caret"></span></a>
<a class="dropdown-toggle visible-mobile" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{% trans "Highlights" %}&nbsp;<span class="caret"></span></a>
<ul class="dropdown-menu "> <ul class="dropdown-menu ">
<li><a class="url" href="#your">{% trans "Scale out" %}</a></li> <li><a class="url-init" href="{% url 'datacenterlight:index' %}#your">{% trans "Scale out" %}</a></li>
<li><a class="url" href="#our">{% trans "Reliable and light" %}</a></li> <li><a class="url-init" href="{% url 'datacenterlight:index' %}#our">{% trans "Reliable and light" %}</a></li>
<li> <a class="url" href="#price">{% trans "Order VM" %}</a></li> <li> <a class="url-init" href="{% url 'datacenterlight:index' %}#price">{% trans "Order VM" %}</a></li>
</ul> </ul>
</li> </li>
<li> <li>

View file

@ -434,8 +434,8 @@ class PaymentOrderView(FormView):
@cache_control(no_cache=True, must_revalidate=True, no_store=True) @cache_control(no_cache=True, must_revalidate=True, no_store=True)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
# if 'specs' not in request.session or 'user' not in request.session: if 'specs' not in request.session or 'user' not in request.session:
# return HttpResponseRedirect(reverse('datacenterlight:index')) return HttpResponseRedirect(reverse('datacenterlight:index'))
return self.render_to_response(self.get_context_data()) return self.render_to_response(self.get_context_data())
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
@ -554,7 +554,7 @@ class OrderConfirmationView(DetailView):
stripe_subscription_obj = subscription_result.get('response_object') stripe_subscription_obj = subscription_result.get('response_object')
# Check if the subscription was approved and is active # Check if the subscription was approved and is active
if stripe_subscription_obj is None or \ if stripe_subscription_obj is None or \
stripe_subscription_obj.status != 'active': stripe_subscription_obj.status != 'active':
msg = subscription_result.get('error') msg = subscription_result.get('error')
messages.add_message(self.request, messages.ERROR, msg, messages.add_message(self.request, messages.ERROR, msg,
extra_tags='failed_payment') extra_tags='failed_payment')

View file

@ -107,7 +107,7 @@ h6 {
.navbar-right .highlights-dropdown .dropdown-menu > li > a{ .navbar-right .highlights-dropdown .dropdown-menu > li > a{
font-size: 13px; font-size: 13px;
font-weight: 300; font-weight: 300;
font-family: 'Lato-Light', sans-serif; font-family: 'Lato', sans-serif;
padding: 1px 10px !important; padding: 1px 10px !important;
background: transparent; background: transparent;
color: #333; color: #333;

View file

@ -1,5 +1,32 @@
// also declared in datacenterlight/js/main.js // also declared in datacenterlight/js/main.js
function _initNavUrl() { function _initNavUrl() {
// $('.url').click(function(event) {
// event.preventDefault();
// var href = $(this).attr('href');
// $('.navbar-collapse').removeClass('in');
// $('.navbar-collapse').addClass('collapsing');
// if ($(href).length) {
// $('html, body').animate({
// scrollTop: $(href).offset().top
// }, 1000);
// } else {
// window.location.href = '/datacenterlight' + href;
// }
// });
$('.url-init').each(function(idx, el) {
var $this = $(el);
var currentPath = window.location.pathname;
var thisPaths = $this.attr('href').split('#')
if ($this.hasClass('dropdown-toggle') && window.matchMedia("(max-width: 767px)").matches) {
$this.removeClass('url-init');
$this.attr('href', '');
} else if ($('#'+thisPaths[1]).length) {
$this.removeClass('url-init').addClass('url');
$this.attr('href', '#' + thisPaths[1]);
} else {
$this.removeClass('url-init');
}
});
$('.url').click(function(event) { $('.url').click(function(event) {
event.preventDefault(); event.preventDefault();
var href = $(this).attr('href'); var href = $(this).attr('href');
@ -9,8 +36,6 @@ function _initNavUrl() {
$('html, body').animate({ $('html, body').animate({
scrollTop: $(href).offset().top scrollTop: $(href).offset().top
}, 1000); }, 1000);
} else {
window.location.href = '/datacenterlight' + href;
} }
}); });
} }