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
// prep | |
var d = document.createElement('template'); | |
d.id = 'myOcotcat'; | |
d.innerHTML = '<img src="" alt="my awesome octocat" width="200" height="200"/>'; | |
document.body.appendChild(d); | |
// query the DOM for the specified template | |
var t = document.querySelector('#myOcotcat'); |
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 sort( a1, a2 ) { | |
var i = 0 | |
, j = 0 | |
, l1 = a1.length | |
, l2 = a2.length | |
, a = []; | |
while( i < l1 && j < l2 ) { |
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
//with jQuery | |
var parent = $(selector) | |
, totalWidthOfChildren = Array.prototype.reduce.call(parent.children(), function(a,b){ return a + $(b).outerWidth( true ); }, 0); | |
//without jquery | |
var parent = document.getElementById('selector') | |
, totalWidthOfChildren = Array.prototype.reduce.call(parent.children, function(a,b){ return a + outerWidth(b); }, 0); | |
function outerWidth( elem ) { |
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() { | |
var d = document.createElement('div') | |
, width = window.document.documentElement[ 'clientWidth' ]; | |
d.id = 'documentWidth'; | |
d.className = 'active'; | |
d.innerHTML = '<p>' + width + '</p'; | |
d.style.position = 'fixed'; | |
d.style.top = '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
function hideElement( elem, target ) { | |
//wrap as jquery object if it isnt one | |
elem = elem instanceof jQuery ? elem : $( elem ); | |
//if there is a target and that target is a function then run that function | |
//and return the elem to hide otherwise simply hide the element | |
target ? typeof( target ) === 'function' ? ( target(elem) ).hide() : elem.find( target ).hide() : elem.hide(); | |
} |
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
getPlaceInfo : function( options ) { | |
//console.log( options ); | |
var request = { | |
location : new google.maps.LatLng( options.locations.lat, options.locations.lng ) | |
} | |
, service = new google.maps.places.PlacesService( options.map ) | |
, places = []; |
NewerOlder