vcavalcante@lambda3.com.br @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
function getElementsByClass(searchClass,node) {
if ( node == null )
node = document;
var classElements = [],
els = node.getElementsByTagName("*"),
elsLen = els.length,
pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"), i, j;
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
Victor Cavalcante @vcavalcante
$(".muitoSimples")
Victor Cavalcante @vcavalcante
if (redButton.addEventListener) { // all browsers and IE>=9
redButton.addEventListener ("click", OnRedClick, false);
}
else {
if (redButton.attachEvent) { // IE before version 9
redButton.attachEvent ('onclick', OnRedClick);
}
}
Victor Cavalcante @vcavalcante
$("#redButton").click(onRedClick)
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
by @ElijahManor
Victor Cavalcante @vcavalcante
by @ElijahManor
Victor Cavalcante @vcavalcante
$("#datepicker");
$("input");
$(".date");
$("input.date");
Victor Cavalcante @vcavalcante
$("#eventos");
document.getElementById("eventos");
$("form");
document.getElementsByTagName("form")
$(".data");
document.getElementsByClassName("data");
$("input.cpf");
document.querySelectorAll("input.cpf"); //Nodelist
document.querySelector("div.cpf"); //FirstElement
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
Victor Cavalcante @vcavalcante
//jquery
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
//nativo
var nodes = document.querySelectorAll("span.nome");
var i;
for(i= 0, len= nodes.length; i< len; ++i) {
nodes[i].innerText= "Hello: "+ i;
};
Victor Cavalcante @vcavalcante
//jquery
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
//nativo
var nodes = document.querySelectorAll("span.nome"),
elems= Array.prototype.slice.call(nodes);
elems.forEach(function(element, index) {
element.innerText= "Olá: "+ index;
});
Victor Cavalcante @vcavalcante
//jquery
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
//nativo
function $t(selector) {
return [].slice.call(document.querySelectorAll(selector));
}
$t("span.nome").forEach(function(element, index) {
element.innerText= "Olá: "+ index;
});
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
//jQuery
$(el).fadeIn();
//Nativo
function fadeIn(el) {
el.style.opacity = 0;
var last = +new Date();
var tick = function() {
el.style.opacity = +el.style.opacity + (new Date() - last) / 400;
last = +new Date();
if (+el.style.opacity < 1) {
(window.requestAnimationFrame && requestAnimationFrame(tick)) ||
setTimeout(tick, 16)
}
};
tick();
}
fadeIn(el);
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
.easeInSine {
width: 399px;
-webkit-transition: all 600ms cubic-bezier(0.47, 0, 0.745, 0.715);
transition: all 600ms cubic-bezier(0.47, 0, 0.745, 0.715);
}
.easeOutSine{
width: 399px;
-webkit-transition: all 600ms cubic-bezier(0.39, 0.575, 0.565, 1);
transition: all 600ms cubic-bezier(0.39, 0.575, 0.565, 1);
}
.easeInOutBack{
width: 399px;
-webkit-transition: all 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
Victor Cavalcante @vcavalcante
var xhr= new XMLHttpRequest();
xhr.open("POST", "/caminho/json/", true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onload= function() {
if(this.status=== 200) { alert(this.responseText); }
};
xhr.send("category=books&sort=asc");
Victor Cavalcante @vcavalcante
var formData= new FormData(), xhr= new XMLHttpRequest();
formData.append("category", "books");
formData.append("sort", "asc");
xhr.open("POST", "/caminho/json/", true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onload= function() {
if(this.status=== 200) { alert(this.responseText); }
};
xhr.send(formData);
Victor Cavalcante @vcavalcante
var form = document.getElementById("myForm");
var formData= newFormData(form);
var xhr= newXMLHttpRequest();
xhr.open("POST", "/caminho/json/", true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onload= function() {
if(this.status=== 200) { alert(this.responseText); }
};
xhr.send(formData);
Victor Cavalcante @vcavalcante
if(Element && !Element.prototype.matches) {
var proto = Element.prototype;
proto.matches= proto.matchesSelector||
proto.mozMatchesSelector||
proto.msMatchesSelector||
proto.oMatchesSelector||
proto.webkitMatchesSelector;
}
document.querySelector("li").matches("ul li")
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Ajax
Animação
Extenção
Elementos
Encontre Elementos
Eventos
Victor Cavalcante @vcavalcante
Dá para ser menor!
Victor Cavalcante @vcavalcante
> git clone git://github.com/jquery/jquery.git
>
> npm install -g grunt-cli bower
>
> grunt -version && bower -version
>
> cd jquery&& npm install
>
> grunt
>
> grunt custom:-sizzle,-ajax,-css,-deprecated
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
victor@cavalcante.net