Merge branch 'refactoring'

pull/56/head
Glen Cheney 10 years ago
commit 65ba679912

2
.gitignore vendored

@ -1,6 +1,8 @@
node_modules
bower_components
.DS_Store
_site
.sass-cache
*.scssc
temp
.grunt

@ -0,0 +1,6 @@
language: node_js
node_js:
- "0.11"
before_install:
- npm install -g bower grunt-cli
- bower install

@ -44,7 +44,11 @@ module.exports = function(grunt) {
},
src: {
files: 'src/*.js',
tasks: ['concat']
tasks: ['concat', 'test']
},
test: {
files: 'test/specs.js',
tasks: ['test']
}
},
@ -104,6 +108,22 @@ module.exports = function(grunt) {
src: 'dist/jquery.shuffle.modernizr.js',
dest: 'dist/jquery.shuffle.modernizr.min.js'
}
},
jasmine: {
main: {
src: 'dist/jquery.shuffle.js',
options: {
specs: 'test/specs.js',
vendor: [
'dist/modernizr.custom.min.js',
'http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js',
'bower_components/jasmine-jquery/lib/jasmine-jquery.js'
],
outfile: 'test/_SpecRunner.html',
keepRunner: true
}
}
}
});
@ -128,10 +148,15 @@ module.exports = function(grunt) {
'concat:main',
'concat:modernizr',
'uglify:main',
'uglify:modernizr'
'uglify:modernizr',
'test'
]);
});
grunt.registerTask('test', function() {
grunt.task.run('jasmine:main');
});
// Default task(s).
grunt.registerTask('default', ['serve']);

@ -1,4 +1,4 @@
# [Shuffle](http://vestride.github.io/Shuffle)
# [Shuffle](http://vestride.github.io/Shuffle) [![Build Status](https://travis-ci.org/Vestride/Shuffle.svg?branch=refactoring)](https://travis-ci.org/Vestride/Shuffle)
Categorize, sort, and filter a responsive grid of items.
```bash

@ -3,7 +3,7 @@ destination: ./_site
plugins: ./_plugins
layouts: ./_layouts
include: ['.htaccess']
exclude: ['_scss', 'temp', 'node_modules', 'src']
exclude: ['_scss', 'temp', 'node_modules', 'src', 'bower_components']
permalink: /:title

@ -1,6 +1,7 @@
<h2>Changes<a href="#changelog"></a></h2>
<ul>
<li><code>v2.1.2</code> 6/1/14 - Explicitly use <code>window.jQuery</code> instead of <code>window.$</code>. Fixes #25.</li>
<li><code>v3.0.0</code> 10/06/14 - Refactored with improvements, added unit tests, more documentation. Removed some triggered events.</li>
<li><code>v2.1.2</code> 6/01/14 - Use <code>window.jQuery</code> instead of <code>window.$</code> to work better with noConflict. Fixed <a href="https://github.com/Vestride/Shuffle/issues/25">#25</a>.</li>
<li><code>v2.1.1</code> 4/16/14 - Fix items with zero opacity overlapping visible ones in IE&lt;10.</li>
<li><code>v2.1.0</code> 4/12/14 - Register with bower as <code>shufflejs</code>.</li>
<li>4/10/14 - Add AMD support.</li>

@ -3,14 +3,9 @@
<ul class="breathable-list">
<li><code class="language-javascript">'loading.shuffle'</code></li>
<li><code class="language-javascript">'done.shuffle'</code></li>
<li><code class="language-javascript">'shrink.shuffle'</code></li>
<li><code class="language-javascript">'shrunk.shuffle'</code></li>
<li><code class="language-javascript">'filter.shuffle'</code></li>
<li><code class="language-javascript">'filtered.shuffle'</code></li>
<li><code class="language-javascript">'layout.shuffle'</code></li>
<li><code class="language-javascript">'removed.shuffle'</code></li>
</ul>
<p><strong>Heads up!</strong> To receive the <code>loading</code> event, you must subscribe to it before initializing the plugin, otherwise it will fire before you have subscribed to it.</p>
<h3>Get notified when shuffle is done with setup</h3>
<pre rel="JavaScript"><code class="language-javascript">$grid.on('done.shuffle', function() {

@ -27,7 +27,7 @@
<div class="site-nav__band">
<div class="container-fluid">
<button class="js-nav-toggle pull-right" data-close-label="Close Nav">Open Nav</button>
<button class="js-nav-toggle pull-right" data-close-label="Close Menu">Open Menu</button>
</div>
</div>
</nav>

@ -1,22 +1,22 @@
<h2>Options<a href="#options"></a></h2>
<p>Settings you can change (these are the defaults)</p>
<p>Settings you can change (these are the defaults).</p>
<pre rel="JavaScript"><code class="language-javascript">// Overrideable options
Shuffle.options = {
group: 'all', // Filter group
speed: 250, // Transition/animation speed (milliseconds)
easing: 'ease-out', // css easing function to use
itemSelector: '', // e.g. '.picture-item'
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)
columnWidth: 0, // a static number or function that returns a number which tells the plugin how wide the columns are (in pixels)
delimeter: null, // if your group is not json, and is comma delimeted, you could set delimeter to ','
buffer: 0, // useful for percentage based heights when they might not always be exactly the same (in pixels)
initialSort: null, // Shuffle can be initialized with a sort object. It is the same object given to the sort method
throttle: $.throttle || null, // By default, shuffle will try to throttle the resize event. This option will change the method it uses
throttleTime: 300, // How often shuffle can be called on resize (in milliseconds)
sequentialFadeDelay: 150, // Delay between each item that fades in when adding items
supported: Modernizr.csstransforms &amp;&amp; Modernizr.csstransitions // supports transitions and transforms
group: ALL_ITEMS, // Initial filter group.
speed: 250, // Transition/animation speed (milliseconds).
easing: 'ease-out', // CSS easing function to use.
itemSelector: '', // e.g. '.picture-item'.
sizer: null, // Sizer element. Use an element to determine the size of columns and gutters.
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).
delimeter: null, // If your group is not json, and is comma delimeted, you could set delimeter to ','.
buffer: 0, // Useful for percentage based heights when they might not always be exactly the same (in pixels).
initialSort: null, // Shuffle can be initialized with a sort object. It is the same object given to the sort method.
throttle: throttle, // By default, shuffle will throttle resize events. This can be changed or removed.
throttleTime: 300, // How often shuffle can be called on resize (in milliseconds).
sequentialFadeDelay: 150, // Delay between each item that fades in when adding items.
supported: CAN_TRANSITION_TRANSFORMS // Whether to use transforms or absolute positioning.
};</code></pre>
<p>No options <em>need</em> to be specified, but <code>itemSelector</code> should be used. Other common options to change are <code>speed</code>, <code>easing</code>, <code>gutterWidth</code>, and <code>columnWidth</code> (or <code>sizer</code>).</p>

@ -0,0 +1,14 @@
<h2>Public Methods<a href="#adding-removing"></a></h2>
<p>A list of the methods available to you and what they do.</p>
<ul class="breathable-list">
<li><code>shuffle</code> - Filters all the shuffle items.</li>
<li><code>sort</code> - Sorts the currently filtered shuffle items.</li>
<li><code>update</code> - Repositions everything. Useful for when dimensions (like the window size) change.</li>
<li><code>layout</code> - Use this instead of <code>update()</code> if you don't need the columns and gutters updated. Maybe an image loaded and now has a height.</li>
<li><code>appended</code> - New items have been appended to the shuffle container.</li>
<li><code>disable</code> - Disables Shuffle from updating dimensions and layout on resize.</li>
<li><code>enable</code> - Enables Shuffle again.</li>
<li><code>remove</code> - Remove one or more shuffle items.</li>
<li><code>destroy</code> - Destroys Shuffle, removes events, styles, classes, and references.</li>
</ul>

@ -26,21 +26,21 @@ extraJS: [ "faq.js" ]
<article id="spaces" class="question js-question">
<div class="question__inner">
<h3 class="question__text">Why Does Shuffle leave empty spaces?</h3>
<h3 class="question__title">Why Does Shuffle leave empty spaces?</h3>
<p class="question__answer">The algorithm used to place items does not keep track of empty space nor try to fill them. If you require this functionality, I suggest <a target="_blank" href="http://packery.metafizzy.co/">packery</a>.</p>
</div>
</article>
<article id="images" class="question js-question">
<div class="question__inner">
<h3 class="question__text">Why are images overlapping?</h3>
<h3 class="question__title">Why are images overlapping?</h3>
<p class="question__answer">If the size of your items are dependent on images, they can overlap if shuffle is initialized before all the images have loaded. Check out <a href="{{ site.baseurl }}{% post_url demos/2013-05-03-images %}">this demo</a> to see how to fix it.</p>
</div>
</article>
<article id="isotope" class="question js-question">
<div class="question__inner">
<h3 class="question__text">What&rsquo;s the difference between Shuffle and Isotope?</h3>
<h3 class="question__title">What&rsquo;s the difference between Shuffle and Isotope?</h3>
<div class="question__answer">
<span>Isotope:</span>
<ul>
@ -58,23 +58,37 @@ extraJS: [ "faq.js" ]
<li>sizer element (which <a href="http://packery.metafizzy.co/options.html#element-sizing">packery also has</a>)</li>
</ul>
<p>They are <em>very</em> similar, but I think Shuffle's filtering and sorting are easier to customize, which is the main reason I created this plugin. Isotope does have a much larger community, more tests, and more stackoverflow answers though.</p>
<p>They are <em>very</em> similar, but I think Shuffle's filtering and sorting are easier to customize, which is the main reason I created this plugin. Isotope has a much larger community, is battle-tested, and has many stackoverflow answers.</p>
</div>
</div>
</article>
<article id="zepto" class="question js-question">
<div class="question__inner">
<h3 class="question__text">Does Shuffle work with Zepto?</h3>
<h3 class="question__title">Does Shuffle work with Zepto?</h3>
<p class="question__answer">Not at the moment.</p>
</div>
</article>
<article id="padding" class="question js-question">
<div class="question__inner">
<h3 class="question__title">Padding isn&rsquo;t working on the shuffle element.</h3>
<p class="question__answer">The padding is ignored by Shuffle because it creates complexities with absolute positioning the shuffle-items when they have a percentage width as well as setting the height of the shuffle container because of box-sizing. To fix this, wrap the shuffle element in another element which has the padding on it.</p>
</div>
</article>
<article id="centering" class="question js-question">
<div class="question__inner">
<h3 class="question__title">Can the columns be centered?</h3>
<p class="question__answer">Nope. Shuffle is heavily based on columns for layout. You can add &ldquo;empty&rdquo; items to achieve a similar effect.</p>
</div>
</article>
{% comment %}
<article class="question js-question">
<div class="question__inner">
<h3 class="question__text">Hi</h3>
<h3 class="question__title">Hi</h3>
<p class="question__answer">Check yo' self</p>
</div>
</article>
@ -82,7 +96,7 @@ extraJS: [ "faq.js" ]
<article class="question question--unanswered">
<div class="question__inner">
<h3 class="question__text">Didn't find an answer?</h3>
<h3 class="question__title">Didn't find an answer?</h3>
<p class="question__answer">Try looking at the javascript files for the demos or searching the issues <a href="https://github.com/Vestride/Shuffle/issues">on GitHub</a>.</p>
</div>
</article>

@ -31,6 +31,14 @@ extraJS: [ "demos/adding-removing.js" ]
left: .5em;
}
.box::after {
content: 'Box SKU: ' attr(created);
position: absolute;
color: white;
bottom: .5em;
left: .5em;
}
.box.shuffle-item,
.box:first-child {
margin-left: 0;
@ -56,19 +64,37 @@ extraJS: [ "demos/adding-removing.js" ]
</section>
<section class="container">
<button id="randomize">Randomize</button>
<div style="margin-bottom: 10px;">
<span class="filter__label">Add mode:</span>
<select id="mode" class="sort-options">
<option value="end">Add to end</option>
<option selected value="end-sequential">Add to end with delay</option>
<option value="mix">Mix in with current</option>
</select>
</div>
<div class="pull-left">
<button id="add">Add 5 Boxes</button>
<button id="remove">Remove Some Boxes</button>
<button id="randomize">Randomize</button>
</div>
<div class="pull-right">
<span class="filter__label">Sort:</span>
<select id="sorter" class="sort-options">
<option value="dom">Default</option>
<option value="created">Box SKU</option>
<option value="random">Randomize</option>
</select>
</div>
</section>
<section class="container">
<div id="my-shuffle" class="items">
<div class="box"></div>
<div class="box h2 w2"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box w2"></div>
<div class="box"></div>
<div class="box" created="45"></div>
<div class="box h2 w2" created="19"></div>
<div class="box" created="66"></div>
<div class="box" created="148"></div>
<div class="box w2" created="99"></div>
<div class="box" created="3"></div>
</div>
</section>

@ -1,718 +0,0 @@
/*------------------------------------*\
$CSSWIZARDRY-GRIDS
\*------------------------------------*/
/**
* CONTENTS
* INTRODUCTION.........How the grid system works.
* VARIABLES............Your settings.
* MIXINS...............Library mixins.
* GRID SETUP...........Build the grid structure.
* WIDTHS...............Build our responsive widths around our breakpoints.
* PUSH.................Push classes.
* PULL.................Pull classes.
*/
/*------------------------------------*\
$INTRODUCTION
\*------------------------------------*/
/**
* csswizardry grids provides you with widths to suit a number of breakpoints
* designed around devices of a size you specify. Out of the box, csswizardry
* grids caters to the following types of device:
*
* palm -- palm-based devices, like phones and small tablets
* lap -- lap-based devices, like iPads or laptops
* portable -- all of the above
* desk -- stationary devices, like desktop computers
* regular -- any/all types of device
*
* These namespaces are then used in the library to give you the ability to
* manipulate your layouts based around them, for example:
*
<div class="grid__item one-whole lap--one-half desk--one-third">
*
* This would give you a grid item which is 100% width unless it is on a lap
* device, at which point it become 50% wide, or it is on a desktop device, at
* which point it becomes 33.333% width.
*
* csswizardry grids also has push and pull classes which allow you to nudge
* grid items left and right by a defined amount. These follow the same naming
* convention as above, but are prepended by either `push--` or `pull--`, for
* example:
*
`class="grid__item one-half push--one-half"`
*
* This would give you a grid item which is 50% width and pushed over to the
* right by 50%.
*
* All classes in csswizardry grids follow this patten, so you should fairly
* quickly be able to piece together any combinations you can imagine, for
* example:
*
`class="grid__item one-whole lap--one-half desk--one-third push--desk--one-third"`
*
`class="grid__item one-quarter palm--one-half push--palm--one-half"`
*
`class="grid__item palm--one-third desk--five-twelfths"`
*/
/*------------------------------------*\
$VARIABLES
\*------------------------------------*/
/**
* If you are building a non-responsive site but would still like to use
* csswizardry-grids, set this to false:
*/
$responsive: true!default;
/**
* Is this build mobile first? Setting to true means that all grids will be
* 100% width if you do not apply a more specific class to them.
*/
$mobile-first: true!default;
/**
* Set the spacing between your grid items.
*/
$gutter: 24px!default;
/**
* Would you like Sass silent classes, or regular CSS classes?
*/
$use-silent-classes: false!default;
/**
* Would you like push and pull classes enabled?
*/
$push: false!default;
$pull: false!default;
/**
* Using `inline-block` means that the grid items need their whitespace removing
* in order for them to work correctly. Set the following to true if you are
* going to achieve this by manually removing/commenting out any whitespace in
* your HTML yourself.
*
* Setting this to false invokes a hack which cannot always be guaranteed,
* please see the following for more detail:
*
* github.com/csswizardry/csswizardry-grids/commit/744d4b23c9d2b77d605b5991e54a397df72e0688
* github.com/csswizardry/inuit.css/issues/170#issuecomment-14859371
*/
$use-markup-fix: true!default;
/**
* Define your breakpoints. The first value is the prefix that shall be used for
* your classes (e.g. `.palm--one-half`), the second value is the media query
* that the breakpoint fires at.
*/
$breakpoints: (
'palm' '(max-width: 480px)',
'lap' '(min-width: 481px) and (max-width: 1023px)',
'portable' '(max-width: 1023px)',
'desk' '(min-width: 1024px)'
)!default;
/**
* Define which namespaced breakpoints you would like to generate for each of
* widths, push and pull. This is handy if you only need pull on, say, desk, or
* you only need a new width breakpoint at mobile sizes. It allows you to only
* compile as much CSS as you need. All are turned on by default, but you can
* add and remove breakpoints at will.
*
* Push and pull shall only be used if `$push` and/or `$pull` and `$responsive`
* have been set to true.
*/
$breakpoint-has-widths: ('palm', 'lap', 'portable', 'desk')!default;
$breakpoint-has-push: ('palm', 'lap', 'portable', 'desk')!default;
$breakpoint-has-pull: ('palm', 'lap', 'portable', 'desk')!default;
/**
* You do not need to edit anything from this line onward; csswizardry-grids is
* good to go. Happy griddin!
*/
$class-type: unquote(".");
@if $use-silent-classes == true{
$class-type: unquote("%");
}
/*------------------------------------*\
$MIXINS
\*------------------------------------*/
/**
* These mixins are for the library to use only, you should not need to modify
* them at all.
*
* Enclose a block of code with a media query as named in `$breakpoints`.
*/
@mixin grid-media-query($media-query){
$breakpoint-found: false;
@each $breakpoint in $breakpoints{
$name: nth($breakpoint, 1);
$declaration: nth($breakpoint, 2);
@if $media-query == $name and $declaration{
$breakpoint-found: true;
@media only screen and #{$declaration}{
@content;
}
}
}
@if $breakpoint-found == false{
@warn "Breakpoint #{$media-query} does not exist"
}
}
/**
* Drop relative positioning into silent classes which cant take advantage of
* the `[class*="push--"]` and `[class*="pull--"]` selectors.
*/
@mixin silent-relative(){
@if $use-silent-classes == true{
position:relative;
}
}
/*------------------------------------*\
$GRID SETUP
\*------------------------------------*/
/**
* 1. Allow the grid system to be used on lists.
* 2. Remove any margins and paddings that might affect the grid system.
* 3. Apply a negative `margin-left` to negate the columns gutters.
*/
#{$class-type}grid{
list-style:none; /* [1] */
margin:0; /* [2] */
padding:0; /* [2] */
margin-left:-$gutter; /* [3] */
@if $use-markup-fix != true{
letter-spacing:-0.31em;
}
}
@if $use-markup-fix != true{
/* Opera hack */
.opera:-o-prefocus,
#{$class-type}grid{
word-spacing:-0.43em;
}
}
/**
* 1. Cause columns to stack side-by-side.
* 2. Space columns apart.
* 3. Align columns to the tops of each other.
* 4. Full-width unless told to behave otherwise.
* 5. Required to combine fluid widths and fixed gutters.
*/
#{$class-type}grid__item{
display:inline-block; /* [1] */
padding-left:$gutter; /* [2] */
vertical-align:top; /* [3] */
@if $mobile-first == true{
width:100%; /* [4] */
}
-webkit-box-sizing:border-box; /* [5] */
-moz-box-sizing:border-box; /* [5] */
box-sizing:border-box; /* [5] */
@if $use-markup-fix != true{
letter-spacing:normal;
word-spacing:normal;
}
}
/**
* Reversed grids allow you to structure your source in the opposite order to
* how your rendered layout will appear. Extends `.grid`.
*/
#{$class-type}grid--rev{
direction:rtl;
text-align:left;
> #{$class-type}grid__item{
direction:ltr;
text-align:left;
}
}
/**
* Gutterless grids have all the properties of regular grids, minus any spacing.
* Extends `.grid`.
*/
#{$class-type}grid--full{
margin-left:0;
> #{$class-type}grid__item{
padding-left:0;
}
}
/**
* Align the entire grid to the right. Extends `.grid`.
*/
#{$class-type}grid--right{
text-align:right;
> #{$class-type}grid__item{
text-align:left;
}
}
/**
* Centered grids align grid items centrally without needing to use push or pull
* classes. Extends `.grid`.
*/
#{$class-type}grid--center{
text-align:center;
> #{$class-type}grid__item{
text-align:left;
}
}
/**
* Align grid cells vertically (`.grid--middle` or `.grid--bottom`). Extends
* `.grid`.
*/
#{$class-type}grid--middle{
> #{$class-type}grid__item{
vertical-align:middle;
}
}
#{$class-type}grid--bottom{
> #{$class-type}grid__item{
vertical-align:bottom;
}
}
/**
* Create grids with narrower gutters. Extends `.grid`.
*/
#{$class-type}grid--narrow{
margin-left:-($gutter / 2);
> #{$class-type}grid__item{
padding-left:$gutter / 2;
}
}
/**
* Create grids with wider gutters. Extends `.grid`.
*/
#{$class-type}grid--wide{
margin-left:-($gutter * 2);
> #{$class-type}grid__item{
padding-left:$gutter * 2;
}
}
/*------------------------------------*\
$WIDTHS
\*------------------------------------*/
/**
* Create our width classes, prefixed by the specified namespace.
*/
@mixin device-type($namespace:""){
/**
* Whole
*/
#{$class-type}#{$namespace}one-whole { width:100%; }
/**
* Halves
*/
#{$class-type}#{$namespace}one-half { width:50%; }
/**
* Thirds
*/
#{$class-type}#{$namespace}one-third { width:33.333%; }
#{$class-type}#{$namespace}two-thirds { width:66.666%; }
/**
* Quarters
*/
#{$class-type}#{$namespace}one-quarter { width:25%; }
#{$class-type}#{$namespace}two-quarters { @extend #{$class-type}#{$namespace}one-half; }
#{$class-type}#{$namespace}three-quarters { width:75%; }
/**
* Fifths
*/
#{$class-type}#{$namespace}one-fifth { width:20%; }
#{$class-type}#{$namespace}two-fifths { width:40%; }
#{$class-type}#{$namespace}three-fifths { width:60%; }
#{$class-type}#{$namespace}four-fifths { width:80%; }
/**
* Sixths
*/
#{$class-type}#{$namespace}one-sixth { width:16.666%; }
#{$class-type}#{$namespace}two-sixths { @extend #{$class-type}#{$namespace}one-third; }
#{$class-type}#{$namespace}three-sixths { @extend #{$class-type}#{$namespace}one-half; }
#{$class-type}#{$namespace}four-sixths { @extend #{$class-type}#{$namespace}two-thirds; }
#{$class-type}#{$namespace}five-sixths { width:83.333%; }
/**
* Eighths
*/
#{$class-type}#{$namespace}one-eighth { width:12.5%; }
#{$class-type}#{$namespace}two-eighths { @extend #{$class-type}#{$namespace}one-quarter; }
#{$class-type}#{$namespace}three-eighths { width:37.5%; }
#{$class-type}#{$namespace}four-eighths { @extend #{$class-type}#{$namespace}one-half; }
#{$class-type}#{$namespace}five-eighths { width:62.5%; }
#{$class-type}#{$namespace}six-eighths { @extend #{$class-type}#{$namespace}three-quarters; }
#{$class-type}#{$namespace}seven-eighths { width:87.5%; }
/**
* Tenths
*/
#{$class-type}#{$namespace}one-tenth { width:10%; }
#{$class-type}#{$namespace}two-tenths { @extend #{$class-type}#{$namespace}one-fifth; }
#{$class-type}#{$namespace}three-tenths { width:30%; }
#{$class-type}#{$namespace}four-tenths { @extend #{$class-type}#{$namespace}two-fifths; }
#{$class-type}#{$namespace}five-tenths { @extend #{$class-type}#{$namespace}one-half; }
#{$class-type}#{$namespace}six-tenths { @extend #{$class-type}#{$namespace}three-fifths; }
#{$class-type}#{$namespace}seven-tenths { width:70%; }
#{$class-type}#{$namespace}eight-tenths { @extend #{$class-type}#{$namespace}four-fifths; }
#{$class-type}#{$namespace}nine-tenths { width:90%; }
/**
* Twelfths
*/
#{$class-type}#{$namespace}one-twelfth { width:8.333%; }
#{$class-type}#{$namespace}two-twelfths { @extend #{$class-type}#{$namespace}one-sixth; }
#{$class-type}#{$namespace}three-twelfths { @extend #{$class-type}#{$namespace}one-quarter; }
#{$class-type}#{$namespace}four-twelfths { @extend #{$class-type}#{$namespace}one-third; }
#{$class-type}#{$namespace}five-twelfths { width:41.666% }
#{$class-type}#{$namespace}six-twelfths { @extend #{$class-type}#{$namespace}one-half; }
#{$class-type}#{$namespace}seven-twelfths { width:58.333%; }
#{$class-type}#{$namespace}eight-twelfths { @extend #{$class-type}#{$namespace}two-thirds; }
#{$class-type}#{$namespace}nine-twelfths { @extend #{$class-type}#{$namespace}three-quarters; }
#{$class-type}#{$namespace}ten-twelfths { @extend #{$class-type}#{$namespace}five-sixths; }
#{$class-type}#{$namespace}eleven-twelfths { width:91.666%; }
}
/**
* Our regular, non-responsive width classes.
*/
@include device-type();
/**
* Our responsive classes, if we have enabled them.
*/
@if $responsive == true{
@each $name in $breakpoint-has-widths {
@include grid-media-query($name) {
@include device-type('#{$name}--');
}
}
}
/*------------------------------------*\
$PUSH
\*------------------------------------*/
/**
* Push classes, to move grid items over to the right by certain amounts.
*/
@mixin push-setup($namespace: ""){
/**
* Whole
*/
#{$class-type}push--#{$namespace}one-whole { left:100%; @include silent-relative(); }
/**
* Halves
*/
#{$class-type}push--#{$namespace}one-half { left:50%; @include silent-relative(); }
/**
* Thirds
*/
#{$class-type}push--#{$namespace}one-third { left:33.333%; @include silent-relative(); }
#{$class-type}push--#{$namespace}two-thirds { left:66.666%; @include silent-relative(); }
/**
* Quarters
*/
#{$class-type}push--#{$namespace}one-quarter { left:25%; @include silent-relative(); }
#{$class-type}push--#{$namespace}two-quarters { @extend #{$class-type}push--#{$namespace}one-half; }
#{$class-type}push--#{$namespace}three-quarters { left:75%; @include silent-relative(); }
/**
* Fifths
*/
#{$class-type}push--#{$namespace}one-fifth { left:20%; @include silent-relative(); }
#{$class-type}push--#{$namespace}two-fifths { left:40%; @include silent-relative(); }
#{$class-type}push--#{$namespace}three-fifths { left:60%; @include silent-relative(); }
#{$class-type}push--#{$namespace}four-fifths { left:80%; @include silent-relative(); }
/**
* Sixths
*/
#{$class-type}push--#{$namespace}one-sixth { left:16.666%; @include silent-relative(); }
#{$class-type}push--#{$namespace}two-sixths { @extend #{$class-type}push--#{$namespace}one-third; }
#{$class-type}push--#{$namespace}three-sixths { @extend #{$class-type}push--#{$namespace}one-half; }
#{$class-type}push--#{$namespace}four-sixths { @extend #{$class-type}push--#{$namespace}two-thirds; }
#{$class-type}push--#{$namespace}five-sixths { left:83.333%; @include silent-relative(); }
/**
* Eighths
*/
#{$class-type}push--#{$namespace}one-eighth { left:12.5%; @include silent-relative(); }
#{$class-type}push--#{$namespace}two-eighths { @extend #{$class-type}push--#{$namespace}one-quarter; }
#{$class-type}push--#{$namespace}three-eighths { left:37.5%; @include silent-relative(); }
#{$class-type}push--#{$namespace}four-eighths { @extend #{$class-type}push--#{$namespace}one-half; }
#{$class-type}push--#{$namespace}five-eighths { left:62.5%; @include silent-relative(); }
#{$class-type}push--#{$namespace}six-eighths { @extend #{$class-type}push--#{$namespace}three-quarters; }
#{$class-type}push--#{$namespace}seven-eighths { left:87.5%; @include silent-relative(); }
/**
* Tenths
*/
#{$class-type}push--#{$namespace}one-tenth { left:10%; @include silent-relative(); }
#{$class-type}push--#{$namespace}two-tenths { @extend #{$class-type}push--#{$namespace}one-fifth; }
#{$class-type}push--#{$namespace}three-tenths { left:30%; @include silent-relative(); }
#{$class-type}push--#{$namespace}four-tenths { @extend #{$class-type}push--#{$namespace}two-fifths; }
#{$class-type}push--#{$namespace}five-tenths { @extend #{$class-type}push--#{$namespace}one-half; }
#{$class-type}push--#{$namespace}six-tenths { @extend #{$class-type}push--#{$namespace}three-fifths; }
#{$class-type}push--#{$namespace}seven-tenths { left:70%; @include silent-relative(); }
#{$class-type}push--#{$namespace}eight-tenths { @extend #{$class-type}push--#{$namespace}four-fifths; }
#{$class-type}push--#{$namespace}nine-tenths { left:90%; @include silent-relative(); }
/**
* Twelfths
*/
#{$class-type}push--#{$namespace}one-twelfth { left:8.333%; @include silent-relative(); }
#{$class-type}push--#{$namespace}two-twelfths { @extend #{$class-type}push--#{$namespace}one-sixth; }
#{$class-type}push--#{$namespace}three-twelfths { @extend #{$class-type}push--#{$namespace}one-quarter; }
#{$class-type}push--#{$namespace}four-twelfths { @extend #{$class-type}push--#{$namespace}one-third; }
#{$class-type}push--#{$namespace}five-twelfths { left:41.666%; @include silent-relative(); }
#{$class-type}push--#{$namespace}six-twelfths { @extend #{$class-type}push--#{$namespace}one-half; }
#{$class-type}push--#{$namespace}seven-twelfths { left:58.333%; @include silent-relative(); }
#{$class-type}push--#{$namespace}eight-twelfths { @extend #{$class-type}push--#{$namespace}two-thirds; }
#{$class-type}push--#{$namespace}nine-twelfths { @extend #{$class-type}push--#{$namespace}three-quarters; }
#{$class-type}push--#{$namespace}ten-twelfths { @extend #{$class-type}push--#{$namespace}five-sixths; }
#{$class-type}push--#{$namespace}eleven-twelfths { left:91.666%; @include silent-relative(); }
}
@if $push == true {
/**
* Not a particularly great selector, but the DRYest way to do things.
*/
[class*="push--"]{ position:relative; }
@include push-setup();
@if $responsive == true{
@each $name in $breakpoint-has-push {
@include grid-media-query($name) {
@include push-setup('#{$name}--');
}
}
}
}
/*------------------------------------*\
$PULL
\*------------------------------------*/
/**
* Pull classes, to move grid items back to the left by certain amounts.
*/
@mixin pull-setup($namespace: ""){
/**
* Whole
*/
#{$class-type}pull--#{$namespace}one-whole { right:100%; @include silent-relative(); }
/**
* Halves
*/
#{$class-type}pull--#{$namespace}one-half { right:50%; @include silent-relative(); }
/**
* Thirds
*/
#{$class-type}pull--#{$namespace}one-third { right:33.333%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}two-thirds { right:66.666%; @include silent-relative(); }
/**
* Quarters
*/
#{$class-type}pull--#{$namespace}one-quarter { right:25%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}two-quarters { @extend #{$class-type}pull--#{$namespace}one-half; }
#{$class-type}pull--#{$namespace}three-quarters { right:75%; @include silent-relative(); }
/**
* Fifths
*/
#{$class-type}pull--#{$namespace}one-fifth { right:20%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}two-fifths { right:40%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}three-fifths { right:60%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}four-fifths { right:80%; @include silent-relative(); }
/**
* Sixths
*/
#{$class-type}pull--#{$namespace}one-sixth { right:16.666%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}two-sixths { @extend #{$class-type}pull--#{$namespace}one-third; }
#{$class-type}pull--#{$namespace}three-sixths { @extend #{$class-type}pull--#{$namespace}one-half; }
#{$class-type}pull--#{$namespace}four-sixths { @extend #{$class-type}pull--#{$namespace}two-thirds; }
#{$class-type}pull--#{$namespace}five-sixths { right:83.333%; @include silent-relative(); }
/**
* Eighths
*/
#{$class-type}pull--#{$namespace}one-eighth { right:12.5%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}two-eighths { @extend #{$class-type}pull--#{$namespace}one-quarter; }
#{$class-type}pull--#{$namespace}three-eighths { right:37.5%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}four-eighths { @extend #{$class-type}pull--#{$namespace}one-half; }
#{$class-type}pull--#{$namespace}five-eighths { right:62.5%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}six-eighths { @extend #{$class-type}pull--#{$namespace}three-quarters; }
#{$class-type}pull--#{$namespace}seven-eighths { right:87.5%; @include silent-relative(); }
/**
* Tenths
*/
#{$class-type}pull--#{$namespace}one-tenth { right:10%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}two-tenths { @extend #{$class-type}pull--#{$namespace}one-fifth; }
#{$class-type}pull--#{$namespace}three-tenths { right:30%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}four-tenths { @extend #{$class-type}pull--#{$namespace}two-fifths; }
#{$class-type}pull--#{$namespace}five-tenths { @extend #{$class-type}pull--#{$namespace}one-half; }
#{$class-type}pull--#{$namespace}six-tenths { @extend #{$class-type}pull--#{$namespace}three-fifths; }
#{$class-type}pull--#{$namespace}seven-tenths { right:70%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}eight-tenths { @extend #{$class-type}pull--#{$namespace}four-fifths; }
#{$class-type}pull--#{$namespace}nine-tenths { right:90%; @include silent-relative(); }
/**
* Twelfths
*/
#{$class-type}pull--#{$namespace}one-twelfth { right:8.333%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}two-twelfths { @extend #{$class-type}pull--#{$namespace}one-sixth; }
#{$class-type}pull--#{$namespace}three-twelfths { @extend #{$class-type}pull--#{$namespace}one-quarter; }
#{$class-type}pull--#{$namespace}four-twelfths { @extend #{$class-type}pull--#{$namespace}one-third; }
#{$class-type}pull--#{$namespace}five-twelfths { right:41.666%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}six-twelfths { @extend #{$class-type}pull--#{$namespace}one-half; }
#{$class-type}pull--#{$namespace}seven-twelfths { right:58.333%; @include silent-relative(); }
#{$class-type}pull--#{$namespace}eight-twelfths { @extend #{$class-type}pull--#{$namespace}two-thirds; }
#{$class-type}pull--#{$namespace}nine-twelfths { @extend #{$class-type}pull--#{$namespace}three-quarters; }
#{$class-type}pull--#{$namespace}ten-twelfths { @extend #{$class-type}pull--#{$namespace}five-sixths; }
#{$class-type}pull--#{$namespace}eleven-twelfths { right:91.666%; @include silent-relative(); }
}
@if $pull == true{
/**
* Not a particularly great selector, but the DRYest way to do things.
*/
[class*="pull--"]{ position:relative; }
@include pull-setup();
@if $responsive == true{
@each $name in $breakpoint-has-pull {
@include grid-media-query($name) {
@include pull-setup('#{$name}--');
}
}
}
}

@ -255,7 +255,7 @@ input.faq-search {
border-top: 2px solid $emerald;
}
.question__text {
.question__title {
margin-top: 0;
}

@ -1,11 +1,8 @@
@import "variables";
@import "normalize";
// @import "csswizardry-grids";
@import "type";
@import "bootstrap";
@import "mobile-grid";
@import "main";
@import "buttons";
@import "helpers";

@ -45,5 +45,8 @@
"dependencies": {
"jquery": ">=1.9.0",
"modernizr": "^2.6.2"
},
"devDependencies": {
"jasmine-jquery": "~2.0.5"
}
}

@ -1,138 +1,111 @@
.filter-options {
margin-top: 20px;
margin-bottom: 40px;
}
margin-bottom: 40px; }
.filter-group .filter-group__label {
margin: 0 0 5px;
}
margin: 0 0 5px; }
.filter-group button {
width: 40px;
height: 40px;
padding: 0;
}
padding: 0; }
.filter-group label {
cursor: pointer;
}
cursor: pointer; }
.shape-up {
position: relative;
overflow: hidden;
}
overflow: hidden; }
.shape {
position: relative;
margin-left: 0;
margin-top: 10px;
}
margin-top: 10px; }
.shape .shape__inner {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
left: 0; }
.shape .shape__space {
width: 100%;
height: 100%;
background-color: black;
border-style: solid;
border-width: 0;
border-color: transparent;
}
border-color: transparent; }
.shape--blue .shape__space {
background-color: #3498db;
border-bottom-color: #3498db;
}
background-color: #3498DB;
border-bottom-color: #3498DB; }
.shape--red .shape__space {
background-color: #e74c3c;
border-bottom-color: #e74c3c;
}
background-color: #E74C3C;
border-bottom-color: #E74C3C; }
.shape--orange .shape__space {
background-color: #f39c12;
border-bottom-color: #f39c12;
}
background-color: #F39C12;
border-bottom-color: #F39C12; }
.shape--green .shape__space {
background-color: #2ecc71;
border-bottom-color: #2ecc71;
}
background-color: #2ECC71;
border-bottom-color: #2ECC71; }
.shape--circle .shape__space {
border-radius: 50%;
}
border-radius: 50%; }
.shape--diamond .shape__space {
-webkit-transform: rotate(45deg) scale(0.70711);
-ms-transform: rotate(45deg) scale(0.70711);
transform: rotate(45deg) scale(0.70711);
}
-ms-transform: rotate(45deg) scale(0.70711);
transform: rotate(45deg) scale(0.70711); }
.shape--triangle .shape__space {
padding-top: 14.5px;
height: 0;
width: 0;
border-width: 0 110px 191px 110px;
background-color: transparent;
}
background-color: transparent; }
.lt-ie9 .shape .keep-ratio {
position: static;
width: 100%;
height: 250px;
overflow: visible;
padding-bottom: 0;
}
padding-bottom: 0; }
.lt-ie9 .shape .shape__inner {
position: static;
width: 100%;
height: 100%;
}
height: 100%; }
@media (min-width: 1200px) {
.shape--triangle .shape__space {
padding-top: 18px;
height: 0;
width: 0;
border-width: 0 135px 234px 135px;
}
}
border-width: 0 135px 234px 135px; } }
@media (min-width: 768px) and (max-width: 979px) {
.shape--triangle .shape__space {
padding-top: 11px;
height: 0;
width: 0;
border-width: 0 83px 144px 83px;
}
}
border-width: 0 83px 144px 83px; } }
@media (max-width: 767px) {
.shape--triangle .shape__space {
padding-top: 40px;
height: 0;
width: 0;
border-width: 0 300px 520px 300px;
margin: auto;
}
}
margin: auto; } }
@media (max-width: 600px) {
.shape--triangle .shape__space {
padding-top: 32px;
height: 0;
width: 0;
border-width: 0 240px 416px 240px;
}
}
border-width: 0 240px 416px 240px; } }
@media (max-width: 480px) {
.shape--triangle .shape__space {
padding-top: 21.5px;
height: 0;
width: 0;
border-width: 0 160px 277px 160px;
}
}
border-width: 0 160px 277px 160px; } }
body::before {
content: 'Default - 940px';
position: fixed;
@ -143,30 +116,21 @@ body::before {
height: 25px;
background-color: rgba(119, 204, 102, 0.6);
-webkit-transition: background .2s ease;
transition: background .2s ease;
}
transition: background .2s ease; }
@media (min-width: 1200px) {
body::before {
content: 'Large Desktop - 1200px+';
background-color: rgba(204, 119, 102, 0.6);
}
}
background-color: rgba(204, 119, 102, 0.6); } }
@media (min-width: 768px) and (max-width: 979px) {
body::before {
content: 'Portrait tablet to landscape and desktop - > 768px && < 979px';
background-color: rgba(204, 187, 102, 0.6);
}
}
background-color: rgba(204, 187, 102, 0.6); } }
@media (max-width: 767px) {
body::before {
content: 'Phones to Tablets - < 767px';
background-color: rgba(102, 153, 204, 0.6);
}
}
background-color: rgba(102, 153, 204, 0.6); } }
@media (max-width: 480px) {
body::before {
content: 'Phones - < 480px';
background-color: rgba(204, 102, 204, 0.6);
}
}
background-color: rgba(204, 102, 204, 0.6); } }

@ -3,16 +3,13 @@
\*=============================================*/
.picture-item {
height: 220px;
margin-top: 24px;
}
margin-top: 24px; }
.picture-item.shuffle-item {
margin-left: 0;
/* shuffle items shouldn't have a left margin*/
}
/* shuffle items shouldn't have a left margin*/ }
.picture-item.picture-item--h2 {
height: 464px;
/* 2x the height + 1 gutter */
}
/* 2x the height + 1 gutter */ }
.picture-item.span6:not(.picture-item--h2) .picture-item__details {
position: absolute;
bottom: 0;
@ -20,33 +17,25 @@
width: 100%;
background-color: #333;
background-color: rgba(0, 0, 0, 0.6);
color: white;
}
color: white; }
.picture-item.span6:not(.picture-item--h2) .picture-item__description {
display: none;
}
display: none; }
.picture-item .picture-item__inner {
background: #ecf0f1;
background: #ECF0F1;
height: 100%;
overflow: hidden;
}
overflow: hidden; }
.picture-item img {
display: block;
width: 100%;
height: auto;
}
.picture-item .picture-item__details,
.picture-item .picture-item__description {
padding: 1em;
}
height: auto; }
.picture-item .picture-item__details, .picture-item .picture-item__description {
padding: 1em; }
.picture-item .picture-item__description {
margin: 0;
padding-top: 0;
padding-right: 2em;
}
padding-right: 2em; }
.picture-item .picture-item__tags {
margin: 0;
}
margin: 0; }
/*
Shuffle needs either relative or absolute positioning on the container
@ -55,63 +44,48 @@
*/
.shuffle--container {
position: relative;
overflow: hidden;
}
overflow: hidden; }
.shuffle--fluid .shuffle__sizer {
position: absolute;
opacity: 0;
visibility: hidden;
}
visibility: hidden; }
/* Animate in styles */
.shuffle--animatein {
overflow: visible;
}
overflow: visible; }
.shuffle--animatein .picture-item__inner {
opacity: 0;
-webkit-transform: translate(0, 220px);
-ms-transform: translate(0, 220px);
transform: translate(0, 220px);
}
-ms-transform: translate(0, 220px);
transform: translate(0, 220px); }
.shuffle--animatein .picture-item__inner--transition {
-webkit-transition: all .6s ease;
transition: all .6s ease;
}
transition: all .6s ease; }
.shuffle--animatein .picture-item.in .picture-item__inner {
opacity: 1;
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
@media (max-width: 47.9375em) {
.picture-item {
height: auto;
margin-top: 20px;
}
margin-top: 20px; }
.picture-item.picture-item--h2 {
height: auto;
}
.picture-item .picture-item__details,
.picture-item .picture-item__description {
height: auto; }
.picture-item .picture-item__details, .picture-item .picture-item__description {
font-size: .875em;
padding: .625em;
}
padding: .625em; }
.picture-item .picture-item__description {
padding-right: .875em;
padding-bottom: 1.25em;
}
padding-bottom: 1.25em; }
.filter > .row-fluid,
.filter > .row-fluid > div {
margin: 10px 0;
}
.filter > .row-fluid, .filter > .row-fluid > div {
margin: 10px 0; }
.m-nofloat {
float: none;
}
}
float: none; } }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -6,13 +6,18 @@ extraJS: [ "demos/homepage.js" ]
includeHeader: true
prism: true
---
<section id="downloads">
<section id="install">
<div class="container-fluid">
<h2>Downloads<a href="#downloads"></a></h2>
<h2>Install<a href="#install"></a></h2>
<div class="row-fluid">
<div class="span12">
<pre><code class="language">bower install shufflejs</code></pre>
</div>
</div>
<div class="row-fluid">
<nav class="span6" role="secondary">
<a href="{{ site.baseurl }}/dist/jquery.shuffle.js">jquery.shuffle.js</a>
<a href="{{ site.baseurl }}/dist/jquery.shuffle.min.js">jquery.shuffle.min.js</a>
<a href="https://github.com/Vestride/Shuffle">View the GitHub repository</a>
<a href="https://github.com/Vestride/Shuffle/releases">See the latest releases</a>
</nav>
</div>
</div>
@ -113,6 +118,12 @@ prism: true
</div>
</section>
<section id="public-methods">
<div class="container-fluid">
{% include public-methods.html %}
</div>
</section>
<section id="extra-features">
<div class="container-fluid">
<h2>Extra Features<a href="#extra-features"></a></h2>

@ -4,17 +4,16 @@ window.Manipulator = (function($) {
var hasConsole = window.console && typeof window.console.log === 'function';
var Manipulator = function( element ) {
var self = this;
this.$el = $( element );
this.init();
self.$el = $( element );
self.init();
this.addToEnd = true;
this.sequentialDelay = true;
};
Manipulator.prototype.init = function() {
var self = this;
self.initShuffle();
self.setupEvents();
this.initShuffle();
this.setupEvents();
};
// Column width and gutter width options can be functions
@ -39,14 +38,14 @@ window.Manipulator = (function($) {
};
Manipulator.prototype.setupEvents = function() {
var self = this;
$('#add').on('click', $.proxy( self.onAddClick, self ));
$('#randomize').on('click', $.proxy( self.onRandomize, self ));
$('#remove').on('click', $.proxy( self.onRemoveClick, self ));
$('#add').on('click', $.proxy( this.onAddClick, this ));
$('#randomize').on('click', $.proxy( this.onRandomize, this ));
$('#remove').on('click', $.proxy( this.onRemoveClick, this ));
$('#sorter').on('change', $.proxy( this.onSortChange, this ));
$('#mode').on('change', $.proxy( this.onModeChange, this ));
// Show off some shuffle events
self.$el.on('removed.shuffle', function( evt, $collection, shuffle ) {
this.$el.on('removed.shuffle', function( evt, $collection, shuffle ) {
// Make sure logs work
if ( !hasConsole ) {
@ -61,10 +60,9 @@ window.Manipulator = (function($) {
// Creating random elements. You could use an
// ajax request or clone elements instead
var self = this,
itemsToCreate = 5,
var itemsToCreate = 5,
frag = document.createDocumentFragment(),
grid = self.$el[0],
grid = this.$el[0],
items = [],
$items,
classes = ['w2', 'h2', 'w3'],
@ -74,6 +72,7 @@ window.Manipulator = (function($) {
random = Math.random();
box = document.createElement('div');
box.className = 'box';
box.setAttribute('created', this.getRandomInt(1, 150));
// Randomly add a class
if ( random > 0.8 ) {
@ -90,9 +89,9 @@ window.Manipulator = (function($) {
// Tell shuffle items have been appended.
// It expects a jQuery object as the parameter.
self.shuffle.appended( $items );
this.shuffle.appended( $items, this.addToEnd, this.sequentialDelay );
// or
// self.$el.shuffle('appended', $items );
// this.$el.shuffle('appended', $items );
};
Manipulator.prototype.getRandomInt = function(min, max) {
@ -101,8 +100,7 @@ window.Manipulator = (function($) {
// Randomly choose some elements to remove
Manipulator.prototype.onRemoveClick = function() {
var self = this,
total = self.shuffle.visibleItems,
var total = this.shuffle.visibleItems,
numberToRemove = Math.min( 3, total ),
indexesToRemove = [],
i = 0,
@ -116,29 +114,59 @@ window.Manipulator = (function($) {
// This has the possibility to choose the same index for more than
// one in the array, meaning sometimes less than 3 will be removed
for ( ; i < numberToRemove; i++ ) {
indexesToRemove.push( self.getRandomInt( 0, total - 1 ) );
indexesToRemove.push( this.getRandomInt( 0, total - 1 ) );
}
// Make a jQuery collection out of the index selections
var self = this;
$.each(indexesToRemove, function(i, index) {
$collection = $collection.add( self.shuffle.$items.eq( index ) );
});
// Tell shuffle to remove them
self.shuffle.remove( $collection );
this.shuffle.remove( $collection );
// or
// self.$el.shuffle('remove', $collection);
// this.$el.shuffle('remove', $collection);
};
Manipulator.prototype.onRandomize = function() {
var self = this,
sortObj = {
randomize: true
};
$('#sorter').val('random').trigger('change');
};
self.shuffle.sort( sortObj );
// or
// self.$el.shuffle('sort', sortObj);
Manipulator.prototype.onSortChange = function(evt) {
var value = evt.target.value;
var opts = {};
// We're given the element wrapped in jQuery
if ( value === 'created' ) {
opts = {
by: function($el) {
return parseInt($el.attr('created'), 10);
}
};
} else if ( value === 'random' ) {
opts = {
randomize: true
};
}
// Filter elements
this.$el.shuffle('sort', opts);
};
Manipulator.prototype.onModeChange = function(evt) {
var value = evt.target.value;
if (value === 'end') {
this.addToEnd = true;
this.sequentialDelay = false;
} else if (value === 'end-sequential') {
this.addToEnd = true;
this.sequentialDelay = true;
} else if (value === 'mix') {
this.addToEnd = false;
this.sequentialDelay = false;
}
};
return Manipulator;

@ -7,7 +7,7 @@
$searchInput = $('#search'),
$questions = $('.js-question'),
$questionInners = $questions.find('.question__inner'),
$questionTexts = $questions.find('.question__text'),
$questionTitles = $questions.find('.question__title'),
keyup = function() {
// Value they've entered
@ -16,7 +16,7 @@
// Filter elements based on if their string exists in the product model
$questions.each(function( i, el ) {
var $el = $( el ),
text = $.trim( $questionTexts.eq( i ).text() ).toLowerCase(),
text = $.trim( $questionTitles.eq( i ).text() ).toLowerCase(),
passes = text.indexOf( val ) !== -1;
if ( passes ) {

@ -16,7 +16,7 @@
],
"main": "jquery.shuffle.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "grunt test"
},
"repository": {
"type": "git",
@ -29,13 +29,14 @@
},
"homepage": "https://github.com/Vestride/Shuffle",
"devDependencies": {
"grunt": "^0.4.4",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-uglify": "^0.4.0",
"grunt-shell": "^0.6.4",
"load-grunt-tasks": "^0.4.0",
"grunt-contrib-sass": "^0.7.3",
"grunt": "^0.4.5",
"grunt-autoprefixer": "^1.0.1",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-jasmine": "^0.7.0",
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-uglify": "^0.5.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-autoprefixer": "^0.7.2"
"grunt-shell": "^1.0.1",
"load-grunt-tasks": "^0.6.0"
}
}

@ -2,7 +2,7 @@
if (typeof define === 'function' && define.amd) {
define(['jquery', 'modernizr'], factory);
} else {
factory(window.jQuery, window.Modernizr);
window.Shuffle = factory(window.jQuery, window.Modernizr);
}
})(function($, Modernizr, undefined) {

File diff suppressed because it is too large Load Diff

@ -0,0 +1,38 @@
{
"node": false,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": false, // Doesn't work well with concat'd files.
"trailing": true,
"smarttabs": true,
"globals": {
"describe": true,
"console": true,
"it": true,
"jasmine": true,
"beforeEach": true,
"afterEach": true,
"loadFixtures": true,
"jasmine": true,
"expect": true,
"spyOn": true,
"$": true,
"Modernizr": true
}
}

@ -0,0 +1,37 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href=".grunt/grunt-contrib-jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="../.grunt/grunt-contrib-jasmine/jasmine.css">
</head>
<body>
<script src="../.grunt/grunt-contrib-jasmine/es5-shim.js"></script>
<script src="../.grunt/grunt-contrib-jasmine/jasmine.js"></script>
<script src="../.grunt/grunt-contrib-jasmine/jasmine-html.js"></script>
<script src="../.grunt/grunt-contrib-jasmine/boot.js"></script>
<script src="../dist/modernizr.custom.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="../bower_components/jasmine-jquery/lib/jasmine-jquery.js"></script>
<script src="../dist/jquery.shuffle.js"></script>
<script src="specs.js"></script>
<script src="../.grunt/grunt-contrib-jasmine/reporter.js"></script>
</body>
</html>

@ -0,0 +1,12 @@
<div id="regular-shuffle">
<div class="item" data-age="21" id="item1" data-groups='["design", "red"]'>Person 1</div>
<div class="item" data-age="50" id="item2" data-groups='["design", "blue"]'>Person 2</div>
<div class="item" data-age="29" id="item3" data-groups='["strategy", "green"]'>Person 3</div>
<div class="item" data-age="27" id="item4" data-groups='["ux", "green"]'>Person 4</div>
<div class="item" data-age="35" id="item5" data-groups='["ux", "blue"]'>Person 5</div>
<div class="item" data-age="23" id="item6" data-groups='["ux", "red"]'>Person 6</div>
<div class="item" data-age="42" id="item7" data-groups='["newbiz"]'>Person 7</div>
<div class="item" data-age="31" id="item8" data-groups='["technology", "black"]'>Person 8</div>
<div class="item" data-age="28" id="item9" data-groups='["design", "red"]'>Person 9</div>
<div class="item" data-age="25" id="item10" data-groups='["technology", "black"]'>Person 10</div>
</div>

@ -0,0 +1,756 @@
jasmine.getFixtures().fixturesPath = 'fixtures';
describe('Shuffle.js', function() {
var $ = window.jQuery;
var Modernizr = window.Modernizr;
describe('regular markup', function() {
var $shuffle;
beforeEach(function() {
loadFixtures('regular.html');
$shuffle = $('#regular-shuffle');
});
afterEach(function(done) {
var shuffle = $shuffle.data('shuffle');
$shuffle = null;
if (!shuffle) {
return done();
}
function finish() {
shuffle.destroy();
done();
}
if (shuffle.initialized) {
setTimeout(finish, 0);
} else {
shuffle.$el.one('done.shuffle', finish);
}
});
it('should get default options', function() {
$('#regular-shuffle').shuffle();
expect($('#regular-shuffle')).toHaveData('shuffle');
var shuffle = $('#regular-shuffle').data('shuffle');
expect(shuffle.$items.length).toBe(10);
expect(shuffle.visibleItems).toBe(10);
expect(shuffle.group).toBe('all');
expect(shuffle.speed).toBe(250);
expect(shuffle.itemSelector).toBe('');
expect(shuffle.sizer).toBe(null);
expect(shuffle.columnWidth).toBe(0);
expect(shuffle.gutterWidth).toBe(0);
expect(shuffle.delimeter).toBe(null);
expect(shuffle.initialSort).toBe(null);
expect(shuffle.throttleTime).toBe(300);
expect(shuffle.sequentialFadeDelay).toBe(150);
expect(shuffle.useSizer).toBe(false);
expect(shuffle.unique).toBe('shuffle_0');
});
it('should add classes and default styles', function() {
$('#regular-shuffle').shuffle();
var shuffle = $('#regular-shuffle').data('shuffle');
expect(shuffle.$el).toHaveClass('shuffle');
expect(shuffle.$items).toHaveClass('shuffle-item filtered');
expect(shuffle.$el).toHaveCss({
position: 'relative',
overflow: 'hidden'
});
expect(shuffle.$items).toHaveCss({
opacity: '1',
position: 'absolute',
visibility: 'visible'
});
expect(shuffle.containerWidth).not.toBe(0);
});
it('should be 3 columns with gutters', function() {
$shuffle.css({
width: '1000px'
});
$shuffle.children().css({
width: '300px',
height: '150px'
});
$shuffle.shuffle({
columnWidth: 300,
gutterWidth: 50
});
var shuffle = $shuffle.data('shuffle');
expect(shuffle.colWidth).toBe(350);
expect(shuffle.cols).toBe(3);
expect(shuffle.positions).toEqual([600, 450, 450]);
});
it('can have a function for columns and gutters', function() {
$shuffle.css({
width: '1000px'
});
$shuffle.children().css({
width: '300px',
height: '150px'
});
$shuffle.shuffle({
columnWidth: function(containerWidth) {
expect(containerWidth).toBe(1000);
return 300;
},
gutterWidth: function() {
return 50;
}
});
var shuffle = $shuffle.data('shuffle');
expect(shuffle._getGutterSize(1000)).toBe(50);
expect(shuffle._getColumnSize(1000, 50)).toBe(350);
expect(shuffle.colWidth).toBe(350);
expect(shuffle.cols).toBe(3);
expect(shuffle.positions).toEqual([600, 450, 450]);
});
it('can have a function for columns/gutters and span multiple columns', function() {
$shuffle.css({
width: '1200px'
});
var $kids = $shuffle.children();
$kids.css({
width: '300px',
height: '10px'
});
$kids.eq(1).css({
width: '600px'
});
$kids.eq(5).css({
width: '600px'
});
$kids.eq(6).css({
width: '900px'
});
$shuffle.shuffle({
columnWidth: function(containerWidth) {
expect(containerWidth).toBe(1200);
return 300;
},
gutterWidth: function() {
return 0;
}
});
var shuffle = $shuffle.data('shuffle');
expect(shuffle._getGutterSize(1200)).toBe(0);
expect(shuffle._getColumnSize(1200, 0)).toBe(300);
expect(shuffle.colWidth).toBe(300);
expect(shuffle.cols).toBe(4);
expect(shuffle.positions).toEqual([40, 40, 30, 30]);
});
it('can filter by the data attribute', function(done) {
var shuffle = $shuffle.shuffle({
speed: 100
}).data('shuffle');
function first() {
shuffle.shuffle('design');
$shuffle.one('layout.shuffle', second);
}
function second() {
expect(shuffle.visibleItems).toBe(3);
var $concealedItems = $('#item3, #item4, #item5, #item6, #item7, #item8, #item10');
var $filteredItems = $('#item1, #item2, #item9');
expect($concealedItems).toHaveClass('concealed');
expect($filteredItems).toHaveClass('filtered');
expect($concealedItems).toHaveCss({
visibility: 'hidden'
});
// Filter by green.
shuffle.shuffle('green');
$shuffle.one('layout.shuffle', third);
}
function third() {
expect(shuffle.visibleItems).toBe(2);
var $concealedItems = $('#item1, #item2, #item5, #item6, #item7, #item8, #item9, #item10');
var $filteredItems = $('#item3, #item4');
expect($concealedItems).toHaveClass('concealed');
expect($filteredItems).toHaveClass('filtered');
done();
}
$shuffle.one('done.shuffle', first);
});
it('can shuffle by function', function(done) {
var shuffle = $shuffle.shuffle({
speed: 100
}).data('shuffle');
function first() {
shuffle.shuffle(function($el) {
return parseInt($el.attr('id').substring(4), 10) <= 5;
});
$shuffle.one('layout.shuffle', second);
}
function second() {
expect(shuffle.visibleItems).toBe(5);
var $concealedItems = $('#item6, #item7, #item8, #item9, #item10');
var $filteredItems = $('#item1, #item2, #item3, #item4, #item5');
expect($concealedItems).toHaveClass('concealed');
expect($filteredItems).toHaveClass('filtered');
expect(shuffle.isTransitioning).toBe(false);
done();
}
// First shuffle is async.
$shuffle.one('done.shuffle', first);
});
it('can shuffle by function without transitions', function(done) {
var shuffle = $shuffle.shuffle({
speed: 100,
supported: false
}).data('shuffle');
function first() {
shuffle.shuffle(function($el) {
return parseInt($el.attr('id').substring(4), 10) <= 5;
});
$shuffle.one('layout.shuffle', second);
}
function second() {
expect(shuffle.visibleItems).toBe(5);
var $concealedItems = $('#item6, #item7, #item8, #item9, #item10');
var $filteredItems = $('#item1, #item2, #item3, #item4, #item5');
expect($concealedItems).toHaveClass('concealed');
expect($filteredItems).toHaveClass('filtered');
expect(shuffle.isTransitioning).toBe(false);
done();
}
// First shuffle is async.
$shuffle.one('done.shuffle', first);
});
it('can initialize filtered and the category parameter is optional', function(done) {
var shuffle = $shuffle.shuffle({
speed: 100,
group: 'design'
}).data('shuffle');
expect(shuffle.visibleItems).toBe(3);
function first() {
expect(shuffle.visibleItems).toBe(10);
done();
}
$shuffle.one('layout.shuffle', first);
shuffle.shuffle();
});
it('can initialize sorted', function() {
var sortObj = {
by: function($el) {
return parseInt($el.attr('data-age'), 10);
}
};
var shuffle = $shuffle.shuffle({
speed: 100,
initialSort: sortObj
}).data('shuffle');
expect(shuffle.lastSort).toEqual(sortObj);
});
describe('inserting elements', function() {
var $collection;
beforeEach(function() {
var $eleven = $('<div>', {
'class': 'item',
'data-age': 36,
'data-groups': '["ux", "black"]',
id: 'item11',
text: 'Person 11'
});
var $twelve = $('<div>', {
'class': 'item',
'data-age': 37,
'data-groups': '["strategy", "blue"]',
id: 'item12',
text: 'Person 12'
});
$collection = $eleven.add($twelve);
});
afterEach(function() {
$collection = null;
});
it('can add items', function(done) {
var shuffle = $shuffle.shuffle({
speed: 100,
group: 'black'
}).data('shuffle');
function first() {
$shuffle.append($collection);
shuffle.appended($collection);
// Already 2 in the items, plus number 11.
expect(shuffle.visibleItems).toBe(3);
$shuffle.one('layout.shuffle', function() {
expect(shuffle.isTransitioning).toBe(false);
done();
});
}
$shuffle.one('done.shuffle', first);
});
it('can add items without transitions', function(done) {
var shuffle = $shuffle.shuffle({
speed: 100,
group: 'black',
supported: false
}).data('shuffle');
function first() {
$shuffle.append($collection);
shuffle.appended($collection);
// Already 2 in the items, plus number 11.
expect(shuffle.visibleItems).toBe(3);
$shuffle.one('layout.shuffle', function() {
expect(shuffle.isTransitioning).toBe(false);
done();
});
}
$shuffle.one('done.shuffle', first);
});
});
describe('removing elements', function() {
var shuffle;
var $itemsToRemove;
var onDone;
var onRemoved;
beforeEach(function() {
$itemsToRemove = $shuffle.children().slice(0, 2);
onDone = function() {
shuffle.remove($itemsToRemove);
$shuffle.one('removed.shuffle', onRemoved);
};
});
afterEach(function() {
$itemsToRemove = null;
shuffle = null;
onDone = null;
onRemoved = null;
});
it('can remove items', function(done) {
shuffle = $shuffle.shuffle({
speed: 100
}).data('shuffle');
onRemoved = function(evt, $items, instance) {
expect(instance.visibleItems).toBe(8);
expect($items[0].id).toBe('item1');
expect($items[1].id).toBe('item2');
expect($shuffle.children().length).toBe(8);
expect(instance.isTransitioning).toBe(false);
done();
};
$shuffle.one('done.shuffle', onDone);
});
it('can remove items without transitions', function(done) {
shuffle = $shuffle.shuffle({
speed: 100,
supported: false
}).data('shuffle');
onRemoved = function(evt, $items, instance) {
expect(instance.visibleItems).toBe(8);
expect($items[0].id).toBe('item1');
expect($items[1].id).toBe('item2');
expect($shuffle.children().length).toBe(8);
expect(instance.isTransitioning).toBe(false);
done();
};
$shuffle.one('done.shuffle', onDone);
});
});
describe('after initialized', function() {
var shuffle;
beforeEach(function(done) {
jasmine.clock().install();
shuffle = $shuffle.shuffle({
speed: 60
}).data('shuffle');
$shuffle.one('done.shuffle', function() {
done();
});
jasmine.clock().tick(17);
});
afterEach(function() {
jasmine.clock().uninstall();
});
it('can calculate column spans', function() {
expect(shuffle._getColumnSpan(50, 100, 3)).toBe(1);
expect(shuffle._getColumnSpan(200, 100, 3)).toBe(2);
expect(shuffle._getColumnSpan(200, 200, 3)).toBe(1);
expect(shuffle._getColumnSpan(300, 100, 3)).toBe(3);
// Column span should not be larger than the number of columns.
expect(shuffle._getColumnSpan(300, 50, 3)).toBe(3);
// Fix for percentage values.
expect(shuffle._getColumnSpan(100.02, 100, 4)).toBe(1);
expect(shuffle._getColumnSpan(99.98, 100, 4)).toBe(1);
});
it('can calculate column sets', function() {
// _getColumnSet(columnSpan, columns)
shuffle.positions = [150, 0, 0, 0];
expect(shuffle._getColumnSet(1, 4)).toEqual([150, 0, 0, 0]);
expect(shuffle._getColumnSet(2, 4)).toEqual([150, 0, 0]);
});
it('can call appended with different options', function() {
spyOn(shuffle, '_addItems').and.callFake(function() {});
shuffle.appended(null, true, true);
expect(shuffle._addItems).toHaveBeenCalledWith(null, true, true);
shuffle.appended(null, false, false);
expect(shuffle._addItems).toHaveBeenCalledWith(null, false, false);
shuffle.appended(null);
expect(shuffle._addItems).toHaveBeenCalledWith(null, false, true);
shuffle.appended(null, null, null);
expect(shuffle._addItems).toHaveBeenCalledWith(null, false, true);
});
it('can get an element option', function() {
var $first = $shuffle.children().first();
expect(shuffle._getElementOption($first)).toEqual($first[0]);
expect(shuffle._getElementOption($first[0])).toEqual($first[0]);
expect(shuffle._getElementOption('#item1')).toEqual($first[0]);
expect(shuffle._getElementOption('#hello-world')).toEqual(null);
expect(shuffle._getElementOption(null)).toEqual(null);
expect(shuffle._getElementOption(undefined)).toEqual(null);
expect(shuffle._getElementOption(function() {
return $first;
})).toEqual(null);
});
it('can test elements against filters', function() {
var $first = $shuffle.children().first();
expect(shuffle._doesPassFilter('design', $first)).toBe(true);
expect(shuffle._doesPassFilter('black', $first)).toBe(false);
expect(shuffle._doesPassFilter(function($el) {
expect($el).toExist();
return $el.attr('data-age') === '21';
}, $first)).toBe(true);
expect(shuffle._doesPassFilter(function($el) {
return $el.attr('data-age') === '22';
}, $first)).toBe(false);
});
it('can initialize a collection of items', function() {
var $eleven = $('<div>', {
'class': 'item',
'data-age': 36,
'data-groups': '["ux", "black"]',
id: 'item11',
text: 'Person 11'
});
var $twelve = $('<div>', {
'class': 'item',
'data-age': 37,
'data-groups': '["strategy", "blue"]',
id: 'item12',
text: 'Person 12'
});
var $collection = $eleven.add($twelve);
expect($collection).not.toHaveClass('shuffle-item');
expect($collection).not.toHaveClass('filtered');
expect($collection).not.toHaveData('point');
shuffle._initItems($collection);
expect($collection).toHaveClass('shuffle-item');
expect($collection).toHaveClass('filtered');
expect($collection).toHaveData('point');
});
it('will maintain the last sort object', function() {
var initialSort = shuffle.lastSort;
spyOn(shuffle, '_layout');
shuffle.sort();
expect(shuffle.lastSort).toEqual(initialSort);
shuffle.sort({ glen: true });
expect(shuffle.lastSort).toEqual({ glen: true });
shuffle.sort();
expect(shuffle.lastSort).toEqual({ glen: true });
});
it('should reset columns', function() {
expect(shuffle.cols).toBeGreaterThan(0);
shuffle._resetCols();
var positions = new Array(shuffle.cols);
for (var i = 0; i < shuffle.cols; i++) {
positions[i] = 0;
}
expect(shuffle.positions).toEqual(positions);
});
it('should destroy properly', function() {
var $items = shuffle.$items;
shuffle.destroy();
expect(shuffle.element).toBe(null);
expect(shuffle.$items).toBe(null);
expect(shuffle.sizer).toBe(null);
expect(shuffle.$el).toBe(null);
expect($shuffle).not.toHaveData('shuffle');
expect($shuffle).not.toHaveClass('shuffle');
expect($items).not.toHaveClass('shuffle-item');
expect($items).not.toHaveClass('filtered');
expect($items).not.toHaveClass('concealed');
expect($items).not.toHaveData('point');
expect($items).not.toHaveData('scale');
});
it('should not update or shuffle when disabled or destroyed', function() {
spyOn(shuffle, 'update');
spyOn(shuffle, '_filter');
shuffle.disable();
shuffle.shuffle('design');
expect(shuffle._filter).not.toHaveBeenCalled();
expect(shuffle.update).not.toHaveBeenCalled();
shuffle.enable(false);
shuffle.destroy();
shuffle._onResize();
expect(shuffle.update).not.toHaveBeenCalled();
});
it('should not update when the container is the same size', function() {
spyOn(shuffle, 'update');
shuffle._onResize();
expect(shuffle.update).not.toHaveBeenCalled();
});
});
it('can get the real width of an element which is scaled', function() {
var div = document.createElement('div');
div.style.cssText = 'width:100px;height:100px;';
div.style[Modernizr.prefixed('transform')] = window.Shuffle._getItemTransformString({
x: 0,
y: 0
}, 0.5);
document.body.appendChild(div);
expect(window.Shuffle._getOuterWidth(div, false)).toBe(100);
expect(window.Shuffle._getOuterWidth(div, true)).toBe(100);
expect(window.Shuffle._getOuterHeight(div, false)).toBe(100);
expect(window.Shuffle._getOuterHeight(div, true)).toBe(100);
div.style.marginLeft = '10px';
div.style.marginRight = '20px';
div.style.marginTop = '30px';
div.style.marginBottom = '40px';
expect(window.Shuffle._getOuterWidth(div, false)).toBe(100);
expect(window.Shuffle._getOuterWidth(div, true)).toBe(130);
expect(window.Shuffle._getOuterHeight(div, false)).toBe(100);
expect(window.Shuffle._getOuterHeight(div, true)).toBe(170);
document.body.removeChild(div);
});
});
describe('the sorted plugin', function() {
beforeEach(function() {
loadFixtures('regular.html');
});
it('will catch empty jQuery objects', function() {
var $items = $();
expect($items.sorted()).toEqual([]);
});
it('can randomize the elements', function() {
var $items = $('#regular-shuffle').children();
var array = $items.toArray();
expect($items.length).toBe(10);
expect($items.sorted({
randomize: true
})).not.toEqual(array);
});
it('can sort by a function', function() {
var $items = $('#regular-shuffle').children();
var array = $items.toArray();
array.sort(function(a, b) {
var age1 = parseInt(a.getAttribute('data-age'), 10);
var age2 = parseInt(b.getAttribute('data-age'), 10);
return age1 - age2;
});
var result = $items.sorted({
by: function($el) {
expect($el).toExist();
return parseInt($el.attr('data-age'), 10);
}
});
expect(result).toEqual(array);
});
it('can sort by a function and reverse it', function() {
var $items = $('#regular-shuffle').children();
var array = $items.toArray();
array.sort(function(a, b) {
var age1 = parseInt(a.getAttribute('data-age'), 10);
var age2 = parseInt(b.getAttribute('data-age'), 10);
return age1 - age2;
}).reverse();
var result = $items.sorted({
reverse: true,
by: function($el) {
expect($el).toExist();
return parseInt($el.attr('data-age'), 10);
}
});
expect(result).toEqual(array);
});
it('will not sort without a `by` function', function() {
var $items = $('#regular-shuffle').children();
var array = $items.toArray();
expect($items.sorted()).toEqual(array);
expect($items.sorted({})).toEqual(array);
expect($items.sorted({
reverse: true
})).toEqual(array.reverse());
});
it('will revert to DOM order if the `by` function returns undefined', function() {
var $items = $('#regular-shuffle').children();
var array = $items.toArray();
var count = 0;
expect($items.sorted({
by: function() {
count++;
return count < 5 ? Math.random() : undefined;
}
})).toEqual(array);
});
it('can sort elements first', function() {
var $items = $('#regular-shuffle').children().slice(0, 4);
var array = $items.toArray();
array = [ array[1], array[0], array[3], array[2] ];
expect($items.sorted({
by: function($el) {
var age = $el.data('age');
if (age === 50) {
return 'sortFirst';
} else {
return age;
}
}
})).toEqual(array);
});
it('can sort elements last', function() {
var $items = $('#regular-shuffle').children().slice(0, 4);
var array = $items.toArray();
array = [ array[0], array[2], array[1], array[3] ];
expect($items.sorted({
by: function($el) {
var age = $el.data('age');
if (age === 27) {
return 'sortLast';
} else {
return age;
}
}
})).toEqual(array);
});
});
});

@ -1,16 +1,5 @@
# Todos and other improvements
## Improvements
* TESTS!
* Horizontal layout
* More JSDoc
* Create an `Item` class for shuffle items so they can handle storing values and more.
## Things I don't like and would like to fix
* Move everything to Shuffle.prototype.method = function.
* Less jQuery dependency
## Reasons Zepto doesn't work
* `.data()` - although I think it can be included?
* `.filter()` and `.not()` don't work with collections.
* `.css(['style1', 'style2', 'style3'])` isn't supported.

Loading…
Cancel
Save