Skip to content

Instantly share code, notes, and snippets.

View jbuncle's full-sized avatar

James Buncle jbuncle

View GitHub Profile
@jbuncle
jbuncle / jquery.toggle-attribute.js
Created November 26, 2015 23:32
jQuery Plugin to toggle an elements attribute
/*!
* jQuery Toggle Attribute
*
* Copyright 2013 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
*/
(function($) {
@jbuncle
jbuncle / jquery.smallcaps.js
Last active May 22, 2016 15:41
jQuery Plugin to apply a 'smallcaps' effect to text
/*!
* jQuery SmallCaps
*
* Demo: https://jsfiddle.net/jbuncle/9wwrkbrf/
*
* Copyright 2013 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
@jbuncle
jbuncle / bootstrap-nav-scroll-hider.js
Last active November 25, 2020 16:07
jQuery script to hide bootstrap fixed navbar on scroll down and reveal on scroll up
/*!
* jQuery script to hide bootstrap fixed navbar on scroll down and reveal on scroll up.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
*/
(function ($) {
@jbuncle
jbuncle / jquery.scale-text.js
Last active May 19, 2016 10:47
jQuery Plugin for responsively scaling text to fill it's parent width.
/*!
* jQuery Plugin for responsively scaling text to fill it's parent width.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
*/
(function ($) {
@jbuncle
jbuncle / jquery.viewport.js
Last active January 25, 2017 19:59
2 jQuery Plugins for detecting if an element is in the current viewport (visible from the current scroll positions).
/*!
* 2 jQuery Plugins for detecting if an element is in the current viewport (visible from the current scroll positions).
*
* $.isWithinViewport - for detecting if the element is fully in view
* $.inViewport - for detecting if the element is partially in view
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
@jbuncle
jbuncle / jquery.has-attr.js
Created May 19, 2016 12:20
jQuery plugin example of checking if an element has a given attribute
(function ($) {
$.fn.hasAttr = function (name) {
var currentAttr = $(this).attr(name);
return currentAttr !== undefined && currentAttr !== false;
};
})(jQuery);
@jbuncle
jbuncle / jquery.sibling-fader.js
Created May 19, 2016 12:23
Simple jQuery Plugin which fades out an elements siblings on hover.
/*!
* Simple jQuery Plugin which fades out an elements siblings on hover.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
*/
(function ($) {
@jbuncle
jbuncle / jquery.scroller.js
Last active May 19, 2016 12:29
Simple jQuery Plugin for using an animated scroll to on page anchors/links
/*!
* Simple jQuery Plugin for using an animated scroll to on page anchors/links.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
*/
(function ($) {
@jbuncle
jbuncle / jquery.scroll-highlight.js
Created May 19, 2016 12:54
Adds class to bookmark/local links when the linked element is in view.
/*!
* Adds class to bookmark/local links when the linked element is in view.
*
* Requires https://gist.github.com/jbuncle/6f6185e88be875b2585e736a422c3f15 for detecting when element is in view.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
@jbuncle
jbuncle / jQuery onEnterKeypress
Created July 1, 2016 08:49
Basic jQuery function for handling enter key being hit.
/**
* Basic jQuery function for handling enter key being hit.
*
* @returns jQuery
*/
$.fn.onEnterKeypress = function (callback) {
return $(this).keypress(function (evt) {
// Check for enter key
if (evt.which === 13) {
// Invoke callback