Document adding and removing collections. Closes #19

Add an arrow icon and more obvious links to demos from each section.
pull/56/head
Glen Cheney 10 years ago
parent 2cf8187f35
commit e94747bd84

@ -0,0 +1,17 @@
<h2>Adding and removing items</h2>
<p>You can add and remove elements from shuffle after it has been created. This also works for infinite scrolling.</p>
<h3>Add a collection</h3>
<pre rel="JavaScript"><code class="language-javascript">// Adds 2 &lt;div&gt;s to an existing Shuffle instance.
var $item1 = $('&lt;div class="gallery-item item1"&gt;')
var $item2 = $('&lt;div class="gallery-item item2"&gt;')
var $items = $item1.add($item2);
$('#my-shuffle').append($items);
$('#my-shuffle').shuffle('appended', $items);</code></pre>
<h3>Remove a collection</h3>
<pre rel="JavaScript"><code class="language-javascript">// Remove the 2 &lt;div&gt;s which were just added.
var $items = $('.gallery-item');
$('#my-shuffle').shuffle('remove', $items);</code></pre>
<p class="demo-link-container">Check out the <a href="{{ site.baseurl }}{% post_url demos/2013-06-19-adding-removing %}">demo</a>.</p>

@ -24,4 +24,4 @@ $('.js-shuffle-search').on('keyup change', function() {
});
});</code></pre>
<p>For another example of advanced filters, check out the <a href="{{ site.baseurl }}{% post_url demos/2013-05-02-adaptive %}">compounded filters demo</a>.</p>
<p class="demo-link-container">Check out the <a href="{{ site.baseurl }}{% post_url demos/2013-05-02-adaptive %}">compounded filters demo</a>.</p>

@ -25,3 +25,5 @@ $grid.shuffle( options );</code></pre>
<pre rel="JavaScript"><code class="language-javascript">$grid.on('removed.shuffle', function( evt, $collection, shuffle ) {
console.log( this, evt, $collection, shuffle );
});</code></pre>
<p class="demo-link-container">Check out the <a href="#demo">demo</a> at the top of the page, or its <a href="/js/demos/homepage.js">JavaScript file.</a></p>

@ -38,3 +38,4 @@ $('.sort-options').on('change', function() {
<p>The <code class="language-javascript">opts</code> parameter can contain two properties. <code class="language-javascript">reverse</code>, a boolean which will reverse the array. <code class="language-javascript">by</code> is a function that is passed the element wrapped in jQuery. In the case above, we&rsquo;re returning the value of the data-date-created or data-title attributes.</p>
<p>Calling sort with an empty object will reset the elements to DOM order.</p>
<p class="demo-link-container">Check out the <a href="#demo">demo</a>.</p>

@ -3,7 +3,7 @@
<h3>The HTML Structure</h3>
<p>The only real important thing here is the <code class="language-markup token attr-name">data-groups</code> attribute. It has to be a <a href="http://jsonlint.com/">valid JSON</a> array of strings. Optionally, it can be a string delimeted by a value you provide. See <code>delimeter</code> in the <a href="#options">options</a>.</p>
<p>In this example, shuffle is using the fluid grid from the <a href="http://twitter.github.io/bootstrap/">Twitter Bootstrap</a>. It's also making use of the <a href="http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/"><abbr title="Block-Element-Modifier">BEM</abbr></a>.</p>
<p>In this example, shuffle is using the fluid grid from the <a href="http://twitter.github.io/bootstrap/">Twitter Bootstrap v2.3</a>. It's also making use of <a href="http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/"><abbr title="Block-Element-Modifier">BEM</abbr></a> class naming.</p>
<pre rel="HTML"><code class="language-markup">&lt;div id="grid" class="row-fluid"&gt;
&lt;figure class="span3 picture-item" data-groups='["photography"]'&gt;
@ -41,7 +41,7 @@
<h3 id="columns">How column widths work</h3>
<p>The <code>columnWidth</code> option is used to calculate the column width. You have several options:</p>
<ol>
<li>Use a <strong>sizer</strong> element. This is the easest way to specify column and gutter widths. You can use an element or an element wrapped in jQuery. The column and gutter widths will be measured using this element. The <code>sizer</code> option is an alias for <code>columnWidth</code>. See <a href="{{ site.baseurl }}{% post_url demos/2013-05-01-basic %}">a demo</a> using a sizer element or <a href="{{ site.baseurl }}/js/demos/homepage.js">look at the js file</a> for the sizer demo.</li>
<li>Use a <strong>sizer</strong> element. This is the easest way to specify column and gutter widths. You can use an element or an element wrapped in jQuery. The column and gutter widths will be measured using this element. The <code>sizer</code> option is an alias for <code>columnWidth</code>.<span class="demo-link-container">See <a href="{{ site.baseurl }}{% post_url demos/2013-05-01-basic %}">a demo</a> using a sizer element or <a href="{{ site.baseurl }}/js/demos/homepage.js">look at the js file</a> for the sizer demo.</span></li>
<li>Use a <strong>function</strong>. When a function is used, its first parameter will be the width of the shuffle element. You need to return the column width for shuffle to use (in pixels).</li>
<li>A <strong>number</strong>. This will explicitly set the column width to your number (in pixels).</li>
<li>By default, shuffle will use jQuery's <code class="language-javascript">outerWidth(true)</code> to calculate the column width of the first item and use that value.</li>

@ -145,6 +145,18 @@ nav > a {
}
.demo-link-container::before {
content: '';
color: $emerald;
margin-right: 5px;
}
span.demo-link-container::before {
margin-left: 5px;
}
// Filters
.filter__label {

@ -1,3 +1,4 @@
@charset "UTF-8";
/*! normalize.css v2.1.2 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
@ -2026,6 +2027,16 @@ nav > a {
margin-bottom: 1em;
}
.demo-link-container::before {
content: '➜';
color: #2ecc71;
margin-right: 5px;
}
span.demo-link-container::before {
margin-left: 5px;
}
.filter__label {
margin: 0 0 3px;
}

@ -107,6 +107,12 @@ prism: true
</div>
</section>
<section id="adding-removing">
<div class="container-fluid">
{% include adding-removing.html %}
</div>
</section>
<section id="extra-features">
<div class="container-fluid">
<h2>Extra Features</h2>

Loading…
Cancel
Save