Skip to content

Instantly share code, notes, and snippets.

View zachshallbetter's full-sized avatar

Zach Shallbetter zachshallbetter

View GitHub Profile
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@zachshallbetter
zachshallbetter / HTML5 Placeholder
Last active December 18, 2015 11:38
SASS mixin for html5 placeholder text
// SCSS mixin for html5 placeholder text.
// Based on Codesnippits article http://css-tricks.com/snippets/css/style-placeholder-text/
//
// @include placeholder {
/* css properties */
//}
@mixin placeholder {
&:-moz-placeholder { @content }
&::-webkit-input-placeholder { @content }
@zachshallbetter
zachshallbetter / SCSS Emboss Mixin
Created June 23, 2013 16:28
An SCSS mixin for semi-transparent one-pixel lines placed above and below an element to give the illusion it’s embossed inside of its parent.
// SCSS mixin for element embossing.
// A semi-transparent one-pixel lines placed above and below an element to give the illusion it’s embossed in its parent.
//
// @include box-emboss(0.8, 0.05);
@mixin box-emboss($opacity, $opacity2){
box-shadow:white($opacity) 0 1px 0, inset black($opacity2) 0 1px 0;
}
@zachshallbetter
zachshallbetter / SCSS Letterpress Mixin
Created June 23, 2013 16:35
An SCSS Mixing to give a semi-transparent text shadow around letters.
// SCSS mixin for letter embossing.
// A semi-transparent text shadow around letters to give the illusion of "letterpressing".
//
// @include letter-emboss(0.8);
@mixin letter-emboss($opacity){
text-shadow:white($opacity) 0 1px 0;
}
@zachshallbetter
zachshallbetter / filepicker require module
Last active December 19, 2015 00:48
Filemaker 'faces' error
define(['jquery', 'filepicker'], function($, TweenMax) {
var FileUpload = (function() {
var Uploaded = {};
// Upload modal
function upload( el, position ) {
Uploaded.location = $(el);
@zachshallbetter
zachshallbetter / After Decoupling
Last active December 19, 2015 02:58
Single responsibility principle (Decoupled code)
function AjaxForm($el) {
this.$form = $el;
this.form = $el[0]; // Internal state via properties
this.$form.on('submit', $.proxy(this.submit, this));
};
AjaxForm.prototype = {
submit: function(e) { // Named Functions
e.PreventDefault();
var this = this;
@zachshallbetter
zachshallbetter / new_gist_file
Created June 28, 2013 17:56
Wraping interface to plugins.
function Datepicker($el) {
this.$el = $el;
}
Datepicker.prototype = {
hide: function() {
this.$el.datepicker('hide');
},
show: function() {
this.$el.datepicker('show');
var Duck = function(){
this.quack = function(){alert('Quaaaaaack!');};
this.feathers = function(){alert('The duck has white and gray feathers.');};
return this;
};
var Person = function(){
this.quack = function(){alert('The person imitates a duck.');};
this.feathers = function(){alert('The person takes a feather from the ground and shows it.');};
this.name = function(){alert('John Smith');};
@zachshallbetter
zachshallbetter / input
Created July 2, 2013 15:24
Form Input Mixin
var FormInputMixin = {
getValue: function() {
return this.$el.val();
},
setValue: function(val) {
return this.$el.val(val);
}
}
var FormInputs = ['Textbox', 'Select', 'Checkbox'];
@zachshallbetter
zachshallbetter / js snippits
Created July 2, 2013 21:45
Jquery & Javascript Snippits
http://tympanus.net/codrops/2010/01/05/some-useful-javascript-jquery-snippets/
http://tympanus.net/codrops/2010/01/07/some-useful-javascript-jquery-snippets-part-2/
http://tympanus.net/codrops/2010/01/08/some-useful-javascript-jquery-snippets-part-3/
http://tympanus.net/codrops/2010/01/11/some-useful-javascript-jquery-snippets-part-4/