42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
window.scwGridFilterPlugin = window.scwGridFilterPlugin || {};
|
|
|
|
window.SEMICOLON_gridFilterInit = function( $gridFilterEl ){
|
|
|
|
$gridFilterEl = $gridFilterEl.filter(':not(.customjs)');
|
|
|
|
if( $gridFilterEl.length < 1 ){
|
|
return true;
|
|
}
|
|
|
|
$gridFilterEl.each( function(){
|
|
let element = $(this),
|
|
elCon = element.attr('data-container'),
|
|
elActClass = element.attr('data-active-class'),
|
|
elDefFilter = element.attr('data-default');
|
|
|
|
if( !elActClass ) { elActClass = 'activeFilter'; }
|
|
|
|
element.find('a').off( 'click' ).on( 'click', function(){
|
|
element.find('li').removeClass( elActClass );
|
|
$(this).parent('li').addClass( elActClass );
|
|
let selector = $(this).attr('data-filter');
|
|
$(elCon).isotope({ filter: selector });
|
|
return false;
|
|
});
|
|
|
|
if( elDefFilter ) {
|
|
element.find('li').removeClass( elActClass );
|
|
element.find('[data-filter="'+ elDefFilter +'"]').parent('li').addClass( elActClass );
|
|
$(elCon).isotope({ filter: elDefFilter });
|
|
}
|
|
});
|
|
|
|
$('.grid-shuffle').off( 'click' ).on( 'click', function(){
|
|
let element = $(this),
|
|
elCon = element.attr('data-container');
|
|
|
|
$(elCon).isotope('shuffle');
|
|
});
|
|
|
|
};
|