Skip to content

Instantly share code, notes, and snippets.

View estados-cidades.json
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
View keypress.js
$(document).keydown(function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
switch(code) {
case 37: // left
//e.preventDefault();
break;
case 38: // top
break;
View FSimg.js
/*
.background {
position: fixed;
width: 100%;
height: 100%;
z-index: -1;
}
<div class="background">
<img class="img" src="bg.jpg" alt="">
View isLocal.js
function isLocal(){
return window.location.href.indexOf('.dev') > -1;
}
// not local (prod)
if ( !isLocal() ) {
}
@yurigoytacaz
yurigoytacaz / detectIE.js
Created May 23, 2014
nice function to detect IE
View detectIE.js
function detectIE(){
var ua = window.navigator.userAgent;
var msie = /MSIE/.test( ua );
var trident = /Trident/.test( ua );
if( msie > 0 ){
// IE 10 or older => return version number
var msiePosition = ua.indexOf('MSIE ')+5;
return parseInt( ua.replace(/.*MSIE ([0-9]+).*/,'$1') ); // Return only the version
}
@yurigoytacaz
yurigoytacaz / causeRepaint.js
Created May 23, 2014
cause repaints to update element using vw/vh on window resize
View causeRepaint.js
causeRepaintsOn = $('element');
$(window).resize(function() {
causeRepaintsOn.css('z-index', 1);
});
@yurigoytacaz
yurigoytacaz / ismobile.js
Created May 23, 2014
check if is mobile
View ismobile.js
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
View if.dev.js
// only run this when NOT locally (i.e.: http://project.dev)
if ( window.location.href.indexOf('.dev') 1== false ) {
// do something
}
You can’t perform that action at this time.