This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When you have a huge amount of DOM elements! | |
// Using an array instead of a loop by 'shifting' the array speeds up the iterations | |
// and setTimeout prevents the browser from locking up. | |
;(function(){ | |
var customScripts = customScripts || {} | |
customScripts.selectorAllToArray = function( selector ){ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.box-to-grid( @columns; @gutter-size: 2em ){ | |
@responsiveColumn: ( 100 / @columns ); | |
@columnAdjust: ( ( ( @columns - 1 ) * @gutter-size ) / @columns ) ; | |
vertical-align: top; | |
display: inline-block; | |
margin-left: @gutter-size; | |
width: calc( ~"@{responsiveColumn}% - @{columnAdjust}" ) ; | |
&:nth-of-type( @{columns}n+1 ){ | |
margin-left: 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hashThis = function( $elem, cb ){ | |
var scrollLocation; | |
$( $elem ).on( "click", function( event ){ | |
event.preventDefault(); | |
scrollLocation = $( window ).scrollTop(); | |
window.location.hash = $( event.target ).attr('href').substr(1); | |
}); | |
$( window ).on( "hashchange", function( event ){ | |
event.preventDefault(); | |
$( window ).scrollTop( scrollLocation ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Object.create | |
if (typeof Object.create != 'function') { | |
(function () { | |
var F = function () {}; | |
Object.create = function (o) { | |
if (arguments.length > 1) { throw Error('Second argument not supported');} | |
if (o === null) { throw Error('Cannot set a null [[Prototype]]');} | |
if (typeof o != 'object') { throw TypeError('Argument must be an object');} | |
F.prototype = o; | |
return new F(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend(){ | |
for(var i=1; i<arguments.length; i++) { | |
for(var key in arguments[i]){ | |
if(arguments[i].hasOwnProperty(key)) { | |
arguments[0][key] = arguments[i][key]; | |
} | |
} | |
} | |
return arguments[0]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert a string to an object and add its value | |
* "formItem.address" -> {"formItem":{"address":"address value"}} | |
* @param {string} dotNotationString - A string that contains dots that whould map to an object key. | |
* @param {string} val - Value to be added to the key | |
*/ | |
var dotNotationStringToObject = function( dotNotationString, val ){ | |
var str = "{"; | |
var strEnd = "}"; | |
var obj = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert a list of nodes or arguments to an array. | |
* @param {object} list - Reference to a node or arguments. | |
*/ | |
var listToArray = function( list ) { | |
return [].map.call( list, function(element) { | |
return element; | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.getComputedStyle(document.querySelector('#element'),':after').getPropertyValue('content') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if('querySelector' in document | |
&& 'localStorage' in window | |
&& 'addEventListener' in window) { | |
// bootstrap the javascript application | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* AMD module | |
*/ | |
!function( name, factory ){ | |
if ( typeof define == 'function' && typeof define.amd == 'object' ) { | |
// Add dependencies here | |
define([ 'jquery', 'dutchcelt/Dater' ], factory); | |
} else { | |
// Not called as an AMD module? |
OlderNewer