This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @desc checks if current element exists | |
* @param none | |
* @return int - the number of elements present, > 0 = element exists | |
*/ | |
jQuery.fn.exists = function(){ return this.length > 0; } | |
// Usage: | |
if( $('#my-div').exists() ){ | |
// do something |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @desc checks if current element is on screen or within viewport | |
* @param none | |
* @return int - the coordinates of the window vs. the element | |
*/ | |
jQuery.fn.isOnScreen = function(){ | |
var win = $(window); | |
var viewport = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @desc create equal height columns | |
* @param object - the elements to apply equal heights to | |
* @return none | |
*/ | |
jQuery.fn.equalHeights = function(){ | |
var colSelector = this.selector;// Get the selector of the object | |
var newHeight; | |
var colHeights = []; | |
$(colSelector).css('height', '');// Clear heights first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @desc checks if current element is on screen or within viewport (as soon as it becomes visible) | |
* @param none | |
* @return int - the coordinates of the window vs. the element | |
*/ | |
jQuery.fn.isOnScreen = function(){ | |
var win = $(window); | |
var viewport = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************************* | |
* Custom excerpt length | |
*************************************************************************************/ | |
function excerpt($limit) { | |
$excerpt = explode(' ', get_the_excerpt(), $limit); | |
if (count($excerpt)>=$limit) { | |
array_pop($excerpt); | |
$excerpt = implode(" ",$excerpt).'...'; | |
} else { | |
$excerpt = implode(" ",$excerpt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('.some-element').bind('DOMSubtreeModified', function() { | |
// Do something | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
"use strict"; | |
$(document).ready (function(){ | |
$(window).scroll(function(){ | |
clearTimeout($.data(this, 'scrollTimer')); | |
$.data(this, 'scrollTimer', setTimeout(function() {// when the user stops scrolling | |
// do something | |
}, 500)); | |
}); | |
});// end document ready |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var resizeTimer; | |
$(window).on('resize', function(e) { | |
clearTimeout(resizeTimer); | |
resizeTimer = setTimeout(function() { | |
// Run code here, resizing has "stopped" | |
}, 250); |
OlderNewer