Skip to content

Instantly share code, notes, and snippets.

View davetayls's full-sized avatar

Dave Taylor davetayls

View GitHub Profile
@davetayls
davetayls / jquery.enterPress.js
Created March 28, 2013 16:35
jquery.enterPress
/**
jQuery.enterPress
@license The MIT License (MIT)
*/
(function($){
'use strict';
$.fn.enterPress = function() {
return this.keypress(function(e) {
if (e.which == 13) {
@davetayls
davetayls / form-search
Created March 12, 2013 14:17
Cross browser search box styling
@davetayls
davetayls / jquery.preventDoubleSubmit.js
Created March 5, 2013 16:23
jquery.preventDoubleSubmit
/**
* A jquery plugin to prevent a form being submitted twice
*
* You'd use this on the form itself
* $('form').preventDoubleSubmit();
*/
;(function($) {
function submitHandler(e) {
var $form = $(this);
given([
"1234",
"^",
"<xss>",
"^",
",",
"' --",
"\""
])
.it('the name should be invalid', function(name){
@davetayls
davetayls / String.polyfills.js
Created February 7, 2013 16:42
String Extensions
/**
* Converts a string to Title case
* eg: hello how are you -> Hello How Are You
* @return {String}
*/
String.prototype.toTitleCase = function(){
return this.replace(/\w\S*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
};
@davetayls
davetayls / jquery.hint.js
Created January 28, 2013 10:05
jquery.hint using placeholder
/**
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/
/*jshint curly:false */
(function ($) {
var isInputSupported = 'placeholder' in document.createElement('input'),
isTextareaSupported = 'placeholder' in document.createElement('textarea');
@davetayls
davetayls / index.html
Created January 4, 2013 11:24
A CodePen by Dave Taylor.
<div id="scene"></div>
<script id="world" type="text/x-tmpl">
<span class="box">
<i class="front"></i>
<i class="back"></i>
</span>
</script>
@davetayls
davetayls / jquery.collapseContainer.js
Created October 10, 2012 16:49
simple jquery collapsible container plugin
/**
jQuery.collapseContainer v0.1
Dave Taylor http://the-taylors.org
@license The MIT License (MIT)
*/
/*global define,require */
(function($){
'use strict';
@davetayls
davetayls / once.js
Created October 5, 2012 16:30
Once function
/**
* Once script to make sure a function is only run once!
*/
(function(global){
 
    function once(func) {
        var ran = false, memo;
        return function() {
            if (ran) return memo;
            ran = true;
@davetayls
davetayls / jquery.equalHeights.js
Created October 3, 2012 16:37
Equal heights reloaded with window resize
/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 *
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com)
 *