Skip to content

Instantly share code, notes, and snippets.

a.lazy-load-youtube {
vertical-align: top;
background: #555;
width: 100%;
max-width: 480px;
height: 270px;
background-size: cover;
text-decoration: none;
color: #ddd;
display: inline-block;
/*
* Lazy Load for Youtube
* by Kevin Weber
*/
var $lly = jQuery.noConflict();
$lly(document).ready(function() {
function doload_lly() {
@kevinweber
kevinweber / Change event for textarea (IE9+)
Last active July 28, 2016 16:38
Change event for textarea (IE9+)
$('#textareaID').on('input change keyup', function () {
if (this.value.length) {
// textarea has content
} else {
// textarea is empty
}
});
/**
* Loop through an object and call a passed function
*/
function loopObject(object, func) {
var property;
for (property in object) {
if (object.hasOwnProperty(property)) {
func(property, object);
}
/**
* Move element's class to parent element
* Usage example:
* $element.moveClassToParent('select-container');
*/
(function ($) {
"use strict";
// Create the defaults once
@kevinweber
kevinweber / Helper: Sort object with objects
Last active July 19, 2016 06:06
Sort objects of an object based on one of their common properties
/**
* Sort objects of an object based on one of their common properties
*
* Call it like this:
* mySortedObject = sortObjectWithObjects(myObject, "name");
*
* To store ...
*
var myObject = [{
@kevinweber
kevinweber / debounce.js
Last active April 25, 2018 01:05
Debounce function
/**
* Debounce function
* based on https://davidwalsh.name/essential-javascript-functions
*/
function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this,
args = arguments,
@kevinweber
kevinweber / poll.js
Last active July 23, 2022 16:45
Poll function
/**
* Poll function
* based on https://davidwalsh.name/essential-javascript-functions
*/
function poll(fn, callback, errback, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
/*global jQuery */
/**
* $.responsiveVideo
* by Kevin Weber
*
* Improve responsiveness of videos.
* Libraries required: jQuery.
*
* Initiate plugin like this:
@kevinweber
kevinweber / browsersync.sh
Last active August 12, 2016 20:22
Browsersync that works with AEM. UPDATE: Use the AEM Front solution instead: https://github.com/kevinweber/aem-front
#! /bin/bash
# https://www.npmjs.com/package/browser-sync
# Documentation: https://browsersync.io/docs/command-line
# Usage: Run `$ sh browsersync.sh` in your terminal from the folder where this script is located.
# Use this script together with https://github.com/kevinweber/aem-front-extension
if ! type "browser-sync" > /dev/null;
then
echo "browser-sync is not installed. Installing..."
sudo npm install browser-sync -g