SlideShare una empresa de Scribd logo
1 de 96
Inside jQuery
   Kenneth Auchenberg




Inside jQuery           @auchenberg kenneth.io
Inside jQuery
   Kenneth Auchenberg




                        Twitter       Blog


Inside jQuery                     @auchenberg kenneth.io
About me
                          Bah



Inside jQuery     @auchenberg kenneth.io
Agenda




Inside jQuery   @auchenberg kenneth.io
The basics.

         jQuery.

         Go Go Go!




Inside jQuery          @auchenberg kenneth.io
The basics




Inside jQuery      @auchenberg kenneth.io
Browsers



Inside jQuery     @auchenberg kenneth.io
BOM vs. DOM?




Inside jQuery                  @auchenberg kenneth.io
Document

        Location

        History

        Frames
                                    BOM
        Navigator   Browser Object Model



Inside jQuery                   @auchenberg kenneth.io
HTML
                                  DOM
                 Document Object Model



Inside jQuery                 @auchenberg kenneth.io
SVG DOM
        Scalable Vector Graphics


        MathML DOM
        Mathematical Markup Langugage


        SMIL DOM
        Synchronized Multimedia Integration Language




                                                           DOM
                                        Document Object Model



Inside jQuery                                          @auchenberg kenneth.io
domReady vs. onLoad?




Inside jQuery           @auchenberg kenneth.io
domReady vs. onLoad?
  DOMcontentLoaded vs. onLoad?



Inside jQuery           @auchenberg kenneth.io
Closure Library




                            Frameworks
                                  Abstractions



Inside jQuery                         @auchenberg kenneth.io
Inside jQuery   @auchenberg kenneth.io
“ Looking at how Behaviour works, I've never
               been completely happy - it simply seems too
               tedious and verbose for everyday ”



                                                               John Resig
                                                              December 2005
  Quote from http://ejohn.org/blog/selectors-in-javascript/




Inside jQuery                                                      @auchenberg kenneth.io
A: Behaviour                               B: pre-jQuery
 

Behaviour.register({                       $('#example
li').bind('click',function(){
 



'#example
li':
function(e){              



this.parentNode.removeChild(this);
 





e.onclick
=
function(){                });
 







this.parentNode.removeChild(this);
 





}
 



}
 

});



   A:
Behaviour.register({'':function(e){e.on=}});

   B:
$('').bind('',);



                                                                        Syntax



Inside jQuery                                                            @auchenberg kenneth.io
A: Behaviour                                    B: pre-jQuery
 

Behaviour.register({                            $('#foo
ol
li')
 



'#foo
ol
li':
function(a)
{                   
.set('title','List
Items!')
 





a.title
=
"List
Items!";                    
.bind('click',function(){alert('Hello!');})
 





a.onclick
=
function(){alert('Hello!');};   



.select('.tmp')
 



},                                            





.style('color','white')
 



'#foo
ol
li.tmp':
function(a)
{               





.select('.foo')
 





a.style.color
=
'white';                    







.style('background','red');
 



},
 



'#foo
ol
li.tmp
.foo':
function(a)
{
 





a.style.background
=
'red';
 



}
 

});


   A:
Behaviour.register({'':function(a){a.=;a.on=;},'#foo
ol
li':function(a){a.style.='';},
   B:
$('').set('','').bind('',).select('').style('','').select('').style('','');




Inside jQuery                                                                 @auchenberg kenneth.io
jQuery


                                                                                                                                    Prototype




                                                                                                                                         Trend
                                                                                                                    October 2010
 Scale is based on the average worldwide traffic of jquery javascript from 2004 to 2010.
 Source: http://www.google.com/trends?q=dojo+javascript,+jquery+javascript,+yui+javascript,+prototype+javascript,+mootools+javascript&ctab=0&geo=all&date=all&sort=1




Inside jQuery                                                                                                                       @auchenberg kenneth.io
Prototype




                                                  jQuery                                                                                      Usage
                                                                                                                          October 2010
 Distribution is calculated from a cross section of website domains provided by URLs entered at BuiltWith.com and the Quantcast Top Million. Last calculated on October 19 2010.
 Source: http://trends.builtwith.com/javascript




Inside jQuery                                                                                                                               @auchenberg kenneth.io
$?

Inside jQuery        @auchenberg kenneth.io
var $ = ‘Hello World’;

     var € = ‘Hello World’;

     var @ = ‘Hello World’;
     var _ = ‘Hello World’;
                              Identifies Names



Inside jQuery                         @auchenberg kenneth.io
“
   7.6 Identifier Names and Identifiers
   Identifier Names are tokens that are interpreted according
   to the grammar given in the “Identifiers” section of chapter
   5 of the Unicode standard, with some small modifications.
   An Identifier is an IdentifierName that is not a
   ReservedWord (see 7.6.1). The Unicode identifier
   grammar is based on both normative and informative
   character categories specified by the Unicode Standard.
   The characters in the specified categories in version 3.0
   of the Unicode standard must be treated as in those
   categories by all conforming ECMAScript
   implementations.

   This standard specifies specific character additions: The
   dollar sign ($) and the underscore (_) are permitted
   anywhere in an IdentifierName.                                  ECMA-262
   …”


  Quote from Standard ECMA-262 ECMAScript Language Specification




Inside jQuery                                                        @auchenberg kenneth.io
Utilities   Traversing    Attributes        Effects



     Core       Selectors    Manipulation        CSS      Events              Ajax



                                       jQuery



                                                                   jQuery



Inside jQuery                                                      @auchenberg kenneth.io
Selectors & Performance

                Events & Delegation

                AJAX & Communication

                Extensions & Community


Inside jQuery                          @auchenberg kenneth.io
Which browsers does
             jQuery support?



Inside jQuery              @auchenberg kenneth.io
3.0+


                                                  9.0+

                2.0+

                              6.0+
                                     Browsers
                       1.0+



Inside jQuery                           @auchenberg kenneth.io
Getting started



Inside jQuery           @auchenberg kenneth.io
<!DOCTYPE
html>
  <html>
  
 <head>
  
 



<title>jQuery</title>
  
 </head>
  

  
 <body></body>
  

  
 <script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/
  jquery/1.4.3/jquery.min.js"></script>
  </html>




                                                                       Inject



Inside jQuery                                                       @auchenberg kenneth.io
$(document).ready(function()
{
   
 


//
Go
mental
   }(;




                                     Ready



Inside jQuery                       @auchenberg kenneth.io
jQuery code begins $
  followed by a selector
  and ends with action(s)
   $(’div’).addClass(‘kenneth’);

   $(’div.groups‐panel’).addClass(‘kenneth’).find(’span:first‐
   child’).text(‘rocks’).show();




Inside jQuery                                     @auchenberg kenneth.io
Selectors and actions can be attached to
 events.
  $(’body’).click(function()
{
  
 


$(’div’).addClass(‘kenneth’)
;
  });


  $(’body’).live(’click’,
function()
{
  
 


$(’div’).addClass(‘kenneth’)
;
  });




Inside jQuery                            @auchenberg kenneth.io
Selectors



Inside jQuery     @auchenberg kenneth.io
document.getElementById('header')


   document.getElementsByTagName('p')


   document.getElementsByClassName(‘.hey’)


   'body
>
div.wrapper
>
section'?




                                             Browser selectors



Inside jQuery                                          @auchenberg kenneth.io
document.getElementById('header')


   document.getElementsByTagName('p')


   document.getElementsByClassName(‘.hey’)


   'body
>
div.wrapper
>
section'?




                                             Browser selectors



Inside jQuery                                          @auchenberg kenneth.io
Selector Engine



Inside jQuery           @auchenberg kenneth.io
Selector Engine



Inside jQuery           @auchenberg kenneth.io
!"#$              ;<"3-)$       ;+=(),"(->)?$   ;()5G+5"&#$
          %&%'%()$          ;&,-)$        ;%'2)B$         ;<"3-)G+5"&#$
          *+&,--$           ;(=)>-%&?$    ;5,->-%&?$      ;&,-)G+5"&#$
          *+&,--*+&,--$     ;%6%($        ;2,3%()$        ;=(&BG+5"&#$
          .$                ;=##$         ;5"##%($
          -%&/0$-%&1$       ;%@>"(#%8?$   ;6"-":&%$       ;"(2H)$
                            ;A)>"(#%8?$                   ;<"&%$
          2,3%()$4$+5"&#$   ;&)>"(#%8?$   .C,))3D$        ;:H))=($
          23%6$7$(%8)$      ;5%,#%3$      .C,))3E6,&D$    ;%(,:&%#$
          23%6$9$-":$       ;,("',)%#$    .C,))3FE6,&D$   ;+5%+I%#$
                                          .C,))DC,))1D$   ;-%&%+)%#$


                                                          Selectors



Inside jQuery                                                  @auchenberg kenneth.io
•   2003.03.25: document.getElementsBySelector() by Simon Willison (later used in behaviour.js)[source]
       •   2004.04.10: CssQuery() 1.0: by Dean Edwards
       •   2005.08.19: CssQuery() 2.0.
       •   2005.08.22: jSelect (precursor to jQuery)
       •   2006.01.14: jQuery first release.
       •   2006.01.18: Prototype. Initial release of selector engine.
       •   2006.04.04: moo.dom (precursor to mootools
       •   2006.08.26: jQuery 1.0
       •   2006.11.14: Mochikit Selector. (orig. ported from prototype)
       •   2007.01.08: jQuery 1.1a ("10-20x faster than 1.0")
       •   2007.01.11: DomQuery by Jack Slocum (ExtJS).
       •   2007.02.05: dojo.query().
       •   2007.03.21: base2.DOM.
       •   2007.05.01: Prototype 1.5.1
       •   2007.05.07: Mootools 1.1
       •   2007.07.01: jQuery 1.1.3 ("800% faster")
       •   2007.07.10: Ext 1.1 RC1
       •
       •
           2007.07.10: Dojo 0.9
           2007.12.04: YUI 2.4.0
                                                                                                              Timeline
       •   2007.12.17: NWMatcher by Diego Perini
       •   2008.08.25: Sizzle.js by John Resig




                                                                        Source: http://paulirish.com/2008/javascript-css-selector-engine-timeline/




Inside jQuery                                                                                                        @auchenberg kenneth.io
Sizzle introduction



Inside jQuery               @auchenberg kenneth.io
Sizzle introduction



Inside jQuery               @auchenberg kenneth.io
if ( document.querySelectorAll ) {
  
    (function(){
  
    
    var oldSizzle = Sizzle, div = document.createElement("div");
  
    
    div.innerHTML = "<p class='TEST'></p>";

  
    
    // Safari can't handle uppercase or unicode characters when
  
    
    // in quirks mode.
  
    
    if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
  
    
    
    return;
  
    
    }
  
  
    
    Sizzle = function(query, context, extra, seed){
  
    
    
    context = context || document;

  
    
    
    // Only use querySelectorAll on non-XML documents
  
    
    
    // (ID selectors don't work in non-HTML documents)
  
    
    
    if ( !seed && !Sizzle.isXML(context) ) {
  
    
    
    
    if ( context.nodeType === 9 ) {
  
    
    
    
    
    try {
  
    
    
    
    
    
     return makeArray( context.querySelectorAll(query), extra );
  
    
    
    
    
    } catch(qsaError) {}




                                                                           querySelectorAll



Inside jQuery                                                                                  @auchenberg kenneth.io
$(ʻheader aʼ)




Inside jQuery                   @auchenberg kenneth.io
$(ʻheader aʼ)

                 document.querySelectorAll(ʻheader aʼ)




                 ????????




                  Selector break-down



Inside jQuery                                @auchenberg kenneth.io
array = [ʻ.headerʼ , ʻaʼ]




Inside jQuery                               @auchenberg kenneth.io
Left to right   Right to left

                  MooTools           Sizzle

                    Ext.JS           YUI 3

                 Prototype.js   querySelectorAll


                                              Direction



Inside jQuery                                      @auchenberg kenneth.io
array = [ʻ.headerʼ , ʻaʼ]




Inside jQuery                               @auchenberg kenneth.io
match:
{
       




ID:
/#((?:[wu00c0‐uFFFF‐]|.)+)/,
       




CLASS:
/.((?:[wu00c0‐uFFFF‐]|.)+)/,
       




NAME:
/[name=['"]*((?:[wu00c0‐uFFFF‐]|.)+)['"]*]/,
       




ATTR:
/[s*((?:[wu00c0‐uFFFF‐]|.)+)s*(?:(S?=)s*(['"]*)(.*?)3|)s*]/,
       




TAG:
/^((?:[wu00c0‐uFFFF*‐]|.)+)/,
       




CHILD:
/:(only|nth|last|first)‐child(?:((even|odd|[dn+‐]*)))?/,
       




POS:
/:(nth|eq|gt|lt|first|last|even|odd)(?:((d*)))?(?=[^‐]|$)/,
       




PSEUDO:
/:((?:[wu00c0‐uFFFF‐]|.)+)(?:((['"]?)((?:([^)]+)|[^()]*)+)2))?/
       },




                                                                                  .find(ʻaʼ)



Inside jQuery                                                                        @auchenberg kenneth.io
TAG:
function(match,
context){
       




return
context.getElementsByTagName(match[1]);
       }




                                                             .find(ʻaʼ)



Inside jQuery                                                 @auchenberg kenneth.io
array = [ʻ.headerʼ , ʻaʼ]




Inside jQuery                               @auchenberg kenneth.io

   
   CLASS:
function(match,
curLoop,
inplace,
result,
not,
isXML){
 
   
   
   match
=
"
"
+
match[1].replace(//g,
"")
+
"
";

 
   
   
    if
(
isXML
)
{
 
   
   
    
   return
match;
 
   
   
    }

 
   
   
   for
(
var
i
=
0,
elem;
(elem
=
curLoop[i])
!=
null;
i++
)
{
 
   
   
   
   if
(
elem
)
{
 
   
   
   
   
   if
(
not
^
(elem.className
&&
("
"
+
elem.className
+
"
").replace(/[tn]/g,
"

 ").indexOf(match)
>=
0)
)
{
 
   
   
   
   
   
    if
(
!inplace
)
{
 
   
   
   
   
   
    
   result.push(
elem
);
 
   
   
   
   
   
    }
 
   
   
   
   
   }
else
if
(
inplace
)
{
 
   
   
   
   
   
    curLoop[i]
=
false;
 
   
   
   
   
   }
 
   
   
   
   }
 
   
   
   }

 

 

     

     

         

         },
              return
false;
                                                                  .find(ʻ.headerʼ)



Inside jQuery                                                                         @auchenberg kenneth.io
$(ʻdiv.me .projectsʼ)

                $(ʻ.me div.projectsʼ)


            http://jsperf.com/sizzle-selector-performance

Inside jQuery                                     @auchenberg kenneth.io
Performance



Inside jQuery        @auchenberg kenneth.io
cache vs. no-cache


                http://jsperf.com/cache-jquery-objects

Inside jQuery                                      @auchenberg kenneth.io
jQuery.each vs. for loop


                http://jsperf.com/jquery-each-vs-for-loop/11


Inside jQuery                                              @auchenberg kenneth.io
jQuery.trim vs. RegExp


                http://jsperf.com/jquery-trim-vs-regexp-trim


Inside jQuery                                              @auchenberg kenneth.io
http://jsperf.com/jquery-htmlencode-vs-string-replace/3


Inside jQuery                                                   @auchenberg kenneth.io
jQuery vs. HtmlEncode


                http://jsperf.com/jquery-htmlencode-vs-string-replace/3


Inside jQuery                                                   @auchenberg kenneth.io
(build) string vs. object

                http://jsperf.com/build-appended-object-test/3


Inside jQuery                                        @auchenberg kenneth.io
Events and delegation




Inside jQuery                 @auchenberg kenneth.io
.bind(eventname,
function)
 
 
 
 .click,
.hover,
.mouseover
  .unbind(eventname)






















.focus,
.submit
  .trigger(eventname,
function)

  .live(eventname,
function)
  .delegate(eventname,
function)




   $(’body’).click(function() {
        $(’div’).addClass(’zyb’) ;
   });
                                                 Events



Inside jQuery                                    @auchenberg kenneth.io
$(’body’).click(function()
{
   
 


$(’div’).addClass(‘kenneth’)
;
   });



   $(’body’).live(‘click’,
function()
{
   
 


$(’div’).addClass(‘kenneth’)
;
   });


   $(’body’).delegate(‘div’,
‘click’,
function()
{
   
 


$(’div’).addClass(‘kenneth’)
;
   });                            Event delegation



Inside jQuery                                        @auchenberg kenneth.io
Event delegation



Inside jQuery            @auchenberg kenneth.io
<ul class="myList">
     <li class="red">The first item.</li>
     <li class="green">The second item.</li>
     <li class="yellow">The third item.</li>
     <li class="blue">The fourth item.</li>
   </ul>
   <p>Class of the last clicked item: <span id="display"> </span></p>


   $(’ul’).click(function(event) {
          if(event.target.nodeName == ”LI”) {
      $(’#display’).text(event.target.className);
     }
   });




                                                     How does it work?



Inside jQuery                                                           @auchenberg kenneth.io
<ul class="myList">
     <li class="red"><b>The <i>first <u>item</u></i></b>.</li>
    
     <li class="green"><b>The <i>second <u>item</u></i></b>.</li>
     <li class="yellow"><b>The <i>third <u>item</u></i></b>.</li>
    
     <li class="blue"><b>The <i>fourth <u>item</u></i></b>.</li>
   </ul>
    
   <p>Class of the last clicked item: <span id="display"> </span></p>
   $("ul").click( function( event ) {
     var elem = event.target;
     while( elem.nodeName != "LI" && elem.parentNode) {
       elem = elem.parentNode;
    }
     if(elem.nodeName == "LI") {
       $("#display").text(event.target.className);
    }
                                                               What if inside?
   });




Inside jQuery                                                           @auchenberg kenneth.io
<ul
class="myList">
   

<li
class="red"><b>The
<i>first
<u>item</u></i></b>.</li>
   

   

<li
class="green"><b>The
<i>second
<u>item</u></i></b>.</li>
   

<li
class="yellow"><b>The
<i>third
<u>item</u></i></b>.</li>
   

   

<li
class="blue"><b>The
<i>fourth
<u>item</u></i></b>.</li>
   </ul>
   

   <p>Class
of
the
last
clicked
item:
<span
id="display">
</span></p>



   $("ul").click(
function(
event
)
{
   

var
$elem
=
$(event.target).closest("li");
   

if($elem.length)
{
   



$("#display").text($elem.attr("class"));
   

}
   });
                                                      Closest to the
                                                            rescue


Inside jQuery                                                           @auchenberg kenneth.io
<ul
class="myList">
   

<li
class="red"><b>The
<i>first
<u>item</u></i></b>.</li>
   

   

<li
class="green"><b>The
<i>second
<u>item</u></i></b>.</li>
   

<li
class="yellow"><b>The
<i>third
<u>item</u></i></b>.</li>
   

   

<li
class="blue"><b>The
<i>fourth
<u>item</u></i></b>.</li>
   </ul>
   

   <p>Class
of
the
last
clicked
item:
<span
id="display">
</span></p>


   $("ul.myList
>
li").live("click",
function(e)
{
   

$("#display").text(
   



$(this).attr("class")
   

);
   });

  $("ul").delegate("li",
"click",
function(e)
{
  

$("#display").text(
                                                     .live & .delegate
  



$(this).attr("class")
  

);
  });




Inside jQuery                                                           @auchenberg kenneth.io
EventHelper
=
(function
(window,
$,
undefined)
{

  

function
proxy_callback(callback,
shouldPreserveDefault,
e)
{
  



var
target
=
$(e.currentTarget);
  



if
(!shouldPreserveDefault)
{
  





e.preventDefault();
  



}
  



callback.apply(this,

  [target].concat(Array.prototype.slice.call(arguments).slice(2)));
  

}

  

function
bind(eventType,
selector,
fn,
shouldPreserveDefault)
{
  



$('body').delegate(selector,
eventType,
proxy_callback.curry(fn,

  shouldPreserveDefault));
  

}

  

function
unbind(eventType,
selector)
{
  



$('body').undelegate(selector,
eventType);
  

}                                                           Wrappers
  })(window,
jQuery);




Inside jQuery                                                         @auchenberg kenneth.io
AJAX/Communication




Inside jQuery              @auchenberg kenneth.io
.ajax(options)

  .get(url,
data,
callback,
dateType)
  .post(url,
data,
callback,
dateType)
  .getJSON(url,
data,
callback,
dateType)
  .getScript(url,
callback)

  .load(url,
data,
callback)


  .ajaxComplete()













.ajaxSetup(options)
  .ajaxStart()
  .ajaxStop()
  .ajaxSuccess()
  .ajaxError()
                                                     Ajax in jQuery



Inside jQuery                                               @auchenberg kenneth.io
.ajax(options)

  .get(url,
data,
callback,
dateType)
  .post(url,
data,
callback,
dateType)
  .getJSON(url,
data,
callback,
dateType)
  .getScript(url,
callback)

  .load(url,
data,
callback)


  .ajaxComplete()













.ajaxSetup(options)
  .ajaxStart()
  .ajaxStop()
  .ajaxSuccess()
  .ajaxError()
                                                     Ajax in jQuery



Inside jQuery                                               @auchenberg kenneth.io
.ajax(options)

  .get(url,
data,
callback,
dateType)
  .post(url,
data,
callback,
dateType)
  .getJSON(url,
data,
callback,
dateType)
  .getScript(url,
callback)

  .load(url,
data,
callback)


  .ajaxComplete()













.ajaxSetup(options)
  .ajaxStart()
  .ajaxStop()
  .ajaxSuccess()
  .ajaxError()
                                                     Ajax in jQuery



Inside jQuery                                               @auchenberg kenneth.io
CORS



Inside jQuery          @auchenberg kenneth.io
CORS
                Cross-Origin Resource Sharing




Inside jQuery                                   @auchenberg kenneth.io
CORS



Inside jQuery          @auchenberg kenneth.io
CORS
                Cross-Origin Resource Sharing




Inside jQuery                                   @auchenberg kenneth.io
Inside jQuery   @auchenberg kenneth.io
Header




Inside jQuery            @auchenberg kenneth.io
Access-Control-Allow-Origin: *
                            Header




Inside jQuery                             @auchenberg kenneth.io
$.get(“http://bar.other/resources/public‐data”,
function()
{
  



console.log(arguments);
  },
“xml”)
  GET /resources/public-data/ HTTP/1.1
  Host: bar.other
  User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081130 Minefield/
  3.1b3pre
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: en-us,en;q=0.5
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 300
  Connection: keep-alive
  Referer: http://foo.example/examples/access-control/simpleXSInvocation.html
  Origin: http://foo.example


  HTTP/1.1 200 OK
  Date: Mon, 01 Dec 2008 00:23:53 GMT
  Server: Apache/2.0.61
  Access-Control-Allow-Origin: *
  Keep-Alive: timeout=2, max=100
  Connection: Keep-Alive
  Transfer-Encoding: chunked
  Content-Type: application/xml

  [XML Data]




Inside jQuery                                                                        @auchenberg kenneth.io
callback=?




Inside jQuery                @auchenberg kenneth.io
TwitterAPI = function() {


      function getUserData(username) {

         $.getJSON('http://twitter.com/status/user_timeline/' + username + '.json?count=10&callback=?', onSucesss);

      }


      function onSuccess(responseData) {

      
     // to render

      }


      return {

      
    getUserData: getUserData

      }

}();

TwitterAPI.getUserData('auchenberg');



                                                                                      JSONP
                                                                           JSON with Padding



Inside jQuery                                                                               @auchenberg kenneth.io
Demo time




Inside jQuery               @auchenberg kenneth.io




function
poll(callback){








$.ajax({












type:
"GET",












url:
”http://localhost:8080/cometd",












timeout:50000,













success:
function(data){
















callback(data);












},












error:
function(XMLHttpRequest,
textStatus,
errorThrown){
















//
Do
the
logging





























}








});




};






setInterval(poll(onPollFinished)),
2000);




                                                                        XHR Polling
                                                                               Old



Inside jQuery                                                            @auchenberg kenneth.io
Chat server
                                   (socket.io)


                XHR Long-polling   XHR Multipart   WebSockets




                       IE            Firefox       Chrome



                                                       Real time



Inside jQuery                                               @auchenberg kenneth.io




function
longPool(callback){








$.ajax({












type:
"GET",












url:
”http://localhost:8080/cometd",












timeout:50000,













success:
function(data){
















callback(data);

 
 
 


longPool(callback);












},












error:
function(XMLHttpRequest,
textStatus,
errorThrown){
















//
Do
the
logging
















longPool(callback);












}








});




};




                                                                 XHR Long Polling
                                                                        HTTP 1.1



Inside jQuery                                                           @auchenberg kenneth.io
MIME‐Version:
1.0                                       HTTP/1.1
200
OK


   Content‐Type:
multipart/mixed;
boundary="frontier"      Content‐Type:
text/plain

                                                           Transfer‐Encoding:
chunked
   This
is
a
message
with
multiple
parts
in
MIME
format.   

   ‐‐frontier                                              25

   Content‐Type:
text/plain                                This
is
the
data
in
the
first
chunk
                                                           

   This
is
the
body
of
the
message.                        1C

   ‐‐frontier                                              and
this
is
the
second
one
   Content‐Type:
application/octet‐stream                  

   Content‐Transfer‐Encoding:
base64                       0


   PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZ




                                                                              XHR Multipart
                                                                                     MIME



Inside jQuery                                                                       @auchenberg kenneth.io
Extend




Inside jQuery   @auchenberg kenneth.io
plugins.jquery.com

                                 community




Inside jQuery                    @auchenberg kenneth.io
jquery.barcode
                          Bloat



Inside jQuery       @auchenberg kenneth.io
(function($) {

  var types = ['DOMMouseScroll', 'mousewheel'];

  $.event.special.mousewheel = {
      setup: function() {
          if ( this.addEventListener ) {
              for ( var i=types.length; i; ) {
                  this.addEventListener( types[--i], handler, false );
              }
          } else {
              this.onmousewheel = handler;
          }
      },
      
      teardown: function() {
          if ( this.removeEventListener ) {
              for ( var i=types.length; i; ) {
                  this.removeEventListener( types[--i], handler, false );
              }
          } else {
              this.onmousewheel = null;
          }
      }
  };

  $.fn.extend({
      mousewheel: function(fn) {
          return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
      },
      
      unmousewheel: function(fn) {
                                                                                     jquery.mouseWheel
          return this.unbind("mousewheel", fn);
      }                                                                                  Custom events
  });



  function handler(event) {
      var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
      event = $.event.fix(orgEvent);
      event.type = "mousewheel";
      
      // Old school scrollwheel delta
Inside jQuery
      if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
                                                                                                          @auchenberg     kenneth.io
      if ( event.detail     ) { delta = -event.detail/3; }
});



  function handler(event) {
      var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
      event = $.event.fix(orgEvent);
      event.type = "mousewheel";
      
      // Old school scrollwheel delta
      if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
      if ( event.detail     ) { delta = -event.detail/3; }
      
      // New school multidimensional scroll (touchpads) deltas
      deltaY = delta;
      
      // Gecko
      if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
          deltaY = 0;
          deltaX = -1*delta;
      }
      
      // Webkit
      if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
      if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
      
      // Add event and delta to the front of the arguments
      args.unshift(event, delta, deltaX, deltaY);
      
      return $.event.handle.apply(this, args);
  }

  })(jQuery);

                                                                                     jquery.mouseWheel
                                                                                         Custom events

                                                                        http://github.com/brandonaaron/jquery-mousewheel



Inside jQuery                                                                                            @auchenberg kenneth.io
var person = {};

          $("form").link(person);
          $("#name").val("foo");

          alert(person.name); // foo
          // ... user changes value ...

          alert(person.name); // <user typed value>
          $(person).data("name", "bar");
          alert($("#name").val()); // bar


                                                     jquery.dataLink
                                                        Databinding

                                            http://github.com/jquery/jquery-datalink



Inside jQuery                                                 @auchenberg kenneth.io
Go Go Go!




Inside jQuery     @auchenberg kenneth.io
Be the cool kid




Inside jQuery          @auchenberg kenneth.io
Thanks



Inside jQuery            @auchenberg kenneth.io

Más contenido relacionado

La actualidad más candente

La actualidad más candente (9)

Learn css3
Learn css3Learn css3
Learn css3
 
Jquery
JqueryJquery
Jquery
 
jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009
 
JavaScript: DOM and jQuery
JavaScript: DOM and jQueryJavaScript: DOM and jQuery
JavaScript: DOM and jQuery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery
jQueryjQuery
jQuery
 
jQuery : Events are where it happens!
jQuery : Events are where it happens!jQuery : Events are where it happens!
jQuery : Events are where it happens!
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery
jQueryjQuery
jQuery
 

Destacado

Destacado (18)

Java script
Java scriptJava script
Java script
 
C++ L02-Conversion+enum+Operators
C++ L02-Conversion+enum+OperatorsC++ L02-Conversion+enum+Operators
C++ L02-Conversion+enum+Operators
 
JSON - Quick Overview
JSON - Quick OverviewJSON - Quick Overview
JSON - Quick Overview
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
 
Fundamental JQuery
Fundamental JQueryFundamental JQuery
Fundamental JQuery
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
HTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryHTML/CSS/java Script/Jquery
HTML/CSS/java Script/Jquery
 
A quick guide to Css and java script
A quick guide to Css and  java scriptA quick guide to Css and  java script
A quick guide to Css and java script
 
Java script
Java scriptJava script
Java script
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
Java script
Java scriptJava script
Java script
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
Java script
Java scriptJava script
Java script
 
Java script
Java scriptJava script
Java script
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 

Similar a Inside jQuery (2011)

JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)jeresig
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)jeresig
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overviewjeresig
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesMark Roden
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overviewjeresig
 
Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do MoreRemy Sharp
 
jQuery and_drupal
jQuery and_drupaljQuery and_drupal
jQuery and_drupalBlackCatWeb
 
Jquery
Jquery Jquery
Jquery eginni
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks TriviaCognizant
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
JQuery Comprehensive Overview
JQuery Comprehensive OverviewJQuery Comprehensive Overview
JQuery Comprehensive OverviewMohamed Loey
 
JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadRuss Fustino
 
Overview on jQuery mobile
Overview on jQuery mobileOverview on jQuery mobile
Overview on jQuery mobileMd. Ziaul Haq
 

Similar a Inside jQuery (2011) (20)

JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)
 
Jquery
JqueryJquery
Jquery
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do More
 
jQuery and_drupal
jQuery and_drupaljQuery and_drupal
jQuery and_drupal
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Jquery
Jquery Jquery
Jquery
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks Trivia
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
jQuery
jQueryjQuery
jQuery
 
JQuery Comprehensive Overview
JQuery Comprehensive OverviewJQuery Comprehensive Overview
JQuery Comprehensive Overview
 
JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) upload
 
Overview on jQuery mobile
Overview on jQuery mobileOverview on jQuery mobile
Overview on jQuery mobile
 

Último

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 

Último (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 

Inside jQuery (2011)

  • 1. Inside jQuery Kenneth Auchenberg Inside jQuery @auchenberg kenneth.io
  • 2. Inside jQuery Kenneth Auchenberg Twitter Blog Inside jQuery @auchenberg kenneth.io
  • 3. About me Bah Inside jQuery @auchenberg kenneth.io
  • 4. Agenda Inside jQuery @auchenberg kenneth.io
  • 5. The basics. jQuery. Go Go Go! Inside jQuery @auchenberg kenneth.io
  • 6. The basics Inside jQuery @auchenberg kenneth.io
  • 7. Browsers Inside jQuery @auchenberg kenneth.io
  • 8. BOM vs. DOM? Inside jQuery @auchenberg kenneth.io
  • 9. Document Location History Frames BOM Navigator Browser Object Model Inside jQuery @auchenberg kenneth.io
  • 10. HTML DOM Document Object Model Inside jQuery @auchenberg kenneth.io
  • 11. SVG DOM Scalable Vector Graphics MathML DOM Mathematical Markup Langugage SMIL DOM Synchronized Multimedia Integration Language DOM Document Object Model Inside jQuery @auchenberg kenneth.io
  • 12. domReady vs. onLoad? Inside jQuery @auchenberg kenneth.io
  • 13. domReady vs. onLoad? DOMcontentLoaded vs. onLoad? Inside jQuery @auchenberg kenneth.io
  • 14. Closure Library Frameworks Abstractions Inside jQuery @auchenberg kenneth.io
  • 15. Inside jQuery @auchenberg kenneth.io
  • 16. “ Looking at how Behaviour works, I've never been completely happy - it simply seems too tedious and verbose for everyday ” John Resig December 2005 Quote from http://ejohn.org/blog/selectors-in-javascript/ Inside jQuery @auchenberg kenneth.io
  • 17. A: Behaviour B: pre-jQuery 

Behaviour.register({ $('#example
li').bind('click',function(){ 



'#example
li':
function(e){ 



this.parentNode.removeChild(this); 





e.onclick
=
function(){ }); 







this.parentNode.removeChild(this); 





} 



} 

}); A:
Behaviour.register({'':function(e){e.on=}});
 B:
$('').bind('',); Syntax Inside jQuery @auchenberg kenneth.io
  • 18. A: Behaviour B: pre-jQuery 

Behaviour.register({ $('#foo
ol
li') 



'#foo
ol
li':
function(a)
{ 
.set('title','List
Items!') 





a.title
=
"List
Items!"; 
.bind('click',function(){alert('Hello!');}) 





a.onclick
=
function(){alert('Hello!');}; 



.select('.tmp') 



}, 





.style('color','white') 



'#foo
ol
li.tmp':
function(a)
{ 





.select('.foo') 





a.style.color
=
'white'; 







.style('background','red'); 



}, 



'#foo
ol
li.tmp
.foo':
function(a)
{ 





a.style.background
=
'red'; 



} 

}); A:
Behaviour.register({'':function(a){a.=;a.on=;},'#foo
ol
li':function(a){a.style.='';}, B:
$('').set('','').bind('',).select('').style('','').select('').style('',''); Inside jQuery @auchenberg kenneth.io
  • 19. jQuery Prototype Trend October 2010 Scale is based on the average worldwide traffic of jquery javascript from 2004 to 2010. Source: http://www.google.com/trends?q=dojo+javascript,+jquery+javascript,+yui+javascript,+prototype+javascript,+mootools+javascript&ctab=0&geo=all&date=all&sort=1 Inside jQuery @auchenberg kenneth.io
  • 20. Prototype jQuery Usage October 2010 Distribution is calculated from a cross section of website domains provided by URLs entered at BuiltWith.com and the Quantcast Top Million. Last calculated on October 19 2010. Source: http://trends.builtwith.com/javascript Inside jQuery @auchenberg kenneth.io
  • 21. $? Inside jQuery @auchenberg kenneth.io
  • 22. var $ = ‘Hello World’; var € = ‘Hello World’; var @ = ‘Hello World’; var _ = ‘Hello World’; Identifies Names Inside jQuery @auchenberg kenneth.io
  • 23. 7.6 Identifier Names and Identifiers Identifier Names are tokens that are interpreted according to the grammar given in the “Identifiers” section of chapter 5 of the Unicode standard, with some small modifications. An Identifier is an IdentifierName that is not a ReservedWord (see 7.6.1). The Unicode identifier grammar is based on both normative and informative character categories specified by the Unicode Standard. The characters in the specified categories in version 3.0 of the Unicode standard must be treated as in those categories by all conforming ECMAScript implementations. This standard specifies specific character additions: The dollar sign ($) and the underscore (_) are permitted anywhere in an IdentifierName. ECMA-262 …” Quote from Standard ECMA-262 ECMAScript Language Specification Inside jQuery @auchenberg kenneth.io
  • 24. Utilities Traversing Attributes Effects Core Selectors Manipulation CSS Events Ajax jQuery jQuery Inside jQuery @auchenberg kenneth.io
  • 25. Selectors & Performance Events & Delegation AJAX & Communication Extensions & Community Inside jQuery @auchenberg kenneth.io
  • 26. Which browsers does jQuery support? Inside jQuery @auchenberg kenneth.io
  • 27. 3.0+ 9.0+ 2.0+ 6.0+ Browsers 1.0+ Inside jQuery @auchenberg kenneth.io
  • 28. Getting started Inside jQuery @auchenberg kenneth.io
  • 29. <!DOCTYPE
html> <html> 
 <head> 
 



<title>jQuery</title> 
 </head> 
 
 <body></body> 
 
 <script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/ jquery/1.4.3/jquery.min.js"></script> </html> Inject Inside jQuery @auchenberg kenneth.io
  • 30. $(document).ready(function()
{ 
 


//
Go
mental }(; Ready Inside jQuery @auchenberg kenneth.io
  • 31. jQuery code begins $ followed by a selector and ends with action(s) $(’div’).addClass(‘kenneth’); $(’div.groups‐panel’).addClass(‘kenneth’).find(’span:first‐ child’).text(‘rocks’).show(); Inside jQuery @auchenberg kenneth.io
  • 32. Selectors and actions can be attached to events. $(’body’).click(function()
{ 
 


$(’div’).addClass(‘kenneth’)
; }); $(’body’).live(’click’,
function()
{ 
 


$(’div’).addClass(‘kenneth’)
; }); Inside jQuery @auchenberg kenneth.io
  • 33. Selectors Inside jQuery @auchenberg kenneth.io
  • 34. document.getElementById('header') document.getElementsByTagName('p') document.getElementsByClassName(‘.hey’) 'body
>
div.wrapper
>
section'? Browser selectors Inside jQuery @auchenberg kenneth.io
  • 35. document.getElementById('header') document.getElementsByTagName('p') document.getElementsByClassName(‘.hey’) 'body
>
div.wrapper
>
section'? Browser selectors Inside jQuery @auchenberg kenneth.io
  • 36. Selector Engine Inside jQuery @auchenberg kenneth.io
  • 37. Selector Engine Inside jQuery @auchenberg kenneth.io
  • 38. !"#$ ;<"3-)$ ;+=(),"(->)?$ ;()5G+5"&#$ %&%'%()$ ;&,-)$ ;%'2)B$ ;<"3-)G+5"&#$ *+&,--$ ;(=)>-%&?$ ;5,->-%&?$ ;&,-)G+5"&#$ *+&,--*+&,--$ ;%6%($ ;2,3%()$ ;=(&BG+5"&#$ .$ ;=##$ ;5"##%($ -%&/0$-%&1$ ;%@>"(#%8?$ ;6"-":&%$ ;"(2H)$ ;A)>"(#%8?$ ;<"&%$ 2,3%()$4$+5"&#$ ;&)>"(#%8?$ .C,))3D$ ;:H))=($ 23%6$7$(%8)$ ;5%,#%3$ .C,))3E6,&D$ ;%(,:&%#$ 23%6$9$-":$ ;,("',)%#$ .C,))3FE6,&D$ ;+5%+I%#$ .C,))DC,))1D$ ;-%&%+)%#$ Selectors Inside jQuery @auchenberg kenneth.io
  • 39. 2003.03.25: document.getElementsBySelector() by Simon Willison (later used in behaviour.js)[source] • 2004.04.10: CssQuery() 1.0: by Dean Edwards • 2005.08.19: CssQuery() 2.0. • 2005.08.22: jSelect (precursor to jQuery) • 2006.01.14: jQuery first release. • 2006.01.18: Prototype. Initial release of selector engine. • 2006.04.04: moo.dom (precursor to mootools • 2006.08.26: jQuery 1.0 • 2006.11.14: Mochikit Selector. (orig. ported from prototype) • 2007.01.08: jQuery 1.1a ("10-20x faster than 1.0") • 2007.01.11: DomQuery by Jack Slocum (ExtJS). • 2007.02.05: dojo.query(). • 2007.03.21: base2.DOM. • 2007.05.01: Prototype 1.5.1 • 2007.05.07: Mootools 1.1 • 2007.07.01: jQuery 1.1.3 ("800% faster") • 2007.07.10: Ext 1.1 RC1 • • 2007.07.10: Dojo 0.9 2007.12.04: YUI 2.4.0 Timeline • 2007.12.17: NWMatcher by Diego Perini • 2008.08.25: Sizzle.js by John Resig Source: http://paulirish.com/2008/javascript-css-selector-engine-timeline/ Inside jQuery @auchenberg kenneth.io
  • 40. Sizzle introduction Inside jQuery @auchenberg kenneth.io
  • 41. Sizzle introduction Inside jQuery @auchenberg kenneth.io
  • 42. if ( document.querySelectorAll ) { (function(){ var oldSizzle = Sizzle, div = document.createElement("div"); div.innerHTML = "<p class='TEST'></p>"; // Safari can't handle uppercase or unicode characters when // in quirks mode. if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { return; } Sizzle = function(query, context, extra, seed){ context = context || document; // Only use querySelectorAll on non-XML documents // (ID selectors don't work in non-HTML documents) if ( !seed && !Sizzle.isXML(context) ) { if ( context.nodeType === 9 ) { try { return makeArray( context.querySelectorAll(query), extra ); } catch(qsaError) {} querySelectorAll Inside jQuery @auchenberg kenneth.io
  • 43. $(ʻheader aʼ) Inside jQuery @auchenberg kenneth.io
  • 44. $(ʻheader aʼ) document.querySelectorAll(ʻheader aʼ) ???????? Selector break-down Inside jQuery @auchenberg kenneth.io
  • 45. array = [ʻ.headerʼ , ʻaʼ] Inside jQuery @auchenberg kenneth.io
  • 46. Left to right Right to left MooTools Sizzle Ext.JS YUI 3 Prototype.js querySelectorAll Direction Inside jQuery @auchenberg kenneth.io
  • 47. array = [ʻ.headerʼ , ʻaʼ] Inside jQuery @auchenberg kenneth.io
  • 48. match:
{ 




ID:
/#((?:[wu00c0‐uFFFF‐]|.)+)/, 




CLASS:
/.((?:[wu00c0‐uFFFF‐]|.)+)/, 




NAME:
/[name=['"]*((?:[wu00c0‐uFFFF‐]|.)+)['"]*]/, 




ATTR:
/[s*((?:[wu00c0‐uFFFF‐]|.)+)s*(?:(S?=)s*(['"]*)(.*?)3|)s*]/, 




TAG:
/^((?:[wu00c0‐uFFFF*‐]|.)+)/, 




CHILD:
/:(only|nth|last|first)‐child(?:((even|odd|[dn+‐]*)))?/, 




POS:
/:(nth|eq|gt|lt|first|last|even|odd)(?:((d*)))?(?=[^‐]|$)/, 




PSEUDO:
/:((?:[wu00c0‐uFFFF‐]|.)+)(?:((['"]?)((?:([^)]+)|[^()]*)+)2))?/ }, .find(ʻaʼ) Inside jQuery @auchenberg kenneth.io
  • 49. TAG:
function(match,
context){ 




return
context.getElementsByTagName(match[1]); } .find(ʻaʼ) Inside jQuery @auchenberg kenneth.io
  • 50. array = [ʻ.headerʼ , ʻaʼ] Inside jQuery @auchenberg kenneth.io
  • 51. 
 CLASS:
function(match,
curLoop,
inplace,
result,
not,
isXML){ 
 
 
 match
=
"
"
+
match[1].replace(//g,
"")
+
"
"; 
 
 
 if
(
isXML
)
{ 
 
 
 
 return
match; 
 
 
 } 
 
 
 for
(
var
i
=
0,
elem;
(elem
=
curLoop[i])
!=
null;
i++
)
{ 
 
 
 
 if
(
elem
)
{ 
 
 
 
 
 if
(
not
^
(elem.className
&&
("
"
+
elem.className
+
"
").replace(/[tn]/g,
"
 ").indexOf(match)
>=
0)
)
{ 
 
 
 
 
 
 if
(
!inplace
)
{ 
 
 
 
 
 
 
 result.push(
elem
); 
 
 
 
 
 
 } 
 
 
 
 
 }
else
if
(
inplace
)
{ 
 
 
 
 
 
 curLoop[i]
=
false; 
 
 
 
 
 } 
 
 
 
 } 
 
 
 } 
 
 
 
 
 }, return
false; .find(ʻ.headerʼ) Inside jQuery @auchenberg kenneth.io
  • 52. $(ʻdiv.me .projectsʼ) $(ʻ.me div.projectsʼ) http://jsperf.com/sizzle-selector-performance Inside jQuery @auchenberg kenneth.io
  • 53. Performance Inside jQuery @auchenberg kenneth.io
  • 54. cache vs. no-cache http://jsperf.com/cache-jquery-objects Inside jQuery @auchenberg kenneth.io
  • 55. jQuery.each vs. for loop http://jsperf.com/jquery-each-vs-for-loop/11 Inside jQuery @auchenberg kenneth.io
  • 56. jQuery.trim vs. RegExp http://jsperf.com/jquery-trim-vs-regexp-trim Inside jQuery @auchenberg kenneth.io
  • 58. jQuery vs. HtmlEncode http://jsperf.com/jquery-htmlencode-vs-string-replace/3 Inside jQuery @auchenberg kenneth.io
  • 59. (build) string vs. object http://jsperf.com/build-appended-object-test/3 Inside jQuery @auchenberg kenneth.io
  • 60. Events and delegation Inside jQuery @auchenberg kenneth.io
  • 61. .bind(eventname,
function)
 
 
 
 .click,
.hover,
.mouseover .unbind(eventname)






















.focus,
.submit .trigger(eventname,
function) .live(eventname,
function) .delegate(eventname,
function) $(’body’).click(function() { $(’div’).addClass(’zyb’) ; }); Events Inside jQuery @auchenberg kenneth.io
  • 62. $(’body’).click(function()
{ 
 


$(’div’).addClass(‘kenneth’)
; }); $(’body’).live(‘click’,
function()
{ 
 


$(’div’).addClass(‘kenneth’)
; }); $(’body’).delegate(‘div’,
‘click’,
function()
{ 
 


$(’div’).addClass(‘kenneth’)
; }); Event delegation Inside jQuery @auchenberg kenneth.io
  • 63. Event delegation Inside jQuery @auchenberg kenneth.io
  • 64. <ul class="myList">   <li class="red">The first item.</li>   <li class="green">The second item.</li>   <li class="yellow">The third item.</li>   <li class="blue">The fourth item.</li> </ul> <p>Class of the last clicked item: <span id="display"> </span></p> $(’ul’).click(function(event) { if(event.target.nodeName == ”LI”) { $(’#display’).text(event.target.className); } }); How does it work? Inside jQuery @auchenberg kenneth.io
  • 65. <ul class="myList">   <li class="red"><b>The <i>first <u>item</u></i></b>.</li>     <li class="green"><b>The <i>second <u>item</u></i></b>.</li>   <li class="yellow"><b>The <i>third <u>item</u></i></b>.</li>     <li class="blue"><b>The <i>fourth <u>item</u></i></b>.</li> </ul>   <p>Class of the last clicked item: <span id="display"> </span></p> $("ul").click( function( event ) {   var elem = event.target;   while( elem.nodeName != "LI" && elem.parentNode) {     elem = elem.parentNode;  }   if(elem.nodeName == "LI") {     $("#display").text(event.target.className);  } What if inside? }); Inside jQuery @auchenberg kenneth.io
  • 66. <ul
class="myList"> 

<li
class="red"><b>The
<i>first
<u>item</u></i></b>.</li> 
 

<li
class="green"><b>The
<i>second
<u>item</u></i></b>.</li> 

<li
class="yellow"><b>The
<i>third
<u>item</u></i></b>.</li> 
 

<li
class="blue"><b>The
<i>fourth
<u>item</u></i></b>.</li> </ul> 
 <p>Class
of
the
last
clicked
item:
<span
id="display">
</span></p> $("ul").click(
function(
event
)
{ 

var
$elem
=
$(event.target).closest("li"); 

if($elem.length)
{ 



$("#display").text($elem.attr("class")); 

} }); Closest to the rescue Inside jQuery @auchenberg kenneth.io
  • 67. <ul
class="myList"> 

<li
class="red"><b>The
<i>first
<u>item</u></i></b>.</li> 
 

<li
class="green"><b>The
<i>second
<u>item</u></i></b>.</li> 

<li
class="yellow"><b>The
<i>third
<u>item</u></i></b>.</li> 
 

<li
class="blue"><b>The
<i>fourth
<u>item</u></i></b>.</li> </ul> 
 <p>Class
of
the
last
clicked
item:
<span
id="display">
</span></p> $("ul.myList
>
li").live("click",
function(e)
{ 

$("#display").text( 



$(this).attr("class") 

); }); $("ul").delegate("li",
"click",
function(e)
{ 

$("#display").text( .live & .delegate 



$(this).attr("class") 

); }); Inside jQuery @auchenberg kenneth.io
  • 68. EventHelper
=
(function
(window,
$,
undefined)
{ 

function
proxy_callback(callback,
shouldPreserveDefault,
e)
{ 



var
target
=
$(e.currentTarget); 



if
(!shouldPreserveDefault)
{ 





e.preventDefault(); 



} 



callback.apply(this,
 [target].concat(Array.prototype.slice.call(arguments).slice(2))); 

} 

function
bind(eventType,
selector,
fn,
shouldPreserveDefault)
{ 



$('body').delegate(selector,
eventType,
proxy_callback.curry(fn,
 shouldPreserveDefault)); 

} 

function
unbind(eventType,
selector)
{ 



$('body').undelegate(selector,
eventType); 

} Wrappers })(window,
jQuery); Inside jQuery @auchenberg kenneth.io
  • 69. AJAX/Communication Inside jQuery @auchenberg kenneth.io
  • 70. .ajax(options) .get(url,
data,
callback,
dateType) .post(url,
data,
callback,
dateType) .getJSON(url,
data,
callback,
dateType) .getScript(url,
callback) .load(url,
data,
callback) .ajaxComplete()













.ajaxSetup(options) .ajaxStart() .ajaxStop() .ajaxSuccess() .ajaxError() Ajax in jQuery Inside jQuery @auchenberg kenneth.io
  • 71. .ajax(options) .get(url,
data,
callback,
dateType) .post(url,
data,
callback,
dateType) .getJSON(url,
data,
callback,
dateType) .getScript(url,
callback) .load(url,
data,
callback) .ajaxComplete()













.ajaxSetup(options) .ajaxStart() .ajaxStop() .ajaxSuccess() .ajaxError() Ajax in jQuery Inside jQuery @auchenberg kenneth.io
  • 72. .ajax(options) .get(url,
data,
callback,
dateType) .post(url,
data,
callback,
dateType) .getJSON(url,
data,
callback,
dateType) .getScript(url,
callback) .load(url,
data,
callback) .ajaxComplete()













.ajaxSetup(options) .ajaxStart() .ajaxStop() .ajaxSuccess() .ajaxError() Ajax in jQuery Inside jQuery @auchenberg kenneth.io
  • 73. CORS Inside jQuery @auchenberg kenneth.io
  • 74. CORS Cross-Origin Resource Sharing Inside jQuery @auchenberg kenneth.io
  • 75. CORS Inside jQuery @auchenberg kenneth.io
  • 76. CORS Cross-Origin Resource Sharing Inside jQuery @auchenberg kenneth.io
  • 77. Inside jQuery @auchenberg kenneth.io
  • 78. Header Inside jQuery @auchenberg kenneth.io
  • 79. Access-Control-Allow-Origin: * Header Inside jQuery @auchenberg kenneth.io
  • 80. $.get(“http://bar.other/resources/public‐data”,
function()
{ 



console.log(arguments); },
“xml”) GET /resources/public-data/ HTTP/1.1 Host: bar.other User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081130 Minefield/ 3.1b3pre Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://foo.example/examples/access-control/simpleXSInvocation.html Origin: http://foo.example HTTP/1.1 200 OK Date: Mon, 01 Dec 2008 00:23:53 GMT Server: Apache/2.0.61 Access-Control-Allow-Origin: * Keep-Alive: timeout=2, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: application/xml [XML Data] Inside jQuery @auchenberg kenneth.io
  • 81. callback=? Inside jQuery @auchenberg kenneth.io
  • 82. TwitterAPI = function() { function getUserData(username) { $.getJSON('http://twitter.com/status/user_timeline/' + username + '.json?count=10&callback=?', onSucesss); } function onSuccess(responseData) { // to render } return { getUserData: getUserData } }(); TwitterAPI.getUserData('auchenberg'); JSONP JSON with Padding Inside jQuery @auchenberg kenneth.io
  • 83. Demo time Inside jQuery @auchenberg kenneth.io
  • 84. 



function
poll(callback){ 







$.ajax({ 











type:
"GET", 











url:
”http://localhost:8080/cometd", 











timeout:50000, 











success:
function(data){ 















callback(data); 











}, 











error:
function(XMLHttpRequest,
textStatus,
errorThrown){ 















//
Do
the
logging 















 











} 







}); 



}; 


setInterval(poll(onPollFinished)),
2000); XHR Polling Old Inside jQuery @auchenberg kenneth.io
  • 85. Chat server (socket.io) XHR Long-polling XHR Multipart WebSockets IE Firefox Chrome Real time Inside jQuery @auchenberg kenneth.io
  • 86. 



function
longPool(callback){ 







$.ajax({ 











type:
"GET", 











url:
”http://localhost:8080/cometd", 











timeout:50000, 











success:
function(data){ 















callback(data); 
 
 
 


longPool(callback); 











}, 











error:
function(XMLHttpRequest,
textStatus,
errorThrown){ 















//
Do
the
logging 















longPool(callback); 











} 







}); 



}; XHR Long Polling HTTP 1.1 Inside jQuery @auchenberg kenneth.io
  • 87. MIME‐Version:
1.0 HTTP/1.1
200
OK
 Content‐Type:
multipart/mixed;
boundary="frontier" Content‐Type:
text/plain
 Transfer‐Encoding:
chunked This
is
a
message
with
multiple
parts
in
MIME
format. 
 ‐‐frontier 25
 Content‐Type:
text/plain This
is
the
data
in
the
first
chunk 
 This
is
the
body
of
the
message. 1C
 ‐‐frontier and
this
is
the
second
one Content‐Type:
application/octet‐stream 
 Content‐Transfer‐Encoding:
base64 0
 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZ XHR Multipart MIME Inside jQuery @auchenberg kenneth.io
  • 88. Extend Inside jQuery @auchenberg kenneth.io
  • 89. plugins.jquery.com community Inside jQuery @auchenberg kenneth.io
  • 90. jquery.barcode Bloat Inside jQuery @auchenberg kenneth.io
  • 91. (function($) { var types = ['DOMMouseScroll', 'mousewheel']; $.event.special.mousewheel = {     setup: function() {         if ( this.addEventListener ) {             for ( var i=types.length; i; ) {                 this.addEventListener( types[--i], handler, false );             }         } else {             this.onmousewheel = handler;         }     },          teardown: function() {         if ( this.removeEventListener ) {             for ( var i=types.length; i; ) {                 this.removeEventListener( types[--i], handler, false );             }         } else {             this.onmousewheel = null;         }     } }; $.fn.extend({     mousewheel: function(fn) {         return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");     },          unmousewheel: function(fn) { jquery.mouseWheel         return this.unbind("mousewheel", fn);     } Custom events }); function handler(event) {     var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;     event = $.event.fix(orgEvent);     event.type = "mousewheel";          // Old school scrollwheel delta Inside jQuery     if ( event.wheelDelta ) { delta = event.wheelDelta/120; } @auchenberg kenneth.io     if ( event.detail ) { delta = -event.detail/3; }
  • 92. }); function handler(event) {     var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;     event = $.event.fix(orgEvent);     event.type = "mousewheel";          // Old school scrollwheel delta     if ( event.wheelDelta ) { delta = event.wheelDelta/120; }     if ( event.detail ) { delta = -event.detail/3; }          // New school multidimensional scroll (touchpads) deltas     deltaY = delta;          // Gecko     if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {         deltaY = 0;         deltaX = -1*delta;     }          // Webkit     if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }     if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }          // Add event and delta to the front of the arguments     args.unshift(event, delta, deltaX, deltaY);          return $.event.handle.apply(this, args); } })(jQuery); jquery.mouseWheel Custom events http://github.com/brandonaaron/jquery-mousewheel Inside jQuery @auchenberg kenneth.io
  • 93. var person = {}; $("form").link(person); $("#name").val("foo"); alert(person.name); // foo // ... user changes value ... alert(person.name); // <user typed value> $(person).data("name", "bar"); alert($("#name").val()); // bar jquery.dataLink Databinding http://github.com/jquery/jquery-datalink Inside jQuery @auchenberg kenneth.io
  • 94. Go Go Go! Inside jQuery @auchenberg kenneth.io
  • 95. Be the cool kid Inside jQuery @auchenberg kenneth.io
  • 96. Thanks Inside jQuery @auchenberg kenneth.io

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. Firefox - ES5 / native\n
  56. \n
  57. Firefox - ES5 / native\n
  58. Firefox - ES5 / native\n
  59. Firefox - ES5 / native\n
  60. Firefox - ES5 / native\n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n