Skip to content

thought-constructor/jquery-lubricants

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

JQuery Lubricants

Keeps your page running smoothly...

Description

JQuery Lubricants (JQL) provides a number of helper functions intended to make code a bit more streamlined (and fun!).

Here's a rundown of what's inside...

Methods

or(alternative)

Evaluates and returns it argument if the current selection is empty:

$selection.or('.alternative')
$selection.or($('.alternative'))
$selection.or(function () { $('.alternative') })

map(method)

A new and improved map that can apply a method based on the given string:

$selection.map('offset')
$selection.map($.fn.offset)

max(method)

Determines the maximum over the current selection of the given attribute:

$selection.max('width')
$selection.max($.fn.width)

min(method)

Determines the minimum over the current selection of the given attribute:

$selection.min('width')
$selection.min($.fn.width)

top()

A shortcut for .offset().top intended to be used with the methods above:

$selection.top()
$selection.offset().top

left()

A shortcut for .offset().left intended to be used with the methods above:

$selection.left()
$selection.offset().left

right()

A shortcut for .offset().right intended to be used with the methods above:

$selection.right()
$selection.offset().right

bottom()

A shortcut for .offset().bottom intended to be used with the methods above:

$selection.bottom()
$selection.offset().bottom

grandparent()

A shortcut for .parent().parent():

$selection.grandparent()
$selection.parent().parent()

swapClass(from, to) and swapClass({ from: to })

Swaps the class(es) on the left with the class(es) on the right:

$selection.swapClass ('off', 'on')
$selection.swapClass ({ off: 'on', down: 'up' })

Pseudoselectors

localURL / local-url

Selects absolute and relative local URLS (sans protocol).

internalURL / internal-url

Selects URLs from the current domain.

externalURL / external-url

Selects URLs from any external domain:

$ (document).on('click', ':external-url(href)', function () { this.target = '_blank' })

About

[JavaScript & jQuery] Keeps your page running smoothly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published