1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- jQuery(document).ready(function($) {
- //window scrolls check
- $(window).scroll(function() {
- var topOfWindow = $(window).scrollTop();
- // console.log('topOfWindow',topOfWindow);
- if (topOfWindow > 100) {
- $("#top-bar").addClass("reduced");
- }
- else {
- $("#top-bar").removeClass("reduced");
- }
- });
- // init categories content images behaviour
- // console.log($(window).width());
- if( $(window).width() > 600 && $('body').is('.home')){
- // init Isotope
- var $grid = $('.grid').isotope({
- itemSelector: '.grid-block',
- transitionDuration: '0.4s'
- });
- // $('.grid .grid-block')
- // .hide()
- // .imagesLoaded().progress( function( imgLoad, image ) {
- // // get item
- // // image is imagesLoaded class, not <img>, <img> is image.img
- // var $item = $( image.img ).parents('.grid-block');
- // // un-hide item
- // $item.show();
- // // isotope does its thing
- // $grid.appended( $item );
- // });
- $grid.imagesLoaded().progress(function(){
- $grid.isotope('layout');
- });
- // filter items on button click
- $('nav.categories a').on( 'click', function(e) {
- e.preventDefault();
- if($(this).is('.active')){
- location.hash = '';
- }else{
- var filterValue = $(this).attr('data-filter');
- location.hash = encodeURIComponent( filterValue );
- }
- return false;
- });
- function onHashchange() {
- var hashFilter = decodeURIComponent(location.hash.replace('#', ''));
- $('nav.categories a').removeClass('active');
- if ( !hashFilter ) {
- $grid.isotope({filter: '*'});
- }else{
- $('nav.categories a[data-filter='+hashFilter+']').addClass('active');
- $grid.isotope({filter: '.'+hashFilter});
- }
- }
- $(window).on( 'hashchange', onHashchange );
- onHashchange();
- }
- });
|