SlideShare a Scribd company logo
Bubbles & trees
with
Me, myself and I
                                          application developer
                                          PHP since 2001
                                          JavaScript since 2002
                                          papaya CMS since
                                           01.2008




Bastian Feder | papaya Software GmbH                               2
What's this all about?
   What is this jQuery?
   All about the basics
   Animation and user interaction
   Event-handling – capability
   Handling asynchronous requests
   Plug-ins – an overview
   Examples
   Conclusion
Bastian Feder | papaya Software GmbH             3
What's this jQuery?
„jQuery is a fast, concise, JavaScript Library that
simplifies how you traverse HTML documents,
handle events, perform animations, and add Ajax
interactions to your web pages.“
(www.jquery.com)




Bastian Feder | papaya Software GmbH                  4
jQuery – some features
   Crossbrowser compatible
    (IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+)
   CSS3 ready
   outstanding features:
     ▹   ability to queue effects
     ▹   user defined animations
     ▹   unobtrusiveness in coexistence with other JS
         libraries or frameworks (e.g. prototype)


Bastian Feder | papaya Software GmbH                    5
All about the basics
   interoperability
   extending the DOM object
   DOM Manipulation
   selectors
   iterations




Bastian Feder | papaya Software GmbH           6
Interoperability
   overriding $()                     <html>
                                        <head>
                                          <script src=quot;prototype.jsquot;></script>
   including jQuery                      <script src=quot;jquery.jsquot;></script>
                                          <script>

    before other libraries
                                            var $j = jQuery.noConflict();

                                            // Use jQuery via $j(...)
                                            $j(document).ready(function(){
   referencing magic-                        $j(quot;divquot;).hide();
                                            });
    shortcuts                              // Use Prototype with $(...), etc.
                                           $('someid').hide();
                                         </script>
                                       </head>
                                       <body></body>
                                       </html>




Bastian Feder | papaya Software GmbH                                             7
Extending the DOM
   $(selector, scope)
     ▹   simplifies the selection of DOM elements
     ▹   extends the DOM node with jQuery methods

   $(document).ready(callback);
     ▹   ensures the javascript will be executed after
         document has been loaded completely



Bastian Feder | papaya Software GmbH                     8
DOM Manipulation
   changing contents
     ▹   html([val])
     ▹   text([val])
   replacing DOM node(s)
     ▹   replaceWith(content)
     ▹   replaceAll(selector)




Bastian Feder | papaya Software GmbH       9
DOM Manipulation (II)
   inserting DOM node
     ▹   inside
         append(content), prepend(), (append|prepend)To(content)

     ▹   outside
         after(content), before(content), insert(After|Before)(content)

     ▹   around
         wrap([html|elem]), wrapAll([html|elem]), wrapInner([html|elem])




Bastian Feder | papaya Software GmbH                                       10
Selectors
    basic
     *, #id, .class, element, selectorN

    hierarchical
     ancestor descendant, parent > child, prev + next, prev ~ siblings

    filters
     :first, :last, :not, :animated, etc

    /*
     * add checkbox to first td found in html,
     * formats the size to a human readable string and
     * attaches event handlers to the tr element
     */
    $('td:first', html).append(checkbox)
       .parent()
       // format the size column
         .find('.size')
         .each( function() {
            words = $(this).text().split(' ');
            $(this).html(words[0] + '<span class=quot;unitquot;>'+ words[1] +'</span>');
         })
       .end();



Bastian Feder | papaya Software GmbH                                               11
Iterations
   each(object, callback)
               $(objList)
                 .each( function(i) {
                      requestQueue.addToListOfRequests(objList[i]);
                    }
                 );



   map(array, callback[, invert])
               var arr = [ quot;aquot;, quot;bquot;, quot;cquot;, quot;dquot;, quot;equot; ]
               $(quot;divquot;).text(arr.join(quot;, quot;));

               arr = jQuery.map(arr, function(n, i){
                 return (n.toUpperCase() + i);
               });




Bastian Feder | papaya Software GmbH                                  12
Animation &
                        user interaction
   appearance
    show(), hide(), toggle()
                                               $(document.body).click(function () {
   sliding                                      $(quot;divquot;).show(quot;slowquot;);
                                                 $(quot;divquot;).animate({left:'+=200'},2000);
    slideDown(), slideUp(), slideToggle()        $(quot;divquot;).queue(function () {
                                                   $(this).addClass(quot;newcolorquot;);
   fading                                         $(this).dequeue();
                                                 });
    fadeIn(speed[,callback]),                    $(quot;divquot;).animate({left:'-=200'},500);
                                                 $(quot;divquot;).queue(function () {
    fadeOut(speed[,callback]), fadeTo(speed,
                                                   $(this).removeClass(quot;newcolorquot;);
    opacity[,callback])                            $(this).dequeue();
                                                 });
   aminate & (de)queue                          $(quot;divquot;).slideUp();
                                               });




Bastian Feder | papaya Software GmbH                                                  13
Event-handling   (DOM perspective)



   DOM handles events in 2 different ways:
     ▹   bubbling
     ▹   capturing




Bastian Feder | papaya Software GmbH                         14
Event-handling                             (II)



     the 'event' object
      ▹   event.ready()
      ▹   event.which
              (keystroke, mouseclick: 1=left, 2=middle, 3=right)

      ▹   event.preventDefault()
      ▹   event.stopPropagation()
      ▹   event.metaKey (PC=ctrl; Mac=Meta)




Bastian Feder | papaya Software GmbH                                      15
Event-handling    (III)



   (un)binding events to a DOM node
     ▹   bind(type[, data], callback)
     ▹   one(type[, data], callback)
     ▹   unbind(type[, data], callback)
   handling triggers
     ▹   trigger(type[, data])
     ▹   triggerHandler(type[, data])


Bastian Feder | papaya Software GmbH              16
Handling asynchronous
                        requests




Bastian Feder | papaya Software GmbH            17
Request handling -
                        example




                                       Live demo




Bastian Feder | papaya Software GmbH               18
Plug-ins – an overview
   mechanism for adding in methods and functionality
   things to remember when writing plugins:
     ▹   names convention (jquery.[nameOfPlugin].js)
     ▹   methods are attached to jQuery.fn object
     ▹   function are attached to jQuery object
     ▹   inside methods 'this' is a reference to current jQuery object
     ▹   your method must return the jQuery object, unless explicity noted
         otherwise.
     ▹   use jQuery instead of $ inside your plugin code - that allows users to
         change the alias for jQuery in a single place.



Bastian Feder | papaya Software GmbH                                              19
Plug-ins – an example
    /**
     * calculates the number to a human readable format
     *
     * calculation taken from papaya-cms {@link http://www.papaya-cms.com}
     */
    jQuery.fn.toHumanReadable = function() {
       var size = this.text();
       var unit;
       if (size > 10000000000) {
         size = (Math.round(size / 1073741824 * 100) / 100);
         unit = 'GB';
       } else if (size > 10000000) {
         size = (Math.round(size / 1048576 * 100) / 100)
         unit = 'MB';
       } else if (size > 10000) {
         size = (Math.round(size / 1024 * 100) / 100)
         unit = 'kB';
       } else {
         size = Math.round(size)
         unit = 'B';
       }

        size = size.toString();
        var p = size.lastIndexOf('.');
        if (p > 0) {
          var i = 2 - size.length + p + 1;
          while (i > 0) {
            size = size + '0';
            i--;
          }
        } else {
          size = size + '.00';
        }

        return this.text(size + ' ' + unit);
    }
Bastian Feder | papaya Software GmbH                                         20
Conclusion
   jQuery is ..
     ▹   an extensive javascript library with an huge
         amount of functionallity
     ▹   very easy to learn and use
     ▹   pretty good documented
     ▹   easy to extend by writing plug-ins




Bastian Feder | papaya Software GmbH                    21
References
   jQuery website                     (http://www.jquery.com)

   A List Apart: DOM Design Tricks I/II
    (http://www.alistapart.com/articles/domtricks2)

   Selfhtml           (http://de.selfhtml.org; sorry german only)

   slides soonish on slideshare
    (http://www.slideshare.com/lapistano)




Bastian Feder | papaya Software GmbH                                 22
License
This set of slides and the source code included in
the download package is licensed under the

Creative Commons Attribution-Noncommercial-
Share Alike 2.0 Generic License



http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en


Bastian Feder | papaya Software GmbH                       23

More Related Content

What's hot

PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
Yuya Takeyama
 
Building High Performance Web Applications and Sites
Building High Performance Web Applications and SitesBuilding High Performance Web Applications and Sites
Building High Performance Web Applications and Sites
goodfriday
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
Rebecca Murphey
 
Taming Command Bus
Taming Command BusTaming Command Bus
Taming Command Bus
Krzysztof Menżyk
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
Robert Nyman
 
Powerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesPowerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best Practices
Dragos Ionita
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
Konstantin Kudryashov
 
Mocking Demystified
Mocking DemystifiedMocking Demystified
Mocking Demystified
Marcello Duarte
 
Symfony World - Symfony components and design patterns
Symfony World - Symfony components and design patternsSymfony World - Symfony components and design patterns
Symfony World - Symfony components and design patterns
Łukasz Chruściel
 
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Krzysztof Menżyk
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
Jace Ju
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
Howard Lewis Ship
 
Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015
Konstantin Kudryashov
 
Min-Maxing Software Costs
Min-Maxing Software CostsMin-Maxing Software Costs
Min-Maxing Software Costs
Konstantin Kudryashov
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
Simon Willison
 
Be pragmatic, be SOLID
Be pragmatic, be SOLIDBe pragmatic, be SOLID
Be pragmatic, be SOLID
Krzysztof Menżyk
 

What's hot (20)

PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
 
Building High Performance Web Applications and Sites
Building High Performance Web Applications and SitesBuilding High Performance Web Applications and Sites
Building High Performance Web Applications and Sites
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
 
Taming Command Bus
Taming Command BusTaming Command Bus
Taming Command Bus
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
 
Powerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesPowerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best Practices
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
Bottom Up
Bottom UpBottom Up
Bottom Up
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
 
Mocking Demystified
Mocking DemystifiedMocking Demystified
Mocking Demystified
 
Symfony World - Symfony components and design patterns
Symfony World - Symfony components and design patternsSymfony World - Symfony components and design patterns
Symfony World - Symfony components and design patterns
 
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
 
Headless Js Testing
Headless Js TestingHeadless Js Testing
Headless Js Testing
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015
 
Min-Maxing Software Costs
Min-Maxing Software CostsMin-Maxing Software Costs
Min-Maxing Software Costs
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Be pragmatic, be SOLID
Be pragmatic, be SOLIDBe pragmatic, be SOLID
Be pragmatic, be SOLID
 

Similar to Bubbles & Trees with jQuery

Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
jeresig
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyond
dion
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryDOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQuery
Remy Sharp
 
dojo.Patterns
dojo.Patternsdojo.Patterns
dojo.Patterns
Peter Higgins
 
Building Robust jQuery Plugins
Building Robust jQuery PluginsBuilding Robust jQuery Plugins
Building Robust jQuery Plugins
Jörn Zaefferer
 
Dojo and Adobe AIR
Dojo and Adobe AIRDojo and Adobe AIR
Dojo and Adobe AIR
Nikolai Onken
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
Hoat Le
 
jQuery Internals + Cool Stuff
jQuery Internals + Cool StuffjQuery Internals + Cool Stuff
jQuery Internals + Cool Stuff
jeresig
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
Rowan Merewood
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
Peter Higgins
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tips
anubavam-techkt
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
Elizabeth Smith
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaveryangdj
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegapyangdj
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
Michael Girouard
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
dion
 

Similar to Bubbles & Trees with jQuery (20)

Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyond
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQueryDOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQuery
 
dojo.Patterns
dojo.Patternsdojo.Patterns
dojo.Patterns
 
Building Robust jQuery Plugins
Building Robust jQuery PluginsBuilding Robust jQuery Plugins
Building Robust jQuery Plugins
 
Dojo and Adobe AIR
Dojo and Adobe AIRDojo and Adobe AIR
Dojo and Adobe AIR
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
 
jQuery Internals + Cool Stuff
jQuery Internals + Cool StuffjQuery Internals + Cool Stuff
jQuery Internals + Cool Stuff
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tips
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 

More from Bastian Feder

JQuery plugin development fundamentals
JQuery plugin development fundamentalsJQuery plugin development fundamentals
JQuery plugin development fundamentals
Bastian Feder
 
Why documentation osidays
Why documentation osidaysWhy documentation osidays
Why documentation osidays
Bastian Feder
 
Solid principles
Solid principlesSolid principles
Solid principles
Bastian Feder
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
Bastian Feder
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
Bastian Feder
 
Introducing TDD to your project
Introducing TDD to your projectIntroducing TDD to your project
Introducing TDD to your project
Bastian Feder
 
jQuery's Secrets
jQuery's SecretsjQuery's Secrets
jQuery's Secrets
Bastian Feder
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
Bastian Feder
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
Bastian Feder
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Bastian Feder
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
Bastian Feder
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Bastian Feder
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn Workshop
Bastian Feder
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
Bastian Feder
 
Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009
Bastian Feder
 
Php Development With Eclipde PDT
Php Development With Eclipde PDTPhp Development With Eclipde PDT
Php Development With Eclipde PDT
Bastian Feder
 
Php Documentor The Beauty And The Beast
Php Documentor The Beauty And The BeastPhp Documentor The Beauty And The Beast
Php Documentor The Beauty And The Beast
Bastian Feder
 
Ajax hands on - Refactoring Google Suggest
Ajax hands on - Refactoring Google SuggestAjax hands on - Refactoring Google Suggest
Ajax hands on - Refactoring Google Suggest
Bastian Feder
 

More from Bastian Feder (20)

JQuery plugin development fundamentals
JQuery plugin development fundamentalsJQuery plugin development fundamentals
JQuery plugin development fundamentals
 
Why documentation osidays
Why documentation osidaysWhy documentation osidays
Why documentation osidays
 
Solid principles
Solid principlesSolid principles
Solid principles
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
 
Introducing TDD to your project
Introducing TDD to your projectIntroducing TDD to your project
Introducing TDD to your project
 
jQuery's Secrets
jQuery's SecretsjQuery's Secrets
jQuery's Secrets
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn Workshop
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
 
Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009Eclipse Pdt2.0 26.05.2009
Eclipse Pdt2.0 26.05.2009
 
Php Development With Eclipde PDT
Php Development With Eclipde PDTPhp Development With Eclipde PDT
Php Development With Eclipde PDT
 
Php Documentor The Beauty And The Beast
Php Documentor The Beauty And The BeastPhp Documentor The Beauty And The Beast
Php Documentor The Beauty And The Beast
 
Ajax hands on - Refactoring Google Suggest
Ajax hands on - Refactoring Google SuggestAjax hands on - Refactoring Google Suggest
Ajax hands on - Refactoring Google Suggest
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

Bubbles & Trees with jQuery

  • 2. Me, myself and I  application developer  PHP since 2001  JavaScript since 2002  papaya CMS since 01.2008 Bastian Feder | papaya Software GmbH 2
  • 3. What's this all about?  What is this jQuery?  All about the basics  Animation and user interaction  Event-handling – capability  Handling asynchronous requests  Plug-ins – an overview  Examples  Conclusion Bastian Feder | papaya Software GmbH 3
  • 4. What's this jQuery? „jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages.“ (www.jquery.com) Bastian Feder | papaya Software GmbH 4
  • 5. jQuery – some features  Crossbrowser compatible (IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+)  CSS3 ready  outstanding features: ▹ ability to queue effects ▹ user defined animations ▹ unobtrusiveness in coexistence with other JS libraries or frameworks (e.g. prototype) Bastian Feder | papaya Software GmbH 5
  • 6. All about the basics  interoperability  extending the DOM object  DOM Manipulation  selectors  iterations Bastian Feder | papaya Software GmbH 6
  • 7. Interoperability  overriding $() <html> <head> <script src=quot;prototype.jsquot;></script>  including jQuery <script src=quot;jquery.jsquot;></script> <script> before other libraries var $j = jQuery.noConflict(); // Use jQuery via $j(...) $j(document).ready(function(){  referencing magic- $j(quot;divquot;).hide(); }); shortcuts // Use Prototype with $(...), etc. $('someid').hide(); </script> </head> <body></body> </html> Bastian Feder | papaya Software GmbH 7
  • 8. Extending the DOM  $(selector, scope) ▹ simplifies the selection of DOM elements ▹ extends the DOM node with jQuery methods  $(document).ready(callback); ▹ ensures the javascript will be executed after document has been loaded completely Bastian Feder | papaya Software GmbH 8
  • 9. DOM Manipulation  changing contents ▹ html([val]) ▹ text([val])  replacing DOM node(s) ▹ replaceWith(content) ▹ replaceAll(selector) Bastian Feder | papaya Software GmbH 9
  • 10. DOM Manipulation (II)  inserting DOM node ▹ inside append(content), prepend(), (append|prepend)To(content) ▹ outside after(content), before(content), insert(After|Before)(content) ▹ around wrap([html|elem]), wrapAll([html|elem]), wrapInner([html|elem]) Bastian Feder | papaya Software GmbH 10
  • 11. Selectors  basic *, #id, .class, element, selectorN  hierarchical ancestor descendant, parent > child, prev + next, prev ~ siblings  filters :first, :last, :not, :animated, etc /* * add checkbox to first td found in html, * formats the size to a human readable string and * attaches event handlers to the tr element */ $('td:first', html).append(checkbox) .parent() // format the size column .find('.size') .each( function() { words = $(this).text().split(' '); $(this).html(words[0] + '<span class=quot;unitquot;>'+ words[1] +'</span>'); }) .end(); Bastian Feder | papaya Software GmbH 11
  • 12. Iterations  each(object, callback) $(objList) .each( function(i) { requestQueue.addToListOfRequests(objList[i]); } );  map(array, callback[, invert]) var arr = [ quot;aquot;, quot;bquot;, quot;cquot;, quot;dquot;, quot;equot; ] $(quot;divquot;).text(arr.join(quot;, quot;)); arr = jQuery.map(arr, function(n, i){ return (n.toUpperCase() + i); }); Bastian Feder | papaya Software GmbH 12
  • 13. Animation & user interaction  appearance show(), hide(), toggle() $(document.body).click(function () {  sliding $(quot;divquot;).show(quot;slowquot;); $(quot;divquot;).animate({left:'+=200'},2000); slideDown(), slideUp(), slideToggle() $(quot;divquot;).queue(function () { $(this).addClass(quot;newcolorquot;);  fading $(this).dequeue(); }); fadeIn(speed[,callback]), $(quot;divquot;).animate({left:'-=200'},500); $(quot;divquot;).queue(function () { fadeOut(speed[,callback]), fadeTo(speed, $(this).removeClass(quot;newcolorquot;); opacity[,callback]) $(this).dequeue(); });  aminate & (de)queue $(quot;divquot;).slideUp(); }); Bastian Feder | papaya Software GmbH 13
  • 14. Event-handling (DOM perspective)  DOM handles events in 2 different ways: ▹ bubbling ▹ capturing Bastian Feder | papaya Software GmbH 14
  • 15. Event-handling (II)  the 'event' object ▹ event.ready() ▹ event.which (keystroke, mouseclick: 1=left, 2=middle, 3=right) ▹ event.preventDefault() ▹ event.stopPropagation() ▹ event.metaKey (PC=ctrl; Mac=Meta) Bastian Feder | papaya Software GmbH 15
  • 16. Event-handling (III)  (un)binding events to a DOM node ▹ bind(type[, data], callback) ▹ one(type[, data], callback) ▹ unbind(type[, data], callback)  handling triggers ▹ trigger(type[, data]) ▹ triggerHandler(type[, data]) Bastian Feder | papaya Software GmbH 16
  • 17. Handling asynchronous requests Bastian Feder | papaya Software GmbH 17
  • 18. Request handling - example Live demo Bastian Feder | papaya Software GmbH 18
  • 19. Plug-ins – an overview  mechanism for adding in methods and functionality  things to remember when writing plugins: ▹ names convention (jquery.[nameOfPlugin].js) ▹ methods are attached to jQuery.fn object ▹ function are attached to jQuery object ▹ inside methods 'this' is a reference to current jQuery object ▹ your method must return the jQuery object, unless explicity noted otherwise. ▹ use jQuery instead of $ inside your plugin code - that allows users to change the alias for jQuery in a single place. Bastian Feder | papaya Software GmbH 19
  • 20. Plug-ins – an example /** * calculates the number to a human readable format * * calculation taken from papaya-cms {@link http://www.papaya-cms.com} */ jQuery.fn.toHumanReadable = function() { var size = this.text(); var unit; if (size > 10000000000) { size = (Math.round(size / 1073741824 * 100) / 100); unit = 'GB'; } else if (size > 10000000) { size = (Math.round(size / 1048576 * 100) / 100) unit = 'MB'; } else if (size > 10000) { size = (Math.round(size / 1024 * 100) / 100) unit = 'kB'; } else { size = Math.round(size) unit = 'B'; } size = size.toString(); var p = size.lastIndexOf('.'); if (p > 0) { var i = 2 - size.length + p + 1; while (i > 0) { size = size + '0'; i--; } } else { size = size + '.00'; } return this.text(size + ' ' + unit); } Bastian Feder | papaya Software GmbH 20
  • 21. Conclusion  jQuery is .. ▹ an extensive javascript library with an huge amount of functionallity ▹ very easy to learn and use ▹ pretty good documented ▹ easy to extend by writing plug-ins Bastian Feder | papaya Software GmbH 21
  • 22. References  jQuery website (http://www.jquery.com)  A List Apart: DOM Design Tricks I/II (http://www.alistapart.com/articles/domtricks2)  Selfhtml (http://de.selfhtml.org; sorry german only)  slides soonish on slideshare (http://www.slideshare.com/lapistano) Bastian Feder | papaya Software GmbH 22
  • 23. License This set of slides and the source code included in the download package is licensed under the Creative Commons Attribution-Noncommercial- Share Alike 2.0 Generic License http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en Bastian Feder | papaya Software GmbH 23