Skip to content

Commit

Permalink
slider carousel fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mastizada committed May 27, 2015
1 parent f3cee5c commit 7cc5268
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 62 deletions.
126 changes: 70 additions & 56 deletions static/js/main.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,77 @@
jQuery(function($) {
//portfolio
$(window).load(function(){
//#main-slider
$(function(){
$('#main-slider').carousel({
interval: 5000
});
});
$('.carousel-indicators li').click(function(e){
e.stopPropagation();
var goTo = $(this).data('slide-to');
$('.carousel-inner .item').each(function(index){
if($(this).data('id') == goTo){
goTo = index;
return false;
}
});
$('#main-slider').carousel(goTo);
});
$('.carousel-next').click(function(e) {
$('#main-slider').carousel('next');
});
$('.carousel-prev').click(function(e) {
$('#main-slider').carousel('prev');
});
$( '.centered' ).each(function( e ) {
$(this).css('margin-top', ($('#main-slider').height() - $(this).height())/2);
});

//#main-slider
$(function(){
$('#main-slider.carousel').carousel({
interval: 8000
});
});
$portfolio_selectors = $('.portfolio-filter >li>a');
if($portfolio_selectors!='undefined'){
$portfolio = $('.portfolio-items');
$portfolio.isotope({
itemSelector : 'li',
layoutMode : 'masonry'
});
$portfolio_selectors.on('click', function(){
$portfolio_selectors.removeClass('active');
$(this).addClass('active');
var selector = $(this).attr('data-filter');
$portfolio.isotope({ filter: selector });
return false;
});
}
});

$( '.centered' ).each(function( e ) {
$(this).css('margin-top', ($('#main-slider').height() - $(this).height())/2);
});
$(window).resize(function(){
$( '.centered' ).each(function( e ) {
$(this).css('margin-top', ($('#main-slider').height() - $(this).height())/2);
});
});
//contact form
var form = $('.contact-form');
form.submit(function () {
$this = $(this);
$.post($(this).attr('action'), function(data) {
$this.prev().text(data.message).fadeIn().delay(3000).fadeOut();
},'json');
return false;
});

$(window).resize(function(){
$( '.centered' ).each(function( e ) {
$(this).css('margin-top', ($('#main-slider').height() - $(this).height())/2);
});
});
//goto top
$('.gototop').click(function(event) {
event.preventDefault();
$('html, body').animate({
scrollTop: $("body").offset().top
}, 500);
});

//portfolio
$(window).load(function(){
$portfolio_selectors = $('.portfolio-filter >li>a');
if($portfolio_selectors!='undefined'){
$portfolio = $('.portfolio-items');
$portfolio.isotope({
itemSelector : 'li',
layoutMode : 'masonry'
});
$portfolio_selectors.on('click', function(){
$portfolio_selectors.removeClass('active');
$(this).addClass('active');
var selector = $(this).attr('data-filter');
$portfolio.isotope({ filter: selector });
return false;
});
}
});

//contact form
var form = $('.contact-form');
form.submit(function () {
$this = $(this);
$.post($(this).attr('action'), function(data) {
$this.prev().text(data.message).fadeIn().delay(3000).fadeOut();
},'json');
return false;
});

//goto top
$('.gototop').click(function(event) {
event.preventDefault();
$('html, body').animate({
scrollTop: $("body").offset().top
}, 500);
});

//Pretty Photo
$("a[rel^='prettyPhoto']").prettyPhoto({
social_tools: false
});
//Pretty Photo
$("a[rel^='prettyPhoto']").prettyPhoto({
social_tools: false
});
});

2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h1>{% block title %}{% endblock %}</h1>
<script src="{% static "js/jquery.prettyPhoto.js" %}"></script>
<script src="{% static "js/jquery.isotope.min.js" %}"></script>
{% include "includes/footer_scripts.html" %}
<script src="{% static "js/main.min.js" %}"></script>
<script src="{% static "js/main.js" %}"></script>
{% endcompress %}
<script src="//mozorg.cdn.mozilla.net/az/tabzilla/tabzilla.js"></script>
</body>
Expand Down
10 changes: 5 additions & 5 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<li data-slide-to="2" data-target="#main-slider" class=""></li>
</ol>
<div class="carousel-inner">
<div style="background-image: url(static/images/slider/bg1.jpg)" class="item active">
<div style="background-image: url(static/images/slider/bg1.jpg)" class="item active" data-id="0">
<div class="container">
<div class="row">
<div class="col-sm-6">
Expand All @@ -35,7 +35,7 @@ <h2 class="animation animated-item-1">{% trans "Firefox: The independent choice"
</div>
</div>
</div>
<div style="background-image: url(static/images/slider/bg2.jpg)" class="item">
<div style="background-image: url(static/images/slider/bg2.jpg)" class="item" data-id="1">
<div class="container">
<div class="row">
<div class="col-sm-12">
Expand All @@ -52,7 +52,7 @@ <h2 class="boxed animation animated-item-1">{% trans "Choose Independent, Choose
</div>
</div>
</div>
<div style="background-image: url(static/images/slider/bg3.jpg)" class="item">
<div style="background-image: url(static/images/slider/bg3.jpg)" class="item" data-id="2">
<div class="container">
<div class="row">
<div class="col-sm-12">
Expand All @@ -68,10 +68,10 @@ <h2 class="boxed animation animated-item-1">{% trans "Firefox Hello - As easy as
</div>
</div>
</div>
<a data-slide="prev" href="#main-slider" class="prev hidden-xs">
<a data-slide="prev" href="#main-slider" class="carousel-prev prev hidden-xs">
<i class="fa fa-chevron-left"></i>
</a>
<a data-slide="next" href="#main-slider" class="next hidden-xs">
<a data-slide="next" href="#main-slider" class="carousel-next next hidden-xs">
<i class="fa fa-chevron-right"></i>
</a>
</section>
Expand Down

0 comments on commit 7cc5268

Please sign in to comment.