Skip to content

Instantly share code, notes, and snippets.

Kevin Weber kevinweber

Block or report user

Report or block kevinweber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Lazy Load for Youtube (CSS)
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;
View Helper: Loop object (for-in)
/**
* 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);
}
View $.fn.moveClassToParent.js
/**
* Move element's class to parent element
* Usage example:
* $element.moveClassToParent('select-container');
*/
(function ($) {
"use strict";
// Create the defaults once
View $.responsiveVideo
/*global jQuery */
/**
* $.responsiveVideo
* by Kevin Weber
*
* Improve responsiveness of videos.
* Libraries required: jQuery.
*
* Initiate plugin like this:
@kevinweber
kevinweber / Helper: Sort object with objects
Last active Jul 19, 2016
Sort objects of an object based on one of their common properties
View Helper: Sort object with objects
/**
* 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 / Change event for textarea (IE9+)
Last active Jul 28, 2016
Change event for textarea (IE9+)
View Change event for textarea (IE9+)
$('#textareaID').on('input change keyup', function () {
if (this.value.length) {
// textarea has content
} else {
// textarea is empty
}
});
@kevinweber
kevinweber / browsersync.sh
Last active Aug 12, 2016
Browsersync that works with AEM. UPDATE: Use the AEM Front solution instead: https://github.com/kevinweber/aem-front
View browsersync.sh
#! /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
@kevinweber
kevinweber / aemsync.sh
Last active Aug 12, 2016
AEMSync pushes changes into your local AEM instance. Run it so you don't have to manually run the maven build all the time. Note that aemsync works for many files (XML, HTML, CSS, ...) but not for all of them, especially Java files. UPDATE: Use the AEM Front solution instead: https://github.com/kevinweber/aem-front
View aemsync.sh
#! /bin/bash
# https://www.npmjs.com/package/aemsync
# Usage: Run `$ sh aemsync.sh` in your terminal from the folder where this script is located.
if ! type "aemsync" > /dev/null;
then
echo "aemsync is not installed. Installing..."
sudo npm install aemsync -g
fi
@kevinweber
kevinweber / poll.js
Last active Sep 2, 2016
Poll function
View poll.js
/**
* 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() {
@kevinweber
kevinweber / ifTargetPageExists.js
Last active Dec 9, 2016
Helper: Check target URL using XMLHttpRequest before we execute a callback accordingly. No Ajax/Promise needed.
View ifTargetPageExists.js
/**
* Ensure that target page exists before we actually do something.
*
* @param {string} targetUrl - Absolute target URL to be tested
* @param {function} [successCallback] - Function to be executed on success
* @param {function} [failCallback] - Function to be executed on fail
*/
function checkTargetFirst(targetUrl, successCallback, failCallback) {
var reader = new XMLHttpRequest();
You can’t perform that action at this time.