You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Vestride_Shuffle/jquery.shuffle.min.js

33 lines
14 KiB
JavaScript

// IMPORTANT!
// If you're already using Modernizr, delete it from this file. If you don't know what Modernizr is, leave it :)
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-csstransforms-csstransforms3d-csstransitions-cssclasses-prefixed-teststyles-testprop-testallprops-prefixes-domprefixes
*/
;window.Modernizr=function(a,b,c){function z(a){j.cssText=a}function A(a,b){return z(m.join(a+";")+(b||""))}function B(a,b){return typeof a===b}function C(a,b){return!!~(""+a).indexOf(b)}function D(a,b){for(var d in a){var e=a[d];if(!C(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function E(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:B(f,"function")?f.bind(d||b):f}return!1}function F(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+o.join(d+" ")+d).split(" ");return B(b,"string")||B(b,"undefined")?D(e,b):(e=(a+" "+p.join(d+" ")+d).split(" "),E(e,b,c))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n="Webkit Moz O ms",o=n.split(" "),p=n.toLowerCase().split(" "),q={},r={},s={},t=[],u=t.slice,v,w=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["&#173;",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},x={}.hasOwnProperty,y;!B(x,"undefined")&&!B(x.call,"undefined")?y=function(a,b){return x.call(a,b)}:y=function(a,b){return b in a&&B(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=u.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(u.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(u.call(arguments)))};return e}),q.csstransforms=function(){return!!F("transform")},q.csstransforms3d=function(){var a=!!F("perspective");return a&&"webkitPerspective"in g.style&&w("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},q.csstransitions=function(){return F("transition")};for(var G in q)y(q,G)&&(v=G.toLowerCase(),e[v]=q[G](),t.push((e[v]?"":"no-")+v));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)y(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},z(""),i=k=null,e._version=d,e._prefixes=m,e._domPrefixes=p,e._cssomPrefixes=o,e.testProp=function(a){return D([a])},e.testAllProps=F,e.testStyles=w,e.prefixed=function(a,b,c){return b?F(a,b,c):F(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+t.join(" "):""),e}(this,this.document);
// Shuffle Doesn't require this shuffle/debounce plugin, but it works better with it.
/*
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
/**
* jQuery Shuffle Plugin
* Uses CSS Transforms to filter down a grid of items.
* Dependencies: jQuery 1.9+, Modernizr 2.6.2. Optionally throttle/debounce by Ben Alman
* Inspired by Isotope http://isotope.metafizzy.co/
* Modified 2014-03-08
* @license MIT license
* @author Glen Cheney <cheney.glen@gmail.com>
* @version 2.0.6
*/
!function(t,e,i){"use strict";function s(t){return t?t.replace(/([A-Z])/g,function(t,e){return"-"+e.toLowerCase()}).replace(/^ms-/,"-ms-"):""}var n=0,r=e.prefixed("transition"),o=e.prefixed("transitionDelay"),a=e.prefixed("transitionDuration"),l={WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[r],u=e.prefixed("transform"),h=s(u),d=e.csstransforms&&e.csstransitions,f=e.csstransforms3d,c="shuffle",p="all",m="groups",y=function(e,i){i=i||{},t.extend(this,y.options,i,y.settings),this.$el=t(e),this.$window=t(window),this.unique="shuffle_"+n++,this._fire(y.EventType.LOADING),this._init(),setTimeout(t.proxy(this._fire,this,y.EventType.DONE),16)};y.EventType={LOADING:"loading",DONE:"done",SHRINK:"shrink",SHRUNK:"shrunk",FILTER:"filter",FILTERED:"filtered",SORTED:"sorted",LAYOUT:"layout",REMOVED:"removed"},y.prototype={_init:function(){var e,i,s=this,n=t.proxy(s._onResize,s),o=s.throttle?s.throttle(s.throttleTime,n):n,a=s.initialSort?s.initialSort:null;s._setVars(),s._resetCols(),s._addClasses(),s._initItems(),s.$window.on("resize."+c+"."+s.unique,o),e=s.$el.css(["paddingLeft","paddingRight","position"]),i=s._getOuterWidth(s.$el[0]),"static"===e.position&&(s.$el[0].style.position="relative"),s.offset={left:parseInt(e.paddingLeft,10)||0,top:parseInt(e.paddingTop,10)||0},s._setColumns(parseInt(i,10)),s.shuffle(s.group,a),s.supported&&setTimeout(function(){s._setTransitions(),s.$el[0].style[r]="height "+s.speed+"ms "+s.easing},0)},_addClasses:function(){this.$el.addClass(c),this.$items.addClass("shuffle-item filtered")},_setVars:function(){var e=this,i=e.columnWidth;e.$items=e._getItems(),e.isFluid=i&&t.isFunction(e.columnWidth),0===i&&null!==e.sizer&&(i=e.sizer),"string"==typeof i?e.$sizer=e.$el.find(i):i&&i.nodeType&&1===i.nodeType?e.$sizer=t(i):i&&i.jquery&&(e.$sizer=i),e.$sizer&&e.$sizer.length&&(e.useSizer=!0,e.sizer=e.$sizer[0])},_filter:function(e,s){var n=this,r=s!==i,o=r?s:n.$items,a=t();return e=e||n.lastFilter,n._fire(y.EventType.FILTER),t.isFunction(e)?o.each(function(){var i=t(this);e.call(i[0],i,n)&&(a=a.add(i))}):(n.group=e,e===p?a=o:o.each(function(){var i=t(this),s=i.data(m),r=n.delimeter&&!t.isArray(s)?s.split(n.delimeter):s;t.inArray(e,r)>-1&&(a=a.add(i))})),n._toggleFilterClasses(o,a),o=null,s=null,a},_toggleFilterClasses:function(e,i){var s="concealed",n="filtered";e.filter(i).each(function(){var e=t(this);e.hasClass(s)&&e.removeClass(s),e.hasClass(n)||e.addClass(n)}),e.not(i).each(function(){var e=t(this);e.hasClass(s)||e.addClass(s),e.hasClass(n)&&e.removeClass(n)})},_initItems:function(t){return t=t||this.$items,t.css(this.itemCss)},_updateItemCount:function(){return this.visibleItems=this.$items.filter(".filtered").length,this},_setTransition:function(t){var e=this;return t.style[r]=h+" "+e.speed+"ms "+e.easing+", opacity "+e.speed+"ms "+e.easing,t},_setTransitions:function(t){var e=this;return t=t||e.$items,t.each(function(){e._setTransition(this)}),e},_setSequentialDelay:function(e){var i=this;i.supported&&t.each(e,function(e){this.style[o]="0ms,"+(e+1)*i.sequentialFadeDelay+"ms",t(this).one(l,function(){this.style[o]="0ms"})})},_getItems:function(){return this.$el.children(this.itemSelector)},_getPreciseDimension:function(e,i){var s;return s=window.getComputedStyle?window.getComputedStyle(e,null)[i]:t(e).css(i),parseFloat(s)},_getOuterWidth:function(t,e){var i=t.offsetWidth;if(e){var s=Math.round(parseFloat(t.style.marginLeft))||0,n=Math.round(parseFloat(t.style.marginRight))||0;i+=s+n}return i},_getColumnSize:function(t,e){var i;return i=this.isFluid?this.columnWidth(e):this.useSizer?this._getPreciseDimension(this.sizer,"width"):this.columnWidth?this.columnWidth:this.$items.length>0?this._getOuterWidth(this.$items[0],!0):e,0===i&&(i=e),i+t},_getGutterSize:function(e){var i;return i=t.isFunction(this.gutterWidth)?this.gutterWidth(e):this.useSizer?this._getPreciseDimension(this.sizer,"marginLeft"):this.gutterWidth},_setColumns:function(t){var e=t||this._getOuterWidth(this.$el[0]),i=this._getGutterSize(e),s=this._getColumnSize(i,e),n=(e+i)/s;Math.abs(Math.round(n)-n)<.03&&(n=Math.round(n)),this.cols=Math.max(Math.floor(n),1),this.containerWidth=e,this.colWidth=s},_setContainerSize:function(){this.$el.css("height",Math.max.apply(Math,this.colYs))},_fire:function(t,e){this.$el.trigger(t+"."+c,e&&e.length?e:[this])},_layout:function(e,i,s,n){var r=this;i=i||r.filterEnd,r.layoutTransitionEnded=!1,t.each(e,function(e,o){var a=t(o),l=r._getOuterWidth(o,!0),u=l/r.colWidth;Math.abs(Math.round(u)-u)<.03&&(u=Math.round(u));var h=Math.min(Math.ceil(u),r.cols);if(1===h)r._placeItem(a,r.colYs,i,s,n);else{var d,f,c=r.cols+1-h,p=[];for(f=0;c>f;f++)d=r.colYs.slice(f,f+h),p[f]=Math.max.apply(Math,d);r._placeItem(a,p,i,s,n)}}),r._processStyleQueue(),r._setContainerSize()},_resetCols:function(){var t=this.cols;for(this.colYs=[];t--;)this.colYs.push(0)},_reLayout:function(t,e){var i=this;t=t||i.filterEnd,i._resetCols(),i.keepSorted&&i.lastSort?i.sort(i.lastSort,!0,e):i._layout(i.$items.filter(".filtered").get(),i.filterEnd,e)},_placeItem:function(t,e,i,s,n){for(var r=this,o=Math.min.apply(Math,e),a=0,l=0,u=e.length;u>l;l++)if(e[l]>=o-r.buffer&&e[l]<=o+r.buffer){a=l;break}var h=r.colWidth*a,d=o;h=Math.round(h+r.offset.left),d=Math.round(d+r.offset.top),t.data({x:h,y:d});var f=o+t.outerHeight(!0),c=r.cols+1-u;for(l=0;c>l;l++)r.colYs[a+l]=f;var p={from:"layout",$this:t,x:h,y:d,scale:1};s?p.skipTransition=!0:(p.opacity=1,p.callback=i),n&&(p.opacity=0),r.styleQueue.push(p)},_shrink:function(e,i){var s=this,n=e||s.$items.filter(".concealed"),r={},o=i||s.shrinkEnd;n.length&&(s._fire(y.EventType.SHRINK),s.shrinkTransitionEnded=!1,n.each(function(){var e=t(this),i=e.data();r={from:"shrink",$this:e,x:i.x,y:i.y,scale:.001,opacity:0,callback:o},s.styleQueue.push(r)}))},_onResize:function(){if(this.enabled&&!this.destroyed){var t=this._getOuterWidth(this.$el[0]);t!==this.containerWidth&&this.resized()}},transition:function(e){var s,n=this,r=function(){n.layoutTransitionEnded||"layout"!==e.from?n.shrinkTransitionEnded||"shrink"!==e.from||(e.callback.call(n),n.shrinkTransitionEnded=!0):(n._fire(y.EventType.LAYOUT),e.callback.call(n),n.layoutTransitionEnded=!0)};if(e.callback=e.callback||t.noop,n.supported)e.scale===i&&(e.scale=1),s=f?"translate3d("+e.x+"px, "+e.y+"px, 0) scale3d("+e.scale+", "+e.scale+", 1)":"translate("+e.x+"px, "+e.y+"px) scale("+e.scale+", "+e.scale+")",e.x!==i&&e.$this.css(u,s),e.opacity!==i&&e.$this.css("opacity",e.opacity),e.$this.one(l,r);else{var o={left:e.x,top:e.y,opacity:e.opacity};e.$this.stop(!0).animate(o,n.speed,"swing",r)}},_processStyleQueue:function(){var e=this,i=e.styleQueue;t.each(i,function(t,i){i.skipTransition?e._skipTransition(i.$this[0],function(){e.transition(i)}):e.transition(i)}),e.styleQueue.length=0},shrinkEnd:function(){this._fire(y.EventType.SHRUNK)},filterEnd:function(){this._fire(y.EventType.FILTERED)},sortEnd:function(){this._fire(y.EventType.SORTED)},_skipTransition:function(e,i,s){var n,r=e.style[a];e.style[a]="0ms",t.isFunction(i)?i():e.style[i]=s,n=e.offsetWidth,e.style[a]=r},_addItems:function(t,e,s){var n,r,o=this;o.supported||(e=!1),t.addClass("shuffle-item"),o._initItems(t),o._setTransitions(t),o.$items=o._getItems(),t.css("opacity",0),n=o._filter(i,t),r=n.get(),o._updateItemCount(),e?(o._layout(r,null,!0,!0),s&&o._setSequentialDelay(n),o._revealAppended(n)):o._layout(r)},_revealAppended:function(e){var i=this;setTimeout(function(){e.each(function(e,s){i.transition({from:"reveal",$this:t(s),opacity:1})})},i.revealAppendedDelay)},shuffle:function(t,e){var i=this;i.enabled&&(t||(t=p),i._filter(t),i.lastFilter=t,i._updateItemCount(),i._resetCols(),i._shrink(),e&&(i.lastSort=e),i._reLayout())},sort:function(t,e,i){var s=this,n=s.$items.filter(".filtered").sorted(t);e||s._resetCols(),s._layout(n,function(){e&&s.filterEnd(),s.sortEnd()},i),s.lastSort=t},resized:function(t){this.enabled&&(t||this._setColumns(),this._reLayout())},layout:function(){this.update(!0)},update:function(t){this.resized(t)},appended:function(t,e,i){e=e===!1?!1:!0,i=i===!1?!1:!0,this._addItems(t,e,i)},disable:function(){this.enabled=!1},enable:function(t){this.enabled=!0,t!==!1&&this.update()},remove:function(t){if(t.length&&t.jquery){var e=this;return e._shrink(t,function(){var e=this;t.remove(),setTimeout(function(){e.$items=e._getItems(),e.layout(),e._updateItemCount(),e._fire(y.EventType.REMOVED,[t,e]),t=null},0)}),e._processStyleQueue(),e}},destroy:function(){var t=this;t.$window.off("."+t.unique),t.$el.removeClass(c).removeAttr("style").removeData(c),t.$items.removeAttr("style").removeClass("concealed filtered shuffle-item"),t.$window=null,t.$items=null,t.$el=null,t.$sizer=null,t.sizer=null,t.destroyed=!0}},y.options={group:p,speed:250,easing:"ease-out",itemSelector:"",sizer:null,gutterWidth:0,columnWidth:0,delimeter:null,buffer:0,initialSort:null,throttle:t.throttle||null,throttleTime:300,sequentialFadeDelay:150,supported:d},y.settings={$sizer:null,useSizer:!1,itemCss:{position:"absolute",top:0,left:0},offset:{top:0,left:0},revealAppendedDelay:300,keepSorted:!0,enabled:!0,destroyed:!1,styleQueue:[]},t.fn.shuffle=function(e){var i=Array.prototype.slice.call(arguments,1);return this.each(function(){var s=t(this),n=s.data(c);n||(n=new y(s,e),s.data(c,n)),"string"==typeof e&&n[e]&&n[e].apply(n,i)})},t.fn.sorted=function(e){var s=t.extend({},t.fn.sorted.defaults,e),n=this.get(),r=!1;return n.length?s.randomize?t.fn.sorted.randomize(n):(s.by!==t.noop&&null!==s.by&&s.by!==i&&n.sort(function(e,n){if(r)return 0;var o=s.by(t(e)),a=s.by(t(n));return o===i&&a===i?(r=!0,0):"sortFirst"===o||"sortLast"===a?-1:"sortLast"===o||"sortFirst"===a?1:a>o?-1:o>a?1:0}),r?this.get():(s.reverse&&n.reverse(),n)):[]},t.fn.sorted.defaults={reverse:!1,by:null,randomize:!1},t.fn.sorted.randomize=function(t){var e,i,s=t.length;if(!s)return t;for(;--s;)i=Math.floor(Math.random()*(s+1)),e=t[i],t[i]=t[s],t[s]=e;return t}}(jQuery,Modernizr);