Skip to content

Instantly share code, notes, and snippets.

@lifo101
lifo101 / TransitionSlide.vue
Last active November 7, 2017 19:05
Vue2 "slide" transition for sliding elements of any height up/down (like jQuery.slideDown()) w/o the need to use a max-height hack
<script>
/**
* Creates a "slide" transition that will slide up/down the content within an element, no matter it's height.
* Some other solutions use max-height but that causes an annoying 'delay' due to having to use a large max-height
* value.
*
* This technique uses the element's "scrollHeight" and adjusts the elements height automatically. So you get a
* perfect slide effect w/o any delays.
*
* Usage:
@lifo101
lifo101 / OneToMany-Remove-Example.php
Created July 26, 2016 12:07
How to easily manage your OneToMany doctrine relationship in a Symfony form
<?php
/*
This is an example of how to easily manage a OneToMany relationship in a
Doctrine Entity with minimal code.
*/
$req = new Req();
$form = $this->createForm('AppBundle\Form\Type\MyType', $req);
@lifo101
lifo101 / xmlentities.php
Last active October 8, 2015 16:49
htmlentities() replacement that converts all entities in a string into character entities (suitable for XML documents)
<?php
/**
* Works like htmlentities() but only encodes entities as numeric codes
* instead of names (for use in XML).
*/
function xmlentities($str, $encoding = 'UTF-8', $asList = false)
{
$list = array();
$ent = '';
$chars = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY);
@lifo101
lifo101 / jquery.closestStyle.js
Created July 24, 2012 11:58
jquery plugin to find the closest CSS style of a DOM element's parents.
// $().closestStyle()
// find the closest CSS style of a parent for a DOM element and apply it
// to the selected element. I use this mainly before calling
// .effect('highlight') so the backgroundColor will mesh properly.
// @example:
// $('.row').closestStyle('backgroundColor').effect('highlight');
(function($){
$.fn.closestStyle = function(attr, val){
var me = $(this);
me.parents().each(function(i){
@lifo101
lifo101 / jquery.placeholder.js
Last active October 7, 2015 13:08
jquery plugin that adds HTML5 "placeholder" support for browsers that do not natively support it
// add HTML5 'placeholder' support to selected inputs if not natively supported.
// @example:
// $(':text[placeholder]').placeholder();
// @css:
// input.placeholder { color: #aaa; } /* since IE doesn't properly support :not() */
//
(function($){
if (document.createElement('input').placeholder !== undefined) {
$.fn.placeholder = $.noop;
} else {