jQuery (DrupalCamp Toronto)

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    jQuery (DrupalCamp Toronto) - Presentation Transcript

    1. jQuery DrupalCamp Toronto - May 2008 John Resig (ejohn.org)
    2. Why Libraries? • Makes JavaScript bearable • Gets the job done fast • Simplifies cross-browser support
    3. What is jQuery? ✦ An open source JavaScript library that simplifies the interaction between HTML and JavaScript.
    4. We missed you! ✦ We’ve been busy: ✦ jQuery 1.1 ✦ jQuery 1.1.1 ✦ jQuery 1.1.2 ✦ jQuery 1.1.3 ✦ jQuery 1.1.4 ✦ jQuery 1.2 ✦ jQuery 1.2.1 ✦ jQuery 1.2.2 ✦ jQuery 1.2.3 ✦ ... since the last Drupal release
    5. Major Releases ✦ More info: ✦ jQuery 1.1: http://jquery.com/blog/2007/01/14/jquery-birthday-11-new-site-new-docs/ ✦ jQuery 1.1.3: http://jquery.com/blog/2007/07/01/jquery-113-800-faster-still-20kb/ ✦ jQuery 1.1.4: http://jquery.com/blog/2007/08/24/jquery-114-faster-more-tests-ready- for-12/ ✦ jQuery 1.2: http://docs.jquery.com/Release:jQuery_1.2 ✦ jQuery 1.2.2: http://docs.jquery.com/Release:jQuery_1.2.2 ✦ jQuery 1.2.3: http://docs.jquery.com/Release:jQuery_1.2.3 ✦ All: http://docs.jquery.com/Downloading_jQuery
    6. The Focus of jQuery Find Some Elements Do something with them { { $(“div”).addClass(“special”); jQuery Object
    7. Keep Clean ✦ jQuery can be rename ‘$’: var $jq = jQuery.noConflict(); $jq(“div”).hide(); ✦ jQuery can even rename ‘jQuery’ allowing multiple copies of jQuery to work side-by- side. ✦ var $a = jQuery.noConflict(true); // load other version of jQuery $a(“div”).hide(); // still works!
    8. Find Some Elements... ✦ Full CSS Selector 1-3 Support ✦ Better CSS Selector support than most browsers
    9. $(“div”) <div id=”body”> <h2>Some Header</h2> <div class=”contents”> <p>...</p> <p>...</p> </div> </div>
    10. $(“#body”) <div id=”body”> <h2>Some Header</h2> <div class=”contents”> <p>...</p> <p>...</p> </div> </div>
    11. $(“div#body”) <div id=”body”> <h2>Some Header</h2> <div class=”contents”> <p>...</p> <p>...</p> </div> </div>
    12. $(“div.contents p”) <div id=”body”> <h2>Some Header</h2> <div class=”contents”> <p>...</p> <p>...</p> </div> </div>
    13. $(“.foo > div”) <div id=”body”> <h2>Some Header</h2> <div class=”contents”> <p>...</p> <p>...</p> </div> </div>
    14. $(“div:has(div)”) <div id=”body”> <h2>Some Header</h2> <div class=”contents”> <p>...</p> <p>...</p> </div> </div>
    15. Do something with them ✦ DOM Manipulation (append, prepend, remove) ✦ Events (click, hover, toggle) ✦ Effects (hide, show, slideDown, fadeOut) ✦ AJAX (load, get, post)
    16. DOM Manipulation ✦ $(“a[target=_blank]”) .append(“ (Opens in New Window)”); ✦ $(“#body”).css({ border: “1px solid green”, height: “40px” });
    17. Events ✦ $(“form”).submit(function(){ if ( $(“input#name”).val() == “” ) { $(“span.help”).show(); return false; } }); ✦ $(“a#open”).click(function(){ $(“#menu”).show(); return false; });
    18. Animations ✦ $(“#menu”).slideDown(“slow”); ✦ Individual properties: $(“div”).animate({ fontSize: “2em”, width: “+=20%”, color: “green” // via plugin }); ✦ Callbacks: $(“div”).hide(500, function(){ // $(this) is an individual <div> element $(this).show(500); });
    19. Ajax ✦ $(“#body”).load(“sample.html”); ✦ Before: <div id=”body”></div> ✦ After: <div id=”body”> <h1>Hello, world!</h1> </div> ✦ $.getJSON(“test.json”, function(js){ for ( var name in js ) $(“ul”).append(“<li>” + name + “</li>”); });
    20. Ajax (cont.) ✦ $(“#body”).load(“sample.html h1:first”); ✦ Before: <div id=”body”></div> ✦ After: <div id=”body”> <h1>Hello, world!</h1> </div>
    21. Chaining ✦ You can have multiple actions against a single set of elements ✦ $(“div”).hide(); ✦ $(“div”).hide().css(“color”,”blue”); ✦ $(“div”).hide().css(“color”,”blue”).slideDown();
    22. Chaining (cont.) ✦ $(“ul.open”) .children(“li”) .addClass(“open”) .end() .find(“a”) .click(function(){ $(this).next().toggle(); return false; }) .end();
    23. Why jQuery? ✦ Fully documented ✦ Great community ✦ Tons of plugins ✦ Small size (15kb) ✦ Everything works in IE 6+, Firefox, Safari 2+, and Opera 9+
    24. Accordion Menu http://jquery.com/files/apple/ http://jquery.com/files/apple/done.html
    25. Plugins ✦ Huge plugin ecosystem ✦ Managed by Plugin tracker - built with Drupal! http://plugins.jquery.com/ ✦ Hundreds in the tracker - even more on the web
    26. jQuery Plugins ✦ Extend the jQuery system ✦ Add on extra methods: $(“div”).hideRemove(); ✦ Trivial to implement: jQuery.fn.hideRemove = function(speed){ return this.hide(speed, function(){ jQuery(this).remove(); }); };
    27. Todo List http://jquery.com/files/todo/ http://jquery.com/files/todo/done.php
    28. jQuery UI ✦ A complete set of themed, cross-browser, user interface components. ✦ Drag, Drop, Sort, Select, Resize ✦ Accordion, Datepicker, Dialog, Slider, Tabs ✦ More info: http://docs.jquery.com/UI ✦ 1.5 is in beta right now: http://jquery.com/blog/2008/02/12/jquery-ui-15b-new-api-more-features-huge-performance-boost/
    29. Accessibility ✦ Keyboard Accessible ✦ Screenreader Accessible ✦ Grant from Mozilla Foundation to implement ARIA
    30. Support ✦ Liferay (Java CMS) hired Paul Bakaus, jQuery UI lead to work on it full time. ✦ More support on the way!
    31. Who uses jQuery? ✦ Google ✦ IBM ✦ NBC ✦ Amazon ✦ Wordpress ✦ Digg ✦ many others...
    32. Community ✦ Very active mailing list ✦ 100+ Posts/Day ✦ 6000+ Members ✦ Technorati: Dozens of blog posts per day
    33. Books ✦ 3 Books Released: ✦ Learning jQuery (Packt) ✦ jQuery Reference (Packt) ✦ jQuery in Action (Manning)
    34. Random ✦ New Logo ✦ and New Web Site ✦ Coming Soon!
    35. jquery.com docs.jquery.com - jquery.com/plugins More: ui.jquery.com visualjquery.com learningjquery.com

    + jeresigjeresig, 2 years ago

    custom

    3202 views, 0 favs, 0 embeds more stats

    DrupalCamp Toronto (May 2008).

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 3202
      • 3202 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 71
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories