42
V UGI ALT.Net Conference Milano :: 23 Gennaio 2010 andreabalducci {ecosystem}

jQuery Ecosystem

Embed Size (px)

DESCRIPTION

Presentation for http://www.ugialt.net/V UgiALT.net Conference.ashx

Citation preview

Page 1: jQuery Ecosystem

V UGI ALT.Net Conference Milano :: 23 Gennaio 2010

andreabalducci

{ecosystem}

Page 2: jQuery Ecosystem

Andrea Balducci

Job: Sviluppatore per passione (da un quarto di secolo…)

Mercato: Applicazioni client / server in c++ per la PMI

[email protected]

http://www.dotnetmarche.org/blogs/andreabalducci

Chi è costui?

andreabalducci

Asp.Net: Catasto Termico, MES

Page 3: jQuery Ecosystem

Agenda

jQuery intro

jQuery UI

QUnit

jQuery Lint

TestSwarm

Profiling

Page 4: jQuery Ecosystem

jQuery

jQuery

è una libreria

JavaScript

http:

//w

ww

.gra

cesm

ith.c

o.uk

/86-

jque

ry-r

esou

rces

-to-

spic

e-up

-you

r-w

ebsi

te/

Page 5: jQuery Ecosystem

jQuery

Creata da John Resig nel 2006

http://ejohn.org

Page 6: jQuery Ecosystem

jQuery

Page 7: jQuery Ecosystem

jQuery

Top 10.000 websites

jQuery 20%

Page 8: jQuery Ecosystem

jQueryhtt

p://

tren

ds.b

uiltw

ith.c

om/j

avas

crip

t

jQuery è presente nel 37% dei siti web che utilizzano Javascript

Page 9: jQuery Ecosystem

jQuery 1.4

http:

//jq

uery

14.c

om

Page 10: jQuery Ecosystem

jQuery

Cross browserSuite di 3060 test (Safari 3.2, Safari 4, Firefox 2, Firefox 3, Firefox 3.5, IE 6, IE 7, IE 8, Opera 10.10 and Chrome).50 browser su 11 piattaforme.

Modello ad eventi.click() .mouseenter() .keydown() etc..

LeggeraSolo 23kb per la versione minified (gzipped).Disponibile sulle CDN Google e Microsoft

Page 11: jQuery Ecosystem

jQueryCentinaia di plug-in già prontiForms, validation, autocomplete, grid, jQuery.UI, gameshttp://plugins.jquery.com/

Documentatahttp://api.jquery.com/<method>http://forum.jquery.com/

Visual jQueryhttp://visualjquery.com/

Delicious bookmarks1.123k+ http://delicious.com/tag/jquery

Page 12: jQuery Ecosystem

jQuery

Google ha 12.900.000 risultati per il termine “jQuery”10 volte più famosa della D’Addario e del Lettone di Putin

Page 13: jQuery Ecosystem

Come funziona?

$(document).ready(function() {$(‘li’).css(‘color’, ‘red’);

)};

Page 14: jQuery Ecosystem

Come funziona?

jQuery

$(document).ready(function() {$(‘li’).css(‘color’, ‘red’);

)};

Page 15: jQuery Ecosystem

Come funziona?

jQuery find things

$(document).ready(function() {$(‘li’).css(‘color’, ‘red’);

)};

Page 16: jQuery Ecosystem

Come funziona?

jQuery find things do stuff

$(document).ready(function() {$(‘li’).css(‘color’, ‘red’);

)};

Page 17: jQuery Ecosystem

Categorie

Selettori

Eventi

Manipolazione del DOM

Ajax

Data

Navigazione del DOM

Page 18: jQuery Ecosystem

jQuery(document).ready(..);

L’entry point di jQuery

Viene eseguito appena il DOM è completo e prima che il contenuto della pagina sia caricato.

E’ possibile registrare l’evento $(document).ready() più volte

Versione breve: $(..);

Page 19: jQuery Ecosystem

Selettori

http://api.jquery.com/category/selectors/

Basic

* All Selector Seleziona tutti gli elementi

.classname Class Selector Seleziona tutti gli elementi sulla base della classe css

Element Element selector Seleziona gli elementi in base al tag

#id ID Selector Seleziona l’elemento con l’id indicato

selector1, selector2 Multiple Selector Seleziona l’insieme degli elementi che soddisfano i selettori (+)

Attribute :: Basic :: Basic Filter :: Child Filter :: Content FilterForm :: Hierarchy :: Visibility Filter

Live test: http://codylindley.com/jqueryselectors/

Page 20: jQuery Ecosystem

Eventi

jQuery introduce il modello ad eventi in modo non intrusivo; il binding degli eventi avviene fuori dal markup dell’elemento.

<html><head><title>Modello ad eventi - click</title> <script src="jquery-1.4.min.js" type="text/javascript"> </script> <script type="text/javascript">

$(document).ready(function() {$('#clickme').click(function(){

$(this).remove();});

}); </script></head><body> <a id="clickme" href="#">click me</a></body></html>

http://api.jquery.com/category/events/

Page 21: jQuery Ecosystem

Manipolazione DOM

Struttura $(‘<div>’) $(‘.clickMe’).remove(); $(‘.clickMe’).clone(); $(‘<div>’).appendTo($(‘#box’));

http://api.jquery.com/category/manipulation/

Attributi $(‘.clickMe’).addClass(‘clicked’); $(‘.clickMe’).attr(‘id’, ‘theone’);

Stile $(‘.clickMe’).css(‘color’, ‘red’);

Lettura / scrittura $(‘#title’).text(‘jQuery @Ugi.Alt’); var title = $(‘#title’).text();

Page 22: jQuery Ecosystem

$.ajax()Low level jQuery.ajax( settings ) // http://api.jquery.com/jQuery.ajax/

http://api.jquery.com/category/ajax/

Shorthand MethodsjQuery.get() esegue una richiesta tramite HTTP GET

jQuery.getJSON() esegue una richiesta di dati in formato JSON tramite HTTP GET

jQuery.getScript() carica uno script tramite una GET e lo esegue

.load() esegue la richiesta al server e inserire la risposta nell’elemento

jQuery.post() esegue la richiesta tramite una POST

Page 23: jQuery Ecosystem

.data()

http://api.jquery.com/data/

.data() permette di associare dei valori agli elementi del DOM senza sporcare il markup.

.data(key, value) $(‘#contact-1’).data(‘name’, ‘Andrea’); $(‘#contact-1’).data(‘age’, 35);

.data(key) var name = $(‘#contact-1’).data(‘name’);

.data() var contact = $(‘#contact-1’).data(); // { name: ‘Andrea’, age: 35}

Page 24: jQuery Ecosystem

Effects

http://api.jquery.com/category/effects/

{demo}

Page 25: jQuery Ecosystem

Navigazione del DOM

http://api.jquery.com/category/traversing/

.add()

.andSelf()

.children()

.closest()

.contents()

.end()

.eq()

.filter()

.find()

.first()

.has()

.is()

.last()

.map()

.next()

.nextAll()

.nextUntil()

.not()

.offsetParent()

.parent()

.parents()

.parentsUntil()

.prev()

.prevAll()

.prevUntil()

.siblings()

.slice()

Page 26: jQuery Ecosystem
Page 27: jQuery Ecosystem

“jQuery UI provides a comprehensive set of core interaction plugins, UI widgets and visual effects that use a jQuery-style, event-driven architecture and a focus on web standards, accessiblity, flexible styling, and user-friendly design.All plugins are tested for compatibility in IE 6.0+, FF 2+, Safari 3.1+, Opera 9.0+, and Google Chrome.”

Page 28: jQuery Ecosystem

In fase di rilascio la versione 1.8

Page 29: jQuery Ecosystem

Roadmap su http://wiki.jqueryui.com/

Interactions Draggable Droppable Resizable Selectable Sortable

Widgets Accordion Autocomplete Button Datepicker Dialog Progressbar Slider Tabs

Effects Add class Remove class Switch class Toggle class Show Hide Toggle Animate Effect

Page 30: jQuery Ecosystem

{demo}

Page 31: jQuery Ecosystem

Case Study – Catasto termico

Sostiuzione di Asp.Net AJAX Control Toolkit

Aumentata l’interattività lato client

Dimezzato il peso delle pagine

Page 32: jQuery Ecosystem

Ovvero…

Prima Dopo

Page 33: jQuery Ecosystem

ThemeRoller

http://jqueryui.com/themeroller/

ThemeRoller permette di configurare a proprio piacimento i temi di jQuery.ui

jQuery.UI = js + css

Page 34: jQuery Ecosystem

QUnit“QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery project to test its code and plugins but is capable of testing any generic JavaScript code”

http://docs.jquery.com/QUnit

Page 35: jQuery Ecosystem

QUnit

http://docs.jquery.com/QUnit

{demo}

Page 36: jQuery Ecosystem

jQuery.Lint“jQuery Lint is a simple script you can download and use with jQuery. It works over the top of jQuery and diligently reports errors and any incorrect usage of jQuery. It will also, to some extent, offer guidance on best practices and performance concerns”.

http://github.com/jamespadolsey/jQuery-Lint

Page 37: jQuery Ecosystem

jQuery.Lint

http://github.com/jamespadolsey/jQuery-Lint

{demo}

Page 38: jQuery Ecosystem

TestSwarm

http://testswarm.com/

“The primary goal of TestSwarm is to take the complicated, and time-consuming, process of running JavaScript test suites in multiple browsers and to grossly simplify it. It achieves this goal by providing all the tools necessary for creating a continuous integration workflow for your JavaScript project.”

Page 39: jQuery Ecosystem

I Want U

Page 40: jQuery Ecosystem

Performance Analysis

http://developer.yahoo.com/yui/theater/video.php?v=resig-testing

{demo}

Page 41: jQuery Ecosystem

{spot :: coming soon}

Dexter, jQuery, Castle Windsor, Asp.Net MVC, NHibernate & co…

Page 42: jQuery Ecosystem

{grazie}

andreabalducci