(function($){ $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); var $return = !results ? null : results[1]; return $return; } $(document).ready(function() { var $is_mobile = false; if( $('.bullets').css('display') == 'none' ) { $is_mobile = true; } //Page habitants if( $('.profile').length ) { $('.profile .user-picture').show(); $('#movetoprevnext').appendTo('#next-prev'); /* $('.profile .user-picture, .profile .views-field-picture').click(function(e){ $('.infos-user').removeClass('active'); $('.profile .user-picture, .profile .views-field-picture').show(); $(this).siblings('.infos-user').addClass('active'); $(this).hide(); return false; }); */ //$('.profile').find('a').click(function(){return false;}); } $('.popup').click(function(event) { var width = 575, height = 400, left = ($(window).width() - width) / 2, top = ($(window).height() - height) / 2, url = this.href, opts = 'status=1' + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left; window.open(url, 'twitter', opts); return false; }); var $optionSets = $('.isotope-options'), $optionLinks = $optionSets.find('a'); var filtre = $.urlParam('filter'); //FRONT if($('.front').length){ var select = false; // $('#filters a').each(function(){ // if($(this).hasClass('selected')) select = true; // }); $('.isotope-options a').each(function(){ if($(this).hasClass('selected')) select = true; }); console.log(!select); console.log(!filtre); // if(!select && !filtre) { $('#filters a[data-option-value="*"]').addClass('selected'); } if(!select && !filtre) { $('.isotope-options a[data-filter=""]').addClass('selected'); } else if(filtre) { var taxo = ''; switch(filtre) { case '0': taxo = ''; break; case '1': taxo = '.creation'; break; case '2': taxo = '.production'; break; case '3': taxo = '.habitants'; break; default: taxo = '' } // $('#filters a[data-option-value="'+taxo+'"]').addClass('selected'); $('.isotope-options a[data-filter="'+taxo+'"]').addClass('selected'); } var $container = $('#isotope-container'); $container.isotope({ itemSelector: '.isotope-element', masonry: { columnWidth: 160 }, filter: taxo }); $optionLinks.click(function(){ var $this = $(this); // don't proceed if already selected if ( $this.hasClass('selected') ) { return false; } var $optionSet = $this.parents('.isotope-options'); $optionSet.find('.selected').removeClass('selected'); $this.addClass('selected'); var options = {}, key = $optionSet.attr('data-option-key'), value = $this.attr('data-filter'); // parse 'false' as false boolean value = value === 'false' ? false : value; options[ 'filter' ] = value; if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) { // changes in layout modes need extra logic changeLayoutMode( $this, options ) } else { // otherwise, apply new options $container.isotope( options ); } return false; }); if ($is_mobile == false) { $('#isotope-container .infos').hide(); $('.isotope-element a').hover(function(){ var $width = $(this).width()-20; $(this).find('.infos').css('width',$width).slideToggle(150, 'easeOutQuad'); }); } } else { if( $('#isotope-container').length ) { var $container = $('#isotope-container'); if ($is_mobile == false) { $container.isotope({ itemSelector: '.isotope-element', masonry: { columnWidth: 160 } }); } $('#isotope-container .infos').hide(); if($('#isotope-container .infos').html()) $('.isotope-element img').hover(function(){ $(this).siblings('.infos').css('width',$(this).width()).stop(true,true).slideToggle(400, 'easeOutBounce'); }); } $('.flippy').addClass('clearfix').appendTo('#next-prev'); $('.flippy li').each(function(){ $(this).removeClass('off'); if(!$(this).find('a').length){ $(this).addClass('off'); } }); } //Footer height var $w = $(window).height(); var $body = $('body').outerHeight(); if($w >= $body){ $('#footer-content').height($w-$body+179); } $(window).resize(function(){ $w = $(window).height(); if($w >= $body){ $('#footer-content').height($w-$body+179); } }); //change small img src on mobile if ($is_mobile == true){ var size = /140x140/gi; var img = $('.container .isotope-element img'); /* //change large img var size2 = /620xxx/gi; var img2 = $('.container .isotope-element.large img'); */ if($('.page-user').length) { size = /habitant/gi; img = $('.container .profile img'); } img.each(function(){ var href = $(this).attr('src'); var newHref = href.replace(size, "300x300"); $(this).attr('src', newHref); $(this).css({'width':'300px','height':'auto'}); $(this).parent('.isotope-element').css({'width':'300px','height':'auto','margin':'0 auto 10px'}); }); } });//end document ready $(window).load(function() { $('.isotope .isotope-item').css({ '-webkit-transition-duration': '0.8s', '-moz-transition-duration' : '0.8s', '-ms-transition-duration' : '0.8s', '-o-transition-duration' : '0.8s', 'transition-duration' : '0.8s' }); }); })(jQuery);