(function($,undf){$.MixItUp=function(){var self=this;self._execAction('_constructor',0);$.extend(self,{selectors:{target:'.mix',filter:'.filter',sort:'.sort'},animation:{enable:true,effects:'fade scale',duration:600,easing:'ease',perspectiveDistance:'3000',perspectiveOrigin:'50% 50%',queue:true,queueLimit:1,animateChangeLayout:false,animateResizeContainer:true,animateResizeTargets:false,staggerSequence:false,reverseOut:false},callbacks:{onMixLoad:false,onMixStart:false,onMixBusy:false,onMixEnd:false,onMixFail:false,_user:false},controls:{enable:true,live:false,toggleFilterButtons:false,toggleLogic:'or',activeClass:'active'},layout:{display:'inline-block',containerClass:'',containerClassFail:'fail'},load:{filter:'all',sort:false},_$body:null,_$container:null,_$targets:null,_$parent:null,_$sortButtons:null,_$filterButtons:null,_suckMode:false,_mixing:false,_sorting:false,_clicking:false,_loading:true,_changingLayout:false,_changingClass:false,_changingDisplay:false,_origOrder:[],_startOrder:[],_newOrder:[],_activeFilter:null,_toggleArray:[],_toggleString:'',_activeSort:'default:asc',_newSort:null,_startHeight:null,_newHeight:null,_incPadding:true,_newDisplay:null,_newClass:null,_targetsBound:0,_targetsDone:0,_queue:[],_$show:$(),_$hide:$()});self._execAction('_constructor',1);};$.MixItUp.prototype={constructor:$.MixItUp,_instances:{},_handled:{_filter:{},_sort:{}},_bound:{_filter:{},_sort:{}},_actions:{},_filters:{},extend:function(extension){for(var key in extension){$.MixItUp.prototype[key]=extension[key];}},addAction:function(hook,name,func,priority){$.MixItUp.prototype._addHook('_actions',hook,name,func,priority);},addFilter:function(hook,name,func,priority){$.MixItUp.prototype._addHook('_filters',hook,name,func,priority);},_addHook:function(type,hook,name,func,priority){var collection=$.MixItUp.prototype[type],obj={};priority=(priority===1||priority==='post')?'post':'pre';obj[hook]={};obj[hook][priority]={};obj[hook][priority][name]=func;$.extend(true,collection,obj);},_init:function(domNode,config){var self=this;self._execAction('_init',0,arguments);config&&$.extend(true,self,config);self._$body=$('body');self._domNode=domNode;self._$container=$(domNode);self._$container.addClass(self.layout.containerClass);self._id=domNode.id;self._platformDetect();self._brake=self._getPrefixedCSS('transition','none');self._refresh(true);self._$parent=self._$targets.parent().length?self._$targets.parent():self._$container;if(self.load.sort){self._newSort=self._parseSort(self.load.sort);self._newSortString=self.load.sort;self._activeSort=self.load.sort;self._sort();self._printSort();}self._activeFilter=self.load.filter==='all'?self.selectors.target:self.load.filter==='none'?'':self.load.filter;self.controls.enable&&self._bindHandlers();if(self.controls.toggleFilterButtons){self._buildToggleArray();for(var i=0;i<=4)&&(self.animation.enable=false);for(var x=0;x-1){var dataName=self._helpers._camelCase(name.substring(5,name.length));target.dataset[dataName]=val;}}}if(target.mixParent===undf){target.mixParent=self._id;}}if((self._$targets.length&&init)||(!self._origOrder.length&&self._$targets.length)){self._origOrder=[];for(var i=0;i-1){$(self.selectors.sort).removeClass(self.controls.activeClass);trackClick($button,type);self.sort(sort);}}if(type==='filter'){var filter=$button.attr('data-filter'),ndx,seperator=self.controls.toggleLogic==='or'?',':'';if(!self.controls.toggleFilterButtons){if(!$button.hasClass(self.controls.activeClass)){$(self.selectors.filter).removeClass(self.controls.activeClass);trackClick($button,type);self.filter(filter);}}else{self._buildToggleArray();if(!$button.hasClass(self.controls.activeClass)){trackClick($button,type);self._toggleArray.push(filter);}else{trackClick($button,type,true);ndx=self._toggleArray.indexOf(filter);self._toggleArray.splice(ndx,1);}self._toggleArray=$.grep(self._toggleArray,function(n){return(n);});self._toggleString=self._toggleArray.join(seperator);self.filter(self._toggleString);}}self._execAction('_processClick',1,arguments);}else{if(typeof self.callbacks.onMixBusy==='function'){self.callbacks.onMixBusy.call(self._domNode,self._state,self);}self._execAction('_processClickBusy',1,arguments);}},_buildToggleArray:function(){var self=this,activeFilter=self._activeFilter.replace(/\s/g,'');self._execAction('_buildToggleArray',0,arguments);if(self.controls.toggleLogic==='or'){self._toggleArray=activeFilter.split(',');}else{self._toggleArray=activeFilter.split('.');!self._toggleArray[0]&&self._toggleArray.shift();for(var i=0,filter;filter=self._toggleArray[i];i++){self._toggleArray[i]='.'+filter;}}self._execAction('_buildToggleArray',1,arguments);},_updateControls:function(command,multi){var self=this,output={filter:command.filter,sort:command.sort},update=function($el,filter){(multi&&type=='filter'&&!(output.filter==='none'||output.filter===''))?$el.filter(filter).addClass(self.controls.activeClass):$el.removeClass(self.controls.activeClass).filter(filter).addClass(self.controls.activeClass);},type='filter',$el=null;self._execAction('_updateControls',0,arguments);(command.filter===undf)&&(output.filter=self._activeFilter);(command.sort===undf)&&(output.sort=self._activeSort);(output.filter===self.selectors.target)&&(output.filter='all');for(var i=0;i<2;i++){$el=self.controls.live?$(self.selectors[type]):self['_$'+type+'Buttons'];$el&&update($el,'[data-'+type+'="'+output[type]+'"]');type='sort';}self._execAction('_updateControls',1,arguments);},_filter:function(){var self=this;self._execAction('_filter',0);for(var i=0;iattrB)return order=='asc'?1:-1;if(attrA==attrB&&self._newSort.length>depth+1)return self._compare(a,b,depth+1);return 0;},_printSort:function(reset){var self=this,order=reset?self._startOrder:self._newOrder,targets=self._$parent[0].querySelectorAll(self.selectors.target),nextSibling=targets[targets.length-1].nextElementSibling,frag=document.createDocumentFragment();self._execAction('_printSort',0,arguments);for(var i=0;i-1){if(extract){var propIndex=self.animation.effects.indexOf(effect+'(');if(propIndex>-1){var str=self.animation.effects.substring(propIndex),match=/\(([^)]+)\)/.exec(str),val=match[1];return{val:val};}}return true;}else{return false;}},negate=function(value,invert){if(invert){return value.charAt(0)==='-'?value.substr(1,value.length):'-'+value;}else{return value;}},buildTransform=function(key,invert){var transforms=[['scale','.01'],['translateX','20px'],['translateY','20px'],['translateZ','20px'],['rotateX','90deg'],['rotateY','90deg'],['rotateZ','180deg'],];for(var i=0;i<2;j++){var a=j===0?a=self._prefix:'';if(self._ff&&self._ff<=20){toShowCSS[a+'transition-property']='all';toShowCSS[a+'transition-timing-function']=self.animation.easing+'ms';toShowCSS[a+'transition-duration']=self.animation.duration+'ms';}toShowCSS[a+'transition-delay']=delay+'ms';toShowCSS[a+'transform']='translate('+translate.x+'px,'+translate.y+'px)';}if(self.effects.transform||self.effects.opacity){self._bindTargetDone($el);}(self._ff&&self._ff<=20)?$el.css(toShowCSS):$el.css(self.effects.transition).css(toShowCSS);}for(var i=0;i<2;j++){var a=j===0?a=self._prefix:'';toHideCSS[a+'transition-delay']=delay+'ms';toHideCSS[a+'transform']=self.effects.transformOut;toHideCSS.opacity=self.effects.opacity;}$el.css(self.effects.transition).css(toHideCSS);if(self.effects.transform||self.effects.opacity){self._bindTargetDone($el);};}self._execAction('_animateTargets',1);},_bindTargetDone:function($el){var self=this,el=$el[0];self._execAction('_bindTargetDone',0,arguments);if(!el.dataset.bound){el.dataset.bound=true;self._targetsBound++;$el.on('webkitTransitionEnd.mixItUp transitionend.mixItUp',function(e){if((e.originalEvent.propertyName.indexOf('transform')>-1||e.originalEvent.propertyName.indexOf('opacity')>-1)&&$(e.originalEvent.target).is(self.selectors.target)){$el.off('.mixItUp');delete el.dataset.bound;self._targetDone();}});}self._execAction('_bindTargetDone',1,arguments);},_targetDone:function(){var self=this;self._execAction('_targetDone',0);self._targetsDone++;(self._targetsDone===self._targetsBound)&&self._cleanUp();self._execAction('_targetDone',1);},_cleanUp:function(){var self=this,targetStyles=self.animation.animateResizeTargets?'transform opacity width height margin-bottom margin-right':'transform opacity';unBrake=function(){self._$targets.removeStyle('transition',self._prefix);};self._execAction('_cleanUp',0);!self._changingLayout?self._$show.css('display',self.layout.display):self._$show.css('display',self._newDisplay);self._$targets.css(self._brake);self._$targets.removeStyle(targetStyles,self._prefix).removeAttr('data-inter-pos-x data-inter-pos-y data-final-pos-x data-final-pos-y data-orig-pos-x data-orig-pos-y data-orig-height data-orig-width data-final-height data-final-width data-inter-width data-inter-height data-orig-margin-right data-orig-margin-bottom data-inter-margin-right data-inter-margin-bottom data-final-margin-right data-final-margin-bottom');self._$hide.removeStyle('display');self._$parent.removeStyle('height transition perspective-distance perspective perspective-origin-x perspective-origin-y perspective-origin perspectiveOrigin',self._prefix);if(self._sorting){self._printSort();self._activeSort=self._newSortString;self._sorting=false;}if(self._changingLayout){if(self._changingDisplay){self.layout.display=self._newDisplay;self._changingDisplay=false;}if(self._changingClass){self._$parent.removeClass(self.layout.containerClass).addClass(self._newClass);self.layout.containerClass=self._newClass;self._changingClass=false;}self._changingLayout=false;}self._refresh();self._buildState();if(self._state.fail){self._$container.addClass(self.layout.containerClassFail);}self._$show=$();self._$hide=$();if(window.requestAnimationFrame){requestAnimationFrame(unBrake);}self._mixing=false;if(typeof self.callbacks._user==='function'){self.callbacks._user.call(self._domNode,self._state,self);}if(typeof self.callbacks.onMixEnd==='function'){self.callbacks.onMixEnd.call(self._domNode,self._state,self);}self._$container.trigger('mixEnd',[self._state,self]);if(self._state.fail){(typeof self.callbacks.onMixFail==='function')&&self.callbacks.onMixFail.call(self._domNode,self._state,self);self._$container.trigger('mixFail',[self._state,self]);}if(self._loading){(typeof self.callbacks.onMixLoad==='function')&&self.callbacks.onMixLoad.call(self._domNode,self._state,self);self._$container.trigger('mixLoad',[self._state,self]);}if(self._queue.length){self._execAction('_queue',0);self.multiMix(self._queue[0][0],self._queue[0][1],self._queue[0][2]);self._queue.splice(0,1);}self._execAction('_cleanUp',1);self._loading=false;},_getPrefixedCSS:function(property,value,prefixValue){var self=this,styles={};for(i=0;i<2;i++){var prefix=i===0?self._prefix:'';prefixValue?styles[prefix+property]=prefix+value:styles[prefix+property]=value;}return self._execFilter('_getPrefixedCSS',styles,arguments);},_getDelay:function(i){var self=this,n=typeof self.animation.staggerSequence==='function'?self.animation.staggerSequence.call(self._domNode,i,self._state):i,delay=self.animation.stagger?n*self.animation.staggerDuration:0;return self._execFilter('_getDelay',delay,arguments);},_parseMultiMixArgs:function(args){var self=this,output={command:null,animate:self.animation.enable,callback:null};for(var i=0;i<2)&&(self._clicking=false);delete self.callbacks._user;if(args.callback)self.callbacks._user=args.callback;var sort=args.command.sort,filter=args.command.filter,changeLayout=args.command.changeLayout;self._refresh();if(sort){self._newSort=self._parseSort(sort);self._newSortString=sort;self._sorting=true;self._sort();}if(filter!==undf){filter=(filter==='all')?self.selectors.target:filter;self._activeFilter=filter;}self._filter();if(changeLayout){self._newDisplay=(typeof changeLayout==='string')?changeLayout:changeLayout.display||self.layout.display;self._newClass=changeLayout.containerClass||'';if(self._newDisplay!==self.layout.display||self._newClass!==self.layout.containerClass){self._changingLayout=true;self._changingClass=(self._newClass!==self.layout.containerClass);self._changingDisplay=(self._newDisplay!==self.layout.display);}}self._$targets.css(self._brake);self._goMix(args.animate^self.animation.enable?args.animate:self.animation.enable);self._execAction('multiMix',1,arguments);}else{if(self.animation.queue&&self._queue.length<<0).toString(16)).substr(-6).toUpperCase();};instance._execAction('_instantiate',0,arguments);domNode.id=!domNode.id?'MixItUp'+rand():domNode.id;if(!instance._instances[domNode.id]){instance._instances[domNode.id]=instance;instance._init(domNode,settings);}instance._execAction('_instantiate',1,arguments);};eachReturn=this.each(function(){if(args&&typeof args[0]==='string'){var instance=$.MixItUp.prototype._instances[this.id];if(args[0]=='isLoaded'){dataReturn.push(instance?true:false);}else{var data=instance[args[0]](args[1],args[2],args[3]);if(data!==undf)dataReturn.push(data);}}else{_instantiate(this,args[0]);}});if(dataReturn.length){return dataReturn.length>1?dataReturn:dataReturn[0];}else{return eachReturn;}};$.fn.removeStyle=function(style,prefix){prefix=prefix?prefix:'';return this.each(function(){var el=this,styles=style.split(' ');for(var i=0;i<2;j++){var prop=j?styles[i]:prefix+styles[i];if(el.style[prop]!==undf&&typeof el.style[prop]!=='unknown'&&el.style[prop].length>0){el.style[prop]='';}if(!prefix)break;}}if(el.attributes&&el.attributes.style&&el.attributes.style!==undf&&el.attributes.style.value===''){el.attributes.removeNamedItem('style');}});};})(jQuery);