Rewrote plugin in more object oriented structure.

Added custom events.
Updated to Modernizr 2.6.1.
Updated images to be 2x the size for retina :)
pull/56/head
Glen Cheeny 12 years ago
parent 147b2c07c1
commit 31c83bf08a

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 19 KiB

@ -7,7 +7,6 @@
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/prettify.css" />
<link href='http://fonts.googleapis.com/css?family=Poly:400,400italic' rel='stylesheet' type='text/css' />
<!--<link href='http://fonts.googleapis.com/css?family=Poly:400,400italic|Open+Sans:400italic,600italic,400,700,300,800' rel='stylesheet' type='text/css'>-->
</head>
<body>
<div id="main">
@ -195,7 +194,7 @@ $(document).ready(function(){
$this.addClass('active');
// Filter elements
$grid.shuffle('shuffle', $this.attr('data-key'));
$grid.shuffle($this.attr('data-key'));
});
// instantiate the plugin
@ -211,7 +210,7 @@ $(document).ready(function(){
</code>
</pre>
<p>Events that get triggered: <code>shrink.shuffle</code>, <code>shrunk.shuffle</code>, <code>filter.shuffle</code>, and <code>filtered.shuffle</code>.</p>
</div>
</section>
@ -263,6 +262,7 @@ $(document).ready(function(){
<section>
<h2>Changes</h2>
<ul>
<li>7.21.12 - Rewrote plugin in more object oriented structure. Added custom events. Updated to Modernizr 2.6.1</li>
<li>7.3.12 - Removed dependency on the css file and now apply the css with javascript</li>
</ul>
@ -275,8 +275,11 @@ $(document).ready(function(){
<script defer src="js/prettify.js"></script>
<script>
$(document).ready(function(){
$(document).ready(function() {
// Make code pretty
prettyPrint();
// Set up button clicks
$('.filter-options li').on('click', function() {
@ -288,7 +291,7 @@ $(document).ready(function(){
$this.addClass('active');
// Filter elements
$grid.shuffle('shuffle', $this.attr('data-key'));
$grid.shuffle($this.attr('data-key'));
});
// instantiate the plugin
@ -300,6 +303,13 @@ $(document).ready(function(){
speed : 800,
easing : 'ease-out'
});
// You can subscribe to custom events: shrink, shrunk, filter, and filtered
// $('#grid').on('shrink.shuffle shrunk.shuffle filter.shuffle filtered.shuffle', function(evt, shuffle) {
// });
});
</script>

@ -1,10 +1,10 @@
// IMPORTANT!
// If you're already using Modernizr, delete it from this file. If you don't know what Modernizr is, leave it :)
/* Modernizr 2.5.3 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-csstransforms-csstransforms3d-csstransitions-cssclasses-prefixed-teststyles-testprop-testallprops-prefixes-domprefixes
/* Modernizr 2.6.1 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-csstransforms-csstransforms3d-csstransitions-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)if(j[a[d]]!==c)return b=="pfx"?a[d]:!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.substr(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.5.3",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=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);return f=["&#173;","<style>",a,"</style>"].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!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});var G=function(a,c){var d=a.join(""),f=c.length;w(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d?d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"":"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.csstransforms3d=(i.csstransforms3d&&i.csstransforms3d.offsetLeft)===9&&i.csstransforms3d.offsetHeight===3},f,c)}([,["@media (",m.join("transform-3d),("),h,")","{#csstransforms3d{left:9px;position:absolute;height:3px;}}"].join("")],[,"csstransforms3d"]);q.csstransforms=function(){return!!F("transform")},q.csstransforms3d=function(){var a=!!F("perspective");return a&&"webkitPerspective"in g.style&&(a=e.csstransforms3d),a},q.csstransitions=function(){return F("transition")};for(var H in q)y(q,H)&&(v=H.toLowerCase(),e[v]=q[H](),t.push((e[v]?"":"no-")+v));return 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);
;window.Modernizr=function(a,b,c){function y(a){i.cssText=a}function z(a,b){return y(l.join(a+";")+(b||""))}function A(a,b){return typeof a===b}function B(a,b){return!!~(""+a).indexOf(b)}function C(a,b){for(var d in a){var e=a[d];if(!B(e,"-")&&i[e]!==c)return b=="pfx"?e:!0}return!1}function D(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:A(f,"function")?f.bind(d||b):f}return!1}function E(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+n.join(d+" ")+d).split(" ");return A(b,"string")||A(b,"undefined")?C(e,b):(e=(a+" "+o.join(d+" ")+d).split(" "),D(e,b,c))}var d="2.6.1",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l=" -webkit- -moz- -o- -ms- ".split(" "),m="Webkit Moz O ms",n=m.split(" "),o=m.toLowerCase().split(" "),p={},q={},r={},s=[],t=s.slice,u,v=function(a,c,d,e){var h,i,j,k=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:g+(d+1),k.appendChild(j);return h=["&#173;",'<style id="s',g,'">',a,"</style>"].join(""),k.id=g,(l?k:m).innerHTML+=h,m.appendChild(k),l||(m.style.background="",f.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},w={}.hasOwnProperty,x;!A(w,"undefined")&&!A(w.call,"undefined")?x=function(a,b){return w.call(a,b)}:x=function(a,b){return b in a&&A(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=t.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(t.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(t.call(arguments)))};return e}),p.csstransforms=function(){return!!E("transform")},p.csstransforms3d=function(){var a=!!E("perspective");return a&&"webkitPerspective"in f.style&&v("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},p.csstransitions=function(){return E("transition")};for(var F in p)x(p,F)&&(u=F.toLowerCase(),e[u]=p[F](),s.push((e[u]?"":"no-")+u));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)x(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,enableClasses&&(f.className+=" "+(b?"":"no-")+a),e[a]=b}return e},y(""),h=j=null,e._version=d,e._prefixes=l,e._domPrefixes=o,e._cssomPrefixes=n,e.testProp=function(a){return C([a])},e.testAllProps=E,e.testStyles=v,e.prefixed=function(a,b,c){return b?E(a,b,c):E(a,"pfx")},e}(this,this.document);
/**
* jQuery Shuffle Plugin
@ -12,108 +12,86 @@
* Inspired by Isotope http://isotope.metafizzy.co/
* Use it for whatever you want!
* @author Glen Cheney (http://glencheney.com)
* @version 1.3
* @date 7/3/12
* @version 1.4
* @date 7/21/12
*/
;(function($, Modernizr) {
"use strict";
var supported = Modernizr.csstransforms || Modernizr.csstransitions,
methods = {
var Shuffle = function($container, options) {
var self = this,
$this = $(this);
$.extend(self, {
itemWidth : 230,
marginTop : 20,
marginRight: 20,
key : 'all',
speed : 800,
easing : 'ease-out'
}, options, {
$container: $container,
supported: Modernizr.csstransforms && Modernizr.csstransitions
});
// CSS for each item
self.itemCss = {
position: 'absolute',
opacity: 1, // Everything after this is for jQuery fallback
top: 0,
left: 0,
marginTop: self.marginTop,
marginRight: self.marginRight,
'float': 'left'
};
init : function(options) {
self.$items = self.$container.children();
self.itemsPerRow = Math.floor(self.$container.width() / self.itemWidth);
self.itemHeight = self.$items.first().outerHeight();
self.transitionName = self.prefixed('transition'),
self.transform = self.getPrefixed('transform');
// Customizable options
var settings = {
itemWidth : 230,
marginTop : 20,
marginRight: 20,
key : 'all',
speed : 800,
easing : 'ease-out'
};
// Set up css for transitions
self.$container.css('position', 'relative').get(0).style[self.transitionName] = 'height ' + self.speed + 'ms ' + self.easing;
self.$items.each(function(index) {
var defaults = self.itemCss;
if (options) {
$.extend(settings, options);
// Set CSS transition for transforms and opacity
if (self.supported) {
this.style[self.transitionName] = self.transform + ' ' + self.speed + 'ms ' + self.easing + ', opacity ' + self.speed + 'ms ' + self.easing;
}
settings.itemCss = {
position: 'absolute',
opacity: 1, // Everything after this is for jQuery fallback
top: 0,
left: 0,
marginTop: settings.marginTop,
marginRight: settings.marginRight,
float: 'left'
};
return this.each(function() {
var $this = $(this),
$items = $this.children(),
itemsPerRow = Math.floor($this.width() / settings.itemWidth),
itemHeight = $items.first().outerHeight(),
data,
transition = Modernizr.prefixed('transition'),
transform = methods.getPrefixed('transform');
// Set the margin-right to zero for the last item in the row
if ((index + 1) % self.itemsPerRow === 0) {
defaults.marginRight = 0;
}
// Set up css for transitions
$this.css('position', 'relative').get(0).style[transition] = 'height ' + settings.speed + 'ms ' + settings.easing;
$items.each(function(index) {
var defaults = settings.itemCss;
// Set CSS transition for transforms and opacity
if (supported) {
this.style[transition] = transform + ' ' + settings.speed + 'ms ' + settings.easing + ', opacity ' + settings.speed + 'ms ' + settings.easing;
}
// Set the margin-right to zero for the last item in the row
if ((index + 1) % itemsPerRow === 0) {
defaults.marginRight = 0;
}
$(this).css(self.itemCss);
});
// Do it
self.shuffle('all');
};
$(this).css(settings.itemCss);
});
Shuffle.prototype = {
data = {
$items : $items,
itemsPerRow : itemsPerRow,
itemHeight : itemHeight,
itemWidth : settings.itemWidth,
marginTop : settings.marginTop,
marginRight : settings.marginRight,
settings : settings
};
constructor: Shuffle,
// Save our settings for recall
$this.data('shuffle', data);
// Do it
methods.shuffle.call(this, 'all');
});
},
/**
* The magic. This is what makes the plugin 'shuffle'
*/
shuffle : function(category) {
var $this = $(this),
data = $this.data('shuffle'),
var self = this,
numElements,
gridHeight;
// If we somehow don't have data, initialize it
if (!data) {
methods.init.call(this);
data = $(this).data('shuffle');
}
if (!category) category = 'all';
// Hide/show appropriate items
if (category === 'all') {
data.$items.removeClass('concealed');
self.$items.removeClass('concealed');
} else {
data.$items.removeClass('concealed filtered').each(function() {
self.$items.removeClass('concealed filtered').each(function() {
var keys = $(this).attr('data-key'),
kArray = $.parseJSON(keys);
if ($.inArray(category, kArray) === -1) {
@ -124,17 +102,25 @@
}
// How many filtered elements?
numElements = data.$items.not('.concealed').addClass('filtered').length;
numElements = self.$items.not('.concealed').addClass('filtered').length;
// Shrink each concealed item
methods.shrink.call(this);
self.$container.trigger('shrink.shuffle', self);
self.shrink();
setTimeout(function() {
self.$container.trigger('shrunk.shuffle', self);
}, self.speed);
// Update transforms on .filtered elements so they will animate to their new positions
methods.filter.call(this);
self.$container.trigger('filter.shuffle', self);
self.filter();
setTimeout(function() {
self.$container.trigger('filtered.shuffle', self);
}, self.speed);
// Adjust the height of the grid
gridHeight = (Math.ceil(numElements / data.itemsPerRow) * (data.itemHeight + data.marginTop)) - data.marginTop;
$this.css('height', gridHeight + 'px');
gridHeight = (Math.ceil(numElements / self.itemsPerRow) * (self.itemHeight + self.marginTop)) - self.marginTop;
self.$container.css('height', gridHeight + 'px');
},
@ -142,25 +128,25 @@
* Hides the elements that don't match our filter
*/
shrink : function() {
var $concealed = $(this).find('.concealed');
var self = this,
$concealed = self.$container.find('.concealed');
if ($concealed.length === 0) {
return;
}
$concealed.each(function() {
var $this = $(this),
x = parseInt($this.attr('data-x'), 10),
y = parseInt($this.attr('data-y'), 10),
data = $this.parent().data('shuffle');
y = parseInt($this.attr('data-y'), 10);
if (!x) x = 0;
if (!y) y = 0;
methods.transition({
self.transition({
$this: $this,
x: x,
y: y,
left: (x + (data.itemWidth / 2)) + 'px',
top: (y + (data.itemHeight / 2)) + 'px',
left: (x + (self.itemWidth / 2)) + 'px',
top: (y + (self.itemHeight / 2)) + 'px',
scale : 0.001,
opacity: 0,
height: '0px',
@ -175,22 +161,23 @@
* Calculates the x and y position and then tranitions it
*/
filter : function() {
var y = 0, $filtered = $(this).find('.filtered');
var self = this,
y = 0,
$filtered = self.$container.find('.filtered');
$filtered.each(function(index) {
var $this = $(this),
data = $this.parent().data('shuffle'),
x = (index % data.itemsPerRow) * (data.itemWidth + data.marginRight),
row = Math.floor(index / data.itemsPerRow);
x = (index % self.itemsPerRow) * (self.itemWidth + self.marginRight),
row = Math.floor(index / self.itemsPerRow);
if (index % data.itemsPerRow === 0) {
y = row * (data.itemHeight + data.marginTop);
if (index % self.itemsPerRow === 0) {
y = row * (self.itemHeight + self.marginTop);
}
// Save data for shrink
$this.attr({'data-x' : x, 'data-y' : y});
methods.transition({
self.transition({
$this: $this,
x: x,
y: y,
@ -198,8 +185,8 @@
top: y + 'px',
scale : 1,
opacity: 1,
height: data.itemHeight + 'px',
width: data.itemWidth + 'px'
height: self.itemHeight + 'px',
width: self.itemWidth + 'px'
});
});
},
@ -214,6 +201,10 @@
$el.css(Modernizr.prefixed(prop), value);
},
prefixed : function(prop) {
return Modernizr.prefixed(prop);
},
/**
* Returns things like -webkit-transition or -moz-box-sizing
* @param {string} property to be prefixed.
@ -238,9 +229,10 @@
* @param {String} opts.width the width of the item (used when no transforms available)
*/
transition: function(opts) {
var transform;
var self = this,
transform;
// Use CSS Transforms if we have them
if (supported) {
if (self.supported) {
if (Modernizr.csstransforms3d) {
transform = 'translate3d(' + opts.x + 'px, ' + opts.y + 'px, 0px) scale3d(' + opts.scale + ', ' + opts.scale + ', ' + opts.scale + ')';
} else {
@ -249,7 +241,7 @@
// Update css to trigger CSS Animation
opts.$this.css('opacity' , opts.opacity);
methods.setPrefixedCss(opts.$this, 'transform', transform);
self.setPrefixedCss(opts.$this, 'transform', transform);
} else {
// Use jQuery to animate left/top
opts.$this.animate({
@ -258,20 +250,29 @@
opacity: opts.opacity,
height: opts.height,
width: opts.width
}, 800);
}, self.speed);
}
}
};
// Plugin definition
$.fn.shuffle = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || ! method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.shuffle');
return false;
}
$.fn.shuffle = function(opts, key) {
return this.each(function() {
var $this = $(this),
shuffle = $this.data('shuffle');
if (!shuffle) {
shuffle = new Shuffle($this, opts);
$this.data('shuffle', shuffle);
}
// Execute a function
if (typeof opts === 'string') {
if (opts !== 'shuffle') {
key = opts;
}
shuffle.shuffle(key);
}
});
};
})(jQuery, Modernizr);

@ -1,10 +1,10 @@
// IMPORTANT!
// If you're already using Modernizr, delete it from this file. If you don't know what Modernizr is, leave it :)
/* Modernizr 2.5.3 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-csstransforms-csstransforms3d-csstransitions-cssclasses-prefixed-teststyles-testprop-testallprops-prefixes-domprefixes
/* Modernizr 2.6.1 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-csstransforms-csstransforms3d-csstransitions-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)if(j[a[d]]!==c)return b=="pfx"?a[d]:!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.substr(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.5.3",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=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);return f=["&#173;","<style>",a,"</style>"].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!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});var G=function(a,c){var d=a.join(""),f=c.length;w(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d?d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"":"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.csstransforms3d=(i.csstransforms3d&&i.csstransforms3d.offsetLeft)===9&&i.csstransforms3d.offsetHeight===3},f,c)}([,["@media (",m.join("transform-3d),("),h,")","{#csstransforms3d{left:9px;position:absolute;height:3px;}}"].join("")],[,"csstransforms3d"]);q.csstransforms=function(){return!!F("transform")},q.csstransforms3d=function(){var a=!!F("perspective");return a&&"webkitPerspective"in g.style&&(a=e.csstransforms3d),a},q.csstransitions=function(){return F("transition")};for(var H in q)y(q,H)&&(v=H.toLowerCase(),e[v]=q[H](),t.push((e[v]?"":"no-")+v));return 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);
;window.Modernizr=function(a,b,c){function y(a){i.cssText=a}function z(a,b){return y(l.join(a+";")+(b||""))}function A(a,b){return typeof a===b}function B(a,b){return!!~(""+a).indexOf(b)}function C(a,b){for(var d in a){var e=a[d];if(!B(e,"-")&&i[e]!==c)return b=="pfx"?e:!0}return!1}function D(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:A(f,"function")?f.bind(d||b):f}return!1}function E(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+n.join(d+" ")+d).split(" ");return A(b,"string")||A(b,"undefined")?C(e,b):(e=(a+" "+o.join(d+" ")+d).split(" "),D(e,b,c))}var d="2.6.1",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l=" -webkit- -moz- -o- -ms- ".split(" "),m="Webkit Moz O ms",n=m.split(" "),o=m.toLowerCase().split(" "),p={},q={},r={},s=[],t=s.slice,u,v=function(a,c,d,e){var h,i,j,k=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:g+(d+1),k.appendChild(j);return h=["&#173;",'<style id="s',g,'">',a,"</style>"].join(""),k.id=g,(l?k:m).innerHTML+=h,m.appendChild(k),l||(m.style.background="",f.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},w={}.hasOwnProperty,x;!A(w,"undefined")&&!A(w.call,"undefined")?x=function(a,b){return w.call(a,b)}:x=function(a,b){return b in a&&A(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=t.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(t.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(t.call(arguments)))};return e}),p.csstransforms=function(){return!!E("transform")},p.csstransforms3d=function(){var a=!!E("perspective");return a&&"webkitPerspective"in f.style&&v("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},p.csstransitions=function(){return E("transition")};for(var F in p)x(p,F)&&(u=F.toLowerCase(),e[u]=p[F](),s.push((e[u]?"":"no-")+u));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)x(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,enableClasses&&(f.className+=" "+(b?"":"no-")+a),e[a]=b}return e},y(""),h=j=null,e._version=d,e._prefixes=l,e._domPrefixes=o,e._cssomPrefixes=n,e.testProp=function(a){return C([a])},e.testAllProps=E,e.testStyles=v,e.prefixed=function(a,b,c){return b?E(a,b,c):E(a,"pfx")},e}(this,this.document);
/**
* jQuery Shuffle Plugin
@ -12,7 +12,13 @@
* Inspired by Isotope http://isotope.metafizzy.co/
* Use it for whatever you want!
* @author Glen Cheney (http://glencheney.com)
* @version 1.3
* @date 7/3/12
* @version 1.4
* @date 7/21/12
*/
;(function(a,b){"use strict";var c=b.csstransforms||b.csstransitions,d={init:function(e){var f={itemWidth:230,marginTop:20,marginRight:20,key:"all",speed:800,easing:"ease-out"};if(e){a.extend(f,e)}f.itemCss={position:"absolute",opacity:1,top:0,left:0,marginTop:f.marginTop,marginRight:f.marginRight,"float":"left"};return this.each(function(){var e=a(this),g=e.children(),h=Math.floor(e.width()/f.itemWidth),i=g.first().outerHeight(),j,k=b.prefixed("transition"),l=d.getPrefixed("transform");e.css("position","relative").get(0).style[k]="height "+f.speed+"ms "+f.easing;g.each(function(b){var d=f.itemCss;if(c){this.style[k]=l+" "+f.speed+"ms "+f.easing+", opacity "+f.speed+"ms "+f.easing}if((b+1)%h===0){d.marginRight=0}a(this).css(f.itemCss)});j={$items:g,itemsPerRow:h,itemHeight:i,itemWidth:f.itemWidth,marginTop:f.marginTop,marginRight:f.marginRight,settings:f};e.data("shuffle",j);d.shuffle.call(this,"all")})},shuffle:function(b){var c=a(this),e=c.data("shuffle"),f,g;if(!e){d.init.call(this);e=a(this).data("shuffle")}if(!b)b="all";if(b==="all"){e.$items.removeClass("concealed")}else{e.$items.removeClass("concealed filtered").each(function(){var c=a(this).attr("data-key"),d=a.parseJSON(c);if(a.inArray(b,d)===-1){a(this).addClass("concealed");return}})}f=e.$items.not(".concealed").addClass("filtered").length;d.shrink.call(this);d.filter.call(this);g=Math.ceil(f/e.itemsPerRow)*(e.itemHeight+e.marginTop)-e.marginTop;c.css("height",g+"px")},shrink:function(){var b=a(this).find(".concealed");if(b.length===0){return}b.each(function(){var b=a(this),c=parseInt(b.attr("data-x"),10),e=parseInt(b.attr("data-y"),10),f=b.parent().data("shuffle");if(!c)c=0;if(!e)e=0;d.transition({$this:b,x:c,y:e,left:c+f.itemWidth/2+"px",top:e+f.itemHeight/2+"px",scale:.001,opacity:0,height:"0px",width:"0px"})})},filter:function(){var b=0,c=a(this).find(".filtered");c.each(function(c){var e=a(this),f=e.parent().data("shuffle"),g=c%f.itemsPerRow*(f.itemWidth+f.marginRight),h=Math.floor(c/f.itemsPerRow);if(c%f.itemsPerRow===0){b=h*(f.itemHeight+f.marginTop)}e.attr({"data-x":g,"data-y":b});d.transition({$this:e,x:g,y:b,left:g+"px",top:b+"px",scale:1,opacity:1,height:f.itemHeight+"px",width:f.itemWidth+"px"})})},setPrefixedCss:function(a,c,d){a.css(b.prefixed(c),d)},getPrefixed:function(a){return b.prefixed(a).replace(/([A-Z])/g,function(a,b){return"-"+b.toLowerCase()}).replace(/^ms-/,"-ms-")},transition:function(a){var e;if(c){if(b.csstransforms3d){e="translate3d("+a.x+"px, "+a.y+"px, 0px) scale3d("+a.scale+", "+a.scale+", "+a.scale+")"}else{e="translate("+a.x+"px, "+a.y+"px) scale("+a.scale+", "+a.scale+")"}a.$this.css("opacity",a.opacity);d.setPrefixedCss(a.$this,"transform",e)}else{a.$this.animate({left:a.left,top:a.top,opacity:a.opacity,height:a.height,width:a.width},800)}}};a.fn.shuffle=function(b){if(d[b]){return d[b].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof b==="object"||!b){return d.init.apply(this,arguments)}else{a.error("Method "+b+" does not exist on jQuery.shuffle");return false}}})(jQuery,Modernizr);
;(function(e,d){var g=function(a,c){var b=this;e(this);e.extend(b,{itemWidth:230,marginTop:20,marginRight:20,key:"all",speed:800,easing:"ease-out"},c,{$container:a,supported:d.csstransforms&&d.csstransitions});b.itemCss={position:"absolute",opacity:1,top:0,left:0,marginTop:b.marginTop,marginRight:b.marginRight,"float":"left"};b.$items=b.$container.children();b.itemsPerRow=Math.floor(b.$container.width()/b.itemWidth);b.itemHeight=b.$items.first().outerHeight();b.transitionName=b.prefixed("transition");
b.transform=b.getPrefixed("transform");b.$container.css("position","relative").get(0).style[b.transitionName]="height "+b.speed+"ms "+b.easing;b.$items.each(function(a){var c=b.itemCss;b.supported&&(this.style[b.transitionName]=b.transform+" "+b.speed+"ms "+b.easing+", opacity "+b.speed+"ms "+b.easing);0===(a+1)%b.itemsPerRow&&(c.marginRight=0);e(this).css(b.itemCss)});b.shuffle("all")};g.prototype={constructor:g,shuffle:function(a){var c=this,b;a||(a="all");"all"===a?c.$items.removeClass("concealed"):
c.$items.removeClass("concealed filtered").each(function(){var b=e(this).attr("data-key"),b=e.parseJSON(b);-1===e.inArray(a,b)&&e(this).addClass("concealed")});b=c.$items.not(".concealed").addClass("filtered").length;c.$container.trigger("shrink.shuffle",c);c.shrink();setTimeout(function(){c.$container.trigger("shrunk.shuffle",c)},c.speed);c.$container.trigger("filter.shuffle",c);c.filter();setTimeout(function(){c.$container.trigger("filtered.shuffle",c)},c.speed);b=Math.ceil(b/c.itemsPerRow)*(c.itemHeight+
c.marginTop)-c.marginTop;c.$container.css("height",b+"px")},shrink:function(){var a=this,c=a.$container.find(".concealed");0!==c.length&&c.each(function(){var b=e(this),c=parseInt(b.attr("data-x"),10),f=parseInt(b.attr("data-y"),10);c||(c=0);f||(f=0);a.transition({$this:b,x:c,y:f,left:c+a.itemWidth/2+"px",top:f+a.itemHeight/2+"px",scale:0.001,opacity:0,height:"0px",width:"0px"})})},filter:function(){var a=this,c=0;a.$container.find(".filtered").each(function(b){var h=e(this),f=b%a.itemsPerRow*(a.itemWidth+
a.marginRight),d=Math.floor(b/a.itemsPerRow);0===b%a.itemsPerRow&&(c=d*(a.itemHeight+a.marginTop));h.attr({"data-x":f,"data-y":c});a.transition({$this:h,x:f,y:c,left:f+"px",top:c+"px",scale:1,opacity:1,height:a.itemHeight+"px",width:a.itemWidth+"px"})})},setPrefixedCss:function(a,c,b){a.css(d.prefixed(c),b)},prefixed:function(a){return d.prefixed(a)},getPrefixed:function(a){return d.prefixed(a).replace(/([A-Z])/g,function(a,b){return"-"+b.toLowerCase()}).replace(/^ms-/,"-ms-")},transition:function(a){var c;
this.supported?(c=d.csstransforms3d?"translate3d("+a.x+"px, "+a.y+"px, 0px) scale3d("+a.scale+", "+a.scale+", "+a.scale+")":"translate("+a.x+"px, "+a.y+"px) scale("+a.scale+", "+a.scale+")",a.$this.css("opacity",a.opacity),this.setPrefixedCss(a.$this,"transform",c)):a.$this.animate({left:a.left,top:a.top,opacity:a.opacity,height:a.height,width:a.width},this.speed)}};e.fn.shuffle=function(a,c){return this.each(function(){var b=e(this),d=b.data("shuffle");d||(d=new g(b,a),b.data("shuffle",d));"string"===
typeof a&&("shuffle"!==a&&(c=a),d.shuffle(c))})}})(jQuery,Modernizr);
Loading…
Cancel
Save