Added favicon. Added description and image to each page for open graph and twitter cards.

Renamed some shuffle methods for more consistency
pull/56/head
Glen Cheney 11 years ago
parent 3c42d0bf39
commit ded96737e3

@ -7,6 +7,12 @@ exclude: ['./_scss/*.*']
permalink: /:title permalink: /:title
url: http://localhost:4000
defaultTitle: 'Shuffle.js'
defaultDescription: 'Categorize, sort, and filter a responsive grid of items'
defaultImage: '/img/hero.png'
demos: demos:
- url: 'demos/2013-05-01-basic' - url: 'demos/2013-05-01-basic'
slug: basic slug: basic

@ -6,21 +6,35 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>{{ page.title }}</title> <title>{{ page.title }}</title>
{% capture description %}{% if page.description %}{{ page.description }}{% else %}{{ site.defaultDescription }}{% endif %}{% endcapture %}
{% capture image %}{% if page.image %}{{ page.image }}{% else %}{{ site.defaultImage }}{% endif %}{% endcapture %}
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="{{ page.title }}" /> <meta property="og:title" content="{{ page.title }}" />
<meta property="og:description" content="Shuffle, categorize, sort, and filter a grid of items" /> <meta property="og:description" content="{{ description }}" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:url" content="http://vestride.github.com/Shuffle/" /> <meta property="og:url" content="{{ site.url }}{{ page.url }}" />
<meta property="og:image" content="http://vestride.github.com/Shuffle/img/hero.png" /> <meta property="og:image" content="{{ site.url }}{{ image }}" />
<meta property="og:site_name" content="jQuery Shuffle Plugin" /> <meta property="og:site_name" content="" />
<meta property="fb:admins" content="771347349" /> <meta property="fb:admins" content="771347349" />
<meta name="author" content="https://plus.google.com/u/0/100210640453700033824" /> <meta name="author" content="https://plus.google.com/u/0/100210640453700033824" />
<meta name="twitter:card" content="summary">
<meta name="twitter:creator" content="@Vestride">
<meta name="twitter:title" content="{{ page.title }}">
<meta name="twitter:description" content="{{ description }}">
<meta name="twitter:image" content="{{ site.url }}{{ image }}">
<link href="https://plus.google.com/u/0/100210640453700033824" rel="author" /> <link href="https://plus.google.com/u/0/100210640453700033824" rel="author" />
<link rel="stylesheet" href="{{ site.url }}/css/prism.css" />
<link rel="icon" type="image/png" href="favicon.png" >
<!-- Prefetch DNS for external assets -->
<link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="dns-prefetch" href="//www.google-analytics.com">
<link rel="dns-prefetch" href="//ajax.googleapis.com">
{% if page.prism %}<link rel="stylesheet" href="{{ site.url }}/css/prism.css" />{% endif %}
<link rel="stylesheet" href="{{ site.url }}/css/style.css" /> <link rel="stylesheet" href="{{ site.url }}/css/style.css" />
<link rel="stylesheet" href="{{ site.url }}/css/shuffle-styles.css" /> <link rel="stylesheet" href="{{ site.url }}/css/shuffle-styles.css" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Ubuntu:300,400,700"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Ubuntu:300,400,700">

@ -5,7 +5,7 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span7"> <div class="span7">
<h1>Shuffle</h1> <h1>Shuffle</h1>
<p>Categorize, sort, and filter a responsive grid of items</p> <p>{{ site.defaultDescription }}</p>
<p>By <a href="https://twitter.com/Vestride" target="_blank">@Vestride</a></p> <p>By <a href="https://twitter.com/Vestride" target="_blank">@Vestride</a></p>
</div> </div>
</div> </div>

@ -1,6 +1,8 @@
--- ---
layout: default layout: default
title: Basic Shuffle Demo title: Basic Shuffle Demo
description: A basic demo using shuffle with a masonry layout. This example also uses a sizer element
image: /demos/basic.jpg
bodyClass: basic bodyClass: basic
extraJS: [ "demos/homepage.js" ] extraJS: [ "demos/homepage.js" ]
--- ---

@ -1,7 +1,8 @@
--- ---
layout: default layout: default
title: Shuffle Adaptive Demo title: Shuffle Adaptive Demo
bodyClass: null description: A responsive demo using the adaptive Twitter Bootstrap grid with compound filtering
image: /demos/adaptive.jpg
extraJS: [ "demos/gallery.js" ] extraJS: [ "demos/gallery.js" ]
extraCSS: [ "/css/gallery.css" ] extraCSS: [ "/css/gallery.css" ]
--- ---

@ -1,6 +1,8 @@
--- ---
layout: default layout: default
title: Using images with imagesloaded.js title: Using images with imagesloaded.js
description: A Shuffle.js demo using Desandro's imagesLoaded plugin. This comes in very handy when using shuffle with images affect the layout of shuffle items
image: /demos/images.jpg
extraJS: [ "imagesloaded.pkgd.js", "demos/images.js"] extraJS: [ "imagesloaded.pkgd.js", "demos/images.js"]
prism: true prism: true
--- ---

@ -1,7 +1,8 @@
--- ---
layout: default layout: default
title: Shuffle Adding and Removing Elements Demo title: Shuffle Adding and Removing Elements Demo
bodyClass: null description: This demo of shuffle shows how to add and removing items.
image: /demos/adding-removing.jpg
extraJS: [ "demos/adding-removing.js" ] extraJS: [ "demos/adding-removing.js" ]
--- ---
<style> <style>
@ -23,7 +24,7 @@ extraJS: [ "demos/adding-removing.js" ]
} }
.box::before { .box::before {
content: counter(boxes); content: 'DOM order: ' counter(boxes);
position: absolute; position: absolute;
color: white; color: white;
top: .5em; top: .5em;

@ -1,7 +1,7 @@
--- ---
layout: default layout: default
title: I need a doctor title: Mobile Grid Layout Test
bodyClass: null description: Testing out the mobile grid for this site
--- ---
<div class="container-fluid"> <div class="container-fluid">

@ -1,6 +1,7 @@
--- ---
layout: default layout: default
title: Image based items title: Image based items
description: A demo of how NOT to use images with shuffle
extraJS: [ "demos/images-broken.js"] extraJS: [ "demos/images-broken.js"]
--- ---

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

@ -1,6 +1,6 @@
--- ---
layout: default layout: default
title: jQuery Shuffle Plugin title: Shuffle.js
bodyClass: home bodyClass: home
extraJS: [ "demos/homepage.js" ] extraJS: [ "demos/homepage.js" ]
includeHeader: true includeHeader: true

@ -1,6 +1,8 @@
window.Manipulator = (function($) { window.Manipulator = (function($) {
'use strict'; 'use strict';
var hasConsole = window.console && typeof window.console.log === 'function';
var Manipulator = function( element ) { var Manipulator = function( element ) {
var self = this; var self = this;
@ -42,6 +44,17 @@ window.Manipulator = (function($) {
$('#add').on('click', $.proxy( self.onAddClick, self )); $('#add').on('click', $.proxy( self.onAddClick, self ));
$('#randomize').on('click', $.proxy( self.onRandomize, self )); $('#randomize').on('click', $.proxy( self.onRandomize, self ));
$('#remove').on('click', $.proxy( self.onRemoveClick, self )); $('#remove').on('click', $.proxy( self.onRemoveClick, self ));
// Show off some shuffle events
self.$el.on('removed.shuffle', function( evt, $collection, shuffle ) {
// Make sure logs work
if ( !hasConsole ) {
return;
}
console.log( this, evt, $collection, shuffle );
});
}; };
Manipulator.prototype.onAddClick = function() { Manipulator.prototype.onAddClick = function() {

@ -27,7 +27,7 @@
* Licensed under the MIT license. * Licensed under the MIT license.
* @author Glen Cheney (http://glencheney.com) * @author Glen Cheney (http://glencheney.com)
* @version 1.6.6 * @version 1.6.6
* @date 06/14/13 * @date 06/28/13
*/ */
(function($, Modernizr, undefined) { (function($, Modernizr, undefined) {
@ -131,9 +131,9 @@ var Shuffle = function( $container, options ) {
self.$window = $(window); self.$window = $(window);
self.unique = 'shuffle_' + id++; self.unique = 'shuffle_' + id++;
self.fire('loading'); self._fire('loading');
self._init(); self._init();
self.fire('done'); self._fire('done');
}; };
Shuffle.prototype = { Shuffle.prototype = {
@ -261,7 +261,7 @@ Shuffle.prototype = {
category = category || self.lastFilter; category = category || self.lastFilter;
self.fire('filter'); self._fire('filter');
// Loop through each item and use provided function to determine // Loop through each item and use provided function to determine
// whether to hide it or not. // whether to hide it or not.
@ -391,7 +391,7 @@ Shuffle.prototype = {
return this.$container.children( this.itemSelector ); return this.$container.children( this.itemSelector );
}, },
getPreciseDimension : function( element, style ) { _getPreciseDimension : function( element, style ) {
var dimension; var dimension;
if ( window.getComputedStyle ) { if ( window.getComputedStyle ) {
dimension = window.getComputedStyle( element, null )[ style ]; dimension = window.getComputedStyle( element, null )[ style ];
@ -409,14 +409,14 @@ Shuffle.prototype = {
gutter = typeof self.gutterWidth === 'function' ? gutter = typeof self.gutterWidth === 'function' ?
self.gutterWidth( containerWidth ) : self.gutterWidth( containerWidth ) :
self.useSizer ? self.useSizer ?
self.getPreciseDimension( self.sizer, 'marginLeft' ) : self._getPreciseDimension( self.sizer, 'marginLeft' ) :
self.gutterWidth, self.gutterWidth,
calculatedColumns; calculatedColumns;
// use fluid columnWidth function if there // use fluid columnWidth function if there
self.colWidth = self.isFluid ? self.columnWidth( containerWidth ) : self.colWidth = self.isFluid ? self.columnWidth( containerWidth ) :
// columnWidth option isn't a function, are they using a sizing element? // columnWidth option isn't a function, are they using a sizing element?
self.useSizer ? self.getPreciseDimension( self.sizer, 'width' ) : self.useSizer ? self._getPreciseDimension( self.sizer, 'width' ) :
// if not, how about the explicitly set option? // if not, how about the explicitly set option?
self.columnWidth || self.columnWidth ||
// or use the size of the first item // or use the size of the first item
@ -460,7 +460,7 @@ Shuffle.prototype = {
/** /**
* Fire events with .shuffle namespace * Fire events with .shuffle namespace
*/ */
fire : function( name, args ) { _fire : function( name, args ) {
this.$container.trigger( name + '.shuffle', args && args.length ? args : [ this ] ); this.$container.trigger( name + '.shuffle', args && args.length ? args : [ this ] );
}, },
@ -508,7 +508,7 @@ Shuffle.prototype = {
} }
}); });
// `_layout` always happens after `shrink`, so it's safe to process the style // `_layout` always happens after `_shrink`, so it's safe to process the style
// queue here with styles from the shrink method // queue here with styles from the shrink method
self._processStyleQueue(); self._processStyleQueue();
@ -596,7 +596,7 @@ Shuffle.prototype = {
/** /**
* Hides the elements that don't match our filter * Hides the elements that don't match our filter
*/ */
shrink : function( $collection, fn ) { _shrink : function( $collection, fn ) {
var self = this, var self = this,
$concealed = $collection || self.$items.filter('.concealed'), $concealed = $collection || self.$items.filter('.concealed'),
transitionObj = {}, transitionObj = {},
@ -607,7 +607,7 @@ Shuffle.prototype = {
return; return;
} }
self.fire('shrink'); self._fire('shrink');
self.shrinkTransitionEnded = false; self.shrinkTransitionEnded = false;
$concealed.each(function() { $concealed.each(function() {
@ -656,8 +656,8 @@ Shuffle.prototype = {
* @param {string} prop the property to set (e.g. 'transition') * @param {string} prop the property to set (e.g. 'transition')
* @param {string} value the value of the prop * @param {string} value the value of the prop
*/ */
setPrefixedCss : function($el, prop, value) { setPrefixedCss : function( $el, prop, value ) {
$el.css(this.prefixed(prop), value); $el.css( this.prefixed( prop ), value );
}, },
@ -667,8 +667,8 @@ Shuffle.prototype = {
* @param {string} property to be prefixed. * @param {string} property to be prefixed.
* @return {string} the prefixed css property * @return {string} the prefixed css property
*/ */
getPrefixed : function(prop) { getPrefixed : function( prop ) {
var styleName = this.prefixed(prop); var styleName = this.prefixed( prop );
return styleName ? styleName.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-') : styleName; return styleName ? styleName.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-') : styleName;
}, },
@ -692,12 +692,12 @@ Shuffle.prototype = {
transform, transform,
// Only fire callback once per collection's transition // Only fire callback once per collection's transition
complete = function() { complete = function() {
if (!self.layoutTransitionEnded && opts.from === 'layout') { if ( !self.layoutTransitionEnded && opts.from === 'layout' ) {
self.fire('layout'); self._fire('layout');
opts.callback.call(self); opts.callback.call( self );
self.layoutTransitionEnded = true; self.layoutTransitionEnded = true;
} else if (!self.shrinkTransitionEnded && opts.from === 'shrink') { } else if ( !self.shrinkTransitionEnded && opts.from === 'shrink' ) {
opts.callback.call(self); opts.callback.call( self );
self.shrinkTransitionEnded = true; self.shrinkTransitionEnded = true;
} }
}; };
@ -737,7 +737,7 @@ Shuffle.prototype = {
}; };
// Use jQuery to animate left/top // Use jQuery to animate left/top
opts.$this.stop( true, true ).animate( cssObj, self.speed, 'swing', complete); opts.$this.stop( true ).animate( cssObj, self.speed, 'swing', complete);
} }
}, },
@ -761,15 +761,15 @@ Shuffle.prototype = {
}, },
shrinkEnd: function() { shrinkEnd: function() {
this.fire('shrunk'); this._fire('shrunk');
}, },
filterEnd: function() { filterEnd: function() {
this.fire('filtered'); this._fire('filtered');
}, },
sortEnd: function() { sortEnd: function() {
this.fire('sorted'); this._fire('sorted');
}, },
/** /**
@ -881,7 +881,7 @@ Shuffle.prototype = {
self._resetCols(); self._resetCols();
// Shrink each concealed item // Shrink each concealed item
self.shrink(); self._shrink();
// If given a valid sort object, save it so that _reLayout() will sort the items // If given a valid sort object, save it so that _reLayout() will sort the items
if ( sortObj ) { if ( sortObj ) {
@ -990,21 +990,28 @@ Shuffle.prototype = {
var self = this; var self = this;
function remove() { // Hide collection first
self._shrink( $collection, function() {
var shuffle = this; var shuffle = this;
// Remove the collection in the callback
$collection.remove(); $collection.remove();
$collection = null;
// Update the items, layout, count and fire off `removed` event
setTimeout(function() { setTimeout(function() {
shuffle.$items = shuffle._getItems(); shuffle.$items = shuffle._getItems();
shuffle.layout(); shuffle.layout();
shuffle._updateItemCount(); shuffle._updateItemCount();
shuffle.fire( 'removed', [ $collection, shuffle ] ); shuffle._fire( 'removed', [ $collection, shuffle ] );
// Let it get garbage collected
$collection = null;
}, 0); }, 0);
} });
self.shrink( $collection, remove ); // Process changes
self._processStyleQueue(); self._processStyleQueue();
return self; return self;
}, },
@ -1030,7 +1037,7 @@ Shuffle.options = {
speed : 250, // Transition/animation speed (milliseconds) speed : 250, // Transition/animation speed (milliseconds)
easing : 'ease-out', // css easing function to use easing : 'ease-out', // css easing function to use
itemSelector: '', // e.g. '.gallery-item' itemSelector: '', // e.g. '.gallery-item'
sizer: null, sizer: null, // sizer element. Can be anything columnWidth is
gutterWidth : 0, // a static number or function that tells the plugin how wide the gutters between columns are (in pixels) gutterWidth : 0, // a static number or function that tells the plugin how wide the gutters between columns are (in pixels)
columnWidth : 0,// a static number or function that returns a number which tells the plugin how wide the columns are (in pixels) columnWidth : 0,// a static number or function that returns a number which tells the plugin how wide the columns are (in pixels)
showInitialTransition : false, // If set to false, the shuffle-items will only have a transition applied to them after the first layout showInitialTransition : false, // If set to false, the shuffle-items will only have a transition applied to them after the first layout

@ -3,7 +3,9 @@
* Debounce plugin is included in shuffle * Debounce plugin is included in shuffle
*/ */
var Support = (function() { var Modules = {};
Modules.Support = (function() {
'use strict'; 'use strict';
var self = {}, var self = {},
@ -42,7 +44,7 @@ var Support = (function() {
}()); }());
var Polyfill = (function( $, Support ) { Modules.Polyfill = (function( $, Support ) {
'use strict'; 'use strict';
var init = function() { var init = function() {
@ -60,10 +62,10 @@ var Polyfill = (function( $, Support ) {
return { return {
init: init init: init
}; };
}( jQuery, Support )); }( jQuery, Modules.Support ));
var NAV = (function( $ ) { Modules.Nav = (function( $ ) {
'use strict'; 'use strict';
function NavTray( element ) { function NavTray( element ) {
@ -172,7 +174,38 @@ var NAV = (function( $ ) {
}( jQuery )); }( jQuery ));
// Analytics
var _gaq = [ ['_setAccount', 'UA-39355642-1'], ['_trackPageview'] ];
(function(doc, script) {
'use strict';
var js,
fjs = doc.scripts[0],
frag = doc.createDocumentFragment(),
add = function(url, id) {
if (doc.getElementById(id)) {return;}
js = doc.createElement(script);
js.src = url;
if ( id ) { js.id = id; }
frag.appendChild( js );
};
// Twitter SDK
// add('//platform.twitter.com/widgets.js', 'twitter-wjs');
// Load GA over http, we know it won't be over ssl
add('//www.google-analytics.com/ga.js');
fjs.parentNode.insertBefore(frag, fjs);
}(document, 'script'));
$(document).ready(function() { $(document).ready(function() {
NAV.init(); 'use strict';
Polyfill.init();
Modules.Nav.init();
Modules.Polyfill.init();
}); });
Loading…
Cancel
Save