This file contains 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
<div class="space" style="height: 300px"> | |
<div class="item moon"><img src="http://nicovanzyl.com/external/files/img/moon.png"></div> | |
<div class="item ship"><img src="http://nicovanzyl.com/external/files/img/small-ship.png"></div> | |
<div class="item earth"></div> | |
<!--(optional)<div class="item shadow"></div>--> | |
</div> |
This file contains 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
Array(16).join('wat' - 1) + ' Batman!'; |
This file contains 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
// Animate scrolling | |
$('a[href*=#]:not([href=#])').click(function() { | |
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); | |
if (target.length) { | |
$('html,body').animate({ | |
scrollTop: target.offset().top | |
}, |
This file contains 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
# Create local server to run app in the browser with live reload | |
ionic serve | |
# Create local server to run app in the browser with android and ios styles side by side | |
ionic serve --lab | |
# Run app on device emulator | |
ionic run android | |
# Run app on device emulator with live reload features |
This file contains 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 $columns = $('.column'); | |
var height = 0; | |
$columns.each(function () { | |
if ($(this).height() > height) { | |
height = $(this).height(); | |
} | |
}); | |
$columns.height(height); |
This file contains 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
// Option 1 | |
function distance(lat1, lon1, lat2, lon2, unit) { | |
var radlat1 = Math.PI * lat1/180 | |
var radlat2 = Math.PI * lat2/180 | |
var radlon1 = Math.PI * lon1/180 | |
var radlon2 = Math.PI * lon2/180 | |
var theta = lon1-lon2 | |
var radtheta = Math.PI * theta/180 | |
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta); | |
dist = Math.acos(dist) |
This file contains 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 api_request(url, type, data, callback, error) { | |
$.ajax({ | |
type: type, | |
url: url, | |
data: data, | |
error: function(xhr, opt, err) { | |
if (error && typeof(error) === "function") { | |
loadError(xhr, opt, err); | |
} else { | |
loadError(xhr.statusText); |
This file contains 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 typewatch = (function(){ | |
var timer = 0; | |
return function(callback, ms){ | |
clearTimeout (timer); | |
timer = setTimeout(callback, ms); | |
}; | |
})(); | |
// Sample | |
$(document).on('keyup', '#branch_address', function(event) { |
This file contains 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 ($('.location-selector').length > 0) { | |
var map; | |
var markersArray = []; | |
// init map | |
function initMap() { | |
var currentLat = -33.9253; | |
var currentLng = 18.4239; | |
var branchLocation = {lat: currentLat, lng: currentLng}; |
This file contains 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 elementInViewport(el) { | |
var top = el.offsetTop; | |
var left = el.offsetLeft; | |
var width = el.offsetWidth; | |
var height = el.offsetHeight; | |
while(el.offsetParent) { | |
el = el.offsetParent; | |
top += el.offsetTop; | |
left += el.offsetLeft; |