JQUERY SANS JQUERY Raphaël Rougeron / @goldoraf



Similar documents
Essential HTML & CSS for WordPress. Mark Raymond Luminys, Inc mraymond@luminys.com

HTML5 & Friends. And How They Change A Developer s Life

Programming in HTML5 with JavaScript and CSS3

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

CIS 467/602-01: Data Visualization

CMSC434 TUTORIAL #3 HTML CSS JavaScript Jquery Ajax + Google AppEngine Mobile WebApp HTML5

Dashboard Skin Tutorial. For ETS2 HTML5 Mobile Dashboard v3.0.2

Contents. Downloading the Data Files Centering Page Elements... 6

Upgrade to Microsoft Web Applications

The purpose of jquery is to make it much easier to use JavaScript on your website.

jquery Tutorial for Beginners: Nothing But the Goods

Web - Travaux Pratiques 1

Mobile Web Applications using HTML5. L. Cotfas 14 Dec. 2011

Example. Represent this as XML

Progressive Enhancement With GQuery and GWT. Ray Cromwell

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

MASTERTAG DEVELOPER GUIDE

Web layout guidelines for daughter sites of Scotland s Environment

Website Login Integration

Making Web Application using Tizen Web UI Framework. Koeun Choi

Introduction to web development and JavaScript

Web Development Recipes

Yandex.Widgets Quick start

Web Same-Origin-Policy Exploration Lab

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Quick Setup Guide. HTML Signatures. A short guide on how to set up HTML Signatures on LetMC s. Last updated 22/11/2012

The CloudBrowser Web Application Framework

Using jquery and CSS to Gain Easy Wins in CiviCRM

HTML5 and CSS3. new semantic elements advanced form support CSS3 features other HTML5 features

1. User Guide API overview addon - xml Definition addon.background addon.background.script

Script Handbook for Interactive Scientific Website Building

UComment. UComment is a comment component for Umbraco, it makes it very easy to add comment functionality to any Umbraco content document you wish.

^/ CS> KRIS. JAMSA, PhD, MBA. y» A- JONES & BARTLETT LEARNING

HAML und SASS. (und COMPASS) markup haiku vs. syntactically awesome stylesheets. Tobias Adam, Jan Krutisch mindmatters GmbH & Co.

Dart and Web Components - Scalable, Structured Web Apps

Unlocking the Java EE Platform with HTML 5

Ready, Set, Go Getting started with Tuscany

Subject Tool Remarks What is JQuery. Slide Javascript Library

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

This document will describe how you can create your own, fully responsive. drag and drop template to use in the creator.

Mobile Web Site Style Guide

Coding HTML Tips, Tricks and Best Practices

Beginning Web Development with Node.js

The Essential Guide to HTML Design

Interactive HTML Reporting Using D3 Naushad Pasha Puliyambalath Ph.D., Nationwide Insurance, Columbus, OH

Responsive Web Design Creative License

Performance Testing for Ajax Applications

JJY s Joomla 1.5 Template Design Tutorial:

CSS : petits compléments

HTML CSS Basic Structure. HTML Structure [Source Code] CSS Structure [Cascading Styles] DIV or ID Tags and Classes. The BOX MODEL

The Essential Guide to HTML Design

THE SAS OUTPUT DELIVERY SYSTEM: BOLDLY TAKE YOUR WEB PAGES WHERE THEY HAVE NEVER GONE BEFORE! CHEVELL PARKER, SAS INSTITUTE INC.

Learnem.com. Web Development Course Series. Quickly Learn. Web Design Using HTML. By: Siamak Sarmady

Modern Web Development:

DIPLOMA IN WEBDEVELOPMENT

HTML and CSS. Elliot Davies. April 10th,

Introduction to Web Development

jquery Sliding Image Gallery

Introduction to the. Barracuda Embedded Web-Server

Create interactive web graphics out of your SAS or R datasets

Investigation Report Regarding Security Issues of Web Applications Using HTML5

Mobile Web Design with HTML5, CSS3, JavaScript and JQuery Mobile Training BSP-2256 Length: 5 days Price: $ 2,895.00

Sizmek Formats. HTML5 Page Skin. Build Guide

NoSQL web apps. w/ MongoDB, Node.js, AngularJS. Dr. Gerd Jungbluth, NoSQL UG Cologne,

07/04/2014 NOBIL API. Version 3.0. Skåland Webservice Side 1 / 16

Blackbox Reversing of XSS Filters

Web Authoring CSS. Module Descriptor

Website Builder Documentation

Pliki.tpl. boxes/facebooklike/box.tpl. boxes/login/box.tpl. boxes/pricelist/box.tpl

( François Agneray. Octobre 2012

CLASSROOM WEB DESIGNING COURSE

maximizing IT productivity

Getting Started Guide

WEB DEVELOPMENT COURSE (PHP/ MYSQL)

NetFlow for SouthWare NetLink

Chapter 1. Introduction to web development

USER S MANUAL JOOMLA! GOVERNMENT WEB TEMPLATE

Coding Standards for Web Development

Google Web Toolkit. Progetto di Applicazioni Software a.a. 2011/12. Massimo Mecella

Magic Liquidizer Documentation

Web Design and Development ACS Chapter 13. Using Forms 11/30/2015 1

Basics of HTML Canvas. Material taken from CSCU9B2

ITNP43: HTML Lecture 4

Network Performance Evaluation within the Web Browser Sandbox

HTML5 & CSS3. Jens Jäger Freiberuflicher Softwareentwickler JavaEE, Ruby on Rails, Webstuff Blog: Mail: mail@jensjaeger.

Transcription:

JQUERY SANS JQUERY Raphaël Rougeron / @goldoraf

JAVASCRIPT IL Y A 10 ANS

2006

JQUERY AUJOURD'HUI 92,2%

POLYFILLING if ('queryselector' in document && 'localstorage' in window && 'addeventlistener' in window) { // Go! } else { // Polyfill all the things... }

if (Modernizr.localStorage) { // Go! } else { // Polyfill all the things... } MODERNIZR

PREMIER EXEMPLE $("button.continue").html("next Step...")

DOCUMENT getelementbyid getelementsbytagname getelementsbyclassname queryselector queryselectorall

document.queryselector >= 8 >= 3.5 >= 1 >= 3.2 >= 10

$("button.continue").html("next Step..."); document.queryselector("button.continue").innerhtml = "Next Step...";

$("button.continue").html("next Step..."); document.queryselector("button.continue").innerhtml = "Next Step..."; Et que se passe t-il si le sélecteur ne correspond à aucun élément?

Uncaught TypeError: Cannot set property 'innerhtml' of null

DEUXIÈME EXEMPLE var hiddenbox = $("#banner-message"); $("#button-container button").on("click", function(event) { hiddenbox.show(); });

addeventlistener var hiddenbox = document.getelementbyid("#banner-message"); document.queryselector("#button-container button").addeventlistener("click", function(event) { hiddenbox.setattribute("style", "display: block"); }, false);

addeventlistener >= 9 >= 1 >= 1 >= 1 >= 7

PLUS VERBEUX? var $ = document.queryselector.bind(document); Element.prototype.on = Element.prototype.addEventListener; var hiddenbox = $("#banner-message"); $("#button-container button").on("click", function(event) { hiddenbox.setattribute("style", "display: block"); });

Element.className hiddenbox.classname += ' hidden'; hiddenbox.classname.replace('hidden', '');

Element.classList hiddenbox.classlist.add('hidden'); hiddenbox.classlist.remove('hidden'); var hiddenbox = $("#banner-message"); $("#button-container button").on("click", function(event) { hiddenbox.classlist.toggle('hidden'); });

Element.classList >= 10 >= 3.6 >= 8 >= 5.1 >= 11.5

insertadjacenthtml $('#box').before('<p>test</p>'); $('#box').after('<p>test</p>'); $('#box').append('<p>test</p>'); $('#box').prepend('<p>test</p>'); $('#box').insertadjacenthtml('beforebegin', '<p>test</p>'); $('#box').insertadjacenthtml('afterend', '<p>test</p>'); $('#box').insertadjacenthtml('beforeend', '<p>test</p>'); $('#box').insertadjacenthtml('afterbegin', '<p>test</p>');

DocumentFragment var tags = ['foo', 'bar', 'baz'], fragment = document.createdocumentfragment(); tags.foreach(function(tag) { var li = document.createelement('li'); li.textcontent = tag; fragment.appendchild(li); }); var ul = document.queryselector('ul'); ul.appendchild(fragment);

TABLE API insertrow() deleterow() insertcell() deletecell() createcaption() deletecaption() createthead()...

TROISIÈME EXEMPLE $.ajax({ url: "/api/getweather", data: { zipcode: 97201 }, success: function(data) { $("#weather-temp").html("<strong>" + data + "</strong> degrees"); } });

XMLHttpRequest var xhr = new XMLHttpRequest(), data = [], rawdata = { zipcode: 97201 }; for (var k in rawdata) { data.push(encodeuricomponent(k) + "=" + encodeuricomponent(rawdata[k])); } xhr.open("get", "/api/getweather"); xhr.onload = function () { document.queryselector("#weather-temp").innerhtml = "<strong>" + xhr.response + "</strong> degrees"; }; xhr.send(data.join("&"));

XMLHttpRequest et FormData var xhr = new XMLHttpRequest(), data = new FormData(), rawdata = { zipcode: 97201 }; for (var k in rawdata) { data.append(k, JSON.stringify(rawData[k])); } xhr.open("get", "/api/getweather"); xhr.onload = function () { document.queryselector("#weather-temp").innerhtml = "<strong>" + xhr.response + "</strong> degrees"; }; xhr.send(data);

XMLHttpRequest et FormData var xhr = new XMLHttpRequest(), data = new FormData(document.querySelector("#zipcode")); xhr.open("get", "/api/getweather"); xhr.onload = function () { document.queryselector("#weather-temp").innerhtml = "<strong>" + xhr.response + "</strong> degrees"; }; xhr.send(data);

FormData >= 10 >= 4 >= 7 >= 12 >= 5

CALLBACK HELL $('#demo5').animo("rotate", { degrees:90 }, function(e) { e.element.animo( { animation: "flipoutx", keep: true } ); $('#demo6').animo("rotate", { degrees:90 }, function(e) { e.element.animo( { animation: "flipouty", keep: true } ); $('#demo7').animo("rotate", { degrees:90 }, function(e) { e.element.animo( { animation: "flipoutx", keep: true } ); $('#demo8').animo("rotate", { degrees:90 }, function(e){ e.element.animo( { animation: "flipouty", keep: true } ); }); }); }); });

JQUERY DEFERREDS $.ajax({ url: "/api/getweather", data: { zipcode: 97201 } }).done(function(data) { $("#weather-temp").html("<strong>" + data + "</strong> degrees"); }).fail(function() { alert("error"); });

PROMISES/A+ gettweetsfor("goldoraf", function (err, results) {... }); var promisefortweets = gettweetsfor("goldoraf"); promisefortweets.then(function(results) {... }); then(fulfilledhandler, errorhandler, progresshandler)

PROMISES & XHR function request(type, url, data) { return new Promise(function (resolve, reject) { var xhr = new XMLHttpRequest; xhr.addeventlistener("error", reject); xhr.addeventlistener("load", resolve); xhr.open("get", url); xhr.send(null); }); }

RÉSULTAT FINAL request("get", "/api/getweather", data).then(function(result) { document.queryselector("#weather-temp").innerhtml = "<strong>" + result + "</strong> degrees"; });

CALLBACK HELL PROMISE HEAVEN $('#demo5').animo("rotate", { degrees:90 }).then(function(e) { e.element.animo({ animation: "flipoutx", keep: true }); return $('#demo6').animo("rotate", { degrees:90 }); }).then(function(e) { e.element.animo({ animation: "flipouty", keep: true }); return $('#demo7').animo("rotate", { degrees:90 }); }).then(function(e) { e.element.animo({ animation: "flipoutx", keep: true }); return $('#demo8').animo("rotate", { degrees:90 }); }).then(function(e){ e.element.animo({ animation: "flipouty", keep: true }); });

$("#book").animate({ left: "+=50" }, 5000, function() { // Animation complete. }); ANIMATIONS

requestanimationframe >= 10 >= 4 >= 10 >= 6 >= 15

requestanimationframe var start = null, d = document.getelementbyid("#book"); function step(timestamp) { var progress; if (start === null) start = timestamp; progress = timestamp - start; d.style.left = Math.min(progress/100, 50) + "px"; if (progress < 5000) { requestanimationframe(step); } } requestanimationframe(step); http://www.html5rocks.com/en/tutorials/speed/rendering/

TRANSITIONS CSS3 button.foo { font-size: 40px; background: #C9C9C9; transition-property: background; -moz-transition-property: background; -webkit-transition-property: background; -o-transition-property: background; transition-duration: 500ms; -webkit-transition-duration: 500ms; } button.foo:hover { background: #959595; color: #FFF; } Hello

ANIMATIONS CSS3 @keyframes 'my-animation' { 0% { background: #C9C9C9; } 50% { background: #61BE50; } 100% { background: #C9C9C9; } } button.bar:hover { background: #959595; color: #FFF; Hello } animation-name: 'my-animation'; animation-duration: 2s; animation-iteration-count: infinite;

transitionend function whichtransitionevent(el){ var t, transitions = { 'transition':'transitionend', 'OTransition':'oTransitionEnd', 'MozTransition':'transitionend', 'WebkitTransition':'webkitTransitionEnd' } } for (t in transitions) { if (el.style[t]!== undefined) { return transitions[t]; } }

transitionend var transitionend = whichtransitionevent(element); element.addeventlistener(transitionend, function(event) { // on déclenche l'animation suivante! element.classlist.add('expand'); });

WEB COMPONENTS UN MODÈLE DE COMPOSANT POUR LE WEB

TEMPLATES <template id="commenttemplate"> <div> <img src=""> <div class="comment-text"></div> </div> </template> var tpl = document.queryselector("#commenttemplate"); tpl.content.queryselector(".comment-text").innerhtml =...; document.body.appendchild(tpl.content.clonenode(true));

DECORATORS <decorator id="modal-controls"> <template> <section> <header> <a id="toggle" href="#">maximize</a> <a id="close" href="#">close</a> </header> <content></content> </section> </template> </decorator>.my-modal { decorator: url(#modal-controls); }

CUSTOM ELEMENTS <element extends="button" name="my-button" attributes="foo bar"> <template>...</template> <script>... </script> </element>

SHADOW DOM HTML IMPORTS <link rel="import" href="my-component.html">

WEB COMPONENTS AVEC X-TAG >= 9 >= 5 >= 4 >= 4 >= 11

<browser-compat ie="9" ff="5" cr="4" sa="4" op="11" /> UN EXEMPLE?

UN EXEMPLE? <polymer-element name="browser-compat" attributes="ie ff cr sa op"> <template> <style>... </style> <table class="browser-compat"> <tr> <td><img src="images/ie.png" /></td>... </tr> <tr> <td class="{{ie_class}}">>= {{ie}}</td>... </tr> </table> </template> <script>... </script> </polymer-element>

UN EXEMPLE? Polymer('browser-compat', { created: function() { switch(parseint(this.ie)) { case 10: this.ie_class = 'red'; break; case 9: this.ie_class = 'yellow'; break; default: this.ie_class = 'green'; break; } } });

CODEZ POUR LE FUTUR! Copyright Steve Thomas Art & Illustration, LLC