Skip to content

Instantly share code, notes, and snippets.

@ellm
ellm / viewport-test.js
Created February 2, 2016 20:54
JavaScript - Test for Element in Viewport
// Check to see if an element is in the viewport
function elementInViewport(el) {
var top = el.offsetTop;
var left = el.offsetLeft;
var width = el.offsetWidth;
var height = el.offsetHeight;
while (el.offsetParent) {
el = el.offsetParent;
top += el.offsetTop;
@ellm
ellm / cool-module-2.js
Created January 28, 2016 18:36
JavaScript - Module Example using Init
var ModuleExample = {
init: function() {
var _self = this;
var varExample = $('form.variations_form');
function exampleFunction() {
console.log(this);
}
}
};
@ellm
ellm / cool-module.js
Created January 25, 2016 19:31
JavaScript - Module Pattern Example
function CoolModule() {
var something = "cool";
var another = [1, 2, 3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join( " ! " ) );
@ellm
ellm / gist:1325000
Last active October 25, 2022 05:09 — forked from NateJacobs/gist:1321741
WordPress - List all authors of a blog grouped by first name with a single letter as a header character.
<?php
/**
* List Users Alphabetically
*
* Create a list of all authors of a WordPress blog.
* Names are grouped by first name with a single letter
* as a header character.
*
* Call the function with <?php ngtj_list_users_alphabetically(); ?>