wp_blog/wp-content/themes/nuzi/assets/js/jquery.isotope.min.js

108 lines
20 KiB
JavaScript
Raw Permalink Normal View History

2020-01-02 23:15:16 +07:00
/**
* Isotope v1.5.25
* An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co
*
* Commercial use requires one-time purchase of a commercial license
* http://isotope.metafizzy.co/docs/license.html
*
* Non-commercial use is licensed under the MIT License
*
* Copyright 2013 Metafizzy
*/
(function(a,b,c){"use strict";var d=a.document,e=a.Modernizr,f=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},g="Moz Webkit O Ms".split(" "),h=function(a){var b=d.documentElement.style,c;if(typeof b[a]=="string")return a;a=f(a);for(var e=0,h=g.length;e<h;e++){c=g[e]+a;if(typeof b[c]=="string")return c}},i=h("transform"),j=h("transitionProperty"),k={csstransforms:function(){return!!i},csstransforms3d:function(){var a=!!h("perspective");if(a){var c=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),d="@media ("+c.join("transform-3d),(")+"modernizr)",e=b("<style>"+d+"{#modernizr{height:3px}}"+"</style>").appendTo("head"),f=b('<div id="modernizr" />').appendTo("html");a=f.height()===3,f.remove(),e.remove()}return a},csstransitions:function(){return!!j}},l;if(e)for(l in k)e.hasOwnProperty(l)||e.addTest(l,k[l]);else{e=a.Modernizr={_version:"1.6ish: miniModernizr for Isotope"};var m=" ",n;for(l in k)n=k[l](),e[l]=n,m+=" "+(n?"":"no-")+l;b("html").addClass(m)}if(e.csstransforms){var o=e.csstransforms3d?{translate:function(a){return"translate3d("+a[0]+"px, "+a[1]+"px, 0) "},scale:function(a){return"scale3d("+a+", "+a+", 1) "}}:{translate:function(a){return"translate("+a[0]+"px, "+a[1]+"px) "},scale:function(a){return"scale("+a+") "}},p=function(a,c,d){var e=b.data(a,"isoTransform")||{},f={},g,h={},j;f[c]=d,b.extend(e,f);for(g in e)j=e[g],h[g]=o[g](j);var k=h.translate||"",l=h.scale||"",m=k+l;b.data(a,"isoTransform",e),a.style[i]=m};b.cssNumber.scale=!0,b.cssHooks.scale={set:function(a,b){p(a,"scale",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.scale?d.scale:1}},b.fx.step.scale=function(a){b.cssHooks.scale.set(a.elem,a.now+a.unit)},b.cssNumber.translate=!0,b.cssHooks.translate={set:function(a,b){p(a,"translate",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.translate?d.translate:[0,0]}}}var q,r;e.csstransitions&&(q={WebkitTransitionProperty:"webkitTransitionEnd",MozTransitionProperty:"transitionend",OTransitionProperty:"oTransitionEnd otransitionend",transitionProperty:"transitionend"}[j],r=h("transitionDuration"));var s=b.event,t=b.event.handle?"handle":"dispatch",u;s.special.smartresize={setup:function(){b(this).bind("resize",s.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",s.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",u&&clearTimeout(u),u=setTimeout(function(){s[t].apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Isotope=function(a,c,d){this.element=b(c),this._create(a),this._init(d)};var v=["width","height"],w=b(a);b.Isotope.settings={resizable:!0,layoutMode:"masonry",containerClass:"isotope",itemClass:"isotope-item",hiddenClass:"isotope-hidden",hiddenStyle:{opacity:0,scale:.001},visibleStyle:{opacity:1,scale:1},containerStyle:{position:"relative",overflow:"hidden"},animationEngine:"best-available",animationOptions:{queue:!1,duration:800},sortBy:"original-order",sortAscending:!0,resizesContainer:!0,transformsEnabled:!0,itemPositionDataEnabled:!1},b.Isotope.prototype={_create:function(a){this.options=b.extend({},b.Isotope.settings,a),this.styleQueue=[],this.elemCount=0;var c=this.element[0].style;this.originalStyle={};var d=v.slice(0);for(var e in this.options.containerStyle)d.push(e);for(var f=0,g=d.length;f<g;f++)e=d[f],this.originalStyle[e]=c[e]||"";this.element.css(this.options.containerStyle),this._updateAnimationEngine(),this._updateUsingTransforms();var h={"original-order":function(a,b){return b.elemCount++,b.elemCount},random:function(){return Math.random()}};this.options.getSortData=b.extend(this.options.getSortData,h),this.reloadItems(),this.offset={left:parseInt(this.element.css("padding-left")||0,10),top:parseInt(this.element.css("padding-top")||0,10)};var i=this;setTimeout(function(){i.element.addClass(i.options.containerClass)},0),this.options.resizable&&w.bind("smartresize.isotope",function(){i.resize()}),this.element.delegate("."+this.options.hiddenClass,"click",function(){return!1})},_getAtoms:f
jQuery(window).load(function() {
"use strict";
//Portfolio
jQuery('.tw-portfolio').each(function(i){
var $currentPortfolio=jQuery(this);
var $currentInfinite=$currentPortfolio.children('.tw-infinite-scroll');
var $currentIsotopeContainer=$currentPortfolio.children('.row').children('.isotope-container');
// Isotop
showFilter($currentIsotopeContainer.closest('.row').prev('.tw-filter').children('.filters'),$currentIsotopeContainer.children('article'));
$currentIsotopeContainer.isotope({
itemSelector: 'article.portfolio',
transformsEnabled: true
});
// Filter
$currentPortfolio.find('ul.filters').each(function() {
var $optionSets = jQuery(this),
$optionLinks = $optionSets.find('a');
$optionLinks.click(function() {
var $container2 = jQuery(this).closest('.tw-portfolio').find('.isotope-container');
var $this = jQuery(this);
// don't proceed if already selected
if ($this.hasClass('selected')) {
return false;
}
$optionSets.find('.selected').removeClass('selected');
$this.addClass('selected');
var options = {},
key = $optionSets.attr('data-option-key'),
value = $this.attr('data-option-value');
value = value === 'false' ? false : value;
options[ key ] = value;
$container2.isotope(options);
return false;
});
});
// Infinite
$currentInfinite.find('a').unbind('click').bind('click',function(e){e.preventDefault();
var $currentNextLink=jQuery(this);
if($currentInfinite.attr('data-has-next')==='true'&&$currentNextLink.hasClass('next')){
var $infiniteURL=$currentNextLink.attr('href');
$currentInfinite.children('.next').hide();
$currentInfinite.children('.loading').fadeIn();
jQuery.ajax({
type: "POST",
url: $infiniteURL,
success: function(response){
var $newElements = jQuery(response).find('.tw-portfolio').eq(i).children('.row').children('.isotope-container').html();
var $newURL = jQuery(response).find('.tw-portfolio').eq(i).find('.tw-infinite-scroll>a.next').attr('href');
var $hasNext = jQuery(response).find('.tw-portfolio').eq(i).find('.tw-infinite-scroll').attr('data-has-next');
if($newElements){
$newElements=jQuery('<div />').append($newElements).find('article').css('opacity','0');
$currentIsotopeContainer.append($newElements);
showFilter($currentIsotopeContainer.closest('.row').prev('.tw-filter').children('.filters'),$currentIsotopeContainer.children('article'));
if($hasNext==='false'){
$currentInfinite.attr('data-has-next','false');
$currentInfinite.children('.loading').hide();
$currentInfinite.children('.no-more').fadeIn();
}else{
$currentNextLink.attr('href',$newURL);
$currentInfinite.children('.loading').hide();
$currentInfinite.children('.next').fadeIn();
}
}else{
$currentInfinite.attr('data-has-next','false');
$currentInfinite.children('.loading').hide();
$currentInfinite.children('.no-more').fadeIn();
}
setTimeout(function(){
$currentIsotopeContainer.children('article').css('opacity','1');
$currentIsotopeContainer.isotope( 'reloadItems' ).isotope({ sortBy: 'original-order' });
img_slider();
},1000);
}
});
}
});
});
});
function showFilter($currentFilter,$currnetElements){
"use strict";
$currnetElements.each(function(){
var $currnetElement = jQuery(this);
if($currentFilter.html()){
$currentFilter.children('li.hidden').each(function(){
var $currentFilterClass=jQuery(this).children('a').attr('data-option-value').replace('.','');
if($currnetElement.hasClass($currentFilterClass)){jQuery(this).removeClass('hidden');}
});
}
});
}