Skip to content

Instantly share code, notes, and snippets.

var data = [
{
name: 'Nadav',
school: 'Weber',
interest: 'Jazz'
},
{
name: 'Noy',
school: 'Epstein'
},
@nadavspi
nadavspi / togglesingle-improved.js
Created February 25, 2015 22:53
togglesingle-improved.js
jQuery.fn.toggleSingle = function (options) {
// passing destruct: true allows
var settings = $j.extend({
destruct: false
}, options);
return this.each(function () {
if (!settings.destruct) {
var $this = $j(this);
// Generate an ID for the content if there isn't one
if (!$next.attr('id')) {
$next.attr('id', 'toggle-' + Math.random().toString(36).substr(2, 9));
}
$this.attr('aria-controls', $next.attr('id'));
var $this = $j(this);
var $next = $this.next();
$this.on('click', function () {
$this.toggleClass('active')
.attr('aria-expanded', !$this.attr('aria-expanded') === 'true');
$next().toggleClass('no-display')
.attr('aria-hidden', !$next.attr('aria-hidden') === 'true');
});
$j(this).on('click', function () {
$j(this)
.toggleClass('active')
.next()
.toggleClass('no-display');
});
// Hide the content
$j(this).next().addClass('no-display');
@nadavspi
nadavspi / toggleSingle.js
Last active August 29, 2015 14:16
Original toggleSingle()
// ==============================================
// UI Pattern - ToggleSingle
// ==============================================
// Use this plugin to toggle the visibility of content based on a toggle link/element.
// This pattern differs from the accordion functionality in the Toggle pattern in that each toggle group acts
// independently of the others. It is named so as not to be confused with the Toggle pattern below
//
// This plugin requires a specific markup structure. The plugin expects a set of elements that it
// will use as the toggle link. It then hides all immediately-following siblings and toggles the sibling's
(function() {
var files = ['assets/site/css/non-critical.css', 'assets/site/img/icons.svg'];
function getExtension(src) {
return src.split('.').pop();
}
function injectContent(content, type) {
if (type === 'css') {
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@nadavspi
nadavspi / SassMeister-input-HTML.html
Created September 12, 2014 16:09
Generated by SassMeister.com.
<h1 class="em">Hi there <span>Dmitry</span></h1>
<h1 class="rem">Hi there <span>Dmitry</span></h1>
@nadavspi
nadavspi / SassMeister-input-HTML.html
Created August 25, 2014 15:18
Generated by SassMeister.com.
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae neque harum, illo adipisci nulla accusamus quaerat, quas voluptatum voluptate ipsa. Deleniti dicta recusandae est a, expedita nostrum ducimus doloremque vero.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae neque harum, illo adipisci nulla accusamus quaerat, quas voluptatum voluptate ipsa. Deleniti dicta recusandae est a, expedita nostrum ducimus doloremque vero.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae neque harum, illo adipisci nulla accusamus quaerat, quas voluptatum voluptate ipsa. Deleniti dicta recusandae est a, expedita nostrum ducimus doloremque vero.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae neque harum, illo adipisci nulla accusamus quaerat, quas voluptatum voluptate ipsa. Deleniti dicta recusandae est a, expedita nostrum ducimus doloremque vero.</p>