Skip to content

Instantly share code, notes, and snippets.

View aklump's full-sized avatar

Aaron Klump aklump

View GitHub Profile
@aklump
aklump / element_properties_to_children
Last active December 28, 2015 03:09
PHP: Convert a renderable Drupal array's properties to children.
/**
* Convert all element properties to children
*
* @param array $array An array with one or more keys that begine with '#' .
*
* @return array Any key that began with '#' will have the # stripped.
*/
function element_properties_to_children($array) {
$keys = array_map(create_function('$item', 'return substr($item, 1);'), array_keys($array));
@aklump
aklump / jquery.multi_fadein.js
Last active December 25, 2015 23:29
A jQuery Plugin to fade in multiple DOM elements in step-wise succession.
/**
* A jQuery Plugin to fade in multiple DOM elements in step-wise succession.
*
* @param bool|object options
* A boolean value will be interpreted as {start: [value]}.
* An object with these properties:
* - speed int How fast to reveal the step in seconds. Each element may also
control it's individual speed with the attribute data-speed.
* - delay int Defaults to 0. How many seconds between the end of one step and
the start of the next. You may also use data-delay for element specific
@aklump
aklump / jquery.resume_playback.js
Last active December 21, 2015 04:49
Remembers the playback position of media and resumes on page load. The playhead position is set on the media events: play, pause, and seeked; as well the position is recorded at an interval defined in the options, anytime the media is playing.
/**
* HTML5 Media Resume Playback (Playhead Position Memory) jQuery Plugin
*
* Remembers the playback position of media and resumes on page load. The
* playhead position is set on the media events: play, pause, and seeked; as
* well the position is recorded at an interval defined in the options, anytime
* the media is playing.
*
* Requires the jStorage plugin <http://www.jstorage.info/>
*
@aklump
aklump / jquery.iframe_to_div.js
Last active May 30, 2019 16:55
A jQuery plugin to replace iframes with divs containing their source by loading via ajax. Benefits use parent page's css and have an auto height to your iframe.
/**
* Convert iframes to divs via ajax iframe_to_div jQuery Plugin
*
* Uses javascript to replace iframes with divs containing their source content
* by loading via ajax. If you use this to load vanilla html snippets, this has the
* effect of applying the page's css to your vanilla html snippet.
*
* This will not work if the iframe src is not a relative link due to ajax restrictions across domains.
*
* As an example:
@aklump
aklump / jquery.swiper.js
Last active December 14, 2015 17:59
jQuery plugin for a fancy left/right slider for prev/next type browsing
/**
* Swiper jQuery Plugin
*
* You need to also include:
http://www.netcu.de/jquery-touchwipe-iphone-ipad-library
*
* @code
* <script>
* $('.track').swiper({
* 'trainClass': 'train',
@aklump
aklump / jquery.list_search_filter.js
Last active October 14, 2015 00:18
Create a searchable list by textfield jQuery Plugin
/**
* Create a searchable list by textfield jQuery Plugin
*
* @param object $input
* A jQuery object of a textfield to use as the search box
* @param options
* code: the ascii code of the key to use for lookup; when this is pressed
the list will be searched, defaults to 13 for the Return key.
* auto: min length needed before it will autosearch, for large lists
setting this too low results in poor performance. Set this to 0 to turn off
@aklump
aklump / jquery.drupal_check_all.js
Created December 11, 2012 19:59
Adds a Check All Option to a group of Checkboxes in Drupal jQuery Plugin
/**
* Adds a Check All Option to a group of Checkboxes in Drupal jQuery Plugin
*
* To make this work you need pass to this function, a div that is a decendent
of a form and an ancestor of multiple checkboxes. It is specifically tuned to
drupal, but can be used for any html by setting the options. Here's and
example, where .form-item-list is fapi element of type checkboxes.
*
* @code
* $('#my-form .form-item-list').drupalCheckAll();
@aklump
aklump / jquery.running_clock.js
Last active October 10, 2015 22:17
jQuery plugin to append a running clock to an element
This has been moved to http://www.intheloftstudios.com/packages/jquery/jquery.running_clock
@aklump
aklump / jquery.fapi_widths.js
Last active October 8, 2015 04:18
jQuery plugin to equalize form element widths
/**
* Form Element Width Equalizer Plugin (Optimized for Drupal FAPI)
*
* Adjusts the widths of child elements to a set pixel dimension.
*
* Makes all text fields and text areas (or other as specified in
* options.elements) equal widths by subracting the css properties of: margin,
* border and padding from each element.
*
* If width is omitted then all elements will have their width matched to $(this)
@aklump
aklump / jquery.loft_labels.js
Last active October 7, 2015 09:58
jQuery plugin to move form labels into the textfield
This has moved to http://www.intheloftstudios.com/packages/jquery/jquery.loft_labels