Skip to content

Instantly share code, notes, and snippets.

View patrick91's full-sized avatar

Patrick Arminio patrick91

View GitHub Profile
@patrick91
patrick91 / jquery.autofitinput.js
Created December 11, 2013 17:17
Resize input according to its content.
(function ($) {
$.fn.autoFitInput = function (o) {
function getTestSubject(input, text) {
var testSubject = $('#input-tester');
if (testSubject.length === 0){
testSubject = $('<pre id="input-tester" />').appendTo('body').css({
position: 'absolute',
top: -9999,
left: -9999,
function scaleImage($img, w, h, targetWidth, targetHeigth) {
var ratio = targetWidth / w;
var height = h * ratio;
var width = w * ratio;
if (targetHeigth && height > targetHeigth) {
ratio = targetHeigth / h;
height = targetHeigth;
@patrick91
patrick91 / AnimatedRegion.js
Created February 20, 2013 10:24
Backbone Marionette View Transition
var AnimatedRegion = Backbone.Marionette.Region.extend({
show: function(view) {
this.ensureEl();
view.render();
this.close();
if (this.currentView && this.currentView !== view) {
return;
}